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

+194
View File
@@ -0,0 +1,194 @@
// Metro module 5667 (f5668).
import LocaleStore from "../user_settings/LocaleStore";
import Module589 from "../../_bundle/Module589";
import { isNotNullish } from "../../utils/GlobalUtils";
import Dispatcher from "../../Dispatcher";
function $mk76656($env) {
return (a0) => {
const r0 = {
type: "sku",
skuId: a0
};
return [r0.type === "application" ? `application:${r0.applicationId}` : `skus:${r0.skuId}`, $env[0]];
};
}
let c3505_3, c3505_4, c3505_5, c3505_6;
const resetStoreState = function resetStoreState() {
c3505_3 = {};
c3505_4 = {};
c3505_5 = {};
c3505_6 = {};
};
c3505_3 = {};
c3505_4 = {};
c3505_5 = {};
c3505_6 = {};
class SKUPricesStore extends Module589.Store {
static displayName = "SKUPricesStore";
initialize() {
this.waitFor(LocaleStore);
this.syncWith([LocaleStore], resetStoreState);
}
getPricesForSkuId(a0) {
if (a0 != null) {
const pricingResultId = c3505_6[a0]?.pricingResultId;
if (pricingResultId != null) {
return c3505_4[pricingResultId];
}
}
}
getFetchStateForSkuId(a0) {
if (a0 != null) {
const r3 = {
type: "sku",
skuId: a0
};
return c3505_3[r3.type === "application" ? `application:${r3.applicationId}` : `skus:${r3.skuId}`];
}
}
getFetchStateForApplicationId(a0) {
if (a0 != null) {
const r3 = {
type: "application",
applicationId: a0
};
return c3505_3[r3.type === "application" ? `application:${r3.applicationId}` : `skus:${r3.skuId}`];
}
}
getRewardsForSkuId(a0) {
if (a0 != null) {
const r5 = c3505_6[a0];
if (r5 != null) {
return r5.rewardResultIds.map((rewardResultId) => c3505_5[rewardResultId]).filter(isNotNullish);
}
}
}
}
const sKUPricesStore = new SKUPricesStore(Dispatcher, {
LOGOUT: resetStoreState,
SKUS_PRICING_FETCH_START: function handleFetchStart({ priceId }) {
let r14;
let env14994;
const r5 = {
type: "loading"
};
const r3 = env14994 = {};
env14994[0] = r5;
if (priceId.type === "application") {
const r22 = {
...c3505_3
};
const r27 = {
type: "application",
applicationId: priceId.applicationId
};
r22[r27.type === "application" ? `application:${r27.applicationId}` : `skus:${r27.skuId}`] = r5;
r14 = r22;
} else {
r14 = {
...c3505_3,
...Object.fromEntries(priceId.skuIds.map($mk76656(r3)))
};
}
c3505_3 = r14;
},
SKUS_PRICING_FETCH_SUCCESS: function handleFetchSuccess({ priceId, data }) {
let r19, r51;
let env14995;
const fetchedAt = Date.now();
const r10 = {
type: "success",
fetchedAt
};
const r6 = env14995 = {};
env14995[0] = r10;
if (priceId.type === "application") {
const r26 = {
...c3505_3
};
const r31 = {
type: "application",
applicationId: priceId.applicationId
};
r26[r31.type === "application" ? `application:${r31.applicationId}` : `skus:${r31.skuId}`] = r10;
r19 = r26;
} else {
r19 = {
...c3505_3,
...Object.fromEntries(priceId.skuIds.map($mk76656(r6)))
};
}
c3505_3 = r19;
if (priceId.type === "application") {
let env14996;
const r47 = {
type: "skus",
skuIds: Object.keys(data.skuPriceMap)
};
const r48 = {
type: "success",
fetchedAt
};
const r49 = env14996 = {};
env14996[0] = r48;
if (r47.type === "application") {
const r64 = {
...c3505_3
};
const r69 = {
type: "application",
applicationId: r47.applicationId
};
r64[r69.type === "application" ? `application:${r69.applicationId}` : `skus:${r69.skuId}`] = r48;
r51 = r64;
} else {
r51 = {
...c3505_3,
...Object.fromEntries(r47.skuIds.map($mk76656(r49)))
};
}
c3505_3 = r51;
}
c3505_4 = {
...c3505_4,
...data.pricingResultIdMap
};
c3505_6 = {
...c3505_6,
...data.skuPriceMap
};
c3505_5 = {
...c3505_5,
...data.rewardResultIdMap
};
},
SKUS_PRICING_FETCH_FAIL: function handleFetchFail({ priceId }) {
let r18;
let env14997;
const r5 = {
type: "error",
fetchedAt: Date.now()
};
const r16 = env14997 = {};
env14997[0] = r5;
if (priceId.type === "application") {
const r25 = {
...c3505_3
};
const r30 = {
type: "application",
applicationId: priceId.applicationId
};
r25[r30.type === "application" ? `application:${r30.applicationId}` : `skus:${r30.skuId}`] = r5;
r18 = r25;
} else {
r18 = {
...c3505_3,
...Object.fromEntries(priceId.skuIds.map($mk76656(r16)))
};
}
c3505_3 = r18;
},
STOREFRONT_PROMOTION_ID_OVERRIDE_SET: resetStoreState
});
export default sKUPricesStore;
@@ -0,0 +1,193 @@
// Metro module 8682 (f8683).
import "../../stores/billing/BillingInfoStore";
import "./SKUPricesStore";
import StorefrontPromotionOverrideStore from "./StorefrontPromotionOverrideStore";
import StorefrontPromotionStore from "./StorefrontPromotionStore";
import StorefrontPromotionRecord from "./records/StorefrontPromotionRecord";
import { Endpoints } from "../../Constants";
import Durations from "../../utils/Durations";
import Dispatcher from "../../Dispatcher";
import { HTTP } from "../../_bundle/sendRequest";
import { transformStorefrontPricesServer } from "./StorefrontUtils";
function $mk115329($env) {
return (a0) => StorefrontPromotionRecord.createFromServer(a0);
}
let fetchStorefrontPromotions, fetchStorefrontPrices, c5657_9, MINUTE;
let env5657 = {};
const shouldFetchStorefrontPromotions = function shouldFetchStorefrontPromotions(a0) {
const fetchState = StorefrontPromotionStore.getFetchState(a0);
if (fetchState === void 0) {
return true;
}
if (fetchState === "loading") {
return false;
}
const fetchedAt = StorefrontPromotionStore.getFetchedAt(a0);
if (fetchedAt == null) {
return true;
}
const r11 = fetchState === "error" ? c5657_9 : MINUTE;
return Date.now() - fetchedAt > r11;
};
fetchStorefrontPromotions = async function fetchStorefrontPromotions(applicationIds) {
let c26267_1, c26267_2;
let c26267_3 = 0;
const r10 = env5657;
L16: {
try {
let env29968;
c26267_2 = r10;
const r28 = env29968 = {
$parent: r10
};
c26267_1 = r28;
env29968[0] = applicationIds;
env29968[1] = void 0;
if (applicationIds.length !== 0) {
c26267_3 = 1;
Dispatcher.dispatch({
type: "STOREFRONT_PROMOTIONS_FETCH_START",
applicationIds
});
const promotionIdOverride = StorefrontPromotionOverrideStore.getPromotionIdOverride();
env29968[1] = (await HTTP.get({
url: Endpoints.STOREFRONT_PROMOTIONS,
query: {
application_ids: applicationIds,
...promotionIdOverride != null ? {
promotion_id_override: promotionIdOverride
} : {}
},
rejectWithError: true
})).body.promotions.map($mk115329(env5657));
Dispatcher.dispatch({
type: "STOREFRONT_PROMOTIONS_FETCH_SUCCESS",
applicationIds: env29968[0],
promotions: env29968[1]
});
c26267_3 = 0;
break L16;
}
} catch ($e) {
let r27 = $e;
if (c26267_3 !== 0) {
while (true) {
try {
c26267_3 = 0;
Dispatcher.dispatch({
type: "STOREFRONT_PROMOTIONS_FETCH_FAIL",
applicationIds: env29968[0]
});
break L16;
} catch ($e) {
r27 = $e;
if (c26267_3 === 0) {
break;
}
}
}
}
throw r27;
}
return void 0;
}
};
fetchStorefrontPrices = async function fetchStorefrontPrices(a0) {
let c26270_3 = 0;
let c26270_2 = 0;
let c29971_0, c29971_1;
const r18 = void 0;
try {
const r20 = c26270_3;
if (r20 === 0) {
c29971_0 = void 0;
c29971_1 = void 0;
} else if (r20 === 1) {
c26270_2 = 0;
Dispatcher.dispatch({
type: "SKUS_PRICING_FETCH_FAIL",
priceId: c29971_0
});
} else {
c29971_1 = r18.body;
Dispatcher.dispatch({
type: "SKUS_PRICING_FETCH_SUCCESS",
priceId: c29971_0,
data: transformStorefrontPricesServer(c29971_1)
});
c26270_2 = 0;
}
} catch ($e) {
let r21 = $e;
if (c26270_2 !== 0) {
while (true) {
c26270_3 = 1;
try {
const r50 = c26270_3;
if (r50 === 0) {
c29971_0 = void 0;
c29971_1 = void 0;
} else if (r50 === 1) {
c26270_2 = 0;
Dispatcher.dispatch({
type: "SKUS_PRICING_FETCH_FAIL",
priceId: c29971_0
});
} else {
c29971_1 = r18.body;
Dispatcher.dispatch({
type: "SKUS_PRICING_FETCH_SUCCESS",
priceId: c29971_0,
data: transformStorefrontPricesServer(c29971_1)
});
c26270_2 = 0;
}
} catch ($e) {
r21 = $e;
if (c26270_2 === 0) {
break;
}
continue;
}
return void 0;
}
}
throw r21;
}
};
c5657_9 = 10 * Durations.Millis.MINUTE;
MINUTE = Durations.Millis.MINUTE;
Durations.Millis.MINUTE;
export async function maybeFetchStorefrontPromotions(c26266_0) {
L11: {
const r23 = c26266_0.filter(shouldFetchStorefrontPromotions);
if (r23.length !== 0) {
await fetchStorefrontPromotions(r23);
break L11;
}
return void 0;
}
}
export { fetchStorefrontPromotions };
export async function fetchStorefrontPricesForApplicationId(c26268_0) {
let c29969_0 = c26268_0.applicationId;
await void 0;
await (0, fetchStorefrontPrices)({
type: "application",
applicationId: c29969_0
});
}
export async function fetchStorefrontPricesForSkuIds(c26269_0) {
let c29970_0 = c26269_0.skuIds;
await void 0;
await (0, fetchStorefrontPrices)({
type: "skus",
skuIds: c29970_0
});
}
export function setStorefrontPromotionIdOverride(a0) {
Dispatcher.dispatch({
type: "STOREFRONT_PROMOTION_ID_OVERRIDE_SET",
promotionIdOverride: a0
});
}
@@ -0,0 +1,199 @@
// Metro module 14100 (f14101).
import LocaleStore from "../user_settings/LocaleStore";
import StorefrontProductStore from "./StorefrontProductStore";
import StorefrontProductRecord from "./records/StorefrontProductRecord";
import { Endpoints } from "../../Constants";
import Durations from "../../utils/Durations";
import Dispatcher from "../../Dispatcher";
import { httpGetWithCountryCodeQuery } from "../../utils/StoreUtils";
import APIError from "../../errors/APIError";
function $mk116646($env) {
return (a0) => {
if (Boolean(a0)) {
const fetchState = StorefrontProductStore.getFetchState(a0);
if (fetchState === "loading") {
return false;
}
const fetchedAt = StorefrontProductStore.getFetchedAt(a0);
if (fetchedAt != null) {
const r17 = fetchState === "error" ? c9864_9 : c9864_8;
return Date.now() - fetchedAt > r17;
}
return true;
}
return false;
};
}
let c9864_8, c9864_9;
let env9864 = {};
export function shouldFetchProductBySku(a0) {
if (Boolean(a0)) {
const fetchStateForSku = StorefrontProductStore.getFetchStateForSku(a0);
if (fetchStateForSku === "loading") {
return false;
}
const fetchedAtForSku = StorefrontProductStore.getFetchedAtForSku(a0);
if (fetchedAtForSku != null) {
const r17 = fetchStateForSku === "error" ? c9864_9 : c9864_8;
return Date.now() - fetchedAtForSku > r17;
}
return true;
}
return false;
}
c9864_8 = 12 * Durations.Millis.HOUR;
c9864_9 = 10 * Durations.Millis.MINUTE;
export async function maybeFetchProductsWithSkus(c27635_0) {
let c27635_1, c27635_2, c27635_3;
let c27635_4 = 0;
const r10 = env9864;
L14: {
try {
let env30702;
c27635_2 = r10;
const r32 = env30702 = {
$parent: r10
};
c27635_1 = r32;
env30702[0] = void 0;
env30702[1] = void 0;
env30702[0] = c27635_0.productIds;
const ignoreCache = c27635_0.ignoreCache;
if (ignoreCache !== void 0) {
env30702[1] = ignoreCache;
env30702[2] = void 0;
env30702[3] = void 0;
} else {
env30702[1] = false;
env30702[2] = void 0;
env30702[3] = void 0;
}
await void 0;
env30702[2] = env30702[0].filter($mk116646(env9864));
if (env30702[2].length !== 0) {
c27635_4 = 1;
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_WITH_SKUS_FETCH",
productIds: env30702[2]
});
env30702[3] = await httpGetWithCountryCodeQuery({
url: Endpoints.STOREFRONT_PRODUCTS_WITH_SKUS,
query: {
product_ids: env30702[2],
locale: LocaleStore.locale,
with_bundled_skus: true,
include_google_sku_ids: true,
ignore_cache: env30702[1]
},
rejectWithError: true
});
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_SUCCESS",
productIds: env30702[2],
products: env30702[3].body.products.map(StorefrontProductRecord.fromServer)
});
c27635_4 = 0;
}
} catch ($e) {
const r30 = $e;
let r8 = r30;
c27635_3 = r30;
if (c27635_4 !== 0) {
while (true) {
try {
const r119 = c27635_3;
c27635_4 = 0;
env30702[4] = r119;
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_FAILURE",
productIds: env30702[2],
apiError: new APIError(env30702[4])
});
break L14;
} catch (r115) {
r8 = r115;
c27635_3 = r115;
if (c27635_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function maybeFetchProductsBySkuIds(c27636_0) {
let c27636_3;
let c27636_4 = 0;
let c30703_0, c30703_1, c30703_2, c30703_3, c30703_4;
L14: {
try {
c30703_0 = void 0;
c30703_1 = void 0;
c30703_0 = c27636_0.skuIds;
const ignoreCache = c27636_0.ignoreCache;
if (ignoreCache !== void 0) {
c30703_1 = ignoreCache;
c30703_2 = void 0;
c30703_3 = void 0;
} else {
c30703_1 = false;
c30703_2 = void 0;
c30703_3 = void 0;
}
await void 0;
c30703_2 = c30703_0.filter(shouldFetchProductBySku);
if (c30703_2.length !== 0) {
c27636_4 = 1;
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH",
skuIds: c30703_2
});
c30703_3 = await httpGetWithCountryCodeQuery({
url: Endpoints.STOREFRONT_PRODUCTS_BY_SKU_IDS,
query: {
sku_ids: c30703_2,
locale: LocaleStore.locale,
with_bundled_skus: true,
include_google_sku_ids: true,
ignore_cache: c30703_1
},
rejectWithError: true
});
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_SUCCESS",
skuIds: c30703_2,
products: c30703_3.body.products.map(StorefrontProductRecord.fromServer)
});
c27636_4 = 0;
}
} catch ($e) {
const r30 = $e;
let r8 = r30;
c27636_3 = r30;
if (c27636_4 !== 0) {
while (true) {
try {
const r119 = c27636_3;
c27636_4 = 0;
c30703_4 = r119;
Dispatcher.dispatch({
type: "STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_FAILURE",
skuIds: c30703_2,
apiError: new APIError(c30703_4)
});
break L14;
} catch (r115) {
r8 = r115;
c27636_3 = r115;
if (c27636_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
@@ -0,0 +1,148 @@
// Metro module 14096 (f14097).
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c9862_0 = {};
let c9862_1 = {};
class StorefrontProductStore extends Module589.Store {
static displayName = "StorefrontProductStore";
getFetchState(a0) {
return a0 != null ? c9862_0[a0]?.state : void 0;
}
getFetchStateForSku(a0) {
return a0 != null ? c9862_1[a0]?.state : void 0;
}
getFetchedAt(a0) {
return a0 != null ? c9862_0[a0]?.fetchedAt : void 0;
}
getFetchedAtForSku(a0) {
return a0 != null ? c9862_1[a0]?.fetchedAt : void 0;
}
getFetchError(a0) {
return a0 != null ? c9862_0[a0]?.fetchError : void 0;
}
getFetchErrorForSku(a0) {
return a0 != null ? c9862_1[a0]?.fetchError : void 0;
}
getProduct(a0) {
const r3 = a0 != null ? c9862_0[a0] : null;
return r3 == null ? null : r3?.state !== "error" ? r3.product == null ? null : r3.product : null;
}
getProductsForSku(a0) {
return a0 != null ? c9862_1[a0]?.products : void 0;
}
}
const storefrontProductStore = new StorefrontProductStore(Dispatcher, {
STOREFRONT_PRODUCTS_WITH_SKUS_FETCH: function handleProductsWithSkusFetch(a0) {
a0.productIds.forEach((productId) => {
c9862_0[productId] = {
state: "loading",
product: c9862_0[productId]?.product
};
});
},
STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_SUCCESS: function handleProductsWithSkusFetchSuccess({ productIds, products }) {
const fetchedAt = Date.now();
let c20900_1 = new Set();
products.forEach((a0) => {
c20900_1.add(a0.id);
c9862_0[a0.id] = {
state: "success",
product: a0,
fetchedAt
};
});
productIds.forEach((productId) => {
if (!c20900_1.has(productId)) {
delete c9862_0[productId];
}
});
},
STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_FAILURE: function handleProductsWithSkusFetchFailure({ productIds, apiError }) {
const fetchedAt2 = Date.now();
productIds.forEach((productId) => {
c9862_0[productId] = {
state: "error",
fetchedAt: fetchedAt2,
fetchError: apiError
};
});
},
STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH: function handleProductsBySkuIdsFetch(a0) {
a0.skuIds.forEach((skuId) => {
c9862_1[skuId] = {
state: "loading",
products: c9862_1[skuId]?.products
};
});
},
STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_SUCCESS: function handleProductsBySkuIdsFetchSuccess({ skuIds, products }) {
const fetchedAt3 = Date.now();
let c20902_1 = products.reduce((acc, product) => {
product.skuIds.forEach((skuId) => {
if (acc[skuId] == null) {
acc[skuId] = [product];
} else {
acc[skuId].push(product);
}
});
return acc;
}, {});
skuIds.forEach((skuId) => {
if (c20902_1[skuId] != null) {
c9862_1[skuId] = {
state: "success",
products: c20902_1[skuId],
fetchedAt: fetchedAt3
};
} else {
delete c9862_1[skuId];
}
});
products.forEach((a0) => {
c9862_0[a0.id] = {
state: "success",
product: a0,
fetchedAt: fetchedAt3
};
});
},
STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_FAILURE: function handleProductsBySkuIdsFetchFailure({ skuIds, apiError: apiError2 }) {
const fetchedAt4 = Date.now();
skuIds.forEach((skuId) => {
c9862_1[skuId] = {
state: "error",
fetchedAt: fetchedAt4,
fetchError: apiError2
};
});
},
STOREFRONT_COLLECTIONS_WITH_PRODUCTS_FETCH_SUCCESS: function handleCollectionsWithProductsFetchSuccess({ collections }) {
const fetchedAt5 = Date.now();
collections.forEach((collection) => {
collection.products.forEach((a0) => {
c9862_0[a0.id] = {
state: "success",
product: a0,
fetchedAt: fetchedAt5
};
});
});
},
STOREFRONT_COLLECTIONS_FOR_APPLICATION_FETCH_SUCCESS: function handleCollectionsForApplicationFetchSuccess({ collections }) {
const fetchedAt6 = Date.now();
collections.forEach((collection) => {
collection.products.forEach((a0) => {
c9862_0[a0.id] = {
state: "success",
product: a0,
fetchedAt: fetchedAt6
};
});
});
},
LOGOUT: function handleLogout() {
c9862_0 = {};
c9862_1 = {};
}
});
export default storefrontProductStore;
@@ -0,0 +1,20 @@
// Metro module 6500 (f6501).
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let promotionIdOverride;
promotionIdOverride = void 0;
class StorefrontPromotionOverrideStore extends Module589.Store {
static displayName = "StorefrontPromotionOverrideStore";
getPromotionIdOverride() {
return promotionIdOverride;
}
}
const storefrontPromotionOverrideStore = new StorefrontPromotionOverrideStore(Dispatcher, {
LOGOUT: function handleLogout() {
promotionIdOverride = void 0;
},
STOREFRONT_PROMOTION_ID_OVERRIDE_SET: function handleSet(a0) {
promotionIdOverride = a0.promotionIdOverride;
}
});
export default storefrontPromotionOverrideStore;
@@ -0,0 +1,84 @@
// Metro module 8683 (f8684).
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c5658_0;
const handleReset = function handleReset() {
c5658_0 = {};
};
c5658_0 = {};
class StorefrontPromotionStore extends Module589.Store {
static displayName = "StorefrontPromotionStore";
getFetchState(a0) {
return c5658_0[a0]?.state;
}
getFetchedAt(a0) {
const r7 = c5658_0[a0];
if (r7?.state !== "success" && r7?.state !== "error") {
return void 0;
}
return r7.fetchedAt;
}
getPromotionsForApplication(a0) {
let r11;
const r7 = c5658_0[a0];
const state = r7?.state;
L9: {
if (state !== "success") {
const state2 = r7?.state;
r11 = null;
if (state2 !== "loading") {
break L9;
}
}
let promotions = r7.promotions;
if (promotions == null) {
promotions = null;
}
r11 = promotions;
}
return r11;
}
}
const storefrontPromotionStore = new StorefrontPromotionStore(Dispatcher, {
LOGOUT: handleReset,
STOREFRONT_PROMOTIONS_FETCH_START: function handleFetchStart(a0) {
for (const applicationId of a0.applicationIds) {
const r11 = c5658_0[applicationId];
c5658_0[applicationId] = {
state: "loading",
promotions: r11?.state === "success" ? [...r11.promotions] : void 0
};
}
},
STOREFRONT_PROMOTIONS_FETCH_SUCCESS: function handleFetchSuccess({ applicationIds, promotions }) {
const fetchedAt = Date.now();
const r27 = {
...c5658_0
};
for (const item of applicationIds) {
r27[item] = {
state: "success",
promotions: [],
fetchedAt
};
}
for (const item2 of promotions) {
const applicationId = item2.applicationId;
if (r27[applicationId]?.state === "success") {
r27[applicationId].promotions.push(item2);
}
}
c5658_0 = r27;
},
STOREFRONT_PROMOTIONS_FETCH_FAIL: function handleFetchFail({ applicationIds }) {
const fetchedAt = Date.now();
for (const item of applicationIds) {
c5658_0[item] = {
state: "error",
fetchedAt
};
}
},
STOREFRONT_PROMOTION_ID_OVERRIDE_SET: handleReset
});
export default storefrontPromotionStore;
+36
View File
@@ -0,0 +1,36 @@
// Metro module 5668 (f5669).
const r9 = {
DISCOUNT: 1,
1: "DISCOUNT",
FIXED_PRICE: 2,
2: "FIXED_PRICE",
ACTION: 3,
3: "ACTION"
};
const r18 = {
FLAT: 1,
1: "FLAT",
PERCENT: 2,
2: "PERCENT"
};
const r21 = {
SELF_PURCHASE: 0,
0: "SELF_PURCHASE",
GIFT: 1,
1: "GIFT"
};
const r25 = {
NORMAL: 0,
0: "NORMAL",
DISCOUNTED: 1,
1: "DISCOUNTED"
};
const r28 = {
TAG: "TAG",
NITRO: "NITRO"
};
export { r9 as StorefrontPromotionRewardType };
export { r18 as StorefrontDiscountTypes };
export { r21 as StorefrontPurchaseType };
export { r25 as StorefrontPriceVariant };
export { r28 as StorefrontPromotionCollectiblesIcon };
+323
View File
@@ -0,0 +1,323 @@
// Metro module 5666 (f5667).
import { useMemo } from "react";
import LocaleStore from "../user_settings/LocaleStore";
import UserStore from "../../stores/UserStore";
import SKUPricesStore from "./SKUPricesStore";
import { PriceSetAssignmentPurchaseTypes, PriceTypes, CurrencyCodes, SKUProductLines, SKUFlags } from "../../Constants";
import { PremiumTypes } from "../premium/PremiumConstants";
import Module12 from "../../_bundle/Module12";
import { StorefrontPromotionRewardType, StorefrontPriceVariant, StorefrontPurchaseType } from "./StorefrontTypes";
import * as _Module501 from "../../_bundle/Module501";
import { isIOS } from "../../_bundle/Module501";
import { hasFlag } from "../../_bundle/Module1384";
import { useStateFromStores, useStateFromStoresArray } from "../../_bundle/Module589";
import { getPrice } from "../slayer_storefront/SlayerStorefrontUtils";
import { formatPrice, formatPercent } from "../../utils/PriceUtils";
import PremiumUtils from "../../utils/PremiumUtils";
import { getOrbPriceFromPrices } from "../virtual_currency/checkout/OrbCheckoutUtils";
function $mk76642() {
return (a0) => ({
currency: a0.currency,
amount: a0.amount
});
}
function $mk76645($env) {
return () => {
const r4 = $env.$parent[6];
let r7 = $env[0]?.id;
if (r7 == null) {
r7 = null;
}
return r4.getPricesForSkuId(r7);
};
}
function $mk76646($env) {
return () => {
let r8, r13, SELF_PURCHASE;
const r4 = $env;
const r6 = $env.$parent;
const r5 = r4[1];
if (r5 == null) {
const r28 = r6[0];
const r29 = r6[2];
SELF_PURCHASE = r28(r29[7]).StorefrontPurchaseType.SELF_PURCHASE;
r13 = r29;
r8 = r28;
} else {
const r3 = r6[8];
if (r3.DEFAULT === r5) {
const r22 = r6[0];
const r23 = r6[2];
SELF_PURCHASE = r22(r23[7]).StorefrontPurchaseType.SELF_PURCHASE;
r13 = r23;
r8 = r22;
} else if (r3.GIFT === r5) {
const r9 = r6[0];
const r10 = r6[2];
SELF_PURCHASE = r9(r10[7]).StorefrontPurchaseType.GIFT;
r13 = r10;
r8 = r9;
} else {
const r12 = r6[0];
r13 = r6[2];
SELF_PURCHASE = r12(r13[7]).StorefrontPurchaseType.SELF_PURCHASE;
r8 = r12;
}
}
if (r4[0] != null) {
const r35 = r4[3];
if (r35 != null) {
let pricesForPurchaseType2 = r35[SELF_PURCHASE];
if (pricesForPurchaseType2 == null) {
pricesForPurchaseType2 = r35[r8(r13[7]).StorefrontPurchaseType.SELF_PURCHASE];
}
const r42 = pricesForPurchaseType2 == null;
let userPrice4 = void 0;
if (!r42) {
const userPrice3 = pricesForPurchaseType2.userPrice;
userPrice4 = userPrice3 == null ? void 0 : userPrice3.find($mk104605(r4));
}
return {
userPrice: userPrice4,
pricesForPurchaseType: pricesForPurchaseType2,
purchaseType: SELF_PURCHASE,
storeHasPrice: true
};
}
}
return {
userPrice: void 0,
pricesForPurchaseType: void 0,
purchaseType: SELF_PURCHASE,
storeHasPrice: r4[3] != null
};
};
}
function $mk76651($env) {
return () => {
const r1 = $env;
return (0, $env.$parent[14])(r1[0], r1[1]);
};
}
function $mk104605($env) {
return (a0) => {
const r0 = $env[2];
const currency = a0.currency;
const DISCORD_ORB = $env.$parent[7].DISCORD_ORB;
return r0 ? currency === DISCORD_ORB : currency !== DISCORD_ORB;
};
}
let formatSKUPrice;
let $mk76650 = function() {
return () => LocaleStore.locale;
};
let env3504 = {};
export function useSKUPrice({ sku, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT }) {
let stateFromStores;
let env14989;
const DEFAULT = priceSetAssignmentPurchaseType;
stateFromStores = void 0;
const r7 = env14989 = {
$parent: env3504
};
env14989[0] = sku;
env14989[1] = DEFAULT;
env14989[2] = false;
env14989[3] = void 0;
const stateFromStores3 = useStateFromStores([SKUPricesStore], $mk76645(r7));
env14989[3] = stateFromStores3;
const memo2 = useMemo($mk76646(r7), [sku, stateFromStores3, DEFAULT, false]);
const { userPrice, pricesForPurchaseType, purchaseType, storeHasPrice } = memo2;
const stateFromStoresArray = useStateFromStoresArray([SKUPricesStore], () => {
let r8 = SKUPricesStore.getRewardsForSkuId(sku?.id);
if (r8 == null) {
r8 = [];
}
return r8;
});
stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
return useMemo(() => {
let normalPrice2;
if (sku == null) {
return {
normalPrice: null,
discountedPrice: null,
discountPercent: null,
userPrice: null
};
}
if (storeHasPrice) {
const r29 = stateFromStoresArray.find((item) => {
const r7 = item[purchaseType];
if (r7 == null) {
return false;
}
const type = r7.type;
if (StorefrontPromotionRewardType.DISCOUNT === type) {
return true;
}
if (StorefrontPromotionRewardType.FIXED_PRICE !== type && StorefrontPromotionRewardType.ACTION !== type) {
r7.type;
return false;
}
return false;
});
const r31 = r29 != null ? r29[purchaseType] : null;
const discountedPrice = r31 != null ? userPrice != null ? userPrice : null : null;
const discountPercent = r31 != null ? r31.amount > 0 ? r31.amount : null : null;
if (r31 != null) {
const r43 = pricesForPurchaseType == null;
let r44 = void 0;
if (!r43) {
const r47 = pricesForPurchaseType.prices[PriceTypes.BASE];
const r48 = r47 == null;
r44 = void 0;
if (!r48) {
const r54 = r47[StorefrontPriceVariant.NORMAL];
r44 = r54 == null ? void 0 : r54.find((item) => item.currency !== CurrencyCodes.DISCORD_ORB);
}
}
normalPrice2 = r44;
} else {
normalPrice2 = userPrice;
}
if (normalPrice2 == null) {
normalPrice2 = null;
}
let userPrice3 = userPrice;
if (userPrice == null) {
userPrice3 = null;
}
return {
normalPrice: normalPrice2,
discountedPrice,
discountPercent,
userPrice: userPrice3
};
}
let normalPrice = sku.productLine === SKUProductLines.SOCIAL_LAYER_GAME_ITEM ? getPrice(sku, DEFAULT) : sku.getPrice(stateFromStores?.premiumType);
if (normalPrice == null) {
normalPrice = null;
}
return {
normalPrice,
discountedPrice: null,
discountPercent: null,
userPrice: normalPrice
};
}, [sku, DEFAULT, stateFromStores?.premiumType, storeHasPrice, userPrice, pricesForPurchaseType, purchaseType, stateFromStoresArray]);
}
formatSKUPrice = function formatSKUPrice({ normalPrice, discountedPrice, discountPercent, userPrice: userPrice3 }, a1) {
return {
normalPrice: normalPrice != null ? formatPrice(normalPrice.amount, normalPrice.currency) : null,
discountedPrice: discountedPrice != null ? formatPrice(discountedPrice.amount, discountedPrice.currency) : null,
discountPercent: discountPercent != null ? formatPercent(a1, -discountPercent / 100) : null,
userPrice: userPrice3 != null ? formatPrice(userPrice3.amount, userPrice3.currency) : null
};
};
export function transformStorefrontPricesServer(a0) {
return {
skuPriceMap: Module12.mapValues(a0.sku_price_map, (a0) => ({
pricingResultId: a0.pricing_result_id,
rewardResultIds: a0.reward_result_ids
})),
pricingResultIdMap: Module12.mapValues(a0.pricing_result_id_map, (a0) => Module12.mapValues(a0, (a0) => ({
userPrice: a0.user_price.map($mk76642()),
prices: Module12.mapValues(a0.prices, (a0) => Module12.mapValues(a0, (a0) => a0.map($mk76642())))
}))),
rewardResultIdMap: Module12.mapValues(a0.reward_result_id_map, (a0) => Module12.mapValues(a0, (a0) => ({
type: a0.type,
amount: a0.amount
})))
};
}
export function transformPriceSetAssignmentToStorefrontPurchaseType(a0) {
if (a0 == null) {
return StorefrontPurchaseType.SELF_PURCHASE;
}
if (PriceSetAssignmentPurchaseTypes.DEFAULT === a0) {
return StorefrontPurchaseType.SELF_PURCHASE;
}
if (PriceSetAssignmentPurchaseTypes.GIFT === a0) {
return StorefrontPurchaseType.GIFT;
}
return StorefrontPurchaseType.SELF_PURCHASE;
}
export function isSlayerSkuAvailableOnThisPlatform(a0) {
let r22;
if (a0 != null && a0.productLine === SKUProductLines.SOCIAL_LAYER_GAME_ITEM) {
let r8 = a0?.flags;
if (r8 == null) {
r8 = 0;
}
if (isIOS()) {
r22 = hasFlag(r8, SKUFlags.AVAILABLE_ON_IOS);
} else {
const isAndroid = _Module501.isAndroid();
r22 = isAndroid ? hasFlag(r8, SKUFlags.AVAILABLE_ON_ANDROID) : !isAndroid;
}
return r22;
}
return false;
}
export function useFormattedSKUPrice({ sku: sku3, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT }) {
let env14991;
const sKUPrice = useSKUPrice({
sku: sku3,
priceSetAssignmentPurchaseType
});
const r10 = env14991 = {
$parent: env3504
};
env14991[0] = sKUPrice;
env14991[1] = void 0;
const stateFromStores3 = useStateFromStores([LocaleStore], $mk76650());
env14991[1] = stateFromStores3;
return useMemo($mk76651(r10), [sKUPrice, stateFromStores3]);
}
export function useFormatSKUPrice(a0) {
let env14990;
const r1 = env14990 = {
$parent: env3504
};
env14990[0] = a0;
const stateFromStores3 = useStateFromStores([LocaleStore], $mk76650());
env14990[1] = stateFromStores3;
return useMemo($mk76651(r1), [a0, stateFromStores3]);
}
export { formatSKUPrice };
export function useSKUOrbPrice({ sku: sku2, priceSetAssignmentPurchaseType = PriceSetAssignmentPurchaseTypes.DEFAULT }) {
let memo;
let env14993;
memo = void 0;
const r6 = env14993 = {
$parent: env3504
};
env14993[0] = sku2;
env14993[1] = priceSetAssignmentPurchaseType;
env14993[2] = true;
env14993[3] = void 0;
const stateFromStores3 = useStateFromStores([SKUPricesStore], $mk76645(r6));
env14993[3] = stateFromStores3;
const memo2 = useMemo($mk76646(r6), [sku2, stateFromStores3, priceSetAssignmentPurchaseType, true]);
const { userPrice: userPrice2, storeHasPrice: storeHasPrice2 } = memo2;
const stateFromStores2 = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
memo = useMemo(() => PremiumUtils.isPremium(stateFromStores2, PremiumTypes.TIER_2), [stateFromStores2]);
return useMemo(() => {
if (sku2 == null) {
return null;
}
if (storeHasPrice2) {
let r19 = userPrice2;
if (userPrice2 == null) {
r19 = null;
}
return r19;
}
const orbPriceFromPrices = getOrbPriceFromPrices(sku2.prices, memo);
return orbPriceFromPrices != null ? {
amount: orbPriceFromPrices.amount,
currency: orbPriceFromPrices.currency
} : null;
}, [sku2, memo, storeHasPrice2, userPrice2]);
}
@@ -0,0 +1,21 @@
// Metro module 8681 (f8682).
import { useEffect } from "react";
import { fetchStorefrontPricesForApplicationId, fetchStorefrontPricesForSkuIds } from "../StorefrontActionCreators";
export function useGetOrFetchStorefrontPricesForApplicationId({ applicationId }) {
useEffect(() => {
if (applicationId != null) {
fetchStorefrontPricesForApplicationId({
applicationId
});
}
}, [applicationId]);
}
export function useGetOrFetchStorefrontPricesForSkuIds({ skuIds }) {
useEffect(() => {
if (skuIds.length !== 0) {
fetchStorefrontPricesForSkuIds({
skuIds
});
}
}, [skuIds]);
}
@@ -0,0 +1,36 @@
// Metro module 9758 (f9759).
import { useEffect, useMemo } from "react";
import { loadInAppSkus } from "../../../actions/native/GPlayActionCreators";
import { useStateFromStores } from "../../../_bundle/Module589";
import IAPStore_android from "../../../stores/native/IAPStore.android";
export function useFormattedSKUPrice({ sku, priceSetAssignmentPurchaseType }) {
let stateFromStores;
stateFromStores = void 0;
const r2 = sku == null;
let r10 = void 0;
if (!r2) {
const googleSkuIds = sku.googleSkuIds;
r10 = googleSkuIds == null ? void 0 : googleSkuIds[priceSetAssignmentPurchaseType];
}
if (r10 == null) {
r10 = null;
}
let c17466_0 = r10;
useEffect(() => {
if (c17466_0 != null) {
loadInAppSkus([c17466_0]);
}
}, [r10]);
stateFromStores = useStateFromStores([IAPStore_android], () => c17466_0 != null ? IAPStore_android.getProduct(c17466_0) : null, [r10]);
return useMemo(() => stateFromStores?.priceString != null ? {
normalPrice: stateFromStores.priceString,
discountedPrice: null,
discountPercent: null,
userPrice: stateFromStores.priceString
} : {
normalPrice: null,
discountedPrice: null,
discountPercent: null,
userPrice: null
}, [stateFromStores]);
}
@@ -0,0 +1,99 @@
// Metro module 5817 (f5818).
import CollectiblesStoreListingStylesRecord from "../../collectibles/records/CollectiblesStoreListingStylesRecord";
import { AssetDisplayConfigRecord } from "../../collectibles/records/ShopAssetConfigRecord";
import StorefrontProductRecord from "./StorefrontProductRecord";
class StorefrontCollectionRecord {
constructor(a0) {
this.id = a0.id;
this.applicationId = a0.applicationId;
this.name = a0.name;
this.description = a0.description;
this.products = a0.products;
this.createdAt = a0.createdAt;
this.updatedAt = a0.updatedAt;
this.unpublishedAt = a0.unpublishedAt;
this.willUnpublishAt = a0.willUnpublishAt;
this.styles = a0.styles;
this.bannerTextColor = a0.bannerTextColor;
this.heroRanking = a0.heroRanking;
this.heroDisplayConfig = a0.heroDisplayConfig;
this.heroLogoDisplayConfig = a0.heroLogoDisplayConfig;
this.heroUrl = a0.heroUrl;
this.heroRiveUrl = a0.heroRiveUrl;
this.heroAnimatedUrl = a0.heroAnimatedUrl;
this.heroLogoUrl = a0.heroLogoUrl;
this.heroBannerUrl = a0.heroBannerUrl;
this.heroBannerAnimatedUrl = a0.heroBannerAnimatedUrl;
this.catalogBannerUrl = a0.catalogBannerUrl;
this.catalogBannerRiveUrl = a0.catalogBannerRiveUrl;
this.catalogBannerAnimatedUrl = a0.catalogBannerAnimatedUrl;
this.featuredBlockUrl = a0.featuredBlockUrl;
this.logoUrl = a0.logoUrl;
this.pdpBgUrl = a0.pdpBgUrl;
this.wideBannerUrl = a0.wideBannerUrl;
this.wideBannerAnimatedUrl = a0.wideBannerAnimatedUrl;
this.mobileHeroUrl = a0.mobileHeroUrl;
this.mobileHeroAnimatedUrl = a0.mobileHeroAnimatedUrl;
this.mobileBannerUrl = a0.mobileBannerUrl;
this.mobileBgUrl = a0.mobileBgUrl;
this.shopButtonBgHoverUrl = a0.shopButtonBgHoverUrl;
this.upsellBannerPopoutUrl = a0.upsellBannerPopoutUrl;
this.upsellBannerUrl = a0.upsellBannerUrl;
this.heroBlockTitle = a0.heroBlockTitle;
this.featuredBlockBody = a0.featuredBlockBody;
this.mobileHeroBlockTitle = a0.mobileHeroBlockTitle;
this.mobileProductsTitle = a0.mobileProductsTitle;
this.mobileSummary = a0.mobileSummary;
this.wideBannerTitle = a0.wideBannerTitle;
this.wideBannerBody = a0.wideBannerBody;
}
static fromServer({ application_id, created_at, updated_at, unpublished_at, unpublish_settings, tenant_metadata, ...rest }) {
let collectibles = tenant_metadata.collectibles;
if (collectibles == null) {
collectibles = {};
}
return new StorefrontCollectionRecord({
...rest,
applicationId: application_id,
products: rest.products.map(StorefrontProductRecord.fromServer),
createdAt: new Date(created_at),
updatedAt: new Date(updated_at),
unpublishedAt: unpublished_at != null ? new Date(unpublished_at) : void 0,
willUnpublishAt: unpublish_settings?.will_unpublish_at != null ? new Date(unpublish_settings.will_unpublish_at) : void 0,
styles: collectibles.styles != null ? CollectiblesStoreListingStylesRecord.fromServer(collectibles.styles) : void 0,
bannerTextColor: collectibles.banner_text_color,
heroRanking: collectibles.hero_ranking,
heroDisplayConfig: collectibles.hero_display_config != null ? AssetDisplayConfigRecord.fromServer(collectibles.hero_display_config) : void 0,
heroLogoDisplayConfig: collectibles.hero_logo_display_config != null ? AssetDisplayConfigRecord.fromServer(collectibles.hero_logo_display_config) : void 0,
heroUrl: collectibles.hero_url,
heroRiveUrl: collectibles.hero_rive_url,
heroAnimatedUrl: collectibles.hero_animated_url,
heroLogoUrl: collectibles.hero_logo_url,
heroBannerUrl: collectibles.hero_banner_url,
heroBannerAnimatedUrl: collectibles.hero_banner_animated_url,
catalogBannerUrl: collectibles.catalog_banner_url,
catalogBannerRiveUrl: collectibles.catalog_banner_rive_url,
catalogBannerAnimatedUrl: collectibles.catalog_banner_animated_url,
featuredBlockUrl: collectibles.featured_block_url,
logoUrl: collectibles.logo_url,
pdpBgUrl: collectibles.pdp_bg_url,
wideBannerUrl: collectibles.wide_banner_url,
wideBannerAnimatedUrl: collectibles.wide_banner_animated_url,
mobileHeroUrl: collectibles.mobile_hero_url,
mobileHeroAnimatedUrl: collectibles.mobile_hero_animated_url,
mobileBannerUrl: collectibles.mobile_banner_url,
mobileBgUrl: collectibles.mobile_bg_url,
shopButtonBgHoverUrl: collectibles.shop_button_bg_hover_url,
upsellBannerPopoutUrl: collectibles.upsell_banner_popout_url,
upsellBannerUrl: collectibles.upsell_banner_url,
heroBlockTitle: collectibles.hero_block_title,
featuredBlockBody: collectibles.featured_block_body,
mobileHeroBlockTitle: collectibles.mobile_hero_block_title,
mobileProductsTitle: collectibles.mobile_products_title,
mobileSummary: collectibles.mobile_summary,
wideBannerTitle: collectibles.wide_banner_title,
wideBannerBody: collectibles.wide_banner_body
});
}
}
export default StorefrontCollectionRecord;
@@ -0,0 +1,57 @@
// Metro module 5819 (f5820).
import CollectiblesStoreListingStylesRecord from "../../collectibles/records/CollectiblesStoreListingStylesRecord";
import SKURecord from "../../skus/SKURecord";
class StorefrontProductRecord {
constructor(a0) {
this.id = a0.id;
this.skuIds = a0.skuIds;
this.name = a0.name;
this.summary = a0.summary;
this.options = a0.options;
this.createdAt = a0.createdAt;
this.updatedAt = a0.updatedAt;
this.skus = a0.skus;
this.primaryCollectionId = a0.primaryCollectionId;
this.primaryCollectionStyles = a0.primaryCollectionStyles;
this.primaryCollectionPdpBgUrl = a0.primaryCollectionPdpBgUrl;
this.primaryCollectionWillUnpublishAt = a0.primaryCollectionWillUnpublishAt;
this.gameApplicationId = a0.gameApplicationId;
}
static fromServer({ sku_ids, options, created_at, updated_at, skus, tenant_metadata, ...rest }) {
const r4 = {
...rest,
skuIds: sku_ids,
options: options.map((option) => ({
name: option.name,
optionValues: option.option_values
})),
createdAt: new Date(created_at),
updatedAt: new Date(updated_at),
skus: skus.map((sku) => SKURecord.createFromServer(sku)),
primaryCollectionId: tenant_metadata.collectibles?.primary_collection_id,
primaryCollectionStyles: tenant_metadata.collectibles?.primary_collection_styles != null ? CollectiblesStoreListingStylesRecord.fromServer(tenant_metadata.collectibles.primary_collection_styles) : void 0,
primaryCollectionPdpBgUrl: tenant_metadata.collectibles?.primary_collection_pdp_bg_url,
primaryCollectionWillUnpublishAt: tenant_metadata.collectibles?.primary_collection_will_unpublish_at != null ? new Date(tenant_metadata.collectibles.primary_collection_will_unpublish_at) : void 0
};
const guild_monetization = tenant_metadata.guild_monetization;
r4.gameApplicationId = guild_monetization == null ? void 0 : guild_monetization.game_server?.game_application_id;
const r72 = {
__proto__: StorefrontProductRecord.prototype
};
r72.id = r4.id;
r72.skuIds = r4.skuIds;
r72.name = r4.name;
r72.summary = r4.summary;
r72.options = r4.options;
r72.createdAt = r4.createdAt;
r72.updatedAt = r4.updatedAt;
r72.skus = r4.skus;
r72.primaryCollectionId = r4.primaryCollectionId;
r72.primaryCollectionStyles = r4.primaryCollectionStyles;
r72.primaryCollectionPdpBgUrl = r4.primaryCollectionPdpBgUrl;
r72.primaryCollectionWillUnpublishAt = r4.primaryCollectionWillUnpublishAt;
r72.gameApplicationId = r4.gameApplicationId;
return r72;
}
}
export default StorefrontProductRecord;
@@ -0,0 +1,158 @@
// Metro module 8684 (f8685).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import Record from "../../../lib/Record";
import { $callWithNewTarget } from "../../../_hermes/prelude";
const parseSkuIds = function parseSkuIds(sku_ids) {
if (sku_ids == null) {
return null;
}
const r1 = {};
for (const item of Object.entries(sku_ids)) {
const r30 = _slicedToArray(item, 2);
r1[r30[0]] = {
priceTiers: r30[1].price_tiers
};
}
return r1;
};
class StorefrontPromotionRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.applicationId = a0.applicationId;
this.displayName = a0.displayName;
this.rewardType = a0.rewardType;
this.rewardConfig = a0.rewardConfig;
this.skuIds = a0.skuIds;
this.appliesToAllSkus = a0.appliesToAllSkus;
this.includeBundles = a0.includeBundles;
this.startsAt = a0.startsAt;
this.endsAt = a0.endsAt;
this.tenantMetadata = a0.tenantMetadata;
}
static createFromServer(a0) {
let r91;
const { id, application_id } = a0;
let display_name = a0.display_name;
if (display_name == null) {
display_name = null;
}
const reward_type = a0.reward_type;
const r2 = a0.reward_config != null;
let rewardConfig = null;
if (r2) {
const reward_config = a0.reward_config;
rewardConfig = reward_config == null ? null : {
discount: reward_config.discount != null ? {
id: reward_config.discount.id,
type: reward_config.discount.type,
amount: reward_config.discount.amount,
fiatEnabled: reward_config.discount.fiat_enabled,
orbsEnabled: reward_config.discount.orbs_enabled
} : null
};
}
const skuIds = parseSkuIds(a0.sku_ids);
const { applies_to_all_skus, include_bundles } = a0;
const startsAt = a0.starts_at != null ? new Date(a0.starts_at) : null;
const endsAt = a0.ends_at != null ? new Date(a0.ends_at) : null;
const r60 = a0.tenant_metadata != null;
let tenantMetadata = null;
if (r60) {
const tenant_metadata = a0.tenant_metadata;
const r3 = tenant_metadata.collectibles != null;
let collectibles2 = void 0;
if (r3) {
const collectibles = tenant_metadata.collectibles;
const reward = collectibles.reward;
const r67 = reward == null ? void 0 : reward.storefront?.nagbar;
const reward2 = collectibles.reward;
const r72 = reward2 == null ? void 0 : reward2.checkout?.offer_notice;
if (r67 == null && r72 == null) {
r91 = {};
} else {
const r75 = r67 != null;
let storefront = void 0;
if (r75) {
let header_text = r67.header_text;
if (header_text == null) {
header_text = void 0;
}
const r78 = r67.cta != null;
let cta = void 0;
if (r78) {
let text = r67.cta.text;
if (text == null) {
text = void 0;
}
cta = {
text
};
}
let help_center_id = r67.help_center_id;
if (help_center_id == null) {
help_center_id = void 0;
}
let icon = r67.icon;
if (icon == null) {
icon = void 0;
}
storefront = {
nagbar: {
headerText: header_text,
cta,
helpCenterId: help_center_id,
icon
}
};
}
const r85 = r72 != null;
let checkout = void 0;
if (r85) {
let icon2 = r72.icon;
if (icon2 == null) {
icon2 = void 0;
}
let text2 = r72.text;
if (text2 == null) {
text2 = void 0;
}
checkout = {
offerNotice: {
icon: icon2,
text: text2
}
};
}
r91 = {
reward: {
storefront,
checkout
}
};
}
collectibles2 = r91;
}
tenantMetadata = {
collectibles: collectibles2
};
}
const prototypeOf = Object.getPrototypeOf(StorefrontPromotionRecord);
const r98 = Object.create(StorefrontPromotionRecord.prototype);
const r100 = $callWithNewTarget(prototypeOf, r98, StorefrontPromotionRecord);
const r101 = r100 instanceof Object ? r100 : r98;
r101.id = id;
r101.applicationId = application_id;
r101.displayName = display_name;
r101.rewardType = reward_type;
r101.rewardConfig = rewardConfig;
r101.skuIds = skuIds;
r101.appliesToAllSkus = applies_to_all_skus;
r101.includeBundles = include_bundles;
r101.startsAt = startsAt;
r101.endsAt = endsAt;
r101.tenantMetadata = tenantMetadata;
return r101;
}
}
export default StorefrontPromotionRecord;