import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KostalPlenticoreClient } from './kostal_plenticore.classes.client.js';
import { KostalPlenticoreConfigFlow } from './kostal_plenticore.classes.configflow.js';
import { createKostalPlenticoreDiscoveryDescriptor } from './kostal_plenticore.discovery.js';
import type { IKostalPlenticoreConfig } from './kostal_plenticore.types.js';
import { kostalPlenticoreDomain, kostalPlenticoreProfile } from './kostal_plenticore.types.js';

export class KostalPlenticoreIntegration extends SimpleLocalIntegration<IKostalPlenticoreConfig> {
  public readonly domain = kostalPlenticoreDomain;
  public readonly discoveryDescriptor = createKostalPlenticoreDiscoveryDescriptor();
  public readonly configFlow = new KostalPlenticoreConfigFlow();

  constructor() {
    super(kostalPlenticoreProfile);
  }

  public async setup(configArg: IKostalPlenticoreConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(kostalPlenticoreProfile, new KostalPlenticoreClient(configArg));
  }
}
