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,26 @@
// Metro module 9708 (f9709).
import AccessibilityStore from "../../a11y/AccessibilityStore";
import useTheme from "../../../hooks/useTheme";
import { useStateFromStores } from "../../../_bundle/Module589";
import { isThemeDark } from "../../../design/utils/shared/themes";
export function useThemeAndReducedMotionAwareAssetUrl(a0, a1) {
let lightStaticUrl;
const theme = useTheme();
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
let r17 = null;
if (a0 != null) {
L11: {
if (!isThemeDark(theme) && !a1) {
if (stateFromStores) {
lightStaticUrl = a0.lightStaticUrl;
break L11;
}
lightStaticUrl = a0.lightUrl;
} else {
lightStaticUrl = stateFromStores ? a0.darkStaticUrl : a0.darkUrl;
}
}
r17 = lightStaticUrl;
}
return r17;
}
@@ -0,0 +1,35 @@
// Metro module 6265 (f6266).
import Record from "../../../lib/Record";
import { PremiumMarketingComponentProperties } from "../../../_bundle/Module6266";
import { base64decode, BinaryReader } from "../../../_bundle/Module1307";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class MarketingComponentRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.componentType = a0.componentType;
this.properties = a0.properties;
this.promotionId = a0.promotionId;
}
static createFromServer(a0) {
let c15644_0 = new TextDecoder("utf-8", {
ignoreBOM: true
});
const { id, component_type } = a0;
const properties = PremiumMarketingComponentProperties.fromBinary(base64decode(a0.properties), {
readUnknownField: true,
readerFactory: (a0) => new BinaryReader(a0, c15644_0)
});
const promotion_id = a0.promotion_id;
const prototypeOf = Object.getPrototypeOf(MarketingComponentRecord);
const r35 = Object.create(MarketingComponentRecord.prototype);
const r37 = $callWithNewTarget(prototypeOf, r35, MarketingComponentRecord);
const r38 = r37 instanceof Object ? r37 : r35;
r38.id = id;
r38.componentType = component_type;
r38.properties = properties;
r38.promotionId = promotion_id;
return r38;
}
}
export default MarketingComponentRecord;
@@ -0,0 +1,30 @@
// Metro module 12431 (f12432).
import SubscriptionPlanStore from "../../../stores/billing/SubscriptionPlanStore";
import { PremiumSubscriptionSKUs, SubscriptionPlans } from "../PremiumConstants";
import { useStateFromStores } from "../../../_bundle/Module589";
import PremiumUtils from "../../../utils/PremiumUtils";
import { formatPrice } from "../../../utils/PriceUtils";
import { intl, t } from "../../../intl/index.native";
import HelpdeskUtils from "../../../utils/HelpdeskUtils";
export function useFormatStringWithCommonPremiumParams(a0) {
let r0 = "...";
const stateFromStores = useStateFromStores([SubscriptionPlanStore], () => SubscriptionPlanStore.isLoadedForSKU(PremiumSubscriptionSKUs.TIER_2));
if (a0.indexOf("{price}") !== -1 && stateFromStores) {
try {
const defaultPrice = PremiumUtils.getDefaultPrice(SubscriptionPlans.PREMIUM_MONTH_TIER_2);
r0 = formatPrice(defaultPrice.amount, defaultPrice.currency);
} catch ($e) {}
}
return a0.replace(/\{price\}/g, r0);
}
export function getHelpArticleLinkProps(a0, a1) {
const r7 = a0?.id != null ? a0.id !== "" ? a0.id : a1 : a1;
if (r7 === "") {
return null;
}
const linkText = a0?.linkText != null && a0.linkText !== "" ? a0.linkText : intl.string(t["sBp+u0"]);
return {
url: HelpdeskUtils.getArticleURL(r7),
linkText
};
}
@@ -0,0 +1,159 @@
// Metro module 6566 (f6567).
import UserSettingsProtoStore from "../../user_settings/UserSettingsProtoStore";
import PromotionRecord from "../../../records/PromotionRecord";
import PromotionsStore from "./PromotionsStore";
import { PromotionFlags } from "../PremiumConstants";
import { Endpoints, Platforms, AnalyticEvents } from "../../../Constants";
import { ActivityPlatform } from "../../activities/Constants";
import { isThemeDark } from "../../../design/shared";
import { HTTP, rejectWithMigratedError } from "../../../_bundle/sendRequest";
import * as _PlatformUtils from "../../../utils/PlatformUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { DismissibleContent } from "../../../_bundle/Module1358";
import { isTimeRecurringSnowflakeBoundDismissibleContentDismissed } from "../../dismissible_content/DismissibleContentUtils";
import { DEDICATED_SURFACE_PARTNER_IDS, PromotionTypes } from "./constants";
function $mk78816($env) {
return (a0) => {
let r0 = a0.id !== $env[0];
if (r0) {
const r8 = $env.$parent;
r0 = !(0, r8[0])(r8[2][11]).hasFlag(a0.flags, r8[7].SUPPRESS_NOTIFICATION);
}
if (r0) {
let r18 = a0.partnerId != null;
if (r18) {
const r19 = $env.$parent;
r18 = (0, r19[0])(r19[2][15]).DEDICATED_SURFACE_PARTNER_IDS.has(a0.partnerId);
}
r0 = !r18;
}
return r0;
};
}
function $mk78817($env) {
return ({ id }) => {
const r6 = $env.$parent;
return (0, r6[1])(r6[2][13]).compare(id, $env[1]) === 1;
};
}
function $mk78818() {
return (a0, a1) => new Date(a0.startDate) < new Date(a1.startDate) ? -1 : 1;
}
let env4226 = {};
export function claimedOutboundPromotionCodeFromServer(a0) {
return {
code: a0.code,
userId: a0.user_id,
claimedAt: a0.claimed_at,
promotion: PromotionRecord.createFromServer(a0.promotion)
};
}
ActivityPlatform;
export function getPromotionImageURL(a0, a1) {
const r9 = isThemeDark(a1) ? "logo-dark" : "logo-light";
const CDN_HOST = window.GLOBAL_ENV.CDN_HOST;
return CDN_HOST != null ? `https://${CDN_HOST}/promotions/${a0}/${r9}?size=256` : `${location.protocol}${window.GLOBAL_ENV.API_ENDPOINT}/promotions/${a0}/${r9}?size=256`;
}
export async function claimOutboundPromotion(c25924_0) {
let c29802_0 = c25924_0.promotionId;
let c29802_1 = c25924_0.promotionTitle;
let c29802_2 = c25924_0.partnerId;
let c29802_3 = c25924_0.analyticsLocations;
await void 0;
let c29802_4 = await HTTP.post({
url: Endpoints.CLAIM_OUTBOUND_PROMOTION_CODE(c29802_0),
rejectWithError: rejectWithMigratedError()
});
let c29802_5 = c29802_4.body;
let c29802_6 = _PlatformUtils.isIOS() ? Platforms.IOS : Platforms.ANDROID;
const OUTBOUND_PROMOTION_CLAIMED = AnalyticEvents.OUTBOUND_PROMOTION_CLAIMED;
let name = c29802_1;
if (c29802_1 == null) {
name = null;
}
let partner = c29802_2;
if (c29802_2 == null) {
partner = null;
}
AnalyticsUtils.track(OUTBOUND_PROMOTION_CLAIMED, {
platform: c29802_6,
status: c29802_4.status,
location_stack: c29802_3,
promotion_id: c29802_0,
name,
partner
});
return (0, claimedOutboundPromotionCodeFromServer)(c29802_5);
}
export function getOutboundPromotionRedemptionUrl(a0, a1) {
let r7;
if (a1.outboundRedemptionUrlFormat != null && a1.outboundRedemptionUrlFormat !== "") {
r7 = a1.outboundRedemptionUrlFormat.replace("{code}", encodeURIComponent(a0));
} else {
r7 = a1.outboundRedemptionPageLink;
if (r7 == null) {
r7 = "";
}
}
return r7;
}
export function getNextUnseenOutboundPromotionId() {
let env15801;
const r4 = env15801 = {
$parent: env4226
};
const outboundPromotions = PromotionsStore.outboundPromotions;
env15801[0] = PromotionsStore.consumedInboundPromotionId;
const r12 = outboundPromotions.filter($mk78816(r4));
const userContent = UserSettingsProtoStore.settings.userContent;
const r16 = userContent == null ? void 0 : userContent.recurringDismissibleContentStates[DismissibleContent.THIRD_PARTY_OUTBOUND_PROMO_NAGBAR]?.lastDismissedObjectId;
env15801[1] = r16;
const r25 = r16 != null ? r12.filter($mk78817(r4)) : r12;
return r25.length !== 0 ? r25.sort($mk78818())[0].id : null;
}
export function shouldShowOutboundPromotionNotice() {
let env15802;
const r5 = env15802 = {
$parent: env4226
};
const outboundPromotions = PromotionsStore.outboundPromotions;
env15802[0] = PromotionsStore.consumedInboundPromotionId;
const r13 = outboundPromotions.filter($mk78816(r5));
const userContent = UserSettingsProtoStore.settings.userContent;
const r17 = userContent == null ? void 0 : userContent.recurringDismissibleContentStates[DismissibleContent.THIRD_PARTY_OUTBOUND_PROMO_NAGBAR]?.lastDismissedObjectId;
env15802[1] = r17;
const r25 = r17 != null ? r13.filter($mk78817(r5)) : r13;
const r29 = r25.length !== 0 ? r25.sort($mk78818())[0].id : null;
return r29 != null && !isTimeRecurringSnowflakeBoundDismissibleContentDismissed(DismissibleContent.THIRD_PARTY_OUTBOUND_PROMO_NAGBAR, r29, {
cooldownDurationMs: 259200000
});
}
export function isDedicatedSurfacePromotion(a0) {
return a0.partnerId != null && DEDICATED_SURFACE_PARTNER_IDS.has(a0.partnerId);
}
export function shouldShowOutboundPromotionOnPlatform(a0) {
const isIOS = _PlatformUtils.isIOS();
return isIOS ? !a0.hasFlag(PromotionFlags.IS_BLOCKED_IOS) : !isIOS;
}
export function getClaimedOutboundPromotionCodeMap(a0) {
const r0 = {};
for (const item of a0) {
r0[item.promotion.id] = item.code;
}
return r0;
}
export function getClaimedEndedOutboundPromotions(a0, a1) {
let c15803_0 = new Set(a1.map((item) => item.id));
return a0.filter(({ promotion }) => {
const r10 = c15803_0.has(promotion.id);
let r0 = (r10 ? !r10 : !(promotion.promotionType === PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING)) && !(promotion.partnerId != null && DEDICATED_SURFACE_PARTNER_IDS.has(promotion.partnerId));
if (r0) {
const isIOS = _PlatformUtils.isIOS();
r0 = isIOS ? !promotion.hasFlag(PromotionFlags.IS_BLOCKED_IOS) : !isIOS;
}
return r0;
});
}
export function isRecurringPromotion(a0) {
return a0.promotionType === PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING;
}
@@ -0,0 +1,223 @@
// Metro module 6564 (f6565).
import LocaleStore from "../../user_settings/LocaleStore";
import PromotionRecord from "../../../records/PromotionRecord";
import PromotionsStore from "./PromotionsStore";
import { PREMIUM_SUBSCRIPTION_APPLICATION } from "../PremiumConstants";
import { Endpoints } from "../../../Constants";
import Dispatcher from "../../../Dispatcher";
import { MarketingComponentPlatform } from "../../../_bundle/Module6565";
import { HTTP, rejectWithMigratedError } from "../../../_bundle/sendRequest";
import { fetchUserEntitlementsForApplication } from "../../../actions/EntitlementActionCreators";
import { PreloadedUserSettingsActionCreators, UserSettingsDelay } from "../../user_settings/UserSettingsProtoActionCreators";
import { StringValue } from "../../../_bundle/Module1337";
import { claimedOutboundPromotionCodeFromServer } from "./PromotionUtils";
const fetchActivePromotions = async function fetchActivePromotions() {
let promotion_id, c25921_1, c25921_2, c25921_3;
let c25921_4 = 0;
const r13 = void 0;
L18: {
try {
let env29799;
c25921_2 = r13;
const r32 = env29799 = {};
c25921_1 = r32;
env29799[0] = void 0;
env29799[1] = void 0;
env29799[2] = void 0;
c25921_4 = 1;
Dispatcher.dispatch({
type: "ACTIVE_PROMOTIONS_FETCH",
locale: LocaleStore.locale
});
env29799[0] = await HTTP.get({
url: Endpoints.PROMOTIONS,
query: {
locale: LocaleStore.locale,
platform: MarketingComponentPlatform.MOBILE
},
oldFormErrors: true,
rejectWithError: true
});
env29799[1] = PromotionsStore.consumedInboundPromotionId;
if (!PromotionsStore.hasFetchedConsumedInboundPromotionId) {
env29799[2] = (await fetchUserEntitlementsForApplication(PREMIUM_SUBSCRIPTION_APPLICATION, false)).find((item) => item.promotion_id != null && item.consumed === true);
const promotion_id2 = env29799[2]?.promotion_id;
promotion_id = promotion_id2;
if (promotion_id2 == null) {
promotion_id = null;
}
env29799[1] = promotion_id;
}
Dispatcher.dispatch({
type: "ACTIVE_PROMOTIONS_FETCH_SUCCESS",
promotions: env29799[0].body,
consumedInboundPromotionId: env29799[1]
});
c25921_4 = 0;
} catch ($e) {
const r30 = $e;
let r8 = r30;
c25921_3 = r30;
if (c25921_4 !== 0) {
while (true) {
try {
c25921_4 = 0;
Dispatcher.dispatch({
type: "ACTIVE_PROMOTIONS_FETCH_FAIL"
});
break L18;
} catch (r126) {
r8 = r126;
c25921_3 = r126;
if (c25921_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
};
export function dismissOutboundPromotionNotice() {
Dispatcher.dispatch({
type: "OUTBOUND_PROMOTION_NOTICE_DISMISS"
});
const lastDismissedOutboundPromotionStartDate = PromotionsStore.lastDismissedOutboundPromotionStartDate;
if (lastDismissedOutboundPromotionStartDate != null) {
PreloadedUserSettingsActionCreators.updateAsync("userContent", (a0) => {
a0.lastDismissedOutboundPromotionStartDate = StringValue.create({
value: lastDismissedOutboundPromotionStartDate
});
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
}
export async function fetchActiveBogoPromotion() {
let c25922_3 = 0;
let c29800_0;
L13: {
L12: {
try {
c29800_0 = void 0;
if (PromotionsStore.isFetchingActiveBogoPromotion) {
break L13;
}
c25922_3 = 1;
Dispatcher.dispatch({
type: "ACTIVE_BOGO_PROMOTION_FETCH"
});
c29800_0 = (await HTTP.get({
url: Endpoints.BOGO_PROMOTIONS,
query: {
locale: LocaleStore.locale
},
rejectWithError: true
})).body;
Dispatcher.dispatch({
type: "ACTIVE_BOGO_PROMOTION_FETCH_SUCCESS",
activePromotion: PromotionRecord.createFromServer(c29800_0)
});
c25922_3 = 0;
} catch ($e) {
let r8 = $e;
if (c25922_3 !== 0) {
while (true) {
try {
c25922_3 = 0;
Dispatcher.dispatch({
type: "ACTIVE_BOGO_PROMOTION_FETCH_FAIL"
});
break L12;
} catch ($e) {
r8 = $e;
if (c25922_3 === 0) {
break;
}
}
}
}
throw r8;
}
}
return void 0;
}
}
export async function fetchClaimedOutboundPromotionCodes() {
let c25923_2 = 0;
let c29801_0;
L10: {
try {
c29801_0 = void 0;
c25923_2 = 1;
c29801_0 = (await HTTP.get({
url: Endpoints.CLAIMED_OUTBOUND_PROMOTION_CODES,
query: {
locale: LocaleStore.locale
},
oldFormErrors: true,
rejectWithError: rejectWithMigratedError()
})).body.map(claimedOutboundPromotionCodeFromServer);
Dispatcher.dispatch({
type: "CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_SUCCESS",
claimedOutboundPromotionCodes: c29801_0
});
c25923_2 = 0;
} catch ($e) {
let r24 = $e;
if (c25923_2 !== 0) {
while (true) {
try {
c25923_2 = 0;
Dispatcher.dispatch({
type: "CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_FAIL"
});
break L10;
} catch ($e) {
r24 = $e;
if (c25923_2 === 0) {
break;
}
}
}
}
throw r24;
}
}
}
export function addClaimedOutboundPromotionCode(a0) {
Dispatcher.dispatch({
type: "CLAIMED_OUTBOUND_PROMOTION_CODE_ADD",
claimedOutboundPromotionCode: a0
});
}
const r35 = {
fetchActivePromotions,
fetchClaimedOutboundPromotionCodes,
addClaimedOutboundPromotionCode,
dismissOutboundPromotionNotice,
markOutboundPromotionsSeen: () => {
Dispatcher.dispatch({
type: "OUTBOUND_PROMOTIONS_SEEN"
});
},
fetchActiveBogoPromotion
};
export default r35;
export function maybeFetchActivePromotions(r4 = true) {
let isFetchingActivePromotions = PromotionsStore.isFetchingActivePromotions;
if (!isFetchingActivePromotions) {
if (r4) {
r4 = PromotionsStore.lastFetchedActivePromotions != null;
}
isFetchingActivePromotions = r4;
}
if (!isFetchingActivePromotions) {
fetchActivePromotions();
}
}
export function clearActivePromotions() {
Dispatcher.dispatch({
type: "ACTIVE_PROMOTIONS_CLEAR"
});
}
export { fetchActivePromotions };
@@ -0,0 +1,123 @@
// Metro module 12498 (f12499).
import { useMemo, useEffect } from "react";
import UserStore from "../../../stores/UserStore";
import PromotionsStore from "./PromotionsStore";
import { PremiumTypes } from "../PremiumConstants";
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/Module589";
import * as _PromotionUtils from "./PromotionUtils";
import { shouldShowOutboundPromotionOnPlatform, getClaimedOutboundPromotionCodeMap, isRecurringPromotion } from "./PromotionUtils";
import PremiumUtils from "../../../utils/PremiumUtils";
import Dispatcher from "../../../Dispatcher";
import PromotionsActionCreators, { maybeFetchActivePromotions } from "./PromotionsActionCreators";
const useEligibleActiveOutboundPromotions = function useEligibleActiveOutboundPromotions(r2 = {}) {
let includeClaimedPromotions = r2.includeClaimedPromotions;
if (includeClaimedPromotions === void 0) {
includeClaimedPromotions = false;
}
let stateFromStores, stateFromStores2;
let c19869_0 = includeClaimedPromotions;
stateFromStores = void 0;
stateFromStores2 = void 0;
const stateFromStoresArray = useStateFromStoresArray([PromotionsStore], () => PromotionsStore.outboundPromotions);
stateFromStores = useStateFromStores([PromotionsStore], () => PromotionsStore.consumedInboundPromotionId);
stateFromStores2 = useStateFromStores([PromotionsStore], () => PromotionsStore.claimedOutboundPromotionCodes);
return useMemo(() => {
const r3 = c19869_0 ? new Set(stateFromStores2.map((item) => item.promotion.id)) : null;
let c27299_0 = r3;
return stateFromStoresArray.filter((item) => {
let r2 = item.id !== stateFromStores;
if (r2) {
let r16 = !!shouldShowOutboundPromotionOnPlatform(item);
if (r16) {
const isDedicatedSurfacePromotion = _PromotionUtils.isDedicatedSurfacePromotion(item);
let r21 = !isDedicatedSurfacePromotion;
if (!isDedicatedSurfacePromotion) {
const r4 = c27299_0 == null;
r21 = true;
if (!r4) {
c27299_0.has(item.id);
r21 = true;
}
}
r16 = r21;
}
r2 = r16;
}
return r2;
});
}, [stateFromStoresArray, stateFromStores, stateFromStores2, includeClaimedPromotions]);
};
export { useEligibleActiveOutboundPromotions };
export function useOutboundPromotions() {
let isPremiumExactly, stateFromStores4, eligibleActiveOutboundPromotions;
const stateFromStores3 = useStateFromStores([PromotionsStore], () => PromotionsStore.lastFetchedActivePromotions);
const stateFromStores6 = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const isPremiumExactly2 = PremiumUtils.isPremiumExactly(stateFromStores6, PremiumTypes.TIER_2);
const isPremium = PremiumUtils.isPremium(stateFromStores6);
isPremiumExactly = isPremium ? isPremiumExactly2 : !isPremium;
stateFromStores4 = useStateFromStores([PromotionsStore], () => PromotionsStore.claimedOutboundPromotionCodes);
let promotionsLoaded = useStateFromStores([PromotionsStore], () => PromotionsStore.claimedOutboundPromotionCodesLoaded);
useEffect(() => {
if (stateFromStores3 != null) {
Dispatcher.wait(() => PromotionsActionCreators.markOutboundPromotionsSeen());
}
}, [stateFromStores3]);
useEffect(() => {
Dispatcher.wait(() => {
let r1 = isPremiumExactly;
if (isPremiumExactly) {
r1 = stateFromStores3 == null;
}
if (r1) {
PromotionsActionCreators.fetchActivePromotions();
}
});
}, [stateFromStores3, isPremiumExactly]);
useEffect(() => {
Dispatcher.wait(() => {
PromotionsActionCreators.fetchClaimedOutboundPromotionCodes();
});
}, []);
const memo = useMemo(() => getClaimedOutboundPromotionCodeMap(stateFromStores4), [stateFromStores4]);
eligibleActiveOutboundPromotions = useEligibleActiveOutboundPromotions({
includeClaimedPromotions: true
});
const memo2 = useMemo(() => {
let c27300_0 = new Set(eligibleActiveOutboundPromotions.map((eligibleActiveOutboundPromotion) => eligibleActiveOutboundPromotion.id));
return stateFromStores4.filter(({ promotion }) => {
const r9 = c27300_0.has(promotion.id);
return (r9 ? !r9 : isRecurringPromotion({
promotionType: promotion.promotionType
}) === false) && !_PromotionUtils.isDedicatedSurfacePromotion(promotion) && shouldShowOutboundPromotionOnPlatform(promotion);
});
}, [eligibleActiveOutboundPromotions, stateFromStores4]);
if (promotionsLoaded) {
promotionsLoaded = isPremiumExactly ? stateFromStores3 != null : !isPremiumExactly;
}
return {
promotionsLoaded,
activeOutboundPromotions: eligibleActiveOutboundPromotions,
claimedEndedOutboundPromotions: memo2,
claimedOutboundPromotionCodeMap: memo
};
}
export function useUnseenOutboundPromotions() {
let eligibleActiveOutboundPromotions2;
const stateFromStores5 = useStateFromStores([PromotionsStore], () => PromotionsStore.lastSeenOutboundPromotionStartDate);
eligibleActiveOutboundPromotions2 = useEligibleActiveOutboundPromotions();
return useMemo(() => stateFromStores5 == null ? eligibleActiveOutboundPromotions2 : eligibleActiveOutboundPromotions2.filter((item) => new Date(item.startDate) > new Date(stateFromStores5)), [eligibleActiveOutboundPromotions2, stateFromStores5]).filter((item) => shouldShowOutboundPromotionOnPlatform(item));
}
export function useBogoPromotion() {
return {
promotion: useStateFromStores([PromotionsStore], () => PromotionsStore.bogoPromotion)
};
}
export function useIsInPromotion(c19872_0) {
return useStateFromStores([PromotionsStore], () => PromotionsStore.hasPromotion(c19872_0));
}
export function useHasActiveBogoPromotion() {
useEffect(() => {
maybeFetchActivePromotions();
}, []);
return useStateFromStores([PromotionsStore], () => PromotionsStore.getActiveBogoRewardPromotion() != null);
}
@@ -0,0 +1,83 @@
// Metro module 16302 (f16303).
import _asyncToGenerator from "../../../_bundle/_asyncToGenerator";
import LocaleStore from "../../user_settings/LocaleStore";
import UserStore from "../../../stores/UserStore";
import SubscriptionStore from "../../../stores/billing/SubscriptionStore";
import PromotionsStore from "./PromotionsStore";
import { PremiumTypes } from "../PremiumConstants";
import { EntitlementTypes } from "../../../Constants";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
import { maybeFetchActivePromotions } from "./PromotionsActionCreators";
import PremiumUtils from "../../../utils/PremiumUtils";
import { maybeFetchActiveBogoPromotion } from "../PremiumBogoPromotionUtilsCommon";
class PromotionsManager extends AutomaticLifecycleManager {
actions = {
POST_CONNECTION_OPEN: this.onPostConnectionOpen.bind(this),
EXPERIMENTS_FETCH_SUCCESS: this.onPostConnectionOpen.bind(this),
IAP_PURCHASE_PRODUCT_SUCCESS: this.onMobilePurchaseSuccess.bind(this),
GPLAY_PURCHASE_VERIFIED: this.onMobilePurchaseSuccess.bind(this),
BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS: this.onOfferUpdated.bind(this),
BILLING_USER_TRIAL_OFFER_ACKNOWLEDGED_SUCCESS: this.onOfferUpdated.bind(this),
BILLING_REFERRAL_RESOLVE_SUCCESS: this.onOfferUpdated.bind(this),
VIRTUAL_CURRENCY_REDEEM_SUCCESS: this.onVCRedeemed.bind(this)
};
stores = new Map().set(LocaleStore, this.onLocaleChanged.bind(this)).set(SubscriptionStore, this.onSubscriptionStateChanged.bind(this)).set(PromotionsStore, this.onPromotionsFetchSettled.bind(this));
lastSubscriptionStateSignature = null;
hasPendingSubscriptionRefetch = false;
maybeFetchBogoPromotion = _asyncToGenerator(function*() {
L11: {
if (PremiumUtils.isPremiumExactly(UserStore.getCurrentUser(), PremiumTypes.TIER_2)) {
break L11;
}
yield maybeFetchActiveBogoPromotion();
return void 0;
}
});
_terminate() {
this.hasPendingSubscriptionRefetch = false;
this.lastSubscriptionStateSignature = null;
}
onLocaleChanged() {
if (PromotionsStore.lastFetchedActivePromotions != null && PromotionsStore.lastFetchedActivePromotionsLocale !== LocaleStore.locale) {
maybeFetchActivePromotions(false);
}
}
async onPostConnectionOpen() {
const _this = this;
maybeFetchActivePromotions();
await _this.maybeFetchBogoPromotion();
}
onSubscriptionStateChanged() {
const subscriptions = SubscriptionStore.getSubscriptions(false);
const lastSubscriptionStateSignature = subscriptions == null ? "" : Object.values(subscriptions).map((item) => `${item.id}:${item.type}:${item.status}:${item.items.map((item) => item.planId).sort().join("|")}`).sort().join(",");
if (lastSubscriptionStateSignature !== this.lastSubscriptionStateSignature) {
this.lastSubscriptionStateSignature = lastSubscriptionStateSignature;
if (PromotionsStore.lastFetchedActivePromotions != null) {
if (PromotionsStore.isFetchingActivePromotions) {
this.hasPendingSubscriptionRefetch = true;
} else {
maybeFetchActivePromotions(false);
}
}
}
}
onPromotionsFetchSettled() {
if (this.hasPendingSubscriptionRefetch && !PromotionsStore.isFetchingActivePromotions) {
this.hasPendingSubscriptionRefetch = false;
maybeFetchActivePromotions(false);
}
}
onMobilePurchaseSuccess() {
maybeFetchActivePromotions(false);
}
onOfferUpdated() {
maybeFetchActivePromotions(false);
}
onVCRedeemed(a0) {
if (a0.entitlements.some((entitlement) => entitlement.type === EntitlementTypes.FRACTIONAL_REDEMPTION)) {
maybeFetchActivePromotions(false);
}
}
}
const promotionsManager = new PromotionsManager();
export default promotionsManager;
@@ -0,0 +1,292 @@
// Metro module 6262 (f6263).
import UserSettingsProtoStore from "../../user_settings/UserSettingsProtoStore";
import PromotionRecord from "../../../records/PromotionRecord";
import MarketingComponentRecord from "./MarketingComponentRecord";
import { PromotionTypes } from "./constants";
import Module589 from "../../../_bundle/Module589";
import Dispatcher from "../../../Dispatcher";
let c3979_5, c3979_7, c3979_8, c3979_9, c3979_10, c3979_11, locale, emptyPromotionsByType, latestActiveOutboundPromotionStartDate, c3979_15, claimedOutboundPromotionCodes2, c3979_17, getLatestActiveOutboundPromotionStartDate, initializeFromUserSettings;
const createEmptyPromotionsByType = function createEmptyPromotionsByType() {
const r1 = {};
r1[PromotionTypes.THIRD_PARTY] = {};
r1[PromotionTypes.BOGO] = {};
r1[PromotionTypes.THIRD_PARTY_DIRECT_FULFILLMENT] = {};
r1[PromotionTypes.MARKETING_MOMENT] = {};
r1[PromotionTypes.THIRD_PARTY_INBOUND] = {};
r1[PromotionTypes.THIRD_PARTY_OUTBOUND] = {};
r1[PromotionTypes.GIFT_PROMOTION] = {};
r1[PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING] = {};
return r1;
};
getLatestActiveOutboundPromotionStartDate = function getLatestActiveOutboundPromotionStartDate() {
let r2 = null;
for (const item of Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND])) {
if (r2 == null || item.startDate > r2) {
r2 = item.startDate;
}
}
const r42 = r2;
let r44 = r42 == null ? void 0 : r42.toISOString();
if (r44 == null) {
r44 = null;
}
return r44;
};
initializeFromUserSettings = function initializeFromUserSettings() {
const userContent = UserSettingsProtoStore.settings.userContent;
let r7 = userContent == null ? void 0 : userContent.lastDismissedOutboundPromotionStartDate?.value;
if (r7 == null) {
r7 = null;
}
latestActiveOutboundPromotionStartDate = r7;
};
c3979_5 = {
hasFetchedConsumedInboundPromotionId: false,
consumedInboundPromotionId: null,
lastSeenOutboundPromotionStartDate: null
};
c3979_7 = null;
c3979_8 = false;
c3979_9 = null;
c3979_10 = false;
c3979_11 = null;
locale = null;
emptyPromotionsByType = createEmptyPromotionsByType();
latestActiveOutboundPromotionStartDate = null;
c3979_15 = new Map();
claimedOutboundPromotionCodes2 = [];
c3979_17 = false;
class PromotionsStore extends Module589.PersistedStore {
static displayName = "PromotionsStore";
static persistKey = "PromotionsPersistedStore";
static migrations = [(a0) => {
try {
delete a0["bogoPromotion"];
} catch ($e) {}
return a0;
}];
initialize(a0) {
if (a0 != null) {
c3979_5 = a0;
}
this.waitFor(UserSettingsProtoStore);
this.syncWith([UserSettingsProtoStore], initializeFromUserSettings);
}
get outboundPromotions() {
return Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND]);
}
get outboundRecurringPromotions() {
return Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING]);
}
get lastSeenOutboundPromotionStartDate() {
return c3979_5.lastSeenOutboundPromotionStartDate;
}
get lastDismissedOutboundPromotionStartDate() {
return latestActiveOutboundPromotionStartDate;
}
get lastFetchedActivePromotions() {
return c3979_11;
}
get lastFetchedActivePromotionsLocale() {
return locale;
}
get isFetchingActivePromotions() {
return c3979_10;
}
get hasFetchedConsumedInboundPromotionId() {
return c3979_5.hasFetchedConsumedInboundPromotionId;
}
get consumedInboundPromotionId() {
return c3979_5.consumedInboundPromotionId;
}
get bogoPromotion() {
return c3979_7;
}
get isFetchingActiveBogoPromotion() {
return c3979_8;
}
get lastFetchedActiveBogoPromotion() {
return c3979_9;
}
get promotionsByType() {
return emptyPromotionsByType;
}
getPromotionByTypeAndId(a0, a1) {
const r3 = emptyPromotionsByType[a0];
return r3 == null ? void 0 : r3[a1];
}
getPromotionByTypeAndKey(a0, c15639_0) {
return Object.values(emptyPromotionsByType[a0]).find((item) => item.promotionKey === c15639_0);
}
getState() {
return c3979_5;
}
getMarketingComponentByType(a0) {
let r5 = c3979_15.get(a0);
if (r5 == null) {
r5 = null;
}
return r5;
}
hasPromotion(c15640_0) {
return Object.values(emptyPromotionsByType).some((item) => Object.values(item).some((item) => item.promotionKey === c15640_0));
}
getPromotionsByPartner(c15641_0) {
return {
oneTime: Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND]).filter((item) => item.partnerId === c15641_0),
recurring: Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND_RECURRING]).filter((item) => item.partnerId === c15641_0)
};
}
getGiftPromotion() {
const r11 = emptyPromotionsByType[PromotionTypes.GIFT_PROMOTION];
const r15 = Object.keys(r11);
return r15.length !== 0 ? r11[r15[0]] : null;
}
getGiftPromotionRewardSkuIds() {
let r5 = this.getGiftPromotion()?.rewardSkuIds;
if (r5 == null) {
r5 = [];
}
return r5;
}
getMarketingMomentPromotion() {
const r13 = emptyPromotionsByType[PromotionTypes.MARKETING_MOMENT];
const r16 = Object.keys(r13);
if (r16.length === 0) {
return null;
}
const r19 = r13[r16[0]];
return r19.endDate < new Date() ? null : r19;
}
getMarketingMomentRewardSkuIds() {
let r5 = this.getMarketingMomentPromotion()?.rewardSkuIds;
if (r5 == null) {
r5 = [];
}
return r5;
}
getActiveBogoRewardPromotion() {
let c15642_0 = new Date();
let r23 = Object.values(emptyPromotionsByType[PromotionTypes.MARKETING_MOMENT]).find((item) => item.hasBogoReward && item.endDate >= c15642_0);
if (r23 == null) {
r23 = null;
}
return r23;
}
get claimedOutboundPromotionCodes() {
return claimedOutboundPromotionCodes2;
}
get claimedOutboundPromotionCodesLoaded() {
return c3979_17;
}
}
const promotionsStore = new PromotionsStore(Dispatcher, {
ACTIVE_PROMOTIONS_FETCH_SUCCESS: function handleActivePromotionsFetchSuccess({ promotions, consumedInboundPromotionId: consumedInboundPromotionId2 }) {
emptyPromotionsByType = createEmptyPromotionsByType();
c3979_15 = new Map();
promotions.forEach((promotion) => {
emptyPromotionsByType[promotion.promotion_type][promotion.id] = PromotionRecord.createFromServer(promotion);
const marketing_components = promotion.marketing_components;
if (marketing_components != null) {
marketing_components.forEach((marketing_component) => {
c3979_15.set(marketing_component.component_type, MarketingComponentRecord.createFromServer(marketing_component));
});
}
});
c3979_11 = Date.now();
c3979_10 = false;
if (!c3979_5.hasFetchedConsumedInboundPromotionId) {
c3979_5.hasFetchedConsumedInboundPromotionId = true;
c3979_5.consumedInboundPromotionId = consumedInboundPromotionId2;
}
},
ACTIVE_PROMOTIONS_FETCH: function handleActivePromotionsFetchStart({ locale: locale2 }) {
c3979_10 = true;
locale = locale2;
},
ACTIVE_PROMOTIONS_FETCH_FAIL: function handleActivePromotionsFetchFail() {
emptyPromotionsByType = createEmptyPromotionsByType();
c3979_15 = new Map();
c3979_10 = false;
},
ACTIVE_PROMOTIONS_CLEAR: function handleActivePromotionsClear() {
emptyPromotionsByType = createEmptyPromotionsByType();
c3979_15 = new Map();
c3979_7 = null;
c3979_10 = false;
c3979_11 = Date.now();
},
ACTIVE_BOGO_PROMOTION_FETCH_SUCCESS: function handleActiveBogoPromotionFetchSuccess({ activePromotion }) {
c3979_7 = {
id: activePromotion.id,
startDate: activePromotion.startDate.toISOString(),
endDate: activePromotion.endDate.toISOString()
};
c3979_9 = Date.now();
c3979_8 = false;
},
ACTIVE_BOGO_PROMOTION_FETCH: function handleActiveBogoPromotionFetchStart() {
c3979_8 = true;
},
ACTIVE_BOGO_PROMOTION_FETCH_FAIL: function handleActiveBogoPromotionFetchFail() {
c3979_7 = null;
c3979_8 = false;
},
OUTBOUND_PROMOTION_NOTICE_DISMISS: function handleDismissOutboundPromotionNotice() {
if (Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND]).length === 0) {
return false;
}
const latestActiveOutboundPromotionStartDate2 = getLatestActiveOutboundPromotionStartDate();
if (latestActiveOutboundPromotionStartDate2 != null) {
latestActiveOutboundPromotionStartDate = latestActiveOutboundPromotionStartDate2;
}
},
OUTBOUND_PROMOTIONS_SEEN: function handleOutboundPromotionsSeen() {
if (Object.values(emptyPromotionsByType[PromotionTypes.THIRD_PARTY_OUTBOUND]).length === 0) {
return false;
}
const latestActiveOutboundPromotionStartDate2 = getLatestActiveOutboundPromotionStartDate();
if (latestActiveOutboundPromotionStartDate2 != null) {
latestActiveOutboundPromotionStartDate = latestActiveOutboundPromotionStartDate2;
c3979_5.lastSeenOutboundPromotionStartDate = latestActiveOutboundPromotionStartDate2;
}
},
CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_SUCCESS: function handleClaimedOutboundPromotionCodesFetchSuccess(a0) {
claimedOutboundPromotionCodes2 = a0.claimedOutboundPromotionCodes;
c3979_17 = true;
},
CLAIMED_OUTBOUND_PROMOTION_CODES_FETCH_FAIL: function handleClaimedOutboundPromotionCodesFetchFail() {
claimedOutboundPromotionCodes2 = [];
c3979_17 = true;
},
CLAIMED_OUTBOUND_PROMOTION_CODE_ADD: function handleClaimedOutboundPromotionCodeAdd({ claimedOutboundPromotionCode }) {
if (claimedOutboundPromotionCodes2.some((item) => item.promotion.id === claimedOutboundPromotionCode.promotion.id)) {
return false;
}
claimedOutboundPromotionCodes2 = [...claimedOutboundPromotionCodes2, claimedOutboundPromotionCode];
},
LOGOUT: function handleLogout() {
c3979_5 = {
hasFetchedConsumedInboundPromotionId: false,
consumedInboundPromotionId: null,
lastSeenOutboundPromotionStartDate: null
};
c3979_10 = false;
c3979_11 = null;
c3979_8 = false;
c3979_9 = null;
emptyPromotionsByType = createEmptyPromotionsByType();
c3979_7 = null;
c3979_15.clear();
claimedOutboundPromotionCodes2 = [];
c3979_17 = false;
},
PREMIUM_MARKETING_PREVIEW: function handlePremiumMarketingPreview({ data }) {
const fromServer = MarketingComponentRecord.createFromServer(data);
c3979_15.set(fromServer.componentType, fromServer);
if (data.promotion != null) {
emptyPromotionsByType[data.promotion.promotion_type][data.promotion.id] = PromotionRecord.createFromServer(data.promotion);
}
}
});
export default promotionsStore;
+47
View File
@@ -0,0 +1,47 @@
// Metro module 6264 (f6265).
const r8 = {
BLOCKLIST: "blocklist",
ALLOWLIST: "allowlist"
};
const r19 = {
THIRD_PARTY: 0,
0: "THIRD_PARTY",
BOGO: 1,
1: "BOGO",
THIRD_PARTY_DIRECT_FULFILLMENT: 2,
2: "THIRD_PARTY_DIRECT_FULFILLMENT",
THIRD_PARTY_INBOUND: 3,
3: "THIRD_PARTY_INBOUND",
THIRD_PARTY_OUTBOUND: 4,
4: "THIRD_PARTY_OUTBOUND",
MARKETING_MOMENT: 5,
5: "MARKETING_MOMENT",
GIFT_PROMOTION: 6,
6: "GIFT_PROMOTION",
THIRD_PARTY_OUTBOUND_RECURRING: 7,
7: "THIRD_PARTY_OUTBOUND_RECURRING"
};
const set = new Set(["logitech", "call_of_duty"]);
export { r8 as CountryListMode };
export { r19 as PromotionTypes };
export const RECURRING_PARTNERS = {
steelseries: {
id: "steelseries",
label: "SteelSeries"
},
kontrolfreek: {
id: "kontrolfreek",
label: "KontrolFreek"
},
logitech: {
id: "logitech",
label: "Logitech"
}
};
export const STEELSERIES_PARTNER_ID = "steelseries";
export const KONTROLFREEK_PARTNER_ID = "kontrolfreek";
export const LOGITECH_PARTNER_ID = "logitech";
export const CALL_OF_DUTY_PARTNER_ID = "call_of_duty";
export const XBOX_PARTNER_ID = "xbox";
export const YOUTUBE_PARTNER_ID = "youtube";
export { set as DEDICATED_SURFACE_PARTNER_IDS };
@@ -0,0 +1,85 @@
// Metro module 15758 (f15759).
import { useCallback } from "react";
import { View } from "react-native";
import { PremiumTypes } from "../../PremiumConstants";
import { AnalyticsObjectTypes, AnalyticsObjects, AnalyticsPages, AnalyticsSections, HelpdeskArticles } from "../../../../Constants";
import { ContentDismissActionType } from "../../../dismissible_content/DismissibleContentConstants";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import openPremiumPlanSelectionActionSheet from "../../native/openPremiumPlanSelectionActionSheet";
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
import FastImage from "../../../../components_native/common/FastImage";
import { Text } from "../../../../design/components/Text/native/Text";
import { intl, t } from "../../../../intl/index.native";
import HelpdeskUtils from "../../../../utils/HelpdeskUtils";
import NitroUpsellButton from "../../components/native/NitroUpsellButton";
const useStyles = createStyles({
container: {
dipslay: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
padding: Module712.space.PX_16,
borderRadius: Module712.radii.lg,
marginBottom: Module712.space.PX_24
},
buttonContainer: {
marginTop: Module712.space.PX_24,
width: 335,
height: 48
},
header: {
marginBottom: 12,
textAlign: "center"
},
subheader: {
textAlign: "center"
},
image: {
alignSelf: "center",
paddingBottom: Module712.space.PX_16,
height: 213,
width: 335,
borderRadius: Module712.radii.lg,
marginBottom: 12
}
});
export default function BogoPromotionActionSheet(props) {
const markAsDismissed = props.markAsDismissed;
const styles = useStyles();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const callback = useCallback(() => {
markAsDismissed(ContentDismissActionType.PRIMARY);
openPremiumPlanSelectionActionSheet({
analyticsLocation: {
page: AnalyticsPages.BOGO_PROMOTION_ACTION_SHEET,
section: AnalyticsSections.FOOTER,
object: AnalyticsObjects.BUTTON_CTA,
objectType: AnalyticsObjectTypes.BUY
},
analyticsLocations,
premiumType: PremiumTypes.TIER_2
});
}, [analyticsLocations, markAsDismissed]);
return <BottomSheet onDismiss={useCallback(() => {
markAsDismissed(ContentDismissActionType.USER_DISMISS);
}, [markAsDismissed])}>
<View style={[styles.container]}>
<FastImage source={{
uri: "https://cdn.discordapp.com/assets/content/a59aed2e0e61a955dc3e0f4f6f7ab295e39f89a93c4f01e4bd84ed7fb418ec63.png"
}} style={styles.image} />
<Text style={[styles.header]} color="mobile-text-heading-primary" variant="heading-xl/bold">
{intl.string(t["6Jjfk8"])}
</Text>
<Text style={[styles.subheader]} color="text-subtle" variant="text-md/medium">
{intl.format(t.y7lJK6, {
helpCenterLink: HelpdeskUtils.getArticleURL(HelpdeskArticles.SUMMER_BOGO_2025)
})}
</Text>
<View style={[styles.buttonContainer]}>
<NitroUpsellButton text={intl.string(t.J61px0)} onPress={callback} />
</View>
</View>
</BottomSheet>;
};
@@ -0,0 +1,84 @@
// Metro module 6685 (f6686).
import { Image as Image2, View } from "react-native";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import { getButtonActionHandler } from "../../premium_marketing/native/PremiumMarketingButtonActions";
import useTrackImpression from "../../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../../_bundle/Module503";
import { MarketingComponentType } from "../../../../_bundle/Module6567";
import { useFormatStringWithCommonPremiumParams, getHelpArticleLinkProps } from "../PromotionStringUtils";
import { Text } from "../../../../design/components/Text/native/Text";
import Linking from "../../../../lib/native/Linking";
import NitroUpsellButton from "../../components/native/NitroUpsellButton";
const useStyles = createStyles({
container: {
width: "100%"
},
card: {
display: "flex",
width: "100%",
flexDirection: "column",
justifyContent: "flex-start",
padding: Module712.space.PX_16,
borderRadius: Module712.radii.lg,
backgroundColor: Module712.colors.BACKGROUND_SECONDARY_ALT,
overflow: "hidden"
},
image: {
width: "100%",
maxWidth: 317,
height: 144,
borderRadius: Module712.radii.md,
marginBottom: Module712.space.PX_16,
padding: Module712.space.PX_8,
alignSelf: "center"
},
bodyText: {
marginTop: Module712.space.PX_4
},
ctaButton: {
marginTop: Module712.space.PX_16
}
});
export default function MarketingPageBannerTile(props) {
const { style, cardStyle, componentId, bannerFields, analyticsPage, onPaymentSuccess, onPaymentDismiss } = props;
const styles = useStyles();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const buttonAction = bannerFields.button?.buttonAction;
const button = bannerFields.button;
const buttonActionHandler = getButtonActionHandler({
buttonAction,
applicationId: button == null ? void 0 : button.navigableStorefrontApplicationId?.value,
analyticsLocations,
analyticsPage,
onPaymentSuccess,
onPaymentDismiss
});
useTrackImpression({
type: ImpressionTypes.VIEW,
name: ImpressionNames.PREMIUM_MARKETING_COMPONENT,
properties: {
component_type: MarketingComponentType.MARKETING_PAGE_BANNER,
component_id: componentId
}
});
const formatStringWithCommonPremiumParams = useFormatStringWithCommonPremiumParams(bannerFields.body);
const helpArticleLinkProps = getHelpArticleLinkProps(bannerFields.helpArticle, bannerFields.helpArticleId);
return <View style={[styles.container, style]}>
<View style={[styles.card, cardStyle]}>
{bannerFields.assetUrl !== "" && <Image2 source={{
uri: bannerFields.assetUrl
}} style={styles.image} resizeMode="contain" />}
<Text color="mobile-text-heading-primary" variant="text-lg/bold">{bannerFields.header}</Text>
<Text color="mobile-text-heading-primary" variant="text-sm/medium" style={styles.bodyText}>
{formatStringWithCommonPremiumParams}
{" "}
{helpArticleLinkProps != null && <Text color="text-link" variant="text-sm/medium" accessibilityRole="link" onPress={() => Linking.openURL(helpArticleLinkProps.url)}>{helpArticleLinkProps.linkText}</Text>}
</Text>
{bannerFields.button != null && <View style={styles.ctaButton}>
<NitroUpsellButton text={bannerFields.button.copy} onPress={buttonActionHandler} />
</View>}
</View>
</View>;
};
@@ -0,0 +1,126 @@
// Metro module 15761 (f15762).
import { useCallback } from "react";
import { View } from "react-native";
import AccessibilityStore from "../../../a11y/AccessibilityStore";
import { AnalyticsPages } from "../../../../Constants";
import { ContentDismissActionType } from "../../../dismissible_content/DismissibleContentConstants";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../_bundle/Module589";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import Dispatcher from "../../../../Dispatcher";
import { getButtonActionHandler } from "../../premium_marketing/native/PremiumMarketingButtonActions";
import useTrackImpression from "../../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../../_bundle/Module503";
import { MarketingComponentType } from "../../../../_bundle/Module6567";
import { getHelpArticleLinkProps } from "../PromotionStringUtils";
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
import { getFile } from "../../../../utils/UploadUtils";
import Video from "../../../../components_native/common/Video";
import FastImage from "../../../../components_native/common/FastImage";
import { Text } from "../../../../design/components/Text/native/Text";
import Linking from "../../../../lib/native/Linking";
import NitroUpsellButton from "../../components/native/NitroUpsellButton";
import { intl, t } from "../../../../intl/index.native";
const useStyles = createStyles({
container: {
display: "flex",
flexDirection: "column",
alignItems: "center",
paddingVertical: 12,
paddingHorizontal: 20,
borderRadius: Module712.radii.lg
},
buttonContainer: {
marginTop: Module712.space.PX_24,
width: 335,
height: 48
},
header: {
marginBottom: Module712.space.PX_8,
textAlign: "center"
},
body: {
textAlign: "center"
},
image: {
height: 188,
width: 335,
borderRadius: Module712.radii.md,
marginBottom: Module712.space.PX_24
},
video: {
borderRadius: Module712.radii.md,
marginBottom: Module712.space.PX_24
}
});
export default function PremiumMarketingMomentActionSheet(props) {
let analyticsLocations, callback, helpArticleLinkProps;
const { markAsDismissed, bottomSheetData, componentId, promotionId } = props;
analyticsLocations = void 0;
callback = void 0;
helpArticleLinkProps = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
analyticsLocations = useAnalyticsLocations().analyticsLocations;
callback = useCallback((a0) => {
markAsDismissed(a0);
Dispatcher.dispatch({
type: "PREMIUM_MARKETING_ANNOUNCEMENT_MODAL_DISMISSED",
promotionId
});
}, [markAsDismissed, promotionId]);
const r40 = [bottomSheetData.button?.buttonAction, , , ,];
const button = bottomSheetData.button;
const r13 = button == null ? void 0 : button.navigableStorefrontApplicationId?.value;
const r45 = () => {
callback(ContentDismissActionType.PRIMARY);
const buttonAction = bottomSheetData.button?.buttonAction;
const button = bottomSheetData.button;
getButtonActionHandler({
buttonAction,
applicationId: button == null ? void 0 : button.navigableStorefrontApplicationId?.value,
analyticsLocations,
analyticsPage: AnalyticsPages.PREMIUM_MARKETING_MOMENT_ACTION_SHEET
})();
};
r40[1] = r13;
r40[2] = callback;
r40[3] = analyticsLocations;
const callback2 = useCallback(r45, r40);
const callback3 = useCallback(() => {
callback(ContentDismissActionType.USER_DISMISS);
}, [callback]);
useTrackImpression({
type: ImpressionTypes.HALFSHEET,
name: ImpressionNames.PREMIUM_MARKETING_COMPONENT,
properties: {
component_type: MarketingComponentType.MOBILE_BOTTOM_SHEET,
component_id: componentId,
dismissible_content: bottomSheetData.dismissibleContent
}
});
helpArticleLinkProps = getHelpArticleLinkProps(bottomSheetData.helpArticle, bottomSheetData.helpArticleId);
const r102 = [getFile({
uri: bottomSheetData.assetUrl
}).isVideo ? <Video src={{
videoURI: bottomSheetData.assetUrl,
uri: bottomSheetData.assetUrl
}} style={styles.video} muted height={188} width={335} paused={stateFromStores} resizeMode="contain" /> : <FastImage source={{
uri: bottomSheetData.assetUrl
}} style={styles.image} resizeMode="contain" />, <Text style={[styles.header]} color="mobile-text-heading-primary" variant="heading-lg/extrabold">{bottomSheetData.header}</Text>, <Text style={[styles.body]} color="text-default" variant="text-sm/normal">
{bottomSheetData.body}
{" "}
{helpArticleLinkProps != null && <Text color="text-link" variant="text-sm/normal" accessibilityRole="link" onPress={() => Linking.openURL(helpArticleLinkProps.url)}>{helpArticleLinkProps.linkText}</Text>}
</Text>, ,];
let text = bottomSheetData.button?.copy;
if (text == null) {
text = intl.string(t.J61px0);
}
r102[3] = <View style={[styles.buttonContainer]}>
<NitroUpsellButton text={text} onPress={callback2} />
</View>;
return <BottomSheet onDismiss={callback3}>
<View style={[styles.container]}>{r102}</View>
</BottomSheet>;
};