@bendyline/squisq-react 2.11.24 → 2.12.0

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,12 +1,12 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-E7UE2PCJ.js";
3
+ } from "./chunk-2K74UJ4T.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
7
7
  useMediaSchedule,
8
8
  useViewportOrientation
9
- } from "./chunk-245G4EEN.js";
9
+ } from "./chunk-AA6NGEP7.js";
10
10
  import {
11
11
  useAutoSurface
12
12
  } from "./chunk-TT6ENR6T.js";
@@ -15,19 +15,78 @@ import {
15
15
  } from "./chunk-T7NVETOH.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-TN3NQAFM.js";
18
+ } from "./chunk-XSSIHHDY.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-5OA2DYA2.js";
22
+ } from "./chunk-3RVUSY4V.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
26
26
  useResourcePolicy
27
27
  } from "./chunk-HCKL2AFN.js";
28
28
 
29
+ // src/hooks/useBuildNavigation.ts
30
+ import { useCallback, useEffect, useMemo, useState } from "react";
31
+ import { blockBuildSteps, buildSourceText } from "@bendyline/squisq/doc";
32
+ function identity(block) {
33
+ return block ? `${block.id}:${JSON.stringify(block.build)}:${buildSourceText(blockBuildSteps(block))}` : "";
34
+ }
35
+ function useBuildNavigation(block, enabled, motion) {
36
+ const key = identity(block);
37
+ const count = enabled && block ? blockBuildSteps(block).length : 0;
38
+ const duration = motion ? Math.max(0, block?.build?.duration ?? 0.4) : 0;
39
+ const [state, setState] = useState({ key: "", revealed: 0, progress: 1, started: 0 });
40
+ const revealed = state.key === key ? Math.min(count, state.revealed) : 0;
41
+ const progress = revealed > 0 && state.key === key ? state.progress : 1;
42
+ useEffect(() => {
43
+ if (!enabled || state.key !== key || state.progress >= 1) return;
44
+ let frame = 0;
45
+ const tick = (now) => {
46
+ const next2 = duration === 0 ? 1 : Math.min(1, (now - state.started) / (duration * 1e3));
47
+ setState(
48
+ (current) => current.key === key && current.started === state.started && current.progress < 1 ? { ...current, progress: next2 } : current
49
+ );
50
+ if (next2 < 1) frame = requestAnimationFrame(tick);
51
+ };
52
+ frame = requestAnimationFrame(tick);
53
+ return () => cancelAnimationFrame(frame);
54
+ }, [enabled, key, state.key, state.started, duration]);
55
+ const next = useCallback(() => {
56
+ if (revealed > 0 && progress < 1) {
57
+ setState((current) => ({ ...current, progress: 1 }));
58
+ return true;
59
+ }
60
+ if (revealed >= count) return false;
61
+ const instant = duration === 0 || block?.build?.effect === "appear" || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
62
+ setState({
63
+ key,
64
+ revealed: revealed + 1,
65
+ progress: instant ? 1 : 0,
66
+ started: performance.now()
67
+ });
68
+ return true;
69
+ }, [key, revealed, progress, count, duration, block?.build?.effect]);
70
+ const previous = useCallback(() => {
71
+ if (!revealed) return false;
72
+ setState({ key, revealed: revealed - 1, progress: 1, started: 0 });
73
+ return true;
74
+ }, [key, revealed]);
75
+ const enter = useCallback((target, complete = false) => {
76
+ setState({
77
+ key: identity(target),
78
+ revealed: complete && target ? blockBuildSteps(target).length : 0,
79
+ progress: 1,
80
+ started: 0
81
+ });
82
+ }, []);
83
+ const showAll = useCallback(() => enter(block, true), [enter, block]);
84
+ const cursor = useMemo(() => ({ revealed, progress }), [revealed, progress]);
85
+ return { cursor, count, next, previous, enter, showAll };
86
+ }
87
+
29
88
  // src/MediaClipLayer.tsx
30
- import { useEffect, useRef } from "react";
89
+ import { useEffect as useEffect2, useRef } from "react";
31
90
  import { serializeMediaCrop } from "@bendyline/squisq/mediaEdit";
32
91
 
33
92
  // src/mediaClipPlayback.ts
@@ -241,7 +300,7 @@ function MediaClipElement({
241
300
  const ref = useRef(null);
242
301
  const src = useMediaUrl(clip.src, basePath);
243
302
  const { sourceIn, absoluteStart, absoluteEnd, gain, fadeIn, fadeOut } = clip;
244
- useEffect(() => {
303
+ useEffect2(() => {
245
304
  const el = ref.current;
246
305
  if (!el) return;
247
306
  if (!active) {
@@ -335,7 +394,7 @@ function MediaClipElement({
335
394
  }
336
395
 
337
396
  // src/hooks/useMediaClipDurations.ts
338
- import { useEffect as useEffect2, useMemo, useState } from "react";
397
+ import { useEffect as useEffect3, useMemo as useMemo2, useState as useState2 } from "react";
339
398
  import { isResourceUrlAllowed } from "@bendyline/squisq/markdown";
340
399
  var durationCache = /* @__PURE__ */ new Map();
341
400
  var PROBE_TIMEOUT_MS = 8e3;
@@ -406,15 +465,15 @@ function useMediaClipDurations(schedule, basePath, mediaProviderOverride) {
406
465
  const contextProvider = useMediaProvider();
407
466
  const provider = mediaProviderOverride !== void 0 ? mediaProviderOverride : contextProvider;
408
467
  const resourcePolicy = useResourcePolicy();
409
- const srcKey = useMemo(() => {
468
+ const srcKey = useMemo2(() => {
410
469
  const set = /* @__PURE__ */ new Set();
411
470
  for (const clip of schedule) {
412
471
  if (clip.kind === "video" && clip.src) set.add(clip.src);
413
472
  }
414
473
  return Array.from(set).sort().join("\n");
415
474
  }, [schedule]);
416
- const [durations, setDurations] = useState(() => /* @__PURE__ */ new Map());
417
- useEffect2(() => {
475
+ const [durations, setDurations] = useState2(() => /* @__PURE__ */ new Map());
476
+ useEffect3(() => {
418
477
  const srcs = srcKey ? srcKey.split("\n") : [];
419
478
  if (srcs.length === 0) {
420
479
  setDurations((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Map());
@@ -450,7 +509,7 @@ function useMediaClipDurations(schedule, basePath, mediaProviderOverride) {
450
509
  }
451
510
 
452
511
  // src/SocialCaptionOverlay.tsx
453
- import { useMemo as useMemo2 } from "react";
512
+ import { useMemo as useMemo3 } from "react";
454
513
  import { resolveFontFamily } from "@bendyline/squisq/schemas";
455
514
  import { jsx as jsx2 } from "react/jsx-runtime";
456
515
  function positionStyle(position, portrait) {
@@ -476,6 +535,7 @@ function contrastText(hex) {
476
535
  var TARGET_CHUNK_SIZE = 4;
477
536
  var MIN_CHUNK_SIZE = 2;
478
537
  var MAX_CHUNK_SIZE = 6;
538
+ var SOCIAL_CAPTION_HOLD_SECONDS = 1;
479
539
  function resolvePhraseTiming(phrase) {
480
540
  if (phrase.words && phrase.words.length > 0) {
481
541
  return phrase.words.map((w) => ({
@@ -527,7 +587,7 @@ function SocialCaptionOverlay({
527
587
  viewport,
528
588
  position = "bottom"
529
589
  }) {
530
- const { chunks } = useMemo2(
590
+ const { chunks } = useMemo3(
531
591
  () => captions ? buildWordStream(captions) : { words: [], chunks: [] },
532
592
  [captions]
533
593
  );
@@ -558,17 +618,15 @@ function SocialCaptionOverlay({
558
618
  }
559
619
  }
560
620
  if (!activeChunk) {
561
- for (let i = 0; i < chunks.length - 1; i++) {
562
- if (currentTime >= chunks[i].endTime && currentTime < chunks[i + 1].startTime) {
563
- activeChunk = chunks[i];
564
- activeWordIndex = activeChunk.words.length - 1;
621
+ for (let i = chunks.length - 1; i >= 0; i--) {
622
+ if (currentTime >= chunks[i].endTime) {
623
+ if (currentTime < chunks[i].endTime + SOCIAL_CAPTION_HOLD_SECONDS) {
624
+ activeChunk = chunks[i];
625
+ activeWordIndex = activeChunk.words.length - 1;
626
+ }
565
627
  break;
566
628
  }
567
629
  }
568
- if (!activeChunk && chunks.length > 0 && currentTime >= chunks[chunks.length - 1].startTime) {
569
- activeChunk = chunks[chunks.length - 1];
570
- activeWordIndex = activeChunk.words.length - 1;
571
- }
572
630
  }
573
631
  if (!activeChunk) return null;
574
632
  if (activeWordIndex === -1) {
@@ -762,8 +820,9 @@ function formatTime(seconds) {
762
820
  }
763
821
 
764
822
  // src/DocProgressBar.tsx
765
- import { useRef as useRef2, useState as useState2, useCallback } from "react";
823
+ import { useRef as useRef2, useState as useState3, useCallback as useCallback2 } from "react";
766
824
  import { jsx as jsx4, jsxs } from "react/jsx-runtime";
825
+ var PLAYER_ACCENT = "var(--squisq-player-accent, #5b9bd5)";
767
826
  function DocProgressBar({
768
827
  state,
769
828
  actions,
@@ -772,9 +831,9 @@ function DocProgressBar({
772
831
  getBlockTitle
773
832
  }) {
774
833
  const progressBarRef = useRef2(null);
775
- const [hoverPosition, setHoverPosition] = useState2(null);
834
+ const [hoverPosition, setHoverPosition] = useState3(null);
776
835
  const playProgress = state.totalDuration > 0 ? Math.max(0, Math.min(1, state.currentTime / state.totalDuration)) : 0;
777
- const handleProgressHover = useCallback((e) => {
836
+ const handleProgressHover = useCallback2((e) => {
778
837
  const bar = progressBarRef.current;
779
838
  if (!bar) return;
780
839
  const rect = bar.getBoundingClientRect();
@@ -782,10 +841,10 @@ function DocProgressBar({
782
841
  const progress = Math.max(0, Math.min(1, x / rect.width));
783
842
  setHoverPosition(progress);
784
843
  }, []);
785
- const handleProgressLeave = useCallback(() => {
844
+ const handleProgressLeave = useCallback2(() => {
786
845
  setHoverPosition(null);
787
846
  }, []);
788
- const handleProgressKeyDown = useCallback(
847
+ const handleProgressKeyDown = useCallback2(
789
848
  (e) => {
790
849
  let next = null;
791
850
  switch (e.key) {
@@ -810,7 +869,7 @@ function DocProgressBar({
810
869
  },
811
870
  [actions, state.currentTime, state.totalDuration]
812
871
  );
813
- const getBlockAtTimeLocal = useCallback(
872
+ const getBlockAtTimeLocal = useCallback2(
814
873
  (time) => {
815
874
  for (let i = expandedBlocks.length - 1; i >= 0; i--) {
816
875
  const blk = expandedBlocks[i];
@@ -881,7 +940,7 @@ function DocProgressBar({
881
940
  left: 0,
882
941
  width: `${playProgress * 100}%`,
883
942
  height: "6px",
884
- background: "#5b9bd5",
943
+ background: PLAYER_ACCENT,
885
944
  borderRadius: "3px"
886
945
  }
887
946
  }
@@ -908,7 +967,7 @@ function DocProgressBar({
908
967
  height: "14px",
909
968
  padding: 0,
910
969
  backgroundColor: active ? "#ffffff" : "rgba(255,255,255,0.75)",
911
- border: "2px solid #5b9bd5",
970
+ border: `2px solid ${PLAYER_ACCENT}`,
912
971
  boxShadow: "0 1px 3px rgba(0,0,0,0.5)",
913
972
  zIndex: 3
914
973
  } : {
@@ -1222,8 +1281,8 @@ function DocControlsOverlay({
1222
1281
  }
1223
1282
 
1224
1283
  // src/DocControlsSlideshow.tsx
1225
- import { useCallback as useCallback2, useEffect as useEffect3, useId, useLayoutEffect, useRef as useRef3, useState as useState3 } from "react";
1226
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1284
+ import { useCallback as useCallback3, useEffect as useEffect4, useId, useLayoutEffect, useRef as useRef3, useState as useState4 } from "react";
1285
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1227
1286
  function DocControlsSlideshow({
1228
1287
  state,
1229
1288
  slideNav,
@@ -1231,16 +1290,16 @@ function DocControlsSlideshow({
1231
1290
  pickerOpen,
1232
1291
  onPickerOpenChange
1233
1292
  }) {
1234
- const [uncontrolledPickerOpen, setUncontrolledPickerOpen] = useState3(false);
1293
+ const [uncontrolledPickerOpen, setUncontrolledPickerOpen] = useState4(false);
1235
1294
  const isPickerOpen = pickerOpen ?? uncontrolledPickerOpen;
1236
- const setPickerOpen = useCallback2(
1295
+ const setPickerOpen = useCallback3(
1237
1296
  (open) => {
1238
1297
  if (pickerOpen === void 0) setUncontrolledPickerOpen(open);
1239
1298
  onPickerOpenChange?.(open);
1240
1299
  },
1241
1300
  [pickerOpen, onPickerOpenChange]
1242
1301
  );
1243
- const [pickerMaxHeight, setPickerMaxHeight] = useState3(280);
1302
+ const [pickerMaxHeight, setPickerMaxHeight] = useState4(280);
1244
1303
  const controlsRef = useRef3(null);
1245
1304
  const triggerRef = useRef3(null);
1246
1305
  const menuRef = useRef3(null);
@@ -1252,10 +1311,10 @@ function DocControlsSlideshow({
1252
1311
  totalBlocks,
1253
1312
  totalSlideNumber
1254
1313
  } = state;
1255
- const isFirst = currentBlockIndex <= 0;
1256
- const isLast = currentBlockIndex >= totalBlocks - 1;
1314
+ const isFirst = currentBlockIndex <= 0 && !(state.buildStep && state.buildStep > 0);
1315
+ const isLast = currentBlockIndex >= totalBlocks - 1 && (state.buildStep ?? 0) >= (state.buildCount ?? 0) && !state.isBuilding;
1257
1316
  const counterText = totalBlocks > 0 ? currentSlideLabel ?? `${currentSlideNumber ?? currentBlockIndex + 1} / ${totalSlideNumber ?? totalBlocks}` : "\u2014";
1258
- useEffect3(() => {
1317
+ useEffect4(() => {
1259
1318
  if (!isPickerOpen) return;
1260
1319
  const handlePointerDown = (event) => {
1261
1320
  if (!controlsRef.current?.contains(event.target)) setPickerOpen(false);
@@ -1294,7 +1353,7 @@ function DocControlsSlideshow({
1294
1353
  window.removeEventListener("resize", updateMaxHeight);
1295
1354
  };
1296
1355
  }, [isPickerOpen]);
1297
- useEffect3(() => {
1356
+ useEffect4(() => {
1298
1357
  if (!isPickerOpen) return;
1299
1358
  menuRef.current?.querySelector('[aria-current="true"]')?.focus();
1300
1359
  }, [isPickerOpen]);
@@ -1340,11 +1399,11 @@ function DocControlsSlideshow({
1340
1399
  {
1341
1400
  onClick: (e) => {
1342
1401
  e.stopPropagation();
1343
- slideNav.prevSlide();
1402
+ (slideNav.prevStep ?? slideNav.prevSlide)();
1344
1403
  },
1345
1404
  disabled: isFirst,
1346
1405
  "data-testid": "slide-prev",
1347
- "aria-label": "Previous slide",
1406
+ "aria-label": state.buildCount ? "Previous build or slide" : "Previous slide",
1348
1407
  title: "Previous slide",
1349
1408
  style: {
1350
1409
  background: "none",
@@ -1495,16 +1554,46 @@ function DocControlsSlideshow({
1495
1554
  })
1496
1555
  }
1497
1556
  ),
1557
+ !!state.buildCount && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1558
+ /* @__PURE__ */ jsxs4("span", { role: "status", style: { color: "inherit", fontSize: 12 }, children: [
1559
+ "Build ",
1560
+ state.buildStep ?? 0,
1561
+ " of ",
1562
+ state.buildCount
1563
+ ] }),
1564
+ /* @__PURE__ */ jsx7(
1565
+ "button",
1566
+ {
1567
+ type: "button",
1568
+ onClick: (event) => {
1569
+ event.stopPropagation();
1570
+ slideNav.showAllBuilds?.();
1571
+ },
1572
+ "aria-label": "Show all build steps",
1573
+ style: {
1574
+ background: "none",
1575
+ color: "inherit",
1576
+ border: "1px solid currentColor",
1577
+ borderRadius: 4,
1578
+ padding: "4px 8px",
1579
+ cursor: "pointer",
1580
+ font: "inherit",
1581
+ fontSize: 12
1582
+ },
1583
+ children: "Show all"
1584
+ }
1585
+ )
1586
+ ] }),
1498
1587
  /* @__PURE__ */ jsx7(
1499
1588
  "button",
1500
1589
  {
1501
1590
  onClick: (e) => {
1502
1591
  e.stopPropagation();
1503
- slideNav.nextSlide();
1592
+ (slideNav.nextStep ?? slideNav.nextSlide)();
1504
1593
  },
1505
1594
  disabled: isLast,
1506
1595
  "data-testid": "slide-next",
1507
- "aria-label": "Next slide",
1596
+ "aria-label": state.buildCount ? "Next build or slide" : "Next slide",
1508
1597
  title: "Next slide",
1509
1598
  style: {
1510
1599
  background: "none",
@@ -1533,7 +1622,7 @@ function DocControlsSlideshow({
1533
1622
  }
1534
1623
 
1535
1624
  // src/DashboardView.tsx
1536
- import { Fragment as Fragment2, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4 } from "react";
1625
+ import { Fragment as Fragment3, useEffect as useEffect5, useMemo as useMemo4, useRef as useRef4 } from "react";
1537
1626
  import { materializeDashboard, resolveThemeForDoc, VIEWPORT_PRESETS } from "@bendyline/squisq/doc";
1538
1627
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1539
1628
  async function waitForDashboardAssets(root) {
@@ -1581,9 +1670,9 @@ function DashboardView({
1581
1670
  className
1582
1671
  }) {
1583
1672
  const rootRef = useRef4(null);
1584
- const activeTheme = useMemo3(() => theme ?? resolveThemeForDoc(doc), [theme, doc]);
1673
+ const activeTheme = useMemo4(() => theme ?? resolveThemeForDoc(doc), [theme, doc]);
1585
1674
  const activeViewport = viewport ?? VIEWPORT_PRESETS.landscape;
1586
- const materialization = useMemo3(
1675
+ const materialization = useMemo4(
1587
1676
  () => materializeDashboard(doc, {
1588
1677
  theme: activeTheme,
1589
1678
  viewport: activeViewport,
@@ -1594,19 +1683,19 @@ function DashboardView({
1594
1683
  }),
1595
1684
  [doc, activeTheme, activeViewport, layout, showTitle, style, documentTitle]
1596
1685
  );
1597
- const backdropBottom = useMemo3(
1686
+ const backdropBottom = useMemo4(
1598
1687
  () => syntheticBlock("dashboard-backdrop-bottom", materialization.backdrop.bottomLayers),
1599
1688
  [materialization]
1600
1689
  );
1601
- const backdropTop = useMemo3(
1690
+ const backdropTop = useMemo4(
1602
1691
  () => materialization.backdrop.topLayers.length > 0 ? syntheticBlock("dashboard-backdrop-top", materialization.backdrop.topLayers) : null,
1603
1692
  [materialization]
1604
1693
  );
1605
- const titleBlock = useMemo3(
1694
+ const titleBlock = useMemo4(
1606
1695
  () => materialization.title ? syntheticBlock("dashboard-title-band", materialization.title.layers) : null,
1607
1696
  [materialization]
1608
1697
  );
1609
- useEffect4(() => {
1698
+ useEffect5(() => {
1610
1699
  if (!renderMode || !onRenderAPIReady) return;
1611
1700
  const api = {
1612
1701
  seekTo: async () => {
@@ -1669,7 +1758,7 @@ function DashboardView({
1669
1758
  theme: activeTheme
1670
1759
  }
1671
1760
  ) }),
1672
- materialization.cells.map((cell) => /* @__PURE__ */ jsxs5(Fragment2, { children: [
1761
+ materialization.cells.map((cell) => /* @__PURE__ */ jsxs5(Fragment3, { children: [
1673
1762
  cell.frame && /* @__PURE__ */ jsx8(
1674
1763
  "div",
1675
1764
  {
@@ -1808,11 +1897,11 @@ function DashboardView({
1808
1897
 
1809
1898
  // src/FlashcardView.tsx
1810
1899
  import {
1811
- useCallback as useCallback3,
1812
- useEffect as useEffect5,
1813
- useMemo as useMemo4,
1900
+ useCallback as useCallback4,
1901
+ useEffect as useEffect6,
1902
+ useMemo as useMemo5,
1814
1903
  useRef as useRef5,
1815
- useState as useState4
1904
+ useState as useState5
1816
1905
  } from "react";
1817
1906
  import { resolveFontFamily as resolveFontFamily2, VIEWPORT_PRESETS as VIEWPORT_PRESETS2 } from "@bendyline/squisq/schemas";
1818
1907
  import {
@@ -1821,7 +1910,7 @@ import {
1821
1910
  resolvePageBlock,
1822
1911
  resolveThemeForDoc as resolveThemeForDoc2
1823
1912
  } from "@bendyline/squisq/doc";
1824
- import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1913
+ import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1825
1914
  var VISUAL_TEMPLATES = /* @__PURE__ */ new Set([
1826
1915
  "diagram",
1827
1916
  "tree",
@@ -1863,7 +1952,7 @@ function FaceBlock({
1863
1952
  customTemplates
1864
1953
  }) {
1865
1954
  const Heading = depth === 0 ? "h2" : depth === 1 ? "h3" : "h4";
1866
- const visualBlock = useMemo4(
1955
+ const visualBlock = useMemo5(
1867
1956
  () => resolveVisualBlock(block, theme, viewport, customTemplates),
1868
1957
  [block, customTemplates, theme, viewport]
1869
1958
  );
@@ -1964,53 +2053,53 @@ function FlashcardView({
1964
2053
  viewport = VIEWPORT_PRESETS2.landscape,
1965
2054
  className
1966
2055
  }) {
1967
- const activeTheme = useMemo4(() => theme ?? resolveThemeForDoc2(doc), [doc, theme]);
1968
- const deck = useMemo4(() => materializeFlashcards(doc, { source }), [doc, source]);
1969
- const [shuffleEnabled, setShuffleEnabled] = useState4(initialShuffle);
1970
- const [sessionSeed, setSessionSeed] = useState4(1);
1971
- const [cardIndex, setCardIndex] = useState4(0);
1972
- const [revealed, setRevealed] = useState4(false);
1973
- const [selectedChoiceId, setSelectedChoiceId] = useState4(null);
1974
- const [ratings, setRatings] = useState4({});
1975
- const [retryIds, setRetryIds] = useState4(null);
2056
+ const activeTheme = useMemo5(() => theme ?? resolveThemeForDoc2(doc), [doc, theme]);
2057
+ const deck = useMemo5(() => materializeFlashcards(doc, { source }), [doc, source]);
2058
+ const [shuffleEnabled, setShuffleEnabled] = useState5(initialShuffle);
2059
+ const [sessionSeed, setSessionSeed] = useState5(1);
2060
+ const [cardIndex, setCardIndex] = useState5(0);
2061
+ const [revealed, setRevealed] = useState5(false);
2062
+ const [selectedChoiceId, setSelectedChoiceId] = useState5(null);
2063
+ const [ratings, setRatings] = useState5({});
2064
+ const [retryIds, setRetryIds] = useState5(null);
1976
2065
  const cardViewportRef = useRef5(null);
1977
- const orderedCards = useMemo4(
2066
+ const orderedCards = useMemo5(
1978
2067
  () => shuffleEnabled ? shuffled(deck.cards, `${doc.articleId}:${sessionSeed}`) : [...deck.cards],
1979
2068
  [deck.cards, doc.articleId, sessionSeed, shuffleEnabled]
1980
2069
  );
1981
- const sessionCards = useMemo4(
2070
+ const sessionCards = useMemo5(
1982
2071
  () => retryIds ? retryIds.map((id) => orderedCards.find((card) => card.id === id)).filter((card) => !!card) : orderedCards,
1983
2072
  [orderedCards, retryIds]
1984
2073
  );
1985
2074
  const currentCard = sessionCards[cardIndex];
1986
2075
  const finished = sessionCards.length > 0 && cardIndex >= sessionCards.length;
1987
- const resetPosition = useCallback3(() => {
2076
+ const resetPosition = useCallback4(() => {
1988
2077
  setCardIndex(0);
1989
2078
  setRevealed(false);
1990
2079
  setSelectedChoiceId(null);
1991
2080
  }, []);
1992
- const restart = useCallback3(() => {
2081
+ const restart = useCallback4(() => {
1993
2082
  setRatings({});
1994
2083
  setRetryIds(null);
1995
2084
  resetPosition();
1996
2085
  setSessionSeed((seed) => seed + 1);
1997
2086
  }, [resetPosition]);
1998
- useEffect5(() => {
2087
+ useEffect6(() => {
1999
2088
  setRatings({});
2000
2089
  setRetryIds(null);
2001
2090
  resetPosition();
2002
2091
  }, [deck, resetPosition]);
2003
- useEffect5(() => {
2092
+ useEffect6(() => {
2004
2093
  if (cardViewportRef.current) cardViewportRef.current.scrollTop = 0;
2005
2094
  }, [cardIndex, retryIds]);
2006
- const revealAnswer = useCallback3(() => {
2095
+ const revealAnswer = useCallback4(() => {
2007
2096
  if (!currentCard) return;
2008
2097
  setRevealed(true);
2009
2098
  if (currentCard.kind === "multiple-choice" && selectedChoiceId === null) {
2010
2099
  setRatings((current) => ({ ...current, [currentCard.id]: "again" }));
2011
2100
  }
2012
2101
  }, [currentCard, selectedChoiceId]);
2013
- const nextCard = useCallback3(() => {
2102
+ const nextCard = useCallback4(() => {
2014
2103
  if (!currentCard) return;
2015
2104
  if (!revealed) {
2016
2105
  revealAnswer();
@@ -2020,7 +2109,7 @@ function FlashcardView({
2020
2109
  setRevealed(false);
2021
2110
  setSelectedChoiceId(null);
2022
2111
  }, [currentCard, revealAnswer, revealed]);
2023
- const previousCard = useCallback3(() => {
2112
+ const previousCard = useCallback4(() => {
2024
2113
  if (finished) {
2025
2114
  setCardIndex(Math.max(0, sessionCards.length - 1));
2026
2115
  setRevealed(true);
@@ -2037,7 +2126,7 @@ function FlashcardView({
2037
2126
  setSelectedChoiceId(null);
2038
2127
  }
2039
2128
  }, [cardIndex, finished, revealed, sessionCards.length]);
2040
- const choose = useCallback3(
2129
+ const choose = useCallback4(
2041
2130
  (choice) => {
2042
2131
  if (!currentCard || revealed) return;
2043
2132
  setSelectedChoiceId(choice.id);
@@ -2049,7 +2138,7 @@ function FlashcardView({
2049
2138
  },
2050
2139
  [currentCard, revealed]
2051
2140
  );
2052
- const rate = useCallback3(
2141
+ const rate = useCallback4(
2053
2142
  (rating) => {
2054
2143
  if (!currentCard) return;
2055
2144
  setRatings((current) => ({ ...current, [currentCard.id]: rating }));
@@ -2059,7 +2148,7 @@ function FlashcardView({
2059
2148
  },
2060
2149
  [currentCard]
2061
2150
  );
2062
- const handleShortcut = useCallback3(
2151
+ const handleShortcut = useCallback4(
2063
2152
  (event) => {
2064
2153
  if (event.defaultPrevented || isInteractiveTarget(event.target)) return;
2065
2154
  if (/^[1-9]$/.test(event.key) && currentCard?.kind === "multiple-choice" && !revealed) {
@@ -2080,7 +2169,7 @@ function FlashcardView({
2080
2169
  },
2081
2170
  [choose, currentCard, nextCard, previousCard, revealed]
2082
2171
  );
2083
- useEffect5(() => {
2172
+ useEffect6(() => {
2084
2173
  if (!globalKeyboardShortcuts) return;
2085
2174
  const listener = (event) => handleShortcut(event);
2086
2175
  document.addEventListener("keydown", listener);
@@ -2282,7 +2371,7 @@ function FlashcardView({
2282
2371
  children: "Previous"
2283
2372
  }
2284
2373
  ),
2285
- /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__primary-actions", children: revealed && currentCard.kind === "basic" ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
2374
+ /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__primary-actions", children: revealed && currentCard.kind === "basic" ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
2286
2375
  /* @__PURE__ */ jsx9(
2287
2376
  "button",
2288
2377
  {
@@ -2400,14 +2489,14 @@ function resolveDocPlayerAppearance(doc, overrides = {}) {
2400
2489
 
2401
2490
  // src/DocPlayer.tsx
2402
2491
  import {
2403
- Fragment as Fragment4,
2492
+ Fragment as Fragment5,
2404
2493
  useId as useId2,
2405
2494
  useRef as useRef7,
2406
- useState as useState6,
2407
- useEffect as useEffect7,
2495
+ useState as useState7,
2496
+ useEffect as useEffect8,
2408
2497
  useLayoutEffect as useLayoutEffect2,
2409
- useCallback as useCallback5,
2410
- useMemo as useMemo5
2498
+ useCallback as useCallback6,
2499
+ useMemo as useMemo6
2411
2500
  } from "react";
2412
2501
  import { flushSync } from "react-dom";
2413
2502
  import {
@@ -2420,7 +2509,7 @@ import {
2420
2509
  import { applySurface, pipStyleVars } from "@bendyline/squisq/schemas";
2421
2510
 
2422
2511
  // src/hooks/useSlideSwipe.ts
2423
- import { useCallback as useCallback4, useEffect as useEffect6, useRef as useRef6, useState as useState5 } from "react";
2512
+ import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef6, useState as useState6 } from "react";
2424
2513
  var DISTANCE_RATIO = 0.3;
2425
2514
  var FLICK_VELOCITY = 0.5;
2426
2515
  var MIN_FLICK_DISTANCE = 12;
@@ -2444,8 +2533,8 @@ function decideSwipe({
2444
2533
  }
2445
2534
  function useSlideSwipe(opts) {
2446
2535
  const settleMs = opts.settleMs ?? DEFAULT_SETTLE_MS;
2447
- const [offsetPx, setOffsetPx] = useState5(0);
2448
- const [phase, setPhase] = useState5("idle");
2536
+ const [offsetPx, setOffsetPx] = useState6(0);
2537
+ const [phase, setPhase] = useState6("idle");
2449
2538
  const optsRef = useRef6(opts);
2450
2539
  optsRef.current = opts;
2451
2540
  const dragRef = useRef6(null);
@@ -2453,7 +2542,7 @@ function useSlideSwipe(opts) {
2453
2542
  phaseRef.current = phase;
2454
2543
  const settleTimer = useRef6(null);
2455
2544
  const settleRaf = useRef6(null);
2456
- const clearPending = useCallback4(() => {
2545
+ const clearPending = useCallback5(() => {
2457
2546
  if (settleTimer.current != null) {
2458
2547
  clearTimeout(settleTimer.current);
2459
2548
  settleTimer.current = null;
@@ -2463,7 +2552,7 @@ function useSlideSwipe(opts) {
2463
2552
  settleRaf.current = null;
2464
2553
  }
2465
2554
  }, []);
2466
- const onPointerDown = useCallback4((e) => {
2555
+ const onPointerDown = useCallback5((e) => {
2467
2556
  const o = optsRef.current;
2468
2557
  if (!o.enabled) return;
2469
2558
  if (phaseRef.current === "settling") return;
@@ -2483,7 +2572,7 @@ function useSlideSwipe(opts) {
2483
2572
  setPhase("dragging");
2484
2573
  setOffsetPx(0);
2485
2574
  }, []);
2486
- useEffect6(() => {
2575
+ useEffect7(() => {
2487
2576
  function currentWidth() {
2488
2577
  return optsRef.current.containerRef.current?.getBoundingClientRect().width ?? 0;
2489
2578
  }
@@ -2553,7 +2642,7 @@ function useSlideSwipe(opts) {
2553
2642
  window.removeEventListener("pointercancel", onCancel);
2554
2643
  };
2555
2644
  }, [settleMs]);
2556
- useEffect6(() => {
2645
+ useEffect7(() => {
2557
2646
  if (!opts.enabled) {
2558
2647
  dragRef.current = null;
2559
2648
  clearPending();
@@ -2561,7 +2650,7 @@ function useSlideSwipe(opts) {
2561
2650
  setOffsetPx(0);
2562
2651
  }
2563
2652
  }, [opts.enabled, clearPending]);
2564
- useEffect6(() => clearPending, [clearPending]);
2653
+ useEffect7(() => clearPending, [clearPending]);
2565
2654
  return { offsetPx, phase, onPointerDown };
2566
2655
  }
2567
2656
 
@@ -2651,7 +2740,7 @@ function waitForVisualUpdate() {
2651
2740
  }
2652
2741
  function DocPlayer(props) {
2653
2742
  const { doc, markdown } = props;
2654
- const markdownDoc = useMemo5(
2743
+ const markdownDoc = useMemo6(
2655
2744
  () => !doc && markdown !== void 0 ? markdownToDoc(parseMarkdown(markdown)) : void 0,
2656
2745
  [doc, markdown]
2657
2746
  );
@@ -2681,6 +2770,7 @@ function DocPlayerContent({
2681
2770
  basePath = ".",
2682
2771
  renderMode = false,
2683
2772
  animationsEnabled = true,
2773
+ buildsEnabled = true,
2684
2774
  autoPlay = false,
2685
2775
  loop = false,
2686
2776
  onEnded,
@@ -2733,17 +2823,17 @@ function DocPlayerContent({
2733
2823
  const audioRef = useRef7(null);
2734
2824
  const containerRef = useRef7(null);
2735
2825
  const playerId = `squisq-player-${useId2().replace(/:/g, "")}`;
2736
- const [tapFeedback, setTapFeedback] = useState6(null);
2826
+ const [tapFeedback, setTapFeedback] = useState7(null);
2737
2827
  const tapFeedbackTimer = useRef7();
2738
2828
  const { viewport } = useViewportOrientation();
2739
2829
  const activeViewport = forceViewport || (renderMode ? VIEWPORT_PRESETS3.landscape : viewport);
2740
2830
  const activeOrientation = activeViewport.height > activeViewport.width ? "portrait" : "landscape";
2741
- const isDebugMode = useMemo5(() => {
2831
+ const isDebugMode = useMemo6(() => {
2742
2832
  if (typeof window === "undefined") return false;
2743
2833
  const params = new URLSearchParams(window.location.search);
2744
2834
  return params.get("debug") === "true";
2745
2835
  }, []);
2746
- const syntheticDuration = useMemo5(
2836
+ const syntheticDuration = useMemo6(
2747
2837
  () => audioMode === "synthetic" ? getDocPlaybackDuration(doc) : 0,
2748
2838
  [audioMode, doc]
2749
2839
  );
@@ -2756,7 +2846,7 @@ function DocPlayerContent({
2756
2846
  syntheticDuration
2757
2847
  );
2758
2848
  const audio = externalAudioController || internalAudio;
2759
- useEffect7(() => {
2849
+ useEffect8(() => {
2760
2850
  if (warnedMissingStyles || !isDevEnvironment()) return;
2761
2851
  const el = containerRef.current;
2762
2852
  if (!el || typeof getComputedStyle !== "function") return;
@@ -2785,19 +2875,19 @@ function DocPlayerContent({
2785
2875
  skipToSegment: _skipToSegment,
2786
2876
  restart
2787
2877
  } = audio;
2788
- const [renderClock, setRenderClock] = useState6(null);
2878
+ const [renderClock, setRenderClock] = useState7(null);
2789
2879
  const renderTimeOverride = renderClock?.doc === doc ? renderClock.time : null;
2790
2880
  const currentTime = renderMode ? renderTimeOverride ?? audioCurrentTime : audioCurrentTime;
2791
- const rawSchedule = useMemo5(() => resolveMediaSchedule(doc), [doc]);
2881
+ const rawSchedule = useMemo6(() => resolveMediaSchedule(doc), [doc]);
2792
2882
  const clipDurations = useMediaClipDurations(rawSchedule, basePath);
2793
- const mediaSchedule = useMemo5(
2883
+ const mediaSchedule = useMemo6(
2794
2884
  () => resolveMediaSchedule(doc, {
2795
2885
  intrinsicDuration: (clip) => clipDurations.get(clip.src),
2796
2886
  ...processedAudio ? { processedAudio } : {}
2797
2887
  }),
2798
2888
  [doc, clipDurations, processedAudio]
2799
2889
  );
2800
- const startActiveTimelineMedia = useCallback5(() => {
2890
+ const startActiveTimelineMedia = useCallback6(() => {
2801
2891
  if (renderMode) return;
2802
2892
  const root = containerRef.current;
2803
2893
  if (!root) return;
@@ -2810,11 +2900,11 @@ function DocPlayerContent({
2810
2900
  });
2811
2901
  });
2812
2902
  }, [renderMode]);
2813
- const playWithTimelineMedia = useCallback5(() => {
2903
+ const playWithTimelineMedia = useCallback6(() => {
2814
2904
  startActiveTimelineMedia();
2815
2905
  return play();
2816
2906
  }, [play, startActiveTimelineMedia]);
2817
- const toggleWithTimelineMedia = useCallback5(() => {
2907
+ const toggleWithTimelineMedia = useCallback6(() => {
2818
2908
  if (!isPlaying) startActiveTimelineMedia();
2819
2909
  return toggle();
2820
2910
  }, [isPlaying, startActiveTimelineMedia, toggle]);
@@ -2837,14 +2927,14 @@ function DocPlayerContent({
2837
2927
  return false;
2838
2928
  });
2839
2929
  }, [currentTime]);
2840
- useEffect7(
2930
+ useEffect8(
2841
2931
  () => () => {
2842
2932
  const error = new Error("DocPlayer unmounted before the requested frame committed.");
2843
2933
  renderCommitWaitersRef.current.splice(0).forEach((waiter) => waiter.reject(error));
2844
2934
  },
2845
2935
  []
2846
2936
  );
2847
- const waitForRenderCommit = useCallback5((time) => {
2937
+ const waitForRenderCommit = useCallback6((time) => {
2848
2938
  if (Math.abs(committedRenderTimeRef.current - time) <= RENDER_TIME_EPSILON_SECONDS) {
2849
2939
  return Promise.resolve();
2850
2940
  }
@@ -2852,7 +2942,7 @@ function DocPlayerContent({
2852
2942
  renderCommitWaitersRef.current.push({ time, resolve, reject });
2853
2943
  });
2854
2944
  }, []);
2855
- const handleContainerClick = useCallback5(
2945
+ const handleContainerClick = useCallback6(
2856
2946
  (e) => {
2857
2947
  if (renderMode || isLinearMode) return;
2858
2948
  const target = e.target;
@@ -2877,7 +2967,7 @@ function DocPlayerContent({
2877
2967
  );
2878
2968
  const autoSurface = useAutoSurface(surface === "auto");
2879
2969
  const resolvedSurface = surface === "auto" ? autoSurface : surface;
2880
- const appearance = useMemo5(
2970
+ const appearance = useMemo6(
2881
2971
  () => resolveDocPlayerAppearance(doc, {
2882
2972
  theme,
2883
2973
  videoPresentation,
@@ -2902,13 +2992,13 @@ function DocPlayerContent({
2902
2992
  coverSlidePlayback
2903
2993
  ]
2904
2994
  );
2905
- const effectiveTheme = useMemo5(() => {
2995
+ const effectiveTheme = useMemo6(() => {
2906
2996
  const base = appearance.theme;
2907
2997
  return resolvedSurface ? applySurface(base, resolvedSurface) : base;
2908
2998
  }, [appearance.theme, resolvedSurface]);
2909
- const resolvedPipStyle = useMemo5(() => pipStyleVars(effectiveTheme), [effectiveTheme]);
2999
+ const resolvedPipStyle = useMemo6(() => pipStyleVars(effectiveTheme), [effectiveTheme]);
2910
3000
  const pipVars = resolvedPipStyle;
2911
- const pipFrameStyle = useMemo5(
3001
+ const pipFrameStyle = useMemo6(
2912
3002
  () => ({
2913
3003
  border: resolvedPipStyle["--squisq-pip-border"],
2914
3004
  borderRadius: resolvedPipStyle["--squisq-pip-radius"],
@@ -2916,7 +3006,7 @@ function DocPlayerContent({
2916
3006
  }),
2917
3007
  [resolvedPipStyle]
2918
3008
  );
2919
- const hasAnchoredBlocks = useMemo5(
3009
+ const hasAnchoredBlocks = useMemo6(
2920
3010
  () => doc.blocks.some(
2921
3011
  (block) => typeof block.sourceStartTime === "number"
2922
3012
  ),
@@ -2955,7 +3045,7 @@ function DocPlayerContent({
2955
3045
  // would no longer match live playback.
2956
3046
  useAudioSegmentTiming: audioMode !== "synthetic" || renderMode && hasAnchoredBlocks
2957
3047
  });
2958
- const coverBlock = useMemo5(() => {
3048
+ const coverBlock = useMemo6(() => {
2959
3049
  const startBlockConfig = doc.startBlock;
2960
3050
  if (!appearance.showCoverSlide) return null;
2961
3051
  if (!startBlockConfig) return null;
@@ -2981,10 +3071,10 @@ function DocPlayerContent({
2981
3071
  appearance.coverSlideTemplate
2982
3072
  ]);
2983
3073
  const hasManagedCover = !!coverBlock;
2984
- const [slideshowCoverVisible, setSlideshowCoverVisible] = useState6(false);
2985
- const [isSlideshowPickerOpen, setIsSlideshowPickerOpen] = useState6(false);
3074
+ const [slideshowCoverVisible, setSlideshowCoverVisible] = useState7(false);
3075
+ const [isSlideshowPickerOpen, setIsSlideshowPickerOpen] = useState7(false);
2986
3076
  const slideshowCoverInitKeyRef = useRef7("");
2987
- useEffect7(() => {
3077
+ useEffect8(() => {
2988
3078
  const initKey = `${doc.articleId}:${isSlideshowMode}:${hasManagedCover}:${renderMode}`;
2989
3079
  if (slideshowCoverInitKeyRef.current === initKey) return;
2990
3080
  slideshowCoverInitKeyRef.current = initKey;
@@ -2995,12 +3085,12 @@ function DocPlayerContent({
2995
3085
  setSlideshowCoverVisible(false);
2996
3086
  }
2997
3087
  }, [doc.articleId, isSlideshowMode, hasManagedCover, renderMode, pause]);
2998
- const [coverForced, setCoverForced] = useState6(false);
2999
- const [coverGraceActive, setCoverGraceActive] = useState6(false);
3088
+ const [coverForced, setCoverForced] = useState7(false);
3089
+ const [coverGraceActive, setCoverGraceActive] = useState7(false);
3000
3090
  const coverGraceTimer = useRef7();
3001
3091
  const coverWasShowing = useRef7(false);
3002
3092
  const hasPlayedOnce = useRef7(false);
3003
- useEffect7(() => {
3093
+ useEffect8(() => {
3004
3094
  hasPlayedOnce.current = false;
3005
3095
  coverWasShowing.current = false;
3006
3096
  clearTimeout(coverGraceTimer.current);
@@ -3009,7 +3099,7 @@ function DocPlayerContent({
3009
3099
  }, [doc]);
3010
3100
  const atRest = !!(coverBlock && !isSlideshowMode && !isPlaying && currentTime === 0 && !hasPlayedOnce.current && !renderMode && !autoPlay);
3011
3101
  if (atRest) coverWasShowing.current = true;
3012
- useEffect7(() => {
3102
+ useEffect8(() => {
3013
3103
  if (isPlaying && coverWasShowing.current && coverBlock && !renderMode && !isSlideshowMode) {
3014
3104
  coverWasShowing.current = false;
3015
3105
  hasPlayedOnce.current = true;
@@ -3020,8 +3110,8 @@ function DocPlayerContent({
3020
3110
  );
3021
3111
  }
3022
3112
  }, [isPlaying, coverBlock, renderMode, isSlideshowMode, appearance.coverSlideDuration]);
3023
- useEffect7(() => () => clearTimeout(coverGraceTimer.current), []);
3024
- useEffect7(() => () => clearTimeout(tapFeedbackTimer.current), []);
3113
+ useEffect8(() => () => clearTimeout(coverGraceTimer.current), []);
3114
+ useEffect8(() => () => clearTimeout(tapFeedbackTimer.current), []);
3025
3115
  const showVideoCoverBlock = !isLinearMode && !!coverBlock && (coverForced || !isSlideshowMode && (coverGraceActive || !isPlaying && currentTime === 0 && !hasPlayedOnce.current && !renderMode && !autoPlay));
3026
3116
  const effectiveSlideshowCoverVisible = coverVisible ?? slideshowCoverVisible;
3027
3117
  const showSlideshowCover = !!(isSlideshowMode && !isLinearMode && !renderMode && coverBlock && effectiveSlideshowCoverVisible);
@@ -3030,19 +3120,19 @@ function DocPlayerContent({
3030
3120
  const slideshowSlideIndex = slideshowHasCover ? effectiveSlideshowCoverVisible ? 0 : currentBlockIndex + 1 : currentBlockIndex;
3031
3121
  const slideshowTotalSlides = slideshowHasCover ? expandedBlocks.length + 1 : expandedBlocks.length;
3032
3122
  const hasAutoPlayed = useRef7(false);
3033
- useEffect7(() => {
3123
+ useEffect8(() => {
3034
3124
  hasAutoPlayed.current = false;
3035
3125
  }, [doc]);
3036
- useEffect7(() => {
3126
+ useEffect8(() => {
3037
3127
  if (isAudioReady && autoPlay && !hasAutoPlayed.current) {
3038
3128
  hasAutoPlayed.current = true;
3039
3129
  playWithTimelineMedia();
3040
3130
  }
3041
3131
  }, [isAudioReady, autoPlay, playWithTimelineMedia]);
3042
- useEffect7(() => {
3132
+ useEffect8(() => {
3043
3133
  onTimeUpdate?.(currentTime);
3044
3134
  }, [currentTime, onTimeUpdate]);
3045
- useEffect7(() => {
3135
+ useEffect8(() => {
3046
3136
  if (isEnded) {
3047
3137
  onEnded?.();
3048
3138
  if (loop && !isSlideshowMode && !isLinearMode && !isDashboardMode) {
@@ -3073,7 +3163,7 @@ function DocPlayerContent({
3073
3163
  };
3074
3164
  }
3075
3165
  const stableRenderAPI = stableRenderAPIRef.current;
3076
- useEffect7(() => {
3166
+ useEffect8(() => {
3077
3167
  if (isDashboardMode || !renderMode && !isDebugMode) {
3078
3168
  liveRenderAPIRef.current = null;
3079
3169
  return;
@@ -3237,7 +3327,7 @@ function DocPlayerContent({
3237
3327
  isDashboardMode,
3238
3328
  activeViewport
3239
3329
  ]);
3240
- useEffect7(() => {
3330
+ useEffect8(() => {
3241
3331
  if (isDashboardMode) return;
3242
3332
  if (!renderMode && !isDebugMode || !containerRef.current) {
3243
3333
  onRenderAPIReady?.(null);
@@ -3247,20 +3337,20 @@ function DocPlayerContent({
3247
3337
  return () => onRenderAPIReady?.(null);
3248
3338
  }, [renderMode, isDebugMode, isDashboardMode, onRenderAPIReady, stableRenderAPI]);
3249
3339
  const defaultMode = captionsEnabledProp === false ? "off" : captionStyle || "standard";
3250
- const [captionMode, setCaptionMode] = useState6(defaultMode);
3251
- useEffect7(() => {
3340
+ const [captionMode, setCaptionMode] = useState7(defaultMode);
3341
+ useEffect8(() => {
3252
3342
  setCaptionMode(defaultMode);
3253
3343
  }, [defaultMode]);
3254
3344
  const captionsEnabled = captionMode !== "off";
3255
3345
  const activeCaptionStyle = captionMode === "social" ? "social" : "standard";
3256
- const setCaptionsEnabled = useCallback5(
3346
+ const setCaptionsEnabled = useCallback6(
3257
3347
  (enabled) => {
3258
3348
  setCaptionMode(enabled ? captionStyle || "standard" : "off");
3259
3349
  onCaptionsToggle?.(enabled);
3260
3350
  },
3261
3351
  [onCaptionsToggle, captionStyle]
3262
3352
  );
3263
- const cycleCaptionMode = useCallback5(() => {
3353
+ const cycleCaptionMode = useCallback6(() => {
3264
3354
  setCaptionMode((prev) => {
3265
3355
  const next = prev === "off" ? "standard" : prev === "standard" ? "social" : "off";
3266
3356
  onCaptionsToggle?.(next !== "off");
@@ -3268,8 +3358,8 @@ function DocPlayerContent({
3268
3358
  });
3269
3359
  }, [onCaptionsToggle]);
3270
3360
  const hasCaptions = doc.captions && doc.captions.phrases.length > 0;
3271
- const [frameSize, setFrameSize] = useState6(null);
3272
- useEffect7(() => {
3361
+ const [frameSize, setFrameSize] = useState7(null);
3362
+ useEffect8(() => {
3273
3363
  const frame = containerRef.current;
3274
3364
  if (!frame || renderMode || !hasCaptions) return;
3275
3365
  const measure = () => {
@@ -3290,9 +3380,24 @@ function DocPlayerContent({
3290
3380
  };
3291
3381
  }, [renderMode, hasCaptions, isLinearMode, isDashboardMode]);
3292
3382
  const captionViewport = !renderMode && frameSize ? { ...activeViewport, ...frameSize } : activeViewport;
3293
- const segmentTitleMap = useMemo5(() => buildSegmentTitleMap(doc), [doc]);
3294
- const playbackState = useMemo5(
3383
+ const segmentTitleMap = useMemo6(() => buildSegmentTitleMap(doc), [doc]);
3384
+ const buildNav = useBuildNavigation(
3385
+ currentBlock,
3386
+ buildsEnabled && isSlideshowMode && !renderMode && !showCoverBlock,
3387
+ animationsEnabled
3388
+ );
3389
+ const {
3390
+ enter: enterBuild,
3391
+ next: nextBuild,
3392
+ previous: previousBuild,
3393
+ showAll: showAllBuilds
3394
+ } = buildNav;
3395
+ const isBuilding = buildNav.cursor.progress < 1;
3396
+ const playbackState = useMemo6(
3295
3397
  () => ({
3398
+ buildStep: buildNav.cursor.revealed,
3399
+ buildCount: buildNav.count,
3400
+ isBuilding,
3296
3401
  isPlaying,
3297
3402
  isBuffering,
3298
3403
  currentTime,
@@ -3314,6 +3419,9 @@ function DocPlayerContent({
3314
3419
  }),
3315
3420
  // eslint-disable-next-line react-hooks/exhaustive-deps -- doc.audio.segments is stable within a given doc
3316
3421
  [
3422
+ buildNav.cursor.revealed,
3423
+ buildNav.count,
3424
+ isBuilding,
3317
3425
  isPlaying,
3318
3426
  isBuffering,
3319
3427
  currentTime,
@@ -3336,7 +3444,7 @@ function DocPlayerContent({
3336
3444
  expandedBlocks.length
3337
3445
  ]
3338
3446
  );
3339
- const playbackActions = useMemo5(
3447
+ const playbackActions = useMemo6(
3340
3448
  () => ({
3341
3449
  toggle: toggleWithTimelineMedia,
3342
3450
  restart,
@@ -3354,12 +3462,13 @@ function DocPlayerContent({
3354
3462
  onFullscreenToggle
3355
3463
  ]
3356
3464
  );
3357
- const slideNavActions = useMemo5(
3465
+ const slideNavActions = useMemo6(
3358
3466
  () => ({
3359
3467
  nextSlide: () => {
3360
3468
  if (slideshowHasCover && slideshowCoverVisible) {
3361
3469
  const target = expandedBlocks[0];
3362
3470
  if (target) {
3471
+ enterBuild(target);
3363
3472
  setSlideshowCoverVisible(false);
3364
3473
  seekTo(target.startTime);
3365
3474
  pause();
@@ -3369,6 +3478,7 @@ function DocPlayerContent({
3369
3478
  if (currentBlockIndex < expandedBlocks.length - 1) {
3370
3479
  const target = expandedBlocks[currentBlockIndex + 1];
3371
3480
  if (target) {
3481
+ enterBuild(target);
3372
3482
  setSlideshowCoverVisible(false);
3373
3483
  seekTo(target.startTime);
3374
3484
  pause();
@@ -3385,6 +3495,7 @@ function DocPlayerContent({
3385
3495
  if (currentBlockIndex > 0) {
3386
3496
  const target = expandedBlocks[currentBlockIndex - 1];
3387
3497
  if (target) {
3498
+ enterBuild(target, true);
3388
3499
  setSlideshowCoverVisible(false);
3389
3500
  seekTo(target.startTime);
3390
3501
  pause();
@@ -3401,6 +3512,7 @@ function DocPlayerContent({
3401
3512
  }
3402
3513
  const target = expandedBlocks[index - 1];
3403
3514
  if (target) {
3515
+ enterBuild(target);
3404
3516
  setSlideshowCoverVisible(false);
3405
3517
  seekTo(target.startTime);
3406
3518
  pause();
@@ -3410,16 +3522,38 @@ function DocPlayerContent({
3410
3522
  if (index >= 0 && index < expandedBlocks.length) {
3411
3523
  const target = expandedBlocks[index];
3412
3524
  if (target) {
3525
+ enterBuild(target);
3413
3526
  seekTo(target.startTime);
3414
3527
  pause();
3415
3528
  }
3416
3529
  }
3417
3530
  }
3418
3531
  }),
3419
- [currentBlockIndex, expandedBlocks, seekTo, pause, slideshowHasCover, slideshowCoverVisible]
3532
+ [
3533
+ currentBlockIndex,
3534
+ expandedBlocks,
3535
+ seekTo,
3536
+ pause,
3537
+ slideshowHasCover,
3538
+ slideshowCoverVisible,
3539
+ enterBuild
3540
+ ]
3541
+ );
3542
+ const stepNavActions = useMemo6(
3543
+ () => ({
3544
+ ...slideNavActions,
3545
+ nextStep: () => {
3546
+ if (!nextBuild()) slideNavActions.nextSlide();
3547
+ },
3548
+ prevStep: () => {
3549
+ if (!previousBuild()) slideNavActions.prevSlide();
3550
+ },
3551
+ showAllBuilds
3552
+ }),
3553
+ [slideNavActions, nextBuild, previousBuild, showAllBuilds]
3420
3554
  );
3421
3555
  const swipeEnabled = isSlideshowMode && !isLinearMode && !renderMode && enableSwipe;
3422
- const armContextFreeSwipeEntry = useCallback5(
3556
+ const armContextFreeSwipeEntry = useCallback6(
3423
3557
  (destinationSlideIndex) => {
3424
3558
  const destinationBlockIndex = destinationSlideIndex - (slideshowHasCover ? 1 : 0);
3425
3559
  const destinationBlock = expandedBlocks[destinationBlockIndex];
@@ -3427,29 +3561,45 @@ function DocPlayerContent({
3427
3561
  },
3428
3562
  [expandedBlocks, slideshowHasCover, suppressOutgoingForNextBlock]
3429
3563
  );
3430
- const handleSwipeNext = useCallback5(() => {
3564
+ const handleSwipeNext = useCallback6(() => {
3565
+ if (nextBuild()) return;
3431
3566
  armContextFreeSwipeEntry(slideshowSlideIndex + 1);
3432
3567
  slideNavActions.nextSlide();
3433
- }, [armContextFreeSwipeEntry, slideshowSlideIndex, slideNavActions]);
3434
- const handleSwipePrev = useCallback5(() => {
3568
+ }, [armContextFreeSwipeEntry, slideshowSlideIndex, slideNavActions, nextBuild]);
3569
+ const handleSwipePrev = useCallback6(() => {
3570
+ if (previousBuild()) return;
3435
3571
  armContextFreeSwipeEntry(slideshowSlideIndex - 1);
3436
3572
  slideNavActions.prevSlide();
3437
- }, [armContextFreeSwipeEntry, slideshowSlideIndex, slideNavActions]);
3573
+ }, [armContextFreeSwipeEntry, slideshowSlideIndex, slideNavActions, previousBuild]);
3438
3574
  const swipe = useSlideSwipe({
3439
3575
  enabled: swipeEnabled,
3440
3576
  containerRef,
3441
- canGoNext: slideshowSlideIndex < slideshowTotalSlides - 1,
3442
- canGoPrev: slideshowSlideIndex > 0,
3577
+ canGoNext: slideshowSlideIndex < slideshowTotalSlides - 1 || buildNav.cursor.revealed < buildNav.count || buildNav.cursor.progress < 1,
3578
+ canGoPrev: slideshowSlideIndex > 0 || buildNav.cursor.revealed > 0,
3443
3579
  onNext: handleSwipeNext,
3444
3580
  onPrev: handleSwipePrev
3445
3581
  });
3446
- useEffect7(() => {
3582
+ useEffect8(() => {
3447
3583
  onPlaybackStateChange?.(playbackState);
3448
3584
  }, [playbackState, onPlaybackStateChange]);
3449
- useEffect7(() => {
3450
- onControlsReady?.({ play: playWithTimelineMedia, pause, ...playbackActions });
3451
- }, [playWithTimelineMedia, pause, playbackActions, onControlsReady]);
3452
- const getBlockTitle = useCallback5((block) => {
3585
+ useEffect8(() => {
3586
+ onControlsReady?.({
3587
+ play: playWithTimelineMedia,
3588
+ pause,
3589
+ ...playbackActions,
3590
+ nextBuild: stepNavActions.nextStep,
3591
+ previousBuild: stepNavActions.prevStep,
3592
+ showAllBuilds
3593
+ });
3594
+ }, [
3595
+ playWithTimelineMedia,
3596
+ pause,
3597
+ playbackActions,
3598
+ onControlsReady,
3599
+ stepNavActions,
3600
+ showAllBuilds
3601
+ ]);
3602
+ const getBlockTitle = useCallback6((block) => {
3453
3603
  const docBlock = block;
3454
3604
  if (isTemplateBlock2(docBlock)) {
3455
3605
  const props = docBlock;
@@ -3473,7 +3623,7 @@ function DocPlayerContent({
3473
3623
  }
3474
3624
  return block.id.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
3475
3625
  }, []);
3476
- const slideshowPickerItems = useMemo5(() => {
3626
+ const slideshowPickerItems = useMemo6(() => {
3477
3627
  const blockItems = expandedBlocks.map((block, index) => ({
3478
3628
  id: block.id,
3479
3629
  label: String(index + 1),
@@ -3489,7 +3639,7 @@ function DocPlayerContent({
3489
3639
  ...blockItems
3490
3640
  ];
3491
3641
  }, [coverBlock, expandedBlocks, getBlockTitle, slideshowHasCover]);
3492
- const blockMarkers = useMemo5(() => {
3642
+ const blockMarkers = useMemo6(() => {
3493
3643
  if (!totalDuration || !expandedBlocks.length) return [];
3494
3644
  let prevSegment = -1;
3495
3645
  return expandedBlocks.map((block, index) => {
@@ -3504,13 +3654,13 @@ function DocPlayerContent({
3504
3654
  };
3505
3655
  });
3506
3656
  }, [expandedBlocks, totalDuration, getBlockTitle]);
3507
- useEffect7(() => {
3657
+ useEffect8(() => {
3508
3658
  if (blockMarkers.length > 0) {
3509
3659
  onBlockMarkers?.(blockMarkers);
3510
3660
  }
3511
3661
  }, [blockMarkers, onBlockMarkers]);
3512
3662
  expandedBlocksLenRef.current = isSlideshowMode ? slideshowTotalSlides : expandedBlocks.length;
3513
- const handleKeyboardShortcut = useCallback5(
3663
+ const handleKeyboardShortcut = useCallback6(
3514
3664
  (e, global) => {
3515
3665
  if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
3516
3666
  const target = e.target instanceof Element ? e.target : null;
@@ -3539,11 +3689,11 @@ function DocPlayerContent({
3539
3689
  case "ArrowDown":
3540
3690
  case " ":
3541
3691
  e.preventDefault();
3542
- slideNavActions.nextSlide();
3692
+ stepNavActions.nextStep();
3543
3693
  break;
3544
3694
  case "ArrowLeft":
3545
3695
  e.preventDefault();
3546
- slideNavActions.prevSlide();
3696
+ stepNavActions.prevStep();
3547
3697
  break;
3548
3698
  case "ArrowUp":
3549
3699
  e.preventDefault();
@@ -3582,14 +3732,15 @@ function DocPlayerContent({
3582
3732
  toggleWithTimelineMedia,
3583
3733
  seekTo,
3584
3734
  slideNavActions,
3735
+ stepNavActions,
3585
3736
  onFullscreenToggle
3586
3737
  ]
3587
3738
  );
3588
- const handleKeyDown = useCallback5(
3739
+ const handleKeyDown = useCallback6(
3589
3740
  (e) => handleKeyboardShortcut(e, false),
3590
3741
  [handleKeyboardShortcut]
3591
3742
  );
3592
- useEffect7(() => {
3743
+ useEffect8(() => {
3593
3744
  if (!globalKeyboardShortcuts || renderMode || isLinearMode || isDashboardMode) return;
3594
3745
  const handleDocumentKeyDown = (event) => {
3595
3746
  handleKeyboardShortcut(event, true);
@@ -3731,6 +3882,8 @@ function DocPlayerContent({
3731
3882
  /* @__PURE__ */ jsx10("div", { className: "doc-player__block doc-player__block--previous", children: /* @__PURE__ */ jsx10(
3732
3883
  BlockRenderer,
3733
3884
  {
3885
+ respectReducedMotion: !renderMode,
3886
+ buildPlayback: buildsEnabled ? "timed" : "all",
3734
3887
  block: previousBlock,
3735
3888
  blockTime: Math.max(0, currentTime - previousBlock.startTime),
3736
3889
  basePath,
@@ -3758,6 +3911,8 @@ function DocPlayerContent({
3758
3911
  BlockRenderer,
3759
3912
  {
3760
3913
  block: currentBlock,
3914
+ respectReducedMotion: !renderMode,
3915
+ buildPlayback: !buildsEnabled ? "all" : isSlideshowMode && !renderMode ? buildNav.cursor : "timed",
3761
3916
  blockTime,
3762
3917
  basePath,
3763
3918
  isEntering: animationsEnabled && isEntering,
@@ -3886,7 +4041,7 @@ function DocPlayerContent({
3886
4041
  hasCaptions && (() => {
3887
4042
  const debugPhrase = getCaptionAtTime2(doc.captions, currentTime);
3888
4043
  const debugEnabled = captionsEnabled && (isPlaying || currentTime > 0);
3889
- return /* @__PURE__ */ jsxs7(Fragment4, { children: [
4044
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
3890
4045
  /* @__PURE__ */ jsxs7("div", { children: [
3891
4046
  /* @__PURE__ */ jsx10("span", { style: { color: "#888" }, children: "captions:" }),
3892
4047
  " ",
@@ -3999,7 +4154,7 @@ function DocPlayerContent({
3999
4154
  DocControlsSlideshow,
4000
4155
  {
4001
4156
  state: playbackState,
4002
- slideNav: slideNavActions,
4157
+ slideNav: stepNavActions,
4003
4158
  slides: slideshowPickerItems,
4004
4159
  pickerOpen: isSlideshowPickerOpen,
4005
4160
  onPickerOpenChange: setIsSlideshowPickerOpen
@@ -4143,7 +4298,7 @@ function DocControlsSidebar({ state, actions }) {
4143
4298
  }
4144
4299
 
4145
4300
  // src/DocPlayerWithSidebar.tsx
4146
- import { useRef as useRef8, useState as useState7, useCallback as useCallback6, useEffect as useEffect8 } from "react";
4301
+ import { useRef as useRef8, useState as useState8, useCallback as useCallback7, useEffect as useEffect9 } from "react";
4147
4302
  import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
4148
4303
  var DEFAULT_STATE = {
4149
4304
  isPlaying: false,
@@ -4179,8 +4334,8 @@ function DocPlayerWithSidebar({
4179
4334
  const stateRef = useRef8(DEFAULT_STATE);
4180
4335
  const actionsRef = useRef8(null);
4181
4336
  const wasPlayingRef = useRef8(false);
4182
- const [, setTick] = useState7(0);
4183
- const handleStateChange = useCallback6(
4337
+ const [, setTick] = useState8(0);
4338
+ const handleStateChange = useCallback7(
4184
4339
  (state) => {
4185
4340
  stateRef.current = state;
4186
4341
  if (onPlayingChange && state.isPlaying !== wasPlayingRef.current) {
@@ -4191,7 +4346,7 @@ function DocPlayerWithSidebar({
4191
4346
  },
4192
4347
  [onPlayingChange]
4193
4348
  );
4194
- const handleControlsReady = useCallback6(
4349
+ const handleControlsReady = useCallback7(
4195
4350
  (controls) => {
4196
4351
  const isFirst = !actionsRef.current;
4197
4352
  actionsRef.current = controls;
@@ -4199,7 +4354,7 @@ function DocPlayerWithSidebar({
4199
4354
  },
4200
4355
  []
4201
4356
  );
4202
- useEffect8(() => {
4357
+ useEffect9(() => {
4203
4358
  const interval = setInterval(() => {
4204
4359
  if (!stateRef.current.isPlaying) return;
4205
4360
  setTick((t) => t + 1);
@@ -4235,6 +4390,7 @@ function DocPlayerWithSidebar({
4235
4390
  }
4236
4391
 
4237
4392
  export {
4393
+ useBuildNavigation,
4238
4394
  MediaClipLayer,
4239
4395
  useMediaClipDurations,
4240
4396
  SocialCaptionOverlay,