/**
 * 用户能力权限枚举
 * 借鉴 Stripe Capability 模型，每项能力可独立开关
 */
export enum Capability {
  LOGIN = 'LOGIN',
  TRADING = 'TRADING',
  C2C = 'C2C',
  TRANSFER_IN = 'TRANSFER_IN',
  TRANSFER_OUT = 'TRANSFER_OUT',
  P2P_SEND = 'P2P_SEND',
  P2P_RECEIVE = 'P2P_RECEIVE',
  MINING_CLAIM = 'MINING_CLAIM',
  KYC = 'KYC',
  PROFILE_EDIT = 'PROFILE_EDIT',
  VIEW_ASSET = 'VIEW_ASSET',
  VIEW_TEAM = 'VIEW_TEAM',
  VIEW_RECORDS = 'VIEW_RECORDS',
}

export const ALL_CAPABILITIES = Object.values(Capability);

export type CapabilityMap = Record<Capability, boolean>;

export function defaultCapabilityMap(): CapabilityMap {
  const map = {} as CapabilityMap;
  for (const cap of ALL_CAPABILITIES) {
    map[cap] = true;
  }
  return map;
}

export const CAPABILITY_LABELS: Record<Capability, string> = {
  [Capability.LOGIN]: '登录',
  [Capability.TRADING]: '交易',
  [Capability.C2C]: 'C2C交易',
  [Capability.TRANSFER_IN]: '划入',
  [Capability.TRANSFER_OUT]: '划出',
  [Capability.P2P_SEND]: 'P2P转出',
  [Capability.P2P_RECEIVE]: 'P2P收款',
  [Capability.MINING_CLAIM]: '挖矿领取',
  [Capability.KYC]: '实名认证',
  [Capability.PROFILE_EDIT]: '编辑资料',
  [Capability.VIEW_ASSET]: '查看资产',
  [Capability.VIEW_TEAM]: '查看团队',
  [Capability.VIEW_RECORDS]: '查看记录',
};
