decord/source/modules/premium/PremiumSubscriptionOfferUtil.tsx

310 lines
11 KiB
TypeScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 7780
2026-07-27 11:26:19 +00:00
// Function ID: 61797
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-25 08:10:48 +00:00
// Dependencies: [57, 31, 3783, 1852, 6188, 7781, 6204, 566, 3713, 6205, 6447, 1882, 7782, 2]
2026-07-20 16:05:17 +00:00
// Exports: renewalInvoiceChurnDiscountInfo, useActiveDiscountInfo, useFetchChurnUserDiscountOffer, useIsInPremiumOfferExperience, useIsNUXEligible, useShouldFetchChurnOffer
2026-07-25 08:10:48 +00:00
// Module 7780 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
import result from "result";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import GuildFeatures from "GuildFeatures";
let closure_10;
let closure_11;
let closure_12;
let closure_13;
let closure_14;
let closure_15;
let closure_16;
let closure_17;
let closure_6;
let closure_7;
let closure_8;
let closure_9;
const require = arg1;
function _createForOfIteratorHelperLoose(iterable) {
let closure_0 = iterable;
iterable = "undefined" !== typeof Symbol;
if (iterable) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol;
2026-07-23 10:11:24 +00:00
iterable = iterable[Symbol.iterator];
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if (!iterable) {
iterable = iterable[Symbol.iterator];
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if (iterable) {
const iter = iterable.call(iterable);
2026-07-20 16:05:17 +00:00
const next = iter.next;
return next.bind(iter);
} else {
const _Array = Array;
2026-07-23 10:11:24 +00:00
let tmp = iterable;
if (!Array.isArray(iterable)) {
2026-07-20 16:05:17 +00:00
let tmp2;
2026-07-23 10:11:24 +00:00
if (iterable) {
if ("string" === typeof iterable) {
tmp2 = _arrayLikeToArray(iterable, undefined);
2026-07-20 16:05:17 +00:00
} else {
const toString = {}.toString;
2026-07-23 10:11:24 +00:00
const substr = toString.call(iterable).slice(8, -1);
2026-07-20 16:05:17 +00:00
let name = substr;
if (tmp3) {
2026-07-23 10:11:24 +00:00
name = iterable.constructor.name;
2026-07-20 16:05:17 +00:00
}
if ("Map" !== name) {
if ("Set" !== name) {
if ("Arguments" === name) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray(iterable, undefined);
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr;
}
const _Array2 = Array;
2026-07-23 10:11:24 +00:00
arr = Array.from(iterable);
const callResult = toString.call(iterable);
tmp3 = "Object" === substr && iterable.constructor;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2;
if (!tmp2) {
const _TypeError = TypeError;
const typeError = new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
throw typeError;
}
}
if (tmp) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0;
2026-07-20 16:05:17 +00:00
return () => {
2026-07-23 10:11:24 +00:00
if (closure_1 >= length.length) {
2026-07-20 16:05:17 +00:00
let obj = { done: true };
} else {
obj = { done: false };
closure_1 = tmp3 + 1;
2026-07-23 10:11:24 +00:00
obj.value = length[+closure_1];
2026-07-20 16:05:17 +00:00
}
return obj;
};
}
}
function _arrayLikeToArray(arg0, arg1) {
let length;
if (tmp) {
length = arg0.length;
}
const ArrayResult = Array(length);
for (let num = 0; num < length; num = num + 1) {
ArrayResult[num] = arg0[num];
}
return ArrayResult;
}
2026-07-23 10:11:24 +00:00
({ PREMIUM_TIER_2_ANNUAL_20_PERCENT_DISCOUNT_ID: closure_6, PREMIUM_TIER_2_ANNUAL_25_PERCENT_DISCOUNT_ID: closure_7, PREMIUM_TIER_2_ANNUAL_V2_20_PERCENT_DISCOUNT_ID: closure_8, PREMIUM_TIER_2_ANNUAL_V2_30_PERCENT_DISCOUNT_ID: closure_9, PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID: closure_10, PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID: closure_11, PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_30_PERCENT_DISCOUNT_ID: closure_12, PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_40_PERCENT_DISCOUNT_ID: closure_13, PREMIUM_TIER_2_LIKELIHOOD_DISCOUNT_ID: closure_14, PREMIUM_TIER_2_REACTIVATION_DISCOUNT_ID: closure_15, PREMIUM_TIER_2_REENGAGEMENT_1_MONTH_40_PERCENT_DISCOUNT_ID: closure_16, PREMIUM_GROUP_30_PERCENT_3_MONTH_DISCOUNT_ID: closure_17 } = GuildFeatures);
2026-07-20 16:05:17 +00:00
function useHasDiscountApplied() {
2026-07-23 10:11:24 +00:00
const items = [_isNativeReflectConstruct];
const stateFromStores = require(566) /* initialize */.useStateFromStores(items, () => outer1_5.getPremiumTypeSubscription());
2026-07-20 16:05:17 +00:00
let prop;
if (null != stateFromStores) {
const metadata = stateFromStores.metadata;
if (null != metadata) {
prop = metadata.active_discount_expires_at;
}
}
let tmp3 = null != prop;
if (tmp3) {
const _Date = Date;
2026-07-25 08:10:48 +00:00
const tmp6 = importDefault(3713);
tmp3 = importDefault(3713)(Date.now()) <= importDefault(3713)(prop);
const tmp6Result = importDefault(3713)(Date.now());
2026-07-20 16:05:17 +00:00
}
return tmp3;
}
2026-07-23 10:11:24 +00:00
const result = require("_isNativeReflectConstruct").fileFinishedImporting("modules/premium/PremiumSubscriptionOfferUtil.tsx");
2026-07-20 16:05:17 +00:00
export const useIsInPremiumOfferExperience = function useIsInPremiumOfferExperience() {
2026-07-25 08:10:48 +00:00
const premiumTrialOffer = require(6188) /* useGetTrialOffer */.usePremiumTrialOffer();
const obj = require(6188) /* useGetTrialOffer */;
const hasActiveTrial = require(7781) /* useHasActiveTrial */.useHasActiveTrial();
const obj2 = require(7781) /* useHasActiveTrial */;
const premiumDiscountOffer = require(6204) /* useGetDiscountOffer */.usePremiumDiscountOffer();
const obj3 = require(6204) /* useGetDiscountOffer */;
const premiumGroupDiscountOffer = require(6204) /* useGetDiscountOffer */.usePremiumGroupDiscountOffer();
2026-07-20 16:05:17 +00:00
let tmp6 = null != premiumTrialOffer;
2026-07-25 08:10:48 +00:00
const obj4 = require(6204) /* useGetDiscountOffer */;
2026-07-20 16:05:17 +00:00
if (!tmp6) {
tmp6 = hasActiveTrial;
}
if (!tmp6) {
tmp6 = null != premiumDiscountOffer;
}
if (!tmp6) {
tmp6 = null != premiumGroupDiscountOffer;
}
if (!tmp6) {
tmp6 = tmp5;
}
return tmp6;
};
export { useHasDiscountApplied };
export const useActiveDiscountInfo = function useActiveDiscountInfo() {
2026-07-23 10:11:24 +00:00
let obj = require(566) /* initialize */;
const items = [_isNativeReflectConstruct];
const stateFromStores = obj.useStateFromStores(items, () => outer1_5.getPremiumTypeSubscription());
2026-07-20 16:05:17 +00:00
let active_discount_id;
if (null != stateFromStores) {
const metadata = stateFromStores.metadata;
if (null != metadata) {
active_discount_id = metadata.active_discount_id;
}
}
if (closure_10 !== active_discount_id) {
if (closure_12 !== active_discount_id) {
if (closure_11 !== active_discount_id) {
if (closure_14 !== active_discount_id) {
if (closure_15 !== active_discount_id) {
if (closure_13 === active_discount_id) {
2026-07-23 10:11:24 +00:00
obj = { duration: 1, percentage: 40, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj;
} else if (closure_6 === active_discount_id) {
2026-07-23 10:11:24 +00:00
obj = { duration: 1, percentage: 20, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj;
} else if (closure_7 === active_discount_id) {
2026-07-23 10:11:24 +00:00
const obj1 = { duration: 1, percentage: 25, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj1;
} else if (closure_8 === active_discount_id) {
2026-07-23 10:11:24 +00:00
const obj2 = { duration: 12, percentage: 20, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj2;
} else if (closure_9 === active_discount_id) {
2026-07-23 10:11:24 +00:00
const obj3 = { duration: 12, percentage: 30, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj3;
} else if (closure_16 === active_discount_id) {
2026-07-23 10:11:24 +00:00
const obj4 = { duration: 1, percentage: 40, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj4;
} else if (closure_17 === active_discount_id) {
2026-07-23 10:11:24 +00:00
const obj5 = { duration: 3, percentage: 30, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj5;
}
}
}
}
2026-07-23 10:11:24 +00:00
const obj6 = { duration: 3, percentage: 30, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj6;
}
}
2026-07-23 10:11:24 +00:00
const obj7 = { duration: 1, percentage: 30, discountId: active_discount_id };
2026-07-20 16:05:17 +00:00
return obj7;
};
export const useFetchChurnUserDiscountOffer = function useFetchChurnUserDiscountOffer(arg0) {
2026-07-23 10:11:24 +00:00
let dependencyMap;
let require;
2026-07-20 16:05:17 +00:00
let tmp4;
let tmp6;
let tmp7;
let tmp9;
2026-07-23 10:11:24 +00:00
function onFetchComplete(result, arg1) {
2026-07-20 16:05:17 +00:00
callback(true);
tmp7(false);
}
2026-07-25 08:10:48 +00:00
const tmp = importDefault(6205)(closure_10);
let tmp2 = importDefault(6205)(closure_11);
2026-07-23 10:11:24 +00:00
[tmp4, require] = onFetchComplete(React.useState(false), 2);
2026-07-20 16:05:17 +00:00
const tmp3 = onFetchComplete(React.useState(false), 2);
[tmp6, tmp7] = onFetchComplete(React.useState(false), 2);
2026-07-23 10:11:24 +00:00
importDefault = tmp7;
2026-07-20 16:05:17 +00:00
const tmp5 = onFetchComplete(React.useState(false), 2);
2026-07-23 10:11:24 +00:00
[tmp9, dependencyMap] = onFetchComplete(React.useState(null), 2);
2026-07-20 16:05:17 +00:00
if (null != tmp) {
tmp2 = tmp;
}
let tmp10 = null;
if (null != tmp2) {
tmp10 = tmp2;
}
if (null != tmp10) {
let obj = { churnUserDiscountOffer: tmp10, isFetchingChurnDiscountOffer: false };
return obj;
} else if (arg0) {
obj = { churnUserDiscountOffer: tmp9, isFetchingChurnDiscountOffer: tmp6 };
return obj;
} else {
let tmp12 = tmp6;
if (!tmp6) {
tmp12 = tmp4;
}
if (!tmp12) {
tmp7(true);
2026-07-25 08:10:48 +00:00
obj = require(6447) /* _fetchUserOffer */;
2026-07-20 16:05:17 +00:00
const churnDiscountOffer = obj.fetchChurnDiscountOffer();
churnDiscountOffer.then((arg0) => {
callback2(arg0);
onFetchComplete();
}).catch(() => {
onFetchComplete();
});
const nextPromise = churnDiscountOffer.then((arg0) => {
callback2(arg0);
onFetchComplete();
});
}
const obj1 = { churnUserDiscountOffer: tmp9, isFetchingChurnDiscountOffer: tmp6 };
return obj1;
}
const tmp8 = onFetchComplete(React.useState(null), 2);
};
export const useShouldFetchChurnOffer = function useShouldFetchChurnOffer() {
2026-07-23 10:11:24 +00:00
const items = [_isNativeReflectConstruct];
const stateFromStores = require(566) /* initialize */.useStateFromStores(items, () => outer1_5.getPremiumTypeSubscription());
2026-07-20 16:05:17 +00:00
let hasPremiumNitroMonthly = null !== stateFromStores;
2026-07-23 10:11:24 +00:00
const obj = require(566) /* initialize */;
2026-07-20 16:05:17 +00:00
if (hasPremiumNitroMonthly) {
hasPremiumNitroMonthly = stateFromStores.hasPremiumNitroMonthly;
}
if (hasPremiumNitroMonthly) {
hasPremiumNitroMonthly = !tmp2;
}
if (hasPremiumNitroMonthly) {
hasPremiumNitroMonthly = tmp3;
}
return hasPremiumNitroMonthly;
};
export const renewalInvoiceChurnDiscountInfo = function renewalInvoiceChurnDiscountInfo(invoiceItems) {
let found;
const tmp = _createForOfIteratorHelperLoose(invoiceItems.invoiceItems);
const iter = tmp();
let iter2 = iter;
if (!iter.done) {
while (true) {
let discounts = iter2.value.discounts;
2026-07-23 10:11:24 +00:00
found = discounts.find((type) => type.type === outer1_0(outer1_2[11]).InvoiceDiscountTypes.SUBSCRIPTION_PLAN);
2026-07-20 16:05:17 +00:00
if (null != found) {
let discount_id = found.discount_id;
let tmp3 = closure_10;
if (closure_10 === discount_id) {
break;
} else {
let tmp4 = closure_11;
if (closure_11 === discount_id) {
let obj = {};
let num = 3;
obj.duration = 3;
({ percentage_amount: obj.percentage, discount_id: obj.discountId } = found);
return obj;
}
}
}
let iter3 = tmp();
iter2 = iter3;
}
obj = { duration: 1 };
({ percentage_amount: obj2.percentage, discount_id: obj2.discountId } = found);
return obj;
}
return null;
};
export const useIsNUXEligible = function useIsNUXEligible() {
2026-07-25 08:10:48 +00:00
return require(7782) /* useIsInReverseTrial */.useIsInReverseTrial();
2026-07-20 16:05:17 +00:00
};