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

267 lines
16 KiB
TypeScript

/* Metro module 7285; source: modules/premium/promotions/PromotionsHooks.tsx; dependencies: [31, 1878, 7064, 7261, 1880, 566, 7286, 7287, 7288, 3802, 694, 7289, 2] */
import Dispatcher from '../../../Dispatcher.tsx'; /* Metro dependency 694 */
import UserStore from '../../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import PremiumUtils from '../../../utils/PremiumUtils.tsx'; /* Metro dependency 3802 */
import UserOfferStore from '../../../stores/billing/UserOfferStore.tsx'; /* Metro dependency 7064 */
import PromotionsStore from './PromotionsStore.tsx'; /* Metro dependency 7261 */
import PromotionsActionCreators from './PromotionsActionCreators.tsx'; /* Metro dependency 7289 */
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 FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as PremiumConstantsModule from '../PremiumConstants.tsx'; /* Metro dependency 1880 */
import * as PromotionUtilsModule from './PromotionUtils.tsx'; /* Metro dependency 7286 */
import * as PremiumSubscriptionTrialUtilModule from '../PremiumSubscriptionTrialUtil.tsx'; /* Metro dependency 7287 */
import * as ReverseTrialUtilsNativeModule from '../ReverseTrialUtils.native.tsx'; /* Metro dependency 7288 */
function _fun58735(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#58735, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:6, offset: 0x016d5cc1, size: 228 bytes, params: 8, frame: 20
const env0_0 = require;
const useEligibleActiveOutboundPromotions2 = useEligibleActiveOutboundPromotions;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/premium/promotions/PromotionsHooks.tsx');
exports.useEligibleActiveOutboundPromotions = useEligibleActiveOutboundPromotions2;
exports.useOutboundPromotions = useOutboundPromotions;
exports.useUnseenOutboundPromotions = useUnseenOutboundPromotions;
exports.useBogoPromotion = function() {
var object = {};
object.promotion = require(dependencyMap[5]).useStateFromStores([PromotionsStore], _fun58764);
return object;
};
function useEligibleActiveOutboundPromotions(a0, a1, a2, a3) { // fn#58736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:159, offset: 0x016d5da5, size: 179 bytes, params: 5, frame: 23
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
return a3.useMemo(_fun58739,
[(require(566) /* metro dependency 566: flux */).useStateFromStoresArray([PromotionsStore], function() {
return PromotionsStore.outboundPromotions;
}), (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore], function() {
return PromotionsStore.consumedInboundPromotionId;
}), a2, a0, a1, a3]);
function _fun58739() { // fn#58739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:370, offset: 0x016d5e76, size: 26 bytes, params: 1, frame: 11
return env0_4.filter(_fun58740);
function _fun58740(a0) { // fn#58740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:384, offset: 0x016d5e90, size: 181 bytes, params: 2, frame: 20
var r4;
var r3;
var r2;
var r1;
var r0;
var value3;
var shouldShowOutboundPromotionOnPlatform2;
var isLogitechPromotion2;
const id = a0.id;
const value = environment.__proto__;
const value2 = id !== consumedInboundPromotionId;
if (value2) {
value3 = environment.__proto__.__proto__;
shouldShowOutboundPromotionOnPlatform2 = (require(7286) /* metro dependency 7286: PromotionUtils */).shouldShowOutboundPromotionOnPlatform(a0);
if (shouldShowOutboundPromotionOnPlatform2) {
if (importDefault) {
r2 = !importDefault;
} else {
isLogitechPromotion2 = (require(7286) /* metro dependency 7286: PromotionUtils */).isLogitechPromotion(a0);
if (isLogitechPromotion2) {
r3 = !isLogitechPromotion2;
} else {
r4 = !env1_0 && !require;
r4 = !r4 ? (require(7286) /* metro dependency 7286: PromotionUtils */).isTrialUserEligibleToSeeOutboundPromotion(a0,
importAll) : r4;
r3 = r4;
}
r2 = r3;
}
r1 = r2;
} else {
r1 = !!shouldShowOutboundPromotionOnPlatform2;
}
r0 = r1;
} else {
r0 = value2;
}
return r0;
}
}
}
function useOutboundPromotions() { // fn#58741, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:754, offset: 0x016d5f45, size: 564 bytes, params: 1, frame: 26
var r4;
const lastFetchedActivePromotions = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.lastFetchedActivePromotions;
});
const currentUser = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getCurrentUser();
});
const value2 = (PremiumSubscriptionTrialUtilModule).useHasActiveTrial();
const value3 = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserOfferStore], function() {
return UserOfferStore.hasAnyUnexpiredOffer();
});
const value4 = (ReverseTrialUtilsNativeModule).useIsInReverseTrial();
const defaultImport = PremiumUtils;
const isPremiumExactly = defaultImport.isPremiumExactly;
const TIER_2 = PremiumTypes.TIER_2;
const isPremiumExactly2 = Reflect.apply(isPremiumExactly, defaultImport, [currentUser, TIER_2]);
const isPremium2 = defaultImport.isPremium(currentUser);
let r5 = isPremium2 ? isPremiumExactly2 : !isPremium2;
const claimedOutboundPromotionCodes = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.claimedOutboundPromotionCodes;
});
const claimedOutboundPromotionCodes2 = claimedOutboundPromotionCodes;
const claimedOutboundPromotionCodesLoaded = (require(566) /* metro dependency 566: flux */).useStateFromStores([PromotionsStore],
function() {
return PromotionsStore.claimedOutboundPromotionCodesLoaded;
});
claimedOutboundPromotionCodes2.useEffect(_fun58747, [lastFetchedActivePromotions, value4]);
claimedOutboundPromotionCodes2.useEffect(_fun58749, [lastFetchedActivePromotions, r5, value4]);
claimedOutboundPromotionCodes2.useEffect(_fun58751, []);
const value6 = claimedOutboundPromotionCodes2.useMemo(_fun58753, [claimedOutboundPromotionCodes]);
const value7 = useEligibleActiveOutboundPromotions(value2, value3, value4, value6);
const value = claimedOutboundPromotionCodes2.useMemo(_fun58754, [value7, claimedOutboundPromotionCodes]);
if (claimedOutboundPromotionCodesLoaded) {
r5 = r5 ? lastFetchedActivePromotions != null : !r5;
r5 = !r5 ? value4 : r5;
r4 = r5;
} else {
r4 = claimedOutboundPromotionCodesLoaded;
}
return {promotionsLoaded: r4, activeOutboundPromotions: value7, claimedEndedOutboundPromotions: value,
claimedOutboundPromotionCodeMap: value6};
function _fun58747() { // fn#58747, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1276, offset: 0x016d61cd, size: 70 bytes, params: 1, frame: 11
var environment;
var value;
if (lastFetchedActivePromotions != null || env0_1) {
value = environment.__proto__;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.wait(_fun58748);
}
function _fun58748() { // fn#58748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1310, offset: 0x016d6213, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__;
return (PromotionsActionCreators).markOutboundPromotionsSeen();
}
}
function _fun58749() { // fn#58749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1376, offset: 0x016d6238, size: 45 bytes, params: 1, frame: 12
var environment;
const value = environment.__proto__;
(Dispatcher).wait(_fun58750);
function _fun58750() { // fn#58750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1396, offset: 0x016d6265, size: 72 bytes, params: 1, frame: 12
let value = environment.__proto__;
if (env1_2 && (lastFetchedActivePromotions == null || env1_1)) {
value = environment.__proto__.__proto__;
value = importDefault(7289) /* metro dependency 7289: PromotionsActionCreators */;
value.fetchActivePromotions();
}
}
}
function _fun58751() { // fn#58751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1478, offset: 0x016d62ad, size: 45 bytes, params: 1, frame: 12
var environment;
const value = environment.__proto__;
(Dispatcher).wait(_fun58752);
function _fun58752() { // fn#58752, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1498, offset: 0x016d62da, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__;
(PromotionsActionCreators).fetchClaimedOutboundPromotionCodes();
}
}
function _fun58753() { // fn#58753, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1575, offset: 0x016d62ff, size: 45 bytes, params: 1, frame: 11
const value = environment.__proto__;
return (PromotionUtilsModule).getClaimedOutboundPromotionCodeMap(claimedOutboundPromotionCodes);
}
function _fun58754() { // fn#58754, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1691, offset: 0x016d632c, size: 77 bytes, params: 1, frame: 14
const Set = global.Set;
const set = new Set(env0_4.map(function(a0) {
return a0.id;
}));
return claimedOutboundPromotionCodes.filter(_fun58756);
function _fun58756({promotion}) { // fn#58756, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:1749, offset: 0x016d6379, size: 175 bytes, params: 2, frame: 14
var r0;
const binding = env0_0;
let value = binding.has(promotion.id);
if (value) {
r0 = !value;
} else {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = value.isRecurringPromotion({promotionType: promotion.promotionType});
value = value === false;
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = !value.isLogitechPromotion(promotion);
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(7286) /* metro dependency 7286: PromotionUtils */;
value = value.shouldShowOutboundPromotionOnPlatform(promotion);
r0 = value;
}
return r0;
}
}
}
function useUnseenOutboundPromotions() { // fn#58757, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2111, offset: 0x016d6428, size: 208 bytes, params: 1, frame: 23
let useStateFromStores = FluxModule.useStateFromStores;
const lastSeenOutboundPromotionStartDate = Reflect.apply(useStateFromStores, FluxModule, [[PromotionsStore],
function() {
return PromotionsStore.lastSeenOutboundPromotionStartDate;
}]);
const value2 = (PremiumSubscriptionTrialUtilModule).useHasActiveTrial();
useStateFromStores = FluxModule.useStateFromStores;
const value5 = useEligibleActiveOutboundPromotions(value2, Reflect.apply(useStateFromStores, FluxModule,
[[UserOfferStore], function() {
return UserOfferStore.hasAnyUnexpiredOffer();
}]), (require(7288) /* metro dependency 7288: ReverseTrialUtilsNative */).useIsInReverseTrial(), {});
const useMemo = ReactModule.useMemo;
return Reflect.apply(useMemo, ReactModule, [_fun58760, [value5, lastSeenOutboundPromotionStartDate]]).filter(_fun58762);
function _fun58760() { // fn#58760, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2412, offset: 0x016d6507, size: 42 bytes, params: 1, frame: 12
return lastSeenOutboundPromotionStartDate == null ? env0_1 : env0_1.filter(function({startDate}) {
var Date = global.Date;
var value2 = new Date(startDate);
startDate = global.Date;
var lastSeenOutboundPromotionStartDateBinding = lastSeenOutboundPromotionStartDate;
var value4 = Object.create(startDate.prototype, {constructor: {value: startDate}});
var value5 = new startDate(lastSeenOutboundPromotionStartDateBinding);
return value2 > (value5 instanceof Object ? value5 : value4);
});
}
function _fun58762(a0) { // fn#58762, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2495, offset: 0x016d657d, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__;
return (PromotionUtilsModule).shouldShowOutboundPromotionOnPlatform(a0);
}
}
function useBogoPromotion() { // fn#58763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2569, offset: 0x016d65a6, size: 64 bytes, params: 1, frame: 14
const useStateFromStores = FluxModule.useStateFromStores;
return {promotion: Reflect.apply(useStateFromStores, FluxModule, [[PromotionsStore], function() {
return PromotionsStore.bogoPromotion;
}])};
function _fun58764() { // fn#58764, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7463:2646, offset: 0x016d65e6, size: 15 bytes, params: 1, frame: 1
return PromotionsStore.bogoPromotion;
}
}
}
global.__d(_fun58735, 7285, [31, 1878, 7064, 7261, 1880, 566, 7286, 7287, 7288, 3802, 694, 7289,
2]) /* metro module 7285, dependencies: [31, 1878, 7064, 7261, 1880, 566, 7286, 7287, 7288, 3802, 694, 7289, 2] */;