import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { IometerClient } from './iometer.classes.client.js';
import { IometerConfigFlow } from './iometer.classes.configflow.js';
import { createIometerDiscoveryDescriptor } from './iometer.discovery.js';
import type { IIometerConfig } from './iometer.types.js';
import { iometerDomain, iometerProfile } from './iometer.types.js';

export class IometerIntegration extends SimpleLocalIntegration<IIometerConfig> {
  public readonly domain = iometerDomain;
  public readonly discoveryDescriptor = createIometerDiscoveryDescriptor();
  public readonly configFlow = new IometerConfigFlow();

  constructor() {
    super(iometerProfile);
  }

  public async setup(configArg: IIometerConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(iometerProfile, new IometerClient(configArg));
  }
}
