@pie-players/pie-assessment-player 0.3.19 → 0.3.21

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,252 +1,288 @@
1
- var M = Object.defineProperty;
2
- var z = (s, e, t) => e in s ? M(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var f = (s, e, t) => z(s, typeof e != "symbol" ? e + "" : e, t);
4
1
  import "@pie-players/pie-section-player/components/section-player-splitpane-element";
5
2
  import "@pie-players/pie-section-player/components/section-player-vertical-element";
6
- function _(s, e) {
7
- const t = `[${s}]`;
3
+ function p(e, t) {
4
+ const s = `[${e}]`;
8
5
  return {
9
- // Only debug method checks debugEnabledFn - it's checked dynamically on every call
10
6
  debug: (n, ...i) => {
11
- e() && console.debug(t, n, ...i);
7
+ t() && console.debug(s, n, ...i);
12
8
  },
13
- // info, warn, error always log (not gated by debug flag)
14
- info: (n, ...i) => console.info(t, n, ...i),
15
- warn: (n, ...i) => console.warn(t, n, ...i),
16
- error: (n, ...i) => console.error(t, n, ...i)
9
+ info: (n, ...i) => console.info(s, n, ...i),
10
+ warn: (n, ...i) => console.warn(s, n, ...i),
11
+ error: (n, ...i) => console.error(s, n, ...i)
17
12
  };
18
13
  }
19
- function D() {
14
+ function f() {
20
15
  return typeof window < "u" && window.PIE_DEBUG === !0;
21
16
  }
22
- var y;
23
- (function(s) {
24
- s.player = "player.js", s.clientPlayer = "client-player.js", s.editor = "editor.js";
25
- })(y || (y = {}));
26
- var E;
27
- (function(s) {
28
- s.loading = "loading", s.loaded = "loaded";
29
- })(E || (E = {}));
17
+ var S;
18
+ (function(e) {
19
+ e.player = "player.js", e.clientPlayer = "client-player.js", e.editor = "editor.js";
20
+ })(S || (S = {}));
21
+ var w;
22
+ (function(e) {
23
+ e.loading = "loading", e.loaded = "loaded";
24
+ })(w || (w = {}));
25
+ function g(e) {
26
+ "@babel/helpers - typeof";
27
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
28
+ return typeof t;
29
+ } : function(t) {
30
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
31
+ }, g(e);
32
+ }
33
+ function Y(e, t) {
34
+ if (g(e) != "object" || !e) return e;
35
+ var s = e[Symbol.toPrimitive];
36
+ if (s !== void 0) {
37
+ var n = s.call(e, t || "default");
38
+ if (g(n) != "object") return n;
39
+ throw new TypeError("@@toPrimitive must return a primitive value.");
40
+ }
41
+ return (t === "string" ? String : Number)(e);
42
+ }
43
+ function V(e) {
44
+ var t = Y(e, "string");
45
+ return g(t) == "symbol" ? t : t + "";
46
+ }
47
+ function a(e, t, s) {
48
+ return (t = V(t)) in e ? Object.defineProperty(e, t, {
49
+ value: s,
50
+ enumerable: !0,
51
+ configurable: !0,
52
+ writable: !0
53
+ }) : e[t] = s, e;
54
+ }
30
55
  typeof window < "u" && !window.pieHelpers && (window.pieHelpers = {
31
56
  loadingScripts: {},
32
- loadingPromises: {}
57
+ loadingPromises: {},
58
+ globalLoadQueue: Promise.resolve(),
59
+ activeBundleUrl: null
33
60
  });
34
- const F = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, T = "https://proxy.pie-api.com", G = `${T}/bundles/`;
35
- function B(s) {
61
+ var _ = "https://proxy.pie-api.com", q = `${_}/bundles/`;
62
+ function U(e) {
36
63
  try {
37
- const e = F?.[s];
38
- if (typeof e == "string" && e.length > 0)
39
- return e;
64
+ const t = {
65
+ BASE_URL: "/",
66
+ DEV: !1,
67
+ MODE: "production",
68
+ PROD: !0,
69
+ SSR: !1
70
+ }[e];
71
+ if (typeof t == "string" && t.length > 0) return t;
40
72
  } catch {
41
73
  }
42
74
  }
43
- typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || B("PUBLIC_BUILDER_ORIGIN_URL");
44
- typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || B("PUBLIC_BUILDER_BUNDLE_URL");
45
- var w;
46
- (function(s) {
47
- s.SAVE = "save", s.MODEL = "model", s.SCORE = "score", s.MANUAL_SCORE = "manual-score";
48
- })(w || (w = {}));
49
- var P;
50
- (function(s) {
51
- s.AUTO = "auto", s.MANUAL = "manual";
52
- })(P || (P = {}));
53
- var N;
54
- (function(s) {
55
- s.GATHER = "gather", s.VIEW = "view", s.EVALUATE = "evaluate";
75
+ var xe = typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || U("PUBLIC_BUILDER_ORIGIN_URL") || _, J = typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || U("PUBLIC_BUILDER_BUNDLE_URL") || q, N;
76
+ (function(e) {
77
+ e.SAVE = "save", e.MODEL = "model", e.SCORE = "score", e.MANUAL_SCORE = "manual-score";
56
78
  })(N || (N = {}));
57
79
  var C;
58
- (function(s) {
59
- s.PENDING = "pending", s.IN_PROGRESS = "in_progress", s.COMPLETED = "completed", s.FAILED = "failed";
80
+ (function(e) {
81
+ e.AUTO = "auto", e.MANUAL = "manual";
60
82
  })(C || (C = {}));
61
83
  var A;
62
- (function(s) {
63
- s[s.ROOT = 0] = "ROOT", s[s.SUBJECT = 1] = "SUBJECT", s[s.LEVEL = 2] = "LEVEL", s[s.STANDARD = 3] = "STANDARD";
84
+ (function(e) {
85
+ e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
64
86
  })(A || (A = {}));
65
- y.player;
66
- function U(s) {
67
- if (!s || typeof s != "object")
68
- return !1;
69
- const e = s;
70
- return typeof e.providerId == "string" && typeof e.providerName == "string" && typeof e.initialize == "function" && typeof e.trackError == "function" && typeof e.trackEvent == "function" && typeof e.destroy == "function" && typeof e.isReady == "function";
87
+ var x;
88
+ (function(e) {
89
+ e.PENDING = "pending", e.IN_PROGRESS = "in_progress", e.COMPLETED = "completed", e.FAILED = "failed";
90
+ })(x || (x = {}));
91
+ var K = class B extends CustomEvent {
92
+ constructor(t, s = !1) {
93
+ super(B.TYPE, {
94
+ bubbles: !0,
95
+ detail: {
96
+ update: t,
97
+ reset: s
98
+ }
99
+ }), a(this, "update", void 0), a(this, "reset", void 0), this.update = t, this.reset = s;
100
+ }
101
+ };
102
+ a(K, "TYPE", "model.updated");
103
+ var W = class $ extends CustomEvent {
104
+ constructor(t, s) {
105
+ super($.TYPE, {
106
+ bubbles: !0,
107
+ detail: {
108
+ src: t,
109
+ done: s
110
+ }
111
+ }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
112
+ }
113
+ };
114
+ a(W, "TYPE", "delete.image");
115
+ var Q = class O extends CustomEvent {
116
+ constructor(t) {
117
+ super(O.TYPE, {
118
+ bubbles: !0,
119
+ detail: t
120
+ }), a(this, "handler", void 0), this.handler = t;
121
+ }
122
+ };
123
+ a(Q, "TYPE", "insert.image");
124
+ var Z = class M extends CustomEvent {
125
+ constructor(t, s) {
126
+ super(M.TYPE, {
127
+ bubbles: !0,
128
+ detail: {
129
+ src: t,
130
+ done: s
131
+ }
132
+ }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
133
+ }
134
+ };
135
+ a(Z, "TYPE", "delete.sound");
136
+ var X = class z extends CustomEvent {
137
+ constructor(t) {
138
+ super(z.TYPE, {
139
+ bubbles: !0,
140
+ detail: t
141
+ }), a(this, "handler", void 0), this.handler = t;
142
+ }
143
+ };
144
+ a(X, "TYPE", "insert.sound");
145
+ var ee = class F extends CustomEvent {
146
+ constructor(t, s) {
147
+ super(F.TYPE, {
148
+ bubbles: !0,
149
+ composed: !0,
150
+ detail: {
151
+ complete: s,
152
+ component: t
153
+ }
154
+ }), a(this, "component", void 0), a(this, "complete", void 0), this.component = t, this.complete = s;
155
+ }
156
+ };
157
+ a(ee, "TYPE", "session-changed");
158
+ var R;
159
+ (function(e) {
160
+ e[e.ROOT = 0] = "ROOT", e[e.SUBJECT = 1] = "SUBJECT", e[e.LEVEL = 2] = "LEVEL", e[e.STANDARD = 3] = "STANDARD";
161
+ })(R || (R = {}));
162
+ var Re = p("math-rendering", () => f()), Le = p("pie-scoring", () => f()), ke = p("pie-updates", () => f()), Te = p("pie-initialization", () => f()), De = {
163
+ buildServiceBase: J,
164
+ bundleType: S.player,
165
+ env: {
166
+ mode: "gather",
167
+ role: "student"
168
+ }
169
+ };
170
+ function G(e) {
171
+ if (!e || typeof e != "object") return !1;
172
+ const t = e;
173
+ 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";
71
174
  }
72
- const H = _("instrumentation-event-bridge", () => D());
73
- function V(s) {
74
- return s && typeof s == "object" ? s : typeof s > "u" ? {} : { value: s };
175
+ var te = p("instrumentation-event-bridge", () => f());
176
+ function se(e) {
177
+ return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
75
178
  }
76
- function j(s) {
77
- H.warn(`[InstrumentationEventBridge:${s}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
179
+ function ne(e) {
180
+ te.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
78
181
  }
79
- function q(s) {
182
+ function ie(e) {
80
183
  try {
81
- s.provider.trackError(s.error instanceof Error ? s.error : new Error(String(s.error ?? "Unknown instrumentation bridge error")), {
82
- component: s.component,
184
+ e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
185
+ component: e.component,
83
186
  errorType: "InstrumentationBridgeError",
84
- sourceEventName: s.sourceEventName
187
+ sourceEventName: e.sourceEventName
85
188
  });
86
189
  } catch {
87
190
  }
88
191
  }
89
- function J(s) {
90
- if (!s.host || !s.eventMap.length)
91
- return () => {
92
- };
93
- if (!s.instrumentationProvider)
94
- return () => {
95
- };
96
- if (!U(s.instrumentationProvider))
97
- return s.debug && j(s.component), () => {
192
+ function re(e) {
193
+ if (!e.host || !e.eventMap.length) return () => {
194
+ };
195
+ if (!e.instrumentationProvider) return () => {
196
+ };
197
+ if (!G(e.instrumentationProvider))
198
+ return e.debug && ne(e.component), () => {
98
199
  };
99
- const e = s.instrumentationProvider, t = [], n = Math.max(0, s.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), o = (r, c) => {
200
+ const t = e.instrumentationProvider, s = [], n = Math.max(0, e.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), c = (o, r) => {
100
201
  const d = [
101
- c.assessmentId,
102
- c.sectionId,
103
- c.attemptId,
104
- c.itemId,
105
- c.canonicalItemId,
106
- c.sourceRuntimeId
107
- ].map((a) => String(a ?? "")).join("|");
108
- return `${r.instrumentationEventName}|${d}`;
202
+ r.assessmentId,
203
+ r.sectionId,
204
+ r.attemptId,
205
+ r.itemId,
206
+ r.canonicalItemId,
207
+ r.sourceRuntimeId
208
+ ].map((l) => String(l ?? "")).join("|");
209
+ return `${o.instrumentationEventName}|${d}`;
109
210
  };
110
- for (const r of s.eventMap) {
111
- const c = (d) => {
211
+ for (const o of e.eventMap) {
212
+ const r = (d) => {
112
213
  try {
113
- if (!e.isReady() || s.shouldTrackEvent && !s.shouldTrackEvent(d))
114
- return;
115
- const u = V(d.detail), m = (/* @__PURE__ */ new Date()).toISOString(), h = {
116
- ...u,
117
- ...s.staticAttributes,
118
- component: s.component,
119
- sourceEventName: r.sourceEventName,
120
- timestamp: m
214
+ if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(d)) return;
215
+ const l = se(d.detail), h = (/* @__PURE__ */ new Date()).toISOString(), I = {
216
+ ...l,
217
+ ...e.staticAttributes,
218
+ component: e.component,
219
+ sourceEventName: o.sourceEventName,
220
+ timestamp: h
121
221
  };
122
222
  if (n > 0) {
123
- const S = Date.now(), I = o(r, h), b = i.get(I);
124
- if (typeof b == "number" && S - b < n)
125
- return;
126
- i.set(I, S);
223
+ const b = Date.now(), E = c(o, I), P = i.get(E);
224
+ if (typeof P == "number" && b - P < n) return;
225
+ i.set(E, b);
127
226
  }
128
- e.trackEvent(r.instrumentationEventName, {
129
- ...h
130
- });
131
- } catch (a) {
132
- q({
133
- provider: e,
134
- component: s.component,
135
- error: a,
136
- sourceEventName: r.sourceEventName
227
+ t.trackEvent(o.instrumentationEventName, { ...I });
228
+ } catch (l) {
229
+ ie({
230
+ provider: t,
231
+ component: e.component,
232
+ error: l,
233
+ sourceEventName: o.sourceEventName
137
234
  });
138
235
  }
139
236
  };
140
- s.host.addEventListener(r.sourceEventName, c), t.push(() => {
141
- s.host?.removeEventListener(r.sourceEventName, c);
237
+ e.host.addEventListener(o.sourceEventName, r), s.push(() => {
238
+ e.host?.removeEventListener(o.sourceEventName, r);
142
239
  });
143
240
  }
144
241
  return () => {
145
- for (const r of t)
146
- r();
242
+ for (const o of s) o();
147
243
  };
148
244
  }
149
- class W {
245
+ var oe = class {
150
246
  constructor() {
151
- f(this, "initialized", !1);
152
- f(this, "config");
153
- }
154
- // ============================================================================
155
- // Public API methods (template methods)
156
- // ============================================================================
157
- /**
158
- * Track an error with the instrumentation provider
159
- *
160
- * Template method that:
161
- * 1. Checks if provider is ready
162
- * 2. Applies error filter if configured
163
- * 3. Transforms attributes if configured
164
- * 4. Delegates to concrete provider implementation (doTrackError)
165
- *
166
- * @param error The error to track
167
- * @param attributes Contextual attributes
168
- */
247
+ a(this, "initialized", !1), a(this, "config", void 0);
248
+ }
169
249
  trackError(e, t) {
170
- if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t))
171
- return;
172
- const n = this.transformAttributes(t);
250
+ if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
251
+ const s = this.transformAttributes(t);
173
252
  try {
174
- this.doTrackError(e, n), this.config?.debug && console.log(`[${this.providerName}] Tracked error:`, e, n);
175
- } catch (i) {
176
- console.error(`[${this.providerName}] Error tracking error:`, i);
253
+ this.doTrackError(e, s), this.config?.debug && console.log(`[${this.providerName}] Tracked error:`, e, s);
254
+ } catch (n) {
255
+ console.error(`[${this.providerName}] Error tracking error:`, n);
177
256
  }
178
257
  }
179
- /**
180
- * Track a custom event with the instrumentation provider
181
- *
182
- * Template method that:
183
- * 1. Checks if provider is ready
184
- * 2. Applies event filter if configured
185
- * 3. Applies sampling if configured
186
- * 4. Transforms attributes if configured
187
- * 5. Adds timestamp if not present
188
- * 6. Delegates to concrete provider implementation (doTrackEvent)
189
- *
190
- * @param eventName Name of the event
191
- * @param attributes Event attributes
192
- */
193
258
  trackEvent(e, t) {
194
- if (!this.guardedOperation("trackEvent", e, t) || !this.applyEventFilter(e, t) || !this.applySampling(e))
195
- return;
196
- let n = this.transformAttributes(t);
197
- n.timestamp || (n = {
198
- ...n,
259
+ if (!this.guardedOperation("trackEvent", e, t) || !this.applyEventFilter(e, t) || !this.applySampling(e)) return;
260
+ let s = this.transformAttributes(t);
261
+ s.timestamp || (s = {
262
+ ...s,
199
263
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
200
264
  });
201
265
  try {
202
- this.doTrackEvent(e, n), this.config?.debug && console.log(`[${this.providerName}] Tracked event:`, e, n);
203
- } catch (i) {
204
- console.error(`[${this.providerName}] Error tracking event:`, i);
266
+ this.doTrackEvent(e, s), this.config?.debug && console.log(`[${this.providerName}] Tracked event:`, e, s);
267
+ } catch (n) {
268
+ console.error(`[${this.providerName}] Error tracking event:`, n);
205
269
  }
206
270
  }
207
- /**
208
- * Track a performance metric
209
- *
210
- * Default implementation tracks metrics as events with a `metric:` prefix.
211
- * Concrete providers can override this method if their backend has a
212
- * dedicated metric API.
213
- *
214
- * @param metricName Name of the metric
215
- * @param value Numeric value
216
- * @param attributes Optional metric attributes
217
- */
218
- trackMetric(e, t, n) {
271
+ trackMetric(e, t, s) {
219
272
  this.trackEvent(`metric:${e}`, {
220
- ...n,
273
+ ...s,
221
274
  metricValue: t,
222
275
  metricName: e
223
276
  });
224
277
  }
225
- /**
226
- * Set user context for session tracking
227
- *
228
- * Template method that checks if provider is ready then delegates
229
- * to concrete provider implementation.
230
- *
231
- * @param userId User identifier
232
- * @param attributes Optional user attributes
233
- */
234
278
  setUserContext(e, t) {
235
279
  if (this.guardedOperation("setUserContext", e, t))
236
280
  try {
237
281
  this.doSetUserContext(e, t), this.config?.debug && console.log(`[${this.providerName}] Set user context:`, e, t);
238
- } catch (n) {
239
- console.error(`[${this.providerName}] Error setting user context:`, n);
282
+ } catch (s) {
283
+ console.error(`[${this.providerName}] Error setting user context:`, s);
240
284
  }
241
285
  }
242
- /**
243
- * Set global custom attributes
244
- *
245
- * Template method that checks if provider is ready then delegates
246
- * to concrete provider implementation.
247
- *
248
- * @param attributes Attributes to set globally
249
- */
250
286
  setGlobalAttributes(e) {
251
287
  if (this.guardedOperation("setGlobalAttributes", e))
252
288
  try {
@@ -255,191 +291,88 @@ class W {
255
291
  console.error(`[${this.providerName}] Error setting global attributes:`, t);
256
292
  }
257
293
  }
258
- // ============================================================================
259
- // Protected utility methods (shared logic)
260
- // ============================================================================
261
- /**
262
- * Guard operation - check if provider is ready
263
- *
264
- * Returns false if provider is not ready, logging a warning in debug mode.
265
- *
266
- * @param operation Name of the operation for logging
267
- * @param args Arguments for logging
268
- * @returns true if provider is ready, false otherwise
269
- */
270
294
  guardedOperation(e, ...t) {
271
295
  return this.isReady() ? !0 : (this.config?.debug && console.warn(`[${this.providerName}] Attempted to ${e} but provider not ready:`, ...t), !1);
272
296
  }
273
- /**
274
- * Apply error filter if configured
275
- *
276
- * Returns false if error should be filtered out, logging in debug mode.
277
- *
278
- * @param error The error
279
- * @param attributes Error attributes
280
- * @returns true if error should be tracked, false if filtered out
281
- */
282
297
  applyErrorFilter(e, t) {
283
298
  return this.config?.errorFilter && !this.config.errorFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Error filtered out:`, e, t), !1) : !0;
284
299
  }
285
- /**
286
- * Apply event filter if configured
287
- *
288
- * Returns false if event should be filtered out, logging in debug mode.
289
- *
290
- * @param eventName Event name
291
- * @param attributes Event attributes
292
- * @returns true if event should be tracked, false if filtered out
293
- */
294
300
  applyEventFilter(e, t) {
295
301
  return this.config?.eventFilter && !this.config.eventFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Event filtered out:`, e, t), !1) : !0;
296
302
  }
297
- /**
298
- * Apply sampling if configured
299
- *
300
- * Returns false if event should be sampled out, logging in debug mode.
301
- *
302
- * @param eventName Event name for logging
303
- * @returns true if event should be tracked, false if sampled out
304
- */
305
303
  applySampling(e) {
306
304
  return this.config?.sampleRate !== void 0 && this.config.sampleRate < 1 && Math.random() > this.config.sampleRate ? (this.config?.debug && console.log(`[${this.providerName}] Event sampled out:`, e), !1) : !0;
307
305
  }
308
- /**
309
- * Transform attributes if transformer is configured
310
- *
311
- * @param attributes Original attributes
312
- * @returns Transformed attributes or original if no transformer
313
- */
314
306
  transformAttributes(e) {
315
307
  return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
316
308
  }
317
- }
318
- class K extends W {
319
- constructor() {
320
- super(...arguments);
321
- f(this, "providerId", "newrelic");
322
- f(this, "providerName", "New Relic");
323
- }
324
- /**
325
- * Initialize the New Relic provider
326
- *
327
- * Checks if the New Relic Browser Agent is available via `window.newrelic`.
328
- * If not available, initialization succeeds but `isReady()` will return false.
329
- *
330
- * @param config Optional configuration
331
- */
332
- async initialize(t) {
333
- this.config = t, 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);
334
- }
335
- /**
336
- * Check if provider is ready
337
- *
338
- * @returns true if New Relic is available and initialized
339
- */
309
+ }, ae = class extends oe {
310
+ constructor(...e) {
311
+ super(...e), a(this, "providerId", "newrelic"), a(this, "providerName", "New Relic");
312
+ }
313
+ async initialize(e) {
314
+ 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);
315
+ }
340
316
  isReady() {
341
317
  return this.initialized && typeof window < "u" && !!window.newrelic;
342
318
  }
343
- /**
344
- * Cleanup provider resources
345
- *
346
- * Marks provider as uninitialized. The global `window.newrelic` object
347
- * is not modified.
348
- */
349
319
  destroy() {
350
320
  this.initialized = !1, this.config?.debug && console.log("[NewRelicProvider] Destroyed");
351
321
  }
352
- /**
353
- * Track an error with New Relic
354
- *
355
- * Calls `newrelic.noticeError(error, attributes)`
356
- *
357
- * @param error The error to track
358
- * @param attributes Transformed attributes (already filtered and transformed by base class)
359
- */
360
- doTrackError(t, n) {
361
- window.newrelic.noticeError(t, n);
362
- }
363
- /**
364
- * Track a custom event/page action with New Relic
365
- *
366
- * Calls `newrelic.addPageAction(eventName, attributes)`
367
- *
368
- * @param eventName Name of the event
369
- * @param attributes Transformed attributes (already filtered and transformed by base class)
370
- */
371
- doTrackEvent(t, n) {
372
- window.newrelic.addPageAction(t, n);
373
- }
374
- /**
375
- * Set user context for session tracking
376
- *
377
- * Calls `newrelic.setUserId()` and `newrelic.setCustomAttribute()` for user attributes.
378
- *
379
- * @param userId User identifier
380
- * @param attributes Optional user attributes
381
- */
382
- doSetUserContext(t, n) {
383
- const i = window.newrelic;
384
- if (i.setUserId && i.setUserId(t), n && i.setCustomAttribute)
385
- for (const [o, r] of Object.entries(n))
386
- i.setCustomAttribute(o, r);
387
- }
388
- /**
389
- * Set global custom attributes
390
- *
391
- * Calls `newrelic.setCustomAttribute()` for each attribute.
392
- *
393
- * @param attributes Attributes to set globally
394
- */
395
- doSetGlobalAttributes(t) {
396
- const n = window.newrelic;
397
- if (n.setCustomAttribute)
398
- for (const [i, o] of Object.entries(t))
399
- n.setCustomAttribute(i, o);
322
+ doTrackError(e, t) {
323
+ window.newrelic.noticeError(e, t);
400
324
  }
325
+ doTrackEvent(e, t) {
326
+ window.newrelic.addPageAction(e, t);
327
+ }
328
+ doSetUserContext(e, t) {
329
+ const s = window.newrelic;
330
+ if (s.setUserId && s.setUserId(e), t && s.setCustomAttribute) for (const [n, i] of Object.entries(t)) s.setCustomAttribute(n, i);
331
+ }
332
+ doSetGlobalAttributes(e) {
333
+ const t = window.newrelic;
334
+ if (t.setCustomAttribute) for (const [s, n] of Object.entries(e)) t.setCustomAttribute(s, n);
335
+ }
336
+ };
337
+ function L(e) {
338
+ return e && typeof e == "object" ? e : {};
401
339
  }
402
- function x(s) {
403
- return s && typeof s == "object" ? s : {};
404
- }
405
- function R(s) {
406
- const e = x(s), t = x(e.loaderConfig);
340
+ function k(e) {
341
+ const t = L(L(e).loaderConfig);
407
342
  return Object.keys(t).length > 0 ? t : null;
408
343
  }
409
- function L(s) {
410
- if (!s || !("instrumentationProvider" in s))
411
- return { kind: "unset" };
412
- const e = s.instrumentationProvider;
413
- return e === null ? { kind: "null" } : typeof e > "u" ? { kind: "unset" } : { kind: "value", value: e };
344
+ function T(e) {
345
+ if (!e || !("instrumentationProvider" in e)) return { kind: "unset" };
346
+ const t = e.instrumentationProvider;
347
+ return t === null ? { kind: "null" } : typeof t > "u" ? { kind: "unset" } : {
348
+ kind: "value",
349
+ value: t
350
+ };
414
351
  }
415
- function k(s) {
416
- if (!s || !("trackPageActions" in s))
417
- return;
418
- const e = s.trackPageActions;
419
- return typeof e == "boolean" ? e : void 0;
352
+ function D(e) {
353
+ if (!e || !("trackPageActions" in e)) return;
354
+ const t = e.trackPageActions;
355
+ return typeof t == "boolean" ? t : void 0;
420
356
  }
421
- function Y(s, e) {
422
- return s.kind === "value" || s.kind === "null" ? s : e;
357
+ function ce(e, t) {
358
+ return e.kind === "value" || e.kind === "null" ? e : t;
423
359
  }
424
- let g;
425
- const Z = _("instrumentation-provider-resolution", () => D());
426
- function Q() {
427
- return g || (g = new K(), g.initialize()), g;
360
+ var v, de = p("instrumentation-provider-resolution", () => f());
361
+ function le() {
362
+ return v || (v = new ae(), v.initialize()), v;
428
363
  }
429
- function X(s) {
430
- const e = R(s.runtimePlayer), t = R(s.player), n = k(e), i = k(t), o = n ?? i ?? !1, r = Y(L(e), L(t));
431
- if (r.kind !== "null") {
432
- if (r.kind === "unset")
433
- return o ? Q() : void 0;
434
- if (U(r.value))
435
- return r.value;
436
- if (s.debug) {
437
- const c = s.component ? `[${s.component}] ` : "";
438
- Z.warn(`${c}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
364
+ function ue(e) {
365
+ const t = k(e.runtimePlayer), s = k(e.player), n = D(t), i = D(s), c = n ?? i ?? !1, o = ce(T(t), T(s));
366
+ if (o.kind !== "null") {
367
+ if (o.kind === "unset") return c ? le() : void 0;
368
+ if (G(o.value)) return o.value;
369
+ if (e.debug) {
370
+ const r = e.component ? `[${e.component}] ` : "";
371
+ de.warn(`${r}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
439
372
  }
440
373
  }
441
374
  }
442
- const ee = [
375
+ var he = [
443
376
  {
444
377
  sourceEventName: "assessment-controller-ready",
445
378
  instrumentationEventName: "pie-assessment-controller-ready"
@@ -473,105 +406,104 @@ const ee = [
473
406
  instrumentationEventName: "pie-assessment-error"
474
407
  }
475
408
  ];
476
- function p() {
409
+ function m() {
477
410
  return Date.now();
478
411
  }
479
- function v(s) {
480
- return s.replace(/[^a-zA-Z0-9_-]/g, "-");
412
+ function y(e) {
413
+ return e.replace(/[^a-zA-Z0-9_-]/g, "-");
481
414
  }
482
- function te(s) {
483
- if (s.attemptId)
484
- return `aas_v1_${v(s.assessmentId)}_${v(s.attemptId)}`;
485
- const e = $(), t = e ? se(e) : "anon";
486
- return `aas_v1_${v(s.assessmentId)}_${v(t)}`;
415
+ function me(e) {
416
+ if (e.attemptId) return `aas_v1_${y(e.assessmentId)}_${y(e.attemptId)}`;
417
+ const t = j(), s = t ? pe(t) : "anon";
418
+ return `aas_v1_${y(e.assessmentId)}_${y(s)}`;
487
419
  }
488
- function $() {
420
+ function j() {
489
421
  try {
490
422
  return typeof window > "u" ? null : window.localStorage;
491
423
  } catch {
492
424
  return null;
493
425
  }
494
426
  }
495
- function se(s) {
496
- const e = "pie:assessment-player:anonymous-device-id", t = s.getItem(e);
497
- if (t) return t;
427
+ function pe(e) {
428
+ const t = "pie:assessment-player:anonymous-device-id", s = e.getItem(t);
429
+ if (s) return s;
498
430
  const n = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
499
- return s.setItem(e, n), n;
431
+ return e.setItem(t, n), n;
500
432
  }
501
- function O() {
433
+ function H() {
502
434
  return (/* @__PURE__ */ new Date()).toISOString();
503
435
  }
504
- function ne(s) {
505
- const e = O(), t = s.sectionIdentifiers[0];
436
+ function fe(e) {
437
+ const t = H(), s = e.sectionIdentifiers[0];
506
438
  return {
507
439
  version: 1,
508
- assessmentAttemptSessionIdentifier: s.assessmentAttemptSessionIdentifier,
509
- assessmentId: s.assessmentId,
510
- startedAt: e,
511
- updatedAt: e,
440
+ assessmentAttemptSessionIdentifier: e.assessmentAttemptSessionIdentifier,
441
+ assessmentId: e.assessmentId,
442
+ startedAt: t,
443
+ updatedAt: t,
512
444
  navigationState: {
513
445
  currentSectionIndex: 0,
514
- visitedSectionIdentifiers: t ? [t] : [],
515
- currentSectionIdentifier: t
446
+ visitedSectionIdentifiers: s ? [s] : [],
447
+ currentSectionIdentifier: s
516
448
  },
517
449
  realization: {
518
- seed: s.seed,
519
- sectionIdentifiers: s.sectionIdentifiers
450
+ seed: e.seed,
451
+ sectionIdentifiers: e.sectionIdentifiers
520
452
  },
521
453
  sectionSessions: {}
522
454
  };
523
455
  }
524
- function ie(s, e) {
525
- const t = O();
456
+ function ge(e, t) {
457
+ const s = H();
526
458
  return {
527
- ...s,
528
- updatedAt: t,
459
+ ...e,
460
+ updatedAt: s,
529
461
  sectionSessions: {
530
- ...s.sectionSessions,
531
- [e.sectionIdentifier]: {
532
- sectionIdentifier: e.sectionIdentifier,
533
- updatedAt: t,
534
- session: e.sectionSession
462
+ ...e.sectionSessions,
463
+ [t.sectionIdentifier]: {
464
+ sectionIdentifier: t.sectionIdentifier,
465
+ updatedAt: s,
466
+ session: t.sectionSession
535
467
  }
536
468
  }
537
469
  };
538
470
  }
539
- function re(s, e) {
540
- const t = new Set(s.navigationState.visitedSectionIdentifiers || []);
541
- return e.currentSectionIdentifier && t.add(e.currentSectionIdentifier), {
542
- ...s,
471
+ function ve(e, t) {
472
+ const s = new Set(e.navigationState.visitedSectionIdentifiers || []);
473
+ return t.currentSectionIdentifier && s.add(t.currentSectionIdentifier), {
474
+ ...e,
543
475
  navigationState: {
544
- ...s.navigationState,
545
- currentSectionIndex: e.currentSectionIndex,
546
- currentSectionIdentifier: e.currentSectionIdentifier,
547
- visitedSectionIdentifiers: Array.from(t)
476
+ ...e.navigationState,
477
+ currentSectionIndex: t.currentSectionIndex,
478
+ currentSectionIdentifier: t.currentSectionIdentifier,
479
+ visitedSectionIdentifiers: Array.from(s)
548
480
  }
549
481
  };
550
482
  }
551
- function oe(s) {
552
- if (!s) return [];
553
- const e = [], t = s.testParts || [];
554
- return t.length > 0 ? (t.forEach((n, i) => {
555
- (n.sections || []).forEach((o, r) => {
556
- e.push({
483
+ function ye(e) {
484
+ if (!e) return [];
485
+ const t = [], s = e.testParts || [];
486
+ return s.length > 0 ? (s.forEach((n, i) => {
487
+ (n.sections || []).forEach((c, o) => {
488
+ t.push({
557
489
  stageIdentifier: n.identifier,
558
490
  stageIndex: i,
559
- sectionIndex: e.length,
560
- sectionIdentifier: o.identifier || `section-${i}-${r}`,
561
- section: o
491
+ sectionIndex: t.length,
492
+ sectionIdentifier: c.identifier || `section-${i}-${o}`,
493
+ section: c
562
494
  });
563
495
  });
564
- }), e) : ((s.sections || []).forEach((n, i) => {
565
- e.push({
496
+ }), t) : ((e.sections || []).forEach((n, i) => {
497
+ t.push({
566
498
  stageIdentifier: "default",
567
499
  stageIndex: 0,
568
500
  sectionIndex: i,
569
501
  sectionIdentifier: n.identifier || `section-${i}`,
570
502
  section: n
571
503
  });
572
- }), e);
504
+ }), t);
573
505
  }
574
- class ae {
506
+ var Se = class {
575
507
  constructor(e) {
576
508
  this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.storageContext = {
577
509
  assessmentId: e.assessmentId,
@@ -581,46 +513,40 @@ class ae {
581
513
  emit(e) {
582
514
  for (const t of this.listeners) t(e);
583
515
  }
584
- handleError(e, t, n) {
585
- const i = e instanceof Error ? e : new Error(String(e));
586
- this.args.hooks?.onError?.(i, { phase: t, details: n });
516
+ handleError(e, t, s) {
517
+ const n = e instanceof Error ? e : new Error(String(e));
518
+ this.args.hooks?.onError?.(n, {
519
+ phase: t,
520
+ details: s
521
+ });
587
522
  }
588
523
  async getPersistenceStrategy() {
589
524
  if (this.persistenceStrategy) return this.persistenceStrategy;
590
- const e = {
591
- createDefaultPersistence: () => {
592
- const t = $(), n = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
593
- return {
594
- async loadSession() {
595
- if (!t) return null;
596
- const i = t.getItem(n);
597
- if (!i) return null;
598
- try {
599
- return JSON.parse(i);
600
- } catch {
601
- return null;
602
- }
603
- },
604
- async saveSession(i, o) {
605
- t && t.setItem(n, JSON.stringify(o));
606
- },
607
- async clearSession() {
608
- t && t.removeItem(n);
525
+ const e = { createDefaultPersistence: () => {
526
+ const t = j(), s = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
527
+ return {
528
+ async loadSession() {
529
+ if (!t) return null;
530
+ const n = t.getItem(s);
531
+ if (!n) return null;
532
+ try {
533
+ return JSON.parse(n);
534
+ } catch {
535
+ return null;
609
536
  }
610
- };
611
- }
612
- };
613
- return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(
614
- this.storageContext,
615
- e
616
- ) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
537
+ },
538
+ async saveSession(n, i) {
539
+ t && t.setItem(s, JSON.stringify(i));
540
+ },
541
+ async clearSession() {
542
+ t && t.removeItem(s);
543
+ }
544
+ };
545
+ } };
546
+ return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(this.storageContext, e) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
617
547
  }
618
548
  async createDeliveryPlan() {
619
- const e = {
620
- createDefaultDeliveryPlan: () => ({
621
- sections: oe(this.args.assessment)
622
- })
623
- }, t = {
549
+ const e = { createDefaultDeliveryPlan: () => ({ sections: ye(this.args.assessment) }) }, t = {
624
550
  assessmentId: this.args.assessmentId,
625
551
  attemptId: this.args.attemptId,
626
552
  assessment: this.args.assessment
@@ -630,8 +556,8 @@ class ae {
630
556
  ensureSession() {
631
557
  if (this.session) return this.session;
632
558
  const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
633
- return this.session = ne({
634
- assessmentAttemptSessionIdentifier: te({
559
+ return this.session = fe({
560
+ assessmentAttemptSessionIdentifier: me({
635
561
  assessmentId: this.args.assessmentId,
636
562
  attemptId: this.args.attemptId
637
563
  }),
@@ -651,8 +577,11 @@ class ae {
651
577
  this.readiness = "hydrating";
652
578
  try {
653
579
  await this.args.hooks?.onBeforeAssessmentHydrate?.(this.storageContext);
654
- const t = await (await this.getPersistenceStrategy()).loadSession(this.storageContext);
655
- t && (this.session = t, this.emit({ type: "assessment-session-applied", timestamp: p() })), this.ensureSession(), this.readiness = "ready";
580
+ const e = await (await this.getPersistenceStrategy()).loadSession(this.storageContext);
581
+ e && (this.session = e, this.emit({
582
+ type: "assessment-session-applied",
583
+ timestamp: m()
584
+ })), this.ensureSession(), this.readiness = "ready";
656
585
  } catch (e) {
657
586
  this.readiness = "error", this.handleError(e, "session-load");
658
587
  }
@@ -660,10 +589,7 @@ class ae {
660
589
  async persist() {
661
590
  try {
662
591
  const e = await this.getPersistenceStrategy();
663
- await this.args.hooks?.onBeforeAssessmentPersist?.(
664
- this.storageContext,
665
- this.session
666
- ), await e.saveSession(this.storageContext, this.session);
592
+ await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), await e.saveSession(this.storageContext, this.session);
667
593
  } catch (e) {
668
594
  this.handleError(e, "session-save");
669
595
  }
@@ -685,17 +611,11 @@ class ae {
685
611
  };
686
612
  }
687
613
  buildNavigationSnapshot() {
688
- const e = this.deliveryPlan.sections.length, t = Math.max(
689
- 0,
690
- Math.min(
691
- e > 0 ? e - 1 : 0,
692
- this.session?.navigationState.currentSectionIndex || 0
693
- )
694
- ), n = this.deliveryPlan.sections[t];
614
+ const e = this.deliveryPlan.sections.length, t = Math.max(0, Math.min(e > 0 ? e - 1 : 0, this.session?.navigationState.currentSectionIndex || 0));
695
615
  return {
696
616
  currentSectionIndex: t,
697
617
  totalSections: e,
698
- currentSectionId: n?.sectionIdentifier,
618
+ currentSectionId: this.deliveryPlan.sections[t]?.sectionIdentifier,
699
619
  canNext: t < e - 1,
700
620
  canPrevious: t > 0
701
621
  };
@@ -703,34 +623,34 @@ class ae {
703
623
  setIndex(e) {
704
624
  const t = this.buildNavigationSnapshot();
705
625
  if (e < 0 || e >= t.totalSections) return !1;
706
- const n = t.currentSectionId, i = this.deliveryPlan.sections[e];
707
- this.session = re(this.ensureSession(), {
626
+ const s = t.currentSectionId, n = this.deliveryPlan.sections[e];
627
+ this.session = ve(this.ensureSession(), {
708
628
  currentSectionIndex: e,
709
- currentSectionIdentifier: i?.sectionIdentifier
629
+ currentSectionIdentifier: n?.sectionIdentifier
710
630
  });
711
- const o = this.buildNavigationSnapshot();
631
+ const i = this.buildNavigationSnapshot();
712
632
  return this.emit({
713
633
  type: "assessment-route-changed",
714
- timestamp: p(),
715
- currentSectionIndex: o.currentSectionIndex,
716
- totalSections: o.totalSections,
717
- currentSectionId: o.currentSectionId,
718
- previousSectionId: n,
719
- canNext: o.canNext,
720
- canPrevious: o.canPrevious
721
- }), this.emit({ type: "assessment-session-changed", timestamp: p() }), this.emit({
634
+ timestamp: m(),
635
+ currentSectionIndex: i.currentSectionIndex,
636
+ totalSections: i.totalSections,
637
+ currentSectionId: i.currentSectionId,
638
+ previousSectionId: s,
639
+ canNext: i.canNext,
640
+ canPrevious: i.canPrevious
641
+ }), this.emit({
642
+ type: "assessment-session-changed",
643
+ timestamp: m()
644
+ }), this.emit({
722
645
  type: "assessment-progress-changed",
723
- timestamp: p(),
646
+ timestamp: m(),
724
647
  visitedSectionCount: this.ensureSession().navigationState.visitedSectionIdentifiers.length,
725
- totalSections: o.totalSections
648
+ totalSections: i.totalSections
726
649
  }), !0;
727
650
  }
728
651
  navigateTo(e) {
729
- if (typeof e == "number")
730
- return this.setIndex(e);
731
- const t = this.deliveryPlan.sections.findIndex(
732
- (n) => n.sectionIdentifier === e
733
- );
652
+ if (typeof e == "number") return this.setIndex(e);
653
+ const t = this.deliveryPlan.sections.findIndex((s) => s.sectionIdentifier === e);
734
654
  return t < 0 ? !1 : this.setIndex(t);
735
655
  }
736
656
  navigateNext() {
@@ -744,7 +664,7 @@ class ae {
744
664
  async submit() {
745
665
  this.submitted = !0, this.emit({
746
666
  type: "assessment-submission-state-changed",
747
- timestamp: p(),
667
+ timestamp: m(),
748
668
  submitted: !0
749
669
  }), await this.persist();
750
670
  }
@@ -762,13 +682,15 @@ class ae {
762
682
  return this.ensureSession().sectionSessions[e]?.session || null;
763
683
  }
764
684
  updateSectionSession(e, t) {
765
- this.session = ie(this.ensureSession(), {
685
+ this.session = ge(this.ensureSession(), {
766
686
  sectionIdentifier: e,
767
687
  sectionSession: t
768
- }), this.emit({ type: "assessment-session-changed", timestamp: p() });
688
+ }), this.emit({
689
+ type: "assessment-session-changed",
690
+ timestamp: m()
691
+ });
769
692
  }
770
- }
771
- const l = {
693
+ }, u = {
772
694
  controllerReady: "assessment-controller-ready",
773
695
  navigationRequested: "assessment-navigation-requested",
774
696
  submitRequested: "assessment-submit-requested",
@@ -778,21 +700,14 @@ const l = {
778
700
  progressChanged: "assessment-progress-changed",
779
701
  submissionStateChanged: "assessment-submission-state-changed",
780
702
  error: "assessment-error"
781
- }, ce = "pie-section-player-splitpane", de = "pie-section-player-vertical";
782
- function le(s, e = !1) {
783
- if (s == null) return e;
784
- if (typeof s == "boolean") return s;
785
- const t = s.trim().toLowerCase();
786
- return t === "" || t === "true" || t === "1" || t === "yes";
703
+ }, Ie = "pie-section-player-splitpane", be = "pie-section-player-vertical";
704
+ function Ee(e, t = !1) {
705
+ if (e == null) return t;
706
+ if (typeof e == "boolean") return e;
707
+ const s = e.trim().toLowerCase();
708
+ return s === "" || s === "true" || s === "1" || s === "yes";
787
709
  }
788
- class ue extends HTMLElement {
789
- constructor() {
790
- super(), this.assessmentId = "", this.attemptId = "", 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.controllerReadyPromise = null, this.controllerReadyResolve = null, this.sectionHost = null, this.sectionControllerRef = null, this._sectionPlayerRuntime = null, this._sectionPlayerPlayer = null, this.readiness = {
791
- phase: "bootstrapping"
792
- }, this.controllerReadyPromise = new Promise((e) => {
793
- this.controllerReadyResolve = e;
794
- });
795
- }
710
+ var Pe = class extends HTMLElement {
796
711
  static get observedAttributes() {
797
712
  return [
798
713
  "assessment-id",
@@ -803,8 +718,13 @@ class ue extends HTMLElement {
803
718
  "debug"
804
719
  ];
805
720
  }
806
- attributeChangedCallback(e, t, n) {
807
- e === "assessment-id" && (this.assessmentId = n || ""), e === "attempt-id" && (this.attemptId = n || ""), e === "show-navigation" && (this.showNavigation = n), e === "section-player-layout" && (this.sectionPlayerLayout = n === "vertical" ? "vertical" : "splitpane"), e === "player-type" && (this.playerType = n || "iife"), e === "debug" && (this.debug = n), this.isConnected && this.bootstrapController();
721
+ constructor() {
722
+ super(), this.assessmentId = "", this.attemptId = "", 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.controllerReadyPromise = null, this.controllerReadyResolve = null, this.sectionHost = null, this.sectionControllerRef = null, this._sectionPlayerRuntime = null, this._sectionPlayerPlayer = null, this.readiness = { phase: "bootstrapping" }, this.controllerReadyPromise = new Promise((e) => {
723
+ this.controllerReadyResolve = e;
724
+ });
725
+ }
726
+ attributeChangedCallback(e, t, s) {
727
+ e === "assessment-id" && (this.assessmentId = s || ""), e === "attempt-id" && (this.attemptId = s || ""), e === "show-navigation" && (this.showNavigation = s), e === "section-player-layout" && (this.sectionPlayerLayout = s === "vertical" ? "vertical" : "splitpane"), e === "player-type" && (this.playerType = s || "iife"), e === "debug" && (this.debug = s), this.isConnected && this.bootstrapController();
808
728
  }
809
729
  get debug() {
810
730
  return this._debug;
@@ -825,24 +745,20 @@ class ue extends HTMLElement {
825
745
  this._sectionPlayerPlayer = e, this.isConnected && this.attachInstrumentationBridge();
826
746
  }
827
747
  connectedCallback() {
828
- this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation;
829
- const e = this.getAttribute("section-player-layout");
830
- this.sectionPlayerLayout = e === "vertical" ? "vertical" : this.sectionPlayerLayout;
831
- const t = this.getAttribute("player-type");
832
- t && (this.playerType = t), this.debug = this.getAttribute("debug") ?? this.debug, this.attachInstrumentationBridge(), this.bootstrapController();
748
+ this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation, this.sectionPlayerLayout = this.getAttribute("section-player-layout") === "vertical" ? "vertical" : this.sectionPlayerLayout;
749
+ const e = this.getAttribute("player-type");
750
+ e && (this.playerType = e), this.debug = this.getAttribute("debug") ?? this.debug, this.attachInstrumentationBridge(), this.bootstrapController();
833
751
  }
834
752
  disconnectedCallback() {
835
753
  this.unsubscribeController?.(), this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = void 0, this.hooks?.onAssessmentControllerDispose?.(this.controller || void 0);
836
754
  }
837
- dispatch(e, t, n = !1) {
838
- return this.dispatchEvent(
839
- new CustomEvent(e, {
840
- detail: t,
841
- bubbles: !0,
842
- composed: !0,
843
- cancelable: n
844
- })
845
- );
755
+ dispatch(e, t, s = !1) {
756
+ return this.dispatchEvent(new CustomEvent(e, {
757
+ detail: t,
758
+ bubbles: !0,
759
+ composed: !0,
760
+ cancelable: s
761
+ }));
846
762
  }
847
763
  async bootstrapController() {
848
764
  if (!this.assessmentId || !this.assessment) {
@@ -850,47 +766,34 @@ class ue extends HTMLElement {
850
766
  return;
851
767
  }
852
768
  this.readiness = { phase: "bootstrapping" }, this.render();
853
- const e = new ae({
769
+ const e = new Se({
854
770
  assessmentId: this.assessmentId,
855
771
  attemptId: this.attemptId || void 0,
856
772
  assessment: this.assessment,
857
773
  hooks: this.hooks || void 0
858
774
  });
859
775
  this.unsubscribeController?.(), this.controller = e, this.unsubscribeController = e.subscribe((t) => {
860
- t.type === "assessment-route-changed" && (this.dispatch(
861
- l.routeChanged,
862
- t
863
- ), this.render()), t.type === "assessment-session-applied" && this.dispatch(l.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(l.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(
864
- l.progressChanged,
865
- t
866
- ), t.type === "assessment-submission-state-changed" && this.dispatch(
867
- l.submissionStateChanged,
868
- t
869
- );
776
+ t.type === "assessment-route-changed" && (this.dispatch(u.routeChanged, t), this.render()), t.type === "assessment-session-applied" && this.dispatch(u.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(u.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(u.progressChanged, t), t.type === "assessment-submission-state-changed" && this.dispatch(u.submissionStateChanged, t);
870
777
  });
871
778
  try {
872
- await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(l.controllerReady, {
873
- controller: e
874
- }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
779
+ await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(u.controllerReady, { controller: e }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
875
780
  } catch (t) {
876
- this.readiness = { phase: "error" }, this.dispatch(l.error, {
877
- error: t
878
- }), this.renderEmptyState("Failed to initialize assessment player");
781
+ this.readiness = { phase: "error" }, this.dispatch(u.error, { error: t }), this.renderEmptyState("Failed to initialize assessment player");
879
782
  }
880
783
  }
881
784
  resolveInstrumentationProvider() {
882
- return X({
785
+ return ue({
883
786
  runtimePlayer: this.sectionPlayerRuntime?.player,
884
787
  player: this.sectionPlayerPlayer,
885
788
  component: "pie-assessment-player-default"
886
789
  });
887
790
  }
888
791
  attachInstrumentationBridge() {
889
- this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = J({
792
+ this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = re({
890
793
  host: this,
891
794
  instrumentationProvider: this.resolveInstrumentationProvider(),
892
795
  component: "pie-assessment-player-default",
893
- eventMap: ee,
796
+ eventMap: he,
894
797
  staticAttributes: {
895
798
  instrumentationLayer: "assessment",
896
799
  assessmentId: this.assessmentId,
@@ -904,40 +807,30 @@ class ue extends HTMLElement {
904
807
  t.className = "pie-assessment-player-empty", t.textContent = e, this.appendChild(t);
905
808
  }
906
809
  buildSectionPlayerTag() {
907
- return this.sectionPlayerLayout === "vertical" ? de : ce;
810
+ return this.sectionPlayerLayout === "vertical" ? be : Ie;
908
811
  }
909
812
  syncCurrentSectionSessionIntoAssessment() {
910
813
  const e = this.controller;
911
814
  if (!e) return;
912
815
  const t = this.sectionControllerRef || this.sectionHost?.firstElementChild?.getSectionController?.();
913
816
  if (!t?.getSession) return;
914
- const n = e.getCurrentSection();
915
- n && e.updateSectionSession(
916
- n.sectionIdentifier,
917
- t.getSession()
918
- );
817
+ const s = e.getCurrentSection();
818
+ s && e.updateSectionSession(s.sectionIdentifier, t.getSession());
919
819
  }
920
820
  attachSectionControllerReadyListener(e, t) {
921
- e.addEventListener("section-controller-ready", async (n) => {
922
- const i = n.detail;
923
- this.sectionControllerRef = i?.controller || null;
924
- const o = this.controller?.getSectionSession(t);
925
- o && this.sectionControllerRef?.applySession && await this.sectionControllerRef.applySession(o, { mode: "replace" });
926
- }), e.addEventListener(
927
- "session-changed",
928
- () => this.syncCurrentSectionSessionIntoAssessment()
929
- ), e.addEventListener(
930
- "item-session-changed",
931
- () => this.syncCurrentSectionSessionIntoAssessment()
932
- );
821
+ e.addEventListener("section-controller-ready", async (s) => {
822
+ this.sectionControllerRef = s.detail?.controller || null;
823
+ const n = this.controller?.getSectionSession(t);
824
+ n && this.sectionControllerRef?.applySession && await this.sectionControllerRef.applySession(n, { mode: "replace" });
825
+ }), e.addEventListener("session-changed", () => this.syncCurrentSectionSessionIntoAssessment()), e.addEventListener("item-session-changed", () => this.syncCurrentSectionSessionIntoAssessment());
933
826
  }
934
827
  render() {
935
828
  const e = this.controller;
936
829
  this.attachInstrumentationBridge(), this.innerHTML = "";
937
830
  const t = document.createElement("div");
938
831
  t.className = "pie-assessment-player-default";
939
- const n = document.createElement("style");
940
- n.textContent = `
832
+ const s = document.createElement("style");
833
+ s.textContent = `
941
834
  :host {
942
835
  display: block;
943
836
  height: 100%;
@@ -984,39 +877,32 @@ class ue extends HTMLElement {
984
877
  height: 100%;
985
878
  overflow: hidden;
986
879
  }
987
- `, t.appendChild(n);
988
- const i = this.getSnapshot();
989
- if (le(this.showNavigation, !0)) {
880
+ `, t.appendChild(s);
881
+ const n = this.getSnapshot();
882
+ if (Ee(this.showNavigation, !0)) {
883
+ const o = document.createElement("div");
884
+ o.className = "pie-assessment-player-navigation";
885
+ const r = document.createElement("div");
886
+ r.className = "pie-assessment-player-current-position", r.textContent = n.navigation.totalSections > 0 ? `Section ${n.navigation.currentIndex + 1} of ${n.navigation.totalSections}` : "No sections";
990
887
  const d = document.createElement("div");
991
- d.className = "pie-assessment-player-navigation";
992
- const a = document.createElement("div");
993
- a.className = "pie-assessment-player-current-position", a.textContent = i.navigation.totalSections > 0 ? `Section ${i.navigation.currentIndex + 1} of ${i.navigation.totalSections}` : "No sections";
994
- const u = document.createElement("div");
995
- u.className = "pie-assessment-player-nav-controls";
996
- const m = document.createElement("button");
997
- m.className = "pie-assessment-player-nav-btn", m.textContent = "Back", m.disabled = !i.navigation.canPrevious, m.addEventListener("click", () => {
998
- this.navigatePrevious();
999
- });
888
+ d.className = "pie-assessment-player-nav-controls";
889
+ const l = document.createElement("button");
890
+ l.className = "pie-assessment-player-nav-btn", l.textContent = "Back", l.disabled = !n.navigation.canPrevious, l.addEventListener("click", () => void this.navigatePrevious());
1000
891
  const h = document.createElement("button");
1001
- h.className = "pie-assessment-player-nav-btn", h.textContent = "Next", h.disabled = !i.navigation.canNext, h.addEventListener("click", () => {
1002
- this.navigateNext();
1003
- }), u.appendChild(m), u.appendChild(h), d.appendChild(a), d.appendChild(u), t.appendChild(d);
892
+ h.className = "pie-assessment-player-nav-btn", h.textContent = "Next", h.disabled = !n.navigation.canNext, h.addEventListener("click", () => void this.navigateNext()), d.appendChild(l), d.appendChild(h), o.appendChild(r), o.appendChild(d), t.appendChild(o);
1004
893
  }
1005
- const r = document.createElement("div");
1006
- r.className = "pie-assessment-player-section-host", this.sectionHost = r;
894
+ const i = document.createElement("div");
895
+ i.className = "pie-assessment-player-section-host", this.sectionHost = i;
1007
896
  const c = e?.getCurrentSection() || null;
1008
897
  if (c) {
1009
- const d = this.buildSectionPlayerTag(), a = document.createElement(d);
1010
- if (a.setAttribute("assessment-id", this.assessmentId), a.setAttribute("section-id", c.sectionIdentifier), this.attemptId && a.setAttribute("attempt-id", this.attemptId), a.setAttribute("player-type", this.playerType), this.debug !== void 0 && this.debug !== null) {
1011
- const u = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
1012
- a.setAttribute("debug", u);
898
+ const o = this.buildSectionPlayerTag(), r = document.createElement(o);
899
+ if (r.setAttribute("assessment-id", this.assessmentId), r.setAttribute("section-id", c.sectionIdentifier), this.attemptId && r.setAttribute("attempt-id", this.attemptId), r.setAttribute("player-type", this.playerType), this.debug !== void 0 && this.debug !== null) {
900
+ const d = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
901
+ r.setAttribute("debug", d);
1013
902
  }
1014
- a.section = c.section, this.env && (a.env = this.env), this.coordinator && (a.coordinator = this.coordinator), this.sectionPlayerRuntime && (a.runtime = this.sectionPlayerRuntime), this.sectionPlayerPlayer && (a.player = this.sectionPlayerPlayer), this.attachSectionControllerReadyListener(
1015
- a,
1016
- c.sectionIdentifier
1017
- ), r.appendChild(a);
903
+ r.section = c.section, this.env && (r.env = this.env), this.coordinator && (r.coordinator = this.coordinator), this.sectionPlayerRuntime && (r.runtime = this.sectionPlayerRuntime), this.sectionPlayerPlayer && (r.player = this.sectionPlayerPlayer), this.attachSectionControllerReadyListener(r, c.sectionIdentifier), i.appendChild(r);
1018
904
  }
1019
- t.appendChild(r), this.appendChild(t);
905
+ t.appendChild(i), this.appendChild(t);
1020
906
  }
1021
907
  applyDebugFlag() {
1022
908
  if (this.debug === void 0 || this.debug === null || typeof window > "u") return;
@@ -1034,12 +920,11 @@ class ue extends HTMLElement {
1034
920
  currentSectionId: void 0,
1035
921
  canNext: !1,
1036
922
  canPrevious: !1,
1037
- visitedSections: 0
923
+ visitedSections: 0,
924
+ submitted: !1
1038
925
  };
1039
926
  return {
1040
- readiness: {
1041
- phase: e.readiness
1042
- },
927
+ readiness: { phase: e.readiness },
1043
928
  navigation: {
1044
929
  currentIndex: e.currentSectionIndex,
1045
930
  totalSections: e.totalSections,
@@ -1063,84 +948,69 @@ class ue extends HTMLElement {
1063
948
  return this.getSnapshot().progress;
1064
949
  }
1065
950
  navigateTo(e) {
1066
- const t = this.selectNavigation(), n = t.currentIndex, i = t.currentSectionId;
1067
- let o = n, r;
951
+ const t = this.selectNavigation(), s = t.currentIndex, n = t.currentSectionId;
952
+ let i = s, c;
1068
953
  if (typeof e == "number")
1069
- o = e, r = this.controller?.getSectionAt(o)?.sectionIdentifier;
1070
- else if (r = e, this.controller?.getCurrentSection()?.sectionIdentifier === r) return !0;
1071
- if (!this.dispatch(
1072
- l.navigationRequested,
1073
- {
1074
- fromIndex: n,
1075
- toIndex: o,
1076
- fromSectionId: i,
1077
- toSectionId: r,
1078
- reason: "navigate-to"
1079
- },
1080
- !0
1081
- )) return !1;
954
+ i = e, c = this.controller?.getSectionAt(i)?.sectionIdentifier;
955
+ else if (c = e, this.controller?.getCurrentSection()?.sectionIdentifier === c) return !0;
956
+ if (!this.dispatch(u.navigationRequested, {
957
+ fromIndex: s,
958
+ toIndex: i,
959
+ fromSectionId: n,
960
+ toSectionId: c,
961
+ reason: "navigate-to"
962
+ }, !0)) return !1;
1082
963
  this.syncCurrentSectionSessionIntoAssessment();
1083
- const d = this.controller?.navigateTo(e) === !0;
1084
- return d && this.controller?.persist(), d;
964
+ const o = this.controller?.navigateTo(e) === !0;
965
+ return o && this.controller?.persist(), o;
1085
966
  }
1086
967
  navigateNext() {
1087
968
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
1088
- if (!this.dispatch(
1089
- l.navigationRequested,
1090
- {
1091
- fromIndex: e.currentIndex,
1092
- toIndex: e.currentIndex + 1,
1093
- fromSectionId: e.currentSectionId,
1094
- toSectionId: t?.sectionIdentifier,
1095
- reason: "navigate-next"
1096
- },
1097
- !0
1098
- )) return !1;
969
+ if (!this.dispatch(u.navigationRequested, {
970
+ fromIndex: e.currentIndex,
971
+ toIndex: e.currentIndex + 1,
972
+ fromSectionId: e.currentSectionId,
973
+ toSectionId: t?.sectionIdentifier,
974
+ reason: "navigate-next"
975
+ }, !0)) return !1;
1099
976
  this.syncCurrentSectionSessionIntoAssessment();
1100
- const i = this.controller?.navigateNext() === !0;
1101
- return i && this.controller?.persist(), i;
977
+ const s = this.controller?.navigateNext() === !0;
978
+ return s && this.controller?.persist(), s;
1102
979
  }
1103
980
  navigatePrevious() {
1104
981
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
1105
- if (!this.dispatch(
1106
- l.navigationRequested,
1107
- {
1108
- fromIndex: e.currentIndex,
1109
- toIndex: e.currentIndex - 1,
1110
- fromSectionId: e.currentSectionId,
1111
- toSectionId: t?.sectionIdentifier,
1112
- reason: "navigate-previous"
1113
- },
1114
- !0
1115
- )) return !1;
982
+ if (!this.dispatch(u.navigationRequested, {
983
+ fromIndex: e.currentIndex,
984
+ toIndex: e.currentIndex - 1,
985
+ fromSectionId: e.currentSectionId,
986
+ toSectionId: t?.sectionIdentifier,
987
+ reason: "navigate-previous"
988
+ }, !0)) return !1;
1116
989
  this.syncCurrentSectionSessionIntoAssessment();
1117
- const i = this.controller?.navigatePrevious() === !0;
1118
- return i && this.controller?.persist(), i;
990
+ const s = this.controller?.navigatePrevious() === !0;
991
+ return s && this.controller?.persist(), s;
1119
992
  }
1120
993
  getAssessmentController() {
1121
994
  return this.controller;
1122
995
  }
1123
996
  async waitForAssessmentController(e = 5e3) {
1124
997
  if (this.controller) return this.controller;
1125
- const t = this.controllerReadyPromise || Promise.resolve(null), n = new Promise((i) => {
1126
- setTimeout(() => i(null), e);
998
+ const t = this.controllerReadyPromise || Promise.resolve(null), s = new Promise((n) => {
999
+ setTimeout(() => n(null), e);
1127
1000
  });
1128
- return Promise.race([t, n]);
1001
+ return Promise.race([t, s]);
1129
1002
  }
1003
+ };
1004
+ customElements.get("pie-assessment-player-default") || customElements.define("pie-assessment-player-default", Pe);
1005
+ function we(e, t = !1) {
1006
+ if (e == null) return t;
1007
+ if (typeof e == "boolean") return e;
1008
+ const s = e.trim().toLowerCase();
1009
+ return s === "" || s === "true" || s === "1" || s === "yes";
1130
1010
  }
1131
- customElements.get("pie-assessment-player-default") || customElements.define(
1132
- "pie-assessment-player-default",
1133
- ue
1134
- );
1135
- function he(s, e = !1) {
1136
- if (s == null) return e;
1137
- if (typeof s == "boolean") return s;
1138
- const t = s.trim().toLowerCase();
1139
- return t === "" || t === "true" || t === "1" || t === "yes";
1140
- }
1141
- class me extends HTMLElement {
1142
- constructor() {
1143
- super(...arguments), this.showNavigation = !0;
1011
+ var Ne = class extends HTMLElement {
1012
+ constructor(...e) {
1013
+ super(...e), this.showNavigation = !0;
1144
1014
  }
1145
1015
  static get observedAttributes() {
1146
1016
  return ["show-navigation"];
@@ -1148,11 +1018,11 @@ class me extends HTMLElement {
1148
1018
  connectedCallback() {
1149
1019
  this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation, this.render();
1150
1020
  }
1151
- attributeChangedCallback(e, t, n) {
1152
- e === "show-navigation" && (this.showNavigation = n), this.render();
1021
+ attributeChangedCallback(e, t, s) {
1022
+ e === "show-navigation" && (this.showNavigation = s), this.render();
1153
1023
  }
1154
1024
  render() {
1155
- const e = he(this.showNavigation, !0);
1025
+ const e = we(this.showNavigation, !0);
1156
1026
  this.innerHTML = "";
1157
1027
  const t = document.createElement("style");
1158
1028
  t.textContent = `
@@ -1173,18 +1043,18 @@ class me extends HTMLElement {
1173
1043
  overflow: hidden;
1174
1044
  }
1175
1045
  `;
1176
- const n = document.createElement("div");
1177
- if (n.className = "pie-assessment-player-shell", e) {
1178
- const r = document.createElement("slot");
1179
- r.name = "navigation", n.appendChild(r);
1046
+ const s = document.createElement("div");
1047
+ if (s.className = "pie-assessment-player-shell", e) {
1048
+ const c = document.createElement("slot");
1049
+ c.name = "navigation", s.appendChild(c);
1180
1050
  }
1181
- const i = document.createElement("div");
1182
- i.className = "pie-assessment-player-shell__body";
1183
- const o = document.createElement("slot");
1184
- i.appendChild(o), n.appendChild(i), this.appendChild(t), this.appendChild(n);
1051
+ const n = document.createElement("div");
1052
+ n.className = "pie-assessment-player-shell__body";
1053
+ const i = document.createElement("slot");
1054
+ n.appendChild(i), s.appendChild(n), this.appendChild(t), this.appendChild(s);
1185
1055
  }
1186
- }
1187
- customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell", me);
1056
+ };
1057
+ customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell", Ne);
1188
1058
  export {
1189
- l as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1059
+ u as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1190
1060
  };