export const AREA_TYPES = [
  { value: 'Storage', label: '存储区' },
  { value: 'Buffer', label: '缓存区' },
  { value: 'FinishedGoods', label: '成品区' }
]

export const AREA_LAYOUT_MODES = [
  { value: 'Flat', label: '平面' },
  { value: 'Grid', label: '网格' }
]

export const STORAGE_TYPES = [
  { value: 'Storage', label: '普通库位' },
  { value: 'LineSide', label: '线边库' },
  { value: 'OfflinePoint', label: '下线点' },
  { value: 'Buffer', label: '缓存库位' },
  { value: 'FinishedGoods', label: '成品库' }
]

export const LOCATION_KINDS = [
  { value: 'Station', label: '接驳位' },
  { value: 'Grid', label: '网格货位' }
]

export const STORAGE_STATUSES = [
  { value: 'Empty', label: '空货位' },
  { value: 'EmptyContainer', label: '空容器' },
  { value: 'FullContainer', label: '满容器' },
  { value: 'Disabled', label: '停用' }
]

export const STORAGE_STATUS_TYPE: Record<string, 'success' | 'warning' | 'danger' | 'info'> = {
  Empty: 'success',
  EmptyContainer: 'warning',
  FullContainer: 'danger',
  Disabled: 'info'
}

export const CONTAINER_TYPES = [
  { value: 'Box', label: '料箱' },
  { value: 'Pallet', label: '托盘' }
]

export const CONTAINER_STATUSES = [
  { value: 'EmptyMaterial', label: '空物料' },
  { value: 'FullMaterial', label: '有物料' }
]

export const CONTAINER_LOCATION_STATUSES = [
  { value: 'Active', label: '正常' },
  { value: 'Locked', label: '锁定' },
  { value: 'Exception', label: '异常' }
]

export const MATERIAL_UNITS = [
  { value: 'pcs', label: 'pcs' },
  { value: 'kg', label: 'kg' },
  { value: 'box', label: 'box' },
  { value: 'set', label: 'set' }
]

export const MATERIAL_LIFECYCLES = [
  { value: 'Active', label: '在用' },
  { value: 'Archived', label: '已归档' }
]

export const STOCK_EVENT_TYPES = [
  { value: 'Bind', label: '绑定' },
  { value: 'Unbind', label: '解绑' },
  { value: 'ContainerMove', label: '容器移位' }
]

export const TRANSPORT_TRIGGER_LABELS: Record<string, string> = {
  MaterialCall: '呼叫物料',
  FinishedGoodsOffline: '成品下线',
  AutoTransfer: '自动转运'
}

export const TRANSPORT_TASK_STATUS_TYPE: Record<string, 'primary' | 'success' | 'warning' | 'info' | 'danger'> = {
  Pending: 'info',
  Reserved: 'warning',
  Dispatched: 'warning',
  InTransit: 'warning',
  Completed: 'success',
  Failed: 'danger',
  Cancelled: 'info'
}

export function labelOf(options: { value: string; label: string }[], value: string) {
  return options.find((o) => o.value === value)?.label ?? value
}

export function truncate(text: string, max = 24) {
  if (!text) return ''
  return text.length <= max ? text : `${text.slice(0, max)}…`
}
