markdown-flow-ui 0.2.25-dev.2 → 0.2.25-dev.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.
@@ -1 +1 @@
1
- {"version":3,"file":"Slide.cjs","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft, GripHorizontal } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport { useResolvedDirection } from \"../../lib/useResolvedDirection\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\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 type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport MarkdownSlideScaling from \"./MarkdownSlideScaling\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type {\n PlayerProps,\n SlidePlayerNavigationContext,\n SlidePlayerSubtitleJumpTarget,\n SlidePlayerSubtitleSeekRequest,\n SlidePlayerTexts,\n} from \"./Player\";\nimport type { SlidePlayerLoadingReason } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport { PlayerKeyboardShortcutContext } from \"./utils/playerKeyboardShortcutContext\";\nimport { activatePlayerKeyboardShortcutOwner } from \"./utils/playerKeyboardShortcuts\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport {\n clampInteractionOverlayDragOffset,\n shouldPresentInteractionOverlay,\n shouldRenderInteractionOverlay,\n type InteractionOverlayDragBounds,\n type InteractionOverlayDragOffset,\n} from \"./utils/interactionPlayback\";\nimport { resolveMarkdownScalingMode } from \"./utils/markdownScaling\";\nimport { shouldWakePlayerControlsAfterNavigation } from \"./utils/playerNavigationContext\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport { resolveRequestedStepNavigation } from \"./utils/requestedStepNavigation\";\nimport {\n hasUnplayedStepAudio,\n resolvePendingStepAudioKey,\n} from \"./utils/stepAudioProgress\";\nimport {\n getPlaybackSequenceTransition,\n shouldStartDefaultAudioSequence,\n} from \"./utils/playbackSequence\";\nimport {\n canReachSubtitleJumpTarget,\n hasResolvedInteractionElement,\n} from \"./utils/subtitleJumpNavigation\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { resolveSlideInteractionState } from \"./utils/interactionResolution\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport {\n areImageOnlyStepIframeVisualsReady,\n DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS,\n} from \"./utils/imageOnlyStepVisualReady\";\nimport { resolveSilentStepAutoAdvanceBehavior } from \"./utils/silentStepAutoAdvance\";\nimport {\n resolveSlidePlayerLayoutState,\n resolveSlidePlayerVisibility,\n type SlidePlayerControlsVisibility,\n} from \"./utils/playerVisibility\";\nimport {\n DEFAULT_SLIDE_BUFFERING_TEXTS,\n getSlideLocaleTexts,\n type SlideBufferingReason,\n} from \"./slideI18n\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nexport type { SlidePlayerControlsVisibility } from \"./utils/playerVisibility\";\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;\nconst DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS = 3000;\nconst DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET: InteractionOverlayDragOffset = {\n x: 0,\n y: 0,\n};\nconst INTERACTION_OVERLAY_LAYOUT_EPSILON_PX = 0.5;\ntype InteractionOverlayLayoutRect = Pick<DOMRect, \"left\" | \"top\">;\nconst useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\nconst INTERACTION_ACTIVITY_SELECTOR = [\n \"button\",\n \"input\",\n \"textarea\",\n '[contenteditable=\"\"]',\n '[contenteditable=\"true\"]',\n '[contenteditable=\"plaintext-only\"]',\n].join(\", \");\nconst DEFAULT_BUFFERING_REASON: SlideBufferingReason = \"waitingForAudio\";\n\nconst normalizeInteractionOverlayDragOffset = ({\n x,\n y,\n}: InteractionOverlayDragOffset): InteractionOverlayDragOffset => ({\n x: Number(x.toFixed(2)),\n y: Number(y.toFixed(2)),\n});\n\nconst hasMeaningfulInteractionOverlayLayoutDelta = (delta: number) =>\n Math.abs(delta) >= INTERACTION_OVERLAY_LAYOUT_EPSILON_PX;\n\nconst areInteractionOverlayDragOffsetsEqual = (\n first: InteractionOverlayDragOffset,\n second: InteractionOverlayDragOffset\n) =>\n Math.abs(first.x - second.x) < INTERACTION_OVERLAY_LAYOUT_EPSILON_PX &&\n Math.abs(first.y - second.y) < INTERACTION_OVERLAY_LAYOUT_EPSILON_PX;\n\nexport type { SlideBufferingReason } from \"./slideI18n\";\n\nexport type SlideBufferingTextConfig =\n | string\n | Partial<Record<SlideBufferingReason, string>>;\n\nconst resolveBufferingTextByReason = (\n bufferingText: SlideBufferingTextConfig,\n reason: SlideBufferingReason\n) => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return (\n bufferingText[reason] ??\n bufferingText[DEFAULT_BUFFERING_REASON] ??\n DEFAULT_SLIDE_BUFFERING_TEXTS[reason]\n );\n};\n\nconst mergeBufferingTextWithLocaleDefaults = (\n bufferingText: SlideBufferingTextConfig | undefined,\n localeBufferingText: Record<string, string>\n): SlideBufferingTextConfig => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return {\n ...localeBufferingText,\n ...bufferingText,\n };\n};\n\nconst shouldShowBufferingOverlay = (\n reason: SlideBufferingReason | null,\n loading: boolean\n) => {\n if (!loading) {\n return false;\n }\n\n // Keep the silent preload/loading phase invisible until audio is actually playable.\n return reason !== \"loadingAudio\";\n};\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n dir?: ContentRenderProps[\"dir\"];\n lang?: string;\n content: string;\n title: string;\n dragHandleAriaLabel: string;\n locale?: MarkdownFlowLocale;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n onDragHandlePointerCancel?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerDown?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerMove?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerUp?: React.PointerEventHandler<HTMLButtonElement>;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n /** Accessible label for the interaction panel drag handle. */\n dragHandleAriaLabel?: 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 dragHandleAriaLabel,\n locale,\n dir,\n lang,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n onDragHandlePointerCancel,\n onDragHandlePointerDown,\n onDragHandlePointerMove,\n onDragHandlePointerUp,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <button\n type=\"button\"\n className=\"slide-player__interaction-drag-handle\"\n aria-label={dragHandleAriaLabel}\n onPointerCancel={onDragHandlePointerCancel}\n onPointerDown={onDragHandlePointerDown}\n onPointerMove={onDragHandlePointerMove}\n onPointerUp={onDragHandlePointerUp}\n >\n <span className=\"slide-player__interaction-drag-handle-icon\">\n <GripHorizontal aria-hidden=\"true\" />\n <GripHorizontal aria-hidden=\"true\" />\n <GripHorizontal aria-hidden=\"true\" />\n </span>\n </button>\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 locale={locale}\n dir={dir}\n lang={lang}\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 sandboxMode=\"content\"\n />\n </div>\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\nconst isInteractionActivityTarget = (\n target: EventTarget | null\n): target is HTMLElement =>\n target instanceof HTMLElement &&\n Boolean(target.closest(INTERACTION_ACTIVITY_SELECTOR));\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Enables the player runtime, including audio playback and keyboard shortcuts. */\n playerEnabled?: boolean;\n /**\n * Controls whether the player controls are always visible, always hidden, or auto-hidden.\n *\n * Use `\"hidden\"` to keep audio playback and keyboard shortcuts active while\n * hiding the visual controls.\n *\n * @example\n * ```tsx\n * <Slide playerControlsVisibility=\"hidden\" enableKeyboardShortcuts />\n * ```\n */\n playerControlsVisibility?: SlidePlayerControlsVisibility;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: SlideBufferingTextConfig;\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 /**\n * Requests navigation to a slide step from the consuming application.\n * The player still reports the resulting step through `onStepChange`.\n */\n requestedStepIndex?: number;\n /**\n * Enables keyboard shortcuts for existing player actions.\n *\n * Defaults to `true`. The active slide responds after users click, touch, or\n * focus the slide/player surface; ignored targets include form controls and\n * interaction overlays.\n *\n * @example\n * ```tsx\n * <Slide elementList={slides} enableKeyboardShortcuts={false} />\n * ```\n */\n enableKeyboardShortcuts?: boolean;\n enableIframeScaling?: boolean;\n /**\n * Fits Markdown-only slides to the available presentation viewport.\n *\n * Defaults to `true`. Disable this to preserve the fixed 16px article\n * typography used by standalone ContentRender.\n */\n enableMarkdownScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n locale,\n playerEnabled,\n playerControlsVisibility,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText,\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 requestedStepIndex,\n enableKeyboardShortcuts = true,\n enableIframeScaling = true,\n enableMarkdownScaling = true,\n disableLoadingOverlay = false,\n className,\n dir,\n lang,\n onPointerDown,\n onFocusCapture,\n ...props\n}) => {\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const localeTexts = useMemo(() => getSlideLocaleTexts(locale), [locale]);\n const resolvedBufferingText = useMemo(\n () =>\n mergeBufferingTextWithLocaleDefaults(\n bufferingText,\n localeTexts.bufferingText\n ),\n [bufferingText, localeTexts.bufferingText]\n );\n const {\n playerEnabled: resolvedPlayerEnabled,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n } = resolveSlidePlayerVisibility({\n playerEnabled,\n playerControlsVisibility,\n });\n const keyboardShortcutOwnerId = useId();\n const sectionRef = useRef<HTMLElement | null>(null);\n const { resolvedDirection } = useResolvedDirection(sectionRef, direction);\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 isPointerInsidePlayerControlsRef = useRef(false);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const imageOnlyStepReadyTimeoutRef = 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 interactionOverlayLayoutRectRef =\n useRef<InteractionOverlayLayoutRect | null>(null);\n const interactionOverlayDragRef = useRef<{\n pointerId: number;\n startClientX: number;\n startClientY: number;\n startOffset: InteractionOverlayDragOffset;\n bounds: InteractionOverlayDragBounds;\n } | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const pendingSubtitleJumpRef = useRef<{\n audioIndex: number;\n audioKey: string;\n slideIndex: number;\n timeMs: number;\n } | null>(null);\n const subtitleSeekRequestIdRef = useRef(0);\n const playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const shouldSkipDefaultAudioStartForSubtitleJumpRef = useRef(false);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n audioSlideIndexes,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n handleGoTo: goTo,\n } = useSlide(elementList);\n const lastRequestedStepIndexRef = useRef<number | null>(null);\n const requestedStepNavigation = useMemo(\n () =>\n resolveRequestedStepNavigation({\n currentStepIndex: currentIndex,\n requestedStepIndex,\n slideStepCount: slideElementList.length,\n }),\n [currentIndex, requestedStepIndex, slideElementList.length]\n );\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\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 const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldMountPlayer =\n resolvedPlayerEnabled &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const keyboardShortcutContextValue = useMemo(\n () => ({\n enabled: enableKeyboardShortcuts,\n ownerId: keyboardShortcutOwnerId,\n }),\n [enableKeyboardShortcuts, keyboardShortcutOwnerId]\n );\n const activateKeyboardShortcutOwner = useCallback(() => {\n if (!enableKeyboardShortcuts || !shouldMountPlayer) {\n return;\n }\n\n activatePlayerKeyboardShortcutOwner(keyboardShortcutOwnerId);\n }, [enableKeyboardShortcuts, keyboardShortcutOwnerId, shouldMountPlayer]);\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 [isPlaybackRequested, setIsPlaybackRequested] = useState(true);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [subtitleSeekRequest, setSubtitleSeekRequest] =\n useState<SlidePlayerSubtitleSeekRequest | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [audioLoadingReason, setAudioLoadingReason] =\n useState<SlideBufferingReason>(DEFAULT_BUFFERING_REASON);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n // Audio keys already played within the current step. A step's audio arrives\n // progressively while content is still being generated, so \"completed\" has to\n // mean \"every key played\" rather than \"reached the end of the list once\".\n const playedAudioKeysRef = useRef<Set<string>>(new Set());\n const [hasCurrentAudioPlaybackStarted, setHasCurrentAudioPlaybackStarted] =\n useState(false);\n const [isSubtitleEnabled, setIsSubtitleEnabled] = useState(true);\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 [hasInteractionOverlayActivity, setHasInteractionOverlayActivity] =\n useState(false);\n const [interactionOverlayDragOffset, setInteractionOverlayDragOffset] =\n useState<InteractionOverlayDragOffset>(\n DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET\n );\n const [isInteractionOverlayDragging, setIsInteractionOverlayDragging] =\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 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 {\n controlsVisible: playerControlsVisible,\n layoutReserved: playerLayoutReserved,\n } = resolveSlidePlayerLayoutState({\n isAutoVisible: isPlayerVisible,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n });\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerLayoutReserved;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const isDesktopBrowserFullscreen = isBrowserFullscreen && !isMobileDevice;\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\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 closeInteractionOverlayForCustomAction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [clearInteractionAutoCloseTimer, clearInteractionOverlayOpenTimer]);\n\n const setPlayerCustomActionActive = useCallback(\n (active: boolean) => {\n if (active) {\n closeInteractionOverlayForCustomAction();\n }\n\n setIsPlayerCustomActionActive(active);\n },\n [closeInteractionOverlayForCustomAction]\n );\n const togglePlayerCustomActionActive = useCallback(() => {\n closeInteractionOverlayForCustomAction();\n setIsPlayerCustomActionActive((previousActive) => !previousActive);\n }, [closeInteractionOverlayForCustomAction]);\n const resetInteractionOverlayDragState = useCallback(() => {\n setInteractionOverlayDragOffset((previousOffset) =>\n previousOffset.x === DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET.x &&\n previousOffset.y === DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET.y\n ? previousOffset\n : DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET\n );\n setIsInteractionOverlayDragging(false);\n interactionOverlayDragRef.current = null;\n interactionOverlayLayoutRectRef.current = null;\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 hasPlayerCustomActions = playerCustomActionCount > 0;\n const isPlayerCustomActionEffectivelyActive =\n hasPlayerCustomActions && isPlayerCustomActionActive;\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 \"--slide-interaction-drag-x\": `${interactionOverlayDragOffset.x}px`,\n \"--slide-interaction-drag-y\": `${interactionOverlayDragOffset.y}px`,\n }) as React.CSSProperties,\n [\n interactionOverlayDragOffset.x,\n interactionOverlayDragOffset.y,\n playerCustomActionCount,\n ]\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 && isPlayerCustomActionEffectivelyActive;\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 const silentStepAutoAdvanceBehavior = useMemo(\n () =>\n resolveSilentStepAutoAdvanceBehavior({\n currentElementList,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n markerAutoAdvanceDelay,\n }),\n [\n currentElementList,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n ]\n );\n const silentStepAutoAdvanceDelay = silentStepAutoAdvanceBehavior.delayMs;\n const isImageOnlySilentStep =\n silentStepAutoAdvanceBehavior.usesImageOnlyDelay;\n const imageOnlyStepVisualReadyKey = useMemo(\n () => `${currentIndex}:${currentRenderElementKeys.join(\"|\")}`,\n [currentIndex, currentRenderElementKeys]\n );\n const [readyImageOnlyStepKey, setReadyImageOnlyStepKey] = useState<\n string | null\n >(null);\n const isImageOnlyStepVisualReady =\n !isImageOnlySilentStep ||\n readyImageOnlyStepKey === imageOnlyStepVisualReadyKey;\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 clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const clearImageOnlyStepReadyTimeout = useCallback(() => {\n if (imageOnlyStepReadyTimeoutRef.current === null) {\n return;\n }\n\n window.clearTimeout(imageOnlyStepReadyTimeoutRef.current);\n imageOnlyStepReadyTimeoutRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(\n (\n options: {\n preservePendingSubtitleJump?: boolean;\n } = {}\n ) => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n clearImageOnlyStepReadyTimeout();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setAudioLoadingReason(DEFAULT_BUFFERING_REASON);\n setHasCompletedCurrentStepAudio(false);\n playedAudioKeysRef.current = new Set();\n setHasCurrentAudioPlaybackStarted(false);\n setSubtitleSeekRequest(null);\n if (!options.preservePendingSubtitleJump) {\n pendingSubtitleJumpRef.current = null;\n }\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n },\n [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]\n );\n\n const requestSubtitleCueSeek = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) => {\n subtitleSeekRequestIdRef.current += 1;\n setSubtitleSeekRequest({\n ...target,\n id: subtitleSeekRequestIdRef.current,\n });\n },\n []\n );\n\n const startCurrentAudioSequence = useCallback(() => {\n // Resume at the first key that has not played yet. Falling back to index 0\n // unconditionally would replay the opening segment every time late audio\n // extends the current step.\n const nextAudioKey = resolvePendingStepAudioKey(\n currentAudioSequenceKeys,\n playedAudioKeysRef.current\n );\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first pending 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 isPlayerControlsHovered = useCallback(\n () =>\n isPointerInsidePlayerControlsRef.current ||\n Boolean(\n sectionRef.current?.querySelector(\".slide-player__controls:hover\")\n ),\n []\n );\n\n const revealPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (\n resolvedPlayerControlsVisibility === \"visible\" ||\n !enableAutoHide ||\n playerAutoHideDelay <= 0 ||\n isPlayerControlsHovered()\n ) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n if (isPlayerControlsHovered()) {\n playerHideTimerRef.current = null;\n return;\n }\n\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n isPlayerControlsHovered,\n playerAutoHideDelay,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n hasResolvedInteractionElement(currentInteractionElement)\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n const handlePlaybackPreferenceChange = useCallback((playing: boolean) => {\n setIsPlaybackRequested(playing);\n }, []);\n\n const syncPlaybackPreferenceBeforeNavigation = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n if (context) {\n setIsPlaybackRequested(context.shouldContinuePlayback);\n }\n },\n []\n );\n\n useEffect(() => {\n // Keep silent-step autoplay aligned with the same play/pause preference as audio.\n setIsAutoAdvanceEnabled(isPlaybackRequested);\n }, [currentIndex, isPlaybackRequested, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n if (playerCustomActionPauseOnActive) {\n setPlayerCustomActionActive(false);\n }\n }, [\n currentIndex,\n playerCustomActionPauseOnActive,\n setPlayerCustomActionActive,\n ]);\n\n useEffect(() => {\n if (!hasPlayerCustomActions) {\n setIsPlayerCustomActionActive(false);\n }\n }, [hasPlayerCustomActions]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearImageOnlyStepReadyTimeout();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n if (!isImageOnlySilentStep) {\n clearImageOnlyStepReadyTimeout();\n return;\n }\n\n let cancelled = false;\n let rafId: number | null = null;\n let cleanupListeners: (() => void) | null = null;\n\n const detachListeners = () => {\n cleanupListeners?.();\n cleanupListeners = null;\n };\n\n const finishVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n setReadyImageOnlyStepKey(imageOnlyStepVisualReadyKey);\n };\n\n const evaluateVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n\n const activeStepContainer = stageLayerRef.current?.querySelector(\n '[data-active-step=\"true\"]'\n ) as HTMLElement | null;\n\n if (!activeStepContainer) {\n return;\n }\n\n const iframeElements = Array.from(\n activeStepContainer.querySelectorAll(\"iframe\")\n ) as HTMLIFrameElement[];\n\n if (\n iframeElements.length === 0 ||\n areImageOnlyStepIframeVisualsReady(iframeElements)\n ) {\n finishVisualReady();\n return;\n }\n\n const cleanupCallbacks: Array<() => void> = [];\n const queueRecheck = () => {\n if (cancelled) {\n return;\n }\n\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n };\n const registerEvent = (\n target: EventTarget,\n eventName: string,\n listener: EventListener\n ) => {\n target.addEventListener(eventName, listener, { once: true });\n cleanupCallbacks.push(() =>\n target.removeEventListener(eventName, listener)\n );\n };\n\n iframeElements.forEach((iframeElement) => {\n const iframeDocument = iframeElement.contentDocument;\n\n if (!iframeDocument || iframeDocument.readyState !== \"complete\") {\n registerEvent(iframeElement, \"load\", queueRecheck);\n return;\n }\n\n Array.from(iframeDocument.images)\n .filter((image) => !image.complete)\n .forEach((image) => {\n registerEvent(image, \"load\", queueRecheck);\n registerEvent(image, \"error\", queueRecheck);\n });\n });\n\n cleanupListeners = () => {\n cleanupCallbacks.forEach((cleanup) => cleanup());\n };\n };\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n\n imageOnlyStepReadyTimeoutRef.current = window.setTimeout(() => {\n finishVisualReady();\n }, DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS);\n\n return () => {\n cancelled = true;\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n };\n }, [\n clearImageOnlyStepReadyTimeout,\n currentElementList,\n currentIndex,\n imageOnlyStepVisualReadyKey,\n isImageOnlySilentStep,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerControlsVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerControlsVisible]);\n\n useEffect(() => {\n if (playerControlsVisible) {\n return;\n }\n\n isPointerInsidePlayerControlsRef.current = false;\n }, [playerControlsVisible]);\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 resetInteractionOverlayDragState();\n };\n const handleOrientationChange = () => {\n resetInteractionOverlayDragState();\n };\n\n syncViewportFullscreenPreference();\n window.addEventListener(\"orientationchange\", handleOrientationChange);\n window.screen?.orientation?.addEventListener?.(\n \"change\",\n handleOrientationChange\n );\n const unsubscribeMobileDeviceChange = subscribeMobileDeviceChange(\n syncViewportFullscreenPreference\n );\n\n return () => {\n unsubscribeMobileDeviceChange();\n window.removeEventListener(\"orientationchange\", handleOrientationChange);\n window.screen?.orientation?.removeEventListener?.(\n \"change\",\n handleOrientationChange\n );\n };\n }, [isMobileDevice, resetInteractionOverlayDragState]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n if (\n previousEffectiveMobileViewModeRef.current !== effectiveMobileViewMode\n ) {\n resetInteractionOverlayDragState();\n }\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n }, [effectiveMobileViewMode, resetInteractionOverlayDragState]);\n\n useLayoutEffect(() => {\n if (!requestedStepNavigation) {\n lastRequestedStepIndexRef.current = null;\n return;\n }\n\n if (!requestedStepNavigation.isAvailable) {\n lastRequestedStepIndexRef.current = null;\n return;\n }\n\n const { targetStepIndex } = requestedStepNavigation;\n\n if (lastRequestedStepIndexRef.current === targetStepIndex) {\n return;\n }\n\n lastRequestedStepIndexRef.current = targetStepIndex;\n goTo(targetStepIndex);\n }, [goTo, requestedStepNavigation]);\n\n useEffect(() => {\n if (requestedStepNavigation?.isPending) {\n return;\n }\n\n onStepChange?.(currentStepElement, currentIndex);\n }, [\n currentIndex,\n currentStepElement,\n onStepChange,\n requestedStepNavigation?.isPending,\n ]);\n\n useEffect(() => {\n const previousState = appendedMarkerAdvanceStateRef.current;\n const shouldAdvanceIntoAppendedMarker = shouldAutoAdvanceIntoAppendedMarker(\n {\n previousMarkerCount: previousState.markerCount,\n nextMarkerCount: slideElementList.length,\n previousIndex: previousState.currentIndex,\n previousCanGoNext: previousState.canGoNext,\n nextCanGoNext: canGoNext,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n }\n );\n\n appendedMarkerAdvanceStateRef.current = {\n markerCount: slideElementList.length,\n currentIndex,\n canGoNext,\n };\n\n if (!shouldAdvanceIntoAppendedMarker) {\n return;\n }\n\n goNext();\n }, [\n canGoNext,\n currentAudioKey,\n currentIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n goNext,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n slideElementList.length,\n ]);\n\n useEffect(() => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (resolvedPlayerControlsVisibility === \"visible\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n revealPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n revealPlayerControls,\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 (!shouldMountPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [activateKeyboardShortcutOwner, shouldMountPlayer, revealPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldMountPlayer,\n keyboardShortcutsEnabled: enableKeyboardShortcuts,\n onKeyboardShortcut: activateKeyboardShortcutOwner,\n onWake: () => {\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n },\n });\n\n useEffect(() => {\n if (!shouldMountPlayer) {\n resetAudioSequence();\n return;\n }\n\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 isPlayerCustomActionActive: isPlayerCustomActionEffectivelyActive,\n });\n\n const pendingSubtitleJump = pendingSubtitleJumpRef.current;\n const shouldPreservePendingSubtitleJump =\n pendingSubtitleJump?.slideIndex === currentIndex;\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence({\n preservePendingSubtitleJump: shouldPreservePendingSubtitleJump,\n });\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (pendingSubtitleJump?.slideIndex === currentIndex) {\n if (\n !canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: pendingSubtitleJump.slideIndex,\n })\n ) {\n // Keep the pending seek queued while the interaction overlay gates playback.\n } else {\n pendingSubtitleJumpRef.current = null;\n // The default audio-start effect still sees the pre-seek render state.\n // Skip it once so it does not replace the subtitle target audio.\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = true;\n setCurrentAudioKey(pendingSubtitleJump.audioKey);\n requestSubtitleCueSeek({\n audioIndex: pendingSubtitleJump.audioIndex,\n timeMs: pendingSubtitleJump.timeMs,\n });\n return;\n }\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 // A custom action may intentionally remain active without pausing ordinary\n // playback. Unresolved interactions still gate progression even while that\n // action temporarily owns the visible overlay surface.\n if (shouldBlockPlaybackForInteraction) {\n return;\n }\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n if (isImageOnlySilentStep && !isImageOnlyStepVisualReady) {\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 }, silentStepAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n activeInteractionElement,\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentIndex,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n isImageOnlySilentStep,\n isImageOnlyStepVisualReady,\n silentStepAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n isPlayerCustomActionEffectivelyActive,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n requestSubtitleCueSeek,\n scheduleInteractionOverlayOpen,\n shouldMountPlayer,\n slideElementList,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n disableLoadingOverlay ||\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 setAudioLoadingReason(\"waitingForAudio\");\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n // A step's audio can keep arriving after the last available segment finished,\n // because narration is synthesized while the lesson is still streaming. The\n // step-completed flag is otherwise only cleared when the reset key changes -\n // which tracks the step index and the interaction content, neither of which\n // moves while new audio is appended to the step the learner is already on.\n // Without this, everything synthesized after that first gap stays silent.\n useEffect(() => {\n if (!hasCompletedCurrentStepAudio) {\n return;\n }\n\n if (\n !hasUnplayedStepAudio(\n currentAudioSequenceKeys,\n playedAudioKeysRef.current\n )\n ) {\n return;\n }\n\n setHasCompletedCurrentStepAudio(false);\n }, [currentAudioSequenceKeys, hasCompletedCurrentStepAudio]);\n\n useEffect(() => {\n const shouldSkipDefaultAudioStart =\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current;\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = false;\n\n if (\n !shouldStartDefaultAudioSequence({\n currentAudioKey,\n currentAudioSequenceLength: currentAudioSequenceKeys.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n shouldPausePlaybackForCustomAction,\n shouldSkipDefaultAudioStart,\n })\n ) {\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 {\n interactionDefaults,\n interactionDefaultSelectedValues,\n hasResolvedInteractionInput,\n isInteractionReadonly: resolvedInteractionReadonly,\n shouldAutoContinueInteraction,\n } = useMemo(\n () =>\n resolveSlideInteractionState(activeInteractionElement, {\n interactionDefaultValueOptions,\n }),\n [activeInteractionElement, interactionDefaultValueOptions]\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || resolvedInteractionReadonly;\n const shouldShowInteractionOverlay = shouldRenderInteractionOverlay({\n hasActiveInteraction: Boolean(activeInteractionElement),\n isInteractionOverlayOpen,\n });\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 (activeInteractionElement && isInteractionOverlayOpen) {\n return;\n }\n\n setHasInteractionOverlayActivity(false);\n }, [activeInteractionElement, isInteractionOverlayOpen]);\n\n useEffect(() => {\n resetInteractionOverlayDragState();\n }, [activeInteractionElement, resetInteractionOverlayDragState]);\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) {\n return;\n }\n\n if (shouldAutoContinueInteraction) {\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }\n\n if (hasInteractionOverlayActivity || !hasResolvedInteractionInput) {\n return;\n }\n\n // Give resolved history interactions a short revisit window before\n // playback resumes, but stop auto-closing once the learner starts editing.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n hasInteractionOverlayActivity,\n hasResolvedInteractionInput,\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 disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n dir={direction}\n lang={language}\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 disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n dir={direction}\n lang={language}\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 markdownScalingMode =\n isActiveStep && enableMarkdownScaling\n ? resolveMarkdownScalingMode(elementList)\n : \"disabled\";\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <MarkdownSlideScaling\n className=\"slide-stage__content flex w-full flex-col gap-4\"\n mode={markdownScalingMode}\n >\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 </MarkdownSlideScaling>\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 canJumpToSubtitleTarget = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) =>\n canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: audioSlideIndexes[target.audioIndex],\n }),\n [\n activeInteractionElement,\n audioSlideIndexes,\n currentIndex,\n slideElementList,\n ]\n );\n\n const handleSubtitleJump = useCallback(\n (\n target: SlidePlayerSubtitleJumpTarget,\n context: SlidePlayerNavigationContext\n ) => {\n const targetAudio = audioList[target.audioIndex];\n const targetAudioKey = targetAudio?.audioKey;\n const targetSlideIndex = audioSlideIndexes[target.audioIndex];\n\n if (!targetAudioKey || targetSlideIndex == null) {\n return false;\n }\n\n if (!canJumpToSubtitleTarget(target)) {\n return false;\n }\n\n syncPlaybackPreferenceBeforeNavigation(context);\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n\n if (targetSlideIndex === currentIndex) {\n pendingSubtitleJumpRef.current = null;\n resetAudioSequence();\n setCurrentAudioKey(targetAudioKey);\n requestSubtitleCueSeek(target);\n return true;\n }\n\n shouldScrollToBottomRef.current = true;\n resetAudioSequence();\n pendingSubtitleJumpRef.current = {\n audioIndex: target.audioIndex,\n audioKey: targetAudioKey,\n slideIndex: targetSlideIndex,\n timeMs: target.timeMs,\n };\n goTo(targetSlideIndex);\n\n return true;\n },\n [\n audioList,\n audioSlideIndexes,\n canJumpToSubtitleTarget,\n currentIndex,\n goTo,\n requestSubtitleCueSeek,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePrev = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goPrev();\n },\n [\n goPrev,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handleNext = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goNext();\n },\n [\n goNext,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePlayerLoadingChange = useCallback(\n ({\n loading,\n reason,\n }: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (loading && reason) {\n setAudioLoadingReason(reason);\n }\n setIsAudioLoadingVisible(shouldShowBufferingOverlay(reason, loading));\n },\n [\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n ]\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n setIsAudioLoadingVisible(false);\n }, [disableLoadingOverlay]);\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 playedAudioKeysRef.current.add(endedAudioKey);\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 return;\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handlePlayerControlsPointerEnter = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = true;\n clearPlayerHideTimer();\n\n if (shouldMountPlayer) {\n setIsPlayerVisible(true);\n }\n }, [clearPlayerHideTimer, shouldMountPlayer]);\n\n const handlePlayerControlsPointerLeave = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = false;\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n\n const stopOverlayPropagation = useCallback(\n (\n event: React.PointerEvent<HTMLElement> | React.MouseEvent<HTMLElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerControlsVisible) {\n revealPlayerControls(true);\n }\n },\n [playerControlsVisible, revealPlayerControls]\n );\n\n const getInteractionOverlayDragBounds = useCallback(\n (\n overlayElement: HTMLElement,\n startOffset: InteractionOverlayDragOffset\n ): InteractionOverlayDragBounds | null => {\n const viewportElement = viewportRef.current;\n\n if (!viewportElement) {\n return null;\n }\n\n const overlayRect = overlayElement.getBoundingClientRect();\n const viewportRect = viewportElement.getBoundingClientRect();\n\n return {\n minX: startOffset.x + viewportRect.left - overlayRect.left,\n maxX: startOffset.x + viewportRect.right - overlayRect.right,\n minY: startOffset.y + viewportRect.top - overlayRect.top,\n maxY: startOffset.y + viewportRect.bottom - overlayRect.bottom,\n };\n },\n []\n );\n\n useIsomorphicLayoutEffect(() => {\n const overlayElement = interactionOverlayRef.current;\n\n if (!shouldShowInteractionOverlay || !overlayElement) {\n interactionOverlayLayoutRectRef.current = null;\n return;\n }\n\n const previousRect = interactionOverlayLayoutRectRef.current;\n const currentRect = overlayElement.getBoundingClientRect();\n\n if (!previousRect || isInteractionOverlayDragging) {\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left,\n top: currentRect.top,\n };\n return;\n }\n\n const deltaX = previousRect.left - currentRect.left;\n const deltaY = previousRect.top - currentRect.top;\n\n if (\n !hasMeaningfulInteractionOverlayLayoutDelta(deltaX) &&\n !hasMeaningfulInteractionOverlayLayoutDelta(deltaY)\n ) {\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left,\n top: currentRect.top,\n };\n return;\n }\n\n const nextOffset = {\n x: interactionOverlayDragOffset.x + deltaX,\n y: interactionOverlayDragOffset.y + deltaY,\n };\n const bounds = getInteractionOverlayDragBounds(\n overlayElement,\n interactionOverlayDragOffset\n );\n const clampedOffset = normalizeInteractionOverlayDragOffset(\n bounds\n ? clampInteractionOverlayDragOffset(nextOffset, bounds)\n : nextOffset\n );\n\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left + clampedOffset.x - interactionOverlayDragOffset.x,\n top: currentRect.top + clampedOffset.y - interactionOverlayDragOffset.y,\n };\n\n if (\n !areInteractionOverlayDragOffsetsEqual(\n clampedOffset,\n interactionOverlayDragOffset\n )\n ) {\n setInteractionOverlayDragOffset((previousOffset) =>\n areInteractionOverlayDragOffsetsEqual(previousOffset, clampedOffset)\n ? previousOffset\n : clampedOffset\n );\n }\n }, [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n isInteractionOverlayDragging,\n playerLayoutReserved,\n shouldShowInteractionOverlay,\n ]);\n\n const handleInteractionOverlayPointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n stopOverlayPropagation(event);\n\n if (\n event.button !== 0 ||\n !event.currentTarget.isConnected ||\n !interactionOverlayRef.current\n ) {\n return;\n }\n\n const bounds = getInteractionOverlayDragBounds(\n interactionOverlayRef.current,\n interactionOverlayDragOffset\n );\n\n if (!bounds) {\n return;\n }\n\n event.preventDefault();\n if (event.currentTarget.hasPointerCapture?.(event.pointerId) !== true) {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n interactionOverlayDragRef.current = {\n pointerId: event.pointerId,\n startClientX: event.clientX,\n startClientY: event.clientY,\n startOffset: interactionOverlayDragOffset,\n bounds,\n };\n setIsInteractionOverlayDragging(true);\n },\n [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n stopOverlayPropagation,\n ]\n );\n\n const handleInteractionOverlayPointerMove = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n setInteractionOverlayDragOffset(\n clampInteractionOverlayDragOffset(\n {\n x: dragState.startOffset.x + event.clientX - dragState.startClientX,\n y: dragState.startOffset.y + event.clientY - dragState.startClientY,\n },\n dragState.bounds\n )\n );\n },\n []\n );\n\n const endInteractionOverlayDrag = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.stopPropagation();\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n interactionOverlayDragRef.current = null;\n setIsInteractionOverlayDragging(false);\n },\n []\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onPointerDown?.(event);\n },\n [activateKeyboardShortcutOwner, onPointerDown]\n );\n\n const handleSurfaceFocusCapture = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onFocusCapture?.(event);\n },\n [activateKeyboardShortcutOwner, onFocusCapture]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }, [revealPlayerControls]);\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 isDesktopBrowserFullscreen && \"slide--browser-fullscreen\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n dir={direction}\n lang={language}\n onClick={handleSurfaceClick}\n onFocusCapture={handleSurfaceFocusCapture}\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={\n fullscreenHeader?.backAriaLabel ??\n localeTexts.fullscreenBackAriaLabel\n }\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft\n className=\"slide-landscape-header__icon h-6 w-6\"\n strokeWidth={2.25}\n />\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 data-active-step={isActiveStep ? \"true\" : undefined}\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={resolveBufferingTextByReason(\n resolvedBufferingText,\n audioLoadingReason\n )}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerLayoutReserved}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n data-player-keyboard-shortcuts-ignore=\"true\"\n className={cn(\n \"slide-interaction-overlay\",\n playerLayoutReserved\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\",\n isInteractionOverlayDragging &&\n \"slide-interaction-overlay--dragging\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDownCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onFocusCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onInputCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n dir={direction}\n lang={language}\n content={String(activeInteractionElement?.content ?? \"\")}\n dragHandleAriaLabel={\n interactionTexts?.dragHandleAriaLabel ??\n localeTexts.interactionTexts.dragHandleAriaLabel\n }\n locale={locale}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={\n interactionTexts?.confirmButtonText ??\n localeTexts.interactionTexts.confirmButtonText\n }\n copyButtonText={\n interactionTexts?.copyButtonText ??\n localeTexts.interactionTexts.copyButtonText\n }\n copiedButtonText={\n interactionTexts?.copiedButtonText ??\n localeTexts.interactionTexts.copiedButtonText\n }\n onSend={handleInteractionSend}\n onDragHandlePointerCancel={endInteractionOverlayDrag}\n onDragHandlePointerDown={handleInteractionOverlayPointerDown}\n onDragHandlePointerMove={handleInteractionOverlayPointerMove}\n onDragHandlePointerUp={endInteractionOverlayDrag}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n localeTexts.interactionTexts.title\n }\n />\n </div>\n ) : null}\n\n {shouldMountPlayer ? (\n <PlayerKeyboardShortcutContext.Provider\n value={keyboardShortcutContextValue}\n >\n <Player\n dir={direction === \"auto\" ? resolvedDirection : direction}\n lang={language}\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 z-[2] -translate-x-1/2\",\n isDesktopBrowserFullscreen ? \"bottom-3\" : \"-bottom-3\",\n playerClassName,\n !playerControlsVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying={isPlaybackRequested}\n enableKeyboardShortcuts={enableKeyboardShortcuts}\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n locale={locale}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\n onPlaybackPreferenceChange={handlePlaybackPreferenceChange}\n onPlaybackTimeChange={playbackTimeStore.setTime}\n onSubtitleToggle={() => {\n setIsSubtitleEnabled((previousEnabled) => !previousEnabled);\n }}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onControlsPointerEnter={handlePlayerControlsPointerEnter}\n onControlsPointerLeave={handlePlayerControlsPointerLeave}\n onNext={handleNext}\n onPrev={handlePrev}\n onSubtitleJump={handleSubtitleJump}\n canJumpToSubtitleTarget={canJumpToSubtitleTarget}\n prevDisabled={!canGoPrev}\n showControls={playerControlsVisible}\n subtitleSeekRequest={subtitleSeekRequest}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n </PlayerKeyboardShortcutContext.Provider>\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","DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET","INTERACTION_OVERLAY_LAYOUT_EPSILON_PX","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","INTERACTION_ACTIVITY_SELECTOR","DEFAULT_BUFFERING_REASON","normalizeInteractionOverlayDragOffset","x","y","hasMeaningfulInteractionOverlayLayoutDelta","delta","areInteractionOverlayDragOffsetsEqual","first","second","resolveBufferingTextByReason","bufferingText","reason","DEFAULT_SLIDE_BUFFERING_TEXTS","mergeBufferingTextWithLocaleDefaults","localeBufferingText","shouldShowBufferingOverlay","loading","InteractionOverlayCard","memo","content","title","dragHandleAriaLabel","locale","dir","lang","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","onDragHandlePointerCancel","onDragHandlePointerDown","onDragHandlePointerMove","onDragHandlePointerUp","readonly","jsxs","jsx","GripHorizontal","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","isInteractionActivityTarget","target","Slide","elementList","playerEnabled","playerControlsVisibility","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","requestedStepIndex","enableKeyboardShortcuts","enableIframeScaling","enableMarkdownScaling","disableLoadingOverlay","className","onPointerDown","onFocusCapture","props","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","localeTexts","useMemo","getSlideLocaleTexts","resolvedBufferingText","resolvedPlayerEnabled","resolvedPlayerControlsVisibility","resolveSlidePlayerVisibility","keyboardShortcutOwnerId","useId","sectionRef","useRef","resolvedDirection","useResolvedDirection","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","isPointerInsidePlayerControlsRef","autoAdvanceTimerRef","imageOnlyStepReadyTimeoutRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","interactionOverlayLayoutRectRef","interactionOverlayDragRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","pendingSubtitleJumpRef","subtitleSeekRequestIdRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","shouldSkipDefaultAudioStartForSubtitleJumpRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","audioSlideIndexes","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","goTo","useSlide","lastRequestedStepIndexRef","requestedStepNavigation","resolveRequestedStepNavigation","currentStepElement","currentRenderElementKeys","isSingleSlide","shouldMountPlayer","keyboardShortcutContextValue","activateKeyboardShortcutOwner","useCallback","activatePlayerKeyboardShortcutOwner","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isPlaybackRequested","setIsPlaybackRequested","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","subtitleSeekRequest","setSubtitleSeekRequest","isAudioLoadingVisible","setIsAudioLoadingVisible","audioLoadingReason","setAudioLoadingReason","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","playedAudioKeysRef","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","hasInteractionOverlayActivity","setHasInteractionOverlayActivity","interactionOverlayDragOffset","setInteractionOverlayDragOffset","isInteractionOverlayDragging","setIsInteractionOverlayDragging","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerControlsVisible","playerLayoutReserved","resolveSlidePlayerLayoutState","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","isDesktopBrowserFullscreen","handleMobileViewModeSelect","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","closeInteractionOverlayForCustomAction","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previousActive","resetInteractionOverlayDragState","previousOffset","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","hasPlayerCustomActions","isPlayerCustomActionEffectivelyActive","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","currentPlaybackStartedResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","silentStepAutoAdvanceBehavior","resolveSilentStepAutoAdvanceBehavior","silentStepAutoAdvanceDelay","isImageOnlySilentStep","imageOnlyStepVisualReadyKey","readyImageOnlyStepKey","setReadyImageOnlyStepKey","isImageOnlyStepVisualReady","clearPlayerHideTimer","clearAutoAdvanceTimer","clearImageOnlyStepReadyTimeout","resetAudioSequence","options","requestSubtitleCueSeek","startCurrentAudioSequence","nextAudioKey","resolvePendingStepAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","isPlayerControlsHovered","revealPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","hasResolvedInteractionElement","shouldBlockPlaybackForInteraction","handlePlaybackPreferenceChange","playing","syncPlaybackPreferenceBeforeNavigation","context","cancelled","rafId","cleanupListeners","detachListeners","finishVisualReady","evaluateVisualReady","activeStepContainer","iframeElements","areImageOnlyStepIframeVisualsReady","cleanupCallbacks","queueRecheck","registerEvent","eventName","listener","iframeElement","iframeDocument","image","cleanup","DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS","syncViewportFullscreenPreference","handleOrientationChange","unsubscribeMobileDeviceChange","subscribeMobileDeviceChange","targetStepIndex","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","pendingSubtitleJump","shouldPreservePendingSubtitleJump","canReachSubtitleJumpTarget","hasUnplayedStepAudio","shouldSkipDefaultAudioStart","shouldStartDefaultAudioSequence","interactionDefaults","interactionDefaultSelectedValues","hasResolvedInteractionInput","resolvedInteractionReadonly","shouldAutoContinueInteraction","resolveSlideInteractionState","isInteractionReadonly","shouldShowInteractionOverlay","shouldRenderInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","markdownScalingMode","resolveMarkdownScalingMode","lastVisibleElementIndex","lastVisibleIndex","MarkdownSlideScaling","isPreRenderedHtml","cn","handleFullscreen","scrollStageToBottom","stageLayerElement","canJumpToSubtitleTarget","handleSubtitleJump","targetAudioKey","targetSlideIndex","shouldWakePlayerControlsAfterNavigation","handlePrev","handleNext","handlePlayerLoadingChange","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handlePlayerControlsPointerEnter","handlePlayerControlsPointerLeave","stopOverlayPropagation","getInteractionOverlayDragBounds","overlayElement","startOffset","viewportElement","overlayRect","viewportRect","previousRect","currentRect","deltaX","deltaY","nextOffset","bounds","clampedOffset","clampInteractionOverlayDragOffset","handleInteractionOverlayPointerDown","handleInteractionOverlayPointerMove","dragState","endInteractionOverlayDrag","handleSurfacePointerDown","handleSurfaceFocusCapture","handleSurfaceClick","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SubtitleOverlay","PlayerKeyboardShortcutContext","Player","previousEnabled"],"mappings":"8wDA2GMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GACtCC,GAAmD,IACnDC,GAAwE,CAC5E,EAAG,EACH,EAAG,CACL,EACMC,GAAwC,GAExCC,GACJ,OAAO,OAAW,IAAcC,EAAAA,UAAYC,EAAAA,gBACxCC,GAAgC,CACpC,SACA,QACA,WACA,uBACA,2BACA,oCACF,EAAE,KAAK,IAAI,EACLC,GAAiD,kBAEjDC,GAAwC,CAAC,CAC7C,EAAAC,EACA,EAAAC,CACF,KAAmE,CACjE,EAAG,OAAOD,EAAE,QAAQ,CAAC,CAAC,EACtB,EAAG,OAAOC,EAAE,QAAQ,CAAC,CAAC,CACxB,GAEMC,GAA8CC,GAClD,KAAK,IAAIA,CAAK,GAAKV,GAEfW,GAAwC,CAC5CC,EACAC,IAEA,KAAK,IAAID,EAAM,EAAIC,EAAO,CAAC,EAAIb,IAC/B,KAAK,IAAIY,EAAM,EAAIC,EAAO,CAAC,EAAIb,GAQ3Bc,GAA+B,CACnCC,EACAC,IAEI,OAAOD,GAAkB,SACpBA,EAIPA,EAAcC,CAAM,GACpBD,EAAcV,EAAwB,GACtCY,GAAAA,8BAA8BD,CAAM,EAIlCE,GAAuC,CAC3CH,EACAI,IAEI,OAAOJ,GAAkB,SACpBA,EAGF,CACL,GAAGI,EACH,GAAGJ,CAAA,EAIDK,GAA6B,CACjCJ,EACAK,IAEKA,EAKEL,IAAW,eAJT,GAgDLM,GAAyBC,EAAAA,KAC7B,CAAC,CACC,QAAAC,EACA,MAAAC,EACA,oBAAAC,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,wBAAA/E,GACA,iBAAkBkL,EAClB,qBAAAjG,GAAA,OACA9H,EACA,kBAAmBmJ,GACnB,kBAAAN,GACA,oBAAqBd,GACrB,gBAAiBqN,GACjB,kBAAmB,IAAM,CACvBxM,GAAkC,EAAI,CACxC,EACA,2BAA4BiH,GAC5B,qBAAsBpF,GAAkB,QACxC,iBAAkB,IAAM,CACtB3B,GAAsBoP,GAAoB,CAACA,CAAe,CAC5D,EACA,aAAc,CAAC9R,EACf,QAASiP,GACT,aAAcX,GACd,aAAc7K,GACd,eAAgBc,EAChB,wBAAyBrG,GAAY,QACrC,uBAAwBkH,GACxB,uBAAwBoK,GACxB,uBAAwBC,GACxB,OAAQV,GACR,OAAQD,GACR,eAAgBJ,GAChB,wBAAAD,GACA,aAAc,CAAC1O,GACf,aAAc8E,EACd,oBAAA/C,GACA,MAAO7F,GACP,oBAAqB8K,GACrB,cAAelL,GACf,qBAAsB+L,EAAA,CAAA,CACxB,CAAA,EAEA,IAAA,CAAA,CAAA,CACN,CAAA,CAAA,CAGN"}
1
+ {"version":3,"file":"Slide.cjs","sources":["../../../src/components/Slide/Slide.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ChevronLeft, GripHorizontal } from \"lucide-react\";\n\nimport { isSandboxInteractionMessage } from \"../../lib/sandboxInteraction\";\nimport { cn } from \"../../lib/utils\";\nimport { useResolvedDirection } from \"../../lib/useResolvedDirection\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\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 type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n isLandscapeViewport as getIsFullscreenPreferredViewport,\n isMobileDevice as getIsMobileDevice,\n subscribeMobileDeviceChange,\n} from \"../../lib/mobileDevice\";\nimport Player from \"./Player\";\nimport MarkdownSlideScaling from \"./MarkdownSlideScaling\";\nimport SubtitleOverlay from \"./SubtitleOverlay\";\nimport type {\n PlayerProps,\n SlidePlayerNavigationContext,\n SlidePlayerSubtitleJumpTarget,\n SlidePlayerSubtitleSeekRequest,\n SlidePlayerTexts,\n} from \"./Player\";\nimport type { SlidePlayerLoadingReason } from \"./Player\";\nimport type { Element } from \"./types\";\nimport useSlide from \"./useSlide\";\nimport useWakePlayerFromIframe from \"./useWakePlayerFromIframe\";\nimport { PlayerKeyboardShortcutContext } from \"./utils/playerKeyboardShortcutContext\";\nimport { activatePlayerKeyboardShortcutOwner } from \"./utils/playerKeyboardShortcuts\";\nimport {\n DEFAULT_MOBILE_VIEW_MODE,\n resolveMobileViewModeState,\n type MobileViewMode,\n} from \"./utils/mobileScreenMode\";\nimport {\n clampInteractionOverlayDragOffset,\n shouldPresentInteractionOverlay,\n shouldRenderInteractionOverlay,\n type InteractionOverlayDragBounds,\n type InteractionOverlayDragOffset,\n} from \"./utils/interactionPlayback\";\nimport { resolveMarkdownScalingMode } from \"./utils/markdownScaling\";\nimport { shouldWakePlayerControlsAfterNavigation } from \"./utils/playerNavigationContext\";\nimport { shouldAutoAdvanceIntoAppendedMarker } from \"./utils/appendedMarkerAdvance\";\nimport { resolveRequestedStepNavigation } from \"./utils/requestedStepNavigation\";\nimport {\n hasUnplayedStepAudio,\n resolvePendingStepAudioKey,\n} from \"./utils/stepAudioProgress\";\nimport {\n getPlaybackSequenceTransition,\n shouldStartDefaultAudioSequence,\n} from \"./utils/playbackSequence\";\nimport {\n canReachSubtitleJumpTarget,\n hasResolvedInteractionElement,\n} from \"./utils/subtitleJumpNavigation\";\nimport {\n getPlayerCustomActionCount,\n resolvePlayerCustomActionElement,\n} from \"./utils/playerCustomActions\";\nimport { createPlaybackTimeStore } from \"./utils/playbackTimeStore\";\nimport { resolveSlideInteractionState } from \"./utils/interactionResolution\";\nimport { shouldUseAutoAdvanceToggle } from \"./utils/playerToggleMode\";\nimport {\n areImageOnlyStepIframeVisualsReady,\n DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS,\n} from \"./utils/imageOnlyStepVisualReady\";\nimport { resolveSilentStepAutoAdvanceBehavior } from \"./utils/silentStepAutoAdvance\";\nimport {\n resolveSlidePlayerLayoutState,\n resolveSlidePlayerVisibility,\n type SlidePlayerControlsVisibility,\n} from \"./utils/playerVisibility\";\nimport {\n DEFAULT_SLIDE_BUFFERING_TEXTS,\n getSlideLocaleTexts,\n type SlideBufferingReason,\n} from \"./slideI18n\";\nimport \"./slide.css\";\nexport type {\n Element,\n ElementAudioSegment,\n ElementSubtitleCue,\n SlidePlayerCustomActionContext,\n SlidePlayerCustomActions,\n} from \"./types\";\nexport type { SlidePlayerControlsVisibility } from \"./utils/playerVisibility\";\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;\nconst DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS = 3000;\nconst DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET: InteractionOverlayDragOffset = {\n x: 0,\n y: 0,\n};\nconst INTERACTION_OVERLAY_LAYOUT_EPSILON_PX = 0.5;\ntype InteractionOverlayLayoutRect = Pick<DOMRect, \"left\" | \"top\">;\nconst useIsomorphicLayoutEffect =\n typeof window === \"undefined\" ? useEffect : useLayoutEffect;\nconst INTERACTION_ACTIVITY_SELECTOR = [\n \"button\",\n \"input\",\n \"textarea\",\n '[contenteditable=\"\"]',\n '[contenteditable=\"true\"]',\n '[contenteditable=\"plaintext-only\"]',\n].join(\", \");\nconst DEFAULT_BUFFERING_REASON: SlideBufferingReason = \"waitingForAudio\";\n\nconst normalizeInteractionOverlayDragOffset = ({\n x,\n y,\n}: InteractionOverlayDragOffset): InteractionOverlayDragOffset => ({\n x: Number(x.toFixed(2)),\n y: Number(y.toFixed(2)),\n});\n\nconst hasMeaningfulInteractionOverlayLayoutDelta = (delta: number) =>\n Math.abs(delta) >= INTERACTION_OVERLAY_LAYOUT_EPSILON_PX;\n\nconst areInteractionOverlayDragOffsetsEqual = (\n first: InteractionOverlayDragOffset,\n second: InteractionOverlayDragOffset\n) =>\n Math.abs(first.x - second.x) < INTERACTION_OVERLAY_LAYOUT_EPSILON_PX &&\n Math.abs(first.y - second.y) < INTERACTION_OVERLAY_LAYOUT_EPSILON_PX;\n\nexport type { SlideBufferingReason } from \"./slideI18n\";\n\nexport type SlideBufferingTextConfig =\n | string\n | Partial<Record<SlideBufferingReason, string>>;\n\nconst resolveBufferingTextByReason = (\n bufferingText: SlideBufferingTextConfig,\n reason: SlideBufferingReason\n) => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return (\n bufferingText[reason] ??\n bufferingText[DEFAULT_BUFFERING_REASON] ??\n DEFAULT_SLIDE_BUFFERING_TEXTS[reason]\n );\n};\n\nconst mergeBufferingTextWithLocaleDefaults = (\n bufferingText: SlideBufferingTextConfig | undefined,\n localeBufferingText: Record<string, string>\n): SlideBufferingTextConfig => {\n if (typeof bufferingText === \"string\") {\n return bufferingText;\n }\n\n return {\n ...localeBufferingText,\n ...bufferingText,\n };\n};\n\nconst shouldShowBufferingOverlay = (\n reason: SlideBufferingReason | null,\n loading: boolean\n) => {\n if (!loading) {\n return false;\n }\n\n // Keep the silent preload/loading phase invisible until audio is actually playable.\n return reason !== \"loadingAudio\";\n};\n\ntype RenderSlideElementOptions = {\n replaceRootScreenHeightWithFull?: boolean;\n};\n\ninterface InteractionOverlayCardProps {\n dir?: ContentRenderProps[\"dir\"];\n lang?: string;\n content: string;\n title: string;\n dragHandleAriaLabel: string;\n locale?: MarkdownFlowLocale;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n confirmButtonText?: string;\n copyButtonText?: string;\n copiedButtonText?: string;\n onSend?: (content: OnSendContentParams) => void;\n onDragHandlePointerCancel?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerDown?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerMove?: React.PointerEventHandler<HTMLButtonElement>;\n onDragHandlePointerUp?: React.PointerEventHandler<HTMLButtonElement>;\n readonly?: boolean;\n}\n\nexport interface SlideInteractionTexts\n extends Pick<\n ContentRenderProps,\n \"confirmButtonText\" | \"copyButtonText\" | \"copiedButtonText\"\n > {\n title?: string;\n /** Accessible label for the interaction panel drag handle. */\n dragHandleAriaLabel?: string;\n}\n\nexport type SlideFullscreenHeader = {\n content?: React.ReactNode;\n backAriaLabel?: string;\n onBack?: () => void;\n};\n\nexport interface SlidePlaybackPosition {\n audioKey: string;\n element?: Element;\n timeMs: number;\n}\n\nexport interface SlidePlaybackResumeRequest {\n audioKey: string;\n id: number | string;\n timeMs: number;\n}\n\nconst InteractionOverlayCard = memo(\n ({\n content,\n title,\n dragHandleAriaLabel,\n locale,\n dir,\n lang,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n onSend,\n onDragHandlePointerCancel,\n onDragHandlePointerDown,\n onDragHandlePointerMove,\n onDragHandlePointerUp,\n readonly = false,\n }: InteractionOverlayCardProps) => (\n <div className=\"slide-player__interaction-card\">\n <button\n type=\"button\"\n className=\"slide-player__interaction-drag-handle\"\n aria-label={dragHandleAriaLabel}\n onPointerCancel={onDragHandlePointerCancel}\n onPointerDown={onDragHandlePointerDown}\n onPointerMove={onDragHandlePointerMove}\n onPointerUp={onDragHandlePointerUp}\n >\n <span className=\"slide-player__interaction-drag-handle-icon\">\n <GripHorizontal aria-hidden=\"true\" />\n <GripHorizontal aria-hidden=\"true\" />\n <GripHorizontal aria-hidden=\"true\" />\n </span>\n </button>\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 locale={locale}\n dir={dir}\n lang={lang}\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 sandboxMode=\"content\"\n />\n </div>\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\nconst isInteractionActivityTarget = (\n target: EventTarget | null\n): target is HTMLElement =>\n target instanceof HTMLElement &&\n Boolean(target.closest(INTERACTION_ACTIVITY_SELECTOR));\nexport interface SlideProps extends React.ComponentProps<\"section\"> {\n elementList?: Element[];\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /** Enables the player runtime, including audio playback and keyboard shortcuts. */\n playerEnabled?: boolean;\n /**\n * Controls whether the player controls are always visible, always hidden, or auto-hidden.\n *\n * Use `\"hidden\"` to keep audio playback and keyboard shortcuts active while\n * hiding the visual controls.\n *\n * @example\n * ```tsx\n * <Slide playerControlsVisibility=\"hidden\" enableKeyboardShortcuts />\n * ```\n */\n playerControlsVisibility?: SlidePlayerControlsVisibility;\n playerClassName?: string;\n fullscreenHeader?: SlideFullscreenHeader;\n playerCustomActions?: PlayerProps[\"customActions\"];\n playerCustomActionPauseOnActive?: boolean;\n bufferingText?: SlideBufferingTextConfig;\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 /** Reports the active logical audio item and its absolute playback time. */\n onPlaybackPositionChange?: (position: SlidePlaybackPosition) => void;\n /**\n * Requests playback restoration for a logical audio item. The request is\n * applied without autoplay and may wait for a streaming segment to arrive.\n */\n playbackResumeRequest?: SlidePlaybackResumeRequest | null;\n /**\n * Requests navigation to a slide step from the consuming application.\n * The player still reports the resulting step through `onStepChange`.\n */\n requestedStepIndex?: number;\n /**\n * Enables keyboard shortcuts for existing player actions.\n *\n * Defaults to `true`. The active slide responds after users click, touch, or\n * focus the slide/player surface; ignored targets include form controls and\n * interaction overlays.\n *\n * @example\n * ```tsx\n * <Slide elementList={slides} enableKeyboardShortcuts={false} />\n * ```\n */\n enableKeyboardShortcuts?: boolean;\n enableIframeScaling?: boolean;\n /**\n * Fits Markdown-only slides to the available presentation viewport.\n *\n * Defaults to `true`. Disable this to preserve the fixed 16px article\n * typography used by standalone ContentRender.\n */\n enableMarkdownScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst Slide: React.FC<SlideProps> = ({\n elementList = [],\n locale,\n playerEnabled,\n playerControlsVisibility,\n playerClassName,\n fullscreenHeader,\n playerCustomActions,\n playerCustomActionPauseOnActive = true,\n bufferingText,\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 onPlaybackPositionChange,\n playbackResumeRequest = null,\n requestedStepIndex,\n enableKeyboardShortcuts = true,\n enableIframeScaling = true,\n enableMarkdownScaling = true,\n disableLoadingOverlay = false,\n className,\n dir,\n lang,\n onPointerDown,\n onFocusCapture,\n ...props\n}) => {\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const localeTexts = useMemo(() => getSlideLocaleTexts(locale), [locale]);\n const resolvedBufferingText = useMemo(\n () =>\n mergeBufferingTextWithLocaleDefaults(\n bufferingText,\n localeTexts.bufferingText\n ),\n [bufferingText, localeTexts.bufferingText]\n );\n const {\n playerEnabled: resolvedPlayerEnabled,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n } = resolveSlidePlayerVisibility({\n playerEnabled,\n playerControlsVisibility,\n });\n const keyboardShortcutOwnerId = useId();\n const sectionRef = useRef<HTMLElement | null>(null);\n const { resolvedDirection } = useResolvedDirection(sectionRef, direction);\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 isPointerInsidePlayerControlsRef = useRef(false);\n const autoAdvanceTimerRef = useRef<number | null>(null);\n const imageOnlyStepReadyTimeoutRef = 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 interactionOverlayLayoutRectRef =\n useRef<InteractionOverlayLayoutRect | null>(null);\n const interactionOverlayDragRef = useRef<{\n pointerId: number;\n startClientX: number;\n startClientY: number;\n startOffset: InteractionOverlayDragOffset;\n bounds: InteractionOverlayDragBounds;\n } | null>(null);\n const prevRenderElementKeysRef = useRef<string[]>([]);\n const shouldScrollToBottomRef = useRef(false);\n const pendingInteractionOverlayStepIndexRef = useRef<number | null>(null);\n const pendingSubtitleJumpRef = useRef<{\n audioIndex: number;\n audioKey: string;\n slideIndex: number;\n timeMs: number;\n } | null>(null);\n const subtitleSeekRequestIdRef = useRef(0);\n const lastPlaybackResumeRequestIdRef = useRef<number | string | null>(null);\n const playbackResetKeyRef = useRef<string | null>(null);\n const appendedMarkerAdvanceStateRef = useRef({\n markerCount: 0,\n currentIndex: -1,\n canGoNext: false,\n });\n const shouldSkipDefaultAudioStartForSubtitleJumpRef = useRef(false);\n const {\n currentElementList,\n stepElementLists,\n slideElementList,\n currentIndex,\n audioList,\n audioSlideIndexes,\n currentAudioSequenceIndexes,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n canGoPrev,\n canGoNext,\n handlePrev: goPrev,\n handleNext: goNext,\n handleGoTo: goTo,\n } = useSlide(elementList);\n const lastRequestedStepIndexRef = useRef<number | null>(null);\n const requestedStepNavigation = useMemo(\n () =>\n resolveRequestedStepNavigation({\n currentStepIndex: currentIndex,\n requestedStepIndex,\n slideStepCount: slideElementList.length,\n }),\n [currentIndex, requestedStepIndex, slideElementList.length]\n );\n const currentStepElement = useMemo(() => {\n if (currentIndex < 0) {\n return undefined;\n }\n\n return slideElementList[currentIndex];\n }, [currentIndex, slideElementList]);\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 const visibleMarkerCount = slideElementList.filter(\n (element) => element.is_renderable !== false\n ).length;\n const isSingleSlide = visibleMarkerCount === 1;\n const shouldMountPlayer =\n resolvedPlayerEnabled &&\n (slideElementList.length > 0 ||\n audioList.length > 0 ||\n Boolean(currentInteractionElement));\n const keyboardShortcutContextValue = useMemo(\n () => ({\n enabled: enableKeyboardShortcuts,\n ownerId: keyboardShortcutOwnerId,\n }),\n [enableKeyboardShortcuts, keyboardShortcutOwnerId]\n );\n const activateKeyboardShortcutOwner = useCallback(() => {\n if (!enableKeyboardShortcuts || !shouldMountPlayer) {\n return;\n }\n\n activatePlayerKeyboardShortcutOwner(keyboardShortcutOwnerId);\n }, [enableKeyboardShortcuts, keyboardShortcutOwnerId, shouldMountPlayer]);\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 [isPlaybackRequested, setIsPlaybackRequested] = useState(true);\n const [isAutoAdvanceEnabled, setIsAutoAdvanceEnabled] = useState(true);\n const [currentAudioKey, setCurrentAudioKey] = useState<string | null>(null);\n const [subtitleSeekRequest, setSubtitleSeekRequest] =\n useState<SlidePlayerSubtitleSeekRequest | null>(null);\n const [isAudioLoadingVisible, setIsAudioLoadingVisible] = useState(false);\n const [audioLoadingReason, setAudioLoadingReason] =\n useState<SlideBufferingReason>(DEFAULT_BUFFERING_REASON);\n const [hasCompletedCurrentStepAudio, setHasCompletedCurrentStepAudio] =\n useState(false);\n // Audio keys already played within the current step. A step's audio arrives\n // progressively while content is still being generated, so \"completed\" has to\n // mean \"every key played\" rather than \"reached the end of the list once\".\n const playedAudioKeysRef = useRef<Set<string>>(new Set());\n const [hasCurrentAudioPlaybackStarted, setHasCurrentAudioPlaybackStarted] =\n useState(false);\n const [isSubtitleEnabled, setIsSubtitleEnabled] = useState(true);\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 [hasInteractionOverlayActivity, setHasInteractionOverlayActivity] =\n useState(false);\n const [interactionOverlayDragOffset, setInteractionOverlayDragOffset] =\n useState<InteractionOverlayDragOffset>(\n DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET\n );\n const [isInteractionOverlayDragging, setIsInteractionOverlayDragging] =\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 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 {\n controlsVisible: playerControlsVisible,\n layoutReserved: playerLayoutReserved,\n } = resolveSlidePlayerLayoutState({\n isAutoVisible: isPlayerVisible,\n playerControlsVisibility: resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n });\n const shouldShowFullscreenHeader =\n isImmersiveMobileFullscreen && playerControlsVisible;\n const shouldApplyFullscreenViewportPadding =\n isImmersiveMobileFullscreen && playerLayoutReserved;\n const shouldShowMobileFullscreenMask =\n isImmersiveMobileFullscreen || isNativeMobileFullscreen;\n const isDesktopBrowserFullscreen = isBrowserFullscreen && !isMobileDevice;\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\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 closeInteractionOverlayForCustomAction = useCallback(() => {\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n }, [clearInteractionAutoCloseTimer, clearInteractionOverlayOpenTimer]);\n\n const setPlayerCustomActionActive = useCallback(\n (active: boolean) => {\n if (active) {\n closeInteractionOverlayForCustomAction();\n }\n\n setIsPlayerCustomActionActive(active);\n },\n [closeInteractionOverlayForCustomAction]\n );\n const togglePlayerCustomActionActive = useCallback(() => {\n closeInteractionOverlayForCustomAction();\n setIsPlayerCustomActionActive((previousActive) => !previousActive);\n }, [closeInteractionOverlayForCustomAction]);\n const resetInteractionOverlayDragState = useCallback(() => {\n setInteractionOverlayDragOffset((previousOffset) =>\n previousOffset.x === DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET.x &&\n previousOffset.y === DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET.y\n ? previousOffset\n : DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET\n );\n setIsInteractionOverlayDragging(false);\n interactionOverlayDragRef.current = null;\n interactionOverlayLayoutRectRef.current = null;\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 hasPlayerCustomActions = playerCustomActionCount > 0;\n const isPlayerCustomActionEffectivelyActive =\n hasPlayerCustomActions && isPlayerCustomActionActive;\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 \"--slide-interaction-drag-x\": `${interactionOverlayDragOffset.x}px`,\n \"--slide-interaction-drag-y\": `${interactionOverlayDragOffset.y}px`,\n }) as React.CSSProperties,\n [\n interactionOverlayDragOffset.x,\n interactionOverlayDragOffset.y,\n playerCustomActionCount,\n ]\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 && isPlayerCustomActionEffectivelyActive;\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 const silentStepAutoAdvanceBehavior = useMemo(\n () =>\n resolveSilentStepAutoAdvanceBehavior({\n currentElementList,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n markerAutoAdvanceDelay,\n }),\n [\n currentElementList,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n markerAutoAdvanceDelay,\n ]\n );\n const silentStepAutoAdvanceDelay = silentStepAutoAdvanceBehavior.delayMs;\n const isImageOnlySilentStep =\n silentStepAutoAdvanceBehavior.usesImageOnlyDelay;\n const imageOnlyStepVisualReadyKey = useMemo(\n () => `${currentIndex}:${currentRenderElementKeys.join(\"|\")}`,\n [currentIndex, currentRenderElementKeys]\n );\n const [readyImageOnlyStepKey, setReadyImageOnlyStepKey] = useState<\n string | null\n >(null);\n const isImageOnlyStepVisualReady =\n !isImageOnlySilentStep ||\n readyImageOnlyStepKey === imageOnlyStepVisualReadyKey;\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 clearAutoAdvanceTimer = useCallback(() => {\n if (autoAdvanceTimerRef.current === null) {\n return;\n }\n\n window.clearTimeout(autoAdvanceTimerRef.current);\n autoAdvanceTimerRef.current = null;\n }, []);\n\n const clearImageOnlyStepReadyTimeout = useCallback(() => {\n if (imageOnlyStepReadyTimeoutRef.current === null) {\n return;\n }\n\n window.clearTimeout(imageOnlyStepReadyTimeoutRef.current);\n imageOnlyStepReadyTimeoutRef.current = null;\n }, []);\n\n const resetAudioSequence = useCallback(\n (\n options: {\n preservePendingSubtitleJump?: boolean;\n } = {}\n ) => {\n clearAutoAdvanceTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n clearImageOnlyStepReadyTimeout();\n setCurrentAudioKey(null);\n playbackTimeStore.reset();\n setIsAudioLoadingVisible(false);\n setAudioLoadingReason(DEFAULT_BUFFERING_REASON);\n setHasCompletedCurrentStepAudio(false);\n playedAudioKeysRef.current = new Set();\n setHasCurrentAudioPlaybackStarted(false);\n setSubtitleSeekRequest(null);\n if (!options.preservePendingSubtitleJump) {\n pendingSubtitleJumpRef.current = null;\n }\n setActiveInteractionElement(undefined);\n setIsInteractionOverlayOpen(false);\n setInteractionOverlaySubtitleOffset(0);\n },\n [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n playbackTimeStore,\n ]\n );\n\n const requestSubtitleCueSeek = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) => {\n subtitleSeekRequestIdRef.current += 1;\n setSubtitleSeekRequest({\n ...target,\n id: subtitleSeekRequestIdRef.current,\n });\n },\n []\n );\n\n const startCurrentAudioSequence = useCallback(() => {\n // Resume at the first key that has not played yet. Falling back to index 0\n // unconditionally would replay the opening segment every time late audio\n // extends the current step.\n const nextAudioKey = resolvePendingStepAudioKey(\n currentAudioSequenceKeys,\n playedAudioKeysRef.current\n );\n\n if (!nextAudioKey) {\n return false;\n }\n\n // Start the first pending 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 isPlayerControlsHovered = useCallback(\n () =>\n isPointerInsidePlayerControlsRef.current ||\n Boolean(\n sectionRef.current?.querySelector(\".slide-player__controls:hover\")\n ),\n []\n );\n\n const revealPlayerControls = useCallback(\n (enableAutoHide = hasPlayerInteracted) => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n return;\n }\n\n setIsPlayerVisible(true);\n clearPlayerHideTimer();\n\n if (\n resolvedPlayerControlsVisibility === \"visible\" ||\n !enableAutoHide ||\n playerAutoHideDelay <= 0 ||\n isPlayerControlsHovered()\n ) {\n return;\n }\n\n playerHideTimerRef.current = window.setTimeout(() => {\n if (isPlayerControlsHovered()) {\n playerHideTimerRef.current = null;\n return;\n }\n\n setIsPlayerVisible(false);\n playerHideTimerRef.current = null;\n }, playerAutoHideDelay);\n },\n [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n isPlayerControlsHovered,\n playerAutoHideDelay,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n ]\n );\n\n const hasResolvedCurrentInteraction = Boolean(\n hasResolvedInteractionElement(currentInteractionElement)\n );\n\n const shouldBlockPlaybackForInteraction =\n Boolean(currentInteractionElement) && !hasResolvedCurrentInteraction;\n\n const handlePlaybackPreferenceChange = useCallback((playing: boolean) => {\n setIsPlaybackRequested(playing);\n }, []);\n\n const syncPlaybackPreferenceBeforeNavigation = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n if (context) {\n setIsPlaybackRequested(context.shouldContinuePlayback);\n }\n },\n []\n );\n\n useEffect(() => {\n // Keep silent-step autoplay aligned with the same play/pause preference as audio.\n setIsAutoAdvanceEnabled(isPlaybackRequested);\n }, [currentIndex, isPlaybackRequested, playerCustomActionPauseOnActive]);\n\n useEffect(() => {\n if (playerCustomActionPauseOnActive) {\n setPlayerCustomActionActive(false);\n }\n }, [\n currentIndex,\n playerCustomActionPauseOnActive,\n setPlayerCustomActionActive,\n ]);\n\n useEffect(() => {\n if (!hasPlayerCustomActions) {\n setIsPlayerCustomActionActive(false);\n }\n }, [hasPlayerCustomActions]);\n\n useEffect(() => {\n return () => {\n clearAutoAdvanceTimer();\n clearImageOnlyStepReadyTimeout();\n clearPlayerHideTimer();\n clearInteractionAutoCloseTimer();\n clearInteractionOverlayOpenTimer();\n };\n }, [\n clearAutoAdvanceTimer,\n clearImageOnlyStepReadyTimeout,\n clearInteractionAutoCloseTimer,\n clearInteractionOverlayOpenTimer,\n clearPlayerHideTimer,\n ]);\n\n useEffect(() => {\n if (!isImageOnlySilentStep) {\n clearImageOnlyStepReadyTimeout();\n return;\n }\n\n let cancelled = false;\n let rafId: number | null = null;\n let cleanupListeners: (() => void) | null = null;\n\n const detachListeners = () => {\n cleanupListeners?.();\n cleanupListeners = null;\n };\n\n const finishVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n setReadyImageOnlyStepKey(imageOnlyStepVisualReadyKey);\n };\n\n const evaluateVisualReady = () => {\n if (cancelled) {\n return;\n }\n\n detachListeners();\n\n const activeStepContainer = stageLayerRef.current?.querySelector(\n '[data-active-step=\"true\"]'\n ) as HTMLElement | null;\n\n if (!activeStepContainer) {\n return;\n }\n\n const iframeElements = Array.from(\n activeStepContainer.querySelectorAll(\"iframe\")\n ) as HTMLIFrameElement[];\n\n if (\n iframeElements.length === 0 ||\n areImageOnlyStepIframeVisualsReady(iframeElements)\n ) {\n finishVisualReady();\n return;\n }\n\n const cleanupCallbacks: Array<() => void> = [];\n const queueRecheck = () => {\n if (cancelled) {\n return;\n }\n\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n };\n const registerEvent = (\n target: EventTarget,\n eventName: string,\n listener: EventListener\n ) => {\n target.addEventListener(eventName, listener, { once: true });\n cleanupCallbacks.push(() =>\n target.removeEventListener(eventName, listener)\n );\n };\n\n iframeElements.forEach((iframeElement) => {\n const iframeDocument = iframeElement.contentDocument;\n\n if (!iframeDocument || iframeDocument.readyState !== \"complete\") {\n registerEvent(iframeElement, \"load\", queueRecheck);\n return;\n }\n\n Array.from(iframeDocument.images)\n .filter((image) => !image.complete)\n .forEach((image) => {\n registerEvent(image, \"load\", queueRecheck);\n registerEvent(image, \"error\", queueRecheck);\n });\n });\n\n cleanupListeners = () => {\n cleanupCallbacks.forEach((cleanup) => cleanup());\n };\n };\n\n rafId = window.requestAnimationFrame(() => {\n rafId = null;\n evaluateVisualReady();\n });\n\n imageOnlyStepReadyTimeoutRef.current = window.setTimeout(() => {\n finishVisualReady();\n }, DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS);\n\n return () => {\n cancelled = true;\n detachListeners();\n clearImageOnlyStepReadyTimeout();\n if (rafId !== null) {\n window.cancelAnimationFrame(rafId);\n }\n };\n }, [\n clearImageOnlyStepReadyTimeout,\n currentElementList,\n currentIndex,\n imageOnlyStepVisualReadyKey,\n isImageOnlySilentStep,\n ]);\n\n useEffect(() => {\n onPlayerVisibilityChange?.(playerControlsVisible);\n\n return () => {\n onPlayerVisibilityChange?.(false);\n };\n }, [onPlayerVisibilityChange, playerControlsVisible]);\n\n useEffect(() => {\n if (playerControlsVisible) {\n return;\n }\n\n isPointerInsidePlayerControlsRef.current = false;\n }, [playerControlsVisible]);\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 resetInteractionOverlayDragState();\n };\n const handleOrientationChange = () => {\n resetInteractionOverlayDragState();\n };\n\n syncViewportFullscreenPreference();\n window.addEventListener(\"orientationchange\", handleOrientationChange);\n window.screen?.orientation?.addEventListener?.(\n \"change\",\n handleOrientationChange\n );\n const unsubscribeMobileDeviceChange = subscribeMobileDeviceChange(\n syncViewportFullscreenPreference\n );\n\n return () => {\n unsubscribeMobileDeviceChange();\n window.removeEventListener(\"orientationchange\", handleOrientationChange);\n window.screen?.orientation?.removeEventListener?.(\n \"change\",\n handleOrientationChange\n );\n };\n }, [isMobileDevice, resetInteractionOverlayDragState]);\n\n useEffect(() => {\n onMobileViewModeChange?.(effectiveMobileViewMode);\n }, [effectiveMobileViewMode, onMobileViewModeChange]);\n\n useEffect(() => {\n if (\n previousEffectiveMobileViewModeRef.current !== effectiveMobileViewMode\n ) {\n resetInteractionOverlayDragState();\n }\n previousEffectiveMobileViewModeRef.current = effectiveMobileViewMode;\n }, [effectiveMobileViewMode, resetInteractionOverlayDragState]);\n\n useLayoutEffect(() => {\n if (!requestedStepNavigation) {\n lastRequestedStepIndexRef.current = null;\n return;\n }\n\n if (!requestedStepNavigation.isAvailable) {\n lastRequestedStepIndexRef.current = null;\n return;\n }\n\n const { targetStepIndex } = requestedStepNavigation;\n\n if (lastRequestedStepIndexRef.current === targetStepIndex) {\n return;\n }\n\n lastRequestedStepIndexRef.current = targetStepIndex;\n goTo(targetStepIndex);\n }, [goTo, requestedStepNavigation]);\n\n useEffect(() => {\n if (requestedStepNavigation?.isPending) {\n return;\n }\n\n onStepChange?.(currentStepElement, currentIndex);\n }, [\n currentIndex,\n currentStepElement,\n onStepChange,\n requestedStepNavigation?.isPending,\n ]);\n\n useEffect(() => {\n const previousState = appendedMarkerAdvanceStateRef.current;\n const shouldAdvanceIntoAppendedMarker = shouldAutoAdvanceIntoAppendedMarker(\n {\n previousMarkerCount: previousState.markerCount,\n nextMarkerCount: slideElementList.length,\n previousIndex: previousState.currentIndex,\n previousCanGoNext: previousState.canGoNext,\n nextCanGoNext: canGoNext,\n currentAudioKey,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n currentStepHasSpeakableElement,\n currentInteractionElement,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n }\n );\n\n appendedMarkerAdvanceStateRef.current = {\n markerCount: slideElementList.length,\n currentIndex,\n canGoNext,\n };\n\n if (!shouldAdvanceIntoAppendedMarker) {\n return;\n }\n\n goNext();\n }, [\n canGoNext,\n currentAudioKey,\n currentIndex,\n currentInteractionElement,\n currentStepHasSpeakableElement,\n goNext,\n hasCompletedCurrentStepAudio,\n hasResolvedCurrentInteraction,\n isAutoAdvanceEnabled,\n shouldUseSilentStepAutoAdvanceToggle,\n slideElementList.length,\n ]);\n\n useEffect(() => {\n if (!shouldMountPlayer || resolvedPlayerControlsVisibility === \"hidden\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(false);\n return;\n }\n\n if (resolvedPlayerControlsVisibility === \"visible\") {\n clearPlayerHideTimer();\n setIsPlayerVisible(true);\n return;\n }\n\n if (!hasPlayerInteracted) {\n // Keep the initial player visible briefly, then hide it automatically.\n revealPlayerControls(true);\n }\n }, [\n clearPlayerHideTimer,\n hasPlayerInteracted,\n resolvedPlayerControlsVisibility,\n shouldMountPlayer,\n revealPlayerControls,\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 (!shouldMountPlayer) {\n return;\n }\n\n // Restore player controls on explicit click/tap without waking on scroll start.\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n };\n\n window.addEventListener(\"message\", handleSandboxInteraction);\n\n return () => {\n window.removeEventListener(\"message\", handleSandboxInteraction);\n };\n }, [activateKeyboardShortcutOwner, shouldMountPlayer, revealPlayerControls]);\n\n useWakePlayerFromIframe({\n sectionRef,\n enabled: shouldMountPlayer,\n keyboardShortcutsEnabled: enableKeyboardShortcuts,\n onKeyboardShortcut: activateKeyboardShortcutOwner,\n onWake: () => {\n activateKeyboardShortcutOwner();\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n },\n });\n\n useEffect(() => {\n if (!shouldMountPlayer) {\n resetAudioSequence();\n return;\n }\n\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 isPlayerCustomActionActive: isPlayerCustomActionEffectivelyActive,\n });\n\n const pendingSubtitleJump = pendingSubtitleJumpRef.current;\n const shouldPreservePendingSubtitleJump =\n pendingSubtitleJump?.slideIndex === currentIndex;\n\n if (hasPlaybackContextChanged) {\n resetAudioSequence({\n preservePendingSubtitleJump: shouldPreservePendingSubtitleJump,\n });\n }\n\n if (currentElementList.length === 0 && !currentInteractionElement) {\n return;\n }\n\n if (shouldPausePlaybackForCustomAction) {\n return;\n }\n\n if (pendingSubtitleJump?.slideIndex === currentIndex) {\n if (\n !canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: pendingSubtitleJump.slideIndex,\n })\n ) {\n // Keep the pending seek queued while the interaction overlay gates playback.\n } else {\n pendingSubtitleJumpRef.current = null;\n // The default audio-start effect still sees the pre-seek render state.\n // Skip it once so it does not replace the subtitle target audio.\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = true;\n setCurrentAudioKey(pendingSubtitleJump.audioKey);\n requestSubtitleCueSeek({\n audioIndex: pendingSubtitleJump.audioIndex,\n timeMs: pendingSubtitleJump.timeMs,\n });\n return;\n }\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 // A custom action may intentionally remain active without pausing ordinary\n // playback. Unresolved interactions still gate progression even while that\n // action temporarily owns the visible overlay surface.\n if (shouldBlockPlaybackForInteraction) {\n return;\n }\n\n if (!shouldInitializeAudioSequence) {\n return;\n }\n\n if (startCurrentAudioSequence()) {\n return;\n }\n\n if (currentStepHasSpeakableElement) {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n setIsAudioLoadingVisible(true);\n return;\n }\n\n if (!canGoNext) {\n return;\n }\n\n if (shouldUseSilentStepAutoAdvanceToggle && !isAutoAdvanceEnabled) {\n return;\n }\n\n if (isImageOnlySilentStep && !isImageOnlyStepVisualReady) {\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 }, silentStepAutoAdvanceDelay);\n\n return () => {\n clearAutoAdvanceTimer();\n };\n }, [\n activeInteractionElement,\n canGoNext,\n clearAutoAdvanceTimer,\n currentElementList.length,\n currentIndex,\n currentInteractionElement,\n currentAudioKey,\n currentPlaybackResetKey,\n currentStepHasSpeakableElement,\n isImageOnlySilentStep,\n isImageOnlyStepVisualReady,\n silentStepAutoAdvanceDelay,\n goNext,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n isAutoAdvanceEnabled,\n hasResolvedCurrentInteraction,\n isPlayerCustomActionEffectivelyActive,\n shouldBlockPlaybackForInteraction,\n clearInteractionOverlayOpenTimer,\n resetAudioSequence,\n requestSubtitleCueSeek,\n scheduleInteractionOverlayOpen,\n shouldMountPlayer,\n slideElementList,\n startCurrentAudioSequence,\n shouldPausePlaybackForCustomAction,\n shouldUseSilentStepAutoAdvanceToggle,\n ]);\n\n useEffect(() => {\n if (\n disableLoadingOverlay ||\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 setAudioLoadingReason(\"waitingForAudio\");\n setIsAudioLoadingVisible(true);\n }, [\n hasAvailableStepAudio,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n shouldPausePlaybackForCustomAction,\n shouldBlockPlaybackForInteraction,\n ]);\n\n // A step's audio can keep arriving after the last available segment finished,\n // because narration is synthesized while the lesson is still streaming. The\n // step-completed flag is otherwise only cleared when the reset key changes -\n // which tracks the step index and the interaction content, neither of which\n // moves while new audio is appended to the step the learner is already on.\n // Without this, everything synthesized after that first gap stays silent.\n useEffect(() => {\n if (!hasCompletedCurrentStepAudio) {\n return;\n }\n\n if (\n !hasUnplayedStepAudio(\n currentAudioSequenceKeys,\n playedAudioKeysRef.current\n )\n ) {\n return;\n }\n\n setHasCompletedCurrentStepAudio(false);\n }, [currentAudioSequenceKeys, hasCompletedCurrentStepAudio]);\n\n useEffect(() => {\n const shouldSkipDefaultAudioStart =\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current;\n shouldSkipDefaultAudioStartForSubtitleJumpRef.current = false;\n\n if (\n !shouldStartDefaultAudioSequence({\n currentAudioKey,\n currentAudioSequenceLength: currentAudioSequenceKeys.length,\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n shouldBlockPlaybackForInteraction,\n shouldPausePlaybackForCustomAction,\n shouldSkipDefaultAudioStart,\n })\n ) {\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 {\n interactionDefaults,\n interactionDefaultSelectedValues,\n hasResolvedInteractionInput,\n isInteractionReadonly: resolvedInteractionReadonly,\n shouldAutoContinueInteraction,\n } = useMemo(\n () =>\n resolveSlideInteractionState(activeInteractionElement, {\n interactionDefaultValueOptions,\n }),\n [activeInteractionElement, interactionDefaultValueOptions]\n );\n\n const isInteractionReadonly =\n Boolean(activeInteractionElement?.readonly) || resolvedInteractionReadonly;\n const shouldShowInteractionOverlay = shouldRenderInteractionOverlay({\n hasActiveInteraction: Boolean(activeInteractionElement),\n isInteractionOverlayOpen,\n });\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 (activeInteractionElement && isInteractionOverlayOpen) {\n return;\n }\n\n setHasInteractionOverlayActivity(false);\n }, [activeInteractionElement, isInteractionOverlayOpen]);\n\n useEffect(() => {\n resetInteractionOverlayDragState();\n }, [activeInteractionElement, resetInteractionOverlayDragState]);\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) {\n return;\n }\n\n if (shouldAutoContinueInteraction) {\n // Auto-close passive interaction markers to keep playback moving.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }\n\n if (hasInteractionOverlayActivity || !hasResolvedInteractionInput) {\n return;\n }\n\n // Give resolved history interactions a short revisit window before\n // playback resumes, but stop auto-closing once the learner starts editing.\n interactionAutoCloseTimerRef.current = window.setTimeout(() => {\n interactionAutoCloseTimerRef.current = null;\n\n continueAfterInteraction();\n }, DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS);\n\n return () => {\n clearInteractionAutoCloseTimer();\n };\n }, [\n clearInteractionAutoCloseTimer,\n continueAfterInteraction,\n hasInteractionOverlayActivity,\n hasResolvedInteractionInput,\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 disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n dir={direction}\n lang={language}\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 disableLoadingOverlay={disableLoadingOverlay}\n hideFullScreen\n locale={locale}\n dir={direction}\n lang={language}\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 markdownScalingMode =\n isActiveStep && enableMarkdownScaling\n ? resolveMarkdownScalingMode(elementList)\n : \"disabled\";\n const lastVisibleElementIndex = elementList.reduce(\n (lastVisibleIndex, element, index) =>\n element.is_renderable !== false ? index : lastVisibleIndex,\n -1\n );\n\n return (\n <MarkdownSlideScaling\n className=\"slide-stage__content flex w-full flex-col gap-4\"\n mode={markdownScalingMode}\n >\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 </MarkdownSlideScaling>\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 canJumpToSubtitleTarget = useCallback(\n (target: SlidePlayerSubtitleJumpTarget) =>\n canReachSubtitleJumpTarget({\n currentIndex,\n resolvedCurrentInteractionElement: activeInteractionElement,\n slideElementList,\n targetSlideIndex: audioSlideIndexes[target.audioIndex],\n }),\n [\n activeInteractionElement,\n audioSlideIndexes,\n currentIndex,\n slideElementList,\n ]\n );\n\n const handleSubtitleJump = useCallback(\n (\n target: SlidePlayerSubtitleJumpTarget,\n context: SlidePlayerNavigationContext\n ) => {\n const targetAudio = audioList[target.audioIndex];\n const targetAudioKey = targetAudio?.audioKey;\n const targetSlideIndex = audioSlideIndexes[target.audioIndex];\n\n if (!targetAudioKey || targetSlideIndex == null) {\n return false;\n }\n\n if (!canJumpToSubtitleTarget(target)) {\n return false;\n }\n\n syncPlaybackPreferenceBeforeNavigation(context);\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n setHasCompletedCurrentStepAudio(false);\n setHasCurrentAudioPlaybackStarted(false);\n\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n\n if (targetSlideIndex === currentIndex) {\n pendingSubtitleJumpRef.current = null;\n resetAudioSequence();\n setCurrentAudioKey(targetAudioKey);\n requestSubtitleCueSeek(target);\n return true;\n }\n\n shouldScrollToBottomRef.current = true;\n resetAudioSequence();\n pendingSubtitleJumpRef.current = {\n audioIndex: target.audioIndex,\n audioKey: targetAudioKey,\n slideIndex: targetSlideIndex,\n timeMs: target.timeMs,\n };\n goTo(targetSlideIndex);\n\n return true;\n },\n [\n audioList,\n audioSlideIndexes,\n canJumpToSubtitleTarget,\n currentIndex,\n goTo,\n requestSubtitleCueSeek,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n useEffect(() => {\n if (\n !playbackResumeRequest ||\n playbackResumeRequest.id === lastPlaybackResumeRequestIdRef.current\n ) {\n return;\n }\n\n const audioIndex = audioList.findIndex(\n (audioItem) => audioItem.audioKey === playbackResumeRequest.audioKey\n );\n if (audioIndex < 0) {\n return;\n }\n\n const accepted = handleSubtitleJump(\n {\n audioIndex,\n timeMs: playbackResumeRequest.timeMs,\n },\n {\n shouldContinuePlayback: false,\n shouldWakeControls: false,\n }\n );\n if (accepted) {\n lastPlaybackResumeRequestIdRef.current = playbackResumeRequest.id;\n }\n }, [audioList, handleSubtitleJump, playbackResumeRequest]);\n\n const handlePlayerPlaybackTimeChange = useCallback(\n (timeMs: number) => {\n playbackTimeStore.setTime(timeMs);\n\n if (!currentAudioItem?.audioKey) {\n return;\n }\n\n onPlaybackPositionChange?.({\n audioKey: currentAudioItem.audioKey,\n element: currentAudioItem.element,\n timeMs,\n });\n },\n [currentAudioItem, onPlaybackPositionChange, playbackTimeStore]\n );\n\n const handlePrev = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goPrev();\n },\n [\n goPrev,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handleNext = useCallback(\n (context?: SlidePlayerNavigationContext) => {\n syncPlaybackPreferenceBeforeNavigation(context);\n shouldScrollToBottomRef.current = true;\n pendingInteractionOverlayStepIndexRef.current = null;\n setIsAudioLoadingVisible(false);\n if (shouldWakePlayerControlsAfterNavigation(context)) {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }\n resetAudioSequence();\n goNext();\n },\n [\n goNext,\n resetAudioSequence,\n revealPlayerControls,\n syncPlaybackPreferenceBeforeNavigation,\n ]\n );\n\n const handlePlayerLoadingChange = useCallback(\n ({\n loading,\n reason,\n }: {\n loading: boolean;\n reason: SlidePlayerLoadingReason | null;\n }) => {\n if (disableLoadingOverlay) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (!currentStepHasSpeakableElement || hasCompletedCurrentStepAudio) {\n setIsAudioLoadingVisible(false);\n return;\n }\n\n if (loading && reason) {\n setAudioLoadingReason(reason);\n }\n setIsAudioLoadingVisible(shouldShowBufferingOverlay(reason, loading));\n },\n [\n currentStepHasSpeakableElement,\n hasCompletedCurrentStepAudio,\n disableLoadingOverlay,\n ]\n );\n\n useEffect(() => {\n if (!disableLoadingOverlay) {\n return;\n }\n\n setIsAudioLoadingVisible(false);\n }, [disableLoadingOverlay]);\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 playedAudioKeysRef.current.add(endedAudioKey);\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 return;\n }\n },\n [\n audioList,\n canGoNext,\n currentIndex,\n currentAudioKey,\n currentAudioSequenceKeys,\n goNext,\n hasCurrentStepAudioUrl,\n slideElementList,\n ]\n );\n\n const handlePlayerControlsPointerEnter = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = true;\n clearPlayerHideTimer();\n\n if (shouldMountPlayer) {\n setIsPlayerVisible(true);\n }\n }, [clearPlayerHideTimer, shouldMountPlayer]);\n\n const handlePlayerControlsPointerLeave = useCallback(() => {\n isPointerInsidePlayerControlsRef.current = false;\n revealPlayerControls(true);\n }, [revealPlayerControls]);\n\n const stopOverlayPropagation = useCallback(\n (\n event: React.PointerEvent<HTMLElement> | React.MouseEvent<HTMLElement>\n ) => {\n event.stopPropagation();\n\n // Keep the player visible a bit longer when users interact with the overlay.\n if (playerControlsVisible) {\n revealPlayerControls(true);\n }\n },\n [playerControlsVisible, revealPlayerControls]\n );\n\n const getInteractionOverlayDragBounds = useCallback(\n (\n overlayElement: HTMLElement,\n startOffset: InteractionOverlayDragOffset\n ): InteractionOverlayDragBounds | null => {\n const viewportElement = viewportRef.current;\n\n if (!viewportElement) {\n return null;\n }\n\n const overlayRect = overlayElement.getBoundingClientRect();\n const viewportRect = viewportElement.getBoundingClientRect();\n\n return {\n minX: startOffset.x + viewportRect.left - overlayRect.left,\n maxX: startOffset.x + viewportRect.right - overlayRect.right,\n minY: startOffset.y + viewportRect.top - overlayRect.top,\n maxY: startOffset.y + viewportRect.bottom - overlayRect.bottom,\n };\n },\n []\n );\n\n useIsomorphicLayoutEffect(() => {\n const overlayElement = interactionOverlayRef.current;\n\n if (!shouldShowInteractionOverlay || !overlayElement) {\n interactionOverlayLayoutRectRef.current = null;\n return;\n }\n\n const previousRect = interactionOverlayLayoutRectRef.current;\n const currentRect = overlayElement.getBoundingClientRect();\n\n if (!previousRect || isInteractionOverlayDragging) {\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left,\n top: currentRect.top,\n };\n return;\n }\n\n const deltaX = previousRect.left - currentRect.left;\n const deltaY = previousRect.top - currentRect.top;\n\n if (\n !hasMeaningfulInteractionOverlayLayoutDelta(deltaX) &&\n !hasMeaningfulInteractionOverlayLayoutDelta(deltaY)\n ) {\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left,\n top: currentRect.top,\n };\n return;\n }\n\n const nextOffset = {\n x: interactionOverlayDragOffset.x + deltaX,\n y: interactionOverlayDragOffset.y + deltaY,\n };\n const bounds = getInteractionOverlayDragBounds(\n overlayElement,\n interactionOverlayDragOffset\n );\n const clampedOffset = normalizeInteractionOverlayDragOffset(\n bounds\n ? clampInteractionOverlayDragOffset(nextOffset, bounds)\n : nextOffset\n );\n\n interactionOverlayLayoutRectRef.current = {\n left: currentRect.left + clampedOffset.x - interactionOverlayDragOffset.x,\n top: currentRect.top + clampedOffset.y - interactionOverlayDragOffset.y,\n };\n\n if (\n !areInteractionOverlayDragOffsetsEqual(\n clampedOffset,\n interactionOverlayDragOffset\n )\n ) {\n setInteractionOverlayDragOffset((previousOffset) =>\n areInteractionOverlayDragOffsetsEqual(previousOffset, clampedOffset)\n ? previousOffset\n : clampedOffset\n );\n }\n }, [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n isInteractionOverlayDragging,\n playerLayoutReserved,\n shouldShowInteractionOverlay,\n ]);\n\n const handleInteractionOverlayPointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n stopOverlayPropagation(event);\n\n if (\n event.button !== 0 ||\n !event.currentTarget.isConnected ||\n !interactionOverlayRef.current\n ) {\n return;\n }\n\n const bounds = getInteractionOverlayDragBounds(\n interactionOverlayRef.current,\n interactionOverlayDragOffset\n );\n\n if (!bounds) {\n return;\n }\n\n event.preventDefault();\n if (event.currentTarget.hasPointerCapture?.(event.pointerId) !== true) {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n interactionOverlayDragRef.current = {\n pointerId: event.pointerId,\n startClientX: event.clientX,\n startClientY: event.clientY,\n startOffset: interactionOverlayDragOffset,\n bounds,\n };\n setIsInteractionOverlayDragging(true);\n },\n [\n getInteractionOverlayDragBounds,\n interactionOverlayDragOffset,\n stopOverlayPropagation,\n ]\n );\n\n const handleInteractionOverlayPointerMove = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n setInteractionOverlayDragOffset(\n clampInteractionOverlayDragOffset(\n {\n x: dragState.startOffset.x + event.clientX - dragState.startClientX,\n y: dragState.startOffset.y + event.clientY - dragState.startClientY,\n },\n dragState.bounds\n )\n );\n },\n []\n );\n\n const endInteractionOverlayDrag = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n const dragState = interactionOverlayDragRef.current;\n\n if (!dragState || dragState.pointerId !== event.pointerId) {\n return;\n }\n\n event.stopPropagation();\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n interactionOverlayDragRef.current = null;\n setIsInteractionOverlayDragging(false);\n },\n []\n );\n\n const handleSurfacePointerDown = useCallback(\n (event: React.PointerEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onPointerDown?.(event);\n },\n [activateKeyboardShortcutOwner, onPointerDown]\n );\n\n const handleSurfaceFocusCapture = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n activateKeyboardShortcutOwner();\n onFocusCapture?.(event);\n },\n [activateKeyboardShortcutOwner, onFocusCapture]\n );\n\n const handleSurfaceClick = useCallback(() => {\n setHasPlayerInteracted(true);\n revealPlayerControls(true);\n }, [revealPlayerControls]);\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 isDesktopBrowserFullscreen && \"slide--browser-fullscreen\",\n isImmersiveMobileFullscreen && \"slide--mobile-landscape\",\n isNativeMobileFullscreen && \"slide--mobile-landscape-native\",\n className\n )}\n dir={direction}\n lang={language}\n onClick={handleSurfaceClick}\n onFocusCapture={handleSurfaceFocusCapture}\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={\n fullscreenHeader?.backAriaLabel ??\n localeTexts.fullscreenBackAriaLabel\n }\n className=\"slide-landscape-header__back\"\n onClick={handleFullscreenHeaderBack}\n type=\"button\"\n >\n <ChevronLeft\n className=\"slide-landscape-header__icon h-6 w-6\"\n strokeWidth={2.25}\n />\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 data-active-step={isActiveStep ? \"true\" : undefined}\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={resolveBufferingTextByReason(\n resolvedBufferingText,\n audioLoadingReason\n )}\n className=\"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2\"\n />\n ) : null}\n\n <SubtitleOverlay\n extraBottomOffset={interactionOverlaySubtitleOffset}\n hasPlayerGap={playerLayoutReserved}\n isEnabled={isSubtitleEnabled && hasCurrentAudioPlaybackStarted}\n playbackTimeStore={playbackTimeStore}\n subtitleCues={currentSubtitleCues}\n />\n\n {shouldShowInteractionOverlay ? (\n <div\n ref={interactionOverlayRef}\n data-player-keyboard-shortcuts-ignore=\"true\"\n className={cn(\n \"slide-interaction-overlay\",\n playerLayoutReserved\n ? \"slide-interaction-overlay--with-player\"\n : \"slide-interaction-overlay--standalone\",\n isInteractionOverlayDragging &&\n \"slide-interaction-overlay--dragging\"\n )}\n onClick={stopOverlayPropagation}\n onPointerDownCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onFocusCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n onInputCapture={(event) => {\n if (isInteractionActivityTarget(event.target)) {\n setHasInteractionOverlayActivity(true);\n }\n }}\n style={interactionOverlayStyle}\n >\n <InteractionOverlayCard\n dir={direction}\n lang={language}\n content={String(activeInteractionElement?.content ?? \"\")}\n dragHandleAriaLabel={\n interactionTexts?.dragHandleAriaLabel ??\n localeTexts.interactionTexts.dragHandleAriaLabel\n }\n locale={locale}\n defaultButtonText={interactionDefaults.buttonText ?? \"\"}\n defaultInputText={interactionDefaults.inputText ?? \"\"}\n defaultSelectedValues={interactionDefaultSelectedValues}\n confirmButtonText={\n interactionTexts?.confirmButtonText ??\n localeTexts.interactionTexts.confirmButtonText\n }\n copyButtonText={\n interactionTexts?.copyButtonText ??\n localeTexts.interactionTexts.copyButtonText\n }\n copiedButtonText={\n interactionTexts?.copiedButtonText ??\n localeTexts.interactionTexts.copiedButtonText\n }\n onSend={handleInteractionSend}\n onDragHandlePointerCancel={endInteractionOverlayDrag}\n onDragHandlePointerDown={handleInteractionOverlayPointerDown}\n onDragHandlePointerMove={handleInteractionOverlayPointerMove}\n onDragHandlePointerUp={endInteractionOverlayDrag}\n readonly={isInteractionReadonly}\n title={\n interactionTexts?.title ??\n interactionTitle ??\n localeTexts.interactionTexts.title\n }\n />\n </div>\n ) : null}\n\n {shouldMountPlayer ? (\n <PlayerKeyboardShortcutContext.Provider\n value={keyboardShortcutContextValue}\n >\n <Player\n dir={direction === \"auto\" ? resolvedDirection : direction}\n lang={language}\n audioList={audioList}\n className={cn(\n \"absolute left-1/2 z-[2] -translate-x-1/2\",\n isDesktopBrowserFullscreen ? \"bottom-3\" : \"-bottom-3\",\n playerClassName,\n !playerControlsVisible && \"pointer-events-none opacity-0\"\n )}\n currentAudioIndex={currentAudioIndex}\n defaultPlaying={isPlaybackRequested}\n enableKeyboardShortcuts={enableKeyboardShortcuts}\n isPlaybackPaused={shouldPausePlaybackForCustomAction}\n isAutoAdvanceEnabled={isAutoAdvanceEnabled}\n locale={locale}\n isInteractionOpen={isInteractionOverlayOpen}\n isSubtitleEnabled={isSubtitleEnabled}\n onAutoAdvanceToggle={setIsAutoAdvanceEnabled}\n onLoadingChange={handlePlayerLoadingChange}\n onPlaybackStarted={() => {\n setHasCurrentAudioPlaybackStarted(true);\n }}\n onPlaybackPreferenceChange={handlePlaybackPreferenceChange}\n onPlaybackTimeChange={handlePlayerPlaybackTimeChange}\n onSubtitleToggle={() => {\n setIsSubtitleEnabled((previousEnabled) => !previousEnabled);\n }}\n nextDisabled={!canGoNext}\n onEnded={handlePlayerEnded}\n onFullscreen={handleFullscreen}\n isFullscreen={isBrowserFullscreen}\n mobileViewMode={effectiveMobileViewMode}\n settingsPortalContainer={viewportRef.current}\n onMobileViewModeChange={handleMobileViewModeSelect}\n onControlsPointerEnter={handlePlayerControlsPointerEnter}\n onControlsPointerLeave={handlePlayerControlsPointerLeave}\n onNext={handleNext}\n onPrev={handlePrev}\n onSubtitleJump={handleSubtitleJump}\n canJumpToSubtitleTarget={canJumpToSubtitleTarget}\n prevDisabled={!canGoPrev}\n showControls={playerControlsVisible}\n subtitleSeekRequest={subtitleSeekRequest}\n texts={playerTexts}\n customActionContext={playerCustomActionContext}\n customActions={playerCustomActions}\n useAutoAdvanceToggle={shouldUseSilentStepAutoAdvanceToggle}\n />\n </PlayerKeyboardShortcutContext.Provider>\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","DEFAULT_RESOLVED_INTERACTION_AUTO_CLOSE_DELAY_MS","DEFAULT_INTERACTION_OVERLAY_DRAG_OFFSET","INTERACTION_OVERLAY_LAYOUT_EPSILON_PX","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","INTERACTION_ACTIVITY_SELECTOR","DEFAULT_BUFFERING_REASON","normalizeInteractionOverlayDragOffset","x","y","hasMeaningfulInteractionOverlayLayoutDelta","delta","areInteractionOverlayDragOffsetsEqual","first","second","resolveBufferingTextByReason","bufferingText","reason","DEFAULT_SLIDE_BUFFERING_TEXTS","mergeBufferingTextWithLocaleDefaults","localeBufferingText","shouldShowBufferingOverlay","loading","InteractionOverlayCard","memo","content","title","dragHandleAriaLabel","locale","dir","lang","defaultButtonText","defaultInputText","defaultSelectedValues","confirmButtonText","copyButtonText","copiedButtonText","onSend","onDragHandlePointerCancel","onDragHandlePointerDown","onDragHandlePointerMove","onDragHandlePointerUp","readonly","jsxs","jsx","GripHorizontal","ContentRender","areStepElementListsEqual","prevElementList","nextElementList","element","index","nextElement","isInteractionActivityTarget","target","Slide","elementList","playerEnabled","playerControlsVisibility","playerClassName","fullscreenHeader","playerCustomActions","playerCustomActionPauseOnActive","interactionTitle","interactionTexts","playerTexts","playerAutoHideDelay","markerAutoAdvanceDelay","interactionDefaultValueOptions","onPlayerVisibilityChange","onMobileViewModeChange","onStepChange","onPlaybackPositionChange","playbackResumeRequest","requestedStepIndex","enableKeyboardShortcuts","enableIframeScaling","enableMarkdownScaling","disableLoadingOverlay","className","onPointerDown","onFocusCapture","props","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","localeTexts","useMemo","getSlideLocaleTexts","resolvedBufferingText","resolvedPlayerEnabled","resolvedPlayerControlsVisibility","resolveSlidePlayerVisibility","keyboardShortcutOwnerId","useId","sectionRef","useRef","resolvedDirection","useResolvedDirection","viewportRef","stageLayerRef","lastElementRef","playerHideTimerRef","isPointerInsidePlayerControlsRef","autoAdvanceTimerRef","imageOnlyStepReadyTimeoutRef","interactionAutoCloseTimerRef","interactionOverlayOpenTimerRef","interactionOverlayRef","interactionOverlayLayoutRectRef","interactionOverlayDragRef","prevRenderElementKeysRef","shouldScrollToBottomRef","pendingInteractionOverlayStepIndexRef","pendingSubtitleJumpRef","subtitleSeekRequestIdRef","lastPlaybackResumeRequestIdRef","playbackResetKeyRef","appendedMarkerAdvanceStateRef","shouldSkipDefaultAudioStartForSubtitleJumpRef","currentElementList","stepElementLists","slideElementList","currentIndex","audioList","audioSlideIndexes","currentAudioSequenceIndexes","currentStepHasSpeakableElement","currentInteractionElement","canGoPrev","canGoNext","goPrev","goNext","goTo","useSlide","lastRequestedStepIndexRef","requestedStepNavigation","resolveRequestedStepNavigation","currentStepElement","currentRenderElementKeys","isSingleSlide","shouldMountPlayer","keyboardShortcutContextValue","activateKeyboardShortcutOwner","useCallback","activatePlayerKeyboardShortcutOwner","currentAudioSequenceKeys","audioIndex","audioKey","isPlayerVisible","setIsPlayerVisible","useState","hasPlayerInteracted","setHasPlayerInteracted","isPlaybackRequested","setIsPlaybackRequested","isAutoAdvanceEnabled","setIsAutoAdvanceEnabled","currentAudioKey","setCurrentAudioKey","subtitleSeekRequest","setSubtitleSeekRequest","isAudioLoadingVisible","setIsAudioLoadingVisible","audioLoadingReason","setAudioLoadingReason","hasCompletedCurrentStepAudio","setHasCompletedCurrentStepAudio","playedAudioKeysRef","hasCurrentAudioPlaybackStarted","setHasCurrentAudioPlaybackStarted","isSubtitleEnabled","setIsSubtitleEnabled","isPlayerCustomActionActive","setIsPlayerCustomActionActive","activeInteractionElement","setActiveInteractionElement","isInteractionOverlayOpen","setIsInteractionOverlayOpen","hasInteractionOverlayActivity","setHasInteractionOverlayActivity","interactionOverlayDragOffset","setInteractionOverlayDragOffset","isInteractionOverlayDragging","setIsInteractionOverlayDragging","interactionOverlaySubtitleOffset","setInteractionOverlaySubtitleOffset","isBrowserFullscreen","setIsBrowserFullscreen","isMobileDevice","getIsMobileDevice","mobileViewMode","setMobileViewMode","DEFAULT_MOBILE_VIEW_MODE","hasManualMobileViewMode","setHasManualMobileViewMode","isViewportFullscreenPreferred","setIsViewportFullscreenPreferred","getIsFullscreenPreferredViewport","playbackTimeStore","createPlaybackTimeStore","effectiveMobileViewMode","isImmersiveMobileFullscreen","isNativeMobileFullscreen","shouldRotateFullscreenViewport","resolveMobileViewModeState","previousEffectiveMobileViewModeRef","playerControlsVisible","playerLayoutReserved","resolveSlidePlayerLayoutState","shouldShowFullscreenHeader","shouldApplyFullscreenViewportPadding","shouldShowMobileFullscreenMask","isDesktopBrowserFullscreen","handleMobileViewModeSelect","nextViewMode","handleMobileViewModeReset","handleFullscreenHeaderBack","clearInteractionAutoCloseTimer","clearInteractionOverlayOpenTimer","closeInteractionOverlayForCustomAction","setPlayerCustomActionActive","active","togglePlayerCustomActionActive","previousActive","resetInteractionOverlayDragState","previousOffset","mountedStepStates","currentMountedStateIndex","nextMountedStepStates","mountedStateIndexByStep","stepElementList","stepIndex","existingMountedStateIndex","mountedStepState","currentStepKey","currentAudioIndex","audioItem","currentAudioItem","currentSubtitleCues","currentAudioSequenceStartKey","playerCustomActionContext","resolvePlayerCustomActionElement","playerCustomActionCount","getPlayerCustomActionCount","hasPlayerCustomActions","isPlayerCustomActionEffectivelyActive","interactionOverlayStyle","hasAvailableStepAudio","currentInteractionResetKey","currentPlaybackResetKey","currentPlaybackStartedResetKey","hasCurrentStepAudioUrl","shouldPausePlaybackForCustomAction","shouldUseSilentStepAutoAdvanceToggle","shouldUseAutoAdvanceToggle","silentStepAutoAdvanceBehavior","resolveSilentStepAutoAdvanceBehavior","silentStepAutoAdvanceDelay","isImageOnlySilentStep","imageOnlyStepVisualReadyKey","readyImageOnlyStepKey","setReadyImageOnlyStepKey","isImageOnlyStepVisualReady","clearPlayerHideTimer","clearAutoAdvanceTimer","clearImageOnlyStepReadyTimeout","resetAudioSequence","options","requestSubtitleCueSeek","startCurrentAudioSequence","nextAudioKey","resolvePendingStepAudioKey","continueAfterInteraction","scheduleInteractionOverlayOpen","interactionElement","openOverlay","isPlayerControlsHovered","revealPlayerControls","enableAutoHide","hasResolvedCurrentInteraction","hasResolvedInteractionElement","shouldBlockPlaybackForInteraction","handlePlaybackPreferenceChange","playing","syncPlaybackPreferenceBeforeNavigation","context","cancelled","rafId","cleanupListeners","detachListeners","finishVisualReady","evaluateVisualReady","activeStepContainer","iframeElements","areImageOnlyStepIframeVisualsReady","cleanupCallbacks","queueRecheck","registerEvent","eventName","listener","iframeElement","iframeDocument","image","cleanup","DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS","syncViewportFullscreenPreference","handleOrientationChange","unsubscribeMobileDeviceChange","subscribeMobileDeviceChange","targetStepIndex","previousState","shouldAdvanceIntoAppendedMarker","shouldAutoAdvanceIntoAppendedMarker","handleSandboxInteraction","event","isSandboxInteractionMessage","useWakePlayerFromIframe","hasPlaybackContextChanged","shouldInitializeAudioSequence","getPlaybackSequenceTransition","shouldOpenInteractionOverlayAfterAudio","shouldPresentOverlay","shouldPresentInteractionOverlay","pendingSubtitleJump","shouldPreservePendingSubtitleJump","canReachSubtitleJumpTarget","hasUnplayedStepAudio","shouldSkipDefaultAudioStart","shouldStartDefaultAudioSequence","interactionDefaults","interactionDefaultSelectedValues","hasResolvedInteractionInput","resolvedInteractionReadonly","shouldAutoContinueInteraction","resolveSlideInteractionState","isInteractionReadonly","shouldShowInteractionOverlay","shouldRenderInteractionOverlay","handleInteractionSend","resolvedUserInput","prevElement","syncFullscreenState","interactionOverlayElement","updateSubtitleOffset","overlayHeight","resizeObserver","renderSlideElement","Fragment","IframeSandbox","renderSlideElementList","isActiveStep","visibleElementCount","markdownScalingMode","resolveMarkdownScalingMode","lastVisibleElementIndex","lastVisibleIndex","MarkdownSlideScaling","isPreRenderedHtml","cn","handleFullscreen","scrollStageToBottom","stageLayerElement","canJumpToSubtitleTarget","handleSubtitleJump","targetAudioKey","targetSlideIndex","shouldWakePlayerControlsAfterNavigation","handlePlayerPlaybackTimeChange","timeMs","handlePrev","handleNext","handlePlayerLoadingChange","handlePlayerEnded","endedAudioKey","activeSequencePosition","audioSequenceKey","nextSequencePosition","nextStepIndex","nextStepElement","handlePlayerControlsPointerEnter","handlePlayerControlsPointerLeave","stopOverlayPropagation","getInteractionOverlayDragBounds","overlayElement","startOffset","viewportElement","overlayRect","viewportRect","previousRect","currentRect","deltaX","deltaY","nextOffset","bounds","clampedOffset","clampInteractionOverlayDragOffset","handleInteractionOverlayPointerDown","handleInteractionOverlayPointerMove","dragState","endInteractionOverlayDrag","handleSurfacePointerDown","handleSurfaceFocusCapture","handleSurfaceClick","prevKeys","shouldAutoScrollToAppend","key","animationFrameId","targetElement","stageLayerRect","targetRect","nextScrollTop","ChevronLeft","mountedStepStateIndex","LoadingOverlayCard","SubtitleOverlay","PlayerKeyboardShortcutContext","Player","previousEnabled"],"mappings":"8wDA2GMA,GAAuC,IACvCC,GAA4C,IAC5CC,GAAiD,IACjDC,GAAsC,GACtCC,GAAmD,IACnDC,GAAwE,CAC5E,EAAG,EACH,EAAG,CACL,EACMC,GAAwC,GAExCC,GACJ,OAAO,OAAW,IAAcC,EAAAA,UAAYC,EAAAA,gBACxCC,GAAgC,CACpC,SACA,QACA,WACA,uBACA,2BACA,oCACF,EAAE,KAAK,IAAI,EACLC,GAAiD,kBAEjDC,GAAwC,CAAC,CAC7C,EAAAC,EACA,EAAAC,CACF,KAAmE,CACjE,EAAG,OAAOD,EAAE,QAAQ,CAAC,CAAC,EACtB,EAAG,OAAOC,EAAE,QAAQ,CAAC,CAAC,CACxB,GAEMC,GAA8CC,GAClD,KAAK,IAAIA,CAAK,GAAKV,GAEfW,GAAwC,CAC5CC,EACAC,IAEA,KAAK,IAAID,EAAM,EAAIC,EAAO,CAAC,EAAIb,IAC/B,KAAK,IAAIY,EAAM,EAAIC,EAAO,CAAC,EAAIb,GAQ3Bc,GAA+B,CACnC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