import type { AccountStatus } from '../types'

/**
 * Map HTTP status code to account status
 */
export function mapHttpStatusToAccountStatus(httpStatus: number): AccountStatus {
  switch (httpStatus) {
    case 200:
      return 'active'
    case 401:
      return 'token_expired'
    case 403:
      return 'banned'
    default:
      return 'error'
  }
}

/**
 * Check if account status allows pooling
 */
export function canPoolAccount(status: AccountStatus): boolean {
  return status === 'active'
}

/**
 * Get status display text
 */
export function getStatusDisplayText(status: AccountStatus): string {
  const statusMap: Record<AccountStatus, string> = {
    pending: '待检查',
    checking: '检查中',
    active: '正常',
    banned: '封禁',
    token_expired: '过期',
    error: '错误',
  }
  return statusMap[status] || '未知'
}

/**
 * Get status color class
 */
export function getStatusColorClass(status: AccountStatus): string {
  const colorMap: Record<AccountStatus, string> = {
    pending: 'text-slate-500',
    checking: 'text-blue-500',
    active: 'text-green-500',
    banned: 'text-red-500',
    token_expired: 'text-orange-500',
    error: 'text-yellow-500',
  }
  return colorMap[status] || 'text-slate-500'
}
