import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { GenericClient } from './generic.classes.client.js';
import { GenericConfigFlow } from './generic.classes.configflow.js';
import { createGenericDiscoveryDescriptor } from './generic.discovery.js';
import type { IGenericConfig } from './generic.types.js';
import { genericDomain, genericProfile } from './generic.types.js';

export class GenericIntegration extends SimpleLocalIntegration<IGenericConfig> {
  public readonly domain = genericDomain;
  public readonly discoveryDescriptor = createGenericDiscoveryDescriptor();
  public readonly configFlow = new GenericConfigFlow();

  constructor() {
    super(genericProfile);
  }

  public async setup(configArg: IGenericConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(genericProfile, new GenericClient(configArg));
  }
}

export class HomeAssistantGenericIntegration extends GenericIntegration {}
