import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OpengarageClient } from './opengarage.classes.client.js';
import { OpengarageConfigFlow } from './opengarage.classes.configflow.js';
import { createOpengarageDiscoveryDescriptor } from './opengarage.discovery.js';
import type { IOpengarageConfig } from './opengarage.types.js';
import { opengarageDomain, opengarageProfile } from './opengarage.types.js';

export class OpengarageIntegration extends SimpleLocalIntegration<IOpengarageConfig> {
  public readonly domain = opengarageDomain;
  public readonly discoveryDescriptor = createOpengarageDiscoveryDescriptor();
  public readonly configFlow = new OpengarageConfigFlow();

  constructor() {
    super(opengarageProfile);
  }

  public override async setup(configArg: IOpengarageConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(opengarageProfile, new OpengarageClient(configArg));
  }
}

export class HomeAssistantOpengarageIntegration extends OpengarageIntegration {}
