import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OctoprintClient } from './octoprint.classes.client.js';
import { OctoprintConfigFlow } from './octoprint.classes.configflow.js';
import { createOctoprintDiscoveryDescriptor } from './octoprint.discovery.js';
import type { IOctoprintConfig } from './octoprint.types.js';
import { octoprintDomain, octoprintProfile } from './octoprint.types.js';

export class OctoprintIntegration extends SimpleLocalIntegration<IOctoprintConfig> {
  public readonly domain = octoprintDomain;
  public readonly discoveryDescriptor = createOctoprintDiscoveryDescriptor();
  public readonly configFlow = new OctoprintConfigFlow();

  constructor() {
    super(octoprintProfile);
  }

  public override async setup(configArg: IOctoprintConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(octoprintProfile, new OctoprintClient(configArg));
  }
}

export class HomeAssistantOctoprintIntegration extends OctoprintIntegration {}
