export interface CopySuggestedTagData {
  tag: string
  reason?: string
  search_intent?: string
  search_type?: string
}

export interface CopySimilarAccountData {
  username: string
  reason?: string
  source?: string
  confidence?: string
  profile_url?: string
  author_verified?: boolean
  follower_count?: number
  engagement_score?: number
  like_count?: number
  reply_count?: number
  post_count?: number
}

export interface CopyMissionResearchMapData {
  audience_summary?: string
  content_goal?: string
  questions?: string[]
  pillars?: string[]
  exclusions?: string[]
  suggested_tags?: CopySuggestedTagData[]
  similar_accounts?: CopySimilarAccountData[]
  benchmark_notes?: string
}

export interface CopyMissionData {
  id: string
  persona_id: string
  label?: string
  seed_query?: string
  brief?: string
  research_map?: CopyMissionResearchMapData
  selected_tags?: string[]
  last_scan_job_id?: string
  status?: string
  create_at: number
  update_at: number
}

export function hasMissionResearchMap(mission: CopyMissionData | null | undefined): boolean {
  const map = mission?.research_map
  return !!(map?.audience_summary || (map?.suggested_tags?.length ?? 0) > 0)
}

export function copyMissionStatusLabel(status?: string): string {
  switch (status) {
    case 'mapped':
      return '地圖就緒'
    case 'scanned':
      return '已海巡'
    case 'drafted':
      return '已產稿'
    case 'archived':
      return '已封存'
    case 'open':
      return '進行中'
    default:
      return '進行中'
  }
}

export function copyMissionStatusTone(status?: string): 'brand' | 'success' | 'warning' | 'neutral' | 'sky' {
  switch (status) {
    case 'drafted':
      return 'success'
    case 'scanned':
      return 'sky'
    case 'mapped':
      return 'brand'
    default:
      return 'neutral'
  }
}