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

export const lgNetcastDomain = "lg_netcast";
export const lgNetcastDefaultName = "LG Netcast";
export type TLgNetcastProtocol = 'roap' | 'hdcp';

export type TLgNetcastRawData = TSimpleLocalRawData;
export interface ILgNetcastSnapshot extends ISimpleLocalSnapshot {}
export interface ILgNetcastConfig extends ISimpleLocalConfig {
  url?: string;
  accessToken?: string;
  pairingKey?: string;
  netcastProtocol?: TLgNetcastProtocol;
  protocol?: TLgNetcastProtocol;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantLgNetcastConfig extends ILgNetcastConfig {}

export const lgNetcastProfile: ISimpleLocalIntegrationProfile = {
  domain: lgNetcastDomain,
  displayName: "LG Netcast",
  manufacturer: "LG Netcast",
  model: "LG Netcast local integration",
  defaultName: lgNetcastDefaultName,
  defaultPort: 8080,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "button",
    "media_player",
  ],
  serviceDomains: [
    "button",
    "media_player",
  ],
  controlServices: [
    "media_pause",
    "media_play",
    "press",
    "volume_down",
    "volume_up",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "lg_netcast",
    "LG Netcast",
    "Lg Netcast",
    "LG",
    "Netcast",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/lg_netcast",
    "upstreamDomain": "lg_netcast",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "pylgnetcast==0.3.9",
    ],
    "dependencies": [
      "network",
    ],
    "codeowners": [
      "@Drafteed",
      "@splinter98",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/lg_netcast",
    "loggers": [
      "pylgnetcast",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "media_pause",
        "media_play",
        "press",
        "volume_down",
        "volume_up",
      ],
      "platforms": [
        "button",
        "media_player",
      ],
      "controls": "native ROAP HTTP key commands when host plus accessToken/token is configured; otherwise delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native LG Netcast ROAP HTTP polling for rootservice.xml, volume_info, and cur_channel on port 8080 when host/url is configured",
        "native LG Netcast ROAP HTTP control through AuthReq session creation and HandleKeyInput commands when accessToken/token is configured",
        "manual local setup for LG Netcast endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for LG Netcast device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when native ROAP credentials are not configured",
      ],
      "explicitUnsupported": [
        "persisting or automatically discovering the on-screen LG Netcast pairing key; native control requires accessToken/token supplied by config",
        "native source/channel changing because Home Assistant delegates channel XML elements from pylgnetcast channel_list and no stable TS channel selection contract exists here",
        "claiming LG Netcast command success without accessToken/token, injected client.execute, or commandExecutor",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
