/**
 * 文件系统传输层接口
 * 本地模式走 Wails IPC，远程模式走 HTTP REST API
 * Composable 和组件不感知底层差异
 */

export type FileItem = {
  name: string
  path: string
  size: number
  size_str?: string
  is_dir: boolean
  mod_time?: string
  mode?: string
}

export type FileOperationResult = {
  path: string
  name: string
  size: number
  size_str?: string
  is_dir: boolean
  mod_time?: string
  mode?: string
  old_path?: string
  deleted?: boolean
}

export type DetectTypeResult = {
  extension: string
  category: string
  mime_type: string
  confidence: number
}

export interface FsTransport {
  // 文件列表与信息
  listDir(path: string): Promise<FileItem[]>
  getFileInfo(path: string): Promise<Record<string, any>>

  // 文件读写
  readFile(path: string): Promise<string>
  writeFile(path: string, content: string): Promise<void>
  saveBase64File(path: string, content: string): Promise<void>

  // 文件操作
  createFile(dirPath: string, filename: string): Promise<FileOperationResult>
  createDir(parentPath: string, dirname: string): Promise<FileOperationResult>
  deletePath(path: string): Promise<FileOperationResult>
  renamePath(oldPath: string, newPath: string): Promise<FileOperationResult>

  // ZIP 操作（Wave 3）
  listZipContents(zipPath: string): Promise<FileItem[]>
  extractFileFromZip(zipPath: string, filePath: string): Promise<string>
  extractFileFromZipToTemp(zipPath: string, filePath: string): Promise<string>
  getZipFileInfo(zipPath: string, filePath: string): Promise<FileItem>

  // 系统操作
  openPath(path: string): Promise<void>
  getFileServerURL(): Promise<string>
  getPreviewToken(): string
  resolveShortcut(lnkPath: string): Promise<any>
  detectFileTypeByContent(path: string): Promise<DetectTypeResult>
  getCommonPaths(): Promise<Record<string, string>>

  // 回收站（Wave 3）
  getRecycleBinEntries(): Promise<any[]>
  restoreFromRecycleBin(path: string): Promise<void>
  deletePermanently(path: string): Promise<void>
  emptyRecycleBin(): Promise<void>
}
