const TERMINAL = new Set(['succeeded', 'failed', 'cancelled', 'expired'])

export function isTerminalJobStatus(status: string): boolean {
  return TERMINAL.has(status)
}

export function jobStatusLabel(status: string): string {
  switch (status) {
    case 'pending':
      return '等待中'
    case 'queued':
      return '已排隊'
    case 'running':
      return '執行中'
    case 'waiting_worker':
      return '等待 Worker'
    case 'cancel_requested':
      return '取消中'
    case 'succeeded':
      return '已完成'
    case 'failed':
      return '失敗'
    case 'cancelled':
      return '已取消'
    case 'expired':
      return '已過期'
    default:
      return status
  }
}

export function jobStatusBadgeClass(status: string): string {
  switch (status) {
    case 'running':
      return 'ac-status-badge--running'
    case 'queued':
    case 'pending':
    case 'waiting_worker':
      return 'ac-status-badge--queued'
    case 'cancel_requested':
      return 'ac-status-badge--waiting'
    case 'succeeded':
      return 'ac-status-badge--success'
    case 'failed':
    case 'expired':
      return 'ac-status-badge--danger'
    case 'cancelled':
      return 'ac-status-badge--muted'
    default:
      return 'ac-status-badge--muted'
  }
}