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

export const flicDomain = 'flic';
export const flicDefaultName = 'Flic';
export const flicDefaultHost = 'localhost';
export const flicDefaultPort = 5551;

export type TFlicClickType = 'single' | 'double' | 'hold';
export type TFlicRawData = TSimpleLocalRawData;
export interface IFlicSnapshot extends ISimpleLocalSnapshot {}
export interface IFlicConfig extends ISimpleLocalConfig {
  discovery?: boolean;
  timeout?: number;
  ignoredClickTypes?: TFlicClickType[];
  ignored_click_types?: TFlicClickType[];
}
export interface IHomeAssistantFlicConfig extends IFlicConfig {}

export const flicProfile: ISimpleLocalIntegrationProfile = {
  domain: 'flic',
  displayName: 'Flic',
  manufacturer: 'Flic',
  model: 'Flic Button',
  defaultName: flicDefaultName,
  defaultPort: flicDefaultPort,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
  ],
  serviceDomains: [
    'binary_sensor',
  ],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'flic',
    'flic button',
    'pyflic',
    'button click',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/flic',
    upstreamDomain: 'flic',
    iotClass: 'local_push',
    qualityScale: 'legacy',
    requirements: [
      'pyflic==2.0.4',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/flic',
    loggers: [
      'pyflic',
    ],
    defaults: {
      host: flicDefaultHost,
      port: flicDefaultPort,
      timeout: 3,
      discovery: true,
      clickTypes: ['single', 'double', 'hold'],
      eventName: 'flic_click',
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'binary_sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual flicd endpoint metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'read-only Flic button binary sensor and click event state mapping',
      ],
      explicitUnsupported: [
        'native pyflic/flicd protocol event loop in this TypeScript package',
        'button scanning or pairing without an injected native client',
        'claiming live command success without an injected client.execute or commandExecutor',
      ],
    },
  },
};
