/// <reference types="vite/client" />

declare global {
   interface Window {
      ipcRenderer: {
         on(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;
         off(channel: string, listener: (...args: unknown[]) => void): unknown;
         send(channel: string, ...args: unknown[]): void;
         invoke(channel: string, ...args: unknown[]): Promise<unknown>;
      };
      /** Electron safeStorage 安全加密 API（由 preload 注入，基于 OS 原生密钥链） */
      safeStorage: {
         encrypt(plaintext: string): Promise<string | null>;
         decrypt(encryptedBase64: string): Promise<string | null>;
      };
      /** 本地存储文件 API（由 preload 注入，主进程 fs 桥接） */
      fileStorage: {
         getDataDir(): Promise<string | null>;
         writeFile(relativePath: string, data: string, encoding?: 'base64' | 'utf8'): Promise<string | null>;
         readFile(relativePath: string): Promise<string | null>;
         deleteFile(relativePath: string): Promise<boolean>;
         makeDir(relativePath: string): Promise<string | null>;
         showItemInFolder(filePath: string): Promise<boolean>;
         fileSize(relativePath: string): Promise<number | null>;
         fileExists(relativePath: string): Promise<boolean>;
      };
      /** 应用运行时 API（由 preload 注入） */
      appRuntime: {
         setWindowEdition(edition: string | null): void;
      };
      /** 无限画布 API（由 preload 注入） */
      canvas: {
         openWindow(projectPath?: string): void;
         scanDirectory(params: { roots: string[]; extensions: string[]; recursive: boolean }): Promise<unknown>;
         scanProject(params: { projectPath: string; stage: string; assetTypeFilter: string; shotQuery: string }): Promise<unknown>;
         readSidecar(params: { filePath: string }): Promise<unknown>;
         writeSidecar(params: { filePath: string; metadata: object }): Promise<unknown>;
         generateThumbnail(params: { filePath: string; size: number }): Promise<unknown>;
         copyFile(params: { src: string; destDir: string; fileName: string }): Promise<unknown>;
         /** 列出目录下的子文件夹（非递归，排除隐藏） */
         listSubdirs(params: { parentPath: string }): Promise<{ success: boolean; data: string[]; error?: string }>;
         /** 扫描阶段文件（单个 episode/shot/stage 组合） */
         scanStageFiles(params: { projectPath: string; episode: string; shot: string; stage: string }): Promise<{ success: boolean; data: Array<{ path: string; fileName: string; ext: string; fileSize: number; modifiedAt: string }>; error?: string }>;
         /** 扫描资产文件（深度递归扫描 assets/ 目录） */
         scanAssetFiles(params: { projectPath: string; assetTypeFilter: string }): Promise<{ success: boolean; data: Array<{ path: string; fileName: string; ext: string; fileSize: number; modifiedAt: string }>; error?: string }>;
         /** 创建目录 */
         createDirectory(params: { parentPath: string; dirName: string }): Promise<{ success: boolean; data: string; error?: string }>;
         /** 将本地文件路径转换为 local-media:// 协议 URL */
         getMediaUrl(filePath: string): string;
         /** 启动原生文件拖拽（从缩略图拖放媒体文件到外部应用） */
         startDrag(params: { filePath: string; fileName: string }): Promise<{ success: boolean; error?: string }>;
      };
   }
}

export {};
