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

export interface PromptTemplate {
  id: string
  name: string
  scene: string
  description?: string
  is_default: boolean
  metadata?: MetadataPayload
  published_version?: PromptVersionInfo
  created_at: string
  updated_at: string
}

export interface PromptVersionInfo {
  version: number
  status: string
  created_at: string
}

export interface PromptTemplateDetail {
  id: string
  name: string
  scene: string
  description?: string
  is_default: boolean
  current_content?: string
  variables?: PromptVariable[]
  versions?: PromptVersion[]
  metadata?: MetadataPayload
  published_version?: PromptVersionInfo
  created_at: string
  updated_at: string
}

export interface PromptVersion {
  version: number
  content: string
  status: 'draft' | 'published' | 'archived'
  variables?: PromptVariable[]
  created_at: string
  published_at?: string
}

export interface PromptVariable {
  name: string
  description?: string
  default_value?: string
}

export interface PromptTemplateCreate {
  name: string
  scene: string
  description?: string
  system_instruction: string
  variables?: PromptVariable[]
  is_default?: boolean
  metadata?: MetadataPayload
}

export interface PromptTemplateUpdate {
  name?: string
  scene?: string
  description?: string
  system_instruction?: string
  variables?: PromptVariable[]
  metadata?: MetadataPayload
}

export interface PromptTemplateListResponse {
  data: PromptTemplate[]
}

export interface PublishRequest {
  version: number
}

export interface RollbackRequest {
  version: number
}

export const SCENE_OPTIONS = [
  { value: 'chat', label: '对话场景' },
  { value: 'qa', label: '问答场景' },
  { value: 'summary', label: '摘要场景' },
  { value: 'translation', label: '翻译场景' },
  { value: 'code', label: '代码场景' },
  { value: 'agent_react', label: 'Agent ReAct 场景' },
  { value: 'custom', label: '自定义场景' }
]

export const BUILTIN_VARIABLES: PromptVariable[] = [
  { name: 'persona_name', description: 'AI 人设名称', default_value: 'AI助手' },
  { name: 'persona_personality', description: 'AI 性格特点', default_value: '热情、耐心、专业' },
  { name: 'persona_tone', description: 'AI 说话风格', default_value: '亲切自然，使用口语化表达' },
  { name: 'brand_name', description: '品牌名称', default_value: '我们公司' },
  { name: 'current_time', description: '当前时间' },
  { name: 'channel_type', description: '渠道类型（web/wechat/phone/app）' },
  { name: 'user_name', description: '用户名称' },
  { name: 'context', description: '检索上下文' },
  { name: 'query', description: '用户问题' },
  { name: 'history', description: '对话历史' },
  { name: 'available_tools', description: '可用工具列表（Agent ReAct 场景专用，自动注入已注册工具的名称、描述和参数）' }
]
