decord/source/modules/premium/native/hooks/usePremiumPlanPrice.tsx

149 lines
5.4 KiB
TypeScript
Raw Normal View History

// Module ID: 9507
// Function ID: 9508
2026-07-20 16:05:17 +00:00
// Name: usePremiumPlanPrice
// Dependencies: [19, 4300, 4301, 7347, 1085, 504, 9508, 9509, 9512, 7350, 1364, 5684, 559, 7367, 7344, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
// Module 9507 (usePremiumPlanPrice)
import SubscriptionPlanActionCreators from "SubscriptionPlanActionCreators" /* 7367 */;
import noop from "module_19" /* 19 */;
import SubscriptionPlanStore from "SubscriptionPlanStore" /* 4300 */;
import SubscriptionStore from "SubscriptionStore" /* 4301 */;
import IAPStore from "IAPStore" /* 7347 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
const PaymentGateways = fn(1085).PaymentGateways;
const PremiumPlanPriceSource = { IAP: "IAP", API: "API" };
const size = fn(2);
const result = size.fileFinishedImporting("modules/premium/native/hooks/usePremiumPlanPrice.tsx");
2026-07-20 16:05:17 +00:00
export default function usePremiumPlanPrice(arg0) {
_require = arg0;
2026-07-29 08:29:29 +00:00
let formatPrice = _require;
let amount = priceState;
let obj = require("initialize");
2026-08-24 06:08:38 +00:00
const items = [closure_5];
const stateFromStores = obj.useStateFromStores(items, () => closure_5.getPremiumTypeSubscription());
const NitroACOMSubscriptionExperiment = require("ACOMExperiments").NitroACOMSubscriptionExperiment;
2026-07-20 16:05:17 +00:00
let enabled = NitroACOMSubscriptionExperiment.useConfig({ location: "usePremiumPlanPrice" }).enabled;
mobileStoreFront = mobileStoreFront(priceState[7]).useMobileStoreFront();
const obj2 = mobileStoreFront(priceState[7]);
const tmp2 = mobileStoreFront;
const items1 = [SubscriptionPlanStore];
2026-07-20 16:05:17 +00:00
const items2 = [arg0];
const stateFromStores1 = require("initialize").useStateFromStores(items1, () => {
value = null;
2026-07-23 10:11:24 +00:00
if (null != closure_0) {
value = SubscriptionPlanStore.get(tmp);
2026-07-20 16:05:17 +00:00
}
return value;
}, items2);
const obj3 = require("initialize");
({ price, priceState } = mobileStoreFront(priceState[8])(stateFromStores1, mobileStoreFront));
2026-07-20 16:05:17 +00:00
let tmp6 = null;
let tmp7 = null;
2026-07-20 16:05:17 +00:00
if (null != arg0) {
tmp7 = formatPrice(amount[9]).BasePlanIdToProductId[arg0];
2026-07-20 16:05:17 +00:00
}
noop = tmp7;
const tmp5 = mobileStoreFront(priceState[8])(stateFromStores1, mobileStoreFront);
const items3 = [IAPStore];
const items4 = [tmp7];
2026-07-29 08:29:29 +00:00
const stateFromStores2 = formatPrice(amount[5]).useStateFromStores(items3, () => {
2026-07-20 16:05:17 +00:00
let product = null;
2026-08-24 06:08:38 +00:00
if (null != closure_3) {
product = IAPStore.getProduct(tmp);
2026-07-20 16:05:17 +00:00
}
return product;
}, items4);
2026-07-29 08:29:29 +00:00
const formatPriceResult = formatPrice(amount[5]);
let isIOSResult = formatPrice(amount[10]).isIOS();
2026-07-20 16:05:17 +00:00
if (isIOSResult) {
if (!enabled) {
let isACOM;
if (stateFromStores != tmp6) {
2026-07-20 16:05:17 +00:00
isACOM = stateFromStores.isACOM;
}
enabled = true === isACOM;
}
isIOSResult = enabled;
}
SubscriptionPlanStore = isIOSResult;
const tmp11 = tmp2(amount[11])(() => new mobileStoreFront(priceState[12])(500, 10000));
closure_5 = tmp11;
const items5 = [isIOSResult, priceState, mobileStoreFront, tmp11];
const effect = noop.useEffect(() => {
2026-08-24 06:08:38 +00:00
if (closure_4) {
if (priceState !== closure_0(priceState[8]).PriceStates.PRICE_AVAILABLE) {
2026-07-29 08:29:29 +00:00
if (tmp === tmp2(tmp3[8]).PriceStates.MISMATCHING_COUNTRIES) {
2026-07-20 16:05:17 +00:00
let country;
if (mobileStoreFront != null) {
2026-07-29 08:29:29 +00:00
country = tmp6.country;
2026-07-20 16:05:17 +00:00
}
if (null != country) {
2026-08-24 06:08:38 +00:00
if (!closure_5.pending) {
2026-07-20 16:05:17 +00:00
if (!isIOSResult.isFetchingForPremiumSKUs()) {
2026-07-29 08:29:29 +00:00
if (obj.fails < 3) {
country = tmp6.country;
obj.fail(() => {
if (!SubscriptionPlanStore.isFetchingForPremiumSKUs()) {
const obj = SubscriptionPlanActionCreators;
const premiumSubscriptionPlans = obj.fetchPremiumSubscriptionPlans(country, undefined, undefined, PaymentGateways.APPLE_ADVANCED_COMMERCE);
2026-07-20 16:05:17 +00:00
premiumSubscriptionPlans.catch(() => {
});
}
});
return () => {
closure_1_5.cancel();
2026-07-20 16:05:17 +00:00
};
}
}
}
}
}
} else {
2026-08-24 06:08:38 +00:00
closure_5.succeed();
2026-07-20 16:05:17 +00:00
}
}
}, items5);
if (tmp6 == arg0) {
2026-07-20 16:05:17 +00:00
return null;
} else if (isIOSResult) {
2026-07-29 08:29:29 +00:00
if (priceState === formatPrice(amount[8]).PriceStates.PRICE_AVAILABLE) {
if (tmp6 != price) {
const obj4 = { price: null, currency: null, countryCode: null, priceString: null, source: null };
({ amount: obj7.price, currency: obj7.currency } = price);
tmp6 = mobileStoreFront == tmp6;
2026-07-20 16:05:17 +00:00
let country;
if (!tmp6) {
country = mobileStoreFront.country;
2026-07-20 16:05:17 +00:00
}
obj4.countryCode = country;
2026-07-29 08:29:29 +00:00
priceState = formatPrice(amount[14]);
formatPrice = priceState.formatPrice;
amount = price.amount;
price = formatPrice(amount, price.currency);
obj4.priceString = price;
obj4.source = obj.API;
2026-07-20 16:05:17 +00:00
}
}
} else if (tmp6 != stateFromStores2) {
const obj5 = { price: null, currency: null, countryCode: null, priceString: null, source: null };
({ price: obj6.price, currencyCode: obj6.currency } = stateFromStores2);
let country1;
if (mobileStoreFront != tmp6) {
country1 = mobileStoreFront.country;
}
if (country1 == tmp6) {
country1 = stateFromStores2.countryCode;
2026-07-20 16:05:17 +00:00
}
obj5.countryCode = country1;
obj5.priceString = stateFromStores2.priceString;
obj5.source = obj.IAP;
2026-07-20 16:05:17 +00:00
}
};
export { PremiumPlanPriceSource };