/**
 * IoT卡相关常量配置
 */

// IoT卡导入任务状态枚举
export enum IotCardImportTaskStatus {
  PENDING = 1, // 待处理
  PROCESSING = 2, // 处理中
  COMPLETED = 3, // 已完成
  FAILED = 4 // 失败
}

// IoT卡导入任务状态选项
export const IOT_CARD_IMPORT_TASK_STATUS_OPTIONS = [
  {
    label: '待处理',
    value: IotCardImportTaskStatus.PENDING,
    type: 'info' as const,
    color: '#909399'
  },
  {
    label: '处理中',
    value: IotCardImportTaskStatus.PROCESSING,
    type: 'warning' as const,
    color: '#E6A23C'
  },
  {
    label: '已完成',
    value: IotCardImportTaskStatus.COMPLETED,
    type: 'success' as const,
    color: '#67C23A'
  },
  {
    label: '失败',
    value: IotCardImportTaskStatus.FAILED,
    type: 'danger' as const,
    color: '#F56C6C'
  }
]

// IoT卡导入任务状态映射
export const IOT_CARD_IMPORT_TASK_STATUS_MAP = IOT_CARD_IMPORT_TASK_STATUS_OPTIONS.reduce(
  (map, item) => {
    map[item.value] = item
    return map
  },
  {} as Record<
    IotCardImportTaskStatus,
    {
      label: string
      value: IotCardImportTaskStatus
      type: 'info' | 'warning' | 'success' | 'danger'
      color: string
    }
  >
)

// 获取IoT卡导入任务状态标签
export function getIotCardImportTaskStatusLabel(status: number): string {
  return IOT_CARD_IMPORT_TASK_STATUS_MAP[status as IotCardImportTaskStatus]?.label || '未知'
}

// 获取IoT卡导入任务状态类型（用于 ElTag）
export function getIotCardImportTaskStatusType(status: number) {
  return IOT_CARD_IMPORT_TASK_STATUS_MAP[status as IotCardImportTaskStatus]?.type || 'info'
}

// 获取IoT卡导入任务状态颜色
export function getIotCardImportTaskStatusColor(status: number): string {
  return IOT_CARD_IMPORT_TASK_STATUS_MAP[status as IotCardImportTaskStatus]?.color || '#909399'
}

// ========== 单卡状态相关 ==========

// 单卡状态枚举
export enum StandaloneCardStatus {
  IN_STOCK = 1, // 在库
  DISTRIBUTED = 2, // 已分销
  ACTIVATED = 3, // 已激活
  DEACTIVATED = 4 // 已停用
}

// 单卡状态选项
export const STANDALONE_CARD_STATUS_OPTIONS = [
  {
    label: '在库',
    value: StandaloneCardStatus.IN_STOCK,
    type: 'info' as const,
    color: '#909399'
  },
  {
    label: '已分销',
    value: StandaloneCardStatus.DISTRIBUTED,
    type: 'warning' as const,
    color: '#E6A23C'
  },
  {
    label: '已激活',
    value: StandaloneCardStatus.ACTIVATED,
    type: 'success' as const,
    color: '#67C23A'
  },
  {
    label: '已停用',
    value: StandaloneCardStatus.DEACTIVATED,
    type: 'danger' as const,
    color: '#F56C6C'
  }
]

// 单卡状态映射
export const STANDALONE_CARD_STATUS_MAP = STANDALONE_CARD_STATUS_OPTIONS.reduce(
  (map, item) => {
    map[item.value] = item
    return map
  },
  {} as Record<
    StandaloneCardStatus,
    {
      label: string
      value: StandaloneCardStatus
      type: 'info' | 'warning' | 'success' | 'danger'
      color: string
    }
  >
)

// 获取单卡状态标签
export function getStandaloneCardStatusLabel(status: number): string {
  return STANDALONE_CARD_STATUS_MAP[status as StandaloneCardStatus]?.label || '未知'
}

// 获取单卡状态类型（用于 ElTag）
export function getStandaloneCardStatusType(status: number) {
  return STANDALONE_CARD_STATUS_MAP[status as StandaloneCardStatus]?.type || 'info'
}

// 获取单卡状态颜色
export function getStandaloneCardStatusColor(status: number): string {
  return STANDALONE_CARD_STATUS_MAP[status as StandaloneCardStatus]?.color || '#909399'
}
