export enum FundAllocationTargetType {
  COST_ACCOUNT = 'COST_ACCOUNT', // 2800 USDT - 成本账户
  OPERATION_ACCOUNT = 'OPERATION_ACCOUNT', // 2100 USDT - 运营账户
  HEADQUARTERS_COMMUNITY = 'HEADQUARTERS_COMMUNITY', // 203 USDT - 总部社区
  REFERRAL_RIGHTS = 'REFERRAL_RIGHTS', // 3600 USDT - 分享权益
  PROVINCE_AREA_RIGHTS = 'PROVINCE_AREA_RIGHTS', // 108 USDT - 省区域权益
  PROVINCE_TEAM_RIGHTS = 'PROVINCE_TEAM_RIGHTS', // 144 USDT - 省团队权益
  CITY_AREA_RIGHTS = 'CITY_AREA_RIGHTS', // 252 USDT - 市区域权益
  CITY_TEAM_RIGHTS = 'CITY_TEAM_RIGHTS', // 288 USDT - 市团队权益
  COMMUNITY_RIGHTS = 'COMMUNITY_RIGHTS', // 576 USDT - 社区权益
  RWAD_POOL = 'RWAD_POOL', // 5760 USDT - RWAD底池
  // [2026-02-26] 新增：总部运营成本压力涨价，加价部分全额归总部 (S0000000001)
  // 金额动态（由 admin-service TreePricingConfig 配置），不计入 FUND_ALLOCATION_AMOUNTS
  HQ_PRICE_SUPPLEMENT = 'HQ_PRICE_SUPPLEMENT',
}

// 基础 10 类分配类型（不含动态加价 HQ_PRICE_SUPPLEMENT）
type BaseAllocationTargetType = Exclude<FundAllocationTargetType, FundAllocationTargetType.HQ_PRICE_SUPPLEMENT>;

// 每棵树的资金分配规则 (总计 15831 USDT，不含涨价补充)
export const FUND_ALLOCATION_AMOUNTS: Record<BaseAllocationTargetType, number> =
  {
    [FundAllocationTargetType.COST_ACCOUNT]: 2800,
    [FundAllocationTargetType.OPERATION_ACCOUNT]: 2100,
    [FundAllocationTargetType.HEADQUARTERS_COMMUNITY]: 203,
    [FundAllocationTargetType.REFERRAL_RIGHTS]: 3600,
    [FundAllocationTargetType.PROVINCE_AREA_RIGHTS]: 108,
    [FundAllocationTargetType.PROVINCE_TEAM_RIGHTS]: 144,
    [FundAllocationTargetType.CITY_AREA_RIGHTS]: 252,
    [FundAllocationTargetType.CITY_TEAM_RIGHTS]: 288,
    [FundAllocationTargetType.COMMUNITY_RIGHTS]: 576,
    [FundAllocationTargetType.RWAD_POOL]: 5760,
  };

// 每棵树价格
export const PRICE_PER_TREE = 15831;

// 验证总额
const TOTAL = Object.values(FUND_ALLOCATION_AMOUNTS).reduce((a, b) => a + b, 0);
if (TOTAL !== PRICE_PER_TREE) {
  throw new Error(`资金分配配置错误: 总额 ${TOTAL} != ${PRICE_PER_TREE}`);
}
