@citolab/qti-components 6.7.1-45 → 6.7.1-46

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.
@@ -695,41 +695,6 @@
695
695
  "declarations": [],
696
696
  "exports": []
697
697
  },
698
- {
699
- "kind": "javascript-module",
700
- "path": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts",
701
- "declarations": [
702
- {
703
- "kind": "class",
704
- "description": "",
705
- "name": "QtiCompanionMaterialsInfo",
706
- "superclass": {
707
- "name": "LitElement",
708
- "package": "lit"
709
- },
710
- "tagName": "qti-companion-materials-info",
711
- "customElement": true
712
- }
713
- ],
714
- "exports": [
715
- {
716
- "kind": "js",
717
- "name": "QtiCompanionMaterialsInfo",
718
- "declaration": {
719
- "name": "QtiCompanionMaterialsInfo",
720
- "module": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts"
721
- }
722
- },
723
- {
724
- "kind": "custom-element-definition",
725
- "name": "qti-companion-materials-info",
726
- "declaration": {
727
- "name": "QtiCompanionMaterialsInfo",
728
- "module": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts"
729
- }
730
- }
731
- ]
732
- },
733
698
  {
734
699
  "kind": "javascript-module",
735
700
  "path": "src/lib/qti-components/qti-assessment-item/item-print-variables.ts",
@@ -909,6 +874,41 @@
909
874
  }
910
875
  ]
911
876
  },
877
+ {
878
+ "kind": "javascript-module",
879
+ "path": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts",
880
+ "declarations": [
881
+ {
882
+ "kind": "class",
883
+ "description": "",
884
+ "name": "QtiCompanionMaterialsInfo",
885
+ "superclass": {
886
+ "name": "LitElement",
887
+ "package": "lit"
888
+ },
889
+ "tagName": "qti-companion-materials-info",
890
+ "customElement": true
891
+ }
892
+ ],
893
+ "exports": [
894
+ {
895
+ "kind": "js",
896
+ "name": "QtiCompanionMaterialsInfo",
897
+ "declaration": {
898
+ "name": "QtiCompanionMaterialsInfo",
899
+ "module": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts"
900
+ }
901
+ },
902
+ {
903
+ "kind": "custom-element-definition",
904
+ "name": "qti-companion-materials-info",
905
+ "declaration": {
906
+ "name": "QtiCompanionMaterialsInfo",
907
+ "module": "src/lib/qti-components/qti-companion-materials-info/qti-companion-materials-info.ts"
908
+ }
909
+ }
910
+ ]
911
+ },
912
912
  {
913
913
  "kind": "javascript-module",
914
914
  "path": "src/lib/qti-components/qti-custom-operator/qti-custom-operator.ts",
package/dist/index.js CHANGED
@@ -167,7 +167,7 @@ var Tr=Object.defineProperty,ws=Object.defineProperties,Ts=Object.getOwnProperty
167
167
  :host {
168
168
  display: none;
169
169
  }
170
- `],We=a([m("qti-outcome-processing")],We);var Cr=class{process(t){for(let e of t)e.process()}};var Nt=class extends q{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let s=await fetch(e);if(s.ok){let o=await s.json();for(let l in o.paths)r&&(o.paths[l]=this.getResolvablePath(o.paths[l],r));return o}}catch(s){}return null};this.getResolvablePath=(e,r)=>e!=null&&e.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`);this.mergeConfigs=async(e,r,s)=>{var n;for(let o in r==null?void 0:r.paths)if(!e.paths[o]){let l=!1;try{let c=(n=r.paths[o])!=null&&n.toLocaleLowerCase().endsWith(".js")?r.paths[o]:r.paths[o]+".js";(await fetch(c)).ok?e.paths[o]=r.paths[o].replace(/\.js$/,""):l=!0}catch(c){l=!0}if(l&&s)if(typeof s=="string")try{let c=await this.loadConfig(s);c!=null&&c.paths[o]&&(e.paths[o]=c.paths[o].replace(/\.js$/,""))}catch(c){}else typeof s=="object"&&s!=null&&s.paths[o]&&(e.paths[o]=s.paths[o].replace(/\.js$/,""));else l&&console.error("Failed to resolve module: "+o)}}}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},_errorMessage:{type:String,state:!0}}}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let s=e[r];if(s){for(let n in s)if(s.hasOwnProperty(n)){let o=s[n];if(Array.isArray(o))return o.map(String);if(o!=null)return String(o)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),s=JSON.stringify(e);if(s!==this.rawResponse){this.rawResponse=s;let n=this.convertQtiVariableJSON(r);this.response=n,this.saveResponse(n)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set response(e){}getTAOConfig(e){let r=e.querySelectorAll("properties"),s={},n=l=>{let c={},u=l.getAttribute("key");if(u){let h=Array.from(l.children),f=h.map(v=>v.getAttribute("key"));f.length>0&&!f.find(v=>!Number.isInteger(+v))?c[u]=h.map(v=>o(v)):c[u]=l.textContent}return c},o=l=>{if(l){let c={};for(let u of l.children)c=E(E({},c),n(u));return c}};for(let l of r)return l.getAttribute("key")||(s=E(E({},s),o(l))),s;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",s=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let n=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(s,n,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,n),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,s.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{}};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}this.registerModules(e).then(()=>{requirejs.config(e)(["require"],s=>{!s.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}}));let n=s.defined(this.module);s([this.module],o=>{this.register(o)},o=>{this._errorMessage=o})},s=>{this._errorMessage=s})})}disconnectedCallback(){super.disconnectedCallback(),this.stopChecking()}async registerModules(e){let r=this.getAttribute("data-base-url");if(r){let n=`${r}/modules/module_resolution.js`,o=`${r}/modules/module_resolution_fallback.js`;if(n){let l=await this.loadConfig(n,r);await this.mergeConfigs(e,l,o)}}let s=this.querySelector("qti-interaction-modules");if(s){let n=s.querySelectorAll("qti-interaction-module");for(let o of n){let l=o.getAttribute("id"),c=o.getAttribute("primary-path"),u=o.getAttribute("fallback-path"),h=c?{paths:T(E({},e.paths),{[l]:this.getResolvablePath(c,r)})}:null,f=u?{paths:T(E({},e.paths),{[l]:this.getResolvablePath(u,r)})}:null;l&&h&&await this.mergeConfigs(e,h,f)}}}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return p`<slot></slot>${this._errorMessage&&p`<div style="color:red">
170
+ `],We=a([m("qti-outcome-processing")],We);var Cr=class{process(t){for(let e of t)e.process()}};var Nt=class extends q{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let s=await fetch(e);if(s.ok){let o=await s.json();for(let l in o.paths)r&&(o.paths[l]=this.getResolvablePath(o.paths[l],r));return o}}catch(s){}return null};this.getResolvablePath=(e,r)=>e!=null&&e.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`);this.mergeConfigs=async(e,r,s)=>{var n;for(let o in r==null?void 0:r.paths)if(!e.paths[o]){let l=!1;try{let c=(n=r.paths[o])!=null&&n.toLocaleLowerCase().endsWith(".js")?r.paths[o]:r.paths[o]+".js";(await fetch(c)).ok?e.paths[o]=r.paths[o].replace(/\.js$/,""):l=!0}catch(c){l=!0}if(l&&s)if(typeof s=="string")try{let c=await this.loadConfig(s);c!=null&&c.paths[o]&&(e.paths[o]=c.paths[o].replace(/\.js$/,""))}catch(c){}else typeof s=="object"&&s!=null&&s.paths[o]&&(e.paths[o]=s.paths[o].replace(/\.js$/,""));else l&&console.error("Failed to resolve module: "+o)}}}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},_errorMessage:{type:String,state:!0}}}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let s=e[r];if(s){for(let n in s)if(s.hasOwnProperty(n)){let o=s[n];if(Array.isArray(o))return o.map(String);if(o!=null)return String(o)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),s=JSON.stringify(e);if(s!==this.rawResponse){this.rawResponse=s;let n=this.convertQtiVariableJSON(r);this.response=n,this.saveResponse(n)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set response(e){}getTAOConfig(e){let r=e.querySelectorAll("properties"),s={},n=l=>{let c={},u=l.getAttribute("key");if(u){let h=Array.from(l.children),f=h.map(v=>v.getAttribute("key"));f.length>0&&!f.find(v=>!Number.isInteger(+v))?c[u]=h.map(v=>o(v)):c[u]=l.textContent}return c},o=l=>{if(l){let c={};for(let u of l.children)c=E(E({},c),n(u));return c}};for(let l of r)return l.getAttribute("key")||(s=E(E({},s),o(l))),s;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",s=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let n=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(s,n,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,n),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,s.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{}};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}this.registerModules(e).then(()=>{requirejs.config(e)(["require"],s=>{!s.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}}));let n=s.defined(this.module);s([this.module],o=>{n&&this.register(o)},o=>{this._errorMessage=o})},s=>{this._errorMessage=s})})}disconnectedCallback(){super.disconnectedCallback(),this.stopChecking()}async registerModules(e){let r=this.getAttribute("data-base-url");if(r){let n=`${r}/modules/module_resolution.js`,o=`${r}/modules/module_resolution_fallback.js`;if(n){let l=await this.loadConfig(n,r);await this.mergeConfigs(e,l,o)}}let s=this.querySelector("qti-interaction-modules");if(s){let n=s.querySelectorAll("qti-interaction-module");for(let o of n){let l=o.getAttribute("id"),c=o.getAttribute("primary-path"),u=o.getAttribute("fallback-path"),h=c?{paths:T(E({},e.paths),{[l]:this.getResolvablePath(c,r)})}:null,f=u?{paths:T(E({},e.paths),{[l]:this.getResolvablePath(u,r)})}:null;l&&h&&await this.mergeConfigs(e,h,f)}}}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return p`<slot></slot>${this._errorMessage&&p`<div style="color:red">
171
171
  <h1>Error</h1>
172
172
  ${this._errorMessage}
173
173
  </div>`}`}};Nt=a([m("qti-portable-custom-interaction")],Nt);var Ht=class i{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(t,e){this.data[t]=e},getData:function(t){return this.data[t]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(t,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let r=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let s of r)this._dragCopy.style[s]=r.getPropertyValue(s);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let r=this;requestAnimationFrame(function(){r._touchEndCalled||r._dragCopy===null||(r._dragCopy.style.top=e.clientY-r._copyOffset.y+"px",r._dragCopy.style.left=e.clientX-r._copyOffset.x+"px")});let s=this._findDroppable(t);s!=this._lastTarget&&(this._dispatchEvent(s,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=s),this._currentDropContainer=s,this._currentDropContainer&&this._dispatchEvent(s,"dragover")}};return i._instance?i._instance:(i._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(t){t.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(t){this._touchBegin=Date.now();let{x:e,y:r}=this._getPoint(t);if(this._touchDown={x:e,y:r},this._dragSrc=t.currentTarget,this._canDrag=!0,this.dragOnClick){let s={clientX:e,clientY:r};this._dragRunning=!0,this._createDragCopy(t,s)}t.preventDefault()}_touchMove(t){if(this._canDrag&&this._dragSrc){let{x:e,y:r}=this._getPoint(t),s={clientX:e,clientY:r};this._getDelta(s)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(t,s),t.preventDefault()}}_touchEnd(t){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let r=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});r.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(r)}this._reset()}_touchCancel(t){this._reset()}_findDroppable(t){let e=this._getPoint(t);return this.elementFromPoint(e.x,e.y)}elementFromPoint(t,e){let r=document.elementFromPoint(t,e);if(r){for(;r.shadowRoot;){let s=r.shadowRoot.elementFromPoint(t,e);if(s===null||s===r)break;r=s}return r}return null}_getPoint(t,e){return t&&t.touches&&(t=t.touches[0]),{x:e?t.pageX:t.clientX,y:e?t.pageY:t.clientY}}_calculateDragCopyPosition(t){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=t.clientX-e.left,this._copyOffset.y=t.clientY-e.top}_getDelta(t){let e=Math.abs(t.clientX-this._touchDown.x),r=Math.abs(t.clientY-this._touchDown.y);return e+r}_dispatchEvent(t,e,r=!0){if(!t)return!1;let s=new CustomEvent(e,{bubbles:r,cancelable:!0});return s.dataTransfer=this._dataTransfer,t.dispatchEvent(s),s.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(t,e){this.data[t]=e},getData:function(t){return this.data[t]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}};var vs=(i,t,e)=>{class r extends i{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(o);let l=Array.from(t?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),l.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of l)this.observer=new MutationObserver(u=>{u.forEach(h=>{if(h.type==="attributes")switch(h.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeHandler(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var o;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(o=this.observer)==null||o.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){return o.preventDefault(),o.currentTarget.setAttribute("active",""),o.dataTransfer.dropEffect="move",!1}dropHandler(o){o.preventDefault();let l=o.currentTarget,c=this.querySelector(`[identifier=${o.dataTransfer.getData("text")}`),u=c||this.shadowRoot.querySelector(`[identifier=${o.dataTransfer.getData("text")}`);return l?u.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(u):console.error(`cannot find droppable, target: ${o.target?JSON.stringify(o.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(o){return o.preventDefault(),o.currentTarget.removeAttribute("active"),o.dataTransfer.dropEffect="none",!1}}return a([d({type:Boolean,reflect:!0})],r.prototype,"disabled",2),r};var ys=(i,t,e)=>{class r extends i{}return r};var z=(i,t,e,r)=>{class s extends ys(vs(i,e,r),r,t){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(l,c){if(this.classList.contains("qti-match-tabular"))return;l.filter(h=>!this.draggables||!this.draggables.get(h)).length>0&&(this.dragDropApi.addDraggables(l),l.forEach(h=>{this.draggables.set(h,{parent:h.parentElement,index:Array.from(h.parentNode.children).indexOf(h)}),h.setAttribute("qti-draggable","true"),h.addEventListener("dragstart",f=>{f.dataTransfer.setData("text",f.currentTarget.getAttribute("identifier")),h.setAttribute("dragging","")}),h.addEventListener("dragend",f=>{if(f.preventDefault(),h.removeAttribute("over"),h.removeAttribute("dragging"),(f.dataTransfer.dropEffect==="none"||f.dataTransfer.dropEffect===void 0)&&this.configuration.dragCanBePlacedBack){let x=f.currentTarget,v=this.draggables.get(x),w=v.index<v.parent.children.length?v.index:v.parent.children.length-1,A=v.parent,S=v.parent.children[w];A.insertBefore(x,S),this.saveResponse(),this.checkMaxMatchAssociations()}f.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(l,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(l,c){this.draggables.forEach((u,h)=>{c?h.setAttribute("disabled",""):h.removeAttribute("disabled"),c?h.removeAttribute("qti-draggable"):h.setAttribute("qti-draggable","true")})}handleReadonlyChange(l,c){this.draggables.forEach((u,h)=>{c?h.setAttribute("readonly",""):h.removeAttribute("readonly"),c?h.removeAttribute("qti-draggable"):h.setAttribute("qti-draggable","true")})}firstUpdated(l){super.firstUpdated(l),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(r):this.querySelectorAll(r))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Ht,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(l=!0){this.draggables.forEach((c,u)=>{let h=c.parent.children,f=c.index<h.length?c.index:h.length;c.parent.insertBefore(u,h[f])}),l&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(l=>{let u=+(l.getAttribute("match-max")||1)<=(l.children.length||0);u?l.setAttribute("disabled",""):l.removeAttribute("disabled"),u?l.removeAttribute("dropzone"):l.setAttribute("dropzone","move")})}set response(l){this.classList.contains("qti-match-tabular")||(this.reset(!1),l!==null&&Array.isArray(l)&&l.forEach(c=>{let[u,...h]=c.split(" ").reverse();if(u){let f=this.droppables.find(x=>x.getAttribute("identifier")===u);h.forEach(x=>{let v=this.querySelector(`[identifier=${x}]`);f?v?(f.appendChild(v),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${x}`):console.error(`cannot find droppable with identifier: ${u}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(r)):Array.from(this.querySelectorAll(r))).filter(u=>u.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let l=this.droppables.map(c=>{var h;let u="";return((h=c.children)==null?void 0:h.length)>0&&(u+=Array.from(c.children).map(f=>f.getAttribute("identifier")).join(" ")+" "),u+=c.getAttribute("identifier"),u});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:l}}))}}return a([ms(t)],s.prototype,"reInitDragAndDrop",1),a([d({type:String,attribute:"response-identifier"})],s.prototype,"responseIdentifier",2),a([d({attribute:!1,type:Object})],s.prototype,"configuration",2),a([$("configuration")],s.prototype,"handleDragOptionsChanged",1),a([d({type:Boolean,reflect:!0})],s.prototype,"disabled",2),a([$("disabled",{waitUntilFirstUpdate:!0})],s.prototype,"handleDisabledChange",1),a([d({type:Boolean,reflect:!0})],s.prototype,"readonly",2),a([$("readonly",{waitUntilFirstUpdate:!0})],s.prototype,"handleReadonlyChange",1),a([d({type:Number,reflect:!0,attribute:"min-associations"})],s.prototype,"minAssociations",2),a([d({type:Number,reflect:!0,attribute:"max-associations"})],s.prototype,"maxAssociations",2),s};var qe=class extends z(g,"qti-simple-associable-choice",!0,".dl"){render(){return p` <slot name="prompt"></slot>