// Metro module 9484 (f9485). import CollectiblesCategoryStore from "../../collectibles/CollectiblesCategoryStore"; import { QuestRewardExpirationMode } from "../../../_bundle/Module9485"; import { QuestRewardTypes } from "../../../_bundle/Module5990"; import { getQuestFormattedDate } from "./QuestDataUtils"; import { differenceInDays } from "../../../_bundle/Module3414"; import { intl, t } from "../../../intl/index.native"; import { getQuestOrbMultiplierEligibilityForUser } from "../hooks/QuestOrbMultiplierHooks"; import { shouldReceiveQuestOrbMultiplier } from "./QuestOrbMultiplierUtils"; import { getFractionalPremiumQuestRewardName } from "../lib/FractionalPremiumUtils"; import { getDefaultReward } from "./QuestCopyUtils"; import { QuestRewardAssignmentMethods } from "../../../_bundle/Module9490"; import { QuestRewardCodePlatforms } from "../QuestTypes"; let c6254_3, $mk82585 = function() { return (a0) => a0.type === QuestRewardTypes.COLLECTIBLE; }, $mk82586 = function() { return (a0) => a0.type === QuestRewardTypes.FRACTIONAL_PREMIUM; }, $mk82587 = function() { return (a0) => a0.type === QuestRewardTypes.VIRTUAL_CURRENCY; }, $mk82588 = function() { return (a0) => a0.type === QuestRewardTypes.VIRTUAL_CURRENCY; }, $mk82589 = function() { return (a0) => a0.type === QuestRewardTypes.VIRTUAL_CURRENCY; }, $mk82590 = function() { return (a0) => a0.type === QuestRewardTypes.VIRTUAL_CURRENCY; }, $mk82591 = function() { return (a0) => a0.type === QuestRewardTypes.VIRTUAL_CURRENCY; }; const _getDefaultRewardName = function _getDefaultRewardName(a0, a1, a2) { let r52; if (a0.rewardsConfig.rewards.some($mk82586())) { return getFractionalPremiumQuestRewardName(a0); } if (a0.rewardsConfig.rewards.some($mk82587())) { const r34 = a0.rewardsConfig.rewards.find($mk82591()); const r36 = r34 == null; let orbAmount = null; if (!r36) { if (a1 == null) { orbAmount = r34.orbQuantity; } else { const questOrbMultiplierEligibilityForUser = getQuestOrbMultiplierEligibilityForUser(a1); const premiumOrbQuantity = a0.rewardsConfig.rewards.find($mk82588())?.premiumOrbQuantity; if (premiumOrbQuantity != null && premiumOrbQuantity > 0 && shouldReceiveQuestOrbMultiplier(questOrbMultiplierEligibilityForUser)) { let premiumOrbQuantity2 = r34.premiumOrbQuantity; if (premiumOrbQuantity2 == null) { premiumOrbQuantity2 = r34.orbQuantity; } r52 = premiumOrbQuantity2; } else { r52 = r34.orbQuantity; } orbAmount = r52; } } if (orbAmount == null) { orbAmount = a0.rewardsConfig.rewards.find($mk82589())?.orbQuantity; } if (orbAmount == null) { orbAmount = 0; } return intl.formatToPlainString(t["nLXlh+"], { orbAmount }); } const messages = getDefaultReward(a0).messages; return a2 ? messages.nameWithArticle : messages.name; }; c6254_3 = new Set([QuestRewardExpirationMode.PREMIUM_EXTENSION, QuestRewardExpirationMode.PREMIUM_PERMANENT]); export function getCollectiblesQuestReward(a0) { const r9 = a0.rewardsConfig.rewards.find($mk82585()); return r9?.type === QuestRewardTypes.COLLECTIBLE ? r9 : null; } export function getCollectibleQuestRewardExtendableExpirationDate(a0) { const r11 = a0.rewardsConfig.rewards.find($mk82585()); const r17 = r11?.type === QuestRewardTypes.COLLECTIBLE ? r11 : null; return r17 != null ? "expiresAtPremium" in r17 ? r17.expiresAtPremium != null ? getQuestFormattedDate(r17.expiresAtPremium) : null : null : null; } export function getCollectibleQuestRewardDuration(a0) { const r20 = a0.rewardsConfig.rewards.find($mk82585()); const r26 = r20?.type === QuestRewardTypes.COLLECTIBLE ? r20 : null; if (r26 != null && "expiresAt" in r26 && r26.expiresAt != null) { const date = new Date(a0.expiresAt); const date2 = new Date(r26.expiresAt); const r43 = differenceInDays(date2, date); const months = Math.floor(r43 / 30) + (25 <= r43 % 30 ? 1 : 0); if (months >= 12) { return intl.formatToPlainString(t.PClsrw, { years: Math.floor(months / 12) }); } if (months > 0) { return intl.formatToPlainString(t.kridzK, { months }); } const days = differenceInDays(date2, date); if (days >= 7) { return intl.formatToPlainString(t.EmoBD2, { weeks: Math.ceil(days / 7) }); } return intl.formatToPlainString(t["k2UNz+"], { days }); } return null; } export function hasFractionalPremiumQuestReward(a0) { return a0.rewardsConfig.rewards.some($mk82586()); } export function hasVirtualCurrencyReward(a0) { return a0.rewardsConfig.rewards.some($mk82587()); } export function hasPremiumOrbQuantity(a0) { const premiumOrbQuantity = a0.rewardsConfig.rewards.find($mk82588())?.premiumOrbQuantity; return premiumOrbQuantity != null && premiumOrbQuantity > 0; } export function hasCollectiblesQuestReward(a0) { const r9 = a0.rewardsConfig.rewards.find($mk82585()); return (r9?.type === QuestRewardTypes.COLLECTIBLE ? r9 : null) != null; } export function hasInGameQuestReward(a0) { return a0.rewardsConfig.rewards.some((reward) => reward.type === QuestRewardTypes.IN_GAME); } export function hasQuestRewardCode(a0) { return a0.rewardsConfig.rewards.some((reward) => reward.type === QuestRewardTypes.REWARD_CODE); } export function getInGameQuestReward(a0) { let r7 = a0.rewardsConfig.rewards.find((reward) => reward.type === QuestRewardTypes.IN_GAME); if (r7 == null) { r7 = null; } return r7; } export function getCollectiblesQuestRewardItem(a0) { const r10 = a0.rewardsConfig.rewards.find($mk82585()); const product = CollectiblesCategoryStore.getProduct((r10?.type === QuestRewardTypes.COLLECTIBLE ? r10 : null)?.skuId); const r23 = product == null; let r24 = void 0; if (!r23) { const items = product.items; r24 = items == null ? void 0 : items[0]; } if (r24 == null) { r24 = null; } return r24; } export function getVirtualCurrencyRewardOrbQuantity(a0) { return a0.rewardsConfig.rewards.find($mk82589())?.orbQuantity; } export function getVirtualCurrencyRewardPremiumOrbQuantity(a0) { const r8 = a0.rewardsConfig.rewards.find((reward) => reward.type === QuestRewardTypes.VIRTUAL_CURRENCY); if (r8?.type === QuestRewardTypes.VIRTUAL_CURRENCY) { return r8.premiumOrbQuantity; } } export function isCollectibleQuestRewardPremiumExtendable(a0) { const r10 = a0.rewardsConfig.rewards.find($mk82585()); const expirationMode = (r10?.type === QuestRewardTypes.COLLECTIBLE ? r10 : null)?.expirationMode; return expirationMode != null && c6254_3.has(expirationMode); } export function isCollectibleQuestRewardPermanentWithPremiumSubscription(a0) { const r8 = a0.rewardsConfig.rewards.find($mk82585()); const expirationMode = (r8?.type === QuestRewardTypes.COLLECTIBLE ? r8 : null)?.expirationMode; let r20 = expirationMode != null && c6254_3.has(expirationMode); if (r20) { const r27 = a0.rewardsConfig.rewards.find($mk82585()); r20 = (r27?.type === QuestRewardTypes.COLLECTIBLE ? r27 : null)?.expirationMode === QuestRewardExpirationMode.PREMIUM_PERMANENT; } return r20; } export function getQuestPrimaryReward(a0) { let r5 = a0.userStatus?.claimedTier; if (r5 == null) { r5 = 0; } const r8 = "rewardsConfig" in a0.config; const config = a0.config; return r8 ? config.rewardsConfig.rewards[r5] : config.rewards[r5]; } export function getQuestOrbMultiplier(a0) { const r11 = a0.rewardsConfig.rewards.find($mk82590()); if (r11?.type !== QuestRewardTypes.VIRTUAL_CURRENCY) { return null; } const { premiumOrbQuantity, orbQuantity } = r11; return premiumOrbQuantity == null ? null : orbQuantity !== 0 ? Math.round(premiumOrbQuantity / orbQuantity * 100) / 100 : null; } export function getQuestOrbMultiplierForUser(a0, a1) { if (a1 == null) { return 1; } const r17 = a0.rewardsConfig.rewards.find($mk82590()); const type = r17?.type; const VIRTUAL_CURRENCY = QuestRewardTypes.VIRTUAL_CURRENCY; let r23 = null; if (type === VIRTUAL_CURRENCY) { const { premiumOrbQuantity, orbQuantity } = r17; r23 = premiumOrbQuantity == null ? null : orbQuantity !== 0 ? Math.round(premiumOrbQuantity / orbQuantity * 100) / 100 : null; } if (r23 == null) { r23 = 1; } const questOrbMultiplierEligibilityForUser = getQuestOrbMultiplierEligibilityForUser(a1); const premiumOrbQuantity2 = a0.rewardsConfig.rewards.find($mk82588())?.premiumOrbQuantity; return premiumOrbQuantity2 != null && premiumOrbQuantity2 > 0 ? shouldReceiveQuestOrbMultiplier(questOrbMultiplierEligibilityForUser) ? r23 : 1 : 1; } export function getQuestOrbRewardQuantityForUser(a0, a1) { let r30; const r14 = a0.rewardsConfig.rewards.find($mk82591()); if (r14 == null) { return null; } if (a1 == null) { return r14.orbQuantity; } const questOrbMultiplierEligibilityForUser = getQuestOrbMultiplierEligibilityForUser(a1); const premiumOrbQuantity = a0.rewardsConfig.rewards.find($mk82588())?.premiumOrbQuantity; if (premiumOrbQuantity != null && premiumOrbQuantity > 0 && shouldReceiveQuestOrbMultiplier(questOrbMultiplierEligibilityForUser)) { let premiumOrbQuantity2 = r14.premiumOrbQuantity; if (premiumOrbQuantity2 == null) { premiumOrbQuantity2 = r14.orbQuantity; } r30 = premiumOrbQuantity2; } else { r30 = r14.orbQuantity; } return r30; } export function getDefaultRewardName(a0, a1) { return _getDefaultRewardName(a0, a1, false); } export function getDefaultRewardNameWithArticle(a0, a1) { return _getDefaultRewardName(a0, a1, true); } export function getRewardCodeQuestReward({ quest, idx }) { if (idx == null) { return null; } const r10 = quest.config.rewardsConfig.rewards[idx]; return r10.type === QuestRewardTypes.REWARD_CODE ? r10 : null; } export function isTieredRewardCodeQuest(a0) { const rewardsConfig = a0.quest.config.rewardsConfig; return rewardsConfig.assignmentMethod === QuestRewardAssignmentMethods.TIERED && rewardsConfig.rewards.length > 0 && rewardsConfig.rewards.every((reward) => reward.type === QuestRewardTypes.REWARD_CODE); } export function getDefaultPlatform(a0) { const platforms = a0.rewardsConfig.platforms; return platforms.length > 0 ? platforms[0] : QuestRewardCodePlatforms.CROSS_PLATFORM; } export function getPlatformString(a0) { if (QuestRewardCodePlatforms.XBOX === a0) { return intl.string(t.G84UWZ); } if (QuestRewardCodePlatforms.PLAYSTATION === a0) { return intl.string(t["6IeKx2"]); } if (QuestRewardCodePlatforms.SWITCH === a0) { return intl.string(t["1pp0su"]); } if (QuestRewardCodePlatforms.PC === a0) { return intl.string(t["YK+wUg"]); } if (QuestRewardCodePlatforms.CROSS_PLATFORM === a0) { return intl.string(t.UWVbzV); } }