import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { GraphiteClient } from './graphite.classes.client.js';
import { GraphiteConfigFlow } from './graphite.classes.configflow.js';
import { createGraphiteDiscoveryDescriptor } from './graphite.discovery.js';
import type { IGraphiteConfig } from './graphite.types.js';
import { graphiteDomain, graphiteProfile } from './graphite.types.js';

export class GraphiteIntegration extends SimpleLocalIntegration<IGraphiteConfig> {
  public readonly domain = graphiteDomain;
  public readonly discoveryDescriptor = createGraphiteDiscoveryDescriptor();
  public readonly configFlow = new GraphiteConfigFlow();

  constructor() {
    super(graphiteProfile);
  }

  public async setup(configArg: IGraphiteConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(graphiteProfile, new GraphiteClient(configArg));
  }
}

export class HomeAssistantGraphiteIntegration extends GraphiteIntegration {}
