const templateLabels: Record<string, string> = {
  "generate-topic-matrix": "話題矩陣產文",
  "generate-formula-draft": "公式草稿產文",
  "generate-rewrite-draft": "貼文改寫",
  "generate-outreach-draft": "獲客草稿",
  "generate-copy-matrix": "文案矩陣",
  "generate-copy-draft": "仿寫草稿",
  "analyze-copy-mission": "文案任務分析",
  "expand-copy-mission-graph": "文案任務圖譜",
  "expand-graph": "知識圖譜擴展",
  "placement-scan": "海巡掃描",
  "scan-viral": "爆款掃描",
  "style-8d": "8D 語調分析",
  "refresh-threads-token": "Threads Token 更新",
  "publish-analytics": "發文成效分析",
  "refill-publish-inventory": "發文庫存補貨",
  demo_long_task: "示範長任務"
};

const eventTypeLabels: Record<string, string> = {
  status_changed: "狀態變更",
  progress_updated: "進度更新",
  step_started: "步驟開始",
  step_finished: "步驟完成",
  step_failed: "步驟失敗",
  retried: "重新排隊",
  cancelled: "已取消",
  expired: "已逾時"
};

const phaseLabels: Record<string, string> = {
  topic_matrix_generate: "產生話題矩陣",
  formula_draft_generate: "產生公式草稿",
  rewrite_draft_generate: "分析並改寫",
  generate_outreach_draft: "產生獲客草稿",
  expand_graph: "擴展圖譜",
  placement_scan: "海巡掃描",
  scan_viral: "爆款掃描",
  style_8d_analyze: "8D 分析"
};

const stepStatusLabels: Record<string, string> = {
  pending: "等待",
  running: "執行中",
  succeeded: "完成",
  failed: "失敗",
  skipped: "略過",
  cancelled: "已取消"
};

export function jobTemplateLabel(type?: string) {
  if (!type) return "背景任務";
  return templateLabels[type] || type.replace(/-/g, " ");
}

export function jobEventTypeLabel(type?: string) {
  if (!type) return "事件";
  return eventTypeLabels[type] || type;
}

export function jobPhaseLabel(phase?: string) {
  if (!phase) return "";
  return phaseLabels[phase] || phase;
}

export function jobStepStatusLabel(status?: string) {
  if (!status) return "未知";
  return stepStatusLabels[status] || status;
}

export function scheduleTemplateLabel(type?: string) {
  return jobTemplateLabel(type);
}