878 lines
37 KiB
TypeScript
878 lines
37 KiB
TypeScript
// Metro module 6217 (f6218).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import { useState, useMemo, useCallback } from "react";
|
|
import { View, ActivityIndicator } from "react-native";
|
|
import { useNativeCheckoutStore } from "../../checkout/native/NativeCheckoutStore";
|
|
import LocaleStore from "../../user_settings/LocaleStore";
|
|
import IAPStore_android from "../../../stores/native/IAPStore.android";
|
|
import { reset, setMobileWebRedirectCheckoutStatus, usePremiumPlanPurchasedStore, setInitiatedPurchaseFromNewFlow } from "./PremiumPlanPurchasedStore";
|
|
import { SubscriptionPlans, DISCOUNTS, SubscriptionPlanInfo, PRICE_PLACEHOLDER, SubscriptionIntervalTypes, PremiumTypes, PremiumSubscriptionSKUs, PREMIUM_PLAN_SELECTION_ACTION_SHEET_KEY } from "../PremiumConstants";
|
|
import { AnalyticEvents, AnalyticsObjects, AnalyticsObjectTypes, MarketingURLs, HelpdeskArticles } from "../../../Constants";
|
|
import { TitleStyleType } from "../../../design/void/Form/native/FormConstants";
|
|
import { ItemPurchaseType, EUR_TO_HRK_CONVERSION_RATE } from "../../payments/PaymentConstants";
|
|
import { CurrencyCodes, PaymentGateways } from "../../../_bundle/Module505";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import PremiumUtils, { getTierDisplayNameByPlanId, castPremiumSubscriptionAsSkuId } from "../../../utils/PremiumUtils";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import Module38 from "../../../_bundle/Module38";
|
|
import PremiumPlanActionSheetHeader from "./PremiumPlanActionSheetHeader";
|
|
import { formatPercent } from "../../../utils/NumberUtils";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { useCheckoutPlanPriceString } from "./hooks/useCheckoutPlanPriceString";
|
|
import { formatRate, formatPrice } from "../../../utils/PriceUtils";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import { useHandlePremiumPurchase } from "./handlePremiumPurchase.android";
|
|
import { useIsPaymentsBlocked } from "../../billing/experiments/BlockedPaymentsCountryExperiment";
|
|
import useTheme from "../../../hooks/useTheme";
|
|
import { usePremiumTrialOffer } from "../hooks/usePremiumTrialOffer.android";
|
|
import { usePremiumDiscountOffer } from "../hooks/usePremiumDiscountOffer.android";
|
|
import { useDiscountedPremiumProductInfo } from "./hooks/useDiscountedPremiumProductInfo";
|
|
import { useBottomSheetRef } from "../../../design/components/Sheet/native/useBottomSheetRef";
|
|
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
|
|
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
|
|
import useInitialValue from "../../../hooks/useInitialValue";
|
|
import { getNewAnalyticsLoadId, getBasePurchaseFlowAnalyticsFields, PaymentFlowStep, getPaymentFlowStepAnalyticsFields } from "./PremiumAnalyticsUtils";
|
|
import * as _MobileWebRedirectCheckoutUtils from "../../payments/utils/MobileWebRedirectCheckoutUtils";
|
|
import { getCustomCheckoutFlowForAnalytics } from "../../payments/utils/MobileWebRedirectCheckoutUtils";
|
|
import useMountEffect from "../../../hooks/useMountEffect";
|
|
import { trackPaymentFlowStartedAnalyticsAndCTP } from "../../experiments/trigger_points/PaymentFlowStartedTriggerPoint";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { goToStandalonePremiumCheckoutFromMobileApp } from "../../payments/native/utils/BillingStandaloneNativeUtils";
|
|
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
|
|
import AlertActionCreators from "../../../actions/native/AlertActionCreators";
|
|
import InvalidGooglePlayPurchase from "../../billing/errors/InvalidGooglePlayPurchase";
|
|
import { fetchSubscriptions } from "../../billing/actions/BillingActionCreators";
|
|
import { getSubscriptionItemsForProduct, getPremiumBundlesWithPredicate } from "./PremiumBundledPlansUtils";
|
|
import { isThemeDark } from "../../../design/shared";
|
|
import Module6315 from "../../../_bundle/Module6315";
|
|
import Module6316 from "../../../_bundle/Module6316";
|
|
import Module6317 from "../../../_bundle/Module6317";
|
|
import Module6318 from "../../../_bundle/Module6318";
|
|
import Module6319 from "../../../_bundle/Module6319";
|
|
import Module6320 from "../../../_bundle/Module6320";
|
|
import { isAndroid, isIOS } from "../../../utils/PlatformUtils";
|
|
import HelpdeskUtils from "../../../utils/HelpdeskUtils";
|
|
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
|
|
import BlockedPaymentsCountryDisplay from "../../billing/native/BlockedPaymentsCountryDisplay";
|
|
import { ActionSheetHeaderBar } from "../../../design/components/Sheet/native/ActionSheetHeaderBar.native";
|
|
import FastImage from "../../../components_native/common/FastImage";
|
|
import FormSection from "../../../design/void/Form/native/FormSection";
|
|
import PaymentFlowWarningMessage from "../../billing/native/PaymentFlowWarningMessage";
|
|
import { RadioGroup } from "../../../design/void/native";
|
|
import { NitroACOMSubscriptionExperiment } from "../../billing/native/ACOMExperiments";
|
|
import { useIsEligibleForBogoOffer } from "./hooks/useIsEligibleForBogoOffer.android";
|
|
import NativeCheckoutStoreProvider from "../../checkout/native/stores/NativeCheckoutStoreProvider";
|
|
function $mk78038($env) {
|
|
return ({ additionalPlans, isDeprecated, numPremiumGuild, premiumTier }) => additionalPlans.length === 0 && !isDeprecated && numPremiumGuild === 0 && premiumTier === $env[0];
|
|
}
|
|
function $mk114907($env) {
|
|
return () => {
|
|
if (isMetaQuest()) {
|
|
(0, reset)();
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
} else {
|
|
const r9 = $env;
|
|
(0, setMobileWebRedirectCheckoutStatus)("in_mobile_web");
|
|
AnalyticsUtils.track(AnalyticEvents.PAYMENT_FLOW_STEP, r9[4]);
|
|
}
|
|
};
|
|
}
|
|
function $mk114908($env) {
|
|
return () => {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.NrBVjw),
|
|
body: intl.string(t["gD+grx"]),
|
|
hideActionSheet: true
|
|
});
|
|
};
|
|
}
|
|
let PlanOptionBadgeComponent, PlanOption, PremiumPlanSelectionActionSheetCTA, PremiumPlanSelectionActionSheet, _excluded, useStyles;
|
|
let env3945 = {};
|
|
const Header = function Header(props) {
|
|
let premiumType2 = props.premiumType;
|
|
const { isPaymentSuccess, selectedPremiumType, trialOffer, discountOffer } = props;
|
|
const styles = useStyles();
|
|
const r23 = (0, useNativeCheckoutStore)((a0) => ({
|
|
orderRequired: a0.orderRequired,
|
|
orderRecord: a0.orderRecord
|
|
}));
|
|
const { orderRequired, orderRecord } = r23;
|
|
if (premiumType2 == null && !isPaymentSuccess) {
|
|
return <Text style={styles.headerText} variant="text-md/semibold" color="text-default" accessibilityRole="header">
|
|
{intl.string(t.vLz3Zs)}
|
|
</Text>;
|
|
}
|
|
if (isPaymentSuccess) {
|
|
premiumType2 = selectedPremiumType;
|
|
}
|
|
Module38(premiumType2 != null, "If isPaymentSuccess is true, a value must be given for selectedPremiumType. Or premiumType must be given.");
|
|
let r44 = trialOffer != null && premiumType2 != null;
|
|
if (r44) {
|
|
let r51 = trialOffer.subscription_trial?.sku_id === PremiumUtils.getSkuIdForPremiumType(premiumType2);
|
|
if (r51) {
|
|
let r3 = !orderRequired;
|
|
if (orderRequired) {
|
|
const trial_id = trialOffer.trial_id;
|
|
const r4 = orderRecord == null;
|
|
let r53 = void 0;
|
|
if (!r4) {
|
|
const subscriptionFacet = orderRecord.subscriptionFacet;
|
|
r53 = subscriptionFacet == null ? void 0 : subscriptionFacet.subscriptionPreview?.subscriptionTrialId;
|
|
}
|
|
r3 = trial_id === r53;
|
|
}
|
|
r51 = r3;
|
|
}
|
|
r44 = r51;
|
|
}
|
|
return (0, jsx)(PremiumPlanActionSheetHeader, {
|
|
premiumType: premiumType2,
|
|
trialOffer: r44 ? trialOffer : null,
|
|
discountOffer
|
|
});
|
|
};
|
|
PlanOptionBadgeComponent = function PlanOptionBadgeComponent(props) {
|
|
const { text, backgroundColorType = "green" } = props;
|
|
const styles = useStyles();
|
|
const style = [styles.planOptionDiscount, ,];
|
|
const r1 = backgroundColorType === "white";
|
|
style[1] = r1 ? styles.planOptionDiscountWhite : null;
|
|
return <View style={style}>
|
|
<Text style={styles.planOptionDiscountText} variant="text-xs/bold" color={r1 ? "text-overlay-dark" : "text-overlay-light"}>{text}</Text>
|
|
</View>;
|
|
};
|
|
PlanOption = function PlanOption(props) {
|
|
let r30, r222;
|
|
const { premiumItem, selectedProductId, optionNeedsProductNameLabel: optionNeedsProductNameLabel2 } = props;
|
|
let customBadgeComponent = props.customBadgeComponent;
|
|
const { trialOffer, discountOffer, discountedPriceString: discountedPriceString2 } = props;
|
|
let userIsEligibleForBogoPromotion2 = props.userIsEligibleForBogoPromotion;
|
|
if (userIsEligibleForBogoPromotion2 === void 0) {
|
|
userIsEligibleForBogoPromotion2 = false;
|
|
}
|
|
const selectedPremiumType = props.selectedPremiumType;
|
|
const styles = useStyles();
|
|
const [state, setState] = useState(0);
|
|
const stateFromStores = useStateFromStores([IAPStore_android], () => IAPStore_android.getProduct(premiumItem.productId));
|
|
let price = useCheckoutPlanPriceString(premiumItem.productId, stateFromStores);
|
|
const r60 = (0, useNativeCheckoutStore)((a0) => ({
|
|
orderRequired: a0.orderRequired,
|
|
orderRecord: a0.orderRecord
|
|
}));
|
|
const { orderRequired, orderRecord } = r60;
|
|
const premiumTier = premiumItem.premiumTier;
|
|
let r4 = trialOffer != null && premiumTier != null;
|
|
if (r4) {
|
|
let r68 = trialOffer.subscription_trial?.sku_id === PremiumUtils.getSkuIdForPremiumType(premiumTier);
|
|
if (r68) {
|
|
let r6 = !orderRequired;
|
|
if (orderRequired) {
|
|
const trial_id = trialOffer.trial_id;
|
|
const r7 = orderRecord == null;
|
|
let r70 = void 0;
|
|
if (!r7) {
|
|
const subscriptionFacet = orderRecord.subscriptionFacet;
|
|
r70 = subscriptionFacet == null ? void 0 : subscriptionFacet.subscriptionPreview?.subscriptionTrialId;
|
|
}
|
|
r6 = trial_id === r70;
|
|
}
|
|
r68 = r6;
|
|
}
|
|
r4 = r68;
|
|
}
|
|
const tierDisplayNameByPlanId = getTierDisplayNameByPlanId(premiumItem.basePlanId);
|
|
const intervalString = PremiumUtils.getIntervalString(premiumItem.interval, false);
|
|
const basePlanId = premiumItem.basePlanId;
|
|
const PREMIUM_YEAR_TIER_2 = SubscriptionPlans.PREMIUM_YEAR_TIER_2;
|
|
const r31 = r4 || discountOffer != null || (userIsEligibleForBogoPromotion2 ? basePlanId === PREMIUM_YEAR_TIER_2 : userIsEligibleForBogoPromotion2);
|
|
const r41 = r31 ? null : DISCOUNTS[premiumItem.basePlanId];
|
|
if (userIsEligibleForBogoPromotion2) {
|
|
userIsEligibleForBogoPromotion2 = premiumItem.basePlanId === SubscriptionPlans.PREMIUM_MONTH_TIER_2;
|
|
}
|
|
const productId2 = premiumItem.productId;
|
|
const r35 = stateFromStores == null ? CurrencyCodes.USD : stateFromStores.currencyCode.toLowerCase() in CurrencyCodes ? stateFromStores.currencyCode.toLowerCase() : CurrencyCodes.USD;
|
|
const r104 = SubscriptionPlanInfo[premiumItem.basePlanId];
|
|
const discountedPrice = discountedPriceString2 != null ? formatRate(discountedPriceString2, r104.interval, r104.intervalCount) : null;
|
|
if (r4) {
|
|
r30 = intl.formatToPlainString(t.hXcaLT, {
|
|
price: formatPrice(0, r35, {
|
|
minimumFractionDigits: 0,
|
|
maximumFractionDigits: 0
|
|
})
|
|
});
|
|
} else {
|
|
r30 = discountedPriceString2;
|
|
if (r30 == null) {
|
|
r30 = price == null ? PRICE_PLACEHOLDER : price;
|
|
}
|
|
}
|
|
const regularPrice = formatRate(price == null ? PRICE_PLACEHOLDER : price, r104.interval, r104.intervalCount);
|
|
const style = state > 0 ? [styles.planOptionPriceContainer, {
|
|
transform: [{
|
|
translateY: state / 2
|
|
}]
|
|
}] : styles.planOptionPriceContainer;
|
|
const variant = discountOffer == null ? r4 ? "text-lg/medium" : "text-md/medium" : "text-lg/medium";
|
|
const r148 = productId2 === selectedProductId;
|
|
let color = "interactive-text-default";
|
|
const r159 = [<Text variant={variant} color={r148 ? "interactive-text-active" : "interactive-text-default"}>
|
|
{optionNeedsProductNameLabel2 ? `${tierDisplayNameByPlanId} ${intervalString}` : intervalString}
|
|
</Text>, ,];
|
|
if (customBadgeComponent == null) {
|
|
customBadgeComponent = r31 ? null : userIsEligibleForBogoPromotion2 ? <PlanOptionBadgeComponent text={intl.string(t.iQTfWx)} /> : r41 != null ? <PlanOptionBadgeComponent text={intl.format(t.IAybsG, {
|
|
discount: formatPercent(LocaleStore.locale, r41 / 100)
|
|
})} /> : null;
|
|
}
|
|
const r202 = [<View style={styles.planOptionDiscountContainer}>
|
|
{customBadgeComponent}
|
|
<Text style={styles.priceText} variant="text-lg/medium" color={r148 ? "interactive-text-active" : "interactive-text-default"}>{r30}</Text>
|
|
</View>, , ,];
|
|
let r203 = null;
|
|
if (r4) {
|
|
const color2 = r148 ? "text-default" : "interactive-text-default";
|
|
if (premiumItem.interval === SubscriptionIntervalTypes.YEAR) {
|
|
const ECT4A5 = t.ECT4A5;
|
|
if (price == null) {
|
|
price = PRICE_PLACEHOLDER;
|
|
}
|
|
r222 = intl.formatToPlainString(ECT4A5, {
|
|
price
|
|
});
|
|
} else {
|
|
r222 = intl.formatToPlainString(t.v9QeON, {
|
|
price: price == null ? PRICE_PLACEHOLDER : price
|
|
});
|
|
}
|
|
r203 = <Text variant="text-xs/medium" color={color2}>{r222}</Text>;
|
|
}
|
|
r202[1] = r203;
|
|
const props2 = {
|
|
style: styles.discountSubTextContainer,
|
|
onLayout: (a0) => {
|
|
const height = a0.nativeEvent.layout.height;
|
|
if (height !== state) {
|
|
setState(height);
|
|
}
|
|
},
|
|
children: null
|
|
};
|
|
const r235 = discountedPrice != null;
|
|
let r236 = null;
|
|
if (r235) {
|
|
const r237 = discountOffer != null;
|
|
r236 = null;
|
|
if (r237) {
|
|
const r238 = selectedPremiumType == null;
|
|
r236 = null;
|
|
if (r238) {
|
|
const color3 = r148 ? "text-default" : "interactive-text-default";
|
|
const r251 = t["02Gmgm"];
|
|
let numMonths = discountOffer.discount?.userUsageLimit;
|
|
if (numMonths == null) {
|
|
numMonths = 1;
|
|
}
|
|
r236 = <Text variant="text-sm/medium" color={color3}>
|
|
{intl.formatToPlainString(r251, {
|
|
discountedPrice,
|
|
numMonths
|
|
})}
|
|
</Text>;
|
|
}
|
|
}
|
|
}
|
|
const children = [r236, ,];
|
|
let r258 = discountedPriceString2 != null && discountOffer != null;
|
|
if (r258) {
|
|
if (r148) {
|
|
color = "text-default";
|
|
}
|
|
const r270 = t["vZk+c/"];
|
|
let numMonths2 = discountOffer.discount?.userUsageLimit;
|
|
if (numMonths2 == null) {
|
|
numMonths2 = 1;
|
|
}
|
|
r258 = <Text variant="text-sm/medium" color={color}>
|
|
{intl.formatToPlainString(r270, {
|
|
regularPrice,
|
|
numMonths: numMonths2
|
|
})}
|
|
</Text>;
|
|
}
|
|
children[1] = r258;
|
|
props2.children = children;
|
|
r202[2] = <View {...props2} />;
|
|
r159[1] = <View style={style}>{r202}</View>;
|
|
return <View style={styles.planOptionContainer}>{r159}</View>;
|
|
};
|
|
PremiumPlanSelectionActionSheetCTA = function PremiumPlanSelectionActionSheetCTA(props) {
|
|
const { isPaymentSuccess, onClose: onClose2, ctaText, onStartPayment, shouldUseMobileWebRedirectCheckout, disabled, loading } = props;
|
|
if (isPaymentSuccess) {
|
|
return <Button text={intl.string(t.WAI6xu)} size="md" grow onPress={onClose2} />;
|
|
}
|
|
return <Button text={ctaText} {...shouldUseMobileWebRedirectCheckout ? {
|
|
size: "lg",
|
|
variant: "primary"
|
|
} : {
|
|
size: "md",
|
|
variant: "active"
|
|
}} grow onPress={() => onStartPayment({
|
|
shouldRedirectToMobileWeb: shouldUseMobileWebRedirectCheckout
|
|
})} loading={loading} disabled={disabled} />;
|
|
};
|
|
PremiumPlanSelectionActionSheet = function PremiumPlanSelectionActionSheet(props) {
|
|
let r309, r387, r400;
|
|
let env15588 = {
|
|
$parent: env3945
|
|
};
|
|
env15588[0] = props.applicationId;
|
|
const { analyticsLocation, analyticsLocations, premiumType: premiumType2 } = props;
|
|
env15588[1] = premiumType2;
|
|
const premiumItems = props.premiumItems;
|
|
env15588[2] = premiumItems;
|
|
const { userIsEligibleForBogoPromotion: userIsEligibleForBogoPromotion2, initialSelectedItem, onPaymentSuccess } = props;
|
|
env15588[3] = onPaymentSuccess;
|
|
const onPaymentDismiss = props.onPaymentDismiss;
|
|
env15588[4] = onPaymentDismiss;
|
|
let showFormTitle = props.showFormTitle;
|
|
if (showFormTitle === void 0) {
|
|
showFormTitle = true;
|
|
}
|
|
env15588[5] = void 0;
|
|
env15588[6] = void 0;
|
|
env15588[7] = void 0;
|
|
env15588[8] = void 0;
|
|
env15588[9] = void 0;
|
|
env15588[10] = void 0;
|
|
env15588[11] = void 0;
|
|
env15588[12] = void 0;
|
|
env15588[13] = void 0;
|
|
env15588[14] = void 0;
|
|
env15588[15] = void 0;
|
|
env15588[16] = void 0;
|
|
env15588[17] = void 0;
|
|
env15588[18] = void 0;
|
|
env15588[19] = void 0;
|
|
env15588[20] = void 0;
|
|
env15588[22] = void 0;
|
|
env15588[21] = function _onPlanSelectionChange() {
|
|
const r9 = async (c29691_0) => {
|
|
let c29691_1, c29691_2;
|
|
L19: {
|
|
L18: {
|
|
L16: {
|
|
let env31403;
|
|
c29691_2 = env15588;
|
|
const r11 = env31403 = {
|
|
$parent: env3945
|
|
};
|
|
c29691_1 = r11;
|
|
env31403[0] = c29691_0;
|
|
env31403[1] = void 0;
|
|
const r26 = env15588[2].find((item) => item.productId === env31403[0]);
|
|
env31403[1] = r26;
|
|
if (r26 == null) {
|
|
break L19;
|
|
}
|
|
if (r26 === env15588[13]) {
|
|
break L19;
|
|
}
|
|
const subscriptionItemsForProduct = getSubscriptionItemsForProduct(c29691_0);
|
|
if (env15588[10]) {
|
|
if (await (0, env15588[9])(subscriptionItemsForProduct.map((item) => ({
|
|
sku_id: castPremiumSubscriptionAsSkuId(PremiumUtils.getSkuIdForPlan(item.planId)),
|
|
subscription_plan_id: item.planId,
|
|
quantity: item.quantity,
|
|
purchase_type: ItemPurchaseType.SUBSCRIPTION
|
|
}))) != null) {
|
|
(0, env15588[14])(env31403[1]);
|
|
break L18;
|
|
}
|
|
break L16;
|
|
}
|
|
(0, env15588[14])(env31403[1]);
|
|
break L19;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
env15588[21] = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const styles = useStyles();
|
|
env15588[5] = styles;
|
|
const premiumPlanPurchasedStore2 = usePremiumPlanPurchasedStore((a0) => a0.isPaymentSuccess);
|
|
env15588[6] = premiumPlanPurchasedStore2;
|
|
const premiumPlanPurchasedStore = usePremiumPlanPurchasedStore((a0) => a0.mobileWebRedirectCheckoutStatus);
|
|
let loading = useStateFromStores([IAPStore_android], () => IAPStore_android.isBusy());
|
|
const handlePremiumPurchase = useHandlePremiumPurchase();
|
|
env15588[7] = handlePremiumPurchase;
|
|
const isPaymentsBlocked = useIsPaymentsBlocked();
|
|
const theme = useTheme();
|
|
const nativeCheckoutStore = useNativeCheckoutStore((a0) => a0.orderRecord);
|
|
env15588[8] = nativeCheckoutStore;
|
|
const nativeCheckoutStore2 = useNativeCheckoutStore((a0) => ({
|
|
patchOrderLineItems: a0.patchOrderLineItems,
|
|
isPatchOrderLoading: a0.isPatchOrderLoading,
|
|
orderRequired: a0.orderRequired
|
|
}));
|
|
env15588[9] = nativeCheckoutStore2.patchOrderLineItems;
|
|
let isPatchOrderLoading = nativeCheckoutStore2.isPatchOrderLoading;
|
|
const orderRequired = nativeCheckoutStore2.orderRequired;
|
|
env15588[10] = orderRequired;
|
|
const nativeCheckoutStore3 = useNativeCheckoutStore((a0) => a0.isCreateOrderLoading);
|
|
if (!isPatchOrderLoading) {
|
|
isPatchOrderLoading = nativeCheckoutStore3;
|
|
}
|
|
const premiumTrialOffer2 = usePremiumTrialOffer();
|
|
const premiumDiscountOffer2 = usePremiumDiscountOffer();
|
|
let r2 = premiumTrialOffer2 != null && premiumType2 != null;
|
|
if (r2) {
|
|
let r94 = premiumTrialOffer2.subscription_trial?.sku_id === PremiumUtils.getSkuIdForPremiumType(premiumType2);
|
|
if (r94) {
|
|
let r5 = !orderRequired;
|
|
if (orderRequired) {
|
|
const trial_id = premiumTrialOffer2.trial_id;
|
|
const r6 = nativeCheckoutStore == null;
|
|
let r96 = void 0;
|
|
if (!r6) {
|
|
const subscriptionFacet = nativeCheckoutStore.subscriptionFacet;
|
|
r96 = subscriptionFacet == null ? void 0 : subscriptionFacet.subscriptionPreview?.subscriptionTrialId;
|
|
}
|
|
r5 = trial_id === r96;
|
|
}
|
|
r94 = r5;
|
|
}
|
|
r2 = r94;
|
|
}
|
|
env15588[11] = r2;
|
|
const discountedPremiumProductInfo = useDiscountedPremiumProductInfo(premiumDiscountOffer2, premiumItems);
|
|
const { discountedProduct, discountedPriceString: discountedPriceString2 } = discountedPremiumProductInfo;
|
|
env15588[12] = discountedPriceString2;
|
|
const r109 = _slicedToArray(useState(initialSelectedItem), 2);
|
|
const r34 = r109[0];
|
|
env15588[13] = r34;
|
|
env15588[14] = r109[1];
|
|
const stateFromStores = useStateFromStores([IAPStore_android], () => {
|
|
const r2 = env15588[13];
|
|
return r2 != null ? IAPStore_android.getProduct(r2.productId) : null;
|
|
});
|
|
const bottomSheetRef = useBottomSheetRef().bottomSheetRef;
|
|
const analyticsLocations2 = useAnalyticsLocations(analyticsLocations, AnalyticsLocation.PREMIUM_PAYMENT_ACTION_SHEET).analyticsLocations;
|
|
env15588[15] = analyticsLocations2;
|
|
const initialValue = useInitialValue(() => getNewAnalyticsLoadId());
|
|
env15588[16] = initialValue;
|
|
const memo = useMemo(() => castPremiumSubscriptionAsSkuId(PremiumUtils.getSkuIdForPremiumType(env15588[1])), [premiumType2]);
|
|
env15588[17] = memo;
|
|
const basePurchaseFlowAnalyticsFields = getBasePurchaseFlowAnalyticsFields({
|
|
analyticsLoadId: initialValue,
|
|
analyticsLocation: {
|
|
object: AnalyticsObjects.BUTTON_CTA,
|
|
object_type: AnalyticsObjectTypes.BUY,
|
|
...analyticsLocation
|
|
},
|
|
analyticsLocations: analyticsLocations2
|
|
});
|
|
env15588[18] = basePurchaseFlowAnalyticsFields;
|
|
const r145 = r34 != null ? r34.basePlanId : null;
|
|
const onClose = function onClose() {
|
|
(0, reset)();
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
};
|
|
env15588[19] = r145;
|
|
const isMobileWebRedirectCheckoutEnabled = _MobileWebRedirectCheckoutUtils.isMobileWebRedirectCheckoutEnabled();
|
|
env15588[20] = isMobileWebRedirectCheckoutEnabled;
|
|
useMountEffect(() => {
|
|
trackPaymentFlowStartedAnalyticsAndCTP({
|
|
...env15588[18],
|
|
application_id: env15588[0],
|
|
subscription_plan_id: env15588[19],
|
|
sku_id: env15588[17],
|
|
custom_checkout_flow: env15588[20] ? getCustomCheckoutFlowForAnalytics() : void 0
|
|
});
|
|
});
|
|
const callback = useCallback(async function(c25749_0) {
|
|
let c25749_1, c25749_2, c25749_3;
|
|
let c25749_4 = 0;
|
|
const r12 = env15588;
|
|
L25: {
|
|
try {
|
|
let env29692;
|
|
c25749_2 = r12;
|
|
const r37 = env29692 = {
|
|
$parent: r12
|
|
};
|
|
c25749_1 = r37;
|
|
env29692[0] = void 0;
|
|
let r16 = c25749_0;
|
|
if (r16 === void 0) {
|
|
r16 = {
|
|
shouldRedirectToMobileWeb: false
|
|
};
|
|
}
|
|
env29692[0] = r16.shouldRedirectToMobileWeb;
|
|
env29692[1] = void 0;
|
|
env29692[2] = void 0;
|
|
env29692[3] = void 0;
|
|
env29692[4] = void 0;
|
|
await void 0;
|
|
Module38(env15588[13] != null, "cannot start payment without a selectedItem");
|
|
env29692[1] = env15588[13].basePlanId;
|
|
env29692[2] = env15588[20] && env29692[0];
|
|
env29692[3] = env29692[2] ? PaymentFlowStep.MOBILE_WEB_REDIRECT_CHECKOUT : PaymentFlowStep.EXTERNAL_PAYMENT;
|
|
env29692[4] = getPaymentFlowStepAnalyticsFields(env15588[18], {
|
|
from_step: PaymentFlowStep.PLAN_SELECT,
|
|
to_step: env29692[3],
|
|
subscription_plan_gateway_plan_id: env15588[13].productId,
|
|
sku_id: env15588[17]
|
|
});
|
|
if (!env29692[2]) {
|
|
AnalyticsUtils.track(AnalyticEvents.PAYMENT_FLOW_STEP, env29692[4]);
|
|
}
|
|
(0, setInitiatedPurchaseFromNewFlow)({
|
|
productId: env15588[13].productId,
|
|
onPaymentSuccess: env15588[3],
|
|
onPaymentDismiss: env15588[4]
|
|
});
|
|
if (env29692[2]) {
|
|
const r120 = c25749_1;
|
|
const r130 = {
|
|
planId: env29692[1],
|
|
isGift: false,
|
|
loadId: env15588[16]
|
|
};
|
|
const r23 = $mk114908(env15588.$parent);
|
|
goToStandalonePremiumCheckoutFromMobileApp("premium_plan_selection_action_sheet", r130, $mk114907(r120), r23);
|
|
} else {
|
|
c25749_4 = 1;
|
|
await env15588[7]({
|
|
productId: env15588[13].productId,
|
|
analyticsLocation: env15588[18].location,
|
|
analyticsLoadId: env15588[16],
|
|
analyticsLocations: env15588[15],
|
|
orderId: env15588[8]?.id
|
|
});
|
|
c25749_4 = 0;
|
|
}
|
|
} catch ($e) {
|
|
const r35 = $e;
|
|
let r7 = r35;
|
|
c25749_3 = r35;
|
|
if (c25749_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r172 = c25749_3;
|
|
c25749_4 = 0;
|
|
env29692[5] = r172;
|
|
if (env29692[5] instanceof InvalidGooglePlayPurchase) {
|
|
fetchSubscriptions();
|
|
AlertActionCreators.show({
|
|
title: intl.string(t["U+H+kd"]),
|
|
body: intl.string(t.F9ktNa),
|
|
hideActionSheet: true
|
|
});
|
|
break L25;
|
|
}
|
|
throw env29692[5];
|
|
} catch (r168) {
|
|
r7 = r168;
|
|
c25749_3 = r168;
|
|
if (c25749_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
}, [memo, basePurchaseFlowAnalyticsFields, initialValue, analyticsLocations2, handlePremiumPurchase, isMobileWebRedirectCheckoutEnabled, onPaymentDismiss, onPaymentSuccess, nativeCheckoutStore, r34]);
|
|
const memo2 = useMemo(() => env15588[20] ? intl.string(t.rylrdY) : env15588[11] ? isAndroid() ? intl.string(t.rKD72m) : intl.string(t.bboTul) : intl.string(t.nIlrxd), [r2, isMobileWebRedirectCheckoutEnabled]);
|
|
env15588[22] = memo2;
|
|
const memo3 = useMemo(() => {
|
|
if (env15588[6]) {
|
|
return null;
|
|
}
|
|
const interval = env15588[13]?.interval;
|
|
if (interval == null) {
|
|
return null;
|
|
}
|
|
if (env15588[11]) {
|
|
return <Text style={env15588[5].legalDisclaimerText} variant="text-xxs/medium">
|
|
{intl.format(isAndroid() ? t.tINI9V : t.ZWXtAj, {
|
|
paidURL: MarketingURLs.PAID_TERMS,
|
|
interval: PremiumUtils.getIntervalStringAsNoun(interval),
|
|
cancelURL: HelpdeskUtils.getArticleURL(HelpdeskArticles.PREMIUM_DETAILS_CANCEL_SUB)
|
|
})}
|
|
</Text>;
|
|
}
|
|
if (env15588[12] != null) {
|
|
return (0, jsx)(Text, {
|
|
style: env15588[5].legalDisclaimerText,
|
|
variant: "text-xxs/medium",
|
|
children: intl.format(t["3uC7vj"], {
|
|
buttonText: env15588[22],
|
|
interval: PremiumUtils.formatInterval(interval),
|
|
cancelSubscriptionArticle: HelpdeskUtils.getArticleURL(HelpdeskArticles.PREMIUM_DETAILS_CANCEL_SUB),
|
|
paidServiceTermsArticle: HelpdeskUtils.getArticleURL(HelpdeskArticles.PAID_TERMS)
|
|
})
|
|
});
|
|
}
|
|
return (0, jsx)(Text, {
|
|
style: env15588[5].legalDisclaimerText,
|
|
variant: "text-xxs/medium",
|
|
children: intl.format(isAndroid() ? t.COObWR : t["7wpqfj"], {
|
|
paidURL: MarketingURLs.PAID_TERMS,
|
|
interval: PremiumUtils.getIntervalStringAsNoun(interval),
|
|
ctaText: env15588[22]
|
|
})
|
|
});
|
|
}, [premiumPlanPurchasedStore2, r34, r2, discountedPriceString2, memo2, styles.legalDisclaimerText]);
|
|
if (isPaymentsBlocked) {
|
|
r400 = <View style={styles.blockedPaymentContainer}>
|
|
<BlockedPaymentsCountryDisplay />
|
|
<ActionSheetHeaderBar variant="floating" onPress={onClose} />
|
|
</View>;
|
|
} else {
|
|
const r185 = [<Header premiumType={premiumType2} isPaymentSuccess={premiumPlanPurchasedStore2} selectedPremiumType={r34?.premiumTier} trialOffer={premiumTrialOffer2} discountOffer={discountedPriceString2 != null ? premiumDiscountOffer2 : null} />, , ,];
|
|
if (premiumPlanPurchasedStore === "in_mobile_web") {
|
|
r387 = <ActivityIndicator size="large" style={styles.loadingIndicator} />;
|
|
} else {
|
|
if (premiumPlanPurchasedStore2) {
|
|
const premiumTier = r34?.premiumTier;
|
|
const r344 = [<FastImage source={PremiumTypes.TIER_0 === premiumTier ? isThemeDark(theme) ? Module6315 : Module6316 : PremiumTypes.TIER_1 === premiumTier ? isThemeDark(theme) ? Module6317 : Module6318 : PremiumTypes.TIER_2 === premiumTier ? isThemeDark(theme) ? Module6319 : Module6320 : void 0} />, ,];
|
|
const premiumTier2 = r34?.premiumTier;
|
|
r344[1] = <Text style={styles.contentActivatedText} variant="text-md/semibold">
|
|
{PremiumTypes.TIER_0 === premiumTier2 ? intl.string(t["6WWrVM"]) : PremiumTypes.TIER_1 === premiumTier2 ? intl.string(t.LAAgsy) : PremiumTypes.TIER_2 === premiumTier2 ? intl.string(t.I7xNzI) : void 0}
|
|
</Text>;
|
|
r309 = <View style={styles.contentActivated}>{r344}</View>;
|
|
} else {
|
|
const r53 = {
|
|
convertToMajorUnits: isAndroid()
|
|
};
|
|
if (showFormTitle) {
|
|
showFormTitle = !r2;
|
|
}
|
|
const r232 = [r2 ? <Text variant="text-md/normal" color="text-strong" style={styles.trialDisclaimer}>
|
|
{intl.string(t.u95Dt4)}
|
|
</Text> : discountedPriceString2 != null ? discountedProduct != null ? premiumType2 != null ? <View>
|
|
<Text variant="text-md/normal" color="text-strong" style={styles.discountDisclaimer}>
|
|
{intl.format(t.yBn7uz, {
|
|
regularPrice: discountedProduct.priceString,
|
|
discountedPrice: discountedPriceString2
|
|
})}
|
|
</Text>
|
|
<View style={[styles.divider, styles.offerDividerMargin]} />
|
|
</View> : null : null : null, ,];
|
|
const title = showFormTitle ? intl.string(t.u95Dt4) : void 0;
|
|
const sectionBodyStyle = [styles.formSectionBody, showFormTitle ? !showFormTitle : styles.formSectionBodyWithNoTitle];
|
|
const r278 = [stateFromStores != null && stateFromStores.countryCode === "HR" && stateFromStores.currencyCode.toLowerCase() === CurrencyCodes.EUR && <PaymentFlowWarningMessage message={intl.formatToPlainString(t["9hnZoK"], {
|
|
kunaPriceWithCurrency: formatPrice(stateFromStores.price * EUR_TO_HRK_CONVERSION_RATE, CurrencyCodes.HRK, r53)
|
|
})} />, ,];
|
|
const productId2 = r34?.productId;
|
|
const productId3 = r34?.productId;
|
|
const identifier2 = discountedProduct?.identifier;
|
|
const productId = productId3;
|
|
const premiumTrialOffer = premiumTrialOffer2;
|
|
const premiumDiscountOffer = premiumDiscountOffer2;
|
|
const identifier = identifier2;
|
|
const discountedPriceString = discountedPriceString2;
|
|
const userIsEligibleForBogoPromotion = userIsEligibleForBogoPromotion2;
|
|
const premiumType = premiumType2;
|
|
const optionNeedsProductNameLabel = new Set(premiumItems.map((premiumItem) => premiumItem.premiumTier)).size > 1;
|
|
r278[1] = <RadioGroup value={productId2} options={premiumItems.map((a0) => ({
|
|
name: <PlanOption premiumItem={a0} selectedProductId={productId} optionNeedsProductNameLabel={optionNeedsProductNameLabel} trialOffer={premiumTrialOffer} discountOffer={premiumDiscountOffer} discountedPriceString={a0.productId === identifier ? discountedPriceString : null} userIsEligibleForBogoPromotion={userIsEligibleForBogoPromotion} selectedPremiumType={premiumType} />,
|
|
value: a0.productId
|
|
}))} onChange={(event) => (function onPlanSelectionChange(a0) {
|
|
return env15588[21].apply(this, arguments);
|
|
})(event.value)} withDividers={false} style={styles.planOptionRowContainer} disabled={loading ? loading : isPatchOrderLoading} indicatorLeft />;
|
|
r232[1] = <FormSection title={title} titleStyleType={TitleStyleType.NO_BORDER_OR_MARGIN} titleViewStyle={styles.formTitle} sectionBodyStyle={sectionBodyStyle} inset>{r278}</FormSection>;
|
|
r309 = <View style={styles.contentSelectPlan}>{r232}</View>;
|
|
}
|
|
const r381 = [r309, ,];
|
|
const disabled = loading ? loading : isPatchOrderLoading;
|
|
if (!loading) {
|
|
loading = isPatchOrderLoading;
|
|
}
|
|
r381[1] = <PremiumPlanSelectionActionSheetCTA isPaymentSuccess={premiumPlanPurchasedStore2} onClose={onClose} ctaText={memo2} onStartPayment={callback} shouldUseMobileWebRedirectCheckout={isMobileWebRedirectCheckoutEnabled} disabled={disabled} loading={loading} />;
|
|
r387 = <>{r381}</>;
|
|
}
|
|
r185[1] = <View style={styles.body}>
|
|
{r387}
|
|
{isMobileWebRedirectCheckoutEnabled ? !isMobileWebRedirectCheckoutEnabled : memo3}
|
|
</View>;
|
|
r185[2] = <ActionSheetHeaderBar variant="floating" onPress={onClose} />;
|
|
r400 = <>{r185}</>;
|
|
}
|
|
return <BottomSheet ref={bottomSheetRef} handleDisabled onDismiss={reset} startExpanded>{r400}</BottomSheet>;
|
|
};
|
|
_excluded = ["predicate", "initialSelectedCriteria", "sortFn"];
|
|
useStyles = createStyles({
|
|
body: {
|
|
padding: 16
|
|
},
|
|
headerText: {
|
|
paddingTop: 30,
|
|
paddingHorizontal: 20
|
|
},
|
|
contentSelectPlan: {
|
|
marginBottom: 16
|
|
},
|
|
contentActivated: {
|
|
alignItems: "center",
|
|
paddingTop: 40,
|
|
paddingBottom: 56
|
|
},
|
|
contentActivatedText: {
|
|
width: 328,
|
|
marginTop: 16,
|
|
textAlign: "center"
|
|
},
|
|
formTitle: {
|
|
paddingTop: 0,
|
|
paddingLeft: 0
|
|
},
|
|
formSectionBody: {
|
|
backgroundColor: "none"
|
|
},
|
|
formSectionBodyWithNoTitle: {
|
|
marginTop: -24
|
|
},
|
|
planOptionRowContainer: {
|
|
paddingHorizontal: 10
|
|
},
|
|
planOptionContainer: {
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
},
|
|
planOptionPriceContainer: {
|
|
flexGrow: 1,
|
|
flexShrink: 1,
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
alignItems: "flex-end"
|
|
},
|
|
planOptionDiscountContainer: {
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
flexShrink: 1
|
|
},
|
|
planOptionDiscount: {
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
borderRadius: Module712.radii.lg,
|
|
backgroundColor: Module712.unsafe_rawColors.GREEN_360,
|
|
paddingVertical: 2,
|
|
paddingHorizontal: 8,
|
|
marginRight: 8
|
|
},
|
|
planOptionDiscountWhite: {
|
|
backgroundColor: Module712.colors.WHITE
|
|
},
|
|
planOptionDiscountText: {
|
|
textTransform: "uppercase"
|
|
},
|
|
blockedPaymentContainer: {
|
|
marginVertical: 40
|
|
},
|
|
legalDisclaimerText: {
|
|
marginTop: 16
|
|
},
|
|
divider: {
|
|
height: 1,
|
|
width: "100%",
|
|
backgroundColor: Module712.colors.BORDER_SUBTLE
|
|
},
|
|
offerDividerMargin: {
|
|
marginBottom: 8
|
|
},
|
|
trialDisclaimer: {
|
|
marginBottom: 8
|
|
},
|
|
discountDisclaimer: {
|
|
marginBottom: 20
|
|
},
|
|
loadingIndicator: {
|
|
marginVertical: 30
|
|
},
|
|
discountSubTextContainer: {
|
|
alignItems: "flex-end"
|
|
},
|
|
priceText: {
|
|
flexShrink: 1
|
|
}
|
|
});
|
|
export default function PremiumPlanSelectionActionSheetWithOrderCTX(props) {
|
|
let r13, APPLE_ADVANCED_COMMERCE, PaymentGateways2, paymentGateway;
|
|
const enabled = NitroACOMSubscriptionExperiment.useConfig({
|
|
location: "PremiumPlanSelectionActionSheetWithOrderCTX"
|
|
}).enabled;
|
|
if (isIOS()) {
|
|
if (enabled) {
|
|
APPLE_ADVANCED_COMMERCE = PaymentGateways.APPLE_ADVANCED_COMMERCE;
|
|
PaymentGateways2 = PaymentGateways;
|
|
} else {
|
|
APPLE_ADVANCED_COMMERCE = PaymentGateways.APPLE;
|
|
PaymentGateways2 = PaymentGateways;
|
|
}
|
|
r13 = PaymentGateways2;
|
|
paymentGateway = APPLE_ADVANCED_COMMERCE;
|
|
} else {
|
|
paymentGateway = PaymentGateways.GOOGLE;
|
|
r13 = PaymentGateways;
|
|
}
|
|
let predicate = props.predicate;
|
|
if (predicate === void 0) {
|
|
let premiumType2 = props.premiumType;
|
|
if (premiumType2 == null) {
|
|
premiumType2 = PremiumTypes.TIER_2;
|
|
}
|
|
let env15591;
|
|
const r32 = env15591 = {};
|
|
env15591[0] = premiumType2;
|
|
predicate = $mk78038(r32);
|
|
}
|
|
let initialSelectedCriteria = props.initialSelectedCriteria;
|
|
if (initialSelectedCriteria === void 0) {
|
|
initialSelectedCriteria = (a0) => a0.interval === SubscriptionIntervalTypes.YEAR;
|
|
}
|
|
const { sortFn = (a0, a1) => a1.interval - a0.interval, ...rest } = props;
|
|
const trial_id = usePremiumTrialOffer()?.trial_id;
|
|
const initialSubscriptionFacet = trial_id != null ? {
|
|
subscription_preview: {
|
|
subscription_trial_id: trial_id
|
|
}
|
|
} : void 0;
|
|
const isEligibleForBogoOffer = useIsEligibleForBogoOffer();
|
|
const premiumItems = sortFn == null ? getPremiumBundlesWithPredicate(predicate) : getPremiumBundlesWithPredicate(predicate).sort(sortFn);
|
|
if (isEligibleForBogoOffer) {
|
|
initialSelectedCriteria = (a0) => a0.interval === SubscriptionIntervalTypes.MONTH;
|
|
}
|
|
const initialSelectedItem = premiumItems.find(initialSelectedCriteria);
|
|
return <NativeCheckoutStoreProvider paymentGateway={paymentGateway} orderRequired={paymentGateway === r13.APPLE_ADVANCED_COMMERCE} skuIds={[]} defaultPlans={initialSelectedItem != null ? getSubscriptionItemsForProduct(initialSelectedItem.productId).map((item) => ({
|
|
subscriptionPlanId: item.planId,
|
|
skuId: castPremiumSubscriptionAsSkuId(PremiumUtils.getSkuIdForPlan(item.planId)),
|
|
quantity: item.quantity
|
|
})) : [{
|
|
subscriptionPlanId: SubscriptionPlans.PREMIUM_YEAR_TIER_2,
|
|
skuId: castPremiumSubscriptionAsSkuId(PremiumSubscriptionSKUs.TIER_2),
|
|
quantity: 1
|
|
}]} isGift={false} activeSubscription={null} initialSubscriptionFacet={initialSubscriptionFacet} onOrderRetryCancellation={() => ActionSheetActionCreators.hideActionSheet(PREMIUM_PLAN_SELECTION_ACTION_SHEET_KEY)}>
|
|
<PremiumPlanSelectionActionSheet {...rest} premiumItems={premiumItems} userIsEligibleForBogoPromotion={isEligibleForBogoOffer} initialSelectedItem={initialSelectedItem} />
|
|
</NativeCheckoutStoreProvider>;
|
|
};
|
|
export function getItemsByPremiumTypePredicate(a0) {
|
|
let env15590;
|
|
const r0 = env15590 = {};
|
|
env15590[0] = a0;
|
|
return $mk78038(r0);
|
|
}
|