// Metro module 14045 (f14046). import { memo, useRef, useState, useCallback, useImperativeHandle, useEffect, useLayoutEffect } from "react"; import { ActivityIndicator, Pressable, View, StyleSheet } from "react-native"; import AppStateStore from "../../../stores/native/AppStateStore"; import { AppStates, ComponentActions } from "../../../Constants"; import Module712 from "../../../_bundle/Module712"; import Video from "../../../_bundle/Video_8143"; import { createStyles } from "../../../design/components/Styles/native/createStyles"; import Module689 from "../../../_bundle/Module689"; import ReanimatedRexport, { useSharedValue, useAnimatedStyle } from "../../reanimated/ReanimatedRexport"; import * as _spring from "../../../design/animation/reanimated/spring/spring"; import * as _springPresets from "../../../design/animation/reanimated/spring/springPresets"; import * as _timing from "../../../design/animation/reanimated/timing/timing"; import * as _timingPresets from "../../../design/animation/reanimated/timing/timingPresets"; import { ComponentDispatch } from "../../../utils/ComponentDispatchUtils"; import { useStateFromStores } from "../../../_bundle/Module589"; import { isAndroid, isIOS } from "../../../utils/PlatformUtils"; import SentryUtils_native from "../../../utils/SentryUtils.native"; import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native"; import { intl, t } from "../../../intl/index.native"; import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables"; import { ClosedCaptionsOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/ClosedCaptionsOutlineIcon"; import { TranscriptOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/TranscriptOutlineIcon"; import { VideoQuestPlayerControlButton } from "./VideoQuestModal/VideoQuestPlayerControlButton"; import { SkipBackwardIcon } from "./VideoQuestModal/icons/SkipBackwardIcon"; import { RetryIcon } from "../../../design/components/Icon/native/redesign/generated/RetryIcon"; import { PlayIcon } from "../../../design/components/Icon/native/redesign/generated/PlayIcon"; import { PauseIcon } from "../../../design/components/Icon/native/redesign/generated/PauseIcon"; import { SkipForwardIcon } from "./VideoQuestModal/icons/SkipForwardIcon"; import { FullscreenEnterIcon } from "../../../design/components/Icon/native/redesign/generated/FullscreenEnterIcon"; let hasVideoEnded, canSeekForward, useStyles, PlayerState, c9821_19, __initData, __initData2, __initData3; let c9821_13 = { left: Module712.space.PX_16, right: Module712.space.PX_16, top: Module712.space.PX_16, bottom: Module712.space.PX_16 }; let Component = memo(Video); const hasVideoEnded2 = function hasVideoEnded(a0, a1) { return a0 >= a1 - 1; }; hasVideoEnded2.__closure = {}; hasVideoEnded2.__workletHash = 8992945176371; hasVideoEnded2.__initData = { code: "function hasVideoEnded_AdVideoPlayerTsx1(currentTime,videoDuration){return currentTime>=videoDuration-1;}" }; hasVideoEnded = hasVideoEnded2; const canSeekForward2 = function canSeekForward(a0, a1, a2, a3) { const r2 = a0 >= a2 - 1; return r2 ? !r2 : a3 ? a3 : a0 <= a1 - 1; }; canSeekForward2.__closure = { hasVideoEnded }; canSeekForward2.__workletHash = 14098132092693; canSeekForward2.__initData = { code: "function canSeekForward_AdVideoPlayerTsx2(currentTime,maxTimestamp,videoDuration,allowUnrestrictedSeeking){const{hasVideoEnded}=this.__closure;return!hasVideoEnded(currentTime,videoDuration)&&(allowUnrestrictedSeeking||currentTime<=maxTimestamp-1);}" }; canSeekForward = canSeekForward2; useStyles = createStyles({ container: { ...StyleSheet.absoluteFillObject }, loadingContainer: { ...StyleSheet.absoluteFillObject, backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST, justifyContent: "center", alignItems: "center" }, bufferingSpinner: { position: "absolute" }, bufferingSpinnerCentered: { ...StyleSheet.absoluteFillObject, justifyContent: "center", alignItems: "center" }, video: { height: "100%", width: "100%" }, videoContainer: { position: "relative", height: "100%", width: "100%" }, controls: { ...StyleSheet.absoluteFillObject, backgroundColor: Module689(Module712.unsafe_rawColors.BLACK).alpha(0.5).hex(), justifyContent: "center", alignItems: "center", flexDirection: "column" }, controlsTopBottom: { flexDirection: "row", justifyContent: "flex-end", padding: Module712.space.PX_8, position: "absolute", left: 0, right: 0 }, controlsMiddle: { justifyContent: "center", alignItems: "center", flexGrow: 1, flexDirection: "row", gap: Module712.space.PX_24, pointerEvents: "box-none" }, controlsTop: { top: 0 }, controlsBottom: { bottom: 0 }, progressContainer: { position: "absolute", bottom: 0, right: 0, left: 0, justifyContent: "flex-end", height: Module712.space.PX_16, overflow: "hidden" }, progress: { height: 1, backgroundColor: Module712.colors.WHITE, shadowOffset: { width: 0, height: 0 }, shadowRadius: 6, shadowOpacity: 1, elevation: 5, shadowColor: Module712.colors.WHITE }, icon: { color: Module712.colors.TEXT_DEFAULT }, iconDisabled: { color: Module712.colors.TEXT_SUBTLE }, controlButton: { padding: Module712.space.PX_8 } }); PlayerState = { PAUSED: "paused", PLAYING: "playing", ENDED: "ended", LOADING: "loading", ERRORED: "errored" }; c9821_19 = { USER_INTERACTION: "USER_INTERACTION", SYSTEM_INITIATED: "SYSTEM_INITIATED", IMPERATIVE_API: "IMPERATIVE_API" }; __initData = { code: "function shouldShowControls_AdVideoPlayerTsx3(){const{hasLoaded,hideControls,showControls,playerState,PlayerState,isVideoEnded}=this.__closure;return hasLoaded&&!hideControls&&(showControls.get()||playerState===PlayerState.PAUSED||playerState===PlayerState.ENDED||playerState===PlayerState.ERRORED||isVideoEnded);}" }; __initData2 = { code: "function AdVideoPlayerTsx4(){const{shouldShowControls,withSpring,SUBTLE_SPRING}=this.__closure;const show=shouldShowControls();return{opacity:withSpring(show?1:0,SUBTLE_SPRING),pointerEvents:show?'auto':'none'};}" }; __initData3 = { code: "function AdVideoPlayerTsx5(){const{withTiming,progressSharedValue,timingFast}=this.__closure;return{width:withTiming(progressSharedValue.get()*100+\"%\",timingFast,'animate-always')};}" }; const r162 = memo(function(a0) { let r351, R3aFPe, children3; let c20872_28, sharedValue, shouldShowControls2, sharedValue2, ref5, callback2, setState5, callback3, callback4, ref6, callback5, callback6, c20872_40, callback7; const { source, initialProgress, contentDuration = 0 } = a0; let allowUnrestrictedSeeking = a0.allowUnrestrictedSeeking; if (allowUnrestrictedSeeking === void 0) { allowUnrestrictedSeeking = false; } let c20872_1 = allowUnrestrictedSeeking; let disableResumeOnLoad = a0.disableResumeOnLoad; if (disableResumeOnLoad === void 0) { disableResumeOnLoad = false; } let c20872_2 = disableResumeOnLoad; const { style, isFullscreen, externallyPaused, contentInsets, captionsEnabled = false, onToggleCaptions, onOpenTranscript, onToggleFullscreen, renderCaptions, onLoadStart, onLoad, onReadyForDisplay, onProgress, onSeek, onBuffer: onBuffer2, onError, onEnd, onPlayerStateChange, onPausePlayback, onResumePlayback, onVideoTracks, onVideoLayout } = a0; let videoRef = a0.videoRef; let bufferingSpinnerPlacement = a0.bufferingSpinnerPlacement; if (bufferingSpinnerPlacement === void 0) { bufferingSpinnerPlacement = "top-left"; } let showCaptionsButton = a0.showCaptionsButton; if (showCaptionsButton === void 0) { showCaptionsButton = false; } let showTranscriptButton = a0.showTranscriptButton; if (showTranscriptButton === void 0) { showTranscriptButton = false; } let showFullscreenButton = a0.showFullscreenButton; if (showFullscreenButton === void 0) { showFullscreenButton = false; } let showProgress = a0.showProgress; if (showProgress === void 0) { showProgress = false; } let showSkipButtons = a0.showSkipButtons; if (showSkipButtons === void 0) { showSkipButtons = true; } let hideControls = a0.hideControls; if (hideControls === void 0) { hideControls = false; } let c20872_13 = hideControls; const { httpEngine, automaticallyWaitsToMinimizeStalling, maxBitRate, bufferConfig, preferredForwardBufferDuration, repeat = false } = a0; let c20872_14 = repeat; const ref8 = a0.ref; c20872_28 = void 0; sharedValue = void 0; shouldShowControls2 = void 0; sharedValue2 = void 0; ref5 = void 0; callback2 = void 0; setState5 = void 0; callback3 = void 0; callback4 = void 0; ref6 = void 0; callback5 = void 0; callback6 = void 0; c20872_40 = void 0; callback7 = void 0; const styles = useStyles(); const ref9 = useRef(null); if (videoRef == null) { videoRef = ref9; } const ref = videoRef; const [state, setState] = useState(contentDuration); const [state2, setState2] = useState({ ...initialProgress }); const [state3, setState3] = useState(PlayerState.LOADING); let [state5, setState4] = useState(false); const state4 = state5; const ref2 = useRef(null); const ref3 = useRef(0); const ref4 = useRef([]); const callback = useCallback((a0) => { setState3(a0); if (onPlayerStateChange != null) { onPlayerStateChange(a0); } }, [onPlayerStateChange]); const isVideoEnded = (state4 ? state3 === PlayerState.ENDED : state4) && state2.timestampSec >= state2.duration - 1; c20872_28 = isVideoEnded; sharedValue = useSharedValue(false); const shouldShowControls = function shouldShowControls() { let r1 = state4; if (state4) { r1 = !c20872_13; } if (r1) { r1 = sharedValue.get() || state3 === PlayerState.PAUSED || state3 === PlayerState.ENDED || state3 === PlayerState.ERRORED || c20872_28; } return r1; }; shouldShowControls.__closure = { hasLoaded: state4, hideControls, showControls: sharedValue, playerState: state3, PlayerState, isVideoEnded }; shouldShowControls.__workletHash = 8094403036162; shouldShowControls.__initData = __initData; shouldShowControls2 = shouldShowControls; const Se = function Se() { let r5 = state4; if (state4) { r5 = !c20872_13; } if (r5) { r5 = sharedValue.get() || state3 === PlayerState.PAUSED || state3 === PlayerState.ENDED || state3 === PlayerState.ERRORED || c20872_28; } return { opacity: _spring.withSpring(r5 ? 1 : 0, _springPresets.SUBTLE_SPRING), pointerEvents: r5 ? "auto" : "none" }; }; Se.__closure = { shouldShowControls: shouldShowControls2, withSpring: _spring.withSpring, SUBTLE_SPRING: _springPresets.SUBTLE_SPRING }; Se.__workletHash = 311315682972; Se.__initData = __initData2; const animatedStyle = useAnimatedStyle(Se); if (state4) { state5 = !hideControls; } if (state5) { state5 = sharedValue.get() || state3 === PlayerState.PAUSED || state3 === PlayerState.ENDED || state3 === PlayerState.ERRORED || isVideoEnded; } sharedValue2 = useSharedValue(0); const pe = () => ({ width: _timing.withTiming(100 * sharedValue2.get() + "%", _timingPresets.timingFast, "animate-always") }); pe.__closure = { withTiming: _timing.withTiming, progressSharedValue: sharedValue2, timingFast: _timingPresets.timingFast }; pe.__workletHash = 11793601648786; pe.__initData = __initData3; const animatedStyle2 = useAnimatedStyle(pe); ref5 = useRef(-1); const callback8 = useCallback((c27618_0) => function(...args) { clearTimeout(ref5.current); sharedValue.set(true); ref5.current = setTimeout(() => { sharedValue.set(false); }, 2000); if (c27618_0 != null) { return c27618_0.apply(void 0, [...args]); } }, [sharedValue]); callback2 = useCallback((timestampSec, duration) => { setState2((prevState2) => ({ timestampSec, maxTimestampSec: Math.max(prevState2.maxTimestampSec, Math.floor(timestampSec)), duration })); }, []); let state6; [state6, setState5] = useState(false); const callback9 = useCallback(() => { if (onReadyForDisplay != null) { onReadyForDisplay(); } setState5(true); }, [onReadyForDisplay]); callback3 = useCallback((a0) => { if (ref.current != null) { const current2 = Math.max(0, Math.min(a0, c20872_1 ? state2.duration : state2.maxTimestampSec)); ref3.current = (ref3.current + 1) % 100; ref.current.seek(current2 + 0.0001 * ref3.current); ref2.current = current2; } }, [allowUnrestrictedSeeking, state2.duration, state2.maxTimestampSec, ref]); useImperativeHandle(ref8, () => ({ seekToStart: () => { if (state3 !== PlayerState.ERRORED) { callback3(0); if (state3 === PlayerState.ENDED) { callback(PlayerState.PLAYING); if (onResumePlayback != null) { onResumePlayback(c9821_19.IMPERATIVE_API); } } } }, play: () => { if (state3 === PlayerState.PAUSED) { callback(PlayerState.PLAYING); if (onResumePlayback != null) { onResumePlayback(c9821_19.IMPERATIVE_API); } } }, pause: () => { if (state3 === PlayerState.PLAYING) { callback(PlayerState.PAUSED); if (onPausePlayback != null) { onPausePlayback(c9821_19.IMPERATIVE_API); } } } }), [callback3, state3, callback, onResumePlayback, onPausePlayback]); const callback10 = useCallback((a0) => { const duration2 = a0.duration; setState(duration2); setState4(true); if (ref.current != null) { const timestampSec2 = initialProgress.timestampSec; if ((c20872_2 ? !c20872_2 : timestampSec2 > 5) && timestampSec2 < duration2 - 3) { callback3(timestampSec2 - 1); } callback(PlayerState.PLAYING); if (onLoad != null) { onLoad(a0); } } }, [ref, initialProgress.timestampSec, disableResumeOnLoad, callback, onLoad, callback3]); callback4 = useCallback(function(r3 = {}) { let shouldRestartVideo = r3.shouldRestartVideo; if (shouldRestartVideo === void 0) { shouldRestartVideo = true; } L16: { L14: { if (state3 !== PlayerState.ERRORED) { if (c20872_28 && shouldRestartVideo) { break L14; } if (state3 !== PlayerState.PAUSED && state3 !== PlayerState.LOADING) { if (state3 !== PlayerState.PLAYING) { break L16; } callback(PlayerState.PAUSED); if (onPausePlayback == null) { break L16; } onPausePlayback(c9821_19.USER_INTERACTION); break L16; } callback(PlayerState.PLAYING); if (onResumePlayback == null) { break L16; } onResumePlayback(c9821_19.USER_INTERACTION); break L16; } } callback3(0); callback(PlayerState.PLAYING); if (onResumePlayback != null) { onResumePlayback(c9821_19.USER_INTERACTION); } } }, [state3, onPausePlayback, onResumePlayback, isVideoEnded, callback, callback3]); const callback11 = useCallback(() => callback4(), [callback4]); ref6 = useRef(false); callback5 = useCallback(() => { ref6.current = false; if (state3 === PlayerState.PLAYING) { ref6.current = true; callback(PlayerState.PAUSED); if (onPausePlayback != null) { onPausePlayback(c9821_19.SYSTEM_INITIATED); } } }, [state3, callback, onPausePlayback]); callback6 = useCallback(() => { if (ref6.current) { ref6.current = false; if (state3 !== PlayerState.ERRORED) { callback(PlayerState.PLAYING); if (onResumePlayback != null) { onResumePlayback(c9821_19.SYSTEM_INITIATED); } } } }, [state3, callback, onResumePlayback]); useEffect(() => { ComponentDispatch.subscribe(ComponentActions.QUEST_GAME_LINK_OPENED, callback5); ComponentDispatch.subscribe(ComponentActions.QUEST_APP_STORE_OVERLAY_FINISHED, callback6); return () => { ComponentDispatch.unsubscribe(ComponentActions.QUEST_GAME_LINK_OPENED, callback5); ComponentDispatch.unsubscribe(ComponentActions.QUEST_APP_STORE_OVERLAY_FINISHED, callback6); }; }, [callback5, callback6]); const callback12 = useCallback(() => { if (sharedValue.get()) { sharedValue.set(false); } callback4({ shouldRestartVideo: false }); }, [sharedValue, callback4]); const callback13 = useCallback((a0) => { let fromTimeSec = ref4.current.shift(); if (fromTimeSec == null) { fromTimeSec = null; } if (ref.current != null) { ref2.current = null; if (state > 0) { sharedValue2.set(a0.currentTime / state); callback2(a0.currentTime, state); } if (onSeek != null) { onSeek({ ...a0, fromTimeSec }); } } }, [state, sharedValue2, onSeek, callback2, ref]); let disabled = state3 === PlayerState.ERRORED; if (!disabled) { const { timestampSec: timestampSec2, maxTimestampSec } = state2; const r8 = timestampSec2 >= state2.duration - 1; let r229 = !r8; if (!r8) { if (!allowUnrestrictedSeeking) { allowUnrestrictedSeeking = timestampSec2 <= maxTimestampSec - 1; } r229 = allowUnrestrictedSeeking; } disabled = !r229; } c20872_40 = disabled; const callback14 = useCallback(() => { if (!c20872_40) { let current2 = ref2.current; if (current2 == null) { current2 = sharedValue2.get() * state; } ref4.current.push(current2); callback3(current2 + 10); } }, [callback3, state, sharedValue2, disabled]); const onPress = callback8(useCallback(() => { let current2 = ref2.current; if (current2 == null) { current2 = sharedValue2.get() * state; } ref4.current.push(current2); callback3(current2 - 10); if (state3 === PlayerState.ENDED) { callback(PlayerState.PLAYING); } }, [callback3, state, sharedValue2, state3, callback])); const onPress2 = callback8(callback14); const callback15 = useCallback((a0) => { const r2 = a0.seekableDuration !== 0 ? a0.currentTime / a0.seekableDuration : 0; callback2(a0.currentTime, a0.seekableDuration); sharedValue2.set(r2); const progress = r2; if (onProgress != null) { onProgress({ currentTime: a0.currentTime, seekableDuration: a0.seekableDuration, progress }); } }, [sharedValue2, callback2, onProgress]); const callback16 = useCallback(() => { if (!c20872_14) { callback(PlayerState.ENDED); } if (onEnd != null) { onEnd(); } }, [callback, onEnd, repeat]); const callback17 = useCallback(() => { callback(PlayerState.LOADING); if (onLoadStart != null) { onLoadStart(); } }, [callback, onLoadStart]); const callback18 = useCallback((a0) => { callback(PlayerState.ERRORED); if (onError != null) { onError(a0); } }, [callback, onError]); const r266 = useStateFromStores([AppStateStore], () => AppStateStore.getState()) === AppStates.ACTIVE; useLayoutEffect(() => { if (isAndroid()) { const current = ref.current; return () => { try { if (current != null) { const setNativeProps = current.setNativeProps; if (setNativeProps != null) { setNativeProps.call(current, { paused: true, repeat: false, src: { uri: null } }); } } } catch ($e) { SentryUtils_native.captureException($e); } }; } }, [ref]); const paused = (r266 ? state3 === PlayerState.PAUSED : !r266) || state3 === PlayerState.LOADING || externallyPaused; const onBuffer = onBuffer2; const ref7 = useRef(false); let [state7, setState6] = useState(false); callback7 = useCallback((a0) => { setState6(a0); if (a0 !== ref7.current) { ref7.current = a0; if (onBuffer != null) { onBuffer(a0); } } }, [onBuffer]); const callback19 = useCallback((a0) => { let isBuffering; L6: { L4: { isBuffering = a0.isBuffering; if (isBuffering) { if (state3 !== PlayerState.LOADING && isIOS()) { break L4; } callback7(true); break L6; } } if (!isBuffering) { callback7(false); } } }, [callback7, state3]); const callback20 = useCallback(() => { if (isIOS()) { callback7(true); } }, [callback7]); const callback21 = useCallback(() => { if (isIOS()) { callback7(false); } }, [callback7]); const safeAreaInsets_native = useSafeAreaInsets_native(); const r302 = isFullscreen && safeAreaInsets_native != null && { paddingRight: Math.max(safeAreaInsets_native.right, c9821_13.right), paddingLeft: Math.max(safeAreaInsets_native.left, c9821_13.left) }; const props = { style: [styles.container, style], accessible: false, children: null }; const props2 = { style: [styles.videoContainer], onPress: callback12, accessible: !state5, accessibilityLabel: intl.string(paused ? t.R3aFPe : t.fTMEUi), children: null }; const children = [state3 !== PlayerState.ERRORED && , renderCaptions == null ? void 0 : renderCaptions(state2.timestampSec), , , , ,]; if (state7) { const style2 = [styles.bufferingSpinner, ,]; if (!isFullscreen && bufferingSpinnerPlacement !== "center") { let top = contentInsets?.top; if (top == null) { top = 0; } let left = contentInsets?.left; if (left == null) { left = 0; } r351 = { top, left }; } else { r351 = styles.bufferingSpinnerCentered; } style2[1] = r351; state7 = ; } children[2] = state7; children[3] = state6 ? !state6 : ; const props3 = { style: [styles.controls, animatedStyle], accessible: false, children: null }; let r371 = showCaptionsButton ? showCaptionsButton : showTranscriptButton; if (r371) { if (showCaptionsButton) { showCaptionsButton = ; } const r398 = [showCaptionsButton, ,]; if (showTranscriptButton) { showTranscriptButton = ; } r398[1] = showTranscriptButton; r371 = {r398}; } const children2 = [r371, , ,]; const props4 = { style: styles.controlsMiddle, children: null }; const r423 = showSkipButtons ? : showSkipButtons; L107: { children3 = [r423, , ,]; if (!isVideoEnded && state3 !== PlayerState.ERRORED) { if (paused) { R3aFPe = t.R3aFPe; break L107; } R3aFPe = t.fTMEUi; } else { R3aFPe = t.K0e7M9; } } children3[1] = {!isVideoEnded && state3 !== PlayerState.ERRORED ? paused ? : : } ; if (showSkipButtons) { showSkipButtons = ; } children3[2] = showSkipButtons; props4.children = children3; children2[1] = ; if (showFullscreenButton) { showFullscreenButton = ; } children2[2] = showFullscreenButton; props3.children = children2; children[4] = ; if (showProgress) { showProgress = ; } children[5] = showProgress; props2.children = children; props.children = ; return ; }); exports.PlayerState = PlayerState; export { c9821_19 as PlaybackTriggerSource }; export { r162 as AdVideoPlayer };