@citolab/qti-components 7.0.6-beta.1 → 7.0.6-beta.3

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 (33) hide show
  1. package/cdn/chunks/{chunk-4WXQYE2P.js → chunk-N5OHGRGG.js} +1 -1
  2. package/cdn/chunks/{chunk-3V6LA7B3.js → chunk-NDHSIO2G.js} +1 -1
  3. package/cdn/chunks/{chunk-PKT2SJQD.js → chunk-QV6I5NVQ.js} +1 -1
  4. package/cdn/chunks/{chunk-FTKONGII.js → chunk-TVDTF6P6.js} +28 -28
  5. package/cdn/chunks/chunk-UJP4TGD3.js +1 -0
  6. package/cdn/exports/interaction.js +1 -1
  7. package/cdn/index.global.js +1 -1
  8. package/cdn/index.js +1 -1
  9. package/cdn/qti-components/index.js +1 -1
  10. package/cdn/qti-test/components/index.js +1 -1
  11. package/cdn/qti-test/components/test-component.abstract.js +1 -1
  12. package/cdn/qti-test/components/test-item-link.js +1 -1
  13. package/cdn/qti-test/components/test-next.js +1 -1
  14. package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
  15. package/cdn/qti-test/components/test-prev.js +1 -1
  16. package/cdn/qti-test/components/test-view.js +1 -1
  17. package/dist/chunks/{chunk-ZPNJ2HP5.js → chunk-OIRWOI3E.js} +2 -1
  18. package/dist/chunks/chunk-OIRWOI3E.js.map +1 -0
  19. package/dist/chunks/{chunk-DU37U6PW.js → chunk-ZHAJ3CMP.js} +25 -31
  20. package/dist/chunks/chunk-ZHAJ3CMP.js.map +1 -0
  21. package/dist/exports/interaction.js +1 -1
  22. package/dist/index.js +2 -2
  23. package/dist/qti-components/index.js +2 -2
  24. package/package.json +1 -1
  25. package/cdn/chunks/chunk-R33OODNX.js +0 -1
  26. package/dist/chunks/chunk-2V6LQV2K.js +0 -50
  27. package/dist/chunks/chunk-2V6LQV2K.js.map +0 -1
  28. package/dist/chunks/chunk-4WVLWWYJ.js +0 -50
  29. package/dist/chunks/chunk-4WVLWWYJ.js.map +0 -1
  30. package/dist/chunks/chunk-DU37U6PW.js.map +0 -1
  31. package/dist/chunks/chunk-O6WEZVEM.js +0 -43
  32. package/dist/chunks/chunk-O6WEZVEM.js.map +0 -1
  33. package/dist/chunks/chunk-ZPNJ2HP5.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{a as l}from"./chunk-IMJOPCFR.js";import{b as m,c as a}from"./chunk-L4CUWIE6.js";import{a as i,b as o}from"./chunk-5GCSZ3CH.js";import{a as s,d as r}from"./chunk-LZZB4VGC.js";import{a as e}from"./chunk-IAP2CEE7.js";var t=class extends l{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}render(){return r` <slot></slot> `}};t.styles=s`
1
+ import{b as m,c as a}from"./chunk-L4CUWIE6.js";import{a as l}from"./chunk-IMJOPCFR.js";import{a as i,b as o}from"./chunk-5GCSZ3CH.js";import{a as s,d as r}from"./chunk-LZZB4VGC.js";import{a as e}from"./chunk-IAP2CEE7.js";var t=class extends l{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}render(){return r` <slot></slot> `}};t.styles=s`
2
2
  :host {
3
3
  ${m};
4
4
  }
@@ -1,4 +1,4 @@
1
- import{a as r}from"./chunk-IMJOPCFR.js";import{b as m,c as o}from"./chunk-L4CUWIE6.js";import{a as l}from"./chunk-5GCSZ3CH.js";import{a as i,d as n}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var t=class extends r{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex+1].identifier)})}willUpdate(e){super.willUpdate(e),e.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex<0||this.itemIndex>=this.items.length-1)}render(){return n`<slot></slot>`}};t.styles=i`
1
+ import{b as m,c as o}from"./chunk-L4CUWIE6.js";import{a as r}from"./chunk-IMJOPCFR.js";import{a as l}from"./chunk-5GCSZ3CH.js";import{a as i,d as n}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var t=class extends r{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex+1].identifier)})}willUpdate(e){super.willUpdate(e),e.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex<0||this.itemIndex>=this.items.length-1)}render(){return n`<slot></slot>`}};t.styles=i`
2
2
  :host {
3
3
  ${m};
4
4
  }
@@ -1,4 +1,4 @@
1
- import{a as r}from"./chunk-IMJOPCFR.js";import{b as o,c as m}from"./chunk-L4CUWIE6.js";import{a as n}from"./chunk-5GCSZ3CH.js";import{a as i,d as l}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var t=class extends r{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex-1].identifier)})}willUpdate(e){super.willUpdate(e),e.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex===0||this.itemIndex===-1)}render(){return l`<slot></slot>`}};t.styles=i`
1
+ import{b as o,c as m}from"./chunk-L4CUWIE6.js";import{a as r}from"./chunk-IMJOPCFR.js";import{a as n}from"./chunk-5GCSZ3CH.js";import{a as i,d as l}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var t=class extends r{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex-1].identifier)})}willUpdate(e){super.willUpdate(e),e.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex===0||this.itemIndex===-1)}render(){return l`<slot></slot>`}};t.styles=i`
2
2
  :host {
3
3
  ${o};
4
4
  }
@@ -1,4 +1,4 @@
1
- import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}from"./chunk-5BR5CJFH.js";import{a as Nt}from"./chunk-5FCXUJAG.js";import{a as Ue}from"./chunk-EHK76KRT.js";import{a as w}from"./chunk-XUJ7TXHW.js";import{a as x}from"./chunk-R33OODNX.js";import{a as Ht}from"./chunk-KWPDTFYH.js";import{a as V}from"./chunk-RXKI3AO4.js";import{a as q}from"./chunk-X2KBNXRO.js";import{a as f,b as d,c as C,d as Ye,e as Vt}from"./chunk-5GCSZ3CH.js";import{a as b,d as h,e as at,f as oe,g as k,i as y}from"./chunk-LZZB4VGC.js";import{a as R}from"./chunk-QQCGUVEV.js";import{a as Dt,b as D}from"./chunk-FRS2J3OS.js";import{a as o}from"./chunk-IAP2CEE7.js";var M=class extends y{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:Ht};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(r=>r.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(r=>r.identifier===t.identifier);return i?{...t,...i}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(r=>r.responseIdentifier===t.identifier);i&&(i.value=t.value)}})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let r=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);r&&(r.value=t.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(r=>"correctResponse"in r&&r.correctResponse).map(r=>({responseIdentifier:r.identifier,response:r.correctResponse}));for(let r of i){let a=this._interactionElements.find(p=>p.getAttribute("response-identifier")===r.responseIdentifier);a&&(a.correctResponse=e?r.response:"")}}processResponse(e=!0){this.validate();let t=this.querySelector("qti-response-processing");return!t||!t.process?!1:(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(i=>i.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:i.cardinality==="single"?t:[...r.value,t]})},this._feedbackElements.forEach(r=>r.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(r=>r.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};o([d({type:String})],M.prototype,"title",2),o([d({type:String})],M.prototype,"identifier",2),o([d({type:String})],M.prototype,"adaptive",2),o([d({type:String})],M.prototype,"timeDependent",2),o([d({type:Boolean})],M.prototype,"disabled",2),o([w("disabled",{waitUntilFirstUpdate:!0})],M.prototype,"_handleDisabledChange",2),o([d({type:Boolean})],M.prototype,"readonly",2),o([w("readonly",{waitUntilFirstUpdate:!0})],M.prototype,"_handleReadonlyChange",2),o([Dt({context:R})],M.prototype,"_context",2),M=o([f("qti-assessment-item")],M);var ce=class extends y{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let r=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);r?await this.updateStimulusRef(r):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Nt().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};o([d({type:String})],ce.prototype,"identifier",2),o([d({type:String})],ce.prototype,"href",2),ce=o([f("qti-assessment-stimulus-ref")],ce);var Xe=class extends y{};Xe=o([f("qti-companion-materials-info")],Xe);var ye=class extends y{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let s=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",s?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let s={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,s,e)}};o([D({context:R,subscribe:!0}),C()],ye.prototype,"_context",2),ye=o([f("qti-custom-operator")],ye);var di=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),xe=l=>{if(typeof l=="string")return l;let s=di();return s==="."?l.toLocaleString():l.toString().replace(".","").replace(s,".")};function lt(l){return l==null}function Ee(l){return l.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var S=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(s){let e=this._context.variables.find(i=>i.identifier===s)||null;if(this.outcomeIdentifier!==s||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!lt(this.identifier)&&!lt(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(s){this.showStatus=s&&this.showHide==="show"||!s&&this.showHide==="hide"?"on":"off"}};o([d({type:String,attribute:"show-hide"})],S.prototype,"showHide",2),o([d({type:String,attribute:"outcome-identifier"})],S.prototype,"outcomeIdentifier",2),o([d({type:String})],S.prototype,"identifier",2),o([d({type:String,attribute:!1})],S.prototype,"showStatus",2),o([D({context:R,subscribe:!0}),C()],S.prototype,"_context",2);var Ce=class extends S{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};Ce.styles=b`
1
+ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as Ot,i as Be,j as It}from"./chunk-5BR5CJFH.js";import{a as Ht}from"./chunk-5FCXUJAG.js";import{a as Ue}from"./chunk-EHK76KRT.js";import{a as T}from"./chunk-XUJ7TXHW.js";import{a as x}from"./chunk-UJP4TGD3.js";import{a as Nt}from"./chunk-KWPDTFYH.js";import{a as V}from"./chunk-RXKI3AO4.js";import{a as q}from"./chunk-X2KBNXRO.js";import{a as f,b as d,c as C,d as Ye,e as Vt}from"./chunk-5GCSZ3CH.js";import{a as b,d as h,e as at,f as oe,g as k,i as y}from"./chunk-LZZB4VGC.js";import{a as R}from"./chunk-QQCGUVEV.js";import{a as Dt,b as D}from"./chunk-FRS2J3OS.js";import{a as o}from"./chunk-IAP2CEE7.js";var M=class extends y{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:Nt};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(r=>r.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.detail.interactionElement)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(r=>r.identifier===t.identifier);return i?{...t,...i}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(r=>r.responseIdentifier===t.identifier);i&&(i.value=t.value)}})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let r=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);r&&(r.value=t.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(r=>"correctResponse"in r&&r.correctResponse).map(r=>({responseIdentifier:r.identifier,response:r.correctResponse}));for(let r of i){let a=this._interactionElements.find(p=>p.getAttribute("response-identifier")===r.responseIdentifier);a&&(a.correctResponse=e?r.response:"")}}processResponse(e=!0){this.validate();let t=this.querySelector("qti-response-processing");return!t||!t.process?!1:(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(i=>i.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:i.cardinality==="single"?t:[...r.value,t]})},this._feedbackElements.forEach(r=>r.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(r=>r.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};o([d({type:String})],M.prototype,"title",2),o([d({type:String})],M.prototype,"identifier",2),o([d({type:String})],M.prototype,"adaptive",2),o([d({type:String})],M.prototype,"timeDependent",2),o([d({type:Boolean})],M.prototype,"disabled",2),o([T("disabled",{waitUntilFirstUpdate:!0})],M.prototype,"_handleDisabledChange",2),o([d({type:Boolean})],M.prototype,"readonly",2),o([T("readonly",{waitUntilFirstUpdate:!0})],M.prototype,"_handleReadonlyChange",2),o([Dt({context:R})],M.prototype,"_context",2),M=o([f("qti-assessment-item")],M);var ce=class extends y{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let r=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);r?await this.updateStimulusRef(r):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Ht().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};o([d({type:String})],ce.prototype,"identifier",2),o([d({type:String})],ce.prototype,"href",2),ce=o([f("qti-assessment-stimulus-ref")],ce);var Xe=class extends y{};Xe=o([f("qti-companion-materials-info")],Xe);var ye=class extends y{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let s=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",s?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let s={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,s,e)}};o([D({context:R,subscribe:!0}),C()],ye.prototype,"_context",2),ye=o([f("qti-custom-operator")],ye);var di=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),xe=l=>{if(typeof l=="string")return l;let s=di();return s==="."?l.toLocaleString():l.toString().replace(".","").replace(s,".")};function lt(l){return l==null}function Ee(l){return l.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var S=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(s){let e=this._context.variables.find(i=>i.identifier===s)||null;if(this.outcomeIdentifier!==s||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!lt(this.identifier)&&!lt(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(s){this.showStatus=s&&this.showHide==="show"||!s&&this.showHide==="hide"?"on":"off"}};o([d({type:String,attribute:"show-hide"})],S.prototype,"showHide",2),o([d({type:String,attribute:"outcome-identifier"})],S.prototype,"outcomeIdentifier",2),o([d({type:String})],S.prototype,"identifier",2),o([d({type:String,attribute:!1})],S.prototype,"showStatus",2),o([D({context:R,subscribe:!0}),C()],S.prototype,"_context",2);var Ce=class extends S{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};Ce.styles=b`
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -15,14 +15,14 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
15
15
  .off {
16
16
  display: none;
17
17
  }
18
- `,qe=o([f("qti-feedback-inline")],qe);var Te=class extends S{render(){return h`
18
+ `,qe=o([f("qti-feedback-inline")],qe);var we=class extends S{render(){return h`
19
19
  <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
20
20
  <slot></slot>
21
21
  <div style="margin-top: var(--qti-gap-size); text-align: center;">
22
22
  <button class="button close-button" @click="${this.closeFeedback}"></button>
23
23
  </div>
24
24
  </dialog>
25
- `}openFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&!s.open&&s.showModal()}closeFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&s.open&&(s.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(s){s.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Te.styles=b`
25
+ `}openFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&!s.open&&s.showModal()}closeFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&s.open&&(s.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(s){s.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};we.styles=b`
26
26
  .qti-dialog {
27
27
  background: var(--qti-bg);
28
28
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
@@ -71,13 +71,13 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
71
71
  display: inline-block;
72
72
  line-height: 1.5;
73
73
  }
74
- `,Te=o([f("qti-modal-feedback")],Te);var we=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};we.styles=b`
74
+ `,we=o([f("qti-modal-feedback")],we);var Te=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Te.styles=b`
75
75
  :host {
76
76
  display: flex;
77
77
  user-select: none;
78
78
  position: absolute;
79
79
  }
80
- `,we=o([f("qti-associable-hotspot")],we);var Pt=(l,s,e)=>{class t extends l{}return t};var H=(l,s,e,t,i="default")=>{class r extends Pt(l,e,s){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.rootNode=null;this.allDropzones=[];this.lastTarget=null;this.dropzoneOriginalParent=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(n,c){this.data[n]=c},getData(n){return this.data[n]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(n,c)=>{for(let m of c)this.draggables.includes(m)&&(this.draggables=this.draggables.filter(g=>g!==m),m.removeAttribute("tabindex"),m.removeEventListener("touchstart",this.handleTouchStart.bind(this)),m.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let m of n)this.draggables.includes(m)||(this.draggables.push(m),m.setAttribute("tabindex","0"),m.hasTouchStartListener||(m.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),m.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),m.hasTouchStartListener=!0));let u=0;this.draggables.forEach(m=>{m.style.viewTransitionName=`drag-${u}-${this.getAttribute("identifier")||crypto.randomUUID()}`,m.setAttribute("qti-draggable","true"),m.addEventListener("dragstart",this.handleDragStart),m.addEventListener("dragend",this.handleDragEnd),u++})};this.droppablesModified=(n,c)=>{for(let u of c)this.droppables.includes(u)&&(this.droppables=this.droppables.filter(m=>m!==u),this.allDropzones=this.allDropzones.filter(m=>m!==u));for(let u of n)this.droppables.includes(u)||(this.droppables.push(u),this.allDropzones.push(u));for(let u of this.droppables)this.dataset.choicesContainerWidth&&(u.style.width=`${this.dataset.choicesContainerWidth}px`,u.style.boxSizing="border-box")};this.handleDragStart=n=>{let c=n.currentTarget;n.dataTransfer.setData("text",c.getAttribute("identifier")),this.responseIdentifier&&n.dataTransfer.setData("responseIdentifier",this.responseIdentifier),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),c.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(c)};this.handleDragEnd=async n=>{n.preventDefault();let c=n.currentTarget;this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),c.removeAttribute("dragging")}}handleDraggableContainerChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.dragContainersModified(n||[],c||[])}dragContainersModified(n,c){for(let u of c)this.dragContainers.includes(u)&&(this.dragContainers=this.dragContainers.filter(m=>m!==u),this.allDropzones=this.allDropzones.filter(m=>m!==u));for(let u of n)this.dragContainers.includes(u)||(this.dragContainers.push(u),this.allDropzones.push(u))}handleDraggablesChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.draggablesModified(n||[],c||[])}handleDroppablesChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.droppablesModified(n||[],c||[])}firstUpdated(n){super.firstUpdated(n),this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let u=Array.from(this.querySelectorAll(s)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[])),m=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),g=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(g,[]),this.droppablesModified(m,[]),this.draggablesModified(u,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(T=>this.resizeObserver?.observe(T))}async moveDraggableToDroppable(n,c){(()=>{n.style.transform="translate(0, 0)",c.tagName==="SLOT"?n.setAttribute("slot",c.getAttribute("name")):c.appendChild(n),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(n){this.dragContainers.includes(n)?(this._internals.states.add("--dragzone-active"),n.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),n.setAttribute("active",""))}deactivateDroppable(n,c=!0){c&&this._internals.states.add("--dragzone-active"),n.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let n=this.querySelectorAll(s),c=Array.from(this.querySelectorAll(e)).map(v=>v),u=0,m=0;n.forEach(v=>{let T=v.getBoundingClientRect();u=Math.max(u,T.height),m=Math.max(m,T.width)});let g=this.querySelector(t)||this.shadowRoot?.querySelector(t);g&&(g.style.minHeight=`${u}px`,g.style.minWidth=`${m}px`);for(let v of c)v.style.minHeight=`${u}px`,v.style.minWidth=`${m}px`}activateDroppables(n){this.dragContainers.forEach(u=>{u.setAttribute("enabled",""),u.hasAttribute("disabled")&&(u.contains(n)||u.shadowRoot&&u.shadowRoot.contains(n))&&u.removeAttribute("disabled")}),this.droppables.forEach(u=>{u.setAttribute("enabled",""),u.hasAttribute("disabled")&&(u.contains(n)||u.shadowRoot&&u.shadowRoot.contains(n))&&u.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(c=>{c.removeAttribute("enabled")}),this.droppables.forEach(c=>c.removeAttribute("enabled"))}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(n){if(this.isDraggable&&this.dragClone){let{x:c,y:u}=this.getEventCoordinates(n),m={clientX:c,clientY:u};this.calculateDragDistance(m)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(m));let g=this.findClosestDropzone();this.currentDropTarget=g,g!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),g&&(this.activateDroppable(g),this.dispatchCustomEvent(g,"dragenter")),this.lastTarget=g),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),n.preventDefault()}}handleTouchEnd(n){if(this.isDragging){if(this.currentDropTarget){let c=this.dragClone;this.moveDraggableToDroppable(c,this.currentDropTarget)}this.resetDragState()}this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),n.preventDefault()}handleTouchCancel(n){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let n=this.getValidAssociations(),c=!0,u="";this.maxAssociations>0&&n>this.maxAssociations?(c=!1,u=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&n<this.minAssociations&&(c=!1,u=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let m=this.lastElementChild;return this._internals.setValidity(c?{}:{customError:!0},u,m),this.reportValidity(),c}reportValidity(){let n=this.shadowRoot.querySelector("#validationMessage");return n&&(this._internals.validity.valid?(n.textContent="",n.style.display="none"):(n.textContent=this._internals.validationMessage,n.style.display="block")),this._internals.validity.valid}checkMaxAssociations(n){let c=this.getMatchMaxValue(n),u=n.querySelectorAll('[qti-draggable="true"]').length;return c===0||u>=c}resetDragState(){if(this.dragClone)if(!(this.currentDropTarget!==null)||this.dragContainers.includes(this.currentDropTarget))this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.pointerEvents="auto",this.dragClone.remove();else{let u=window.getComputedStyle(this.dragSource);for(let m=0;m<u.length;m++){let g=u[m];this.dragClone.style.setProperty(g,u.getPropertyValue(g))}this.dragClone.style.opacity="1.0",this.dragClone.style.display="block",this.dragClone.style.pointerEvents="auto"}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null}checkAllMaxAssociations(){this.droppables.forEach(n=>{this.checkMaxAssociations(n)?this.disableDroppable(n):this.enableDroppable(n)})}getMatchMaxValue(n){let c=n.getAttribute("match-max");return c?parseInt(c,10):1}disableDroppable(n){n.setAttribute("disabled","")}enableDroppable(n){n.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(n){if(!this.isMatchTabular())if(Array.isArray(n)){n?.forEach(u=>this.placeResponse(u));let c=new FormData;n.forEach(u=>{c.append(this.responseIdentifier,u)}),this._internals.setFormValue(c)}else this._internals.setFormValue(n||"")}placeResponse(n){let[c,...u]=n.split(" ").reverse(),m=this.findDroppableById(c);u.forEach(g=>this.placeDraggableInDroppable(g,m))}findDroppableById(n){return this.droppables.find(c=>c.getAttribute("identifier")===n)}async placeDraggableInDroppable(n,c){let u=this.querySelector(`[identifier=${n}]`);if(!c||!u){console.error(`Cannot find draggable or droppable with the given identifier: ${n}`);return}let m=()=>{u.style.transform="translate(0, 0)",c.appendChild(u),this.checkAllMaxAssociations()};document.startViewTransition?await document.startViewTransition(m).finished:m()}getValidAssociations(){return this.droppables.filter(n=>n.childElementCount>0).length}saveResponse(){this.validate();let n=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:n}}))}collectResponseData(){return this.droppables.map(c=>{let u=c.querySelectorAll('[qti-draggable="true"]'),m=Array.from(u).map(v=>v.getAttribute("identifier")),g=c.getAttribute("identifier");return m.map(v=>`${v} ${g}`)}).flat()}reset(n=!0){n&&this.saveResponse()}updateDragClonePosition(n){if(!this.isDragging||!this.dragClone)return;let c=n.clientX-this.cloneOffset.x,u=n.clientY-this.cloneOffset.y,{newLeft:m,newTop:g}=this.applyBoundaries(c,u,this.dragClone);this.dragClone.style.left=`${m}px`,this.dragClone.style.top=`${g}px`}getEventCoordinates(n,c=!1){let u=n.touches?n.touches[0]:n;return{x:c?u.pageX:u.clientX,y:c?u.pageY:u.clientY}}calculateDragDistance(n){let c=Math.abs(n.clientX-this.touchStartPoint.x),u=Math.abs(n.clientY-this.touchStartPoint.y);return c+u}applyBoundaries(n,c,u){let m=new DOMRect(0,0,window.innerWidth,window.innerHeight);this.rootNode instanceof ShadowRoot?m=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document&&(m=document.documentElement.getBoundingClientRect());let g=u.getBoundingClientRect(),v=g.width,T=g.height,E=Math.max(m.left,Math.min(n,m.right-v)),z=Math.max(m.top,Math.min(c,m.bottom-T));return{newLeft:E,newTop:z}}findClosestDropzone(){let n=this.allDropzones.filter(g=>!g.hasAttribute("disabled"));if(!this.dragClone||n.length===0)return null;let c=this.dragClone.getBoundingClientRect(),u=null,m=0;for(let g of n){let v=g.getBoundingClientRect(),T=this.calculateOverlapArea(c,v);T>m&&(m=T,u=g)}if(!u){let g=200;for(let v of n){let T=v.getBoundingClientRect(),E=Math.sqrt(Math.pow(c.left-T.left,2)+Math.pow(c.top-T.top,2));E<g&&(g=E,u=v)}}return u}calculateOverlapArea(n,c){let u=Math.max(0,Math.min(n.right,c.right)-Math.max(n.left,c.left)),m=Math.max(0,Math.min(n.bottom,c.bottom)-Math.max(n.top,c.top));return u*m}dispatchCustomEvent(n,c,u=!0){if(!n)return;let m=new CustomEvent(c,{bubbles:u,cancelable:!0});m.dataTransfer=this.dataTransfer,n.dispatchEvent(m)}appendClone(){let n=this.findParentInteractionElement(this.dragSource);i=="default"?n?n.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone):i=="interaction"?n?n.appendChild(this.dragClone):console.error("No interaction found to append the drag clone"):i=="host"?this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):console.error("No host found to append the drag clone"):i=="body"&&document.body.appendChild(this.dragClone)}handleTouchStart(n){let{x:c,y:u}=this.getEventCoordinates(n);this.dropzoneOriginalParent=n.currentTarget.parentElement,this.touchStartPoint={x:c,y:u},this.dragSource=n.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode();let m=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),g=this.dragSource.parentElement;if(this.droppables.includes(g)){this.enableDroppable(g),this.dragClone=this.dragSource,this.dragSource=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier"));let v=this.dragClone.getBoundingClientRect();this.appendClone(),v&&this.setDragCloneStyles(v)}else{let v=m.getBoundingClientRect();this.cloneOffset.x=c-v.left,this.cloneOffset.y=u-v.top,this.dragClone=m.cloneNode(!0);let T=window.getComputedStyle(this.dragSource);for(let A=0;A<T.length;A++){let ze=T[A];this.dragClone.style.setProperty(ze,T.getPropertyValue(ze))}v&&this.setDragCloneStyles(v),this.appendClone();let E=this.getMatchMaxValue(this.dragSource),z=this.draggables.filter(A=>A.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));E!==0&&z.length>=E?(m.style.opacity="0.0",m.style.pointerEvents="none"):m.style.opacity="1.0",n.preventDefault()}}findParentInteractionElement(n){let c=n.parentElement;for(;c&&!c.tagName?.toLowerCase().endsWith("-interaction");)c=c.parentElement;return c}findDraggableInDraggableContainer(n){let c=this.dragContainers.flat();for(let u of c){if(u.getAttribute("identifier")===n)return u;let m;u instanceof HTMLSlotElement?m=Array.from(u.assignedElements()||[]):m=Array.from(u.querySelectorAll(s));let g=m.find(v=>v.getAttribute("identifier")===n);if(g)return g}}setDragCloneStyles(n){this.dragClone.style.position="fixed",this.dragClone.style.top=`${n.top}px`,this.dragClone.style.left=`${n.left}px`,this.dragClone.style.width=`${n.width}px`,this.dragClone.style.height=`${n.height}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return o([d({attribute:!1,type:Object})],r.prototype,"configuration",2),o([d({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),o([d({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),o([Ue(t)],r.prototype,"handleDraggableContainerChange",1),o([Ue(s)],r.prototype,"handleDraggablesChange",1),o([Ue(e)],r.prototype,"handleDroppablesChange",1),r};var Ft=b`
80
+ `,Te=o([f("qti-associable-hotspot")],Te);var Pt=(l,s,e)=>{class t extends l{}return t};var N=(l,s,e,t,i="default")=>{class r extends Pt(l,e,s){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.rootNode=null;this.allDropzones=[];this.lastTarget=null;this.dropzoneOriginalParent=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(n,c){this.data[n]=c},getData(n){return this.data[n]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(n,c)=>{for(let m of c)this.draggables.includes(m)&&(this.draggables=this.draggables.filter(g=>g!==m),m.removeAttribute("tabindex"),m.removeEventListener("touchstart",this.handleTouchStart.bind(this)),m.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let m of n)this.draggables.includes(m)||(this.draggables.push(m),m.setAttribute("tabindex","0"),m.hasTouchStartListener||(m.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),m.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),m.hasTouchStartListener=!0));let u=0;this.draggables.forEach(m=>{m.style.viewTransitionName=`drag-${u}-${this.getAttribute("identifier")||crypto.randomUUID()}`,m.setAttribute("qti-draggable","true"),u++})};this.droppablesModified=(n,c)=>{for(let u of c)this.droppables.includes(u)&&(this.droppables=this.droppables.filter(m=>m!==u),this.allDropzones=this.allDropzones.filter(m=>m!==u));for(let u of n)this.droppables.includes(u)||(this.droppables.push(u),this.allDropzones.push(u));for(let u of this.droppables)this.dataset.choicesContainerWidth&&(u.style.width=`${this.dataset.choicesContainerWidth}px`,u.style.boxSizing="border-box")}}handleDraggableContainerChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.dragContainersModified(n||[],c||[])}dragContainersModified(n,c){for(let u of c)this.dragContainers.includes(u)&&(this.dragContainers=this.dragContainers.filter(m=>m!==u),this.allDropzones=this.allDropzones.filter(m=>m!==u));for(let u of n)this.dragContainers.includes(u)||(this.dragContainers.push(u),this.allDropzones.push(u))}handleDraggablesChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.draggablesModified(n||[],c||[])}handleDroppablesChange(n,c){this.isMatchTabular()||(n.length>0||c.length>0)&&this.droppablesModified(n||[],c||[])}firstUpdated(n){super.firstUpdated(n),this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let u=Array.from(this.querySelectorAll(s)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[])),m=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),g=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(g,[]),this.droppablesModified(m,[]),this.draggablesModified(u,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(w=>this.resizeObserver?.observe(w))}async moveDraggableToDroppable(n,c){(()=>{n.style.transform="translate(0, 0)",c.tagName==="SLOT"?n.setAttribute("slot",c.getAttribute("name")):c.appendChild(n),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(n){this.dragContainers.includes(n)?(this._internals.states.add("--dragzone-active"),n.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),n.setAttribute("active",""))}deactivateDroppable(n,c=!0){c&&this._internals.states.add("--dragzone-active"),n.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let n=this.querySelectorAll(s),c=Array.from(this.querySelectorAll(e)).map(v=>v),u=0,m=0;n.forEach(v=>{let w=v.getBoundingClientRect();u=Math.max(u,w.height),m=Math.max(m,w.width)});let g=this.querySelector(t)||this.shadowRoot?.querySelector(t);g&&(g.style.minHeight=`${u}px`,g.style.minWidth=`${m}px`);for(let v of c)v.style.minHeight=`${u}px`,v.style.minWidth=`${m}px`}activateDroppables(n){this.dragContainers.forEach(u=>{u.setAttribute("enabled",""),u.hasAttribute("disabled")&&(u.contains(n)||u.shadowRoot&&u.shadowRoot.contains(n))&&u.removeAttribute("disabled")}),this.droppables.forEach(u=>{u.setAttribute("enabled",""),u.hasAttribute("disabled")&&(u.contains(n)||u.shadowRoot&&u.shadowRoot.contains(n))&&u.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(c=>{c.removeAttribute("enabled"),c.removeAttribute("active")}),this.droppables.forEach(c=>{c.removeAttribute("enabled"),c.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(n){if(this.isDraggable&&this.dragClone){let{x:c,y:u}=this.getEventCoordinates(n),m={clientX:c,clientY:u};this.calculateDragDistance(m)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(m));let g=this.findClosestDropzone();this.currentDropTarget=g,g!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),g&&(this.activateDroppable(g),this.dispatchCustomEvent(g,"dragenter")),this.lastTarget=g),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),n.preventDefault()}}handleTouchEnd(n){if(this.isDragging){if(this.currentDropTarget){let c=this.dragClone;this.moveDraggableToDroppable(c,this.currentDropTarget)}this.resetDragState()}this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.dragClone?.removeAttribute("dragging"),n.preventDefault()}handleTouchCancel(n){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let n=this.getValidAssociations(),c=!0,u="";this.maxAssociations>0&&n>this.maxAssociations?(c=!1,u=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&n<this.minAssociations&&(c=!1,u=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let m=this.lastElementChild;return this._internals.setValidity(c?{}:{customError:!0},u,m),this.reportValidity(),c}reportValidity(){let n=this.shadowRoot.querySelector("#validationMessage");return n&&(this._internals.validity.valid?(n.textContent="",n.style.display="none"):(n.textContent=this._internals.validationMessage,n.style.display="block")),this._internals.validity.valid}checkMaxAssociations(n){let c=this.getMatchMaxValue(n),u=n.querySelectorAll('[qti-draggable="true"]').length;return c===0||u>=c}resetDragState(){if(this.dragClone)if(!(this.currentDropTarget!==null)||this.dragContainers.includes(this.currentDropTarget))this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.pointerEvents="auto",this.dragClone.remove();else{let u=window.getComputedStyle(this.dragSource);for(let m=0;m<u.length;m++){let g=u[m];this.dragClone.style.setProperty(g,u.getPropertyValue(g))}this.dragClone.style.opacity="1.0",this.dragClone.style.display="block",this.dragClone.style.pointerEvents="auto"}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null}checkAllMaxAssociations(){this.droppables.forEach(n=>{this.checkMaxAssociations(n)?this.disableDroppable(n):this.enableDroppable(n)})}getMatchMaxValue(n){let c=n.getAttribute("match-max");return c?parseInt(c,10):1}disableDroppable(n){n.setAttribute("disabled","")}enableDroppable(n){n.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(n){if(!this.isMatchTabular())if(Array.isArray(n)){n?.forEach(u=>this.placeResponse(u));let c=new FormData;n.forEach(u=>{c.append(this.responseIdentifier,u)}),this._internals.setFormValue(c)}else this._internals.setFormValue(n||"")}placeResponse(n){let[c,...u]=n.split(" ").reverse(),m=this.findDroppableById(c);u.forEach(g=>this.placeDraggableInDroppable(g,m))}findDroppableById(n){return this.droppables.find(c=>c.getAttribute("identifier")===n)}async placeDraggableInDroppable(n,c){let u=this.querySelector(`[identifier=${n}]`);if(!c||!u){console.error(`Cannot find draggable or droppable with the given identifier: ${n}`);return}let m=()=>{u.style.transform="translate(0, 0)",c.appendChild(u),this.checkAllMaxAssociations()};document.startViewTransition?await document.startViewTransition(m).finished:m()}getValidAssociations(){return this.droppables.filter(n=>n.childElementCount>0).length}saveResponse(){this.validate();let n=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:n}}))}collectResponseData(){return this.droppables.map(c=>{let u=c.querySelectorAll('[qti-draggable="true"]'),m=Array.from(u).map(v=>v.getAttribute("identifier")),g=c.getAttribute("identifier");return m.map(v=>`${v} ${g}`)}).flat()}reset(n=!0){n&&this.saveResponse()}updateDragClonePosition(n){if(!this.isDragging||!this.dragClone)return;let c=n.clientX-this.cloneOffset.x,u=n.clientY-this.cloneOffset.y,{newLeft:m,newTop:g}=this.applyBoundaries(c,u,this.dragClone);this.dragClone.style.left=`${m}px`,this.dragClone.style.top=`${g}px`}getEventCoordinates(n,c=!1){let u=n.touches?n.touches[0]:n;return{x:c?u.pageX:u.clientX,y:c?u.pageY:u.clientY}}calculateDragDistance(n){let c=Math.abs(n.clientX-this.touchStartPoint.x),u=Math.abs(n.clientY-this.touchStartPoint.y);return c+u}applyBoundaries(n,c,u){let m=new DOMRect(0,0,window.innerWidth,window.innerHeight);this.rootNode instanceof ShadowRoot?m=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document&&(m=document.documentElement.getBoundingClientRect());let g=u.getBoundingClientRect(),v=g.width,w=g.height,E=Math.max(m.left,Math.min(n,m.right-v)),z=Math.max(m.top,Math.min(c,m.bottom-w));return{newLeft:E,newTop:z}}findClosestDropzone(){let n=this.allDropzones.filter(g=>!g.hasAttribute("disabled"));if(!this.dragClone||n.length===0)return null;let c=this.dragClone.getBoundingClientRect(),u=null,m=0;for(let g of n){let v=g.getBoundingClientRect(),w=this.calculateOverlapArea(c,v);w>m&&(m=w,u=g)}if(!u){let g=200;for(let v of n){let w=v.getBoundingClientRect(),E=Math.sqrt(Math.pow(c.left-w.left,2)+Math.pow(c.top-w.top,2));E<g&&(g=E,u=v)}}return u}calculateOverlapArea(n,c){let u=Math.max(0,Math.min(n.right,c.right)-Math.max(n.left,c.left)),m=Math.max(0,Math.min(n.bottom,c.bottom)-Math.max(n.top,c.top));return u*m}dispatchCustomEvent(n,c,u=!0){if(!n)return;let m=new CustomEvent(c,{bubbles:u,cancelable:!0});m.dataTransfer=this.dataTransfer,n.dispatchEvent(m)}appendClone(){let n=this.findParentInteractionElement(this.dragSource);i=="default"?n?n.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone):i=="interaction"?n?n.appendChild(this.dragClone):console.error("No interaction found to append the drag clone"):i=="host"?this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):console.error("No host found to append the drag clone"):i=="body"&&document.body.appendChild(this.dragClone)}handleTouchStart(n){let{x:c,y:u}=this.getEventCoordinates(n);this.dropzoneOriginalParent=n.currentTarget.parentElement,this.touchStartPoint={x:c,y:u},this.dragSource=n.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode(),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.dragSource.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(this.dragSource);let m=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),g=this.dragSource.parentElement;if(this.droppables.includes(g)){this.enableDroppable(g),this.dragClone=this.dragSource,this.dragSource=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier"));let v=this.dragClone.getBoundingClientRect();this.appendClone(),v&&this.setDragCloneStyles(v)}else{let v=m.getBoundingClientRect();this.cloneOffset.x=c-v.left,this.cloneOffset.y=u-v.top,this.dragClone=m.cloneNode(!0);let w=window.getComputedStyle(this.dragSource);for(let A=0;A<w.length;A++){let ze=w[A];this.dragClone.style.setProperty(ze,w.getPropertyValue(ze))}v&&this.setDragCloneStyles(v),this.appendClone();let E=this.getMatchMaxValue(this.dragSource),z=this.draggables.filter(A=>A.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));E!==0&&z.length>=E?(m.style.opacity="0.0",m.style.pointerEvents="none"):m.style.opacity="1.0",n.preventDefault()}}findParentInteractionElement(n){let c=n.parentElement;for(;c&&!c.tagName?.toLowerCase().endsWith("-interaction");)c=c.parentElement;return c}findDraggableInDraggableContainer(n){let c=this.dragContainers.flat();for(let u of c){if(u.getAttribute("identifier")===n)return u;let m;u instanceof HTMLSlotElement?m=Array.from(u?.assignedElements()||[]):m=Array.from(u.querySelectorAll(s));let g=m.find(v=>v.getAttribute("identifier")===n);if(g)return g}}setDragCloneStyles(n){this.dragClone.style.position="fixed",this.dragClone.style.top=`${n.top}px`,this.dragClone.style.left=`${n.left}px`,this.dragClone.style.width=`${n.width}px`,this.dragClone.style.height=`${n.height}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return o([d({attribute:!1,type:Object})],r.prototype,"configuration",2),o([d({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),o([d({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),o([Ue(t)],r.prototype,"handleDraggableContainerChange",1),o([Ue(s)],r.prototype,"handleDraggablesChange",1),o([Ue(e)],r.prototype,"handleDroppablesChange",1),r};var Ft=b`
81
81
  :host {
82
82
  display: block; /* necessary to calculate scaling position */
83
83
  }
@@ -102,7 +102,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
102
102
  rgb(0 0 0 / 0%) calc(50% + 1px)
103
103
  );
104
104
  }
105
- `;var pe=class extends H(x,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
105
+ `;var pe=class extends N(x,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
106
106
  <slot name="qti-simple-associable-choice"></slot>
107
107
  <div part="drop-container">
108
108
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
@@ -111,7 +111,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
111
111
  </div>`)}
112
112
 
113
113
  <div role="alert" id="validationMessage"></div>
114
- </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};pe.styles=Ft,o([C()],pe.prototype,"_childrenMap",2),pe=o([f("qti-associate-interaction")],pe);var J=(l,s)=>{class e extends l{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(r,a)=>{this._choiceElements.forEach(p=>p.disabled=a)};this._handleReadonlyChange=(r,a)=>{this._choiceElements.forEach(p=>p.readonly=a)};this._value=""}_handleMaxChoicesChange(r,a){this._determineInputType()}get value(){return Array.isArray(this._value)&&this._value.length===0||this._value===""?null:Array.isArray(this._value)?this._value.join(","):this._value}set value(r){if(this.maxChoices>1&&(typeof r=="string"||r===null)?this._value=r?r.toString().split(","):[]:this._value=r||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(p=>{a.append(this.responseIdentifier,p)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(r){this._correctResponse=r;let a=Array.isArray(r)?r:[r];this._choiceElements.forEach(p=>{p.internals.states.delete("correct-response"),p.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(p.identifier)?p.internals.states.add("correct-response"):p.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${s}`,this._registerChoiceElement),this.addEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.addEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${s}`,this._registerChoiceElement),this.removeEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}validate(){let r=this._choiceElements.filter(c=>this._getChoiceChecked(c)),a=r.length,p=!0,n="";return this.maxChoices!==0&&a>this.maxChoices?(p=!1,n=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):a<this.minChoices&&(p=!1,n=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),r.length>0&&this._internals.setValidity(p?{}:{customError:!0},n,r[a-1]||this._choiceElements[0]||this),this.reportValidity(),p}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(r){r.stopPropagation();let a=r.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(r){r.stopPropagation();let a=r.target;this._choiceElements=this._choiceElements.filter(p=>p!==a)}_determineInputType(){this._choiceElements.forEach(r=>{this._setInputType(r)})}_setInputType(r){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";r.internals.role=a,r.internals.states.delete(a==="radio"?"checkbox":"radio"),r.internals.states.add(a)}_choiceElementSelectedHandler(r){this._toggleChoiceChecked(r.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==r.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(r,a){r.internals?.states&&(a?(r.internals.states.add("--checked"),r.internals.ariaChecked="true"):(r.internals.states.delete("--checked"),r.internals.ariaChecked="false"))}_getChoiceChecked(r){return r.internals.states.has("--checked")}_toggleChoiceChecked(r){let a=this._getChoiceChecked(r);this._setChoiceChecked(r,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(p=>this._getChoiceChecked(p)).map(p=>p.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let r=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let p=r.includes(a.identifier);this._setChoiceChecked(a,p)})}}return o([Ye("#validationMessage")],e.prototype,"_validationMessageElement",2),o([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),o([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),o([w("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),o([w("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),o([w("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var je=(l,s)=>{class e extends l{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(r){r.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let r=Array.from(this.querySelectorAll(s)),a=r.filter(g=>g.hasAttribute("fixed")),p=r.filter(g=>!g.hasAttribute("fixed"));if(p.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let n=[...p],c=!1,u=0;for(;!c&&u<10;){u++;for(let g=p.length-1;g>0;g--){let v=Math.floor(Math.random()*(g+1));[p[g],p[v]]=[p[v],p[g]]}c=!p.every((g,v)=>g===n[v])}c||console.warn("Failed to shuffle the choices after multiple attempts.");let m=1;[...a,...p].forEach(g=>{g.style.setProperty("order",String(m++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(r=>{r.style.setProperty("order","initial")})}}return o([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var zt=(l,s)=>{class e extends l{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(r){r&&(this._classes=r.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(r){super.updated(r),r.has("shuffle")&&this._addLabels()}_addLabels(){let r=this._classes.some(p=>this._allLabels.includes(p)||this._allLabelSuffixes.includes(p)),a=p=>!isNaN(+p);if(r){let n=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,u)=>({el:c,order:a(c.style.order)?+c.style.order:u+1})).sort((c,u)=>c.order-u.order).map(c=>c.el);for(let c=0;c<n.length;c++)n[c].marker=this._getLabel(c+1)}}_getLabel(r){let a=this._classes.filter(c=>this._allLabels.includes(c)).pop(),p=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!a&&p&&(a="qti-labels-upper-alpha");let n="";switch(a){case"qti-labels-decimal":n=`${r}`;break;case"qti-labels-lower-alpha":n=`${String.fromCharCode(97+r-1)}`;break;case"qti-labels-upper-alpha":n=`${String.fromCharCode(65+r-1)}`;break}return p==="qti-labels-suffix-period"?n+=".":p==="qti-labels-suffix-parenthesis"&&(n+=")"),n}}return o([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Yt=b`
114
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};pe.styles=Ft,o([C()],pe.prototype,"_childrenMap",2),pe=o([f("qti-associate-interaction")],pe);var J=(l,s)=>{class e extends l{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(r,a)=>{this._choiceElements.forEach(p=>p.disabled=a)};this._handleReadonlyChange=(r,a)=>{this._choiceElements.forEach(p=>p.readonly=a)};this._value=""}_handleMaxChoicesChange(r,a){this._determineInputType()}get value(){return Array.isArray(this._value)&&this._value.length===0||this._value===""?null:Array.isArray(this._value)?this._value.join(","):this._value}set value(r){if(this.maxChoices>1&&(typeof r=="string"||r===null)?this._value=r?r.toString().split(","):[]:this._value=r||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(p=>{a.append(this.responseIdentifier,p)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(r){this._correctResponse=r;let a=Array.isArray(r)?r:[r];this._choiceElements.forEach(p=>{p.internals.states.delete("correct-response"),p.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(p.identifier)?p.internals.states.add("correct-response"):p.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${s}`,this._registerChoiceElement),this.addEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.addEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${s}`,this._registerChoiceElement),this.removeEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}validate(){let r=this._choiceElements.filter(c=>this._getChoiceChecked(c)),a=r.length,p=!0,n="";return this.maxChoices!==0&&a>this.maxChoices?(p=!1,n=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):a<this.minChoices&&(p=!1,n=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),r.length>0&&this._internals.setValidity(p?{}:{customError:!0},n,r[a-1]||this._choiceElements[0]||this),this.reportValidity(),p}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(r){r.stopPropagation();let a=r.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(r){r.stopPropagation();let a=r.target;this._choiceElements=this._choiceElements.filter(p=>p!==a)}_determineInputType(){this._choiceElements.forEach(r=>{this._setInputType(r)})}_setInputType(r){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";r.internals.role=a,r.internals.states.delete(a==="radio"?"checkbox":"radio"),r.internals.states.add(a)}_choiceElementSelectedHandler(r){this._toggleChoiceChecked(r.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==r.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(r,a){r.internals?.states&&(a?(r.internals.states.add("--checked"),r.internals.ariaChecked="true"):(r.internals.states.delete("--checked"),r.internals.ariaChecked="false"))}_getChoiceChecked(r){return r.internals.states.has("--checked")}_toggleChoiceChecked(r){let a=this._getChoiceChecked(r);this._setChoiceChecked(r,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(p=>this._getChoiceChecked(p)).map(p=>p.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let r=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let p=r.includes(a.identifier);this._setChoiceChecked(a,p)})}}return o([Ye("#validationMessage")],e.prototype,"_validationMessageElement",2),o([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),o([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),o([T("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),o([T("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),o([T("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var je=(l,s)=>{class e extends l{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(r){r.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let r=Array.from(this.querySelectorAll(s)),a=r.filter(g=>g.hasAttribute("fixed")),p=r.filter(g=>!g.hasAttribute("fixed"));if(p.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let n=[...p],c=!1,u=0;for(;!c&&u<10;){u++;for(let g=p.length-1;g>0;g--){let v=Math.floor(Math.random()*(g+1));[p[g],p[v]]=[p[v],p[g]]}c=!p.every((g,v)=>g===n[v])}c||console.warn("Failed to shuffle the choices after multiple attempts.");let m=1;[...a,...p].forEach(g=>{g.style.setProperty("order",String(m++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(r=>{r.style.setProperty("order","initial")})}}return o([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var zt=(l,s)=>{class e extends l{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(r){r&&(this._classes=r.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(r){super.updated(r),r.has("shuffle")&&this._addLabels()}_addLabels(){let r=this._classes.some(p=>this._allLabels.includes(p)||this._allLabelSuffixes.includes(p)),a=p=>!isNaN(+p);if(r){let n=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,u)=>({el:c,order:a(c.style.order)?+c.style.order:u+1})).sort((c,u)=>c.order-u.order).map(c=>c.el);for(let c=0;c<n.length;c++)n[c].marker=this._getLabel(c+1)}}_getLabel(r){let a=this._classes.filter(c=>this._allLabels.includes(c)).pop(),p=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!a&&p&&(a="qti-labels-upper-alpha");let n="";switch(a){case"qti-labels-decimal":n=`${r}`;break;case"qti-labels-lower-alpha":n=`${String.fromCharCode(97+r-1)}`;break;case"qti-labels-upper-alpha":n=`${String.fromCharCode(65+r-1)}`;break}return p==="qti-labels-suffix-period"?n+=".":p==="qti-labels-suffix-parenthesis"&&(n+=")"),n}}return o([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Yt=b`
115
115
  [part='slot'] {
116
116
  display: flex;
117
117
  flex-direction: column;
@@ -198,7 +198,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
198
198
  ?disabled="${this.disabled}"
199
199
  ?readonly="${this.readonly}"
200
200
  .value=${this._value}
201
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_.styles=Ut,o([C()],_.prototype,"_rows",2),o([d({type:Number,attribute:"expected-length"})],_.prototype,"expectedLength",2),o([d({type:String,attribute:"pattern-mask"})],_.prototype,"patternMask",2),o([d({type:String,attribute:"placeholder-text"})],_.prototype,"placeholderText",2),o([d({type:String,attribute:"data-patternmask-message"})],_.prototype,"dataPatternmaskMessage",2),o([C()],_.prototype,"_value",2),o([d({type:String,attribute:"class"})],_.prototype,"classNames",2),o([w("classNames")],_.prototype,"handleclassNamesChange",1),_=o([f("qti-extended-text-interaction")],_);var ue=class extends y{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ue.styles=b`
201
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};_.styles=Ut,o([C()],_.prototype,"_rows",2),o([d({type:Number,attribute:"expected-length"})],_.prototype,"expectedLength",2),o([d({type:String,attribute:"pattern-mask"})],_.prototype,"patternMask",2),o([d({type:String,attribute:"placeholder-text"})],_.prototype,"placeholderText",2),o([d({type:String,attribute:"data-patternmask-message"})],_.prototype,"dataPatternmaskMessage",2),o([C()],_.prototype,"_value",2),o([d({type:String,attribute:"class"})],_.prototype,"classNames",2),o([T("classNames")],_.prototype,"handleclassNamesChange",1),_=o([f("qti-extended-text-interaction")],_);var ue=class extends y{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ue.styles=b`
202
202
  :host {
203
203
  display: flex;
204
204
  user-select: none;
@@ -237,10 +237,10 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
237
237
  border-radius: 0.3rem;
238
238
  gap: 0.5rem;
239
239
  }
240
- `;var Me=class extends H(x,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
240
+ `;var Me=class extends N(x,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
241
241
  <slot part="drags" name="drags"></slot>
242
242
  <slot part="drops"></slot>
243
- <div role="alert" id="validationMessage"></div>`}set correctResponse(s){let e=[],t=Array.isArray(s)?s:[s];t&&(e=t.map(r=>{let a=r.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(r=>{let a=r.getAttribute("identifier"),p=e.find(c=>c.gap===a)?.text,n=this.querySelector(`qti-gap-text[identifier="${p}"]`)?.textContent.trim();if(p&&n){if(!r.nextElementSibling?.classList.contains("correct-option")){let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=n,r.insertAdjacentElement("afterend",c)}}else r.nextElementSibling?.classList.contains("correct-option")&&r.nextElementSibling.remove()})}};Me.styles=Bt,Me=o([f("qti-gap-match-interaction")],Me);var Xt={toAttribute:l=>l?"true":"false",fromAttribute:l=>l==="true"};function N(l,s){class e extends l{constructor(...r){super(...r);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(r,a){this.tabIndex=a?-1:0,a&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${s}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${s}`,{bubbles:!0,composed:!0}))}_onKeyUp(r){r.altKey||r.code==="Space"&&(r.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${s}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return o([d({type:String})],e.prototype,"identifier",2),o([d({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),o([d({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Xt})],e.prototype,"disabled",2),o([d({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Xt})],e.prototype,"readonly",2),o([w("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var he=class extends N(y,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};he.styles=b`
243
+ <div role="alert" id="validationMessage"></div>`}set correctResponse(s){let e=[],t=Array.isArray(s)?s:[s];t&&(e=t.map(r=>{let a=r.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(r=>{let a=r.getAttribute("identifier"),p=e.find(c=>c.gap===a)?.text,n=this.querySelector(`qti-gap-text[identifier="${p}"]`)?.textContent.trim();if(p&&n){if(!r.nextElementSibling?.classList.contains("correct-option")){let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=n,r.insertAdjacentElement("afterend",c)}}else r.nextElementSibling?.classList.contains("correct-option")&&r.nextElementSibling.remove()})}};Me.styles=Bt,Me=o([f("qti-gap-match-interaction")],Me);var Xt={toAttribute:l=>l?"true":"false",fromAttribute:l=>l==="true"};function H(l,s){class e extends l{constructor(...r){super(...r);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(r,a){this.tabIndex=a?-1:0,a&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${s}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${s}`,{bubbles:!0,composed:!0}))}_onKeyUp(r){r.altKey||r.code==="Space"&&(r.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${s}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return o([d({type:String})],e.prototype,"identifier",2),o([d({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),o([d({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Xt})],e.prototype,"disabled",2),o([d({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Xt})],e.prototype,"readonly",2),o([T("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var he=class extends H(y,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};he.styles=b`
244
244
  :host {
245
245
  display: inline-flex;
246
246
  user-select: none;
@@ -250,7 +250,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
250
250
  display: flex;
251
251
  user-select: none;
252
252
  }
253
- `,o([d({type:Number,reflect:!0})],me.prototype,"tabindex",2),me=o([f("qti-gap")],me);var jt=(l,s,e)=>{let t=new Map;for(let i=s;i<=e;i++)t.set(l[i],i);return t},We=W(class extends ae{constructor(l){if(super(l),l.type!==ne.CHILD)throw Error("repeat() can only be used in text expressions")}dt(l,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let i=[],r=[],a=0;for(let p of l)i[a]=t?t(p,a):a,r[a]=e(p,a),a++;return{values:r,keys:i}}render(l,s,e){return this.dt(l,s,e).values}update(l,[s,e,t]){let i=It(l),{values:r,keys:a}=this.dt(s,e,t);if(!Array.isArray(i))return this.ut=a,r;let p=this.ut??(this.ut=[]),n=[],c,u,m=0,g=i.length-1,v=0,T=r.length-1;for(;m<=g&&v<=T;)if(i[m]===null)m++;else if(i[g]===null)g--;else if(p[m]===a[v])n[v]=K(i[m],r[v]),m++,v++;else if(p[g]===a[T])n[T]=K(i[g],r[T]),g--,T--;else if(p[m]===a[T])n[T]=K(i[m],r[T]),le(l,n[T+1],i[m]),m++,T--;else if(p[g]===a[v])n[v]=K(i[g],r[v]),le(l,i[m],i[g]),g--,v++;else if(c===void 0&&(c=jt(a,v,T),u=jt(p,m,g)),c.has(p[m]))if(c.has(p[g])){let E=u.get(a[v]),z=E!==void 0?i[E]:null;if(z===null){let A=le(l,i[m]);K(A,r[v]),n[v]=A}else n[v]=K(z,r[v]),le(l,i[m],z),i[E]=null;v++}else Be(i[g]),g--;else Be(i[m]),m++;for(;v<=T;){let E=le(l,n[T+1]);K(E,r[v]),n[v++]=E}for(;m<=g;){let E=i[m++];E!==null&&Be(E)}return this.ut=a,$t(l,n),oe}});function fe(l,s,e,t){switch(l){case"circle":{let[i,r,a]=s,p=i/e.width*100,n=r/e.height*100,c=a/e.width*100;t.style.left=p-c+"%",t.style.top=n-c+"%",t.style.width=t.style.height=4*c+"px",t.style.borderRadius="9999px"}break;case"rect":{let[i,r,a,p]=s,n=i/e.width*100,c=r/e.height*100,u=a/e.width*100,m=p/e.height*100;t.style.left=n+"%",t.style.top=c+"%",t.style.width=u-n+"%",t.style.height=m-c+"%"}break;case"poly":{let i=s.reduce((E,z,A,ze)=>{if(A%2===1){let pi=E.pop();E[E.length]={x:pi,y:ze[A]}}else E.push(z);return E},[]),r=Math.min(...i.map(E=>E.x)),a=Math.max(...i.map(E=>E.x)),p=Math.min(...i.map(E=>E.y)),n=Math.max(...i.map(E=>E.y)),c=r/e.width*100,u=p/e.height*100,m=a/e.width*100,g=n/e.height*100;t.style.left=r/e.width*100+"%",t.style.top=p/e.height*100+"%",t.style.width=m-c+"%",t.style.height=g-u+"%";let T=i.map(E=>({x:(E.x-r)/(a-r)*100,y:(E.y-p)/(n-p)*100})).map(E=>Math.round(E.x)+"% "+Math.round(E.y)+"%").join(",");t.style.clipPath=`polygon(${T})`}break;default:break}}var Wt=b`
253
+ `,o([d({type:Number,reflect:!0})],me.prototype,"tabindex",2),me=o([f("qti-gap")],me);var jt=(l,s,e)=>{let t=new Map;for(let i=s;i<=e;i++)t.set(l[i],i);return t},We=W(class extends ae{constructor(l){if(super(l),l.type!==ne.CHILD)throw Error("repeat() can only be used in text expressions")}dt(l,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let i=[],r=[],a=0;for(let p of l)i[a]=t?t(p,a):a,r[a]=e(p,a),a++;return{values:r,keys:i}}render(l,s,e){return this.dt(l,s,e).values}update(l,[s,e,t]){let i=Ot(l),{values:r,keys:a}=this.dt(s,e,t);if(!Array.isArray(i))return this.ut=a,r;let p=this.ut??(this.ut=[]),n=[],c,u,m=0,g=i.length-1,v=0,w=r.length-1;for(;m<=g&&v<=w;)if(i[m]===null)m++;else if(i[g]===null)g--;else if(p[m]===a[v])n[v]=K(i[m],r[v]),m++,v++;else if(p[g]===a[w])n[w]=K(i[g],r[w]),g--,w--;else if(p[m]===a[w])n[w]=K(i[m],r[w]),le(l,n[w+1],i[m]),m++,w--;else if(p[g]===a[v])n[v]=K(i[g],r[v]),le(l,i[m],i[g]),g--,v++;else if(c===void 0&&(c=jt(a,v,w),u=jt(p,m,g)),c.has(p[m]))if(c.has(p[g])){let E=u.get(a[v]),z=E!==void 0?i[E]:null;if(z===null){let A=le(l,i[m]);K(A,r[v]),n[v]=A}else n[v]=K(z,r[v]),le(l,i[m],z),i[E]=null;v++}else Be(i[g]),g--;else Be(i[m]),m++;for(;v<=w;){let E=le(l,n[w+1]);K(E,r[v]),n[v++]=E}for(;m<=g;){let E=i[m++];E!==null&&Be(E)}return this.ut=a,$t(l,n),oe}});function fe(l,s,e,t){switch(l){case"circle":{let[i,r,a]=s,p=i/e.width*100,n=r/e.height*100,c=a/e.width*100;t.style.left=p-c+"%",t.style.top=n-c+"%",t.style.width=t.style.height=4*c+"px",t.style.borderRadius="9999px"}break;case"rect":{let[i,r,a,p]=s,n=i/e.width*100,c=r/e.height*100,u=a/e.width*100,m=p/e.height*100;t.style.left=n+"%",t.style.top=c+"%",t.style.width=u-n+"%",t.style.height=m-c+"%"}break;case"poly":{let i=s.reduce((E,z,A,ze)=>{if(A%2===1){let pi=E.pop();E[E.length]={x:pi,y:ze[A]}}else E.push(z);return E},[]),r=Math.min(...i.map(E=>E.x)),a=Math.max(...i.map(E=>E.x)),p=Math.min(...i.map(E=>E.y)),n=Math.max(...i.map(E=>E.y)),c=r/e.width*100,u=p/e.height*100,m=a/e.width*100,g=n/e.height*100;t.style.left=r/e.width*100+"%",t.style.top=p/e.height*100+"%",t.style.width=m-c+"%",t.style.height=g-u+"%";let w=i.map(E=>({x:(E.x-r)/(a-r)*100,y:(E.y-p)/(n-p)*100})).map(E=>Math.round(E.x)+"% "+Math.round(E.y)+"%").join(",");t.style.clipPath=`polygon(${w})`}break;default:break}}var Wt=b`
254
254
  slot:not([name='prompt']) {
255
255
  // position: relative; /* qti-hotspot-choice relative to the slot */
256
256
  display: block;
@@ -358,7 +358,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
358
358
  user-select: none;
359
359
  pointer-events: none;
360
360
  }
361
- `;var Se=class extends H(x,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
361
+ `;var Se=class extends N(x,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
362
362
  <slot part="image"></slot>
363
363
  <slot part="drags" name="drags" class="hover-border"></slot>
364
364
  <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(s){let e=s.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),r=t.split(",").map(a=>parseInt(a));switch(i){case"circle":{let[a,p,n]=r;e.style.left=a-n+"px",e.style.top=p-n+"px",e.style.width=e.style.height=2*n+"px"}break;case"rect":{let[a,p,n,c]=r;e.style.left=a+"px",e.style.top=p+"px",e.style.width=n-a+"px",e.style.height=c-p+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Se.styles=Kt,Se=o([f("qti-graphic-gap-match-interaction")],Se);var Jt=b`
@@ -376,7 +376,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
376
376
  <slot name="prompt"></slot>
377
377
  <slot></slot>
378
378
  <div role="alert" id="validationMessage"></div>
379
- `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(a=>a.getAttribute("identifier")===t),r=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=r){this.choiceOrdering=!1;return}i.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),i.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,r=i.getAttribute("coords"),a=i.getAttribute("shape"),p=r.split(",").map(n=>parseInt(n));fe(a,p,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};_e.styles=Jt,_e=o([f("qti-graphic-order-interaction")],_e);var ge=class extends N(y,"qti-hotspot-choice"){};ge.styles=b`
379
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(a=>a.getAttribute("identifier")===t),r=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=r){this.choiceOrdering=!1;return}i.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),i.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,r=i.getAttribute("coords"),a=i.getAttribute("shape"),p=r.split(",").map(n=>parseInt(n));fe(a,p,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};_e.styles=Jt,_e=o([f("qti-graphic-order-interaction")],_e);var ge=class extends H(y,"qti-hotspot-choice"){};ge.styles=b`
380
380
  :host {
381
381
  display: flex;
382
382
  user-select: none;
@@ -397,7 +397,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
397
397
  `;var ke=class extends J(x,"qti-hotspot-choice"){render(){return h`
398
398
  <slot name="prompt"></slot>
399
399
  <slot></slot>
400
- `}positionHotspotOnRegister(s){let e=this.querySelector("img"),t=s.target,i=t.getAttribute("coords"),r=t.getAttribute("shape"),a=i.split(",").map(p=>parseInt(p));fe(r,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};ke.styles=Zt,ke=o([f("qti-hotspot-interaction")],ke);var Ke=class extends J(x,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}};Ke=o([f("qti-hottext-interaction")],Ke);var Re=class extends N(y,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
400
+ `}positionHotspotOnRegister(s){let e=this.querySelector("img"),t=s.target,i=t.getAttribute("coords"),r=t.getAttribute("shape"),a=i.split(",").map(p=>parseInt(p));fe(r,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};ke.styles=Zt,ke=o([f("qti-hotspot-interaction")],ke);var Ke=class extends J(x,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}};Ke=o([f("qti-hottext-interaction")],Ke);var Re=class extends H(y,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
401
401
  <slot></slot> `}};Re.styles=b`
402
402
  :host {
403
403
  display: flex;
@@ -438,7 +438,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
438
438
  display: block;
439
439
  cursor: pointer;
440
440
  }
441
- `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};o([d({type:String})],Ae.prototype,"identifier",2),Ae=o([f("qti-inline-choice")],Ae);var te=class extends N(y,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
441
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};o([d({type:String})],Ae.prototype,"identifier",2),Ae=o([f("qti-inline-choice")],Ae);var te=class extends H(y,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
442
442
  <slot part="slot"></slot>
443
443
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
444
444
  `}};te.styles=b`
@@ -480,7 +480,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
480
480
  /* Make sure the drag and drop container slots have the same width */
481
481
  flex: 1;
482
482
  }
483
- `;var B=class extends H(x,"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","body"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=[];this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,r=t.name,a=t.type;t.checked?(this.value?this.value.indexOf(i)===-1&&(a==="radio"&&(this.value=this.value.filter(p=>p.indexOf(r)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=t):(this.value=this.value.filter(p=>p!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
483
+ `;var B=class extends N(x,"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","body"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=[];this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,r=t.name,a=t.type;t.checked?(this.value?this.value.indexOf(i)===-1&&(a==="radio"&&(this.value=this.value.filter(p=>p.indexOf(r)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=t):(this.value=this.value.filter(p=>p!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
484
484
  <slot name="prompt"></slot>
485
485
  <slot ?hidden=${e}></slot>
486
486
 
@@ -559,7 +559,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
559
559
  :host(.qti-choices-right) [part='container'] {
560
560
  flex-direction: row-reverse;
561
561
  }
562
- `;var X=class extends je(H(x,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
562
+ `;var X=class extends je(N(x,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
563
563
  <div part="container">
564
564
  <slot part="drags"> </slot>
565
565
  <div part="drops">
@@ -603,7 +603,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
603
603
  display: block;
604
604
  position: relative;
605
605
  }
606
- `],o([d({type:Number,attribute:"max-choices"})],ie.prototype,"maxChoices",2),o([d({type:Number,attribute:"min-choices"})],ie.prototype,"minChoices",2),o([C()],ie.prototype,"_points",2),ie=o([f("qti-select-point-interaction")],ie);var be=class extends N(y,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
606
+ `],o([d({type:Number,attribute:"max-choices"})],ie.prototype,"maxChoices",2),o([d({type:Number,attribute:"min-choices"})],ie.prototype,"minChoices",2),o([C()],ie.prototype,"_points",2),ie=o([f("qti-select-point-interaction")],ie);var be=class extends H(y,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
607
607
  <div part="cha"></div>
608
608
  </div>
609
609
  ${this.marker?h`<div id="label">${this.marker}</div>`:k}
@@ -706,7 +706,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
706
706
  <div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
707
707
  </div>
708
708
  </div>
709
- `}_onMouseDown(e){this._startDrag(e.pageX);let t=r=>this._onDrag(r.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=r=>this._onDrag(r.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,r=Math.min(1,Math.max(0,i/t.width)),a=this.min+Math.round(r*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};$.formAssociated=!0,$.styles=ii,o([Ye("#rail")],$.prototype,"_rail",2),o([d({type:Number,attribute:"lower-bound"})],$.prototype,"min",2),o([d({type:Number,attribute:"upper-bound"})],$.prototype,"max",2),o([d({type:Number,attribute:"step"})],$.prototype,"step",2),$=o([f("qti-slider-interaction")],$);var ri=()=>new pt,pt=class{},ct=new WeakMap,Oa=W(class extends Ot{render(l){return k}update(l,[s]){let e=s!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=s,this.ht=l.options?.host,this.rt(this.ct=l.element)),k}rt(l){if(this.isConnected||(l=void 0),typeof this.Y=="function"){let s=this.ht??globalThis,e=ct.get(s);e===void 0&&(e=new WeakMap,ct.set(s,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,l),l!==void 0&&this.Y.call(this.ht,l)}else this.Y.value=l}get lt(){return typeof this.Y=="function"?ct.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var si=b`
709
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=r=>this._onDrag(r.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=r=>this._onDrag(r.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,r=Math.min(1,Math.max(0,i/t.width)),a=this.min+Math.round(r*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};$.formAssociated=!0,$.styles=ii,o([Ye("#rail")],$.prototype,"_rail",2),o([d({type:Number,attribute:"lower-bound"})],$.prototype,"min",2),o([d({type:Number,attribute:"upper-bound"})],$.prototype,"max",2),o([d({type:Number,attribute:"step"})],$.prototype,"step",2),$=o([f("qti-slider-interaction")],$);var ri=()=>new pt,pt=class{},ct=new WeakMap,Ia=W(class extends It{render(l){return k}update(l,[s]){let e=s!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=s,this.ht=l.options?.host,this.rt(this.ct=l.element)),k}rt(l){if(this.isConnected||(l=void 0),typeof this.Y=="function"){let s=this.ht??globalThis,e=ct.get(s);e===void 0&&(e=new WeakMap,ct.set(s,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,l),l!==void 0&&this.Y.call(this.ht,l)}else this.Y.value=l}get lt(){return typeof this.Y=="function"?ct.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var si=b`
710
710
  :host {
711
711
  display: inline-block;
712
712
  }
@@ -788,7 +788,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
788
788
  width: 57rem;
789
789
  min-width: 57rem;
790
790
  }
791
- `;var I=class extends x{constructor(){super(...arguments);this._value="";this.inputRef=ri()}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return h`
791
+ `;var O=class extends x{constructor(){super(...arguments);this._value="";this.inputRef=ri()}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return h`
792
792
  <input
793
793
  part="input"
794
794
  name="${this.responseIdentifier}"
@@ -807,12 +807,12 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
807
807
  ?readonly="${this.readonly}"
808
808
  />
809
809
  <div part="correct">${this._correctResponse}</div>
810
- `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};I.styles=si,o([d({type:Number,attribute:"expected-length"})],I.prototype,"expectedLength",2),o([d({type:String,attribute:"pattern-mask"})],I.prototype,"patternMask",2),o([d({type:String,attribute:"placeholder-text"})],I.prototype,"placeholderText",2),o([d({type:String,attribute:"data-patternmask-message"})],I.prototype,"dataPatternmaskMessage",2),o([C()],I.prototype,"_value",2),I=o([f("qti-text-entry-interaction")],I);var He=class extends x{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get value(){return this._base64}set value(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...x.properties}}render(){return h`
810
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};O.styles=si,o([d({type:Number,attribute:"expected-length"})],O.prototype,"expectedLength",2),o([d({type:String,attribute:"pattern-mask"})],O.prototype,"patternMask",2),o([d({type:String,attribute:"placeholder-text"})],O.prototype,"placeholderText",2),o([d({type:String,attribute:"data-patternmask-message"})],O.prototype,"dataPatternmaskMessage",2),o([C()],O.prototype,"_value",2),O=o([f("qti-text-entry-interaction")],O);var Ne=class extends x{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get value(){return this._base64}set value(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...x.properties}}render(){return h`
811
811
  <div>
812
812
  <slot name="prompt"></slot>
813
813
  <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
814
814
  </div>
815
- `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>i(r.error),r.readAsDataURL(e)})}};He.styles=[b`
815
+ `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,i)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>i(r.error),r.readAsDataURL(e)})}};Ne.styles=[b`
816
816
  :host {
817
817
  display: block;
818
818
  margin: 1em 0;
@@ -821,11 +821,11 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
821
821
  display: block;
822
822
  margin-top: 0.5em;
823
823
  }
824
- `],He=o([f("qti-upload-interaction")],He);var oi=b`
824
+ `],Ne=o([f("qti-upload-interaction")],Ne);var oi=b`
825
825
  :host {
826
826
  display: block;
827
827
  }
828
- `;var Ne=class extends y{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};Ne.styles=oi,Ne=o([f("qti-item-body")],Ne);var $e=class extends y{render(){return h`<slot></slot>`}process(){let s=new dt,e=[...this.children];s.process(e)}};$e.styles=[b`
828
+ `;var He=class extends y{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};He.styles=oi,He=o([f("qti-item-body")],He);var $e=class extends y{render(){return h`<slot></slot>`}process(){let s=new dt,e=[...this.children];s.process(e)}};$e.styles=[b`
829
829
  :host {
830
830
  display: none;
831
831
  }
@@ -878,15 +878,15 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
878
878
  </qti-set-outcome-value>
879
879
  </qti-response-else>
880
880
  </qti-response-condition>
881
- </qti-response-processing>`;var Ie=class extends y{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(s){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(ai).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(li).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(ni).firstElementChild.firstElementChild);break}}}fragmentFromString(s){return document.createRange().createContextualFragment(s)}};Ie.styles=[b`
881
+ </qti-response-processing>`;var Oe=class extends y{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(s){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(ai).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(li).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(ni).firstElementChild.firstElementChild);break}}}fragmentFromString(s){return document.createRange().createContextualFragment(s)}};Oe.styles=[b`
882
882
  :host {
883
883
  display: none;
884
884
  }
885
- `],Ie=o([f("qti-response-processing")],Ie);var O=class extends y{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};O=o([f("qti-rule")],O);var Ge=class extends O{get childExpression(){return this.firstElementChild}process(){let s=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(s),t;return e.interpolationTable&&(t=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:xe(t)}})),t)}};o([d({type:String})],Ge.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ge);var ut=class extends O{render(){return h`<slot></slot>`}process(){let s=[...this.children];for(let e=0;e<s.length;e++){let t=s[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ut);var ht=class extends O{process(){let s=this.getAttribute("identifier"),e=this.firstElementChild,i=new mt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:s,value:Array.isArray(i)?i.map(r=>xe(r)):xe(i)}}))}},mt=class{constructor(s){this.expression=s}process(){let s=this.expression?this.expression.calculate():null;if(s==null){console.warn("setOutcomeValue: value is null or undefined");return}return s}};customElements.define("qti-set-outcome-value",ht);var Oe=class extends y{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let s=this.getSubRules();for(let e=0;e<s.length;e++)s[e].process()}};customElements.define("qti-response-else",Oe);var Pe=class extends Oe{calculate(){return this.firstElementChild.calculate()}getSubRules(){let s=[];for(let e=1;e<this.children.length;e++)s.push(this.children[e]);return s}};customElements.define("qti-response-if",Pe);var ft=class extends Pe{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",ft);var ci=class extends hi(V){calculate(){return this.calculateChildren(Array.from(this.children))}};function hi(l){return class extends l{calculateChildren(e){return e.map(i=>{let r=i;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=r.calculate(),p=!1;if(typeof a=="string")if(a==="true")p=!0;else if(a==="false")p=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(p=a);return p}).every(i=>typeof i=="boolean"&&i)}}}var Qe=class extends q{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};o([d({type:String,attribute:"base-type"})],Qe.prototype,"baseType",2);customElements.define("qti-base-value",Qe);var gt=class extends V{getResult(){let s=this.getVariables();if(this.children.length===2){let e=s[0],t=s[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,r=t.value;return i.filter(n=>r.includes(n)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",gt);var bt=class extends q{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let s=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===s)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",bt);var et=class extends q{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let r=parseFloat(t.value),a=parseFloat(i.value);if(!isNaN(r)&&!isNaN(a))return this.roundingMode==="significantFigures"?r.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(r*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${r}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};o([d({type:String})],et.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",et);var L=class{static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let i=parseInt(s,10),r=parseInt(e,10);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let i=parseFloat(s),r=parseFloat(e);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=s.split(" ").sort(),r=e.split(" ").sort();if(i.length===2&&r.length===2)return t==="pair"&&(i.sort(),r.sort()),i.join(" ")===r.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${s} 2: ${e}`);break}}return!1}};var tt=class extends q{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):L.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};o([d({type:String})],tt.prototype,"toleranceMode",2);customElements.define("qti-equal",tt);var vt=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",vt);var yt=class extends V{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",yt);var xt=class extends q{getResult(){if(this.children.length===1){let s=this.getVariables();if(!s)return!0;let e=s[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",xt);var Et=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Et);var Ct=class extends V{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Ct);var it=class extends q{getResult(){let s=this.context.variables.find(r=>r.identifier===this.identifier);if(!s)return console.warn(`Response ${this.identifier} can not be found`),null;let e=s.mapping,t=Array.isArray(s.value)?s.value:[s.value],i=0;for(let r of t){let a=e.mapEntries.find(p=>L.compareSingleValues(p.mapKey,r,s.baseType));a==null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};o([d({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var ve=class extends y{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};o([d({attribute:"default-value",type:Number})],ve.prototype,"defaultValue",2),o([d({attribute:"lower-bound",type:Number})],ve.prototype,"lowerBound",2),o([d({attribute:"upper-bound",type:Number})],ve.prototype,"upperBound",2);customElements.define("qti-mapping",ve);var qt=class l extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return l.match(e,t)}return console.error("unexpected number of children in match"),null}static match(s,e){switch(e.cardinality){case"single":return s.value===null?!1:Array.isArray(s.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):L.compareSingleValues(s.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;for(let t=0;t<s.value.length;t++)if(!L.compareSingleValues(e.value[t],s.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let r=null,a=[...s.value];for(let p of a)if(L.compareSingleValues(i,p,e.baseType)){r=p;break}if(r!==null)a.splice(a.indexOf(r),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",qt);var Tt=class extends q{getResult(){let s=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=s;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",Tt);var wt=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return s}};customElements.define("qti-multiple",wt);var Mt=class extends q{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Mt);var St=class extends V{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),r=!1;if(typeof i=="string")if(i==="true")r=!0;else if(i==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(r=i);return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var _t=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return s}};customElements.define("qti-ordered",_t);var Fe=class extends y{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};o([d({type:String})],Fe.prototype,"identifier",2),o([D({context:R,subscribe:!0}),C()],Fe.prototype,"context",2);customElements.define("qti-printed-variable",Fe);var kt=class extends q{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseInt(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",kt);var rt=class extends mi(q){getResult(){return this.calculateChildren(Array.from(this.children))}};function mi(l){return class extends l{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=i.calculate();return Number.isNaN(r)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(r)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",rt);var st=class extends q{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let r=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return L.compareSingleValues(r,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};o([d({type:String,attribute:"case-sensitive"})],st.prototype,"caseSensitive",2);customElements.define("qti-string-match",st);var Rt=class extends q{constructor(){super(),this._expression=new Lt(Array.from(this.children))}getResult(){return this._expression.calculate()}},Lt=class{constructor(s){this.expressions=s}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Rt);var At=class extends q{getResult(){let s=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===s).value}};customElements.define("qti-variable",At);var ot=class extends y{render(){return h`<slot></slot>`}};ot=o([f("qti-content-body")],ot);var P=class extends y{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};P.styles=b`
885
+ `],Oe=o([f("qti-response-processing")],Oe);var I=class extends y{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};I=o([f("qti-rule")],I);var Ge=class extends I{get childExpression(){return this.firstElementChild}process(){let s=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(s),t;return e.interpolationTable&&(t=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:xe(t)}})),t)}};o([d({type:String})],Ge.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ge);var ut=class extends I{render(){return h`<slot></slot>`}process(){let s=[...this.children];for(let e=0;e<s.length;e++){let t=s[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ut);var ht=class extends I{process(){let s=this.getAttribute("identifier"),e=this.firstElementChild,i=new mt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:s,value:Array.isArray(i)?i.map(r=>xe(r)):xe(i)}}))}},mt=class{constructor(s){this.expression=s}process(){let s=this.expression?this.expression.calculate():null;if(s==null){console.warn("setOutcomeValue: value is null or undefined");return}return s}};customElements.define("qti-set-outcome-value",ht);var Ie=class extends y{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let s=this.getSubRules();for(let e=0;e<s.length;e++)s[e].process()}};customElements.define("qti-response-else",Ie);var Pe=class extends Ie{calculate(){return this.firstElementChild.calculate()}getSubRules(){let s=[];for(let e=1;e<this.children.length;e++)s.push(this.children[e]);return s}};customElements.define("qti-response-if",Pe);var ft=class extends Pe{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",ft);var ci=class extends hi(V){calculate(){return this.calculateChildren(Array.from(this.children))}};function hi(l){return class extends l{calculateChildren(e){return e.map(i=>{let r=i;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=r.calculate(),p=!1;if(typeof a=="string")if(a==="true")p=!0;else if(a==="false")p=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(p=a);return p}).every(i=>typeof i=="boolean"&&i)}}}var Qe=class extends q{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};o([d({type:String,attribute:"base-type"})],Qe.prototype,"baseType",2);customElements.define("qti-base-value",Qe);var gt=class extends V{getResult(){let s=this.getVariables();if(this.children.length===2){let e=s[0],t=s[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,r=t.value;return i.filter(n=>r.includes(n)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",gt);var bt=class extends q{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let s=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===s)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",bt);var et=class extends q{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let r=parseFloat(t.value),a=parseFloat(i.value);if(!isNaN(r)&&!isNaN(a))return this.roundingMode==="significantFigures"?r.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(r*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${r}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};o([d({type:String})],et.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",et);var L=class{static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let i=parseInt(s,10),r=parseInt(e,10);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let i=parseFloat(s),r=parseFloat(e);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=s.split(" ").sort(),r=e.split(" ").sort();if(i.length===2&&r.length===2)return t==="pair"&&(i.sort(),r.sort()),i.join(" ")===r.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${s} 2: ${e}`);break}}return!1}};var tt=class extends q{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):L.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};o([d({type:String})],tt.prototype,"toleranceMode",2);customElements.define("qti-equal",tt);var vt=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",vt);var yt=class extends V{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",yt);var xt=class extends q{getResult(){if(this.children.length===1){let s=this.getVariables();if(!s)return!0;let e=s[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",xt);var Et=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Et);var Ct=class extends V{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Ct);var it=class extends q{getResult(){let s=this.context.variables.find(r=>r.identifier===this.identifier);if(!s)return console.warn(`Response ${this.identifier} can not be found`),null;let e=s.mapping,t=Array.isArray(s.value)?s.value:[s.value],i=0;for(let r of t){let a=e.mapEntries.find(p=>L.compareSingleValues(p.mapKey,r,s.baseType));a==null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};o([d({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var ve=class extends y{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};o([d({attribute:"default-value",type:Number})],ve.prototype,"defaultValue",2),o([d({attribute:"lower-bound",type:Number})],ve.prototype,"lowerBound",2),o([d({attribute:"upper-bound",type:Number})],ve.prototype,"upperBound",2);customElements.define("qti-mapping",ve);var qt=class l extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return l.match(e,t)}return console.error("unexpected number of children in match"),null}static match(s,e){switch(e.cardinality){case"single":return s.value===null?!1:Array.isArray(s.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):L.compareSingleValues(s.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;for(let t=0;t<s.value.length;t++)if(!L.compareSingleValues(e.value[t],s.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let r=null,a=[...s.value];for(let p of a)if(L.compareSingleValues(i,p,e.baseType)){r=p;break}if(r!==null)a.splice(a.indexOf(r),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",qt);var wt=class extends q{getResult(){let s=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=s;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",wt);var Tt=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return s}};customElements.define("qti-multiple",Tt);var Mt=class extends q{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Mt);var St=class extends V{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),r=!1;if(typeof i=="string")if(i==="true")r=!0;else if(i==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(r=i);return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var _t=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return s}};customElements.define("qti-ordered",_t);var Fe=class extends y{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};o([d({type:String})],Fe.prototype,"identifier",2),o([D({context:R,subscribe:!0}),C()],Fe.prototype,"context",2);customElements.define("qti-printed-variable",Fe);var kt=class extends q{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseInt(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",kt);var rt=class extends mi(q){getResult(){return this.calculateChildren(Array.from(this.children))}};function mi(l){return class extends l{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=i.calculate();return Number.isNaN(r)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(r)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",rt);var st=class extends q{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let r=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return L.compareSingleValues(r,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};o([d({type:String,attribute:"case-sensitive"})],st.prototype,"caseSensitive",2);customElements.define("qti-string-match",st);var Rt=class extends q{constructor(){super(),this._expression=new Lt(Array.from(this.children))}getResult(){return this._expression.calculate()}},Lt=class{constructor(s){this.expressions=s}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Rt);var At=class extends q{getResult(){let s=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===s).value}};customElements.define("qti-variable",At);var ot=class extends y{render(){return h`<slot></slot>`}};ot=o([f("qti-content-body")],ot);var P=class extends y{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};P.styles=b`
886
886
  :host {
887
887
  display: block;
888
888
  }
889
- `,o([d({type:String})],P.prototype,"id",2),o([d({type:String})],P.prototype,"use",2),o([d({type:String})],P.prototype,"view",2),o([d({type:String,attribute:"class"})],P.prototype,"classNames",2),o([w("classNames",{waitUntilFirstUpdate:!0})],P.prototype,"handleclassNamesChange",1),P=o([f("qti-rubric-block")],P);var nt=class extends y{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let r=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};nt=o([f("qti-stylesheet")],nt);var re=class extends y{render(){return h`<slot></slot>`}defaultValues(s){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||s.cardinality==="multiple"||s.cardinality==="ordered"?t:t[0]}};re=o([f("qti-variabledeclaration")],re);var F=class extends re{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(i.getAttribute("source-value")),a=parseInt(i.getAttribute("target-value"));(isNaN(r)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(r,a)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};F.styles=[b`
889
+ `,o([d({type:String})],P.prototype,"id",2),o([d({type:String})],P.prototype,"use",2),o([d({type:String})],P.prototype,"view",2),o([d({type:String,attribute:"class"})],P.prototype,"classNames",2),o([T("classNames",{waitUntilFirstUpdate:!0})],P.prototype,"handleclassNamesChange",1),P=o([f("qti-rubric-block")],P);var nt=class extends y{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let r=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};nt=o([f("qti-stylesheet")],nt);var re=class extends y{render(){return h`<slot></slot>`}defaultValues(s){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||s.cardinality==="multiple"||s.cardinality==="ordered"?t:t[0]}};re=o([f("qti-variabledeclaration")],re);var F=class extends re{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(i.getAttribute("source-value")),a=parseInt(i.getAttribute("target-value"));(isNaN(r)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(r,a)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};F.styles=[b`
890
890
  :host {
891
891
  display: none;
892
892
  }
@@ -894,7 +894,7 @@ import{a as ne,b as W,c as ae,e as le,f as K,g as $t,h as It,i as Be,j as Ot}fro
894
894
  :host {
895
895
  display: none;
896
896
  }
897
- `],o([d({type:String,attribute:"base-type"})],j.prototype,"baseType",2),o([d({type:String})],j.prototype,"identifier",2),o([d({type:String})],j.prototype,"cardinality",2),o([D({context:R,subscribe:!0}),C()],j.prototype,"itemContext",2),j=o([f("qti-response-declaration")],j);export{M as a,ce as b,Xe as c,ye as d,Ce as e,qe as f,Te as g,we as h,pe as i,de as j,Y as k,Z as l,_ as m,ue as n,Me as o,he as p,me as q,U as r,Se as s,_e as t,ge as u,ke as v,Ke as w,Re as x,ee as y,Ae as z,te as A,B,De as C,X as D,se as E,Je as F,Ve as G,ie as H,be as I,$ as J,I as K,He as L,Ne as M,$e as N,dt as O,Ze as P,Ie as Q,O as R,Ge as S,ut as T,ht as U,mt as V,Oe as W,Pe as X,ft as Y,ci as Z,hi as _,Qe as $,gt as aa,bt as ba,et as ca,tt as da,vt as ea,yt as fa,xt as ga,Et as ha,Ct as ia,it as ja,ve as ka,qt as la,Tt as ma,wt as na,Mt as oa,St as pa,_t as qa,Fe as ra,kt as sa,rt as ta,mi as ua,st as va,Rt as wa,Lt as xa,At as ya,ot as za,P as Aa,nt as Ba,F as Ca,j as Da};
897
+ `],o([d({type:String,attribute:"base-type"})],j.prototype,"baseType",2),o([d({type:String})],j.prototype,"identifier",2),o([d({type:String})],j.prototype,"cardinality",2),o([D({context:R,subscribe:!0}),C()],j.prototype,"itemContext",2),j=o([f("qti-response-declaration")],j);export{M as a,ce as b,Xe as c,ye as d,Ce as e,qe as f,we as g,Te as h,pe as i,de as j,Y as k,Z as l,_ as m,ue as n,Me as o,he as p,me as q,U as r,Se as s,_e as t,ge as u,ke as v,Ke as w,Re as x,ee as y,Ae as z,te as A,B,De as C,X as D,se as E,Je as F,Ve as G,ie as H,be as I,$ as J,O as K,Ne as L,He as M,$e as N,dt as O,Ze as P,Oe as Q,I as R,Ge as S,ut as T,ht as U,mt as V,Ie as W,Pe as X,ft as Y,ci as Z,hi as _,Qe as $,gt as aa,bt as ba,et as ca,tt as da,vt as ea,yt as fa,xt as ga,Et as ha,Ct as ia,it as ja,ve as ka,qt as la,wt as ma,Tt as na,Mt as oa,St as pa,_t as qa,Fe as ra,kt as sa,rt as ta,mi as ua,st as va,Rt as wa,Lt as xa,At as ya,ot as za,P as Aa,nt as Ba,F as Ca,j as Da};
898
898
  /*! Bundled license information:
899
899
 
900
900
  lit-html/node/directives/if-defined.js:
@@ -0,0 +1 @@
1
+ import{b as s,c as n}from"./chunk-5GCSZ3CH.js";import{i}from"./chunk-LZZB4VGC.js";import{a as r}from"./chunk-IAP2CEE7.js";var e=class extends i{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}reportValidity(){return this._internals.reportValidity()}reset(){this.value=""}get correctResponse(){return this._correctResponse}set correctResponse(t){this._correctResponse=t}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(t){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(t)?[...t]:t}}))}};e.formAssociated=!0,r([s({type:String,attribute:"response-identifier"})],e.prototype,"responseIdentifier",2),r([s({reflect:!0,type:Boolean})],e.prototype,"disabled",2),r([s({reflect:!0,type:Boolean})],e.prototype,"readonly",2),r([n()],e.prototype,"_correctResponse",2);export{e as a};