Files
discord-decomp/sources/modules/collectibles/CollectiblesUtils.tsx
T
2026-07-28 01:06:53 +03:00

749 lines
40 KiB
TypeScript

/* Metro module 5134; source: modules/collectibles/CollectiblesUtils.tsx; dependencies: [5126, 1902, 5127, 5128, 5135, 663, 661, 482, 3802, 1893, 1895, 5136, 5137, 477, 1904, 22, 1244, 5133, 2] */
import PremiumUtils from '../../utils/PremiumUtils.tsx'; /* Metro dependency 3802 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as Module00022Module from '../../by-id/module-00022.js'; /* Metro dependency 22 */
import * as ConstantsModule from '../../external/discord_common/js/shared/Constants.tsx'; /* Metro dependency 482 */
import * as CollectiblesShopConstantsModule from './CollectiblesShopConstants.tsx'; /* Metro dependency 663 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as NameplateRecordModule from './records/NameplateRecord.tsx'; /* Metro dependency 1902 */
import * as CollectiblesItemTypeModule from '../../external/discord_common/js/shared/shared-constants/CollectiblesItemType.tsx'; /* Metro dependency 1904 */
import * as AvatarDecorationRecordModule from './records/AvatarDecorationRecord.tsx'; /* Metro dependency 5126 */
import * as ProfileEffectRecordModule from './records/ProfileEffectRecord.tsx'; /* Metro dependency 5127 */
import * as ProfileFrameRecordModule from './records/ProfileFrameRecord.tsx'; /* Metro dependency 5128 */
import * as ShopAssetConfigRecordModule from './records/ShopAssetConfigRecord.tsx'; /* Metro dependency 5135 */
function _fun45193(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#45193, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:6, offset: 0x0118408a, size: 1078 bytes, params: 8, frame: 38
let env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = CollectiblesShopConstantsModule;
const env0_8 = value.EXTERNAL_PRODUCT_SKU_IDS;
const env0_9 = value.LIMITED_TIME_BADGE_DAYS_THRESHOLD;
const env0_10 = value.SHOP_CARD_PER_PRODUCT_NEW_BADGE_EXPIRY_SETTINGS;
value = require(661) /* metro dependency 661: Constants */;
const env0_11 = value.COLLECTIBLES_APPLICATION_ID;
const env0_12 = value.EntitlementTypes;
const env0_13 = value.PriceSetAssignmentPurchaseTypes;
const CurrencyCodes = (ConstantsModule).CurrencyCodes;
object = {NITRO: 'nitro', THIRDPARTY: 'thirdparty'};
const object2 = {};
const NITRO = object.NITRO;
object2[NITRO] = 'nitro';
const THIRDPARTY = object.THIRDPARTY;
object2[THIRDPARTY] = 'xbox';
const closure = function(a0, a1, a2) {
return extractPriceByPurchaseTypes(a0,
a2 ? a1 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a1 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT);
};
const closure2 = function(a0) {
return require(dependencyMap[13]).isAndroid() || require(dependencyMap[13]).isIOS() ? a0 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.MOBILE : a0 ? PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.DEFAULT;
};
const closure3 = function({bundledProducts}) {
if (bundledProducts == null) {
return 0;
}
var env0_0 = getDefaultPriceSetAssignmentPurchaseType(false);
return bundledProducts.reduce(_fun45197, 0);
};
const closure4 = function(a0, a1) {
var property = a0.prices[a1];
var value = null;
var r1 = value != property ? property : value;
return value != r1 ? value == r1.countryPrices || value == r1.countryPrices.prices ? undefined : r1.countryPrices.prices[0] : value;
};
const closure5 = function(a0) {
return a0.reduce(_fun45200, []);
};
const getProductsFromCategories2 = getProductsFromCategories;
const getItemRecordsFromPurchases2 = getItemRecordsFromPurchases;
const getItemRecordsFromCategories2 = getItemRecordsFromCategories;
const closure9 = function(a0) {
var getItemRecordsFromPurchasesBinding = getItemRecordsFromPurchases;
var AVATAR_DECORATION = require(dependencyMap[14]).CollectiblesItemType.AVATAR_DECORATION;
return getItemRecordsFromPurchasesBinding(a0, AVATAR_DECORATION);
};
const closure10 = function(a0) {
var getItemRecordsFromCategoriesBinding = getItemRecordsFromCategories;
var AVATAR_DECORATION = require(dependencyMap[14]).CollectiblesItemType.AVATAR_DECORATION;
return getItemRecordsFromCategoriesBinding(a0, AVATAR_DECORATION);
};
const closure11 = function(a0) {
var getItemRecordsFromPurchasesBinding = getItemRecordsFromPurchases;
var NAMEPLATE = require(dependencyMap[14]).CollectiblesItemType.NAMEPLATE;
return getItemRecordsFromPurchasesBinding(a0, NAMEPLATE);
};
const closure12 = function(a0) {
var getItemRecordsFromCategoriesBinding = getItemRecordsFromCategories;
var NAMEPLATE = require(dependencyMap[14]).CollectiblesItemType.NAMEPLATE;
return getItemRecordsFromCategoriesBinding(a0, NAMEPLATE);
};
const closure13 = function(a0) {
var getItemRecordsFromPurchasesBinding = getItemRecordsFromPurchases;
var PROFILE_EFFECT = require(dependencyMap[14]).CollectiblesItemType.PROFILE_EFFECT;
return getItemRecordsFromPurchasesBinding(a0, PROFILE_EFFECT);
};
const closure14 = function(a0) {
var getItemRecordsFromCategoriesBinding = getItemRecordsFromCategories;
var PROFILE_EFFECT = require(dependencyMap[14]).CollectiblesItemType.PROFILE_EFFECT;
return getItemRecordsFromCategoriesBinding(a0, PROFILE_EFFECT);
};
const closure15 = function(a0) {
var getItemRecordsFromPurchasesBinding = getItemRecordsFromPurchases;
var PROFILE_FRAME = require(dependencyMap[14]).CollectiblesItemType.PROFILE_FRAME;
return getItemRecordsFromPurchasesBinding(a0, PROFILE_FRAME);
};
const closure16 = function(a0) {
var getItemRecordsFromCategoriesBinding = getItemRecordsFromCategories;
var PROFILE_FRAME = require(dependencyMap[14]).CollectiblesItemType.PROFILE_FRAME;
return getItemRecordsFromCategoriesBinding(a0, PROFILE_FRAME);
};
const getDaysRemaining2 = getDaysRemaining;
const closure18 = function(a0) {
return a0?.type === require(dependencyMap[14]).CollectiblesItemType.BUNDLE;
};
const KZT = CurrencyCodes.KZT;
const items2 = [KZT];
const NGN = CurrencyCodes.NGN;
items2[1] = NGN;
const EGP = CurrencyCodes.EGP;
items2[2] = EGP;
(FileImportTrackerModule).fileFinishedImporting('modules/collectibles/CollectiblesUtils.tsx');
exports.ShopDiscountSource = object;
exports.getAnalyticsShopDiscountSource = getAnalyticsShopDiscountSource;
exports.getShopDiscountSource = getShopDiscountSource;
exports.isPremiumCollectiblesProduct = function(a0) {
return a0?.premiumType != null;
};
exports.isPremiumCollectiblesPurchase = isPremiumCollectiblesPurchase;
exports.getAssetForAvatarDecorationProduct = getAssetForAvatarDecorationProduct;
exports.getPriceForCollectiblesProduct = closure;
exports.getFormattedPriceForCollectiblesProduct = getFormattedPriceForCollectiblesProduct;
exports.getDefaultPriceSetAssignmentPurchaseType = closure2;
exports.getBundleItemsPriceSum = closure3;
exports.extractPriceByPurchaseTypes = closure4;
exports.NoDiscount = {'original': -1, 'discountPercentage': -1};
exports.getProductDiscount = getProductDiscount;
exports.getCollectiblesProductPriceComparisons = getCollectiblesProductPriceComparisons;
exports.isFreeCollectiblesProduct = isFreeCollectiblesProduct;
exports.extendVariantsProducts = closure5;
exports.getProductsFromCategories = getProductsFromCategories2;
exports.getItemRecordsFromPurchases = getItemRecordsFromPurchases2;
exports.getItemRecordsFromCategories = getItemRecordsFromCategories2;
exports.getCollectibleTypeLabel = getCollectibleTypeLabel;
exports.getAssetDisplayConfig = getAssetDisplayConfig;
exports.getAvatarDecorationsFromPurchases = closure9;
exports.getAvatarDecorationsFromCategories = closure10;
exports.getAvatarDecorations = function(a0, a1) {
var moduleValue = require(dependencyMap[15]);
var value2 = getAvatarDecorationsFromPurchases(a0);
var items = [];
arraySpread(items, getAvatarDecorationsFromCategories(a1), arraySpread(items, value2, 0, undefined), undefined);
return moduleValue.uniqBy(items, 'skuId');
};
exports.getNameplatesFromPurchases = closure11;
exports.getNameplatesFromCategories = closure12;
exports.getNameplates = function(a0, a1) {
var moduleValue = require(dependencyMap[15]);
var value2 = getNameplatesFromPurchases(a0);
var items = [];
arraySpread(items, getNameplatesFromCategories(a1), arraySpread(items, value2, 0, undefined), undefined);
return moduleValue.uniqBy(items, 'skuId');
};
exports.getProfileEffectsFromPurchases = closure13;
exports.getProfileEffectsFromCategories = closure14;
exports.getProfileEffects = function(a0, a1) {
var moduleValue = require(dependencyMap[15]);
var value2 = getProfileEffectsFromPurchases(a0);
var items = [];
arraySpread(items, getProfileEffectsFromCategories(a1), arraySpread(items, value2, 0, undefined), undefined);
return moduleValue.uniqBy(items, 'skuId');
};
exports.groupProfileEffects = groupProfileEffects;
exports.getProfileFramesFromPurchases = closure15;
exports.getProfileFramesFromCategories = closure16;
exports.getProfileFrames = function(a0, a1) {
var moduleValue = require(dependencyMap[15]);
var value2 = getProfileFramesFromPurchases(a0);
var items = [];
arraySpread(items, getProfileFramesFromCategories(a1), arraySpread(items, value2, 0, undefined), undefined);
return moduleValue.uniqBy(items, 'skuId');
};
exports.isCollectiblesGiftCode = function({applicationId}) {
return applicationId === COLLECTIBLES_APPLICATION_ID;
};
exports.LOGO_ASPECT_RATIO = 3.8;
exports.getLogoSize = function(a0) {
return 3.8 * a0;
};
exports.getDaysRemaining = getDaysRemaining2;
exports.shouldShowLimitedTimeBadge = shouldShowLimitedTimeBadge;
exports.isProductNew = isProductNew;
exports.isBundleProduct = closure18;
exports.getCollectiblesItemTypeForDisplay = getCollectiblesItemTypeForDisplay;
exports.getCollectiblesPrice = getCollectiblesPrice;
exports.shouldHideGiftingForCurrency = shouldHideGiftingForCurrency;
exports.getStrikeThroughPriceAmountForCollectiblesProduct = getStrikeThroughPriceAmountForCollectiblesProduct;
exports.canActionOnProduct = canActionOnProduct;
exports.getProductTypeNameForLogging = getProductTypeNameForLogging;
exports.sortProductsByPrice = function(a0, a1, a2) {
var env0_0 = a1;
var env0_1 = a2;
return a0.sort(_fun45244);
};
exports.sortProductsByUserDiscounts = function(a0, a1) {
if (a1.length === 0) {
return a0;
}
if (a0.length === 0) {
return a0;
}
var env0_0 = a1.map(_fun45246);
return a0.sort(_fun45247);
};
exports.removeRewardProductsFilter = function(a0) {
return a0.filter(_fun45251);
};
function getBundleItemsPriceSum({bundledProducts}) { // fn#45196, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:954, offset: 0x01184580, size: 62 bytes, params: 2, frame: 14
if (bundledProducts == null) {
return 0;
}
const env0_0 = getDefaultPriceSetAssignmentPurchaseType(false);
return bundledProducts.reduce(_fun45197, 0);
function _fun45197(a0, a1) { // fn#45197, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:1070, offset: 0x011845be, size: 61 bytes, params: 3, frame: 13
let value = environment.__proto__;
const extractPriceByPurchaseTypesBinding = extractPriceByPurchaseTypes;
value = undefined;
const value2 = extractPriceByPurchaseTypesBinding(a1, env0_0);
return a0 + ((value2 == null ? value : value2.amount) ?? 0);
}
}
function extendVariantsProducts(a0) { // fn#45199, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:1389, offset: 0x0118464b, size: 28 bytes, params: 2, frame: 13
return a0.reduce(_fun45200, []);
function _fun45200(a0, a1) { // fn#45200, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:1402, offset: 0x01184667, size: 143 bytes, params: 3, frame: 18
var environment;
var r0;
var type;
var value2;
var variants;
var moduleValue;
var concat;
let value = a0;
const env0_0 = a1;
if (a1 == null) {
value.push(a1);
r0 = value;
} else {
type = a1.type;
value2 = environment.__proto__;
if (type !== (require(1904) /* metro dependency 1904: CollectiblesItemType */).CollectiblesItemType.VARIANTS_GROUP) {
value.push(a1);
r0 = value;
} else {
variants = a1.variants;
if (variants != null) {
moduleValue = require(22) /* metro dependency 22 */;
concat = moduleValue.concat;
variants = a1.variants;
value = Reflect.apply(concat, moduleValue, [value, variants.map(function(a0) {
var r3;
var object = {};
copyDataProperties(object, a0, r3);
object['variantGroupStoreListingId'] = require.storeListingId;
object['eligibleOffers'] = require.eligibleOffers;
return object;
})]);
r0 = value;
} else {
value.push(a1);
r0 = value;
}
}
}
return r0;
}
}
function getProductsFromCategories(a0, a1) { // fn#45202, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:1660, offset: 0x01184729, size: 111 bytes, params: 3, frame: 20
const flatMap = Module00022Module.flatMap;
const value2 = a0.values();
const items2 = [];
arraySpread(items2, value2, 0, undefined);
const value3 = Reflect.apply(flatMap, Module00022Module, [items2, 'products']);
return Module00022Module.uniqBy(a1 ? extendVariantsProducts(value3) : value3, 'storeListingId');
}
function getItemRecordsFromPurchases(a0, a1) { // fn#45203, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:1819, offset: 0x01184798, size: 557 bytes, params: 3, frame: 21
var moduleValue;
var flatMap;
var value2;
var items2;
var value3;
var moduleValue3;
var value4;
var value5;
var moduleValue5;
var value6;
var value7;
var moduleValue7;
var value8;
var value9;
const CollectiblesItemType = (CollectiblesItemTypeModule).CollectiblesItemType;
const AVATAR_DECORATION = CollectiblesItemType.AVATAR_DECORATION;
if (a1 === AVATAR_DECORATION) {
moduleValue7 = require(22) /* metro dependency 22 */;
flatMap = moduleValue7.flatMap;
value8 = a0.values();
items2 = [];
arraySpread(items2, value8, 0, undefined);
value9 = Reflect.apply(flatMap, moduleValue7, [items2, 'items']);
return (require(22) /* metro dependency 22 */).uniqBy(value9.filter(isAvatarDecorationRecord), 'skuId');
}
const NAMEPLATE = CollectiblesItemType.NAMEPLATE;
if (a1 === NAMEPLATE) {
moduleValue5 = require(22) /* metro dependency 22 */;
flatMap = moduleValue5.flatMap;
value6 = a0.values();
items2 = [];
arraySpread(items2, value6, 0, undefined);
value7 = Reflect.apply(flatMap, moduleValue5, [items2, 'items']);
return (require(22) /* metro dependency 22 */).uniqBy(value7.filter(isNameplateRecord), 'skuId');
}
const PROFILE_EFFECT = CollectiblesItemType.PROFILE_EFFECT;
if (a1 === PROFILE_EFFECT) {
moduleValue3 = require(22) /* metro dependency 22 */;
flatMap = moduleValue3.flatMap;
value4 = a0.values();
items2 = [];
arraySpread(items2, value4, 0, undefined);
value5 = Reflect.apply(flatMap, moduleValue3, [items2, 'items']);
return (require(22) /* metro dependency 22 */).uniqBy(value5.filter(isProfileEffectRecord), 'skuId');
}
const PROFILE_FRAME = CollectiblesItemType.PROFILE_FRAME;
if (a1 === PROFILE_FRAME) {
moduleValue = require(22) /* metro dependency 22 */;
flatMap = moduleValue.flatMap;
value2 = a0.values();
items2 = [];
arraySpread(items2, value2, 0, undefined);
value3 = Reflect.apply(flatMap, moduleValue, [items2, 'items']);
return (require(22) /* metro dependency 22 */).uniqBy(value3.filter(isProfileFrameRecord), 'skuId');
}
return [];
}
function getItemRecordsFromCategories(a0, a1) { // fn#45204, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:2443, offset: 0x011849c5, size: 478 bytes, params: 3, frame: 18
var value3;
var value4;
var value5;
var value6;
const productsFromCategories = getProductsFromCategories(a0, true);
const CollectiblesItemType = (CollectiblesItemTypeModule).CollectiblesItemType;
const AVATAR_DECORATION = CollectiblesItemType.AVATAR_DECORATION;
if (a1 === AVATAR_DECORATION) {
value6 = (require(22) /* metro dependency 22 */).flatMap(productsFromCategories, 'items');
return (require(22) /* metro dependency 22 */).uniqBy(value6.filter(isAvatarDecorationRecord), 'skuId');
}
const NAMEPLATE = CollectiblesItemType.NAMEPLATE;
if (a1 === NAMEPLATE) {
value5 = (require(22) /* metro dependency 22 */).flatMap(productsFromCategories, 'items');
return (require(22) /* metro dependency 22 */).uniqBy(value5.filter(isNameplateRecord), 'skuId');
}
const PROFILE_EFFECT = CollectiblesItemType.PROFILE_EFFECT;
if (a1 === PROFILE_EFFECT) {
value4 = (require(22) /* metro dependency 22 */).flatMap(productsFromCategories, 'items');
return (require(22) /* metro dependency 22 */).uniqBy(value4.filter(isProfileEffectRecord), 'skuId');
}
const PROFILE_FRAME = CollectiblesItemType.PROFILE_FRAME;
if (a1 === PROFILE_FRAME) {
value3 = (require(22) /* metro dependency 22 */).flatMap(productsFromCategories, 'items');
return (require(22) /* metro dependency 22 */).uniqBy(value3.filter(isProfileFrameRecord), 'skuId');
}
return [];
}
function getAnalyticsShopDiscountSource(a0) { // fn#45215, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:4309, offset: 0x01184e23, size: 25 bytes, params: 2, frame: 3
const value = null;
return value != a0 ? env0_15[a0] : value;
}
function getShopDiscountSource(a0) { // fn#45216, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:4402, offset: 0x01184e3c, size: 336 bytes, params: 2, frame: 18
var r1;
var defaultImport2;
var moduleValue;
var value3;
var perkSource;
const PerkSource = (require(1895) /* metro dependency 1895: user */).PerkSource;
var moduleValue2;
const value2 = undefined;
const defaultImport = PremiumUtils;
if (defaultImport.canUseShopDiscounts(a0)) {
defaultImport2 = defaultImport;
if (defaultImport2.canUseCollectibles(a0)) {
return env0_14.NITRO;
}
moduleValue = require(1893) /* metro dependency 1893: PerksStateUtils */;
value3 = null;
perkSource = moduleValue.getPerkSource(value3 == a0 ? value2 : a0.perks,
(require(1895) /* metro dependency 1895: user */).Perk.SHOP_DISCOUNTS);
if (value3 == perkSource) {
moduleValue2 = require(5136) /* metro dependency 5136: CrepeExperiment */;
r1 = moduleValue2.getIsCrepeEnabled('getShopDiscountSource') && value3 != perkSource && perkSource.includes(PerkSource.SOURCE_THIRDPARTY_CROISSANT) ? env0_14.THIRDPARTY : value3;
} else if (perkSource.includes(PerkSource.SOURCE_NITRO)) {
r1 = env0_14.NITRO;
} else {
moduleValue2 = require(5136) /* metro dependency 5136: CrepeExperiment */;
r1 = moduleValue2.getIsCrepeEnabled('getShopDiscountSource') && value3 != perkSource && perkSource.includes(PerkSource.SOURCE_THIRDPARTY_CROISSANT) ? env0_14.THIRDPARTY : value3;
}
return r1;
}
return null;
}
function isPremiumCollectiblesPurchase(a0) { // fn#45218, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:4925, offset: 0x01184fa6, size: 39 bytes, params: 2, frame: 3
const purchaseType = a0?.purchaseType;
const PREMIUM_PURCHASE = EntitlementTypes.PREMIUM_PURCHASE;
return purchaseType === PREMIUM_PURCHASE;
}
function getAssetForAvatarDecorationProduct({items}) { // fn#45219, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:5018, offset: 0x01184fcd, size: 46 bytes, params: 2, frame: 11
return items.find(isAvatarDecorationRecord)?.asset;
}
function getFormattedPriceForCollectiblesProduct(a0, a1, a2) { // fn#45220, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:5183, offset: 0x01184ffb, size: 102 bytes, params: 4, frame: 18
var r0;
var value;
const getPriceForCollectiblesProductBinding = getPriceForCollectiblesProduct;
const value2 = undefined;
const priceForCollectiblesProductBinding = getPriceForCollectiblesProductBinding(a0, a1, a2);
if (priceForCollectiblesProductBinding == null) {
r0 = '';
} else {
value = require(5137) /* metro dependency 5137: PriceUtils */;
value = value.formatPrice(priceForCollectiblesProductBinding == null ? value2 : priceForCollectiblesProductBinding.amount,
priceForCollectiblesProductBinding == null ? value2 : priceForCollectiblesProductBinding.currency);
r0 = value;
}
return r0;
}
function getProductDiscount(a0, a1) { // fn#45221, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:5554, offset: 0x01185061, size: 129 bytes, params: 3, frame: 17
if (a0 == null) {
return env0_20;
}
const bundleItemsPriceSum = getBundleItemsPriceSum(a0);
if (bundleItemsPriceSum <= 0) {
return env0_20;
}
const value3 = extractPriceByPurchaseTypes(a0, getDefaultPriceSetAssignmentPurchaseType(a1));
return value3 == null ? env0_20 : {original: bundleItemsPriceSum,
discountPercentage: global.Math.round((bundleItemsPriceSum - value3.amount) / bundleItemsPriceSum * 100)};
}
function getCollectiblesProductPriceComparisons(a0, {hasShopDiscount, discount}) { // fn#45222, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:5834, offset: 0x011850e2, size: 237 bytes, params: 3, frame: 18
var r3;
var object;
let extractPriceByPurchaseTypesBinding = extractPriceByPurchaseTypes;
const DEFAULT = PriceSetAssignmentPurchaseTypes.DEFAULT;
const value2 = extractPriceByPurchaseTypesBinding(a0, DEFAULT);
if (value2 == null) {
return null;
}
if (value2.amount <= 0) {
return {defaultPrice: value2, showDefaultPriceOnly: true};
}
extractPriceByPurchaseTypesBinding = extractPriceByPurchaseTypes;
const PREMIUM_TIER_2 = PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2;
const value3 = extractPriceByPurchaseTypesBinding(a0, PREMIUM_TIER_2);
if (isBundleProduct(a0)) {
if (hasShopDiscount) {
object = {};
copyDataProperties(object, value2, extractPriceByPurchaseTypesBinding);
object['amount'] = discount.original;
r3 = object;
} else {
r3 = value2;
}
} else {
r3 = value2;
}
const r5 = hasShopDiscount && value3 != null;
const r4 = r5 ? value3 : r3;
return {defaultPrice: value2, originalPrice: r3, premiumPrice: value3, finalPrice: r4, showDiscountPrice: r5,
finalPriceIsDifferent: r4.amount !== r3.amount, showDefaultPriceOnly: false};
}
function isFreeCollectiblesProduct(a0) { // fn#45223, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:6311, offset: 0x011851cf, size: 51 bytes, params: 2, frame: 13
const extractPriceByPurchaseTypesBinding = extractPriceByPurchaseTypes;
const DEFAULT = PriceSetAssignmentPurchaseTypes.DEFAULT;
const value = undefined;
const value2 = extractPriceByPurchaseTypesBinding(a0, DEFAULT);
return (value2 == null ? value : value2.amount) === 0;
}
function getCollectibleTypeLabel(a0) { // fn#45224, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:6648, offset: 0x01185202, size: 381 bytes, params: 2, frame: 15
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
const CollectiblesItemType = (CollectiblesItemTypeModule).CollectiblesItemType;
const AVATAR_DECORATION = CollectiblesItemType.AVATAR_DECORATION;
if (AVATAR_DECORATION === a0) {
return intl.string(t['7v0T9P']);
}
const PROFILE_EFFECT = CollectiblesItemType.PROFILE_EFFECT;
if (PROFILE_EFFECT === a0) {
return intl.string(t.wR5wOo);
}
const NAMEPLATE = CollectiblesItemType.NAMEPLATE;
if (NAMEPLATE === a0) {
return intl.string(t.x5CoXR);
}
const PROFILE_FRAME = CollectiblesItemType.PROFILE_FRAME;
if (PROFILE_FRAME === a0) {
return intl.string(t.GWrZOd);
}
return null;
}
function getAssetDisplayConfig(a0) { // fn#45225, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:7096, offset: 0x0118537f, size: 34 bytes, params: 2, frame: 12
return a0 != null ? AssetDisplayConfigRecord.fromServer(a0) : undefined;
}
function groupProfileEffects(a0, a1) { // fn#45229, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:7922, offset: 0x011854a6, size: 66 bytes, params: 3, frame: 13
const profileEffectsFromPurchases = getProfileEffectsFromPurchases(a1);
let value = getProfileEffectsFromCategories(a0);
value = value.filter(function({skuId}) {
return !skuId.some(_fun45231);
});
return {purchased: profileEffectsFromPurchases, shopPreviews: value};
function _fun45230({skuId}) { // fn#45230, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8015, offset: 0x011854e8, size: 42 bytes, params: 2, frame: 11
const binding = skuId;
return !binding.some(function({skuId}) {
return skuId === skuId;
});
function _fun45231({skuId}) { // fn#45231, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8037, offset: 0x00fc3122, size: 21 bytes, params: 2, frame: 2
return skuId === skuId;
}
}
}
function shouldShowLimitedTimeBadge(a0) { // fn#45235, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8504, offset: 0x01185591, size: 36 bytes, params: 2, frame: 13
return a0 != null && getDaysRemaining(a0) <= LIMITED_TIME_BADGE_DAYS_THRESHOLD;
}
function isProductNew(a0) { // fn#45236, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8554, offset: 0x011855b5, size: 67 bytes, params: 2, frame: 11
var r0;
var date;
const property = SHOP_CARD_PER_PRODUCT_NEW_BADGE_EXPIRY_SETTINGS[a0];
const value = property != null;
if (value) {
date = new global.Date();
date = date.getTime() < property;
r0 = date;
} else {
r0 = value;
}
return r0;
}
function getCollectiblesItemTypeForDisplay(a0) { // fn#45237, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8679, offset: 0x011855f8, size: 127 bytes, params: 2, frame: 16
const CollectiblesItemType = (CollectiblesItemTypeModule).CollectiblesItemType;
if (a0 != null) {
return a0.type === CollectiblesItemType.BUNDLE ? CollectiblesItemType.BUNDLE : a0.items == null || a0.items[0] == null ? undefined : a0.items[0].type;
}
}
function shouldHideGiftingForCurrency(a0) { // fn#45239, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:9207, offset: 0x01185732, size: 31 bytes, params: 2, frame: 12
return a0 != null && env0_35.includes(a0);
}
function getStrikeThroughPriceAmountForCollectiblesProduct(a0, a1, a2) { // fn#45240, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:9285, offset: 0x01185751, size: 112 bytes, params: 4, frame: 16
const isBundleProductBinding = isBundleProduct;
const value2 = undefined;
if (isBundleProductBinding(a0)) {
return getBundleItemsPriceSum(a0);
}
const value = extractPriceByPurchaseTypes(a0,
a1 ? a2 ? PriceSetAssignmentPurchaseTypes.MOBILE : PriceSetAssignmentPurchaseTypes.DEFAULT : a2 ? PriceSetAssignmentPurchaseTypes.MOBILE_PREMIUM_TIER_2 : PriceSetAssignmentPurchaseTypes.PREMIUM_TIER_2);
return value == null ? value2 : value.amount;
}
function canActionOnProduct({product, isPartiallyOwnedBundle, isPurchased}) { // fn#45241, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:9510, offset: 0x011857c1, size: 71 bytes, params: 2, frame: 6
var r0;
var value;
var ORB_PROFILE_BADGE;
if (isPartiallyOwnedBundle) {
r0 = isPartiallyOwnedBundle;
} else {
ORB_PROFILE_BADGE = EXTERNAL_PRODUCT_SKU_IDS.ORB_PROFILE_BADGE;
value = undefined;
value = ORB_PROFILE_BADGE === (product == null ? value : product.skuId);
r0 = value && isPurchased;
}
return !r0;
}
function getProductTypeNameForLogging(a0, a1) { // fn#45242, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:9651, offset: 0x01185808, size: 382 bytes, params: 3, frame: 15
const CollectiblesItemType = (CollectiblesItemTypeModule).CollectiblesItemType;
const AVATAR_DECORATION = CollectiblesItemType.AVATAR_DECORATION;
if (AVATAR_DECORATION === a0) {
return 'avatar decoration';
}
const PROFILE_EFFECT = CollectiblesItemType.PROFILE_EFFECT;
if (PROFILE_EFFECT === a0) {
return 'profile effect';
}
const NAMEPLATE = CollectiblesItemType.NAMEPLATE;
if (NAMEPLATE === a0) {
return 'nameplate';
}
const PROFILE_FRAME = CollectiblesItemType.PROFILE_FRAME;
if (PROFILE_FRAME === a0) {
return 'profile frame';
}
const BUNDLE = CollectiblesItemType.BUNDLE;
if (BUNDLE === a0) {
return 'bundle';
}
const EXTERNAL_SKU = CollectiblesItemType.EXTERNAL_SKU;
if (EXTERNAL_SKU === a0) {
return a1 === EXTERNAL_PRODUCT_SKU_IDS.FRACTIONAL_PREMIUM ? '3-day nitro credit' : a1 === EXTERNAL_PRODUCT_SKU_IDS.FRACTIONAL_PREMIUM_1_DAY ? '1-day nitro credit' : a1 !== EXTERNAL_PRODUCT_SKU_IDS.ORB_PROFILE_BADGE ? 'unknown' : 'orb profile badge';
}
const VARIANTS_GROUP = CollectiblesItemType.VARIANTS_GROUP;
if (VARIANTS_GROUP === a0) {
return 'variants group';
}
return 'unknown';
}
function sortProductsByPrice(a0, a1, a2) { // fn#45243, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10340, offset: 0x01185986, size: 37 bytes, params: 4, frame: 11
const env0_0 = a1;
const env0_1 = a2;
return a0.sort(_fun45244);
function _fun45244(a0, a1) { // fn#45244, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10357, offset: 0x011859ab, size: 228 bytes, params: 3, frame: 18
const r0 = importDefault ? (require(5133) /* metro dependency 5133: CollectiblesProductUtils */).getProductOrbPrice({product: a0,
hasShopDiscount: require}) : getPriceForCollectiblesProduct(a0, require, true);
const r4 = importDefault ? (require(5133) /* metro dependency 5133: CollectiblesProductUtils */).getProductOrbPrice({product: a1,
hasShopDiscount: require}) : getPriceForCollectiblesProduct(a1, require, true);
const value = undefined;
const amount = r0 == null ? value : r0.amount;
const value5 = 0;
return (amount ?? value5) - ((r4 == null ? value : r4.amount) ?? value5);
}
}
function sortProductsByUserDiscounts(a0, a1) { // fn#45245, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10696, offset: 0x01185a8f, size: 67 bytes, params: 3, frame: 13
if (a1.length === 0) {
return a0;
}
if (a0.length === 0) {
return a0;
}
const env0_0 = a1.map(function(a0) {
return a0.discountId;
});
return a0.sort(function(a0, a1) {
var r4;
var r2;
var eligibleOffers = a0.eligibleOffers;
var value = undefined;
r4 = eligibleOffers == null ? value : eligibleOffers.some(_fun45248);
var r0 = r4 != null && r4;
eligibleOffers = a1.eligibleOffers;
r2 = eligibleOffers == null ? value : eligibleOffers.some(_fun45249);
value = r2 != null;
value = Number(value && r2);
return value - Number(r0);
});
function _fun45247({eligibleOffers}, {eligibleOffers}) { // fn#45247, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10789, offset: 0x01185add, size: 104 bytes, params: 3, frame: 15
let value = undefined;
const r4 = eligibleOffers == null ? value : eligibleOffers.some(_fun45248);
const r0 = r4 != null && r4;
const r2 = eligibleOffers == null ? value : eligibleOffers.some(_fun45249);
value = r2 != null;
value = Number(value && r2);
return value - Number(r0);
function _fun45248(a0) { // fn#45248, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10862, offset: 0x01185b45, size: 22 bytes, params: 2, frame: 11
return env1_0.includes(a0);
}
function _fun45249(a0) { // fn#45249, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10944, offset: 0x01185b45, size: 22 bytes, params: 2, frame: 11
return env1_0.includes(a0);
}
}
}
function removeRewardProductsFilter(a0) { // fn#45250, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:11004, offset: 0x01185b5b, size: 22 bytes, params: 2, frame: 11
return a0.filter(function(a0) {
return !a0.isCategoryReward;
});
}
}
function getDaysRemaining(a0) { // fn#45213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:3915, offset: 0x01184d43, size: 162 bytes, params: 2, frame: 18
let Date = global.Date;
let date = new Date();
Date = global.Date;
let UTC = Date.UTC;
const fullYear = date.getFullYear();
const month = date.getMonth();
let getDate = date.getDate;
date = Reflect.apply(UTC, Date, [fullYear, month, Reflect.apply(getDate, date, [])]);
Date = global.Date;
UTC = Date.UTC;
const fullYear2 = a0.getFullYear();
const month2 = a0.getMonth();
getDate = a0.getDate;
const value6 = Reflect.apply(UTC, Date, [fullYear2, month2, Reflect.apply(getDate, a0, [])]);
const Math = global.Math;
return Math.floor((value6 - date) / 86400000);
}
function getCollectiblesPrice({invoicePreview, selectedSkuId, skusById}) { // fn#45238, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:8862, offset: 0x01185677, size: 187 bytes, params: 2, frame: 8
var price;
var r0;
var property;
var object;
const unitPrice = invoicePreview == null || invoicePreview.invoiceItems == null ? undefined : invoicePreview.invoiceItems[0]?.unitPrice;
const r4 = unitPrice != null ? {amount: unitPrice.amount, currency: unitPrice.currency} : undefined;
if (r4 != null) {
r0 = r4;
} else if (selectedSkuId == null) {
r0 = r4;
} else {
property = skusById[selectedSkuId];
price = property?.price;
if (price == null) {
r0 = r4;
} else {
object = {};
price = property.price;
object.amount = price.amount;
price = property.price;
object.currency = price.currency;
r0 = object;
}
}
return r0;
}
function _fun45246(a0) { // fn#45246, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:10756, offset: 0x01185ad2, size: 11 bytes, params: 2, frame: 1
return a0.discountId;
}
function _fun45251({isCategoryReward}) { // fn#45251, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5312:11017, offset: 0x01185b71, size: 14 bytes, params: 2, frame: 1
return !isCategoryReward;
}
global.__d(_fun45193, 5134, [5126, 1902, 5127, 5128, 5135, 663, 661, 482, 3802, 1893, 1895, 5136, 5137, 477, 1904,
22, 1244, 5133,
2]) /* metro module 5134, dependencies: [5126, 1902, 5127, 5128, 5135, 663, 661, 482, 3802, 1893, 1895, 5136, 5137, 477, 1904, 22, 1244, 5133, 2] */;