// Metro module 4405 (f4406). import _slicedToArray from "../../_bundle/_slicedToArray"; import { useState, useRef, useCallback, useEffect } from "react"; import FamilyCenterPendingConnectionStore from "../parent_tools/FamilyCenterPendingConnectionStore"; import RegionalFeatureConfigStore from "../regional_feature_config/RegionalFeatureConfigStore"; import AuthenticationStore from "../../stores/AuthenticationStore"; import MessageStore from "../../stores/MessageStore"; import UserStore from "../../stores/UserStore"; import AgeVerificationStore from "./AgeVerificationStore"; import { FULLSCREEN_AGE_VERIFICATION_ENTRY_POINTS } from "./AgeVerificationConstants"; import { MessageEmbedTypes } from "../../Constants"; import { AgeGateSource, REACTIVE_CHECK_AGE_GATE_SOURCES } from "../age_gate/AgeGateConstants"; import { SafetyToastType } from "../safety_common/Constants"; import { AgeVerificationModalEntryPoint } from "./AgeVerificationAnalyticsUtils"; import { AgeGatedFeature } from "../../_bundle/Module5013"; import { useIsFeatureAgeGated } from "../regional_feature_config/RegionalFeatureConfigUtils"; import { AgeVerificationStatusUkAndAusOnly } from "../../flow/Server"; import { useStateFromStores } from "../../_bundle/Module589"; import { FamilyCenterConnectionPrereqExperiment } from "../parent_tools/FamilyCenterConnectionPrereqExperiment"; import Dispatcher from "../../Dispatcher"; import { requestAgeVerification } from "./AgeVerificationURLActionCreators"; import AgeVerificationActionCreators_native from "./AgeVerificationActionCreators.native"; import SafetyToastsActionCreators_native from "../safety_common/SafetyToastsActionCreators.native"; import usePrevious from "../../hooks/usePrevious"; import { intl, t } from "../../intl/index.native"; import AgeAssurance_messages from "./AgeAssurance.messages"; import { fetchReactiveCheckResult } from "./ReactiveCheckActionCreators"; let shouldCallReactiveCheck, c2635_16, c2635_17, c2635_18, c2635_19; let $mk74512 = function() { return () => UserStore.getCurrentUser()?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT; }, $mk74513 = function() { return () => UserStore.getCurrentUser(); }; let env2635 = {}; export function useShouldCallReactiveCheck() { const stateFromStores = useStateFromStores([UserStore], $mk74513()); const r18 = stateFromStores?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.UNVERIFIED && stateFromStores?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.CLIENT_ONLY_PENDING; let c14234_0 = r18; const isFeatureAgeGated = useIsFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK); return useStateFromStores([AgeVerificationStore], () => { let r1 = !c14234_0; if (!c14234_0) { let r5 = isFeatureAgeGated; if (isFeatureAgeGated) { r5 = AgeVerificationStore.shouldCallReactiveCheck(); } r1 = r5; } return r1; }, [r18, isFeatureAgeGated]); } shouldCallReactiveCheck = function shouldCallReactiveCheck() { const currentUser = UserStore.getCurrentUser(); const r14 = currentUser?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.UNVERIFIED && currentUser?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.CLIENT_ONLY_PENDING; return r14 ? !r14 : RegionalFeatureConfigStore.isFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK) && AgeVerificationStore.shouldCallReactiveCheck(); }; c2635_16 = new Set([AgeVerificationModalEntryPoint.STAGE_CHANNEL_AGE_VERIFICATION_PROMPT, AgeVerificationModalEntryPoint.START_STAGE_PROMPT, AgeVerificationModalEntryPoint.STAGE_CHANNEL_RAISE_HAND]); c2635_17 = new Set([AgeGateSource.NSFW_SERVER, AgeGateSource.NSFW_SERVER_INVITE, AgeGateSource.NSFW_SERVER_INVITE_EMBED, AgeGateSource.LARGE_GUILD, AgeGateSource.JOIN_LARGE_GUILD_UNDERAGE, AgeGateSource.ACCESS_LARGE_GUILD_UNDERAGE]); c2635_18 = { CTAS: "ctas", CONTENT_TYPE: "content_type" }; c2635_19 = { RETRY: "retry", CONNECT_TO_TEEN: "connect_to_teen" }; const r87 = { VERIFIED_ADULT: "verified_adult", VERIFIED_TEEN: "verified_teen", ERROR: "error" }; export function ageGateSourceHasLightboxBackdrop(a0) { return c2635_17.has(a0); } export function shouldShowTiggerPawtect() { const ageVerificationStatus = UserStore.getCurrentUser()?.ageVerificationStatus; let r16 = ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.VERIFIED_ADULT; if (r16) { const isFeatureAgeGated2 = RegionalFeatureConfigStore.isFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK); r16 = isFeatureAgeGated2 ? ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT : !isFeatureAgeGated2; } return r16; } export function useShouldShowTiggerPawtect() { const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser()); const r19 = useIsFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK) && stateFromStores?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT; return stateFromStores?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.VERIFIED_ADULT && !r19; } export function isVerifiedTeen() { return UserStore.getCurrentUser()?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.VERIFIED_TEEN; } export function useIsVerifiedTeen() { return useStateFromStores([UserStore], () => UserStore.getCurrentUser())?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.VERIFIED_TEEN; } export function isVerifiedAdult() { const ageVerificationStatus = UserStore.getCurrentUser()?.ageVerificationStatus; return ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.VERIFIED_ADULT || RegionalFeatureConfigStore.isFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK) && ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT; } export function useIsVerifiedAdult() { const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser()); const r19 = useIsFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK) && stateFromStores?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT; return stateFromStores?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.VERIFIED_ADULT || r19; } export function useIsExplicitlyVerifiedAdult() { return useStateFromStores([UserStore], () => UserStore.getCurrentUser())?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.VERIFIED_ADULT; } export function isAssignedByDiscord() { return UserStore.getCurrentUser()?.ageVerificationStatus === AgeVerificationStatusUkAndAusOnly.INFERRED_ADULT; } export function useIsAssignedByDiscord() { return useStateFromStores([UserStore], $mk74512()); } export function useShowAssignedAgeGroupSettings() { const stateFromStores = useStateFromStores([UserStore], $mk74512()); return useIsFeatureAgeGated(AgeGatedFeature.REACTIVE_CHECK) && stateFromStores; } export { c2635_18 as AgeVerificationSystemNotificationEmbedKeys }; export { c2635_19 as AgeVerificationSystemNotificationCtaTypes }; export { r87 as AgeVerificationSystemNotificationContentType }; export function isAgeVerificationMessageWithRetryCta(a0, a1) { const message = MessageStore.getMessage(a0, a1); if (message != null && message.embeds != null && message.embeds.length !== 0 && message.embeds[0].fields != null && message.embeds[0].type === MessageEmbedTypes.AGE_VERIFICATION_SYSTEM_NOTIFICATION) { const r24 = message.embeds[0].fields.find((field) => field.rawName === c2635_18.CTAS); return r24 == null ? void 0 : r24.rawValue.split(",").includes(c2635_19.RETRY); } return false; } export function isAgeVerificationMessageWithConnectToTeenCta(a0, a1) { if (FamilyCenterPendingConnectionStore.getPendingConnection() == null) { return false; } const message = MessageStore.getMessage(a0, a1); if (message != null && message.embeds != null && message.embeds.length !== 0 && message.embeds[0].fields != null && message.embeds[0].type === MessageEmbedTypes.AGE_VERIFICATION_SYSTEM_NOTIFICATION) { const r28 = message.embeds[0].fields.find((field) => field.rawName === c2635_18.CTAS); return !((r28 == null ? void 0 : r28.rawValue.split(",").includes(c2635_19.CONNECT_TO_TEEN)) !== true) && FamilyCenterConnectionPrereqExperiment.getConfig({ location: "isAgeVerificationMessageWithConnectToTeenCta" }).enabled; } return false; } export function isAgeVerified() { const currentUser = UserStore.getCurrentUser(); return currentUser?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.UNVERIFIED && currentUser?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.CLIENT_ONLY_PENDING; } export function useIsAgeVerified() { const stateFromStores = useStateFromStores([UserStore], $mk74513()); return stateFromStores?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.UNVERIFIED && stateFromStores?.ageVerificationStatus !== AgeVerificationStatusUkAndAusOnly.CLIENT_ONLY_PENDING; } export function useInitiateAgeVerification(a0) { let env14235 = { $parent: env2635 }; const onComplete = a0.onComplete; env14235[0] = onComplete; const entryPoint = a0.entryPoint; env14235[1] = entryPoint; let shouldShowExpressiveModal = a0.shouldShowExpressiveModal; if (shouldShowExpressiveModal === void 0) { shouldShowExpressiveModal = false; } env14235[2] = shouldShowExpressiveModal; let classificationId2 = a0.classificationId; if (classificationId2 === void 0) { classificationId2 = null; } env14235[3] = classificationId2; env14235[4] = void 0; env14235[5] = void 0; env14235[6] = void 0; const r17 = _slicedToArray(useState(false), 2); const loading = r17[0]; env14235[4] = r17[1]; const ageVerificationStatus = useStateFromStores([UserStore], () => UserStore.getCurrentUser())?.ageVerificationStatus; let c14236_0; const current = useRef(ageVerificationStatus).current; env14235[5] = current; const callback = useCallback(() => { Dispatcher.dispatch({ type: "CLOSE_AGE_VERIFICATION_MODAL", status: env14235[5] }); }, [current]); env14235[6] = callback; c14236_0 = void 0; c14236_0 = async (method, vendor) => { let classificationId, c29335_5; let c29335_6 = 0; let c31344_0; L14: { try { c31344_0 = void 0; (0, env14235[4])(true); c29335_6 = 2; Dispatcher.dispatch({ type: "INITIATE_AGE_VERIFICATION" }); classificationId = env14235[3]; if (classificationId == null) { classificationId = void 0; } c31344_0 = await requestAgeVerification({ method, classificationId, vendor }); if (AgeVerificationActionCreators_native.showAgeVerification({ webviewUrl: c31344_0.verification_webview_url, verificationRequestId: c31344_0.verification_request_id, verificationVendorName: c31344_0.verification_vendor_name, incodeParameters: c31344_0.incode_parameters, onComplete: env14235[0], onClose: env14235[6], onCancel: env14235[6], entryPoint: env14235[1], shouldShowExpressiveModal: env14235[2] }) === false) { SafetyToastsActionCreators_native.showFailedToast(SafetyToastType.TIGGER_PAWTECT_ERROR); (0, env14235[6])(); } c29335_6 = 1; c29335_6 = 0; (0, env14235[4])(false); } catch ($e) { const r29 = $e; let r7 = r29; c29335_5 = r29; let r30 = c29335_6; if (r30 !== 0) { while (true) { if (r30 === 1) { try { const r136 = c29335_5; c29335_6 = 0; (0, env14235[4])(false); throw r136; } catch (r134) { r7 = r134; c29335_5 = r134; r30 = c29335_6; if (r30 === 0) { break; } } } else { try { c29335_6 = 1; SafetyToastsActionCreators_native.showFailedToast(SafetyToastType.TIGGER_PAWTECT_ERROR); (0, env14235[6])(); c29335_6 = 0; (0, env14235[4])(false); break L14; } catch (r112) { r7 = r112; c29335_5 = r112; r30 = c29335_6; if (r30 === 0) { break; } } } } } throw r7; } } }; return { loading, initiateAgeVerification: useCallback(function() { return c14236_0.apply(this, arguments); }, [onComplete, callback, shouldShowExpressiveModal, classificationId2, entryPoint]) }; } export function useWatchAgeVerificationStatusChange(a0) { let c14237_1, c14237_2; const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser()?.ageVerificationStatus); const previous = usePrevious(stateFromStores); const stateFromStores2 = useStateFromStores([AuthenticationStore], () => AuthenticationStore.getSuspendedUserToken() != null); const stateFromStores3 = useStateFromStores([AuthenticationStore], () => AuthenticationStore.isAuthenticated()); const r0 = previous != null && stateFromStores != null && previous !== stateFromStores; c14237_1 = r0; const r33 = stateFromStores2 ? !stateFromStores2 : !stateFromStores3; c14237_2 = r33; useEffect(() => { if (c14237_1 || c14237_2) { a0(); } }, [a0, r0, r33]); } export function isFullscreenAgeVerificationEntryPoint(a0) { return a0 != null && FULLSCREEN_AGE_VERIFICATION_ENTRY_POINTS.has(a0); } export function getAgeVerificationGetStartedTitle(a0) { return c2635_16.has(a0) ? intl.string(t.lSWVTM) : intl.string(t.xYXsr6); } export function getAgeVerificationGetStartedSubtitle(a0, a1, r2 = false) { return c2635_16.has(a0) ? intl.string(t["S/xS/w"]) : r2 ? intl.string(AgeAssurance_messages.h7qzoa) : a1 != null ? intl.format(AgeAssurance_messages.RpMIT0, { handleOnHelpUrlHook: a1 }) : intl.string(t.HxS3oQ); } export function useMaybePerformReactiveCheckForSource(a0) { const shouldCallReactiveCheck2 = useShouldCallReactiveCheck(); let c14238_1 = shouldCallReactiveCheck2; useEffect(() => { if (c14238_1 && REACTIVE_CHECK_AGE_GATE_SOURCES.has(a0)) { fetchReactiveCheckResult(); } }, [shouldCallReactiveCheck2, a0]); } export { shouldCallReactiveCheck }; export async function maybePerformReactiveCheck() { let reactiveCheckResult; L11: { const shouldCallReactiveCheck2 = shouldCallReactiveCheck(); const r12 = null; if (shouldCallReactiveCheck2) { reactiveCheckResult = await fetchReactiveCheckResult(); break L11; } return r12; } return reactiveCheckResult; }