import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LidarrClient } from './lidarr.classes.client.js';
import { LidarrConfigFlow } from './lidarr.classes.configflow.js';
import { createLidarrDiscoveryDescriptor } from './lidarr.discovery.js';
import type { ILidarrConfig } from './lidarr.types.js';
import { lidarrDomain, lidarrProfile } from './lidarr.types.js';

export class LidarrIntegration extends SimpleLocalIntegration<ILidarrConfig> {
  public readonly domain = lidarrDomain;
  public readonly discoveryDescriptor = createLidarrDiscoveryDescriptor();
  public readonly configFlow = new LidarrConfigFlow();

  constructor() {
    super(lidarrProfile);
  }

  public override async setup(configArg: ILidarrConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(lidarrProfile, new LidarrClient(configArg));
  }
}

export class HomeAssistantLidarrIntegration extends LidarrIntegration {}
