/**
 * 运行时配置读取工具
 * 从 window.__LEAI_CONFIG__（public/config.js）读取配置
 */
const raw = window.__LEAI_CONFIG__ || {}
const authMode = raw.authMode || 'hmac'
const isTokenMode = authMode === 'token'
const env = isTokenMode ? (raw.prod || {}) : (raw.dev || {})

const config = {
  authMode,
  isTokenMode,
  apiBaseUrl:    env.apiBaseUrl || '',
  wsBaseUrl:     env.wsBaseUrl  || '',
  brand:         raw.brand || { title: '乐读派', subtitle: 'AI智能儿童绘本创作', slogan: '让想象力飞翔' },
  dev:           isTokenMode ? null : (raw.dev || {}),
  embedMode:     raw.embedMode || 'standalone',
  parentOrigins: raw.parentOrigins || [],
  isEmbedded:    (raw.embedMode === 'iframe') || (window.self !== window.top)
}

export default config
