import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { ImeonInverterClient } from './imeon_inverter.classes.client.js';
import { ImeonInverterConfigFlow } from './imeon_inverter.classes.configflow.js';
import { createImeonInverterDiscoveryDescriptor } from './imeon_inverter.discovery.js';
import type { IImeonInverterConfig } from './imeon_inverter.types.js';
import { imeonInverterDomain, imeonInverterProfile } from './imeon_inverter.types.js';

export class ImeonInverterIntegration extends SimpleLocalIntegration<IImeonInverterConfig> {
  public readonly domain = imeonInverterDomain;
  public readonly discoveryDescriptor = createImeonInverterDiscoveryDescriptor();
  public readonly configFlow = new ImeonInverterConfigFlow();

  constructor() {
    super(imeonInverterProfile);
  }

  public async setup(configArg: IImeonInverterConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(imeonInverterProfile, new ImeonInverterClient(configArg));
  }
}
