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

export const ibeaconDomain = 'ibeacon';
export const ibeaconDefaultName = 'iBeacon Tracker';

export type TIbeaconRawData = TSimpleLocalRawData;
export interface IIbeaconSnapshot extends ISimpleLocalSnapshot {}
export interface IIbeaconConfig extends ISimpleLocalConfig {
  address?: string;
  uuid?: string;
  major?: number;
  minor?: number;
  allowNamelessUuids?: string[];
  ignoreAddresses?: string[];
  ignoreUuids?: string[];
}
export interface IHomeAssistantIbeaconConfig extends IIbeaconConfig {}

export const ibeaconProfile: ISimpleLocalIntegrationProfile = {
  domain: ibeaconDomain,
  displayName: 'iBeacon Tracker',
  manufacturer: 'Apple',
  model: 'iBeacon advertisement',
  defaultName: ibeaconDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'bluetooth',
    'custom',
  ],
  discoveryKeywords: [
    'ibeacon',
    'iBeacon',
    'bluetooth',
    'beacon',
    'device tracker',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/ibeacon',
    upstreamDomain: 'ibeacon',
    integrationType: 'hub',
    iotClass: 'local_push',
    qualityScale: undefined,
    requirements: [
      'ibeacon-ble==1.2.0',
    ],
    dependencies: [
      'bluetooth_adapters',
    ],
    afterDependencies: [],
    codeowners: [],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/ibeacon',
    bluetooth: [
      {
        manufacturer_data_start: [2, 21],
        manufacturer_id: 76,
      },
    ],
    homeAssistantPlatforms: [
      'device_tracker',
      'sensor',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'binary_sensor',
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual Bluetooth beacon setup from discovered metadata, snapshots, rawData, snapshotProvider, and injected native clients',
        'runtime mapping for iBeacon presence and advertisement sensor snapshots',
      ],
      explicitUnsupported: [
        'opening Bluetooth scanner sessions without an injected native client or snapshotProvider',
        'Home Assistant device_tracker platform semantics beyond binary presence snapshot mapping',
        'claiming live command success without injected client.execute or commandExecutor',
      ],
    },
  },
};
