import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const gc100Domain = 'gc100';
export const gc100DefaultName = 'Global Cache GC-100';
export const gc100DefaultPort = 4998;

export type TGc100RawData = TSimpleLocalRawData;
export interface IGc100Snapshot extends ISimpleLocalSnapshot {}
export interface IGc100Config extends ISimpleLocalConfig {
  ports?: Array<Record<string, string>>;
}
export interface IHomeAssistantGc100Config extends IGc100Config {}

export const gc100Profile: ISimpleLocalIntegrationProfile = {
  domain: gc100Domain,
  displayName: 'Global Cache GC-100',
  manufacturer: 'Global Cache',
  model: 'GC-100',
  defaultName: gc100DefaultName,
  defaultPort: gc100DefaultPort,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'switch',
  ],
  serviceDomains: [
    'binary_sensor',
    'switch',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
    'toggle',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'global cache',
    'gc100',
    'gc-100',
    'relay',
    'digital input',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/gc100',
    upstreamDomain: 'gc100',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'python-gc100==1.0.3a0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/gc100',
    defaults: {
      port: gc100DefaultPort,
    },
    platforms: [
      'binary_sensor',
      'switch',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
        'toggle',
      ],
      platforms: [
        'binary_sensor',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for GC-100 host, port, port mapping metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime mapping for digital input and relay snapshots as binary sensor and switch entities',
        'safe relay control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native python-gc100 socket command protocol in this TypeScript package',
        'claiming relay write success without an injected client.execute or commandExecutor',
        'Home Assistant YAML platform setup and stop-event socket cleanup',
      ],
    },
  },
};
