// 模型服务商配置列表（服务端托管）
export const modelProviders = {
  deepseek: {
    id: 'deepseek',
    name: 'DeepSeek',
    description: '深度求索',
    model: import.meta.env.VITE_DEEPSEEK_MODEL || 'deepseek-chat',
    serverManaged: true
  },
  qianfan: {
    id: 'qianfan',
    name: '千帆大模型',
    description: '百度文心一言',
    model: import.meta.env.VITE_QIANFAN_MODEL || 'ernie-4.0-8k',
    serverManaged: true
  },
  openai: {
    id: 'openai',
    name: 'OpenAI',
    description: 'GPT 系列',
    model: import.meta.env.VITE_OPENAI_MODEL || 'gpt-4o',
    serverManaged: true
  },
  claude: {
    id: 'claude',
    name: 'Claude',
    description: 'Anthropic Claude',
    model: import.meta.env.VITE_CLAUDE_MODEL || 'claude-3-5-sonnet',
    serverManaged: true
  },
  custom: {
    id: 'custom',
    name: '自定义',
    description: '自定义 API 端点',
    model: import.meta.env.VITE_CUSTOM_MODEL || '',
    serverManaged: true
  }
}

// 服务端托管模式下，前端仅展示所有服务商
export const getConfiguredProviders = () => {
  return Object.values(modelProviders)
}

// 获取默认服务商
export const getDefaultProvider = () => {
  const configured = getConfiguredProviders()
  return configured.length > 0 ? configured[0] : modelProviders.deepseek
}

// 应用配置
export const config = {
  appVersion: '1.0.0',
  isDev: import.meta.env.DEV,
  mode: import.meta.env.MODE
}

// 验证配置（服务端托管时仅返回空错误）
export const validateConfig = () => {
  return []
}

// 获取配置摘要（用于调试）
export const getConfigSummary = () => {
  return {
    configuredProviders: getConfiguredProviders().map(p => p.name),
    defaultProvider: getDefaultProvider().name,
    mode: config.mode,
    isDev: config.isDev
  }
}
