export const vipProgramOptions = [
    ["legacy_timed", "Lalu 经典VIP"],
    ["tiered_privilege_v1", "Fami P1 VIP"],
];

export const vipProgramLabels = Object.fromEntries(vipProgramOptions);

// 两套体系都按等级保存最终权益快照；隐藏策略不能再回退到 cumulative，否则会重新引入自动继承语义。
export const vipProgramDefaults = {
    legacy_timed: {
        levelCount: 10,
        sameLevelExpiryPolicy: "extend_remaining",
        upgradeExpiryPolicy: "extend_remaining",
        downgradePurchasePolicy: "reject",
        benefitInheritancePolicy: "target_only",
        grantMode: "direct_membership",
        trialCardEnabled: false,
    },
    tiered_privilege_v1: {
        levelCount: 9,
        sameLevelExpiryPolicy: "extend_remaining",
        upgradeExpiryPolicy: "replace_from_now",
        downgradePurchasePolicy: "reject",
        benefitInheritancePolicy: "target_only",
        grantMode: "trial_card",
        trialCardEnabled: true,
    },
};

export const vipUpgradePolicyLabels = {
    extend_remaining: "保留剩余时间并续期",
    replace_from_now: "高等级从购买时重新计时",
};

export const vipGrantModeLabels = {
    direct_membership: "真实VIP",
    trial_card: "VIP体验卡",
};

// 这三项由 room/wallet 按真实资源和 entitlement 执行。后台必须限定目录类型，
// 否则把头像框等任意资源绑定进房间权益后，只会在用户实际应用时才失败。
export const vipBenefitResourceTypes = {
    colored_room_name: "room_name_style",
    mic_skin: "mic_seat_animation",
    room_border: "room_border",
};

// P1 的 34 项权益用于目录展示和兼容服务端契约；unlockLevel 只是历史字段，后台不据此补齐、开启或继承权益。
export const p1BenefitCatalog = [
    benefit("vip_badge_identity", "VIP标识", 1, "function", "user", false),
    benefit("vip_medal", "VIP勋章", 1, "decoration", "user", true),
    benefit("avatar_frame", "VIP头像框", 1, "decoration", "user", true),
    benefit("vip_title", "VIP称号", 1, "function", "user", false),
    benefit("chat_bubble", "VIP聊天气泡", 2, "decoration", "room", true),
    benefit("vip_gift", "VIP礼物", 2, "function", "room", false),
    benefit("entry_effect", "VIP进场通知", 2, "function", "room", false),
    benefit("visitor_history", "查看访客", 2, "function", "user", false),
    benefit("voice_wave", "VIP声波纹", 3, "decoration", "room", true),
    benefit("profile_card", "VIP资料卡皮肤", 3, "decoration", "user", true),
    benefit("custom_room_background", "自定义房间背景", 3, "function", "room", false),
    benefit("room_image_message", "房间发图", 3, "function", "room", false),
    benefit("animated_avatar", "动态头像", 4, "function", "user", false),
    benefit("animated_room_cover", "动态房间封面", 4, "function", "room", false),
    benefit("mic_skin", "麦克风皮肤", 4, "decoration", "room", true),
    benefit("room_border", "房间边框", 4, "decoration", "room", true),
    benefit("vehicle", "VIP座驾", 4, "decoration", "room", true),
    benefit("colored_room_name", "VIP彩色房间名称", 5, "decoration", "room", false),
    benefit("colored_nickname", "VIP彩色昵称", 5, "function", "user", false),
    benefit("colored_id", "VIP彩色ID", 5, "function", "user", false),
    benefit("gift_tray_skin", "送礼托盘皮肤", 5, "function", "room", false),
    benefit("hide_profile_data", "隐藏个人数据", 6, "function", "user", false),
    benefit("custom_avatar_frame", "定制头框", 6, "function", "user", false),
    benefit("leaderboard_invisible", "榜单隐身", 6, "function", "user", false),
    benefit("daily_coin_rebate", "金币返现", 6, "function", "wallet", false, false),
    benefit("custom_profile_card", "定制资料卡", 7, "function", "user", false),
    benefit("anonymous_profile_visit", "匿名访问主页", 7, "function", "user", false),
    benefit("custom_gift", "定制礼物", 7, "function", "room", false),
    benefit("room_entry_notice", "进房高亮通知", 8, "function", "room", false),
    benefit("custom_pretty_id", "定制靓号", 8, "function", "user", false),
    benefit("custom_vehicle", "定制座驾", 8, "function", "room", false),
    benefit("anti_kick", "防踢", 9, "function", "room", false),
    benefit("anti_mute", "防禁言", 9, "function", "room", false),
    benefit("online_global_notice", "上线全服通知", 9, "function", "notice", false),
];

function benefit(benefitCode, name, unlockLevel, benefitType, executionScope, autoEquip, trialEnabled = true) {
    return {
        autoEquip,
        benefitCode,
        benefitType,
        executionScope,
        name,
        trialEnabled,
        unlockLevel,
    };
}
