Files
2026-07-28 01:06:53 +03:00

349 lines
21 KiB
TypeScript

/* Metro module 6833; source: modules/storefront/StorefrontUtils.tsx; dependencies: [31, 1949, 1878, 6834, 661, 1880, 22, 6835, 478, 1391, 566, 6829, 5137, 3802, 6836, 2] */
import Module00022 from '../../by-id/module-00022.js'; /* Metro dependency 22 */
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import LocaleStore from '../user_settings/LocaleStore.tsx'; /* Metro dependency 1949 */
import SKUPricesStore from './SKUPricesStore.tsx'; /* Metro dependency 6834 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as PremiumConstantsModule from '../premium/PremiumConstants.tsx'; /* Metro dependency 1880 */
import * as StorefrontTypesModule from './StorefrontTypes.tsx'; /* Metro dependency 6835 */
import * as OrbCheckoutUtilsModule from '../virtual_currency/checkout/OrbCheckoutUtils.tsx'; /* Metro dependency 6836 */
function _fun53784(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#53784, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:6, offset: 0x01355809, size: 354 bytes, params: 8, frame: 21
const env0_0 = require;
const transformStorefrontSKUPricesServer = function(a0) {
return a0.map(_fun53786);
};
const useSKUPrice2 = useSKUPrice;
const formatSKUPrice2 = formatSKUPrice;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/storefront/StorefrontUtils.tsx');
exports.transformStorefrontPricesServer = function(a0) {
var object = {};
object.skuPriceMap = importDefault(dependencyMap[6]).mapValues(a0.sku_price_map, _fun53807);
object.pricingResultIdMap = transformStorefrontPricesResultMapServer(a0.pricing_result_id_map);
object.rewardResultIdMap = transformStorefrontRewardsResultMapServer(a0.reward_result_id_map);
return object;
};
exports.isSlayerSkuAvailableOnThisPlatform = isSlayerSkuAvailableOnThisPlatform;
exports.useSKUPrice = useSKUPrice2;
exports.useFormattedSKUPrice = useFormattedSKUPrice;
exports.formatSKUPrice = formatSKUPrice2;
exports.useSKUOrbPrice = useSKUOrbPrice;
function transformStorefrontSKUPricesServer(a0) { // fn#53785, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:271, offset: 0x0135596b, size: 22 bytes, params: 2, frame: 11
return a0.map(function(a0) {
return {currency: a0.currency, amount: a0.amount};
});
}
function transformStorefrontPricesResultMapServer(a0) { // fn#53787, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:377, offset: 0x0135599e, size: 49 bytes, params: 2, frame: 13
return (Module00022).mapValues(a0, _fun53788);
function _fun53788(a0) { // fn#53788, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:458, offset: 0x013559cf, size: 49 bytes, params: 2, frame: 13
var environment;
const value = environment.__proto__;
return (Module00022).mapValues(a0, _fun53789);
function _fun53789({user_price, prices}) { // fn#53789, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:482, offset: 0x01355a00, size: 84 bytes, params: 2, frame: 15
var environment;
const object = {};
const value = environment.__proto__.__proto__;
object.userPrice = transformStorefrontSKUPricesServer(user_price);
object.prices = (importDefault(22) /* metro dependency 22 */).mapValues(prices, _fun53790);
return object;
function _fun53790(a0) { // fn#53790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:581, offset: 0x01355a54, size: 49 bytes, params: 2, frame: 13
var environment;
const value = environment.__proto__.__proto__.__proto__;
return (importDefault(22) /* metro dependency 22 */).mapValues(a0, function(a0) {
return transformStorefrontSKUPricesServer(a0);
});
}
}
}
}
function transformStorefrontRewardsResultMapServer(a0) { // fn#53792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:656, offset: 0x01355a98, size: 49 bytes, params: 2, frame: 13
return (Module00022).mapValues(a0, _fun53793);
function _fun53793(a0) { // fn#53793, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:738, offset: 0x01355ac9, size: 49 bytes, params: 2, frame: 13
var environment;
const value = environment.__proto__;
return (importDefault(22) /* metro dependency 22 */).mapValues(a0, function(a0) {
return {type: a0.type, amount: a0.amount};
});
}
}
function useResolvedUserPrice({sku, priceSetAssignmentPurchaseType, isOrbPrice}) { // fn#53795, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:867, offset: 0x01355b15, size: 134 bytes, params: 2, frame: 18
const pricesForSkuId = (require(566) /* metro dependency 566: flux */).useStateFromStores([SKUPricesStore],
function() {
var r3;
var skuPricesStoreBinding = SKUPricesStore;
var getPricesForSkuId = skuPricesStoreBinding.getPricesForSkuId;
var skuBinding = sku;
var value2 = null;
r3 = value2 == skuBinding ? undefined : sku.id;
return Reflect.apply(getPricesForSkuId, skuPricesStoreBinding, [value2 != r3 ? r3 : value2]);
});
return pricesForSkuId.useMemo(_fun53797, [sku, pricesForSkuId, priceSetAssignmentPurchaseType, isOrbPrice]);
function _fun53797() { // fn#53797, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:1088, offset: 0x01355bd8, size: 373 bytes, params: 1, frame: 17
const StorefrontPurchaseType = (StorefrontTypesModule).StorefrontPurchaseType;
const priceSetAssignmentPurchaseTypeBinding = priceSetAssignmentPurchaseType;
const r3 = priceSetAssignmentPurchaseTypeBinding == null || PriceSetAssignmentPurchaseTypes.DEFAULT === priceSetAssignmentPurchaseTypeBinding ? StorefrontPurchaseType.SELF_PURCHASE : PriceSetAssignmentPurchaseTypes.GIFT === priceSetAssignmentPurchaseTypeBinding ? StorefrontPurchaseType.GIFT : StorefrontPurchaseType.SELF_PURCHASE;
if (sku == null) {
return {userPrice: undefined, pricesForPurchaseType: undefined, purchaseType: r3,
storeHasPrice: pricesForSkuId != null};
}
if (pricesForSkuId == null) {
return {userPrice: undefined, pricesForPurchaseType: undefined, purchaseType: r3,
storeHasPrice: pricesForSkuId != null};
}
const r4 = pricesForSkuId[r3] ?? pricesForSkuId[StorefrontPurchaseType.SELF_PURCHASE];
return {userPrice: r4 == null || r4.userPrice == null ? undefined : r4.userPrice.find(_fun53798),
pricesForPurchaseType: r4, purchaseType: r3, storeHasPrice: true};
function _fun53798({currency}) { // fn#53798, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:1614, offset: 0x01355d4d, size: 44 bytes, params: 2, frame: 4
let value = environment.__proto__;
const isOrbPriceBinding = isOrbPrice;
value = environment.__proto__.__proto__;
const DISCORD_ORB = CurrencyCodes.DISCORD_ORB;
return isOrbPriceBinding ? currency === DISCORD_ORB : currency !== DISCORD_ORB;
}
}
}
function useSKUPrice({sku, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT}) { // fn#53799, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:1745, offset: 0x01355d79, size: 308 bytes, params: 2, frame: 25
const value4 = useResolvedUserPrice({sku: sku, priceSetAssignmentPurchaseType: priceSetAssignmentPurchaseType,
isOrbPrice: false});
const userPrice = value4.userPrice;
const pricesForPurchaseType = value4.pricesForPurchaseType;
const pricesForPurchaseType2 = pricesForPurchaseType;
const purchaseType = value4.purchaseType;
const storeHasPrice = value4.storeHasPrice;
const value5 = (require(566) /* metro dependency 566: flux */).useStateFromStoresArray([SKUPricesStore], _fun53800);
const currentUser = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getCurrentUser();
});
return pricesForPurchaseType2.useMemo(_fun53802, [sku, priceSetAssignmentPurchaseType, currentUser?.premiumType,
storeHasPrice, userPrice, pricesForPurchaseType, purchaseType, value5]);
function _fun53800() { // fn#53800, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:2016, offset: 0x01355ead, size: 57 bytes, params: 1, frame: 14
const value = environment.__proto__;
return SKUPricesStore.getRewardsForSkuId(sku?.id) ?? [];
}
function _fun53802() { // fn#53802, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:2172, offset: 0x01355ee6, size: 499 bytes, params: 1, frame: 21
var environment;
var r0;
var userPrice2;
var amount;
var r6;
var moduleValue;
var value5;
var property;
var pricesForPurchaseTypeBinding;
var value6;
var prices;
var value7;
let skuBinding = sku;
const value2 = null;
if (value2 == skuBinding) {
return {'normalPrice': null, 'discountedPrice': null, 'discountPercent': null, 'userPrice': null};
}
if (storeHasPrice) {
value5 = env0_6.find(_fun53803);
r0 = value2 != value5 ? value5[purchaseType] : value2;
userPrice2 = value2 != r0 && value2 != userPrice ? userPrice : value2;
if (value2 != r0) {
amount = r0.amount;
amount = amount > 0 ? r0.amount : value2;
} else {
amount = value2;
}
if (value2 != r0) {
pricesForPurchaseTypeBinding = pricesForPurchaseType;
value6 = undefined;
if (value2 == pricesForPurchaseTypeBinding) {
r0 = value6;
} else {
prices = pricesForPurchaseType.prices;
value7 = environment.__proto__;
property = prices[PriceTypes.BASE];
if (value2 == property) {
r0 = value6;
} else {
property = property[(require(6835) /* metro dependency 6835: StorefrontTypes */).StorefrontPriceVariant.NORMAL];
r0 = value2 == property ? value6 : property.find(function({currency}) {
return currency !== CurrencyCodes.DISCORD_ORB;
});
}
}
r6 = r0;
} else {
r6 = userPrice;
}
return {normalPrice: value2 != r6 && r6.amount > 0 ? r6 : value2, discountedPrice: userPrice2,
discountPercent: amount, userPrice: value2 != userPrice ? userPrice : value2};
}
const productLine = sku.productLine;
const SOCIAL_LAYER_GAME_ITEM = SKUProductLines.SOCIAL_LAYER_GAME_ITEM;
if (productLine === SOCIAL_LAYER_GAME_ITEM) {
moduleValue = require(6829) /* metro dependency 6829: SlayerStorefrontUtils */;
r0 = moduleValue.getPrice(sku, env0_1);
} else {
skuBinding = sku;
r0 = skuBinding.getPrice(value2 == currentUser ? undefined : currentUser.premiumType);
}
const r3 = value2 != r0 && r0.amount > 0 ? r0 : value2;
return {'normalPrice': null, 'discountedPrice': null, 'discountPercent': null, normalPrice: r3, userPrice: r3};
function _fun53803(a0) { // fn#53803, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:2513, offset: 0x013560d9, size: 73 bytes, params: 2, frame: 13
const value = environment.__proto__;
const type = a0[purchaseType]?.type;
const StorefrontPromotionRewardType = (StorefrontTypesModule).StorefrontPromotionRewardType;
const DISCOUNT = StorefrontPromotionRewardType.DISCOUNT;
return type === DISCOUNT;
}
}
}
function formatSKUPrice({normalPrice, discountedPrice, discountPercent, userPrice}, a1) { // fn#53805, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:2997, offset: 0x0135613e, size: 337 bytes, params: 3, frame: 19
var r1;
var moduleValue;
var moduleValue2;
const object = {};
let value = null;
if (value != normalPrice) {
if (normalPrice.amount > 0) {
moduleValue = require(5137) /* metro dependency 5137: PriceUtils */;
r1 = moduleValue.formatPrice(normalPrice.amount, normalPrice.currency);
} else {
r1 = value;
}
} else {
r1 = value;
}
object.normalPrice = r1;
if (value != discountedPrice) {
if (discountedPrice.amount > 0) {
moduleValue2 = require(5137) /* metro dependency 5137: PriceUtils */;
r1 = moduleValue2.formatPrice(discountedPrice.amount, discountedPrice.currency);
} else {
r1 = value;
}
} else {
r1 = value;
}
object.discountedPrice = r1;
object.discountPercent = value != discountPercent ? (require(5137) /* metro dependency 5137: PriceUtils */).formatPercent(a1,
-discountPercent / 100) : value;
if (value != userPrice) {
if (userPrice.amount > 0) {
value = require(5137) /* metro dependency 5137: PriceUtils */;
value = value.formatPrice(userPrice.amount, userPrice.currency);
r1 = value;
} else {
r1 = value;
}
} else {
r1 = value;
}
object.userPrice = r1;
return object;
}
function transformStorefrontPricesServer({sku_price_map, pricing_result_id_map, reward_result_id_map}) { // fn#53806, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:3516, offset: 0x0135628f, size: 108 bytes, params: 2, frame: 17
const object = {};
object.skuPriceMap = (importDefault(22) /* metro dependency 22 */).mapValues(sku_price_map, function(a0) {
return {pricingResultId: a0.pricing_result_id, rewardResultIds: a0.reward_result_ids};
});
object.pricingResultIdMap = transformStorefrontPricesResultMapServer(pricing_result_id_map);
object.rewardResultIdMap = transformStorefrontRewardsResultMapServer(reward_result_id_map);
return object;
}
function isSlayerSkuAvailableOnThisPlatform(a0) { // fn#53808, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:3964, offset: 0x0135631c, size: 216 bytes, params: 2, frame: 18
var r0;
var isAndroid2;
var moduleValue3;
var moduleValue4;
if (a0 == null) {
return false;
}
const productLine = a0.productLine;
const SOCIAL_LAYER_GAME_ITEM = SKUProductLines.SOCIAL_LAYER_GAME_ITEM;
if (productLine !== SOCIAL_LAYER_GAME_ITEM) {
return false;
}
const r4 = a0?.flags ?? 0;
if ((require(478) /* metro dependency 478: PlatformUtils */).isIOS()) {
moduleValue4 = require(1391) /* metro dependency 1391: FlagUtils */;
r0 = moduleValue4.hasFlag(r4, SKUFlags.AVAILABLE_ON_IOS);
} else {
isAndroid2 = (require(478) /* metro dependency 478: PlatformUtils */).isAndroid();
if (isAndroid2) {
moduleValue3 = require(1391) /* metro dependency 1391: FlagUtils */;
r0 = moduleValue3.hasFlag(r4, SKUFlags.AVAILABLE_ON_ANDROID);
} else {
r0 = !isAndroid2;
}
}
return r0;
}
function useFormattedSKUPrice({sku, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT}) { // fn#53809, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:4297, offset: 0x013563f4, size: 158 bytes, params: 2, frame: 16
return ReactModule.useMemo(_fun53811, [useSKUPrice({sku: sku,
priceSetAssignmentPurchaseType: priceSetAssignmentPurchaseType}),
(require(566) /* metro dependency 566: flux */).useStateFromStores([LocaleStore], function() {
return LocaleStore.locale;
})]);
function _fun53811() { // fn#53811, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:4507, offset: 0x00e3d6c3, size: 28 bytes, params: 1, frame: 13
return formatSKUPrice(env0_0, locale);
}
}
function useSKUOrbPrice({sku, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT}) { // fn#53812, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:4589, offset: 0x013564a1, size: 233 bytes, params: 2, frame: 18
const {userPrice, storeHasPrice} = useResolvedUserPrice({sku: sku,
priceSetAssignmentPurchaseType: priceSetAssignmentPurchaseType, isOrbPrice: true});
const currentUser = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getCurrentUser();
});
const currentUser2 = currentUser;
return currentUser2.useMemo(_fun53815, [sku, currentUser2.useMemo(function() {
return importDefault(dependencyMap[13]).isPremium(currentUser, PremiumTypes.TIER_2);
}, [currentUser]), storeHasPrice, userPrice]);
function _fun53815() { // fn#53815, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:4912, offset: 0x013565c2, size: 130 bytes, params: 1, frame: 15
const skuBinding = sku;
const value2 = null;
if (value2 == skuBinding) {
return value2;
}
if (storeHasPrice) {
return value2 != userPrice ? userPrice : value2;
}
const orbPriceFromPrices = (OrbCheckoutUtilsModule).getOrbPriceFromPrices(sku.prices,
env0_4);
return value2 != orbPriceFromPrices ? {amount: orbPriceFromPrices.amount,
currency: orbPriceFromPrices.currency} : value2;
}
}
}
function _fun53786({currency, amount}) { // fn#53786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:332, offset: 0x01355981, size: 29 bytes, params: 2, frame: 3
return {currency: currency, amount: amount};
}
function _fun53807({pricing_result_id, reward_result_ids}) { // fn#53807, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7011:3614, offset: 0x013562fb, size: 33 bytes, params: 2, frame: 3
return {pricingResultId: pricing_result_id, rewardResultIds: reward_result_ids};
}
global.__d(_fun53784, 6833, [31, 1949, 1878, 6834, 661, 1880, 22, 6835, 478, 1391, 566, 6829, 5137, 3802, 6836,
2]) /* metro module 6833, dependencies: [31, 1949, 1878, 6834, 661, 1880, 22, 6835, 478, 1391, 566, 6829, 5137, 3802, 6836, 2] */;