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

export const folderWatcherDomain = 'folder_watcher';
export const folderWatcherDefaultName = 'Folder Watcher';
export const folderWatcherDefaultPattern = '*';

export type TFolderWatcherEventType = 'closed' | 'created' | 'deleted' | 'modified' | 'moved';
export type TFolderWatcherRawData = TSimpleLocalRawData;
export interface IFolderWatcherSnapshot extends ISimpleLocalSnapshot {}
export interface IFolderWatcherConfig extends ISimpleLocalConfig {
  folder?: string;
  folderPath?: string;
  folder_path?: string;
  patterns?: string[];
}
export interface IHomeAssistantFolderWatcherConfig extends IFolderWatcherConfig {}

export const folderWatcherProfile: ISimpleLocalIntegrationProfile = {
  domain: 'folder_watcher',
  displayName: 'Folder Watcher',
  manufacturer: 'Folder watcher',
  model: 'Watchdog folder observer',
  defaultName: folderWatcherDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'folder_watcher',
    'folder watcher',
    'watchdog',
    'file events',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/folder_watcher',
    upstreamDomain: 'folder_watcher',
    iotClass: 'local_polling',
    qualityScale: 'internal',
    requirements: [
      'watchdog==6.0.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/folder_watcher',
    loggers: [
      'watchdog',
    ],
    defaults: {
      patterns: [folderWatcherDefaultPattern],
      eventTypes: ['closed', 'created', 'deleted', 'modified', 'moved'],
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'event',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local folder path setup, snapshots, raw data, snapshotProvider, and injected native clients',
        'read-only Folder Watcher event snapshots from config.folder, config.folderPath, or config.folder_path',
        'Home Assistant event payload mapping for closed, created, deleted, modified, and moved file events',
      ],
      explicitUnsupported: [
        'native watchdog subscription and live push event delivery in this TypeScript package',
        'Home Assistant allowlist enforcement outside caller-provided safe local paths',
        'claiming live command success without injected client.execute or commandExecutor',
      ],
    },
  },
};
