// Metro module 12580 (f12581). import { useEffect } from "react"; import { useNativeCheckoutStore } from "../../../checkout/native/NativeCheckoutStore"; import IAPStore_android from "../../../../stores/native/IAPStore.android"; import { PremiumTypes, SubscriptionIntervalTypes } from "../../PremiumConstants"; import { getProductIdFromSubscription, getSubscriptionItemsForProduct } from "../PremiumBundledPlansUtils"; import { AppStorePremiumProductIdsToPremiumBundledItems } from "../ProductIds.android"; import { isIOS, getPlatformName, isAndroid } from "../../../../utils/PlatformUtils"; import { formatPrice } from "../../../../utils/PriceUtils"; import { captureBillingException } from "../../../../utils/BillingUtils"; import { useStateFromStores } from "../../../../_bundle/Module589"; let c8678_7; const getViewerProductId = function getViewerProductId(a0) { let productIdFromSubscription; if (a0 == null) { return null; } try { productIdFromSubscription = getProductIdFromSubscription(a0, false); } catch ($e) { return null; } return productIdFromSubscription; }; c8678_7 = { priceString: null, failure: null }; export function usePremiumTier2DeltaPriceString(a0, a1, a2, a3) { let r51, r67, r92; let viewerProductId; const nativeCheckoutStore = useNativeCheckoutStore((a0) => ({ orderRequired: a0.orderRequired, checkoutContext: a0.getCheckoutContextRecord() })); const { orderRequired, checkoutContext } = nativeCheckoutStore; viewerProductId = getViewerProductId(a1); const stateFromStores = useStateFromStores([IAPStore_android], () => viewerProductId != null ? IAPStore_android.getProduct(viewerProductId) : null); const r31 = isIOS() && orderRequired; let r3 = false; if (a3) { const premiumTier = a0.premiumTier; const TIER_2 = PremiumTypes.TIER_2; r3 = false; if (premiumTier === TIER_2) { const interval = a0.interval; const MONTH = SubscriptionIntervalTypes.MONTH; r3 = false; if (interval === MONTH) { const r2 = a0.numPremiumGuild < 1; r3 = false; if (!r2) { const viewerProductId2 = getViewerProductId(a1); const r43 = viewerProductId2 != null ? AppStorePremiumProductIdsToPremiumBundledItems[viewerProductId2] : null; r3 = r43 != null && r43.basePlanId === a0.basePlanId && r43.numPremiumGuild === 0; } } } } if (r3) { L39: { if (r31) { L38: { if (checkoutContext == null) { r92 = c8678_7; } else { const availablePlanForItems = checkoutContext.getAvailablePlanForItems(getSubscriptionItemsForProduct(a0.productId)); if (availablePlanForItems == null) { r92 = c8678_7; } else { const addOnPrice = availablePlanForItems.getAddOnPrice(); if (addOnPrice != null && addOnPrice.majorUnits > 0) { r92 = { priceString: formatPrice(addOnPrice.majorUnits, addOnPrice.currency, { convertToMajorUnits: false }), failure: null }; break L38; } r92 = c8678_7; } } } r67 = r92; } else { if (a2 != null && stateFromStores != null) { const platformName = getPlatformName(); if (a2.currencyCode !== stateFromStores.currencyCode) { r67 = { priceString: null, failure: { kind: "currency_mismatch", platform: platformName, productId: a0.productId, currencyCode: a2.currencyCode } }; break L39; } const r62 = a2.price - stateFromStores.price; if (r62 > 0 && r62 < a2.price) { r67 = { priceString: formatPrice(isAndroid() ? r62 / 100 : r62, a2.currencyCode, { convertToMajorUnits: false }), failure: null }; break L39; } r67 = { priceString: null, failure: { kind: "delta_out_of_range", platform: platformName, productId: a0.productId, currencyCode: a2.currencyCode } }; break L39; } r67 = c8678_7; } } r51 = r67; } else { r51 = c8678_7; } const { priceString, failure } = r51; let r106 = failure?.kind; if (r106 == null) { r106 = null; } const delta_failure_kind = r106; let r108 = failure?.platform; if (r108 == null) { r108 = null; } let c19908_1 = r108; let r110 = failure?.currencyCode; if (r110 == null) { r110 = null; } let c19908_2 = r110; let r112 = failure?.productId; if (r112 == null) { r112 = null; } let c19908_3 = r112; useEffect(() => { if (delta_failure_kind != null) { const error = new Error(`delta_price_integrity_${delta_failure_kind}`); let delta_platform = c19908_1; if (delta_platform == null) { delta_platform = "unknown"; } let delta_currency_code = c19908_2; if (delta_currency_code == null) { delta_currency_code = "unknown"; } let delta_product_id = c19908_3; if (delta_product_id == null) { delta_product_id = "unknown"; } captureBillingException(error, { tags: { source: "usePremiumTier2DeltaPriceString", delta_failure_kind, delta_platform, delta_currency_code, delta_product_id } }); } }, [delta_failure_kind, r108, r110, r112]); return priceString; }