@citolab/qti-components 7.0.6-beta.4 → 7.0.6-beta.5

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 (43) hide show
  1. package/cdn/chunks/chunk-EFU4L43Q.js +8 -0
  2. package/cdn/chunks/chunk-RIXTWE2H.js +8 -0
  3. package/cdn/chunks/chunk-ROZIP5LG.js +8 -0
  4. package/cdn/chunks/chunk-RPZVSBLM.js +8 -0
  5. package/cdn/chunks/chunk-TEYXRLTI.js +8 -0
  6. package/cdn/chunks/{chunk-SXM25YH3.js → chunk-U2TE6TOV.js} +12 -12
  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-end-attempt.js +1 -1
  13. package/cdn/qti-test/components/test-item-link.js +1 -1
  14. package/cdn/qti-test/components/test-next.js +1 -1
  15. package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
  16. package/cdn/qti-test/components/test-prev.js +1 -1
  17. package/cdn/qti-test/components/test-show-correct-response.js +1 -1
  18. package/cdn/qti-test/components/test-view.js +1 -1
  19. package/dist/chunks/{chunk-MEQM6M67.js → chunk-6PAEJQSQ.js} +23 -28
  20. package/dist/chunks/chunk-6PAEJQSQ.js.map +1 -0
  21. package/dist/index.js +16 -16
  22. package/dist/qti-components/index.js +1 -1
  23. package/dist/qti-test/components/index.js +7 -7
  24. package/dist/qti-test/components/test-component.abstract.js +1 -1
  25. package/dist/qti-test/components/test-end-attempt.js +3 -3
  26. package/dist/qti-test/components/test-item-link.js +3 -3
  27. package/dist/qti-test/components/test-next.js +3 -3
  28. package/dist/qti-test/components/test-paging-buttons-stamp.js +1 -1
  29. package/dist/qti-test/components/test-prev.js +3 -3
  30. package/dist/qti-test/components/test-show-correct-response.js +3 -3
  31. package/dist/qti-test/components/test-view.js +1 -1
  32. package/package.json +1 -1
  33. package/dist/chunks/chunk-4MQV5IRV.js +0 -59
  34. package/dist/chunks/chunk-4MQV5IRV.js.map +0 -1
  35. package/dist/chunks/chunk-5RTLOB3Q.js +0 -59
  36. package/dist/chunks/chunk-5RTLOB3Q.js.map +0 -1
  37. package/dist/chunks/chunk-MEQM6M67.js.map +0 -1
  38. package/dist/chunks/chunk-NHA53UTY.js +0 -52
  39. package/dist/chunks/chunk-NHA53UTY.js.map +0 -1
  40. package/dist/chunks/chunk-VAPB5TN4.js +0 -46
  41. package/dist/chunks/chunk-VAPB5TN4.js.map +0 -1
  42. package/dist/chunks/chunk-Z5THRO6Z.js +0 -46
  43. package/dist/chunks/chunk-Z5THRO6Z.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ import{b as i,c as n}from"./chunk-L4CUWIE6.js";import{a as r}from"./chunk-PPWEIKLT.js";import{a as m}from"./chunk-5GCSZ3CH.js";import{a as t,d as o}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var e=class extends r{_processResponse(){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._testContext.navItemId}"]`).assessmentItem.processResponse()}constructor(){super(),this.addEventListener("click",()=>this._processResponse())}render(){return o` <slot></slot> `}};e.styles=t`
2
+ :host {
3
+ ${i};
4
+ }
5
+ :host([disabled]) {
6
+ ${n};
7
+ }
8
+ `,e=s([m("test-end-attempt")],e);export{e as a};
@@ -0,0 +1,8 @@
1
+ import{b as i,c as n}from"./chunk-L4CUWIE6.js";import{a as o}from"./chunk-PPWEIKLT.js";import{a as r}from"./chunk-5GCSZ3CH.js";import{a as s,d as m}from"./chunk-LZZB4VGC.js";import{a as e}from"./chunk-IAP2CEE7.js";var t=class extends o{_processResponse(){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._testContext.navItemId}"]`).assessmentItem.showCorrectResponse(!0)}constructor(){super(),this.addEventListener("click",()=>this._processResponse())}render(){return m` <slot></slot> `}};t.styles=s`
2
+ :host {
3
+ ${i};
4
+ }
5
+ :host([disabled]) {
6
+ ${n};
7
+ }
8
+ `,t=e([r("test-show-correct-response")],t);export{t as a};
@@ -0,0 +1,8 @@
1
+ import{b as m,c as n}from"./chunk-L4CUWIE6.js";import{a as l}from"./chunk-PPWEIKLT.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))}_requestItem(d){this.dispatchEvent(new CustomEvent("qti-request-test-item",{composed:!0,bubbles:!0,detail:d}))}render(){return r` <slot></slot> `}};t.styles=s`
2
+ :host {
3
+ ${m};
4
+ }
5
+ :host([disabled]) {
6
+ ${n};
7
+ }
8
+ `,e([o({type:String,attribute:"item-id"})],t.prototype,"itemId",2),t=e([i("test-item-link")],t);export{t as a};
@@ -0,0 +1,8 @@
1
+ import{b as m,c as o}from"./chunk-L4CUWIE6.js";import{a as l}from"./chunk-PPWEIKLT.js";import{a as r}from"./chunk-5GCSZ3CH.js";import{a as i,d as n}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var e=class extends l{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex+1].identifier)})}willUpdate(t){super.willUpdate(t),t.has("_testContext")&&(this.disabled=!this._testElement||this.itemIndex<0||this.itemIndex>=this.items.length-1)}_requestItem(t){this.dispatchEvent(new CustomEvent("qti-request-test-item",{composed:!0,bubbles:!0,detail:t}))}render(){return n`<slot></slot>`}};e.styles=i`
2
+ :host {
3
+ ${m};
4
+ }
5
+ :host([disabled]) {
6
+ ${o};
7
+ }
8
+ `,e=s([r("test-next")],e);export{e as a};
@@ -0,0 +1,8 @@
1
+ import{b as o,c as m}from"./chunk-L4CUWIE6.js";import{a as l}from"./chunk-PPWEIKLT.js";import{a as r}from"./chunk-5GCSZ3CH.js";import{a as i,d as n}from"./chunk-LZZB4VGC.js";import{a as s}from"./chunk-IAP2CEE7.js";var e=class extends l{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex-1].identifier)})}_requestItem(t){this.dispatchEvent(new CustomEvent("qti-request-test-item",{composed:!0,bubbles:!0,detail:t}))}willUpdate(t){super.willUpdate(t),t.has("_testContext")&&(this.disabled=!this._testElement||this.itemIndex===0||this.itemIndex===-1)}render(){return n`<slot></slot>`}};e.styles=i`
2
+ :host {
3
+ ${o};
4
+ }
5
+ :host([disabled]) {
6
+ ${m};
7
+ }
8
+ `,e=s([r("test-prev")],e);export{e as a};
@@ -1,4 +1,4 @@
1
- import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}from"./chunk-5BR5CJFH.js";import{a as $t}from"./chunk-5FCXUJAG.js";import{a as Ue}from"./chunk-EHK76KRT.js";import{a as M}from"./chunk-XUJ7TXHW.js";import{a as x}from"./chunk-UJP4TGD3.js";import{a as Ht}from"./chunk-KWPDTFYH.js";import{a as V}from"./chunk-RXKI3AO4.js";import{a as C}from"./chunk-X2KBNXRO.js";import{a as h,b as d,c as E,d as Ye,e as Vt}from"./chunk-5GCSZ3CH.js";import{a as f,d as u,e as at,f as ne,g as R,i as v}from"./chunk-LZZB4VGC.js";import{a as L}from"./chunk-QQCGUVEV.js";import{a as Dt,b as D}from"./chunk-FRS2J3OS.js";import{a as n}from"./chunk-IAP2CEE7.js";var S=class extends v{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(o=>o.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(o=>o.identifier===t.identifier);return i?{...t,...i}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(o=>o.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 o=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);o&&(o.value=t.response)}}render(){return u`<slot></slot>`}showCorrectResponse(e){let t=this._context.variables.filter(i=>"correctResponse"in i&&i.correctResponse).map(i=>({responseIdentifier:i.identifier,response:i.correctResponse||""}));for(let{responseIdentifier:i,response:o}of t){let a=this._interactionElements.find(r=>r.getAttribute("response-identifier")===i);a&&(a.correctResponse=e?o:"")}}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(o=>o.identifier!==e?o:{...o,value:i.cardinality==="single"?t:[...o.value,t]})},this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(o=>o.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}))}};n([d({type:String})],S.prototype,"title",2),n([d({type:String})],S.prototype,"identifier",2),n([d({type:String})],S.prototype,"adaptive",2),n([d({type:String})],S.prototype,"timeDependent",2),n([d({type:Boolean})],S.prototype,"disabled",2),n([M("disabled",{waitUntilFirstUpdate:!0})],S.prototype,"_handleDisabledChange",2),n([d({type:Boolean})],S.prototype,"readonly",2),n([M("readonly",{waitUntilFirstUpdate:!0})],S.prototype,"_handleReadonlyChange",2),n([Dt({context:L})],S.prototype,"_context",2),S=n([h("qti-assessment-item")],S);var pe=class extends v{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 o=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);o?await this.updateStimulusRef(o):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await $t().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};n([d({type:String})],pe.prototype,"identifier",2),n([d({type:String})],pe.prototype,"href",2),pe=n([h("qti-assessment-stimulus-ref")],pe);var Xe=class extends v{};Xe=n([h("qti-companion-materials-info")],Xe);var xe=class extends v{render(){return u`<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)}};n([D({context:L,subscribe:!0}),E()],xe.prototype,"_context",2),xe=n([h("qti-custom-operator")],xe);var di=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ee=c=>{if(typeof c=="string")return c;let s=di();return s==="."?c.toLocaleString():c.toString().replace(".","").replace(s,".")};function lt(c){return c==null}function Ce(c){return c.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var _=class extends v{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"}};n([d({type:String,attribute:"show-hide"})],_.prototype,"showHide",2),n([d({type:String,attribute:"outcome-identifier"})],_.prototype,"outcomeIdentifier",2),n([d({type:String})],_.prototype,"identifier",2),n([d({type:String,attribute:!1})],_.prototype,"showStatus",2),n([D({context:L,subscribe:!0}),E()],_.prototype,"_context",2);var qe=class extends _{render(){return u` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};qe.styles=f`
1
+ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}from"./chunk-5BR5CJFH.js";import{a as $t}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-UJP4TGD3.js";import{a as Ht}from"./chunk-KWPDTFYH.js";import{a as V}from"./chunk-RXKI3AO4.js";import{a as C}from"./chunk-X2KBNXRO.js";import{a as h,b as d,c as E,d as Ye,e as Vt}from"./chunk-5GCSZ3CH.js";import{a as f,d as u,e as at,f as ne,g as R,i as v}from"./chunk-LZZB4VGC.js";import{a as L}from"./chunk-QQCGUVEV.js";import{a as Dt,b as D}from"./chunk-FRS2J3OS.js";import{a as n}from"./chunk-IAP2CEE7.js";var S=class extends v{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(o=>o.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(o=>o.identifier===t.identifier);return i?{...t,...i}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(o=>o.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 o=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);o&&(o.value=t.response)}}render(){return u`<slot></slot>`}showCorrectResponse(e){let t=this._context.variables.filter(i=>"correctResponse"in i&&i.correctResponse).map(i=>({responseIdentifier:i.identifier,response:i.correctResponse||""}));for(let{responseIdentifier:i,response:o}of t){let a=this._interactionElements.find(r=>r.getAttribute("response-identifier")===i);a&&(a.correctResponse=e?o:"")}}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(o=>o.identifier!==e?o:{...o,value:i.cardinality==="single"?t:[...o.value,t]})},this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(o=>o.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}))}};n([d({type:String})],S.prototype,"title",2),n([d({type:String})],S.prototype,"identifier",2),n([d({type:String})],S.prototype,"adaptive",2),n([d({type:String})],S.prototype,"timeDependent",2),n([d({type:Boolean})],S.prototype,"disabled",2),n([w("disabled",{waitUntilFirstUpdate:!0})],S.prototype,"_handleDisabledChange",2),n([d({type:Boolean})],S.prototype,"readonly",2),n([w("readonly",{waitUntilFirstUpdate:!0})],S.prototype,"_handleReadonlyChange",2),n([Dt({context:L})],S.prototype,"_context",2),S=n([h("qti-assessment-item")],S);var pe=class extends v{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 o=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);o?await this.updateStimulusRef(o):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await $t().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};n([d({type:String})],pe.prototype,"identifier",2),n([d({type:String})],pe.prototype,"href",2),pe=n([h("qti-assessment-stimulus-ref")],pe);var Xe=class extends v{};Xe=n([h("qti-companion-materials-info")],Xe);var xe=class extends v{render(){return u`<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)}};n([D({context:L,subscribe:!0}),E()],xe.prototype,"_context",2),xe=n([h("qti-custom-operator")],xe);var di=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ee=c=>{if(typeof c=="string")return c;let s=di();return s==="."?c.toLocaleString():c.toString().replace(".","").replace(s,".")};function lt(c){return c==null}function Ce(c){return c.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var _=class extends v{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"}};n([d({type:String,attribute:"show-hide"})],_.prototype,"showHide",2),n([d({type:String,attribute:"outcome-identifier"})],_.prototype,"outcomeIdentifier",2),n([d({type:String})],_.prototype,"identifier",2),n([d({type:String,attribute:!1})],_.prototype,"showStatus",2),n([D({context:L,subscribe:!0}),E()],_.prototype,"_context",2);var qe=class extends _{render(){return u` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};qe.styles=f`
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -15,14 +15,14 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
15
15
  .off {
16
16
  display: none;
17
17
  }
18
- `,Te=n([h("qti-feedback-inline")],Te);var we=class extends _{render(){return u`
18
+ `,Te=n([h("qti-feedback-inline")],Te);var Me=class extends _{render(){return u`
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())}};we.styles=f`
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())}};Me.styles=f`
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 ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
71
71
  display: inline-block;
72
72
  line-height: 1.5;
73
73
  }
74
- `,we=n([h("qti-modal-feedback")],we);var Me=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return u` <slot name="drags"></slot> `}};Me.styles=f`
74
+ `,Me=n([h("qti-modal-feedback")],Me);var we=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return u` <slot name="drags"></slot> `}};we.styles=f`
75
75
  :host {
76
76
  display: flex;
77
77
  user-select: none;
78
78
  position: absolute;
79
79
  }
80
- `,Me=n([h("qti-associable-hotspot")],Me);var Pt=(c,s,e)=>{class t extends c{}return t};var H=(c,s,e,t)=>{class i extends Pt(c,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.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(r,l){this.data[r]=l},getData(r){return this.data[r]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(r,l)=>{for(let m of l)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 r)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 p=0;this.draggables.forEach(m=>{m.style.viewTransitionName=`drag-${p}-${this.getAttribute("identifier")||crypto.randomUUID()}`,m.setAttribute("qti-draggable","true"),p++})};this.droppablesModified=(r,l)=>{for(let p of l)this.droppables.includes(p)&&(this.droppables=this.droppables.filter(m=>m!==p),this.allDropzones=this.allDropzones.filter(m=>m!==p));for(let p of r)this.droppables.includes(p)||(this.droppables.push(p),this.allDropzones.push(p));for(let p of this.droppables)this.dataset.choicesContainerWidth&&(p.style.width=`${this.dataset.choicesContainerWidth}px`,p.style.boxSizing="border-box")}}handleDraggableContainerChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.dragContainersModified(r||[],l||[])}dragContainersModified(r,l){for(let p of l)this.dragContainers.includes(p)&&(this.dragContainers=this.dragContainers.filter(m=>m!==p),this.allDropzones=this.allDropzones.filter(m=>m!==p));for(let p of r)this.dragContainers.includes(p)||(this.dragContainers.push(p),this.allDropzones.push(p))}handleDraggablesChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.draggablesModified(r||[],l||[])}handleDroppablesChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.droppablesModified(r||[],l||[])}firstUpdated(r){super.firstUpdated(r),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 p=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(p,[]),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(y=>this.resizeObserver?.observe(y))}async moveDraggableToDroppable(r,l){(()=>{r.style.transform="translate(0, 0)",l.tagName==="SLOT"?r.setAttribute("slot",l.getAttribute("name")):l.appendChild(r),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(r){this.dragContainers.includes(r)?(this._internals.states.add("--dragzone-active"),r.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),r.setAttribute("active",""))}deactivateDroppable(r,l=!0){l&&this._internals.states.add("--dragzone-active"),r.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let r=this.querySelectorAll(s),l=Array.from(this.querySelectorAll(e)).map(b=>b),p=0,m=0;r.forEach(b=>{let y=b.getBoundingClientRect();p=Math.max(p,y.height),m=Math.max(m,y.width)});let g=this.querySelector(t)||this.shadowRoot?.querySelector(t);g&&(g.style.minHeight=`${p}px`,g.style.minWidth=`${m}px`);for(let b of l)b.style.minHeight=`${p}px`,b.style.minWidth=`${m}px`}activateDroppables(r){this.dragContainers.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(r)||p.shadowRoot&&p.shadowRoot.contains(r))&&p.removeAttribute("disabled")}),this.droppables.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(r)||p.shadowRoot&&p.shadowRoot.contains(r))&&p.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.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(r){if(this.isDraggable&&this.dragClone){let{x:l,y:p}=this.getEventCoordinates(r),m={clientX:l,clientY:p};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"),r.preventDefault()}}handleTouchEnd(r){this.isDragging&&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.draggables.forEach(l=>{l.removeAttribute("dragging")}),r.preventDefault()}handleTouchCancel(r){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let r=this.getValidAssociations(),l=!0,p="";this.maxAssociations>0&&r>this.maxAssociations?(l=!1,p=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&r<this.minAssociations&&(l=!1,p=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let m=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},p,m),this.reportValidity(),l}reportValidity(){let r=this.shadowRoot.querySelector("#validationMessage");return r&&(this._internals.validity.valid?(r.textContent="",r.style.display="none"):(r.textContent=this._internals.validationMessage,r.style.display="block")),this._internals.validity.valid}checkMaxAssociations(r){let l=this.getMatchMaxValue(r),p=r.querySelectorAll('[qti-draggable="true"]').length;return l===0||p>=l}resetDragState(){if(this.dragClone){let r=this.currentDropTarget!==null,l=!r||this.dragContainers.includes(this.currentDropTarget);if(r&&this.currentDropTarget&&!l){let p=this.dragSource.cloneNode(!0);p.removeAttribute("style"),this.currentDropTarget.appendChild(p),this.draggablesModified([p],[])}l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto"),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){this.droppables.forEach(r=>{this.checkMaxAssociations(r)?this.disableDroppable(r):this.enableDroppable(r)})}getMatchMaxValue(r){let l=r.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(r){r.setAttribute("disabled","")}enableDroppable(r){r.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(r){if(!this.isMatchTabular())if(Array.isArray(r)){r?.forEach(p=>this.placeResponse(p));let l=new FormData;r.forEach(p=>{l.append(this.responseIdentifier,p)}),this._internals.setFormValue(l)}else this._internals.setFormValue(r||"")}placeResponse(r){let[l,...p]=r.split(" ").reverse(),m=this.findDroppableById(l);p.forEach(g=>this.placeDraggableInDroppable(g,m))}findDroppableById(r){return this.droppables.find(l=>l.getAttribute("identifier")===r)}async placeDraggableInDroppable(r,l){let p=this.querySelector(`[identifier=${r}]`);if(!l||!p){console.error(`Cannot find draggable or droppable with the given identifier: ${r}`);return}let m=()=>{p.style.transform="translate(0, 0)",l.appendChild(p),this.checkAllMaxAssociations()};document.startViewTransition?await document.startViewTransition(m).finished:m()}getValidAssociations(){return this.droppables.filter(r=>r.childElementCount>0).length}saveResponse(){let r=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:r}}))}collectResponseData(){return this.droppables.map(l=>{let p=l.querySelectorAll('[qti-draggable="true"]'),m=Array.from(p).map(b=>b.getAttribute("identifier")),g=l.getAttribute("identifier");return m.map(b=>`${b} ${g}`)}).flat()}reset(r=!0){r&&this.saveResponse()}updateDragClonePosition(r){if(!this.isDragging||!this.dragClone)return;let l=r.clientX-this.cloneOffset.x,p=r.clientY-this.cloneOffset.y,{newLeft:m,newTop:g}=this.applyInteractionBoundaries(l,p,this.dragClone);this.dragClone.style.left=`${m}px`,this.dragClone.style.top=`${g}px`}applyInteractionBoundaries(r,l,p){let m=this.getBoundingClientRect(),g=p.getBoundingClientRect(),b=g.width,y=g.height,T=Math.max(m.left,Math.min(r,m.right-b)),q=Math.max(m.top,Math.min(l,m.bottom-y));return{newLeft:T,newTop:q}}getEventCoordinates(r,l=!1){let p=r.touches?r.touches[0]:r;return{x:l?p.pageX:p.clientX,y:l?p.pageY:p.clientY}}calculateDragDistance(r){let l=Math.abs(r.clientX-this.touchStartPoint.x),p=Math.abs(r.clientY-this.touchStartPoint.y);return l+p}findClosestDropzone(){let r=this.allDropzones.filter(g=>!g.hasAttribute("disabled"));if(!this.dragClone||r.length===0)return null;let l=this.dragClone.getBoundingClientRect(),p=null,m=0;for(let g of r){let b=g.getBoundingClientRect(),y=this.calculateOverlapArea(l,b);y>m&&(m=y,p=g)}if(!p){let g=200;for(let b of r){let y=b.getBoundingClientRect(),T=Math.sqrt(Math.pow(l.left-y.left,2)+Math.pow(l.top-y.top,2));T<g&&(g=T,p=b)}}return p}calculateOverlapArea(r,l){let p=Math.max(0,Math.min(r.right,l.right)-Math.max(r.left,l.left)),m=Math.max(0,Math.min(r.bottom,l.bottom)-Math.max(r.top,l.top));return p*m}dispatchCustomEvent(r,l,p=!0){if(!r)return;let m=new CustomEvent(l,{bubbles:p,cancelable:!0});m.dataTransfer=this.dataTransfer,r.dispatchEvent(m)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(r){if(this.isDragging)return;let{x:l,y:p}=this.getEventCoordinates(r);this.touchStartPoint={x:l,y:p},this.dragSource=r.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let m=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),g=this.droppables.some(w=>Array.from(w.children).some(oe=>oe===this.dragSource)),b=this.dragSource.getBoundingClientRect();g&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=m),this.cloneOffset.x=l-b.left,this.cloneOffset.y=p-b.top,this.dragClone=m.cloneNode(!0);let y=window.getComputedStyle(m);for(let w=0;w<y.length;w++){let oe=y[w];this.dragClone.style.setProperty(oe,y.getPropertyValue(oe))}let T=m.getBoundingClientRect();this.dragClone.style.width=`${T.width}px`,this.dragClone.style.height=`${T.height}px`,b&&this.setDragCloneStyles(b),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let q=this.getMatchMaxValue(this.dragSource),re=this.draggables.filter(w=>w.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));q!==0&&re.length>=q?(m.style.opacity="0.0",m.style.pointerEvents="none"):m.style.opacity="1.0",r.preventDefault(),this.dragClone.setAttribute("dragging","")}findParentInteractionElement(r){let l=r.parentElement;for(;l&&!l.tagName?.toLowerCase().endsWith("-interaction");)l=l.parentElement;return l}findDraggableInDraggableContainer(r){let l=this.dragContainers.flat();for(let p of l){if(p.getAttribute("identifier")===r)return p;let m;p instanceof HTMLSlotElement?m=Array.from(p?.assignedElements()||[]):m=Array.from(p.querySelectorAll(s));let g=m.find(b=>b.getAttribute("identifier")===r);if(g)return g}}setDragCloneStyles(r){this.dragClone.style.position="fixed",this.dragClone.style.top=`${r.top}px`,this.dragClone.style.left=`${r.left}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 n([d({attribute:!1,type:Object})],i.prototype,"configuration",2),n([d({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),n([d({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),n([Ue(t)],i.prototype,"handleDraggableContainerChange",1),n([Ue(s)],i.prototype,"handleDraggablesChange",1),n([Ue(e)],i.prototype,"handleDroppablesChange",1),i};var Ft=f`
80
+ `,we=n([h("qti-associable-hotspot")],we);var Pt=(c,s,e)=>{class t extends c{}return t};var H=(c,s,e,t)=>{class i extends Pt(c,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.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(r,l){this.data[r]=l},getData(r){return this.data[r]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(r,l)=>{for(let m of l)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 r)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 p=0;this.draggables.forEach(m=>{m.style.viewTransitionName=`drag-${p}-${this.getAttribute("identifier")||crypto.randomUUID()}`,m.setAttribute("qti-draggable","true"),p++})};this.droppablesModified=(r,l)=>{for(let p of l)this.droppables.includes(p)&&(this.droppables=this.droppables.filter(m=>m!==p),this.allDropzones=this.allDropzones.filter(m=>m!==p));for(let p of r)this.droppables.includes(p)||(this.droppables.push(p),this.allDropzones.push(p));for(let p of this.droppables)this.dataset.choicesContainerWidth&&(p.style.width=`${this.dataset.choicesContainerWidth}px`,p.style.boxSizing="border-box")}}handleDraggableContainerChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.dragContainersModified(r||[],l||[])}dragContainersModified(r,l){for(let p of l)this.dragContainers.includes(p)&&(this.dragContainers=this.dragContainers.filter(m=>m!==p),this.allDropzones=this.allDropzones.filter(m=>m!==p));for(let p of r)this.dragContainers.includes(p)||(this.dragContainers.push(p),this.allDropzones.push(p))}handleDraggablesChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.draggablesModified(r||[],l||[])}handleDroppablesChange(r,l){this.isMatchTabular()||(r.length>0||l.length>0)&&this.droppablesModified(r||[],l||[])}firstUpdated(r){super.firstUpdated(r),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 p=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(p,[]),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(y=>this.resizeObserver?.observe(y))}async moveDraggableToDroppable(r,l){(()=>{r.style.transform="translate(0, 0)",l.tagName==="SLOT"?r.setAttribute("slot",l.getAttribute("name")):l.appendChild(r),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(r){this.dragContainers.includes(r)?(this._internals.states.add("--dragzone-active"),r.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),r.setAttribute("active",""))}deactivateDroppable(r,l=!0){l&&this._internals.states.add("--dragzone-active"),r.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let r=this.querySelectorAll(s),l=Array.from(this.querySelectorAll(e)).map(b=>b),p=0,m=0;r.forEach(b=>{let y=b.getBoundingClientRect();p=Math.max(p,y.height),m=Math.max(m,y.width)});let g=this.querySelector(t)||this.shadowRoot?.querySelector(t);g&&(g.style.minHeight=`${p}px`,g.style.minWidth=`${m}px`);for(let b of l)b.style.minHeight=`${p}px`,b.style.minWidth=`${m}px`}activateDroppables(r){this.dragContainers.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(r)||p.shadowRoot&&p.shadowRoot.contains(r))&&p.removeAttribute("disabled")}),this.droppables.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(r)||p.shadowRoot&&p.shadowRoot.contains(r))&&p.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.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(r){if(this.isDraggable&&this.dragClone){let{x:l,y:p}=this.getEventCoordinates(r),m={clientX:l,clientY:p};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"),r.preventDefault()}}handleTouchEnd(r){this.isDragging&&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.draggables.forEach(l=>{l.removeAttribute("dragging")}),r.preventDefault()}handleTouchCancel(r){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let r=this.getValidAssociations(),l=!0,p="";this.maxAssociations>0&&r>this.maxAssociations?(l=!1,p=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&r<this.minAssociations&&(l=!1,p=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let m=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},p,m),this.reportValidity(),l}reportValidity(){let r=this.shadowRoot.querySelector("#validationMessage");return r&&(this._internals.validity.valid?(r.textContent="",r.style.display="none"):(r.textContent=this._internals.validationMessage,r.style.display="block")),this._internals.validity.valid}checkMaxAssociations(r){let l=this.getMatchMaxValue(r),p=r.querySelectorAll('[qti-draggable="true"]').length;return l===0||p>=l}dropDraggableInDroppable(r,l){let p=r.cloneNode(!0);p.removeAttribute("style"),this.moveDraggableToDroppable(p,l),this.draggablesModified([p],[]);let m=this.getMatchMaxValue(r),g=this.draggables.filter(b=>b.getAttribute("identifier")===r.getAttribute("identifier"));m!==0&&g.length>=m?(r.style.opacity="0.0",r.style.pointerEvents="none"):r.style.opacity="1.0"}resetDragState(){if(this.dragClone){let r=this.currentDropTarget!==null,l=!r||this.dragContainers.includes(this.currentDropTarget);r&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto"),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){this.droppables.forEach(r=>{this.checkMaxAssociations(r)?this.disableDroppable(r):this.enableDroppable(r)})}getMatchMaxValue(r){let l=r.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(r){r.setAttribute("disabled","")}enableDroppable(r){r.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(r){if(!this.isMatchTabular())if(Array.isArray(r)){r?.forEach(p=>this.placeResponse(p));let l=new FormData;r.forEach(p=>{l.append(this.responseIdentifier,p)}),this._internals.setFormValue(l)}else this._internals.setFormValue(r||"")}placeResponse(r){let[l,...p]=r.split(" ").reverse();p.forEach(m=>{let g=this.querySelector(`[identifier=${m}]`),b=this.querySelector(`[identifier=${l}]`);this.dropDraggableInDroppable(g,b)})}getValidAssociations(){return this.droppables.filter(r=>r.childElementCount>0).length}saveResponse(){let r=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:r}}))}collectResponseData(){return this.droppables.map(l=>{let p=l.querySelectorAll('[qti-draggable="true"]'),m=Array.from(p).map(b=>b.getAttribute("identifier")),g=l.getAttribute("identifier");return m.map(b=>`${b} ${g}`)}).flat()}reset(r=!0){r&&this.saveResponse()}updateDragClonePosition(r){if(!this.isDragging||!this.dragClone)return;let l=r.clientX-this.cloneOffset.x,p=r.clientY-this.cloneOffset.y,{newLeft:m,newTop:g}=this.applyInteractionBoundaries(l,p,this.dragClone);this.dragClone.style.left=`${m}px`,this.dragClone.style.top=`${g}px`}applyInteractionBoundaries(r,l,p){let m=this.getBoundingClientRect(),g=p.getBoundingClientRect(),b=g.width,y=g.height,T=Math.max(m.left,Math.min(r,m.right-b)),q=Math.max(m.top,Math.min(l,m.bottom-y));return{newLeft:T,newTop:q}}getEventCoordinates(r,l=!1){let p=r.touches?r.touches[0]:r;return{x:l?p.pageX:p.clientX,y:l?p.pageY:p.clientY}}calculateDragDistance(r){let l=Math.abs(r.clientX-this.touchStartPoint.x),p=Math.abs(r.clientY-this.touchStartPoint.y);return l+p}findClosestDropzone(){let r=this.allDropzones.filter(g=>!g.hasAttribute("disabled"));if(!this.dragClone||r.length===0)return null;let l=this.dragClone.getBoundingClientRect(),p=null,m=0;for(let g of r){let b=g.getBoundingClientRect(),y=this.calculateOverlapArea(l,b);y>m&&(m=y,p=g)}if(!p){let g=200;for(let b of r){let y=b.getBoundingClientRect(),T=Math.sqrt(Math.pow(l.left-y.left,2)+Math.pow(l.top-y.top,2));T<g&&(g=T,p=b)}}return p}calculateOverlapArea(r,l){let p=Math.max(0,Math.min(r.right,l.right)-Math.max(r.left,l.left)),m=Math.max(0,Math.min(r.bottom,l.bottom)-Math.max(r.top,l.top));return p*m}dispatchCustomEvent(r,l,p=!0){if(!r)return;let m=new CustomEvent(l,{bubbles:p,cancelable:!0});m.dataTransfer=this.dataTransfer,r.dispatchEvent(m)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(r){if(this.isDragging)return;let{x:l,y:p}=this.getEventCoordinates(r);this.touchStartPoint={x:l,y:p},this.dragSource=r.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let m=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),g=this.droppables.some(M=>Array.from(M.children).some(oe=>oe===this.dragSource)),b=this.dragSource.getBoundingClientRect();g&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=m),this.cloneOffset.x=l-b.left,this.cloneOffset.y=p-b.top,this.dragClone=m.cloneNode(!0);let y=window.getComputedStyle(m);for(let M=0;M<y.length;M++){let oe=y[M];this.dragClone.style.setProperty(oe,y.getPropertyValue(oe))}let T=m.getBoundingClientRect();this.dragClone.style.width=`${T.width}px`,this.dragClone.style.height=`${T.height}px`,b&&this.setDragCloneStyles(b),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let q=this.getMatchMaxValue(this.dragSource),re=this.draggables.filter(M=>M.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));q!==0&&re.length>=q?(m.style.opacity="0.0",m.style.pointerEvents="none"):m.style.opacity="1.0",r.preventDefault(),this.dragClone.setAttribute("dragging","")}findParentInteractionElement(r){let l=r.parentElement;for(;l&&!l.tagName?.toLowerCase().endsWith("-interaction");)l=l.parentElement;return l}findDraggableInDraggableContainer(r){let l=this.dragContainers.flat();for(let p of l){if(p.getAttribute("identifier")===r)return p;let m;p instanceof HTMLSlotElement?m=Array.from(p?.assignedElements()||[]):m=Array.from(p.querySelectorAll(s));let g=m.find(b=>b.getAttribute("identifier")===r);if(g)return g}}setDragCloneStyles(r){this.dragClone.style.position="fixed",this.dragClone.style.top=`${r.top}px`,this.dragClone.style.left=`${r.left}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 n([d({attribute:!1,type:Object})],i.prototype,"configuration",2),n([d({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),n([d({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),n([Ue(t)],i.prototype,"handleDraggableContainerChange",1),n([Ue(s)],i.prototype,"handleDraggablesChange",1),n([Ue(e)],i.prototype,"handleDroppablesChange",1),i};var Ft=f`
81
81
  :host {
82
82
  display: block; /* necessary to calculate scaling position */
83
83
  }
@@ -111,7 +111,7 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}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)}};de.styles=Ft,n([E()],de.prototype,"_childrenMap",2),de=n([h("qti-associate-interaction")],de);var K=(c,s)=>{class e extends c{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,a)=>{this._choiceElements.forEach(r=>r.disabled=a)};this._handleReadonlyChange=(o,a)=>{this._choiceElements.forEach(r=>r.readonly=a)};this._value=""}_handleMaxChoicesChange(o,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(o){if(this.maxChoices>1&&(typeof o=="string"||o===null)?this._value=o?o.toString().split(","):[]:this._value=o||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(r=>{a.append(this.responseIdentifier,r)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(o){this._correctResponse=o;let a=Array.isArray(o)?o:[o];this._choiceElements.forEach(r=>{r.internals.states.delete("correct-response"),r.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(r.identifier)?r.internals.states.add("correct-response"):r.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 o=this._choiceElements.filter(p=>this._getChoiceChecked(p)),a=o.length,r=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(r=!1,l=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):a<this.minChoices&&(r=!1,l=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),o.length>0&&this._internals.setValidity(r?{}:{customError:!0},l,o[a-1]||this._choiceElements[0]||this),this.reportValidity(),r}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(o){o.stopPropagation();let a=o.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(o){o.stopPropagation();let a=o.target;this._choiceElements=this._choiceElements.filter(r=>r!==a)}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}_setInputType(o){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";o.internals.role=a,o.internals.states.delete(a==="radio"?"checkbox":"radio"),o.internals.states.add(a)}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==o.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(o,a){o.internals?.states&&(a?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let a=this._getChoiceChecked(o);this._setChoiceChecked(o,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(r=>this._getChoiceChecked(r)).map(r=>r.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let o=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let r=o.includes(a.identifier);this._setChoiceChecked(a,r)})}}return n([Ye("#validationMessage")],e.prototype,"_validationMessageElement",2),n([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),n([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),n([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var je=(c,s)=>{class e extends c{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(o){o.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let o=Array.from(this.querySelectorAll(s)),a=o.filter(b=>b.hasAttribute("fixed")),r=o.filter(b=>!b.hasAttribute("fixed"));if(r.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let l=[...r],p=!1,m=0;for(;!p&&m<10;){m++;for(let b=r.length-1;b>0;b--){let y=Math.floor(Math.random()*(b+1));[r[b],r[y]]=[r[y],r[b]]}p=!r.every((b,y)=>b===l[y])}p||console.warn("Failed to shuffle the choices after multiple attempts.");let g=1;[...a,...r].forEach(b=>{b.style.setProperty("order",String(g++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(o=>{o.style.setProperty("order","initial")})}}return n([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var zt=(c,s)=>{class e extends c{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(o){o&&(this._classes=o.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(o){super.updated(o),o.has("shuffle")&&this._addLabels()}_addLabels(){let o=this._classes.some(r=>this._allLabels.includes(r)||this._allLabelSuffixes.includes(r)),a=r=>!isNaN(+r);if(o){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(p=>p).map((p,m)=>({el:p,order:a(p.style.order)?+p.style.order:m+1})).sort((p,m)=>p.order-m.order).map(p=>p.el);for(let p=0;p<l.length;p++)l[p].marker=this._getLabel(p+1)}}_getLabel(o){let a=this._classes.filter(p=>this._allLabels.includes(p)).pop(),r=this._classes.filter(p=>this._allLabelSuffixes.includes(p)).pop();!a&&r&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${o}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+o-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+o-1)}`;break}return r==="qti-labels-suffix-period"?l+=".":r==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Yt=f`
114
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};de.styles=Ft,n([E()],de.prototype,"_childrenMap",2),de=n([h("qti-associate-interaction")],de);var K=(c,s)=>{class e extends c{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,a)=>{this._choiceElements.forEach(r=>r.disabled=a)};this._handleReadonlyChange=(o,a)=>{this._choiceElements.forEach(r=>r.readonly=a)};this._value=""}_handleMaxChoicesChange(o,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(o){if(this.maxChoices>1&&(typeof o=="string"||o===null)?this._value=o?o.toString().split(","):[]:this._value=o||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(r=>{a.append(this.responseIdentifier,r)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(o){this._correctResponse=o;let a=Array.isArray(o)?o:[o];this._choiceElements.forEach(r=>{r.internals.states.delete("correct-response"),r.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(r.identifier)?r.internals.states.add("correct-response"):r.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 o=this._choiceElements.filter(p=>this._getChoiceChecked(p)),a=o.length,r=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(r=!1,l=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):a<this.minChoices&&(r=!1,l=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),o.length>0&&this._internals.setValidity(r?{}:{customError:!0},l,o[a-1]||this._choiceElements[0]||this),this.reportValidity(),r}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(o){o.stopPropagation();let a=o.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(o){o.stopPropagation();let a=o.target;this._choiceElements=this._choiceElements.filter(r=>r!==a)}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}_setInputType(o){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";o.internals.role=a,o.internals.states.delete(a==="radio"?"checkbox":"radio"),o.internals.states.add(a)}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==o.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(o,a){o.internals?.states&&(a?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let a=this._getChoiceChecked(o);this._setChoiceChecked(o,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(r=>this._getChoiceChecked(r)).map(r=>r.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let o=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let r=o.includes(a.identifier);this._setChoiceChecked(a,r)})}}return n([Ye("#validationMessage")],e.prototype,"_validationMessageElement",2),n([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),n([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),n([w("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([w("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([w("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var je=(c,s)=>{class e extends c{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(o){o.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let o=Array.from(this.querySelectorAll(s)),a=o.filter(b=>b.hasAttribute("fixed")),r=o.filter(b=>!b.hasAttribute("fixed"));if(r.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let l=[...r],p=!1,m=0;for(;!p&&m<10;){m++;for(let b=r.length-1;b>0;b--){let y=Math.floor(Math.random()*(b+1));[r[b],r[y]]=[r[y],r[b]]}p=!r.every((b,y)=>b===l[y])}p||console.warn("Failed to shuffle the choices after multiple attempts.");let g=1;[...a,...r].forEach(b=>{b.style.setProperty("order",String(g++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(o=>{o.style.setProperty("order","initial")})}}return n([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var zt=(c,s)=>{class e extends c{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(o){o&&(this._classes=o.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(o){super.updated(o),o.has("shuffle")&&this._addLabels()}_addLabels(){let o=this._classes.some(r=>this._allLabels.includes(r)||this._allLabelSuffixes.includes(r)),a=r=>!isNaN(+r);if(o){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(p=>p).map((p,m)=>({el:p,order:a(p.style.order)?+p.style.order:m+1})).sort((p,m)=>p.order-m.order).map(p=>p.el);for(let p=0;p<l.length;p++)l[p].marker=this._getLabel(p+1)}}_getLabel(o){let a=this._classes.filter(p=>this._allLabels.includes(p)).pop(),r=this._classes.filter(p=>this._allLabelSuffixes.includes(p)).pop();!a&&r&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${o}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+o-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+o-1)}`;break}return r==="qti-labels-suffix-period"?l+=".":r==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Yt=f`
115
115
  [part='slot'] {
116
116
  display: flex;
117
117
  flex-direction: column;
@@ -198,7 +198,7 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}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")}};k.styles=Ut,n([E()],k.prototype,"_rows",2),n([d({type:Number,attribute:"expected-length"})],k.prototype,"expectedLength",2),n([d({type:String,attribute:"pattern-mask"})],k.prototype,"patternMask",2),n([d({type:String,attribute:"placeholder-text"})],k.prototype,"placeholderText",2),n([d({type:String,attribute:"data-patternmask-message"})],k.prototype,"dataPatternmaskMessage",2),n([E()],k.prototype,"_value",2),n([d({type:String,attribute:"class"})],k.prototype,"classNames",2),n([M("classNames")],k.prototype,"handleclassNamesChange",1),k=n([h("qti-extended-text-interaction")],k);var he=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};he.styles=f`
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")}};k.styles=Ut,n([E()],k.prototype,"_rows",2),n([d({type:Number,attribute:"expected-length"})],k.prototype,"expectedLength",2),n([d({type:String,attribute:"pattern-mask"})],k.prototype,"patternMask",2),n([d({type:String,attribute:"placeholder-text"})],k.prototype,"placeholderText",2),n([d({type:String,attribute:"data-patternmask-message"})],k.prototype,"dataPatternmaskMessage",2),n([E()],k.prototype,"_value",2),n([d({type:String,attribute:"class"})],k.prototype,"classNames",2),n([w("classNames")],k.prototype,"handleclassNamesChange",1),k=n([h("qti-extended-text-interaction")],k);var he=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};he.styles=f`
202
202
  :host {
203
203
  display: flex;
204
204
  user-select: none;
@@ -240,7 +240,7 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
240
240
  `;var Se=class extends H(x,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return u`<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(o=>{let a=o.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(o=>{let a=o.getAttribute("identifier"),r=e.find(p=>p.gap===a)?.text,l=this.querySelector(`qti-gap-text[identifier="${r}"]`)?.textContent.trim();if(r&&l){if(!o.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=l,o.insertAdjacentElement("afterend",p)}}else o.nextElementSibling?.classList.contains("correct-option")&&o.nextElementSibling.remove()})}};Se.styles=Bt,Se=n([h("qti-gap-match-interaction")],Se);var Xt={toAttribute:c=>c?"true":"false",fromAttribute:c=>c==="true"};function $(c,s){class e extends c{constructor(...o){super(...o);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(o,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(o){o.altKey||o.code==="Space"&&(o.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 u`<slot></slot>`}}return n([d({type:String})],e.prototype,"identifier",2),n([d({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),n([d({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Xt})],e.prototype,"disabled",2),n([d({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Xt})],e.prototype,"readonly",2),n([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var me=class extends $(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return u`<slot></slot>`}};me.styles=f`
243
+ <div role="alert" id="validationMessage"></div>`}set correctResponse(s){let e=[],t=Array.isArray(s)?s:[s];t&&(e=t.map(o=>{let a=o.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(o=>{let a=o.getAttribute("identifier"),r=e.find(p=>p.gap===a)?.text,l=this.querySelector(`qti-gap-text[identifier="${r}"]`)?.textContent.trim();if(r&&l){if(!o.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=l,o.insertAdjacentElement("afterend",p)}}else o.nextElementSibling?.classList.contains("correct-option")&&o.nextElementSibling.remove()})}};Se.styles=Bt,Se=n([h("qti-gap-match-interaction")],Se);var Xt={toAttribute:c=>c?"true":"false",fromAttribute:c=>c==="true"};function $(c,s){class e extends c{constructor(...o){super(...o);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(o,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(o){o.altKey||o.code==="Space"&&(o.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 u`<slot></slot>`}}return n([d({type:String})],e.prototype,"identifier",2),n([d({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),n([d({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Xt})],e.prototype,"disabled",2),n([d({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Xt})],e.prototype,"readonly",2),n([w("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var me=class extends $(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return u`<slot></slot>`}};me.styles=f`
244
244
  :host {
245
245
  display: inline-flex;
246
246
  user-select: none;
@@ -250,7 +250,7 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
250
250
  display: flex;
251
251
  user-select: none;
252
252
  }
253
- `,n([d({type:Number,reflect:!0})],fe.prototype,"tabindex",2),fe=n([h("qti-gap")],fe);var jt=(c,s,e)=>{let t=new Map;for(let i=s;i<=e;i++)t.set(c[i],i);return t},We=j(class extends le{constructor(c){if(super(c),c.type!==ae.CHILD)throw Error("repeat() can only be used in text expressions")}dt(c,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let i=[],o=[],a=0;for(let r of c)i[a]=t?t(r,a):a,o[a]=e(r,a),a++;return{values:o,keys:i}}render(c,s,e){return this.dt(c,s,e).values}update(c,[s,e,t]){let i=Ot(c),{values:o,keys:a}=this.dt(s,e,t);if(!Array.isArray(i))return this.ut=a,o;let r=this.ut??(this.ut=[]),l=[],p,m,g=0,b=i.length-1,y=0,T=o.length-1;for(;g<=b&&y<=T;)if(i[g]===null)g++;else if(i[b]===null)b--;else if(r[g]===a[y])l[y]=W(i[g],o[y]),g++,y++;else if(r[b]===a[T])l[T]=W(i[b],o[T]),b--,T--;else if(r[g]===a[T])l[T]=W(i[g],o[T]),ce(c,l[T+1],i[g]),g++,T--;else if(r[b]===a[y])l[y]=W(i[b],o[y]),ce(c,i[g],i[b]),b--,y++;else if(p===void 0&&(p=jt(a,y,T),m=jt(r,g,b)),p.has(r[g]))if(p.has(r[b])){let q=m.get(a[y]),re=q!==void 0?i[q]:null;if(re===null){let w=ce(c,i[g]);W(w,o[y]),l[y]=w}else l[y]=W(re,o[y]),ce(c,i[g],re),i[q]=null;y++}else Be(i[b]),b--;else Be(i[g]),g++;for(;y<=T;){let q=ce(c,l[T+1]);W(q,o[y]),l[y++]=q}for(;g<=b;){let q=i[g++];q!==null&&Be(q)}return this.ut=a,Nt(c,l),ne}});function ge(c,s,e,t){switch(c){case"circle":{let[i,o,a]=s,r=i/e.width*100,l=o/e.height*100,p=a/e.width*100;t.style.left=r-p+"%",t.style.top=l-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[i,o,a,r]=s,l=i/e.width*100,p=o/e.height*100,m=a/e.width*100,g=r/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=m-l+"%",t.style.height=g-p+"%"}break;case"poly":{let i=s.reduce((q,re,w,oe)=>{if(w%2===1){let pi=q.pop();q[q.length]={x:pi,y:oe[w]}}else q.push(re);return q},[]),o=Math.min(...i.map(q=>q.x)),a=Math.max(...i.map(q=>q.x)),r=Math.min(...i.map(q=>q.y)),l=Math.max(...i.map(q=>q.y)),p=o/e.width*100,m=r/e.height*100,g=a/e.width*100,b=l/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=r/e.height*100+"%",t.style.width=g-p+"%",t.style.height=b-m+"%";let T=i.map(q=>({x:(q.x-o)/(a-o)*100,y:(q.y-r)/(l-r)*100})).map(q=>Math.round(q.x)+"% "+Math.round(q.y)+"%").join(",");t.style.clipPath=`polygon(${T})`}break;default:break}}var Wt=f`
253
+ `,n([d({type:Number,reflect:!0})],fe.prototype,"tabindex",2),fe=n([h("qti-gap")],fe);var jt=(c,s,e)=>{let t=new Map;for(let i=s;i<=e;i++)t.set(c[i],i);return t},We=j(class extends le{constructor(c){if(super(c),c.type!==ae.CHILD)throw Error("repeat() can only be used in text expressions")}dt(c,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let i=[],o=[],a=0;for(let r of c)i[a]=t?t(r,a):a,o[a]=e(r,a),a++;return{values:o,keys:i}}render(c,s,e){return this.dt(c,s,e).values}update(c,[s,e,t]){let i=Ot(c),{values:o,keys:a}=this.dt(s,e,t);if(!Array.isArray(i))return this.ut=a,o;let r=this.ut??(this.ut=[]),l=[],p,m,g=0,b=i.length-1,y=0,T=o.length-1;for(;g<=b&&y<=T;)if(i[g]===null)g++;else if(i[b]===null)b--;else if(r[g]===a[y])l[y]=W(i[g],o[y]),g++,y++;else if(r[b]===a[T])l[T]=W(i[b],o[T]),b--,T--;else if(r[g]===a[T])l[T]=W(i[g],o[T]),ce(c,l[T+1],i[g]),g++,T--;else if(r[b]===a[y])l[y]=W(i[b],o[y]),ce(c,i[g],i[b]),b--,y++;else if(p===void 0&&(p=jt(a,y,T),m=jt(r,g,b)),p.has(r[g]))if(p.has(r[b])){let q=m.get(a[y]),re=q!==void 0?i[q]:null;if(re===null){let M=ce(c,i[g]);W(M,o[y]),l[y]=M}else l[y]=W(re,o[y]),ce(c,i[g],re),i[q]=null;y++}else Be(i[b]),b--;else Be(i[g]),g++;for(;y<=T;){let q=ce(c,l[T+1]);W(q,o[y]),l[y++]=q}for(;g<=b;){let q=i[g++];q!==null&&Be(q)}return this.ut=a,Nt(c,l),ne}});function ge(c,s,e,t){switch(c){case"circle":{let[i,o,a]=s,r=i/e.width*100,l=o/e.height*100,p=a/e.width*100;t.style.left=r-p+"%",t.style.top=l-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[i,o,a,r]=s,l=i/e.width*100,p=o/e.height*100,m=a/e.width*100,g=r/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=m-l+"%",t.style.height=g-p+"%"}break;case"poly":{let i=s.reduce((q,re,M,oe)=>{if(M%2===1){let pi=q.pop();q[q.length]={x:pi,y:oe[M]}}else q.push(re);return q},[]),o=Math.min(...i.map(q=>q.x)),a=Math.max(...i.map(q=>q.x)),r=Math.min(...i.map(q=>q.y)),l=Math.max(...i.map(q=>q.y)),p=o/e.width*100,m=r/e.height*100,g=a/e.width*100,b=l/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=r/e.height*100+"%",t.style.width=g-p+"%",t.style.height=b-m+"%";let T=i.map(q=>({x:(q.x-o)/(a-o)*100,y:(q.y-r)/(l-r)*100})).map(q=>Math.round(q.x)+"% "+Math.round(q.y)+"%").join(",");t.style.clipPath=`polygon(${T})`}break;default:break}}var Wt=f`
254
254
  slot:not([name='prompt']) {
255
255
  // position: relative; /* qti-hotspot-choice relative to the slot */
256
256
  display: block;
@@ -882,11 +882,11 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
882
882
  :host {
883
883
  display: none;
884
884
  }
885
- `],Ie=n([h("qti-response-processing")],Ie);var I=class extends v{render(){return u`<slot></slot>`}process(){throw new Error("Not implemented")}};I=n([h("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:Ee(t)}})),t)}};n([d({type:String})],Ge.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ge);var ut=class extends I{render(){return u`<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(o=>Ee(o)):Ee(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 Pe=class extends v{render(){return u`<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",Pe);var Fe=class extends Pe{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",Fe);var ft=class extends Fe{render(){return u`${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(c){return class extends c{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=o.calculate(),r=!1;if(typeof a=="string")if(a==="true")r=!0;else if(a==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(r=a);return r}).every(i=>typeof i=="boolean"&&i)}}}var Qe=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([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,o=t.value;return i.filter(l=>o.includes(l)).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 C{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 C{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 o=parseFloat(t.value),a=parseFloat(i.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*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: ${o}, ${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}};n([d({type:String})],et.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",et);var A=class{static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let i=parseInt(s,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let i=parseFloat(s),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=s.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return t==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.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 C{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):A.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([d({type:String})],tt.prototype,"toleranceMode",2);customElements.define("qti-equal",tt);var vt=class extends C{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 C{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 C{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 C{getResult(){let s=this.context.variables.find(o=>o.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 o of t){let a=e.mapEntries.find(r=>A.compareSingleValues(r.mapKey,o,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}};n([d({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var ye=class extends v{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")}))}};n([d({attribute:"default-value",type:Number})],ye.prototype,"defaultValue",2),n([d({attribute:"lower-bound",type:Number})],ye.prototype,"lowerBound",2),n([d({attribute:"upper-bound",type:Number})],ye.prototype,"upperBound",2);customElements.define("qti-mapping",ye);var qt=class c extends C{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return c.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):A.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(!A.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 o=null,a=[...s.value];for(let r of a)if(A.compareSingleValues(i,r,e.baseType)){o=r;break}if(o!==null)a.splice(a.indexOf(o),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 C{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 C{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 C{render(){return u`${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(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var _t=class extends C{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 ze=class extends v{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return u`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([d({type:String})],ze.prototype,"identifier",2),n([D({context:L,subscribe:!0}),E()],ze.prototype,"context",2);customElements.define("qti-printed-variable",ze);var kt=class extends C{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(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function mi(c){return class extends c{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=i.calculate();return Number.isNaN(o)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(o)});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 C{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 o=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return A.compareSingleValues(o,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([d({type:String,attribute:"case-sensitive"})],st.prototype,"caseSensitive",2);customElements.define("qti-string-match",st);var Rt=class extends C{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 C{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 v{render(){return u`<slot></slot>`}};ot=n([h("qti-content-body")],ot);var P=class extends v{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 u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};P.styles=f`
885
+ `],Ie=n([h("qti-response-processing")],Ie);var I=class extends v{render(){return u`<slot></slot>`}process(){throw new Error("Not implemented")}};I=n([h("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:Ee(t)}})),t)}};n([d({type:String})],Ge.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ge);var ut=class extends I{render(){return u`<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(o=>Ee(o)):Ee(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 Pe=class extends v{render(){return u`<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",Pe);var Fe=class extends Pe{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",Fe);var ft=class extends Fe{render(){return u`${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(c){return class extends c{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=o.calculate(),r=!1;if(typeof a=="string")if(a==="true")r=!0;else if(a==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(r=a);return r}).every(i=>typeof i=="boolean"&&i)}}}var Qe=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([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,o=t.value;return i.filter(l=>o.includes(l)).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 C{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 C{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 o=parseFloat(t.value),a=parseFloat(i.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*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: ${o}, ${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}};n([d({type:String})],et.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",et);var A=class{static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let i=parseInt(s,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let i=parseFloat(s),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=s.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return t==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.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 C{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):A.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([d({type:String})],tt.prototype,"toleranceMode",2);customElements.define("qti-equal",tt);var vt=class extends C{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 C{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 C{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 C{getResult(){let s=this.context.variables.find(o=>o.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 o of t){let a=e.mapEntries.find(r=>A.compareSingleValues(r.mapKey,o,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}};n([d({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var ye=class extends v{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")}))}};n([d({attribute:"default-value",type:Number})],ye.prototype,"defaultValue",2),n([d({attribute:"lower-bound",type:Number})],ye.prototype,"lowerBound",2),n([d({attribute:"upper-bound",type:Number})],ye.prototype,"upperBound",2);customElements.define("qti-mapping",ye);var qt=class c extends C{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return c.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):A.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(!A.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 o=null,a=[...s.value];for(let r of a)if(A.compareSingleValues(i,r,e.baseType)){o=r;break}if(o!==null)a.splice(a.indexOf(o),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 C{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 Mt=class extends C{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",Mt);var wt=class extends C{render(){return u`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",wt);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(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var _t=class extends C{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 ze=class extends v{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return u`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([d({type:String})],ze.prototype,"identifier",2),n([D({context:L,subscribe:!0}),E()],ze.prototype,"context",2);customElements.define("qti-printed-variable",ze);var kt=class extends C{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(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function mi(c){return class extends c{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=i.calculate();return Number.isNaN(o)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(o)});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 C{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 o=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return A.compareSingleValues(o,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([d({type:String,attribute:"case-sensitive"})],st.prototype,"caseSensitive",2);customElements.define("qti-string-match",st);var Rt=class extends C{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 C{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 v{render(){return u`<slot></slot>`}};ot=n([h("qti-content-body")],ot);var P=class extends v{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 u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};P.styles=f`
886
886
  :host {
887
887
  display: block;
888
888
  }
889
- `,n([d({type:String})],P.prototype,"id",2),n([d({type:String})],P.prototype,"use",2),n([d({type:String})],P.prototype,"view",2),n([d({type:String,attribute:"class"})],P.prototype,"classNames",2),n([M("classNames",{waitUntilFirstUpdate:!0})],P.prototype,"handleclassNamesChange",1),P=n([h("qti-rubric-block")],P);var nt=class extends v{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 o=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${o}}`,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=n([h("qti-stylesheet")],nt);var ie=class extends v{render(){return u`<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]}};ie=n([h("qti-variabledeclaration")],ie);var F=class extends ie{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return u`${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 o=parseInt(i.getAttribute("source-value")),a=parseInt(i.getAttribute("target-value"));(isNaN(o)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(o,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=[f`
889
+ `,n([d({type:String})],P.prototype,"id",2),n([d({type:String})],P.prototype,"use",2),n([d({type:String})],P.prototype,"view",2),n([d({type:String,attribute:"class"})],P.prototype,"classNames",2),n([w("classNames",{waitUntilFirstUpdate:!0})],P.prototype,"handleclassNamesChange",1),P=n([h("qti-rubric-block")],P);var nt=class extends v{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 o=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${o}}`,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=n([h("qti-stylesheet")],nt);var ie=class extends v{render(){return u`<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]}};ie=n([h("qti-variabledeclaration")],ie);var F=class extends ie{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return u`${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 o=parseInt(i.getAttribute("source-value")),a=parseInt(i.getAttribute("target-value"));(isNaN(o)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(o,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=[f`
890
890
  :host {
891
891
  display: none;
892
892
  }
@@ -894,7 +894,7 @@ import{a as ae,b as j,c as le,e as ce,f as W,g as Nt,h as Ot,i as Be,j as It}fro
894
894
  :host {
895
895
  display: none;
896
896
  }
897
- `],n([d({type:String,attribute:"base-type"})],X.prototype,"baseType",2),n([d({type:String})],X.prototype,"identifier",2),n([d({type:String})],X.prototype,"cardinality",2),n([D({context:L,subscribe:!0}),E()],X.prototype,"itemContext",2),X=n([h("qti-response-declaration")],X);export{S as a,pe as b,Xe as c,xe as d,qe as e,Te as f,we as g,Me as h,de as i,ue as j,z as k,J as l,k as m,he as n,Se as o,me as p,fe as q,Y as r,_e as s,ke as t,be as u,Re as v,Ke as w,Le as x,Q as y,De as z,ee as A,U as B,Ve as C,B as D,se as E,Je as F,He as G,te as H,ve as I,N as J,O as K,$e as L,Ne as M,Oe as N,dt as O,Ze as P,Ie as Q,I as R,Ge as S,ut as T,ht as U,mt as V,Pe as W,Fe 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,ye as ka,qt as la,Tt as ma,wt as na,Mt as oa,St as pa,_t as qa,ze 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,X as Da};
897
+ `],n([d({type:String,attribute:"base-type"})],X.prototype,"baseType",2),n([d({type:String})],X.prototype,"identifier",2),n([d({type:String})],X.prototype,"cardinality",2),n([D({context:L,subscribe:!0}),E()],X.prototype,"itemContext",2),X=n([h("qti-response-declaration")],X);export{S as a,pe as b,Xe as c,xe as d,qe as e,Te as f,Me as g,we as h,de as i,ue as j,z as k,J as l,k as m,he as n,Se as o,me as p,fe as q,Y as r,_e as s,ke as t,be as u,Re as v,Ke as w,Le as x,Q as y,De as z,ee as A,U as B,Ve as C,B as D,se as E,Je as F,He as G,te as H,ve as I,N as J,O as K,$e as L,Ne as M,Oe as N,dt as O,Ze as P,Ie as Q,I as R,Ge as S,ut as T,ht as U,mt as V,Pe as W,Fe 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,ye as ka,qt as la,Tt as ma,Mt as na,wt as oa,St as pa,_t as qa,ze 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,X as Da};
898
898
  /*! Bundled license information:
899
899
 
900
900
  lit-html/node/directives/if-defined.js: