This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,175 @@
// Metro module 7839 (f7840).
import { useState } from "react";
import SubscriptionStore from "../../stores/billing/SubscriptionStore";
import { PREMIUM_GROUP_30_PERCENT_3_MONTH_DISCOUNT_ID, PREMIUM_TIER_2_ANNUAL_20_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_ANNUAL_25_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_ANNUAL_V2_20_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_ANNUAL_V2_30_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID, PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID, PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_30_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_40_PERCENT_DISCOUNT_ID, PREMIUM_TIER_2_LIKELIHOOD_DISCOUNT_ID, PREMIUM_TIER_2_REACTIVATION_DISCOUNT_ID, PREMIUM_TIER_2_REENGAGEMENT_1_MONTH_40_PERCENT_DISCOUNT_ID } from "./PremiumConstants";
import { usePremiumTrialOffer } from "./hooks/usePremiumTrialOffer.android";
import { useHasActiveTrial } from "./PremiumSubscriptionTrialUtil";
import { usePremiumDiscountOffer, usePremiumGroupDiscountOffer } from "./hooks/usePremiumDiscountOffer.android";
import { useStateFromStores } from "../../_bundle/Module589";
import Module3771 from "../../_bundle/Module3771";
import useDiscountOffer from "./hooks/useDiscountOffer";
import { fetchChurnDiscountOffer } from "./UserOfferActionCreators";
import { InvoiceDiscountTypes } from "../../flow/Server";
import { useIsInReverseTrial } from "./ReverseTrialUtils.native";
let $mk79310 = function() {
return () => SubscriptionStore.getPremiumTypeSubscription();
};
const useHasDiscountApplied = () => {
const stateFromStores = useStateFromStores([SubscriptionStore], $mk79310());
const r13 = stateFromStores == null ? void 0 : stateFromStores.metadata?.active_discount_expires_at;
return r13 != null && Module3771(Date.now()) <= Module3771(r13);
};
export function useIsInPremiumOfferExperience() {
const premiumTrialOffer = usePremiumTrialOffer();
const hasActiveTrial = useHasActiveTrial();
const premiumDiscountOffer = usePremiumDiscountOffer();
const premiumGroupDiscountOffer = usePremiumGroupDiscountOffer();
const stateFromStores = useStateFromStores([SubscriptionStore], $mk79310());
const r33 = stateFromStores == null ? void 0 : stateFromStores.metadata?.active_discount_expires_at;
const r36 = r33 != null && Module3771(Date.now()) <= Module3771(r33);
return premiumTrialOffer != null || hasActiveTrial || premiumDiscountOffer != null || premiumGroupDiscountOffer != null || r36;
}
export { useHasDiscountApplied };
export function useActiveDiscountInfo() {
const stateFromStores = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getPremiumTypeSubscription());
const discountId = stateFromStores == null ? void 0 : stateFromStores.metadata?.active_discount_id;
if (PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID !== discountId && PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_30_PERCENT_DISCOUNT_ID !== discountId) {
if (PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID !== discountId && PREMIUM_TIER_2_LIKELIHOOD_DISCOUNT_ID !== discountId && PREMIUM_TIER_2_REACTIVATION_DISCOUNT_ID !== discountId) {
if (PREMIUM_TIER_2_LIKELIHOOD_1_MONTH_40_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 1,
percentage: 40,
discountId
};
}
if (PREMIUM_TIER_2_ANNUAL_20_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 1,
percentage: 20,
discountId
};
}
if (PREMIUM_TIER_2_ANNUAL_25_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 1,
percentage: 25,
discountId
};
}
if (PREMIUM_TIER_2_ANNUAL_V2_20_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 12,
percentage: 20,
discountId
};
}
if (PREMIUM_TIER_2_ANNUAL_V2_30_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 12,
percentage: 30,
discountId
};
}
if (PREMIUM_TIER_2_REENGAGEMENT_1_MONTH_40_PERCENT_DISCOUNT_ID === discountId) {
return {
duration: 1,
percentage: 40,
discountId
};
}
if (PREMIUM_GROUP_30_PERCENT_3_MONTH_DISCOUNT_ID === discountId) {
return {
duration: 3,
percentage: 30,
discountId
};
}
return void 0;
}
return {
duration: 3,
percentage: 30,
discountId
};
}
return {
duration: 1,
percentage: 30,
discountId
};
}
export function useFetchChurnUserDiscountOffer(a0) {
let churnUserDiscountOffer = useDiscountOffer(PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID);
const discountOffer = useDiscountOffer(PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID);
const [state, setState] = useState(false);
const [isFetchingChurnDiscountOffer, setState2] = useState(false);
const [churnUserDiscountOffer2, setState3] = useState(null);
if (churnUserDiscountOffer == null) {
churnUserDiscountOffer = discountOffer;
}
if (churnUserDiscountOffer == null) {
churnUserDiscountOffer = null;
}
if (churnUserDiscountOffer != null) {
return {
churnUserDiscountOffer,
isFetchingChurnDiscountOffer: false
};
}
if (a0) {
return {
churnUserDiscountOffer: churnUserDiscountOffer2,
isFetchingChurnDiscountOffer
};
}
if (!(isFetchingChurnDiscountOffer || state)) {
setState2(true);
fetchChurnDiscountOffer().then((result) => {
setState3(result);
setState(true);
setState2(false);
}).catch(() => {
setState(true);
setState2(false);
});
}
return {
churnUserDiscountOffer: churnUserDiscountOffer2,
isFetchingChurnDiscountOffer
};
}
export function useShouldFetchChurnOffer() {
const stateFromStores = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getPremiumTypeSubscription());
const stateFromStores2 = useStateFromStores([SubscriptionStore], $mk79310());
const r24 = stateFromStores2 == null ? void 0 : stateFromStores2.metadata?.active_discount_expires_at;
const r27 = r24 != null && Module3771(Date.now()) <= Module3771(r24);
return stateFromStores !== null && stateFromStores.hasPremiumNitroMonthly && !r27 && !!!stateFromStores?.hasActiveTrial;
}
export function renewalInvoiceChurnDiscountInfo(a0) {
for (const invoiceItem of a0.invoiceItems) {
const r26 = invoiceItem.discounts.find((discount) => discount.type === InvoiceDiscountTypes.SUBSCRIPTION_PLAN);
if (r26 == null) {
continue;
}
const discount_id = r26.discount_id;
if (PREMIUM_TIER_2_CHURN_1_MONTH_DISCOUNT_ID !== discount_id) {
if (PREMIUM_TIER_2_CHURN_3_MONTH_DISCOUNT_ID !== discount_id) {
continue;
}
return {
duration: 3,
percentage: r26.percentage_amount,
discountId: r26.discount_id
};
}
return {
duration: 1,
percentage: r26.percentage_amount,
discountId: r26.discount_id
};
}
return null;
}
export function useIsNUXEligible() {
return useIsInReverseTrial();
}