/**
 * 类型定义模块
 * JavaScript 版本 - 使用 JSDoc 注释提供类型提示
 */

/**
 * @typedef {'text' | 'image' | 'file'} DeviceCapability
 */

/**
 * @typedef {Object} DeviceInfo
 * @property {string} deviceId
 * @property {string} deviceName
 * @property {string} ip
 * @property {number} wsPort
 * @property {number} httpPort
 * @property {boolean} online
 * @property {DeviceCapability[]} capabilities
 * @property {number} lastSeen
 */

/**
 * 消息类型
 * - text: 文本消息
 * - image: 图片消息
 * - file: 文件消息
 * - event: 系统事件
 * - ack: 确认回执
 * - ping: 心跳 ping
 * - pong: 心跳 pong
 * @typedef {'text' | 'image' | 'file' | 'event' | 'ack' | 'ping' | 'pong'} MessageType
 */

/**
 * @typedef {'pending' | 'sent' | 'delivered' | 'read' | 'failed'} MessageStatus
 */

/**
 * @typedef {Object} ChatMessage
 * @property {string} id
 * @property {MessageType} type
 * @property {string} content
 * @property {string} from
 * @property {string} to
 * @property {number} timestamp
 * @property {MessageStatus} status
 */

/**
 * @typedef {'pending' | 'transferring' | 'completed' | 'failed' | 'cancelled'} TransferStatus
 */

/**
 * @typedef {Object} FileTransfer
 * @property {string} fileId
 * @property {string} name
 * @property {number} size
 * @property {number} progress
 * @property {TransferStatus} status
 * @property {string} mimeType
 * @property {string} fromDevice
 * @property {string} toDevice
 * @property {string} [localPath]
 * @property {number} createdAt
 * @property {number} [completedAt]
 * @property {number} transferredBytes
 */

/**
 * @typedef {Object} FileMetadata
 * @property {string} fileId
 * @property {string} name
 * @property {number} size
 * @property {string} mimeType
 * @property {string} [thumbnail]
 * @property {string} [path]
 */

/**
 * @typedef {Object} AppConfig
 * @property {string} deviceId
 * @property {string} deviceName
 * @property {number} udpPort
 * @property {number} wsPort
 * @property {number} httpPort
 * @property {string} downloadDir
 * @property {boolean} autoAcceptFiles
 * @property {number} maxFileSize
 */

/**
 * @typedef {Object} TransferProgressEvent
 * @property {string} fileId
 * @property {number} progress
 * @property {number} transferredBytes
 * @property {number} totalBytes
 * @property {TransferStatus} status
 * @property {string} [fileName]
 * @property {string} [localPath]
 */

/**
 * @typedef {Object} CommandError
 * @property {string} code
 * @property {string} message
 */

/** 事件名称 */
export const EventNames = {
  DEVICE_FOUND: 'device_found',
  DEVICE_LOST: 'device_lost',
  MESSAGE_RECEIVED: 'message_received',
  FILE_RECEIVED: 'file_received',
  TRANSFER_PROGRESS: 'transfer_progress',
  WEBSOCKET_CONNECTED: 'websocket_connected',
  WEBSOCKET_DISCONNECTED: 'websocket_disconnected',
  MESSAGE_STATUS_UPDATED: 'message_status_updated',
}
