@pie-players/pie-assessment-player 0.3.74 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,155 +1,46 @@
1
- import "@pie-players/pie-section-player/components/section-player-splitpane-element";
2
- import "@pie-players/pie-section-player/components/section-player-vertical-element";
3
- import { SECTION_PLAYER_PUBLIC_EVENTS as N } from "@pie-players/pie-section-player/contracts/public-events";
4
- import { coerceBooleanLike as R, defineCustomElementSafely as B } from "@pie-players/pie-players-shared";
5
- import { createNewAssessmentSession as V, frameworkErrorFromUnknown as Q, setCurrentSectionPosition as J, upsertSectionSession as K } from "@pie-players/pie-assessment-toolkit";
6
- var b = (e) => {
7
- if (e === null || typeof e != "object") return e;
8
- if (Array.isArray(e)) return e.map(b);
9
- const t = {};
10
- for (const i in e) Object.hasOwn(e, i) && (t[i] = b(e[i]));
11
- return t;
12
- };
13
- function S(e) {
1
+ import "@pie-players/pie-section-player";
2
+ import { createNewAssessmentSession as Q, frameworkErrorFromUnknown as J, setCurrentSectionPosition as K, upsertSectionSession as Y } from "@pie-players/pie-assessment-toolkit";
3
+ function w(e) {
14
4
  "@babel/helpers - typeof";
15
- return S = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
5
+ return w = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
16
6
  return typeof t;
17
7
  } : function(t) {
18
8
  return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
19
- }, S(e);
9
+ }, w(e);
20
10
  }
21
- function Y(e, t) {
22
- if (S(e) != "object" || !e) return e;
11
+ function Z(e, t) {
12
+ if (w(e) != "object" || !e) return e;
23
13
  var i = e[Symbol.toPrimitive];
24
14
  if (i !== void 0) {
25
- var s = i.call(e, t || "default");
26
- if (S(s) != "object") return s;
15
+ var n = i.call(e, t || "default");
16
+ if (w(n) != "object") return n;
27
17
  throw new TypeError("@@toPrimitive must return a primitive value.");
28
18
  }
29
19
  return (t === "string" ? String : Number)(e);
30
20
  }
31
- function Z(e) {
32
- var t = Y(e, "string");
33
- return S(t) == "symbol" ? t : t + "";
21
+ function X(e) {
22
+ var t = Z(e, "string");
23
+ return w(t) == "symbol" ? t : t + "";
34
24
  }
35
- function g(e, t, i) {
36
- return (t = Z(t)) in e ? Object.defineProperty(e, t, {
25
+ function f(e, t, i) {
26
+ return (t = X(t)) in e ? Object.defineProperty(e, t, {
37
27
  value: i,
38
28
  enumerable: !0,
39
29
  configurable: !0,
40
30
  writable: !0
41
31
  }) : e[t] = i, e;
42
32
  }
43
- function O(e, t) {
44
- const i = `[${e}]`;
45
- return {
46
- debug: (s, ...n) => {
47
- t() && console.debug(i, s, ...n);
48
- },
49
- info: (s, ...n) => console.info(i, s, ...n),
50
- warn: (s, ...n) => console.warn(i, s, ...n),
51
- error: (s, ...n) => console.error(i, s, ...n)
52
- };
53
- }
54
- function H() {
55
- return typeof window < "u" && window.PIE_DEBUG === !0;
56
- }
57
- function q(e) {
58
- if (!e || typeof e != "object") return !1;
59
- const t = e;
60
- return typeof t.providerId == "string" && typeof t.providerName == "string" && typeof t.initialize == "function" && typeof t.trackError == "function" && typeof t.trackEvent == "function" && typeof t.destroy == "function" && typeof t.isReady == "function";
61
- }
62
- var X = O("instrumentation-event-bridge", () => H());
63
- function ee(e) {
64
- return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
65
- }
66
- function te(e) {
67
- X.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
68
- }
69
- function ie(e) {
70
- try {
71
- e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
72
- component: e.component,
73
- errorType: "InstrumentationBridgeError",
74
- sourceEventName: e.sourceEventName
75
- });
76
- } catch {
77
- }
78
- }
79
- function se(e) {
80
- if (!e.host || !e.eventMap.length) return () => {
81
- };
82
- if (!e.instrumentationProvider) return () => {
83
- };
84
- if (!q(e.instrumentationProvider))
85
- return e.debug && te(e.component), () => {
86
- };
87
- const t = e.instrumentationProvider, i = [], s = Math.max(0, e.dedupeWindowMs ?? 0), n = /* @__PURE__ */ new Map(), o = (r, a) => {
88
- const h = [
89
- a.assessmentId,
90
- a.sectionId,
91
- a.attemptId,
92
- a.itemId,
93
- a.canonicalItemId,
94
- a.sourceRuntimeId
95
- ].map((d) => String(d ?? "")).join("|");
96
- return `${r.instrumentationEventName}|${h}`;
97
- };
98
- for (const r of e.eventMap) {
99
- const a = (h) => {
100
- try {
101
- if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(h)) return;
102
- const d = ee(h.detail), c = (/* @__PURE__ */ new Date()).toISOString(), m = {
103
- ...d,
104
- ...e.staticAttributes,
105
- component: e.component,
106
- sourceEventName: r.sourceEventName,
107
- timestamp: c
108
- };
109
- if (s > 0) {
110
- const u = Date.now(), l = o(r, m), f = n.get(l);
111
- if (typeof f == "number" && u - f < s) return;
112
- n.set(l, u);
113
- }
114
- t.trackEvent(r.instrumentationEventName, { ...m });
115
- } catch (d) {
116
- ie({
117
- provider: t,
118
- component: e.component,
119
- error: d,
120
- sourceEventName: r.sourceEventName
121
- });
122
- }
123
- };
124
- e.host.addEventListener(r.sourceEventName, a), i.push(() => {
125
- e.host?.removeEventListener(r.sourceEventName, a);
126
- });
127
- }
128
- return () => {
129
- for (const r of i) r();
130
- };
131
- }
132
- function T(e) {
133
- const t = e;
134
- return typeof t?.noticeError == "function" && typeof t.addPageAction == "function";
135
- }
136
- function y() {
137
- if (typeof window > "u") return;
138
- const { newrelic: e, NREUM: t } = window;
139
- if (T(e)) return e;
140
- if (T(t)) return t;
141
- }
142
- var ne = class {
33
+ var ee = class {
143
34
  constructor() {
144
- g(this, "initialized", !1), g(this, "config", void 0);
35
+ f(this, "initialized", !1), f(this, "config", void 0);
145
36
  }
146
37
  trackError(e, t) {
147
38
  if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
148
39
  const i = this.transformAttributes(t);
149
40
  try {
150
41
  this.doTrackError(e, i), this.config?.debug && console.log(`[${this.providerName}] Tracked error:`, e, i);
151
- } catch (s) {
152
- console.error(`[${this.providerName}] Error tracking error:`, s);
42
+ } catch (n) {
43
+ console.error(`[${this.providerName}] Error tracking error:`, n);
153
44
  }
154
45
  }
155
46
  trackEvent(e, t) {
@@ -161,8 +52,8 @@ var ne = class {
161
52
  });
162
53
  try {
163
54
  this.doTrackEvent(e, i), this.config?.debug && console.log(`[${this.providerName}] Tracked event:`, e, i);
164
- } catch (s) {
165
- console.error(`[${this.providerName}] Error tracking event:`, s);
55
+ } catch (n) {
56
+ console.error(`[${this.providerName}] Error tracking event:`, n);
166
57
  }
167
58
  }
168
59
  trackMetric(e, t, i) {
@@ -203,34 +94,219 @@ var ne = class {
203
94
  transformAttributes(e) {
204
95
  return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
205
96
  }
206
- }, oe = class extends ne {
97
+ };
98
+ function x(e) {
99
+ const t = e;
100
+ return typeof t?.noticeError == "function" && typeof t.addPageAction == "function";
101
+ }
102
+ function b() {
103
+ if (typeof window > "u") return;
104
+ const { newrelic: e, NREUM: t } = window;
105
+ if (x(e)) return e;
106
+ if (x(t)) return t;
107
+ }
108
+ var te = class extends ee {
207
109
  constructor(...e) {
208
- super(...e), g(this, "providerId", "newrelic"), g(this, "providerName", "New Relic");
110
+ super(...e), f(this, "providerId", "newrelic"), f(this, "providerName", "New Relic");
209
111
  }
210
112
  async initialize(e) {
211
- this.config = e, this.initialized = !0, this.config?.debug && console.log(y() ? "[NewRelicProvider] Initialized successfully" : "[NewRelicProvider] Initialized; sends once the New Relic agent is on the page");
113
+ this.config = e, this.initialized = !0, this.config?.debug && console.log(b() ? "[NewRelicProvider] Initialized successfully" : "[NewRelicProvider] Initialized; sends once the New Relic agent is on the page");
212
114
  }
213
115
  isReady() {
214
- return this.initialized && y() !== void 0;
116
+ return this.initialized && b() !== void 0;
215
117
  }
216
118
  destroy() {
217
119
  this.initialized = !1, this.config?.debug && console.log("[NewRelicProvider] Destroyed");
218
120
  }
219
121
  doTrackError(e, t) {
220
- y()?.noticeError(e, t);
122
+ b()?.noticeError(e, t);
221
123
  }
222
124
  doTrackEvent(e, t) {
223
- y()?.addPageAction(e, t);
125
+ b()?.addPageAction(e, t);
224
126
  }
225
127
  doSetUserContext(e, t) {
226
- const i = y();
227
- if (typeof i?.setUserId == "function" && i.setUserId(e), t && typeof i?.setCustomAttribute == "function") for (const [s, n] of Object.entries(t)) i.setCustomAttribute(s, n);
128
+ const i = b();
129
+ if (typeof i?.setUserId == "function" && i.setUserId(e), t && typeof i?.setCustomAttribute == "function") for (const [n, s] of Object.entries(t)) i.setCustomAttribute(n, s);
228
130
  }
229
131
  doSetGlobalAttributes(e) {
230
- const t = y();
231
- if (typeof t?.setCustomAttribute == "function") for (const [i, s] of Object.entries(e)) t.setCustomAttribute(i, s);
132
+ const t = b();
133
+ if (typeof t?.setCustomAttribute == "function") for (const [i, n] of Object.entries(e)) t.setCustomAttribute(i, n);
134
+ }
135
+ };
136
+ function B(e) {
137
+ if (!e || typeof e != "object") return !1;
138
+ const t = e;
139
+ return typeof t.providerId == "string" && typeof t.providerName == "string" && typeof t.initialize == "function" && typeof t.trackError == "function" && typeof t.trackEvent == "function" && typeof t.destroy == "function" && typeof t.isReady == "function";
140
+ }
141
+ var ie = /* @__PURE__ */ new Set([
142
+ "annotation-xml",
143
+ "color-profile",
144
+ "font-face",
145
+ "font-face-src",
146
+ "font-face-uri",
147
+ "font-face-format",
148
+ "font-face-name",
149
+ "missing-glyph"
150
+ ]), ne = /^[a-z][a-z0-9._-]*-[a-z0-9._-]*$/, se = (e, t = "custom element tag") => {
151
+ if (!e || typeof e != "string") throw new Error(`Invalid ${t}: expected a non-empty string`);
152
+ const i = e.trim();
153
+ if (!i) throw new Error(`Invalid ${t}: tag is empty`);
154
+ if (i !== i.toLowerCase()) throw new Error(`Invalid ${t} "${i}": custom element names must be lowercase`);
155
+ if (!i.includes("-")) throw new Error(`Invalid ${t} "${i}": custom element names must include a hyphen`);
156
+ if (ie.has(i)) throw new Error(`Invalid ${t} "${i}": this name is reserved by the HTML spec`);
157
+ if (!ne.test(i)) throw new Error(`Invalid ${t} "${i}": allowed characters are lowercase letters, numbers, ".", "_" and "-"`);
158
+ return i;
159
+ }, oe = (e) => typeof DOMException < "u" && e instanceof DOMException ? e.name === "NotSupportedError" || e.code === DOMException.NOT_SUPPORTED_ERR : (typeof e == "object" && e !== null && "name" in e ? String(e.name) : "") === "NotSupportedError", re = (e, t, i = "custom element tag", n = {}) => {
160
+ const s = se(e, i);
161
+ if (customElements.get(s)) return {
162
+ outcome: "already-defined",
163
+ tagName: s
164
+ };
165
+ try {
166
+ return customElements.define(s, t), {
167
+ outcome: "defined",
168
+ tagName: s
169
+ };
170
+ } catch (o) {
171
+ if (!oe(o)) return {
172
+ outcome: "error",
173
+ tagName: s,
174
+ error: o
175
+ };
176
+ if (customElements.get(s)) return {
177
+ outcome: "already-defined",
178
+ tagName: s
179
+ };
180
+ if (!n.allowWrappedFallback) return {
181
+ outcome: "error",
182
+ tagName: s,
183
+ error: o
184
+ };
185
+ try {
186
+ return customElements.define(s, class extends t {
187
+ }), {
188
+ outcome: "defined-wrapped",
189
+ tagName: s
190
+ };
191
+ } catch (r) {
192
+ return {
193
+ outcome: "wrapped-error",
194
+ tagName: s,
195
+ error: r
196
+ };
197
+ }
232
198
  }
199
+ }, H = (e, t, i = "custom element tag") => {
200
+ const n = re(e, t, i);
201
+ if (n.outcome === "error" || n.outcome === "wrapped-error") throw n.error;
202
+ return {
203
+ status: n.outcome === "already-defined" ? "already-defined" : "defined",
204
+ tagName: n.tagName
205
+ };
206
+ }, y = (e) => {
207
+ if (e === null || typeof e != "object") return e;
208
+ if (Array.isArray(e)) return e.map(y);
209
+ const t = {};
210
+ for (const i in e) Object.hasOwn(e, i) && (t[i] = y(e[i]));
211
+ return t;
233
212
  };
213
+ function $(e, t) {
214
+ const i = `[${e}]`;
215
+ return {
216
+ debug: (n, ...s) => {
217
+ t() && console.debug(i, n, ...s);
218
+ },
219
+ info: (n, ...s) => console.info(i, n, ...s),
220
+ warn: (n, ...s) => console.warn(i, n, ...s),
221
+ error: (n, ...s) => console.error(i, n, ...s)
222
+ };
223
+ }
224
+ function q() {
225
+ return typeof window < "u" && window.PIE_DEBUG === !0;
226
+ }
227
+ var ae = $("instrumentation-event-bridge", () => q());
228
+ function le(e) {
229
+ if (e === null) return !0;
230
+ const t = typeof e;
231
+ if (t === "function" || t === "symbol") return !1;
232
+ if (t !== "object" || Array.isArray(e)) return !0;
233
+ const i = Object.getPrototypeOf(e);
234
+ return i === Object.prototype || i === null;
235
+ }
236
+ function ce(e) {
237
+ if (e && typeof e == "object") {
238
+ const t = {};
239
+ for (const [i, n] of Object.entries(e)) le(n) && (t[i] = n);
240
+ return t;
241
+ }
242
+ return typeof e > "u" ? {} : { value: e };
243
+ }
244
+ function de(e) {
245
+ ae.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
246
+ }
247
+ function ue(e) {
248
+ try {
249
+ e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
250
+ component: e.component,
251
+ errorType: "InstrumentationBridgeError",
252
+ sourceEventName: e.sourceEventName
253
+ });
254
+ } catch {
255
+ }
256
+ }
257
+ function he(e) {
258
+ if (!e.host || !e.eventMap.length) return () => {
259
+ };
260
+ if (!e.instrumentationProvider) return () => {
261
+ };
262
+ if (!B(e.instrumentationProvider))
263
+ return e.debug && de(e.component), () => {
264
+ };
265
+ const t = e.instrumentationProvider, i = [], n = Math.max(0, e.dedupeWindowMs ?? 0), s = /* @__PURE__ */ new Map(), o = (r, a) => {
266
+ const h = [
267
+ a.assessmentId,
268
+ a.sectionId,
269
+ a.attemptId,
270
+ a.itemId,
271
+ a.canonicalItemId,
272
+ a.sourceRuntimeId
273
+ ].map((d) => String(d ?? "")).join("|");
274
+ return `${r.instrumentationEventName}|${h}`;
275
+ };
276
+ for (const r of e.eventMap) {
277
+ const a = (h) => {
278
+ try {
279
+ if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(h)) return;
280
+ const d = ce(h.detail), c = (/* @__PURE__ */ new Date()).toISOString(), p = {
281
+ ...d,
282
+ ...e.staticAttributes,
283
+ component: e.component,
284
+ sourceEventName: r.sourceEventName,
285
+ timestamp: c
286
+ };
287
+ if (n > 0) {
288
+ const u = Date.now(), l = o(r, p), m = s.get(l);
289
+ if (typeof m == "number" && u - m < n) return;
290
+ s.set(l, u);
291
+ }
292
+ t.trackEvent(r.instrumentationEventName, { ...p });
293
+ } catch (d) {
294
+ ue({
295
+ provider: t,
296
+ component: e.component,
297
+ error: d,
298
+ sourceEventName: r.sourceEventName
299
+ });
300
+ }
301
+ };
302
+ e.host.addEventListener(r.sourceEventName, a), i.push(() => {
303
+ e.host?.removeEventListener(r.sourceEventName, a);
304
+ });
305
+ }
306
+ return () => {
307
+ for (const r of i) r();
308
+ };
309
+ }
234
310
  function L(e) {
235
311
  return e && typeof e == "object" ? e : {};
236
312
  }
@@ -251,25 +327,25 @@ function F(e) {
251
327
  const t = e.trackPageActions;
252
328
  return typeof t == "boolean" ? t : void 0;
253
329
  }
254
- function re(e, t) {
330
+ function pe(e, t) {
255
331
  return e.kind === "value" || e.kind === "null" ? e : t;
256
332
  }
257
- var I, ae = O("instrumentation-provider-resolution", () => H());
258
- function le() {
259
- return I || (I = new oe(), I.initialize()), I;
333
+ var I, me = $("instrumentation-provider-resolution", () => q());
334
+ function ge() {
335
+ return I || (I = new te(), I.initialize()), I;
260
336
  }
261
- function ce(e) {
262
- const t = D(e.runtimePlayer), i = D(e.player), s = F(t), n = F(i), o = s ?? n ?? !1, r = re(M(t), M(i));
337
+ function fe(e) {
338
+ const t = D(e.runtimePlayer), i = D(e.player), n = F(t), s = F(i), o = n ?? s ?? !1, r = pe(M(t), M(i));
263
339
  if (r.kind !== "null") {
264
- if (r.kind === "unset") return o ? le() : void 0;
265
- if (q(r.value)) return r.value;
340
+ if (r.kind === "unset") return o ? ge() : void 0;
341
+ if (B(r.value)) return r.value;
266
342
  if (e.debug) {
267
343
  const a = e.component ? `[${e.component}] ` : "";
268
- ae.warn(`${a}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
344
+ me.warn(`${a}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
269
345
  }
270
346
  }
271
347
  }
272
- var de = [
348
+ var ye = [
273
349
  {
274
350
  sourceEventName: "assessment-controller-ready",
275
351
  instrumentationEventName: "pie-assessment-controller-ready"
@@ -302,32 +378,47 @@ var de = [
302
378
  sourceEventName: "assessment-error",
303
379
  instrumentationEventName: "pie-assessment-error"
304
380
  }
305
- ], ue = { "nl-NL": () => import("./nl-NL-BVlv1TF9.js") }, he = ["en-US", "nl-NL"];
306
- async function pe(e) {
307
- const t = ue[e];
381
+ ];
382
+ function R(e, t = !1) {
383
+ if (typeof e == "boolean") return e;
384
+ if (e == null) return t;
385
+ const i = String(e).trim().toLowerCase();
386
+ return i === "" ? t : ![
387
+ "false",
388
+ "0",
389
+ "off",
390
+ "no"
391
+ ].includes(i);
392
+ }
393
+ var ve = { "nl-NL": () => import("./nl-NL-DqnT-1mq.js") }, be = ["en-US", "nl-NL"];
394
+ async function Se(e) {
395
+ const t = ve[e];
308
396
  if (!t) throw new Error(`No bundled i18n catalog for locale: ${e}`);
309
397
  return (await t()).default;
310
398
  }
311
- function w(e) {
399
+ function A(e) {
312
400
  return e ? e.trim().replace(/_/g, "-").split(/[.@]/)[0].toLowerCase() : "";
313
401
  }
314
- function me(e) {
315
- const t = w(e);
402
+ function E(e) {
403
+ return e ? e.trim().replace(/_/g, "-") : "";
404
+ }
405
+ function we(e) {
406
+ const t = A(e);
316
407
  if (!t) return [];
317
- const i = t.split("-"), s = [];
318
- for (let n = i.length; n > 0; n--) {
319
- const o = i.slice(0, n);
320
- o.length > 1 && o[o.length - 1].length === 1 || s.push(o.join("-"));
408
+ const i = t.split("-"), n = [];
409
+ for (let s = i.length; s > 0; s--) {
410
+ const o = i.slice(0, s);
411
+ o.length > 1 && o[o.length - 1].length === 1 || n.push(o.join("-"));
321
412
  }
322
- return s;
413
+ return n;
323
414
  }
324
- function ge(e, t) {
325
- for (const i of me(e)) {
326
- const s = t.find((n) => w(n) === i);
327
- if (s != null) return s;
415
+ function Ae(e, t) {
416
+ for (const i of we(e)) {
417
+ const n = t.find((s) => A(s) === i);
418
+ if (n != null) return n;
328
419
  }
329
420
  }
330
- var fe = {
421
+ var Ie = {
331
422
  common: {
332
423
  close: "Close",
333
424
  cancel: "Cancel",
@@ -635,44 +726,20 @@ var fe = {
635
726
  textToSpeech: {
636
727
  name: "Text to Speech",
637
728
  description: "Read content aloud",
638
- toolA11y: "Text-to-speech tool",
639
- title: "Text-to-Speech",
640
- initializing: "Initializing…",
641
- initFailed: "Failed to initialize text-to-speech.",
642
- selectText: "Select text on the page to read it aloud.",
643
- speed: "Speed:",
644
- play: "Play",
645
- pause: "Pause",
646
- resume: "Resume",
647
- stop: "Stop",
648
- speaking: "Speaking…",
649
- paused: "Paused",
650
- charactersSelected: {
651
- one: "{count} character selected",
652
- other: "{count} characters selected"
653
- },
654
- rate: {
655
- slow: "Slow",
656
- slower: "Slower",
657
- normal: "Normal",
658
- faster: "Faster",
659
- fast: "Fast",
660
- veryFast: "Very Fast"
661
- },
729
+ initFailed: "Unable to initialize text-to-speech. Try again.",
662
730
  inline: {
663
731
  controlsA11y: "Reading controls",
664
732
  playbackSpeedA11y: "Playback speed",
665
733
  rewindA11y: "Rewind",
666
734
  fastForwardA11y: "Fast-forward",
667
735
  stopA11y: "Stop reading",
668
- initializing: "Initializing text-to-speech",
669
- initFailed: "Unable to initialize text-to-speech. Try again.",
670
736
  starting: "Starting reading",
671
737
  started: "Reading started",
672
738
  resumed: "Reading resumed",
673
739
  pausedAnnouncement: "Reading paused",
674
740
  stopped: "Reading stopped",
675
741
  switchedSection: "Reading switched to another section",
742
+ nothingToRead: "Nothing to read aloud here",
676
743
  startFailed: "Unable to start reading",
677
744
  skippedForward: "Skipped forward",
678
745
  skipForwardFailed: "Unable to skip forward",
@@ -752,6 +819,7 @@ var fe = {
752
819
  pnp: {
753
820
  title: "PNP Profile",
754
821
  noAssessmentBound: "No assessment bound",
822
+ noAssessmentBoundBody: "Profile, district and test-administration policy have nothing to read, so only an item's requiredTools can grant an accommodation. Pass the assessment to the toolkit's assessment property, or call updateAssessment(...) on the toolkit coordinator.",
755
823
  determinationReadOnly: "Determination (read-only)",
756
824
  toolsEditor: "Tools Editor",
757
825
  enforcement: "PNP enforcement",
@@ -764,6 +832,7 @@ var fe = {
764
832
  resolvedTools: "Resolved Tools (toolkit)",
765
833
  provenanceSummary: "Tool Policy Provenance Summary",
766
834
  perToolDecisions: "Per-Tool Decisions",
835
+ policyDiagnostics: "Policy Diagnostics",
767
836
  profileReadOnly: "PNP Profile (read-only)"
768
837
  },
769
838
  tts: {
@@ -826,15 +895,42 @@ var fe = {
826
895
  previewEnterText: "Enter preview text before starting playback.",
827
896
  previewUnavailable: "Cannot preview while this service is unavailable.",
828
897
  browserSynthesisUnavailable: "Browser speech synthesis is unavailable.",
829
- browserSynthesisEndedEarly: "Browser speech synthesis ended before audio started. Restart the browser and try again.",
830
- browserSynthesisQueueFailed: "Browser speech synthesis failed to queue preview audio.",
831
- browserPreviewFailed: "Failed to play browser voice preview.",
832
898
  ssmlWordTrackingDisabled: "Google SSML preview preserves authored SSML, so word tracking is disabled.",
833
899
  applyUnavailable: "Cannot apply settings while this service is unavailable.",
834
- coordinatorUnavailable: "Toolkit coordinator is not available for text-to-speech updates."
900
+ coordinatorUnavailable: "Toolkit coordinator is not available for text-to-speech updates.",
901
+ customProviderNotRegistered: "Custom provider '{id}' is not registered.",
902
+ customProviderNoConfig: "Custom provider '{id}' did not return an apply config.",
903
+ httpError: "HTTP {status}: {message}",
904
+ unknownError: "Unknown error",
905
+ previewRequestFailed: "Preview request failed ({status}).",
906
+ notAvailable: "n/a",
907
+ voiceLocal: "local",
908
+ voiceRemote: "remote",
909
+ voiceBrowserDefault: "browser default",
910
+ browserAvailable: {
911
+ one: "Browser TTS available ({count} voice detected).",
912
+ other: "Browser TTS available ({count} voices detected)."
913
+ },
914
+ pollyAvailable: {
915
+ one: "AWS Polly available ({count} matching voice, {engine} engine).",
916
+ other: "AWS Polly available ({count} matching voices, {engine} engine)."
917
+ },
918
+ googleAvailable: {
919
+ one: "Google Cloud TTS available ({count} matching voice).",
920
+ other: "Google Cloud TTS available ({count} matching voices)."
921
+ },
922
+ headerRowReservation: "Item header row reservation: {state}",
923
+ speedOptionsHelp: "Comma or semicolon-separated multipliers. Include 1 for Normal; leave empty to hide speed controls.",
924
+ usingSelectedVoice: "Using selected voice: {voice}",
925
+ autoVoice: "Best available voice (auto): {voice}",
926
+ autoVoiceWaiting: "Best available voice (auto): waiting for browser voices.",
927
+ previewHintBrowserSsml: "SSML is unsupported in Browser preview.",
928
+ previewHintGoogleSsml: "SSML preserved. Tracking disabled.",
929
+ previewHintCustom: "Tracking enabled when provider returns speech marks.",
930
+ previewHintTracking: "Tracking enabled while preview plays."
835
931
  }
836
932
  }
837
- }, k = "en-US", ye = /* @__PURE__ */ new Set([
933
+ }, k = "en-US", Ee = /* @__PURE__ */ new Set([
838
934
  "ar",
839
935
  "ckb",
840
936
  "dv",
@@ -850,7 +946,7 @@ var fe = {
850
946
  "ug",
851
947
  "ur",
852
948
  "yi"
853
- ]), ve = /* @__PURE__ */ new Set([
949
+ ]), Pe = /* @__PURE__ */ new Set([
854
950
  "zero",
855
951
  "one",
856
952
  "two",
@@ -861,7 +957,7 @@ var fe = {
861
957
  function _(e) {
862
958
  if (typeof e != "object" || e === null) return !1;
863
959
  const t = Object.keys(e);
864
- return t.length > 0 && t.every((i) => ve.has(i));
960
+ return t.length > 0 && t.every((i) => Pe.has(i));
865
961
  }
866
962
  function z(e) {
867
963
  try {
@@ -869,18 +965,18 @@ function z(e) {
869
965
  if (i?.direction === "rtl" || i?.direction === "ltr") return i.direction;
870
966
  } catch {
871
967
  }
872
- const t = w(e).split("-")[0] ?? "";
873
- return ye.has(t) ? "rtl" : "ltr";
968
+ const t = A(e).split("-")[0] ?? "";
969
+ return Ee.has(t) ? "rtl" : "ltr";
874
970
  }
875
- var G = class E {
971
+ var G = class C {
876
972
  constructor(t = {}) {
877
- g(this, "locale", void 0), g(this, "fallbackLocale", void 0), g(this, "catalogs", void 0), g(this, "customMessages", void 0), g(this, "loading", void 0), g(this, "listeners", /* @__PURE__ */ new Set()), g(this, "config", void 0), this.config = { ...t }, this.fallbackLocale = C(t.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[k, fe]]), this.customMessages = { ...t.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(t.locale) ?? "en-US";
973
+ f(this, "locale", void 0), f(this, "fallbackLocale", void 0), f(this, "catalogs", void 0), f(this, "customMessages", void 0), f(this, "loading", void 0), f(this, "listeners", /* @__PURE__ */ new Set()), f(this, "config", void 0), this.config = { ...t }, this.fallbackLocale = E(t.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[k, Ie]]), this.customMessages = { ...t.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(t.locale) ?? "en-US";
878
974
  }
879
975
  async initialize(t) {
880
976
  if (this.config = {
881
977
  ...this.config,
882
978
  ...t
883
- }, t.customMessages) for (const [i, s] of Object.entries(t.customMessages)) this.addCustomMessages(i, s);
979
+ }, t.customMessages) for (const [i, n] of Object.entries(t.customMessages)) this.addCustomMessages(i, n);
884
980
  await this.setLocale(t.locale ?? this.locale);
885
981
  }
886
982
  getLocale() {
@@ -889,17 +985,17 @@ var G = class E {
889
985
  async setLocale(t) {
890
986
  const i = this.resolveLocaleTag(t);
891
987
  if (!i) {
892
- this.locale = C(t) || "en-US", this.notify();
988
+ this.locale = E(t) || "en-US", this.notify();
893
989
  return;
894
990
  }
895
- if (!this.catalogs.has(i)) {
896
- const s = this.loading.get(i);
897
- if (s) await s;
991
+ if (!this.catalogs.has(i) && this.config.availableLocales?.includes(i)) {
992
+ const n = this.loading.get(i);
993
+ if (n) await n;
898
994
  else {
899
- const n = this.loadCatalog(i);
900
- this.loading.set(i, n);
995
+ const s = this.loadCatalog(i);
996
+ this.loading.set(i, s);
901
997
  try {
902
- await n;
998
+ await s;
903
999
  } finally {
904
1000
  this.loading.delete(i);
905
1001
  }
@@ -908,12 +1004,12 @@ var G = class E {
908
1004
  this.locale = i, this.notify();
909
1005
  }
910
1006
  t(t, i) {
911
- const s = this.lookup(t);
912
- return s === void 0 ? (this.config.onMissingKey?.(t, this.locale), t) : U(s, i);
1007
+ const n = this.lookup(t);
1008
+ return n === void 0 ? (this.config.onMissingKey?.(t, this.locale), t) : U(n, i);
913
1009
  }
914
1010
  plural(t, i) {
915
- const s = this.lookupNode(t);
916
- return s === void 0 || !_(s) ? this.t(t, i) : U(s[this.selectPluralCategory(i.count)] ?? s.other, i);
1011
+ const n = this.lookupNode(t);
1012
+ return n === void 0 || !_(n) ? this.t(t, i) : U(n[this.selectPluralCategory(i.count)] ?? n.other, i);
917
1013
  }
918
1014
  getDirection() {
919
1015
  return z(this.locale);
@@ -938,17 +1034,17 @@ var G = class E {
938
1034
  return this.lookup(t) !== void 0;
939
1035
  }
940
1036
  addCustomMessages(t, i) {
941
- const s = C(t);
942
- this.customMessages[s] = $(this.customMessages[s] ?? {}, i), this.notify();
1037
+ const n = E(t);
1038
+ this.customMessages[n] = j(this.customMessages[n] ?? {}, i), this.notify();
943
1039
  }
944
1040
  withLocale(t) {
945
- const i = this.resolveLocaleTag(t) ?? C(t);
1041
+ const i = this.resolveLocaleTag(t) ?? E(t);
946
1042
  if (i === this.locale) return this;
947
- const s = new E({
1043
+ const n = new C({
948
1044
  ...this.config,
949
1045
  locale: i
950
1046
  });
951
- return s.locale = i || "en-US", s.catalogs = this.catalogs, s.customMessages = this.customMessages, s.loading = this.loading, s;
1047
+ return n.locale = i || "en-US", n.catalogs = this.catalogs, n.customMessages = this.customMessages, n.loading = this.loading, n;
952
1048
  }
953
1049
  formatNumber(t, i) {
954
1050
  try {
@@ -967,29 +1063,29 @@ var G = class E {
967
1063
  getBundle(t = this.locale) {
968
1064
  const i = this.resolveLocaleTag(t);
969
1065
  if (!i) return;
970
- const s = this.catalogs.get(i);
971
- if (s)
1066
+ const n = this.catalogs.get(i);
1067
+ if (n)
972
1068
  return {
973
1069
  locale: i,
974
- translations: s,
1070
+ translations: n,
975
1071
  direction: z(i)
976
1072
  };
977
1073
  }
978
1074
  resolveLocaleTag(t) {
979
1075
  if (!t) return;
980
- const i = this.getAvailableLocales(), s = ge(t, i);
981
- if (s) return s;
982
- const n = w(t).split("-")[0];
983
- if (n)
984
- return i.find((o) => w(o).split("-")[0] === n);
1076
+ const i = this.getAvailableLocales(), n = Ae(t, i);
1077
+ if (n) return n;
1078
+ const s = A(t).split("-")[0];
1079
+ if (s)
1080
+ return i.find((o) => A(o).split("-")[0] === s);
985
1081
  }
986
1082
  async loadCatalog(t) {
987
1083
  const i = this.config.loadCatalog;
988
1084
  if (i)
989
1085
  try {
990
1086
  this.catalogs.set(t, await i(t));
991
- } catch (s) {
992
- throw new Error(`Failed to load i18n catalog for locale: ${t}`, { cause: s });
1087
+ } catch (n) {
1088
+ throw new Error(`Failed to load i18n catalog for locale: ${t}`, { cause: n });
993
1089
  }
994
1090
  }
995
1091
  lookupNode(t) {
@@ -999,9 +1095,9 @@ var G = class E {
999
1095
  this.customMessages[this.fallbackLocale],
1000
1096
  this.catalogs.get(this.fallbackLocale)
1001
1097
  ];
1002
- for (const s of i) {
1003
- const n = be(s, t);
1004
- if (n !== void 0) return n;
1098
+ for (const n of i) {
1099
+ const s = Ce(n, t);
1100
+ if (s !== void 0) return s;
1005
1101
  }
1006
1102
  }
1007
1103
  lookup(t) {
@@ -1010,14 +1106,14 @@ var G = class E {
1010
1106
  if (i !== void 0 && _(i)) return i.other;
1011
1107
  }
1012
1108
  selectPluralCategory(t) {
1013
- let i = E.pluralRules.get(this.locale);
1109
+ let i = C.pluralRules.get(this.locale);
1014
1110
  if (!i) {
1015
1111
  try {
1016
1112
  i = new Intl.PluralRules(this.locale);
1017
1113
  } catch {
1018
1114
  return t === 1 ? "one" : "other";
1019
1115
  }
1020
- E.pluralRules.set(this.locale, i);
1116
+ C.pluralRules.set(this.locale, i);
1021
1117
  }
1022
1118
  return i.select(t);
1023
1119
  }
@@ -1025,91 +1121,88 @@ var G = class E {
1025
1121
  for (const t of this.listeners) t();
1026
1122
  }
1027
1123
  };
1028
- g(G, "pluralRules", /* @__PURE__ */ new Map());
1029
- function C(e) {
1030
- return e ? e.trim().replace(/_/g, "-") : "";
1031
- }
1032
- function be(e, t) {
1124
+ f(G, "pluralRules", /* @__PURE__ */ new Map());
1125
+ function Ce(e, t) {
1033
1126
  if (!e) return;
1034
1127
  let i = e;
1035
- for (const s of t.split("."))
1036
- if (typeof i != "object" || i === null || (i = i[s], i === void 0)) return;
1128
+ for (const n of t.split("."))
1129
+ if (typeof i != "object" || i === null || (i = i[n], i === void 0)) return;
1037
1130
  return i;
1038
1131
  }
1039
1132
  function U(e, t) {
1040
- return t ? e.replace(/\{(\w+)\}/g, (i, s) => {
1041
- const n = t[s];
1042
- return n == null ? i : String(n);
1133
+ return t ? e.replace(/\{(\w+)\}/g, (i, n) => {
1134
+ const s = t[n];
1135
+ return s == null ? i : String(s);
1043
1136
  }) : e;
1044
1137
  }
1045
- function $(e, t) {
1138
+ function j(e, t) {
1046
1139
  const i = { ...e };
1047
- for (const [s, n] of Object.entries(t)) {
1048
- const o = i[s];
1049
- n && typeof n == "object" && o && typeof o == "object" ? i[s] = $(o, n) : i[s] = n;
1140
+ for (const [n, s] of Object.entries(t)) {
1141
+ const o = i[n];
1142
+ s && typeof s == "object" && o && typeof o == "object" ? i[n] = j(o, s) : i[n] = s;
1050
1143
  }
1051
1144
  return i;
1052
1145
  }
1053
- function Se(e = {}) {
1146
+ function ke(e = {}) {
1054
1147
  return new G({
1055
- loadCatalog: pe,
1056
- availableLocales: he,
1148
+ loadCatalog: Se,
1149
+ availableLocales: be,
1057
1150
  ...e
1058
1151
  });
1059
1152
  }
1060
- function v() {
1153
+ function S() {
1061
1154
  return Date.now();
1062
1155
  }
1063
1156
  function P(e) {
1064
1157
  return e.replace(/[^a-zA-Z0-9_-]/g, "-");
1065
1158
  }
1066
- function we(e) {
1159
+ function Re(e) {
1067
1160
  if (e.attemptId) return `aas_v1_${P(e.assessmentId)}_${P(e.attemptId)}`;
1068
- const t = j(), i = t ? Ae(t) : "anon";
1161
+ const t = W(), i = t ? Ne(t) : "anon";
1069
1162
  return `aas_v1_${P(e.assessmentId)}_${P(i)}`;
1070
1163
  }
1071
- function j() {
1164
+ function W() {
1072
1165
  try {
1073
1166
  return typeof window > "u" ? null : window.localStorage;
1074
1167
  } catch {
1075
1168
  return null;
1076
1169
  }
1077
1170
  }
1078
- function Ae(e) {
1171
+ function Ne(e) {
1079
1172
  const t = "pie:assessment-player:anonymous-device-id", i = e.getItem(t);
1080
1173
  if (i) return i;
1081
- const s = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
1082
- return e.setItem(t, s), s;
1174
+ const n = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
1175
+ return e.setItem(t, n), n;
1083
1176
  }
1084
- function Ie(e) {
1177
+ function Te(e) {
1085
1178
  if (!e) return [];
1086
1179
  const t = [], i = e.testParts || [];
1087
- return i.length > 0 ? (i.forEach((s, n) => {
1088
- (s.sections || []).forEach((o, r) => {
1180
+ return i.length > 0 ? (i.forEach((n, s) => {
1181
+ (n.sections || []).forEach((o, r) => {
1089
1182
  t.push({
1090
- stageIdentifier: s.identifier,
1091
- stageIndex: n,
1183
+ stageIdentifier: n.identifier,
1184
+ stageIndex: s,
1092
1185
  sectionIndex: t.length,
1093
- sectionIdentifier: o.identifier || `section-${n}-${r}`,
1186
+ sectionIdentifier: o.identifier || `section-${s}-${r}`,
1094
1187
  section: o
1095
1188
  });
1096
1189
  });
1097
- }), t) : ((e.sections || []).forEach((s, n) => {
1190
+ }), t) : ((e.sections || []).forEach((n, s) => {
1098
1191
  t.push({
1099
1192
  stageIdentifier: "default",
1100
1193
  stageIndex: 0,
1101
- sectionIndex: n,
1102
- sectionIdentifier: s.identifier || `section-${n}`,
1103
- section: s
1194
+ sectionIndex: s,
1195
+ sectionIdentifier: n.identifier || `section-${s}`,
1196
+ section: n
1104
1197
  });
1105
1198
  }), t);
1106
1199
  }
1107
- var Ce = class {
1200
+ var xe = class {
1108
1201
  constructor(e) {
1109
- this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.disposed = !1, this.storageContext = {
1202
+ this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.saveQueue = Promise.resolve(), this.disposed = !1, this.storageContext = {
1110
1203
  assessmentId: e.assessmentId,
1111
1204
  attemptId: e.attemptId
1112
- };
1205
+ }, this.initialSession = e.initialSession ? y(e.initialSession) : null;
1113
1206
  }
1114
1207
  emit(e) {
1115
1208
  if (!this.disposed)
@@ -1121,39 +1214,46 @@ var Ce = class {
1121
1214
  throw e.name = "AbortError", e;
1122
1215
  }
1123
1216
  handleError(e, t, i) {
1124
- const s = e instanceof Error ? e : new Error(String(e));
1125
- this.args.hooks?.onError?.(s, {
1217
+ const n = e instanceof Error ? e : new Error(String(e));
1218
+ this.args.hooks?.onError?.(n, {
1126
1219
  phase: t,
1127
1220
  details: i
1128
1221
  });
1129
1222
  }
1223
+ reportFailure(e, t) {
1224
+ try {
1225
+ this.disposed || (this.readiness = "error", t && this.handleError(e, t));
1226
+ } catch (i) {
1227
+ console.error("Assessment error hook failed", i);
1228
+ }
1229
+ }
1130
1230
  async getPersistenceStrategy() {
1131
1231
  if (this.persistenceStrategy) return this.persistenceStrategy;
1132
1232
  const e = { createDefaultPersistence: () => {
1133
- const t = j(), i = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
1233
+ const t = W(), { assessmentId: i, attemptId: n } = this.storageContext, s = n ? `pie:assessment-controller:v1:${i}:${n}` : null;
1134
1234
  return {
1135
1235
  async loadSession() {
1136
- if (!t) return null;
1137
- const s = t.getItem(i);
1138
- if (!s) return null;
1236
+ if (!t || !s) return null;
1237
+ const o = t.getItem(s);
1238
+ if (!o) return null;
1139
1239
  try {
1140
- return JSON.parse(s);
1240
+ return JSON.parse(o);
1141
1241
  } catch {
1142
1242
  return null;
1143
1243
  }
1144
1244
  },
1145
- async saveSession(s, n) {
1146
- t && t.setItem(i, JSON.stringify(n));
1245
+ async saveSession(o, r) {
1246
+ !t || !s || t.setItem(s, JSON.stringify(r));
1147
1247
  },
1148
1248
  async clearSession() {
1149
- t && t.removeItem(i);
1249
+ !t || !s || t.removeItem(s);
1150
1250
  }
1151
1251
  };
1152
1252
  } };
1153
1253
  return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(this.storageContext, e) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
1154
1254
  }
1155
1255
  async createDeliveryPlan() {
1156
- const e = { createDefaultDeliveryPlan: () => ({ sections: Ie(this.args.assessment) }) }, t = {
1256
+ const e = { createDefaultDeliveryPlan: () => ({ sections: Te(this.args.assessment) }) }, t = {
1157
1257
  assessmentId: this.args.assessmentId,
1158
1258
  attemptId: this.args.attemptId,
1159
1259
  assessment: this.args.assessment
@@ -1163,8 +1263,8 @@ var Ce = class {
1163
1263
  ensureSession() {
1164
1264
  if (this.session) return this.session;
1165
1265
  const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
1166
- return this.session = V({
1167
- assessmentAttemptSessionIdentifier: we({
1266
+ return this.session = Q({
1267
+ assessmentAttemptSessionIdentifier: Re({
1168
1268
  assessmentId: this.args.assessmentId,
1169
1269
  attemptId: this.args.attemptId
1170
1270
  }),
@@ -1183,12 +1283,7 @@ var Ce = class {
1183
1283
  const t = await this.createDeliveryPlan();
1184
1284
  this.assertActive(), this.deliveryPlan = t, this.ensureSession(), e = null, await this.hydrate(), this.assertActive(), this.readiness = "ready";
1185
1285
  } catch (t) {
1186
- try {
1187
- this.disposed || (this.readiness = "error", e && this.handleError(t, e));
1188
- } catch (i) {
1189
- console.error("Assessment error hook failed", i);
1190
- }
1191
- throw t;
1286
+ throw this.reportFailure(t, e), t;
1192
1287
  }
1193
1288
  }
1194
1289
  async hydrate() {
@@ -1197,18 +1292,15 @@ var Ce = class {
1197
1292
  await this.args.hooks?.onBeforeAssessmentHydrate?.(this.storageContext), this.assertActive();
1198
1293
  const e = await this.getPersistenceStrategy();
1199
1294
  this.assertActive();
1200
- const t = await e.loadSession(this.storageContext);
1201
- this.assertActive(), t && (this.session = t), this.ensureSession(), this.readiness = "ready", t && this.emit({
1295
+ const t = this.initialSession;
1296
+ this.initialSession = null;
1297
+ const i = t ?? await e.loadSession(this.storageContext);
1298
+ this.assertActive(), i && (this.session = i), this.ensureSession(), this.readiness = "ready", i && this.emit({
1202
1299
  type: "assessment-session-applied",
1203
- timestamp: v()
1300
+ timestamp: S()
1204
1301
  }), this.assertActive();
1205
1302
  } catch (e) {
1206
- try {
1207
- this.disposed || (this.readiness = "error", this.handleError(e, "session-load"));
1208
- } catch (t) {
1209
- console.error("Assessment error hook failed", t);
1210
- }
1211
- throw e;
1303
+ throw this.reportFailure(e, "session-load"), e;
1212
1304
  }
1213
1305
  }
1214
1306
  dispose() {
@@ -1223,13 +1315,19 @@ var Ce = class {
1223
1315
  async persist() {
1224
1316
  this.assertActive();
1225
1317
  try {
1226
- const e = await this.getPersistenceStrategy();
1227
- if (this.disposed || (await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), this.disposed)) return;
1228
- await e.saveSession(this.storageContext, this.session);
1318
+ await this.save();
1229
1319
  } catch (e) {
1230
1320
  this.disposed || this.handleError(e, "session-save");
1231
1321
  }
1232
1322
  }
1323
+ save() {
1324
+ const e = this.saveQueue.then(async () => {
1325
+ const t = await this.getPersistenceStrategy();
1326
+ this.disposed || (await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), !this.disposed && await t.saveSession(this.storageContext, this.session));
1327
+ });
1328
+ return this.saveQueue = e.catch(() => {
1329
+ }), e;
1330
+ }
1233
1331
  getSession() {
1234
1332
  return this.session;
1235
1333
  }
@@ -1260,29 +1358,29 @@ var Ce = class {
1260
1358
  if (this.disposed) return !1;
1261
1359
  const t = this.buildNavigationSnapshot();
1262
1360
  if (e < 0 || e >= t.totalSections) return !1;
1263
- const i = t.currentSectionId, s = this.deliveryPlan.sections[e];
1264
- this.session = J(this.ensureSession(), {
1361
+ const i = t.currentSectionId, n = this.deliveryPlan.sections[e];
1362
+ this.session = K(this.ensureSession(), {
1265
1363
  currentSectionIndex: e,
1266
- currentSectionIdentifier: s?.sectionIdentifier
1364
+ currentSectionIdentifier: n?.sectionIdentifier
1267
1365
  });
1268
- const n = this.buildNavigationSnapshot();
1366
+ const s = this.buildNavigationSnapshot();
1269
1367
  return this.emit({
1270
1368
  type: "assessment-route-changed",
1271
- timestamp: v(),
1272
- currentSectionIndex: n.currentSectionIndex,
1273
- totalSections: n.totalSections,
1274
- currentSectionId: n.currentSectionId,
1369
+ timestamp: S(),
1370
+ currentSectionIndex: s.currentSectionIndex,
1371
+ totalSections: s.totalSections,
1372
+ currentSectionId: s.currentSectionId,
1275
1373
  previousSectionId: i,
1276
- canNext: n.canNext,
1277
- canPrevious: n.canPrevious
1374
+ canNext: s.canNext,
1375
+ canPrevious: s.canPrevious
1278
1376
  }), this.disposed || (this.emit({
1279
1377
  type: "assessment-session-changed",
1280
- timestamp: v()
1378
+ timestamp: S()
1281
1379
  }), this.disposed) ? !1 : (this.emit({
1282
1380
  type: "assessment-progress-changed",
1283
- timestamp: v(),
1381
+ timestamp: S(),
1284
1382
  visitedSectionCount: this.ensureSession().navigationState.visitedSectionIdentifiers.length,
1285
- totalSections: n.totalSections
1383
+ totalSections: s.totalSections
1286
1384
  }), !0);
1287
1385
  }
1288
1386
  navigateTo(e) {
@@ -1299,11 +1397,17 @@ var Ce = class {
1299
1397
  return this.setIndex(e.currentSectionIndex - 1);
1300
1398
  }
1301
1399
  async submit() {
1302
- this.assertActive(), this.submitted = !0, this.emit({
1400
+ this.assertActive();
1401
+ try {
1402
+ await this.save();
1403
+ } catch (e) {
1404
+ throw this.disposed || this.handleError(e, "session-save"), e;
1405
+ }
1406
+ this.disposed || (this.submitted = !0, this.emit({
1303
1407
  type: "assessment-submission-state-changed",
1304
- timestamp: v(),
1408
+ timestamp: S(),
1305
1409
  submitted: !0
1306
- }), await this.persist();
1410
+ }));
1307
1411
  }
1308
1412
  subscribe(e) {
1309
1413
  return this.disposed ? () => {
@@ -1320,15 +1424,15 @@ var Ce = class {
1320
1424
  return this.disposed ? null : this.ensureSession().sectionSessions[e]?.session || null;
1321
1425
  }
1322
1426
  updateSectionSession(e, t) {
1323
- this.disposed || (this.session = K(this.ensureSession(), {
1427
+ this.disposed || (this.session = Y(this.ensureSession(), {
1324
1428
  sectionIdentifier: e,
1325
1429
  sectionSession: t
1326
1430
  }), this.emit({
1327
1431
  type: "assessment-session-changed",
1328
- timestamp: v()
1432
+ timestamp: S()
1329
1433
  }));
1330
1434
  }
1331
- }, p = {
1435
+ }, g = {
1332
1436
  controllerReady: "assessment-controller-ready",
1333
1437
  navigationRequested: "assessment-navigation-requested",
1334
1438
  routeChanged: "assessment-route-changed",
@@ -1338,31 +1442,35 @@ var Ce = class {
1338
1442
  submissionStateChanged: "assessment-submission-state-changed",
1339
1443
  error: "assessment-error"
1340
1444
  };
1341
- function Pe(e, t) {
1342
- return !e?.delivery || e.delivery.enabled === !1 || !t || e.delivery.assignmentId !== void 0 ? e : {
1343
- ...e,
1344
- delivery: {
1345
- ...e.delivery,
1346
- assignmentId: t
1347
- }
1348
- };
1349
- }
1350
- function Ee(e) {
1351
- const { sectionPlayerRuntime: t, playerType: i, attemptId: s, env: n, coordinator: o } = e, r = t?.player && typeof t.player == "object" ? {
1445
+ function Le(e) {
1446
+ const { sectionPlayerRuntime: t, playerType: i, assessmentId: n, env: s, coordinator: o } = e, r = t?.player && typeof t.player == "object" ? {
1352
1447
  ...t.player,
1353
- backend: Pe(t.player.backend ? b(t.player.backend) : void 0, s)
1448
+ backend: t.player.backend ? y(t.player.backend) : void 0
1354
1449
  } : t?.player;
1355
1450
  return {
1356
1451
  playerType: i,
1357
- ...n ? { env: n } : {},
1452
+ ...n ? { assessmentId: n } : {},
1453
+ ...s ? { env: s } : {},
1358
1454
  ...o ? { coordinator: o } : {},
1359
1455
  ...t || {},
1360
1456
  ...r !== void 0 ? { player: r } : {}
1361
1457
  };
1362
1458
  }
1363
- var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe = class extends HTMLElement {
1459
+ function O(e) {
1460
+ return !!e && typeof e == "object";
1461
+ }
1462
+ function N(e, t) {
1463
+ if (Object.is(e, t)) return !0;
1464
+ if (Array.isArray(e) || Array.isArray(t))
1465
+ return !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((n, s) => N(n, t[s]));
1466
+ if (!O(e) || !O(t)) return !1;
1467
+ const i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
1468
+ for (const n of i) if (!N(e[n], t[n])) return !1;
1469
+ return !0;
1470
+ }
1471
+ var De = "pie-section-player-splitpane", Me = "pie-section-player-vertical", Fe = class extends HTMLElement {
1364
1472
  constructor(...e) {
1365
- super(...e), this._assessmentId = "", this._attemptId = "", this._locale = "", this._assessment = null, this._env = null, this._coordinator = null, this._hooks = null, this._showNavigation = !0, this._sectionPlayerLayout = "splitpane", this._playerType = "iife", this._debug = void 0, this.controller = null, this.initializingController = null, this.generation = 0, this.reconcileQueued = !1, this.controllerWaiters = /* @__PURE__ */ new Set(), this.i18n = Se(), this.sectionHost = null, this.sectionControllerRef = null, this.sectionSessionReady = !1, this.containerRef = null, this.announcer = null, this.restoreFocusOnRender = !1, this._sectionPlayerRuntime = null, this.readiness = { phase: "bootstrapping" };
1473
+ super(...e), this._assessmentId = "", this._attemptId = "", this._locale = "", this._assessment = null, this._env = null, this._coordinator = null, this._hooks = null, this.pendingSession = null, this._showNavigation = !0, this._sectionPlayerLayout = "splitpane", this._playerType = "iife", this._debug = void 0, this.controller = null, this.initializingController = null, this.generation = 0, this.reconcileQueued = !1, this.controllerWaiters = /* @__PURE__ */ new Set(), this.i18n = ke(), this.sectionHost = null, this.sectionControllerRef = null, this.sectionSessionReady = !1, this.containerRef = null, this.announcer = null, this.restoreFocusOnRender = !1, this._sectionPlayerRuntime = null, this.readiness = { phase: "bootstrapping" };
1366
1474
  }
1367
1475
  static get observedAttributes() {
1368
1476
  return [
@@ -1399,6 +1507,13 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1399
1507
  set hooks(e) {
1400
1508
  this._hooks !== e && (this._hooks = e, this.queueReconciliation());
1401
1509
  }
1510
+ get session() {
1511
+ return this.controller ? y(this.controller.getSession()) : this.pendingSession;
1512
+ }
1513
+ set session(e) {
1514
+ const t = e ?? null;
1515
+ t !== this.pendingSession && (t && this.controller && N(t, this.controller.getSession()) || (this.pendingSession = t, this.queueReconciliation()));
1516
+ }
1402
1517
  get locale() {
1403
1518
  return this._locale;
1404
1519
  }
@@ -1498,67 +1613,68 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1498
1613
  return;
1499
1614
  }
1500
1615
  this.readiness = { phase: "bootstrapping" }, this.renderEmptyState();
1501
- const e = this.generation, t = this.hooks, i = () => this.isConnected && this.generation === e, s = new Ce({
1616
+ const e = this.generation, t = this.hooks, i = () => this.isConnected && this.generation === e, n = this.pendingSession, s = new xe({
1502
1617
  assessmentId: this.assessmentId,
1503
1618
  attemptId: this.attemptId || void 0,
1504
1619
  assessment: this.assessment,
1620
+ initialSession: n,
1505
1621
  hooks: {
1506
1622
  ...t,
1507
- onError: (n, o) => {
1623
+ onError: (o, r) => {
1508
1624
  if (i())
1509
1625
  try {
1510
- t?.onError?.(n, o);
1626
+ t?.onError?.(o, r);
1511
1627
  } finally {
1512
- i() && o.phase === "session-load" && this.controller === s && (this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(p.error, { error: n }));
1628
+ i() && r.phase === "session-load" && this.controller === s && (this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(g.error, { error: o }));
1513
1629
  }
1514
1630
  }
1515
1631
  }
1516
1632
  });
1517
- this.initializingController = s, this.unsubscribeController = s.subscribe((n) => {
1633
+ this.initializingController = s, this.unsubscribeController = s.subscribe((o) => {
1518
1634
  if (i()) {
1519
- if (n.type === "assessment-route-changed") {
1520
- if (this.syncCurrentSectionSessionIntoAssessment(), !i() || (this.cleanupTtsForSectionNavigation(n), !i()) || (this.dispatch(p.routeChanged, n), !i())) return;
1635
+ if (o.type === "assessment-route-changed") {
1636
+ if (this.syncCurrentSectionSessionIntoAssessment(), !i() || (this.cleanupTtsForSectionNavigation(o), !i()) || (this.dispatch(g.routeChanged, o), !i())) return;
1521
1637
  this.restoreFocusOnRender = !0, this.render(!1);
1522
1638
  }
1523
- n.type === "assessment-session-applied" && this.dispatch(p.sessionApplied, n), n.type === "assessment-session-changed" && this.dispatch(p.sessionChanged, n), n.type === "assessment-progress-changed" && this.dispatch(p.progressChanged, n), n.type === "assessment-submission-state-changed" && this.dispatch(p.submissionStateChanged, n);
1639
+ o.type === "assessment-session-applied" && this.dispatch(g.sessionApplied, o), o.type === "assessment-session-changed" && this.dispatch(g.sessionChanged, o), o.type === "assessment-progress-changed" && this.dispatch(g.progressChanged, o), o.type === "assessment-submission-state-changed" && this.dispatch(g.submissionStateChanged, o);
1524
1640
  }
1525
1641
  });
1526
1642
  try {
1527
1643
  if (await s.initialize(), !i()) return;
1528
- this.initializingController = null, this.controller = s, this.readiness = { phase: "ready" }, this.render(), this.settleControllerWaiters(s);
1529
- const n = (o) => {
1644
+ this.pendingSession === n && (this.pendingSession = null), this.initializingController = null, this.controller = s, this.readiness = { phase: "ready" }, this.render(), this.settleControllerWaiters(s);
1645
+ const o = (r) => {
1530
1646
  if (i()) {
1531
1647
  try {
1532
- t?.onError?.(o instanceof Error ? o : new Error(String(o)), { phase: "controller-init" });
1533
- } catch (r) {
1534
- console.error("Assessment error hook failed", r);
1648
+ t?.onError?.(r instanceof Error ? r : new Error(String(r)), { phase: "controller-init" });
1649
+ } catch (a) {
1650
+ console.error("Assessment error hook failed", a);
1535
1651
  }
1536
- i() && this.dispatch(p.error, { error: o });
1652
+ i() && this.dispatch(g.error, { error: r });
1537
1653
  }
1538
1654
  };
1539
1655
  try {
1540
- Promise.resolve(t?.onAssessmentControllerReady?.(s)).catch(n);
1541
- } catch (o) {
1542
- n(o);
1656
+ Promise.resolve(t?.onAssessmentControllerReady?.(s)).catch(o);
1657
+ } catch (r) {
1658
+ o(r);
1543
1659
  }
1544
- i() && this.dispatch(p.controllerReady, { controller: s });
1545
- } catch (n) {
1660
+ i() && this.dispatch(g.controllerReady, { controller: s });
1661
+ } catch (o) {
1546
1662
  if (!i()) return;
1547
- this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(p.error, { error: n });
1663
+ this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(g.error, { error: o });
1548
1664
  }
1549
1665
  }
1550
1666
  resolveInstrumentationProvider() {
1551
- return ce({
1667
+ return fe({
1552
1668
  runtimePlayer: this.sectionPlayerRuntime?.player,
1553
1669
  component: "pie-assessment-player-default"
1554
1670
  });
1555
1671
  }
1556
1672
  attachInstrumentationBridge() {
1557
- this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = se({
1673
+ this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = he({
1558
1674
  host: this,
1559
1675
  instrumentationProvider: this.resolveInstrumentationProvider(),
1560
1676
  component: "pie-assessment-player-default",
1561
- eventMap: de,
1677
+ eventMap: ye,
1562
1678
  staticAttributes: {
1563
1679
  instrumentationLayer: "assessment",
1564
1680
  assessmentId: this.assessmentId,
@@ -1574,8 +1690,8 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1574
1690
  createStatusContent(e, t) {
1575
1691
  const i = document.createElement("div");
1576
1692
  i.className = "pie-assessment-player-empty", i.tabIndex = -1;
1577
- const s = document.createElement("style");
1578
- s.textContent = `
1693
+ const n = document.createElement("style");
1694
+ n.textContent = `
1579
1695
  .pie-assessment-player-empty { display: grid; justify-items: start; gap: 0.75rem; padding: 1rem; }
1580
1696
  .pie-assessment-player-status-message { margin: 0; }
1581
1697
  .pie-assessment-player-retry {
@@ -1595,9 +1711,9 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1595
1711
  outline: 2px solid var(--pie-button-focus-outline, var(--pie-primary, #0066cc));
1596
1712
  outline-offset: 2px;
1597
1713
  }
1598
- `, i.appendChild(s);
1599
- const n = document.createElement("p");
1600
- if (n.className = "pie-assessment-player-status-message", n.setAttribute("role", t ? "alert" : "status"), n.dataset.pieMessageKey = e, n.textContent = this.i18n.t(e), i.appendChild(n), t) {
1714
+ `, i.appendChild(n);
1715
+ const s = document.createElement("p");
1716
+ if (s.className = "pie-assessment-player-status-message", s.setAttribute("role", t ? "alert" : "status"), s.dataset.pieMessageKey = e, s.textContent = this.i18n.t(e), i.appendChild(s), t) {
1601
1717
  const o = document.createElement("button");
1602
1718
  o.type = "button", o.className = "pie-assessment-player-retry", o.textContent = this.i18n.t("common.retry"), o.addEventListener("click", t), i.appendChild(o);
1603
1719
  }
@@ -1626,18 +1742,18 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1626
1742
  t.next,
1627
1743
  this.sectionHost
1628
1744
  ];
1629
- for (const s of i)
1630
- if (s && !(s instanceof HTMLButtonElement && s.disabled) && (s.focus(), document.activeElement === s))
1745
+ for (const n of i)
1746
+ if (n && !(n instanceof HTMLButtonElement && n.disabled) && (n.focus(), document.activeElement === n))
1631
1747
  return;
1632
1748
  }
1633
1749
  buildSectionPlayerTag() {
1634
- return this.sectionPlayerLayout === "vertical" ? Re : ke;
1750
+ return this.sectionPlayerLayout === "vertical" ? Me : De;
1635
1751
  }
1636
1752
  buildSectionRuntime() {
1637
- return Ee({
1753
+ return Le({
1638
1754
  sectionPlayerRuntime: this.sectionPlayerRuntime,
1639
1755
  playerType: this.playerType,
1640
- attemptId: this.attemptId || void 0,
1756
+ assessmentId: this.assessmentId || void 0,
1641
1757
  env: this.env,
1642
1758
  coordinator: this.coordinator
1643
1759
  });
@@ -1649,25 +1765,17 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1649
1765
  cleanupTtsForSectionNavigation(e) {
1650
1766
  if (e.currentSectionId && e.previousSectionId && e.currentSectionId === e.previousSectionId) return;
1651
1767
  const t = this.coordinator, i = t?.ttsService;
1652
- if (!i) return;
1653
- const s = (n) => {
1654
- t?.reportFrameworkError?.(Q({
1655
- kind: "tts-init",
1656
- source: "AssessmentPlayerDefaultElement.cleanupTtsForSectionNavigation",
1657
- error: n,
1658
- recoverable: !0
1659
- }));
1660
- };
1661
- try {
1662
- i.stop?.();
1663
- } catch (n) {
1664
- s(n);
1665
- }
1666
- try {
1667
- i.requestControlHandoff?.();
1668
- } catch (n) {
1669
- s(n);
1670
- }
1768
+ if (i)
1769
+ try {
1770
+ i.stop();
1771
+ } catch (n) {
1772
+ t?.reportFrameworkError?.(J({
1773
+ kind: "tts-init",
1774
+ source: "AssessmentPlayerDefaultElement.cleanupTtsForSectionNavigation",
1775
+ error: n,
1776
+ recoverable: !0
1777
+ }));
1778
+ }
1671
1779
  }
1672
1780
  syncCurrentSectionSessionIntoAssessment() {
1673
1781
  const e = this.controller;
@@ -1675,38 +1783,34 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1675
1783
  const t = this.sectionControllerRef;
1676
1784
  if (!t?.getSession) return;
1677
1785
  const i = this.sectionHost?.firstElementChild?.getAttribute("section-id");
1678
- i && e.updateSectionSession(i, b(t.getSession()));
1786
+ i && e.updateSectionSession(i, y(t.getSession()));
1679
1787
  }
1680
- attachSectionControllerReadyListener(e, t) {
1681
- const i = e, s = this.generation, n = this.sectionHost, o = this.controller, r = b(o.getSectionSession(t)), a = () => this.isConnected && this.generation === s && this.sectionHost === n && this.controller === o;
1682
- n.setAttribute("aria-busy", "true"), i.inert = !0;
1788
+ attachSectionControllerReadyListener(e, t, i) {
1789
+ const n = e, s = this.generation, o = this.sectionHost, r = this.controller, a = () => this.isConnected && this.generation === s && this.sectionHost === o && this.controller === r;
1790
+ o.setAttribute("aria-busy", "true"), n.inert = !0;
1683
1791
  let h;
1684
1792
  new Promise((c) => {
1685
- let m = !1;
1686
- const u = (A) => {
1687
- m || (m = !0, clearTimeout(f), i.removeEventListener(N.stageChange, l), c(A));
1688
- }, l = (A) => {
1689
- if (A.target !== i) return;
1690
- const { stage: x, status: W } = A.detail;
1691
- W === "failed" || x === "disposed" ? u(null) : x === "engine-ready" && u(i.getSectionController?.() || null);
1692
- }, f = setTimeout(() => u(null), 5e3);
1693
- i.addEventListener(N.stageChange, l), h = () => u(null);
1793
+ let p = !1;
1794
+ const u = (v) => {
1795
+ p || (p = !0, clearTimeout(m), n.removeEventListener("pie-stage-change", l), c(v));
1796
+ }, l = (v) => {
1797
+ if (v.target !== n) return;
1798
+ const { stage: T, status: V } = v.detail;
1799
+ V === "failed" || T === "disposed" ? u(null) : T === "engine-ready" && u(n.getSectionController?.() || null);
1800
+ }, m = setTimeout(() => u(null), 5e3);
1801
+ n.addEventListener("pie-stage-change", l), h = () => u(null);
1694
1802
  }).then(async (c) => {
1695
1803
  if (a()) {
1696
1804
  if (!c) throw new Error("Section controller did not become ready");
1697
- if (r) {
1698
- if (!c.applySession) throw new Error("Section controller cannot restore its saved session");
1699
- await c.applySession(r, { mode: "replace" });
1700
- }
1701
- a() && (this.sectionControllerRef = c, this.sectionSessionReady = !0, i.inert = !1, n.setAttribute("aria-busy", "false"));
1805
+ a() && (this.sectionControllerRef = c, this.sectionSessionReady = !0, n.inert = !1, o.setAttribute("aria-busy", "false"));
1702
1806
  }
1703
1807
  }).catch((c) => {
1704
1808
  if (!a()) return;
1705
1809
  this.detachSectionListeners?.(), this.detachSectionListeners = void 0, this.sectionControllerRef = null, this.sectionSessionReady = !1;
1706
- const m = n.contains(document.activeElement), u = this.createStatusContent(r ? "player.assessment.restoreFailed" : "player.assessment.loadFailed", () => {
1810
+ const p = o.contains(document.activeElement), u = this.createStatusContent(i ? "player.assessment.restoreFailed" : "player.assessment.loadFailed", () => {
1707
1811
  this.restoreFocusOnRender = this.contains(document.activeElement), this.render();
1708
1812
  });
1709
- n.replaceChildren(u), n.setAttribute("aria-busy", "false"), m && u.focus();
1813
+ o.replaceChildren(u), o.setAttribute("aria-busy", "false"), p && u.focus();
1710
1814
  try {
1711
1815
  this.hooks?.onError?.(c instanceof Error ? c : new Error(String(c)), {
1712
1816
  phase: "navigation",
@@ -1715,7 +1819,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1715
1819
  } catch (l) {
1716
1820
  console.error("Assessment error hook failed", l);
1717
1821
  }
1718
- a() && this.dispatch(p.error, { error: c });
1822
+ a() && this.dispatch(g.error, { error: c });
1719
1823
  });
1720
1824
  const d = () => {
1721
1825
  a() && this.syncCurrentSectionSessionIntoAssessment();
@@ -1731,10 +1835,10 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1731
1835
  this.detachSectionListeners?.(), this.detachSectionListeners = void 0;
1732
1836
  const i = this.controller;
1733
1837
  this.attachInstrumentationBridge();
1734
- const s = this.restoreFocusOnRender || this.containerRef?.classList.contains("pie-assessment-player-empty") ? this.captureFocusIntent() : null;
1838
+ const n = this.restoreFocusOnRender || this.containerRef?.classList.contains("pie-assessment-player-empty") ? this.captureFocusIntent() : null;
1735
1839
  this.restoreFocusOnRender = !1, this.ensureAnnouncer(), this.sectionControllerRef = null, this.sectionSessionReady = !1;
1736
- const n = document.createElement("div");
1737
- n.className = "pie-assessment-player-default";
1840
+ const s = document.createElement("div");
1841
+ s.className = "pie-assessment-player-default";
1738
1842
  const o = document.createElement("style");
1739
1843
  o.textContent = `
1740
1844
  :host {
@@ -1757,7 +1861,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1757
1861
  padding: 0.5rem;
1758
1862
  border: 1px solid var(--pie-border-light, #e5e7eb);
1759
1863
  border-radius: 0.375rem;
1760
- background: var(--pie-background-light, var(--pie-background, #fff));
1864
+ background: var(--pie-background, #fff);
1761
1865
  }
1762
1866
  .pie-assessment-player-navigation[hidden] { display: none; }
1763
1867
  .pie-assessment-player-current-position {
@@ -1772,7 +1876,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1772
1876
  padding: 0.35rem 0.75rem;
1773
1877
  border: 1px solid var(--pie-border-light, #e5e7eb);
1774
1878
  border-radius: 0.375rem;
1775
- background: var(--pie-background-light, var(--pie-background, #fff));
1879
+ background: var(--pie-background, #fff);
1776
1880
  cursor: pointer;
1777
1881
  }
1778
1882
  .pie-assessment-player-nav-btn:disabled {
@@ -1784,7 +1888,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1784
1888
  height: 100%;
1785
1889
  overflow: hidden;
1786
1890
  }
1787
- `, n.appendChild(o);
1891
+ `, s.appendChild(o);
1788
1892
  const r = this.getSnapshot(), a = r.navigation.totalSections > 0 ? this.i18n.t("player.assessment.sectionPosition", {
1789
1893
  position: r.navigation.currentIndex + 1,
1790
1894
  total: r.navigation.totalSections
@@ -1795,25 +1899,26 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1795
1899
  u.className = "pie-assessment-player-navigation", u.hidden = !R(this.showNavigation, !0);
1796
1900
  const l = document.createElement("div");
1797
1901
  l.className = "pie-assessment-player-current-position", l.textContent = a;
1798
- const f = document.createElement("div");
1799
- f.className = "pie-assessment-player-nav-controls", h = document.createElement("button"), h.type = "button", h.className = "pie-assessment-player-nav-btn", h.setAttribute("data-pie-navigation", "previous"), h.textContent = this.i18n.t("common.back"), h.disabled = !r.navigation.canPrevious, h.addEventListener("click", () => {
1902
+ const m = document.createElement("div");
1903
+ m.className = "pie-assessment-player-nav-controls", h = document.createElement("button"), h.type = "button", h.className = "pie-assessment-player-nav-btn", h.setAttribute("data-pie-navigation", "previous"), h.textContent = this.i18n.t("common.back"), h.disabled = !r.navigation.canPrevious, h.addEventListener("click", () => {
1800
1904
  this.navigatePrevious();
1801
1905
  }), d = document.createElement("button"), d.type = "button", d.className = "pie-assessment-player-nav-btn", d.setAttribute("data-pie-navigation", "next"), d.textContent = this.i18n.t("common.next"), d.disabled = !r.navigation.canNext, d.addEventListener("click", () => {
1802
1906
  this.navigateNext();
1803
- }), f.appendChild(h), f.appendChild(d), u.appendChild(l), u.appendChild(f), n.appendChild(u);
1907
+ }), m.appendChild(h), m.appendChild(d), u.appendChild(l), u.appendChild(m), s.appendChild(u);
1804
1908
  }
1805
1909
  const c = document.createElement("div");
1806
1910
  c.className = "pie-assessment-player-section-host", c.setAttribute("role", "region"), c.setAttribute("aria-label", a), c.tabIndex = -1, this.sectionHost = c;
1807
- const m = i?.getCurrentSection() || null;
1808
- if (m) {
1911
+ const p = i?.getCurrentSection() || null;
1912
+ if (p) {
1809
1913
  const u = this.buildSectionPlayerTag(), l = document.createElement(u);
1810
- if (l.setAttribute("assessment-id", this.assessmentId), l.setAttribute("section-id", m.sectionIdentifier), this.attemptId && l.setAttribute("attempt-id", this.attemptId), this.locale && l.setAttribute("locale", this.locale), this.debug !== void 0 && this.debug !== null) {
1811
- const f = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
1812
- l.setAttribute("debug", f);
1914
+ if (l.setAttribute("section-id", p.sectionIdentifier), this.attemptId && l.setAttribute("attempt-id", this.attemptId), this.locale && l.setAttribute("locale", this.locale), this.debug !== void 0 && this.debug !== null) {
1915
+ const v = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
1916
+ l.setAttribute("debug", v);
1813
1917
  }
1814
- l.section = m.section, l.runtime = this.buildSectionRuntime(), l.hooks = { cardTitleFormatter: this.hooks?.cardTitleFormatter }, c.appendChild(l), this.attachSectionControllerReadyListener(l, m.sectionIdentifier);
1918
+ const m = y(i.getSectionSession(p.sectionIdentifier));
1919
+ l.section = p.section, m && (l.session = m), l.runtime = this.buildSectionRuntime(), l.hooks = { cardTitleFormatter: this.hooks?.cardTitleFormatter }, c.appendChild(l), this.attachSectionControllerReadyListener(l, p.sectionIdentifier, !!m);
1815
1920
  }
1816
- n.appendChild(c), this.swapContent(n), s && (this.applyFocusIntent(s, {
1921
+ s.appendChild(c), this.swapContent(s), n && (this.applyFocusIntent(n, {
1817
1922
  previous: h,
1818
1923
  next: d
1819
1924
  }), this.announceSectionChange(a));
@@ -1824,10 +1929,10 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1824
1929
  total: e.totalSections
1825
1930
  }) : this.i18n.t("player.assessment.noSections"), i = this.containerRef?.querySelector(".pie-assessment-player-navigation");
1826
1931
  i && (i.hidden = !R(this.showNavigation, !0), i.hidden && i.contains(document.activeElement) && this.sectionHost?.focus());
1827
- const s = this.containerRef?.querySelector(".pie-assessment-player-current-position");
1828
- s && (s.textContent = t);
1829
- const n = i?.querySelector('[data-pie-navigation="previous"]'), o = i?.querySelector('[data-pie-navigation="next"]');
1830
- n && (n.textContent = this.i18n.t("common.back")), o && (o.textContent = this.i18n.t("common.next")), this.sectionHost?.setAttribute("aria-label", t);
1932
+ const n = this.containerRef?.querySelector(".pie-assessment-player-current-position");
1933
+ n && (n.textContent = t);
1934
+ const s = i?.querySelector('[data-pie-navigation="previous"]'), o = i?.querySelector('[data-pie-navigation="next"]');
1935
+ s && (s.textContent = this.i18n.t("common.back")), o && (o.textContent = this.i18n.t("common.next")), this.sectionHost?.setAttribute("aria-label", t);
1831
1936
  const r = this.containerRef?.querySelector(".pie-assessment-player-status-message");
1832
1937
  r instanceof HTMLElement && r.dataset.pieMessageKey && (r.textContent = this.i18n.t(r.dataset.pieMessageKey));
1833
1938
  const a = this.containerRef?.querySelector(".pie-assessment-player-retry");
@@ -1881,15 +1986,15 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1881
1986
  return this.getSnapshot().progress;
1882
1987
  }
1883
1988
  navigateTo(e) {
1884
- const t = this.selectNavigation(), i = t.currentIndex, s = t.currentSectionId;
1885
- let n = i, o;
1989
+ const t = this.selectNavigation(), i = t.currentIndex, n = t.currentSectionId;
1990
+ let s = i, o;
1886
1991
  if (typeof e == "number")
1887
- n = e, o = this.controller?.getSectionAt(n)?.sectionIdentifier;
1992
+ s = e, o = this.controller?.getSectionAt(s)?.sectionIdentifier;
1888
1993
  else if (o = e, this.controller?.getCurrentSection()?.sectionIdentifier === o) return !0;
1889
- if (!this.dispatch(p.navigationRequested, {
1994
+ if (!this.dispatch(g.navigationRequested, {
1890
1995
  fromIndex: i,
1891
- toIndex: n,
1892
- fromSectionId: s,
1996
+ toIndex: s,
1997
+ fromSectionId: n,
1893
1998
  toSectionId: o,
1894
1999
  reason: "navigate-to"
1895
2000
  }, !0)) return !1;
@@ -1898,7 +2003,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1898
2003
  }
1899
2004
  navigateNext() {
1900
2005
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
1901
- if (!this.dispatch(p.navigationRequested, {
2006
+ if (!this.dispatch(g.navigationRequested, {
1902
2007
  fromIndex: e.currentIndex,
1903
2008
  toIndex: e.currentIndex + 1,
1904
2009
  fromSectionId: e.currentSectionId,
@@ -1910,7 +2015,7 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1910
2015
  }
1911
2016
  navigatePrevious() {
1912
2017
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
1913
- if (!this.dispatch(p.navigationRequested, {
2018
+ if (!this.dispatch(g.navigationRequested, {
1914
2019
  fromIndex: e.currentIndex,
1915
2020
  toIndex: e.currentIndex - 1,
1916
2021
  fromSectionId: e.currentSectionId,
@@ -1926,21 +2031,21 @@ var ke = "pie-section-player-splitpane", Re = "pie-section-player-vertical", xe
1926
2031
  async waitForAssessmentController(e = 5e3) {
1927
2032
  const t = this.getAssessmentController();
1928
2033
  return t || (!this.isConnected || this.controller || this.readiness.phase === "error" ? null : new Promise((i) => {
1929
- const s = (o) => {
1930
- clearTimeout(n), this.controllerWaiters.delete(s), i(o);
1931
- }, n = setTimeout(() => s(null), e);
1932
- this.controllerWaiters.add(s);
2034
+ const n = (o) => {
2035
+ clearTimeout(s), this.controllerWaiters.delete(n), i(o);
2036
+ }, s = setTimeout(() => n(null), e);
2037
+ this.controllerWaiters.add(n);
1933
2038
  }));
1934
2039
  }
1935
2040
  };
1936
- B("pie-assessment-player-default", xe, "assessment player default tag");
1937
- var Ne = class extends HTMLElement {
1938
- constructor(...e) {
1939
- super(...e), this.showNavigation = !0;
1940
- }
2041
+ H("pie-assessment-player-default", Fe, "assessment player default tag");
2042
+ var _e = class extends HTMLElement {
1941
2043
  static get observedAttributes() {
1942
2044
  return ["show-navigation"];
1943
2045
  }
2046
+ constructor() {
2047
+ super(), this.showNavigation = !0, this.attachShadow({ mode: "open" });
2048
+ }
1944
2049
  connectedCallback() {
1945
2050
  this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation, this.render();
1946
2051
  }
@@ -1948,9 +2053,7 @@ var Ne = class extends HTMLElement {
1948
2053
  e === "show-navigation" && (this.showNavigation = i), this.render();
1949
2054
  }
1950
2055
  render() {
1951
- const e = R(this.showNavigation, !0);
1952
- this.innerHTML = "";
1953
- const t = document.createElement("style");
2056
+ const e = R(this.showNavigation, !0), t = document.createElement("style");
1954
2057
  t.textContent = `
1955
2058
  :host {
1956
2059
  display: block;
@@ -1958,13 +2061,14 @@ var Ne = class extends HTMLElement {
1958
2061
  min-height: 0;
1959
2062
  }
1960
2063
  .pie-assessment-player-shell {
1961
- display: grid;
1962
- grid-template-rows: auto minmax(0, 1fr);
2064
+ display: flex;
2065
+ flex-direction: column;
1963
2066
  height: 100%;
1964
2067
  min-height: 0;
1965
2068
  gap: 0.5rem;
1966
2069
  }
1967
2070
  .pie-assessment-player-shell__body {
2071
+ flex: 1 1 0;
1968
2072
  min-height: 0;
1969
2073
  overflow: hidden;
1970
2074
  }
@@ -1974,13 +2078,13 @@ var Ne = class extends HTMLElement {
1974
2078
  const o = document.createElement("slot");
1975
2079
  o.name = "navigation", i.appendChild(o);
1976
2080
  }
1977
- const s = document.createElement("div");
1978
- s.className = "pie-assessment-player-shell__body";
1979
- const n = document.createElement("slot");
1980
- s.appendChild(n), i.appendChild(s), this.appendChild(t), this.appendChild(i);
2081
+ const n = document.createElement("div");
2082
+ n.className = "pie-assessment-player-shell__body";
2083
+ const s = document.createElement("slot");
2084
+ n.appendChild(s), i.appendChild(n), this.shadowRoot?.replaceChildren(t, i);
1981
2085
  }
1982
2086
  };
1983
- B("pie-assessment-player-shell", Ne, "assessment player shell tag");
2087
+ H("pie-assessment-player-shell", _e, "assessment player shell tag");
1984
2088
  export {
1985
- p as ASSESSMENT_PLAYER_PUBLIC_EVENTS
2089
+ g as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1986
2090
  };