@intellectif/lk-react 14.0.0 → 14.1.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/{WrittenResponse-C0P34En1.d.ts → WrittenResponse-DrzI89Wg.d.ts} +1 -1
  4. package/dist/{WrittenResponse-pB1ik8hg.d.cts → WrittenResponse-rRpOr9W1.d.cts} +1 -1
  5. package/dist/{chunk-YEYKJFEC.cjs → chunk-4Y5TELVU.cjs} +12 -12
  6. package/dist/{chunk-YEYKJFEC.cjs.map → chunk-4Y5TELVU.cjs.map} +1 -1
  7. package/dist/{chunk-72UGRIMM.js → chunk-5CP2Z6IS.js} +5 -5
  8. package/dist/{chunk-72UGRIMM.js.map → chunk-5CP2Z6IS.js.map} +1 -1
  9. package/dist/{chunk-BVRUUYYR.cjs → chunk-5JCTJFQU.cjs} +18 -18
  10. package/dist/{chunk-BVRUUYYR.cjs.map → chunk-5JCTJFQU.cjs.map} +1 -1
  11. package/dist/{chunk-D57QZILZ.js → chunk-5JFMXBH7.js} +62 -37
  12. package/dist/chunk-5JFMXBH7.js.map +1 -0
  13. package/dist/{chunk-SWY6PWXK.js → chunk-AS2QGND5.js} +4 -4
  14. package/dist/{chunk-SWY6PWXK.js.map → chunk-AS2QGND5.js.map} +1 -1
  15. package/dist/{chunk-TDJEKXEP.js → chunk-AWQ53DON.js} +3 -2
  16. package/dist/chunk-AWQ53DON.js.map +1 -0
  17. package/dist/{chunk-BO6P723E.js → chunk-B4BCEQNO.js} +3 -3
  18. package/dist/{chunk-BO6P723E.js.map → chunk-B4BCEQNO.js.map} +1 -1
  19. package/dist/{chunk-RRH7ZPXC.cjs → chunk-CTW3G3EH.cjs} +6 -6
  20. package/dist/{chunk-RRH7ZPXC.cjs.map → chunk-CTW3G3EH.cjs.map} +1 -1
  21. package/dist/{chunk-XIBOFTOL.js → chunk-DB4DLHN6.js} +22 -4
  22. package/dist/chunk-DB4DLHN6.js.map +1 -0
  23. package/dist/{chunk-USBANZ7K.cjs → chunk-DPEY7DSE.cjs} +5 -5
  24. package/dist/{chunk-USBANZ7K.cjs.map → chunk-DPEY7DSE.cjs.map} +1 -1
  25. package/dist/{chunk-XUEIUEPI.js → chunk-IDYZ2FA2.js} +5 -5
  26. package/dist/{chunk-XUEIUEPI.js.map → chunk-IDYZ2FA2.js.map} +1 -1
  27. package/dist/{chunk-NDQD3ZRY.cjs → chunk-JG4DWAUJ.cjs} +13 -13
  28. package/dist/{chunk-NDQD3ZRY.cjs.map → chunk-JG4DWAUJ.cjs.map} +1 -1
  29. package/dist/{chunk-36FTYJWJ.cjs → chunk-KIO6QXGT.cjs} +80 -55
  30. package/dist/chunk-KIO6QXGT.cjs.map +1 -0
  31. package/dist/{chunk-J2CDPIRC.cjs → chunk-MZITNWZ2.cjs} +27 -25
  32. package/dist/chunk-MZITNWZ2.cjs.map +1 -0
  33. package/dist/{chunk-SE6WWDVW.cjs → chunk-N536RUCZ.cjs} +13 -13
  34. package/dist/{chunk-SE6WWDVW.cjs.map → chunk-N536RUCZ.cjs.map} +1 -1
  35. package/dist/{chunk-47HHC4GD.js → chunk-NJAF34GN.js} +5 -5
  36. package/dist/{chunk-47HHC4GD.js.map → chunk-NJAF34GN.js.map} +1 -1
  37. package/dist/{chunk-U3APKQ7P.cjs → chunk-PSUKWVKU.cjs} +13 -13
  38. package/dist/{chunk-U3APKQ7P.cjs.map → chunk-PSUKWVKU.cjs.map} +1 -1
  39. package/dist/{chunk-YMBBM5K7.js → chunk-RCPW6HVY.js} +10 -10
  40. package/dist/{chunk-YMBBM5K7.js.map → chunk-RCPW6HVY.js.map} +1 -1
  41. package/dist/{chunk-62AKSD5Y.js → chunk-TUVEJLOT.js} +39 -11
  42. package/dist/chunk-TUVEJLOT.js.map +1 -0
  43. package/dist/{chunk-LLXCX5KK.js → chunk-U432HTUW.js} +5 -5
  44. package/dist/{chunk-LLXCX5KK.js.map → chunk-U432HTUW.js.map} +1 -1
  45. package/dist/{chunk-LGCUOLP6.js → chunk-UDQS5INQ.js} +5 -5
  46. package/dist/{chunk-LGCUOLP6.js.map → chunk-UDQS5INQ.js.map} +1 -1
  47. package/dist/{chunk-I33FOKZ7.js → chunk-UDZWYHDV.js} +14 -12
  48. package/dist/chunk-UDZWYHDV.js.map +1 -0
  49. package/dist/{chunk-B2XQLU2E.cjs → chunk-UMDWVMB5.cjs} +24 -6
  50. package/dist/chunk-UMDWVMB5.cjs.map +1 -0
  51. package/dist/{chunk-LB3FEV7Z.cjs → chunk-VSFHJ7FB.cjs} +3 -2
  52. package/dist/chunk-VSFHJ7FB.cjs.map +1 -0
  53. package/dist/{chunk-WTS34S5E.cjs → chunk-WC4OD3EE.cjs} +13 -13
  54. package/dist/{chunk-WTS34S5E.cjs.map → chunk-WC4OD3EE.cjs.map} +1 -1
  55. package/dist/{chunk-F4TBCRGI.cjs → chunk-YM64MS4G.cjs} +42 -13
  56. package/dist/chunk-YM64MS4G.cjs.map +1 -0
  57. package/dist/components/ActivityPreview.cjs +12 -12
  58. package/dist/components/ActivityPreview.d.cts +2 -2
  59. package/dist/components/ActivityPreview.d.ts +2 -2
  60. package/dist/components/ActivityPreview.js +11 -11
  61. package/dist/components/ActivitySequence.cjs +13 -13
  62. package/dist/components/ActivitySequence.d.cts +14 -7
  63. package/dist/components/ActivitySequence.d.ts +14 -7
  64. package/dist/components/ActivitySequence.js +12 -12
  65. package/dist/components/Dictation.cjs +5 -5
  66. package/dist/components/Dictation.d.cts +1 -1
  67. package/dist/components/Dictation.d.ts +1 -1
  68. package/dist/components/Dictation.js +4 -4
  69. package/dist/components/FillInTheBlanks.cjs +5 -5
  70. package/dist/components/FillInTheBlanks.d.cts +1 -1
  71. package/dist/components/FillInTheBlanks.d.ts +1 -1
  72. package/dist/components/FillInTheBlanks.js +4 -4
  73. package/dist/components/GapSelect.cjs +5 -5
  74. package/dist/components/GapSelect.d.cts +1 -1
  75. package/dist/components/GapSelect.d.ts +1 -1
  76. package/dist/components/GapSelect.js +4 -4
  77. package/dist/components/MultipleChoice.cjs +5 -5
  78. package/dist/components/MultipleChoice.d.cts +1 -1
  79. package/dist/components/MultipleChoice.d.ts +1 -1
  80. package/dist/components/MultipleChoice.js +4 -4
  81. package/dist/components/PronunciationFeedback.cjs +4 -4
  82. package/dist/components/PronunciationFeedback.d.cts +5 -2
  83. package/dist/components/PronunciationFeedback.d.ts +5 -2
  84. package/dist/components/PronunciationFeedback.js +3 -3
  85. package/dist/components/ReadAloud.cjs +6 -6
  86. package/dist/components/ReadAloud.d.cts +2 -2
  87. package/dist/components/ReadAloud.d.ts +2 -2
  88. package/dist/components/ReadAloud.js +5 -5
  89. package/dist/components/StimulusPanel.cjs +4 -4
  90. package/dist/components/StimulusPanel.d.cts +1 -1
  91. package/dist/components/StimulusPanel.d.ts +1 -1
  92. package/dist/components/StimulusPanel.js +3 -3
  93. package/dist/components/WrittenResponse.cjs +5 -5
  94. package/dist/components/WrittenResponse.d.cts +3 -3
  95. package/dist/components/WrittenResponse.d.ts +3 -3
  96. package/dist/components/WrittenResponse.js +4 -4
  97. package/dist/i18n/LkIntlProvider.cjs +7 -7
  98. package/dist/i18n/LkIntlProvider.d.cts +2 -2
  99. package/dist/i18n/LkIntlProvider.d.ts +2 -2
  100. package/dist/i18n/LkIntlProvider.js +1 -1
  101. package/dist/index.cjs +29 -29
  102. package/dist/index.d.cts +2 -2
  103. package/dist/index.d.ts +2 -2
  104. package/dist/index.js +13 -13
  105. package/dist/{strings-CtdSf2St.d.ts → strings-l8Wv1Xax.d.ts} +16 -0
  106. package/dist/{strings--ADnHcaA.d.cts → strings-wjAF2ONm.d.cts} +16 -0
  107. package/dist/theme/skin.css +17 -1
  108. package/package.json +3 -3
  109. package/dist/chunk-36FTYJWJ.cjs.map +0 -1
  110. package/dist/chunk-62AKSD5Y.js.map +0 -1
  111. package/dist/chunk-B2XQLU2E.cjs.map +0 -1
  112. package/dist/chunk-D57QZILZ.js.map +0 -1
  113. package/dist/chunk-F4TBCRGI.cjs.map +0 -1
  114. package/dist/chunk-I33FOKZ7.js.map +0 -1
  115. package/dist/chunk-J2CDPIRC.cjs.map +0 -1
  116. package/dist/chunk-LB3FEV7Z.cjs.map +0 -1
  117. package/dist/chunk-TDJEKXEP.js.map +0 -1
  118. package/dist/chunk-XIBOFTOL.js.map +0 -1
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var chunkF4TBCRGI_cjs = require('./chunk-F4TBCRGI.cjs');
4
+ var chunkYM64MS4G_cjs = require('./chunk-YM64MS4G.cjs');
5
5
  var chunkUDCQTOVU_cjs = require('./chunk-UDCQTOVU.cjs');
6
6
  var chunkOD65OZIW_cjs = require('./chunk-OD65OZIW.cjs');
7
7
  var chunkBRPEB43C_cjs = require('./chunk-BRPEB43C.cjs');
8
- var chunkUSBANZ7K_cjs = require('./chunk-USBANZ7K.cjs');
9
- var chunkB2XQLU2E_cjs = require('./chunk-B2XQLU2E.cjs');
8
+ var chunkDPEY7DSE_cjs = require('./chunk-DPEY7DSE.cjs');
9
+ var chunkUMDWVMB5_cjs = require('./chunk-UMDWVMB5.cjs');
10
10
  var chunkXOR4MPEN_cjs = require('./chunk-XOR4MPEN.cjs');
11
- var chunkLB3FEV7Z_cjs = require('./chunk-LB3FEV7Z.cjs');
11
+ var chunkVSFHJ7FB_cjs = require('./chunk-VSFHJ7FB.cjs');
12
12
  var lkCore = require('@intellectif/lk-core');
13
13
  var react = require('react');
14
14
  var jsxRuntime = require('react/jsx-runtime');
@@ -56,6 +56,20 @@ function stampTake(value, take) {
56
56
  function takeOf(value) {
57
57
  return typeof value === "object" && value !== null ? takes.get(value) : void 0;
58
58
  }
59
+ var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
60
+ function readRecordingBounds(recording) {
61
+ const bounds = typeof recording === "object" && recording !== null ? recording : {};
62
+ const maxSeconds = isNumber(bounds.maxSeconds) && bounds.maxSeconds > 0 ? Math.min(bounds.maxSeconds, lkCore.READ_ALOUD_MAX_SECONDS) : lkCore.READ_ALOUD_MAX_SECONDS;
63
+ const minSeconds = isNumber(bounds.minSeconds) && bounds.minSeconds >= 0 && bounds.minSeconds < maxSeconds ? bounds.minSeconds : void 0;
64
+ const takes2 = bounds.maxTakes;
65
+ const maxTakes = takes2 === void 0 || takes2 === null ? void 0 : isNumber(takes2) ? Math.min(Math.max(1, Math.floor(takes2)), lkCore.READ_ALOUD_MAX_TAKES) : lkCore.READ_ALOUD_MAX_TAKES;
66
+ return { maxSeconds, minSeconds, maxTakes };
67
+ }
68
+ function secondsWithin(milliseconds, maxSeconds, rounding) {
69
+ const seconds = milliseconds / 1e3;
70
+ const whole = rounding === "nearest" ? Math.round(seconds) : Math.floor(seconds);
71
+ return Math.min(Math.max(0, whole), maxSeconds);
72
+ }
59
73
  var modelsGroupCount = 0;
60
74
  var VISIBLE_TEXT_RE = /[^\p{White_Space}\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]/u;
61
75
  var MARK_ID_RE = /^w\d+$/;
@@ -74,6 +88,9 @@ function takeStateOf(phase, uploaded) {
74
88
  }
75
89
  return offersRetry(phase, uploaded) ? "retryable" : "settled";
76
90
  }
91
+ function capturing(status) {
92
+ return status === "recording" || status === "requesting-permission";
93
+ }
77
94
  function readingKeyOf(data, bounds) {
78
95
  const text = (value) => typeof value === "string" ? value : null;
79
96
  return JSON.stringify([
@@ -155,7 +172,7 @@ function OutcomeSummary({
155
172
  "data-status": reading.status,
156
173
  "data-passed": String(reading.grade.passed),
157
174
  children: scoreShown ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
158
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-grade", children: s.scoreAnnouncement(chunkF4TBCRGI_cjs.percentOfGrade(reading.grade), reading.grade.passed) }),
175
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-grade", children: s.scoreAnnouncement(chunkYM64MS4G_cjs.percentOfGrade(reading.grade), reading.grade.passed) }),
159
176
  reading.grade.feedback ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-grade-feedback", dir: "auto", children: reading.grade.feedback }) : null
160
177
  ] })
161
178
  }
@@ -202,15 +219,16 @@ function ReadAloud({
202
219
  recordingBinding,
203
220
  assessment,
204
221
  breakThreshold,
205
- monotoneThreshold
222
+ monotoneThreshold,
223
+ workletUrl
206
224
  }) {
207
225
  const isExam = renderMode === "exam";
208
226
  const isReview = renderMode === "review";
209
- const s = chunkLB3FEV7Z_cjs.useLkStrings(strings);
227
+ const s = chunkVSFHJ7FB_cjs.useLkStrings(strings);
210
228
  const slot = react.useContext(SequenceSlotContext);
211
229
  const captureGroup = slot?.captureGroup;
212
230
  const devError = react.useMemo(() => {
213
- if (!chunkUSBANZ7K_cjs.isDevelopment()) {
231
+ if (!chunkDPEY7DSE_cjs.isDevelopment()) {
214
232
  return null;
215
233
  }
216
234
  if (data.redacted === true) {
@@ -224,19 +242,19 @@ function ReadAloud({
224
242
  const result = lkCore.validateActivity("read-aloud", data);
225
243
  return result.success ? null : new lkCore.ActivitySchemaError("read-aloud", result.errors);
226
244
  }, [data]);
227
- const bounds = data.recording;
228
- const maxSeconds = typeof bounds?.maxSeconds === "number" && bounds.maxSeconds > 0 ? Math.min(bounds.maxSeconds, lkCore.READ_ALOUD_MAX_SECONDS) : lkCore.READ_ALOUD_MAX_SECONDS;
229
- const minSeconds = typeof bounds?.minSeconds === "number" ? bounds.minSeconds : void 0;
230
- const maxTakes = typeof bounds?.maxTakes === "number" && Number.isFinite(bounds.maxTakes) ? Math.min(Math.max(1, Math.floor(bounds.maxTakes)), lkCore.READ_ALOUD_MAX_TAKES) : void 0;
245
+ const { maxSeconds, minSeconds, maxTakes } = readRecordingBounds(data.recording);
231
246
  const readingKey = readingKeyOf(data, { maxSeconds, minSeconds, maxTakes });
232
247
  const recorder = chunkUDCQTOVU_cjs.useSpeechRecorder(
233
248
  react.useMemo(
234
249
  () => ({
235
250
  maxDurationMs: maxSeconds * 1e3,
236
251
  ...minSeconds !== void 0 ? { minDurationMs: minSeconds * 1e3 } : {},
237
- ...maxTakes !== void 0 ? { maxTakes } : {}
252
+ ...maxTakes !== void 0 ? { maxTakes } : {},
253
+ // Forwarded, never defaulted: without it the recorder mints its own
254
+ // `blob:` module, which is the one a strict policy refuses.
255
+ ...workletUrl !== void 0 ? { workletUrl } : {}
238
256
  }),
239
- [maxSeconds, minSeconds, maxTakes]
257
+ [maxSeconds, minSeconds, maxTakes, workletUrl]
240
258
  )
241
259
  );
242
260
  const { state, start, complete, getTimeSpent, reset } = chunkXOR4MPEN_cjs.useActivityState(
@@ -334,7 +352,7 @@ function ReadAloud({
334
352
  const statusRef = react.useRef(recorder.status);
335
353
  statusRef.current = recorder.status;
336
354
  const releaseMicrophone = react.useCallback(() => {
337
- if (statusRef.current === "recording" || statusRef.current === "requesting-permission") {
355
+ if (capturing(statusRef.current)) {
338
356
  recorder.discard();
339
357
  }
340
358
  }, [recorder.discard]);
@@ -373,8 +391,9 @@ function ReadAloud({
373
391
  slot.takeState(take2, phaseTakeState);
374
392
  }, [slot, phaseTake, phaseTakeState]);
375
393
  const modelsRef = react.useRef(null);
394
+ const isCapturing = capturing(recorder.status);
376
395
  react.useEffect(() => {
377
- if (recorder.status !== "recording") {
396
+ if (!isCapturing) {
378
397
  return;
379
398
  }
380
399
  const node = modelsRef.current;
@@ -394,11 +413,14 @@ function ReadAloud({
394
413
  return () => {
395
414
  node.removeEventListener("play", hush, true);
396
415
  };
397
- }, [recorder.status]);
416
+ }, [isCapturing]);
398
417
  const slowMedia = react.useMemo(
399
418
  () => slowMediaFor(data, s.readAloudSlowRecording),
400
419
  [data, s.readAloudSlowRecording]
401
420
  );
421
+ const takeAudio = isReview ? playbackUrl : takeUrl;
422
+ const playback = chunkYM64MS4G_cjs.usePlaybackRefusal(takeAudio);
423
+ const submitRef = react.useRef(null);
402
424
  if (devError) {
403
425
  throw devError;
404
426
  }
@@ -444,7 +466,7 @@ function ReadAloud({
444
466
  if (run !== runRef.current) {
445
467
  return;
446
468
  }
447
- const result = chunkF4TBCRGI_cjs.readAssessResult(answer);
469
+ const result = chunkYM64MS4G_cjs.readAssessResult(answer);
448
470
  if (result.status === "failed") {
449
471
  raise({ kind: "assess-failed", take: take2, retryable: result.retryable });
450
472
  fire("assessment-failed", { takes: takes2, durationMs, retryable: result.retryable });
@@ -475,9 +497,9 @@ function ReadAloud({
475
497
  passed: grade.passed,
476
498
  timeSpent,
477
499
  xapiStatement: lkCore.xAPIBuilder.buildAnsweredStatement({
478
- actor: chunkUSBANZ7K_cjs.ANONYMOUS_ACTOR,
500
+ actor: chunkDPEY7DSE_cjs.ANONYMOUS_ACTOR,
479
501
  object: {
480
- id: chunkUSBANZ7K_cjs.objectIdFor(data.id),
502
+ id: chunkDPEY7DSE_cjs.objectIdFor(data.id),
481
503
  name: { [data.locale ?? "en-US"]: data.title },
482
504
  ...lkCore.xapiDefinitionFor(data)
483
505
  },
@@ -487,7 +509,7 @@ function ReadAloud({
487
509
  // optional, and an empty list is the honest reading of "no per-word
488
510
  // marks were stored" — never a mark of its own.
489
511
  scoringResult: {
490
- score: chunkF4TBCRGI_cjs.fractionOfGrade(grade),
512
+ score: chunkYM64MS4G_cjs.fractionOfGrade(grade),
491
513
  maxScore: 1,
492
514
  passed: grade.passed,
493
515
  feedback: grade.feedback,
@@ -581,8 +603,8 @@ function ReadAloud({
581
603
  };
582
604
  const contentLang = typeof data.locale === "string" ? data.locale : void 0;
583
605
  const contentDir = chunkOD65OZIW_cjs.localeDirectionOf(data.locale);
584
- const outcomeReading = react.useMemo(() => chunkF4TBCRGI_cjs.readOutcome(outcome), [outcome]);
585
- const keptEvidence = react.useMemo(() => chunkF4TBCRGI_cjs.readEvidence(assessment), [assessment]);
606
+ const outcomeReading = react.useMemo(() => chunkYM64MS4G_cjs.readOutcome(outcome), [outcome]);
607
+ const keptEvidence = react.useMemo(() => chunkYM64MS4G_cjs.readEvidence(assessment), [assessment]);
586
608
  const storedGrade = outcomeReading?.kind === "graded" && outcomeReading.status === "graded" ? outcomeReading.grade : null;
587
609
  const storedMarks = react.useMemo(
588
610
  () => isReview && keptEvidence === null && storedGrade?.details !== void 0 ? marksFromDetails(storedGrade.details) : null,
@@ -590,7 +612,7 @@ function ReadAloud({
590
612
  );
591
613
  const feedbackAssessment = isReview ? keptEvidence : phase.kind === "graded" ? phase.assessment : null;
592
614
  const feedbackGrade = isReview ? storedGrade : phase.kind === "graded" ? phase.grade : null;
593
- const feedbackAudio = isReview ? playbackUrl : takeUrl;
615
+ const feedbackAudio = playback.refused ? null : takeAudio;
594
616
  const rootRef = react.useRef(null);
595
617
  const [panelLostTheGrade, setPanelLostTheGrade] = react.useState(false);
596
618
  const panelHasGrade = feedbackAssessment !== null && feedbackGrade !== null;
@@ -608,7 +630,10 @@ function ReadAloud({
608
630
  return { text: s.readAloudRecordingStarted, feedback: null };
609
631
  }
610
632
  const stopped = recorder.status === "recorded" && take !== null ? {
611
- text: s.readAloudRecordingStopped(Math.round(take.durationMs / 1e3), maxSeconds),
633
+ text: s.readAloudRecordingStopped(
634
+ secondsWithin(take.durationMs, maxSeconds, "nearest"),
635
+ maxSeconds
636
+ ),
612
637
  feedback: null
613
638
  } : null;
614
639
  if (isExam) {
@@ -621,7 +646,7 @@ function ReadAloud({
621
646
  case "graded": {
622
647
  const grade = phase.grade;
623
648
  return grade === null ? { text: `${s.answerSubmitted} ${s.couldNotBeGraded}`, feedback: null } : {
624
- text: `${s.answerSubmitted} ${s.scoreAnnouncement(chunkF4TBCRGI_cjs.percentOfGrade(grade), grade.passed)}`,
649
+ text: `${s.answerSubmitted} ${s.scoreAnnouncement(chunkYM64MS4G_cjs.percentOfGrade(grade), grade.passed)}`,
625
650
  feedback: grade.feedback
626
651
  };
627
652
  }
@@ -654,7 +679,7 @@ function ReadAloud({
654
679
  data.media !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "lk-ra-model", children: [
655
680
  /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "lk-ra-model-label", children: s.readAloudModelRecording }),
656
681
  /* @__PURE__ */ jsxRuntime.jsx(
657
- chunkB2XQLU2E_cjs.ActivityMedia,
682
+ chunkUMDWVMB5_cjs.ActivityMedia,
658
683
  {
659
684
  media: data.media,
660
685
  renderMode,
@@ -664,14 +689,14 @@ function ReadAloud({
664
689
  ...strings !== void 0 ? { strings } : {},
665
690
  ...onInteraction !== void 0 ? { onInteraction } : {},
666
691
  ...locale !== void 0 ? { locale } : {},
667
- ...disabled !== void 0 ? { disabled } : {}
692
+ ...disabled === true || isCapturing ? { disabled: true } : {}
668
693
  }
669
694
  )
670
695
  ] }) : null,
671
696
  slowMedia !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "lk-ra-model", "data-slow": "true", children: [
672
697
  /* @__PURE__ */ jsxRuntime.jsx("legend", { className: "lk-ra-model-label", children: s.readAloudSlowRecording }),
673
698
  /* @__PURE__ */ jsxRuntime.jsx(
674
- chunkB2XQLU2E_cjs.ActivityMedia,
699
+ chunkUMDWVMB5_cjs.ActivityMedia,
675
700
  {
676
701
  media: slowMedia,
677
702
  renderMode,
@@ -679,7 +704,7 @@ function ReadAloud({
679
704
  ...mediaStrings !== void 0 ? { mediaStrings } : {},
680
705
  ...strings !== void 0 ? { strings } : {},
681
706
  ...locale !== void 0 ? { locale } : {},
682
- ...disabled !== void 0 ? { disabled } : {}
707
+ ...disabled === true || isCapturing ? { disabled: true } : {}
683
708
  }
684
709
  )
685
710
  ] }) : null
@@ -722,41 +747,40 @@ function ReadAloud({
722
747
  // whole second, so as a live region it announced ten times in a
723
748
  // ten-second take — into the microphone. What a screen-reader
724
749
  // learner needs instead is said once each, below.
725
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-progress", "aria-hidden": "true", children: s.readAloudRecordingProgress(Math.floor(recorder.elapsedMs / 1e3), maxSeconds) })
750
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-progress", "aria-hidden": "true", children: s.readAloudRecordingProgress(
751
+ secondsWithin(recorder.elapsedMs, maxSeconds, "down"),
752
+ maxSeconds
753
+ ) })
726
754
  ) : null,
727
755
  takesLeft !== void 0 && maxTakes !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-takes", children: s.readAloudTakesRemaining(takesLeft, maxTakes) }) : null
728
756
  ]
729
757
  }
730
758
  ),
731
- !isReview && takeUrl !== null ? (
759
+ takeAudio === null ? null : playback.refused ? (
760
+ // In the player's place, not beside it: a player the page will not
761
+ // load looks exactly like one that works until it is pressed, and then
762
+ // does nothing. A note rather than an alert — the learner can still
763
+ // submit, and nothing here asks them to act.
764
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-take-unavailable", role: "note", children: s.readAloudPlaybackUnavailable })
765
+ ) : (
732
766
  // biome-ignore lint/a11y/useMediaCaption: the learner's own take has no caption track to offer; its accessible name says whose recording it is
733
767
  /* @__PURE__ */ jsxRuntime.jsx(
734
768
  "audio",
735
769
  {
736
770
  className: "lk-ra-take",
737
771
  controls: true,
738
- src: takeUrl,
772
+ src: takeAudio,
739
773
  "aria-label": s.readAloudYourRecording,
740
- "data-take": recorder.takesUsed
741
- }
742
- )
743
- ) : null,
744
- isReview && playbackUrl !== null ? (
745
- // biome-ignore lint/a11y/useMediaCaption: the learner's own take has no caption track to offer; its accessible name says whose recording it is
746
- /* @__PURE__ */ jsxRuntime.jsx(
747
- "audio",
748
- {
749
- className: "lk-ra-take",
750
- controls: true,
751
- src: playbackUrl,
752
- "aria-label": s.readAloudYourRecording
774
+ onError: (event) => playback.refuse(event.currentTarget),
775
+ ...isReview ? {} : { "data-take": recorder.takesUsed }
753
776
  }
754
777
  )
755
- ) : null,
778
+ ),
756
779
  isReview || submitted ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "lk-ra-actions", children: [
757
780
  /* @__PURE__ */ jsxRuntime.jsx(
758
781
  "button",
759
782
  {
783
+ ref: submitRef,
760
784
  type: "submit",
761
785
  className: "lk-ra-submit",
762
786
  disabled: disabled === true,
@@ -791,6 +815,7 @@ function ReadAloud({
791
815
  type: "button",
792
816
  className: "lk-ra-retry",
793
817
  onClick: () => {
818
+ submitRef.current?.focus();
794
819
  if (phase.kind === "upload-failed") {
795
820
  void submitTake(recorder.take);
796
821
  } else if (phase.kind === "assess-failed" && uploaded !== null) {
@@ -804,7 +829,7 @@ function ReadAloud({
804
829
  busy ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-pending", role: "status", "aria-busy": "true", children: phase.kind === "uploading" ? s.readAloudUploading : s.readAloudAssessing }) : null,
805
830
  alertText !== null ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "lk-ra-alert", role: "alert", children: alertText }, errorNonce) : null,
806
831
  feedbackAssessment !== null ? /* @__PURE__ */ jsxRuntime.jsx(
807
- chunkF4TBCRGI_cjs.PronunciationFeedback,
832
+ chunkYM64MS4G_cjs.PronunciationFeedback,
808
833
  {
809
834
  data: { referenceText: data.referenceText, locale: data.locale },
810
835
  assessment: feedbackAssessment,
@@ -818,14 +843,14 @@ function ReadAloud({
818
843
  ) : null,
819
844
  storedMarks !== null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "lk-ra-marks", children: [
820
845
  /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "lk-ra-words", "aria-label": s.pronunciationWordsLabel, dir: contentDir, children: storedMarks.map((entry, index) => {
821
- const sentence = chunkF4TBCRGI_cjs.markSentence(entry, s);
846
+ const sentence = chunkYM64MS4G_cjs.markSentence(entry, s);
822
847
  return /* @__PURE__ */ jsxRuntime.jsxs(
823
848
  "li",
824
849
  {
825
850
  className: "lk-ra-word",
826
851
  "data-state": entry.state,
827
852
  children: [
828
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "lk-visually-hidden", style: chunkF4TBCRGI_cjs.VISUALLY_HIDDEN, children: sentence }),
853
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "lk-visually-hidden", style: chunkYM64MS4G_cjs.VISUALLY_HIDDEN, children: sentence }),
829
854
  /* @__PURE__ */ jsxRuntime.jsx(
830
855
  "span",
831
856
  {
@@ -849,15 +874,15 @@ function ReadAloud({
849
874
  // but a live region is the only thing that TELLS a screen-reader
850
875
  // learner a grade arrived, since nothing takes focus. Clipped rather
851
876
  // than `display: none`, which would stop it being announced at all.
852
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "lk-visually-hidden", style: chunkF4TBCRGI_cjs.VISUALLY_HIDDEN, children: /* @__PURE__ */ jsxRuntime.jsx(AnnouncementText, { announcement }) })
877
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "lk-visually-hidden", style: chunkYM64MS4G_cjs.VISUALLY_HIDDEN, children: /* @__PURE__ */ jsxRuntime.jsx(AnnouncementText, { announcement }) })
853
878
  ) : /* @__PURE__ */ jsxRuntime.jsx(AnnouncementText, { announcement }) })
854
879
  ]
855
880
  }
856
881
  );
857
882
  }
858
883
  function ReadAloud2(props) {
859
- const strings = chunkLB3FEV7Z_cjs.useLkStrings(props.strings);
860
- return /* @__PURE__ */ jsxRuntime.jsx(chunkUSBANZ7K_cjs.ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsxRuntime.jsx(ReadAloud, { ...props }) });
884
+ const strings = chunkVSFHJ7FB_cjs.useLkStrings(props.strings);
885
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkDPEY7DSE_cjs.ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsxRuntime.jsx(ReadAloud, { ...props }) });
861
886
  }
862
887
 
863
888
  exports.ReadAloud = ReadAloud2;
@@ -865,5 +890,5 @@ exports.SequenceSlotContext = SequenceSlotContext;
865
890
  exports.mintTake = mintTake;
866
891
  exports.stopCaptureGroup = stopCaptureGroup;
867
892
  exports.takeOf = takeOf;
868
- //# sourceMappingURL=chunk-36FTYJWJ.cjs.map
869
- //# sourceMappingURL=chunk-36FTYJWJ.cjs.map
893
+ //# sourceMappingURL=chunk-KIO6QXGT.cjs.map
894
+ //# sourceMappingURL=chunk-KIO6QXGT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/shared/capture-registry.ts","../src/components/shared/sequence-slot.ts","../src/components/ReadAloud/recording-bounds.ts","../src/components/ReadAloud/ReadAloud.tsx","../src/components/ReadAloud/index.tsx"],"names":["createContext","READ_ALOUD_MAX_SECONDS","takes","READ_ALOUD_MAX_TAKES","jsxs","Fragment","jsx","percentOfGrade","useLkStrings","useContext","useMemo","isDevelopment","assertRedacted","validateActivity","ActivitySchemaError","useSpeechRecorder","useActivityState","useState","useId","useRef","useEffect","take","useCallback","usePlaybackRefusal","readAssessResult","xAPIBuilder","ANONYMOUS_ACTOR","objectIdFor","xapiDefinitionFor","fractionOfGrade","localeDirectionOf","readOutcome","readEvidence","ActivityMedia","PronunciationFeedback","markSentence","VISUALLY_HIDDEN","state","FeedbackRegion","ReadAloud","ActivityErrorBoundary"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAM,MAAA,uBAAa,GAAA,EAA6B;AAGzC,SAAS,gBAAA,CAAiB,OAAe,IAAA,EAA8B;AAC5E,EAAA,IAAI,OAAA,GAAU,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA;AAC9B,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA,OAAA,uBAAc,GAAA,EAAI;AAClB,IAAA,MAAA,CAAO,GAAA,CAAI,OAAO,OAAO,CAAA;AAAA,EAC3B;AACA,EAAA,OAAA,CAAQ,IAAI,IAAI,CAAA;AAChB,EAAA,OAAO,MAAM;AACX,IAAA,MAAM,OAAA,GAAU,MAAA,CAAO,GAAA,CAAI,KAAK,CAAA;AAChC,IAAA,IAAI,YAAY,MAAA,EAAW;AACzB,MAAA;AAAA,IACF;AACA,IAAA,OAAA,CAAQ,OAAO,IAAI,CAAA;AACnB,IAAA,IAAI,OAAA,CAAQ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BAAA9B,cAAA,CAAC,gBAAA,EAAA,EAAiB,YAAA,EAA4B,CAAA,EAChD;AAAA,4BAEAA,cAAA,CAAC,gBAAA,EAAA,EAAiB,YAAA,EAA4B,CAAA,EAElD;AAAA;AAAA;AAAA,GACF;AAEJ;AC38CO,SAASiC,WAAU,KAAA,EAAuB;AAC/C,EAAA,MAAM,OAAA,GAAU/B,8BAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC1C,EAAA,uBACEF,cAAAA,CAACkC,uCAAA,EAAA,EAAsB,aAAA,EAAe,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,OAAA,EACvD,QAAA,kBAAAlC,cAAAA,CAAC,SAAA,EAAA,EAAe,GAAG,OAAO,CAAA,EAC5B,CAAA;AAEJ","file":"chunk-KIO6QXGT.cjs","sourcesContent":["'use client';\n\n/**\n * Microphone captures that must stop when the region holding them goes away,\n * keyed by group name.\n *\n * Module-level for the reason `playback-group.ts` is: the thing that knows a\n * pane was hidden — the sequence — is not the thing holding the microphone,\n * and a context would have to be threaded through every activity component to\n * reach one. The caller mints the group name per region; a sequence uses the\n * slot's, so hiding one slot stops that slot's capture and no other's. The name\n * reaches a recorder only through `SequenceSlotContext`, never as a prop, so no\n * consumer string can join another region's group.\n *\n * This **supplements** a recorder's own teardown and never replaces it. The\n * sequence's pane effect runs only on a `hidden` transition, not on unmount,\n * and neither a preview nor a standalone render has panes at all — so a\n * component that records still releases the microphone from its own cleanup,\n * and this registry only covers the case where the component is left mounted\n * and merely hidden.\n *\n * No `useCaptureGroup` hook, unlike playback: that one re-registers after every\n * commit because the element behind a ref can be replaced while the ref object\n * is not, whereas a recorder's `stop` keeps one identity for the life of the\n * hook and a plain effect registers it exactly once.\n */\nconst groups = new Map<string, Set<() => void>>();\n\n/** Adds a capture's stop to a group; returns the matching removal. */\nexport function joinCaptureGroup(group: string, stop: () => void): () => void {\n let members = groups.get(group);\n if (members === undefined) {\n members = new Set();\n groups.set(group, members);\n }\n members.add(stop);\n return () => {\n const current = groups.get(group);\n if (current === undefined) {\n return;\n }\n current.delete(stop);\n if (current.size === 0) {\n groups.delete(group);\n }\n };\n}\n\n/**\n * Stops every capture in the group.\n *\n * The members are copied before they are called. Each `stop` is expected to\n * run its own removal, and a component that answers one by starting again\n * would otherwise be stopped by the sweep that its own stop provoked.\n */\nexport function stopCaptureGroup(group: string): void {\n const members = groups.get(group);\n if (members === undefined) {\n return;\n }\n for (const stop of [...members]) {\n stop();\n }\n}\n","'use client';\n\nimport { createContext } from 'react';\n\n/**\n * How far a take that was handed in has got, as a pager deciding whether its\n * set is finished needs to know it.\n *\n * - `in-flight` — being stored or being judged. The set waits for it.\n * - `retryable` — it failed, and the learner is being offered another try at\n * the SAME take. The set waits for it while the learner is on that question.\n * - `settled` — nothing more will come of it: a grade, a take with no grade, a\n * failure nobody can retry, or a take the learner walked away from.\n */\nexport type TakeState = 'in-flight' | 'retryable' | 'settled';\n\n/**\n * What a pager hands the one slot it renders, and only through\n * {@link SequenceSlotContext} — never as a prop, so none of it can appear on a\n * public component's signature. A consumer string in any of it could stop\n * another component's microphone or finish another paper's set.\n */\nexport interface SequenceSlotChannel {\n /**\n * The capture-registry group whose captures stop when the slot's pane is\n * hidden. Minted per pager and per slot, so no two pagers share one.\n */\n readonly captureGroup: string;\n /**\n * Reports the state of the take numbered `take`, a number from\n * {@link mintTake}. A take numbered below the slot's latest is a take the\n * learner has since replaced, and the pager ignores it.\n */\n takeState(take: number, state: TakeState): void;\n}\n\n/** `null` outside a pager: a standalone component belongs to no slot. */\nexport const SequenceSlotContext = createContext<SequenceSlotChannel | null>(null);\n\n/**\n * The last take number handed out. Module-level and never reset, so a number\n * is unique for the life of the page: across mounts, across papers, and across\n * two pagers side by side. A result can therefore only ever match the take that\n * produced it, whatever slot and activity ids a later paper reuses — ids a host\n * chooses, and can repeat, never decide it.\n */\nlet lastTake = 0;\n\n/** A take number no other take on this page has had, or will have. */\nexport function mintTake(): number {\n lastTake += 1;\n return lastTake;\n}\n\n/**\n * The take each reported value belongs to. A `WeakMap` rather than a field, so\n * a response or a result a host receives carries no extra key it would persist\n * or compare, and the number never outlives the object.\n */\nconst takes = new WeakMap<object, number>();\n\n/** Marks `value` as produced by take `take`, and returns it. */\nexport function stampTake<T extends object>(value: T, take: number): T {\n takes.set(value, take);\n return value;\n}\n\n/** The take `value` was produced by, or `undefined` when nothing stamped it. */\nexport function takeOf(value: unknown): number | undefined {\n return typeof value === 'object' && value !== null ? takes.get(value) : undefined;\n}\n","'use client';\n\nimport { READ_ALOUD_MAX_SECONDS, READ_ALOUD_MAX_TAKES } from '@intellectif/lk-core';\n\n/** The bounds a take is captured under, as the recorder and the sentences use them. */\nexport interface RecordingBounds {\n /** Above 0, and at most `READ_ALOUD_MAX_SECONDS`. */\n maxSeconds: number;\n /** At least 0 and below `maxSeconds`, or `undefined` for no minimum. */\n minSeconds: number | undefined;\n /** A whole number from 1 to `READ_ALOUD_MAX_TAKES`, or `undefined` for no limit. */\n maxTakes: number | undefined;\n}\n\nconst isNumber = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value);\n\n/**\n * The one reading of an item's `recording`: every bound the component captures\n * under, every sentence that names one, and the key that decides whether a new\n * `data` is a new reading all come from here, so no two of them can read the\n * same field differently.\n *\n * `practice` renders unvalidated content in production, so what comes in may\n * be anything a server stored. What comes out is always a set of bounds the\n * schema accepts, and bounds the schema accepts come out unchanged. Three\n * rules decide the rest, and each errs toward a take the learner can finish:\n *\n * - **A present bound that cannot be read is the schema's own ceiling**, never\n * no bound at all: a `maxSeconds` of `\"20\"` or `NaN` records up to\n * `READ_ALOUD_MAX_SECONDS`, and a `maxTakes` of `\"1\"` allows\n * `READ_ALOUD_MAX_TAKES`. Unreadable data can make the recorder stricter\n * than the ceiling, never looser: `maxTakes: \"1\"` used to mean unlimited\n * takes. `null` is an absent optional, as it is everywhere a host sends JSON.\n * - **A count is a whole number in range**: `0` and `1.5` read as `1`, `999`\n * as the ceiling.\n * - **A minimum the maximum cannot reach is no minimum.** A `minSeconds` of 30\n * under a `maxSeconds` of 20 stopped every take at 20 and then refused it as\n * too short, so the item could never be answered. The schema refuses that\n * pair; a reading that honoured it would leave the learner a dead end.\n */\nexport function readRecordingBounds(recording: unknown): RecordingBounds {\n const bounds =\n typeof recording === 'object' && recording !== null\n ? (recording as Record<string, unknown>)\n : {};\n const maxSeconds =\n isNumber(bounds.maxSeconds) && bounds.maxSeconds > 0\n ? Math.min(bounds.maxSeconds, READ_ALOUD_MAX_SECONDS)\n : READ_ALOUD_MAX_SECONDS;\n const minSeconds =\n isNumber(bounds.minSeconds) && bounds.minSeconds >= 0 && bounds.minSeconds < maxSeconds\n ? bounds.minSeconds\n : undefined;\n const takes = bounds.maxTakes;\n const maxTakes =\n takes === undefined || takes === null\n ? undefined\n : isNumber(takes)\n ? Math.min(Math.max(1, Math.floor(takes)), READ_ALOUD_MAX_TAKES)\n : READ_ALOUD_MAX_TAKES;\n return { maxSeconds, minSeconds, maxTakes };\n}\n\n/**\n * A length of audio as the whole seconds a sentence says beside `maxSeconds`,\n * never more than it. A bound may be fractional — the schema allows 2.5 — and\n * rounding a take that ran to it said \"3 of 2.5 seconds\". Rounded to the\n * nearest second for a finished take, and down for the counter of one still\n * running, which should not reach its bound before the take does.\n */\nexport function secondsWithin(\n milliseconds: number,\n maxSeconds: number,\n rounding: 'nearest' | 'down',\n): number {\n const seconds = milliseconds / 1000;\n const whole = rounding === 'nearest' ? Math.round(seconds) : Math.floor(seconds);\n return Math.min(Math.max(0, whole), maxSeconds);\n}\n","'use client';\n\nimport {\n type ActivityMedia as ActivityMediaData,\n ActivitySchemaError,\n assertRedacted,\n type GradeRecord,\n type InteractionKind,\n type LearnerResponse,\n type MediaPlaybackPolicy,\n type ReadAloudData,\n type ReadAloudLearnerResponse,\n type ReadAloudWordAlignment,\n type RecordingRef,\n type ScoringDetail,\n type SpeechAssessment,\n validateActivity,\n xAPIBuilder,\n xapiDefinitionFor,\n} from '@intellectif/lk-core';\nimport {\n type CSSProperties,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useActivityState } from '../../hooks/useActivityState.js';\nimport type { RecordedTake, SpeechRecorderStatus } from '../../hooks/useSpeechRecorder.js';\nimport { useSpeechRecorder } from '../../hooks/useSpeechRecorder.js';\nimport { localeDirectionOf } from '../../i18n/direction.js';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStrings } from '../../i18n/strings.js';\nimport { ANONYMOUS_ACTOR, isDevelopment, objectIdFor } from '../_internal.js';\nimport { PronunciationFeedback } from '../PronunciationFeedback/index.js';\nimport { markSentence, VISUALLY_HIDDEN } from '../PronunciationFeedback/PronunciationFeedback.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport { joinCaptureGroup } from '../shared/capture-registry.js';\nimport { FeedbackRegion } from '../shared/FeedbackRegion.js';\nimport { usePlaybackRefusal } from '../shared/playback-refusal.js';\nimport {\n fractionOfGrade,\n type OutcomeReading,\n percentOfGrade,\n type ReadGrade,\n readAssessResult,\n readEvidence,\n readOutcome,\n} from '../shared/read-grade.js';\nimport {\n mintTake,\n SequenceSlotContext,\n stampTake,\n type TakeState,\n} from '../shared/sequence-slot.js';\nimport type { ActivityProps, Renderable } from '../types.js';\nimport { readRecordingBounds, secondsWithin } from './recording-bounds.js';\n\n/**\n * Names playback groups for the model recordings. Per mount and never derived\n * from `useId`: two separately hydrated roots derive the same id for the same\n * tree position, and their recordings would pause each other. The name never\n * reaches the DOM.\n */\nlet modelsGroupCount = 0;\n\n/** A title with something in it a screen reader can say. */\nconst VISIBLE_TEXT_RE = /[^\\p{White_Space}\\p{Cc}\\p{Cf}\\p{Default_Ignorable_Code_Point}]/u;\n\n/** A stored mark's id, as `gradeReadAloud` numbers the reference words. */\nconst MARK_ID_RE = /^w\\d+$/;\n\n/** The states a mark rebuilt from stored details can carry: insertions are not stored. */\nconst STORED_STATES: readonly ReadAloudWordAlignment['state'][] = [\n 'correct',\n 'mispronounced',\n 'omitted',\n];\n\n/** The level meter's resolution, in steps the skin can select on. */\nconst LEVEL_STEPS = 10;\n\n/**\n * What an application's assessor came back with.\n *\n * `code` is a plain `string` and not `SpeechUnscorableCode`: an application's\n * own assessor may refuse a take for a reason the SDK has no name for, and a\n * narrower type would make it unreportable. This component classifies the two\n * codes that mean \"nothing was heard\" and treats every other one the same way.\n */\nexport type ReadAloudAssessResult =\n | { status: 'graded'; assessment: SpeechAssessment; grade: GradeRecord }\n | { status: 'unscorable'; code: string; assessment?: SpeechAssessment }\n | { status: 'failed'; retryable: boolean };\n\n/**\n * How a take reaches the application, and how a judgement comes back.\n *\n * Named `recordingBinding` rather than `recording` because both\n * `ReadAloudData.recording` (the bounds) and `ReadAloudLearnerResponse.recording`\n * (the stored take) already exist: the plain name would read as one of those.\n */\nexport interface RecordingBinding {\n /**\n * Puts the take in your storage and returns its key. **Required** outside\n * `review`: without it a learner can speak into a control that submits\n * nothing. Settle it — a promise that never does leaves the submit pending\n * for ever.\n */\n upload(take: RecordedTake): Promise<RecordingRef>;\n /**\n * Judges the stored take. `practice` only — an exam never assesses on the\n * client. Optional: a binding without it records, uploads and submits, and\n * the feedback is replaced by a notice.\n */\n assess?(ref: RecordingRef): Promise<ReadAloudAssessResult>;\n /** A playable link to a stored take. `review` only. */\n playbackUrl?(ref: RecordingRef): Promise<string>;\n}\n\nexport interface ReadAloudProps extends ActivityProps<ReadAloudData> {\n /** How a take is stored and judged. See {@link RecordingBinding}. */\n recordingBinding?: RecordingBinding;\n /**\n * The evidence behind a stored grade, for `review`. Without it a graded\n * outcome still shows its marks, rebuilt from `outcome.grade.details`; with\n * neither, the score is shown and no marks are.\n */\n assessment?: SpeechAssessment;\n /**\n * Confidence above which a break note is shown, 0..1, forwarded to\n * {@link PronunciationFeedback}. No default — see its own prop.\n */\n breakThreshold?: number;\n /** The same, for the monotone note. */\n monotoneThreshold?: number;\n /**\n * The URL of a self-hosted copy of `CAPTURE_PROCESSOR_SOURCE`, handed to the\n * recorder, for a Content-Security-Policy whose `script-src` does not allow\n * `blob:`. Without it the capture module is loaded from a `blob:` URL, and a\n * policy that refuses one sends every take through the deprecated\n * main-thread `ScriptProcessorNode` — a take that still records, so nothing\n * says so. See `useSpeechRecorder`'s option of the same name.\n */\n workletUrl?: string;\n /**\n * Never called. A read-aloud answer is a key in your storage, and there is\n * none until the take has been uploaded — so there is no intermediate\n * response to report, and reporting the take itself would offer a host a\n * recording it has nowhere to put. `onSubmit` carries the response, once.\n */\n onChange?: (response: LearnerResponse) => void;\n}\n\n/** What the live region says: the SDK's own sentence, then any grader feedback. */\ninterface Announcement {\n text: string;\n feedback: string | null;\n}\n\n/**\n * How far the submitted take has got. `idle` also means \"nothing submitted yet\".\n *\n * Every other phase names its `take`, the number `mintTake` gave the submit\n * that reached it: a phase describes one take, and a pager told about it must\n * be able to tell that take from the one before it.\n */\ntype SubmitPhase =\n | { kind: 'idle' }\n | { kind: 'uploading'; take: number }\n | { kind: 'upload-failed'; take: number }\n | { kind: 'assessing'; take: number }\n | { kind: 'submitted'; take: number }\n | { kind: 'unassessed'; take: number }\n /**\n * The assessor's judgement, as `readAssessResult` read it: `grade` is `null`\n * when what came back cannot be shown as a grade, and `assessment` is `null`\n * when there is no evidence to mark words from.\n */\n | {\n kind: 'graded';\n take: number;\n assessment: SpeechAssessment | null;\n grade: ReadGrade | null;\n }\n | { kind: 'unscorable'; take: number; code: string | undefined }\n | { kind: 'assess-failed'; take: number; retryable: boolean };\n\n/**\n * Whether the screen offers \"Try again\" for the take this phase describes —\n * the one answer to that question, read by the button that offers it and by\n * the take state a pager is told, so the two cannot disagree. A retry re-sends\n * the SAME take: a take that failed to upload is sent again, and a stored take\n * whose assessment failed is judged again without being uploaded twice.\n */\nfunction offersRetry(phase: SubmitPhase, uploaded: RecordingRef | null): boolean {\n return (\n phase.kind === 'upload-failed' ||\n (phase.kind === 'assess-failed' && phase.retryable && uploaded !== null)\n );\n}\n\n/**\n * The state of the phase's take, as a pager deciding whether its set is\n * finished reads it. Derived from the phase alone, so no path through a submit\n * can leave a pager waiting on a take this component has finished with: every\n * path ends in a phase.\n */\nfunction takeStateOf(phase: SubmitPhase, uploaded: RecordingRef | null): TakeState {\n if (phase.kind === 'uploading' || phase.kind === 'assessing') {\n return 'in-flight';\n }\n return offersRetry(phase, uploaded) ? 'retryable' : 'settled';\n}\n\n/**\n * Whether the recorder is capturing, or about to: the one answer to \"is a take\n * being recorded\", read by everything that must hold still for one. A\n * permission prompt counts — a prompt answered after the pane went away would\n * otherwise open a microphone nobody is in front of, and a model recording\n * played while the prompt is up would be charged a play and then silenced.\n */\nfunction capturing(status: SpeechRecorderStatus): boolean {\n return status === 'recording' || status === 'requesting-permission';\n}\n\n/**\n * What a take is a take OF: the item, the words, their language and the bounds\n * the take is captured under. A change to any of these is a different reading,\n * and a take of the old one answers nothing.\n *\n * Deliberately NOT the identity of `data`. `redact()` returns a new object on\n * every call, and `activities={raw.map(redact)}` is a documented way to pass a\n * paper, so a host that rebuilds its items on every render is ordinary — and a\n * reset keyed on identity silently threw away every grade still in flight and\n * refunded the take budget on each of those renders, so a `maxTakes: 1` exam\n * accepted a second take. The title, the instructions and the model recordings\n * are presentation; editing them leaves the take a take of the same reading.\n *\n * The bounds are the CLAMPED ones, which are what the recorder is given. Read\n * field by field into strings, so no value unvalidated data carries can make\n * the key throw.\n */\nfunction readingKeyOf(\n data: Renderable<ReadAloudData>,\n bounds: { maxSeconds: number; minSeconds: number | undefined; maxTakes: number | undefined },\n): string {\n const text = (value: unknown): string | null => (typeof value === 'string' ? value : null);\n return JSON.stringify([\n text(data.id),\n text(data.referenceText),\n text(data.locale),\n String(bounds.maxSeconds),\n String(bounds.minSeconds),\n String(bounds.maxTakes),\n ]);\n}\n\n/**\n * The slower model recording as an `ActivityMedia`: it follows the model\n * recording's playback policy minus `maxPlays` (`controls`, `seek`, `rate`,\n * the native hints), so a locked scrubber or a fixed speed binds both files —\n * and it never carries a budget of its own, so `<ActivityMedia>` never demands\n * a binding for it. `undefined` when there is no slow recording.\n */\nfunction slowMediaFor(\n data: Renderable<ReadAloudData>,\n label: string,\n): ActivityMediaData | undefined {\n const slow = data.slowMedia;\n if (slow === undefined) {\n return undefined;\n }\n const policy: MediaPlaybackPolicy = data.media?.playback ?? {};\n const { maxPlays: _budget, ...inherited } = policy;\n const hasPolicy = Object.values(inherited).some((value) => value !== undefined);\n return {\n type: 'audio',\n url: slow.url,\n alt: slow.alt ?? label,\n ...(hasPolicy ? { playback: inherited } : {}),\n };\n}\n\n/**\n * Word marks rebuilt from stored scoring details — a server-recorded mark shown\n * after the fact, with no assessment on the client. Inserted words are not in\n * the details (`gradeReadAloud` stores one mark per REFERENCE word, and a word\n * the learner added is not one the item asked for), so none appear.\n *\n * The details are a read grade's, so every entry is well-formed; what is left\n * to decide here is whether they are word marks at all, rather than a rubric's\n * own breakdown.\n */\nfunction marksFromDetails(details: readonly ScoringDetail[]): ReadAloudWordAlignment[] | null {\n if (details.length === 0 || !details.every((detail) => MARK_ID_RE.test(detail.itemId))) {\n return null;\n }\n return details.map((detail) => {\n const heard = Array.isArray(detail.learnerResponse)\n ? detail.learnerResponse.join(' ')\n : detail.learnerResponse;\n const reference = Array.isArray(detail.correctResponse)\n ? detail.correctResponse.join(' ')\n : detail.correctResponse;\n const correct = detail.outcome !== undefined ? detail.outcome === 'correct' : detail.correct;\n const state: ReadAloudWordAlignment['state'] = correct\n ? 'correct'\n : detail.outcome === 'incorrect-omission'\n ? 'omitted'\n : 'mispronounced';\n return {\n itemId: detail.itemId,\n reference,\n heard,\n state,\n // `ScoringDetail.score` is the word's accuracy divided by 100; the marks\n // carry it back in the units the assessment used.\n ...(typeof detail.score === 'number' ? { accuracy: detail.score * 100 } : {}),\n };\n });\n}\n\n/** The stored take a learner response points at, or `null` for a blank or another type. */\nfunction recordingOf(response: LearnerResponse | undefined): RecordingRef | null {\n return response !== undefined && response.type === 'read-aloud' ? response.recording : null;\n}\n\n/** The response this component emits; `takes` is written only when one was made. */\nfunction responseOf(recording: RecordingRef | null, takes: number): ReadAloudLearnerResponse {\n return { type: 'read-aloud', recording, ...(takes > 0 ? { takes } : {}) };\n}\n\n/**\n * Which learner message an unscorable code earns. The two codes that mean\n * \"nothing was heard\" send the learner back to a quieter room; every other one,\n * the SDK's and an application's own alike — and no code at all — says only\n * that this take could not be assessed. **The code itself is never shown** — it\n * is a developer's label.\n */\nfunction unscorableMessage(code: string | undefined, s: LkStrings): string {\n return code === 'no_speech' || code === 'insufficient_voiced_time'\n ? s.readAloudNotHeard\n : s.readAloudNotAssessed;\n}\n\n/**\n * The announcement, with grader feedback in its own isolated span: its\n * direction is its own, so an English \"Well read.\" in an Arabic interface keeps\n * its full stop at its end. Its language is not guessed — feedback may be\n * written in the interface's language or the reading's.\n */\nfunction AnnouncementText({ announcement }: { announcement: Announcement | null }) {\n if (announcement === null) {\n return null;\n }\n return (\n <>\n {announcement.text}\n {announcement.feedback ? (\n <>\n {' '}\n <span dir=\"auto\">{announcement.feedback}</span>\n </>\n ) : null}\n </>\n );\n}\n\n/**\n * The server's outcome in `review`, as `readOutcome` read it. Nothing on this\n * path scores, infers or defaults a grade.\n *\n * `scoreShown` says whether the grade is already on screen — it is, whenever\n * `<PronunciationFeedback>` was given the same grade — so the sentence is not\n * rendered twice. The wrapper and its attributes are rendered either way,\n * because they are what a stylesheet and a diagnostic read.\n */\nfunction OutcomeSummary({\n reading,\n s,\n scoreShown,\n}: {\n reading: OutcomeReading;\n s: LkStrings;\n scoreShown: boolean;\n}) {\n switch (reading.kind) {\n case 'graded':\n return (\n <div\n className=\"lk-ra-outcome\"\n data-status={reading.status}\n data-passed={String(reading.grade.passed)}\n >\n {scoreShown ? null : (\n <>\n <p className=\"lk-ra-grade\">\n {s.scoreAnnouncement(percentOfGrade(reading.grade), reading.grade.passed)}\n </p>\n {reading.grade.feedback ? (\n <p className=\"lk-ra-grade-feedback\" dir=\"auto\">\n {reading.grade.feedback}\n </p>\n ) : null}\n </>\n )}\n </div>\n );\n case 'deferred':\n return (\n <div className=\"lk-ra-outcome\" data-status=\"deferred\">\n <p className=\"lk-ra-grade\">{s.awaitingGrade}</p>\n </div>\n );\n case 'unscorable':\n // An unscorable code is a developer-facing label: it goes on the element\n // for diagnostics and routing, and never in front of the learner as text.\n return (\n <div\n className=\"lk-ra-outcome\"\n data-status=\"unscorable\"\n {...(reading.code !== undefined ? { 'data-code': reading.code } : {})}\n >\n <p className=\"lk-ra-grade\">{s.couldNotBeGraded}</p>\n </div>\n );\n default:\n // A stored outcome that claims a grade and carries none that can be read\n // gets the deferred vocabulary's own sentence rather than \"Score NaN%.\":\n // there is a grade, and this screen cannot say what it was. No\n // `data-passed`, because there is no verdict to style.\n return (\n <div\n className=\"lk-ra-outcome\"\n {...(reading.status !== undefined ? { 'data-status': reading.status } : {})}\n >\n <p className=\"lk-ra-grade\">{s.couldNotBeGraded}</p>\n </div>\n );\n }\n}\n\n/**\n * Reads a text aloud and hands the recording to the application.\n *\n * The SDK records; it never judges. A take is captured as mono 16-bit PCM WAV\n * at 16 kHz — the one format `inspectWav` measures directly — handed to\n * `recordingBinding.upload`, and reported through `onSubmit`. Whether anything\n * assesses it, and where, is the application's: in `practice` an optional\n * `assess` may come back with a grade, and in `exam` nothing is ever assessed\n * on the client.\n *\n * **`recordingBinding.upload` is required outside `review`** and its absence\n * throws at render, in production too: a learner must never speak into a\n * control that stores nothing. `assess` is not required — a binding without it\n * records, uploads and submits, and shows a notice in place of the feedback.\n *\n * **A grade that comes back is read, not trusted** — whether `assess` returned\n * it or `outcome` carries it. A score that is not a number between 0 and its\n * maximum, or a `passed` that is not a boolean, is shown as could-not-be-graded\n * and never reaches `onComplete` or a statement; `onComplete` fires exactly when\n * a score is on screen, with that score.\n *\n * **Under a strict Content-Security-Policy** the take is played back from a\n * `blob:` URL, so `media-src` must allow `blob:` — refused, the player and the\n * per-word buttons give way to a note saying the take cannot be played here —\n * and the capture module loads from one too, so either `script-src` allows\n * `blob:` or `workletUrl` names a self-hosted copy of `CAPTURE_PROCESSOR_SOURCE`.\n *\n * ```tsx\n * <ReadAloud\n * data={item}\n * recordingBinding={{ upload, assess }}\n * onSubmit={persist}\n * onComplete={record}\n * />\n * ```\n */\nexport function ReadAloud({\n data,\n onComplete,\n onSubmit,\n onInteraction,\n value,\n defaultValue,\n defaultSubmitted,\n renderMode = 'practice',\n outcome,\n mediaBudget,\n mediaStrings,\n strings,\n theme,\n locale,\n disabled,\n recordingBinding,\n assessment,\n breakThreshold,\n monotoneThreshold,\n workletUrl,\n}: ReadAloudProps) {\n const isExam = renderMode === 'exam';\n const isReview = renderMode === 'review';\n const s = useLkStrings(strings);\n // The pager slot this component sits in, if any: the capture group its pane\n // stops, and where the state of each take is reported. A context and never a\n // prop, so none of it is on this component's published signature — a\n // consumer string in a prop could stop another pager's microphone. `null`\n // for a standalone component, which then belongs to no group at all and\n // releases the microphone from its own unmount alone.\n const slot = useContext(SequenceSlotContext);\n const captureGroup = slot?.captureGroup;\n\n const devError = useMemo(() => {\n if (!isDevelopment()) {\n return null;\n }\n // No `hasKey` branch, unlike `<Dictation>`: a read-aloud item has no answer\n // key, so `redact()` produces a projection the strict redacted schema\n // describes exactly and there is no revealed variant to make room for.\n if (data.redacted === true) {\n try {\n assertRedacted(data);\n return null;\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n }\n const result = validateActivity('read-aloud', data);\n return result.success ? null : new ActivitySchemaError('read-aloud', result.errors);\n }, [data]);\n\n // The bounds a take is captured under, READ and not merely defaulted, because\n // `practice` renders unvalidated content in production: a `maxSeconds` of\n // 100000 arms a recording that never stops itself, a `maxTakes` of \"1\" meant\n // unlimited takes, and a minimum above the maximum refused every take. One\n // reader owns all of it — see `readRecordingBounds`.\n const { maxSeconds, minSeconds, maxTakes } = readRecordingBounds(data.recording);\n const readingKey = readingKeyOf(data, { maxSeconds, minSeconds, maxTakes });\n\n const recorder = useSpeechRecorder(\n useMemo(\n () => ({\n maxDurationMs: maxSeconds * 1000,\n ...(minSeconds !== undefined ? { minDurationMs: minSeconds * 1000 } : {}),\n ...(maxTakes !== undefined ? { maxTakes } : {}),\n // Forwarded, never defaulted: without it the recorder mints its own\n // `blob:` module, which is the one a strict policy refuses.\n ...(workletUrl !== undefined ? { workletUrl } : {}),\n }),\n [maxSeconds, minSeconds, maxTakes, workletUrl],\n ),\n );\n\n const { state, start, complete, getTimeSpent, reset } = useActivityState(\n defaultSubmitted === true ? 'completed' : 'idle',\n );\n const [phase, setPhase] = useState<SubmitPhase>({ kind: 'idle' });\n const [uploaded, setUploaded] = useState<RecordingRef | null>(null);\n const [takeUrl, setTakeUrl] = useState<string | null>(null);\n const [playbackUrl, setPlaybackUrl] = useState<string | null>(null);\n // Re-keys the alert so the SAME message announces again — a learner who is\n // refused the microphone twice hears it twice.\n const [errorNonce, setErrorNonce] = useState(0);\n\n const ids = useId();\n const titleId = `${ids}-title`;\n // Per mount, not per activity id: two renderings of one item on a page (a\n // review list, a preview beside a sequence) are separate players.\n const [modelsGroup] = useState(() => {\n modelsGroupCount += 1;\n return `lk-ra-models-${modelsGroupCount}`;\n });\n\n // The latest callbacks, so an effect can fire an event without depending on a\n // binding or a handler the host rebuilds on every render.\n const interactionRef = useRef(onInteraction);\n interactionRef.current = onInteraction;\n const bindingRef = useRef(recordingBinding);\n bindingRef.current = recordingBinding;\n // Guards a second submit while one is in flight: two clicks would upload the\n // same take twice and charge the application for two assessments.\n const submittingRef = useRef(false);\n // Which reading this instance is on. Everything asynchronous reads it once\n // and re-reads it after every await, so an instance that has been unmounted,\n // or handed a different reading, reports nothing for the one it has left —\n // the treatment the playback-url effect below already gives itself.\n //\n // A counter rather than the boolean `live` that effect uses, because a\n // boolean cleared on the reading reset would stay cleared and leave a\n // perfectly live component unable to submit its next take.\n const runRef = useRef(0);\n // The pager slot as of the latest render, and the last take it was told\n // about, so an unmount can tell it that take is over — a take whose result\n // this instance will now never report must not hold a set open for ever.\n const slotRef = useRef(slot);\n slotRef.current = slot;\n const reportedTakeRef = useRef<number | null>(null);\n useEffect(\n () => () => {\n runRef.current += 1;\n const take = reportedTakeRef.current;\n if (take !== null) {\n slotRef.current?.takeState(take, 'settled');\n }\n },\n [],\n );\n\n const fire = useCallback(\n (type: InteractionKind, payload: Record<string, unknown>): void => {\n interactionRef.current?.({ type, activityId: data.id, timestamp: Date.now(), payload });\n },\n [data.id],\n );\n\n // `recording-started` and `recording-stopped` are reported from the recorder's\n // own status rather than from the click handlers: a take also ends when it\n // reaches its bound, and a handler would report only the ends a learner asked\n // for.\n const lastStatusRef = useRef<SpeechRecorderStatus>(recorder.status);\n useEffect(() => {\n if (lastStatusRef.current === recorder.status) {\n return;\n }\n lastStatusRef.current = recorder.status;\n if (recorder.status === 'recording') {\n fire('recording-started', { takes: recorder.takesUsed, durationMs: 0 });\n } else if (recorder.status === 'recorded' && recorder.take !== null) {\n fire('recording-stopped', {\n takes: recorder.takesUsed,\n durationMs: recorder.take.durationMs,\n });\n }\n }, [recorder.status, recorder.take, recorder.takesUsed, fire]);\n\n useEffect(() => {\n if (recorder.error !== null) {\n setErrorNonce((nonce) => nonce + 1);\n }\n }, [recorder.error]);\n\n // The take preview. Guarded because an embedder may forbid object URLs, and a\n // preview is worth less than the take it previews.\n const take = recorder.take;\n useEffect(() => {\n if (take === null || typeof URL.createObjectURL !== 'function') {\n return;\n }\n const url = URL.createObjectURL(take.blob);\n setTakeUrl(url);\n return () => {\n URL.revokeObjectURL(url);\n setTakeUrl(null);\n };\n }, [take]);\n\n const restored = recordingOf(value ?? defaultValue);\n const restoredKey = restored?.key ?? null;\n // Keyed by the reading as well as the take: the reading reset below clears\n // the link, and a link nothing mints again would leave the stored take with\n // no player for as long as it stays on screen.\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the stored take and the reading, not by the identity of a response object a host rebuilds every render\n useEffect(() => {\n const binding = bindingRef.current;\n if (!isReview || restored === null || binding?.playbackUrl === undefined) {\n return;\n }\n let live = true;\n void Promise.resolve(binding.playbackUrl(restored)).then(\n (url) => {\n if (live) {\n setPlaybackUrl(url);\n }\n },\n () => {\n /* a link that could not be minted; the marks still render without it */\n },\n );\n return () => {\n live = false;\n };\n }, [isReview, restoredKey, readingKey]);\n\n // What the registry may do to this component, and it is narrow: release the\n // DEVICE, and only while one is actually open.\n //\n // The pager stops a hidden slot's captures on EVERY hidden transition, so a\n // join that discarded unconditionally threw away a take that was already\n // encoded — and `discard` deliberately refunds nothing, so Next then Prev\n // left the learner an activity they could no longer answer and no message\n // saying why. That contradicts the pager's own founding principle: slots stay\n // mounted precisely so nobody silently loses an answer. A capture still\n // running has nothing to lose yet; a finished take has everything.\n //\n // The status is read from a ref so this callback keeps ONE identity and the\n // effect below joins the group exactly once, as `playback-group`'s does.\n const statusRef = useRef(recorder.status);\n statusRef.current = recorder.status;\n const releaseMicrophone = useCallback(() => {\n if (capturing(statusRef.current)) {\n recorder.discard();\n }\n }, [recorder.discard]);\n\n // The registry SUPPLEMENTS the recorder's own unmount cleanup; it covers the\n // one case that cleanup cannot, a component left mounted and merely hidden.\n useEffect(() => {\n if (captureGroup === undefined) {\n return;\n }\n return joinCaptureGroup(captureGroup, releaseMicrophone);\n }, [captureGroup, releaseMicrophone]);\n\n // Identity-guarded so the mount run is a no-op: without it this fires after\n // the first paint and undoes every seed it was just given.\n const defaultSubmittedRef = useRef(defaultSubmitted);\n useEffect(() => {\n defaultSubmittedRef.current = defaultSubmitted;\n }, [defaultSubmitted]);\n // Keyed by the READING, never by the identity of `data` — see `readingKeyOf`\n // for the regression that identity caused. A host that rebuilds an\n // unchanged item keeps the take, the budget and any grade still in flight.\n const lastReadingRef = useRef(readingKey);\n useEffect(() => {\n if (lastReadingRef.current === readingKey) {\n return;\n }\n lastReadingRef.current = readingKey;\n submittingRef.current = false;\n // Anything still in flight belongs to the reading that has just left.\n runRef.current += 1;\n setPhase({ kind: 'idle' });\n setUploaded(null);\n setPlaybackUrl(null);\n // `reset`, not `discard`: the takes belong to the READING, and `discard`\n // refunds none of them on purpose. A new reading that inherited the old\n // one's spent takes renders a recorder that looks live and refuses to\n // record — reachable in `<ActivityPreview>`, whose remount key is derived\n // from the media alone, so an author who tries one take and then edits the\n // reference text can never record again without reloading the page.\n recorder.reset();\n reset(defaultSubmittedRef.current === true ? 'completed' : 'idle');\n }, [readingKey, reset, recorder.reset]);\n\n // What became of each take, told to the pager slot this sits in: the one\n // channel through which a sequence learns whether its set can be reported.\n //\n // Read from the committed PHASE, and only from it. Every way a submit can end\n // — a grade, a take with no grade, a failure, a retry, a learner recording\n // again, a reading reset — ends in a phase, so none of them can leave a set\n // waiting on a take this component is done with. And an effect runs after\n // the commit, which is after `onSubmit` and `onComplete` were called for the\n // same phase: a pager told a take has settled has already been handed\n // everything that take produced. The one state that must not wait for a\n // commit — a take on its way — is reported as the submit starts.\n const phaseTake = phase.kind === 'idle' ? null : phase.take;\n const phaseTakeState = takeStateOf(phase, uploaded);\n useEffect(() => {\n // An idle phase settles the take before it: re-recording drops a take\n // whose failure was being offered a retry, and so does a reading reset.\n const take = phaseTake ?? reportedTakeRef.current;\n if (slot === null || take === null) {\n return;\n }\n reportedTakeRef.current = take;\n slot.takeState(take, phaseTakeState);\n }, [slot, phaseTake, phaseTakeState]);\n\n // Model recordings stay silent for as long as the learner records: a\n // microphone that hears the model reading would assess the model's\n // pronunciation, not theirs.\n //\n // Pausing once, when the capture starts, is not enough — the play controls\n // are still on screen and still work throughout the take, so the hazard\n // simply moves one door along. The listener holds the guard for the whole\n // capture and is removed with it; `play` does not bubble, so it is taken in\n // the capture phase. It is what silences the browser's own control bar; a\n // budgeted model is refused before it is charged, by the `disabled` its\n // player is rendered with below.\n const modelsRef = useRef<HTMLDivElement>(null);\n const isCapturing = capturing(recorder.status);\n useEffect(() => {\n if (!isCapturing) {\n return;\n }\n const node = modelsRef.current;\n if (node === null) {\n return;\n }\n const hush = (): void => {\n for (const media of node.querySelectorAll('audio, video')) {\n const element = media as HTMLMediaElement;\n if (!element.paused) {\n element.pause();\n }\n }\n };\n hush();\n node.addEventListener('play', hush, true);\n return () => {\n node.removeEventListener('play', hush, true);\n };\n }, [isCapturing]);\n\n const slowMedia = useMemo(\n () => slowMediaFor(data, s.readAloudSlowRecording),\n [data, s.readAloudSlowRecording],\n );\n\n // The learner's own take, as every element that plays it plays it: the\n // preview before it is sent, the stored link a review mints, and the\n // per-word buttons in the feedback panel. One refusal covers all of them.\n const takeAudio = isReview ? playbackUrl : takeUrl;\n const playback = usePlaybackRefusal(takeAudio);\n // Where focus goes when a retry takes the \"Try again\" button away: the\n // submit it retries, which says it is busy for as long as the retry runs.\n const submitRef = useRef<HTMLButtonElement>(null);\n\n // All hooks are called before these throws, so hook order stays stable.\n if (devError) {\n throw devError;\n }\n // `review` needs no upload: it renders what a server already stored.\n if (!isReview && recordingBinding?.upload === undefined) {\n throw new Error(\n `ReadAloud \"${data.id}\" was rendered in renderMode \"${renderMode}\" without ` +\n '`recordingBinding.upload`. The learner could record a take that is stored ' +\n 'nowhere and submitted as nothing, which looks like a working activity the ' +\n 'whole way through. Pass a `recordingBinding` whose `upload` puts the take in ' +\n 'your storage and returns its key. `assess` is optional: without it the take is ' +\n 'still recorded, uploaded and submitted, and a notice replaces the feedback.',\n );\n }\n\n const submitted = state === 'completed';\n const inactive = disabled === true || submitted || isReview;\n const busy = phase.kind === 'uploading' || phase.kind === 'assessing';\n const takesLeft = maxTakes === undefined ? undefined : Math.max(0, maxTakes - recorder.takesUsed);\n\n /** Marks a failure so the alert announces even when the sentence repeats. */\n const raise = (next: SubmitPhase): void => {\n setErrorNonce((nonce) => nonce + 1);\n setPhase(next);\n };\n\n /**\n * Tells the pager slot, if there is one, that `take` is on its way — before\n * anything is awaited. The report a pager's set waits on must exist before\n * the first result it waits for can arrive; the take's later states follow\n * from the phase it reaches (see the effect above).\n */\n const beginTakeReport = (take: number): void => {\n reportedTakeRef.current = take;\n slot?.takeState(take, 'in-flight');\n };\n\n const runAssess = async (\n ref: RecordingRef,\n current: RecordedTake | null,\n take: number,\n ): Promise<void> => {\n const assess = bindingRef.current?.assess;\n const durationMs = current?.durationMs ?? 0;\n const takes = recorder.takesUsed;\n const run = runRef.current;\n if (assess === undefined) {\n // D5: a binding that stores but does not judge is a supported binding,\n // not a mistake — it is what an authoring preview supplies.\n setPhase({ kind: 'unassessed', take });\n return;\n }\n setPhase({ kind: 'assessing', take });\n fire('assessment-requested', { takes, durationMs });\n let answer: unknown;\n try {\n answer = await assess(ref);\n } catch {\n // Detached while the assessor was working: an instance that has been\n // unmounted, or handed a different reading, reports nothing for the one\n // it has left — not a phase, not an event, and not a grade.\n if (run !== runRef.current) {\n return;\n }\n raise({ kind: 'assess-failed', take, retryable: true });\n fire('assessment-failed', { takes, durationMs, retryable: true });\n return;\n }\n if (run !== runRef.current) {\n return;\n }\n // Read once, here, and nothing below touches `answer` again: the phase the\n // screen renders from, `onComplete` and the statement all take what the\n // reader returned, so they cannot disagree about what came back.\n const result = readAssessResult(answer);\n if (result.status === 'failed') {\n raise({ kind: 'assess-failed', take, retryable: result.retryable });\n fire('assessment-failed', { takes, durationMs, retryable: result.retryable });\n return;\n }\n if (result.status === 'unscorable') {\n // Reported as a failed assessment because that is what it is to a\n // consumer's log — a take that produced no grade — and `code` says which\n // kind. `retryable` is true because another take is offered.\n setPhase({ kind: 'unscorable', take, code: result.code });\n fire('assessment-failed', {\n takes,\n durationMs,\n retryable: true,\n ...(result.code !== undefined ? { code: result.code } : {}),\n });\n return;\n }\n const timeSpent = getTimeSpent();\n setPhase({ kind: 'graded', take, assessment: result.assessment, grade: result.grade });\n const grade = result.grade;\n if (grade === null) {\n // A judgement that carries no grade the reader can show is not an\n // `ActivityResult`: reporting one would mean inventing the score, exactly\n // as an `unscorable` result would. To a consumer's log it is what an\n // unscorable take is — an assessment that produced no grade, with another\n // take offered.\n fire('assessment-failed', { takes, durationMs, retryable: true });\n return;\n }\n\n // xAPI's `score.scaled` is a fraction in [-1, 1], and the SDK's builder\n // writes `ScoringResult.score` into it verbatim, then validates — so a\n // points-based grade (82 out of 100, which `GradeRecord` allows and a\n // grader's own units readily produce) does not merely ship a wrong number:\n // the build THROWS, and the grade never reaches the screen at all. The read\n // grade's fraction is in 0..1 by construction, and `passed` is a boolean by\n // construction, so the statement validates whatever the host sent. The\n // learner's own numbers go to `onComplete` untouched.\n //\n // Stamped with its take, as the response was: a pager records a grade only\n // for the take its slot holds now, so a grade that outlived a newer take\n // can never be filed beside that newer take's response.\n onComplete?.(\n stampTake(\n {\n score: grade.score,\n maxScore: grade.maxScore,\n passed: grade.passed,\n timeSpent,\n xapiStatement: xAPIBuilder.buildAnsweredStatement({\n actor: ANONYMOUS_ACTOR,\n object: {\n id: objectIdFor(data.id),\n name: { [data.locale ?? 'en-US']: data.title },\n ...xapiDefinitionFor(data),\n },\n timeSpentMs: timeSpent,\n response: result.recognizedText ?? '',\n // `ScoringResult.details` is required where `GradeRecord.details` is\n // optional, and an empty list is the honest reading of \"no per-word\n // marks were stored\" — never a mark of its own.\n scoringResult: {\n score: fractionOfGrade(grade),\n maxScore: 1,\n passed: grade.passed,\n feedback: grade.feedback,\n details: grade.details ?? [],\n },\n }),\n },\n take,\n ),\n );\n };\n\n const submitTake = async (current: RecordedTake | null): Promise<void> => {\n const binding = bindingRef.current;\n if (inactive || submittingRef.current || binding === undefined) {\n return;\n }\n submittingRef.current = true;\n const takes = recorder.takesUsed;\n const run = runRef.current;\n // Every submit is a take of its own, a retried upload included: a number\n // no earlier submit on this page had, so whatever an earlier one still\n // brings back cannot be taken for this one's.\n const take = mintTake();\n beginTakeReport(take);\n try {\n let ref: RecordingRef | null = null;\n if (current !== null) {\n setPhase({ kind: 'uploading', take });\n try {\n ref = await binding.upload(current);\n } catch {\n if (run !== runRef.current) {\n return;\n }\n // The take never reached storage, so nothing is submitted: a take\n // that failed to upload must not become a blank response.\n raise({ kind: 'upload-failed', take });\n fire('recording-upload-failed', {\n takes,\n durationMs: current.durationMs,\n retryable: true,\n });\n return;\n }\n // Detached while the take travelled. The bytes are in the application's\n // storage and this instance drops their key, which is a smaller cost\n // than the alternative: `onSubmit` carries no activity id, so a\n // response reported for a reading the learner has left is one a pager\n // would file against whatever is on screen now.\n if (run !== runRef.current) {\n return;\n }\n setUploaded(ref);\n fire('recording-uploaded', { takes, durationMs: current.durationMs });\n }\n onSubmit?.(stampTake(responseOf(ref, takes), take));\n fire('submitted', { takes, durationMs: current?.durationMs ?? 0 });\n if (isExam || ref === null) {\n // Exam never assesses, never scores, never reveals, and builds no xAPI\n // statement: its `correctResponsesPattern` would be the answer key, and\n // a read-aloud is graded on a server from the stored bytes.\n complete();\n setPhase({ kind: 'submitted', take });\n return;\n }\n await runAssess(ref, current, take);\n } finally {\n submittingRef.current = false;\n }\n };\n\n /**\n * Judges the take that is already stored, again — the SAME take, so the same\n * number. Guarded like a submit: an assessment costs an application money,\n * and two presses of one retry must not buy two of them.\n */\n const retryAssess = async (ref: RecordingRef, take: number): Promise<void> => {\n if (submittingRef.current) {\n return;\n }\n submittingRef.current = true;\n beginTakeReport(take);\n try {\n await runAssess(ref, recorder.take, take);\n } finally {\n submittingRef.current = false;\n }\n };\n\n const handleSubmit = (event: React.FormEvent): void => {\n event.preventDefault();\n if (inactive || busy || recorder.take === null || phase.kind !== 'idle') {\n return;\n }\n void submitTake(recorder.take);\n };\n\n const beginTake = (): void => {\n if (inactive || busy || !recorder.canRecord) {\n return;\n }\n if (recorder.take !== null) {\n fire('recording-discarded', {\n takes: recorder.takesUsed,\n durationMs: recorder.take.durationMs,\n });\n }\n setPhase({ kind: 'idle' });\n setUploaded(null);\n start();\n void recorder.start();\n };\n\n // The reading's own language and the direction its tag names. No `_`→`-`\n // normalisation, unlike `<Dictation>`: `ReadAloudData.locale` is canonical by\n // schema, so there is nothing to normalise.\n const contentLang = typeof data.locale === 'string' ? data.locale : undefined;\n const contentDir = localeDirectionOf(data.locale);\n\n // What the host sent, as the one reader of a host's grade reads it. Every\n // path below that shows or decides anything about a grade — the summary, the\n // panel, the marks, who renders the score, the announcement — reads these and\n // never `outcome` or `assessment` directly.\n const outcomeReading = useMemo(() => readOutcome(outcome), [outcome]);\n const keptEvidence = useMemo(() => readEvidence(assessment), [assessment]);\n const storedGrade =\n outcomeReading?.kind === 'graded' && outcomeReading.status === 'graded'\n ? outcomeReading.grade\n : null;\n // The marks a review shows: the assessment when the caller kept one, and the\n // stored details otherwise. With neither, the score is shown and no marks are.\n const storedMarks = useMemo(\n () =>\n isReview && keptEvidence === null && storedGrade?.details !== undefined\n ? marksFromDetails(storedGrade.details)\n : null,\n [isReview, keptEvidence, storedGrade],\n );\n const feedbackAssessment = isReview\n ? keptEvidence\n : phase.kind === 'graded'\n ? phase.assessment\n : null;\n const feedbackGrade = isReview ? storedGrade : phase.kind === 'graded' ? phase.grade : null;\n // A take the page refused to play is handed to no per-word button: each of\n // them would do nothing when pressed, and the note in the player's place\n // already says why.\n const feedbackAudio = playback.refused ? null : takeAudio;\n\n // Whether the score and the grader's words are already on screen inside the\n // feedback panel, which is what decides who renders them here.\n //\n // The props say the panel WAS GIVEN a grade; only the DOM says it rendered\n // one. The panel can fail outright — D2's dev throw for evidence the\n // validator refuses is one way, and nothing on either path validates a host's\n // grade either — and clipping on the props alone then hides a score that\n // exists nowhere, leaving a learner \"this activity could not be displayed\"\n // and no percentage at all. So the props may only ever clip for the single\n // commit before the fact arrives, and the fact may always un-clip: a grade on\n // screen twice is a far smaller defect than a grade nowhere. `.lk-pf-grade`\n // is the panel's own hook for this, named as such in its source.\n const rootRef = useRef<HTMLFormElement>(null);\n const [panelLostTheGrade, setPanelLostTheGrade] = useState(false);\n // Only a READ grade is handed to the panel, and the panel shows a read grade's\n // score without exception — so the prediction is made from the reader's\n // output, and never from a grade the panel would refuse.\n const panelHasGrade = feedbackAssessment !== null && feedbackGrade !== null;\n const gradeShownInPanel = panelHasGrade && !panelLostTheGrade;\n // Deliberately without a dependency list: what it reads is the committed DOM,\n // which no list can name. The updater keeps the settled value a fixed point,\n // so a render that changes nothing here costs one extra pass and then stops.\n useEffect(() => {\n const root = rootRef.current;\n const lost = panelHasGrade && (root === null || root.querySelector('.lk-pf-grade') === null);\n setPanelLostTheGrade((was) => (was === lost ? was : lost));\n });\n\n const announcement = useMemo<Announcement | null>(() => {\n if (isReview) {\n return null;\n }\n // The two moments of a capture, said once each. The per-second counter used\n // to be a live region of its own, so a ten-second take produced ten\n // announcements — and on any device without headphones a screen reader\n // speaks each of them into the take about to be assessed FOR PRONUNCIATION.\n // This component already stops the model recordings for exactly that\n // reason; the counter it generates itself is the same hazard.\n if (recorder.status === 'recording') {\n return { text: s.readAloudRecordingStarted, feedback: null };\n }\n // The length is in the sentence because the counter is no longer announced:\n // a take that ran to its bound reads back as \"20 of 20 seconds\", which is\n // how a learner hears that it stopped itself rather than that they stopped it.\n const stopped: Announcement | null =\n recorder.status === 'recorded' && take !== null\n ? {\n text: s.readAloudRecordingStopped(\n secondsWithin(take.durationMs, maxSeconds, 'nearest'),\n maxSeconds,\n ),\n feedback: null,\n }\n : null;\n if (isExam) {\n if (phase.kind === 'submitted' || submitted) {\n return { text: s.answerSubmitted, feedback: null };\n }\n return phase.kind === 'idle' ? stopped : null;\n }\n switch (phase.kind) {\n case 'graded': {\n const grade = phase.grade;\n // A judgement with no grade that can be read says so, in the same\n // sentence a review uses — never nothing, which reads as a grade\n // still on its way.\n return grade === null\n ? { text: `${s.answerSubmitted} ${s.couldNotBeGraded}`, feedback: null }\n : {\n text: `${s.answerSubmitted} ${s.scoreAnnouncement(percentOfGrade(grade), grade.passed)}`,\n feedback: grade.feedback,\n };\n }\n case 'unscorable':\n return { text: unscorableMessage(phase.code, s), feedback: null };\n case 'unassessed':\n return { text: s.readAloudAssessmentUnavailable, feedback: null };\n case 'idle':\n return stopped;\n default:\n // Uploading and assessing have their own pending sentence, and both\n // failures have an alert; a stale \"recording stopped\" beside either\n // would be the loudest thing on the screen.\n return null;\n }\n }, [isReview, isExam, phase, submitted, s, recorder.status, take, maxSeconds]);\n\n const alertText =\n recorder.error !== null\n ? s.readAloudRecorderError(recorder.error)\n : phase.kind === 'upload-failed'\n ? s.readAloudUploadFailed\n : phase.kind === 'assess-failed'\n ? s.readAloudAssessmentFailed\n : null;\n\n return (\n <form\n className=\"lk-ra\"\n ref={rootRef}\n // A title with nothing to say would name the form with silence.\n aria-labelledby={VISIBLE_TEXT_RE.test(data.title) ? titleId : undefined}\n lang={locale}\n data-render-mode={renderMode}\n style={theme as CSSProperties | undefined}\n onSubmit={handleSubmit}\n >\n {/*\n The form's name: read from here, it keeps the content's language. A\n paragraph of its own, so without a language to go by its own first\n letter decides its direction.\n */}\n <p id={titleId} className=\"lk-ra-title\" dir={contentDir ?? 'auto'} lang={contentLang}>\n {data.title}\n </p>\n\n {typeof data.instructions === 'string' && data.instructions !== '' ? (\n <p className=\"lk-ra-instructions\" dir={contentDir ?? 'auto'} lang={contentLang}>\n {data.instructions}\n </p>\n ) : null}\n\n {/* The reading itself. Never redacted: a read-aloud has no answer key, so\n the learner's copy carries the text in full. */}\n <p className=\"lk-ra-reference\" dir={contentDir ?? 'auto'} lang={contentLang}>\n {data.referenceText}\n </p>\n\n {data.media !== undefined || slowMedia !== undefined ? (\n <div className=\"lk-ra-models\" ref={modelsRef}>\n {/*\n Each model recording is a named group (a fieldset with a legend,\n which is what `role=\"group\"` plus a label spells natively), so the\n two players are told apart by name and not only by position.\n */}\n {data.media !== undefined ? (\n <fieldset className=\"lk-ra-model\">\n <legend className=\"lk-ra-model-label\">{s.readAloudModelRecording}</legend>\n {/* The ONLY budgeted recording: the binding is whatever the pager or the caller passes.\n Disabled while a take is captured, so a press is refused BEFORE a play is\n charged — silenced after the charge, it cost the learner a play they never\n heard. Nothing is announced for the refusal: a screen reader speaking now\n would speak into the take. */}\n <ActivityMedia\n media={data.media}\n renderMode={renderMode}\n playbackGroup={modelsGroup}\n {...(mediaBudget !== undefined ? { mediaBudget } : {})}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(onInteraction !== undefined ? { onInteraction } : {})}\n {...(locale !== undefined ? { locale } : {})}\n {...(disabled === true || isCapturing ? { disabled: true } : {})}\n />\n </fieldset>\n ) : null}\n {slowMedia !== undefined ? (\n <fieldset className=\"lk-ra-model\" data-slow=\"true\">\n <legend className=\"lk-ra-model-label\">{s.readAloudSlowRecording}</legend>\n {/* No budget of its own, by contract — so no binding is passed and none is demanded. */}\n <ActivityMedia\n media={slowMedia}\n renderMode={renderMode}\n playbackGroup={modelsGroup}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(locale !== undefined ? { locale } : {})}\n {...(disabled === true || isCapturing ? { disabled: true } : {})}\n />\n </fieldset>\n ) : null}\n </div>\n ) : null}\n\n {/* Gone once the item is committed, rather than left behind disabled: a\n submitted exam answer is not a control a learner should still meet. */}\n {isReview || submitted ? null : (\n <div\n className=\"lk-ra-recorder\"\n data-status={recorder.status}\n data-level={\n recorder.status === 'recording'\n ? Math.min(LEVEL_STEPS, Math.round(recorder.level * LEVEL_STEPS))\n : undefined\n }\n >\n {recorder.status === 'recording' ? (\n <button\n type=\"button\"\n className=\"lk-ra-stop\"\n disabled={inactive}\n onClick={() => recorder.stop()}\n >\n {s.readAloudStop}\n </button>\n ) : (\n // aria-disabled, never disabled, once the takes are spent: a\n // natively disabled button drops keyboard focus to the page body,\n // and this is the control a learner comes back to.\n <button\n type=\"button\"\n className=\"lk-ra-record\"\n disabled={inactive}\n aria-disabled={!recorder.canRecord || busy || undefined}\n onClick={beginTake}\n >\n {recorder.take === null ? s.readAloudRecord : s.readAloudRerecord}\n </button>\n )}\n {recorder.status === 'recording' ? (\n // Visible, and hidden from assistive technology, beside the level\n // meter the recorder's `data-level` drives. Its text changes every\n // whole second, so as a live region it announced ten times in a\n // ten-second take — into the microphone. What a screen-reader\n // learner needs instead is said once each, below.\n <p className=\"lk-ra-progress\" aria-hidden=\"true\">\n {s.readAloudRecordingProgress(\n secondsWithin(recorder.elapsedMs, maxSeconds, 'down'),\n maxSeconds,\n )}\n </p>\n ) : null}\n {takesLeft !== undefined && maxTakes !== undefined ? (\n <p className=\"lk-ra-takes\">{s.readAloudTakesRemaining(takesLeft, maxTakes)}</p>\n ) : null}\n </div>\n )}\n\n {takeAudio === null ? null : playback.refused ? (\n // In the player's place, not beside it: a player the page will not\n // load looks exactly like one that works until it is pressed, and then\n // does nothing. A note rather than an alert — the learner can still\n // submit, and nothing here asks them to act.\n <p className=\"lk-ra-take-unavailable\" role=\"note\">\n {s.readAloudPlaybackUnavailable}\n </p>\n ) : (\n // biome-ignore lint/a11y/useMediaCaption: the learner's own take has no caption track to offer; its accessible name says whose recording it is\n <audio\n className=\"lk-ra-take\"\n controls\n src={takeAudio}\n aria-label={s.readAloudYourRecording}\n onError={(event) => playback.refuse(event.currentTarget)}\n {...(isReview ? {} : { 'data-take': recorder.takesUsed })}\n />\n )}\n\n {isReview || submitted ? null : (\n <div className=\"lk-ra-actions\">\n <button\n ref={submitRef}\n type=\"submit\"\n className=\"lk-ra-submit\"\n disabled={disabled === true}\n aria-disabled={recorder.take === null || phase.kind !== 'idle' || undefined}\n aria-busy={busy || undefined}\n >\n {s.submit}\n </button>\n {isExam ? (\n // Explicit, and only here: an exam answer with no recording is a\n // decision a learner takes, never something a failed upload does\n // for them.\n <button\n type=\"button\"\n className=\"lk-ra-submit-blank\"\n disabled={inactive}\n aria-disabled={busy || undefined}\n onClick={() => {\n if (!busy) {\n void submitTake(null);\n }\n }}\n >\n {s.readAloudSubmitWithoutRecording}\n </button>\n ) : null}\n {offersRetry(phase, uploaded) ? (\n <button\n type=\"button\"\n className=\"lk-ra-retry\"\n onClick={() => {\n // The retry takes this button away with the phase it answers,\n // and focus on a removed element drops to the page body — a\n // keyboard learner is then back at the top of the page with no\n // idea the retry started. It goes to the submit being retried.\n submitRef.current?.focus();\n if (phase.kind === 'upload-failed') {\n void submitTake(recorder.take);\n } else if (phase.kind === 'assess-failed' && uploaded !== null) {\n void retryAssess(uploaded, phase.take);\n }\n }}\n >\n {s.readAloudTryAgain}\n </button>\n ) : null}\n </div>\n )}\n\n {busy ? (\n <p className=\"lk-ra-pending\" role=\"status\" aria-busy=\"true\">\n {phase.kind === 'uploading' ? s.readAloudUploading : s.readAloudAssessing}\n </p>\n ) : null}\n\n {alertText !== null ? (\n <p key={errorNonce} className=\"lk-ra-alert\" role=\"alert\">\n {alertText}\n </p>\n ) : null}\n\n {feedbackAssessment !== null ? (\n <PronunciationFeedback\n data={{ referenceText: data.referenceText, locale: data.locale }}\n assessment={feedbackAssessment}\n {...(feedbackGrade !== null ? { grade: feedbackGrade } : {})}\n {...(feedbackAudio !== null ? { audioUrl: feedbackAudio } : {})}\n {...(breakThreshold !== undefined ? { breakThreshold } : {})}\n {...(monotoneThreshold !== undefined ? { monotoneThreshold } : {})}\n {...(locale !== undefined ? { locale } : {})}\n {...(strings !== undefined ? { strings } : {})}\n />\n ) : null}\n\n {storedMarks !== null ? (\n <div className=\"lk-ra-marks\">\n {/* The list's name and the hidden sentences are interface text; only\n the words carry the reading's language. */}\n <ol className=\"lk-ra-words\" aria-label={s.pronunciationWordsLabel} dir={contentDir}>\n {storedMarks.map((entry, index) => {\n const sentence = markSentence(entry, s);\n return (\n <li\n // biome-ignore lint/suspicious/noArrayIndexKey: mark order is the identity; words repeat\n key={index}\n className=\"lk-ra-word\"\n data-state={entry.state}\n >\n {/* One channel for assistive technology, not two: the same\n sentence as a `title` is an accessible description, read\n straight after the name it repeats. */}\n <span className=\"lk-visually-hidden\" style={VISUALLY_HIDDEN}>\n {sentence}\n </span>\n <span\n className=\"lk-ra-word-text\"\n aria-hidden=\"true\"\n dir={contentDir ?? 'auto'}\n lang={contentLang}\n >\n {entry.reference}\n </span>\n </li>\n );\n })}\n </ol>\n {/* Three rows, not four: a stored mark set carries no insertions. */}\n <ul className=\"lk-ra-legend\">\n {STORED_STATES.map((state) => (\n <li key={state} data-state={state}>\n {s.pronunciationLegend(state)}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n <FeedbackRegion id={`${data.id}-feedback`}>\n {isReview ? (\n outcomeReading !== undefined ? (\n <OutcomeSummary reading={outcomeReading} s={s} scoreShown={gradeShownInPanel} />\n ) : null\n ) : gradeShownInPanel ? (\n // Announced, not repeated. A grade the feedback panel is already\n // showing would otherwise be read on screen twice, feedback and all —\n // but a live region is the only thing that TELLS a screen-reader\n // learner a grade arrived, since nothing takes focus. Clipped rather\n // than `display: none`, which would stop it being announced at all.\n <span className=\"lk-visually-hidden\" style={VISUALLY_HIDDEN}>\n <AnnouncementText announcement={announcement} />\n </span>\n ) : (\n <AnnouncementText announcement={announcement} />\n )}\n </FeedbackRegion>\n </form>\n );\n}\n","'use client';\n\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport { ReadAloud as ReadAloudCore, type ReadAloudProps } from './ReadAloud.js';\n\n// `RecordedTake` travels with `RecordingBinding` because `upload`, the one\n// method a binding must have, takes one: a binding written against this subpath\n// must not need a second import path to name its own argument.\nexport type { RecordedTake } from '../../hooks/useSpeechRecorder.js';\nexport type { ReadAloudAssessResult, ReadAloudProps, RecordingBinding } from './ReadAloud.js';\n\n/**\n * Public Read Aloud activity: the core wrapped in `ActivityErrorBoundary` so a\n * render failure (including the dev schema-validation throw and the\n * missing-`upload` guard) degrades to an accessible fallback instead of\n * crashing the host.\n */\nexport function ReadAloud(props: ReadAloudProps) {\n const strings = useLkStrings(props.strings);\n return (\n <ActivityErrorBoundary activityTitle={props.data?.title} strings={strings}>\n <ReadAloudCore {...props} />\n </ActivityErrorBoundary>\n );\n}\n"]}