@bendyline/squisq-react 2.12.3 → 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,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-PVRZGR5J.js";
3
+ } from "./chunk-MGFMKGZY.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
@@ -15,11 +15,11 @@ import {
15
15
  } from "./chunk-YVQ7KEYI.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-M7DM4NOX.js";
18
+ } from "./chunk-PFKYO6C2.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-LWB4AM3W.js";
22
+ } from "./chunk-4ILJDBJ7.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
@@ -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)",
@@ -1918,6 +2032,7 @@ function DashboardView({
1918
2032
  import {
1919
2033
  useCallback as useCallback4,
1920
2034
  useEffect as useEffect6,
2035
+ useLayoutEffect as useLayoutEffect2,
1921
2036
  useMemo as useMemo5,
1922
2037
  useRef as useRef5,
1923
2038
  useState as useState5
@@ -1929,7 +2044,7 @@ import {
1929
2044
  resolvePageBlock,
1930
2045
  resolveThemeForDoc as resolveThemeForDoc2
1931
2046
  } from "@bendyline/squisq/doc";
1932
- 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";
1933
2048
  var VISUAL_TEMPLATES = /* @__PURE__ */ new Set([
1934
2049
  "diagram",
1935
2050
  "tree",
@@ -2056,6 +2171,12 @@ function shuffled(values, seed) {
2056
2171
  function ChoiceContent(props) {
2057
2172
  return /* @__PURE__ */ jsx9(FaceContent, { ...props, face: props.choice.content });
2058
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
+ }
2059
2180
  function isInteractiveTarget(target) {
2060
2181
  return target instanceof Element && !!target.closest('button, a, input, select, textarea, [contenteditable="true"]');
2061
2182
  }
@@ -2070,8 +2191,11 @@ function FlashcardView({
2070
2191
  onCopyCode,
2071
2192
  fenceRenderers,
2072
2193
  viewport = VIEWPORT_PRESETS2.landscape,
2194
+ density = "comfortable",
2073
2195
  className
2074
2196
  }) {
2197
+ const compact = density === "compact";
2198
+ const rootClassName = "squisq-flashcards" + (compact ? " squisq-flashcards--compact" : "") + (className ? ` ${className}` : "");
2075
2199
  const activeTheme = useMemo5(() => theme ?? resolveThemeForDoc2(doc), [doc, theme]);
2076
2200
  const deck = useMemo5(() => materializeFlashcards(doc, { source }), [doc, source]);
2077
2201
  const [shuffleEnabled, setShuffleEnabled] = useState5(initialShuffle);
@@ -2082,6 +2206,8 @@ function FlashcardView({
2082
2206
  const [ratings, setRatings] = useState5({});
2083
2207
  const [retryIds, setRetryIds] = useState5(null);
2084
2208
  const cardViewportRef = useRef5(null);
2209
+ const [deckElement, setDeckElement] = useState5(null);
2210
+ const [sideRails, setSideRails] = useState5(false);
2085
2211
  const orderedCards = useMemo5(
2086
2212
  () => shuffleEnabled ? shuffled(deck.cards, `${doc.articleId}:${sessionSeed}`) : [...deck.cards],
2087
2213
  [deck.cards, doc.articleId, sessionSeed, shuffleEnabled]
@@ -2111,6 +2237,29 @@ function FlashcardView({
2111
2237
  useEffect6(() => {
2112
2238
  if (cardViewportRef.current) cardViewportRef.current.scrollTop = 0;
2113
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]);
2114
2263
  const revealAnswer = useCallback4(() => {
2115
2264
  if (!currentCard) return;
2116
2265
  setRevealed(true);
@@ -2224,7 +2373,7 @@ function FlashcardView({
2224
2373
  return /* @__PURE__ */ jsx9(
2225
2374
  "div",
2226
2375
  {
2227
- className: `squisq-flashcards squisq-flashcards--empty${className ? ` ${className}` : ""}`,
2376
+ className: `${rootClassName} squisq-flashcards--empty`,
2228
2377
  style: rootStyle,
2229
2378
  role: "region",
2230
2379
  "aria-label": "Flashcards",
@@ -2240,7 +2389,7 @@ function FlashcardView({
2240
2389
  return /* @__PURE__ */ jsx9(
2241
2390
  "div",
2242
2391
  {
2243
- className: `squisq-flashcards${className ? ` ${className}` : ""}`,
2392
+ className: rootClassName,
2244
2393
  style: rootStyle,
2245
2394
  role: "region",
2246
2395
  "aria-label": "Flashcard session summary",
@@ -2275,10 +2424,83 @@ function FlashcardView({
2275
2424
  }
2276
2425
  const choices = currentCard?.choices ? shuffled(currentCard.choices, `${currentCard.id}:${sessionSeed}`) : [];
2277
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
+ ) });
2278
2499
  return /* @__PURE__ */ jsxs6(
2279
2500
  "div",
2280
2501
  {
2281
- className: `squisq-flashcards${className ? ` ${className}` : ""}`,
2502
+ ref: setDeckElement,
2503
+ className: rootClassName + (railsActive ? " squisq-flashcards--side-rails" : ""),
2282
2504
  style: rootStyle,
2283
2505
  role: "region",
2284
2506
  "aria-label": "Flashcards",
@@ -2287,41 +2509,18 @@ function FlashcardView({
2287
2509
  children: [
2288
2510
  /* @__PURE__ */ jsxs6("header", { className: "squisq-flashcards__header", children: [
2289
2511
  /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__deck-copy", children: [
2290
- /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__eyebrow", children: "Flashcards" }),
2291
- deck.title && /* @__PURE__ */ jsx9("h1", { children: deck.title })
2292
- ] }),
2293
- /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__tools", children: [
2294
- /* @__PURE__ */ jsx9(
2295
- "button",
2296
- {
2297
- type: "button",
2298
- className: "squisq-flashcards__tool",
2299
- "aria-pressed": shuffleEnabled,
2300
- onClick: () => {
2301
- setShuffleEnabled((enabled) => !enabled);
2302
- restart();
2303
- },
2304
- children: "Shuffle"
2305
- }
2306
- ),
2307
- /* @__PURE__ */ jsx9("button", { type: "button", className: "squisq-flashcards__tool", onClick: restart, children: "Restart" })
2308
- ] })
2309
- ] }),
2310
- /* @__PURE__ */ jsxs6("div", { className: "squisq-flashcards__progress-row", children: [
2311
- /* @__PURE__ */ jsxs6("span", { children: [
2312
- "Card ",
2313
- cardIndex + 1,
2314
- " of ",
2315
- sessionCards.length
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 })
2316
2514
  ] }),
2317
- /* @__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
2318
2522
  ] }),
2319
- /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__progress", "aria-hidden": "true", children: /* @__PURE__ */ jsx9(
2320
- "span",
2321
- {
2322
- style: { width: `${(cardIndex + (revealed ? 1 : 0)) / sessionCards.length * 100}%` }
2323
- }
2324
- ) }),
2523
+ compact && progressBar,
2325
2524
  /* @__PURE__ */ jsxs6(
2326
2525
  "main",
2327
2526
  {
@@ -2343,6 +2542,7 @@ function FlashcardView({
2343
2542
  className: "squisq-flashcards__choice",
2344
2543
  "data-choice-status": status,
2345
2544
  "aria-pressed": selected,
2545
+ "aria-keyshortcuts": index < 9 ? String(index + 1) : void 0,
2346
2546
  disabled: revealed,
2347
2547
  onClick: () => choose(choice),
2348
2548
  children: [
@@ -2353,10 +2553,9 @@ function FlashcardView({
2353
2553
  choice.id
2354
2554
  );
2355
2555
  }) }),
2356
- revealed && currentCard.kind === "basic" && /* @__PURE__ */ jsxs6("section", { className: "squisq-flashcards__answer", "aria-label": "Answer", children: [
2357
- /* @__PURE__ */ jsx9("span", { className: "squisq-flashcards__answer-label", children: "Answer" }),
2358
- /* @__PURE__ */ jsx9(FaceContent, { ...faceProps, face: currentCard.back })
2359
- ] }),
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 }) }),
2360
2559
  revealed && currentCard.kind === "multiple-choice" && /* @__PURE__ */ jsxs6(
2361
2560
  "div",
2362
2561
  {
@@ -2379,50 +2578,15 @@ function FlashcardView({
2379
2578
  ]
2380
2579
  }
2381
2580
  ),
2382
- /* @__PURE__ */ jsxs6("footer", { className: "squisq-flashcards__footer", children: [
2383
- /* @__PURE__ */ jsx9(
2384
- "button",
2385
- {
2386
- type: "button",
2387
- className: "squisq-flashcards__button",
2388
- disabled: cardIndex === 0 && !revealed,
2389
- onClick: previousCard,
2390
- children: "Previous"
2391
- }
2392
- ),
2393
- /* @__PURE__ */ jsx9("div", { className: "squisq-flashcards__primary-actions", children: revealed && currentCard.kind === "basic" ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
2394
- /* @__PURE__ */ jsx9(
2395
- "button",
2396
- {
2397
- type: "button",
2398
- className: "squisq-flashcards__button",
2399
- onClick: () => rate("again"),
2400
- children: "Again"
2401
- }
2402
- ),
2403
- /* @__PURE__ */ jsx9(
2404
- "button",
2405
- {
2406
- type: "button",
2407
- className: "squisq-flashcards__button squisq-flashcards__button--primary",
2408
- onClick: () => rate("got-it"),
2409
- children: "Got it"
2410
- }
2411
- )
2412
- ] }) : /* @__PURE__ */ jsx9(
2413
- "button",
2414
- {
2415
- type: "button",
2416
- className: "squisq-flashcards__button squisq-flashcards__button--primary",
2417
- onClick: nextCard,
2418
- children: revealed ? cardIndex === sessionCards.length - 1 ? "Finish" : "Next card" : "Reveal answer"
2419
- }
2420
- ) })
2421
- ] }),
2422
- /* @__PURE__ */ jsxs6("p", { className: "squisq-flashcards__shortcut-hint", children: [
2423
- "Use \u2190 and \u2192 to navigate, Space to reveal",
2424
- currentCard.kind === "multiple-choice" ? ", or 1\u20139 to answer" : "",
2425
- "."
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
2426
2590
  ] })
2427
2591
  ]
2428
2592
  }
@@ -2508,12 +2672,12 @@ function resolveDocPlayerAppearance(doc, overrides = {}) {
2508
2672
 
2509
2673
  // src/DocPlayer.tsx
2510
2674
  import {
2511
- Fragment as Fragment5,
2675
+ Fragment as Fragment4,
2512
2676
  useId as useId2,
2513
2677
  useRef as useRef7,
2514
2678
  useState as useState7,
2515
2679
  useEffect as useEffect8,
2516
- useLayoutEffect as useLayoutEffect2,
2680
+ useLayoutEffect as useLayoutEffect3,
2517
2681
  useCallback as useCallback6,
2518
2682
  useMemo as useMemo6
2519
2683
  } from "react";
@@ -2937,7 +3101,7 @@ function DocPlayerContent({
2937
3101
  const totalDurationRef = useRef7(totalDuration);
2938
3102
  totalDurationRef.current = totalDuration;
2939
3103
  const expandedBlocksLenRef = useRef7(0);
2940
- useLayoutEffect2(() => {
3104
+ useLayoutEffect3(() => {
2941
3105
  committedRenderTimeRef.current = currentTime;
2942
3106
  const pending = renderCommitWaitersRef.current;
2943
3107
  renderCommitWaitersRef.current = pending.filter((waiter) => {
@@ -4064,7 +4228,7 @@ function DocPlayerContent({
4064
4228
  hasCaptions && (() => {
4065
4229
  const debugPhrase = getCaptionAtTime2(doc.captions, currentTime);
4066
4230
  const debugEnabled = captionsEnabled && captionClockRunning;
4067
- return /* @__PURE__ */ jsxs7(Fragment5, { children: [
4231
+ return /* @__PURE__ */ jsxs7(Fragment4, { children: [
4068
4232
  /* @__PURE__ */ jsxs7("div", { children: [
4069
4233
  /* @__PURE__ */ jsx10("span", { style: { color: "#888" }, children: "captions:" }),
4070
4234
  " ",
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-YVQ7KEYI.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-M7DM4NOX.js";
11
+ } from "./chunk-PFKYO6C2.js";
12
12
  import {
13
13
  svgDataImageSrc,
14
14
  useMediaUrl
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-LWB4AM3W.js";
15
+ } from "./chunk-4ILJDBJ7.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";