decord/source/modules/premium/promotions/PromotionsStore.tsx

427 lines
15 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 7666
// Function ID: 7667
2026-07-29 08:29:29 +00:00
// Name: createEmptyPromotionsByType
2026-08-24 06:08:38 +00:00
// Dependencies: [1340, 7667, 1922, 7668, 7694, 589, 7695, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 7666 (createEmptyPromotionsByType)
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_3 from "handleConnectionClosedOrResumed" /* 1340 */;
import closure_4 from "createFromServer" /* 7667 */;
import closure_5 from "mergeGuildAvatar" /* 1922 */;
import closure_6 from "createFromServer" /* 7668 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
function createEmptyPromotionsByType() {
2026-08-11 06:20:06 +00:00
return { [closure_0(closure_2[4]).PromotionTypes.THIRD_PARTY]: {}, [closure_0(closure_2[4]).PromotionTypes.BOGO]: {}, [closure_0(closure_2[4]).PromotionTypes.THIRD_PARTY_DIRECT_FULFILLMENT]: {}, [closure_0(closure_2[4]).PromotionTypes.MARKETING_MOMENT]: {}, [closure_0(closure_2[4]).PromotionTypes.THIRD_PARTY_INBOUND]: {}, [closure_0(closure_2[4]).PromotionTypes.THIRD_PARTY_OUTBOUND]: {}, [closure_0(closure_2[4]).PromotionTypes.GIFT_PROMOTION]: {}, [closure_0(closure_2[4]).PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING]: {} };
2026-07-20 16:05:17 +00:00
}
function getLatestActiveOutboundPromotionStartDate() {
let startDate = null;
2026-08-24 06:08:38 +00:00
const values = Object.values(dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.THIRD_PARTY_OUTBOUND]);
2026-07-29 08:29:29 +00:00
for (const item10019 of values) {
let tmp3 = item10019;
let tmp4 = startDate;
let tmp5 = null == startDate;
if (!tmp5) {
let tmp6 = item10019;
let tmp7 = startDate;
tmp5 = tmp3.startDate > startDate;
}
if (tmp5) {
let tmp8 = item10019;
startDate = tmp3.startDate;
}
continue;
2026-07-20 16:05:17 +00:00
}
let toISOStringResult;
2026-07-29 08:29:29 +00:00
if (startDate != null) {
toISOStringResult = startDate.toISOString();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (toISOStringResult == null) {
toISOStringResult = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return toISOStringResult;
2026-07-20 16:05:17 +00:00
}
function initializeFromUserSettings() {
const userContent = settings.settings.userContent;
let value;
2026-07-29 08:29:29 +00:00
if (userContent != null) {
if (userContent.lastDismissedOutboundPromotionStartDate != null) {
2026-07-20 16:05:17 +00:00
value = iter.value;
}
}
2026-07-29 08:29:29 +00:00
if (value == null) {
value = null;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
c16 = value;
2026-07-20 16:05:17 +00:00
}
2026-08-11 06:20:06 +00:00
let closure_7 = { hasFetchedConsumedInboundPromotionId: false, consumedInboundPromotionId: null, lastSeenOutboundPromotionStartDate: null };
let c9 = null;
let c10 = false;
let c11 = null;
let c12 = false;
2026-08-06 08:05:19 +00:00
let c13 = null;
2026-08-11 06:20:06 +00:00
let c14 = null;
let closure_15 = createEmptyPromotionsByType();
let c16 = null;
2026-07-23 10:11:24 +00:00
let map = new Map();
2026-08-11 06:20:06 +00:00
let c18 = null;
let closure_19 = [];
let c20 = false;
2026-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class PromotionsStore extends PersistedStore {
}
const prototype = PromotionsStore.prototype;
prototype["initialize"] = function initialize(arg0) {
if (null != arg0) {
2026-08-24 06:08:38 +00:00
closure_7 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
this.waitFor(closure_3, closure_5);
const items = [closure_3];
2026-07-29 08:29:29 +00:00
this.syncWith(items, initializeFromUserSettings);
};
Object.defineProperty(prototype, "outboundPromotions", {
get: function outboundPromotions() {
2026-08-24 06:08:38 +00:00
return Object.values(dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.THIRD_PARTY_OUTBOUND]);
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "outboundRecurringPromotions", {
get: function outboundRecurringPromotions() {
2026-08-24 06:08:38 +00:00
return Object.values(dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING]);
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "lastSeenOutboundPromotionStartDate", {
get: function lastSeenOutboundPromotionStartDate() {
2026-08-11 06:20:06 +00:00
return closure_7.lastSeenOutboundPromotionStartDate;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "lastDismissedOutboundPromotionStartDate", {
get: function lastDismissedOutboundPromotionStartDate(arg0) {
2026-08-11 06:20:06 +00:00
return c16;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "lastFetchedActivePromotions", {
get: function lastFetchedActivePromotions() {
2026-08-11 06:20:06 +00:00
return c13;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "lastFetchedActivePromotionsLocale", {
get: function lastFetchedActivePromotionsLocale() {
2026-08-11 06:20:06 +00:00
return c14;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "isFetchingActivePromotions", {
get: function isFetchingActivePromotions() {
2026-08-11 06:20:06 +00:00
return c12;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "hasFetchedConsumedInboundPromotionId", {
get: function hasFetchedConsumedInboundPromotionId() {
2026-08-11 06:20:06 +00:00
return closure_7.hasFetchedConsumedInboundPromotionId;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "consumedInboundPromotionId", {
get: function consumedInboundPromotionId() {
2026-08-11 06:20:06 +00:00
return closure_7.consumedInboundPromotionId;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "bogoPromotion", {
get: function bogoPromotion(arg0) {
2026-08-11 06:20:06 +00:00
return c9;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "isFetchingActiveBogoPromotion", {
get: function isFetchingActiveBogoPromotion() {
2026-08-11 06:20:06 +00:00
return c10;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "lastFetchedActiveBogoPromotion", {
get: function lastFetchedActiveBogoPromotion() {
2026-08-11 06:20:06 +00:00
return c11;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "promotionsByType", {
get: function promotionsByType() {
2026-08-11 06:20:06 +00:00
return closure_15;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
prototype["getPromotionByTypeAndId"] = function getPromotionByTypeAndId(MARKETING_MOMENT, promotionId) {
let tmp2;
if (dependencyMap[MARKETING_MOMENT] != null) {
tmp2 = tmp[promotionId];
}
return tmp2;
};
prototype["getPromotionByTypeAndKey"] = function getPromotionByTypeAndKey(arg0, arg1) {
2026-08-24 06:08:38 +00:00
closure_0 = arg1;
2026-07-29 08:29:29 +00:00
const values = Object.values(dependencyMap[arg0]);
return values.find((promotionKey) => promotionKey.promotionKey === closure_0);
};
prototype["getState"] = function getState() {
2026-08-11 06:20:06 +00:00
return closure_7;
2026-07-29 08:29:29 +00:00
};
prototype["getMarketingComponentByType"] = function getMarketingComponentByType(GIFT_CUSTOMIZATION_BANNER) {
2026-08-06 08:05:19 +00:00
let componentType;
if (_null != null) {
componentType = _null.componentType;
}
if (componentType === GIFT_CUSTOMIZATION_BANNER) {
2026-08-11 06:20:06 +00:00
return _null;
2026-08-06 08:05:19 +00:00
} else {
2026-08-11 06:20:06 +00:00
const currentUser2 = currentUser.getCurrentUser();
const _Date = Date;
const date = new Date();
2026-08-06 08:05:19 +00:00
let items = map.get(GIFT_CUSTOMIZATION_BANNER);
if (items == null) {
items = [];
}
2026-08-24 06:08:38 +00:00
return date(7695)(items, date, (isIncludedInRollout) => {
2026-08-14 17:33:39 +00:00
let isIncludedInRolloutResult = null != closure_0;
if (isIncludedInRolloutResult) {
isIncludedInRolloutResult = isIncludedInRollout.isIncludedInRollout(tmp.id, date);
2026-08-11 06:20:06 +00:00
}
2026-08-14 17:33:39 +00:00
return isIncludedInRolloutResult;
2026-08-11 06:20:06 +00:00
});
2026-07-29 08:29:29 +00:00
}
};
prototype["hasPromotion"] = function hasPromotion(closure_0) {
2026-08-11 06:20:06 +00:00
let values = Object.values(closure_15);
2026-07-29 08:29:29 +00:00
return values.some((arg0) => {
const values = Object.values(arg0);
return values.some((promotionKey) => promotionKey.promotionKey === closure_0);
});
};
prototype["getPromotionsByPartner"] = function getPromotionsByPartner(arg0) {
const _require = arg0;
const obj = { oneTime: null, recurring: null };
2026-08-24 06:08:38 +00:00
let values = Object.values(dependencyMap[_require(undefined, 7694).PromotionTypes.THIRD_PARTY_OUTBOUND]);
2026-07-29 08:29:29 +00:00
obj[0] = values.filter((partnerId) => partnerId.partnerId === closure_0);
2026-08-24 06:08:38 +00:00
values = Object.values(dependencyMap[_require(undefined, 7694).PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING]);
2026-07-29 08:29:29 +00:00
obj[1] = values.filter((partnerId) => partnerId.partnerId === closure_0);
return obj;
};
prototype["getGiftPromotion"] = function getGiftPromotion() {
2026-08-24 06:08:38 +00:00
const tmp = dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.GIFT_PROMOTION];
2026-07-29 08:29:29 +00:00
const keys = Object.keys(tmp);
let tmp2 = null;
if (0 !== keys.length) {
tmp2 = tmp[keys[0]];
}
return tmp2;
};
prototype["getGiftPromotionRewardSkuIds"] = function getGiftPromotionRewardSkuIds() {
const giftPromotion = this.getGiftPromotion();
let rewardSkuIds;
if (giftPromotion != null) {
rewardSkuIds = giftPromotion.rewardSkuIds;
}
if (rewardSkuIds == null) {
rewardSkuIds = [];
}
return rewardSkuIds;
};
prototype["getMarketingMomentPromotion"] = function getMarketingMomentPromotion() {
2026-08-24 06:08:38 +00:00
const tmp = dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.MARKETING_MOMENT];
2026-07-29 08:29:29 +00:00
const keys = Object.keys(tmp);
if (0 === keys.length) {
return null;
} else {
const _Date = Date;
const date = new Date();
let tmp7 = null;
if (tmp[keys[0]].endDate >= date) {
tmp7 = tmp2;
}
return tmp7;
}
};
prototype["getMarketingMomentRewardSkuIds"] = function getMarketingMomentRewardSkuIds() {
const marketingMomentPromotion = this.getMarketingMomentPromotion();
let rewardSkuIds;
if (marketingMomentPromotion != null) {
rewardSkuIds = marketingMomentPromotion.rewardSkuIds;
}
if (rewardSkuIds == null) {
rewardSkuIds = [];
}
return rewardSkuIds;
};
prototype["getActiveBogoRewardPromotion"] = function getActiveBogoRewardPromotion() {
const date = new Date();
2026-08-24 06:08:38 +00:00
const values = Object.values(dependencyMap[date(undefined, 7694).PromotionTypes.MARKETING_MOMENT]);
2026-07-29 08:29:29 +00:00
let found = values.find((hasBogoReward) => {
hasBogoReward = hasBogoReward.hasBogoReward;
if (hasBogoReward) {
hasBogoReward = hasBogoReward.endDate >= date;
}
return hasBogoReward;
});
if (found == null) {
found = null;
}
return found;
};
Object.defineProperty(prototype, "claimedOutboundPromotionCodes", {
get: function claimedOutboundPromotionCodes() {
2026-08-11 06:20:06 +00:00
return closure_19;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
Object.defineProperty(prototype, "claimedOutboundPromotionCodesLoaded", {
get: function claimedOutboundPromotionCodesLoaded() {
2026-08-11 06:20:06 +00:00
return c20;
2026-07-29 08:29:29 +00:00
},
set: undefined
});
PromotionsStore.displayName = "PromotionsStore";
PromotionsStore.persistKey = "PromotionsPersistedStore";
2026-07-23 10:11:24 +00:00
let items = [
2026-07-20 16:05:17 +00:00
(arg0) => {
2026-07-29 08:29:29 +00:00
try {
delete tmp[tmp2];
return arg0;
} catch (err) {
}
2026-07-20 16:05:17 +00:00
}
];
2026-07-29 08:29:29 +00:00
PromotionsStore.migrations = items;
2026-08-24 06:08:38 +00:00
const promotionsStore = new PromotionsStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
ACTIVE_PROMOTIONS_FETCH_SUCCESS: function handleActivePromotionsFetchSuccess(promotions) {
promotions = promotions.promotions;
2026-08-24 06:08:38 +00:00
closure_15 = createEmptyPromotionsByType();
map = new Map();
c18 = null;
2026-07-23 10:11:24 +00:00
let item = promotions.forEach((id) => {
2026-08-24 06:08:38 +00:00
const fromServer = closure_4.createFromServer(id);
2026-08-14 17:33:39 +00:00
table[id.promotion_type][id.id] = fromServer;
2026-07-20 16:05:17 +00:00
const marketing_components = id.marketing_components;
2026-07-29 08:29:29 +00:00
if (marketing_components != null) {
2026-07-20 16:05:17 +00:00
const item = marketing_components.forEach((component_type) => {
2026-08-24 06:08:38 +00:00
let items = closure_1_17.get(component_type.component_type);
2026-08-06 08:05:19 +00:00
if (items == null) {
items = [];
}
2026-08-24 06:08:38 +00:00
items.push(closure_1_6.createFromServer(component_type, fromServer));
const result = closure_1_17.set(component_type.component_type, items);
2026-07-20 16:05:17 +00:00
});
}
});
2026-08-24 06:08:38 +00:00
closure_13 = Date.now();
c12 = false;
2026-08-11 06:20:06 +00:00
if (!closure_7.hasFetchedConsumedInboundPromotionId) {
closure_7.hasFetchedConsumedInboundPromotionId = true;
closure_7.consumedInboundPromotionId = promotions.consumedInboundPromotionId;
2026-07-20 16:05:17 +00:00
}
},
ACTIVE_PROMOTIONS_FETCH: function handleActivePromotionsFetchStart(locale) {
2026-08-24 06:08:38 +00:00
c12 = true;
2026-07-20 16:05:17 +00:00
locale = locale.locale;
},
ACTIVE_PROMOTIONS_FETCH_FAIL: function handleActivePromotionsFetchFail() {
2026-08-24 06:08:38 +00:00
closure_15 = createEmptyPromotionsByType();
map = new Map();
c18 = null;
c12 = false;
2026-07-20 16:05:17 +00:00
},
ACTIVE_PROMOTIONS_CLEAR: function handleActivePromotionsClear() {
2026-08-24 06:08:38 +00:00
closure_15 = createEmptyPromotionsByType();
map = new Map();
c18 = null;
c9 = null;
c12 = false;
closure_13 = Date.now();
2026-07-20 16:05:17 +00:00
},
ACTIVE_BOGO_PROMOTION_FETCH_SUCCESS: function handleActiveBogoPromotionFetchSuccess(activePromotion) {
activePromotion = activePromotion.activePromotion;
2026-07-23 10:11:24 +00:00
const obj = { id: activePromotion.id, startDate: startDate.toISOString(), endDate: endDate.toISOString() };
2026-07-20 16:05:17 +00:00
({ startDate, endDate } = activePromotion);
2026-08-24 06:08:38 +00:00
closure_11 = Date.now();
c10 = false;
2026-07-20 16:05:17 +00:00
},
ACTIVE_BOGO_PROMOTION_FETCH: function handleActiveBogoPromotionFetchStart() {
2026-08-24 06:08:38 +00:00
c10 = true;
2026-07-20 16:05:17 +00:00
},
ACTIVE_BOGO_PROMOTION_FETCH_FAIL: function handleActiveBogoPromotionFetchFail() {
2026-08-24 06:08:38 +00:00
c9 = null;
c10 = false;
2026-07-20 16:05:17 +00:00
},
OUTBOUND_PROMOTION_NOTICE_DISMISS: function handleDismissOutboundPromotionNotice() {
2026-08-24 06:08:38 +00:00
if (0 === Object.values(dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.THIRD_PARTY_OUTBOUND]).length) {
2026-07-20 16:05:17 +00:00
return false;
} else {
const tmp2 = getLatestActiveOutboundPromotionStartDate();
if (null != tmp2) {
2026-08-24 06:08:38 +00:00
closure_16 = tmp2;
2026-07-20 16:05:17 +00:00
}
}
},
OUTBOUND_PROMOTIONS_SEEN: function handleOutboundPromotionsSeen() {
2026-08-24 06:08:38 +00:00
if (0 === Object.values(dependencyMap[require(undefined, 7694) /* CountryListMode */.PromotionTypes.THIRD_PARTY_OUTBOUND]).length) {
2026-07-20 16:05:17 +00:00
return false;
} else {
const tmp2 = getLatestActiveOutboundPromotionStartDate();
if (null != tmp2) {
2026-08-24 06:08:38 +00:00
closure_16 = tmp2;
2026-08-11 06:20:06 +00:00
closure_7.lastSeenOutboundPromotionStartDate = tmp2;
2026-07-20 16:05:17 +00:00
}
}
},
CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_SUCCESS: function handleClaimedOutboundPromotionCodesFetchSuccess(claimedOutboundPromotionCodes) {
2026-08-24 06:08:38 +00:00
closure_19 = claimedOutboundPromotionCodes.claimedOutboundPromotionCodes;
c20 = true;
2026-07-20 16:05:17 +00:00
},
CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_FAIL: function handleClaimedOutboundPromotionCodesFetchFail() {
2026-08-24 06:08:38 +00:00
closure_19 = [];
c20 = true;
2026-07-20 16:05:17 +00:00
},
CLAIMED_OUTBOUND_PROMOTION_CODE_ADD: function handleClaimedOutboundPromotionCodeAdd(claimedOutboundPromotionCode) {
claimedOutboundPromotionCode = claimedOutboundPromotionCode.claimedOutboundPromotionCode;
2026-07-23 10:11:24 +00:00
if (items.some((promotion) => promotion.promotion.id === claimedOutboundPromotionCode.promotion.id)) {
2026-07-20 16:05:17 +00:00
return false;
} else {
2026-07-23 10:11:24 +00:00
items = [];
2026-07-29 08:29:29 +00:00
items[HermesBuiltin.arraySpread(items, 0)] = claimedOutboundPromotionCode;
2026-07-20 16:05:17 +00:00
}
},
LOGOUT: function handleLogout() {
2026-08-24 06:08:38 +00:00
closure_7 = { hasFetchedConsumedInboundPromotionId: false, consumedInboundPromotionId: null, lastSeenOutboundPromotionStartDate: null };
c12 = false;
c13 = null;
c10 = false;
c11 = null;
closure_15 = createEmptyPromotionsByType();
c9 = null;
2026-07-20 16:05:17 +00:00
map.clear();
2026-08-24 06:08:38 +00:00
c18 = null;
closure_19 = [];
c20 = false;
2026-07-20 16:05:17 +00:00
},
PREMIUM_MARKETING_PREVIEW: function handlePremiumMarketingPreview(data) {
data = data.data;
2026-08-14 17:33:39 +00:00
let fromServer = null;
2026-07-20 16:05:17 +00:00
if (null != data.promotion) {
2026-08-24 06:08:38 +00:00
fromServer = closure_4.createFromServer(data.promotion);
2026-08-14 17:33:39 +00:00
}
2026-08-24 06:08:38 +00:00
closure_18 = closure_6.createFromServer(data, fromServer);
2026-08-14 17:33:39 +00:00
if (null != fromServer) {
dependencyMap[fromServer.promotionType][fromServer.id] = fromServer;
2026-07-20 16:05:17 +00:00
}
}
});
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/premium/promotions/PromotionsStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default promotionsStore;