import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { GoalzeroClient } from './goalzero.classes.client.js';
import { GoalzeroConfigFlow } from './goalzero.classes.configflow.js';
import { createGoalzeroDiscoveryDescriptor } from './goalzero.discovery.js';
import type { IGoalzeroConfig } from './goalzero.types.js';
import { goalzeroDomain, goalzeroProfile } from './goalzero.types.js';

export class GoalzeroIntegration extends SimpleLocalIntegration<IGoalzeroConfig> {
  public readonly domain = goalzeroDomain;
  public readonly discoveryDescriptor = createGoalzeroDiscoveryDescriptor();
  public readonly configFlow = new GoalzeroConfigFlow();

  constructor() {
    super(goalzeroProfile);
  }

  public async setup(configArg: IGoalzeroConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(goalzeroProfile, new GoalzeroClient(configArg));
  }
}

export class HomeAssistantGoalzeroIntegration extends GoalzeroIntegration {}
