import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OtbrClient } from './otbr.classes.client.js';
import { OtbrConfigFlow } from './otbr.classes.configflow.js';
import { createOtbrDiscoveryDescriptor } from './otbr.discovery.js';
import type { IOtbrConfig } from './otbr.types.js';
import { otbrDomain, otbrProfile } from './otbr.types.js';

export class OtbrIntegration extends SimpleLocalIntegration<IOtbrConfig> {
  public readonly domain = otbrDomain;
  public readonly discoveryDescriptor = createOtbrDiscoveryDescriptor();
  public readonly configFlow = new OtbrConfigFlow();

  constructor() {
    super(otbrProfile);
  }

  public async setup(configArg: IOtbrConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(otbrProfile, new OtbrClient(configArg));
  }
}

export class HomeAssistantOtbrIntegration extends OtbrIntegration {}
