368 lines
16 KiB
TypeScript
368 lines
16 KiB
TypeScript
// Metro module 14144 (f14145).
|
|
import Module19, { useState } from "react";
|
|
import { View } from "react-native";
|
|
import QuestStore from "../../QuestStore";
|
|
import { QuestTaskPlatform, QuestsExperimentLocations } from "../../QuestConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { getQuestLogger } from "../../lib/getQuestLogger";
|
|
import { manuallyStartConsoleQuest } from "../../QuestActionCreators";
|
|
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import Module9172 from "../../../../_bundle/Module9172";
|
|
import { useQuestTaskDetails, useIsQuestProgressing, useTaskPlatformScreen, useConnectedAccounts, useQuestHowToHelpArticle } from "../../hooks/QuestHooks";
|
|
import { supportedConsoles } from "../../utils/QuestPlatformUtils";
|
|
import { TaskPlatformScreen, QuestContent } from "../../QuestTypes";
|
|
import { useHasWatchVideoOnMobileTasks, useMobileActivityQuest } from "../QuestHooks.native";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { QuestContentImpressionTrackerNative } from "../QuestContentImpressionTracker.native";
|
|
import * as _QuestTaskUtils from "../../utils/QuestTaskUtils";
|
|
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
|
|
import QuestBottomSheetHeader from "./QuestBottomSheetHeader";
|
|
import QuestBottomSheetFooter from "./QuestBottomSheetFooter";
|
|
import { useTrackQuestContentClickedWithImpression } from "../../lib/analytics/AnalyticsHooks";
|
|
import { useQuestImpressionId } from "../../lib/analytics/ContentImpressionTrackerHooks";
|
|
import { QuestContentCTA } from "../../lib/analytics/AnalyticsTypes";
|
|
import { shouldMigrateToAdAnalyticsInterface, AdAnalyticsInterfaceExperimentStep } from "../../experiments/AdAnalyticsInterfaceExperiment";
|
|
import { captureAdUserAction } from "../../../ads/analytics/captureAdUserAction";
|
|
import { AdUserActionType } from "../../../ads/analytics/captureAdUserActionTypes";
|
|
import { AdCreativeType } from "../../../../_bundle/Module6013";
|
|
import { QuestBottomSheetProgressCardWatchTask, QuestBottomSheetProgressCardInGameTask, QuestBottomSheetProgressCardPlayStreamTask } from "./QuestBottomSheetProgressCard";
|
|
import QuestBottomSheetTaskSelect from "./QuestBottomSheetTaskSelect";
|
|
import QuestBottomSheetConsoleConnect from "./QuestBottomSheetConsoleConnect";
|
|
import { isSponsoredPlayQuest } from "../../utils/QuestUtils";
|
|
import { WarningIcon } from "../../../../design/components/Icon/native/redesign/generated/WarningIcon";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
let c9898_13, useStyles, useEnrolledQuestContentProps, QuestBottomSheetContent, MicrophoneUnit, context;
|
|
const QuestBottomSheet = function QuestBottomSheet(props) {
|
|
let state, r55, Provider, defibrillator, footer, handleTaskSelect2, props2, quest5, showMicrophone, sourceQuestContent4, step, styles;
|
|
let setState;
|
|
L4: {
|
|
quest5 = props.quest;
|
|
const initialStep2 = props.initialStep;
|
|
sourceQuestContent4 = props.sourceQuestContent;
|
|
setState = void 0;
|
|
styles = useStyles();
|
|
const enrolledQuestContentProps = useEnrolledQuestContentProps({
|
|
quest: quest5,
|
|
initialStep: initialStep2,
|
|
location: QuestsExperimentLocations.QUEST_HOME_MOBILE,
|
|
sourceQuestContent: sourceQuestContent4
|
|
});
|
|
step = enrolledQuestContentProps.step;
|
|
defibrillator = enrolledQuestContentProps.defibrillator;
|
|
const stepActions = enrolledQuestContentProps.stepActions;
|
|
handleTaskSelect2 = enrolledQuestContentProps.handleTaskSelect;
|
|
showMicrophone = enrolledQuestContentProps.showMicrophone;
|
|
const hasWatchVideoOnMobileTasks3 = useHasWatchVideoOnMobileTasks(quest5.config);
|
|
const hasWatchVideoTasks = _QuestTaskUtils.hasWatchVideoTasks(quest5);
|
|
const isInGameQuest = _QuestTaskUtils.isInGameQuest(quest5);
|
|
let state;
|
|
[state, setState] = useState(0);
|
|
const memo4 = Module19.useMemo(() => ({
|
|
isInQuestBottomSheet: true
|
|
}), []);
|
|
Provider = context.Provider;
|
|
r55 = {
|
|
value: memo4,
|
|
children: null
|
|
};
|
|
props2 = {
|
|
header: <QuestBottomSheetHeader quest={quest5} step={step} location={QuestsExperimentLocations.QUEST_HOME_MOBILE} />,
|
|
footer: null,
|
|
startExpanded: true,
|
|
children: null
|
|
};
|
|
footer = null;
|
|
if (!isInGameQuest) {
|
|
if (hasWatchVideoTasks) {
|
|
footer = null;
|
|
if (!hasWatchVideoOnMobileTasks3) {
|
|
break L4;
|
|
}
|
|
}
|
|
footer = <QuestBottomSheetFooter quest={quest5} sourceQuestContent={sourceQuestContent4} step={step} isDefibrilating={defibrillator.isActive} onLayout={function onLayout(event) {
|
|
setState(event.nativeEvent.layout.height);
|
|
}} onBack={stepActions.onBack} onDefib={defibrillator.start} onConnectConsoleNext={stepActions.onNext} />;
|
|
}
|
|
}
|
|
props2.footer = footer;
|
|
props2.children = <View style={[styles.contentContainer, {
|
|
paddingBottom: step !== c9898_13.TASK_SELECT ? state : 0
|
|
}]}>
|
|
<QuestBottomSheetContent defibrillator={defibrillator} quest={quest5} handleTaskSelect={handleTaskSelect2} location={QuestsExperimentLocations.QUEST_HOME_MOBILE} showMicrophone={showMicrophone} sourceQuestContent={sourceQuestContent4} step={step} />
|
|
</View>;
|
|
r55.children = <BottomSheet {...props2} />;
|
|
return <Provider {...r55} />;
|
|
};
|
|
useEnrolledQuestContentProps = function useEnrolledQuestContentProps(a0) {
|
|
let xboxAndPlaystationAccounts, c20940_2, c20940_3, c20940_4, state, setState2, c20940_7, callback, hideConsoleSelect2, memo, memo2, memo3, hasWatchVideoOnMobileTasks, isMobileActivityQuest;
|
|
const { quest, initialStep: initialStep2 } = a0;
|
|
a0.location;
|
|
const sourceQuestContent = a0.sourceQuestContent;
|
|
const trackQuestContentClickedWithImpression = useTrackQuestContentClickedWithImpression();
|
|
const questImpressionId = useQuestImpressionId();
|
|
const questTaskDetails = useQuestTaskDetails(quest);
|
|
const isQuestProgressing = useIsQuestProgressing(quest);
|
|
let [r14, , c20939_4] = useTaskPlatformScreen(quest, questTaskDetails);
|
|
const hasWatchVideoOnMobileTasks3 = useHasWatchVideoOnMobileTasks(quest.config);
|
|
const quest2 = quest;
|
|
xboxAndPlaystationAccounts = void 0;
|
|
c20940_2 = void 0;
|
|
c20940_3 = void 0;
|
|
c20940_4 = void 0;
|
|
state = void 0;
|
|
setState2 = void 0;
|
|
c20940_7 = void 0;
|
|
callback = void 0;
|
|
memo = void 0;
|
|
memo2 = void 0;
|
|
memo3 = void 0;
|
|
hasWatchVideoOnMobileTasks = void 0;
|
|
isMobileActivityQuest = void 0;
|
|
const showConsoleSelect2 = function showConsoleSelect() {
|
|
return setState2(true);
|
|
};
|
|
hideConsoleSelect2 = function hideConsoleSelect() {
|
|
return setState2(false);
|
|
};
|
|
const r57 = quest.userStatus?.completedAt != null;
|
|
xboxAndPlaystationAccounts = useConnectedAccounts().xboxAndPlaystationAccounts;
|
|
const memo4 = Module19.useMemo(() => supportedConsoles(quest2).filter((c31707_0) => xboxAndPlaystationAccounts.find((xboxAndPlaystationAccount) => xboxAndPlaystationAccount.type === c31707_0) != null), [quest, xboxAndPlaystationAccounts]);
|
|
const questTaskDetails2 = useQuestTaskDetails(quest);
|
|
let r20 = useIsQuestProgressing(quest);
|
|
const [r26, r25, r77] = useTaskPlatformScreen(quest, questTaskDetails2);
|
|
c20940_2 = r26;
|
|
c20940_3 = r25;
|
|
c20940_4 = r77;
|
|
[state, setState2] = Module19.useState(memo4.length === 0 && !r57 && r26 === TaskPlatformScreen.CONSOLE || initialStep2 === c9898_13.CONSOLE_CONNECT);
|
|
if (!r20) {
|
|
r20 = questTaskDetails2.progressSeconds > 0;
|
|
}
|
|
c20940_7 = r20;
|
|
if (!(memo4.length !== 0 || r57 || r26 !== TaskPlatformScreen.CONSOLE || state)) {
|
|
setState2(true);
|
|
}
|
|
callback = Module19.useCallback(() => {
|
|
setState2(false);
|
|
c20940_4(null);
|
|
}, [r77]);
|
|
memo = Module19.useMemo(() => [{
|
|
type: c9898_13.TASK_STATUS,
|
|
shouldShow: true
|
|
}], []);
|
|
memo2 = Module19.useMemo(() => [{
|
|
type: c9898_13.CONSOLE_CONNECT,
|
|
shouldShow: state,
|
|
onNext: hideConsoleSelect2
|
|
}, {
|
|
type: c9898_13.TASK_STATUS,
|
|
shouldShow: true,
|
|
onBack: c20940_7 ? void 0 : showConsoleSelect2
|
|
}], [state, r20]);
|
|
memo3 = Module19.useMemo(() => {
|
|
const TASK_SELECT = c9898_13.TASK_SELECT;
|
|
const r15 = [{
|
|
type: TASK_SELECT,
|
|
shouldShow: c20940_2 === TaskPlatformScreen.SELECT
|
|
}, , ,];
|
|
const shouldShow = c20940_2 === TaskPlatformScreen.CONSOLE && state;
|
|
let r23 = callback;
|
|
r15[1] = {
|
|
type: c9898_13.CONSOLE_CONNECT,
|
|
shouldShow,
|
|
onBack: callback,
|
|
onNext: hideConsoleSelect2
|
|
};
|
|
let onBack = void 0;
|
|
if (!c20940_7) {
|
|
if (c20940_2 === TaskPlatformScreen.CONSOLE) {
|
|
r23 = showConsoleSelect2;
|
|
}
|
|
onBack = r23;
|
|
}
|
|
r15[2] = {
|
|
type: c9898_13.TASK_STATUS,
|
|
shouldShow: true,
|
|
onBack
|
|
};
|
|
return r15;
|
|
}, [r26, state, r20, callback]);
|
|
hasWatchVideoOnMobileTasks = useHasWatchVideoOnMobileTasks(quest.config);
|
|
isMobileActivityQuest = useMobileActivityQuest(quest).isMobileActivityQuest;
|
|
const memo5 = Module19.useMemo(() => {
|
|
let r16;
|
|
const r5 = c20940_3.length === 1 && c20940_3.includes(QuestTaskPlatform.DESKTOP);
|
|
const r12 = c20940_3.length === 1 && c20940_3.includes(QuestTaskPlatform.CONSOLE);
|
|
L10: {
|
|
r16 = memo3;
|
|
if (!r5 && (!hasWatchVideoOnMobileTasks && !isMobileActivityQuest)) {
|
|
if (!r12) {
|
|
break L10;
|
|
}
|
|
r16 = memo2;
|
|
} else {
|
|
r16 = memo;
|
|
}
|
|
}
|
|
let r21 = r16.find((item) => item.shouldShow);
|
|
const r23 = r16;
|
|
if (r21 == null) {
|
|
r21 = r23.at(-1);
|
|
}
|
|
return r21;
|
|
}, [r25, memo3, memo, memo2, hasWatchVideoOnMobileTasks, isMobileActivityQuest]);
|
|
const r130 = [memo5.type, ,];
|
|
const onBack = memo5?.onBack;
|
|
const onNext = memo5?.onNext;
|
|
r130[1] = {
|
|
onBack,
|
|
onNext
|
|
};
|
|
const [step, stepActions] = r130;
|
|
const quest3 = quest;
|
|
const questLogger = getQuestLogger({
|
|
quest,
|
|
location: QuestsExperimentLocations.QUEST_HOME_MOBILE
|
|
});
|
|
const [errorHints, setState3] = useState([]);
|
|
const [isActive, setState4] = useState(false);
|
|
return {
|
|
quest,
|
|
defibrillator: {
|
|
errorHints,
|
|
isActive,
|
|
start: Module19.useCallback(() => {
|
|
setState4(true);
|
|
manuallyStartConsoleQuest(quest3.id).then((result) => setState3(result.errorHints)).catch((error) => {
|
|
setState3([]);
|
|
questLogger.error("Failed to start console quest", error);
|
|
ToastActionCreators.open({
|
|
key: "START_DEFIBRILLATOR_ERROR",
|
|
content: intl.string(t.CKsXk3),
|
|
icon: Module9172
|
|
});
|
|
}).finally(() => setState4(false));
|
|
}, [quest, questLogger, setState4, setState3])
|
|
},
|
|
step,
|
|
stepActions,
|
|
showMicrophone: !(quest.userStatus?.completedAt != null) && !isQuestProgressing && r14 === TaskPlatformScreen.CONSOLE && !hasWatchVideoOnMobileTasks3,
|
|
handleTaskSelect: function handleTaskSelect(a0) {
|
|
const questContentCTA = a0 === QuestTaskPlatform.CONSOLE ? QuestContentCTA.SELECT_CONSOLE_PLATFORM : a0 === QuestTaskPlatform.DESKTOP ? QuestContentCTA.SELECT_DESKTOP_PLATFORM : QuestContentCTA.DESELECT_PLATFORM;
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_2_CLICKED_INTERNAL, "quest_bottom_sheet")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_INTERNAL,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: quest.id,
|
|
questContentCTA,
|
|
surfaceId: QuestContent.QUEST_BOTTOM_SHEET,
|
|
sourceQuestContent,
|
|
impressionId: questImpressionId
|
|
});
|
|
} else {
|
|
trackQuestContentClickedWithImpression({
|
|
questId: quest.id,
|
|
questContent: QuestContent.QUEST_BOTTOM_SHEET,
|
|
questContentCTA,
|
|
sourceQuestContent
|
|
});
|
|
}
|
|
c20939_4(a0);
|
|
}
|
|
};
|
|
};
|
|
QuestBottomSheetContent = function QuestBottomSheetContent(props) {
|
|
const { defibrillator, quest: quest4, handleTaskSelect: handleTaskSelect2 } = props;
|
|
let showMicrophone = props.showMicrophone;
|
|
if (showMicrophone === void 0) {
|
|
showMicrophone = false;
|
|
}
|
|
const { sourceQuestContent: sourceQuestContent2, step } = props;
|
|
const hasWatchVideoOnMobileTasks2 = useHasWatchVideoOnMobileTasks(quest4.config);
|
|
const memo4 = Module19.useMemo(() => hasWatchVideoOnMobileTasks2 ? <QuestBottomSheetProgressCardWatchTask quest={quest4} sourceQuestContent={sourceQuestContent2} /> : _QuestTaskUtils.isInGameQuest(quest4) ? <QuestBottomSheetProgressCardInGameTask quest={quest4} sourceQuestContent={sourceQuestContent2} /> : <QuestBottomSheetProgressCardPlayStreamTask quest={quest4} sourceQuestContent={sourceQuestContent2} />, [quest4, hasWatchVideoOnMobileTasks2, sourceQuestContent2]);
|
|
const r33 = [step === c9898_13.TASK_SELECT && <QuestBottomSheetTaskSelect onTaskSelect={handleTaskSelect2} />, step === c9898_13.CONSOLE_CONNECT && <QuestBottomSheetConsoleConnect quest={quest4} step={step} sourceQuestContent={sourceQuestContent2} />, ,];
|
|
let r42 = step === c9898_13.TASK_STATUS;
|
|
if (r42) {
|
|
const r44 = [memo4, ,];
|
|
if (showMicrophone) {
|
|
showMicrophone = !hasWatchVideoOnMobileTasks2;
|
|
}
|
|
if (showMicrophone) {
|
|
showMicrophone = <MicrophoneUnit quest={quest4} errorHints={defibrillator?.errorHints} />;
|
|
}
|
|
r44[1] = showMicrophone;
|
|
r42 = <View>{r44}</View>;
|
|
}
|
|
r33[2] = r42;
|
|
return <>{r33}</>;
|
|
};
|
|
MicrophoneUnit = function MicrophoneUnit(props) {
|
|
const { quest: quest5, errorHints } = props;
|
|
const styles = useStyles();
|
|
const message = useQuestHowToHelpArticle().message;
|
|
let r27 = errorHints?.length;
|
|
if (r27 == null) {
|
|
r27 = 0;
|
|
}
|
|
const r28 = r27 > 0;
|
|
const r47 = r28 && errorHints != null ? [...errorHints.map((errorHint) => errorHint.message), message] : [isSponsoredPlayQuest(quest5) ? intl.string(t.bUyEZZ) : intl.formatToPlainString(t.GXqvC1, {
|
|
gameTitle: quest5.config.messages.gameTitle
|
|
})];
|
|
return <View style={styles.microphoneUnit}>
|
|
<View style={styles.microphoneUnitHeader}>
|
|
<WarningIcon color={r28 ? "text-feedback-critical" : "text-feedback-warning"} />
|
|
<Text variant="text-md/medium" color="mobile-text-heading-primary">
|
|
{r28 ? intl.formatToPlainString(t["28Ql27"], {
|
|
gameTitle: quest5.config.messages.gameTitle
|
|
}) : intl.string(t.YstzGO)}
|
|
</Text>
|
|
</View>
|
|
{r47.map((item, index) => <Text key={index} variant="text-sm/normal">
|
|
{item}
|
|
</Text>)}
|
|
</View>;
|
|
};
|
|
c9898_13 = {
|
|
TASK_SELECT: "TASK_SELECT",
|
|
CONSOLE_CONNECT: "CONSOLE_CONNECT",
|
|
TASK_STATUS: "TASK_STATUS"
|
|
};
|
|
useStyles = createStyles({
|
|
contentContainer: {
|
|
display: "flex",
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
gap: Module712.space.PX_24
|
|
},
|
|
microphoneUnit: {
|
|
display: "flex",
|
|
gap: Module712.space.PX_8,
|
|
marginHorizontal: -Module712.space.PX_16,
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
marginTop: Module712.space.PX_16,
|
|
paddingTop: Module712.space.PX_16,
|
|
borderTopWidth: 1,
|
|
borderTopColor: Module712.colors.BORDER_SUBTLE
|
|
},
|
|
microphoneUnitHeader: {
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_8
|
|
}
|
|
});
|
|
context = Module19.createContext({
|
|
isInQuestBottomSheet: false
|
|
});
|
|
export default function QuestBottomSheetConnected(props) {
|
|
const { questId, initialStep, sourceQuestContent: sourceQuestContent3, questContentPosition } = props;
|
|
const stateFromStores = useStateFromStores([QuestStore], () => QuestStore.getQuest(questId));
|
|
return stateFromStores != null ? <QuestContentImpressionTrackerNative overrideVisibility questOrQuests={stateFromStores} questContent={QuestContent.QUEST_BOTTOM_SHEET} questContentPosition={questContentPosition} sourceQuestContent={sourceQuestContent3}>
|
|
{() => <QuestBottomSheet quest={stateFromStores} initialStep={initialStep} sourceQuestContent={sourceQuestContent3} />}
|
|
</QuestContentImpressionTrackerNative> : null;
|
|
};
|
|
export { c9898_13 as QuestBottomSheetStep };
|
|
export { useEnrolledQuestContentProps };
|
|
export { QuestBottomSheetContent };
|
|
export { context as QuestBottomSheetContext };
|