import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { FlexitBacnetClient } from './flexit_bacnet.classes.client.js';
import { FlexitBacnetConfigFlow } from './flexit_bacnet.classes.configflow.js';
import { createFlexitBacnetDiscoveryDescriptor } from './flexit_bacnet.discovery.js';
import type { IFlexitBacnetConfig } from './flexit_bacnet.types.js';
import { flexitBacnetDomain, flexitBacnetProfile } from './flexit_bacnet.types.js';

export class FlexitBacnetIntegration extends SimpleLocalIntegration<IFlexitBacnetConfig> {
  public readonly domain = flexitBacnetDomain;
  public readonly discoveryDescriptor = createFlexitBacnetDiscoveryDescriptor();
  public readonly configFlow = new FlexitBacnetConfigFlow();

  constructor() {
    super(flexitBacnetProfile);
  }

  public async setup(configArg: IFlexitBacnetConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(flexitBacnetProfile, new FlexitBacnetClient(configArg));
  }
}

export class HomeAssistantFlexitBacnetIntegration extends FlexitBacnetIntegration {}
