@citolab/qti-components 10.0.0-next.16 → 10.0.0-next.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +233 -459
  3. package/dist/base.d.ts +12 -10
  4. package/dist/base.js +1 -0
  5. package/dist/chunk-DJ7PB252.js +7 -0
  6. package/dist/chunk-DJ7PB252.js.map +1 -0
  7. package/dist/chunk-J6VX4N7M.js +197 -0
  8. package/dist/chunk-J6VX4N7M.js.map +1 -0
  9. package/dist/chunk-PZ5AY32C.js +10 -0
  10. package/dist/chunk-PZ5AY32C.js.map +1 -0
  11. package/dist/{chunk-NWSDBYK7.js → chunk-QLGUI5VG.js} +2 -2
  12. package/dist/chunk-UCXLDQYA.js +56 -0
  13. package/dist/chunk-UCXLDQYA.js.map +1 -0
  14. package/dist/{chunk-LQ65RILE.js → chunk-UURHLJVM.js} +66 -1803
  15. package/dist/chunk-UURHLJVM.js.map +1 -0
  16. package/dist/{chunk-4DC5Z2LQ.js → chunk-V5GL7PTC.js} +2 -2
  17. package/dist/{chunk-M4TZIB3W.js → chunk-WGUQCB2Z.js} +4 -54
  18. package/dist/chunk-WGUQCB2Z.js.map +1 -0
  19. package/dist/{chunk-H3Z3TMFB.js → chunk-ZAHZVBV7.js} +8 -18
  20. package/dist/chunk-ZAHZVBV7.js.map +1 -0
  21. package/dist/{computed.types.d-n3K2VvB0.d.ts → computed.types.d-D4wskgi0.d.ts} +1 -1
  22. package/dist/corrections.d.ts +13 -14
  23. package/dist/corrections.js +6 -6
  24. package/dist/corrections.js.map +1 -1
  25. package/dist/elements.d.ts +5 -105
  26. package/dist/elements.js +7 -4
  27. package/dist/index.d.ts +17 -13
  28. package/dist/index.js +15 -55
  29. package/dist/interactions.d.ts +5 -4
  30. package/dist/interactions.js +1 -0
  31. package/dist/item.d.ts +6 -4
  32. package/dist/item.js +1 -0
  33. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  34. package/dist/loader.d.ts +4 -2
  35. package/dist/loader.js +1 -0
  36. package/dist/processing.d.ts +4 -3
  37. package/dist/processing.js +1 -0
  38. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  39. package/dist/qti-components-jsx.d.ts +2686 -4046
  40. package/dist/{qti-condition-expression.d-B-T1NNl0.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  41. package/dist/{qti-expression.d-B-Cfbqlb.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  42. package/dist/{qti-feedback.d-1JL_qHjc.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +1 -1
  43. package/dist/{qti-item.d-DDMDjWIk.d.ts → qti-item.d-CLChmRvB.d.ts} +2 -1
  44. package/dist/qti-test-state-BAf5AmJ2.d.ts +68 -0
  45. package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
  46. package/dist/{qti-test.d-CDdyCp6e.d.ts → qti-test.d-COzv7YZG.d.ts} +9 -546
  47. package/dist/{qti-text-entry-interaction.d-BTAKmr4b.d.ts → qti-text-entry-interaction.d-DsUyecBC.d.ts} +3 -2
  48. package/dist/{record.d-Bojj6_LW.d.ts → record.d-BfZhFr0L.d.ts} +1 -1
  49. package/dist/{session.context.d-BNxGeyh9.d.ts → session.context.d-9gRdGK4T.d.ts} +1 -1
  50. package/dist/test-plugin-api.d.ts +134 -0
  51. package/dist/test-plugin-api.js +19 -0
  52. package/dist/test-plugin-api.js.map +1 -0
  53. package/dist/test.d.ts +16 -158
  54. package/dist/test.js +11 -50
  55. package/dist/transformers.js +1 -0
  56. package/dist/{item.types.d-DuVR0ZVK.d.ts → variables.d-DWHlTszN.d.ts} +1 -23
  57. package/package.json +7 -3
  58. package/dist/chunk-H3Z3TMFB.js.map +0 -1
  59. package/dist/chunk-LQ65RILE.js.map +0 -1
  60. package/dist/chunk-M4TZIB3W.js.map +0 -1
  61. /package/dist/{chunk-NWSDBYK7.js.map → chunk-QLGUI5VG.js.map} +0 -0
  62. /package/dist/{chunk-4DC5Z2LQ.js.map → chunk-V5GL7PTC.js.map} +0 -0
@@ -1,9 +1,16 @@
1
1
  import {
2
- QtiModalFeedback,
3
- dispatchDeclared,
4
- listenDeclared,
2
+ button,
3
+ buttonPrimary,
4
+ control,
5
+ dispatchPublic,
6
+ listenPublic as listenPublic2
7
+ } from "./chunk-J6VX4N7M.js";
8
+ import {
9
+ QtiModalFeedback
10
+ } from "./chunk-WGUQCB2Z.js";
11
+ import {
5
12
  listenPublic
6
- } from "./chunk-M4TZIB3W.js";
13
+ } from "./chunk-UCXLDQYA.js";
7
14
  import {
8
15
  item_css_default
9
16
  } from "./chunk-WWY2H2YO.js";
@@ -21,7 +28,6 @@ import {
21
28
  QtiExpression,
22
29
  computedContext,
23
30
  configContext,
24
- isRecordValue,
25
31
  qtiContext,
26
32
  sessionContext,
27
33
  testContext
@@ -637,18 +643,18 @@ var EvalAstFactory = class {
637
643
  }
638
644
  const value = this.right.evaluate(scope);
639
645
  let receiver = void 0;
640
- let property24;
646
+ let property15;
641
647
  if (this.left.type === "Getter") {
642
648
  receiver = this.left.receiver.evaluate(scope);
643
- property24 = this.left.name;
649
+ property15 = this.left.name;
644
650
  } else if (this.left.type === "Index") {
645
651
  receiver = this.left.receiver.evaluate(scope);
646
- property24 = this.left.argument.evaluate(scope);
652
+ property15 = this.left.argument.evaluate(scope);
647
653
  } else if (this.left.type === "ID") {
648
654
  receiver = scope;
649
- property24 = this.left.value;
655
+ property15 = this.left.value;
650
656
  }
651
- return receiver === void 0 ? void 0 : receiver[property24] = value;
657
+ return receiver === void 0 ? void 0 : receiver[property15] = value;
652
658
  }
653
659
  return f(this.left.evaluate(scope), this.right.evaluate(scope));
654
660
  },
@@ -1104,32 +1110,6 @@ var makeLitTemplate = (template) => {
1104
1110
  import { createContext } from "@lit/context";
1105
1111
  var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
1106
1112
 
1107
- // ../qti-test/dist/public-events.js
1108
- var PUBLIC_EVENTS = {
1109
- "qc-test-navigate": { kind: "request", scope: "test", deprecated: "cito-test-navigate" },
1110
- "qc-test-end-attempt": { kind: "request", scope: "test", deprecated: "cito-test-end-attempt" },
1111
- "qc-test-submit": { kind: "request", scope: "test", deprecated: "cito-test-submit" },
1112
- "qc-test-update-outcome": { kind: "request", scope: "test", deprecated: "cito-test-update-outcome" },
1113
- "qc-test-update-plugin-state": { kind: "request", scope: "test", deprecated: "cito-test-update-plugin-state" },
1114
- "qc-test-switch-view": { kind: "request", scope: "test", deprecated: "cito-test-switch-view" },
1115
- "qc-test-submitted": { kind: "notification", scope: "test", deprecated: "cito-test-submitted" },
1116
- "qc-test-navigated": { kind: "notification", scope: "test", deprecated: "cito-test-navigated" },
1117
- "qc-test-navigation-started": { kind: "notification", scope: "test", deprecated: "cito-test-navigation-started" },
1118
- "qc-test-navigation-failed": { kind: "notification", scope: "test", deprecated: "cito-test-navigation-failed" },
1119
- "qc-test-rendered": { kind: "notification", scope: "test", deprecated: "cito-test-rendered" },
1120
- "qc-test-loaded": { kind: "notification", scope: "test", deprecated: "cito-test-loaded" },
1121
- "qc-test-state-changed": { kind: "notification", scope: "test", deprecated: "cito-test-state-changed" },
1122
- "qc-test-items-skipped": { kind: "notification", scope: "test", deprecated: "cito-test-items-skipped" },
1123
- "qc-test-end-reached": { kind: "notification", scope: "test", deprecated: "cito-test-end-reached" },
1124
- "qc-item-ref-connected": { kind: "notification", scope: "item", deprecated: "cito-item-ref-connected" }
1125
- };
1126
- function dispatchPublic(target, name, detail) {
1127
- dispatchDeclared(target, PUBLIC_EVENTS, name, detail);
1128
- }
1129
- function listenPublic2(target, name, handler) {
1130
- listenDeclared(target, PUBLIC_EVENTS, name, handler);
1131
- }
1132
-
1133
1113
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
1134
1114
  var __decorate = function(decorators, target, key, desc) {
1135
1115
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2538,7 +2518,7 @@ var TestBaseMixin = (superClass) => {
2538
2518
  * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
2539
2519
  * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
2540
2520
  */
2541
- updateItemVariables(itemRefID, values, state10) {
2521
+ updateItemVariables(itemRefID, values, state5) {
2542
2522
  this.testContext = {
2543
2523
  ...this.testContext,
2544
2524
  items: this.testContext.items.map((item) => {
@@ -2558,15 +2538,15 @@ var TestBaseMixin = (superClass) => {
2558
2538
  else
2559
2539
  variables.push(updated);
2560
2540
  }
2561
- return { ...item, variables, ...state10 ? { state: { ...state10 } } : {} };
2541
+ return { ...item, variables, ...state5 ? { state: { ...state5 } } : {} };
2562
2542
  })
2563
2543
  };
2564
2544
  const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
2565
2545
  if (!assessmentItem)
2566
2546
  return;
2567
2547
  assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
2568
- if (state10)
2569
- assessmentItem.state = state10;
2548
+ if (state5)
2549
+ assessmentItem.state = state5;
2570
2550
  }
2571
2551
  _initializeEventListeners() {
2572
2552
  this.addEventListener("qti-testdoc-loaded", () => {
@@ -2603,7 +2583,7 @@ var TestBaseMixin = (superClass) => {
2603
2583
  this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
2604
2584
  });
2605
2585
  }
2606
- _updateItemVariablesInTestContext(identifier, variables, state10, valid) {
2586
+ _updateItemVariablesInTestContext(identifier, variables, state5, valid) {
2607
2587
  this.testContext = {
2608
2588
  ...this.testContext,
2609
2589
  // Spread existing test context properties
@@ -2618,7 +2598,7 @@ var TestBaseMixin = (superClass) => {
2618
2598
  const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
2619
2599
  return matchingVariable ? { ...matchingVariable, ...variable } : variable;
2620
2600
  }),
2621
- ...state10 !== void 0 ? { state: state10 ? { ...state10 } : void 0 } : {},
2601
+ ...state5 !== void 0 ? { state: state5 ? { ...state5 } : void 0 } : {},
2622
2602
  ...valid !== void 0 ? { valid } : {}
2623
2603
  };
2624
2604
  })
@@ -2658,8 +2638,8 @@ var TestBase = class extends TestBaseMixin(LitElement9) {
2658
2638
  // ../qti-test/dist/mixins/test-state.mixin.js
2659
2639
  var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
2660
2640
  var isQtiTestState = (value) => {
2661
- const state10 = value;
2662
- return state10?.version === QTI_TEST_STATE_VERSION && Array.isArray(state10.test?.items) && Array.isArray(state10.test?.outcomes) && typeof state10.session === "object" && state10.session !== null;
2641
+ const state5 = value;
2642
+ return state5?.version === QTI_TEST_STATE_VERSION && Array.isArray(state5.test?.items) && Array.isArray(state5.test?.outcomes) && typeof state5.session === "object" && state5.session !== null;
2663
2643
  };
2664
2644
  var toState = (test, session) => ({
2665
2645
  version: QTI_TEST_STATE_VERSION,
@@ -2749,25 +2729,25 @@ var TestStateMixin = (superClass) => {
2749
2729
  super.updated(changed);
2750
2730
  if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
2751
2731
  return;
2752
- const state10 = this.state;
2753
- const serialized = JSON.stringify(state10);
2732
+ const state5 = this.state;
2733
+ const serialized = JSON.stringify(state5);
2754
2734
  if (serialized === this.#lastEmitted)
2755
2735
  return;
2756
2736
  this.#lastEmitted = serialized;
2757
- dispatchPublic(this, "qc-test-state-changed", state10);
2737
+ dispatchPublic(this, "qc-test-state-changed", state5);
2758
2738
  }
2759
- #apply(state10) {
2760
- for (const saved of state10.test.items)
2739
+ #apply(state5) {
2740
+ for (const saved of state5.test.items)
2761
2741
  this.updateItemVariables(saved.identifier, saved.variables, saved.state);
2762
- const savedOutcomes = new Map(state10.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2742
+ const savedOutcomes = new Map(state5.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2763
2743
  this.testContext = {
2764
2744
  ...this.testContext,
2765
2745
  testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
2766
2746
  };
2767
2747
  this.sessionContext = {
2768
2748
  ...this.sessionContext,
2769
- ...this.#validSession(state10.session),
2770
- plugins: state10.session.plugins && typeof state10.session.plugins === "object" ? { ...state10.session.plugins } : {}
2749
+ ...this.#validSession(state5.session),
2750
+ plugins: state5.session.plugins && typeof state5.session.plugins === "object" ? { ...state5.session.plugins } : {}
2771
2751
  };
2772
2752
  }
2773
2753
  /** A stored position may point at an item or section a revised test no longer has. */
@@ -3053,144 +3033,6 @@ __decorate13([
3053
3033
  import { LitElement as LitElement12 } from "lit";
3054
3034
  import { property as property11 } from "lit/decorators.js";
3055
3035
  import { consume as consume7 } from "@lit/context";
3056
-
3057
- // ../qti-test/dist/components/styles.js
3058
- import { css as css5, html as html11 } from "lit";
3059
- var surface = css5`var(--qti-color-base-100, var(--qc-color-base-100, var(--cito-color-base-100, Canvas)))`;
3060
- var content = css5`var(--qti-color-base-content, var(--qc-color-base-content, var(--cito-color-base-content, CanvasText)))`;
3061
- var neutral = css5`var(--qti-color-neutral, var(--qc-color-neutral, var(--cito-color-neutral, CanvasText)))`;
3062
- var neutralContent = css5`var(--qti-color-neutral-content, var(--qc-color-neutral-content, var(--cito-color-neutral-content, Canvas)))`;
3063
- var radius = css5`var(--button-border-radius, var(--test-button-border-radius, var(--qti-radius-field, var(--qc-radius-field, var(--cito-radius-field, 0.2rem)))))`;
3064
- var borderWidth = css5`var(--qti-border-width, var(--qc-border-width, var(--cito-border-width, 1px)))`;
3065
- var hostBox = css5`
3066
- display: inline-flex;
3067
- cursor: pointer;
3068
- user-select: none;
3069
- border-radius: ${radius};
3070
- `;
3071
- var form = css5`
3072
- display: flex;
3073
- flex: 1 1 auto;
3074
- align-items: center;
3075
- justify-content: center;
3076
- gap: 0.375em;
3077
- box-sizing: border-box;
3078
- min-block-size: var(--button-size, var(--test-button-size, 2.25rem));
3079
- padding: 0 0.875rem;
3080
- font: inherit;
3081
- line-height: 1.25;
3082
- cursor: pointer;
3083
- user-select: none;
3084
- border-radius: ${radius};
3085
- `;
3086
- var btn = css5`
3087
- ${form};
3088
- background-color: var(--button-background-color, var(--test-button-background-color, ${surface}));
3089
- color: var(--button-color, var(--test-button-color, inherit));
3090
- border: ${borderWidth} solid
3091
- var(
3092
- --button-border-color,
3093
- var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})))
3094
- );
3095
- `;
3096
- var btnPrimary = css5`
3097
- background-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
3098
- color: var(--button-primary-color, var(--test-button-primary-color, ${neutralContent}));
3099
- border-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
3100
- `;
3101
- var btnInteractive = css5`
3102
- background-color: var(
3103
- --button-hover-background-color,
3104
- var(--test-button-hover-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%)))
3105
- );
3106
- `;
3107
- var btnPrimaryInteractive = css5`
3108
- background-color: var(
3109
- --button-primary-hover-background-color,
3110
- var(
3111
- --test-button-primary-hover-background-color,
3112
- color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
3113
- )
3114
- );
3115
- `;
3116
- var btnActive = css5`
3117
- background-color: var(
3118
- --button-active-background-color,
3119
- var(--test-button-active-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%)))
3120
- );
3121
- `;
3122
- var btnPrimaryActive = css5`
3123
- background-color: var(
3124
- --button-primary-active-background-color,
3125
- var(
3126
- --test-button-primary-active-background-color,
3127
- color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
3128
- )
3129
- );
3130
- `;
3131
- var focusRing = css5`
3132
- outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);
3133
- outline-offset: var(--qti-focus-offset, 2px);
3134
- `;
3135
- var dis = css5`
3136
- cursor: not-allowed;
3137
- opacity: 0.45;
3138
- `;
3139
- var ind = css5`
3140
- ${form};
3141
- border: ${borderWidth} solid var(--qti-border-color, GrayText);
3142
- `;
3143
- var control = html11`<span class="control" part="button"><slot></slot></span>`;
3144
- var button = css5`
3145
- :host {
3146
- ${hostBox};
3147
- }
3148
- .control {
3149
- ${btn};
3150
- }
3151
- @media (hover: hover) and (pointer: fine) {
3152
- :host(:hover:not([disabled])) .control {
3153
- ${btnInteractive};
3154
- }
3155
- }
3156
- :host(:active:not([disabled])) .control {
3157
- ${btnActive};
3158
- }
3159
- /* The press the theme gives a choice (qti-motion.css), from the same knob: a touch smaller while
3160
- the button is down, springing back on release; 0 motion means no press. */
3161
- .control {
3162
- transition:
3163
- background-color calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1),
3164
- scale calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1);
3165
- }
3166
- :host(:active:not([disabled])) .control {
3167
- scale: calc(1 - 0.03 * var(--qti-motion, 1));
3168
- }
3169
- :host(:focus-visible) {
3170
- ${focusRing};
3171
- }
3172
- :host([disabled]) {
3173
- ${dis};
3174
- }
3175
- :host([disabled]) .control {
3176
- cursor: not-allowed;
3177
- }
3178
- `;
3179
- var buttonPrimary = css5`
3180
- .control {
3181
- ${btnPrimary};
3182
- }
3183
- @media (hover: hover) and (pointer: fine) {
3184
- :host(:hover:not([disabled])) .control {
3185
- ${btnPrimaryInteractive};
3186
- }
3187
- }
3188
- :host(:active:not([disabled])) .control {
3189
- ${btnPrimaryActive};
3190
- }
3191
- `;
3192
-
3193
- // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
3194
3036
  var __decorate14 = function(decorators, target, key, desc) {
3195
3037
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3196
3038
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3284,40 +3126,11 @@ __decorate14([
3284
3126
  watch("computedContext")
3285
3127
  ], TestEndAttempt.prototype, "_handleTestElementChange", null);
3286
3128
 
3287
- // ../qti-test/dist/components/test-item-link/test-item-link.js
3288
- import { LitElement as LitElement13 } from "lit";
3289
- import { property as property12 } from "lit/decorators.js";
3290
- var __decorate15 = function(decorators, target, key, desc) {
3291
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3292
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3293
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3294
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3295
- };
3296
- var TestItemLink = class extends LitElement13 {
3297
- static {
3298
- this.styles = button;
3299
- }
3300
- constructor() {
3301
- super();
3302
- this.itemId = null;
3303
- this.addEventListener("click", () => this._requestItem(this.itemId));
3304
- }
3305
- _requestItem(identifier) {
3306
- dispatchPublic(this, "qc-test-navigate", { type: "item", id: identifier });
3307
- }
3308
- render() {
3309
- return control;
3310
- }
3311
- };
3312
- __decorate15([
3313
- property12({ type: String, attribute: "item-id" })
3314
- ], TestItemLink.prototype, "itemId", void 0);
3315
-
3316
3129
  // ../qti-test/dist/components/test-navigation/test-navigation.js
3317
3130
  import { ContextConsumer, consume as consume8, provide as provide3 } from "@lit/context";
3318
- import { html as html12, LitElement as LitElement14 } from "lit";
3319
- import { property as property13, state as state4 } from "lit/decorators.js";
3320
- var __decorate16 = function(decorators, target, key, desc) {
3131
+ import { html as html11, LitElement as LitElement13 } from "lit";
3132
+ import { property as property12, state as state4 } from "lit/decorators.js";
3133
+ var __decorate15 = function(decorators, target, key, desc) {
3321
3134
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3322
3135
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3323
3136
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -3326,7 +3139,7 @@ var __decorate16 = function(decorators, target, key, desc) {
3326
3139
  var newQtiContext = () => ({
3327
3140
  QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3328
3141
  });
3329
- var TestNavigation = class extends LitElement14 {
3142
+ var TestNavigation = class extends LitElement13 {
3330
3143
  /**
3331
3144
  * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
3332
3145
  * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
@@ -3476,7 +3289,7 @@ var TestNavigation = class extends LitElement14 {
3476
3289
  }
3477
3290
  }
3478
3291
  render() {
3479
- return html12`<slot></slot>`;
3292
+ return html11`<slot></slot>`;
3480
3293
  }
3481
3294
  /* PK: on test connected we can build the computed context */
3482
3295
  #handleTestConnected(event) {
@@ -3888,43 +3701,43 @@ var TestNavigation = class extends LitElement14 {
3888
3701
  return Number.isNaN(parsed) ? null : parsed;
3889
3702
  }
3890
3703
  };
3891
- __decorate16([
3892
- property13({ type: String })
3704
+ __decorate15([
3705
+ property12({ type: String })
3893
3706
  ], TestNavigation.prototype, "identifier", void 0);
3894
- __decorate16([
3707
+ __decorate15([
3895
3708
  state4()
3896
3709
  ], TestNavigation.prototype, "initContext", void 0);
3897
- __decorate16([
3710
+ __decorate15([
3898
3711
  state4(),
3899
3712
  consume8({ context: configContext, subscribe: true })
3900
3713
  ], TestNavigation.prototype, "configContext", void 0);
3901
- __decorate16([
3714
+ __decorate15([
3902
3715
  state4(),
3903
3716
  consume8({ context: testContext, subscribe: true })
3904
3717
  ], TestNavigation.prototype, "_testContext", void 0);
3905
- __decorate16([
3718
+ __decorate15([
3906
3719
  state4(),
3907
3720
  consume8({ context: sessionContext, subscribe: true })
3908
3721
  ], TestNavigation.prototype, "_sessionContext", void 0);
3909
- __decorate16([
3722
+ __decorate15([
3910
3723
  state4(),
3911
3724
  provide3({ context: computedContext })
3912
3725
  ], TestNavigation.prototype, "computedContext", void 0);
3913
- __decorate16([
3914
- property13({ type: Boolean, attribute: "auto-score-items" })
3726
+ __decorate15([
3727
+ property12({ type: Boolean, attribute: "auto-score-items" })
3915
3728
  ], TestNavigation.prototype, "autoScoreItems", void 0);
3916
3729
 
3917
3730
  // ../qti-test/dist/components/test-next/test-next.js
3918
- import { LitElement as LitElement15 } from "lit";
3919
- import { property as property14 } from "lit/decorators.js";
3731
+ import { LitElement as LitElement14 } from "lit";
3732
+ import { property as property13 } from "lit/decorators.js";
3920
3733
  import { consume as consume9 } from "@lit/context";
3921
- var __decorate17 = function(decorators, target, key, desc) {
3734
+ var __decorate16 = function(decorators, target, key, desc) {
3922
3735
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3923
3736
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3924
3737
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3925
3738
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3926
3739
  };
3927
- var TestNext = class extends LitElement15 {
3740
+ var TestNext = class extends LitElement14 {
3928
3741
  _handleTestElementChange(_oldValue, newValue) {
3929
3742
  if (newValue) {
3930
3743
  this.requestUpdate();
@@ -3978,27 +3791,27 @@ var TestNext = class extends LitElement15 {
3978
3791
  return control;
3979
3792
  }
3980
3793
  };
3981
- __decorate17([
3982
- property14({ type: Boolean, reflect: true, attribute: "disabled" })
3794
+ __decorate16([
3795
+ property13({ type: Boolean, reflect: true, attribute: "disabled" })
3983
3796
  ], TestNext.prototype, "_internalDisabled", void 0);
3984
- __decorate17([
3797
+ __decorate16([
3985
3798
  consume9({ context: computedContext, subscribe: true })
3986
3799
  ], TestNext.prototype, "computedContext", void 0);
3987
- __decorate17([
3800
+ __decorate16([
3988
3801
  watch("computedContext")
3989
3802
  ], TestNext.prototype, "_handleTestElementChange", null);
3990
3803
 
3991
3804
  // ../qti-test/dist/components/test-prev/test-prev.js
3992
- import { LitElement as LitElement16 } from "lit";
3993
- import { property as property15 } from "lit/decorators.js";
3805
+ import { LitElement as LitElement15 } from "lit";
3806
+ import { property as property14 } from "lit/decorators.js";
3994
3807
  import { consume as consume10 } from "@lit/context";
3995
- var __decorate18 = function(decorators, target, key, desc) {
3808
+ var __decorate17 = function(decorators, target, key, desc) {
3996
3809
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3997
3810
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3998
3811
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3999
3812
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4000
3813
  };
4001
- var TestPrev = class extends LitElement16 {
3814
+ var TestPrev = class extends LitElement15 {
4002
3815
  _handleTestElementChange(_oldValue, newValue) {
4003
3816
  if (newValue) {
4004
3817
  this.requestUpdate();
@@ -4039,577 +3852,19 @@ var TestPrev = class extends LitElement16 {
4039
3852
  return control;
4040
3853
  }
4041
3854
  };
4042
- __decorate18([
4043
- property15({ type: Boolean, reflect: true, attribute: "disabled" })
3855
+ __decorate17([
3856
+ property14({ type: Boolean, reflect: true, attribute: "disabled" })
4044
3857
  ], TestPrev.prototype, "_internalDisabled", void 0);
4045
- __decorate18([
3858
+ __decorate17([
4046
3859
  consume10({ context: computedContext, subscribe: true })
4047
3860
  ], TestPrev.prototype, "computedContext", void 0);
4048
- __decorate18([
3861
+ __decorate17([
4049
3862
  watch("computedContext")
4050
3863
  ], TestPrev.prototype, "_handleTestElementChange", null);
4051
3864
 
4052
- // ../qti-test/dist/components/test-section-link/test-section-link.js
4053
- import { LitElement as LitElement17 } from "lit";
4054
- import { property as property16 } from "lit/decorators.js";
4055
- var __decorate19 = function(decorators, target, key, desc) {
4056
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4057
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4058
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4059
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4060
- };
4061
- var TestSectionLink = class extends LitElement17 {
4062
- static {
4063
- this.styles = button;
4064
- }
4065
- #requestItem(identifier) {
4066
- dispatchPublic(this, "qc-test-navigate", { type: "section", id: identifier });
4067
- }
4068
- constructor() {
4069
- super();
4070
- this.sectionId = null;
4071
- this.addEventListener("click", () => this.#requestItem(this.sectionId));
4072
- }
4073
- render() {
4074
- return control;
4075
- }
4076
- };
4077
- __decorate19([
4078
- property16({ type: String, attribute: "section-id" })
4079
- ], TestSectionLink.prototype, "sectionId", void 0);
4080
-
4081
- // ../qti-test/dist/plugin-state.js
4082
- var pluginState = (context, plugin) => context?.plugins?.[plugin];
4083
-
4084
- // ../qti-test/dist/components/test-bookmark/test-bookmark.js
4085
- import { css as css6, html as html13, LitElement as LitElement18 } from "lit";
4086
- import { consume as consume11 } from "@lit/context";
4087
- import { property as property17 } from "lit/decorators.js";
4088
- var __decorate20 = function(decorators, target, key, desc) {
4089
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4090
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4091
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4092
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4093
- };
4094
- var bookmarkedItems = (context) => pluginState(context, "bookmarks") ?? [];
4095
- var itemRefOf2 = (element) => {
4096
- const itemRef = element.closest("qti-assessment-item-ref");
4097
- if (itemRef)
4098
- return itemRef.getAttribute("identifier") ?? void 0;
4099
- const root = element.getRootNode();
4100
- return root instanceof ShadowRoot ? itemRefOf2(root.host) : void 0;
4101
- };
4102
- var TestBookmark = class extends LitElement18 {
4103
- static {
4104
- this.styles = [
4105
- button,
4106
- css6`
4107
- svg {
4108
- width: 1.1em;
4109
- height: 1.1em;
4110
- flex: none;
4111
- fill: none;
4112
- stroke: currentColor;
4113
- stroke-width: 2;
4114
- stroke-linejoin: round;
4115
- }
4116
- :host([bookmarked]) {
4117
- color: var(--qti-bookmark-color, #b45309);
4118
- }
4119
- :host([bookmarked]) svg {
4120
- fill: currentColor;
4121
- }
4122
- `
4123
- ];
4124
- }
4125
- constructor() {
4126
- super();
4127
- this.bookmarked = false;
4128
- this.disabled = false;
4129
- this.addEventListener("click", () => this.#toggle());
4130
- this.addEventListener("keydown", (event) => {
4131
- if (event.key !== "Enter" && event.key !== " ")
4132
- return;
4133
- event.preventDefault();
4134
- this.#toggle();
4135
- });
4136
- }
4137
- connectedCallback() {
4138
- super.connectedCallback();
4139
- if (!this.hasAttribute("role"))
4140
- this.setAttribute("role", "button");
4141
- if (!this.hasAttribute("tabindex"))
4142
- this.setAttribute("tabindex", "0");
4143
- }
4144
- /** The item this button marks: its own, or else the one on screen. */
4145
- get #activeItem() {
4146
- return this.item || (itemRefOf2(this) ?? this.computedContext?.testParts?.flatMap((part) => part.sections.flatMap((section) => section.items)).find((item) => item.active)?.identifier);
4147
- }
4148
- willUpdate() {
4149
- const active = this.#activeItem;
4150
- this.disabled = !active;
4151
- this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);
4152
- }
4153
- updated() {
4154
- this.setAttribute("aria-pressed", String(this.bookmarked));
4155
- this.setAttribute("aria-disabled", String(this.disabled));
4156
- }
4157
- #toggle() {
4158
- const active = this.#activeItem;
4159
- if (!active)
4160
- return;
4161
- const marked = bookmarkedItems(this.computedContext);
4162
- const next = marked.includes(active) ? marked.filter((id) => id !== active) : [...marked, active];
4163
- dispatchPublic(this, "qc-test-update-plugin-state", {
4164
- plugin: "bookmarks",
4165
- value: next.length > 0 ? next : null
4166
- });
4167
- }
4168
- render() {
4169
- return html13`<span class="control" part="button"
4170
- ><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot
4171
- ></span>`;
4172
- }
4173
- };
4174
- __decorate20([
4175
- consume11({ context: computedContext, subscribe: true }),
4176
- property17({ attribute: false })
4177
- ], TestBookmark.prototype, "computedContext", void 0);
4178
- __decorate20([
4179
- property17({ reflect: true })
4180
- ], TestBookmark.prototype, "item", void 0);
4181
- __decorate20([
4182
- property17({ type: Boolean, reflect: true })
4183
- ], TestBookmark.prototype, "bookmarked", void 0);
4184
- __decorate20([
4185
- property17({ type: Boolean, reflect: true })
4186
- ], TestBookmark.prototype, "disabled", void 0);
4187
-
4188
- // ../qti-test/dist/components/test-check-item/test-check-item.js
4189
- import { LitElement as LitElement19 } from "lit";
4190
- import { property as property18 } from "lit/decorators.js";
4191
- var __decorate21 = function(decorators, target, key, desc) {
4192
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4193
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4194
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4195
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4196
- };
4197
- var TestCheckItem = class extends LitElement19 {
4198
- static {
4199
- this.styles = button;
4200
- }
4201
- constructor() {
4202
- super();
4203
- this.view = "scorer";
4204
- this.addEventListener("click", () => {
4205
- dispatchPublic(this, "qc-test-end-attempt", {});
4206
- dispatchPublic(this, "qc-test-switch-view", this.view);
4207
- });
4208
- }
4209
- render() {
4210
- return control;
4211
- }
4212
- };
4213
- __decorate21([
4214
- property18({ type: String })
4215
- ], TestCheckItem.prototype, "view", void 0);
4216
-
4217
- // ../qti-test/dist/components/test-print-context/test-print-context.js
4218
- import { html as html14, LitElement as LitElement20 } from "lit";
4219
- import { consume as consume12 } from "@lit/context";
4220
- import { state as state5 } from "lit/decorators.js";
4221
- var __decorate22 = function(decorators, target, key, desc) {
4222
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4223
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4224
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4225
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4226
- };
4227
- var TestPrintContext = class extends LitElement20 {
4228
- render() {
4229
- return html14` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
4230
- }
4231
- };
4232
- __decorate22([
4233
- state5(),
4234
- consume12({ context: computedContext, subscribe: true })
4235
- ], TestPrintContext.prototype, "computedContext", void 0);
4236
-
4237
- // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
4238
- import { html as html15, css as css7, LitElement as LitElement21 } from "lit";
4239
- import { consume as consume13 } from "@lit/context";
4240
- var __decorate23 = function(decorators, target, key, desc) {
4241
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4242
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4243
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4244
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4245
- };
4246
- var formatVariableValue = (value) => {
4247
- if (value === null || value === void 0)
4248
- return "";
4249
- if (Array.isArray(value))
4250
- return value.map(formatVariableValue).join(", ");
4251
- if (isRecordValue(value)) {
4252
- return Object.entries(value).map(([field, fieldValue]) => `${field}: ${formatVariableValue(fieldValue)}`).join(", ");
4253
- }
4254
- return String(value);
4255
- };
4256
- var TestPrintVariables = class extends LitElement21 {
4257
- static {
4258
- this.styles = css7`
4259
- table {
4260
- width: 100%;
4261
- border-collapse: collapse;
4262
- margin: 20px 0;
4263
- font-size: 14px;
4264
- text-align: left;
4265
- }
4266
- th,
4267
- td {
4268
- border: 1px solid #ddd;
4269
- padding: 8px;
4270
- }
4271
- th {
4272
- background-color: #f4f4f4;
4273
- font-weight: bold;
4274
- }
4275
- h3 {
4276
- margin-top: 20px;
4277
- font-size: 16px;
4278
- }
4279
- `;
4280
- }
4281
- render() {
4282
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4283
- if (!activeItem || !activeItem.variables)
4284
- return html15``;
4285
- const responseVariables = activeItem.variables.filter((v) => v.type === "response");
4286
- const outcomeVariables = activeItem.variables.filter((v) => v.type === "outcome");
4287
- const renderTable = (variables, title) => html15`
4288
- <h3>${title}</h3>
4289
- <table>
4290
- <thead>
4291
- <tr>
4292
- <th>Identifier</th>
4293
- <th>Value</th>
4294
- <th>Cardinality</th>
4295
- <th>Base Type</th>
4296
- <th>Correct Response / Mappings</th>
4297
- </tr>
4298
- </thead>
4299
- <tbody>
4300
- ${variables.map((v) => {
4301
- const correctResponse = formatVariableValue(v.correctResponse);
4302
- const mapEntries = v.mapping?.mapEntries?.map((m) => `${m.mapKey}=${m.mappedValue}pt`).join(", ") || "";
4303
- const areaMapEntries = v.areaMapping?.areaMapEntries?.map((m) => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ") || "";
4304
- return html15`
4305
- <tr>
4306
- <td>${v.identifier}</td>
4307
- <td>${formatVariableValue(v.value)}</td>
4308
- <td>${v.cardinality}</td>
4309
- <td>${v.baseType}</td>
4310
- <td>${correctResponse || mapEntries || areaMapEntries}</td>
4311
- </tr>
4312
- `;
4313
- })}
4314
- </tbody>
4315
- </table>
4316
- `;
4317
- return html15`
4318
- ${renderTable(responseVariables, "Response Variables")} ${renderTable(outcomeVariables, "Outcome Variables")}
4319
- `;
4320
- }
4321
- };
4322
- __decorate23([
4323
- consume13({ context: computedContext, subscribe: true })
4324
- ], TestPrintVariables.prototype, "computedContext", void 0);
4325
-
4326
- // ../qti-test/dist/components/test-print-state/test-print-state.js
4327
- import { css as css8, html as html16, LitElement as LitElement22, nothing as nothing3 } from "lit";
4328
- import { state as state6 } from "lit/decorators.js";
4329
- var __decorate24 = function(decorators, target, key, desc) {
4330
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4331
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4332
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4333
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4334
- };
4335
- var TestPrintState = class extends LitElement22 {
4336
- #test = null;
4337
- static {
4338
- this.styles = css8`
4339
- :host {
4340
- display: block;
4341
- }
4342
- ul {
4343
- list-style: none;
4344
- margin: 0;
4345
- padding-inline-start: 1rem;
4346
- }
4347
- summary {
4348
- cursor: pointer;
4349
- }
4350
- [part~='count'] {
4351
- opacity: 0.7;
4352
- }
4353
- `;
4354
- }
4355
- #onStateChanged = (event) => {
4356
- this.testState = event.detail;
4357
- };
4358
- connectedCallback() {
4359
- super.connectedCallback();
4360
- this.#test = this.closest("qti-test");
4361
- this.#test?.addEventListener("qc-test-state-changed", this.#onStateChanged);
4362
- this.testState = this.#test?.state;
4363
- }
4364
- disconnectedCallback() {
4365
- super.disconnectedCallback();
4366
- this.#test?.removeEventListener("qc-test-state-changed", this.#onStateChanged);
4367
- this.#test = null;
4368
- }
4369
- render() {
4370
- if (!this.testState)
4371
- return nothing3;
4372
- return html16`<ul>
4373
- ${this.#renderNode("state", this.testState, 0)}
4374
- </ul>`;
4375
- }
4376
- #renderNode(label, value, depth) {
4377
- if (value === null || typeof value !== "object") {
4378
- return html16`<li><span part="key">${label}</span>: <span part="value">${JSON.stringify(value)}</span></li>`;
4379
- }
4380
- const entries = Array.isArray(value) ? value.map((entry, index) => [entryLabel(entry, index), entry]) : Object.entries(value);
4381
- const count = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
4382
- return html16`<li>
4383
- <details ?open=${depth < 2}>
4384
- <summary><span part="key">${label}</span> <span part="count">${count}</span></summary>
4385
- <ul>
4386
- ${entries.map(([key, entry]) => this.#renderNode(key, entry, depth + 1))}
4387
- </ul>
4388
- </details>
4389
- </li>`;
4390
- }
4391
- };
4392
- __decorate24([
4393
- state6()
4394
- ], TestPrintState.prototype, "testState", void 0);
4395
- var entryLabel = (entry, index) => {
4396
- const identifier = entry?.identifier;
4397
- return typeof identifier === "string" ? `${index} \xB7 ${identifier}` : String(index);
4398
- };
4399
-
4400
- // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
4401
- import { html as html17, LitElement as LitElement23, nothing as nothing4 } from "lit";
4402
- import { consume as consume14 } from "@lit/context";
4403
- import { property as property19 } from "lit/decorators.js";
4404
- var __decorate25 = function(decorators, target, key, desc) {
4405
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4406
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4407
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4408
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4409
- };
4410
- var TestScoringButtons = class extends LitElement23 {
4411
- createRenderRoot() {
4412
- return this;
4413
- }
4414
- connectedCallback() {
4415
- super.connectedCallback();
4416
- const templateElement = this.querySelector("template");
4417
- if (!templateElement) {
4418
- this.myTemplate = null;
4419
- return;
4420
- }
4421
- this.myTemplate = prepareTemplate(templateElement);
4422
- }
4423
- #changeOutcomeScore(value) {
4424
- const testPart = this.computedContext?.testParts.find((testPart2) => testPart2.active);
4425
- const sectionItems = testPart.sections.flatMap((section) => section.items);
4426
- const currentItemIdentifier = sectionItems.find((item) => item.active)?.identifier;
4427
- dispatchPublic(this, "qc-test-update-outcome", {
4428
- assessmentItemRefId: currentItemIdentifier,
4429
- outcomeVariableId: "SCORE",
4430
- value
4431
- });
4432
- }
4433
- render() {
4434
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4435
- if (!activeItem || !activeItem.variables)
4436
- return html17``;
4437
- const maxScore = activeItem.variables.find((vr) => vr.identifier == "MAXSCORE")?.value;
4438
- const scoreOutcome = activeItem.variables.find((vr) => vr.identifier == "SCORE");
4439
- const score = scoreOutcome?.value;
4440
- const disabled = !(scoreOutcome?.externalScored === "human");
4441
- if (!maxScore || !scoreOutcome)
4442
- return nothing4;
4443
- const scores = [...Array(Number(maxScore) + 1).keys()];
4444
- return html17`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing4}`;
4445
- }
4446
- constructor() {
4447
- super();
4448
- this.view = "";
4449
- this.disabled = false;
4450
- this.myTemplate = null;
4451
- this.addEventListener("click", (e) => {
4452
- const target = e.target;
4453
- const value = parseFloat(target.value);
4454
- if (target.tagName === "INPUT") {
4455
- this.#changeOutcomeScore(value);
4456
- }
4457
- });
4458
- }
4459
- };
4460
- __decorate25([
4461
- property19({ type: String, attribute: "view" })
4462
- ], TestScoringButtons.prototype, "view", void 0);
4463
- __decorate25([
4464
- property19({ type: Boolean })
4465
- ], TestScoringButtons.prototype, "disabled", void 0);
4466
- __decorate25([
4467
- consume14({ context: computedContext, subscribe: true })
4468
- ], TestScoringButtons.prototype, "computedContext", void 0);
4469
-
4470
- // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
4471
- import { consume as consume15 } from "@lit/context";
4472
- import { html as html18, LitElement as LitElement24 } from "lit";
4473
- import { property as property20 } from "lit/decorators.js";
4474
- var __decorate26 = function(decorators, target, key, desc) {
4475
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4476
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4477
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4478
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4479
- };
4480
- var TestScoringFeedback = class extends LitElement24 {
4481
- constructor() {
4482
- super(...arguments);
4483
- this.view = null;
4484
- }
4485
- render() {
4486
- const activeItem = this.computedContext?.testParts.flatMap((testPart) => testPart.sections.flatMap((section) => section.items)).find((item) => item.active);
4487
- if (!activeItem || !activeItem.variables)
4488
- return html18``;
4489
- if (activeItem["category"] === "dep-informational")
4490
- return html18`<div>${this.dataset.informational}</div>`;
4491
- const scoreOutcome = activeItem?.variables.find((vr) => vr.identifier == "SCORE");
4492
- const score = parseFloat(scoreOutcome?.value);
4493
- const externalScored = activeItem["externalScored"];
4494
- const feedbackText = () => {
4495
- if (activeItem.valid === false || activeItem.isDefaultResponse) {
4496
- return this.dataset.textNoResponse;
4497
- }
4498
- if (!externalScored && score !== void 0 && !Number.isNaN(score)) {
4499
- return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;
4500
- }
4501
- if (externalScored === "externalMachine") {
4502
- return Number.isNaN(score) || score === void 0 ? this.dataset.scoreUnknown : `We hebben je antwoord ${score === 0 ? "geen punten" : score == 1 ? "\xE9\xE9n punt" : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;
4503
- }
4504
- if (externalScored === "human") {
4505
- return Number.isNaN(score) ? "" : "Deze score heb je zelf toegekend.";
4506
- }
4507
- return this.dataset.inProgress;
4508
- };
4509
- return html18`<div>${feedbackText()}</div>`;
4510
- }
4511
- };
4512
- __decorate26([
4513
- consume15({ context: computedContext, subscribe: true })
4514
- ], TestScoringFeedback.prototype, "computedContext", void 0);
4515
- __decorate26([
4516
- property20({ type: String, attribute: "view" })
4517
- ], TestScoringFeedback.prototype, "view", void 0);
4518
-
4519
- // ../qti-test/dist/components/test-stamp/test-stamp.js
4520
- import { html as html19, LitElement as LitElement25, nothing as nothing5 } from "lit";
4521
- import { property as property21, state as state7 } from "lit/decorators.js";
4522
- import { consume as consume16 } from "@lit/context";
4523
- var __decorate27 = function(decorators, target, key, desc) {
4524
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4525
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4526
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4527
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4528
- };
4529
- var TestStamp = class extends LitElement25 {
4530
- constructor() {
4531
- super(...arguments);
4532
- this.debug = false;
4533
- this.stampContext = {
4534
- view: "candidate",
4535
- activeItem: {},
4536
- activeSection: {
4537
- items: []
4538
- },
4539
- activeTestpart: {
4540
- items: [],
4541
- sections: []
4542
- },
4543
- test: {}
4544
- };
4545
- }
4546
- createRenderRoot() {
4547
- return this;
4548
- }
4549
- connectedCallback() {
4550
- super.connectedCallback();
4551
- const templateElement = this.querySelector("template");
4552
- if (!templateElement) {
4553
- this.myTemplate = null;
4554
- return;
4555
- }
4556
- this.myTemplate = prepareTemplate(templateElement);
4557
- }
4558
- willUpdate(_changedProperties) {
4559
- if (!this.computedContext) {
4560
- return;
4561
- }
4562
- const activeTestPart = this.computedContext.testParts.find((testPart) => testPart.active);
4563
- const activeSection = activeTestPart?.sections.find((section) => section.active);
4564
- const activeItem = activeSection?.items.find((item) => item.active);
4565
- const { variables, ...augmentedItem } = activeItem || {};
4566
- if (!activeTestPart) {
4567
- return;
4568
- }
4569
- const augmentedTestPart = {
4570
- ...activeTestPart,
4571
- items: activeTestPart.sections.flatMap((section) => section.items.map(({ variables: variables2, ...rest }) => rest)),
4572
- sections: activeTestPart.sections.map((section) => ({
4573
- ...section,
4574
- items: section.items.map(({ variables: variables2, ...rest }) => rest)
4575
- }))
4576
- };
4577
- const augmentedSection = {
4578
- ...activeSection,
4579
- items: (activeSection?.items ?? []).map(({ variables: variables2, ...rest }) => rest)
4580
- };
4581
- const { testParts, ...activeTest } = this.computedContext;
4582
- this.stampContext = {
4583
- view: this.computedContext.view,
4584
- activeItem: augmentedItem,
4585
- activeSection: augmentedSection,
4586
- activeTestpart: augmentedTestPart,
4587
- test: activeTest
4588
- };
4589
- this.dispatchEvent(new CustomEvent("qti-stamp-context-updated", {
4590
- detail: this.stampContext,
4591
- bubbles: true
4592
- }));
4593
- }
4594
- render() {
4595
- return html19` ${this.debug ? html19`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing5}
4596
- ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing5}`;
4597
- }
4598
- };
4599
- __decorate27([
4600
- property21({ type: Boolean, reflect: true })
4601
- ], TestStamp.prototype, "debug", void 0);
4602
- __decorate27([
4603
- state7(),
4604
- consume16({ context: computedContext, subscribe: true })
4605
- ], TestStamp.prototype, "computedContext", void 0);
4606
- __decorate27([
4607
- state7()
4608
- ], TestStamp.prototype, "stampContext", void 0);
4609
-
4610
3865
  // ../qti-test/dist/components/test-submit/test-submit.js
4611
- import { LitElement as LitElement26 } from "lit";
4612
- var TestSubmit = class extends LitElement26 {
3866
+ import { LitElement as LitElement16 } from "lit";
3867
+ var TestSubmit = class extends LitElement16 {
4613
3868
  static {
4614
3869
  this.styles = button;
4615
3870
  }
@@ -4622,975 +3877,8 @@ var TestSubmit = class extends LitElement26 {
4622
3877
  }
4623
3878
  };
4624
3879
 
4625
- // ../qti-test/dist/components/test-view-toggle/test-view.js
4626
- import { html as html20, LitElement as LitElement27 } from "lit";
4627
- import { property as property22, state as state8 } from "lit/decorators.js";
4628
- import { consume as consume17 } from "@lit/context";
4629
- var __decorate28 = function(decorators, target, key, desc) {
4630
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4631
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4632
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4633
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4634
- };
4635
- var _a;
4636
- var TestView = class extends LitElement27 {
4637
- constructor() {
4638
- super(...arguments);
4639
- this.label = "view";
4640
- this._handleViewOptionsChange = () => {
4641
- this.#updateViewOptions();
4642
- };
4643
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
4644
- }
4645
- static {
4646
- this.DEFAULT_VIEW_OPTIONS = ["author", "candidate", "proctor", "scorer", "testConstructor", "tutor"];
4647
- }
4648
- connectedCallback() {
4649
- super.connectedCallback();
4650
- this.#updateViewOptions();
4651
- }
4652
- #updateViewOptions() {
4653
- if (this.viewOptions) {
4654
- const options = this.viewOptions.split(",").map((opt) => opt.trim());
4655
- this._viewOptions = options.filter((opt) => _a.DEFAULT_VIEW_OPTIONS.includes(opt));
4656
- } else {
4657
- this._viewOptions = _a.DEFAULT_VIEW_OPTIONS;
4658
- }
4659
- }
4660
- _switchView(view) {
4661
- dispatchPublic(this, "qc-test-switch-view", view);
4662
- }
4663
- render() {
4664
- return html20`
4665
- <label part="label" for="viewSelect">${this.label}</label>
4666
- <select
4667
- part="select"
4668
- id="viewSelect"
4669
- @change=${(e) => {
4670
- const el = e.target;
4671
- this._switchView(el.value);
4672
- }}
4673
- >
4674
- ${this._viewOptions.map((v) => html20`<option value="${v}" ?selected=${v === this.sessionContext.view}>${v}</option>`)}
4675
- </select>
4676
- `;
4677
- }
4678
- };
4679
- _a = TestView;
4680
- __decorate28([
4681
- consume17({ context: sessionContext, subscribe: true })
4682
- ], TestView.prototype, "sessionContext", void 0);
4683
- __decorate28([
4684
- property22({ type: String })
4685
- ], TestView.prototype, "label", void 0);
4686
- __decorate28([
4687
- property22({ type: String, attribute: "view-options" })
4688
- ], TestView.prototype, "viewOptions", void 0);
4689
- __decorate28([
4690
- watch("viewOptions", { waitUntilFirstUpdate: true })
4691
- ], TestView.prototype, "_handleViewOptionsChange", void 0);
4692
- __decorate28([
4693
- state8()
4694
- ], TestView.prototype, "_viewOptions", void 0);
4695
-
4696
- // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
4697
- import { consume as consume18 } from "@lit/context";
4698
- import { html as html21, LitElement as LitElement28, nothing as nothing6 } from "lit";
4699
- var __decorate29 = function(decorators, target, key, desc) {
4700
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4701
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4702
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4703
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4704
- };
4705
- var TestViewToggle = class extends LitElement28 {
4706
- createRenderRoot() {
4707
- return this;
4708
- }
4709
- connectedCallback() {
4710
- super.connectedCallback();
4711
- const templateElement = this.querySelector("template");
4712
- if (!templateElement) {
4713
- this.myTemplate = null;
4714
- return;
4715
- }
4716
- this.myTemplate = prepareTemplate(templateElement);
4717
- }
4718
- _switchView(view) {
4719
- dispatchPublic(this, "qc-test-switch-view", view);
4720
- }
4721
- firstUpdated(_changedProperties) {
4722
- this.addEventListener("click", () => {
4723
- if (this.sessionContext?.view === "scorer") {
4724
- this._switchView("candidate");
4725
- } else {
4726
- this._switchView("scorer");
4727
- }
4728
- });
4729
- }
4730
- render() {
4731
- return html21`${this.myTemplate ? this.myTemplate({
4732
- view: this.sessionContext?.view
4733
- }) : nothing6}`;
4734
- }
4735
- };
4736
- __decorate29([
4737
- consume18({ context: sessionContext, subscribe: true })
4738
- ], TestViewToggle.prototype, "sessionContext", void 0);
4739
-
4740
- // ../qti-test/dist/tts/test-item-to-speech.js
4741
- import { html as html22, LitElement as LitElement29, css as css9 } from "lit";
4742
- import { consume as consume19, provide as provide4, createContext as createContext2 } from "@lit/context";
4743
- import { property as property23, state as state9 } from "lit/decorators.js";
4744
- import { ifDefined } from "lit/directives/if-defined.js";
4745
- var __decorate30 = function(decorators, target, key, desc) {
4746
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4747
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4748
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4749
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4750
- };
4751
- var HIGHLIGHT_ELEMENT = "tts-element";
4752
- var HIGHLIGHT_WORD = "tts-word";
4753
- var highlightSheet = null;
4754
- function getHighlightSheet() {
4755
- if (!highlightSheet) {
4756
- highlightSheet = new CSSStyleSheet();
4757
- highlightSheet.replaceSync(`
4758
- ::highlight(${HIGHLIGHT_ELEMENT}) {
4759
- background-color: var(--test-tts-element-highlight, color-mix(in oklab, var(--qti-color-info, var(--qc-color-info, var(--cito-color-info, Highlight))) 15%, transparent));
4760
- color: inherit;
4761
- }
4762
- ::highlight(${HIGHLIGHT_WORD}) {
4763
- background-color: var(--test-tts-word-highlight, color-mix(in oklab, var(--qti-color-warning, var(--qc-color-warning, var(--cito-color-warning, Mark))) 55%, transparent));
4764
- color: inherit;
4765
- }
4766
- `);
4767
- }
4768
- return highlightSheet;
4769
- }
4770
- var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
4771
- var ICONS = {
4772
- play: "M8 5v14l11-7z",
4773
- pause: "M6 5h4v14H6zM14 5h4v14h-4z",
4774
- stop: "M6 6h12v12H6z",
4775
- prev: "M6 5h2v14H6zM20 5v14L9 12z",
4776
- next: "M16 5h2v14h-2zM4 5v14l11-7z",
4777
- pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
4778
- };
4779
- var iconContent = (icon, label) => {
4780
- const svg = html22`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
4781
- <path d="${ICONS[icon]}"></path>
4782
- </svg>`;
4783
- return html22`${svg}<span class="label">${label}</span>`;
4784
- };
4785
- var TtsButtonBase = class extends LitElement29 {
4786
- static {
4787
- this.styles = css9`
4788
- :host {
4789
- display: inline-flex;
4790
- }
4791
- button {
4792
- ${btn};
4793
- min-inline-size: var(--button-size, var(--test-button-size, 2.25rem));
4794
- padding-inline: 0.5rem;
4795
- /* Containing block for the visually hidden .label. Without it the label is placed against
4796
- the nearest positioned ancestor, which can sit outside a scroll container and make the
4797
- page as tall as the scrolled content. */
4798
- position: relative;
4799
- }
4800
- @media (hover: hover) and (pointer: fine) {
4801
- button:hover:not(:disabled) {
4802
- ${btnInteractive};
4803
- }
4804
- }
4805
- button:active:not(:disabled) {
4806
- ${btnActive};
4807
- }
4808
- button:focus-visible {
4809
- ${focusRing};
4810
- }
4811
- button:disabled {
4812
- ${dis};
4813
- }
4814
- /* A toggle that is on (the pick button in pick mode). The host carries :state(selected) for a
4815
- page's own rules; in here the inner button's aria-pressed says the same thing and matches in
4816
- a browser without :state(), so the look keys on that. */
4817
- button[aria-pressed='true'],
4818
- button[aria-pressed='true']:hover {
4819
- background-color: var(
4820
- --button-selected-background-color,
4821
- var(--test-button-selected-background-color, var(--qti-selected-bg, Highlight))
4822
- );
4823
- color: var(--button-selected-color, var(--test-button-selected-color, var(--qti-selected-color, HighlightText)));
4824
- }
4825
- svg,
4826
- ::slotted(svg) {
4827
- flex: none;
4828
- inline-size: var(--test-tts-icon-size, 1.125rem);
4829
- block-size: var(--test-tts-icon-size, 1.125rem);
4830
- }
4831
- svg {
4832
- fill: currentColor;
4833
- }
4834
- /* The default content is icon-only; this keeps the button's accessible name. */
4835
- .label {
4836
- position: absolute;
4837
- inline-size: 1px;
4838
- block-size: 1px;
4839
- overflow: hidden;
4840
- clip-path: inset(50%);
4841
- white-space: nowrap;
4842
- }
4843
- `;
4844
- }
4845
- #internals = this.attachInternals();
4846
- #mirroredState;
4847
- #mirroredPicking = false;
4848
- #mirroredSelected = false;
4849
- /** Whether this control is a toggle that is on; mirrored as `:state(selected)`. A plain button never is. */
4850
- get selected() {
4851
- return false;
4852
- }
4853
- updated(_changed) {
4854
- const state10 = this._tts?.state;
4855
- const picking = this._tts?.picking ?? false;
4856
- const selected = this.selected;
4857
- if (state10 === this.#mirroredState && picking === this.#mirroredPicking && selected === this.#mirroredSelected)
4858
- return;
4859
- this.#mirroredState = state10;
4860
- this.#mirroredPicking = picking;
4861
- this.#mirroredSelected = selected;
4862
- this.#internals.states.clear();
4863
- if (state10)
4864
- this.#internals.states.add(state10);
4865
- if (picking)
4866
- this.#internals.states.add("picking");
4867
- if (selected)
4868
- this.#internals.states.add("selected");
4869
- }
4870
- };
4871
- __decorate30([
4872
- property23({ type: String })
4873
- ], TtsButtonBase.prototype, "label", void 0);
4874
- __decorate30([
4875
- consume19({ context: ttsContext, subscribe: true })
4876
- ], TtsButtonBase.prototype, "_tts", void 0);
4877
- var TestItemToSpeech = class extends LitElement29 {
4878
- static {
4879
- this.styles = css9`
4880
- :host {
4881
- display: inline-flex;
4882
- flex-wrap: wrap;
4883
- align-items: center;
4884
- gap: var(--test-tts-gap, 0.25rem);
4885
- }
4886
- `;
4887
- }
4888
- #internals;
4889
- // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
4890
- // placeholder itself is looked up on every use — a host may swap the element.
4891
- #stimulusMode;
4892
- // Stimulus mode: resets the player when the stimulus content next to it is replaced.
4893
- #stimulusObserver;
4894
- // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
4895
- // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
4896
- #contentMode;
4897
- // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
4898
- #itemRef;
4899
- // Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's
4900
- // navigation request is heard.
4901
- #eventHost;
4902
- #boundHandleItemConnected;
4903
- #boundHandleNavigation;
4904
- // Cursor mode: the previous navigation position, to detect moving to another item or section.
4905
- #prevNavItemRefId;
4906
- #prevNavSectionId;
4907
- // Current set of block-level reading elements for the item, and the root they were collected from
4908
- #readingElements;
4909
- #readingRoot;
4910
- #currentElementIndex;
4911
- // Text nodes of the element currently being spoken (for word-boundary highlight)
4912
- #textNodes;
4913
- // The utterance this player is speaking; lets the error handler tell "our speech was
4914
- // cancelled by another player" apart from a cancel we issued ourselves.
4915
- #currentUtterance;
4916
- // Pick mode: all elements highlighted, a click on one starts reading from there.
4917
- #picking;
4918
- #pickRoot;
4919
- #boundHandlePickClick;
4920
- // Set when the last element has been read: the cursor stays on it (so prev still works),
4921
- // but the next play starts the item over instead of repeating that last element.
4922
- #finished;
4923
- // Two separate CSS Highlight objects
4924
- #elementHighlight;
4925
- // whole-element cursor
4926
- #wordHighlight;
4927
- // current word during speech
4928
- constructor() {
4929
- super();
4930
- this.language = "nl-NL";
4931
- this.#internals = this.attachInternals();
4932
- this.#stimulusMode = false;
4933
- this.#stimulusObserver = null;
4934
- this.#contentMode = false;
4935
- this.#itemRef = null;
4936
- this.#eventHost = null;
4937
- this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
4938
- this.#boundHandleNavigation = () => this.#stop();
4939
- this.#prevNavItemRefId = void 0;
4940
- this.#prevNavSectionId = void 0;
4941
- this.#readingElements = null;
4942
- this.#readingRoot = null;
4943
- this.#currentElementIndex = 0;
4944
- this.#textNodes = [];
4945
- this.#currentUtterance = null;
4946
- this.#picking = false;
4947
- this.#pickRoot = null;
4948
- this.#boundHandlePickClick = this.#handlePickClick.bind(this);
4949
- this.#finished = false;
4950
- this.#elementHighlight = new Highlight();
4951
- this.#wordHighlight = new Highlight();
4952
- this._ttsContext = {
4953
- state: "idle",
4954
- currentElementIndex: 0,
4955
- elementCount: 0,
4956
- play: () => this.#playSpeech(),
4957
- pause: () => this.#pause(),
4958
- resume: () => this.#resume(),
4959
- stop: () => {
4960
- this.#stopPicking();
4961
- this.#stop();
4962
- },
4963
- prevElement: () => this.#prevElement(),
4964
- nextElement: () => this.#nextElement(),
4965
- togglePick: () => this.#togglePick(),
4966
- picking: false
4967
- };
4968
- }
4969
- // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
4970
- // render already under way instead of scheduling a second one (Lit's change-in-update).
4971
- willUpdate(changed) {
4972
- super.willUpdate(changed);
4973
- if (this.#stimulusMode || this.#contentMode || this.#itemRef)
4974
- return;
4975
- const { item, section } = this.#activePosition();
4976
- const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
4977
- const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
4978
- const rerendered = this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();
4979
- if (itemChanged || sectionChanged || rerendered)
4980
- this.#resetReadingPosition();
4981
- this.#prevNavItemRefId = item;
4982
- this.#prevNavSectionId = section;
4983
- }
4984
- /** Stop speech and forget the collected reading elements, so the next play starts afresh. */
4985
- #resetReadingPosition() {
4986
- this.#stopPicking();
4987
- this.#stop();
4988
- this.#readingElements = null;
4989
- this.#currentElementIndex = 0;
4990
- this.#finished = false;
4991
- this.#updateContext();
4992
- }
4993
- connectedCallback() {
4994
- super.connectedCallback();
4995
- this.#setSpeechState("idle");
4996
- this.#stimulusMode = this.#stimulusPlaceholder() !== null;
4997
- if (this.#stimulusMode) {
4998
- this.#stimulusObserver = new MutationObserver((records) => {
4999
- if (records.some((record) => !this.contains(record.target)))
5000
- this.#handleStimulusReplaced();
5001
- });
5002
- this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
5003
- return;
5004
- }
5005
- this.#contentMode = this.#contentElement() !== null;
5006
- if (this.#contentMode)
5007
- return;
5008
- this.#itemRef = this.closest("qti-assessment-item-ref");
5009
- if (this.#itemRef) {
5010
- this.#eventHost = this.#itemRef;
5011
- this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
5012
- } else {
5013
- this.#eventHost = this.closest("test-navigation") ?? this.getRootNode();
5014
- this.#eventHost.addEventListener("qc-test-navigate", this.#boundHandleNavigation);
5015
- this.#eventHost.addEventListener("cito-test-navigate", this.#boundHandleNavigation);
5016
- }
5017
- }
5018
- disconnectedCallback() {
5019
- super.disconnectedCallback();
5020
- if (this.#currentUtterance) {
5021
- this.#currentUtterance = null;
5022
- speechSynthesis.cancel();
5023
- }
5024
- this.#stopPicking();
5025
- this.#clearAllHighlights();
5026
- this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
5027
- this.#eventHost?.removeEventListener("qc-test-navigate", this.#boundHandleNavigation);
5028
- this.#eventHost?.removeEventListener("cito-test-navigate", this.#boundHandleNavigation);
5029
- this.#eventHost = null;
5030
- this.#itemRef = null;
5031
- this.#stimulusObserver?.disconnect();
5032
- this.#stimulusObserver = null;
5033
- this.#stimulusMode = false;
5034
- this.#contentMode = false;
5035
- }
5036
- render() {
5037
- return html22`<slot></slot>`;
5038
- }
5039
- /** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */
5040
- #handleItemConnected() {
5041
- if (this.#readingElements !== null)
5042
- this.#resetReadingPosition();
5043
- }
5044
- /** Cursor mode: the active item and section, from the computed context. */
5045
- #activePosition() {
5046
- for (const part of this._computedContext?.testParts ?? []) {
5047
- for (const section of part.sections) {
5048
- if (!section.active)
5049
- continue;
5050
- return { item: section.items.find((item) => item.active)?.identifier ?? null, section: section.identifier };
5051
- }
5052
- }
5053
- return { item: null, section: null };
5054
- }
5055
- /**
5056
- * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
5057
- * collected, so the next play reads the new content from the top. Unlike
5058
- * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
5059
- * while an item player on the same page is speaking.
5060
- */
5061
- #handleStimulusReplaced() {
5062
- if (this.#currentUtterance) {
5063
- this.#currentUtterance = null;
5064
- speechSynthesis.cancel();
5065
- }
5066
- this.#stopPicking();
5067
- this.#clearAllHighlights();
5068
- this.#setSpeechState("idle");
5069
- this.#readingElements = null;
5070
- this.#currentElementIndex = 0;
5071
- this.#finished = false;
5072
- this.#updateContext();
5073
- }
5074
- /**
5075
- * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
5076
- * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
5077
- * loading replaces the placeholder's content.
5078
- */
5079
- #stimulusPlaceholder() {
5080
- return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
5081
- }
5082
- /**
5083
- * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
5084
- * The marker goes on one container; the player finds the readable elements inside it.
5085
- */
5086
- #contentElement() {
5087
- return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
5088
- }
5089
- /**
5090
- * The element whose text is read: the stimulus body next to the player (stimulus mode), the
5091
- * marked content next to it (content mode), or the item body of the item to read.
5092
- */
5093
- #resolveReadingRoot() {
5094
- if (this.#stimulusMode)
5095
- return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
5096
- if (this.#contentMode)
5097
- return this.#contentElement();
5098
- return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
5099
- }
5100
- /**
5101
- * The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test
5102
- * looks the active one up in its own items (`computedContext.itemElement`), so a page with
5103
- * several tests showing the same item still reads the right one.
5104
- */
5105
- #resolveItem() {
5106
- if (this.#itemRef)
5107
- return this.#itemRef.assessmentItem;
5108
- const { item } = this.#activePosition();
5109
- return item ? this._computedContext?.itemElement?.(item) ?? null : null;
5110
- }
5111
- /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
5112
- #setSpeechState(state10) {
5113
- this._ttsContext = { ...this._ttsContext, state: state10 };
5114
- this.#internals.states.delete("idle");
5115
- this.#internals.states.delete("playing");
5116
- this.#internals.states.delete("paused");
5117
- this.#internals.states.add(state10);
5118
- }
5119
- /** Push currentElementIndex and elementCount into context so children can react. */
5120
- #updateContext() {
5121
- this._ttsContext = {
5122
- ...this._ttsContext,
5123
- currentElementIndex: this.#currentElementIndex,
5124
- elementCount: this.#getReadingElements().length
5125
- };
5126
- }
5127
- /**
5128
- * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
5129
- * first call), filtered live for visibility on every call. Feedback and other
5130
- * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
5131
- * CSS custom state reveals it) is excluded while hidden and picked up again once shown,
5132
- * without needing to re-collect the candidate set.
5133
- */
5134
- #getReadingElements() {
5135
- if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
5136
- this.#readingElements = null;
5137
- this.#currentElementIndex = 0;
5138
- this.#finished = false;
5139
- }
5140
- if (this.#readingElements === null) {
5141
- const root = this.#resolveReadingRoot();
5142
- if (!root)
5143
- return [];
5144
- this.#readingRoot = root;
5145
- const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
5146
- this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
5147
- }
5148
- return this.#readingElements.filter((el) => this.#isVisible(el));
5149
- }
5150
- /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
5151
- #isVisible(element) {
5152
- if (typeof element.checkVisibility === "function") {
5153
- return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
5154
- }
5155
- return element.getClientRects().length > 0;
5156
- }
5157
- /**
5158
- * Resolve the speech language for a reading element.
5159
- * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.
5160
- * Empty `lang=""` is treated as absent.
5161
- */
5162
- #resolveLang(element) {
5163
- let node = element;
5164
- while (node) {
5165
- const lang = node.getAttribute("lang") || node.getAttribute("xml:lang");
5166
- if (lang?.trim())
5167
- return lang.trim();
5168
- node = node.parentElement ?? node.getRootNode().host ?? null;
5169
- }
5170
- const documentLang = document.documentElement.getAttribute("lang");
5171
- if (documentLang?.trim())
5172
- return documentLang.trim();
5173
- return this.language;
5174
- }
5175
- #playSpeech() {
5176
- const elements = this.#getReadingElements();
5177
- if (!elements.length) {
5178
- console.warn("test-item-to-speech: no readable elements found");
5179
- return;
5180
- }
5181
- this.#stopPicking();
5182
- speechSynthesis.cancel();
5183
- if (this.#finished) {
5184
- this.#finished = false;
5185
- this.#currentElementIndex = 0;
5186
- }
5187
- if (this.#contentMode && this.#currentElementIndex === 0)
5188
- this.#readingElements = null;
5189
- this.#speakElement(this.#currentElementIndex);
5190
- }
5191
- /** Speak the element at the given index, then auto-advance when it ends. */
5192
- #speakElement(index) {
5193
- const elements = this.#getReadingElements();
5194
- if (index >= elements.length) {
5195
- this.#clearWordHighlight();
5196
- this.#currentElementIndex = elements.length - 1;
5197
- if (elements.length > 0)
5198
- this.#highlightElement(elements[this.#currentElementIndex]);
5199
- this.#finished = true;
5200
- this.#setSpeechState("idle");
5201
- this.#updateContext();
5202
- return;
5203
- }
5204
- this.#currentElementIndex = index;
5205
- this.#finished = false;
5206
- this.#updateContext();
5207
- const element = elements[index];
5208
- element.scrollIntoView({ behavior: "smooth", block: "nearest" });
5209
- this.#highlightElement(element);
5210
- this.#textNodes = this.#collectTextNodes(element);
5211
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
5212
- if (!text.trim()) {
5213
- this.#speakElement(index + 1);
5214
- return;
5215
- }
5216
- const utterance = new SpeechSynthesisUtterance(text);
5217
- utterance.lang = this.#resolveLang(element);
5218
- utterance.rate = 1;
5219
- utterance.onboundary = (event) => {
5220
- if (event.name !== "word")
5221
- return;
5222
- this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);
5223
- };
5224
- utterance.onend = () => {
5225
- if (this.#currentUtterance !== utterance)
5226
- return;
5227
- this.#currentUtterance = null;
5228
- this.#clearWordHighlight();
5229
- this.#speakElement(this.#currentElementIndex + 1);
5230
- };
5231
- utterance.onerror = () => {
5232
- if (this.#currentUtterance !== utterance)
5233
- return;
5234
- this.#currentUtterance = null;
5235
- this.#clearAllHighlights();
5236
- this.#setSpeechState("idle");
5237
- };
5238
- this.#currentUtterance = utterance;
5239
- speechSynthesis.speak(utterance);
5240
- this.#setSpeechState("playing");
5241
- }
5242
- #pause() {
5243
- speechSynthesis.pause();
5244
- this.#setSpeechState("paused");
5245
- }
5246
- #resume() {
5247
- speechSynthesis.resume();
5248
- this.#setSpeechState("playing");
5249
- }
5250
- #stop() {
5251
- this.#currentUtterance = null;
5252
- speechSynthesis.cancel();
5253
- this.#clearAllHighlights();
5254
- this.#setSpeechState("idle");
5255
- }
5256
- // ─── Pick mode ────────────────────────────────────────────────────────────
5257
- #togglePick() {
5258
- if (this.#picking)
5259
- this.#stopPicking();
5260
- else
5261
- this.#startPicking();
5262
- }
5263
- /** Highlight every reading element and wait for a click on one of them. */
5264
- #startPicking() {
5265
- if (this.#contentMode)
5266
- this.#readingElements = null;
5267
- const elements = this.#getReadingElements();
5268
- if (!elements.length) {
5269
- console.warn("test-item-to-speech: no readable elements found");
5270
- return;
5271
- }
5272
- this.#stop();
5273
- this.#picking = true;
5274
- this.#internals.states.add("picking");
5275
- this.#highlightElements(elements);
5276
- this.#pickRoot = elements[0].getRootNode();
5277
- this.#pickRoot.addEventListener("click", this.#boundHandlePickClick, true);
5278
- this._ttsContext = { ...this._ttsContext, picking: true };
5279
- }
5280
- #stopPicking() {
5281
- if (!this.#picking)
5282
- return;
5283
- this.#picking = false;
5284
- this.#internals.states.delete("picking");
5285
- this.#pickRoot?.removeEventListener("click", this.#boundHandlePickClick, true);
5286
- this.#pickRoot = null;
5287
- this.#clearAllHighlights();
5288
- this._ttsContext = { ...this._ttsContext, picking: false };
5289
- }
5290
- #handlePickClick(event) {
5291
- const elements = this.#getReadingElements();
5292
- const path = event.composedPath();
5293
- let index = elements.findIndex((el) => path.includes(el));
5294
- if (index < 0) {
5295
- const container = path.find((node) => node instanceof Element && node.matches("qti-simple-choice, li, qti-prompt"));
5296
- if (container)
5297
- index = elements.findIndex((el) => container.contains(el));
5298
- }
5299
- if (index < 0)
5300
- return;
5301
- event.preventDefault();
5302
- event.stopPropagation();
5303
- this.#stopPicking();
5304
- speechSynthesis.cancel();
5305
- this.#speakElement(index);
5306
- }
5307
- #prevElement() {
5308
- const elements = this.#getReadingElements();
5309
- if (!elements.length)
5310
- return;
5311
- this.#currentUtterance = null;
5312
- speechSynthesis.cancel();
5313
- this.#clearWordHighlight();
5314
- this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);
5315
- this.#finished = false;
5316
- this.#updateContext();
5317
- const el = elements[this.#currentElementIndex];
5318
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
5319
- this.#highlightElement(el);
5320
- this.#setSpeechState("idle");
5321
- }
5322
- #nextElement() {
5323
- const elements = this.#getReadingElements();
5324
- if (!elements.length)
5325
- return;
5326
- this.#currentUtterance = null;
5327
- speechSynthesis.cancel();
5328
- this.#clearWordHighlight();
5329
- this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);
5330
- this.#finished = false;
5331
- this.#updateContext();
5332
- const el = elements[this.#currentElementIndex];
5333
- el.scrollIntoView({ behavior: "smooth", block: "nearest" });
5334
- this.#highlightElement(el);
5335
- this.#setSpeechState("idle");
5336
- }
5337
- /** Walk text nodes without crossing shadow DOM boundaries. */
5338
- #collectTextNodes(root) {
5339
- const nodes = [];
5340
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
5341
- let node;
5342
- while (node = walker.nextNode()) {
5343
- if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
5344
- nodes.push(node);
5345
- }
5346
- }
5347
- return nodes;
5348
- }
5349
- /** Highlight the whole element as the navigation cursor (blue). */
5350
- #highlightElement(element) {
5351
- this.#highlightElements([element]);
5352
- }
5353
- /** Put the blue cursor highlight on several elements at once (pick mode). */
5354
- #highlightElements(elements) {
5355
- if (!("highlights" in CSS))
5356
- return;
5357
- this.#ensureHighlightStyles();
5358
- this.#elementHighlight.clear();
5359
- for (const element of elements) {
5360
- const range = new Range();
5361
- range.selectNodeContents(element);
5362
- this.#elementHighlight.add(range);
5363
- }
5364
- CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);
5365
- }
5366
- /** Highlight the current word within #textNodes (yellow, during speech). */
5367
- #updateWordHighlight(charIndex, charLength) {
5368
- if (!("highlights" in CSS))
5369
- return;
5370
- this.#ensureHighlightStyles();
5371
- this.#wordHighlight.clear();
5372
- const text = this.#textNodes.map((n) => n.textContent ?? "").join("");
5373
- const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));
5374
- let offset = 0;
5375
- let startNode = null;
5376
- let startOffset = 0;
5377
- let endNode = null;
5378
- let endOffset = 0;
5379
- for (const node of this.#textNodes) {
5380
- const len = node.textContent?.length ?? 0;
5381
- if (!startNode && offset + len > charIndex) {
5382
- startNode = node;
5383
- startOffset = charIndex - offset;
5384
- }
5385
- if (startNode && offset + len >= endIndex) {
5386
- endNode = node;
5387
- endOffset = endIndex - offset;
5388
- break;
5389
- }
5390
- offset += len;
5391
- }
5392
- if (startNode && endNode) {
5393
- const range = new Range();
5394
- range.setStart(startNode, startOffset);
5395
- range.setEnd(endNode, endOffset);
5396
- this.#wordHighlight.add(range);
5397
- CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);
5398
- }
5399
- }
5400
- #clearWordHighlight() {
5401
- if (!("highlights" in CSS))
5402
- return;
5403
- this.#wordHighlight.clear();
5404
- if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight)
5405
- CSS.highlights.delete(HIGHLIGHT_WORD);
5406
- }
5407
- #clearAllHighlights() {
5408
- if (!("highlights" in CSS))
5409
- return;
5410
- this.#clearWordHighlight();
5411
- this.#elementHighlight.clear();
5412
- if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight)
5413
- CSS.highlights.delete(HIGHLIGHT_ELEMENT);
5414
- }
5415
- /** Fallback word-length when charLength is 0. */
5416
- #wordLengthAt(charIndex, text) {
5417
- const right = text.slice(charIndex).search(/\s/);
5418
- return right < 0 ? text.length - charIndex : right;
5419
- }
5420
- /**
5421
- * Add ::highlight() rules both to the shadow root the highlighted text lives in and to the
5422
- * document (safety net — spec allows document rules to apply across shadow DOM). Called lazily
5423
- * on first highlight use, once the reading elements have been collected.
5424
- */
5425
- #ensureHighlightStyles() {
5426
- if (!("highlights" in CSS))
5427
- return;
5428
- const sheet = getHighlightSheet();
5429
- if (!document.adoptedStyleSheets.includes(sheet)) {
5430
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
5431
- }
5432
- const roots = /* @__PURE__ */ new Set();
5433
- const ownRoot = this.getRootNode();
5434
- if (ownRoot instanceof ShadowRoot)
5435
- roots.add(ownRoot);
5436
- const itemRoot = this.#readingElements?.[0]?.getRootNode();
5437
- if (itemRoot instanceof ShadowRoot)
5438
- roots.add(itemRoot);
5439
- for (const root of roots) {
5440
- if (!root.adoptedStyleSheets.includes(sheet)) {
5441
- root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
5442
- }
5443
- }
5444
- }
5445
- };
5446
- __decorate30([
5447
- property23({ type: String })
5448
- ], TestItemToSpeech.prototype, "language", void 0);
5449
- __decorate30([
5450
- consume19({ context: computedContext, subscribe: true })
5451
- ], TestItemToSpeech.prototype, "_computedContext", void 0);
5452
- __decorate30([
5453
- state9(),
5454
- provide4({ context: ttsContext })
5455
- ], TestItemToSpeech.prototype, "_ttsContext", void 0);
5456
- var TestTtsPlay = class extends TtsButtonBase {
5457
- #toggle() {
5458
- if (!this._tts)
5459
- return;
5460
- if (this._tts.state === "idle")
5461
- this._tts.play();
5462
- else if (this._tts.state === "playing")
5463
- this._tts.pause();
5464
- else
5465
- this._tts.resume();
5466
- }
5467
- render() {
5468
- const playing = this._tts?.state === "playing";
5469
- return html22`
5470
- <button part="button" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>
5471
- ${playing ? html22`<slot name="pause">${iconContent("pause", this.pauseLabel ?? "Pause")}</slot>` : html22`<slot name="play">${iconContent("play", this.label ?? "Play")}</slot>`}
5472
- </button>
5473
- `;
5474
- }
5475
- };
5476
- __decorate30([
5477
- property23({ type: String, attribute: "pause-label" })
5478
- ], TestTtsPlay.prototype, "pauseLabel", void 0);
5479
- var TestTtsPause = class extends TtsButtonBase {
5480
- render() {
5481
- return html22`
5482
- <button
5483
- part="button"
5484
- aria-label=${ifDefined(this.label)}
5485
- ?disabled=${this._tts?.state !== "playing"}
5486
- @click=${() => this._tts?.pause()}
5487
- >
5488
- <slot>${iconContent("pause", this.label ?? "Pause")}</slot>
5489
- </button>
5490
- `;
5491
- }
5492
- };
5493
- var TestTtsResume = class extends TtsButtonBase {
5494
- render() {
5495
- return html22`
5496
- <button
5497
- part="button"
5498
- aria-label=${ifDefined(this.label)}
5499
- ?disabled=${this._tts?.state !== "paused"}
5500
- @click=${() => this._tts?.resume()}
5501
- >
5502
- <slot>${iconContent("play", this.label ?? "Resume")}</slot>
5503
- </button>
5504
- `;
5505
- }
5506
- };
5507
- var TestTtsStop = class extends TtsButtonBase {
5508
- render() {
5509
- const idle = this._tts?.state === "idle" && !this._tts?.picking;
5510
- return html22`
5511
- <button part="button" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>
5512
- <slot>${iconContent("stop", this.label ?? "Stop")}</slot>
5513
- </button>
5514
- `;
5515
- }
5516
- };
5517
- var TestTtsPrev = class extends TtsButtonBase {
5518
- render() {
5519
- const collected = (this._tts?.elementCount ?? 0) > 0;
5520
- const atStart = (this._tts?.currentElementIndex ?? 0) === 0;
5521
- return html22`
5522
- <button
5523
- part="button"
5524
- aria-label=${ifDefined(this.label)}
5525
- ?disabled=${collected && atStart}
5526
- @click=${() => this._tts?.prevElement()}
5527
- >
5528
- <slot>${iconContent("prev", this.label ?? "Previous sentence")}</slot>
5529
- </button>
5530
- `;
5531
- }
5532
- };
5533
- var TestTtsNext = class extends TtsButtonBase {
5534
- render() {
5535
- const count = this._tts?.elementCount ?? 0;
5536
- const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;
5537
- return html22`
5538
- <button
5539
- part="button"
5540
- aria-label=${ifDefined(this.label)}
5541
- ?disabled=${atEnd}
5542
- @click=${() => this._tts?.nextElement()}
5543
- >
5544
- <slot>${iconContent("next", this.label ?? "Next sentence")}</slot>
5545
- </button>
5546
- `;
5547
- }
5548
- };
5549
- var TestTtsPick = class extends TtsButtonBase {
5550
- get selected() {
5551
- return this._tts?.picking ?? false;
5552
- }
5553
- render() {
5554
- return html22`
5555
- <button
5556
- part="button"
5557
- aria-label=${ifDefined(this.label)}
5558
- aria-pressed=${this._tts?.picking ? "true" : "false"}
5559
- @click=${() => this._tts?.togglePick()}
5560
- >
5561
- <slot>${iconContent("pick", this.label ?? "Read from here")}</slot>
5562
- </button>
5563
- `;
5564
- }
5565
- };
5566
-
5567
- // ../qti-test/dist/tts/elements.js
5568
- var ttsElements = [
5569
- { tag: "test-item-to-speech", ctor: TestItemToSpeech },
5570
- { tag: "test-tts-next", ctor: TestTtsNext },
5571
- { tag: "test-tts-pause", ctor: TestTtsPause },
5572
- { tag: "test-tts-pick", ctor: TestTtsPick },
5573
- { tag: "test-tts-play", ctor: TestTtsPlay },
5574
- { tag: "test-tts-prev", ctor: TestTtsPrev },
5575
- { tag: "test-tts-resume", ctor: TestTtsResume },
5576
- { tag: "test-tts-stop", ctor: TestTtsStop }
5577
- ];
5578
-
5579
3880
  // ../qti-test/dist/plugins/elements.js
5580
- var pluginElements = [
5581
- { tag: "test-check-item", ctor: TestCheckItem },
5582
- { tag: "test-bookmark", ctor: TestBookmark },
5583
- { tag: "test-print-context", ctor: TestPrintContext },
5584
- { tag: "test-print-item-variables", ctor: TestPrintVariables },
5585
- { tag: "test-print-state", ctor: TestPrintState },
5586
- { tag: "test-scoring-buttons", ctor: TestScoringButtons },
5587
- { tag: "test-scoring-feedback", ctor: TestScoringFeedback },
5588
- { tag: "test-stamp", ctor: TestStamp },
5589
- { tag: "test-submit", ctor: TestSubmit },
5590
- { tag: "test-view", ctor: TestView },
5591
- { tag: "test-view-toggle", ctor: TestViewToggle },
5592
- ...ttsElements
5593
- ];
3881
+ var pluginElements = [{ tag: "test-submit", ctor: TestSubmit }];
5594
3882
 
5595
3883
  // ../qti-test/dist/elements.js
5596
3884
  var qtiTestElements = [
@@ -5609,11 +3897,9 @@ var qtiTestElements = [
5609
3897
  { tag: "qti-test-variables", ctor: QtiTestVariables },
5610
3898
  { tag: "test-container", ctor: TestContainer },
5611
3899
  { tag: "test-end-attempt", ctor: TestEndAttempt },
5612
- { tag: "test-item-link", ctor: TestItemLink },
5613
3900
  { tag: "test-navigation", ctor: TestNavigation },
5614
3901
  { tag: "test-next", ctor: TestNext },
5615
3902
  { tag: "test-prev", ctor: TestPrev },
5616
- { tag: "test-section-link", ctor: TestSectionLink },
5617
3903
  ...pluginElements
5618
3904
  ];
5619
3905
 
@@ -5636,33 +3922,10 @@ export {
5636
3922
  QtiTest,
5637
3923
  TestContainer,
5638
3924
  TestEndAttempt,
5639
- TestItemLink,
5640
3925
  TestNavigation,
5641
3926
  TestNext,
5642
3927
  TestPrev,
5643
- TestSectionLink,
5644
- pluginState,
5645
- bookmarkedItems,
5646
- TestBookmark,
5647
- TestCheckItem,
5648
- TestPrintContext,
5649
- TestPrintVariables,
5650
- TestPrintState,
5651
- TestScoringButtons,
5652
- TestScoringFeedback,
5653
- TestStamp,
5654
3928
  TestSubmit,
5655
- TestView,
5656
- TestViewToggle,
5657
- TestItemToSpeech,
5658
- TestTtsPlay,
5659
- TestTtsPause,
5660
- TestTtsResume,
5661
- TestTtsStop,
5662
- TestTtsPrev,
5663
- TestTtsNext,
5664
- TestTtsPick,
5665
- ttsElements,
5666
3929
  pluginElements,
5667
3930
  qtiTestElements
5668
3931
  };
@@ -5678,4 +3941,4 @@ export {
5678
3941
  * Portions Copyright (c) 2013, the Dart project authors.
5679
3942
  *)
5680
3943
  */
5681
- //# sourceMappingURL=chunk-LQ65RILE.js.map
3944
+ //# sourceMappingURL=chunk-UURHLJVM.js.map