/**
 * SKG model and size configuration.
 * These values mirror the backend /health capabilities and keep the canvas UI simple.
 */

export const SKG_IMAGE_SIZE_OPTIONS = [
  { label: '自动', key: 'auto' },
  { label: '竖图 2:3', key: '1024x1536' },
  { label: '方图 1:1', key: '1024x1024' },
  { label: '横图 3:2', key: '1536x1024' }
]

export const SKG_IMAGE_QUALITY_OPTIONS = [
  { label: '标准', key: 'standard' }
]

export const SKG_VIDEO_SIZE_OPTIONS = [
  { label: '竖屏 9:16', key: '720x1280' },
  { label: '横屏 16:9', key: '1280x720' },
  { label: '方形 1:1', key: '1024x1024' },
  { label: '竖屏 3:4', key: '960x1280' }
]

export const VIDEO_RATIO_LIST = SKG_VIDEO_SIZE_OPTIONS

export const SEEDANCE_RESOLUTION_OPTIONS = [
  { label: '720p', key: '720p' },
  { label: '1080p', key: '1080p' }
]

export const IMAGE_MODELS = [
  {
    label: '自动',
    key: 'auto',
    provider: ['skg'],
    sizes: SKG_IMAGE_SIZE_OPTIONS.map(s => s.key),
    qualities: SKG_IMAGE_QUALITY_OPTIONS,
    defaultParams: { size: '1024x1536', quality: 'standard', style: 'commercial' }
  },
  {
    label: 'GPT Image 2',
    key: 'gpt-image-2',
    provider: ['skg'],
    sizes: SKG_IMAGE_SIZE_OPTIONS.map(s => s.key),
    qualities: SKG_IMAGE_QUALITY_OPTIONS,
    defaultParams: { size: '1024x1536', quality: 'standard', style: 'commercial' }
  },
  {
    label: 'Gemini 图片备用',
    key: 'gemini-3-pro-image-preview',
    provider: ['skg'],
    sizes: SKG_IMAGE_SIZE_OPTIONS.map(s => s.key),
    qualities: SKG_IMAGE_QUALITY_OPTIONS,
    defaultParams: { size: '1024x1536', quality: 'standard', style: 'commercial' }
  }
]

export const VIDEO_MODELS = [
  {
    label: 'Seedance',
    key: 'seedance',
    provider: ['skg'],
    type: 't2v+i2v',
    ratios: SKG_VIDEO_SIZE_OPTIONS.map(s => s.key),
    durs: [5, 8, 10, 12, 15].map(s => ({ label: `${s} 秒`, key: s })),
    resolutions: ['720p', '1080p'],
    defaultResolution: '1080p',
    defaultParams: { ratio: '720x1280', duration: 10, resolution: '1080p' }
  },
  {
    label: 'Kling',
    key: 'kling',
    provider: ['skg'],
    type: 't2v+i2v',
    ratios: SKG_VIDEO_SIZE_OPTIONS.map(s => s.key),
    durs: [4, 8, 12].map(s => ({ label: `${s} 秒`, key: s })),
    resolutions: ['720p'],
    defaultResolution: '720p',
    defaultParams: { ratio: '720x1280', duration: 8, resolution: '720p' }
  },
  {
    label: 'Veo 3',
    key: 'veo3',
    provider: ['skg'],
    type: 't2v+i2v',
    ratios: SKG_VIDEO_SIZE_OPTIONS.map(s => s.key),
    durs: [4, 8, 12].map(s => ({ label: `${s} 秒`, key: s })),
    resolutions: ['720p'],
    defaultResolution: '720p',
    defaultParams: { ratio: '720x1280', duration: 8, resolution: '720p' }
  }
]

export const CHAT_MODELS = [
  { label: 'SKG 提示词助手', key: 'skg-copy', provider: ['skg'] }
]

export const IMAGE_SIZE_OPTIONS = SKG_IMAGE_SIZE_OPTIONS
export const IMAGE_QUALITY_OPTIONS = SKG_IMAGE_QUALITY_OPTIONS
export const IMAGE_STYLE_OPTIONS = [{ label: '商业营销', key: 'commercial' }]
export const VIDEO_RATIO_OPTIONS = SKG_VIDEO_SIZE_OPTIONS
export const VIDEO_DURATION_OPTIONS = [5, 8, 10, 12, 15].map(s => ({ label: `${s} 秒`, key: s }))

export const SEEDREAM_SIZE_OPTIONS = SKG_IMAGE_SIZE_OPTIONS
export const SEEDREAM_4K_SIZE_OPTIONS = SKG_IMAGE_SIZE_OPTIONS
export const SEEDREAM_QUALITY_OPTIONS = SKG_IMAGE_QUALITY_OPTIONS

export const DEFAULT_IMAGE_MODEL = 'auto'
export const DEFAULT_VIDEO_MODEL = 'seedance'
export const DEFAULT_CHAT_MODEL = 'skg-copy'
export const DEFAULT_IMAGE_SIZE = '1024x1536'
export const DEFAULT_VIDEO_RATIO = '720x1280'
export const DEFAULT_VIDEO_DURATION = 10

export const getModelByName = (key) => {
  const allModels = [...IMAGE_MODELS, ...VIDEO_MODELS, ...CHAT_MODELS]
  return allModels.find(m => m.key === key)
}
