/**
 * 环境配置文件
 * 统一管理所有API URL和环境变量
 */

// 获取环境变量
const env = import.meta.env.MODE || 'development'

// 环境配置
const envConfig = {
  development: {
    // 开发环境配置
    baseURL: '/insurance/api',
    timeout: 30000,
    // 其他开发环境配置
    wsURL: 'ws://localhost:3000',
  },
  production: {
    // 生产环境配置
    baseURL: '/insurance/api',
    timeout: 10000,
    // 其他生产环境配置
    wsURL: 'wss://production-domain.com',
  },
  test: {
    // 测试环境配置
    baseURL: '/insurance/api',
    timeout: 15000,
    // 其他测试环境配置
    wsURL: 'ws://test-server:3000',
  }
}

// 导出当前环境配置
export default envConfig[env] || envConfig.development

// 导出特定配置项，方便按需引入
export const { baseURL, timeout, wsURL } = envConfig[env] || envConfig.development

// API端点配置
export const API_ENDPOINTS = {
  // 认证相关
  AUTH: {
    LOGIN: '/auth/login',
    LOGOUT: '/auth/logout',
    REFRESH: '/auth/refresh',
    PROFILE: '/users/profile'
  },
  
  // 用户管理
  USERS: {
    LIST: '/users',
    CREATE: '/users',
    UPDATE: (id) => `/users/${id}`,
    DELETE: (id) => `/users/${id}`,
    EXPORT: '/users/export'
  },
  
  // 保险类型管理
  INSURANCE_TYPES: {
    LIST: '/insurance-types',
    CREATE: '/insurance-types',
    UPDATE: (id) => `/insurance-types/${id}`,
    DELETE: (id) => `/insurance-types/${id}`,
    EXPORT: '/insurance-types/export'
  },
  
  // 申请管理
  APPLICATIONS: {
    LIST: '/insurance/applications',
    DETAIL: (id) => `/insurance/applications/${id}`,
    CREATE: '/insurance/applications',
    UPDATE: (id) => `/insurance/applications/${id}`,
    REVIEW: (id) => `/insurance/applications/${id}/review`,
    EXPORT: '/insurance/applications/export'
  },
  
  // 保单管理
  POLICIES: {
    LIST: '/policies',
    DETAIL: (id) => `/policies/${id}`,
    CREATE: '/policies',
    UPDATE: (id) => `/policies/${id}`,
    EXPORT: '/policies/export'
  },
  
  // 理赔管理
  CLAIMS: {
    LIST: '/claims',
    DETAIL: (id) => `/claims/${id}`,
    UPDATE_STATUS: (id) => `/claims/${id}/status`,
    EXPORT: '/claims/export'
  },
  
  // 设备预警
  DEVICE_ALERTS: {
    LIST: '/device-alerts',
    DETAIL: (id) => `/device-alerts/${id}`,
    STATS: '/device-alerts/stats',
    MARK_READ: (id) => `/device-alerts/${id}/read`,
    EXPORT: '/device-alerts/export'
  },
  
  // 监管任务
  SUPERVISION_TASKS: {
    LIST: '/supervision-tasks',
    DETAIL: (id) => `/supervision-tasks/${id}`,
    CREATE: '/supervision-tasks',
    UPDATE: (id) => `/supervision-tasks/${id}`,
    DELETE: (id) => `/supervision-tasks/${id}`,
    STATS: '/supervision-tasks/stats',
    EXPORT: '/supervision-tasks/export',
    ARCHIVE: (id) => `/supervision-tasks/${id}/archive`,
    DOWNLOAD_REPORT: (id) => `/supervision-tasks/${id}/report`
  },
  
  // 待安装任务
  INSTALLATION_TASKS: {
    LIST: '/installation-tasks',
    DETAIL: (id) => `/installation-tasks/${id}`,
    CREATE: '/installation-tasks',
    UPDATE: (id) => `/installation-tasks/${id}`,
    DELETE: (id) => `/installation-tasks/${id}`,
    STATS: '/installation-tasks/stats',
    EXPORT: '/installation-tasks/export'
  },
  
  // 生资保险
  LIVESTOCK: {
    TYPES: '/livestock-types',
    POLICIES: '/livestock-policies',
    CLAIMS: '/livestock-claims'
  },
  
  // 操作日志
  OPERATION_LOGS: {
    LIST: '/operation-logs',
    STATS: '/operation-logs/stats',
    EXPORT: '/operation-logs/export'
  },
  
  // 权限管理
  PERMISSIONS: {
    LIST: '/permissions',
    TREE: '/permissions/tree'
  },
  
  // 角色权限
  ROLE_PERMISSIONS: {
    ROLES: '/role-permissions/roles',
    PERMISSIONS: '/role-permissions/permissions',
    ASSIGN: (roleId) => `/role-permissions/${roleId}/assign`,
    COPY: '/role-permissions/copy'
  }
}

