import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { EgardiaClient } from './egardia.classes.client.js';
import { EgardiaConfigFlow } from './egardia.classes.configflow.js';
import { createEgardiaDiscoveryDescriptor } from './egardia.discovery.js';
import type { IEgardiaConfig } from './egardia.types.js';
import { egardiaDomain, egardiaProfile } from './egardia.types.js';

export class EgardiaIntegration extends SimpleLocalIntegration<IEgardiaConfig> {
  public readonly domain = egardiaDomain;
  public readonly discoveryDescriptor = createEgardiaDiscoveryDescriptor();
  public readonly configFlow = new EgardiaConfigFlow();

  constructor() {
    super(egardiaProfile);
  }

  public async setup(configArg: IEgardiaConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(egardiaProfile, new EgardiaClient(configArg));
  }
}

export class HomeAssistantEgardiaIntegration extends EgardiaIntegration {}
