import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MinecraftServerClient } from './minecraft_server.classes.client.js';
import { MinecraftServerConfigFlow } from './minecraft_server.classes.configflow.js';
import { createMinecraftServerDiscoveryDescriptor } from './minecraft_server.discovery.js';
import type { IMinecraftServerConfig } from './minecraft_server.types.js';
import { minecraftServerDomain, minecraftServerProfile } from './minecraft_server.types.js';

export class MinecraftServerIntegration extends SimpleLocalIntegration<IMinecraftServerConfig> {
  public readonly domain = minecraftServerDomain;
  public readonly discoveryDescriptor = createMinecraftServerDiscoveryDescriptor();
  public readonly configFlow = new MinecraftServerConfigFlow();

  constructor() {
    super(minecraftServerProfile);
  }

  public async setup(configArg: IMinecraftServerConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(minecraftServerProfile, new MinecraftServerClient(configArg));
  }
}

export class HomeAssistantMinecraftServerIntegration extends MinecraftServerIntegration {}
