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

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 (72) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +1643 -2742
  3. package/dist/base.d.ts +32 -8
  4. package/dist/base.js +7 -1
  5. package/dist/{chunk-HGKLF7SP.js → chunk-4DC5Z2LQ.js} +2 -2
  6. package/dist/{chunk-MP2SUN7J.js → chunk-7MYZHZWV.js} +981 -383
  7. package/dist/chunk-7MYZHZWV.js.map +1 -0
  8. package/dist/{chunk-LFVPS7KB.js → chunk-DAOLVUTR.js} +2 -2
  9. package/dist/{chunk-CCI3QMQA.js → chunk-H3Z3TMFB.js} +55 -60
  10. package/dist/chunk-H3Z3TMFB.js.map +1 -0
  11. package/dist/{chunk-LEF7AAYZ.js → chunk-J3F3JSCW.js} +2 -2
  12. package/dist/{chunk-NYNL5HSR.js → chunk-L3LBSAGZ.js} +2 -2
  13. package/dist/{chunk-BZPMN57E.js → chunk-L7J2ZOJL.js} +2 -2
  14. package/dist/{chunk-TLAVOBEM.js → chunk-LORYM4U2.js} +120 -1
  15. package/dist/chunk-LORYM4U2.js.map +1 -0
  16. package/dist/{chunk-6XRNX574.js → chunk-LQ65RILE.js} +141 -106
  17. package/dist/chunk-LQ65RILE.js.map +1 -0
  18. package/dist/{chunk-C7SYDLMG.js → chunk-M4TZIB3W.js} +61 -27
  19. package/dist/chunk-M4TZIB3W.js.map +1 -0
  20. package/dist/{chunk-S5GLISQA.js → chunk-NWSDBYK7.js} +2 -2
  21. package/dist/{chunk-O2ENNGKV.js → chunk-NZ7ZC4SP.js} +126 -7
  22. package/dist/chunk-NZ7ZC4SP.js.map +1 -0
  23. package/dist/{chunk-SWNFCQ4G.js → chunk-OG5HIRHE.js} +4 -4
  24. package/dist/{chunk-TU34FFWF.js → chunk-UDJ7MHLF.js} +4 -4
  25. package/dist/chunk-UDJ7MHLF.js.map +1 -0
  26. package/dist/chunk-WWY2H2YO.js +7 -0
  27. package/dist/chunk-WWY2H2YO.js.map +1 -0
  28. package/dist/{computed.types.d-IXACuBr7.d.ts → computed.types.d-n3K2VvB0.d.ts} +2 -2
  29. package/dist/{config.context.d-BniMHSBB.d.ts → config.context.d-CCqlJXpE.d.ts} +2 -1
  30. package/dist/corrections.d.ts +119 -15
  31. package/dist/corrections.js +9 -9
  32. package/dist/elements.d.ts +67 -16
  33. package/dist/elements.js +4 -4
  34. package/dist/index.d.ts +11 -11
  35. package/dist/index.js +21 -15
  36. package/dist/interactions.d.ts +83 -17
  37. package/dist/interactions.js +3 -3
  38. package/dist/item.css +1133 -2370
  39. package/dist/item.d.ts +4 -4
  40. package/dist/item.js +5 -5
  41. package/dist/loader.d.ts +1 -1
  42. package/dist/loader.js +2 -2
  43. package/dist/processing.js +3 -3
  44. package/dist/qti-components-jsx.d.ts +1239 -214
  45. package/dist/{qti-feedback.d-DbzPSJuK.d.ts → qti-feedback.d-1JL_qHjc.d.ts} +7 -0
  46. package/dist/{qti-item.d-BqWYBdV2.d.ts → qti-item.d-DDMDjWIk.d.ts} +2 -2
  47. package/dist/{qti-test.d-C0I1BIdH.d.ts → qti-test.d-CDdyCp6e.d.ts} +21 -18
  48. package/dist/{qti-text-entry-interaction.d-V4sWE9TO.d.ts → qti-text-entry-interaction.d-BTAKmr4b.d.ts} +160 -50
  49. package/dist/{qti-transform-test.d-BL7GGFJj.d.ts → qti-transform-test.d-Bb9vnLzP.d.ts} +1 -0
  50. package/dist/{record.d-C6m0Y4xr.d.ts → record.d-Bojj6_LW.d.ts} +34 -3
  51. package/dist/{session.context.d-DW09Lrie.d.ts → session.context.d-BNxGeyh9.d.ts} +1 -1
  52. package/dist/test.d.ts +9 -9
  53. package/dist/test.js +6 -6
  54. package/dist/transformers.d.ts +1 -1
  55. package/dist/transformers.js +1 -1
  56. package/package.json +11 -11
  57. package/dist/chunk-6XRNX574.js.map +0 -1
  58. package/dist/chunk-C7SYDLMG.js.map +0 -1
  59. package/dist/chunk-CCI3QMQA.js.map +0 -1
  60. package/dist/chunk-MP2SUN7J.js.map +0 -1
  61. package/dist/chunk-O2ENNGKV.js.map +0 -1
  62. package/dist/chunk-Q4MJCEDE.js +0 -7
  63. package/dist/chunk-Q4MJCEDE.js.map +0 -1
  64. package/dist/chunk-TLAVOBEM.js.map +0 -1
  65. package/dist/chunk-TU34FFWF.js.map +0 -1
  66. /package/dist/{chunk-HGKLF7SP.js.map → chunk-4DC5Z2LQ.js.map} +0 -0
  67. /package/dist/{chunk-LFVPS7KB.js.map → chunk-DAOLVUTR.js.map} +0 -0
  68. /package/dist/{chunk-LEF7AAYZ.js.map → chunk-J3F3JSCW.js.map} +0 -0
  69. /package/dist/{chunk-NYNL5HSR.js.map → chunk-L3LBSAGZ.js.map} +0 -0
  70. /package/dist/{chunk-BZPMN57E.js.map → chunk-L7J2ZOJL.js.map} +0 -0
  71. /package/dist/{chunk-S5GLISQA.js.map → chunk-NWSDBYK7.js.map} +0 -0
  72. /package/dist/{chunk-SWNFCQ4G.js.map → chunk-OG5HIRHE.js.map} +0 -0
@@ -6,6 +6,7 @@ import {
6
6
  boxSizing,
7
7
  configContext,
8
8
  dropRegion,
9
+ hasState,
9
10
  inferRecordFieldBaseType,
10
11
  interactionContext,
11
12
  isRecordValue,
@@ -16,8 +17,9 @@ import {
16
17
  removeDoubleSlashes,
17
18
  responseAttributeConverter,
18
19
  serializeResponseAttribute,
20
+ setState,
19
21
  validationMessage
20
- } from "./chunk-O2ENNGKV.js";
22
+ } from "./chunk-NZ7ZC4SP.js";
21
23
 
22
24
  // ../interactions/core/dist/elements/qti-associable-hotspot/qti-associable-hotspot.js
23
25
  import { LitElement, html } from "lit";
@@ -55,7 +57,7 @@ var qti_associable_hotspot_styles_default = [
55
57
 
56
58
  /* A placed chip keeps the box it had in the bank, even in a hotspot narrower than it (a boxed
57
59
  word on a small region): shrinking would wrap or squeeze its text (drag-drop.invariance). */
58
- [part~='drag'] {
60
+ [part~='chip'] {
59
61
  flex-shrink: 0;
60
62
  }
61
63
  `
@@ -344,7 +346,7 @@ function ActiveElementMixin(Base, type, { activateOn = "click" } = {}) {
344
346
  this.#pressActivated = false;
345
347
  if (activateOn !== "press" || event.button !== 0 || !event.isPrimary)
346
348
  return;
347
- if (this.hasAttribute("qti-draggable") || this.disabled || this.readonly)
349
+ if (this.hasAttribute("data-draggable") || this.disabled || this.readonly)
348
350
  return;
349
351
  this.#pressActivated = true;
350
352
  this.focus();
@@ -474,7 +476,7 @@ var qti_gap_text_styles_default = [
474
476
  /*
475
477
  * Centred wherever it lives — this is the one-line follow-up the note here used to promise.
476
478
  *
477
- * It read :host(:not([part~='drag'])), which reproduced an older accident: the centring rule
479
+ * It read :host(:not([part~='chip'])), which reproduced an older accident: the centring rule
478
480
  * used to be a document selector ('qti-gap-match-interaction qti-gap-text'), and a placed chip
479
481
  * lives inside qti-gap's shadow root where no document selector reaches. So a chip in the bank was
480
482
  * centred and the same chip in a gap was not, and the stylesheet gave no hint why.
@@ -576,6 +578,15 @@ var QtiHotspotChoice = class extends ActiveElementMixin(LitElement5, "qti-hotspo
576
578
  static {
577
579
  this.styles = qti_hotspot_choice_styles_default;
578
580
  }
581
+ updated(changed) {
582
+ super.updated(changed);
583
+ if (changed.has("order")) {
584
+ if (this.order === void 0 || this.order === null)
585
+ this.removeAttribute("data-order");
586
+ else
587
+ this.setAttribute("data-order", String(this.order));
588
+ }
589
+ }
579
590
  };
580
591
  __decorate6([
581
592
  property6({ attribute: "aria-ordervalue", type: Number, reflect: true })
@@ -758,9 +769,9 @@ var qti_simple_associable_choice_styles_default = [
758
769
  * draggable chip; in match's last match-set it is a drop target. In tabular match it is neither —
759
770
  * drag-drop is off and it is a row or column header in a grid.
760
771
  *
761
- * So the drop-target rules key on :state(droppable), which the interaction sets on exactly the
772
+ * So the drop-target rules key on :state(drop), which the interaction sets on exactly the
762
773
  * elements it tracks as droppables. Keying on the *absence* of a chip marker instead
763
- * (:not(:state(drag))) swept up every tabular header cell and gave each one a 4rem minimum.
774
+ * (:not(:state(chip))) swept up every tabular header cell and gave each one a 4rem minimum.
764
775
  *
765
776
  * A state rather than an attribute, and this used to be written both ways. An attribute cannot
766
777
  * be used by every host: the editor renders these choices inside a ProseMirror document, whose
@@ -769,7 +780,7 @@ var qti_simple_associable_choice_styles_default = [
769
780
  * that observer, so the state is the form that works everywhere and the [qti-droppable]
770
781
  * attribute that used to accompany it is gone. Positive opt-in, so tabular headers are untouched.
771
782
  */
772
- :host(:is(:state(droppable), [data-state~='droppable'])) {
783
+ :host(:is(:state(drop), [data-state~='drop'])) {
773
784
  /*
774
785
  * The CARD token, not the slot one. This element is a droppable only in match, and match
775
786
  * publishes no measurement — so reading --qti-dropzone-min-height here meant reading a name
@@ -795,7 +806,7 @@ var qti_simple_associable_choice_styles_default = [
795
806
  justify-content: space-between;
796
807
  }
797
808
 
798
- :host(:is(:state(droppable), [data-state~='droppable'])) [part~='drop'] {
809
+ :host(:is(:state(drop), [data-state~='drop'])) [part~='drop'] {
799
810
  /*
800
811
  * Match's dropzones are NOT auto-sized from the chips: a match target is a category, and
801
812
  * should look able to hold several answers rather than hugging the widest one. So this reads
@@ -835,7 +846,7 @@ var qti_simple_associable_choice_styles_default = [
835
846
  }
836
847
 
837
848
  /* The label sits against the drop region below it. */
838
- :host(:is(:state(droppable), [data-state~='droppable'])) [part~='label'] {
849
+ :host(:is(:state(drop), [data-state~='drop'])) [part~='label'] {
839
850
  align-content: flex-end;
840
851
  }
841
852
 
@@ -845,12 +856,12 @@ var qti_simple_associable_choice_styles_default = [
845
856
  * bank. The <slot> this replaced collapsed to nothing by accident; a div has to be told.
846
857
  *
847
858
  * Two conditions, because a chip identifies itself two ways:
848
- * :state(drag) a chip in the light-DOM bank, from the interaction's draggablesSelector
849
- * [part~='drag'] a chip a drop target renders, where that selector cannot reach it — match's
859
+ * :state(chip) a chip in the light-DOM bank, from the interaction's draggablesSelector
860
+ * [part~='chip'] a chip a drop target renders, where that selector cannot reach it — match's
850
861
  * selector names a light-DOM ancestry the placed clone no longer has
851
862
  */
852
- :host(:is(:state(drag), [data-state~='drag'])) [part~='drop'],
853
- :host([part~='drag']) [part~='drop'] {
863
+ :host(:is(:state(chip), [data-state~='chip'])) [part~='drop'],
864
+ :host([part~='chip']) [part~='drop'] {
854
865
  display: none;
855
866
  }
856
867
 
@@ -1107,7 +1118,7 @@ function applyDropzoneAutoSizing(host, draggables, droppables, dragContainers, o
1107
1118
  }
1108
1119
  });
1109
1120
  }
1110
- var DropzoneAutoSizeMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part="drags"]') => {
1121
+ var DropzoneAutoSizeMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]') => {
1111
1122
  class DropzoneAutoSizeElement extends superClass {
1112
1123
  constructor() {
1113
1124
  super(...arguments);
@@ -1293,22 +1304,22 @@ var [Observable, Subscriber] = (() => {
1293
1304
  const AsyncFromSyncIteratorPrototype = {
1294
1305
  next(...args) {
1295
1306
  const O = this;
1296
- const state16 = privateState.get(O);
1297
- if (!state16?.syncIteratorRecord)
1307
+ const state17 = privateState.get(O);
1308
+ if (!state17?.syncIteratorRecord)
1298
1309
  throw new TypeError(
1299
1310
  "AsyncFromSyncIteratorPrototype.next called on invalid object"
1300
1311
  );
1301
- const { syncIteratorRecord } = state16;
1312
+ const { syncIteratorRecord } = state17;
1302
1313
  return pTry(() => syncIteratorRecord.next(...args));
1303
1314
  },
1304
1315
  return(...args) {
1305
1316
  const O = this;
1306
- const state16 = privateState.get(O);
1307
- if (!state16?.syncIteratorRecord)
1317
+ const state17 = privateState.get(O);
1318
+ if (!state17?.syncIteratorRecord)
1308
1319
  throw new TypeError(
1309
1320
  "AsyncFromSyncIteratorPrototype.return called on invalid object"
1310
1321
  );
1311
- const { syncIteratorRecord } = state16;
1322
+ const { syncIteratorRecord } = state17;
1312
1323
  return pTry(() => {
1313
1324
  if (!syncIteratorRecord.return) return { value: void 0, done: true };
1314
1325
  return syncIteratorRecord.return(...args);
@@ -1316,12 +1327,12 @@ var [Observable, Subscriber] = (() => {
1316
1327
  },
1317
1328
  throw(...args) {
1318
1329
  const O = this;
1319
- const state16 = privateState.get(O);
1320
- if (!state16?.syncIteratorRecord)
1330
+ const state17 = privateState.get(O);
1331
+ if (!state17?.syncIteratorRecord)
1321
1332
  throw new TypeError(
1322
1333
  "AsyncFromSyncIteratorPrototype.throw called on invalid object"
1323
1334
  );
1324
- const { syncIteratorRecord } = state16;
1335
+ const { syncIteratorRecord } = state17;
1325
1336
  return pTry(() => {
1326
1337
  if (!syncIteratorRecord.throw) {
1327
1338
  syncIteratorRecord.return();
@@ -1387,11 +1398,11 @@ var [Observable, Subscriber] = (() => {
1387
1398
  }
1388
1399
  }
1389
1400
  function closeASubscription(subscriber, reason) {
1390
- const state16 = privateState.get(subscriber);
1391
- if (!state16?.active) return;
1392
- state16.active = false;
1393
- state16.subscriptionController.abort(reason);
1394
- for (const teardown of state16.teardowns.reverse()) {
1401
+ const state17 = privateState.get(subscriber);
1402
+ if (!state17?.active) return;
1403
+ state17.active = false;
1404
+ state17.subscriptionController.abort(reason);
1405
+ for (const teardown of state17.teardowns.reverse()) {
1395
1406
  if (isBrowserContext() && !isDocumentFullyActive(document)) return;
1396
1407
  try {
1397
1408
  teardown();
@@ -1472,10 +1483,10 @@ var [Observable, Subscriber] = (() => {
1472
1483
  if (!(this instanceof Subscriber2))
1473
1484
  throw new TypeError("illegal invocation");
1474
1485
  if (!arguments.length) throw new TypeError("too few arguments");
1475
- const state16 = privateState.get(this);
1476
- if (!state16?.active) return;
1486
+ const state17 = privateState.get(this);
1487
+ if (!state17?.active) return;
1477
1488
  if (isBrowserContext() && !isDocumentFullyActive(document)) return;
1478
- const internalObservers = new Set(state16.observers);
1489
+ const internalObservers = new Set(state17.observers);
1479
1490
  for (const observer of internalObservers) {
1480
1491
  observer.next(value);
1481
1492
  }
@@ -1485,14 +1496,14 @@ var [Observable, Subscriber] = (() => {
1485
1496
  if (!(this instanceof Subscriber2))
1486
1497
  throw new TypeError("illegal invocation");
1487
1498
  if (!arguments.length) throw new TypeError("too few arguments");
1488
- const state16 = privateState.get(this);
1489
- if (!state16?.active) {
1499
+ const state17 = privateState.get(this);
1500
+ if (!state17?.active) {
1490
1501
  reportError(error);
1491
1502
  return;
1492
1503
  }
1493
1504
  if (isBrowserContext() && !isDocumentFullyActive(document)) return;
1494
1505
  closeASubscription(this, error);
1495
- const internalObservers = new Set(state16.observers);
1506
+ const internalObservers = new Set(state17.observers);
1496
1507
  for (const observer of internalObservers) {
1497
1508
  observer.error(error);
1498
1509
  }
@@ -1501,11 +1512,11 @@ var [Observable, Subscriber] = (() => {
1501
1512
  complete() {
1502
1513
  if (!(this instanceof Subscriber2))
1503
1514
  throw new TypeError("illegal invocation");
1504
- const state16 = privateState.get(this);
1505
- if (!state16?.active) return;
1515
+ const state17 = privateState.get(this);
1516
+ if (!state17?.active) return;
1506
1517
  if (isBrowserContext() && !isDocumentFullyActive(document)) return;
1507
1518
  closeASubscription(this);
1508
- const internalObservers = new Set(state16.observers);
1519
+ const internalObservers = new Set(state17.observers);
1509
1520
  for (const observer of internalObservers) {
1510
1521
  observer.complete();
1511
1522
  }
@@ -1518,9 +1529,9 @@ var [Observable, Subscriber] = (() => {
1518
1529
  throw new TypeError(`Parameter 1 is not of type 'Function'`);
1519
1530
  }
1520
1531
  if (isBrowserContext() && !isDocumentFullyActive(document)) return;
1521
- const state16 = privateState.get(this);
1522
- if (state16?.active)
1523
- state16.teardowns.push(teardown);
1532
+ const state17 = privateState.get(this);
1533
+ if (state17?.active)
1534
+ state17.teardowns.push(teardown);
1524
1535
  else teardown();
1525
1536
  }
1526
1537
  get active() {
@@ -2575,7 +2586,7 @@ function containsPoint(zone, x, y) {
2575
2586
  return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
2576
2587
  }
2577
2588
  function closestCornersWithInventoryPriorityCollision(dropzones, clientX, clientY, dragElement, dragContainers) {
2578
- const identifiedDragContainers = dragContainers && dragContainers.length > 0 ? dropzones.filter((zone) => dragContainers.includes(zone)) : dropzones.filter((zone) => zone.tagName === "SLOT" && zone.hasAttribute("part") && zone.getAttribute("part")?.includes("drags"));
2589
+ const identifiedDragContainers = dragContainers && dragContainers.length > 0 ? dropzones.filter((zone) => dragContainers.includes(zone)) : dropzones.filter((zone) => zone.tagName === "SLOT" && zone.hasAttribute("part") && zone.getAttribute("part")?.split(/\s+/).includes("bank"));
2579
2590
  const allRegularDroppables = dropzones.filter((zone) => !identifiedDragContainers.includes(zone));
2580
2591
  const regularDroppables = allRegularDroppables;
2581
2592
  if (identifiedDragContainers.length === 0 && regularDroppables.length === 0)
@@ -2684,10 +2695,10 @@ function findDraggableTarget(event, draggablesSelector) {
2684
2695
  const composedPath = event.composedPath ? event.composedPath() : [event.target];
2685
2696
  for (const element of composedPath) {
2686
2697
  if (element instanceof HTMLElement && element.tagName !== "SLOT") {
2687
- if (element.matches(draggablesSelector) || element.hasAttribute("qti-draggable")) {
2698
+ if (element.matches(draggablesSelector) || element.hasAttribute("data-draggable")) {
2688
2699
  return element;
2689
2700
  }
2690
- const closest = element.closest(draggablesSelector) || element.closest('[qti-draggable="true"]');
2701
+ const closest = element.closest(draggablesSelector) || element.closest('[data-draggable="true"]');
2691
2702
  if (closest) {
2692
2703
  return closest;
2693
2704
  }
@@ -2704,50 +2715,61 @@ function isDraggableDisabled(target) {
2704
2715
  return internals?.states?.has("disabled") ?? false;
2705
2716
  }
2706
2717
  var internalsOf = (el) => el?.internals;
2707
- function setDragChipState(el, state16, on) {
2708
- const states = internalsOf(el)?.states;
2709
- if (!states)
2710
- return;
2711
- if (on)
2712
- states.add(state16);
2713
- else
2714
- states.delete(state16);
2718
+ function setDragChipState(el, state17, on) {
2719
+ setState(internalsOf(el)?.states, state17, on);
2715
2720
  }
2716
- function hasDragChipState(el, state16) {
2717
- return internalsOf(el)?.states?.has(state16) ?? false;
2721
+ function hasDragChipState(el, state17) {
2722
+ return hasState(internalsOf(el)?.states, state17);
2718
2723
  }
2719
2724
  function clearDragChipStates(el) {
2720
- setDragChipState(el, "dragging", false);
2721
- setDragChipState(el, "placeholder", false);
2722
- setDragChipState(el, "return-anchor", false);
2725
+ setDragChipState(el, "lifted", false);
2726
+ setDragChipState(el, "used", false);
2727
+ setDragChipState(el, "return-target", false);
2723
2728
  }
2724
2729
  function isDragChipHidden(el) {
2725
- return hasDragChipState(el, "dragging") || hasDragChipState(el, "placeholder");
2730
+ return hasDragChipState(el, "lifted") || hasDragChipState(el, "used");
2726
2731
  }
2732
+ var DROP_FLAG_ALIASES = {
2733
+ filled: [],
2734
+ full: [],
2735
+ "drag-active": ["active", "enabled"],
2736
+ "drag-over": ["hover"]
2737
+ };
2727
2738
  function setDropFlag(el, flag, on) {
2728
2739
  if (!el)
2729
2740
  return;
2730
- if (on)
2731
- el.setAttribute(flag, "");
2732
- else
2733
- el.removeAttribute(flag);
2734
- const states = internalsOf(el)?.states;
2735
- if (states) {
2741
+ const names = [flag, ...DROP_FLAG_ALIASES[flag]];
2742
+ for (const name of names) {
2736
2743
  if (on)
2737
- states.add(flag);
2744
+ el.setAttribute(name, "");
2738
2745
  else
2739
- states.delete(flag);
2746
+ el.removeAttribute(name);
2747
+ }
2748
+ const states = internalsOf(el)?.states;
2749
+ if (states) {
2750
+ setState(states, flag, on, DROP_FLAG_ALIASES[flag]);
2740
2751
  return;
2741
2752
  }
2742
2753
  const tokens = new Set((el.getAttribute("part") ?? "").split(/\s+/).filter(Boolean));
2743
- if (!tokens.has("drop"))
2754
+ if (!tokens.has("drop") && !tokens.has("bank"))
2744
2755
  return;
2745
- if (on)
2746
- tokens.add(flag);
2747
- else
2748
- tokens.delete(flag);
2756
+ for (const name of names) {
2757
+ if (on)
2758
+ tokens.add(name);
2759
+ else
2760
+ tokens.delete(name);
2761
+ }
2749
2762
  el.setAttribute("part", [...tokens].join(" "));
2750
2763
  }
2764
+ function setDropFull(el, full) {
2765
+ if (!el)
2766
+ return;
2767
+ if (full)
2768
+ el.setAttribute("disabled", "");
2769
+ else
2770
+ el.removeAttribute("disabled");
2771
+ setDropFlag(el, "full", full);
2772
+ }
2751
2773
  function setDropFilled(el, filled) {
2752
2774
  setDropFlag(el, "filled", filled);
2753
2775
  }
@@ -2842,7 +2864,7 @@ function patchWindow(window2) {
2842
2864
  patchedWindows.add(window2);
2843
2865
  }
2844
2866
  var hasStates = (el) => !!el.internals?.states;
2845
- var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part="drags"]', defaultCollisionAlgorithm = "pointerWithin") => {
2867
+ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]', defaultCollisionAlgorithm = "pointerWithin") => {
2846
2868
  class DragDropCoreElement extends superClass {
2847
2869
  constructor() {
2848
2870
  super(...arguments);
@@ -2862,6 +2884,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
2862
2884
  returnAnchorItems: []
2863
2885
  };
2864
2886
  this.cloneFrame = IDENTITY_FIXED_FRAME;
2887
+ this.cursorBeforeDrag = null;
2865
2888
  this.cloneZoom = 1;
2866
2889
  this.subscriptions = [];
2867
2890
  this.dragSubscriptions = [];
@@ -2960,8 +2983,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
2960
2983
  const collect = (selector, scope) => Array.from(scope?.querySelectorAll(selector) ?? []);
2961
2984
  const lightDraggables = collect(draggablesSelector, this);
2962
2985
  const shadowDraggables = collect(draggablesSelector, this.shadowRoot);
2963
- const lightClones = collect('[qti-draggable="true"]:not([data-drag-clone])', this);
2964
- const shadowClones = collect('[qti-draggable="true"]:not([data-drag-clone])', this.shadowRoot);
2986
+ const lightClones = collect('[data-draggable="true"]:not([data-drag-clone])', this);
2987
+ const shadowClones = collect('[data-draggable="true"]:not([data-drag-clone])', this.shadowRoot);
2965
2988
  const registeredDraggables = this.registeredMatching(draggablesSelector);
2966
2989
  this.trackedDraggables = Array.from(/* @__PURE__ */ new Set([...lightDraggables, ...shadowDraggables, ...lightClones, ...shadowClones, ...registeredDraggables]));
2967
2990
  const lightDroppables = collect(droppablesSelector, this);
@@ -2980,20 +3003,14 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
2980
3003
  for (const el of this.#statefulRoleElements) {
2981
3004
  if (currentStateful.has(el))
2982
3005
  continue;
2983
- el.internals.states.delete("drag");
2984
- el.internals.states.delete("droppable");
3006
+ setState(el.internals.states, "chip", false);
3007
+ setState(el.internals.states, "drop", false);
2985
3008
  }
2986
3009
  for (const el of currentStateful) {
2987
3010
  const isDrag = dragRoleSet.has(el);
2988
3011
  const isDrop = !isDrag && effectiveDroppableSet.has(el);
2989
- if (isDrag)
2990
- el.internals.states.add("drag");
2991
- else
2992
- el.internals.states.delete("drag");
2993
- if (isDrop)
2994
- el.internals.states.add("droppable");
2995
- else
2996
- el.internals.states.delete("droppable");
3012
+ setState(el.internals.states, "chip", isDrag);
3013
+ setState(el.internals.states, "drop", isDrop);
2997
3014
  }
2998
3015
  this.#statefulRoleElements = currentStateful;
2999
3016
  this.trackedDraggables.forEach((draggable) => {
@@ -3005,7 +3022,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3005
3022
  draggable.style.touchAction = "none";
3006
3023
  draggable.style.webkitUserSelect = "none";
3007
3024
  draggable.style.webkitTouchCallout = "none";
3008
- draggable.setAttribute("qti-draggable", "true");
3025
+ draggable.setAttribute("data-draggable", "true");
3009
3026
  draggable.setAttribute("tabindex", "0");
3010
3027
  } else {
3011
3028
  draggable.style.cursor = "";
@@ -3013,7 +3030,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3013
3030
  draggable.style.touchAction = "";
3014
3031
  draggable.style.webkitUserSelect = "";
3015
3032
  draggable.style.webkitTouchCallout = "";
3016
- draggable.removeAttribute("qti-draggable");
3033
+ draggable.removeAttribute("data-draggable");
3017
3034
  if (draggable.getAttribute("tabindex") === "0") {
3018
3035
  draggable.removeAttribute("tabindex");
3019
3036
  }
@@ -3125,6 +3142,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3125
3142
  if (target && ["Space", "Enter"].includes(e.code) && !hostDisabled && !targetDisabled) {
3126
3143
  e.preventDefault();
3127
3144
  target.setAttribute("data-keyboard-dragging", "true");
3145
+ setDragChipState(target, "lifted", true);
3146
+ this.activateAllDroppables(this.trackedDroppables.some((d) => d.contains(target) || !!d.shadowRoot?.contains(target)));
3128
3147
  keyboardState = {
3129
3148
  dragging: true,
3130
3149
  dragElement: target,
@@ -3161,7 +3180,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3161
3180
  this.handleInvalidDrop(keyboardState.dragElement);
3162
3181
  }
3163
3182
  }
3164
- this.trackedDraggables.forEach((d) => d.removeAttribute("data-keyboard-dragging"));
3183
+ this.endKeyboardDrag();
3165
3184
  this.saveResponse();
3166
3185
  keyboardState = {
3167
3186
  dragging: false,
@@ -3174,7 +3193,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3174
3193
  }
3175
3194
  case "Escape": {
3176
3195
  e.preventDefault();
3177
- this.trackedDraggables.forEach((d) => d.removeAttribute("data-keyboard-dragging"));
3196
+ this.endKeyboardDrag();
3178
3197
  keyboardState = {
3179
3198
  dragging: false,
3180
3199
  dragElement: null,
@@ -3186,9 +3205,9 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3186
3205
  }
3187
3206
  }
3188
3207
  }
3189
- this.allDropzones.forEach((zone) => zone.removeAttribute("hover"));
3208
+ this.allDropzones.forEach((zone) => setDropFlag(zone, "drag-over", false));
3190
3209
  if (keyboardState.dragging && keyboardState.dropElement) {
3191
- keyboardState.dropElement.setAttribute("hover", "");
3210
+ setDropFlag(keyboardState.dropElement, "drag-over", true);
3192
3211
  if (keyboardState.dropElement.hasAttribute("tabindex") && keyboardState.dropElement.getAttribute("tabindex") !== "-1") {
3193
3212
  keyboardState.dropElement.focus();
3194
3213
  }
@@ -3230,22 +3249,28 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3230
3249
  this.dragState.dragClone?.setAttribute("data-drag-origin", "droppable");
3231
3250
  this.removeChipFromDroppable(sourceDroppable, dragElement);
3232
3251
  this.cacheInteractiveElements();
3252
+ setDropFull(sourceDroppable, false);
3233
3253
  if (sourceDroppable) {
3234
3254
  sourceDroppable.setAttribute("data-drag-source", "true");
3235
3255
  }
3236
3256
  const identifier = dragElement.getAttribute("identifier");
3237
3257
  if (identifier) {
3238
3258
  const anchors = findInventoryItems(this.trackedDragContainers, identifier);
3239
- anchors.forEach((item) => setDragChipState(item, "return-anchor", true));
3259
+ anchors.forEach((item) => setDragChipState(item, "return-target", true));
3240
3260
  this.dragState.returnAnchorItems = anchors;
3241
3261
  }
3242
3262
  } else {
3243
3263
  this.dragState.dragClone?.setAttribute("data-drag-origin", "inventory");
3244
- setDragChipState(dragElement, "dragging", true);
3264
+ setDragChipState(dragElement, "lifted", true);
3245
3265
  }
3246
3266
  this.updateClonePosition(startX, startY);
3247
- this.activateAllDroppables();
3267
+ this.activateAllDroppables(isCloneInDroppable);
3248
3268
  this.watchDragCloneHost();
3269
+ if (eventSource === "pointer") {
3270
+ const root = this.ownerDocument.documentElement;
3271
+ this.cursorBeforeDrag = root.style.cursor;
3272
+ root.style.cursor = "grabbing";
3273
+ }
3249
3274
  this.setupMoveObservables(inputType, eventSource);
3250
3275
  }
3251
3276
  setupMoveObservables(inputType, eventSource = "pointer") {
@@ -3372,9 +3397,9 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3372
3397
  const MIN_TARGET_SWITCH_INTERVAL = 50;
3373
3398
  if (dropTarget !== this.dragState.currentTarget) {
3374
3399
  if (dropTarget === null || timeSinceLastChange >= MIN_TARGET_SWITCH_INTERVAL) {
3375
- this.allDropzones.forEach((zone) => setDropFlag(zone, "hover", false));
3400
+ this.allDropzones.forEach((zone) => setDropFlag(zone, "drag-over", false));
3376
3401
  if (dropTarget) {
3377
- setDropFlag(dropTarget, "hover", true);
3402
+ setDropFlag(dropTarget, "drag-over", true);
3378
3403
  }
3379
3404
  this.dragState.currentTarget = dropTarget;
3380
3405
  this.dragState.lastTargetChangeTime = now;
@@ -3394,7 +3419,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3394
3419
  const canDrop = !!dragSource && !!dropTarget && this.allowDrop(dragSource, dropTarget);
3395
3420
  if (canDrop && dragSource && dropTarget) {
3396
3421
  this.handleDrop(dragSource, dropTarget);
3397
- setDragChipState(dragSource, "dragging", false);
3422
+ setDragChipState(dragSource, "lifted", false);
3398
3423
  } else {
3399
3424
  this.handleInvalidDrop(dragSource);
3400
3425
  }
@@ -3402,7 +3427,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3402
3427
  dragClone.remove();
3403
3428
  }
3404
3429
  (this.dragState.returnAnchorItems || []).forEach((item) => {
3405
- setDragChipState(item, "return-anchor", false);
3430
+ setDragChipState(item, "return-target", false);
3406
3431
  });
3407
3432
  if (this.dragState.touchCleanup) {
3408
3433
  this.dragState.touchCleanup();
@@ -3429,8 +3454,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3429
3454
  const clone = element.cloneNode(true);
3430
3455
  const computedStyles = window.getComputedStyle(element);
3431
3456
  for (let i = 0; i < computedStyles.length; i++) {
3432
- const property27 = computedStyles[i];
3433
- clone.style.setProperty(property27, computedStyles.getPropertyValue(property27));
3457
+ const property28 = computedStyles[i];
3458
+ clone.style.setProperty(property28, computedStyles.getPropertyValue(property28));
3434
3459
  }
3435
3460
  clone.style.removeProperty("box-shadow");
3436
3461
  const host = resolveDragCloneHost(element.isConnected ? element : this, this.dragCloneRoot());
@@ -3443,7 +3468,7 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3443
3468
  clone.style.pointerEvents = "none";
3444
3469
  clone.style.touchAction = "none";
3445
3470
  clone.style.userSelect = "none";
3446
- clone.removeAttribute("qti-draggable");
3471
+ clone.removeAttribute("data-draggable");
3447
3472
  clone.removeAttribute("tabindex");
3448
3473
  clone.setAttribute("data-drag-clone", "true");
3449
3474
  clone.setAttribute("data-drag-interaction", this.tagName.toLowerCase());
@@ -3507,29 +3532,44 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3507
3532
  }
3508
3533
  });
3509
3534
  }
3510
- activateAllDroppables() {
3511
- this.setInternalsState("dragzone-enabled", true);
3512
- this.setInternalsState("dragzone-active", true);
3535
+ /**
3536
+ * A drag is in progress: the host and every target carry `drag-active` (CONTRACT.md §3). The
3537
+ * bank carries it only when the chip comes from a target: then the bank can take it back, and
3538
+ * lights up as a place to drop. A chip lifted out of the bank itself gives the bank nothing to
3539
+ * say. The host's old pair `dragzone-enabled` + `dragzone-active` is set alongside for one major.
3540
+ */
3541
+ activateAllDroppables(fromDroppable = false) {
3542
+ this.setDragActive(true);
3513
3543
  this.allDropzones.forEach((zone) => {
3514
- setDropFlag(zone, "enabled", true);
3515
- setDropFlag(zone, "active", true);
3544
+ const isBank = this.trackedDragContainers.includes(zone);
3545
+ setDropFlag(zone, "drag-active", fromDroppable || !isBank);
3516
3546
  });
3517
3547
  }
3518
3548
  deactivateAllDroppables() {
3519
- this.setInternalsState("dragzone-enabled", false);
3520
- this.setInternalsState("dragzone-active", false);
3549
+ this.setDragActive(false);
3521
3550
  this.allDropzones.forEach((zone) => {
3522
- setDropFlag(zone, "enabled", false);
3523
- setDropFlag(zone, "active", false);
3524
- setDropFlag(zone, "hover", false);
3551
+ setDropFlag(zone, "drag-active", false);
3552
+ setDropFlag(zone, "drag-over", false);
3553
+ });
3554
+ }
3555
+ /** The keyboard drag is over, dropped or cancelled: clear what the pick-up set. */
3556
+ endKeyboardDrag() {
3557
+ this.trackedDraggables.forEach((d) => {
3558
+ if (d.hasAttribute("data-keyboard-dragging"))
3559
+ setDragChipState(d, "lifted", false);
3560
+ d.removeAttribute("data-keyboard-dragging");
3525
3561
  });
3562
+ this.deactivateAllDroppables();
3563
+ }
3564
+ setDragActive(on) {
3565
+ setState(this._internals?.states, "drag-active", on, ["dragzone-active", "dragzone-enabled"]);
3526
3566
  }
3527
3567
  resetDragState() {
3528
3568
  if (this.dragState.activationTimeout) {
3529
3569
  clearTimeout(this.dragState.activationTimeout);
3530
3570
  }
3531
3571
  (this.dragState.returnAnchorItems || []).forEach((item) => {
3532
- setDragChipState(item, "return-anchor", false);
3572
+ setDragChipState(item, "return-target", false);
3533
3573
  });
3534
3574
  if (this.dragState.touchCleanup) {
3535
3575
  try {
@@ -3550,6 +3590,10 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3550
3590
  this.dragSubscriptions = [];
3551
3591
  this.cloneFrame = IDENTITY_FIXED_FRAME;
3552
3592
  this.cloneZoom = 1;
3593
+ if (this.cursorBeforeDrag !== null) {
3594
+ this.ownerDocument.documentElement.style.cursor = this.cursorBeforeDrag;
3595
+ this.cursorBeforeDrag = null;
3596
+ }
3553
3597
  this.dragState = {
3554
3598
  dragging: false,
3555
3599
  dragSource: null,
@@ -3564,14 +3608,14 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3564
3608
  returnAnchorItems: []
3565
3609
  };
3566
3610
  }
3567
- setInternalsState(state16, enabled) {
3611
+ setInternalsState(state17, enabled) {
3568
3612
  const internals = this._internals;
3569
3613
  if (!internals?.states)
3570
3614
  return;
3571
3615
  if (enabled) {
3572
- internals.states.add(state16);
3616
+ internals.states.add(state17);
3573
3617
  } else {
3574
- internals.states.delete(state16);
3618
+ internals.states.delete(state17);
3575
3619
  }
3576
3620
  }
3577
3621
  cleanup() {
@@ -3588,8 +3632,8 @@ var DragDropCoreMixin = (superClass, draggablesSelector, droppablesSelector, dra
3588
3632
  for (const el of this.#statefulRoleElements) {
3589
3633
  if (!hasStates(el))
3590
3634
  continue;
3591
- el.internals.states.delete("drag");
3592
- el.internals.states.delete("droppable");
3635
+ setState(el.internals.states, "chip", false);
3636
+ setState(el.internals.states, "drop", false);
3593
3637
  }
3594
3638
  this.#statefulRoleElements.clear();
3595
3639
  this.resetDragState();
@@ -3697,15 +3741,14 @@ var __decorate11 = function(decorators, target, key, desc) {
3697
3741
  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;
3698
3742
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3699
3743
  };
3700
- var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part="drags"]', collisionAlgorithm = "closestCornersWithInventoryPriority") => {
3744
+ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector, dragContainersSelector = 'slot[part~="bank"]', collisionAlgorithm = "closestCornersWithInventoryPriority") => {
3701
3745
  const AutoSized = DropzoneAutoSizeMixin(superClass, draggablesSelector, droppablesSelector, dragContainersSelector);
3702
3746
  const Core = DragDropCoreMixin(AutoSized, draggablesSelector, droppablesSelector, dragContainersSelector, collisionAlgorithm);
3703
3747
  class DragDropSlottedElement extends Core {
3704
3748
  constructor() {
3705
3749
  super(...arguments);
3706
3750
  this.minAssociations = 1;
3707
- this._maxAssociations = 0;
3708
- this._maxAssociationsDefaultApplied = false;
3751
+ this.maxAssociations = 0;
3709
3752
  this._response = [];
3710
3753
  this._dragDrop = { dragsByTarget: {}, countByTarget: {}, nodesByTarget: {} };
3711
3754
  this.#placement = /* @__PURE__ */ new WeakMap();
@@ -3719,22 +3762,6 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
3719
3762
  this._enableFlipAnimations = true;
3720
3763
  this._pendingResponse = void 0;
3721
3764
  }
3722
- get maxAssociations() {
3723
- if (!this._maxAssociationsDefaultApplied) {
3724
- this._maxAssociationsDefaultApplied = true;
3725
- const tagName = this.tagName?.toLowerCase() || "";
3726
- const isGapMatchInteraction = tagName === "qti-graphic-gap-match-interaction" || tagName === "qti-gap-match-interaction";
3727
- if (isGapMatchInteraction && !this.hasAttribute("max-associations") && this._maxAssociations === 0) {
3728
- this._maxAssociations = 1;
3729
- }
3730
- }
3731
- return this._maxAssociations;
3732
- }
3733
- set maxAssociations(value) {
3734
- const oldValue = this._maxAssociations;
3735
- this._maxAssociations = value;
3736
- this.requestUpdate("maxAssociations", oldValue);
3737
- }
3738
3765
  /**
3739
3766
  * The one place that reads placement out of the DOM.
3740
3767
  *
@@ -3824,7 +3851,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
3824
3851
  if (!targetId)
3825
3852
  continue;
3826
3853
  const bySelector = this.chipsIn(droppable);
3827
- const byAttribute = this.isDeclarativeTarget(droppable) ? bySelector : Array.from(droppable.querySelectorAll('[qti-draggable="true"]'));
3854
+ const byAttribute = this.isDeclarativeTarget(droppable) ? bySelector : Array.from(droppable.querySelectorAll('[data-draggable="true"]'));
3828
3855
  dragsByTarget[targetId] = bySelector.map((chip) => chip.getAttribute("identifier")).filter((id) => Boolean(id));
3829
3856
  countByTarget[targetId] = Math.max(bySelector.length, byAttribute.length);
3830
3857
  nodesByTarget[targetId] = bySelector;
@@ -3927,6 +3954,8 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
3927
3954
  this._response = typeof value === "string" && value.length > 0 ? [value] : [];
3928
3955
  }
3929
3956
  this._internals.setFormValue(JSON.stringify(this._response));
3957
+ if (this.trackedDroppables?.length)
3958
+ this.validate();
3930
3959
  }
3931
3960
  afterCache() {
3932
3961
  this.updateMinDimensionsForDropZones();
@@ -3998,7 +4027,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
3998
4027
  this.updateInventoryBasedOnMatchMax(identifier);
3999
4028
  }
4000
4029
  this.validate();
4001
- this.reportValidity();
4030
+ this.reportValidity({ trigger: "change" });
4002
4031
  }
4003
4032
  handleInvalidDrop(dragSource) {
4004
4033
  const sourceDroppable = this.dragState.sourceDroppable;
@@ -4012,7 +4041,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4012
4041
  this.dropDraggableInDroppable(dragSource, inventoryReturnTarget);
4013
4042
  } else if (sourceDroppable && this.trackedDroppables.includes(sourceDroppable)) {
4014
4043
  this.dropDraggableInDroppable(dragSource, sourceDroppable, this.dragState.dragClone?.getBoundingClientRect());
4015
- } else if (hasDragChipState(dragSource, "dragging")) {
4044
+ } else if (hasDragChipState(dragSource, "lifted")) {
4016
4045
  this.restoreInventoryItem(dragSource, this.dragState.dragClone?.getBoundingClientRect());
4017
4046
  const identifier = dragSource.getAttribute("identifier");
4018
4047
  if (identifier) {
@@ -4026,7 +4055,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4026
4055
  const attemptedDisabledTarget = !!currentTarget && currentTarget.hasAttribute("disabled") && !currentTarget.hasAttribute("data-drag-source");
4027
4056
  this._dropBlockedDueToMax = attemptedDisabledTarget && maxReached;
4028
4057
  this.validate();
4029
- this.reportValidity();
4058
+ this.reportValidity({ trigger: "change" });
4030
4059
  }
4031
4060
  /**
4032
4061
  * Fly a chip home from wherever it was last seen on screen.
@@ -4095,10 +4124,10 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4095
4124
  const parsedMatchMax = parseInt(droppable.getAttribute("match-max") || "1", 10);
4096
4125
  const matchMax = Number.isNaN(parsedMatchMax) ? 1 : parsedMatchMax;
4097
4126
  const allowsMultiple = matchMax === 0 || matchMax > 1;
4098
- const existingChildren = Array.from(droppable.querySelectorAll('[qti-draggable="true"]'));
4127
+ const existingChildren = Array.from(droppable.querySelectorAll('[data-draggable="true"]'));
4099
4128
  const flipStates = this.enableFlipAnimations && existingChildren.length > 0 ? captureMultipleFlipStates(existingChildren) : null;
4100
4129
  if (!allowsMultiple) {
4101
- const existing = this.chipsIn(droppable)[0] ?? (this.isDeclarativeTarget(droppable) ? null : droppable.querySelector('[qti-draggable="true"]'));
4130
+ const existing = this.chipsIn(droppable)[0] ?? (this.isDeclarativeTarget(droppable) ? null : droppable.querySelector('[data-draggable="true"]'));
4102
4131
  if (existing) {
4103
4132
  const existingId = existing.getAttribute("identifier");
4104
4133
  const evictedFrom = existing.getBoundingClientRect();
@@ -4117,11 +4146,15 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4117
4146
  const cleanClone = draggable.cloneNode(true);
4118
4147
  cleanClone.removeAttribute("style");
4119
4148
  cleanClone.removeAttribute("data-keyboard-dragging");
4120
- cleanClone.setAttribute("qti-draggable", "true");
4149
+ cleanClone.setAttribute("data-draggable", "true");
4121
4150
  cleanClone.setAttribute("tabindex", "0");
4122
4151
  if (this.isDeclarativeTarget(droppable)) {
4123
- cleanClone.setAttribute("part", cleanClone.localName === "qti-gap-text" ? "drag drag-text" : "drag");
4124
- cleanClone.setAttribute("exportparts", "control: drag-control, label: drag-label, correction, correction-correct, correction-incorrect");
4152
+ cleanClone.setAttribute("part", cleanClone.localName === "qti-gap-text" ? "chip text drag drag-text" : "chip drag");
4153
+ cleanClone.setAttribute("exportparts", [
4154
+ "control: chip-control, control: drag-control, label: chip-label, label: drag-label",
4155
+ "correction, candidate-correct, candidate-incorrect, candidate-partial",
4156
+ "correction-correct, correction-incorrect, correction-partially-correct"
4157
+ ].join(", "));
4125
4158
  this.placeChip(droppable, cleanClone);
4126
4159
  } else if (droppable.tagName === "SLOT") {
4127
4160
  cleanClone.setAttribute("slot", droppable.getAttribute("name") || "");
@@ -4182,7 +4215,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4182
4215
  const returning = new Set(inventoryItems);
4183
4216
  const shiftingItems = [];
4184
4217
  this.trackedDragContainers.forEach((container) => {
4185
- container.querySelectorAll('[qti-draggable="true"]').forEach((item) => !returning.has(item) && shiftingItems.push(item));
4218
+ container.querySelectorAll('[data-draggable="true"]').forEach((item) => !returning.has(item) && shiftingItems.push(item));
4186
4219
  });
4187
4220
  const flipStates = this.enableFlipAnimations && shiftingItems.length > 0 ? captureMultipleFlipStates(shiftingItems) : null;
4188
4221
  inventoryItems.forEach((item) => {
@@ -4205,21 +4238,17 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4205
4238
  return count + droppable.querySelectorAll(`[identifier="${identifier}"]`).length;
4206
4239
  }, 0);
4207
4240
  inventoryItems.forEach((item) => {
4208
- setDragChipState(item, "placeholder", matchMax !== 0 && placedInDropzones >= matchMax);
4241
+ setDragChipState(item, "used", matchMax !== 0 && placedInDropzones >= matchMax);
4209
4242
  });
4210
4243
  }
4211
4244
  checkAllMaxAssociations() {
4212
4245
  const totalAssociations = this.totalAssociationsFromState();
4213
- const disableAtMax = this.resolveDisableAfterMaxReached({ defaultWhenUnset: true });
4246
+ const disableAtMax = this.resolveDisableAfterMaxReached({ defaultWhenUnset: false });
4214
4247
  const maxReached = this.maxAssociations > 0 && totalAssociations >= this.maxAssociations;
4215
4248
  this.trackedDroppables.forEach((droppable) => {
4216
4249
  const isDragSource = droppable.hasAttribute("data-drag-source");
4217
4250
  const isAtCapacity = this.droppableAtCapacityFromState(droppable);
4218
- if ((isAtCapacity || disableAtMax && maxReached) && !isDragSource) {
4219
- droppable.setAttribute("disabled", "");
4220
- } else {
4221
- droppable.removeAttribute("disabled");
4222
- }
4251
+ setDropFull(droppable, (isAtCapacity || disableAtMax && maxReached) && !isDragSource);
4223
4252
  });
4224
4253
  }
4225
4254
  saveResponse(value) {
@@ -4253,6 +4282,9 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4253
4282
  });
4254
4283
  this.resetDragState();
4255
4284
  this.cacheInteractiveElements();
4285
+ this.trackedDroppables.forEach((droppable) => setDropFull(droppable, false));
4286
+ this.checkAllMaxAssociations();
4287
+ this.resetValidityReport();
4256
4288
  this._response = [];
4257
4289
  this._internals.setFormValue(JSON.stringify(this._response));
4258
4290
  if (save) {
@@ -4266,13 +4298,17 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4266
4298
  const belowMin = this.minAssociations > 0 && totalAssociations < this.minAssociations;
4267
4299
  let validityMessage = "";
4268
4300
  let isValid = true;
4301
+ let kind = "other";
4269
4302
  if (exceedsMax) {
4303
+ kind = "max";
4270
4304
  validityMessage = this.getFirstMessageAttribute(["data-max-associations-message", "data-max-selections-message"]) || this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
4271
4305
  isValid = false;
4272
4306
  } else if (atMaxCapacity && this._dropBlockedDueToMax && this.shouldTreatBlockedMaxAsInvalid()) {
4307
+ kind = "max";
4273
4308
  validityMessage = this.getFirstMessageAttribute(["data-max-associations-message", "data-max-selections-message"]) || this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
4274
4309
  isValid = false;
4275
4310
  } else if (belowMin) {
4311
+ kind = "min";
4276
4312
  validityMessage = this.getFirstMessageAttribute(["data-min-associations-message", "data-min-selections-message"]) || this.dataset.minAssociationsMessage || this.dataset.minSelectionsMessage || `Please select at least ${this.minAssociations} ${this.minAssociations === 1 ? "association" : "associations"}.`;
4277
4313
  isValid = false;
4278
4314
  this._dropBlockedDueToMax = false;
@@ -4280,11 +4316,11 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4280
4316
  this._dropBlockedDueToMax = false;
4281
4317
  }
4282
4318
  const validityAnchor = this.trackedDroppables[0] ?? this.trackedDraggables[0] ?? this;
4283
- this.setInteractionValidity(isValid, validityMessage, validityAnchor, { suppressInline: true });
4319
+ this.setInteractionValidity(isValid, validityMessage, validityAnchor, { suppressInline: true, kind });
4284
4320
  return isValid;
4285
4321
  }
4286
- reportValidity() {
4287
- return super.reportValidity();
4322
+ reportValidity(options) {
4323
+ return super.reportValidity(options);
4288
4324
  }
4289
4325
  }
4290
4326
  __decorate11([
@@ -4292,7 +4328,7 @@ var DragDropSlottedMixin = (superClass, draggablesSelector, droppablesSelector,
4292
4328
  ], DragDropSlottedElement.prototype, "minAssociations", void 0);
4293
4329
  __decorate11([
4294
4330
  property11({ type: Number, reflect: true, attribute: "max-associations" })
4295
- ], DragDropSlottedElement.prototype, "maxAssociations", null);
4331
+ ], DragDropSlottedElement.prototype, "maxAssociations", void 0);
4296
4332
  __decorate11([
4297
4333
  provide({ context: dragDropContext })
4298
4334
  ], DragDropSlottedElement.prototype, "_dragDrop", void 0);
@@ -4353,6 +4389,7 @@ function resetSortableDragContext(context) {
4353
4389
  function createDropPlaceholder(source, rect, config = {}) {
4354
4390
  const mergedConfig = { ...defaultPlaceholderConfig, ...config };
4355
4391
  const placeholder = document.createElement("div");
4392
+ placeholder.setAttribute("data-drop-preview", "true");
4356
4393
  placeholder.setAttribute("data-drop-placeholder", "true");
4357
4394
  placeholder.style.width = `${rect.width}px`;
4358
4395
  placeholder.style.height = `${rect.height}px`;
@@ -4375,7 +4412,7 @@ function isElementInContainer(element, containers) {
4375
4412
  }
4376
4413
 
4377
4414
  // ../interactions/core/dist/mixins/drag-drop-observables/drag-drop-slotted-sortable.mixin.js
4378
- var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[qti-draggable="true"]') => {
4415
+ var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[data-draggable="true"]') => {
4379
4416
  class DragDropSlottedSortableElement extends superClass {
4380
4417
  constructor() {
4381
4418
  super(...arguments);
@@ -4532,7 +4569,7 @@ var DragDropSlottedSortableMixin = (superClass, sortableItemSelector = '[qti-dra
4532
4569
  if (this.#slotAllowsMultiple(slot) && this.#isSlotAtCapacity(slot)) {
4533
4570
  return;
4534
4571
  }
4535
- slot.removeAttribute("disabled");
4572
+ setDropFull(slot, false);
4536
4573
  this.#temporarilyEnabledSlots.add(slot);
4537
4574
  }
4538
4575
  });
@@ -4610,15 +4647,19 @@ var qti_associate_interaction_styles_default = [
4610
4647
  then compresses the chips instead of moving them down: a bank of six squeezed the last chip
4611
4648
  until only its grip was left, at no width the author could see coming. A chip is a fixed
4612
4649
  thing, so the only place the overflow can go is the next line. */
4613
- slot[part~='drags'] {
4650
+ [part~='bank'] {
4651
+ /* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
4652
+ margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
4653
+ in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
4614
4654
  display: flex;
4615
4655
  flex-wrap: wrap;
4616
4656
  align-items: flex-start;
4617
4657
  flex: 1;
4618
- border: 2px solid transparent;
4619
- margin: 1rem 0;
4620
- border-radius: 0.3rem;
4621
- gap: 0.5rem;
4658
+ gap: var(--qti-gap, 0.5rem);
4659
+ padding: 0;
4660
+ margin: 0;
4661
+ border: 0;
4662
+ border-radius: var(--qti-radius-box, 0.2rem);
4622
4663
  }
4623
4664
 
4624
4665
  /* Drop target. --qti-dropzone-min-height is published by the interaction from the measured
@@ -4638,7 +4679,7 @@ var qti_associate_interaction_styles_default = [
4638
4679
  gap: 0.5rem;
4639
4680
  }
4640
4681
 
4641
- :host::part(drop-row) {
4682
+ :host::part(row) {
4642
4683
  display: flex;
4643
4684
  justify-content: space-between;
4644
4685
  background: linear-gradient(
@@ -4666,7 +4707,7 @@ var __decorate12 = function(decorators, target, key, desc) {
4666
4707
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4667
4708
  };
4668
4709
  var SlottedBase = DragDropSlottedMixin(Interaction, "qti-simple-associable-choice", `[part~='drop']`, `slot[name='qti-simple-associable-choice']`, "pointerWithin");
4669
- var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(SlottedBase, '[qti-draggable="true"]') {
4710
+ var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(SlottedBase, '[data-draggable="true"]') {
4670
4711
  static {
4671
4712
  this.styles = qti_associate_interaction_styles_default;
4672
4713
  }
@@ -4750,9 +4791,9 @@ var QtiAssociateInteraction = class extends DragDropSlottedSortableMixin(Slotted
4750
4791
  }
4751
4792
  render() {
4752
4793
  return html11` <slot name="prompt"></slot>
4753
- <slot part="drags" name="qti-simple-associable-choice"></slot>
4794
+ <slot part="bank drags" name="qti-simple-associable-choice"></slot>
4754
4795
  <div part="drops">
4755
- ${this._childrenMap.length > 0 && Array.from({ length: this.#rowCount }, (_, index) => html11`<div part="drop-row">
4796
+ ${this._childrenMap.length > 0 && Array.from({ length: this.#rowCount }, (_, index) => html11`<div part="row drop-row">
4756
4797
  ${this.#renderDrop(`droplist${index}_left`, `left${index}`)}
4757
4798
  ${this.#renderDrop(`droplist${index}_right`, `right${index}`)}
4758
4799
  </div>`)}
@@ -4865,7 +4906,7 @@ var ChoicesMixin = (superClass, selector) => {
4865
4906
  }
4866
4907
  });
4867
4908
  this._determineInputType();
4868
- const validIdentifiers = new Set(this._choiceElements.map((c) => c.identifier));
4909
+ const validIdentifiers = new Set(this._choiceElements.map((c) => c.getAttribute("identifier") ?? c.identifier));
4869
4910
  if (Array.isArray(this.response)) {
4870
4911
  const filteredResponse = this.response.filter((id) => validIdentifiers.has(id));
4871
4912
  if (filteredResponse.length !== this.response.length) {
@@ -4881,19 +4922,22 @@ var ChoicesMixin = (superClass, selector) => {
4881
4922
  const selectedCount = selectedChoices.length;
4882
4923
  let isValid = true;
4883
4924
  let validityMessage = "";
4925
+ let kind = "other";
4884
4926
  if (this.maxChoices !== 0 && selectedCount > this.maxChoices) {
4885
4927
  isValid = false;
4928
+ kind = "max";
4886
4929
  validityMessage = this.dataset.maxSelectionsMessage || `Please select no more than ${this.maxChoices} ${this.maxChoices === 1 ? "option" : "options"}.`;
4887
4930
  } else if (selectedCount < this.minChoices) {
4888
4931
  isValid = false;
4932
+ kind = "min";
4889
4933
  validityMessage = this.dataset.minSelectionsMessage || `Please select at least ${this.minChoices} ${this.minChoices === 1 ? "option" : "options"}.`;
4890
4934
  }
4891
4935
  const anchor = this._choiceElements.find((c) => this.contains(c)) || this;
4892
- this.setInteractionValidity(isValid, validityMessage, anchor, { suppressInline: true });
4936
+ this.setInteractionValidity(isValid, validityMessage, anchor, { suppressInline: true, kind });
4893
4937
  return isValid;
4894
4938
  }
4895
- reportValidity() {
4896
- return super.reportValidity();
4939
+ reportValidity(options) {
4940
+ return super.reportValidity(options);
4897
4941
  }
4898
4942
  /**
4899
4943
  * Publish the role the choices should take. Each choice subscribes to
@@ -4957,7 +5001,7 @@ var ChoicesMixin = (superClass, selector) => {
4957
5001
  const selectedIdentifiers = selectedChoices.map((choice) => choice.identifier);
4958
5002
  this.response = this.maxChoices === 1 ? selectedIdentifiers[0] || "" : selectedIdentifiers;
4959
5003
  this.validate();
4960
- this.reportValidity();
5004
+ this.reportValidity({ trigger: "change" });
4961
5005
  this.saveResponse(this.response);
4962
5006
  }
4963
5007
  /**
@@ -5149,13 +5193,13 @@ var qti_choice_interaction_styles_default = [
5149
5193
 
5150
5194
  /* No gap of its own: a choice carries its own padding, which already spaces a list. A theme sets
5151
5195
  --qti-choice-gap where the choices are drawn as separate boxes and need air between them. */
5152
- [part='slot'] {
5196
+ [part~='choices'] {
5153
5197
  display: grid;
5154
5198
  gap: var(--qti-choice-gap, 0);
5155
5199
  }
5156
5200
 
5157
5201
  /* Define the number of columns dynamically */
5158
- :host([class*='qti-choices-stacking-']) [part='slot'] {
5202
+ :host([class*='qti-choices-stacking-']) [part~='choices'] {
5159
5203
  grid-template-columns: repeat(var(--stacking-count, 1), 1fr);
5160
5204
  }
5161
5205
 
@@ -5184,24 +5228,24 @@ var qti_choice_interaction_styles_default = [
5184
5228
  }
5185
5229
 
5186
5230
  /* Orientation styles */
5187
- :host(.qti-orientation-horizontal) [part='slot'] {
5231
+ :host(.qti-orientation-horizontal) [part~='choices'] {
5188
5232
  grid-auto-flow: dense column;
5189
5233
  grid-auto-columns: 1fr;
5190
5234
  }
5191
5235
 
5192
- :host(.qti-orientation-vertical) [part='slot'] {
5236
+ :host(.qti-orientation-vertical) [part~='choices'] {
5193
5237
  grid-auto-flow: row;
5194
5238
  }
5195
5239
 
5196
5240
  /* Vertical and horizontal stacking logic */
5197
- :host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part='slot'] {
5241
+ :host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part~='choices'] {
5198
5242
  grid-auto-flow: dense column;
5199
5243
  grid-auto-columns: 1fr;
5200
5244
  grid-template-columns: repeat(var(--stacking-count), 1fr);
5201
5245
  grid-template-rows: repeat(calc(var(--item-count) / var(--stacking-count)), 1fr);
5202
5246
  }
5203
5247
 
5204
- :host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part='slot'] {
5248
+ :host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part~='choices'] {
5205
5249
  grid-auto-flow: row;
5206
5250
  grid-template-columns: repeat(var(--stacking-count), 1fr);
5207
5251
  grid-template-rows: unset;
@@ -5236,7 +5280,7 @@ var QtiChoiceInteraction = class extends VocabularyMixin(ChoicesMixin(Interactio
5236
5280
  render() {
5237
5281
  return html12`
5238
5282
  <slot part="prompt" name="prompt"></slot>
5239
- <slot part="slot" @slotchange=${this.#handleSlotChange}></slot>
5283
+ <slot part="choices slot" @slotchange=${this.#handleSlotChange}></slot>
5240
5284
  <div part="message" role="alert" id="validation-message"></div>
5241
5285
  `;
5242
5286
  }
@@ -5960,18 +6004,20 @@ var QtiExtendedTextInteraction = class extends Interaction {
5960
6004
  } else {
5961
6005
  isValid = textarea.checkValidity();
5962
6006
  }
6007
+ let kind = "other";
5963
6008
  if (isValid && !this.response && this.minStrings >= 1) {
5964
6009
  isValid = false;
6010
+ kind = "min";
5965
6011
  }
5966
6012
  if (!isValid && !validityMessage) {
5967
6013
  validityMessage = textarea.validationMessage || "Invalid value.";
5968
6014
  }
5969
- this.setInteractionValidity(isValid, validityMessage, textarea, { suppressInline: true });
6015
+ this.setInteractionValidity(isValid, validityMessage, textarea, { suppressInline: true, kind });
5970
6016
  return isValid;
5971
6017
  }
5972
- reportValidity() {
6018
+ reportValidity(options) {
5973
6019
  this.validate();
5974
- return super.reportValidity();
6020
+ return super.reportValidity(options);
5975
6021
  }
5976
6022
  /*
5977
6023
  * The template in named pieces, so a subclass can recompose it.
@@ -6001,7 +6047,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
6001
6047
  @keyup="${this.textChanged}"
6002
6048
  @change="${this.textChanged}"
6003
6049
  @blur="${(_) => {
6004
- this.reportValidity();
6050
+ this.reportValidity({ trigger: "change" });
6005
6051
  }}"
6006
6052
  placeholder="${ifDefined(this.placeholderText ? this.placeholderText : void 0)}"
6007
6053
  rows="${this._rows}"
@@ -6024,6 +6070,7 @@ var QtiExtendedTextInteraction = class extends Interaction {
6024
6070
  if (this.response !== input.value) {
6025
6071
  this.value = input.value;
6026
6072
  this.saveResponse(input.value);
6073
+ this.reportValidity({ trigger: "change" });
6027
6074
  }
6028
6075
  }
6029
6076
  };
@@ -6102,34 +6149,42 @@ var qti_gap_match_interaction_styles_default = [
6102
6149
  }
6103
6150
  /* Wraps, for the reason spelled out on associate's identical bank: nowrap does not overflow, it
6104
6151
  shrinks, and a squeezed chip is worse than a second line. */
6105
- [name='drags'] {
6152
+ [part~='bank'] {
6153
+ /* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
6154
+ margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
6155
+ in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
6106
6156
  display: flex;
6107
6157
  flex-wrap: wrap;
6108
6158
  align-items: flex-start;
6109
6159
  flex: 1;
6110
- border: 2px solid transparent;
6111
- padding: 0.3rem;
6112
- border-radius: 0.3rem;
6113
- gap: 0.5rem;
6160
+ gap: var(--qti-gap, 0.5rem);
6161
+ padding: 0;
6162
+ margin: 0;
6163
+ border: 0;
6164
+ border-radius: var(--qti-radius-box, 0.2rem);
6114
6165
  }
6115
6166
 
6116
6167
  /* An answer key shows the answer, not the bank you would have dragged it from. The attribute is
6117
6168
  set on the clone by the correct-response mixin; the theme used to do this with a
6118
6169
  '.full-correct-response' descendant selector, from the document. */
6119
- :host([answer-key]) [part~='drags'] {
6170
+ :host([answer-key]) [part~='bank'] {
6120
6171
  display: none;
6121
6172
  }
6122
6173
  `
6123
6174
  ];
6124
6175
 
6125
6176
  // ../interactions/gap-match-interaction/dist/qti-gap-match-interaction.js
6126
- var QtiGapMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-gap-text", "qti-gap", `slot[part~='drags']`), '[qti-draggable="true"]') {
6177
+ var QtiGapMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-gap-text", "qti-gap", `slot[part~='drags']`), '[data-draggable="true"]') {
6178
+ constructor() {
6179
+ super(...arguments);
6180
+ this.maxAssociations = 1;
6181
+ }
6127
6182
  static {
6128
6183
  this.styles = qti_gap_match_interaction_styles_default;
6129
6184
  }
6130
6185
  render() {
6131
6186
  return html16`<slot name="prompt"> </slot>
6132
- <slot part="drags" name="drags"></slot>
6187
+ <slot part="bank drags" name="drags"></slot>
6133
6188
  <slot part="drops"></slot>
6134
6189
  <div role="alert" part="message" id="validation-message"></div>`;
6135
6190
  }
@@ -6366,6 +6421,25 @@ var qti_graphic_associate_interaction_styles_default = [
6366
6421
  position: absolute;
6367
6422
  top: 0px;
6368
6423
  left: 0px;
6424
+ /* Lines take clicks; the empty canvas lets them through to the points underneath. */
6425
+ pointer-events: none;
6426
+ }
6427
+ /* A wide invisible stroke over each line, so removing one does not take a 3px aim. */
6428
+ line[data-hit] {
6429
+ stroke: transparent;
6430
+ stroke-width: 16px;
6431
+ stroke-linecap: round;
6432
+ pointer-events: stroke;
6433
+ cursor: pointer;
6434
+ outline: none;
6435
+ }
6436
+ /* A line under the pointer or keyboard focus shows that it can be removed. */
6437
+ line[data-hit]:hover,
6438
+ line[data-hit]:focus-visible {
6439
+ stroke: color-mix(in srgb, currentColor 18%, transparent);
6440
+ }
6441
+ ::slotted(qti-associable-hotspot) {
6442
+ cursor: pointer;
6369
6443
  }
6370
6444
  `
6371
6445
  ];
@@ -6383,23 +6457,55 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
6383
6457
  }
6384
6458
  #hotspots;
6385
6459
  #startPoint;
6386
- #endPoint;
6387
6460
  constructor() {
6388
6461
  super();
6389
6462
  this.#hotspots = [];
6390
6463
  this.#startPoint = null;
6391
- this.#endPoint = null;
6392
6464
  this._response = [];
6465
+ this.minAssociations = 0;
6466
+ this.maxAssociations = 1;
6393
6467
  this.addEventListener("qti-register-hotspot", this.#positionHotspotOnRegister);
6394
6468
  }
6395
6469
  reset() {
6470
+ this.resetValidityReport();
6396
6471
  this._response = [];
6472
+ this._internals.setFormValue(null);
6473
+ this.validate();
6474
+ this.#startPoint = null;
6475
+ this.#syncHotspotStates();
6397
6476
  }
6398
6477
  validate() {
6399
- return this.#getResponseArray().length > 0;
6478
+ const count = this.#getResponseArray().length;
6479
+ const exceedsMax = this.maxAssociations > 0 && count > this.maxAssociations;
6480
+ const belowMin = count < this.minAssociations;
6481
+ let kind = "other";
6482
+ let message = "";
6483
+ if (exceedsMax) {
6484
+ kind = "max";
6485
+ message = this.dataset.maxAssociationsMessage || this.dataset.maxSelectionsMessage || `You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`;
6486
+ } else if (belowMin) {
6487
+ kind = "min";
6488
+ message = this.dataset.minAssociationsMessage || this.dataset.minSelectionsMessage || `Please select at least ${this.minAssociations} ${this.minAssociations === 1 ? "association" : "associations"}.`;
6489
+ }
6490
+ const isValid = !exceedsMax && !belowMin;
6491
+ this.setInteractionValidity(isValid, message, this, { suppressInline: true, kind });
6492
+ return isValid;
6493
+ }
6494
+ reportValidity(options) {
6495
+ return super.reportValidity(options);
6400
6496
  }
6401
6497
  set response(val) {
6402
6498
  this._response = this.#normalizeResponse(val);
6499
+ this.#responseChanged(false);
6500
+ this.#syncHotspotStates();
6501
+ }
6502
+ /** The form value and the validity follow every change; a candidate's change also reports. */
6503
+ #responseChanged(byCandidate) {
6504
+ const lines = this.#getResponseArray();
6505
+ this._internals.setFormValue(lines.length ? JSON.stringify(lines) : null);
6506
+ this.validate();
6507
+ if (byCandidate)
6508
+ this.reportValidity({ trigger: "change" });
6403
6509
  }
6404
6510
  get response() {
6405
6511
  return this._response;
@@ -6418,36 +6524,61 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
6418
6524
  }
6419
6525
  render() {
6420
6526
  return html17`<slot name="prompt"></slot>
6421
- <line-container>
6527
+ <line-container
6528
+ @click=${(e) => {
6529
+ if (this.#startPoint && !e.composedPath().some((n) => this.#hotspots.includes(n))) {
6530
+ this.#cancel();
6531
+ }
6532
+ }}
6533
+ >
6422
6534
  <svg
6423
6535
  width=${ifDefined2(this.grImage[0]?.width)}
6424
6536
  height=${ifDefined2(this.grImage[0]?.height)}
6425
6537
  viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
6426
6538
  >
6427
- ${repeat5(this.#getResponseArray(), (line) => line, (line, index) => svg`
6428
- <line
6429
- part="line"
6430
- x1=${parseInt(this.querySelector(`[identifier=${line.split(" ")[0]}]`).style.left)}
6431
- y1=${parseInt(this.querySelector(`[identifier=${line.split(" ")[0]}]`).style.top)}
6432
- x2=${parseInt(this.querySelector(`[identifier=${line.split(" ")[1]}]`).style.left)}
6433
- y2=${parseInt(this.querySelector(`[identifier=${line.split(" ")[1]}]`).style.top)}
6434
- stroke="red"
6435
- stroke-width="3"
6436
- @click=${(e) => {
6437
- e.stopPropagation();
6438
- this._response = this._response.filter((_, i) => i !== index);
6439
- this.saveResponse(this.response);
6440
- }}
6441
- />
6442
- `)}
6539
+ ${repeat5(this.#getResponseArray(), (line) => line, (line, index) => {
6540
+ const [a, b] = line.split(" ");
6541
+ const from = this.querySelector(`[identifier=${a}]`);
6542
+ const to = this.querySelector(`[identifier=${b}]`);
6543
+ if (!from || !to)
6544
+ return nothing2;
6545
+ const x1 = parseInt(from.style.left);
6546
+ const y1 = parseInt(from.style.top);
6547
+ const x2 = parseInt(to.style.left);
6548
+ const y2 = parseInt(to.style.top);
6549
+ const remove = (e) => {
6550
+ e.stopPropagation();
6551
+ this.#removeLine(index);
6552
+ };
6553
+ return svg`
6554
+ <line part="line" x1=${x1} y1=${y1} x2=${x2} y2=${y2} stroke="currentColor" stroke-width="3" />
6555
+ <line
6556
+ data-hit
6557
+ x1=${x1}
6558
+ y1=${y1}
6559
+ x2=${x2}
6560
+ y2=${y2}
6561
+ tabindex=${this.disabled || this.readonly ? -1 : 0}
6562
+ role="button"
6563
+ aria-label=${`Remove line ${a} \u2013 ${b}`}
6564
+ @click=${remove}
6565
+ @keydown=${(e) => {
6566
+ if (["Enter", " ", "Delete", "Backspace"].includes(e.key)) {
6567
+ e.preventDefault();
6568
+ remove(e);
6569
+ }
6570
+ }}
6571
+ ><title>Remove line ${a} – ${b}</title></line>
6572
+ `;
6573
+ })}
6443
6574
  ${this.renderSupplementalLines()}
6444
6575
  ${this.#startPoint && svg`<line
6445
6576
  part="point"
6446
6577
  x1=${this.startCoord.x}
6447
6578
  y1=${this.startCoord.y}
6448
- x2=${this.mouseCoord.x}
6449
- y2=${this.mouseCoord.y}
6450
- stroke="var(--qti-border-active)"
6579
+ x2=${(this.mouseCoord ?? this.startCoord).x}
6580
+ y2=${(this.mouseCoord ?? this.startCoord).y}
6581
+ stroke="currentColor"
6451
6582
  stroke-width="3"
6452
6583
  />`}
6453
6584
  </svg>
@@ -6481,26 +6612,91 @@ var QtiGraphicAssociateInteraction = class extends Interaction {
6481
6612
  this.#hotspots.forEach((hotspot) => {
6482
6613
  hotspot.style.left = hotspot.getAttribute("coords").split(",")[0] + "px";
6483
6614
  hotspot.style.top = hotspot.getAttribute("coords").split(",")[1] + "px";
6484
- hotspot.addEventListener("click", (event) => {
6485
- if (!this.#startPoint) {
6486
- this.#startPoint = event.target;
6487
- this.startCoord = {
6488
- x: parseInt(this.#startPoint.getAttribute("coords").split(",")[0]),
6489
- y: parseInt(this.#startPoint.getAttribute("coords").split(",")[1])
6490
- };
6491
- } else if (!this.#endPoint) {
6492
- this.#endPoint = event.target;
6493
- this._response = this.#getResponseArray();
6494
- this._response = [
6495
- ...this._response,
6496
- `${this.#startPoint.getAttribute("identifier")} ${this.#endPoint.getAttribute("identifier")}`
6497
- ];
6498
- this.saveResponse(this.response);
6499
- this.#startPoint = null;
6500
- this.#endPoint = null;
6615
+ hotspot.tabIndex = 0;
6616
+ hotspot.setAttribute("role", "button");
6617
+ if (!hotspot.hasAttribute("aria-label")) {
6618
+ hotspot.setAttribute("aria-label", hotspot.getAttribute("hotspot-label") || hotspot.getAttribute("identifier"));
6619
+ }
6620
+ hotspot.addEventListener("click", () => this.#pick(hotspot));
6621
+ hotspot.addEventListener("keydown", (event) => {
6622
+ if (event.key === "Enter" || event.key === " ") {
6623
+ event.preventDefault();
6624
+ this.#pick(hotspot);
6501
6625
  }
6502
6626
  });
6503
6627
  });
6628
+ this.addEventListener("keydown", (event) => {
6629
+ if (event.key === "Escape" && this.#startPoint)
6630
+ this.#cancel();
6631
+ });
6632
+ this.#syncHotspotStates();
6633
+ }
6634
+ /** A point clicked or activated: start a line, finish one, or cancel by picking the start again. */
6635
+ #pick(hotspot) {
6636
+ if (this.disabled || this.readonly)
6637
+ return;
6638
+ if (!this.#startPoint) {
6639
+ if (this.#isFull(hotspot))
6640
+ return;
6641
+ this.#startPoint = hotspot;
6642
+ this.startCoord = this.#centre(hotspot);
6643
+ this.mouseCoord = this.startCoord;
6644
+ this.#syncHotspotStates();
6645
+ return;
6646
+ }
6647
+ if (hotspot === this.#startPoint) {
6648
+ this.#cancel();
6649
+ return;
6650
+ }
6651
+ const a = this.#startPoint.getAttribute("identifier");
6652
+ const b = hotspot.getAttribute("identifier");
6653
+ const current = this.#getResponseArray();
6654
+ const exists = current.some((pair) => this.#samePair(pair, a, b));
6655
+ const roomLeft = this.maxAssociations === 0 || current.length < this.maxAssociations;
6656
+ if (!exists && roomLeft && !this.#isFull(hotspot)) {
6657
+ this._response = [...current, `${a} ${b}`];
6658
+ this.saveResponse(this.response);
6659
+ this.#responseChanged(true);
6660
+ }
6661
+ this.#cancel();
6662
+ }
6663
+ #cancel() {
6664
+ this.#startPoint = null;
6665
+ this.#syncHotspotStates();
6666
+ this.requestUpdate();
6667
+ }
6668
+ #removeLine(index) {
6669
+ if (this.disabled || this.readonly)
6670
+ return;
6671
+ this._response = this.#getResponseArray().filter((_, i) => i !== index);
6672
+ this.saveResponse(this.response);
6673
+ this.#responseChanged(true);
6674
+ this.#syncHotspotStates();
6675
+ }
6676
+ /** Pairs are undirected: "A B" is "B A". */
6677
+ #samePair(pair, a, b) {
6678
+ const [x, y] = pair.split(" ");
6679
+ return x === a && y === b || x === b && y === a;
6680
+ }
6681
+ /** Lines this point takes part in, against its `match-max` (0 = no limit). */
6682
+ #isFull(hotspot) {
6683
+ const max = Number(hotspot.getAttribute("match-max") ?? 0);
6684
+ if (!max)
6685
+ return false;
6686
+ const id = hotspot.getAttribute("identifier");
6687
+ return this.#getResponseArray().filter((pair) => pair.split(" ").includes(id)).length >= max;
6688
+ }
6689
+ #centre(hotspot) {
6690
+ const [x, y] = (hotspot.getAttribute("coords") ?? "0,0").split(",").map((n) => parseInt(n));
6691
+ return { x, y };
6692
+ }
6693
+ /** `checked` on the chosen start point, `full` on a point at its `match-max`. */
6694
+ #syncHotspotStates() {
6695
+ for (const hotspot of this.#hotspots) {
6696
+ const states = hotspot.internals?.states;
6697
+ setState(states, "checked", hotspot === this.#startPoint);
6698
+ setState(states, "full", this.#isFull(hotspot));
6699
+ }
6504
6700
  }
6505
6701
  disconnectedCallback() {
6506
6702
  super.disconnectedCallback();
@@ -6519,6 +6715,12 @@ __decorate19([
6519
6715
  __decorate19([
6520
6716
  state9()
6521
6717
  ], QtiGraphicAssociateInteraction.prototype, "_response", void 0);
6718
+ __decorate19([
6719
+ property18({ type: Number, attribute: "min-associations" })
6720
+ ], QtiGraphicAssociateInteraction.prototype, "minAssociations", void 0);
6721
+ __decorate19([
6722
+ property18({ type: Number, attribute: "max-associations" })
6723
+ ], QtiGraphicAssociateInteraction.prototype, "maxAssociations", void 0);
6522
6724
  __decorate19([
6523
6725
  property18({
6524
6726
  attribute: "response",
@@ -6593,15 +6795,19 @@ var qti_graphic_gap_match_interaction_styles_default = [
6593
6795
  }
6594
6796
  /* [part='drops'] , */
6595
6797
 
6596
- [name='drags'] {
6798
+ [part~='bank'] {
6799
+ /* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
6800
+ margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
6801
+ in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
6597
6802
  display: flex;
6598
- align-items: flex-start;
6599
6803
  flex-wrap: wrap;
6804
+ align-items: flex-start;
6600
6805
  flex: 1;
6601
- border: 2px solid transparent;
6602
- padding: 0.3rem;
6603
- border-radius: 0.3rem;
6604
- gap: 0.5rem;
6806
+ gap: var(--qti-gap, 0.5rem);
6807
+ padding: 0;
6808
+ margin: 0;
6809
+ border: 0;
6810
+ border-radius: var(--qti-radius-box, 0.2rem);
6605
6811
  }
6606
6812
  /*
6607
6813
  * Fluid, like the hotspot interaction's graphic: an item declares the graphic at the size its
@@ -6632,10 +6838,11 @@ var __decorate20 = function(decorators, target, key, desc) {
6632
6838
  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;
6633
6839
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6634
6840
  };
6635
- var SlottedBase2 = DragDropSlottedMixin(Interaction, "qti-gap-img, qti-gap-text", "qti-associable-hotspot", `slot[part~='drags']`);
6636
- var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(SlottedBase2, '[qti-draggable="true"]') {
6841
+ var SlottedBase2 = DragDropSlottedMixin(Interaction, "qti-gap-img, qti-gap-text", "qti-associable-hotspot", `slot[part~='bank']`);
6842
+ var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(SlottedBase2, '[data-draggable="true"]') {
6637
6843
  constructor() {
6638
6844
  super(...arguments);
6845
+ this.maxAssociations = 1;
6639
6846
  this.autoSizeDropzones = false;
6640
6847
  this._graphicScale = 1;
6641
6848
  this.#graphicObserver = null;
@@ -6653,7 +6860,7 @@ var QtiGraphicGapMatchInteraction = class extends DragDropSlottedSortableMixin(S
6653
6860
  const scale = `--qti-graphic-scale: ${this._graphicScale}`;
6654
6861
  return html18` <slot name="prompt"></slot>
6655
6862
  <slot part="image" style=${scale}></slot>
6656
- <slot part="drags" name="drags" class="hover-border" style=${scale}></slot>
6863
+ <slot part="bank drags" name="drags" class="hover-border" style=${scale}></slot>
6657
6864
  <div role="alert" part="message" id="validation-message"></div>`;
6658
6865
  }
6659
6866
  shouldReturnToInventoryOnInventoryDrop() {
@@ -6844,9 +7051,11 @@ var QtiGraphicOrderInteraction = class _QtiGraphicOrderInteraction extends Choic
6844
7051
  ordered.push(identifier);
6845
7052
  }
6846
7053
  this.response = ordered;
6847
- this.validate();
6848
- this.reportValidity();
6849
7054
  this.saveResponse(this.response);
7055
+ void this.updateComplete.then(() => {
7056
+ this.validate();
7057
+ this.reportValidity({ trigger: "change" });
7058
+ });
6850
7059
  }
6851
7060
  /** The response as the ordered identifier list this interaction always treats it as. */
6852
7061
  #orderedResponse() {
@@ -7397,7 +7606,7 @@ var own = css21`
7397
7606
  Rendered as a CSS mask so the theme controls its colour via color:.
7398
7607
  The span in the template is empty; this CSS provides the visual.
7399
7608
  */
7400
- [part~='dropdown-icon'] {
7609
+ [part~='icon'] {
7401
7610
  flex: 0 0 auto;
7402
7611
  display: inline-block;
7403
7612
  width: 1em;
@@ -7409,7 +7618,7 @@ var own = css21`
7409
7618
  transform-origin: center;
7410
7619
  }
7411
7620
 
7412
- [part~='dropdown-icon-open'] {
7621
+ [part~='open'] {
7413
7622
  transform: rotate(180deg);
7414
7623
  }
7415
7624
 
@@ -7512,7 +7721,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7512
7721
  this.minChoices = 0;
7513
7722
  this._handleRequiredChange = () => {
7514
7723
  this.validate();
7515
- this.reportValidity();
7724
+ this.reportValidity({ trigger: "change" });
7516
7725
  };
7517
7726
  this._pendingResponse = void 0;
7518
7727
  this.#onTriggerClick = (event) => {
@@ -7615,7 +7824,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7615
7824
  >
7616
7825
  <span part="value">${selected?.content}</span>
7617
7826
  <span
7618
- part="${this._dropdownOpen ? "dropdown-icon dropdown-icon-open" : "dropdown-icon"}"
7827
+ part="${this._dropdownOpen ? "icon open dropdown-icon dropdown-icon-open" : "icon dropdown-icon"}"
7619
7828
  aria-hidden="true"
7620
7829
  ></span>
7621
7830
  </button>
@@ -7634,7 +7843,15 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7634
7843
  const nothingChosen = prompt?.selected ?? true;
7635
7844
  const hidden = promptEmpty && nothingChosen;
7636
7845
  const clear = promptEmpty && !nothingChosen;
7637
- const parts = ["option", "option-prompt", prompt?.selected ? "option-selected" : "", clear ? "option-clear" : ""].filter(Boolean).join(" ");
7846
+ const parts = [
7847
+ "option",
7848
+ "prompt",
7849
+ prompt?.selected ? "selected" : "",
7850
+ clear ? "clear" : "",
7851
+ "option-prompt",
7852
+ prompt?.selected ? "option-selected" : "",
7853
+ clear ? "option-clear" : ""
7854
+ ].filter(Boolean).join(" ");
7638
7855
  return html22`
7639
7856
  <div
7640
7857
  id="${this._menuId}"
@@ -7775,7 +7992,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7775
7992
  * up mid-animation.)
7776
7993
  */
7777
7994
  menuAutoSizeExtraWidth() {
7778
- const icon = this.renderRoot.querySelector('span[part~="dropdown-icon"]');
7995
+ const icon = this.renderRoot.querySelector('span[part~="icon"]');
7779
7996
  if (!icon)
7780
7997
  return 0;
7781
7998
  const trigger = this.renderRoot.querySelector('button[part="trigger"]');
@@ -7788,13 +8005,14 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7788
8005
  const answerDemanded = this.required || this.minChoices >= 1;
7789
8006
  const isValid = hasSelection || !answerDemanded;
7790
8007
  const validityMessage = this.dataset.minChoicesMessage || "Please select an option.";
7791
- this.setInteractionValidity(isValid, isValid ? "" : validityMessage, this, { suppressInline: true });
8008
+ this.setInteractionValidity(isValid, isValid ? "" : validityMessage, this, { suppressInline: true, kind: "min" });
7792
8009
  return isValid;
7793
8010
  }
7794
- reportValidity() {
7795
- return super.reportValidity();
8011
+ reportValidity(options) {
8012
+ return super.reportValidity(options);
7796
8013
  }
7797
8014
  reset() {
8015
+ this.resetValidityReport();
7798
8016
  this.#setDropdownOpen(false);
7799
8017
  this.options = this.options.map((option, i) => ({ ...option, selected: i === 0 }));
7800
8018
  this.#syncSlottedChoices();
@@ -7816,7 +8034,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7816
8034
  this.options = this.options.map((option) => ({ ...option, selected: option.value === value }));
7817
8035
  this.#syncSlottedChoices();
7818
8036
  this.validate();
7819
- this.reportValidity();
8037
+ this.reportValidity({ trigger: "change" });
7820
8038
  this.saveResponse(value);
7821
8039
  this.#setDropdownOpen(false);
7822
8040
  }
@@ -7872,6 +8090,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
7872
8090
  }
7873
8091
  }
7874
8092
  async #syncSlottedChoices() {
8093
+ this._internals.setFormValue(this.response);
7875
8094
  await this.updateComplete;
7876
8095
  const selectedValue = this.options.find((option) => option.selected)?.value ?? "";
7877
8096
  const choices = Array.from(this.querySelectorAll("qti-inline-choice"));
@@ -8100,19 +8319,19 @@ var qti_match_interaction_tabular_styles_default = [
8100
8319
  outer grid's tracks. This structure is shared with the editor's tabular
8101
8320
  template so both can inherit the same theme CSS. No per-choice inline
8102
8321
  style writes are needed — auto-flow + subgrid handle placement. */
8103
- :host(.qti-match-tabular) [part='cols-wrap'] {
8322
+ :host(.qti-match-tabular) [part~='columns'] {
8104
8323
  grid-column: 2 / -1;
8105
8324
  grid-row: 1;
8106
8325
  display: grid;
8107
8326
  grid-template-columns: subgrid;
8108
8327
  }
8109
- :host(.qti-match-tabular) [part='rows-wrap'] {
8328
+ :host(.qti-match-tabular) [part~='rows'] {
8110
8329
  grid-column: 1;
8111
8330
  grid-row: 2 / -1;
8112
8331
  display: grid;
8113
8332
  grid-template-rows: subgrid;
8114
8333
  }
8115
- :host(.qti-match-tabular) [part='checkbox-grid'] {
8334
+ :host(.qti-match-tabular) [part~='cells'] {
8116
8335
  grid-column: 2 / -1;
8117
8336
  grid-row: 2 / -1;
8118
8337
  display: grid;
@@ -8123,6 +8342,20 @@ var qti_match_interaction_tabular_styles_default = [
8123
8342
  display: contents;
8124
8343
  }
8125
8344
 
8345
+ /*
8346
+ * qti-header-hidden (vocabulary §1.2.8.2): "Do not display the top row of the table where the
8347
+ * column headers are displayed." The whole row goes, the top-left cell with it.
8348
+ */
8349
+ :host(.qti-match-tabular.qti-header-hidden) [part='grid'] {
8350
+ grid-template-rows: repeat(var(--qti-match-rows, 1), auto);
8351
+ }
8352
+ :host(.qti-match-tabular.qti-header-hidden) :is([part='corner'], [part~='columns']) {
8353
+ display: none;
8354
+ }
8355
+ :host(.qti-match-tabular.qti-header-hidden) :is([part~='rows'], [part~='cells']) {
8356
+ grid-row: 1 / -1;
8357
+ }
8358
+
8126
8359
  /*
8127
8360
  * The radio/checkbox box centres its own mark. qti-simple-choice.styles.ts does the same for
8128
8361
  * the non-tabular control; here the cells are plain spans in this shadow root, so the rule
@@ -8148,10 +8381,12 @@ var __decorate23 = function(decorators, target, key, desc) {
8148
8381
  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;
8149
8382
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8150
8383
  };
8151
- var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice", "qti-simple-match-set:last-of-type > qti-simple-associable-choice", "qti-simple-match-set:first-of-type"), '[qti-draggable="true"]') {
8384
+ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlottedMixin(Interaction, "qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice", "qti-simple-match-set:last-of-type > qti-simple-associable-choice", "qti-simple-match-set:first-of-type"), '[data-draggable="true"]') {
8152
8385
  constructor() {
8153
8386
  super(...arguments);
8154
8387
  this.autoSizeDropzones = false;
8388
+ this.maxAssociations = 1;
8389
+ this.minAssociations = 0;
8155
8390
  this.lastCheckedRadio = null;
8156
8391
  this.class = "";
8157
8392
  this._response = [];
@@ -8303,10 +8538,12 @@ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlo
8303
8538
  role="grid"
8304
8539
  style="--qti-match-rows: ${this.sourceChoices.length}; --qti-match-cols: ${this.targetChoices.length};"
8305
8540
  >
8306
- <div part="corner"></div>
8307
- <div part="cols-wrap" role="row"><slot name="match-cols" part="c-header"></slot></div>
8308
- <div part="rows-wrap"><slot name="match-rows" part="r-header"></slot></div>
8309
- <div part="checkbox-grid">
8541
+ <div part="corner">${this.dataFirstColumnHeader ?? nothing3}</div>
8542
+ <div part="columns cols-wrap" role="row">
8543
+ <slot name="match-cols" part="column-header c-header"></slot>
8544
+ </div>
8545
+ <div part="rows rows-wrap"><slot name="match-rows" part="row-header r-header"></slot></div>
8546
+ <div part="cells checkbox-grid">
8310
8547
  ${this.sourceChoices.map((row, r) => html23`
8311
8548
  <div role="row" style="display: contents;">
8312
8549
  ${this.targetChoices.map((col, c) => {
@@ -8323,7 +8560,7 @@ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlo
8323
8560
  const disable = row.matchMax === 1 ? false : row.matchMax !== 0 && selectedInRowCount >= row.matchMax && !checked;
8324
8561
  return html23`
8325
8562
  <label
8326
- part="input-cell"
8563
+ part="cell input-cell"
8327
8564
  role="gridcell"
8328
8565
  style="grid-row: ${r + 1}; grid-column: ${c + 1}; display: flex; align-items: center; justify-content: center; cursor: pointer;"
8329
8566
  >
@@ -8355,6 +8592,9 @@ var QtiMatchInteraction = class extends DragDropSlottedSortableMixin(DragDropSlo
8355
8592
  __decorate23([
8356
8593
  property21({ type: String })
8357
8594
  ], QtiMatchInteraction.prototype, "class", void 0);
8595
+ __decorate23([
8596
+ property21({ type: String, attribute: "data-first-column-header" })
8597
+ ], QtiMatchInteraction.prototype, "dataFirstColumnHeader", void 0);
8358
8598
  __decorate23([
8359
8599
  state12()
8360
8600
  ], QtiMatchInteraction.prototype, "_response", void 0);
@@ -8450,11 +8690,19 @@ var qti_order_interaction_styles_default = [
8450
8690
  display: block;
8451
8691
  }
8452
8692
 
8453
- [part='drags'] {
8693
+ [part~='bank'] {
8694
+ /* The bank, the same in every drag-drop interaction: flush with the container (no padding, no
8695
+ margin, no edge of its own), chips a --qti-gap apart. Its lit and ringed looks while a chip is
8696
+ in flight are the theme's ('::part(bank drag-active)', '::part(bank drag-over)'). */
8454
8697
  display: flex;
8698
+ flex-wrap: wrap;
8455
8699
  align-items: flex-start;
8456
8700
  flex: 1;
8457
- flex-wrap: wrap;
8701
+ gap: var(--qti-gap, 0.5rem);
8702
+ padding: 0;
8703
+ margin: 0;
8704
+ border: 0;
8705
+ border-radius: var(--qti-radius-box, 0.2rem);
8458
8706
  }
8459
8707
 
8460
8708
  [part='drops'] {
@@ -8481,8 +8729,8 @@ var qti_order_interaction_styles_default = [
8481
8729
  gap: 0.5rem;
8482
8730
  }
8483
8731
 
8484
- :host([orientation='horizontal']) [part='drags'],
8485
- :host(.qti-orientation-horizontal) [part='drags'] {
8732
+ :host([orientation='horizontal']) [part~='bank'],
8733
+ :host(.qti-orientation-horizontal) [part~='bank'] {
8486
8734
  flex-direction: row;
8487
8735
  }
8488
8736
  /*
@@ -8495,8 +8743,8 @@ var qti_order_interaction_styles_default = [
8495
8743
  * wrapped and the '.qti-orientation-horizontal' class did not. The theme's rule is gone and so
8496
8744
  * is this one; both spellings now wrap, which is what the attribute already did.
8497
8745
  */
8498
- :host([orientation='vertical']) [part='drags'],
8499
- :host(.qti-orientation-vertical) [part='drags'] {
8746
+ :host([orientation='vertical']) [part~='bank'],
8747
+ :host(.qti-orientation-vertical) [part~='bank'] {
8500
8748
  flex-direction: column;
8501
8749
  }
8502
8750
  :host([orientation='vertical']) [part='drops'],
@@ -8548,7 +8796,7 @@ var qti_order_interaction_styles_default = [
8548
8796
  * never done anything; it is left in the theme rather than deleted here, since removing it is a
8549
8797
  * decision about how a long label should behave, not a relocation.
8550
8798
  */
8551
- [part~='drag'] {
8799
+ [part~='chip'] {
8552
8800
  display: flex;
8553
8801
  align-items: center;
8554
8802
  overflow: visible;
@@ -8665,7 +8913,7 @@ var __decorate24 = function(decorators, target, key, desc) {
8665
8913
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8666
8914
  };
8667
8915
  var SlottedBase3 = DragDropSlottedMixin(Interaction, `qti-simple-choice`, `[part~='drop']`, `slot[part~='drags']`);
8668
- var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase3, '[qti-draggable="true"]') {
8916
+ var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase3, '[data-draggable="true"]') {
8669
8917
  constructor() {
8670
8918
  super(...arguments);
8671
8919
  this.nrChoices = 0;
@@ -8680,7 +8928,7 @@ var QtiOrderInteraction = class extends DragDropSlottedSortableMixin(SlottedBase
8680
8928
  }
8681
8929
  return html25` <slot name="prompt"> </slot>
8682
8930
  <div part="container">
8683
- <slot part="drags"> </slot>
8931
+ <slot part="bank drags"> </slot>
8684
8932
  <div part="drops">
8685
8933
  ${[...Array(this.nrChoices)].map((_, i) => {
8686
8934
  const identifier = `droplist${i}`;
@@ -8997,18 +9245,18 @@ var QtiPortableCustomInteraction = class extends Interaction {
8997
9245
  this.#pciCustomValidityMessage = pciCustomValidity;
8998
9246
  }
8999
9247
  const stateRaw = data?.params?.state;
9000
- let state16;
9248
+ let state17;
9001
9249
  if (stateRaw === void 0) {
9002
- state16 = void 0;
9250
+ state17 = void 0;
9003
9251
  } else if (stateRaw === null) {
9004
- state16 = null;
9252
+ state17 = null;
9005
9253
  } else if (typeof stateRaw === "string") {
9006
- state16 = stateRaw;
9254
+ state17 = stateRaw;
9007
9255
  } else {
9008
9256
  try {
9009
- state16 = `__qti_json__::${JSON.stringify(stateRaw)}`;
9257
+ state17 = `__qti_json__::${JSON.stringify(stateRaw)}`;
9010
9258
  } catch {
9011
- state16 = null;
9259
+ state17 = null;
9012
9260
  }
9013
9261
  }
9014
9262
  if (converted === null) {
@@ -9016,13 +9264,13 @@ var QtiPortableCustomInteraction = class extends Interaction {
9016
9264
  const emptyResponse = cardinality === "record" ? null : cardinality === "single" ? "" : [];
9017
9265
  this.response = emptyResponse;
9018
9266
  this.validate();
9019
- this.saveResponse(emptyResponse, state16);
9267
+ this.saveResponse(emptyResponse, state17);
9020
9268
  break;
9021
9269
  }
9022
9270
  const response = converted;
9023
9271
  this.response = response;
9024
9272
  this.validate();
9025
- this.saveResponse(response, state16);
9273
+ this.saveResponse(response, state17);
9026
9274
  break;
9027
9275
  }
9028
9276
  case "error":
@@ -10573,101 +10821,427 @@ __decorate25([
10573
10821
  ], QtiPortableCustomInteraction.prototype, "response", void 0);
10574
10822
 
10575
10823
  // ../interactions/position-object-interaction/dist/qti-position-object-interaction.js
10576
- import { LitElement as LitElement12, html as html27 } from "lit";
10824
+ import { html as html27, nothing as nothing4 } from "lit";
10825
+ import { property as property24, state as state15 } from "lit/decorators.js";
10826
+ import { repeat as repeat7 } from "lit/directives/repeat.js";
10827
+ import { styleMap } from "lit/directives/style-map.js";
10577
10828
 
10578
10829
  // ../interactions/position-object-interaction/dist/qti-position-object-interaction.styles.js
10579
10830
  import { css as css28 } from "lit";
10580
10831
  var qti_position_object_interaction_styles_default = [
10581
10832
  boxSizing,
10833
+ validationMessage,
10582
10834
  css28`
10835
+ /* Not positioned on purpose: the placed copies are absolutely positioned against the stage
10836
+ (qti-position-object-stage), so they land on its image wherever this tray sits. */
10583
10837
  :host {
10584
- display: block;
10838
+ display: inline-block;
10839
+ vertical-align: top;
10840
+ margin-block-start: var(--qti-gap, 0.5rem);
10841
+ margin-inline-end: var(--qti-gap, 0.5rem);
10842
+ }
10843
+
10844
+ [part~='object'] {
10845
+ display: inline-flex;
10846
+ padding: var(--qti-size-field, 0.125rem);
10847
+ cursor: grab;
10848
+ touch-action: none;
10849
+ user-select: none;
10850
+ }
10851
+ [part~='object'][aria-disabled='true'] {
10852
+ cursor: default;
10585
10853
  }
10586
10854
  ::slotted(img) {
10855
+ display: block;
10856
+ pointer-events: none;
10857
+ }
10858
+
10859
+ [part~='point'] {
10587
10860
  position: absolute;
10588
- cursor: move;
10861
+ cursor: grab;
10862
+ touch-action: none;
10589
10863
  user-select: none;
10590
- left: 50%;
10591
- transform: translateX(-50%);
10864
+ z-index: 1;
10865
+ }
10866
+ [part~='point'][data-ghost] {
10867
+ pointer-events: none;
10592
10868
  }
10593
10869
  `
10594
10870
  ];
10595
10871
 
10596
10872
  // ../interactions/position-object-interaction/dist/qti-position-object-interaction.js
10597
- var QtiPositionObjectInteraction = class extends LitElement12 {
10873
+ var __decorate26 = function(decorators, target, key, desc) {
10874
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10875
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10876
+ 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;
10877
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10878
+ };
10879
+ var CLICK_SLOP = 4;
10880
+ var QtiPositionObjectInteraction = class extends Interaction {
10881
+ constructor() {
10882
+ super(...arguments);
10883
+ this.maxChoices = 1;
10884
+ this.minChoices = 0;
10885
+ this.centerPoint = null;
10886
+ this.response = null;
10887
+ this._layout = 0;
10888
+ this._drag = null;
10889
+ this._armed = false;
10890
+ this.#stageImg = null;
10891
+ this.#resize = new ResizeObserver(() => this._layout++);
10892
+ this._handleResponseChange = () => {
10893
+ this._internals.setFormValue(serializeResponseAttribute(this.response) || null);
10894
+ this.validate();
10895
+ setState(this._internals.states, "used", this.#atMax());
10896
+ };
10897
+ this.#onMove = (event) => {
10898
+ if (!this._drag)
10899
+ return;
10900
+ const client = { x: event.clientX, y: event.clientY };
10901
+ const moved = this._drag.moved || Math.hypot(client.x - this._drag.start.x, client.y - this._drag.start.y) > CLICK_SLOP;
10902
+ this._drag = { ...this._drag, client, moved };
10903
+ };
10904
+ this.#onUp = (event) => {
10905
+ window.removeEventListener("pointermove", this.#onMove);
10906
+ const drag = this._drag;
10907
+ this._drag = null;
10908
+ if (!drag)
10909
+ return;
10910
+ if (!drag.moved) {
10911
+ if (drag.index === -1)
10912
+ this._armed = !this._armed;
10913
+ return;
10914
+ }
10915
+ const target = this.#toStage({ x: event.clientX, y: event.clientY });
10916
+ const points = this.#points();
10917
+ if (drag.index === -1) {
10918
+ if (target)
10919
+ this.#place(target);
10920
+ } else if (target) {
10921
+ points[drag.index] = target;
10922
+ this.#write(points);
10923
+ } else {
10924
+ this.#write(points.filter((_, i) => i !== drag.index));
10925
+ }
10926
+ };
10927
+ this.#onStageClick = (event) => {
10928
+ if (!this._armed || this.#locked)
10929
+ return;
10930
+ const target = this.#toStage({ x: event.clientX, y: event.clientY });
10931
+ if (!target)
10932
+ return;
10933
+ this._armed = false;
10934
+ this.#place(target);
10935
+ };
10936
+ }
10598
10937
  static {
10599
10938
  this.styles = qti_position_object_interaction_styles_default;
10600
10939
  }
10940
+ #stageImg;
10941
+ #resize;
10942
+ #points() {
10943
+ return (this.response ?? []).map((entry) => {
10944
+ const [x, y] = entry.split(" ").map(Number);
10945
+ return { x, y };
10946
+ });
10947
+ }
10948
+ #write(points) {
10949
+ this.response = points.map((p) => `${Math.round(p.x)} ${Math.round(p.y)}`);
10950
+ this.saveResponse(this.response);
10951
+ this.validate();
10952
+ this.reportValidity({ trigger: "change" });
10953
+ }
10954
+ #atMax() {
10955
+ return this.maxChoices > 0 && (this.response?.length ?? 0) >= this.maxChoices;
10956
+ }
10957
+ validate() {
10958
+ const count = this.response?.length ?? 0;
10959
+ const exceedsMax = this.maxChoices > 0 && count > this.maxChoices;
10960
+ const belowMin = count < this.minChoices;
10961
+ let kind = "other";
10962
+ let message = "";
10963
+ if (exceedsMax) {
10964
+ kind = "max";
10965
+ message = this.dataset.maxSelectionsMessage || `Please place no more than ${this.maxChoices} ${this.maxChoices === 1 ? "position" : "positions"}.`;
10966
+ } else if (belowMin) {
10967
+ kind = "min";
10968
+ message = this.dataset.minSelectionsMessage || `Please place at least ${this.minChoices} ${this.minChoices === 1 ? "position" : "positions"}.`;
10969
+ }
10970
+ const isValid = !exceedsMax && !belowMin;
10971
+ this.setInteractionValidity(isValid, message, this, { suppressInline: true, kind });
10972
+ return isValid;
10973
+ }
10974
+ reportValidity(options) {
10975
+ return super.reportValidity(options);
10976
+ }
10977
+ reset() {
10978
+ this.resetValidityReport();
10979
+ this._armed = false;
10980
+ this.response = [];
10981
+ this._internals.setFormValue(null);
10982
+ }
10983
+ // ── Geometry ──────────────────────────────────────────────────────────────────────────────────
10984
+ get #stage() {
10985
+ return this.closest("qti-position-object-stage");
10986
+ }
10987
+ /** The stage image's own size: its `width`/`height` attributes, else its natural size. */
10988
+ #stageSize() {
10989
+ const img = this.#stageImg;
10990
+ if (!img)
10991
+ return { width: 1, height: 1 };
10992
+ return {
10993
+ width: parseFloat(img.getAttribute("width") ?? "") || img.naturalWidth || img.clientWidth || 1,
10994
+ height: parseFloat(img.getAttribute("height") ?? "") || img.naturalHeight || img.clientHeight || 1
10995
+ };
10996
+ }
10997
+ /** Stage-image units per CSS pixel. */
10998
+ #scale() {
10999
+ const rect = this.#stageImg?.getBoundingClientRect();
11000
+ if (!rect || rect.width === 0)
11001
+ return 1;
11002
+ return this.#stageSize().width / rect.width;
11003
+ }
11004
+ /** The object's own size and centre point, in the object's pixels. */
11005
+ #object() {
11006
+ const img = this.querySelector("img");
11007
+ const width = parseFloat(img?.getAttribute("width") ?? "") || img?.naturalWidth || 30;
11008
+ const height = parseFloat(img?.getAttribute("height") ?? "") || img?.naturalHeight || 30;
11009
+ const [cx, cy] = (this.centerPoint ?? "").split(/[\s,]+/).map(Number);
11010
+ return {
11011
+ width,
11012
+ height,
11013
+ centre: Number.isFinite(cx) && Number.isFinite(cy) ? { x: cx, y: cy } : { x: width / 2, y: height / 2 }
11014
+ };
11015
+ }
11016
+ /** A client position as a stage point, or null when it is off the stage image. */
11017
+ #toStage(client) {
11018
+ const rect = this.#stageImg?.getBoundingClientRect();
11019
+ if (!rect)
11020
+ return null;
11021
+ if (client.x < rect.left || client.x > rect.right || client.y < rect.top || client.y > rect.bottom)
11022
+ return null;
11023
+ const scale = this.#scale();
11024
+ return { x: (client.x - rect.left) * scale, y: (client.y - rect.top) * scale };
11025
+ }
11026
+ /** Where a copy whose centre point sits at a stage point is drawn, relative to the stage. */
11027
+ #styleFor(point) {
11028
+ const stageRect = this.#stage?.getBoundingClientRect();
11029
+ const imgRect = this.#stageImg?.getBoundingClientRect();
11030
+ if (!stageRect || !imgRect)
11031
+ return { display: "none" };
11032
+ const scale = this.#scale();
11033
+ const object = this.#object();
11034
+ return {
11035
+ left: `${imgRect.left - stageRect.left + point.x / scale - object.centre.x / scale}px`,
11036
+ top: `${imgRect.top - stageRect.top + point.y / scale - object.centre.y / scale}px`,
11037
+ width: `${object.width / scale}px`,
11038
+ height: `${object.height / scale}px`
11039
+ };
11040
+ }
11041
+ // ── Input ─────────────────────────────────────────────────────────────────────────────────────
11042
+ get #locked() {
11043
+ return this.disabled || this.readonly;
11044
+ }
11045
+ #place(point) {
11046
+ if (this.#atMax())
11047
+ return;
11048
+ this.#write([...this.#points(), point]);
11049
+ }
11050
+ #startDrag(event, index) {
11051
+ if (this.#locked || event.button !== 0)
11052
+ return;
11053
+ if (index === -1 && this.#atMax())
11054
+ return;
11055
+ event.preventDefault();
11056
+ const client = { x: event.clientX, y: event.clientY };
11057
+ this._drag = { index, client, start: client, moved: false };
11058
+ window.addEventListener("pointermove", this.#onMove);
11059
+ window.addEventListener("pointerup", this.#onUp, { once: true });
11060
+ }
11061
+ #onMove;
11062
+ #onUp;
11063
+ #onStageClick;
11064
+ #onObjectKey(event) {
11065
+ if (this.#locked)
11066
+ return;
11067
+ if (event.key === "Enter" || event.key === " ") {
11068
+ event.preventDefault();
11069
+ if (this.#atMax())
11070
+ return;
11071
+ const { width, height } = this.#stageSize();
11072
+ this.#place({ x: width / 2, y: height / 2 });
11073
+ void this.updateComplete.then(() => {
11074
+ const copies = this.shadowRoot?.querySelectorAll('[part~="point"]');
11075
+ copies?.[copies.length - 1]?.focus();
11076
+ });
11077
+ } else if (event.key === "Escape") {
11078
+ this._armed = false;
11079
+ }
11080
+ }
11081
+ #onPointKey(event, index) {
11082
+ if (this.#locked)
11083
+ return;
11084
+ const step = event.shiftKey ? 10 : 1;
11085
+ const moves = {
11086
+ ArrowLeft: { x: -step, y: 0 },
11087
+ ArrowRight: { x: step, y: 0 },
11088
+ ArrowUp: { x: 0, y: -step },
11089
+ ArrowDown: { x: 0, y: step }
11090
+ };
11091
+ const points = this.#points();
11092
+ if (moves[event.key]) {
11093
+ event.preventDefault();
11094
+ const { width, height } = this.#stageSize();
11095
+ const p = points[index];
11096
+ points[index] = {
11097
+ x: Math.min(width, Math.max(0, p.x + moves[event.key].x)),
11098
+ y: Math.min(height, Math.max(0, p.y + moves[event.key].y))
11099
+ };
11100
+ this.#write(points);
11101
+ void this.updateComplete.then(() => this.shadowRoot?.querySelectorAll('[part~="point"]')[index]?.focus());
11102
+ } else if (event.key === "Delete" || event.key === "Backspace") {
11103
+ event.preventDefault();
11104
+ this.#write(points.filter((_, i) => i !== index));
11105
+ void this.updateComplete.then(() => this.shadowRoot?.querySelector('[part~="object"]')?.focus());
11106
+ }
11107
+ }
11108
+ // ── Lifecycle ─────────────────────────────────────────────────────────────────────────────────
11109
+ connectedCallback() {
11110
+ super.connectedCallback();
11111
+ this.#stageImg = this.#stage?.querySelector(":scope > img, :scope > picture img") ?? null;
11112
+ if (this.#stageImg) {
11113
+ this.#resize.observe(this.#stageImg);
11114
+ this.#stageImg.addEventListener("load", () => this._layout++);
11115
+ this.#stageImg.addEventListener("click", this.#onStageClick);
11116
+ }
11117
+ }
11118
+ disconnectedCallback() {
11119
+ super.disconnectedCallback();
11120
+ this.#resize.disconnect();
11121
+ this.#stageImg?.removeEventListener("click", this.#onStageClick);
11122
+ window.removeEventListener("pointermove", this.#onMove);
11123
+ }
11124
+ // ── Render ────────────────────────────────────────────────────────────────────────────────────
10601
11125
  render() {
10602
- return html27`<slot></slot>`;
11126
+ void this._layout;
11127
+ const src = this.querySelector("img")?.currentSrc || this.querySelector("img")?.src || "";
11128
+ const alt = this.querySelector("img")?.getAttribute("alt") || "object";
11129
+ const used = this.#atMax();
11130
+ const objectPart = ["object", this._armed ? "selected" : "", used ? "used" : ""].filter(Boolean).join(" ");
11131
+ const points = this.#points();
11132
+ const drag = this._drag;
11133
+ const dragPoint = drag && drag.moved && this.#stageImg ? (() => {
11134
+ const rect = this.#stageImg.getBoundingClientRect();
11135
+ const scale = this.#scale();
11136
+ return { x: (drag.client.x - rect.left) * scale, y: (drag.client.y - rect.top) * scale };
11137
+ })() : null;
11138
+ return html27`
11139
+ <div
11140
+ part=${objectPart}
11141
+ role="button"
11142
+ tabindex=${this.#locked || used ? -1 : 0}
11143
+ aria-disabled=${this.#locked || used ? "true" : "false"}
11144
+ aria-pressed=${this._armed ? "true" : "false"}
11145
+ aria-label=${`Place ${alt}`}
11146
+ @pointerdown=${(e) => this.#startDrag(e, -1)}
11147
+ @keydown=${(e) => this.#onObjectKey(e)}
11148
+ >
11149
+ <slot></slot>
11150
+ </div>
11151
+ ${repeat7(points, (_, i) => i, (point, index) => {
11152
+ const shown = drag && drag.index === index && dragPoint ? dragPoint : point;
11153
+ return html27`<img
11154
+ part="point"
11155
+ src=${src}
11156
+ alt=${`${alt} at ${Math.round(point.x)}, ${Math.round(point.y)}`}
11157
+ role="button"
11158
+ tabindex=${this.#locked ? -1 : 0}
11159
+ draggable="false"
11160
+ style=${styleMap(this.#styleFor(shown))}
11161
+ @pointerdown=${(e) => this.#startDrag(e, index)}
11162
+ @keydown=${(e) => this.#onPointKey(e, index)}
11163
+ />`;
11164
+ })}
11165
+ ${drag && drag.index === -1 && dragPoint ? html27`<img part="point" data-ghost src=${src} alt="" style=${styleMap(this.#styleFor(dragPoint))} />` : nothing4}
11166
+ <div part="message" role="alert" id="validation-message" style="display:none;"></div>
11167
+ `;
10603
11168
  }
10604
11169
  };
11170
+ __decorate26([
11171
+ property24({ type: Number, attribute: "max-choices" })
11172
+ ], QtiPositionObjectInteraction.prototype, "maxChoices", void 0);
11173
+ __decorate26([
11174
+ property24({ type: Number, attribute: "min-choices" })
11175
+ ], QtiPositionObjectInteraction.prototype, "minChoices", void 0);
11176
+ __decorate26([
11177
+ property24({ type: String, attribute: "center-point" })
11178
+ ], QtiPositionObjectInteraction.prototype, "centerPoint", void 0);
11179
+ __decorate26([
11180
+ property24({
11181
+ attribute: "response",
11182
+ reflect: false,
11183
+ converter: {
11184
+ fromAttribute: (value) => {
11185
+ const parsed = parseResponseAttribute(value);
11186
+ if (parsed === null)
11187
+ return null;
11188
+ return Array.isArray(parsed) ? parsed : [parsed];
11189
+ },
11190
+ toAttribute: (value) => serializeResponseAttribute(value)
11191
+ }
11192
+ })
11193
+ ], QtiPositionObjectInteraction.prototype, "response", void 0);
11194
+ __decorate26([
11195
+ state15()
11196
+ ], QtiPositionObjectInteraction.prototype, "_layout", void 0);
11197
+ __decorate26([
11198
+ state15()
11199
+ ], QtiPositionObjectInteraction.prototype, "_drag", void 0);
11200
+ __decorate26([
11201
+ state15()
11202
+ ], QtiPositionObjectInteraction.prototype, "_armed", void 0);
11203
+ __decorate26([
11204
+ watch("response")
11205
+ ], QtiPositionObjectInteraction.prototype, "_handleResponseChange", void 0);
10605
11206
 
10606
11207
  // ../interactions/position-object-interaction/dist/qti-position-object-stage.js
10607
- import { LitElement as LitElement13, html as html28 } from "lit";
11208
+ import { LitElement as LitElement12, html as html28 } from "lit";
10608
11209
 
10609
11210
  // ../interactions/position-object-interaction/dist/qti-position-object-stage.styles.js
10610
11211
  import { css as css29 } from "lit";
10611
11212
  var qti_position_object_stage_styles_default = [
10612
11213
  boxSizing,
10613
11214
  css29`
11215
+ /* The containing block of every placed copy. */
10614
11216
  :host {
10615
11217
  display: inline-block;
10616
11218
  position: relative;
10617
11219
  }
11220
+ ::slotted(img),
11221
+ ::slotted(picture) {
11222
+ display: block;
11223
+ max-width: 100%;
11224
+ height: auto;
11225
+ user-select: none;
11226
+ }
10618
11227
  `
10619
11228
  ];
10620
11229
 
10621
11230
  // ../interactions/position-object-interaction/dist/qti-position-object-stage.js
10622
- var QtiPositionObjectStage = class extends LitElement13 {
11231
+ var QtiPositionObjectStage = class extends LitElement12 {
10623
11232
  static {
10624
11233
  this.styles = qti_position_object_stage_styles_default;
10625
11234
  }
10626
11235
  render() {
10627
11236
  return html28`<slot></slot>`;
10628
11237
  }
10629
- constructor() {
10630
- super();
10631
- this.removeMoveListener = this.removeMoveListener.bind(this);
10632
- this.dragElementHandler = this.dragElementHandler.bind(this);
10633
- }
10634
- // Define a function to handle the mousemove event on the draggable element
10635
- dragElementHandler(event) {
10636
- event.preventDefault();
10637
- const deltaX = event.clientX - this.startX;
10638
- const deltaY = event.clientY - this.startY;
10639
- this.dragElement.style.left = this.dragElement.offsetLeft + deltaX + "px";
10640
- this.dragElement.style.top = this.dragElement.offsetTop + deltaY + "px";
10641
- this.startX = event.clientX;
10642
- this.startY = event.clientY;
10643
- }
10644
- firstUpdated(a) {
10645
- super.firstUpdated(a);
10646
- this.dragElement = this.querySelector("qti-position-object-interaction>img");
10647
- this.startX = 0;
10648
- this.startY = 0;
10649
- this.dragElement.addEventListener("mousedown", (event) => {
10650
- this.startX = event.clientX;
10651
- this.startY = event.clientY;
10652
- document.addEventListener("mousemove", this.dragElementHandler, true);
10653
- });
10654
- document.addEventListener("mouseup", this.removeMoveListener);
10655
- }
10656
- removeMoveListener() {
10657
- document.removeEventListener("mousemove", this.dragElementHandler, true);
10658
- }
10659
- disconnectedCallback() {
10660
- super.disconnectedCallback();
10661
- document.removeEventListener("mousemove", this.dragElementHandler);
10662
- document.removeEventListener("mouseup", this.removeMoveListener);
10663
- }
10664
11238
  };
10665
11239
 
10666
11240
  // ../interactions/select-point-interaction/dist/qti-select-point-interaction.js
10667
- import { html as html29, nothing as nothing4 } from "lit";
10668
- import { property as property24, state as state15 } from "lit/decorators.js";
10669
- import { repeat as repeat7 } from "lit/directives/repeat.js";
10670
- import { styleMap } from "lit/directives/style-map.js";
11241
+ import { html as html29, nothing as nothing5 } from "lit";
11242
+ import { property as property25, state as state16 } from "lit/decorators.js";
11243
+ import { repeat as repeat8 } from "lit/directives/repeat.js";
11244
+ import { styleMap as styleMap2 } from "lit/directives/style-map.js";
10671
11245
 
10672
11246
  // ../interactions/select-point-interaction/dist/qti-select-point-interaction.styles.js
10673
11247
  import { css as css30 } from "lit";
@@ -10678,12 +11252,15 @@ var qti_select_point_interaction_styles_default = [
10678
11252
  display: block;
10679
11253
  --qti-select-point-marker-size: 1.5rem;
10680
11254
  /* Where the marker's shape points: -100% stands it on the point by its bottom (a pin's tip),
10681
- -50% centres it (a ring, a star). A theme that changes the shape sets --cito-marker-anchor. */
10682
- --qti-select-point-marker-anchor: var(--cito-marker-anchor, -100%);
10683
- /* The marker's shape: a pin by default, or the theme's --cito-icon-marker (a mask). */
11255
+ -50% centres it (a ring, a star). A theme that changes the shape sets --qc-marker-anchor. */
11256
+ --qti-select-point-marker-anchor: var(--qc-marker-anchor, var(--cito-marker-anchor, -100%));
11257
+ /* The marker's shape: a pin by default, or the theme's --qc-icon-marker (a mask). */
10684
11258
  --qti-select-point-icon: var(
10685
- --cito-icon-marker,
10686
- url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath d='M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z'/%3E%3C/svg%3E")
11259
+ --qc-icon-marker,
11260
+ var(
11261
+ --cito-icon-marker,
11262
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512'%3E%3Cpath d='M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z'/%3E%3C/svg%3E")
11263
+ )
10687
11264
  );
10688
11265
  }
10689
11266
  point-container {
@@ -10738,7 +11315,7 @@ var qti_select_point_interaction_styles_default = [
10738
11315
  ];
10739
11316
 
10740
11317
  // ../interactions/select-point-interaction/dist/qti-select-point-interaction.js
10741
- var __decorate26 = function(decorators, target, key, desc) {
11318
+ var __decorate27 = function(decorators, target, key, desc) {
10742
11319
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10743
11320
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10744
11321
  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;
@@ -10752,6 +11329,10 @@ var QtiSelectPointInteraction = class extends Interaction {
10752
11329
  this.response = null;
10753
11330
  this.areaMappings = null;
10754
11331
  this._areaEntries = [];
11332
+ this._handleResponseChange = () => {
11333
+ this._internals.setFormValue(serializeResponseAttribute(this.response) || null);
11334
+ this.validate();
11335
+ };
10755
11336
  this._handleAreaMappingsChange = () => {
10756
11337
  this.#syncAreaEntriesFromAttribute();
10757
11338
  };
@@ -10782,6 +11363,8 @@ var QtiSelectPointInteraction = class extends Interaction {
10782
11363
  }
10783
11364
  }
10784
11365
  this.saveResponse(this.response);
11366
+ this.validate();
11367
+ this.reportValidity({ trigger: "change" });
10785
11368
  };
10786
11369
  this.#onResize = () => {
10787
11370
  this.#calculateScale();
@@ -10840,7 +11423,7 @@ var QtiSelectPointInteraction = class extends Interaction {
10840
11423
  }
10841
11424
  /** Extension hook for optional layers rendered above the response points. */
10842
11425
  renderSupplementalLayer() {
10843
- return nothing4;
11426
+ return nothing5;
10844
11427
  }
10845
11428
  /** Positions overlay elements that carry `data-coord` and `data-shape`. */
10846
11429
  positionOverlayElements(elements32) {
@@ -10861,14 +11444,14 @@ var QtiSelectPointInteraction = class extends Interaction {
10861
11444
  const responseList = Array.isArray(rawResponse) ? rawResponse : rawResponse ? [rawResponse] : [];
10862
11445
  return html29` <slot name="prompt"></slot>
10863
11446
  <point-container>
10864
- ${repeat7(responseList.filter((point) => point), (point) => point, (point, index) => {
11447
+ ${repeat8(responseList.filter((point) => point), (point) => point, (point, index) => {
10865
11448
  const [x, y] = point.split(" ").map(Number);
10866
11449
  const leftPercentage = x / (this.#imageWidthOriginal || 1) * 100;
10867
11450
  const topPercentage = y / (this.#imageHeightOriginal || 1) * 100;
10868
11451
  return html29`
10869
11452
  <button
10870
11453
  part=${this.pointPart(point, index)}
10871
- style=${styleMap({
11454
+ style=${styleMap2({
10872
11455
  pointerEvents: this.maxChoices === 1 ? "none" : "auto",
10873
11456
  position: "absolute",
10874
11457
  left: `${leftPercentage}%`,
@@ -10880,13 +11463,16 @@ var QtiSelectPointInteraction = class extends Interaction {
10880
11463
  e.stopPropagation();
10881
11464
  this.response = (this.response || []).filter((_, i) => i !== index);
10882
11465
  this.saveResponse(this.response);
11466
+ this.validate();
11467
+ this.reportValidity({ trigger: "change" });
10883
11468
  }}
10884
11469
  ></button>
10885
11470
  `;
10886
11471
  })}
10887
11472
  ${this.renderSupplementalLayer()}
10888
11473
  <slot></slot>
10889
- </point-container>`;
11474
+ </point-container>
11475
+ <div part="message" role="alert" id="validation-message" style="display:none;"></div>`;
10890
11476
  }
10891
11477
  validate() {
10892
11478
  const selectedCount = this.response?.length ?? 0;
@@ -10894,18 +11480,21 @@ var QtiSelectPointInteraction = class extends Interaction {
10894
11480
  const belowMin = selectedCount < this.minChoices;
10895
11481
  let isValid = true;
10896
11482
  let validityMessage = "";
11483
+ let kind = "other";
10897
11484
  if (exceedsMax) {
10898
11485
  isValid = false;
11486
+ kind = "max";
10899
11487
  validityMessage = this.dataset.maxSelectionsMessage || `Please select no more than ${this.maxChoices} ${this.maxChoices === 1 ? "point" : "points"}.`;
10900
11488
  } else if (belowMin) {
10901
11489
  isValid = false;
11490
+ kind = "min";
10902
11491
  validityMessage = this.dataset.minSelectionsMessage || `Please select at least ${this.minChoices} ${this.minChoices === 1 ? "point" : "points"}.`;
10903
11492
  }
10904
- this.setInteractionValidity(isValid, validityMessage, this.#imgElement ?? this, { suppressInline: true });
11493
+ this.setInteractionValidity(isValid, validityMessage, this.#imgElement ?? this, { suppressInline: true, kind });
10905
11494
  return isValid;
10906
11495
  }
10907
- reportValidity() {
10908
- return super.reportValidity();
11496
+ reportValidity(options) {
11497
+ return super.reportValidity(options);
10909
11498
  }
10910
11499
  #calculateScale() {
10911
11500
  this.#imageWidthOriginal = this.#imgElement.getAttribute("width") ? parseFloat(this.#imgElement.getAttribute("width")) : this.#imgElement.naturalWidth;
@@ -10933,20 +11522,20 @@ var QtiSelectPointInteraction = class extends Interaction {
10933
11522
  }
10934
11523
  }
10935
11524
  };
10936
- __decorate26([
10937
- property24({
11525
+ __decorate27([
11526
+ property25({
10938
11527
  type: Number,
10939
11528
  attribute: "max-choices"
10940
11529
  })
10941
11530
  ], QtiSelectPointInteraction.prototype, "maxChoices", void 0);
10942
- __decorate26([
10943
- property24({
11531
+ __decorate27([
11532
+ property25({
10944
11533
  type: Number,
10945
11534
  attribute: "min-choices"
10946
11535
  })
10947
11536
  ], QtiSelectPointInteraction.prototype, "minChoices", void 0);
10948
- __decorate26([
10949
- property24({
11537
+ __decorate27([
11538
+ property25({
10950
11539
  attribute: "response",
10951
11540
  reflect: false,
10952
11541
  converter: {
@@ -10962,19 +11551,22 @@ __decorate26([
10962
11551
  }
10963
11552
  })
10964
11553
  ], QtiSelectPointInteraction.prototype, "response", void 0);
10965
- __decorate26([
10966
- property24({ attribute: "area-mappings" })
11554
+ __decorate27([
11555
+ property25({ attribute: "area-mappings" })
10967
11556
  ], QtiSelectPointInteraction.prototype, "areaMappings", void 0);
10968
- __decorate26([
10969
- state15()
11557
+ __decorate27([
11558
+ state16()
10970
11559
  ], QtiSelectPointInteraction.prototype, "_areaEntries", void 0);
10971
- __decorate26([
11560
+ __decorate27([
11561
+ watch("response")
11562
+ ], QtiSelectPointInteraction.prototype, "_handleResponseChange", void 0);
11563
+ __decorate27([
10972
11564
  watch("areaMappings")
10973
11565
  ], QtiSelectPointInteraction.prototype, "_handleAreaMappingsChange", void 0);
10974
11566
 
10975
11567
  // ../interactions/slider-interaction/dist/qti-slider-interaction.js
10976
- import { html as html30, nothing as nothing5 } from "lit";
10977
- import { property as property25, query as query2 } from "lit/decorators.js";
11568
+ import { html as html30, nothing as nothing6 } from "lit";
11569
+ import { property as property26, query as query2 } from "lit/decorators.js";
10978
11570
 
10979
11571
  // ../interactions/slider-interaction/dist/qti-slider-interaction.styles.js
10980
11572
  import { css as css31 } from "lit";
@@ -11052,7 +11644,7 @@ var qti_slider_interaction_styles_default = [
11052
11644
  ];
11053
11645
 
11054
11646
  // ../interactions/slider-interaction/dist/qti-slider-interaction.js
11055
- var __decorate27 = function(decorators, target, key, desc) {
11647
+ var __decorate28 = function(decorators, target, key, desc) {
11056
11648
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11057
11649
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11058
11650
  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;
@@ -11107,7 +11699,7 @@ var QtiSliderInteraction = class extends Interaction {
11107
11699
  }
11108
11700
  /** Extension hook for optional content rendered on the slider rail. */
11109
11701
  renderRailSupplement() {
11110
- return nothing5;
11702
+ return nothing6;
11111
11703
  }
11112
11704
  /** Moves the knob to `newValue`, clamped to the bounds, or empties the slider. Returns whether it moved. */
11113
11705
  #show(newValue) {
@@ -11148,7 +11740,7 @@ var QtiSliderInteraction = class extends Interaction {
11148
11740
 
11149
11741
  <div id="rail" part="rail" @mousedown=${this.#onMouseDown} @touchstart=${this.#onTouchStart}>
11150
11742
  <div id="knob" part="knob">
11151
- ${this.#value === null ? nothing5 : html30`<div id="value" part="value">${this.#value}</div>`}
11743
+ ${this.#value === null ? nothing6 : html30`<div id="value" part="value">${this.#value}</div>`}
11152
11744
  </div>
11153
11745
 
11154
11746
  ${this.renderRailSupplement()}
@@ -11192,25 +11784,25 @@ var QtiSliderInteraction = class extends Interaction {
11192
11784
  this.dispatchEvent(new Event("change", { bubbles: true }));
11193
11785
  }
11194
11786
  };
11195
- __decorate27([
11787
+ __decorate28([
11196
11788
  query2("#rail")
11197
11789
  ], QtiSliderInteraction.prototype, "_rail", void 0);
11198
- __decorate27([
11199
- property25({ type: Number, attribute: "lower-bound" })
11790
+ __decorate28([
11791
+ property26({ type: Number, attribute: "lower-bound" })
11200
11792
  ], QtiSliderInteraction.prototype, "min", void 0);
11201
- __decorate27([
11202
- property25({ type: Number, attribute: "upper-bound" })
11793
+ __decorate28([
11794
+ property26({ type: Number, attribute: "upper-bound" })
11203
11795
  ], QtiSliderInteraction.prototype, "max", void 0);
11204
- __decorate27([
11205
- property25({ type: Number, attribute: "step" })
11796
+ __decorate28([
11797
+ property26({ type: Number, attribute: "step" })
11206
11798
  ], QtiSliderInteraction.prototype, "step", void 0);
11207
- __decorate27([
11208
- property25({ attribute: "response", reflect: false, noAccessor: true })
11799
+ __decorate28([
11800
+ property26({ attribute: "response", reflect: false, noAccessor: true })
11209
11801
  ], QtiSliderInteraction.prototype, "response", null);
11210
11802
 
11211
11803
  // ../interactions/text-entry-interaction/dist/qti-text-entry-interaction.js
11212
11804
  import { html as html31 } from "lit";
11213
- import { property as property26, query as query3 } from "lit/decorators.js";
11805
+ import { property as property27, query as query3 } from "lit/decorators.js";
11214
11806
  import { ifDefined as ifDefined4 } from "lit/directives/if-defined.js";
11215
11807
  import { createRef } from "lit/directives/ref.js";
11216
11808
 
@@ -11311,7 +11903,7 @@ var qti_text_entry_interaction_styles_default = [
11311
11903
  ];
11312
11904
 
11313
11905
  // ../interactions/text-entry-interaction/dist/qti-text-entry-interaction.js
11314
- var __decorate28 = function(decorators, target, key, desc) {
11906
+ var __decorate29 = function(decorators, target, key, desc) {
11315
11907
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11316
11908
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11317
11909
  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;
@@ -11354,13 +11946,15 @@ var QtiTextEntryInteraction = class extends Interaction {
11354
11946
  } else {
11355
11947
  isValid = this._input.checkValidity();
11356
11948
  }
11949
+ let kind = "other";
11357
11950
  if (isValid && this.response === "") {
11358
11951
  isValid = false;
11952
+ kind = "min";
11359
11953
  }
11360
11954
  if (!isValid && !validityMessage) {
11361
11955
  validityMessage = this._input.validationMessage || "Invalid value.";
11362
11956
  }
11363
- this.setInteractionValidity(isValid, validityMessage, this._input, { suppressInline: true });
11957
+ this.setInteractionValidity(isValid, validityMessage, this._input, { suppressInline: true, kind });
11364
11958
  return isValid;
11365
11959
  }
11366
11960
  /*
@@ -11370,7 +11964,7 @@ var QtiTextEntryInteraction = class extends Interaction {
11370
11964
  */
11371
11965
  /** The answer-key line, revealed above the field when the correct response is shown. */
11372
11966
  renderAnswer() {
11373
- return html31`<div part="answer" aria-hidden="true"></div>`;
11967
+ return html31`<div part="answer-key answer" aria-hidden="true"></div>`;
11374
11968
  }
11375
11969
  /** The field itself. */
11376
11970
  renderInput() {
@@ -11380,7 +11974,7 @@ var QtiTextEntryInteraction = class extends Interaction {
11380
11974
  spellcheck="false"
11381
11975
  autocomplete="off"
11382
11976
  @blur="${(_) => {
11383
- this.reportValidity();
11977
+ this.reportValidity({ trigger: "change" });
11384
11978
  }}"
11385
11979
  @keydown="${(event) => event.stopImmediatePropagation()}"
11386
11980
  @keyup="${this.textChanged}"
@@ -11410,33 +12004,33 @@ var QtiTextEntryInteraction = class extends Interaction {
11410
12004
  this.saveResponse(input.value);
11411
12005
  }
11412
12006
  }
11413
- reportValidity() {
12007
+ reportValidity(options) {
11414
12008
  this.validate();
11415
- return super.reportValidity();
12009
+ return super.reportValidity(options);
11416
12010
  }
11417
12011
  reset() {
11418
12012
  this.response = "";
11419
12013
  }
11420
12014
  };
11421
- __decorate28([
11422
- property26({ type: Number, attribute: "expected-length" })
12015
+ __decorate29([
12016
+ property27({ type: Number, attribute: "expected-length" })
11423
12017
  ], QtiTextEntryInteraction.prototype, "expectedLength", void 0);
11424
- __decorate28([
11425
- property26({ type: String, attribute: "pattern-mask" })
12018
+ __decorate29([
12019
+ property27({ type: String, attribute: "pattern-mask" })
11426
12020
  ], QtiTextEntryInteraction.prototype, "patternMask", void 0);
11427
- __decorate28([
11428
- property26({ type: String, attribute: "placeholder-text" })
12021
+ __decorate29([
12022
+ property27({ type: String, attribute: "placeholder-text" })
11429
12023
  ], QtiTextEntryInteraction.prototype, "placeholderText", void 0);
11430
- __decorate28([
11431
- property26({ type: String, attribute: "data-patternmask-message" })
12024
+ __decorate29([
12025
+ property27({ type: String, attribute: "data-patternmask-message" })
11432
12026
  ], QtiTextEntryInteraction.prototype, "dataPatternmaskMessage", void 0);
11433
- __decorate28([
11434
- property26({ type: String, attribute: "response", reflect: false })
12027
+ __decorate29([
12028
+ property27({ type: String, attribute: "response", reflect: false })
11435
12029
  ], QtiTextEntryInteraction.prototype, "response", void 0);
11436
- __decorate28([
12030
+ __decorate29([
11437
12031
  query3("input")
11438
12032
  ], QtiTextEntryInteraction.prototype, "_input", void 0);
11439
- __decorate28([
12033
+ __decorate29([
11440
12034
  watch("response", { waitUntilFirstUpdate: true })
11441
12035
  ], QtiTextEntryInteraction.prototype, "_handleValueChange", void 0);
11442
12036
 
@@ -11467,8 +12061,10 @@ var QtiUploadInteraction = class extends Interaction {
11467
12061
  #file = null;
11468
12062
  #base64 = null;
11469
12063
  reset() {
12064
+ this.resetValidityReport();
11470
12065
  this.#file = null;
11471
12066
  this.#base64 = null;
12067
+ this._internals.setFormValue(null);
11472
12068
  this.saveResponse(null);
11473
12069
  }
11474
12070
  validate() {
@@ -11480,6 +12076,7 @@ var QtiUploadInteraction = class extends Interaction {
11480
12076
  set response(base64) {
11481
12077
  if (typeof base64 === "string") {
11482
12078
  this.#base64 = base64;
12079
+ this._internals.setFormValue(base64);
11483
12080
  this.saveResponse(base64);
11484
12081
  } else if (base64 === null) {
11485
12082
  this.reset();
@@ -11511,6 +12108,7 @@ var QtiUploadInteraction = class extends Interaction {
11511
12108
  if (input.files && input.files.length > 0) {
11512
12109
  this.#file = input.files[0];
11513
12110
  this.#base64 = await this.#convertToBase64(this.#file);
12111
+ this._internals.setFormValue(this.#base64);
11514
12112
  this.saveResponse(this.#base64);
11515
12113
  this.dispatchEvent(new CustomEvent("qti-interaction-response", {
11516
12114
  detail: { response: this.#base64 }
@@ -12168,4 +12766,4 @@ export {
12168
12766
  elements31 as elements21,
12169
12767
  qtiInteractionElements
12170
12768
  };
12171
- //# sourceMappingURL=chunk-MP2SUN7J.js.map
12769
+ //# sourceMappingURL=chunk-7MYZHZWV.js.map