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

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