import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { EnphaseEnvoyClient } from './enphase_envoy.classes.client.js';
import { EnphaseEnvoyConfigFlow } from './enphase_envoy.classes.configflow.js';
import { createEnphaseEnvoyDiscoveryDescriptor } from './enphase_envoy.discovery.js';
import type { IEnphaseEnvoyConfig } from './enphase_envoy.types.js';
import { enphaseEnvoyDomain, enphaseEnvoyProfile } from './enphase_envoy.types.js';

export class EnphaseEnvoyIntegration extends SimpleLocalIntegration<IEnphaseEnvoyConfig> {
  public readonly domain = enphaseEnvoyDomain;
  public readonly discoveryDescriptor = createEnphaseEnvoyDiscoveryDescriptor();
  public readonly configFlow = new EnphaseEnvoyConfigFlow();

  constructor() {
    super(enphaseEnvoyProfile);
  }

  public async setup(configArg: IEnphaseEnvoyConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(enphaseEnvoyProfile, new EnphaseEnvoyClient(configArg));
  }
}

export class HomeAssistantEnphaseEnvoyIntegration extends EnphaseEnvoyIntegration {}
