import type { OtherWalletType, WalletType } from '@/stores/transfer'

/** 划转/资产展示用钱包类型文案（与各语言 assets.*Account 对齐） */
export type WalletKind = WalletType | OtherWalletType

/** 后端 WalletType 枚举名 → 前端钱包类型（划转记录 source/target 为枚举名） */
const BACKEND_WALLET_ALIAS: Record<string, WalletKind> = {
  SPOT: 'SPOT',
  SWAP: 'SWAP',
  FOLLOW: 'FOLLOW',
  EXCHANGE: 'SPOT_TRADING',
  SPOT_TRADING: 'SPOT_TRADING',
}

/** 将划转记录中的后端钱包类型转为多语言展示名 */
export function resolveBackendWalletLabel(t: (key: string) => string, raw: string): string {
  const k = BACKEND_WALLET_ALIAS[raw.trim().toUpperCase()]
  return k ? walletTypeLabel(t, k) : raw
}

export function walletTypeLabel(t: (key: string) => string, w: WalletKind): string {
  switch (w) {
    case 'SPOT':
      return t('assets.fundAccount')
    case 'SWAP':
      return t('assets.swapAccount')
    case 'FOLLOW':
      return t('assets.followAccount')
    case 'SPOT_TRADING':
      return t('assets.spotTradingAccount')
    default:
      return String(w)
  }
}
