This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,51 @@
// Metro module 14620 (f14621).
import { COLLECTIBLES_SHOP_CARD_WIDTH, COLLECTIBLES_SHOP_CARD_GAP, COLLECTIBLES_SHOP_CARD_MAX_WIDTH } from "../CollectiblesShopCardV2";
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
export function useCardLayout() {
const width = useWindowDimensions_native().width;
const columns = width >= 320 ? 2 : 1;
if (columns < 2) {
return {
columns,
cardWidth: void 0,
rowWidth: void 0
};
}
const r7 = width >= 768 ? 4 : 2;
const r2 = COLLECTIBLES_SHOP_CARD_WIDTH * columns;
const r31 = columns - 1;
const r33 = width - (r2 + COLLECTIBLES_SHOP_CARD_GAP * r31);
const r41 = r33 < 2 * COLLECTIBLES_SHOP_CARD_GAP ? Math.max(4, r33) : 2 * COLLECTIBLES_SHOP_CARD_GAP;
const r51 = (width - (r41 + COLLECTIBLES_SHOP_CARD_GAP * r31)) / columns;
let r55 = r51;
let columns2 = columns;
if (r51 > COLLECTIBLES_SHOP_CARD_MAX_WIDTH) {
let r58 = columns;
r55 = r51;
columns2 = r58;
while (columns2 < r7) {
const r63 = r58 + 1;
const r72 = (width - (r41 + COLLECTIBLES_SHOP_CARD_GAP * (r63 - 1))) / r63;
r55 = r72;
columns2 = r63;
if (!(r72 > COLLECTIBLES_SHOP_CARD_MAX_WIDTH)) {
break;
}
r58 = r63;
r55 = r72;
columns2 = r58;
}
}
const cardWidth = Math.min(Math.max(r55, COLLECTIBLES_SHOP_CARD_WIDTH), COLLECTIBLES_SHOP_CARD_MAX_WIDTH);
const r96 = cardWidth * columns2;
const r100 = columns2 - 1;
return r96 + (r41 + COLLECTIBLES_SHOP_CARD_GAP * r100) > width && 1 < columns2 ? {
columns: 1,
cardWidth: void 0,
rowWidth: void 0
} : {
columns: columns2,
cardWidth,
rowWidth: cardWidth * columns2 + COLLECTIBLES_SHOP_CARD_GAP * r100 + r41
};
}
@@ -0,0 +1,18 @@
// Metro module 8740 (f8741).
import { useMemo } from "react";
import UserStore from "../../../../stores/UserStore";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { getCollectibleGoogleSkuId } from "../CollectiblesUtils";
export default function useCollectiblesExternalGatewayFacet(a0) {
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
return useMemo(() => {
const collectibleGoogleSkuId = getCollectibleGoogleSkuId(a0, stateFromStores);
if (collectibleGoogleSkuId != null) {
return {
line_items: [{
external_product_id: collectibleGoogleSkuId
}]
};
}
}, [stateFromStores, a0]);
};
@@ -0,0 +1,26 @@
// Metro module 14103 (f14104).
import { useCallback, useMemo } from "react";
import UserStore from "../../../../stores/UserStore";
import { CollectiblesMobileShopScreen } from "../../CollectiblesShopConstants";
import { useBadBundleFilter } from "../../hooks/useBadBundleFilter";
import { useAndroidUnsyncedFilter } from "../useAndroidUnsyncedFilter";
import { usePurchasedProductsSort } from "../../hooks/usePurchasedProductsSort";
import { useStateFromStores } from "../../../../_bundle/Module589";
import PremiumUtils from "../../../../utils/PremiumUtils";
import { getProductOrbPrice } from "../../utils/CollectiblesProductUtils";
export function useFilteredAndSortedProducts({ products, maxProducts, bypassAndroidUnsyncedFilter, screen }) {
let callback, purchasedProductsSort;
callback = void 0;
purchasedProductsSort = void 0;
const badBundleFilter = useBadBundleFilter();
const androidUnsyncedFilter = useAndroidUnsyncedFilter();
const r1 = screen === CollectiblesMobileShopScreen.ORBS;
let c20908_0 = r1;
const canUseShopDiscounts = PremiumUtils.canUseShopDiscounts(useStateFromStores([UserStore], () => UserStore.getCurrentUser()));
callback = useCallback((a0) => c20908_0 ? a0.filter((item) => getProductOrbPrice({
product: item,
hasShopDiscount: canUseShopDiscounts
}) != null) : a0, [r1, canUseShopDiscounts]);
purchasedProductsSort = usePurchasedProductsSort(useMemo(() => [bypassAndroidUnsyncedFilter ? (a0) => a0 : androidUnsyncedFilter, badBundleFilter, callback].reduce((acc, item) => item(acc), products), [badBundleFilter, androidUnsyncedFilter, products, bypassAndroidUnsyncedFilter, callback]));
return useMemo(() => maxProducts != null ? purchasedProductsSort.slice(0, maxProducts) : purchasedProductsSort, [purchasedProductsSort, maxProducts]);
}
@@ -0,0 +1,13 @@
// Metro module 11888 (f11889).
import UserStore from "../../../../stores/UserStore";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { getCollectibleGoogleSkuId } from "../CollectiblesUtils";
import useMobilePurchaseSKU_android from "../../../billing/native/hooks/useMobilePurchaseSKU.android";
export default function useMobileCollectiblesPurchaseSKU({ product, ...rest }) {
return useMobilePurchaseSKU_android({
...rest,
skuId: product.skuId,
platformSkuId: getCollectibleGoogleSkuId(product, useStateFromStores([UserStore], () => UserStore.getCurrentUser())),
isFreeForStaffSelfPurchase: true
});
};
@@ -0,0 +1,278 @@
// Metro module 14095 (f14096).
import { useState, useEffect, useMemo } from "react";
import StorefrontProductStore from "../../../storefront/StorefrontProductStore";
import UserStore from "../../../../stores/UserStore";
import CollectiblesCategoryStore from "../../CollectiblesCategoryStore";
import CollectiblesProductRecord from "../../records/CollectiblesProductRecord";
import { CollectiblesMobileShopScreen } from "../../CollectiblesShopConstants";
import Durations from "../../../../utils/Durations";
import { getProductOrbPrice } from "../../utils/CollectiblesProductUtils";
import { useStateFromStores, useStateFromStoresArray } from "../../../../_bundle/Module589";
import PremiumUtils from "../../../../utils/PremiumUtils";
import { BountiesShopCarouselExperimentVariation } from "../../../quests/experiments/BountiesShopCarouselExperiment";
import { CollectibleSearchSortType } from "../../../../_bundle/Module681";
import { search } from "../../api/Shopfront";
import { CollectibleSearchCurrencyFilter } from "../../../../_bundle/Module14099";
import { CollectibleSearchSortDirection } from "../../../../_bundle/Module682";
import { useFetchCollectiblesProducts } from "../../hooks/useFetchCollectiblesProducts";
import { maybeFetchProductsBySkuIds } from "../../../storefront/StorefrontProductActionCreators";
import { useGetOrFetchStorefrontPricesForSkuIds } from "../../../storefront/hooks/useGetOrFetchStorefrontPrices";
import useGetProductsFromSkus from "../../hooks/useGetProductsFromSkus";
import { useFilteredAndSortedProducts } from "./useFilteredAndSortedProducts";
const timeout = 10 * Durations.Millis.SECOND;
let c9861_12 = 10 * Durations.Millis.SECOND;
export const MIN_PRODUCTS_FOR_ORB_SHOP_CAROUSEL = 3;
export function usePopularOrbShopProducts(a0) {
let POPULARITY2;
let POPULARITY, stateFromStoresArray, stateFromStoresArray2, c20899_10, memo, filteredAndSortedProducts;
let enabled2 = a0.enabled;
const enabled = enabled2;
const variation = a0.variation;
POPULARITY = void 0;
stateFromStoresArray = void 0;
stateFromStoresArray2 = void 0;
c20899_10 = void 0;
memo = void 0;
filteredAndSortedProducts = void 0;
const [state, setState] = useState([]);
const [state2, setState2] = useState(false);
const [state3, setState3] = useState(false);
const canUseShopDiscounts = PremiumUtils.canUseShopDiscounts(useStateFromStores([UserStore], () => UserStore.getCurrentUser()));
if (BountiesShopCarouselExperimentVariation.POPULARITY === variation) {
POPULARITY2 = CollectibleSearchSortType.POPULARITY;
} else if (BountiesShopCarouselExperimentVariation.RECENCY === variation) {
POPULARITY2 = CollectibleSearchSortType.RECENCY;
} else {
BountiesShopCarouselExperimentVariation.BASE;
POPULARITY2 = CollectibleSearchSortType.POPULARITY;
}
POPULARITY = POPULARITY2;
useEffect(() => {
let c27631_0;
let _fetchSearchResults2 = function _fetchSearchResults() {
const r9 = async () => {
let skus, c31706_3;
let c31706_4 = 0;
let c32055_0;
L16: {
try {
c32055_0 = void 0;
c31706_4 = 2;
c32055_0 = await search({
item_types: [],
colors: [],
themes: [],
orbs_eligible: true,
currency: CollectibleSearchCurrencyFilter.ORBS,
offset: 0,
limit: 10,
sort_type: POPULARITY,
sort_direction: CollectibleSearchSortDirection.DESC
}, {
timeout
});
if (!c27631_0) {
const skus2 = c32055_0.skus;
skus = skus2;
if (skus2 == null) {
skus = [];
}
setState(skus);
}
c31706_4 = 1;
c31706_4 = 0;
if (!c27631_0) {
(0, setState2)(true);
}
} catch ($e) {
const r29 = $e;
let r7 = r29;
c31706_3 = r29;
let r30 = c31706_4;
if (r30 !== 0) {
while (true) {
if (r30 === 1) {
try {
const r103 = c31706_3;
c31706_4 = 0;
if (!c27631_0) {
(0, setState2)(true);
}
throw r103;
} catch (r101) {
r7 = r101;
c31706_3 = r101;
r30 = c31706_4;
if (r30 === 0) {
break;
}
}
} else {
try {
c31706_4 = 1;
if (!c27631_0) {
(0, setState)([]);
}
c31706_4 = 0;
if (c27631_0) {
break L16;
}
(0, setState2)(true);
break L16;
} catch (r86) {
r7 = r86;
c31706_3 = r86;
r30 = c31706_4;
if (r30 === 0) {
break;
}
}
}
}
}
throw r7;
}
}
};
_fetchSearchResults2 = r9;
return r9.apply(this, arguments);
};
if (enabled) {
c27631_0 = false;
setState2(false);
(function fetchSearchResults() {
return _fetchSearchResults2.apply(this, arguments);
})();
return () => {
c27631_0 = true;
};
}
setState([]);
setState2(false);
}, [enabled, POPULARITY]);
useEffect(() => {
if (enabled && state2) {
setState3(false);
let c27632_0 = setTimeout(() => setState3(true), c9861_12);
return () => clearTimeout(c27632_0);
}
setState3(false);
}, [enabled, state2, state]);
let isLoadingProducts = useFetchCollectiblesProducts(state);
useEffect(() => {
if (state.length !== 0) {
maybeFetchProductsBySkuIds({
skuIds: state
});
}
}, [state]);
useGetOrFetchStorefrontPricesForSkuIds({
skuIds: state
});
stateFromStoresArray = useStateFromStoresArray([StorefrontProductStore], () => state.map((item) => StorefrontProductStore.getProductsForSku(item)));
stateFromStoresArray2 = useStateFromStoresArray([StorefrontProductStore], () => state.map((item) => StorefrontProductStore.getFetchStateForSku(item)));
const getProductsFromSkus = useGetProductsFromSkus();
c20899_10 = getProductsFromSkus;
memo = useMemo(() => c20899_10(state).map((a0, index) => {
const r12 = stateFromStoresArray[index];
const productOrbPrice = getProductOrbPrice({
product: a0,
hasShopDiscount: canUseShopDiscounts
});
let r23 = a0;
if (productOrbPrice == null) {
const r26 = (function getStorefrontPricesForSkuId(c27630_0, a1) {
if (a1 == null) {
return null;
}
for (const item of a1) {
const r28 = item.skus.find((sku) => sku.id === c27630_0);
if (r28 == null) {
continue;
}
if (!(Object.keys(r28.prices).length > 0)) {
continue;
}
return r28.prices;
}
return null;
})(a0.skuId, r12);
r23 = a0;
if (r26 != null) {
const r27 = r12 == null ? void 0 : r12.flatMap((item) => item.skus).find((item) => item.id === a0.skuId);
const prices = {
...a0.prices,
...r26
};
let googleSkuIds = r27?.googleSkuIds;
if (googleSkuIds == null) {
googleSkuIds = a0.googleSkuIds;
}
r23 = new CollectiblesProductRecord({
storeListingId: a0.storeListingId,
skuId: a0.skuId,
name: a0.name,
summary: a0.summary,
styles: a0.styles,
type: a0.type,
premiumType: a0.premiumType,
items: a0.items,
categorySkuId: a0.categorySkuId,
isCategoryReward: a0.isCategoryReward,
prices,
bundledProducts: a0.bundledProducts,
previewAssets: a0.previewAssets,
googleSkuIds,
variants: a0.variants,
eligibleOffers: a0.eligibleOffers,
badgeOverride: a0.badgeOverride,
hideBadge: a0.hideBadge
});
}
}
return r23;
}), [getProductsFromSkus, state, stateFromStoresArray, canUseShopDiscounts]);
const memo2 = useMemo(() => state.length !== 0 && state.some((item, index) => {
const product = CollectiblesCategoryStore.getProduct(item);
if (product != null && getProductOrbPrice({
product,
hasShopDiscount: canUseShopDiscounts
}) != null) {
return false;
}
const r18 = stateFromStoresArray2[index];
return r18 === "loading" || r18 == null;
}), [state, stateFromStoresArray2, canUseShopDiscounts]);
filteredAndSortedProducts = useFilteredAndSortedProducts({
products: useMemo(() => memo.filter((item) => getProductOrbPrice({
product: item,
hasShopDiscount: canUseShopDiscounts
}) != null), [memo, canUseShopDiscounts]),
screen: CollectiblesMobileShopScreen.ORBS
});
const memo3 = useMemo(() => filteredAndSortedProducts.slice(0, 10), [filteredAndSortedProducts]);
if (!isLoadingProducts) {
isLoadingProducts = memo2;
}
const r122 = state2 ? state.length >= 3 : state2;
const r127 = memo3.length >= 3;
const isSearchingSkuIds = enabled ? !state2 : enabled;
if (enabled) {
enabled2 = r122;
}
if (enabled2) {
enabled2 = !r127;
}
if (enabled2) {
enabled2 = isLoadingProducts;
}
if (enabled2) {
enabled2 = !state3;
}
return {
products: memo3,
isSearchingSkuIds,
isLoadingProducts,
showPlaceholderCarousel: enabled2
};
}
@@ -0,0 +1,28 @@
// Metro module 14610 (f14611).
import { useRef, useEffect } from "react";
export const INITIAL_SCROLL_DELAY_MS = 100;
export function useScrollToInitialIndexOnce(a0) {
const { initialScrollIndex, shouldScroll, flashListRef, afterMs = 100 } = a0;
let c21252_3 = afterMs;
const resetKey = a0.resetKey;
const ref = useRef(false);
const ref2 = useRef(resetKey);
useEffect(() => {
if (ref2.current !== resetKey) {
ref2.current = resetKey;
ref.current = false;
}
if (initialScrollIndex != null && shouldScroll && !ref.current) {
ref.current = true;
setTimeout(() => {
const current = flashListRef.current;
if (current != null) {
current.scrollToIndex({
animated: true,
index: initialScrollIndex
});
}
}, c21252_3);
}
}, [shouldScroll, initialScrollIndex, afterMs, flashListRef, resetKey]);
}
@@ -0,0 +1,122 @@
// Metro module 8662 (f8663).
import { useRef, useEffect, useCallback } from "react";
import { AnalyticEvents } from "../../../../Constants";
import { useCollectiblesAnalyticsContext } from "../../CollectiblesAnalyticsContext";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
import { useCurrentUser } from "../../hooks/useCurrentUser";
import PremiumUtils from "../../../../utils/PremiumUtils";
import { getShopDiscountSource, getPriceForCollectiblesProduct, getStrikeThroughPriceAmountForCollectiblesProduct, getAnalyticsShopDiscountSource } from "../../CollectiblesUtils";
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
import { trackImpression } from "../../../app_analytics/useTrackImpression";
import { ImpressionNames, ImpressionTypes } from "../../../../_bundle/Module503";
import { getProductSkuIds } from "../../utils/CollectiblesProductUtils";
export function useTrackShopCardImpression(a0, a1, a2) {
let callback, callback2;
let c16700_0 = a0;
let c16700_1 = a1;
let c16700_2 = a2;
const collectiblesAnalyticsContext = useCollectiblesAnalyticsContext();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const windowDimensions_native = useWindowDimensions_native();
const { width, height } = windowDimensions_native;
const currentUser = useCurrentUser();
const canUseCollectibles = PremiumUtils.canUseCollectibles(currentUser);
const shopDiscountSource = getShopDiscountSource(currentUser);
const ref = useRef(null);
const ref2 = useRef(null);
const ref3 = useRef({
windowWidth: width,
windowHeight: height
});
const ref4 = useRef(false);
const ref5 = useRef(false);
const ref6 = useRef(false);
const ref7 = useRef(false);
useEffect(() => {
ref3.current = {
windowWidth: width,
windowHeight: height
};
}, [width, height]);
const sessionId = collectiblesAnalyticsContext?.sessionId;
callback = useCallback(() => {
const r10 = c16700_0 != null ? getPriceForCollectiblesProduct(c16700_0, canUseCollectibles, true) : null;
const display_price_strikethrough = c16700_0 != null ? getStrikeThroughPriceAmountForCollectiblesProduct(c16700_0, canUseCollectibles, true) : void 0;
const COLLECTIBLES_TILE_IMPRESSION = AnalyticEvents.COLLECTIBLES_TILE_IMPRESSION;
AnalyticsUtils.track(COLLECTIBLES_TILE_IMPRESSION, {
collectibles_shop_session_id: collectiblesAnalyticsContext?.sessionId,
sku_id: c16700_0.skuId,
display_price: r10?.amount,
display_price_currency: r10 == null ? void 0 : r10.currency.toString(),
display_price_strikethrough,
position: collectiblesAnalyticsContext?.tilePosition,
page_category: collectiblesAnalyticsContext?.pageCategory,
page_section: collectiblesAnalyticsContext?.pageSection,
category_position: collectiblesAnalyticsContext?.categoryPosition,
type: "product"
});
}, [canUseCollectibles, sessionId, collectiblesAnalyticsContext?.tilePosition, collectiblesAnalyticsContext?.pageCategory, collectiblesAnalyticsContext?.pageSection, collectiblesAnalyticsContext?.categoryPosition, a0]);
callback2 = useCallback(() => {
trackImpression({
name: ImpressionNames.SHOP_CARD,
type: ImpressionTypes.VIEW,
properties: {
sku_id: c16700_1.skuId,
card_id: collectiblesAnalyticsContext?.cardId,
shop_session_id: collectiblesAnalyticsContext?.sessionId,
position_in_section: collectiblesAnalyticsContext?.tilePosition,
product_sku_ids: getProductSkuIds(c16700_0),
location_stack: analyticsLocations,
discount_source: getAnalyticsShopDiscountSource(shopDiscountSource)
}
}, false, true);
}, [a0, a1, collectiblesAnalyticsContext?.cardId, collectiblesAnalyticsContext?.sessionId, collectiblesAnalyticsContext?.tilePosition, analyticsLocations, shopDiscountSource]);
useEffect(() => {
if (c16700_2) {
ref2.current = setInterval(() => {
if (ref.current != null) {
ref.current.measure((a0, a1, a2, a3, a4, a5) => {
const current = ref3.current;
const { windowWidth, windowHeight } = current;
const r36 = Math.max(0, Math.min(a5 + a3, windowHeight) - Math.max(a5, 0)) * Math.max(0, Math.min(a4 + a2, windowWidth) - Math.max(a4, 0));
const r37 = a2 * a3;
const current2 = r37 > 0 && r36 > 0 && r36 / r37 >= 0;
const r61 = Math.max(0, Math.min(a5 + a3, windowHeight) - Math.max(a5, 0)) * Math.max(0, Math.min(a4 + a2, windowWidth) - Math.max(a4, 0));
const r62 = a2 * a3;
const current3 = r62 > 0 && r61 > 0 && r61 / r62 >= 0.5;
if (current2) {
if (ref4.current && !ref5.current) {
callback();
ref5.current = true;
}
} else {
ref5.current = false;
}
ref4.current = current2;
if (current3) {
if (ref6.current && !ref7.current) {
callback2();
ref7.current = true;
}
} else {
ref7.current = false;
}
ref6.current = current3;
});
}
}, 1000);
return () => {
if (ref2.current !== null) {
clearInterval(ref2.current);
ref2.current = null;
}
ref4.current = false;
ref5.current = false;
ref6.current = false;
ref7.current = false;
};
}
}, [a2, callback, callback2]);
return ref;
}
@@ -0,0 +1,16 @@
// Metro module 8762 (f8763).
import { useMemo } from "react";
import { getProductOrbPrice } from "../../utils/CollectiblesProductUtils";
import { useFetchVirtualCurrencyBalance } from "../../../virtual_currency/hooks/index";
export function useVirtualCurrencyData(a0, a1) {
const productOrbPrice = getProductOrbPrice({
product: a0,
hasShopDiscount: a1
});
const balance = useFetchVirtualCurrencyBalance().balance;
return {
price: productOrbPrice,
balance,
canAfford: useMemo(() => productOrbPrice == null ? null : balance == null ? null : productOrbPrice.amount <= balance, [productOrbPrice, balance])
};
}