import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { PeblarClient } from './peblar.classes.client.js';
import { PeblarConfigFlow } from './peblar.classes.configflow.js';
import { createPeblarDiscoveryDescriptor } from './peblar.discovery.js';
import type { IPeblarConfig } from './peblar.types.js';
import { peblarDomain, peblarProfile } from './peblar.types.js';

export class PeblarIntegration extends SimpleLocalIntegration<IPeblarConfig> {
  public readonly domain = peblarDomain;
  public readonly discoveryDescriptor = createPeblarDiscoveryDescriptor();
  public readonly configFlow = new PeblarConfigFlow();

  constructor() {
    super(peblarProfile);
  }

  public async setup(configArg: IPeblarConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(peblarProfile, new PeblarClient(configArg));
  }
}

export class HomeAssistantPeblarIntegration extends PeblarIntegration {}
