@pie-players/pie-assessment-player 0.3.73 → 0.3.75

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,31 +1,12 @@
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 x } from "@pie-players/pie-section-player/contracts/public-events";
4
- import { coerceBooleanLike as L, defineCustomElementSafely as V } from "@pie-players/pie-players-shared";
5
- import { createNewAssessmentSession as re, frameworkErrorFromUnknown as ae, setCurrentSectionPosition as le, upsertSectionSession as ce } from "@pie-players/pie-assessment-toolkit";
6
- var S = (e) => {
1
+ import "@pie-players/pie-section-player";
2
+ import { coerceBooleanLike as R, defineCustomElementSafely as O } from "@pie-players/pie-players-shared";
3
+ import { createNewAssessmentSession as Q, frameworkErrorFromUnknown as J, setCurrentSectionPosition as K, upsertSectionSession as Y } from "@pie-players/pie-assessment-toolkit";
4
+ var y = (e) => {
7
5
  if (e === null || typeof e != "object") return e;
8
- if (Array.isArray(e)) return e.map(S);
6
+ if (Array.isArray(e)) return e.map(y);
9
7
  const t = {};
10
- for (const i in e) Object.hasOwn(e, i) && (t[i] = S(e[i]));
8
+ for (const i in e) Object.hasOwn(e, i) && (t[i] = y(e[i]));
11
9
  return t;
12
- }, Y = "https://proxy.pie-api.com", de = `${Y}/bundles/`;
13
- function W(e) {
14
- try {
15
- const t = {
16
- BASE_URL: "/",
17
- DEV: !1,
18
- MODE: "production",
19
- PROD: !0,
20
- SSR: !1
21
- }[e];
22
- if (typeof t == "string" && t.length > 0) return t;
23
- } catch {
24
- }
25
- }
26
- var nt = typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || W("PUBLIC_BUILDER_ORIGIN_URL") || Y, ue = typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || W("PUBLIC_BUILDER_BUNDLE_URL") || de, he = {
27
- retryDelayMs: 3e3,
28
- timeoutMs: 12e4
29
10
  };
30
11
  function w(e) {
31
12
  "@babel/helpers - typeof";
@@ -35,7 +16,7 @@ function w(e) {
35
16
  return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
36
17
  }, w(e);
37
18
  }
38
- function pe(e, t) {
19
+ function Z(e, t) {
39
20
  if (w(e) != "object" || !e) return e;
40
21
  var i = e[Symbol.toPrimitive];
41
22
  if (i !== void 0) {
@@ -45,106 +26,19 @@ function pe(e, t) {
45
26
  }
46
27
  return (t === "string" ? String : Number)(e);
47
28
  }
48
- function me(e) {
49
- var t = pe(e, "string");
29
+ function X(e) {
30
+ var t = Z(e, "string");
50
31
  return w(t) == "symbol" ? t : t + "";
51
32
  }
52
- function a(e, t, i) {
53
- return (t = me(t)) in e ? Object.defineProperty(e, t, {
33
+ function f(e, t, i) {
34
+ return (t = X(t)) in e ? Object.defineProperty(e, t, {
54
35
  value: i,
55
36
  enumerable: !0,
56
37
  configurable: !0,
57
38
  writable: !0
58
39
  }) : e[t] = i, e;
59
40
  }
60
- var D;
61
- (function(e) {
62
- e.SAVE = "save", e.MODEL = "model", e.SCORE = "score", e.MANUAL_SCORE = "manual-score";
63
- })(D || (D = {}));
64
- var _;
65
- (function(e) {
66
- e.AUTO = "auto", e.MANUAL = "manual";
67
- })(_ || (_ = {}));
68
- var U;
69
- (function(e) {
70
- e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
71
- })(U || (U = {}));
72
- var M;
73
- (function(e) {
74
- e.PENDING = "pending", e.IN_PROGRESS = "in_progress", e.COMPLETED = "completed", e.FAILED = "failed";
75
- })(M || (M = {}));
76
- var ge = class Q extends CustomEvent {
77
- constructor(t, i = !1) {
78
- super(Q.TYPE, {
79
- bubbles: !0,
80
- detail: {
81
- update: t,
82
- reset: i
83
- }
84
- }), a(this, "update", void 0), a(this, "reset", void 0), this.update = t, this.reset = i;
85
- }
86
- };
87
- a(ge, "TYPE", "model.updated");
88
- var fe = class J extends CustomEvent {
89
- constructor(t, i) {
90
- super(J.TYPE, {
91
- bubbles: !0,
92
- detail: {
93
- src: t,
94
- done: i
95
- }
96
- }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = i;
97
- }
98
- };
99
- a(fe, "TYPE", "delete.image");
100
- var ve = class K extends CustomEvent {
101
- constructor(t) {
102
- super(K.TYPE, {
103
- bubbles: !0,
104
- detail: t
105
- }), a(this, "handler", void 0), this.handler = t;
106
- }
107
- };
108
- a(ve, "TYPE", "insert.image");
109
- var ye = class Z extends CustomEvent {
110
- constructor(t, i) {
111
- super(Z.TYPE, {
112
- bubbles: !0,
113
- detail: {
114
- src: t,
115
- done: i
116
- }
117
- }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = i;
118
- }
119
- };
120
- a(ye, "TYPE", "delete.sound");
121
- var be = class X extends CustomEvent {
122
- constructor(t) {
123
- super(X.TYPE, {
124
- bubbles: !0,
125
- detail: t
126
- }), a(this, "handler", void 0), this.handler = t;
127
- }
128
- };
129
- a(be, "TYPE", "insert.sound");
130
- var Se = class ee extends CustomEvent {
131
- constructor(t, i) {
132
- super(ee.TYPE, {
133
- bubbles: !0,
134
- composed: !0,
135
- detail: {
136
- complete: i,
137
- component: t
138
- }
139
- }), a(this, "component", void 0), a(this, "complete", void 0), this.component = t, this.complete = i;
140
- }
141
- };
142
- a(Se, "TYPE", "session-changed");
143
- var F;
144
- (function(e) {
145
- e[e.ROOT = 0] = "ROOT", e[e.SUBJECT = 1] = "SUBJECT", e[e.LEVEL = 2] = "LEVEL", e[e.STANDARD = 3] = "STANDARD";
146
- })(F || (F = {}));
147
- function v(e, t) {
41
+ function H(e, t) {
148
42
  const i = `[${e}]`;
149
43
  return {
150
44
  debug: (s, ...n) => {
@@ -155,38 +49,35 @@ function v(e, t) {
155
49
  error: (s, ...n) => console.error(i, s, ...n)
156
50
  };
157
51
  }
158
- function y() {
52
+ function q() {
159
53
  return typeof window < "u" && window.PIE_DEBUG === !0;
160
54
  }
161
- var T;
162
- (function(e) {
163
- e.player = "player.js", e.clientPlayer = "client-player.js", e.editor = "editor.js";
164
- })(T || (T = {}));
165
- var B;
166
- (function(e) {
167
- e.loading = "loading", e.loaded = "loaded";
168
- })(B || (B = {}));
169
- var ot = v("pie-scoring", () => y()), rt = v("pie-initialize-element", () => y()), at = v("math-rendering", () => y()), lt = v("pie-updates", () => y()), ct = v("pie-initialization", () => y()), dt = he.timeoutMs, ut = {
170
- buildServiceBase: ue,
171
- bundleType: T.player,
172
- env: {
173
- mode: "gather",
174
- role: "student"
175
- }
176
- }, ht = v("pie-element-observer", () => y()), pt = v("asset-handler", () => y()), mt = v("authoring", () => y());
177
- function te(e) {
55
+ function G(e) {
178
56
  if (!e || typeof e != "object") return !1;
179
57
  const t = e;
180
58
  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";
181
59
  }
182
- var we = v("instrumentation-event-bridge", () => y());
183
- function Ae(e) {
184
- return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
60
+ var ee = H("instrumentation-event-bridge", () => q());
61
+ function te(e) {
62
+ if (e === null) return !0;
63
+ const t = typeof e;
64
+ if (t === "function" || t === "symbol") return !1;
65
+ if (t !== "object" || Array.isArray(e)) return !0;
66
+ const i = Object.getPrototypeOf(e);
67
+ return i === Object.prototype || i === null;
68
+ }
69
+ function ie(e) {
70
+ if (e && typeof e == "object") {
71
+ const t = {};
72
+ for (const [i, s] of Object.entries(e)) te(s) && (t[i] = s);
73
+ return t;
74
+ }
75
+ return typeof e > "u" ? {} : { value: e };
185
76
  }
186
- function Ee(e) {
187
- we.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
77
+ function se(e) {
78
+ ee.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
188
79
  }
189
- function Ie(e) {
80
+ function ne(e) {
190
81
  try {
191
82
  e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
192
83
  component: e.component,
@@ -196,62 +87,72 @@ function Ie(e) {
196
87
  } catch {
197
88
  }
198
89
  }
199
- function Pe(e) {
90
+ function oe(e) {
200
91
  if (!e.host || !e.eventMap.length) return () => {
201
92
  };
202
93
  if (!e.instrumentationProvider) return () => {
203
94
  };
204
- if (!te(e.instrumentationProvider))
205
- return e.debug && Ee(e.component), () => {
95
+ if (!G(e.instrumentationProvider))
96
+ return e.debug && se(e.component), () => {
206
97
  };
207
- const t = e.instrumentationProvider, i = [], s = Math.max(0, e.dedupeWindowMs ?? 0), n = /* @__PURE__ */ new Map(), o = (r, l) => {
208
- const p = [
209
- l.assessmentId,
210
- l.sectionId,
211
- l.attemptId,
212
- l.itemId,
213
- l.canonicalItemId,
214
- l.sourceRuntimeId
215
- ].map((u) => String(u ?? "")).join("|");
216
- return `${r.instrumentationEventName}|${p}`;
98
+ const t = e.instrumentationProvider, i = [], s = Math.max(0, e.dedupeWindowMs ?? 0), n = /* @__PURE__ */ new Map(), o = (r, a) => {
99
+ const h = [
100
+ a.assessmentId,
101
+ a.sectionId,
102
+ a.attemptId,
103
+ a.itemId,
104
+ a.canonicalItemId,
105
+ a.sourceRuntimeId
106
+ ].map((d) => String(d ?? "")).join("|");
107
+ return `${r.instrumentationEventName}|${h}`;
217
108
  };
218
109
  for (const r of e.eventMap) {
219
- const l = (p) => {
110
+ const a = (h) => {
220
111
  try {
221
- if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(p)) return;
222
- const u = Ae(p.detail), d = (/* @__PURE__ */ new Date()).toISOString(), g = {
223
- ...u,
112
+ if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(h)) return;
113
+ const d = ie(h.detail), c = (/* @__PURE__ */ new Date()).toISOString(), p = {
114
+ ...d,
224
115
  ...e.staticAttributes,
225
116
  component: e.component,
226
117
  sourceEventName: r.sourceEventName,
227
- timestamp: d
118
+ timestamp: c
228
119
  };
229
120
  if (s > 0) {
230
- const h = Date.now(), c = o(r, g), f = n.get(c);
231
- if (typeof f == "number" && h - f < s) return;
232
- n.set(c, h);
121
+ const u = Date.now(), l = o(r, p), m = n.get(l);
122
+ if (typeof m == "number" && u - m < s) return;
123
+ n.set(l, u);
233
124
  }
234
- t.trackEvent(r.instrumentationEventName, { ...g });
235
- } catch (u) {
236
- Ie({
125
+ t.trackEvent(r.instrumentationEventName, { ...p });
126
+ } catch (d) {
127
+ ne({
237
128
  provider: t,
238
129
  component: e.component,
239
- error: u,
130
+ error: d,
240
131
  sourceEventName: r.sourceEventName
241
132
  });
242
133
  }
243
134
  };
244
- e.host.addEventListener(r.sourceEventName, l), i.push(() => {
245
- e.host?.removeEventListener(r.sourceEventName, l);
135
+ e.host.addEventListener(r.sourceEventName, a), i.push(() => {
136
+ e.host?.removeEventListener(r.sourceEventName, a);
246
137
  });
247
138
  }
248
139
  return () => {
249
140
  for (const r of i) r();
250
141
  };
251
142
  }
252
- var Ce = class {
143
+ function T(e) {
144
+ const t = e;
145
+ return typeof t?.noticeError == "function" && typeof t.addPageAction == "function";
146
+ }
147
+ function b() {
148
+ if (typeof window > "u") return;
149
+ const { newrelic: e, NREUM: t } = window;
150
+ if (T(e)) return e;
151
+ if (T(t)) return t;
152
+ }
153
+ var re = class {
253
154
  constructor() {
254
- a(this, "initialized", !1), a(this, "config", void 0);
155
+ f(this, "initialized", !1), f(this, "config", void 0);
255
156
  }
256
157
  trackError(e, t) {
257
158
  if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
@@ -313,42 +214,42 @@ var Ce = class {
313
214
  transformAttributes(e) {
314
215
  return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
315
216
  }
316
- }, Re = class extends Ce {
217
+ }, ae = class extends re {
317
218
  constructor(...e) {
318
- super(...e), a(this, "providerId", "newrelic"), a(this, "providerName", "New Relic");
219
+ super(...e), f(this, "providerId", "newrelic"), f(this, "providerName", "New Relic");
319
220
  }
320
221
  async initialize(e) {
321
- this.config = e, typeof window < "u" && window.newrelic ? (this.initialized = !0, this.config?.debug && console.log("[NewRelicProvider] Initialized successfully")) : (this.config?.debug && console.warn("[NewRelicProvider] New Relic not available (window.newrelic not found)"), this.initialized = !1);
222
+ 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");
322
223
  }
323
224
  isReady() {
324
- return this.initialized && typeof window < "u" && !!window.newrelic;
225
+ return this.initialized && b() !== void 0;
325
226
  }
326
227
  destroy() {
327
228
  this.initialized = !1, this.config?.debug && console.log("[NewRelicProvider] Destroyed");
328
229
  }
329
230
  doTrackError(e, t) {
330
- window.newrelic.noticeError(e, t);
231
+ b()?.noticeError(e, t);
331
232
  }
332
233
  doTrackEvent(e, t) {
333
- window.newrelic.addPageAction(e, t);
234
+ b()?.addPageAction(e, t);
334
235
  }
335
236
  doSetUserContext(e, t) {
336
- const i = window.newrelic;
337
- if (i.setUserId && i.setUserId(e), t && i.setCustomAttribute) for (const [s, n] of Object.entries(t)) i.setCustomAttribute(s, n);
237
+ const i = b();
238
+ 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);
338
239
  }
339
240
  doSetGlobalAttributes(e) {
340
- const t = window.newrelic;
341
- if (t.setCustomAttribute) for (const [i, s] of Object.entries(e)) t.setCustomAttribute(i, s);
241
+ const t = b();
242
+ if (typeof t?.setCustomAttribute == "function") for (const [i, s] of Object.entries(e)) t.setCustomAttribute(i, s);
342
243
  }
343
244
  };
344
- function z(e) {
245
+ function L(e) {
345
246
  return e && typeof e == "object" ? e : {};
346
247
  }
347
- function O(e) {
348
- const t = z(z(e).loaderConfig);
248
+ function D(e) {
249
+ const t = L(L(e).loaderConfig);
349
250
  return Object.keys(t).length > 0 ? t : null;
350
251
  }
351
- function G(e) {
252
+ function M(e) {
352
253
  if (!e || !("instrumentationProvider" in e)) return { kind: "unset" };
353
254
  const t = e.instrumentationProvider;
354
255
  return t === null ? { kind: "null" } : typeof t > "u" ? { kind: "unset" } : {
@@ -356,35 +257,30 @@ function G(e) {
356
257
  value: t
357
258
  };
358
259
  }
359
- function $(e) {
260
+ function F(e) {
360
261
  if (!e || !("trackPageActions" in e)) return;
361
262
  const t = e.trackPageActions;
362
263
  return typeof t == "boolean" ? t : void 0;
363
264
  }
364
- function ke(e, t) {
265
+ function le(e, t) {
365
266
  return e.kind === "value" || e.kind === "null" ? e : t;
366
267
  }
367
- var I, Le = v("instrumentation-provider-resolution", () => y());
368
- function Te() {
369
- return I || (I = new Re(), I.initialize()), I;
268
+ var I, ce = H("instrumentation-provider-resolution", () => q());
269
+ function de() {
270
+ return I || (I = new ae(), I.initialize()), I;
370
271
  }
371
- function Ne(e) {
372
- const t = O(e.runtimePlayer), i = O(e.player), s = $(t), n = $(i), o = s ?? n ?? !1, r = ke(G(t), G(i));
272
+ function ue(e) {
273
+ const t = D(e.runtimePlayer), i = D(e.player), s = F(t), n = F(i), o = s ?? n ?? !1, r = le(M(t), M(i));
373
274
  if (r.kind !== "null") {
374
- if (r.kind === "unset") return o ? Te() : void 0;
375
- if (te(r.value)) return r.value;
275
+ if (r.kind === "unset") return o ? de() : void 0;
276
+ if (G(r.value)) return r.value;
376
277
  if (e.debug) {
377
- const l = e.component ? `[${e.component}] ` : "";
378
- Le.warn(`${l}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
278
+ const a = e.component ? `[${e.component}] ` : "";
279
+ ce.warn(`${a}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
379
280
  }
380
281
  }
381
282
  }
382
- var gt = Object.freeze([
383
- "composed",
384
- "engine-ready",
385
- "interactive",
386
- "disposed"
387
- ]), xe = [
283
+ var he = [
388
284
  {
389
285
  sourceEventName: "assessment-controller-ready",
390
286
  instrumentationEventName: "pie-assessment-controller-ready"
@@ -417,25 +313,16 @@ var gt = Object.freeze([
417
313
  sourceEventName: "assessment-error",
418
314
  instrumentationEventName: "pie-assessment-error"
419
315
  }
420
- ], ft = /* @__PURE__ */ new Set([
421
- "id",
422
- "element",
423
- .../* @__PURE__ */ new Set([
424
- "complete",
425
- "component",
426
- "timestamp",
427
- "sourceRuntimeId"
428
- ])
429
- ]), vt = v("pie-overrides", () => y()), De = { "nl-NL": () => import("./nl-NL-FLtEAIq9.js") }, _e = ["en-US", "nl-NL"];
430
- async function Ue(e) {
431
- const t = De[e];
316
+ ], pe = { "nl-NL": () => import("./nl-NL-CfezB59b.js") }, me = ["en-US", "nl-NL"];
317
+ async function ge(e) {
318
+ const t = pe[e];
432
319
  if (!t) throw new Error(`No bundled i18n catalog for locale: ${e}`);
433
320
  return (await t()).default;
434
321
  }
435
322
  function A(e) {
436
323
  return e ? e.trim().replace(/_/g, "-").split(/[.@]/)[0].toLowerCase() : "";
437
324
  }
438
- function Me(e) {
325
+ function fe(e) {
439
326
  const t = A(e);
440
327
  if (!t) return [];
441
328
  const i = t.split("-"), s = [];
@@ -445,13 +332,13 @@ function Me(e) {
445
332
  }
446
333
  return s;
447
334
  }
448
- function Fe(e, t) {
449
- for (const i of Me(e)) {
335
+ function ye(e, t) {
336
+ for (const i of fe(e)) {
450
337
  const s = t.find((n) => A(n) === i);
451
338
  if (s != null) return s;
452
339
  }
453
340
  }
454
- var Be = {
341
+ var ve = {
455
342
  common: {
456
343
  close: "Close",
457
344
  cancel: "Cancel",
@@ -496,6 +383,7 @@ var Be = {
496
383
  items: "Items",
497
384
  section: "Section",
498
385
  loadingSection: "Loading section content…",
386
+ sectionLoadError: "Section content could not be loaded.",
499
387
  loadingPassage: "Loading passage content…",
500
388
  configurationError: "Configuration Error",
501
389
  playerError: "Player Error",
@@ -561,6 +449,11 @@ var Be = {
561
449
  centerA11y: "Center tool window",
562
450
  closeA11y: "Close tool"
563
451
  },
452
+ placement: {
453
+ controlsA11y: "Move and rotate",
454
+ rotateClockwiseA11y: "Rotate {degrees}° clockwise",
455
+ rotateCounterclockwiseA11y: "Rotate {degrees}° counterclockwise"
456
+ },
564
457
  announce: {
565
458
  movedUp: "Moved up to {position}",
566
459
  movedDown: "Moved down to {position}",
@@ -588,8 +481,8 @@ var Be = {
588
481
  },
589
482
  graph: {
590
483
  name: "Graph",
591
- description: "Graphing calculator and coordinate plane",
592
- buttonA11y: "Graph, graphing calculator",
484
+ description: "Coordinate plane",
485
+ buttonA11y: "Graph, coordinate plane",
593
486
  tooltip: "Graph",
594
487
  toolA11y: "Graph tool — draw points and lines on a coordinate grid",
595
488
  canvasA11y: "Graph canvas — use tools to add points and draw lines",
@@ -753,30 +646,6 @@ var Be = {
753
646
  textToSpeech: {
754
647
  name: "Text to Speech",
755
648
  description: "Read content aloud",
756
- toolA11y: "Text-to-speech tool",
757
- title: "Text-to-Speech",
758
- initializing: "Initializing…",
759
- initFailed: "Failed to initialize text-to-speech.",
760
- selectText: "Select text on the page to read it aloud.",
761
- speed: "Speed:",
762
- play: "Play",
763
- pause: "Pause",
764
- resume: "Resume",
765
- stop: "Stop",
766
- speaking: "Speaking…",
767
- paused: "Paused",
768
- charactersSelected: {
769
- one: "{count} character selected",
770
- other: "{count} characters selected"
771
- },
772
- rate: {
773
- slow: "Slow",
774
- slower: "Slower",
775
- normal: "Normal",
776
- faster: "Faster",
777
- fast: "Fast",
778
- veryFast: "Very Fast"
779
- },
780
649
  inline: {
781
650
  controlsA11y: "Reading controls",
782
651
  playbackSpeedA11y: "Playback speed",
@@ -882,6 +751,7 @@ var Be = {
882
751
  resolvedTools: "Resolved Tools (toolkit)",
883
752
  provenanceSummary: "Tool Policy Provenance Summary",
884
753
  perToolDecisions: "Per-Tool Decisions",
754
+ policyDiagnostics: "Policy Diagnostics",
885
755
  profileReadOnly: "PNP Profile (read-only)"
886
756
  },
887
757
  tts: {
@@ -952,7 +822,7 @@ var Be = {
952
822
  coordinatorUnavailable: "Toolkit coordinator is not available for text-to-speech updates."
953
823
  }
954
824
  }
955
- }, k = "en-US", ze = /* @__PURE__ */ new Set([
825
+ }, k = "en-US", be = /* @__PURE__ */ new Set([
956
826
  "ar",
957
827
  "ckb",
958
828
  "dv",
@@ -968,7 +838,7 @@ var Be = {
968
838
  "ug",
969
839
  "ur",
970
840
  "yi"
971
- ]), Oe = /* @__PURE__ */ new Set([
841
+ ]), Se = /* @__PURE__ */ new Set([
972
842
  "zero",
973
843
  "one",
974
844
  "two",
@@ -976,23 +846,23 @@ var Be = {
976
846
  "many",
977
847
  "other"
978
848
  ]);
979
- function H(e) {
849
+ function _(e) {
980
850
  if (typeof e != "object" || e === null) return !1;
981
851
  const t = Object.keys(e);
982
- return t.length > 0 && t.every((i) => Oe.has(i));
852
+ return t.length > 0 && t.every((i) => Se.has(i));
983
853
  }
984
- function q(e) {
854
+ function z(e) {
985
855
  try {
986
856
  const i = new Intl.Locale(e).textInfo;
987
857
  if (i?.direction === "rtl" || i?.direction === "ltr") return i.direction;
988
858
  } catch {
989
859
  }
990
860
  const t = A(e).split("-")[0] ?? "";
991
- return ze.has(t) ? "rtl" : "ltr";
861
+ return be.has(t) ? "rtl" : "ltr";
992
862
  }
993
- var ie = class R {
863
+ var $ = class E {
994
864
  constructor(t = {}) {
995
- a(this, "locale", void 0), a(this, "fallbackLocale", void 0), a(this, "catalogs", void 0), a(this, "customMessages", void 0), a(this, "loading", void 0), a(this, "listeners", /* @__PURE__ */ new Set()), a(this, "config", void 0), this.config = { ...t }, this.fallbackLocale = P(t.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[k, Be]]), this.customMessages = { ...t.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(t.locale) ?? "en-US";
865
+ 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 = P(t.fallbackLocale) || "en-US", this.catalogs = /* @__PURE__ */ new Map([[k, ve]]), this.customMessages = { ...t.customMessages ?? {} }, this.loading = /* @__PURE__ */ new Map(), this.locale = this.resolveLocaleTag(t.locale) ?? "en-US";
996
866
  }
997
867
  async initialize(t) {
998
868
  if (this.config = {
@@ -1027,14 +897,14 @@ var ie = class R {
1027
897
  }
1028
898
  t(t, i) {
1029
899
  const s = this.lookup(t);
1030
- return s === void 0 ? (this.config.onMissingKey?.(t, this.locale), t) : j(s, i);
900
+ return s === void 0 ? (this.config.onMissingKey?.(t, this.locale), t) : U(s, i);
1031
901
  }
1032
902
  plural(t, i) {
1033
903
  const s = this.lookupNode(t);
1034
- return s === void 0 || !H(s) ? this.t(t, i) : j(s[this.selectPluralCategory(i.count)] ?? s.other, i);
904
+ return s === void 0 || !_(s) ? this.t(t, i) : U(s[this.selectPluralCategory(i.count)] ?? s.other, i);
1035
905
  }
1036
906
  getDirection() {
1037
- return q(this.locale);
907
+ return z(this.locale);
1038
908
  }
1039
909
  getAvailableLocales() {
1040
910
  return [.../* @__PURE__ */ new Set([
@@ -1057,12 +927,12 @@ var ie = class R {
1057
927
  }
1058
928
  addCustomMessages(t, i) {
1059
929
  const s = P(t);
1060
- this.customMessages[s] = se(this.customMessages[s] ?? {}, i), this.notify();
930
+ this.customMessages[s] = j(this.customMessages[s] ?? {}, i), this.notify();
1061
931
  }
1062
932
  withLocale(t) {
1063
933
  const i = this.resolveLocaleTag(t) ?? P(t);
1064
934
  if (i === this.locale) return this;
1065
- const s = new R({
935
+ const s = new E({
1066
936
  ...this.config,
1067
937
  locale: i
1068
938
  });
@@ -1090,12 +960,12 @@ var ie = class R {
1090
960
  return {
1091
961
  locale: i,
1092
962
  translations: s,
1093
- direction: q(i)
963
+ direction: z(i)
1094
964
  };
1095
965
  }
1096
966
  resolveLocaleTag(t) {
1097
967
  if (!t) return;
1098
- const i = this.getAvailableLocales(), s = Fe(t, i);
968
+ const i = this.getAvailableLocales(), s = ye(t, i);
1099
969
  if (s) return s;
1100
970
  const n = A(t).split("-")[0];
1101
971
  if (n)
@@ -1118,24 +988,24 @@ var ie = class R {
1118
988
  this.catalogs.get(this.fallbackLocale)
1119
989
  ];
1120
990
  for (const s of i) {
1121
- const n = Ge(s, t);
991
+ const n = we(s, t);
1122
992
  if (n !== void 0) return n;
1123
993
  }
1124
994
  }
1125
995
  lookup(t) {
1126
996
  const i = this.lookupNode(t);
1127
997
  if (typeof i == "string") return i;
1128
- if (i !== void 0 && H(i)) return i.other;
998
+ if (i !== void 0 && _(i)) return i.other;
1129
999
  }
1130
1000
  selectPluralCategory(t) {
1131
- let i = R.pluralRules.get(this.locale);
1001
+ let i = E.pluralRules.get(this.locale);
1132
1002
  if (!i) {
1133
1003
  try {
1134
1004
  i = new Intl.PluralRules(this.locale);
1135
1005
  } catch {
1136
1006
  return t === 1 ? "one" : "other";
1137
1007
  }
1138
- R.pluralRules.set(this.locale, i);
1008
+ E.pluralRules.set(this.locale, i);
1139
1009
  }
1140
1010
  return i.select(t);
1141
1011
  }
@@ -1143,63 +1013,63 @@ var ie = class R {
1143
1013
  for (const t of this.listeners) t();
1144
1014
  }
1145
1015
  };
1146
- a(ie, "pluralRules", /* @__PURE__ */ new Map());
1016
+ f($, "pluralRules", /* @__PURE__ */ new Map());
1147
1017
  function P(e) {
1148
1018
  return e ? e.trim().replace(/_/g, "-") : "";
1149
1019
  }
1150
- function Ge(e, t) {
1020
+ function we(e, t) {
1151
1021
  if (!e) return;
1152
1022
  let i = e;
1153
1023
  for (const s of t.split("."))
1154
1024
  if (typeof i != "object" || i === null || (i = i[s], i === void 0)) return;
1155
1025
  return i;
1156
1026
  }
1157
- function j(e, t) {
1027
+ function U(e, t) {
1158
1028
  return t ? e.replace(/\{(\w+)\}/g, (i, s) => {
1159
1029
  const n = t[s];
1160
1030
  return n == null ? i : String(n);
1161
1031
  }) : e;
1162
1032
  }
1163
- function se(e, t) {
1033
+ function j(e, t) {
1164
1034
  const i = { ...e };
1165
1035
  for (const [s, n] of Object.entries(t)) {
1166
1036
  const o = i[s];
1167
- n && typeof n == "object" && o && typeof o == "object" ? i[s] = se(o, n) : i[s] = n;
1037
+ n && typeof n == "object" && o && typeof o == "object" ? i[s] = j(o, n) : i[s] = n;
1168
1038
  }
1169
1039
  return i;
1170
1040
  }
1171
- function $e(e = {}) {
1172
- return new ie({
1173
- loadCatalog: Ue,
1174
- availableLocales: _e,
1041
+ function Ae(e = {}) {
1042
+ return new $({
1043
+ loadCatalog: ge,
1044
+ availableLocales: me,
1175
1045
  ...e
1176
1046
  });
1177
1047
  }
1178
- function b() {
1048
+ function S() {
1179
1049
  return Date.now();
1180
1050
  }
1181
1051
  function C(e) {
1182
1052
  return e.replace(/[^a-zA-Z0-9_-]/g, "-");
1183
1053
  }
1184
- function He(e) {
1054
+ function Ie(e) {
1185
1055
  if (e.attemptId) return `aas_v1_${C(e.assessmentId)}_${C(e.attemptId)}`;
1186
- const t = ne(), i = t ? qe(t) : "anon";
1056
+ const t = W(), i = t ? Pe(t) : "anon";
1187
1057
  return `aas_v1_${C(e.assessmentId)}_${C(i)}`;
1188
1058
  }
1189
- function ne() {
1059
+ function W() {
1190
1060
  try {
1191
1061
  return typeof window > "u" ? null : window.localStorage;
1192
1062
  } catch {
1193
1063
  return null;
1194
1064
  }
1195
1065
  }
1196
- function qe(e) {
1066
+ function Pe(e) {
1197
1067
  const t = "pie:assessment-player:anonymous-device-id", i = e.getItem(t);
1198
1068
  if (i) return i;
1199
1069
  const s = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
1200
1070
  return e.setItem(t, s), s;
1201
1071
  }
1202
- function je(e) {
1072
+ function Ce(e) {
1203
1073
  if (!e) return [];
1204
1074
  const t = [], i = e.testParts || [];
1205
1075
  return i.length > 0 ? (i.forEach((s, n) => {
@@ -1222,12 +1092,12 @@ function je(e) {
1222
1092
  });
1223
1093
  }), t);
1224
1094
  }
1225
- var Ve = class {
1095
+ var Ee = class {
1226
1096
  constructor(e) {
1227
- 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 = {
1097
+ 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 = {
1228
1098
  assessmentId: e.assessmentId,
1229
1099
  attemptId: e.attemptId
1230
- };
1100
+ }, this.initialSession = e.initialSession ? y(e.initialSession) : null;
1231
1101
  }
1232
1102
  emit(e) {
1233
1103
  if (!this.disposed)
@@ -1248,30 +1118,30 @@ var Ve = class {
1248
1118
  async getPersistenceStrategy() {
1249
1119
  if (this.persistenceStrategy) return this.persistenceStrategy;
1250
1120
  const e = { createDefaultPersistence: () => {
1251
- const t = ne(), i = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
1121
+ const t = W(), { assessmentId: i, attemptId: s } = this.storageContext, n = s ? `pie:assessment-controller:v1:${i}:${s}` : null;
1252
1122
  return {
1253
1123
  async loadSession() {
1254
- if (!t) return null;
1255
- const s = t.getItem(i);
1256
- if (!s) return null;
1124
+ if (!t || !n) return null;
1125
+ const o = t.getItem(n);
1126
+ if (!o) return null;
1257
1127
  try {
1258
- return JSON.parse(s);
1128
+ return JSON.parse(o);
1259
1129
  } catch {
1260
1130
  return null;
1261
1131
  }
1262
1132
  },
1263
- async saveSession(s, n) {
1264
- t && t.setItem(i, JSON.stringify(n));
1133
+ async saveSession(o, r) {
1134
+ !t || !n || t.setItem(n, JSON.stringify(r));
1265
1135
  },
1266
1136
  async clearSession() {
1267
- t && t.removeItem(i);
1137
+ !t || !n || t.removeItem(n);
1268
1138
  }
1269
1139
  };
1270
1140
  } };
1271
1141
  return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(this.storageContext, e) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
1272
1142
  }
1273
1143
  async createDeliveryPlan() {
1274
- const e = { createDefaultDeliveryPlan: () => ({ sections: je(this.args.assessment) }) }, t = {
1144
+ const e = { createDefaultDeliveryPlan: () => ({ sections: Ce(this.args.assessment) }) }, t = {
1275
1145
  assessmentId: this.args.assessmentId,
1276
1146
  attemptId: this.args.attemptId,
1277
1147
  assessment: this.args.assessment
@@ -1281,8 +1151,8 @@ var Ve = class {
1281
1151
  ensureSession() {
1282
1152
  if (this.session) return this.session;
1283
1153
  const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
1284
- return this.session = re({
1285
- assessmentAttemptSessionIdentifier: He({
1154
+ return this.session = Q({
1155
+ assessmentAttemptSessionIdentifier: Ie({
1286
1156
  assessmentId: this.args.assessmentId,
1287
1157
  attemptId: this.args.attemptId
1288
1158
  }),
@@ -1315,10 +1185,12 @@ var Ve = class {
1315
1185
  await this.args.hooks?.onBeforeAssessmentHydrate?.(this.storageContext), this.assertActive();
1316
1186
  const e = await this.getPersistenceStrategy();
1317
1187
  this.assertActive();
1318
- const t = await e.loadSession(this.storageContext);
1319
- this.assertActive(), t && (this.session = t), this.ensureSession(), this.readiness = "ready", t && this.emit({
1188
+ const t = this.initialSession;
1189
+ this.initialSession = null;
1190
+ const i = t ?? await e.loadSession(this.storageContext);
1191
+ this.assertActive(), i && (this.session = i), this.ensureSession(), this.readiness = "ready", i && this.emit({
1320
1192
  type: "assessment-session-applied",
1321
- timestamp: b()
1193
+ timestamp: S()
1322
1194
  }), this.assertActive();
1323
1195
  } catch (e) {
1324
1196
  try {
@@ -1341,13 +1213,19 @@ var Ve = class {
1341
1213
  async persist() {
1342
1214
  this.assertActive();
1343
1215
  try {
1344
- const e = await this.getPersistenceStrategy();
1345
- if (this.disposed || (await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), this.disposed)) return;
1346
- await e.saveSession(this.storageContext, this.session);
1216
+ await this.save();
1347
1217
  } catch (e) {
1348
1218
  this.disposed || this.handleError(e, "session-save");
1349
1219
  }
1350
1220
  }
1221
+ save() {
1222
+ const e = this.saveQueue.then(async () => {
1223
+ const t = await this.getPersistenceStrategy();
1224
+ this.disposed || (await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), !this.disposed && await t.saveSession(this.storageContext, this.session));
1225
+ });
1226
+ return this.saveQueue = e.catch(() => {
1227
+ }), e;
1228
+ }
1351
1229
  getSession() {
1352
1230
  return this.session;
1353
1231
  }
@@ -1379,14 +1257,14 @@ var Ve = class {
1379
1257
  const t = this.buildNavigationSnapshot();
1380
1258
  if (e < 0 || e >= t.totalSections) return !1;
1381
1259
  const i = t.currentSectionId, s = this.deliveryPlan.sections[e];
1382
- this.session = le(this.ensureSession(), {
1260
+ this.session = K(this.ensureSession(), {
1383
1261
  currentSectionIndex: e,
1384
1262
  currentSectionIdentifier: s?.sectionIdentifier
1385
1263
  });
1386
1264
  const n = this.buildNavigationSnapshot();
1387
1265
  return this.emit({
1388
1266
  type: "assessment-route-changed",
1389
- timestamp: b(),
1267
+ timestamp: S(),
1390
1268
  currentSectionIndex: n.currentSectionIndex,
1391
1269
  totalSections: n.totalSections,
1392
1270
  currentSectionId: n.currentSectionId,
@@ -1395,10 +1273,10 @@ var Ve = class {
1395
1273
  canPrevious: n.canPrevious
1396
1274
  }), this.disposed || (this.emit({
1397
1275
  type: "assessment-session-changed",
1398
- timestamp: b()
1276
+ timestamp: S()
1399
1277
  }), this.disposed) ? !1 : (this.emit({
1400
1278
  type: "assessment-progress-changed",
1401
- timestamp: b(),
1279
+ timestamp: S(),
1402
1280
  visitedSectionCount: this.ensureSession().navigationState.visitedSectionIdentifiers.length,
1403
1281
  totalSections: n.totalSections
1404
1282
  }), !0);
@@ -1417,11 +1295,17 @@ var Ve = class {
1417
1295
  return this.setIndex(e.currentSectionIndex - 1);
1418
1296
  }
1419
1297
  async submit() {
1420
- this.assertActive(), this.submitted = !0, this.emit({
1298
+ this.assertActive();
1299
+ try {
1300
+ await this.save();
1301
+ } catch (e) {
1302
+ throw this.disposed || this.handleError(e, "session-save"), e;
1303
+ }
1304
+ this.disposed || (this.submitted = !0, this.emit({
1421
1305
  type: "assessment-submission-state-changed",
1422
- timestamp: b(),
1306
+ timestamp: S(),
1423
1307
  submitted: !0
1424
- }), await this.persist();
1308
+ }));
1425
1309
  }
1426
1310
  subscribe(e) {
1427
1311
  return this.disposed ? () => {
@@ -1438,18 +1322,17 @@ var Ve = class {
1438
1322
  return this.disposed ? null : this.ensureSession().sectionSessions[e]?.session || null;
1439
1323
  }
1440
1324
  updateSectionSession(e, t) {
1441
- this.disposed || (this.session = ce(this.ensureSession(), {
1325
+ this.disposed || (this.session = Y(this.ensureSession(), {
1442
1326
  sectionIdentifier: e,
1443
1327
  sectionSession: t
1444
1328
  }), this.emit({
1445
1329
  type: "assessment-session-changed",
1446
- timestamp: b()
1330
+ timestamp: S()
1447
1331
  }));
1448
1332
  }
1449
- }, m = {
1333
+ }, g = {
1450
1334
  controllerReady: "assessment-controller-ready",
1451
1335
  navigationRequested: "assessment-navigation-requested",
1452
- submitRequested: "assessment-submit-requested",
1453
1336
  routeChanged: "assessment-route-changed",
1454
1337
  sessionApplied: "assessment-session-applied",
1455
1338
  sessionChanged: "assessment-session-changed",
@@ -1457,7 +1340,7 @@ var Ve = class {
1457
1340
  submissionStateChanged: "assessment-submission-state-changed",
1458
1341
  error: "assessment-error"
1459
1342
  };
1460
- function Ye(e, t) {
1343
+ function ke(e, t) {
1461
1344
  return !e?.delivery || e.delivery.enabled === !1 || !t || e.delivery.assignmentId !== void 0 ? e : {
1462
1345
  ...e,
1463
1346
  delivery: {
@@ -1466,22 +1349,35 @@ function Ye(e, t) {
1466
1349
  }
1467
1350
  };
1468
1351
  }
1469
- function We(e) {
1470
- const { sectionPlayerRuntime: t, playerType: i, attemptId: s, env: n, coordinator: o } = e, r = t?.player && typeof t.player == "object" ? {
1352
+ function Re(e) {
1353
+ const { sectionPlayerRuntime: t, playerType: i, assessmentId: s, attemptId: n, env: o, coordinator: r } = e, a = t?.player && typeof t.player == "object" ? {
1471
1354
  ...t.player,
1472
- backend: Ye(t.player.backend ? S(t.player.backend) : void 0, s)
1355
+ backend: ke(t.player.backend ? y(t.player.backend) : void 0, n)
1473
1356
  } : t?.player;
1474
1357
  return {
1475
1358
  playerType: i,
1476
- ...n ? { env: n } : {},
1477
- ...o ? { coordinator: o } : {},
1359
+ ...s ? { assessmentId: s } : {},
1360
+ ...o ? { env: o } : {},
1361
+ ...r ? { coordinator: r } : {},
1478
1362
  ...t || {},
1479
- ...r !== void 0 ? { player: r } : {}
1363
+ ...a !== void 0 ? { player: a } : {}
1480
1364
  };
1481
1365
  }
1482
- var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke = class extends HTMLElement {
1366
+ function B(e) {
1367
+ return !!e && typeof e == "object";
1368
+ }
1369
+ function N(e, t) {
1370
+ if (Object.is(e, t)) return !0;
1371
+ if (Array.isArray(e) || Array.isArray(t))
1372
+ return !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((s, n) => N(s, t[n]));
1373
+ if (!B(e) || !B(t)) return !1;
1374
+ const i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
1375
+ for (const s of i) if (!N(e[s], t[s])) return !1;
1376
+ return !0;
1377
+ }
1378
+ var Ne = "pie-section-player-splitpane", xe = "pie-section-player-vertical", Te = class extends HTMLElement {
1483
1379
  constructor(...e) {
1484
- 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 = $e(), 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" };
1380
+ 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 = Ae(), 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" };
1485
1381
  }
1486
1382
  static get observedAttributes() {
1487
1383
  return [
@@ -1518,6 +1414,13 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1518
1414
  set hooks(e) {
1519
1415
  this._hooks !== e && (this._hooks = e, this.queueReconciliation());
1520
1416
  }
1417
+ get session() {
1418
+ return this.controller ? y(this.controller.getSession()) : this.pendingSession;
1419
+ }
1420
+ set session(e) {
1421
+ const t = e ?? null;
1422
+ t !== this.pendingSession && (t && this.controller && N(t, this.controller.getSession()) || (this.pendingSession = t, this.queueReconciliation()));
1423
+ }
1521
1424
  get locale() {
1522
1425
  return this._locale;
1523
1426
  }
@@ -1617,67 +1520,68 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1617
1520
  return;
1618
1521
  }
1619
1522
  this.readiness = { phase: "bootstrapping" }, this.renderEmptyState();
1620
- const e = this.generation, t = this.hooks, i = () => this.isConnected && this.generation === e, s = new Ve({
1523
+ const e = this.generation, t = this.hooks, i = () => this.isConnected && this.generation === e, s = this.pendingSession, n = new Ee({
1621
1524
  assessmentId: this.assessmentId,
1622
1525
  attemptId: this.attemptId || void 0,
1623
1526
  assessment: this.assessment,
1527
+ initialSession: s,
1624
1528
  hooks: {
1625
1529
  ...t,
1626
- onError: (n, o) => {
1530
+ onError: (o, r) => {
1627
1531
  if (i())
1628
1532
  try {
1629
- t?.onError?.(n, o);
1533
+ t?.onError?.(o, r);
1630
1534
  } finally {
1631
- i() && o.phase === "session-load" && this.controller === s && (this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(m.error, { error: n }));
1535
+ i() && r.phase === "session-load" && this.controller === n && (this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(g.error, { error: o }));
1632
1536
  }
1633
1537
  }
1634
1538
  }
1635
1539
  });
1636
- this.initializingController = s, this.unsubscribeController = s.subscribe((n) => {
1540
+ this.initializingController = n, this.unsubscribeController = n.subscribe((o) => {
1637
1541
  if (i()) {
1638
- if (n.type === "assessment-route-changed") {
1639
- if (this.syncCurrentSectionSessionIntoAssessment(), !i() || (this.cleanupTtsForSectionNavigation(n), !i()) || (this.dispatch(m.routeChanged, n), !i())) return;
1542
+ if (o.type === "assessment-route-changed") {
1543
+ if (this.syncCurrentSectionSessionIntoAssessment(), !i() || (this.cleanupTtsForSectionNavigation(o), !i()) || (this.dispatch(g.routeChanged, o), !i())) return;
1640
1544
  this.restoreFocusOnRender = !0, this.render(!1);
1641
1545
  }
1642
- n.type === "assessment-session-applied" && this.dispatch(m.sessionApplied, n), n.type === "assessment-session-changed" && this.dispatch(m.sessionChanged, n), n.type === "assessment-progress-changed" && this.dispatch(m.progressChanged, n), n.type === "assessment-submission-state-changed" && this.dispatch(m.submissionStateChanged, n);
1546
+ 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);
1643
1547
  }
1644
1548
  });
1645
1549
  try {
1646
- if (await s.initialize(), !i()) return;
1647
- this.initializingController = null, this.controller = s, this.readiness = { phase: "ready" }, this.render(), this.settleControllerWaiters(s);
1648
- const n = (o) => {
1550
+ if (await n.initialize(), !i()) return;
1551
+ this.pendingSession === s && (this.pendingSession = null), this.initializingController = null, this.controller = n, this.readiness = { phase: "ready" }, this.render(), this.settleControllerWaiters(n);
1552
+ const o = (r) => {
1649
1553
  if (i()) {
1650
1554
  try {
1651
- t?.onError?.(o instanceof Error ? o : new Error(String(o)), { phase: "controller-init" });
1652
- } catch (r) {
1653
- console.error("Assessment error hook failed", r);
1555
+ t?.onError?.(r instanceof Error ? r : new Error(String(r)), { phase: "controller-init" });
1556
+ } catch (a) {
1557
+ console.error("Assessment error hook failed", a);
1654
1558
  }
1655
- i() && this.dispatch(m.error, { error: o });
1559
+ i() && this.dispatch(g.error, { error: r });
1656
1560
  }
1657
1561
  };
1658
1562
  try {
1659
- Promise.resolve(t?.onAssessmentControllerReady?.(s)).catch(n);
1660
- } catch (o) {
1661
- n(o);
1563
+ Promise.resolve(t?.onAssessmentControllerReady?.(n)).catch(o);
1564
+ } catch (r) {
1565
+ o(r);
1662
1566
  }
1663
- i() && this.dispatch(m.controllerReady, { controller: s });
1664
- } catch (n) {
1567
+ i() && this.dispatch(g.controllerReady, { controller: n });
1568
+ } catch (o) {
1665
1569
  if (!i()) return;
1666
- this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(m.error, { error: n });
1570
+ this.retireController(), this.readiness = { phase: "error" }, this.renderEmptyState(), this.dispatch(g.error, { error: o });
1667
1571
  }
1668
1572
  }
1669
1573
  resolveInstrumentationProvider() {
1670
- return Ne({
1574
+ return ue({
1671
1575
  runtimePlayer: this.sectionPlayerRuntime?.player,
1672
1576
  component: "pie-assessment-player-default"
1673
1577
  });
1674
1578
  }
1675
1579
  attachInstrumentationBridge() {
1676
- this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = Pe({
1580
+ this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = oe({
1677
1581
  host: this,
1678
1582
  instrumentationProvider: this.resolveInstrumentationProvider(),
1679
1583
  component: "pie-assessment-player-default",
1680
- eventMap: xe,
1584
+ eventMap: he,
1681
1585
  staticAttributes: {
1682
1586
  instrumentationLayer: "assessment",
1683
1587
  assessmentId: this.assessmentId,
@@ -1750,12 +1654,13 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1750
1654
  return;
1751
1655
  }
1752
1656
  buildSectionPlayerTag() {
1753
- return this.sectionPlayerLayout === "vertical" ? Je : Qe;
1657
+ return this.sectionPlayerLayout === "vertical" ? xe : Ne;
1754
1658
  }
1755
1659
  buildSectionRuntime() {
1756
- return We({
1660
+ return Re({
1757
1661
  sectionPlayerRuntime: this.sectionPlayerRuntime,
1758
1662
  playerType: this.playerType,
1663
+ assessmentId: this.assessmentId || void 0,
1759
1664
  attemptId: this.attemptId || void 0,
1760
1665
  env: this.env,
1761
1666
  coordinator: this.coordinator
@@ -1770,7 +1675,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1770
1675
  const t = this.coordinator, i = t?.ttsService;
1771
1676
  if (!i) return;
1772
1677
  const s = (n) => {
1773
- t?.reportFrameworkError?.(ae({
1678
+ t?.reportFrameworkError?.(J({
1774
1679
  kind: "tts-init",
1775
1680
  source: "AssessmentPlayerDefaultElement.cleanupTtsForSectionNavigation",
1776
1681
  error: n,
@@ -1794,53 +1699,49 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1794
1699
  const t = this.sectionControllerRef;
1795
1700
  if (!t?.getSession) return;
1796
1701
  const i = this.sectionHost?.firstElementChild?.getAttribute("section-id");
1797
- i && e.updateSectionSession(i, S(t.getSession()));
1798
- }
1799
- attachSectionControllerReadyListener(e, t) {
1800
- const i = e, s = this.generation, n = this.sectionHost, o = this.controller, r = S(o.getSectionSession(t)), l = () => this.isConnected && this.generation === s && this.sectionHost === n && this.controller === o;
1801
- n.setAttribute("aria-busy", "true"), i.inert = !0;
1802
- let p;
1803
- new Promise((d) => {
1804
- let g = !1;
1805
- const h = (E) => {
1806
- g || (g = !0, clearTimeout(f), i.removeEventListener(x.stageChange, c), d(E));
1807
- }, c = (E) => {
1808
- if (E.target !== i) return;
1809
- const { stage: N, status: oe } = E.detail;
1810
- oe === "failed" || N === "disposed" ? h(null) : N === "engine-ready" && h(i.getSectionController?.() || null);
1811
- }, f = setTimeout(() => h(null), 5e3);
1812
- i.addEventListener(x.stageChange, c), p = () => h(null);
1813
- }).then(async (d) => {
1814
- if (l()) {
1815
- if (!d) throw new Error("Section controller did not become ready");
1816
- if (r) {
1817
- if (!d.applySession) throw new Error("Section controller cannot restore its saved session");
1818
- await d.applySession(r, { mode: "replace" });
1819
- }
1820
- l() && (this.sectionControllerRef = d, this.sectionSessionReady = !0, i.inert = !1, n.setAttribute("aria-busy", "false"));
1702
+ i && e.updateSectionSession(i, y(t.getSession()));
1703
+ }
1704
+ attachSectionControllerReadyListener(e, t, i) {
1705
+ const s = e, n = this.generation, o = this.sectionHost, r = this.controller, a = () => this.isConnected && this.generation === n && this.sectionHost === o && this.controller === r;
1706
+ o.setAttribute("aria-busy", "true"), s.inert = !0;
1707
+ let h;
1708
+ new Promise((c) => {
1709
+ let p = !1;
1710
+ const u = (v) => {
1711
+ p || (p = !0, clearTimeout(m), s.removeEventListener("pie-stage-change", l), c(v));
1712
+ }, l = (v) => {
1713
+ if (v.target !== s) return;
1714
+ const { stage: x, status: V } = v.detail;
1715
+ V === "failed" || x === "disposed" ? u(null) : x === "engine-ready" && u(s.getSectionController?.() || null);
1716
+ }, m = setTimeout(() => u(null), 5e3);
1717
+ s.addEventListener("pie-stage-change", l), h = () => u(null);
1718
+ }).then(async (c) => {
1719
+ if (a()) {
1720
+ if (!c) throw new Error("Section controller did not become ready");
1721
+ a() && (this.sectionControllerRef = c, this.sectionSessionReady = !0, s.inert = !1, o.setAttribute("aria-busy", "false"));
1821
1722
  }
1822
- }).catch((d) => {
1823
- if (!l()) return;
1723
+ }).catch((c) => {
1724
+ if (!a()) return;
1824
1725
  this.detachSectionListeners?.(), this.detachSectionListeners = void 0, this.sectionControllerRef = null, this.sectionSessionReady = !1;
1825
- const g = n.contains(document.activeElement), h = this.createStatusContent(r ? "player.assessment.restoreFailed" : "player.assessment.loadFailed", () => {
1726
+ const p = o.contains(document.activeElement), u = this.createStatusContent(i ? "player.assessment.restoreFailed" : "player.assessment.loadFailed", () => {
1826
1727
  this.restoreFocusOnRender = this.contains(document.activeElement), this.render();
1827
1728
  });
1828
- n.replaceChildren(h), n.setAttribute("aria-busy", "false"), g && h.focus();
1729
+ o.replaceChildren(u), o.setAttribute("aria-busy", "false"), p && u.focus();
1829
1730
  try {
1830
- this.hooks?.onError?.(d instanceof Error ? d : new Error(String(d)), {
1731
+ this.hooks?.onError?.(c instanceof Error ? c : new Error(String(c)), {
1831
1732
  phase: "navigation",
1832
1733
  details: { sectionIdentifier: t }
1833
1734
  });
1834
- } catch (c) {
1835
- console.error("Assessment error hook failed", c);
1735
+ } catch (l) {
1736
+ console.error("Assessment error hook failed", l);
1836
1737
  }
1837
- l() && this.dispatch(m.error, { error: d });
1738
+ a() && this.dispatch(g.error, { error: c });
1838
1739
  });
1839
- const u = () => {
1840
- l() && this.syncCurrentSectionSessionIntoAssessment();
1740
+ const d = () => {
1741
+ a() && this.syncCurrentSectionSessionIntoAssessment();
1841
1742
  };
1842
- e.addEventListener("session-changed", u), e.addEventListener("item-session-changed", u), this.detachSectionListeners = () => {
1843
- p(), e.removeEventListener("session-changed", u), e.removeEventListener("item-session-changed", u);
1743
+ e.addEventListener("session-changed", d), this.detachSectionListeners = () => {
1744
+ h(), e.removeEventListener("session-changed", d);
1844
1745
  };
1845
1746
  }
1846
1747
  render(e = !0) {
@@ -1876,7 +1777,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1876
1777
  padding: 0.5rem;
1877
1778
  border: 1px solid var(--pie-border-light, #e5e7eb);
1878
1779
  border-radius: 0.375rem;
1879
- background: var(--pie-background-light, var(--pie-background, #fff));
1780
+ background: var(--pie-background, #fff);
1880
1781
  }
1881
1782
  .pie-assessment-player-navigation[hidden] { display: none; }
1882
1783
  .pie-assessment-player-current-position {
@@ -1891,7 +1792,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1891
1792
  padding: 0.35rem 0.75rem;
1892
1793
  border: 1px solid var(--pie-border-light, #e5e7eb);
1893
1794
  border-radius: 0.375rem;
1894
- background: var(--pie-background-light, var(--pie-background, #fff));
1795
+ background: var(--pie-background, #fff);
1895
1796
  cursor: pointer;
1896
1797
  }
1897
1798
  .pie-assessment-player-nav-btn:disabled {
@@ -1904,53 +1805,54 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
1904
1805
  overflow: hidden;
1905
1806
  }
1906
1807
  `, n.appendChild(o);
1907
- const r = this.getSnapshot(), l = r.navigation.totalSections > 0 ? this.i18n.t("player.assessment.sectionPosition", {
1808
+ const r = this.getSnapshot(), a = r.navigation.totalSections > 0 ? this.i18n.t("player.assessment.sectionPosition", {
1908
1809
  position: r.navigation.currentIndex + 1,
1909
1810
  total: r.navigation.totalSections
1910
1811
  }) : this.i18n.t("player.assessment.noSections");
1911
- let p = null, u = null;
1812
+ let h = null, d = null;
1912
1813
  {
1913
- const h = document.createElement("div");
1914
- h.className = "pie-assessment-player-navigation", h.hidden = !L(this.showNavigation, !0);
1915
- const c = document.createElement("div");
1916
- c.className = "pie-assessment-player-current-position", c.textContent = l;
1917
- const f = document.createElement("div");
1918
- f.className = "pie-assessment-player-nav-controls", p = document.createElement("button"), p.type = "button", p.className = "pie-assessment-player-nav-btn", p.setAttribute("data-pie-navigation", "previous"), p.textContent = this.i18n.t("common.back"), p.disabled = !r.navigation.canPrevious, p.addEventListener("click", () => {
1814
+ const u = document.createElement("div");
1815
+ u.className = "pie-assessment-player-navigation", u.hidden = !R(this.showNavigation, !0);
1816
+ const l = document.createElement("div");
1817
+ l.className = "pie-assessment-player-current-position", l.textContent = a;
1818
+ const m = document.createElement("div");
1819
+ 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", () => {
1919
1820
  this.navigatePrevious();
1920
- }), u = document.createElement("button"), u.type = "button", u.className = "pie-assessment-player-nav-btn", u.setAttribute("data-pie-navigation", "next"), u.textContent = this.i18n.t("common.next"), u.disabled = !r.navigation.canNext, u.addEventListener("click", () => {
1821
+ }), 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", () => {
1921
1822
  this.navigateNext();
1922
- }), f.appendChild(p), f.appendChild(u), h.appendChild(c), h.appendChild(f), n.appendChild(h);
1823
+ }), m.appendChild(h), m.appendChild(d), u.appendChild(l), u.appendChild(m), n.appendChild(u);
1923
1824
  }
1924
- const d = document.createElement("div");
1925
- d.className = "pie-assessment-player-section-host", d.setAttribute("role", "region"), d.setAttribute("aria-label", l), d.tabIndex = -1, this.sectionHost = d;
1926
- const g = i?.getCurrentSection() || null;
1927
- if (g) {
1928
- const h = this.buildSectionPlayerTag(), c = document.createElement(h);
1929
- if (c.setAttribute("assessment-id", this.assessmentId), c.setAttribute("section-id", g.sectionIdentifier), this.attemptId && c.setAttribute("attempt-id", this.attemptId), this.locale && c.setAttribute("locale", this.locale), this.debug !== void 0 && this.debug !== null) {
1930
- const f = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
1931
- c.setAttribute("debug", f);
1825
+ const c = document.createElement("div");
1826
+ c.className = "pie-assessment-player-section-host", c.setAttribute("role", "region"), c.setAttribute("aria-label", a), c.tabIndex = -1, this.sectionHost = c;
1827
+ const p = i?.getCurrentSection() || null;
1828
+ if (p) {
1829
+ const u = this.buildSectionPlayerTag(), l = document.createElement(u);
1830
+ 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) {
1831
+ const v = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
1832
+ l.setAttribute("debug", v);
1932
1833
  }
1933
- c.section = g.section, c.runtime = this.buildSectionRuntime(), c.hooks = { cardTitleFormatter: this.hooks?.cardTitleFormatter }, d.appendChild(c), this.attachSectionControllerReadyListener(c, g.sectionIdentifier);
1834
+ const m = y(i.getSectionSession(p.sectionIdentifier));
1835
+ 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);
1934
1836
  }
1935
- n.appendChild(d), this.swapContent(n), s && (this.applyFocusIntent(s, {
1936
- previous: p,
1937
- next: u
1938
- }), this.announceSectionChange(l));
1837
+ n.appendChild(c), this.swapContent(n), s && (this.applyFocusIntent(s, {
1838
+ previous: h,
1839
+ next: d
1840
+ }), this.announceSectionChange(a));
1939
1841
  }
1940
1842
  updateNavigationChrome() {
1941
1843
  const e = this.selectNavigation(), t = e.totalSections > 0 ? this.i18n.t("player.assessment.sectionPosition", {
1942
1844
  position: e.currentIndex + 1,
1943
1845
  total: e.totalSections
1944
1846
  }) : this.i18n.t("player.assessment.noSections"), i = this.containerRef?.querySelector(".pie-assessment-player-navigation");
1945
- i && (i.hidden = !L(this.showNavigation, !0), i.hidden && i.contains(document.activeElement) && this.sectionHost?.focus());
1847
+ i && (i.hidden = !R(this.showNavigation, !0), i.hidden && i.contains(document.activeElement) && this.sectionHost?.focus());
1946
1848
  const s = this.containerRef?.querySelector(".pie-assessment-player-current-position");
1947
1849
  s && (s.textContent = t);
1948
1850
  const n = i?.querySelector('[data-pie-navigation="previous"]'), o = i?.querySelector('[data-pie-navigation="next"]');
1949
1851
  n && (n.textContent = this.i18n.t("common.back")), o && (o.textContent = this.i18n.t("common.next")), this.sectionHost?.setAttribute("aria-label", t);
1950
1852
  const r = this.containerRef?.querySelector(".pie-assessment-player-status-message");
1951
1853
  r instanceof HTMLElement && r.dataset.pieMessageKey && (r.textContent = this.i18n.t(r.dataset.pieMessageKey));
1952
- const l = this.containerRef?.querySelector(".pie-assessment-player-retry");
1953
- l && (l.textContent = this.i18n.t("common.retry")), this.forwardLocaleToSection();
1854
+ const a = this.containerRef?.querySelector(".pie-assessment-player-retry");
1855
+ a && (a.textContent = this.i18n.t("common.retry")), this.forwardLocaleToSection();
1954
1856
  }
1955
1857
  announceSectionChange(e) {
1956
1858
  const t = this.ensureAnnouncer();
@@ -2005,7 +1907,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
2005
1907
  if (typeof e == "number")
2006
1908
  n = e, o = this.controller?.getSectionAt(n)?.sectionIdentifier;
2007
1909
  else if (o = e, this.controller?.getCurrentSection()?.sectionIdentifier === o) return !0;
2008
- if (!this.dispatch(m.navigationRequested, {
1910
+ if (!this.dispatch(g.navigationRequested, {
2009
1911
  fromIndex: i,
2010
1912
  toIndex: n,
2011
1913
  fromSectionId: s,
@@ -2017,7 +1919,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
2017
1919
  }
2018
1920
  navigateNext() {
2019
1921
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
2020
- if (!this.dispatch(m.navigationRequested, {
1922
+ if (!this.dispatch(g.navigationRequested, {
2021
1923
  fromIndex: e.currentIndex,
2022
1924
  toIndex: e.currentIndex + 1,
2023
1925
  fromSectionId: e.currentSectionId,
@@ -2029,7 +1931,7 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
2029
1931
  }
2030
1932
  navigatePrevious() {
2031
1933
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
2032
- if (!this.dispatch(m.navigationRequested, {
1934
+ if (!this.dispatch(g.navigationRequested, {
2033
1935
  fromIndex: e.currentIndex,
2034
1936
  toIndex: e.currentIndex - 1,
2035
1937
  fromSectionId: e.currentSectionId,
@@ -2052,8 +1954,8 @@ var Qe = "pie-section-player-splitpane", Je = "pie-section-player-vertical", Ke
2052
1954
  }));
2053
1955
  }
2054
1956
  };
2055
- V("pie-assessment-player-default", Ke, "assessment player default tag");
2056
- var Ze = class extends HTMLElement {
1957
+ O("pie-assessment-player-default", Te, "assessment player default tag");
1958
+ var Le = class extends HTMLElement {
2057
1959
  constructor(...e) {
2058
1960
  super(...e), this.showNavigation = !0;
2059
1961
  }
@@ -2067,7 +1969,7 @@ var Ze = class extends HTMLElement {
2067
1969
  e === "show-navigation" && (this.showNavigation = i), this.render();
2068
1970
  }
2069
1971
  render() {
2070
- const e = L(this.showNavigation, !0);
1972
+ const e = R(this.showNavigation, !0);
2071
1973
  this.innerHTML = "";
2072
1974
  const t = document.createElement("style");
2073
1975
  t.textContent = `
@@ -2099,7 +2001,7 @@ var Ze = class extends HTMLElement {
2099
2001
  s.appendChild(n), i.appendChild(s), this.appendChild(t), this.appendChild(i);
2100
2002
  }
2101
2003
  };
2102
- V("pie-assessment-player-shell", Ze, "assessment player shell tag");
2004
+ O("pie-assessment-player-shell", Le, "assessment player shell tag");
2103
2005
  export {
2104
- m as ASSESSMENT_PLAYER_PUBLIC_EVENTS
2006
+ g as ASSESSMENT_PLAYER_PUBLIC_EVENTS
2105
2007
  };