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

export const genericDomain = 'generic';
export const genericDefaultName = 'Generic Camera';

export type TGenericRawData = TSimpleLocalRawData;
export interface IGenericSnapshot extends ISimpleLocalSnapshot {}
export interface IGenericConfig extends ISimpleLocalConfig {
  stillImageUrl?: string;
  still_image_url?: string;
  streamSource?: string;
  stream_source?: string;
  contentType?: string;
  content_type?: string;
  framerate?: number;
  verifySsl?: boolean;
  verify_ssl?: boolean;
  rtspTransport?: string;
  rtsp_transport?: string;
  authentication?: 'basic' | 'digest' | string;
}
export interface IHomeAssistantGenericConfig extends IGenericConfig {}

export const genericProfile: ISimpleLocalIntegrationProfile = {
  domain: 'generic',
  displayName: 'Generic Camera',
  manufacturer: 'Generic',
  model: 'IP camera',
  defaultName: genericDefaultName,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [
    'camera',
  ],
  controlServices: [
    'turn_on',
    'turn_off',
  ],
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'generic',
    'camera',
    'ip camera',
    'rtsp',
    'still image',
    'stream',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/generic',
    upstreamDomain: 'generic',
    integrationType: 'device',
    iotClass: 'local_push',
    qualityScale: undefined,
    requirements: [
      'av==16.0.1',
      'Pillow==12.2.0',
    ],
    dependencies: [
      'http',
      'stream',
    ],
    afterDependencies: [],
    codeowners: [
      '@davet2001',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/generic',
    homeAssistantPlatforms: [
      'camera',
    ],
    defaults: {
      framerate: 2,
      verifySsl: true,
      rtspTransport: 'tcp',
      authentication: 'basic',
      limitRefetchToUrlChange: false,
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'turn_on',
        'turn_off',
      ],
      platforms: [
        'sensor',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local still-image and stream-source setup metadata',
        'snapshot, raw data, snapshotProvider, and injected native client operation',
        'runtime device/entity mapping for configured Generic camera endpoints',
      ],
      explicitUnsupported: [
        'serving or transcoding camera streams from this TypeScript package',
        'claiming camera turn_on or turn_off success without an injected client.execute or commandExecutor',
        'Home Assistant preview WebSocket and YAML reload handlers',
      ],
    },
  },
};
