decord/source/modules/premium/gifting/GiftingBadgesUtils.tsx
2026-08-08 06:10:11 +00:00

94 lines
3.5 KiB
TypeScript

// Module ID: 12843
// Function ID: 12844
// Name: getGiftingBadgeProgressPercent
// Dependencies: [8790, 1903, 9578, 12844, 589, 4123, 1358, 2]
// Exports: getGiftingBadgeProgressPercent, getIsGiftingBadgesDesktopEnabled, useIsEligibleToShowGiftingBadgeCoachmark, useIsGiftingBadgesDesktopEnabled
// Module 12843 (getGiftingBadgeProgressPercent)
import { getSingleRequirementThreshold as closure_2 } from "map";
import mergeGuildAvatar from "mergeGuildAvatar";
let result = require("apexExperiment").fileFinishedImporting("modules/premium/gifting/GiftingBadgesUtils.tsx");
export const getGiftingBadgeProgressPercent = function getGiftingBadgeProgressPercent(badgeProgress, currentTier, nextTier) {
const tmp = callback(currentTier);
const tmp2 = callback(nextTier);
if (null != nextTier) {
let num6 = 100;
if (tmp2 > 0) {
num6 = badgeProgress / tmp2 * 100;
}
let num3 = num6;
} else {
num3 = 100;
if (tmp > 0) {
const _Math = Math;
num3 = Math.min(tmp, badgeProgress) / tmp * 100;
}
}
return Math.min(Math.max(num3, 0), 100);
};
export const useIsGiftingBadgesDesktopEnabled = function useIsGiftingBadgesDesktopEnabled(location) {
const GiftingBadgeExperiment = require(9578) /* apexExperiment */.GiftingBadgeExperiment;
let obj = { location };
const enabled = GiftingBadgeExperiment.useConfig(obj).enabled;
const GiftingBadgeDesktopExperiment = require(12844) /* apexExperiment */.GiftingBadgeDesktopExperiment;
let str = "-DISABLED";
if (enabled) {
str = "";
}
obj = { location: "" + location + str };
return GiftingBadgeDesktopExperiment.useConfig(obj).enabled && enabled;
};
export const getIsGiftingBadgesDesktopEnabled = function getIsGiftingBadgesDesktopEnabled(location) {
const GiftingBadgeExperiment = require(9578) /* apexExperiment */.GiftingBadgeExperiment;
let obj = { location };
let enabled = GiftingBadgeExperiment.getConfig(obj).enabled;
if (enabled) {
const GiftingBadgeDesktopExperiment = require(12844) /* apexExperiment */.GiftingBadgeDesktopExperiment;
obj = { location: null };
obj[0] = location;
enabled = GiftingBadgeDesktopExperiment.getConfig(obj).enabled;
}
return enabled;
};
export const useIsEligibleToShowGiftingBadgeCoachmark = function useIsEligibleToShowGiftingBadgeCoachmark(location) {
const _location = location.location;
const GiftingBadgeExperiment = require(9578) /* apexExperiment */.GiftingBadgeExperiment;
const enabled = GiftingBadgeExperiment.useConfig({ location: _location }).enabled;
const GiftingBadgeDesktopExperiment = require(12844) /* apexExperiment */.GiftingBadgeDesktopExperiment;
let str = "-DISABLED";
if ("web" === location.platform) {
str = "";
}
let enabled2 = GiftingBadgeDesktopExperiment.useConfig({ location: "" + _location + str }).enabled;
let tmp4 = enabled;
if ("web" === location.platform) {
if (enabled2) {
enabled2 = enabled;
}
tmp4 = enabled2;
}
let tmpResult = tmp(589);
const items = [mergeGuildAvatar];
const stateFromStores = tmpResult.useStateFromStores(items, () => {
currentUser = currentUser.getCurrentUser();
let flag;
if (currentUser != null) {
flag = currentUser.hasHadPremium();
}
if (flag == null) {
flag = false;
}
return flag;
});
tmpResult = tmp(4123);
const result = tmpResult.useIsDismissibleContentDismissed_UNSAFE(tmp(1358).DismissibleContent.NEW_GIFTING_BADGES_COACHMARK);
if (tmp4) {
tmp4 = stateFromStores;
}
if (tmp4) {
tmp4 = !result;
}
return tmp4;
};