import type { MetadataPayload } from '@/types/metadata'

export interface DecompositionTemplate {
  id: string
  name: string
  scene: string
  description?: string
  current_version: number
  status: DecompositionStatus
  is_latest_effective: boolean
  effective_at?: string
  metadata?: MetadataPayload
  created_at: string
  updated_at: string
}

export interface DecompositionTemplateDetail {
  id: string
  name: string
  scene: string
  description?: string
  current_version: number
  status: DecompositionStatus
  is_latest_effective: boolean
  effective_at?: string
  steps: DecompositionStep[]
  versions: DecompositionVersion[]
  metadata?: MetadataPayload
  created_at: string
  updated_at: string
}

export type DecompositionStatus = 'draft' | 'active' | 'archived'

export interface DecompositionStep {
  step_id: string
  step_no: number
  instruction: string
  expected_output?: string
  dependencies?: string[]
}

export interface DecompositionVersion {
  version: number
  status: DecompositionStatus
  steps: DecompositionStep[]
  created_at: string
  effective_at?: string
  archived_at?: string
}

export interface DecompositionTemplateCreate {
  name: string
  scene: string
  description?: string
  steps: DecompositionStep[]
  metadata?: MetadataPayload
}

export interface DecompositionTemplateUpdate {
  name?: string
  scene?: string
  description?: string
  steps?: DecompositionStep[]
  metadata?: MetadataPayload
}

export interface DecompositionTemplateListResponse {
  data: DecompositionTemplate[]
}

export const DECOMPOSITION_STATUS_OPTIONS = [
  { value: 'draft', label: '草稿', color: 'info' },
  { value: 'active', label: '生效', color: 'success' },
  { value: 'archived', label: '归档', color: 'warning' }
]

export const DECOMPOSITION_SCENE_OPTIONS = [
  { value: 'customer_service', label: '客服场景' },
  { value: 'sales', label: '销售场景' },
  { value: 'support', label: '技术支持' },
  { value: 'complaint', label: '投诉处理' },
  { value: 'general', label: '通用场景' }
]
