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

export const owntracksDomain = "owntracks";
export const owntracksDefaultName = "OwnTracks";

export type TOwntracksRawData = TSimpleLocalRawData;
export interface IOwntracksSnapshot extends ISimpleLocalSnapshot {}
export interface IOwntracksConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOwntracksConfig extends IOwntracksConfig {}

export const owntracksProfile: ISimpleLocalIntegrationProfile = {
  domain: owntracksDomain,
  displayName: "OwnTracks",
  manufacturer: "OwnTracks",
  model: "OwnTracks local integration",
  defaultName: owntracksDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "owntracks",
    "OwnTracks",
    "Owntracks",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/owntracks",
    "upstreamDomain": "owntracks",
    "integrationType": "service",
    "iotClass": "local_push",
    "requirements": [
      "PyNaCl==1.6.2",
    ],
    "dependencies": [
      "webhook",
    ],
    "afterDependencies": [
      "mqtt",
      "cloud",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/owntracks",
    "loggers": [
      "nacl",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
      "liveProtocol": "push-only OwnTracks webhook or MQTT ingestion is not a client-side polling API",
    },
    "localApi": {
      "implemented": [
        "manual snapshots, rawData, snapshotProvider, and injected native clients for already-ingested OwnTracks state",
        "runtime mapping for OwnTracks device snapshots and Home Assistant platform metadata",
      ],
      "explicitUnsupported": [
        "native live polling because OwnTracks sends local_push updates to an inbound webhook and exposes no local HTTP polling endpoint",
        "MQTT broker topic subscription because correct operation requires broker subscription semantics and retained/availability message handling",
        "encrypted OwnTracks payload decryption/encryption because Home Assistant uses PyNaCl/libsodium and no equivalent dependency is available here",
        "webhook/cloudhook registration and HTTP server lifecycle because this runtime has no inbound Home Assistant webhook server contract",
        "Home Assistant entity registry migrations and repair flows",
        "claiming OwnTracks command/write success; the integration is read-only push ingestion",
      ],
    },
  },
};
