@bendyline/squisq-react 2.12.2 → 2.12.4

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,30 +1,30 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-2K74UJ4T.js";
3
+ } from "./chunk-MGFMKGZY.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
7
7
  useMediaSchedule,
8
8
  useViewportOrientation
9
- } from "./chunk-AA6NGEP7.js";
9
+ } from "./chunk-3H6QBEYX.js";
10
10
  import {
11
11
  useAutoSurface
12
12
  } from "./chunk-TT6ENR6T.js";
13
13
  import {
14
14
  MarkdownRenderer
15
- } from "./chunk-T7NVETOH.js";
15
+ } from "./chunk-YVQ7KEYI.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-XSSIHHDY.js";
18
+ } from "./chunk-PFKYO6C2.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-3RVUSY4V.js";
22
+ } from "./chunk-4ILJDBJ7.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
26
26
  useResourcePolicy
27
- } from "./chunk-HCKL2AFN.js";
27
+ } from "./chunk-JP2VHB5H.js";
28
28
 
29
29
  // src/hooks/useBuildNavigation.ts
30
30
  import { useCallback, useEffect, useMemo, useState } from "react";
@@ -511,31 +511,106 @@ function useMediaClipDurations(schedule, basePath, mediaProviderOverride) {
511
511
  // src/SocialCaptionOverlay.tsx
512
512
  import { useMemo as useMemo3 } from "react";
513
513
  import { resolveFontFamily } from "@bendyline/squisq/schemas";
514
- import { jsx as jsx2 } from "react/jsx-runtime";
515
- function positionStyle(position, portrait) {
516
- switch (position) {
517
- case "top":
518
- return { top: portrait ? "12%" : "8%" };
519
- case "center":
520
- return { top: "50%", transform: "translateY(-50%)" };
521
- default:
522
- return { bottom: portrait ? "24%" : "16%" };
523
- }
524
- }
525
- function contrastText(hex) {
526
- const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
527
- if (!m) return "#ffffff";
528
- const n = parseInt(m[1], 16);
529
- const r = n >> 16 & 255;
530
- const g = n >> 8 & 255;
531
- const b = n & 255;
532
- const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
533
- return luma > 150 ? "#111111" : "#ffffff";
534
- }
514
+
515
+ // src/socialCaptionLayout.ts
535
516
  var TARGET_CHUNK_SIZE = 4;
536
517
  var MIN_CHUNK_SIZE = 2;
537
518
  var MAX_CHUNK_SIZE = 6;
538
- var SOCIAL_CAPTION_HOLD_SECONDS = 1;
519
+ var SOCIAL_CAPTION_MAX_ROWS = 2;
520
+ var SOCIAL_CAPTION_LAYOUT = {
521
+ wordPadEm: 0.16,
522
+ columnGapEm: 0.28,
523
+ chunkPadXEm: 0.55,
524
+ letterSpacingEm: 0.01
525
+ };
526
+ var CHAR_EM = {
527
+ A: 0.76,
528
+ B: 0.76,
529
+ C: 0.72,
530
+ D: 0.83,
531
+ E: 0.72,
532
+ F: 0.67,
533
+ G: 0.81,
534
+ H: 0.91,
535
+ I: 0.45,
536
+ J: 0.6,
537
+ K: 0.82,
538
+ L: 0.69,
539
+ M: 1.02,
540
+ N: 0.84,
541
+ O: 0.82,
542
+ P: 0.7,
543
+ Q: 0.82,
544
+ R: 0.8,
545
+ S: 0.65,
546
+ T: 0.68,
547
+ U: 0.83,
548
+ V: 0.76,
549
+ W: 1.13,
550
+ X: 0.81,
551
+ Y: 0.73,
552
+ Z: 0.69,
553
+ "0": 0.7,
554
+ "1": 0.5,
555
+ "2": 0.63,
556
+ "3": 0.62,
557
+ "4": 0.65,
558
+ "5": 0.6,
559
+ "6": 0.65,
560
+ "7": 0.55,
561
+ "8": 0.68,
562
+ "9": 0.65,
563
+ "'": 0.28,
564
+ "\u2019": 0.33,
565
+ ".": 0.33,
566
+ ",": 0.33,
567
+ ";": 0.37,
568
+ ":": 0.37,
569
+ "!": 0.38,
570
+ "?": 0.55,
571
+ "-": 0.38,
572
+ "\u2013": 0.7,
573
+ "\u2014": 1,
574
+ '"': 0.56,
575
+ "\u201C": 0.52,
576
+ "\u201D": 0.52,
577
+ "(": 0.45,
578
+ ")": 0.45,
579
+ "%": 1,
580
+ "&": 0.83,
581
+ "/": 0.47,
582
+ "\xB0": 0.42,
583
+ $: 0.64
584
+ };
585
+ var DEFAULT_CHAR_EM = 0.9;
586
+ var WIDTH_SAFETY = 1.06;
587
+ function estimateSocialWordEm(text) {
588
+ let em = 0;
589
+ let count = 0;
590
+ for (const ch of text.toUpperCase().normalize("NFD").replace(/\p{M}/gu, "")) {
591
+ em += CHAR_EM[ch] ?? DEFAULT_CHAR_EM;
592
+ count++;
593
+ }
594
+ const { letterSpacingEm: letterSpacingEm2, wordPadEm: wordPadEm2 } = SOCIAL_CAPTION_LAYOUT;
595
+ return (em + count * letterSpacingEm2) * WIDTH_SAFETY + 2 * wordPadEm2;
596
+ }
597
+ function estimateSocialRows(words, rowEm) {
598
+ let rows = 0;
599
+ let x = 0;
600
+ for (const word of words) {
601
+ const width = estimateSocialWordEm(word);
602
+ if (rows === 0) {
603
+ rows = 1;
604
+ x = width;
605
+ } else if (x + SOCIAL_CAPTION_LAYOUT.columnGapEm + width <= rowEm) {
606
+ x += SOCIAL_CAPTION_LAYOUT.columnGapEm + width;
607
+ } else {
608
+ rows++;
609
+ x = width;
610
+ }
611
+ }
612
+ return rows;
613
+ }
539
614
  function resolvePhraseTiming(phrase) {
540
615
  if (phrase.words && phrase.words.length > 0) {
541
616
  return phrase.words.map((w) => ({
@@ -554,10 +629,11 @@ function resolvePhraseTiming(phrase) {
554
629
  endTime: phrase.startTime + (i + 1) * wordDuration
555
630
  }));
556
631
  }
557
- function buildWordStream(captions) {
632
+ function buildWordStream(captions, rowEm = Number.POSITIVE_INFINITY) {
558
633
  const allWords = [];
559
634
  for (const phrase of captions.phrases) {
560
- allWords.push(...resolvePhraseTiming(phrase));
635
+ for (const word of resolvePhraseTiming(phrase))
636
+ allWords.push({ ...word, segment: phrase.audioSegment });
561
637
  }
562
638
  if (allWords.length === 0) return { words: [], chunks: [] };
563
639
  let chunkSize = TARGET_CHUNK_SIZE;
@@ -569,16 +645,50 @@ function buildWordStream(captions) {
569
645
  chunkSize = Math.max(MIN_CHUNK_SIZE, allWords.length);
570
646
  }
571
647
  const chunks = [];
572
- for (let i = 0; i < allWords.length; i += chunkSize) {
573
- const chunkWords = allWords.slice(i, i + chunkSize);
648
+ let current = [];
649
+ const close = () => {
650
+ if (current.length === 0) return;
574
651
  chunks.push({
575
- words: chunkWords,
576
- startTime: chunkWords[0].startTime,
577
- endTime: chunkWords[chunkWords.length - 1].endTime
652
+ words: current,
653
+ startTime: current[0].startTime,
654
+ endTime: current[current.length - 1].endTime
578
655
  });
656
+ current = [];
657
+ };
658
+ for (const word of allWords) {
659
+ if (current.length > 0 && (current.length >= chunkSize || word.segment !== current[0].segment || estimateSocialRows([...current.map((w) => w.text), word.text], rowEm) > SOCIAL_CAPTION_MAX_ROWS)) {
660
+ close();
661
+ }
662
+ current.push(word);
579
663
  }
664
+ close();
580
665
  return { words: allWords, chunks };
581
666
  }
667
+
668
+ // src/SocialCaptionOverlay.tsx
669
+ import { jsx as jsx2 } from "react/jsx-runtime";
670
+ var { wordPadEm, columnGapEm, chunkPadXEm, letterSpacingEm } = SOCIAL_CAPTION_LAYOUT;
671
+ function positionStyle(position, portrait) {
672
+ switch (position) {
673
+ case "top":
674
+ return { top: portrait ? "12%" : "8%" };
675
+ case "center":
676
+ return { top: "50%", transform: "translateY(-50%)" };
677
+ default:
678
+ return { bottom: portrait ? "24%" : "16%" };
679
+ }
680
+ }
681
+ function contrastText(hex) {
682
+ const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
683
+ if (!m) return "#ffffff";
684
+ const n = parseInt(m[1], 16);
685
+ const r = n >> 16 & 255;
686
+ const g = n >> 8 & 255;
687
+ const b = n & 255;
688
+ const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
689
+ return luma > 150 ? "#111111" : "#ffffff";
690
+ }
691
+ var SOCIAL_CAPTION_HOLD_SECONDS = 1;
582
692
  function SocialCaptionOverlay({
583
693
  captions,
584
694
  currentTime,
@@ -587,9 +697,16 @@ function SocialCaptionOverlay({
587
697
  viewport,
588
698
  position = "bottom"
589
699
  }) {
700
+ const viewportWidth = viewport?.width ?? 1280;
701
+ const viewportHeight = viewport?.height ?? 720;
702
+ const portrait = viewportHeight > viewportWidth;
703
+ const baseFontSize = Math.min(viewportHeight * 0.055, viewportWidth * 0.068);
704
+ const fontSize = Math.max(22, Math.min(96, Math.round(baseFontSize)));
705
+ const sidePadding = portrait ? 0.07 : 0.1;
706
+ const rowEm = viewportWidth * (1 - 2 * sidePadding) / fontSize - 2 * chunkPadXEm;
590
707
  const { chunks } = useMemo3(
591
- () => captions ? buildWordStream(captions) : { words: [], chunks: [] },
592
- [captions]
708
+ () => captions ? buildWordStream(captions, rowEm) : { words: [], chunks: [] },
709
+ [captions, rowEm]
593
710
  );
594
711
  if (!enabled || chunks.length === 0) {
595
712
  return /* @__PURE__ */ jsx2(
@@ -598,7 +715,7 @@ function SocialCaptionOverlay({
598
715
  className: "social-caption-overlay",
599
716
  style: {
600
717
  position: "absolute",
601
- ...positionStyle(position, (viewport?.height ?? 0) > (viewport?.width ?? 1)),
718
+ ...positionStyle(position, portrait),
602
719
  left: 0,
603
720
  right: 0,
604
721
  zIndex: 50,
@@ -649,11 +766,8 @@ function SocialCaptionOverlay({
649
766
  }
650
767
  const primaryColor = theme?.colors?.primary ?? "#5b9bd5";
651
768
  const fontFamily = theme?.typography?.titleFont ? resolveFontFamily(theme.typography.titleFont, '"PT Serif", Georgia, serif') : '"PT Serif", Georgia, serif';
652
- const viewportWidth = viewport?.width ?? 1280;
653
- const viewportHeight = viewport?.height ?? 720;
654
- const portrait = viewportHeight > viewportWidth;
655
- const baseFontSize = Math.min(viewportHeight * 0.055, viewportWidth * 0.082);
656
- const fontSize = Math.max(22, Math.min(96, Math.round(baseFontSize)));
769
+ const widestEm = Math.max(...activeChunk.words.map((w) => estimateSocialWordEm(w.text)));
770
+ const chunkFontSize = widestEm > rowEm ? Math.max(16, Math.floor(fontSize * rowEm / widestEm)) : fontSize;
657
771
  return /* @__PURE__ */ jsx2(
658
772
  "div",
659
773
  {
@@ -667,7 +781,7 @@ function SocialCaptionOverlay({
667
781
  pointerEvents: "none",
668
782
  display: "flex",
669
783
  justifyContent: "center",
670
- padding: portrait ? "0 7%" : "0 10%",
784
+ padding: `0 ${sidePadding * 100}%`,
671
785
  boxSizing: "border-box",
672
786
  opacity: 1,
673
787
  transition: "opacity 0.15s ease-in-out"
@@ -683,17 +797,17 @@ function SocialCaptionOverlay({
683
797
  alignItems: "baseline",
684
798
  maxWidth: "100%",
685
799
  rowGap: "0.12em",
686
- columnGap: "0.28em",
687
- padding: "0.22em 0.55em",
800
+ columnGap: `${columnGapEm}em`,
801
+ padding: `0.22em ${chunkPadXEm}em`,
688
802
  borderRadius: "0.4em",
689
803
  background: "rgba(10, 10, 12, 0.42)",
690
804
  backdropFilter: "blur(8px)",
691
805
  WebkitBackdropFilter: "blur(8px)",
692
806
  fontFamily,
693
- fontSize: `${fontSize}px`,
807
+ fontSize: `${chunkFontSize}px`,
694
808
  lineHeight: 1.18,
695
809
  textTransform: "uppercase",
696
- letterSpacing: "0.01em",
810
+ letterSpacing: `${letterSpacingEm}em`,
697
811
  whiteSpace: "normal"
698
812
  },
699
813
  children: activeChunk.words.map((word, i) => {
@@ -705,7 +819,7 @@ function SocialCaptionOverlay({
705
819
  style: {
706
820
  display: "inline-block",
707
821
  whiteSpace: "nowrap",
708
- padding: "0 0.16em",
822
+ padding: `0 ${wordPadEm}em`,
709
823
  borderRadius: "0.18em",
710
824
  fontWeight: 800,
711
825
  color: isActive ? contrastText(primaryColor) : "rgba(255, 255, 255, 0.95)",
@@ -1621,6 +1735,23 @@ function DocControlsSlideshow({
1621
1735
  );
1622
1736
  }
1623
1737
 
1738
+ // src/utils/decodeSvgImages.ts
1739
+ async function decodeSvgImages(root) {
1740
+ if (typeof Image === "undefined") return;
1741
+ const hrefs = /* @__PURE__ */ new Set();
1742
+ for (const element of Array.from(root.querySelectorAll("svg image"))) {
1743
+ const href = element.getAttribute("href") ?? element.getAttribute("xlink:href");
1744
+ if (href && /^(?:data|blob):/i.test(href)) hrefs.add(href);
1745
+ }
1746
+ await Promise.allSettled(
1747
+ [...hrefs].map((href) => {
1748
+ const image = new Image();
1749
+ image.src = href;
1750
+ return typeof image.decode === "function" ? image.decode().catch(() => void 0) : Promise.resolve();
1751
+ })
1752
+ );
1753
+ }
1754
+
1624
1755
  // src/DashboardView.tsx
1625
1756
  import { Fragment as Fragment3, useEffect as useEffect5, useMemo as useMemo4, useRef as useRef4 } from "react";
1626
1757
  import { materializeDashboard, resolveThemeForDoc, VIEWPORT_PRESETS } from "@bendyline/squisq/doc";
@@ -1643,6 +1774,7 @@ async function waitForDashboardAssets(root) {
1643
1774
  });
1644
1775
  })
1645
1776
  );
1777
+ await decodeSvgImages(root);
1646
1778
  await new Promise((resolve) => {
1647
1779
  if (typeof requestAnimationFrame === "function") {
1648
1780
  requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
@@ -1819,7 +1951,8 @@ function DashboardView({
1819
1951
  muted,
1820
1952
  animationsEnabled,
1821
1953
  theme: activeTheme,
1822
- videoEmbeds: renderMode ? "placeholder" : "player"
1954
+ videoEmbeds: renderMode ? "placeholder" : "player",
1955
+ staticMedia: renderMode
1823
1956
  }
1824
1957
  ),
1825
1958
  cell.frame && cell.frame.overlayLayers.length > 0 && // Borders and accents ride above the block: a template that
@@ -1899,6 +2032,7 @@ function DashboardView({
1899
2032
  import {
1900
2033
  useCallback as useCallback4,
1901
2034
  useEffect as useEffect6,
2035
+ useLayoutEffect as useLayoutEffect2,
1902
2036
  useMemo as useMemo5,
1903
2037
  useRef as useRef5,
1904
2038
  useState as useState5
@@ -1910,7 +2044,7 @@ import {
1910
2044
  resolvePageBlock,
1911
2045
  resolveThemeForDoc as resolveThemeForDoc2
1912
2046
  } from "@bendyline/squisq/doc";
1913
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
2047
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1914
2048
  var VISUAL_TEMPLATES = /* @__PURE__ */ new Set([
1915
2049
  "diagram",
1916
2050
  "tree",
@@ -2037,6 +2171,12 @@ function shuffled(values, seed) {
2037
2171
  function ChoiceContent(props) {
2038
2172
  return /* @__PURE__ */ jsx9(FaceContent, { ...props, face: props.choice.content });
2039
2173
  }
2174
+ var REVEALED_PARTS = ".squisq-flashcards__answer, .squisq-flashcards__feedback, .squisq-flashcards__explanation";
2175
+ var SIDE_RAILS_MIN_WIDTH = 860;
2176
+ function wantsSideRails(width, height, current) {
2177
+ if (width < SIDE_RAILS_MIN_WIDTH || height <= 0) return false;
2178
+ return width / height >= (current ? 1.1 : 1.2);
2179
+ }
2040
2180
  function isInteractiveTarget(target) {
2041
2181
  return target instanceof Element && !!target.closest('button, a, input, select, textarea, [contenteditable="true"]');
2042
2182
  }
@@ -2051,8 +2191,11 @@ function FlashcardView({
2051
2191
  onCopyCode,
2052
2192
  fenceRenderers,
2053
2193
  viewport = VIEWPORT_PRESETS2.landscape,
2194
+ density = "comfortable",
2054
2195
  className
2055
2196
  }) {
2197
+ const compact = density === "compact";
2198
+ const rootClassName = "squisq-flashcards" + (compact ? " squisq-flashcards--compact" : "") + (className ? ` ${className}` : "");
2056
2199
  const activeTheme = useMemo5(() => theme ?? resolveThemeForDoc2(doc), [doc, theme]);
2057
2200
  const deck = useMemo5(() => materializeFlashcards(doc, { source }), [doc, source]);
2058
2201
  const [shuffleEnabled, setShuffleEnabled] = useState5(initialShuffle);
@@ -2063,6 +2206,8 @@ function FlashcardView({
2063
2206
  const [ratings, setRatings] = useState5({});
2064
2207
  const [retryIds, setRetryIds] = useState5(null);
2065
2208
  const cardViewportRef = useRef5(null);
2209
+ const [deckElement, setDeckElement] = useState5(null);
2210
+ const [sideRails, setSideRails] = useState5(false);
2066
2211
  const orderedCards = useMemo5(
2067
2212
  () => shuffleEnabled ? shuffled(deck.cards, `${doc.articleId}:${sessionSeed}`) : [...deck.cards],
2068
2213
  [deck.cards, doc.articleId, sessionSeed, shuffleEnabled]
@@ -2092,6 +2237,29 @@ function FlashcardView({
2092
2237
  useEffect6(() => {
2093
2238
  if (cardViewportRef.current) cardViewportRef.current.scrollTop = 0;
2094
2239
  }, [cardIndex, retryIds]);
2240
+ useEffect6(() => {
2241
+ const viewport2 = cardViewportRef.current;
2242
+ if (!revealed || !viewport2) return;
2243
+ const revealedParts = viewport2.querySelectorAll(REVEALED_PARTS);
2244
+ if (revealedParts.length === 0) return;
2245
+ const bounds = viewport2.getBoundingClientRect();
2246
+ const first = revealedParts[0].getBoundingClientRect();
2247
+ const last = revealedParts[revealedParts.length - 1].getBoundingClientRect();
2248
+ const delta = Math.min(last.bottom - bounds.bottom, first.top - bounds.top - 12);
2249
+ if (delta > 0) viewport2.scrollTop += delta;
2250
+ }, [revealed, cardIndex, retryIds]);
2251
+ useLayoutEffect2(() => {
2252
+ if (compact || !deckElement) return;
2253
+ const measure = () => {
2254
+ const { width, height } = deckElement.getBoundingClientRect();
2255
+ setSideRails((current) => wantsSideRails(width, height, current));
2256
+ };
2257
+ measure();
2258
+ if (typeof ResizeObserver === "undefined") return;
2259
+ const observer = new ResizeObserver(measure);
2260
+ observer.observe(deckElement);
2261
+ return () => observer.disconnect();
2262
+ }, [compact, deckElement]);
2095
2263
  const revealAnswer = useCallback4(() => {
2096
2264
  if (!currentCard) return;
2097
2265
  setRevealed(true);
@@ -2205,7 +2373,7 @@ function FlashcardView({
2205
2373
  return /* @__PURE__ */ jsx9(
2206
2374
  "div",
2207
2375
  {
2208
- className: `squisq-flashcards squisq-flashcards--empty${className ? ` ${className}` : ""}`,
2376
+ className: `${rootClassName} squisq-flashcards--empty`,
2209
2377
  style: rootStyle,
2210
2378
  role: "region",
2211
2379
  "aria-label": "Flashcards",
@@ -2221,7 +2389,7 @@ function FlashcardView({
2221
2389
  return /* @__PURE__ */ jsx9(
2222
2390
  "div",
2223
2391
  {
2224
- className: `squisq-flashcards${className ? ` ${className}` : ""}`,
2392
+ className: rootClassName,
2225
2393
  style: rootStyle,
2226
2394
  role: "region",
2227
2395
  "aria-label": "Flashcard session summary",
@@ -2256,10 +2424,83 @@ function FlashcardView({
2256
2424
  }
2257
2425
  const choices = currentCard?.choices ? shuffled(currentCard.choices, `${currentCard.id}:${sessionSeed}`) : [];
2258
2426
  const selectedChoice = choices.find((choice) => choice.id === selectedChoiceId);
2427
+ const position = `Card ${cardIndex + 1} of ${sessionCards.length}`;
2428
+ const lastCard = cardIndex === sessionCards.length - 1;
2429
+ const nextLabel = revealed ? lastCard ? "Finish" : "Next card" : "Reveal";
2430
+ const railsActive = sideRails && !compact;
2431
+ const tools = /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__tools", children: [
2432
+ /* @__PURE__ */ jsx9(
2433
+ "button",
2434
+ {
2435
+ type: "button",
2436
+ className: "squisq-flashcards__tool",
2437
+ "aria-pressed": shuffleEnabled,
2438
+ onClick: () => {
2439
+ setShuffleEnabled((enabled) => !enabled);
2440
+ restart();
2441
+ },
2442
+ children: "Shuffle"
2443
+ }
2444
+ ),
2445
+ /* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__tool", onClick: restart, children: "Restart" })
2446
+ ] });
2447
+ const previousButton = /* @__PURE__ */ jsx9(
2448
+ "button",
2449
+ {
2450
+ type: "button",
2451
+ className: "squisq-flashcards__button",
2452
+ disabled: cardIndex === 0 && !revealed,
2453
+ onClick: previousCard,
2454
+ "aria-keyshortcuts": "ArrowLeft",
2455
+ title: "Previous (\u2190)",
2456
+ children: "Previous"
2457
+ }
2458
+ );
2459
+ const progressBar = /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__progress", "aria-hidden": "true", children: /* @__PURE__ */ jsx9(
2460
+ "span",
2461
+ {
2462
+ style: { width: `${(cardIndex + (revealed ? 1 : 0)) / sessionCards.length * 100}%` }
2463
+ }
2464
+ ) });
2465
+ const ratingButtons = [
2466
+ /* @__PURE__ */ jsx9(
2467
+ "button",
2468
+ {
2469
+ type: "button",
2470
+ className: "squisq-flashcards__button",
2471
+ onClick: () => rate("again"),
2472
+ children: "Again"
2473
+ },
2474
+ "again"
2475
+ ),
2476
+ /* @__PURE__ */ jsx9(
2477
+ "button",
2478
+ {
2479
+ type: "button",
2480
+ className: "squisq-flashcards__button squisq-flashcards__button--primary",
2481
+ onClick: () => rate("got-it"),
2482
+ children: lastCard ? "Finish" : "Next"
2483
+ },
2484
+ "got-it"
2485
+ )
2486
+ ];
2487
+ if (railsActive) ratingButtons.reverse();
2488
+ const primaryActions = /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__primary-actions", children: revealed && currentCard.kind === "basic" ? ratingButtons : /* @__PURE__ */ jsx9(
2489
+ "button",
2490
+ {
2491
+ type: "button",
2492
+ className: "squisq-flashcards__button squisq-flashcards__button--primary",
2493
+ onClick: nextCard,
2494
+ "aria-keyshortcuts": "Space ArrowRight",
2495
+ title: `${nextLabel} (Space or \u2192)`,
2496
+ children: nextLabel
2497
+ }
2498
+ ) });
2259
2499
  return /* @__PURE__ */ jsxs6(
2260
2500
  "div",
2261
2501
  {
2262
- className: `squisq-flashcards${className ? ` ${className}` : ""}`,
2502
+ ref: setDeckElement,
2503
+ className: rootClassName + (railsActive ? " squisq-flashcards--side-rails" : ""),
2263
2504
  style: rootStyle,
2264
2505
  role: "region",
2265
2506
  "aria-label": "Flashcards",
@@ -2268,41 +2509,18 @@ function FlashcardView({
2268
2509
  children: [
2269
2510
  /* @__PURE__ */ jsxs6("header", { className: "squisq-flashcards__header", children: [
2270
2511
  /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__deck-copy", children: [
2271
- /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__eyebrow", children: "Flashcards" }),
2272
- deck.title && /* @__PURE__ */ jsx9("h1", { children: deck.title })
2512
+ deck.title && /* @__PURE__ */ jsx9("h1", { title: compact ? deck.title : void 0, children: deck.title }),
2513
+ compact && /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__position", children: position })
2273
2514
  ] }),
2274
- /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__tools", children: [
2275
- /* @__PURE__ */ jsx9(
2276
- "button",
2277
- {
2278
- type: "button",
2279
- className: "squisq-flashcards__tool",
2280
- "aria-pressed": shuffleEnabled,
2281
- onClick: () => {
2282
- setShuffleEnabled((enabled) => !enabled);
2283
- restart();
2284
- },
2285
- children: "Shuffle"
2286
- }
2287
- ),
2288
- /* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__tool", onClick: restart, children: "Restart" })
2289
- ] })
2290
- ] }),
2291
- /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__progress-row", children: [
2292
- /* @__PURE__ */ jsxs6("span", { children: [
2293
- "Card ",
2294
- cardIndex + 1,
2295
- " of ",
2296
- sessionCards.length
2297
- ] }),
2298
- /* @__PURE__ */ jsx9("span", { children: revealed ? "Answer revealed" : "Question" })
2515
+ compact ? /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__controls", children: [
2516
+ tools,
2517
+ /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__navigation", children: [
2518
+ previousButton,
2519
+ primaryActions
2520
+ ] })
2521
+ ] }) : tools
2299
2522
  ] }),
2300
- /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__progress", "aria-hidden": "true", children: /* @__PURE__ */ jsx9(
2301
- "span",
2302
- {
2303
- style: { width: `${(cardIndex + (revealed ? 1 : 0)) / sessionCards.length * 100}%` }
2304
- }
2305
- ) }),
2523
+ compact && progressBar,
2306
2524
  /* @__PURE__ */ jsxs6(
2307
2525
  "main",
2308
2526
  {
@@ -2324,6 +2542,7 @@ function FlashcardView({
2324
2542
  className: "squisq-flashcards__choice",
2325
2543
  "data-choice-status": status,
2326
2544
  "aria-pressed": selected,
2545
+ "aria-keyshortcuts": index < 9 ? String(index + 1) : void 0,
2327
2546
  disabled: revealed,
2328
2547
  onClick: () => choose(choice),
2329
2548
  children: [
@@ -2334,10 +2553,9 @@ function FlashcardView({
2334
2553
  choice.id
2335
2554
  );
2336
2555
  }) }),
2337
- revealed && currentCard.kind === "basic" && /* @__PURE__ */ jsxs6("section", { className: "squisq-flashcards__answer", "aria-label": "Answer", children: [
2338
- /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__answer-label", children: "Answer" }),
2339
- /* @__PURE__ */ jsx9(FaceContent, { ...faceProps, face: currentCard.back })
2340
- ] }),
2556
+ revealed && currentCard.kind === "basic" && // The rule above the answer marks it; aria-label names it for
2557
+ // assistive tech without spending a visible line on an eyebrow.
2558
+ /* @__PURE__ */ jsx9("section", { className: "squisq-flashcards__answer", "aria-label": "Answer", children: /* @__PURE__ */ jsx9(FaceContent, { ...faceProps, face: currentCard.back }) }),
2341
2559
  revealed && currentCard.kind === "multiple-choice" && /* @__PURE__ */ jsxs6(
2342
2560
  "div",
2343
2561
  {
@@ -2360,50 +2578,15 @@ function FlashcardView({
2360
2578
  ]
2361
2579
  }
2362
2580
  ),
2363
- /* @__PURE__ */ jsxs6("footer", { className: "squisq-flashcards__footer", children: [
2364
- /* @__PURE__ */ jsx9(
2365
- "button",
2366
- {
2367
- type: "button",
2368
- className: "squisq-flashcards__button",
2369
- disabled: cardIndex === 0 && !revealed,
2370
- onClick: previousCard,
2371
- children: "Previous"
2372
- }
2373
- ),
2374
- /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__primary-actions", children: revealed && currentCard.kind === "basic" ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
2375
- /* @__PURE__ */ jsx9(
2376
- "button",
2377
- {
2378
- type: "button",
2379
- className: "squisq-flashcards__button",
2380
- onClick: () => rate("again"),
2381
- children: "Again"
2382
- }
2383
- ),
2384
- /* @__PURE__ */ jsx9(
2385
- "button",
2386
- {
2387
- type: "button",
2388
- className: "squisq-flashcards__button squisq-flashcards__button--primary",
2389
- onClick: () => rate("got-it"),
2390
- children: "Got it"
2391
- }
2392
- )
2393
- ] }) : /* @__PURE__ */ jsx9(
2394
- "button",
2395
- {
2396
- type: "button",
2397
- className: "squisq-flashcards__button squisq-flashcards__button--primary",
2398
- onClick: nextCard,
2399
- children: revealed ? cardIndex === sessionCards.length - 1 ? "Finish" : "Next card" : "Reveal answer"
2400
- }
2401
- ) })
2402
- ] }),
2403
- /* @__PURE__ */ jsxs6("p", { className: "squisq-flashcards__shortcut-hint", children: [
2404
- "Use \u2190 and \u2192 to navigate, Space to reveal",
2405
- currentCard.kind === "multiple-choice" ? ", or 1\u20139 to answer" : "",
2406
- "."
2581
+ !compact && /* @__PURE__ */ jsxs6("footer", { className: "squisq-flashcards__footer", children: [
2582
+ /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__back", children: [
2583
+ previousButton,
2584
+ /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__progress-group", children: [
2585
+ /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__position", children: position }),
2586
+ progressBar
2587
+ ] })
2588
+ ] }),
2589
+ primaryActions
2407
2590
  ] })
2408
2591
  ]
2409
2592
  }
@@ -2489,12 +2672,12 @@ function resolveDocPlayerAppearance(doc, overrides = {}) {
2489
2672
 
2490
2673
  // src/DocPlayer.tsx
2491
2674
  import {
2492
- Fragment as Fragment5,
2675
+ Fragment as Fragment4,
2493
2676
  useId as useId2,
2494
2677
  useRef as useRef7,
2495
2678
  useState as useState7,
2496
2679
  useEffect as useEffect8,
2497
- useLayoutEffect as useLayoutEffect2,
2680
+ useLayoutEffect as useLayoutEffect3,
2498
2681
  useCallback as useCallback6,
2499
2682
  useMemo as useMemo6
2500
2683
  } from "react";
@@ -2918,7 +3101,7 @@ function DocPlayerContent({
2918
3101
  const totalDurationRef = useRef7(totalDuration);
2919
3102
  totalDurationRef.current = totalDuration;
2920
3103
  const expandedBlocksLenRef = useRef7(0);
2921
- useLayoutEffect2(() => {
3104
+ useLayoutEffect3(() => {
2922
3105
  committedRenderTimeRef.current = currentTime;
2923
3106
  const pending = renderCommitWaitersRef.current;
2924
3107
  renderCommitWaitersRef.current = pending.filter((waiter) => {
@@ -3873,7 +4056,8 @@ function DocPlayerContent({
3873
4056
  theme: effectiveTheme,
3874
4057
  tableContentRenderer,
3875
4058
  growTextToFit: isSlideshowMode,
3876
- videoEmbeds: renderMode ? "placeholder" : "poster"
4059
+ videoEmbeds: renderMode ? "placeholder" : "poster",
4060
+ staticMedia: renderMode
3877
4061
  }
3878
4062
  ) }),
3879
4063
  animationsEnabled && !showCoverBlock && previousBlock && isExiting && // Keyed by block id so each block is its own DOM subtree: React never
@@ -3896,7 +4080,8 @@ function DocPlayerContent({
3896
4080
  theme: effectiveTheme,
3897
4081
  tableContentRenderer,
3898
4082
  growTextToFit: isSlideshowMode,
3899
- videoEmbeds: renderMode ? "placeholder" : "poster"
4083
+ videoEmbeds: renderMode ? "placeholder" : "poster",
4084
+ staticMedia: renderMode
3900
4085
  }
3901
4086
  ) }, previousBlock.id),
3902
4087
  currentBlock && /* @__PURE__ */ jsx10(
@@ -3924,7 +4109,8 @@ function DocPlayerContent({
3924
4109
  theme: effectiveTheme,
3925
4110
  tableContentRenderer,
3926
4111
  growTextToFit: isSlideshowMode,
3927
- videoEmbeds: renderMode ? "placeholder" : "player"
4112
+ videoEmbeds: renderMode ? "placeholder" : "player",
4113
+ staticMedia: renderMode
3928
4114
  }
3929
4115
  )
3930
4116
  },
@@ -4042,7 +4228,7 @@ function DocPlayerContent({
4042
4228
  hasCaptions && (() => {
4043
4229
  const debugPhrase = getCaptionAtTime2(doc.captions, currentTime);
4044
4230
  const debugEnabled = captionsEnabled && captionClockRunning;
4045
- return /* @__PURE__ */ jsxs7(Fragment5, { children: [
4231
+ return /* @__PURE__ */ jsxs7(Fragment4, { children: [
4046
4232
  /* @__PURE__ */ jsxs7("div", { children: [
4047
4233
  /* @__PURE__ */ jsx10("span", { style: { color: "#888" }, children: "captions:" }),
4048
4234
  " ",
@@ -4400,6 +4586,7 @@ export {
4400
4586
  DocProgressBar,
4401
4587
  DocControlsOverlay,
4402
4588
  DocControlsSlideshow,
4589
+ decodeSvgImages,
4403
4590
  DashboardView,
4404
4591
  FlashcardFaceView,
4405
4592
  FlashcardView,