markdown-flow-ui 0.1.108-beta.2 → 0.1.108-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.cjs4.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.cjs7.js +1 -1
- package/dist/_virtual/index.es4.js +4 -4
- package/dist/_virtual/index.es5.js +4 -4
- package/dist/_virtual/index.es6.js +2 -5
- package/dist/_virtual/index.es6.js.map +1 -1
- package/dist/_virtual/index.es7.js +5 -2
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/components/Slide/Player.cjs.js +1 -1
- package/dist/components/Slide/Player.cjs.js.map +1 -1
- package/dist/components/Slide/Player.d.ts +2 -1
- package/dist/components/Slide/Player.es.js +160 -154
- package/dist/components/Slide/Player.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js +390 -377
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/SubtitleOverlay.cjs.js +1 -1
- package/dist/components/Slide/SubtitleOverlay.cjs.js.map +1 -1
- package/dist/components/Slide/SubtitleOverlay.d.ts +2 -1
- package/dist/components/Slide/SubtitleOverlay.es.js +33 -32
- package/dist/components/Slide/SubtitleOverlay.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slide.cjs.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport ContentRender from \"../ContentRender\";\nimport type { ContentRenderProps } from \"../ContentRender/ContentRender\";\nimport IframeSandbox from \"../ContentRender/IframeSandbox\";\nimport type { OnSendContentParams } from \"../types\";\nimport {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type { PlayerProps, SlidePlayerTexts } from \"./Player\";\nimport { DEFAULT_SLIDE_PLAYER_TEXTS } from \"./constants\";\nimport SlideFullscreenHint from \"./SlideFullscreenHint\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { shouldPresentInteractionOverlay } from \"./utils/interactionPlayback\";\nimport { getPlaybackSequenceTransition } from \"./utils/playbackSequence\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\n\nconst DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS = 2000;\nconst DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS = 300;\nconst DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX = 160;\nconst DEFAULT_INTERACTION_SUBTITLE_GAP_PX = 16;\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nexport type SlideFullscreenHeader = {\n content?: React.ReactNode;\n backAriaLabel?: string;\n onBack?: () => void;\n};\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\n sandboxMode=\"content\"\n />\n </div>\n <div className=\"slide-player__interaction-arrow\" />\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: string;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerTexts?: SlidePlayerTexts;\n playerAutoHideDelay?: number;\n markerAutoAdvanceDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n enableIframeScaling?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText = \"Buffering...\",\n interactionTitle,\n interactionTexts,\n playerTexts,\n playerAutoHideDelay = 3000,\n markerAutoAdvanceDelay = DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onMobileViewModeChange,\n onStepChange,\n enableIframeScaling = true,\n className,\n onPointerDown,\n ...props\n}) => {\n const sectionRef = useRef<HTMLElement | null>(null);\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const interactionOverlayOpenTimerRef = useRef<number | null>(null);\n const interactionOverlayRef = useRef<HTMLDivElement | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const playbackResetKeyRef = useRef<string | null>(null);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n } = useSlide(elementList);\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\n const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldRenderPlayer =\n showPlayer &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const currentAudioSequenceKeys = useMemo(\n () =>\n currentAudioSequenceIndexes\n .map((audioIndex) => audioList[audioIndex]?.audioKey)\n .filter((audioKey): audioKey is string => Boolean(audioKey)),\n [audioList, currentAudioSequenceIndexes]\n );\n const [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n const [isPlayerCustomActionActive, setIsPlayerCustomActionActive] =\n useState(false);\n const [activeInteractionElement, setActiveInteractionElement] = useState<\n Element | undefined\n >();\n const [isInteractionOverlayOpen, setIsInteractionOverlayOpen] =\n useState(false);\n const [\n interactionOverlaySubtitleOffset,\n setInteractionOverlaySubtitleOffset,\n ] = useState(0);\n const [isBrowserFullscreen, setIsBrowserFullscreen] = useState(false);\n const isMobileDevice = useMemo(() => getIsMobileDevice(), []);\n const [mobileViewMode, setMobileViewMode] = useState<MobileViewMode>(\n DEFAULT_MOBILE_VIEW_MODE\n );\n const [hasManualMobileViewMode, setHasManualMobileViewMode] = useState(false);\n const [isViewportFullscreenPreferred, setIsViewportFullscreenPreferred] =\n useState(() =>\n isMobileDevice ? getIsFullscreenPreferredViewport() : false\n );\n const [isFullscreenHintOpen, setIsFullscreenHintOpen] = useState(false);\n const playbackTimeStore = useMemo(() => createPlaybackTimeStore(), []);\n const {\n effectiveMobileViewMode,\n isImmersiveMobileFullscreen,\n isNativeMobileFullscreen,\n shouldRotateFullscreenViewport,\n } = useMemo(\n () =>\n resolveMobileViewModeState({\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n }),\n [\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n ]\n );\n const previousEffectiveMobileViewModeRef = useRef(effectiveMobileViewMode);\n const playerVisible =\n shouldRenderPlayer && (playerAlwaysVisible || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const fullscreenHintText =\n playerTexts?.fullscreenHintText ??\n DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText;\n const handleMobileViewModeSelect = useCallback(\n (nextViewMode: MobileViewMode) => {\n setHasManualMobileViewMode(true);\n setMobileViewMode(nextViewMode);\n },\n []\n );\n const handleMobileViewModeReset = useCallback(() => {\n // Clear manual override so the effective mode returns to the default non-fullscreen state.\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, []);\n const handleFullscreenHeaderBack = useCallback(() => {\n handleMobileViewModeReset();\n fullscreenHeader?.onBack?.();\n }, [fullscreenHeader, handleMobileViewModeReset]);\n const handleFullscreenHintClose = useCallback(() => {\n setIsFullscreenHintOpen(false);\n }, []);\n const setPlayerCustomActionActive = useCallback((active: boolean) => {\n setIsPlayerCustomActionActive(active);\n }, []);\n const togglePlayerCustomActionActive = useCallback(() => {\n setIsPlayerCustomActionActive((previous) => !previous);\n }, []);\n const { mountedStepStates, currentMountedStateIndex } = useMemo(() => {\n const nextMountedStepStates: Array<{\n elementList: Element[];\n sourceStepIndexes: number[];\n }> = [];\n const mountedStateIndexByStep = new Map<number, number>();\n\n stepElementLists.forEach((stepElementList, stepIndex) => {\n const existingMountedStateIndex = nextMountedStepStates.findIndex(\n (mountedStepState) =>\n areStepElementListsEqual(\n mountedStepState.elementList,\n stepElementList\n )\n );\n\n if (existingMountedStateIndex >= 0) {\n nextMountedStepStates[\n existingMountedStateIndex\n ]?.sourceStepIndexes.push(stepIndex);\n mountedStateIndexByStep.set(stepIndex, existingMountedStateIndex);\n return;\n }\n\n nextMountedStepStates.push({\n elementList: stepElementList,\n sourceStepIndexes: [stepIndex],\n });\n mountedStateIndexByStep.set(stepIndex, nextMountedStepStates.length - 1);\n });\n\n return {\n mountedStepStates: nextMountedStepStates,\n currentMountedStateIndex:\n currentIndex >= 0\n ? (mountedStateIndexByStep.get(currentIndex) ?? -1)\n : -1,\n };\n }, [currentIndex, stepElementLists]);\n const currentStepKey = useMemo(() => String(currentIndex), [currentIndex]);\n const currentAudioIndex = useMemo(() => {\n if (!currentAudioKey) {\n return -1;\n }\n\n return audioList.findIndex(\n (audioItem) => (audioItem.audioKey ?? \"\") === currentAudioKey\n );\n }, [audioList, currentAudioKey]);\n const currentAudioItem = useMemo(\n () => (currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined),\n [audioList, currentAudioIndex]\n );\n const currentSubtitleCues = currentAudioItem?.element?.subtitle_cues ?? [];\n const currentAudioSequenceStartKey = useMemo(\n () => currentAudioSequenceKeys[0] ?? \"none\",\n [currentAudioSequenceKeys]\n );\n const playerCustomActionContext = useMemo(\n () => ({\n currentElement: resolvePlayerCustomActionElement({\n currentAudioIndex,\n currentAudioSequenceIndexes,\n audioList,\n currentInteractionElement: activeInteractionElement,\n currentStepElement,\n }),\n currentIndex,\n currentStepElement,\n isActive: isPlayerCustomActionActive,\n setActive: setPlayerCustomActionActive,\n toggleActive: togglePlayerCustomActionActive,\n }),\n [\n activeInteractionElement,\n audioList,\n currentAudioIndex,\n currentAudioSequenceIndexes,\n currentIndex,\n currentStepElement,\n isPlayerCustomActionActive,\n setPlayerCustomActionActive,\n togglePlayerCustomActionActive,\n ]\n );\n const playerCustomActionCount = useMemo(\n () =>\n getPlayerCustomActionCount(\n playerCustomActions,\n playerCustomActionContext\n ),\n [playerCustomActionContext, playerCustomActions]\n );\n const interactionOverlayStyle = useMemo(\n () =>\n ({\n \"--slide-player-custom-action-count\": String(playerCustomActionCount),\n \"--slide-player-mobile-control-count\": String(\n playerCustomActionCount + 4\n ),\n }) as React.CSSProperties,\n [playerCustomActionCount]\n );\n const hasAvailableStepAudio = currentAudioSequenceKeys.length > 0;\n const currentInteractionResetKey = useMemo(() => {\n if (!currentInteractionElement) {\n return \"none\";\n }\n\n return `${currentInteractionElement.sequence_number ?? \"none\"}:${String(\n currentInteractionElement.content ?? \"\"\n )}`;\n }, [currentInteractionElement]);\n const currentPlaybackResetKey = useMemo(\n () => [currentStepKey, currentInteractionResetKey].join(\"|\"),\n [currentInteractionResetKey, currentStepKey]\n );\n const currentStepAudioUrl = useMemo(() => {\n if (\n !currentAudioSequenceStartKey ||\n currentAudioSequenceStartKey === \"none\"\n ) {\n return \"\";\n }\n\n const currentStepAudioItem = audioList.find(\n (audioItem) => audioItem.audioKey === currentAudioSequenceStartKey\n );\n\n return currentStepAudioItem?.audioUrl?.trim() ?? \"\";\n }, [audioList, currentAudioSequenceStartKey]);\n const hasCurrentStepAudioUrl = Boolean(currentStepAudioUrl);\n const shouldPausePlaybackForCustomAction =\n playerCustomActionPauseOnActive &&\n Boolean(playerCustomActions) &&\n isPlayerCustomActionActive;\n const shouldUseSilentStepAutoAdvanceToggle = useMemo(\n () =>\n shouldUseAutoAdvanceToggle({\n canGoNext,\n currentAudioIndex,\n currentStepHasSpeakableElement,\n hasInteraction: Boolean(currentInteractionElement),\n }),\n [\n canGoNext,\n currentAudioIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n ]\n );\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const clearInteractionOverlayOpenTimer = useCallback(() => {\n if (interactionOverlayOpenTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionOverlayOpenTimerRef.current);\n interactionOverlayOpenTimerRef.current = null;\n }, []);\n\n const clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(() => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]);\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioKey = currentAudioSequenceKeys[0];\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioKey(nextAudioKey);\n return true;\n }, [currentAudioSequenceKeys]);\n\n const continueAfterInteraction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (canGoNext) {\n goNext();\n }\n }, [\n canGoNext,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n goNext,\n startCurrentAudioSequence,\n ]);\n\n const scheduleInteractionOverlayOpen = useCallback(\n (interactionElement?: Element) => {\n clearInteractionOverlayOpenTimer();\n\n if (!interactionElement) {\n return;\n }\n\n const openOverlay = () => {\n interactionOverlayOpenTimerRef.current = null;\n setInteractionOverlaySubtitleOffset(\n DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX\n );\n setIsInteractionOverlayOpen(true);\n pendingInteractionOverlayStepIndexRef.current = null;\n };\n\n interactionOverlayOpenTimerRef.current = window.setTimeout(\n openOverlay,\n DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS\n );\n },\n [clearInteractionOverlayOpenTimer]\n );\n\n const showPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldRenderPlayer) {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (playerAlwaysVisible || !enableAutoHide || playerAutoHideDelay <= 0) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n playerAutoHideDelay,\n shouldRenderPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n currentInteractionElement?.readonly ||\n currentInteractionElement?.user_input?.trim()\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n useEffect(() => {\n // Reset silent-step autoplay toggle whenever navigation lands on a new step.\n setIsAutoAdvanceEnabled(true);\n\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerVisible]);\n\n useEffect(() => {\n if (isMobileDevice || mobileViewMode === DEFAULT_MOBILE_VIEW_MODE) {\n return;\n }\n\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, [isMobileDevice, mobileViewMode]);\n\n useEffect(() => {\n if (!isMobileDevice) {\n setIsViewportFullscreenPreferred(false);\n return;\n }\n\n const syncViewportFullscreenPreference = () => {\n setIsViewportFullscreenPreferred(getIsFullscreenPreferredViewport());\n };\n\n syncViewportFullscreenPreference();\n\n return subscribeMobileDeviceChange(syncViewportFullscreenPreference);\n }, [isMobileDevice]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n const previousMode = previousEffectiveMobileViewModeRef.current;\n const hasEnteredFullscreen =\n previousMode !== \"fullscreen\" && effectiveMobileViewMode === \"fullscreen\";\n const shouldShowFullscreenHint =\n hasEnteredFullscreen && !isViewportFullscreenPreferred;\n\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n\n if (!isMobileDevice) {\n setIsFullscreenHintOpen(false);\n return;\n }\n\n if (shouldShowFullscreenHint) {\n setIsFullscreenHintOpen(true);\n return;\n }\n\n if (effectiveMobileViewMode !== \"fullscreen\") {\n setIsFullscreenHintOpen(false);\n }\n }, [effectiveMobileViewMode, isMobileDevice, isViewportFullscreenPreferred]);\n\n useEffect(() => {\n onStepChange?.(currentStepElement, currentIndex);\n }, [currentIndex, currentStepElement, onStepChange]);\n\n useEffect(() => {\n if (!shouldRenderPlayer) {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (playerAlwaysVisible) {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n showPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n shouldRenderPlayer,\n showPlayerControls,\n ]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const handleSandboxInteraction = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) {\n return;\n }\n\n if (!isSandboxInteractionMessage(event.data)) {\n return;\n }\n\n if (event.data.eventType !== \"click\") {\n return;\n }\n\n if (!shouldRenderPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [shouldRenderPlayer, showPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldRenderPlayer,\n onWake: () => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n },\n });\n\n useEffect(() => {\n const { hasPlaybackContextChanged, shouldInitializeAudioSequence } =\n getPlaybackSequenceTransition({\n previousResetKey: playbackResetKeyRef.current,\n nextResetKey: currentPlaybackResetKey,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n });\n\n playbackResetKeyRef.current = currentPlaybackResetKey;\n\n const shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n const shouldPresentOverlay = shouldPresentInteractionOverlay({\n hasInteraction: Boolean(currentInteractionElement),\n shouldBlockPlaybackForInteraction,\n shouldOpenInteractionOverlayAfterAudio,\n hasPlaybackContextChanged,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n });\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence();\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n }\n\n if (shouldPresentOverlay) {\n // Delay auto-presenting the overlay so subtitles can settle above it.\n scheduleInteractionOverlayOpen(currentInteractionElement);\n return;\n }\n\n clearInteractionOverlayOpenTimer();\n pendingInteractionOverlayStepIndexRef.current = null;\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, markerAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n scheduleInteractionOverlayOpen,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasAvailableStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n if (currentAudioKey || currentAudioSequenceKeys.length === 0) {\n return;\n }\n\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n return;\n }\n\n startCurrentAudioSequence();\n }, [\n currentAudioKey,\n currentAudioSequenceKeys,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n startCurrentAudioSequence,\n ]);\n\n useEffect(() => {\n if (!currentAudioKey || currentAudioIndex >= 0) {\n return;\n }\n\n setCurrentAudioKey(null);\n }, [currentAudioIndex, currentAudioKey]);\n\n useEffect(() => {\n if (currentAudioIndex >= 0) {\n return;\n }\n\n playbackTimeStore.reset();\n }, [currentAudioIndex, playbackTimeStore]);\n\n const interactionDefaults = useMemo(() => {\n if (!activeInteractionElement) {\n return {};\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const interactionDefaultSelectedValues = useMemo(() => {\n if (!activeInteractionElement) {\n return undefined;\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultSelectedValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement?.user_input?.trim()\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || hasResolvedInteractionInput;\n const shouldAutoContinueInteraction =\n isInteractionReadonly || hasResolvedInteractionInput;\n const shouldShowInteractionOverlay =\n Boolean(activeInteractionElement) && isInteractionOverlayOpen;\n\n const handleInteractionSend = useCallback(\n (content: OnSendContentParams) => {\n const submittedValues = [\n ...(content.selectedValues ?? []),\n content.inputText?.trim() ?? \"\",\n content.buttonText?.trim() ?? \"\",\n ].filter(Boolean);\n const resolvedUserInput = submittedValues.join(\", \");\n\n setActiveInteractionElement((prevElement) => {\n if (!prevElement || !resolvedUserInput) {\n return prevElement;\n }\n\n return {\n ...prevElement,\n user_input: resolvedUserInput,\n };\n });\n\n onSend?.(content, activeInteractionElement);\n continueAfterInteraction();\n },\n [activeInteractionElement, continueAfterInteraction, onSend]\n );\n\n useEffect(() => {\n // Keep the player icon in sync with the actual fullscreen owner.\n const syncFullscreenState = () => {\n setIsBrowserFullscreen(document.fullscreenElement === sectionRef.current);\n };\n\n syncFullscreenState();\n document.addEventListener(\"fullscreenchange\", syncFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", syncFullscreenState);\n };\n }, []);\n\n useEffect(() => {\n if (!shouldShowInteractionOverlay) {\n setInteractionOverlaySubtitleOffset(0);\n return;\n }\n\n const interactionOverlayElement = interactionOverlayRef.current;\n\n if (!interactionOverlayElement) {\n return;\n }\n\n const updateSubtitleOffset = () => {\n const overlayHeight = Math.ceil(\n interactionOverlayElement.getBoundingClientRect().height\n );\n\n setInteractionOverlaySubtitleOffset(\n overlayHeight + DEFAULT_INTERACTION_SUBTITLE_GAP_PX\n );\n };\n\n updateSubtitleOffset();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n updateSubtitleOffset();\n });\n\n resizeObserver.observe(interactionOverlayElement);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [shouldShowInteractionOverlay]);\n\n useEffect(() => {\n clearInteractionAutoCloseTimer();\n\n if (!isInteractionOverlayOpen || !shouldAutoContinueInteraction) {\n return;\n }\n\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, 2000);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n isInteractionOverlayOpen,\n shouldAutoContinueInteraction,\n ]);\n\n const renderSlideElement = (\n element?: Element,\n options: RenderSlideElementOptions = {}\n ) => {\n if (!element) {\n return null;\n }\n\n if (element.type === \"slot\") {\n return <>{element.content}</>;\n }\n\n if (element.type === \"html\") {\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n hideFullScreen\n mode=\"blackboard\"\n replaceRootScreenHeightWithFull={\n options.replaceRootScreenHeightWithFull\n }\n type=\"sandbox\"\n content={element.content as string}\n enableScaling={enableIframeScaling}\n />\n );\n }\n\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n hideFullScreen\n mode=\"blackboard\"\n type=\"markdown\"\n content={element.content as string}\n />\n );\n };\n\n const renderSlideElementList = (\n elementList: Element[] = [],\n isActiveStep = false\n ) => {\n if (elementList.length === 0) {\n return null;\n }\n\n const visibleElementCount = elementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <div className=\"slide-stage__content flex w-full flex-col gap-4\">\n {elementList.map((element, index) => {\n const isPreRenderedHtml =\n element.type === \"html\" && element.is_renderable === false;\n\n return (\n <div\n key={element.sequence_number ?? `${element.type}-${index}`}\n ref={\n isActiveStep && index === lastVisibleElementIndex\n ? lastElementRef\n : null\n }\n aria-hidden={isPreRenderedHtml || undefined}\n className={cn(\n \"w-full shrink-0\",\n visibleElementCount === 1 &&\n element.is_renderable !== false &&\n \"slide-element--single\",\n isPreRenderedHtml\n ? \"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0\"\n : element.is_renderable === false && \"hidden\"\n )}\n >\n {renderSlideElement(element, {\n replaceRootScreenHeightWithFull:\n visibleElementCount === 1 &&\n element.type === \"html\" &&\n element.is_renderable !== false,\n })}\n </div>\n );\n })}\n </div>\n );\n };\n\n const handleFullscreen = useCallback(() => {\n const target = sectionRef.current;\n if (!target) {\n return;\n }\n\n if (document.fullscreenElement === target) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n\n target.requestFullscreen?.().catch(() => {});\n }, []);\n\n const scrollStageToBottom = useCallback(() => {\n const stageLayerElement = stageLayerRef.current;\n\n if (!stageLayerElement) {\n return;\n }\n\n // Keep the latest content visible after manual player navigation.\n stageLayerElement.scrollTo({\n top: stageLayerElement.scrollHeight,\n behavior: \"smooth\",\n });\n }, []);\n\n const handlePrev = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goPrev();\n }, [goPrev, resetAudioSequence, showPlayerControls]);\n\n const handleNext = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goNext();\n }, [goNext, resetAudioSequence, showPlayerControls]);\n\n const handlePlayerLoadingChange = useCallback(\n (loading: boolean) => {\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(loading);\n },\n [currentStepHasSpeakableElement, hasCompletedCurrentStepAudio]\n );\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n const endedAudioKey = audioList[audioIndex]?.audioKey;\n\n if (!endedAudioKey || !currentAudioKey) {\n return;\n }\n\n if (endedAudioKey !== currentAudioKey) {\n return;\n }\n\n const activeSequencePosition = currentAudioSequenceKeys.findIndex(\n (audioSequenceKey) => audioSequenceKey === endedAudioKey\n );\n if (activeSequencePosition < 0) {\n setCurrentAudioKey(null);\n return;\n }\n\n const nextSequencePosition = activeSequencePosition + 1;\n const nextAudioKey = currentAudioSequenceKeys[nextSequencePosition];\n\n if (nextAudioKey) {\n setCurrentAudioKey(nextAudioKey);\n return;\n }\n\n setCurrentAudioKey(null);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n const nextStepIndex = currentIndex + 1;\n const nextStepElement = slideElementList[nextStepIndex];\n\n if (hasCurrentStepAudioUrl && nextStepElement?.type === \"interaction\") {\n pendingInteractionOverlayStepIndexRef.current = nextStepIndex;\n }\n\n goNext();\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handleInteractionToggle = useCallback(() => {\n if (!activeInteractionElement) {\n return;\n }\n\n setIsInteractionOverlayOpen((prevOpen) => !prevOpen);\n }, [activeInteractionElement]);\n\n const stopOverlayPropagation = useCallback(\n (\n event:\n | React.PointerEvent<HTMLDivElement>\n | React.MouseEvent<HTMLDivElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerVisible) {\n showPlayerControls(true);\n }\n },\n [isPlayerVisible, showPlayerControls]\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n }, [showPlayerControls]);\n\n const currentRenderElementKeys = useMemo(\n () =>\n currentElementList.map(\n (element, index) =>\n `${element.sequence_number ?? `${element.type}-${index}`}:${String(element.is_new ?? \"\")}`\n ),\n [currentElementList]\n );\n\n useEffect(() => {\n const prevKeys = prevRenderElementKeysRef.current;\n const hasStablePrefix =\n prevKeys.length > 0 &&\n prevKeys.length < currentRenderElementKeys.length &&\n prevKeys.every((key, index) => key === currentRenderElementKeys[index]);\n const appendedElements = hasStablePrefix\n ? currentElementList.slice(prevKeys.length)\n : [];\n const shouldAutoScrollToAppend = appendedElements.some(\n (element) => element.is_new === false\n );\n\n prevRenderElementKeysRef.current = currentRenderElementKeys;\n\n if (!shouldAutoScrollToAppend) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n const stageLayerElement = stageLayerRef.current;\n const targetElement = lastElementRef.current;\n\n if (!stageLayerElement || !targetElement) {\n return;\n }\n\n const stageLayerRect = stageLayerElement.getBoundingClientRect();\n const targetRect = targetElement.getBoundingClientRect();\n const nextScrollTop =\n stageLayerElement.scrollTop + (targetRect.top - stageLayerRect.top);\n\n // Keep newly appended content visible when the current slide grows downward.\n stageLayerElement.scrollTo({\n top: Math.max(nextScrollTop, 0),\n behavior: \"smooth\",\n });\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, currentRenderElementKeys]);\n\n useEffect(() => {\n if (!shouldScrollToBottomRef.current) {\n return;\n }\n\n shouldScrollToBottomRef.current = false;\n\n if (currentElementList.length === 0) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n scrollStageToBottom();\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, scrollStageToBottom]);\n\n return (\n <section\n ref={sectionRef}\n className={cn(\n \"relative h-full w-full\",\n isMobileDevice && \"slide--mobile-device\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n onClick={handleSurfaceClick}\n onPointerDown={handleSurfacePointerDown}\n {...props}\n >\n {shouldShowMobileFullscreenMask ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]\"\n />\n ) : null}\n\n <div\n ref={viewportRef}\n className={cn(\n \"slide__viewport relative h-full min-h-0 w-full\",\n isImmersiveMobileFullscreen && \"slide__viewport--mobile-landscape\",\n isImmersiveMobileFullscreen &&\n !shouldRotateFullscreenViewport &&\n \"slide__viewport--mobile-landscape-native\"\n )}\n >\n {shouldShowFullscreenHeader ? (\n <div className=\"slide-landscape-header\">\n <button\n aria-label={fullscreenHeader?.backAriaLabel ?? \"Back\"}\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft className=\"h-6 w-6 text-white\" strokeWidth={2.25} />\n </button>\n\n {fullscreenHeader?.content ? (\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n {fullscreenHeader.content}\n </div>\n ) : null}\n </div>\n ) : null}\n\n <div\n className={cn(\n \"h-full min-h-0 w-full\",\n shouldApplyFullscreenViewportPadding &&\n \"slide__viewport-content--with-header\",\n isSingleSlide ? \"slide-content--single\" : \"grid gap-4\"\n )}\n >\n {currentElementList.length > 0 ? (\n <div className=\"slide-stage\">\n <div ref={stageLayerRef} className=\"slide-stage__layer w-full\">\n {mountedStepStates.map(\n (mountedStepState, mountedStepStateIndex) => {\n const isActiveStep =\n mountedStepStateIndex === currentMountedStateIndex;\n\n return (\n <div\n key={\n mountedStepState.sourceStepIndexes[0] ??\n mountedStepStateIndex\n }\n aria-hidden={!isActiveStep || undefined}\n className=\"w-full h-full\"\n style={{ display: isActiveStep ? undefined : \"none\" }}\n >\n {renderSlideElementList(\n mountedStepState.elementList,\n isActiveStep\n )}\n </div>\n );\n }\n )}\n </div>\n </div>\n ) : null}\n </div>\n\n {isAudioLoadingVisible ? (\n <LoadingOverlayCard\n message={bufferingText}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SlideFullscreenHint\n onClose={handleFullscreenHintClose}\n open={isFullscreenHintOpen}\n text={fullscreenHintText}\n />\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerVisible}\n isPlayerHidden={shouldRenderPlayer && !playerVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n className={cn(\n \"slide-interaction-overlay\",\n playerVisible && shouldRenderPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDown={stopOverlayPropagation}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={interactionTexts?.confirmButtonText}\n copyButtonText={interactionTexts?.copyButtonText}\n copiedButtonText={interactionTexts?.copiedButtonText}\n onSend={handleInteractionSend}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n \"Submit the content below to continue.\"\n }\n />\n </div>\n ) : null}\n\n {shouldRenderPlayer ? (\n <Player\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 bottom-6 z-[2] -translate-x-1/2\",\n playerClassName,\n !playerVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackTimeChange={playbackTimeStore.setTime}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n prevDisabled={!canGoPrev}\n showControls={playerVisible}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n ) : null}\n </div>\n </section>\n );\n};\n\nexport default Slide;\n"],"names":["DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX","DEFAULT_INTERACTION_SUBTITLE_GAP_PX","InteractionOverlayCard","memo","content","title","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","readonly","jsxs","jsx","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","Slide","elementList","showPlayer","playerAlwaysVisible","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","bufferingText","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableIframeScaling","className","onPointerDown","props","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","autoAdvanceTimerRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","playbackResetKeyRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","useSlide","currentStepElement","useMemo","isSingleSlide","shouldRenderPlayer","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","isFullscreenHintOpen","setIsFullscreenHintOpen","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","fullscreenHintText","DEFAULT_SLIDE_PLAYER_TEXTS","handleMobileViewModeSelect","useCallback","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","handleFullscreenHintClose","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previous","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","syncViewportFullscreenPreference","subscribeMobileDeviceChange","shouldShowFullscreenHint","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","interactionDefaults","shouldPreferResolvedInteractionInput","getInteractionDefaultValues","interactionDefaultSelectedValues","getInteractionDefaultSelectedValues","hasResolvedInteractionInput","isInteractionReadonly","shouldAutoContinueInteraction","shouldShowInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","options","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","lastVisibleElementIndex","lastVisibleIndex","isPreRenderedHtml","cn","handleFullscreen","target","scrollStageToBottom","stageLayerElement","handlePrev","handleNext","handlePlayerLoadingChange","loading","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","handleSurfaceClick","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SlideFullscreenHint","SubtitleOverlay","Player"],"mappings":"6uCAyDMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GAiCtCC,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,GACA,OAAAC,GACA,SAAAC,EAAW,EAAA,IAEXC,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,iCACb,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,mCACb,SAAAA,EAAAA,kBAAAA,IAAC,KAAE,UAAU,kCAAmC,WAAM,CAAA,CACxD,EACAA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCACb,SAAAA,EAAAA,kBAAAA,IAACC,GAAAA,QAAA,CACC,QAAAZ,EACA,kBAAAE,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,GACA,OAAAC,GACA,SAAAC,EACA,iBAAkB,GAClB,YAAY,SAAA,CAAA,EAEhB,EACAE,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCAAA,CAAkC,CAAA,CAAA,CACnD,CAEJ,EAEAb,GAAuB,YAAc,yBAErC,MAAMe,GAA2B,CAC/BC,EACAC,IAEAD,EAAgB,SAAWC,EAAgB,QAC3CD,EAAgB,MAAM,CAACE,EAASC,IAAU,CACxC,MAAMC,EAAcH,EAAgBE,CAAK,EAEzC,OACED,EAAQ,kBAAoBE,GAAa,iBACzCF,EAAQ,OAASE,GAAa,MAC9BF,EAAQ,UAAYE,GAAa,OAErC,CAAC,EAwBGC,GAA8B,CAAC,CACnC,YAAAC,EAAc,CAAA,EACd,WAAAC,E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EAAA,CAAA,EAGfmD,GACCzL,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKuC,GACL,UAAWqK,EAAAA,GACT,4BACAjG,GAAiB/C,EACb,yCACA,uCAAA,EAEN,QAASkK,GACT,cAAeA,GACf,MAAOlF,GAEP,SAAA5I,EAAAA,kBAAAA,IAACb,GAAA,CACC,QAAS,OAAO4F,GAA0B,SAAW,EAAE,EACvD,kBAAmBkG,GAAoB,YAAc,GACrD,iBAAkBA,GAAoB,WAAa,GACnD,sBAAuBG,GACvB,kBAAmBlK,GAAkB,kBACrC,eAAgBA,GAAkB,eAClC,iBAAkBA,GAAkB,iBACpC,OAAQwK,GACR,SAAUH,GACV,MACErK,GAAkB,OAClBD,IACA,uCAAA,CAAA,CAEJ,CAAA,EAEA,KAEH2C,EACC5D,EAAAA,kBAAAA,IAAC+O,GAAAA,QAAA,CACC,UAAA/L,EACA,UAAW4J,EAAAA,GACT,oDACAhM,EACA,CAAC+F,GAAiB,+BAAA,EAEpB,kBAAAyB,EACA,eAAc,GACd,iBAAkBa,EAClB,qBAAA5E,GACA,eAAgB,EAAQU,EACxB,kBAAmBE,GACnB,oBAAqBX,GACrB,gBAAiB6I,GACjB,qBAAsBhH,EAAkB,QACxC,aAAc,CAAC9C,EACf,QAASgK,GACT,aAAcR,GACd,aAAcxH,GACd,eAAgBgB,EAChB,wBAAyBrE,GAAY,QACrC,uBAAwBiF,GACxB,oBAAqB2G,GACrB,OAAQV,GACR,OAAQD,GACR,aAAc,CAAC7J,GACf,aAAcuD,EACd,MAAOxF,GACP,oBAAqBqH,GACrB,cAAe1H,EACf,qBAAsBoI,EAAA,CAAA,EAEtB,IAAA,CAAA,CAAA,CACN,CAAA,CAAA,CAGN"}
|
|
1
|
+
{"version":3,"file":"Slide.cjs.js","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport LoadingOverlayCard from \"../ui/loading-overlay-card\";\nimport ContentRender from \"../ContentRender\";\nimport type { ContentRenderProps } from \"../ContentRender/ContentRender\";\nimport IframeSandbox from \"../ContentRender/IframeSandbox\";\nimport type { OnSendContentParams } from \"../types\";\nimport {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type { PlayerProps, SlidePlayerTexts } from \"./Player\";\nimport { DEFAULT_SLIDE_PLAYER_TEXTS } from \"./constants\";\nimport SlideFullscreenHint from \"./SlideFullscreenHint\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport { shouldPresentInteractionOverlay } from \"./utils/interactionPlayback\";\nimport { getPlaybackSequenceTransition } from \"./utils/playbackSequence\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\n\nconst DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS = 2000;\nconst DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS = 300;\nconst DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX = 160;\nconst DEFAULT_INTERACTION_SUBTITLE_GAP_PX = 16;\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n content: string;\n title: string;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n}\n\nexport type SlideFullscreenHeader = {\n content?: React.ReactNode;\n backAriaLabel?: string;\n onBack?: () => void;\n};\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <div className=\"slide-player__interaction-header\">\n <p className=\"slide-player__interaction-title\">{title}</p>\n </div>\n <div className=\"slide-player__interaction-body\">\n <ContentRender\n content={content}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n onSend={onSend}\n readonly={readonly}\n enableTypewriter={false}\n sandboxMode=\"content\"\n />\n </div>\n <div className=\"slide-player__interaction-arrow\" />\n </div>\n )\n);\n\nInteractionOverlayCard.displayName = \"InteractionOverlayCard\";\n\nconst areStepElementListsEqual = (\n prevElementList: Element[],\n nextElementList: Element[]\n) =>\n prevElementList.length === nextElementList.length &&\n prevElementList.every((element, index) => {\n const nextElement = nextElementList[index];\n\n return (\n element.sequence_number === nextElement?.sequence_number &&\n element.type === nextElement?.type &&\n element.content === nextElement?.content\n );\n });\n\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n showPlayer?: boolean;\n playerAlwaysVisible?: boolean;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: string;\n interactionTitle?: string;\n interactionTexts?: SlideInteractionTexts;\n playerTexts?: SlidePlayerTexts;\n playerAutoHideDelay?: number;\n markerAutoAdvanceDelay?: number;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n onSend?: (content: OnSendContentParams, element?: Element) => void;\n onPlayerVisibilityChange?: (visible: boolean) => void;\n onMobileViewModeChange?: (viewMode: MobileViewMode) => void;\n onStepChange?: (element: Element | undefined, index: number) => void;\n enableIframeScaling?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n showPlayer = true,\n playerAlwaysVisible = false,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText = \"Buffering...\",\n interactionTitle,\n interactionTexts,\n playerTexts,\n playerAutoHideDelay = 3000,\n markerAutoAdvanceDelay = DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS,\n interactionDefaultValueOptions,\n onSend,\n onPlayerVisibilityChange,\n onMobileViewModeChange,\n onStepChange,\n enableIframeScaling = true,\n className,\n onPointerDown,\n ...props\n}) => {\n const sectionRef = useRef<HTMLElement | null>(null);\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const stageLayerRef = useRef<HTMLDivElement | null>(null);\n const lastElementRef = useRef<HTMLDivElement | null>(null);\n const playerHideTimerRef = useRef<number | null>(null);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const interactionAutoCloseTimerRef = useRef<number | null>(null);\n const interactionOverlayOpenTimerRef = useRef<number | null>(null);\n const interactionOverlayRef = useRef<HTMLDivElement | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const playbackResetKeyRef = useRef<string | null>(null);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n } = useSlide(elementList);\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\n const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldRenderPlayer =\n showPlayer &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const currentAudioSequenceKeys = useMemo(\n () =>\n currentAudioSequenceIndexes\n .map((audioIndex) => audioList[audioIndex]?.audioKey)\n .filter((audioKey): audioKey is string => Boolean(audioKey)),\n [audioList, currentAudioSequenceIndexes]\n );\n const [isPlayerVisible, setIsPlayerVisible] = useState(true);\n const [hasPlayerInteracted, setHasPlayerInteracted] = useState(false);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n const [hasCurrentAudioPlaybackStarted, setHasCurrentAudioPlaybackStarted] =\n useState(false);\n const [isPlayerCustomActionActive, setIsPlayerCustomActionActive] =\n useState(false);\n const [activeInteractionElement, setActiveInteractionElement] = useState<\n Element | undefined\n >();\n const [isInteractionOverlayOpen, setIsInteractionOverlayOpen] =\n useState(false);\n const [\n interactionOverlaySubtitleOffset,\n setInteractionOverlaySubtitleOffset,\n ] = useState(0);\n const [isBrowserFullscreen, setIsBrowserFullscreen] = useState(false);\n const isMobileDevice = useMemo(() => getIsMobileDevice(), []);\n const [mobileViewMode, setMobileViewMode] = useState<MobileViewMode>(\n DEFAULT_MOBILE_VIEW_MODE\n );\n const [hasManualMobileViewMode, setHasManualMobileViewMode] = useState(false);\n const [isViewportFullscreenPreferred, setIsViewportFullscreenPreferred] =\n useState(() =>\n isMobileDevice ? getIsFullscreenPreferredViewport() : false\n );\n const [isFullscreenHintOpen, setIsFullscreenHintOpen] = useState(false);\n const playbackTimeStore = useMemo(() => createPlaybackTimeStore(), []);\n const {\n effectiveMobileViewMode,\n isImmersiveMobileFullscreen,\n isNativeMobileFullscreen,\n shouldRotateFullscreenViewport,\n } = useMemo(\n () =>\n resolveMobileViewModeState({\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n }),\n [\n hasManualMobileViewMode,\n isMobileDevice,\n isViewportFullscreenPreferred,\n mobileViewMode,\n ]\n );\n const previousEffectiveMobileViewModeRef = useRef(effectiveMobileViewMode);\n const playerVisible =\n shouldRenderPlayer && (playerAlwaysVisible || isPlayerVisible);\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerVisible;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const fullscreenHintText =\n playerTexts?.fullscreenHintText ??\n DEFAULT_SLIDE_PLAYER_TEXTS.fullscreenHintText;\n const handleMobileViewModeSelect = useCallback(\n (nextViewMode: MobileViewMode) => {\n setHasManualMobileViewMode(true);\n setMobileViewMode(nextViewMode);\n },\n []\n );\n const handleMobileViewModeReset = useCallback(() => {\n // Clear manual override so the effective mode returns to the default non-fullscreen state.\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, []);\n const handleFullscreenHeaderBack = useCallback(() => {\n handleMobileViewModeReset();\n fullscreenHeader?.onBack?.();\n }, [fullscreenHeader, handleMobileViewModeReset]);\n const handleFullscreenHintClose = useCallback(() => {\n setIsFullscreenHintOpen(false);\n }, []);\n const setPlayerCustomActionActive = useCallback((active: boolean) => {\n setIsPlayerCustomActionActive(active);\n }, []);\n const togglePlayerCustomActionActive = useCallback(() => {\n setIsPlayerCustomActionActive((previous) => !previous);\n }, []);\n const { mountedStepStates, currentMountedStateIndex } = useMemo(() => {\n const nextMountedStepStates: Array<{\n elementList: Element[];\n sourceStepIndexes: number[];\n }> = [];\n const mountedStateIndexByStep = new Map<number, number>();\n\n stepElementLists.forEach((stepElementList, stepIndex) => {\n const existingMountedStateIndex = nextMountedStepStates.findIndex(\n (mountedStepState) =>\n areStepElementListsEqual(\n mountedStepState.elementList,\n stepElementList\n )\n );\n\n if (existingMountedStateIndex >= 0) {\n nextMountedStepStates[\n existingMountedStateIndex\n ]?.sourceStepIndexes.push(stepIndex);\n mountedStateIndexByStep.set(stepIndex, existingMountedStateIndex);\n return;\n }\n\n nextMountedStepStates.push({\n elementList: stepElementList,\n sourceStepIndexes: [stepIndex],\n });\n mountedStateIndexByStep.set(stepIndex, nextMountedStepStates.length - 1);\n });\n\n return {\n mountedStepStates: nextMountedStepStates,\n currentMountedStateIndex:\n currentIndex >= 0\n ? (mountedStateIndexByStep.get(currentIndex) ?? -1)\n : -1,\n };\n }, [currentIndex, stepElementLists]);\n const currentStepKey = useMemo(() => String(currentIndex), [currentIndex]);\n const currentAudioIndex = useMemo(() => {\n if (!currentAudioKey) {\n return -1;\n }\n\n return audioList.findIndex(\n (audioItem) => (audioItem.audioKey ?? \"\") === currentAudioKey\n );\n }, [audioList, currentAudioKey]);\n const currentAudioItem = useMemo(\n () => (currentAudioIndex >= 0 ? audioList[currentAudioIndex] : undefined),\n [audioList, currentAudioIndex]\n );\n const currentSubtitleCues = currentAudioItem?.element?.subtitle_cues ?? [];\n const currentAudioSequenceStartKey = useMemo(\n () => currentAudioSequenceKeys[0] ?? \"none\",\n [currentAudioSequenceKeys]\n );\n const playerCustomActionContext = useMemo(\n () => ({\n currentElement: resolvePlayerCustomActionElement({\n currentAudioIndex,\n currentAudioSequenceIndexes,\n audioList,\n currentInteractionElement: activeInteractionElement,\n currentStepElement,\n }),\n currentIndex,\n currentStepElement,\n isActive: isPlayerCustomActionActive,\n setActive: setPlayerCustomActionActive,\n toggleActive: togglePlayerCustomActionActive,\n }),\n [\n activeInteractionElement,\n audioList,\n currentAudioIndex,\n currentAudioSequenceIndexes,\n currentIndex,\n currentStepElement,\n isPlayerCustomActionActive,\n setPlayerCustomActionActive,\n togglePlayerCustomActionActive,\n ]\n );\n const playerCustomActionCount = useMemo(\n () =>\n getPlayerCustomActionCount(\n playerCustomActions,\n playerCustomActionContext\n ),\n [playerCustomActionContext, playerCustomActions]\n );\n const interactionOverlayStyle = useMemo(\n () =>\n ({\n \"--slide-player-custom-action-count\": String(playerCustomActionCount),\n \"--slide-player-mobile-control-count\": String(\n playerCustomActionCount + 4\n ),\n }) as React.CSSProperties,\n [playerCustomActionCount]\n );\n const hasAvailableStepAudio = currentAudioSequenceKeys.length > 0;\n const currentInteractionResetKey = useMemo(() => {\n if (!currentInteractionElement) {\n return \"none\";\n }\n\n return `${currentInteractionElement.sequence_number ?? \"none\"}:${String(\n currentInteractionElement.content ?? \"\"\n )}`;\n }, [currentInteractionElement]);\n const currentPlaybackResetKey = useMemo(\n () => [currentStepKey, currentInteractionResetKey].join(\"|\"),\n [currentInteractionResetKey, currentStepKey]\n );\n const currentPlaybackStartedResetKey = useMemo(\n () =>\n [\n currentPlaybackResetKey,\n currentAudioItem?.audioKey ?? \"none\",\n String(currentAudioIndex),\n ].join(\"|\"),\n [currentAudioIndex, currentAudioItem?.audioKey, currentPlaybackResetKey]\n );\n const currentStepAudioUrl = useMemo(() => {\n if (\n !currentAudioSequenceStartKey ||\n currentAudioSequenceStartKey === \"none\"\n ) {\n return \"\";\n }\n\n const currentStepAudioItem = audioList.find(\n (audioItem) => audioItem.audioKey === currentAudioSequenceStartKey\n );\n\n return currentStepAudioItem?.audioUrl?.trim() ?? \"\";\n }, [audioList, currentAudioSequenceStartKey]);\n const hasCurrentStepAudioUrl = Boolean(currentStepAudioUrl);\n const shouldPausePlaybackForCustomAction =\n playerCustomActionPauseOnActive &&\n Boolean(playerCustomActions) &&\n isPlayerCustomActionActive;\n const shouldUseSilentStepAutoAdvanceToggle = useMemo(\n () =>\n shouldUseAutoAdvanceToggle({\n canGoNext,\n currentAudioIndex,\n currentStepHasSpeakableElement,\n hasInteraction: Boolean(currentInteractionElement),\n }),\n [\n canGoNext,\n currentAudioIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n ]\n );\n\n const clearPlayerHideTimer = useCallback(() => {\n if (playerHideTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(playerHideTimerRef.current);\n playerHideTimerRef.current = null;\n }, []);\n\n const clearInteractionAutoCloseTimer = useCallback(() => {\n if (interactionAutoCloseTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionAutoCloseTimerRef.current);\n interactionAutoCloseTimerRef.current = null;\n }, []);\n\n const clearInteractionOverlayOpenTimer = useCallback(() => {\n if (interactionOverlayOpenTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(interactionOverlayOpenTimerRef.current);\n interactionOverlayOpenTimerRef.current = null;\n }, []);\n\n const clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(() => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]);\n\n const startCurrentAudioSequence = useCallback(() => {\n const nextAudioKey = currentAudioSequenceKeys[0];\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first audio segment for the current step immediately.\n setCurrentAudioKey(nextAudioKey);\n return true;\n }, [currentAudioSequenceKeys]);\n\n const continueAfterInteraction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (canGoNext) {\n goNext();\n }\n }, [\n canGoNext,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n goNext,\n startCurrentAudioSequence,\n ]);\n\n const scheduleInteractionOverlayOpen = useCallback(\n (interactionElement?: Element) => {\n clearInteractionOverlayOpenTimer();\n\n if (!interactionElement) {\n return;\n }\n\n const openOverlay = () => {\n interactionOverlayOpenTimerRef.current = null;\n setInteractionOverlaySubtitleOffset(\n DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX\n );\n setIsInteractionOverlayOpen(true);\n pendingInteractionOverlayStepIndexRef.current = null;\n };\n\n interactionOverlayOpenTimerRef.current = window.setTimeout(\n openOverlay,\n DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS\n );\n },\n [clearInteractionOverlayOpenTimer]\n );\n\n const showPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldRenderPlayer) {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (playerAlwaysVisible || !enableAutoHide || playerAutoHideDelay <= 0) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n playerAutoHideDelay,\n shouldRenderPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n currentInteractionElement?.readonly ||\n currentInteractionElement?.user_input?.trim()\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n useEffect(() => {\n // Reset silent-step autoplay toggle whenever navigation lands on a new step.\n setIsAutoAdvanceEnabled(true);\n\n if (playerCustomActionPauseOnActive) {\n setIsPlayerCustomActionActive(false);\n }\n }, [currentIndex, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerVisible]);\n\n useEffect(() => {\n if (isMobileDevice || mobileViewMode === DEFAULT_MOBILE_VIEW_MODE) {\n return;\n }\n\n setHasManualMobileViewMode(false);\n setMobileViewMode(DEFAULT_MOBILE_VIEW_MODE);\n }, [isMobileDevice, mobileViewMode]);\n\n useEffect(() => {\n if (!isMobileDevice) {\n setIsViewportFullscreenPreferred(false);\n return;\n }\n\n const syncViewportFullscreenPreference = () => {\n setIsViewportFullscreenPreferred(getIsFullscreenPreferredViewport());\n };\n\n syncViewportFullscreenPreference();\n\n return subscribeMobileDeviceChange(syncViewportFullscreenPreference);\n }, [isMobileDevice]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n const previousMode = previousEffectiveMobileViewModeRef.current;\n const hasEnteredFullscreen =\n previousMode !== \"fullscreen\" && effectiveMobileViewMode === \"fullscreen\";\n const shouldShowFullscreenHint =\n hasEnteredFullscreen && !isViewportFullscreenPreferred;\n\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n\n if (!isMobileDevice) {\n setIsFullscreenHintOpen(false);\n return;\n }\n\n if (shouldShowFullscreenHint) {\n setIsFullscreenHintOpen(true);\n return;\n }\n\n if (effectiveMobileViewMode !== \"fullscreen\") {\n setIsFullscreenHintOpen(false);\n }\n }, [effectiveMobileViewMode, isMobileDevice, isViewportFullscreenPreferred]);\n\n useEffect(() => {\n onStepChange?.(currentStepElement, currentIndex);\n }, [currentIndex, currentStepElement, onStepChange]);\n\n useEffect(() => {\n if (!shouldRenderPlayer) {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (playerAlwaysVisible) {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n showPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n playerAlwaysVisible,\n shouldRenderPlayer,\n showPlayerControls,\n ]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const handleSandboxInteraction = (event: MessageEvent) => {\n if (event.origin !== window.location.origin) {\n return;\n }\n\n if (!isSandboxInteractionMessage(event.data)) {\n return;\n }\n\n if (event.data.eventType !== \"click\") {\n return;\n }\n\n if (!shouldRenderPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [shouldRenderPlayer, showPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldRenderPlayer,\n onWake: () => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n },\n });\n\n useEffect(() => {\n const { hasPlaybackContextChanged, shouldInitializeAudioSequence } =\n getPlaybackSequenceTransition({\n previousResetKey: playbackResetKeyRef.current,\n nextResetKey: currentPlaybackResetKey,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n });\n\n playbackResetKeyRef.current = currentPlaybackResetKey;\n\n const shouldOpenInteractionOverlayAfterAudio =\n pendingInteractionOverlayStepIndexRef.current === currentIndex &&\n Boolean(currentInteractionElement);\n const shouldPresentOverlay = shouldPresentInteractionOverlay({\n hasInteraction: Boolean(currentInteractionElement),\n shouldBlockPlaybackForInteraction,\n shouldOpenInteractionOverlayAfterAudio,\n hasPlaybackContextChanged,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n });\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence();\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (currentInteractionElement) {\n setActiveInteractionElement(currentInteractionElement);\n }\n\n if (shouldPresentOverlay) {\n // Delay auto-presenting the overlay so subtitles can settle above it.\n scheduleInteractionOverlayOpen(currentInteractionElement);\n return;\n }\n\n clearInteractionOverlayOpenTimer();\n pendingInteractionOverlayStepIndexRef.current = null;\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n // Auto-advance silent marker-only steps so playback flow does not stall.\n autoAdvanceTimerRef.current = window.setTimeout(() => {\n autoAdvanceTimerRef.current = null;\n goNext();\n }, markerAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n scheduleInteractionOverlayOpen,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (hasAvailableStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n useEffect(() => {\n if (currentAudioKey || currentAudioSequenceKeys.length === 0) {\n return;\n }\n\n if (\n shouldPausePlaybackForCustomAction ||\n !currentStepHasSpeakableElement ||\n shouldBlockPlaybackForInteraction\n ) {\n return;\n }\n\n if (hasCompletedCurrentStepAudio) {\n return;\n }\n\n startCurrentAudioSequence();\n }, [\n currentAudioKey,\n currentAudioSequenceKeys,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n startCurrentAudioSequence,\n ]);\n\n useEffect(() => {\n if (!currentAudioKey || currentAudioIndex >= 0) {\n return;\n }\n\n setCurrentAudioKey(null);\n }, [currentAudioIndex, currentAudioKey]);\n\n useEffect(() => {\n if (currentAudioIndex >= 0) {\n return;\n }\n\n playbackTimeStore.reset();\n }, [currentAudioIndex, playbackTimeStore]);\n\n useEffect(() => {\n setHasCurrentAudioPlaybackStarted(false);\n }, [currentPlaybackStartedResetKey]);\n\n const interactionDefaults = useMemo(() => {\n if (!activeInteractionElement) {\n return {};\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const interactionDefaultSelectedValues = useMemo(() => {\n if (!activeInteractionElement) {\n return undefined;\n }\n\n const shouldPreferResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n\n return getInteractionDefaultSelectedValues(\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined,\n activeInteractionElement.user_input,\n shouldPreferResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions\n );\n }, [activeInteractionElement, interactionDefaultValueOptions]);\n\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement?.user_input?.trim()\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || hasResolvedInteractionInput;\n const shouldAutoContinueInteraction =\n isInteractionReadonly || hasResolvedInteractionInput;\n const shouldShowInteractionOverlay =\n Boolean(activeInteractionElement) && isInteractionOverlayOpen;\n\n const handleInteractionSend = useCallback(\n (content: OnSendContentParams) => {\n const submittedValues = [\n ...(content.selectedValues ?? []),\n content.inputText?.trim() ?? \"\",\n content.buttonText?.trim() ?? \"\",\n ].filter(Boolean);\n const resolvedUserInput = submittedValues.join(\", \");\n\n setActiveInteractionElement((prevElement) => {\n if (!prevElement || !resolvedUserInput) {\n return prevElement;\n }\n\n return {\n ...prevElement,\n user_input: resolvedUserInput,\n };\n });\n\n onSend?.(content, activeInteractionElement);\n continueAfterInteraction();\n },\n [activeInteractionElement, continueAfterInteraction, onSend]\n );\n\n useEffect(() => {\n // Keep the player icon in sync with the actual fullscreen owner.\n const syncFullscreenState = () => {\n setIsBrowserFullscreen(document.fullscreenElement === sectionRef.current);\n };\n\n syncFullscreenState();\n document.addEventListener(\"fullscreenchange\", syncFullscreenState);\n\n return () => {\n document.removeEventListener(\"fullscreenchange\", syncFullscreenState);\n };\n }, []);\n\n useEffect(() => {\n if (!shouldShowInteractionOverlay) {\n setInteractionOverlaySubtitleOffset(0);\n return;\n }\n\n const interactionOverlayElement = interactionOverlayRef.current;\n\n if (!interactionOverlayElement) {\n return;\n }\n\n const updateSubtitleOffset = () => {\n const overlayHeight = Math.ceil(\n interactionOverlayElement.getBoundingClientRect().height\n );\n\n setInteractionOverlaySubtitleOffset(\n overlayHeight + DEFAULT_INTERACTION_SUBTITLE_GAP_PX\n );\n };\n\n updateSubtitleOffset();\n\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n updateSubtitleOffset();\n });\n\n resizeObserver.observe(interactionOverlayElement);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [shouldShowInteractionOverlay]);\n\n useEffect(() => {\n clearInteractionAutoCloseTimer();\n\n if (!isInteractionOverlayOpen || !shouldAutoContinueInteraction) {\n return;\n }\n\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, 2000);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n isInteractionOverlayOpen,\n shouldAutoContinueInteraction,\n ]);\n\n const renderSlideElement = (\n element?: Element,\n options: RenderSlideElementOptions = {}\n ) => {\n if (!element) {\n return null;\n }\n\n if (element.type === \"slot\") {\n return <>{element.content}</>;\n }\n\n if (element.type === \"html\") {\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n hideFullScreen\n mode=\"blackboard\"\n replaceRootScreenHeightWithFull={\n options.replaceRootScreenHeightWithFull\n }\n type=\"sandbox\"\n content={element.content as string}\n enableScaling={enableIframeScaling}\n />\n );\n }\n\n return (\n <IframeSandbox\n className=\"content-render-iframe\"\n hideFullScreen\n mode=\"blackboard\"\n type=\"markdown\"\n content={element.content as string}\n />\n );\n };\n\n const renderSlideElementList = (\n elementList: Element[] = [],\n isActiveStep = false\n ) => {\n if (elementList.length === 0) {\n return null;\n }\n\n const visibleElementCount = elementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <div className=\"slide-stage__content flex w-full flex-col gap-4\">\n {elementList.map((element, index) => {\n const isPreRenderedHtml =\n element.type === \"html\" && element.is_renderable === false;\n\n return (\n <div\n key={element.sequence_number ?? `${element.type}-${index}`}\n ref={\n isActiveStep && index === lastVisibleElementIndex\n ? lastElementRef\n : null\n }\n aria-hidden={isPreRenderedHtml || undefined}\n className={cn(\n \"w-full shrink-0\",\n visibleElementCount === 1 &&\n element.is_renderable !== false &&\n \"slide-element--single\",\n isPreRenderedHtml\n ? \"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0\"\n : element.is_renderable === false && \"hidden\"\n )}\n >\n {renderSlideElement(element, {\n replaceRootScreenHeightWithFull:\n visibleElementCount === 1 &&\n element.type === \"html\" &&\n element.is_renderable !== false,\n })}\n </div>\n );\n })}\n </div>\n );\n };\n\n const handleFullscreen = useCallback(() => {\n const target = sectionRef.current;\n if (!target) {\n return;\n }\n\n if (document.fullscreenElement === target) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n\n target.requestFullscreen?.().catch(() => {});\n }, []);\n\n const scrollStageToBottom = useCallback(() => {\n const stageLayerElement = stageLayerRef.current;\n\n if (!stageLayerElement) {\n return;\n }\n\n // Keep the latest content visible after manual player navigation.\n stageLayerElement.scrollTo({\n top: stageLayerElement.scrollHeight,\n behavior: \"smooth\",\n });\n }, []);\n\n const handlePrev = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goPrev();\n }, [goPrev, resetAudioSequence, showPlayerControls]);\n\n const handleNext = useCallback(() => {\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setHasPlayerInteracted(true);\n setIsAudioLoadingVisible(false);\n showPlayerControls(true);\n resetAudioSequence();\n goNext();\n }, [goNext, resetAudioSequence, showPlayerControls]);\n\n const handlePlayerLoadingChange = useCallback(\n (loading: boolean) => {\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(loading);\n },\n [currentStepHasSpeakableElement, hasCompletedCurrentStepAudio]\n );\n\n const handlePlayerEnded = useCallback(\n (audioIndex: number) => {\n const endedAudioKey = audioList[audioIndex]?.audioKey;\n\n if (!endedAudioKey || !currentAudioKey) {\n return;\n }\n\n if (endedAudioKey !== currentAudioKey) {\n return;\n }\n\n const activeSequencePosition = currentAudioSequenceKeys.findIndex(\n (audioSequenceKey) => audioSequenceKey === endedAudioKey\n );\n if (activeSequencePosition < 0) {\n setCurrentAudioKey(null);\n return;\n }\n\n const nextSequencePosition = activeSequencePosition + 1;\n const nextAudioKey = currentAudioSequenceKeys[nextSequencePosition];\n\n if (nextAudioKey) {\n setCurrentAudioKey(nextAudioKey);\n return;\n }\n\n setCurrentAudioKey(null);\n setHasCompletedCurrentStepAudio(true);\n setIsAudioLoadingVisible(false);\n\n if (canGoNext) {\n const nextStepIndex = currentIndex + 1;\n const nextStepElement = slideElementList[nextStepIndex];\n\n if (hasCurrentStepAudioUrl && nextStepElement?.type === \"interaction\") {\n pendingInteractionOverlayStepIndexRef.current = nextStepIndex;\n }\n\n goNext();\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handleInteractionToggle = useCallback(() => {\n if (!activeInteractionElement) {\n return;\n }\n\n setIsInteractionOverlayOpen((prevOpen) => !prevOpen);\n }, [activeInteractionElement]);\n\n const stopOverlayPropagation = useCallback(\n (\n event:\n | React.PointerEvent<HTMLDivElement>\n | React.MouseEvent<HTMLDivElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerVisible) {\n showPlayerControls(true);\n }\n },\n [isPlayerVisible, showPlayerControls]\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n onPointerDown?.(event);\n },\n [onPointerDown]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n showPlayerControls(true);\n }, [showPlayerControls]);\n\n const currentRenderElementKeys = useMemo(\n () =>\n currentElementList.map(\n (element, index) =>\n `${element.sequence_number ?? `${element.type}-${index}`}:${String(element.is_new ?? \"\")}`\n ),\n [currentElementList]\n );\n\n useEffect(() => {\n const prevKeys = prevRenderElementKeysRef.current;\n const hasStablePrefix =\n prevKeys.length > 0 &&\n prevKeys.length < currentRenderElementKeys.length &&\n prevKeys.every((key, index) => key === currentRenderElementKeys[index]);\n const appendedElements = hasStablePrefix\n ? currentElementList.slice(prevKeys.length)\n : [];\n const shouldAutoScrollToAppend = appendedElements.some(\n (element) => element.is_new === false\n );\n\n prevRenderElementKeysRef.current = currentRenderElementKeys;\n\n if (!shouldAutoScrollToAppend) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n const stageLayerElement = stageLayerRef.current;\n const targetElement = lastElementRef.current;\n\n if (!stageLayerElement || !targetElement) {\n return;\n }\n\n const stageLayerRect = stageLayerElement.getBoundingClientRect();\n const targetRect = targetElement.getBoundingClientRect();\n const nextScrollTop =\n stageLayerElement.scrollTop + (targetRect.top - stageLayerRect.top);\n\n // Keep newly appended content visible when the current slide grows downward.\n stageLayerElement.scrollTo({\n top: Math.max(nextScrollTop, 0),\n behavior: \"smooth\",\n });\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, currentRenderElementKeys]);\n\n useEffect(() => {\n if (!shouldScrollToBottomRef.current) {\n return;\n }\n\n shouldScrollToBottomRef.current = false;\n\n if (currentElementList.length === 0) {\n return;\n }\n\n const animationFrameId = window.requestAnimationFrame(() => {\n scrollStageToBottom();\n });\n\n return () => {\n window.cancelAnimationFrame(animationFrameId);\n };\n }, [currentElementList, scrollStageToBottom]);\n\n return (\n <section\n ref={sectionRef}\n className={cn(\n \"relative h-full w-full\",\n isMobileDevice && \"slide--mobile-device\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n onClick={handleSurfaceClick}\n onPointerDown={handleSurfacePointerDown}\n {...props}\n >\n {shouldShowMobileFullscreenMask ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]\"\n />\n ) : null}\n\n <div\n ref={viewportRef}\n className={cn(\n \"slide__viewport relative h-full min-h-0 w-full\",\n isImmersiveMobileFullscreen && \"slide__viewport--mobile-landscape\",\n isImmersiveMobileFullscreen &&\n !shouldRotateFullscreenViewport &&\n \"slide__viewport--mobile-landscape-native\"\n )}\n >\n {shouldShowFullscreenHeader ? (\n <div className=\"slide-landscape-header\">\n <button\n aria-label={fullscreenHeader?.backAriaLabel ?? \"Back\"}\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft className=\"h-6 w-6 text-white\" strokeWidth={2.25} />\n </button>\n\n {fullscreenHeader?.content ? (\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n {fullscreenHeader.content}\n </div>\n ) : null}\n </div>\n ) : null}\n\n <div\n className={cn(\n \"h-full min-h-0 w-full\",\n shouldApplyFullscreenViewportPadding &&\n \"slide__viewport-content--with-header\",\n isSingleSlide ? \"slide-content--single\" : \"grid gap-4\"\n )}\n >\n {currentElementList.length > 0 ? (\n <div className=\"slide-stage\">\n <div ref={stageLayerRef} className=\"slide-stage__layer w-full\">\n {mountedStepStates.map(\n (mountedStepState, mountedStepStateIndex) => {\n const isActiveStep =\n mountedStepStateIndex === currentMountedStateIndex;\n\n return (\n <div\n key={\n mountedStepState.sourceStepIndexes[0] ??\n mountedStepStateIndex\n }\n aria-hidden={!isActiveStep || undefined}\n className=\"w-full h-full\"\n style={{ display: isActiveStep ? undefined : \"none\" }}\n >\n {renderSlideElementList(\n mountedStepState.elementList,\n isActiveStep\n )}\n </div>\n );\n }\n )}\n </div>\n </div>\n ) : null}\n </div>\n\n {isAudioLoadingVisible ? (\n <LoadingOverlayCard\n message={bufferingText}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SlideFullscreenHint\n onClose={handleFullscreenHintClose}\n open={isFullscreenHintOpen}\n text={fullscreenHintText}\n />\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerVisible}\n isEnabled={hasCurrentAudioPlaybackStarted}\n isPlayerHidden={shouldRenderPlayer && !playerVisible}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n className={cn(\n \"slide-interaction-overlay\",\n playerVisible && shouldRenderPlayer\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDown={stopOverlayPropagation}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n content={String(activeInteractionElement?.content ?? \"\")}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={interactionTexts?.confirmButtonText}\n copyButtonText={interactionTexts?.copyButtonText}\n copiedButtonText={interactionTexts?.copiedButtonText}\n onSend={handleInteractionSend}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n \"Submit the content below to continue.\"\n }\n />\n </div>\n ) : null}\n\n {shouldRenderPlayer ? (\n <Player\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 bottom-6 z-[2] -translate-x-1/2\",\n playerClassName,\n !playerVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n hasInteraction={Boolean(activeInteractionElement)}\n isInteractionOpen={isInteractionOverlayOpen}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\n onPlaybackTimeChange={playbackTimeStore.setTime}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onInteractionToggle={handleInteractionToggle}\n onNext={handleNext}\n onPrev={handlePrev}\n prevDisabled={!canGoPrev}\n showControls={playerVisible}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n ) : null}\n </div>\n </section>\n );\n};\n\nexport default Slide;\n"],"names":["DEFAULT_MARKER_AUTO_ADVANCE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_OPEN_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_FALLBACK_OFFSET_PX","DEFAULT_INTERACTION_SUBTITLE_GAP_PX","InteractionOverlayCard","memo","content","title","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","readonly","jsxs","jsx","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","Slide","elementList","showPlayer","playerAlwaysVisible","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","bufferingText","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","enableIframeScaling","className","onPointerDown","props","sectionRef","useRef","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","autoAdvanceTimerRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","playbackResetKeyRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","useSlide","currentStepElement","useMemo","isSingleSlide","shouldRenderPlayer","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","isAudioLoadingVisible","setIsAudioLoadingVisible","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","isFullscreenHintOpen","setIsFullscreenHintOpen","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerVisible","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","fullscreenHintText","DEFAULT_SLIDE_PLAYER_TEXTS","handleMobileViewModeSelect","useCallback","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","handleFullscreenHintClose","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previous","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","currentPlaybackStartedResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","clearPlayerHideTimer","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","clearAutoAdvanceTimer","resetAudioSequence","startCurrentAudioSequence","nextAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","showPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","shouldBlockPlaybackForInteraction","useEffect","syncViewportFullscreenPreference","subscribeMobileDeviceChange","shouldShowFullscreenHint","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","interactionDefaults","shouldPreferResolvedInteractionInput","getInteractionDefaultValues","interactionDefaultSelectedValues","getInteractionDefaultSelectedValues","hasResolvedInteractionInput","isInteractionReadonly","shouldAutoContinueInteraction","shouldShowInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","options","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","lastVisibleElementIndex","lastVisibleIndex","isPreRenderedHtml","cn","handleFullscreen","target","scrollStageToBottom","stageLayerElement","handlePrev","handleNext","handlePlayerLoadingChange","loading","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handleInteractionToggle","prevOpen","stopOverlayPropagation","handleSurfacePointerDown","handleSurfaceClick","currentRenderElementKeys","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SlideFullscreenHint","SubtitleOverlay","Player"],"mappings":"6uCAyDMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GAiCtCC,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,kBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,GACA,OAAAC,GACA,SAAAC,EAAW,EAAA,IAEXC,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,iCACb,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,mCACb,SAAAA,EAAAA,kBAAAA,IAAC,KAAE,UAAU,kCAAmC,WAAM,CAAA,CACxD,EACAA,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCACb,SAAAA,EAAAA,kBAAAA,IAACC,GAAAA,QAAA,CACC,QAAAZ,EACA,kBAAAE,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,GACA,OAAAC,GACA,SAAAC,EACA,iBAAkB,GAClB,YAAY,SAAA,CAAA,EAEhB,EACAE,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,iCAAA,CAAkC,CAAA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