@citolab/qti-components 7.0.9-beta.0 → 7.0.9-beta.1

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 (42) hide show
  1. package/cdn/chunks/{chunk-GVU44M3E.js → chunk-DKMHSSEK.js} +7 -16
  2. package/cdn/chunks/{chunk-I3HQJPKA.js → chunk-EG3QNAM6.js} +76 -71
  3. package/cdn/chunks/{chunk-LCKLXCUP.js → chunk-I5J4YQIW.js} +7 -16
  4. package/cdn/index.global.js +1 -1
  5. package/cdn/index.js +1 -1
  6. package/cdn/qti-components/index.js +1 -1
  7. package/cdn/qti-item/core/index.js +1 -1
  8. package/cdn/qti-test/components/index.js +1 -1
  9. package/cdn/qti-test/components/test-container.js +1 -1
  10. package/dist/chunks/{chunk-NPHDN2TQ.js → chunk-5E4OEZCA.js} +360 -70
  11. package/dist/chunks/chunk-5E4OEZCA.js.map +1 -0
  12. package/dist/chunks/{chunk-MDWBTFKL.js → chunk-BH5H7BSS.js} +8 -17
  13. package/dist/chunks/{chunk-MDWBTFKL.js.map → chunk-BH5H7BSS.js.map} +1 -1
  14. package/dist/chunks/{chunk-6MW3J6OM.js → chunk-QGPXAPBK.js} +8 -17
  15. package/dist/chunks/{chunk-6MW3J6OM.js.map → chunk-QGPXAPBK.js.map} +1 -1
  16. package/dist/exports/item.context.d.ts +1 -1
  17. package/dist/exports/qti-assessment-item.context.d.ts +1 -1
  18. package/dist/exports/qti-condition-expression.d.ts +1 -1
  19. package/dist/exports/qti-expression.d.ts +1 -1
  20. package/dist/exports/session.context.d.ts +3 -3
  21. package/dist/exports/test.context.d.ts +1 -1
  22. package/dist/exports/variables.d.ts +1 -1
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.js +7 -3
  25. package/dist/item.css +7 -16
  26. package/dist/qti-components/index.d.ts +44 -26
  27. package/dist/qti-components/index.js +5 -1
  28. package/dist/qti-components-jsx.d.ts +32 -0
  29. package/dist/qti-item/core/index.js +1 -1
  30. package/dist/qti-loader/index.d.ts +2 -2
  31. package/dist/{qti-response-declaration-CyOeVboh.d.ts → qti-response-declaration-CESClJ3_.d.ts} +5 -1
  32. package/dist/qti-test/components/index.d.ts +3 -3
  33. package/dist/qti-test/components/index.js +1 -1
  34. package/dist/qti-test/components/test-container.js +1 -1
  35. package/dist/qti-test/components/test-navigation.d.ts +3 -3
  36. package/dist/qti-test/core/index.d.ts +4 -4
  37. package/dist/{qti-test-part-zX9tOUbA.d.ts → qti-test-part-BAM_WUTL.d.ts} +1 -1
  38. package/dist/{variables-cO3DzqJy.d.ts → variables-DNDfraER.d.ts} +14 -1
  39. package/dist/vscode.html-custom-data.json +16 -0
  40. package/package.json +1 -1
  41. package/cdn/chunks/chunk-KGVJXME7.js +0 -934
  42. package/dist/chunks/chunk-NPHDN2TQ.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f as J,g as Nt,h as Ot,i as Be,j as It}from"./chunk-5BR5CJFH.js";import{a as w}from"./chunk-XUJ7TXHW.js";import{a as H}from"./chunk-R45JL2ZY.js";import{a as q}from"./chunk-YIYKK4RV.js";import{a as $t}from"./chunk-5FCXUJAG.js";import{a as E}from"./chunk-UJP4TGD3.js";import{a as m,b as d,c as C,d as Ye,e as Ht}from"./chunk-5GCSZ3CH.js";import{a as b,d as h,e as at,f as ne,g as R,i as v}from"./chunk-LZZB4VGC.js";import{a as Vt}from"./chunk-KWPDTFYH.js";import{a as L}from"./chunk-QQCGUVEV.js";import{a as Dt,b as D}from"./chunk-M5PPZ5M3.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(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:Vt};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(s=>s.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:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),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 r=e.find(s=>s.identifier===t.identifier);return r?{...t,...r}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);r&&(r.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 s=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.value=t.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let t=this._context.variables.filter(r=>"correctResponse"in r&&r.correctResponse).map(r=>({responseIdentifier:r.identifier,response:r.correctResponse||""}));for(let{responseIdentifier:r,response:s}of t){let a=this._interactionElements.find(o=>o.getAttribute("response-identifier")===r);a&&(a.correctResponse=e?s:"")}}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(r=>r.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:r}=e.detail;this.updateResponseVariable(t,r)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,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 r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:r.cardinality==="single"?t:[...s.value,t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value})}validate(e=!0){return this._interactionElements.every(t=>t.validate())?!0:this._interactionElements.some(t=>t.validate())?!1:(e&&this.reportValidity(),null)}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);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([m("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 s=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);s?await this.updateStimulusRef(s):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await $t().load(this.href).then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};n([d({type:String})],pe.prototype,"identifier",2),n([d({type:String})],pe.prototype,"href",2),pe=n([m("qti-assessment-stimulus-ref")],pe);var Xe=class extends v{};Xe=n([m("qti-companion-materials-info")],Xe);var xe=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let i=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",i?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let i={variable:t=>this._context?.variables.find(r=>r.identifier===t)?.value??"",correct:t=>this._context?.variables.find(r=>r.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(r=>r.identifier===t),updateOutcomeVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:r}}))},updateResponseVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:r}}))}};return this.operatorFunction(this._context,i,e)}};n([D({context:L,subscribe:!0}),C()],xe.prototype,"_context",2),xe=n([m("qti-custom-operator")],xe);var dr=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ee=c=>{if(typeof c=="string")return c;let i=dr();return i==="."?c.toLocaleString():c.toString().replace(".","").replace(i,".")};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(i){let e=this._context.variables.find(r=>r.identifier===i)||null;if(this.outcomeIdentifier!==i||!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(i){this.showStatus=i&&this.showHide==="show"||!i&&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}),C()],_.prototype,"_context",2);var qe=class extends _{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};qe.styles=b`
1
+ import{a as je}from"./chunk-EHK76KRT.js";import{a as le,b as J,c as ce,e as pe,f as K,g as Ft,h as zt,i as Xe,j as Bt}from"./chunk-5BR5CJFH.js";import{a as _}from"./chunk-XUJ7TXHW.js";import{a as $}from"./chunk-R45JL2ZY.js";import{a as q}from"./chunk-YIYKK4RV.js";import{a as Pt}from"./chunk-5FCXUJAG.js";import{a as C}from"./chunk-UJP4TGD3.js";import{a as m,b as d,c as E,d as Ue,e as Ot}from"./chunk-5GCSZ3CH.js";import{a as b,d as h,e as dt,f as ae,g as D,i as v}from"./chunk-LZZB4VGC.js";import{a as It}from"./chunk-KWPDTFYH.js";import{a as T}from"./chunk-QQCGUVEV.js";import{a as Nt,b as A}from"./chunk-M5PPZ5M3.js";import{a as n}from"./chunk-IAP2CEE7.js";var R=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={identifier:this.getAttribute("identifier"),variables:It};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(i=>i.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:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),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 r=e.find(i=>i.identifier===t.identifier);return r?{...t,...r}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(i=>i.responseIdentifier===t.identifier);r&&(r.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 i=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);i&&(i.value=t.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let t=this._context.variables.filter(r=>"correctResponse"in r&&r.correctResponse).map(r=>({responseIdentifier:r.identifier,response:r.correctResponse||""}));for(let{responseIdentifier:r,response:i}of t){let a=this._interactionElements.find(o=>o.getAttribute("response-identifier")===r);a&&(a.correctResponse=e?i:"")}}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(r=>r.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:r}=e.detail;this.updateResponseVariable(t,r)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,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 r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:r.cardinality==="single"?t:[...i.value,t]})},this._feedbackElements.forEach(i=>i.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(i=>i.identifier===e)?.value})}validate(e=!0){return this._interactionElements.every(t=>t.validate())?!0:this._interactionElements.some(t=>t.validate())?!1:(e&&this.reportValidity(),null)}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);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})],R.prototype,"title",2),n([d({type:String})],R.prototype,"identifier",2),n([d({type:String})],R.prototype,"adaptive",2),n([d({type:String})],R.prototype,"timeDependent",2),n([d({type:Boolean})],R.prototype,"disabled",2),n([_("disabled",{waitUntilFirstUpdate:!0})],R.prototype,"_handleDisabledChange",2),n([d({type:Boolean})],R.prototype,"readonly",2),n([_("readonly",{waitUntilFirstUpdate:!0})],R.prototype,"_handleReadonlyChange",2),n([Nt({context:T})],R.prototype,"_context",2),R=n([m("qti-assessment-item")],R);var de=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 i=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);i?await this.updateStimulusRef(i):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Pt().load(this.href).then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};n([d({type:String})],de.prototype,"identifier",2),n([d({type:String})],de.prototype,"href",2),de=n([m("qti-assessment-stimulus-ref")],de);var We=class extends v{};We=n([m("qti-companion-materials-info")],We);var Ce=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let s=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",s?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let s={variable:t=>this._context?.variables.find(r=>r.identifier===t)?.value??"",correct:t=>this._context?.variables.find(r=>r.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(r=>r.identifier===t),updateOutcomeVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:r}}))},updateResponseVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:r}}))}};return this.operatorFunction(this._context,s,e)}};n([A({context:T,subscribe:!0}),E()],Ce.prototype,"_context",2),Ce=n([m("qti-custom-operator")],Ce);var fr=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),qe=p=>{if(typeof p=="string")return p;let s=fr();return s==="."?p.toLocaleString():p.toString().replace(".","").replace(s,".")};function ut(p){return p==null}function we(p){return p.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var k=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(r=>r.identifier===s)||null;if(this.outcomeIdentifier!==s||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!ut(this.identifier)&&!ut(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"})],k.prototype,"showHide",2),n([d({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),n([d({type:String})],k.prototype,"identifier",2),n([d({type:String,attribute:!1})],k.prototype,"showStatus",2),n([A({context:T,subscribe:!0}),E()],k.prototype,"_context",2);var Te=class extends k{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};Te.styles=b`
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -8,21 +8,21 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
8
8
  .off {
9
9
  display: none;
10
10
  }
11
- `,qe=n([m("qti-feedback-block")],qe);var Te=class extends _{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${this.showStatus}"></slot> `}};Te.styles=b`
11
+ `,Te=n([m("qti-feedback-block")],Te);var Me=class extends k{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${this.showStatus}"></slot> `}};Me.styles=b`
12
12
  .on {
13
13
  display: inline-block;
14
14
  }
15
15
  .off {
16
16
  display: none;
17
17
  }
18
- `,Te=n([m("qti-feedback-inline")],Te);var Me=class extends _{render(){return h`
18
+ `,Me=n([m("qti-feedback-inline")],Me);var Se=class extends k{render(){return h`
19
19
  <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
20
20
  <slot></slot>
21
21
  <div style="margin-top: var(--qti-gap-size); text-align: center;">
22
22
  <button class="button close-button" @click="${this.closeFeedback}"></button>
23
23
  </div>
24
24
  </dialog>
25
- `}openFeedback(){let i=this.shadowRoot?.querySelector("dialog");i&&!i.open&&i.showModal()}closeFeedback(){let i=this.shadowRoot?.querySelector("dialog");i&&i.open&&(i.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(i){i.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Me.styles=b`
25
+ `}openFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&!s.open&&s.showModal()}closeFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&s.open&&(s.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(s){s.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Se.styles=b`
26
26
  .qti-dialog {
27
27
  background: var(--qti-bg);
28
28
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
@@ -71,13 +71,13 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
71
71
  display: inline-block;
72
72
  line-height: 1.5;
73
73
  }
74
- `,Me=n([m("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 h` <slot name="drags"></slot> `}};we.styles=b`
74
+ `,Se=n([m("qti-modal-feedback")],Se);var _e=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};_e.styles=b`
75
75
  :host {
76
76
  display: flex;
77
77
  user-select: none;
78
78
  position: absolute;
79
79
  }
80
- `,we=n([m("qti-associable-hotspot")],we);var Pt=(c,i,e)=>{class t extends c{}return t};var V=(c,i,e,t)=>{class r extends Pt(c,e,i){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(o,l){this.data[o]=l},getData(o){return this.data[o]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(o,l)=>{for(let u of l)this.draggables.includes(u)&&(this.draggables=this.draggables.filter(f=>f!==u),u.removeAttribute("tabindex"),u.removeEventListener("touchstart",this.handleTouchStart.bind(this)),u.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let u of o)this.draggables.includes(u)||(this.draggables.push(u),u.setAttribute("tabindex","0"),u.hasTouchStartListener||(u.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),u.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),u.hasTouchStartListener=!0));let p=0;this.draggables.forEach(u=>{u.style.viewTransitionName=`drag-${p}-${this.getAttribute("identifier")||crypto.randomUUID()}`,u.setAttribute("qti-draggable","true"),p++})};this.droppablesModified=(o,l)=>{for(let p of l)this.droppables.includes(p)&&(this.droppables=this.droppables.filter(u=>u!==p),this.allDropzones=this.allDropzones.filter(u=>u!==p));for(let p of o)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(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.dragContainersModified(o||[],l||[])}dragContainersModified(o,l){for(let p of l)this.dragContainers.includes(p)&&(this.dragContainers=this.dragContainers.filter(u=>u!==p),this.allDropzones=this.allDropzones.filter(u=>u!==p));for(let p of o)this.dragContainers.includes(p)||(this.dragContainers.push(p),this.allDropzones.push(p))}handleDraggablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.draggablesModified(o||[],l||[])}handleDroppablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.droppablesModified(o||[],l||[])}firstUpdated(o){super.firstUpdated(o),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(i)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(i)||[])),u=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),f=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(f,[]),this.droppablesModified(u,[]),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(o,l){(()=>{o.style.transform="translate(0, 0)",l.tagName==="SLOT"?o.setAttribute("slot",l.getAttribute("name")):l.appendChild(o),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(o){this.dragContainers.includes(o)?(this._internals.states.add("--dragzone-active"),o.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),o.setAttribute("active",""))}deactivateDroppable(o,l=!0){l&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let o=this.querySelectorAll(i),l=Array.from(this.querySelectorAll(e)).map(g=>g),p=0,u=0;o.forEach(g=>{let y=g.getBoundingClientRect();p=Math.max(p,y.height),u=Math.max(u,y.width)});let f=this.querySelector(t)||this.shadowRoot?.querySelector(t);f&&(f.style.minHeight=`${p}px`,f.style.minWidth=`${u}px`);for(let g of l)g.style.minHeight=`${p}px`,g.style.minWidth=`${u}px`}activateDroppables(o){this.dragContainers.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(o)||p.shadowRoot&&p.shadowRoot.contains(o))&&p.removeAttribute("disabled")}),this.droppables.forEach(p=>{p.setAttribute("enabled",""),p.hasAttribute("disabled")&&(p.contains(o)||p.shadowRoot&&p.shadowRoot.contains(o))&&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(o){if(this.isDraggable&&this.dragClone){let{x:l,y:p}=this.getEventCoordinates(o),u={clientX:l,clientY:p};this.calculateDragDistance(u)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(u));let f=this.findClosestDropzone();this.currentDropTarget=f,f!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),f&&(this.activateDroppable(f),this.dispatchCustomEvent(f,"dragenter")),this.lastTarget=f),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),o.preventDefault()}}handleTouchEnd(o){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")}),o.preventDefault()}handleTouchCancel(o){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let o=this.getValidAssociations(),l=!0,p="";this.maxAssociations>0&&o>this.maxAssociations?(l=!1,p=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&o<this.minAssociations&&(l=!1,p=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let u=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},p,u),l}reportValidity(){let o=this.shadowRoot.querySelector("#validationMessage");return o&&(this._internals.validity.valid?(o.textContent="",o.style.display="none"):(o.textContent=this._internals.validationMessage,o.style.display="block")),this._internals.validity.valid}checkMaxAssociations(o){let l=this.getMatchMaxValue(o),p=o.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&p>=l}dropDraggableInDroppable(o,l){let p=o.cloneNode(!0);p.removeAttribute("style"),this.moveDraggableToDroppable(p,l),this.draggablesModified([p],[]);let u=this.getMatchMaxValue(o),f=this.draggables.filter(g=>g.getAttribute("identifier")===o.getAttribute("identifier"));u!==0&&f.length>=u?(o.style.opacity="0.0",o.style.pointerEvents="none"):o.style.opacity="1.0"}resetDragState(){if(this.dragClone){let o=this.currentDropTarget!==null,l=!o||this.dragContainers.includes(this.currentDropTarget);o&&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.saveResponse()),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(){let o=this.getValidAssociations(),l=this.maxAssociations!==0&&o>=this.maxAssociations;this.droppables.forEach(p=>{l?this.disableDroppable(p):this.checkMaxAssociations(p)?this.disableDroppable(p):this.enableDroppable(p)})}getMatchMaxValue(o){let l=o.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(o){o.setAttribute("disabled","")}enableDroppable(o){o.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(o){if(!this.isMatchTabular())if(Array.isArray(o)){this.reset(),o?.forEach(p=>this.placeResponse(p));let l=new FormData;o.forEach(p=>{l.append(this.responseIdentifier,p)}),this._internals.setFormValue(l)}else this._internals.setFormValue(o||"")}placeResponse(o){let[l,...p]=o.split(" ").reverse(),u=Array.from(this.draggables),f=Array.from(this.droppables);p.forEach(g=>{let y=u.find(x=>x.getAttribute("identifier")===g),T=f.find(x=>x.getAttribute("identifier")===l);this.dropDraggableInDroppable(y,T)})}getValidAssociations(){let o=0;for(let l of this.droppables)o=o+this.getDraggablesFromDroppable(l).length;return o}saveResponse(){let o=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:o}}))}collectResponseData(){return this.droppables.map(l=>{let u=this.getDraggablesFromDroppable(l).map(g=>g.getAttribute("identifier")),f=l.getAttribute("identifier");return u.map(g=>`${g} ${f}`)}).flat()}getDraggablesFromDroppable(o){return this.draggables.map(u=>u.getAttribute("identifier")).filter((u,f,g)=>g.indexOf(u)===f).flatMap(u=>Array.from(o.querySelectorAll(`[identifier='${u}']`))).filter(u=>!!u).map(u=>u)}reset(o=!1){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(u=>{u.remove(),this.draggablesModified([],[u])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(u=>{u.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,o&&this.saveResponse()}updateDragClonePosition(o){if(!this.isDragging||!this.dragClone)return;let l=o.clientX-this.cloneOffset.x,p=o.clientY-this.cloneOffset.y,{newLeft:u,newTop:f}=this.applyInteractionBoundaries(l,p,this.dragClone);this.dragClone.style.left=`${u}px`,this.dragClone.style.top=`${f}px`}applyInteractionBoundaries(o,l,p){let u=this.getBoundingClientRect(),f=p.getBoundingClientRect(),g=f.width,y=f.height,T=Math.max(u.left,Math.min(o,u.right-g)),x=Math.max(u.top,Math.min(l,u.bottom-y));return{newLeft:T,newTop:x}}getEventCoordinates(o,l=!1){let p=o.touches?o.touches[0]:o;return{x:l?p.pageX:p.clientX,y:l?p.pageY:p.clientY}}calculateDragDistance(o){let l=Math.abs(o.clientX-this.touchStartPoint.x),p=Math.abs(o.clientY-this.touchStartPoint.y);return l+p}findClosestDropzone(){let o=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||o.length===0)return null;let l=this.dragClone.getBoundingClientRect(),p=null,u=0;for(let f of o){let g=f.getBoundingClientRect(),y=this.calculateOverlapArea(l,g);y>u&&(u=y,p=f)}if(!p){let f=200;for(let g of o){let y=g.getBoundingClientRect(),T=Math.sqrt(Math.pow(l.left-y.left,2)+Math.pow(l.top-y.top,2));T<f&&(f=T,p=g)}}return p}calculateOverlapArea(o,l){let p=Math.max(0,Math.min(o.right,l.right)-Math.max(o.left,l.left)),u=Math.max(0,Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top));return p*u}dispatchCustomEvent(o,l,p=!0){if(!o)return;let u=new CustomEvent(l,{bubbles:p,cancelable:!0});u.dataTransfer=this.dataTransfer,o.dispatchEvent(u)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(o){if(this.isDragging)return;let{x:l,y:p}=this.getEventCoordinates(o);this.touchStartPoint={x:l,y:p},this.dragSource=o.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let u=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),f=this.droppables.some(M=>Array.from(M.children).some(W=>W===this.dragSource)),g=this.dragSource.getBoundingClientRect();f&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=u),this.cloneOffset.x=l-g.left,this.cloneOffset.y=p-g.top,this.dragClone=u.cloneNode(!0);let y=window.getComputedStyle(u);for(let M=0;M<y.length;M++){let W=y[M];this.dragClone.style.setProperty(W,y.getPropertyValue(W))}let T=u.getBoundingClientRect();this.dragClone.style.width=`${T.width}px`,this.dragClone.style.height=`${T.height}px`,g&&this.setDragCloneStyles(g),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let x=this.getMatchMaxValue(this.dragSource),j=this.draggables.filter(M=>M.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));x!==0&&j.length>=x?(u.style.opacity="0.0",u.style.pointerEvents="none"):u.style.opacity="1.0",o.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(o){let l=this.dragContainers.flat();for(let p of l){if(p.getAttribute("identifier")===o)return p;let u;p instanceof HTMLSlotElement?u=Array.from(p?.assignedElements()||[]):u=Array.from(p.querySelectorAll(i));let f=u.find(g=>g.getAttribute("identifier")===o);if(f)return f}}setDragCloneStyles(o){this.dragClone.style.position="fixed",this.dragClone.style.top=`${o.top}px`,this.dragClone.style.left=`${o.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})],r.prototype,"configuration",2),n([d({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),n([d({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),n([Ue(t)],r.prototype,"handleDraggableContainerChange",1),n([Ue(i)],r.prototype,"handleDraggablesChange",1),n([Ue(e)],r.prototype,"handleDroppablesChange",1),r};var Ft=b`
80
+ `,_e=n([m("qti-associable-hotspot")],_e);var Yt=(p,s,e)=>{class t extends p{}return t};var N=(p,s,e,t)=>{class r extends Yt(p,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(o,l){this.data[o]=l},getData(o){return this.data[o]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(o,l)=>{for(let u of l)this.draggables.includes(u)&&(this.draggables=this.draggables.filter(f=>f!==u),u.removeAttribute("tabindex"),u.removeEventListener("touchstart",this.handleTouchStart.bind(this)),u.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let u of o)this.draggables.includes(u)||(this.draggables.push(u),u.setAttribute("tabindex","0"),u.hasTouchStartListener||(u.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),u.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),u.hasTouchStartListener=!0));let c=0;this.draggables.forEach(u=>{u.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,u.setAttribute("qti-draggable","true"),c++})};this.droppablesModified=(o,l)=>{for(let c of l)this.droppables.includes(c)&&(this.droppables=this.droppables.filter(u=>u!==c),this.allDropzones=this.allDropzones.filter(u=>u!==c));for(let c of o)this.droppables.includes(c)||(this.droppables.push(c),this.allDropzones.push(c));for(let c of this.droppables)this.dataset.choicesContainerWidth&&(c.style.width=`${this.dataset.choicesContainerWidth}px`,c.style.boxSizing="border-box")}}handleDraggableContainerChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.dragContainersModified(o||[],l||[])}dragContainersModified(o,l){for(let c of l)this.dragContainers.includes(c)&&(this.dragContainers=this.dragContainers.filter(u=>u!==c),this.allDropzones=this.allDropzones.filter(u=>u!==c));for(let c of o)this.dragContainers.includes(c)||(this.dragContainers.push(c),this.allDropzones.push(c))}handleDraggablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.draggablesModified(o||[],l||[])}handleDroppablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.droppablesModified(o||[],l||[])}firstUpdated(o){super.firstUpdated(o),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 c=Array.from(this.querySelectorAll(s)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[])),u=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),f=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(f,[]),this.droppablesModified(u,[]),this.draggablesModified(c,[]),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(o,l){(()=>{o.style.transform="translate(0, 0)",l.tagName==="SLOT"?o.setAttribute("slot",l.getAttribute("name")):l.appendChild(o),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(o){this.dragContainers.includes(o)?(this._internals.states.add("--dragzone-active"),o.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),o.setAttribute("active",""))}deactivateDroppable(o,l=!0){l&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let o=this.querySelectorAll(s),l=Array.from(this.querySelectorAll(e)).map(g=>g),c=0,u=0;o.forEach(g=>{let y=g.getBoundingClientRect();c=Math.max(c,y.height),u=Math.max(u,y.width)});let f=this.querySelector(t)||this.shadowRoot?.querySelector(t);f&&(f.style.minHeight=`${c}px`,f.style.minWidth=`${u}px`);for(let g of l)g.style.minHeight=`${c}px`,g.style.minWidth=`${u}px`}activateDroppables(o){this.dragContainers.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")}),this.droppables.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.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(o){if(this.isDraggable&&this.dragClone){let{x:l,y:c}=this.getEventCoordinates(o),u={clientX:l,clientY:c};this.calculateDragDistance(u)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(u));let f=this.findClosestDropzone();this.currentDropTarget=f,f!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),f&&(this.activateDroppable(f),this.dispatchCustomEvent(f,"dragenter")),this.lastTarget=f),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),o.preventDefault()}}handleTouchEnd(o){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")}),o.preventDefault()}handleTouchCancel(o){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let o=this.getValidAssociations(),l=!0,c="";this.maxAssociations>0&&o>this.maxAssociations?(l=!1,c=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&o<this.minAssociations&&(l=!1,c=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let u=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},c,u),l}reportValidity(){let o=this.shadowRoot.querySelector("#validationMessage");return o&&(this._internals.validity.valid?(o.textContent="",o.style.display="none"):(o.textContent=this._internals.validationMessage,o.style.display="block")),this._internals.validity.valid}checkMaxAssociations(o){let l=this.getMatchMaxValue(o),c=o.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&c>=l}dropDraggableInDroppable(o,l){let c=o.cloneNode(!0);c.removeAttribute("style"),this.moveDraggableToDroppable(c,l),this.draggablesModified([c],[]);let u=this.getMatchMaxValue(o),f=this.draggables.filter(g=>g.getAttribute("identifier")===o.getAttribute("identifier"));u!==0&&f.length>=u?(o.style.opacity="0.0",o.style.pointerEvents="none"):o.style.opacity="1.0"}resetDragState(){if(this.dragClone){let o=this.currentDropTarget!==null,l=!o||this.dragContainers.includes(this.currentDropTarget);o&&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.saveResponse()),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(){let o=this.getValidAssociations(),l=this.maxAssociations!==0&&o>=this.maxAssociations;this.droppables.forEach(c=>{l?this.disableDroppable(c):this.checkMaxAssociations(c)?this.disableDroppable(c):this.enableDroppable(c)})}getMatchMaxValue(o){let l=o.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(o){o.setAttribute("disabled","")}enableDroppable(o){o.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(o){if(!this.isMatchTabular())if(Array.isArray(o)){this.reset(),o?.forEach(c=>this.placeResponse(c));let l=new FormData;o.forEach(c=>{l.append(this.responseIdentifier,c)}),this._internals.setFormValue(l)}else this._internals.setFormValue(o||"")}placeResponse(o){let[l,...c]=o.split(" ").reverse(),u=Array.from(this.draggables),f=Array.from(this.droppables);c.forEach(g=>{let y=u.find(x=>x.getAttribute("identifier")===g),w=f.find(x=>x.getAttribute("identifier")===l);this.dropDraggableInDroppable(y,w)})}getValidAssociations(){let o=0;for(let l of this.droppables)o=o+this.getDraggablesFromDroppable(l).length;return o}saveResponse(){let o=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:o}}))}collectResponseData(){return this.droppables.map(l=>{let u=this.getDraggablesFromDroppable(l).map(g=>g.getAttribute("identifier")),f=l.getAttribute("identifier");return u.map(g=>`${g} ${f}`)}).flat()}getDraggablesFromDroppable(o){return this.draggables.map(u=>u.getAttribute("identifier")).filter((u,f,g)=>g.indexOf(u)===f).flatMap(u=>Array.from(o.querySelectorAll(`[identifier='${u}']`))).filter(u=>!!u).map(u=>u)}reset(o=!1){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(u=>{u.remove(),this.draggablesModified([],[u])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(u=>{u.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,o&&this.saveResponse()}updateDragClonePosition(o){if(!this.isDragging||!this.dragClone)return;let l=o.clientX-this.cloneOffset.x,c=o.clientY-this.cloneOffset.y,{newLeft:u,newTop:f}=this.applyInteractionBoundaries(l,c,this.dragClone);this.dragClone.style.left=`${u}px`,this.dragClone.style.top=`${f}px`}applyInteractionBoundaries(o,l,c){let u=this.getBoundingClientRect(),f=c.getBoundingClientRect(),g=f.width,y=f.height,w=Math.max(u.left,Math.min(o,u.right-g)),x=Math.max(u.top,Math.min(l,u.bottom-y));return{newLeft:w,newTop:x}}getEventCoordinates(o,l=!1){let c=o.touches?o.touches[0]:o;return{x:l?c.pageX:c.clientX,y:l?c.pageY:c.clientY}}calculateDragDistance(o){let l=Math.abs(o.clientX-this.touchStartPoint.x),c=Math.abs(o.clientY-this.touchStartPoint.y);return l+c}findClosestDropzone(){let o=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||o.length===0)return null;let l=this.dragClone.getBoundingClientRect(),c=null,u=0;for(let f of o){let g=f.getBoundingClientRect(),y=this.calculateOverlapArea(l,g);y>u&&(u=y,c=f)}if(!c){let f=200;for(let g of o){let y=g.getBoundingClientRect(),w=Math.sqrt(Math.pow(l.left-y.left,2)+Math.pow(l.top-y.top,2));w<f&&(f=w,c=g)}}return c}calculateOverlapArea(o,l){let c=Math.max(0,Math.min(o.right,l.right)-Math.max(o.left,l.left)),u=Math.max(0,Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top));return c*u}dispatchCustomEvent(o,l,c=!0){if(!o)return;let u=new CustomEvent(l,{bubbles:c,cancelable:!0});u.dataTransfer=this.dataTransfer,o.dispatchEvent(u)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(o){if(this.isDragging)return;let{x:l,y:c}=this.getEventCoordinates(o);this.touchStartPoint={x:l,y:c},this.dragSource=o.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let u=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),f=this.droppables.some(S=>Array.from(S.children).some(H=>H===this.dragSource)),g=this.dragSource.getBoundingClientRect();f&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=u),this.cloneOffset.x=l-g.left,this.cloneOffset.y=c-g.top,this.dragClone=u.cloneNode(!0);let y=window.getComputedStyle(u);for(let S=0;S<y.length;S++){let H=y[S];this.dragClone.style.setProperty(H,y.getPropertyValue(H))}let w=u.getBoundingClientRect();this.dragClone.style.width=`${w.width}px`,this.dragClone.style.height=`${w.height}px`,g&&this.setDragCloneStyles(g),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let x=this.getMatchMaxValue(this.dragSource),V=this.draggables.filter(S=>S.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));x!==0&&V.length>=x?(u.style.opacity="0.0",u.style.pointerEvents="none"):u.style.opacity="1.0",o.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(o){let l=this.dragContainers.flat();for(let c of l){if(c.getAttribute("identifier")===o)return c;let u;c instanceof HTMLSlotElement?u=Array.from(c?.assignedElements()||[]):u=Array.from(c.querySelectorAll(s));let f=u.find(g=>g.getAttribute("identifier")===o);if(f)return f}}setDragCloneStyles(o){this.dragClone.style.position="fixed",this.dragClone.style.top=`${o.top}px`,this.dragClone.style.left=`${o.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})],r.prototype,"configuration",2),n([d({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),n([d({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),n([je(t)],r.prototype,"handleDraggableContainerChange",1),n([je(s)],r.prototype,"handleDraggablesChange",1),n([je(e)],r.prototype,"handleDroppablesChange",1),r};var Ut=b`
81
81
  :host {
82
82
  display: block; /* necessary to calculate scaling position */
83
83
  }
@@ -102,7 +102,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
102
102
  rgb(0 0 0 / 0%) calc(50% + 1px)
103
103
  );
104
104
  }
105
- `;var de=class extends V(E,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
105
+ `;var ue=class extends N(C,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
106
106
  <slot name="qti-simple-associable-choice"></slot>
107
107
  <div part="drop-container">
108
108
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
@@ -111,7 +111,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
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([C()],de.prototype,"_childrenMap",2),de=n([m("qti-associate-interaction")],de);var Z=(c,i)=>{class e extends c{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,a)=>{this._choiceElements.forEach(o=>o.disabled=a)};this._handleReadonlyChange=(s,a)=>{this._choiceElements.forEach(o=>o.readonly=a)};this._value=""}_handleMaxChoicesChange(s,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(s){if(this.maxChoices>1&&(typeof s=="string"||s===null)?this._value=s?s.toString().split(","):[]:this._value=s||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(o=>{a.append(this.responseIdentifier,o)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(s){this._correctResponse=s;let a=Array.isArray(s)?s:[s];this._choiceElements.forEach(o=>{o.internals.states.delete("correct-response"),o.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(o.identifier)?o.internals.states.add("correct-response"):o.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${i}`,this._registerChoiceElement),this.addEventListener(`unregister-${i}`,this._unregisterChoiceElement),this.addEventListener(`activate-${i}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${i}`,this._registerChoiceElement),this.removeEventListener(`unregister-${i}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${i}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(p=>this._getChoiceChecked(p)),a=s.length,o=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(o=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):a<this.minChoices&&(o=!1,l=`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(o?{}:{customError:!0},l,s[a-1]||this._choiceElements[0]||this),o}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(s){s.stopPropagation();let a=s.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(s){s.stopPropagation();let a=s.target;this._choiceElements=this._choiceElements.filter(o=>o!==a)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";s.internals.role=a,s.internals.states.delete(a==="radio"?"checkbox":"radio"),s.internals.states.add(a)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==s.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(s,a){s.internals?.states&&(a?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let a=this._getChoiceChecked(s);this._setChoiceChecked(s,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(o=>this._getChoiceChecked(o)).map(o=>o.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let s=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let o=s.includes(a.identifier);this._setChoiceChecked(a,o)})}}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,i)=>{class e extends c{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(s){s.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let s=Array.from(this.querySelectorAll(i)),a=s.filter(g=>g.hasAttribute("fixed")),o=s.filter(g=>!g.hasAttribute("fixed"));if(o.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let l=[...o],p=!1,u=0;for(;!p&&u<10;){u++;for(let g=o.length-1;g>0;g--){let y=Math.floor(Math.random()*(g+1));[o[g],o[y]]=[o[y],o[g]]}p=!o.every((g,y)=>g===l[y])}p||console.warn("Failed to shuffle the choices after multiple attempts.");let f=1;[...a,...o].forEach(g=>{g.style.setProperty("order",String(f++))})}_resetShuffleChoices(){this.querySelectorAll(i).forEach(s=>{s.style.setProperty("order","initial")})}}return n([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var zt=(c,i)=>{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(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),s.has("shuffle")&&this._addLabels()}_addLabels(){let s=this._classes.some(o=>this._allLabels.includes(o)||this._allLabelSuffixes.includes(o)),a=o=>!isNaN(+o);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(p=>p).map((p,u)=>({el:p,order:a(p.style.order)?+p.style.order:u+1})).sort((p,u)=>p.order-u.order).map(p=>p.el);for(let p=0;p<l.length;p++)l[p].marker=this._getLabel(p+1)}}_getLabel(s){let a=this._classes.filter(p=>this._allLabels.includes(p)).pop(),o=this._classes.filter(p=>this._allLabelSuffixes.includes(p)).pop();!a&&o&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return o==="qti-labels-suffix-period"?l+=".":o==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Yt=b`
114
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ue.styles=Ut,n([E()],ue.prototype,"_childrenMap",2),ue=n([m("qti-associate-interaction")],ue);var Z=(p,s)=>{class e extends p{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(i,a)=>{this._choiceElements.forEach(o=>o.disabled=a)};this._handleReadonlyChange=(i,a)=>{this._choiceElements.forEach(o=>o.readonly=a)};this._value=""}_handleMaxChoicesChange(i,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(i){if(this.maxChoices>1&&(typeof i=="string"||i===null)?this._value=i?i.toString().split(","):[]:this._value=i||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(o=>{a.append(this.responseIdentifier,o)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(i){this._correctResponse=i;let a=Array.isArray(i)?i:[i];this._choiceElements.forEach(o=>{o.internals.states.delete("correct-response"),o.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(o.identifier)?o.internals.states.add("correct-response"):o.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 i=this._choiceElements.filter(c=>this._getChoiceChecked(c)),a=i.length,o=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(o=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):a<this.minChoices&&(o=!1,l=`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),i.length>0&&this._internals.setValidity(o?{}:{customError:!0},l,i[a-1]||this._choiceElements[0]||this),o}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(i){i.stopPropagation();let a=i.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(i){i.stopPropagation();let a=i.target;this._choiceElements=this._choiceElements.filter(o=>o!==a)}_determineInputType(){this._choiceElements.forEach(i=>{this._setInputType(i)})}_setInputType(i){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";i.internals.role=a,i.internals.states.delete(a==="radio"?"checkbox":"radio"),i.internals.states.add(a)}_choiceElementSelectedHandler(i){this._toggleChoiceChecked(i.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==i.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(i,a){i.internals?.states&&(a?(i.internals.states.add("--checked"),i.internals.ariaChecked="true"):(i.internals.states.delete("--checked"),i.internals.ariaChecked="false"))}_getChoiceChecked(i){return i.internals.states.has("--checked")}_toggleChoiceChecked(i){let a=this._getChoiceChecked(i);this._setChoiceChecked(i,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(o=>this._getChoiceChecked(o)).map(o=>o.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let i=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let o=i.includes(a.identifier);this._setChoiceChecked(a,o)})}}return n([Ue("#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([_("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([_("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([_("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Je=(p,s)=>{class e extends p{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(i){i.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let i=Array.from(this.querySelectorAll(s)),a=i.filter(g=>g.hasAttribute("fixed")),o=i.filter(g=>!g.hasAttribute("fixed"));if(o.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let l=[...o],c=!1,u=0;for(;!c&&u<10;){u++;for(let g=o.length-1;g>0;g--){let y=Math.floor(Math.random()*(g+1));[o[g],o[y]]=[o[y],o[g]]}c=!o.every((g,y)=>g===l[y])}c||console.warn("Failed to shuffle the choices after multiple attempts.");let f=1;[...a,...o].forEach(g=>{g.style.setProperty("order",String(f++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(i=>{i.style.setProperty("order","initial")})}}return n([d({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var jt=(p,s)=>{class e extends p{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(i){i&&(this._classes=i.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(i){super.updated(i),i.has("shuffle")&&this._addLabels()}_addLabels(){let i=this._classes.some(o=>this._allLabels.includes(o)||this._allLabelSuffixes.includes(o)),a=o=>!isNaN(+o);if(i){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,u)=>({el:c,order:a(c.style.order)?+c.style.order:u+1})).sort((c,u)=>c.order-u.order).map(c=>c.el);for(let c=0;c<l.length;c++)l[c].marker=this._getLabel(c+1)}}_getLabel(i){let a=this._classes.filter(c=>this._allLabels.includes(c)).pop(),o=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!a&&o&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${i}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+i-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+i-1)}`;break}return o==="qti-labels-suffix-period"?l+=".":o==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([d({type:String,reflect:!0})],e.prototype,"class",1),e};var Xt=b`
115
115
  [part='slot'] {
116
116
  display: flex;
117
117
  flex-direction: column;
@@ -149,18 +149,18 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
149
149
  :host([orientation='horizontal']) [part='slot'] {
150
150
  flex-direction: row;
151
151
  }
152
- `;var ue=class extends zt(je(Z(E,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return h`
152
+ `;var he=class extends jt(Je(Z(C,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return h`
153
153
  <slot part="prompt" name="prompt"></slot><slot part="slot"></slot>
154
154
  <div part="message" role="alert" id="validationMessage"></div>
155
- `}};ue.styles=Yt,n([d({type:String})],ue.prototype,"orientation",2),ue=n([m("qti-choice-interaction")],ue);var z=class extends E{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:Ce(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),t=e.contentDocument;window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
155
+ `}};he.styles=Xt,n([d({type:String})],he.prototype,"orientation",2),he=n([m("qti-choice-interaction")],he);var Y=class extends C{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:we(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),t=e.contentDocument;window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
156
156
  <html>
157
157
  <head>
158
- <link href='${Ce(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
159
- <script src='${Ce(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
158
+ <link href='${we(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
159
+ <script src='${we(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
160
160
  </head>
161
161
  <body></body>
162
162
  </html>
163
- `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let s of r){let a=s.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;l&&this.getInnerIFrames(l,r)}catch(l){console.error("Error accessing nested iframe:",l)}}return r.forEach((s,a)=>{r.indexOf(s)!==a&&r.splice(a,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let a=s.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",a)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let s of r)s.contentWindow&&s.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:r}=e.data;switch(t){case"setResponse":this.rawResponse=r,this.saveResponse(r);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let s=this.manifest.media.map(a=>a.startsWith("http")?a:Ce(this.baseRefUrl+"/"+a));this.postToWindowAndIframes("mediaData",s);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get value(){return this.rawResponse}set value(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else throw new Error("Value must be a string")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
163
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let i of r){let a=i.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=i.contentDocument||i.contentWindow.document;l&&this.getInnerIFrames(l,r)}catch(l){console.error("Error accessing nested iframe:",l)}}return r.forEach((i,a)=>{r.indexOf(i)!==a&&r.splice(a,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(i=>{t.push(i);let a=i.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=i.contentDocument||i.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",a)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let i of r)i.contentWindow&&i.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:r}=e.data;switch(t){case"setResponse":this.rawResponse=r,this.saveResponse(r);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let i=this.manifest.media.map(a=>a.startsWith("http")?a:we(this.baseRefUrl+"/"+a));this.postToWindowAndIframes("mediaData",i);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get value(){return this.rawResponse}set value(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else throw new Error("Value must be a string")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
164
164
  width=${this.getAttribute("width")}
165
165
  height=${this.getAttribute("height")}
166
166
  frameborder="0"
@@ -171,7 +171,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
171
171
  ${this._errorMessage&&h`<div style="color:red">
172
172
  <h1>Error</h1>
173
173
  ${this._errorMessage}
174
- </div>`}`}};n([d({type:String,attribute:"data"})],z.prototype,"data",2),n([d({type:String,attribute:"data-base-item"})],z.prototype,"baseItemUrl",2),n([d({type:String,attribute:"data-base-ref"})],z.prototype,"baseRefUrl",2),n([d({type:String,attribute:"id"})],z.prototype,"id",2),n([C()],z.prototype,"_errorMessage",2),z=n([m("qti-custom-interaction")],z);var G=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};n([d({type:String,attribute:"response-identifier"})],G.prototype,"responseIdentifier",2),n([d({reflect:!0,type:Boolean})],G.prototype,"disabled",2),n([d({type:String,attribute:"count-attempt"})],G.prototype,"countAttempt",2),n([d({type:String})],G.prototype,"title",2),G=n([m("qti-end-attempt-interaction")],G);var Q=c=>c??R;var Ut=b`
174
+ </div>`}`}};n([d({type:String,attribute:"data"})],Y.prototype,"data",2),n([d({type:String,attribute:"data-base-item"})],Y.prototype,"baseItemUrl",2),n([d({type:String,attribute:"data-base-ref"})],Y.prototype,"baseRefUrl",2),n([d({type:String,attribute:"id"})],Y.prototype,"id",2),n([E()],Y.prototype,"_errorMessage",2),Y=n([m("qti-custom-interaction")],Y);var G=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};n([d({type:String,attribute:"response-identifier"})],G.prototype,"responseIdentifier",2),n([d({reflect:!0,type:Boolean})],G.prototype,"disabled",2),n([d({type:String,attribute:"count-attempt"})],G.prototype,"countAttempt",2),n([d({type:String})],G.prototype,"title",2),G=n([m("qti-end-attempt-interaction")],G);var Q=p=>p??D;var Wt=b`
175
175
  /* PK: display host as block, else design will be collapsed */
176
176
  :host {
177
177
  display: block;
@@ -182,7 +182,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
182
182
  height: 100%;
183
183
  border: 0;
184
184
  }
185
- `;var k=class extends E{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,t){let r=t.split(" "),s=!1;if(r.forEach(a=>{if(a.startsWith("qti-height-lines-")){let o=a.replace("qti-height-lines-","");this._rows=parseInt(o),s=!0}}),!s&&this.expectedLength){let a=Math.ceil(this.expectedLength/50);this._rows=a}}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(t);e.checkValidity()&&r.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return h`<slot name="prompt"></slot
185
+ `;var L=class extends C{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,t){let r=t.split(" "),i=!1;if(r.forEach(a=>{if(a.startsWith("qti-height-lines-")){let o=a.replace("qti-height-lines-","");this._rows=parseInt(o),i=!0}}),!i&&this.expectedLength){let a=Math.ceil(this.expectedLength/50);this._rows=a}}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(t);e.checkValidity()&&r.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return h`<slot name="prompt"></slot
186
186
  ><textarea
187
187
  part="textarea"
188
188
  name="${this.responseIdentifier}"
@@ -198,12 +198,12 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
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([C()],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([C()],k.prototype,"_value",2),n([d({type:String,attribute:"class"})],k.prototype,"classNames",2),n([w("classNames")],k.prototype,"handleclassNamesChange",1),k=n([m("qti-extended-text-interaction")],k);var he=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};he.styles=b`
201
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};L.styles=Wt,n([E()],L.prototype,"_rows",2),n([d({type:Number,attribute:"expected-length"})],L.prototype,"expectedLength",2),n([d({type:String,attribute:"pattern-mask"})],L.prototype,"patternMask",2),n([d({type:String,attribute:"placeholder-text"})],L.prototype,"placeholderText",2),n([d({type:String,attribute:"data-patternmask-message"})],L.prototype,"dataPatternmaskMessage",2),n([E()],L.prototype,"_value",2),n([d({type:String,attribute:"class"})],L.prototype,"classNames",2),n([_("classNames")],L.prototype,"handleclassNamesChange",1),L=n([m("qti-extended-text-interaction")],L);var me=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};me.styles=b`
202
202
  :host {
203
203
  display: flex;
204
204
  user-select: none;
205
205
  }
206
- `,n([d({type:Number,reflect:!0})],he.prototype,"tabindex",2),he=n([m("qti-gap-img")],he);var Bt=b`
206
+ `,n([d({type:Number,reflect:!0})],me.prototype,"tabindex",2),me=n([m("qti-gap-img")],me);var Jt=b`
207
207
  :host {
208
208
  display: flex;
209
209
  align-items: flex-start;
@@ -237,20 +237,20 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
237
237
  border-radius: 0.3rem;
238
238
  gap: 0.5rem;
239
239
  }
240
- `;var Se=class extends V(E,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
240
+ `;var Re=class extends N(C,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
241
241
  <slot part="drags" name="drags"></slot>
242
242
  <slot part="drops"></slot>
243
- <div role="alert" id="validationMessage"></div>`}set correctResponse(i){let e=[],t=Array.isArray(i)?i:[i];t&&(e=t.map(s=>{let a=s.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(s=>{let a=s.getAttribute("identifier"),o=e.find(p=>p.gap===a)?.text,l=this.querySelector(`qti-gap-text[identifier="${o}"]`)?.textContent.trim();if(o&&l){if(!s.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=l,s.insertAdjacentElement("afterend",p)}}else s.nextElementSibling?.classList.contains("correct-option")&&s.nextElementSibling.remove()})}};Se.styles=Bt,Se=n([m("qti-gap-match-interaction")],Se);var Xt={toAttribute:c=>c?"true":"false",fromAttribute:c=>c==="true"};function $(c,i){class e extends c{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,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-${i}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${i}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${i}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<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 h`<slot></slot>`}};me.styles=b`
243
+ <div role="alert" id="validationMessage"></div>`}set correctResponse(s){let e=[],t=Array.isArray(s)?s:[s];t&&(e=t.map(i=>{let a=i.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(i=>{let a=i.getAttribute("identifier"),o=e.find(c=>c.gap===a)?.text,l=this.querySelector(`qti-gap-text[identifier="${o}"]`)?.textContent.trim();if(o&&l){if(!i.nextElementSibling?.classList.contains("correct-option")){let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=l,i.insertAdjacentElement("afterend",c)}}else i.nextElementSibling?.classList.contains("correct-option")&&i.nextElementSibling.remove()})}};Re.styles=Jt,Re=n([m("qti-gap-match-interaction")],Re);var Kt={toAttribute:p=>p?"true":"false",fromAttribute:p=>p==="true"};function O(p,s){class e extends p{constructor(...i){super(...i);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(i,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(i){i.altKey||i.code==="Space"&&(i.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${s}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return 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:Kt})],e.prototype,"disabled",2),n([d({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Kt})],e.prototype,"readonly",2),n([_("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var fe=class extends O(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};fe.styles=b`
244
244
  :host {
245
245
  display: inline-flex;
246
246
  user-select: none;
247
247
  }
248
- `,n([d({type:Number,reflect:!0})],me.prototype,"tabindex",2),me=n([m("qti-gap-text")],me);var fe=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};fe.styles=b`
248
+ `,n([d({type:Number,reflect:!0})],fe.prototype,"tabindex",2),fe=n([m("qti-gap-text")],fe);var ge=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};ge.styles=b`
249
249
  :host {
250
250
  display: flex;
251
251
  user-select: none;
252
252
  }
253
- `,n([d({type:Number,reflect:!0})],fe.prototype,"tabindex",2),fe=n([m("qti-gap")],fe);var jt=(c,i,e)=>{let t=new Map;for(let r=i;r<=e;r++)t.set(c[r],r);return t},We=K(class extends le{constructor(c){if(super(c),c.type!==ae.CHILD)throw Error("repeat() can only be used in text expressions")}dt(c,i,e){let t;e===void 0?e=i:i!==void 0&&(t=i);let r=[],s=[],a=0;for(let o of c)r[a]=t?t(o,a):a,s[a]=e(o,a),a++;return{values:s,keys:r}}render(c,i,e){return this.dt(c,i,e).values}update(c,[i,e,t]){let r=Ot(c),{values:s,keys:a}=this.dt(i,e,t);if(!Array.isArray(r))return this.ut=a,s;let o=this.ut??(this.ut=[]),l=[],p,u,f=0,g=r.length-1,y=0,T=s.length-1;for(;f<=g&&y<=T;)if(r[f]===null)f++;else if(r[g]===null)g--;else if(o[f]===a[y])l[y]=J(r[f],s[y]),f++,y++;else if(o[g]===a[T])l[T]=J(r[g],s[T]),g--,T--;else if(o[f]===a[T])l[T]=J(r[f],s[T]),ce(c,l[T+1],r[f]),f++,T--;else if(o[g]===a[y])l[y]=J(r[g],s[y]),ce(c,r[f],r[g]),g--,y++;else if(p===void 0&&(p=jt(a,y,T),u=jt(o,f,g)),p.has(o[f]))if(p.has(o[g])){let x=u.get(a[y]),j=x!==void 0?r[x]:null;if(j===null){let M=ce(c,r[f]);J(M,s[y]),l[y]=M}else l[y]=J(j,s[y]),ce(c,r[f],j),r[x]=null;y++}else Be(r[g]),g--;else Be(r[f]),f++;for(;y<=T;){let x=ce(c,l[T+1]);J(x,s[y]),l[y++]=x}for(;f<=g;){let x=r[f++];x!==null&&Be(x)}return this.ut=a,Nt(c,l),ne}});function ge(c,i,e,t){switch(c){case"circle":{let[r,s,a]=i,o=r/e.width*100,l=s/e.height*100,p=a/e.width*100;t.style.left=o-p+"%",t.style.top=l-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,s,a,o]=i,l=r/e.width*100,p=s/e.height*100,u=a/e.width*100,f=o/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=u-l+"%",t.style.height=f-p+"%"}break;case"ellipse":{let[r,s,a,o]=i,l=r/e.width*100,p=s/e.height*100,u=a/e.width*100,f=o/e.height*100;t.style.left=l-u+"%",t.style.top=p-f+"%",t.style.width=2*u+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"poly":{let r=[];for(let x=0;x<i.length;x+=2)r.push({x:i[x],y:i[x+1]});let s=Math.min(...r.map(x=>x.x)),a=Math.max(...r.map(x=>x.x)),o=Math.min(...r.map(x=>x.y)),l=Math.max(...r.map(x=>x.y)),p=s/e.width*100,u=o/e.height*100,f=a/e.width*100,g=l/e.height*100;t.style.left=p+"%",t.style.top=u+"%",t.style.width=f-p+"%",t.style.height=g-u+"%";let T=r.map(x=>({x:(x.x-s)/(a-s)*100,y:(x.y-o)/(l-o)*100})).map(x=>`${x.x}% ${x.y}%`).join(",");t.style.clipPath=`polygon(${T})`}break;default:console.error(`Unsupported shape: ${c}`);break}}var Wt=b`
253
+ `,n([d({type:Number,reflect:!0})],ge.prototype,"tabindex",2),ge=n([m("qti-gap")],ge);var Zt=(p,s,e)=>{let t=new Map;for(let r=s;r<=e;r++)t.set(p[r],r);return t},Ke=J(class extends ce{constructor(p){if(super(p),p.type!==le.CHILD)throw Error("repeat() can only be used in text expressions")}dt(p,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let r=[],i=[],a=0;for(let o of p)r[a]=t?t(o,a):a,i[a]=e(o,a),a++;return{values:i,keys:r}}render(p,s,e){return this.dt(p,s,e).values}update(p,[s,e,t]){let r=zt(p),{values:i,keys:a}=this.dt(s,e,t);if(!Array.isArray(r))return this.ut=a,i;let o=this.ut??(this.ut=[]),l=[],c,u,f=0,g=r.length-1,y=0,w=i.length-1;for(;f<=g&&y<=w;)if(r[f]===null)f++;else if(r[g]===null)g--;else if(o[f]===a[y])l[y]=K(r[f],i[y]),f++,y++;else if(o[g]===a[w])l[w]=K(r[g],i[w]),g--,w--;else if(o[f]===a[w])l[w]=K(r[f],i[w]),pe(p,l[w+1],r[f]),f++,w--;else if(o[g]===a[y])l[y]=K(r[g],i[y]),pe(p,r[f],r[g]),g--,y++;else if(c===void 0&&(c=Zt(a,y,w),u=Zt(o,f,g)),c.has(o[f]))if(c.has(o[g])){let x=u.get(a[y]),V=x!==void 0?r[x]:null;if(V===null){let S=pe(p,r[f]);K(S,i[y]),l[y]=S}else l[y]=K(V,i[y]),pe(p,r[f],V),r[x]=null;y++}else Xe(r[g]),g--;else Xe(r[f]),f++;for(;y<=w;){let x=pe(p,l[w+1]);K(x,i[y]),l[y++]=x}for(;f<=g;){let x=r[f++];x!==null&&Xe(x)}return this.ut=a,Ft(p,l),ae}});function be(p,s,e,t){switch(p){case"circle":{let[r,i,a]=s,o=r/e.width*100,l=i/e.height*100,c=a/e.width*100;t.style.left=o-c+"%",t.style.top=l-c+"%",t.style.width=t.style.height=4*c+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,i,a,o]=s,l=r/e.width*100,c=i/e.height*100,u=a/e.width*100,f=o/e.height*100;t.style.left=l+"%",t.style.top=c+"%",t.style.width=u-l+"%",t.style.height=f-c+"%"}break;case"ellipse":{let[r,i,a,o]=s,l=r/e.width*100,c=i/e.height*100,u=a/e.width*100,f=o/e.height*100;t.style.left=l-u+"%",t.style.top=c-f+"%",t.style.width=2*u+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"poly":{let r=[];for(let x=0;x<s.length;x+=2)r.push({x:s[x],y:s[x+1]});let i=Math.min(...r.map(x=>x.x)),a=Math.max(...r.map(x=>x.x)),o=Math.min(...r.map(x=>x.y)),l=Math.max(...r.map(x=>x.y)),c=i/e.width*100,u=o/e.height*100,f=a/e.width*100,g=l/e.height*100;t.style.left=c+"%",t.style.top=u+"%",t.style.width=f-c+"%",t.style.height=g-u+"%";let w=r.map(x=>({x:(x.x-i)/(a-i)*100,y:(x.y-o)/(l-o)*100})).map(x=>`${x.x}% ${x.y}%`).join(",");t.style.clipPath=`polygon(${w})`}break;default:console.error(`Unsupported shape: ${p}`);break}}var Gt=b`
254
254
  slot:not([name='prompt']) {
255
255
  // position: relative; /* qti-hotspot-choice relative to the slot */
256
256
  display: block;
@@ -273,14 +273,14 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
273
273
  top: 0px;
274
274
  left: 0px;
275
275
  }
276
- `;var Y=class extends E{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){return h`<slot name="prompt"></slot>
276
+ `;var U=class extends C{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){return h`<slot name="prompt"></slot>
277
277
  <line-container>
278
278
  <svg
279
279
  width=${Q(this.grImage[0]?.width)}
280
280
  height=${Q(this.grImage[0]?.height)}
281
281
  viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
282
282
  >
283
- ${We(this._lines,e=>e,(e,t)=>at`
283
+ ${Ke(this._lines,e=>e,(e,t)=>dt`
284
284
  <line
285
285
  part="line"
286
286
  x1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.left)}
@@ -289,10 +289,10 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
289
289
  y2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.top)}
290
290
  stroke="red"
291
291
  stroke-width="3"
292
- @click=${r=>{r.stopPropagation(),this._lines=this._lines.filter((s,a)=>a!==t),this.saveResponse(this._lines)}}
292
+ @click=${r=>{r.stopPropagation(),this._lines=this._lines.filter((i,a)=>a!==t),this.saveResponse(this._lines)}}
293
293
  />
294
294
  `)}
295
- ${this.startPoint&&at`<line
295
+ ${this.startPoint&&dt`<line
296
296
  part="point"
297
297
  x1=${this.startCoord.x}
298
298
  y1=${this.startCoord.y}
@@ -304,7 +304,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
304
304
  </svg>
305
305
  <slot></slot>
306
306
  </line-container>
307
- <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),a=r.getAttribute("shape"),o=s.split(",").map(l=>parseInt(l));ge(a,o,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Y.styles=Wt,n([C()],Y.prototype,"_lines",2),n([C()],Y.prototype,"startCoord",2),n([C()],Y.prototype,"mouseCoord",2),n([Ht({selector:"img"})],Y.prototype,"grImage",2),Y=n([m("qti-graphic-associate-interaction")],Y);var Kt=b`
307
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),a=r.getAttribute("shape"),o=i.split(",").map(l=>parseInt(l));be(a,o,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};U.styles=Gt,n([E()],U.prototype,"_lines",2),n([E()],U.prototype,"startCoord",2),n([E()],U.prototype,"mouseCoord",2),n([Ot({selector:"img"})],U.prototype,"grImage",2),U=n([m("qti-graphic-associate-interaction")],U);var Qt=b`
308
308
  :host {
309
309
  display: flex;
310
310
  align-items: flex-start;
@@ -358,10 +358,10 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
358
358
  user-select: none;
359
359
  pointer-events: none;
360
360
  }
361
- `;var _e=class extends V(E,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
361
+ `;var ke=class extends N(C,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
362
362
  <slot part="image"></slot>
363
363
  <slot part="drags" name="drags" class="hover-border"></slot>
364
- <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(i){let e=i.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),s=t.split(",").map(a=>parseInt(a));switch(r){case"circle":{let[a,o,l]=s;e.style.left=a-l+"px",e.style.top=o-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[a,o,l,p]=s;e.style.left=a+"px",e.style.top=o+"px",e.style.width=l-a+"px",e.style.height=p-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};_e.styles=Kt,_e=n([m("qti-graphic-gap-match-interaction")],_e);var Jt=b`
364
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(s){let e=s.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),i=t.split(",").map(a=>parseInt(a));switch(r){case"circle":{let[a,o,l]=i;e.style.left=a-l+"px",e.style.top=o-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[a,o,l,c]=i;e.style.left=a+"px",e.style.top=o+"px",e.style.width=l-a+"px",e.style.height=c-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ke.styles=Qt,ke=n([m("qti-graphic-gap-match-interaction")],ke);var er=b`
365
365
  slot:not([name='prompt']) {
366
366
  position: relative; /* qti-hotspot-choice relative to the slot */
367
367
  display: block;
@@ -372,17 +372,17 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
372
372
  pointer-events: none;
373
373
  user-select: none;
374
374
  }
375
- `;var ke=class extends Z(E,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
375
+ `;var Le=class extends Z(C,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
376
376
  <slot name="prompt"></slot>
377
377
  <slot></slot>
378
378
  <div role="alert" id="validationMessage"></div>
379
- `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=s){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),a=r.getAttribute("shape"),o=s.split(",").map(l=>parseInt(l));ge(a,o,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};ke.styles=Jt,ke=n([m("qti-graphic-order-interaction")],ke);var be=class extends $(v,"qti-hotspot-choice"){};be.styles=b`
379
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t);if(!r)return;let i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){let a=this._choiceElements.filter(o=>o.order!=null).length;if(a>=i){this.choiceOrdering=!1;return}r.order=a+1}else{let a=r.order;r.order=null,this._choiceElements.forEach(o=>{o.order!=null&&o.order>a&&o.order--})}this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),a=r.getAttribute("shape"),o=i.split(",").map(l=>parseInt(l));be(a,o,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Le.styles=er,Le=n([m("qti-graphic-order-interaction")],Le);var ve=class extends O(v,"qti-hotspot-choice"){};ve.styles=b`
380
380
  :host {
381
381
  display: flex;
382
382
  user-select: none;
383
383
  position: absolute;
384
384
  }
385
- `,n([d({attribute:"aria-ordervalue",type:Number,reflect:!0})],be.prototype,"order",2),be=n([m("qti-hotspot-choice")],be);var Zt=b`
385
+ `,n([d({attribute:"aria-ordervalue",type:Number,reflect:!0})],ve.prototype,"order",2),ve=n([m("qti-hotspot-choice")],ve);var tr=b`
386
386
  slot:not([name='prompt']) {
387
387
  position: relative; /* qti-hotspot-choice relative to the slot */
388
388
  display: block;
@@ -394,16 +394,16 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
394
394
  user-select: none;
395
395
  /* width:100%; */
396
396
  }
397
- `;var Re=class extends Z(E,"qti-hotspot-choice"){render(){return h`
397
+ `;var Ae=class extends Z(C,"qti-hotspot-choice"){render(){return h`
398
398
  <slot name="prompt"></slot>
399
399
  <slot></slot>
400
- `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),a=r.split(",").map(o=>parseInt(o));ge(s,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};Re.styles=Zt,Re=n([m("qti-hotspot-interaction")],Re);var Ke=class extends Z(E,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}};Ke=n([m("qti-hottext-interaction")],Ke);var Le=class extends $(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
401
- <slot></slot> `}};Le.styles=b`
400
+ `}positionHotspotOnRegister(s){let e=this.querySelector("img"),t=s.target,r=t.getAttribute("coords"),i=t.getAttribute("shape"),a=r.split(",").map(o=>parseInt(o));be(i,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ae.styles=tr,Ae=n([m("qti-hotspot-interaction")],Ae);var Ze=class extends Z(C,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}};Ze=n([m("qti-hottext-interaction")],Ze);var De=class extends O(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
401
+ <slot></slot> `}};De.styles=b`
402
402
  :host {
403
403
  display: flex;
404
404
  user-select: none;
405
405
  }
406
- `,Le=n([m("qti-hottext")],Le);var Ae=class extends le{constructor(i){if(super(i),this.it=R,i.type!==ae.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===R||i==null)return this._t=void 0,this.it=i;if(i===ne)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this._t;this.it=i;let e=[i];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};Ae.directiveName="unsafeHTML",Ae.resultType=1;var ee=K(Ae);var te=class extends E{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[b`
406
+ `,De=n([m("qti-hottext")],De);var Ve=class extends ce{constructor(s){if(super(s),this.it=D,s.type!==le.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(s){if(s===D||s==null)return this._t=void 0,this.it=s;if(s===ae)return s;if(typeof s!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(s===this.it)return this._t;this.it=s;let e=[s];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};Ve.directiveName="unsafeHTML",Ve.resultType=1;var ee=J(Ve);var te=class extends C{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[b`
407
407
  :host {
408
408
  display: inline-block;
409
409
  }
@@ -433,12 +433,12 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
433
433
  </select>
434
434
 
435
435
  ${ee(this.correctOption)}
436
- `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set value(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get value(){return this.options.find(e=>e.selected)?.value||null}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};te.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],n([C()],te.prototype,"options",2),n([C()],te.prototype,"correctOption",2),n([d({attribute:"data-prompt",type:String})],te.prototype,"dataPrompt",2),te=n([m("qti-inline-choice-interaction")],te);var De=class extends v{static get styles(){return[b`
436
+ `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set value(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get value(){return this.options.find(e=>e.selected)?.value||null}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};te.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],n([E()],te.prototype,"options",2),n([E()],te.prototype,"correctOption",2),n([d({attribute:"data-prompt",type:String})],te.prototype,"dataPrompt",2),te=n([m("qti-inline-choice-interaction")],te);var He=class extends v{static get styles(){return[b`
437
437
  :host {
438
438
  display: block;
439
439
  cursor: pointer;
440
440
  }
441
- `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};n([d({type:String})],De.prototype,"identifier",2),De=n([m("qti-inline-choice")],De);var re=class extends $(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
441
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};n([d({type:String})],He.prototype,"identifier",2),He=n([m("qti-inline-choice")],He);var re=class extends O(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
442
442
  <slot part="slot"></slot>
443
443
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
444
444
  `}};re.styles=b`
@@ -453,7 +453,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
453
453
  slot[name='qti-simple-associable-choice'] {
454
454
  width: 100%;
455
455
  }
456
- `,n([d({type:Number,attribute:"match-min"})],re.prototype,"matchMin",2),n([d({type:Number,attribute:"match-max"})],re.prototype,"matchMax",2),n([d({type:Boolean,attribute:"fixed"})],re.prototype,"fixed",2),re=n([m("qti-simple-associable-choice")],re);var Gt=b`
456
+ `,n([d({type:Number,attribute:"match-min"})],re.prototype,"matchMin",2),n([d({type:Number,attribute:"match-max"})],re.prototype,"matchMax",2),n([d({type:Boolean,attribute:"fixed"})],re.prototype,"fixed",2),re=n([m("qti-simple-associable-choice")],re);var rr=b`
457
457
  slot:not([hidden]) {
458
458
  /* slot where the */
459
459
  display: flex;
@@ -480,7 +480,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
480
480
  /* Make sure the drag and drop container slots have the same width */
481
481
  flex: 1;
482
482
  }
483
- `;var U=class extends V(E,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=[];this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,r=t.value,s=t.name,a=t.type;t.checked?(this.value?this.value.indexOf(r)===-1&&(a==="radio"&&(this.value=this.value.filter(o=>o.indexOf(s)===-1)),this.value=[...this.value,r]):this.value=[r],this.lastCheckedRadio=t):(this.value=this.value.filter(o=>o!==r),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e,this.class.split(" ").includes("qti-match-tabular")||(this.value=e))}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
483
+ `;var j=class extends N(C,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=[];this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,r=t.value,i=t.name,a=t.type;t.checked?(this.value?this.value.indexOf(r)===-1&&(a==="radio"&&(this.value=this.value.filter(o=>o.indexOf(i)===-1)),this.value=[...this.value,r]):this.value=[r],this.lastCheckedRadio=t):(this.value=this.value.filter(o=>o!==r),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e,this.class.split(" ").includes("qti-match-tabular")||(this.value=e))}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
484
484
  <slot name="prompt"></slot>
485
485
  <slot ?hidden=${e}></slot>
486
486
 
@@ -493,11 +493,11 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
493
493
 
494
494
  ${this.rows.map(t=>h`<tr>
495
495
  <td part="c-header">${ee(t.innerHTML)}</td>
496
- ${this.cols.map(r=>{let s=t.getAttribute("identifier"),a=r.getAttribute("identifier"),o=`${s} ${a}`,l=this.value.filter(g=>g.split(" ")[0]===s).length||0,p=this.value.includes(o),u=`rb ${p?"rb-checked":""} ${this.correctOptions.includes(o)?"rb-correct":""}`,f=this.correctOptions.length>0?!0:t.matchMax===1?!1:t.matchMax!==0&&l>=t.matchMax&&!p;return h`<td>
496
+ ${this.cols.map(r=>{let i=t.getAttribute("identifier"),a=r.getAttribute("identifier"),o=`${i} ${a}`,l=this.value.filter(g=>g.split(" ")[0]===i).length||0,c=this.value.includes(o),u=`rb ${c?"rb-checked":""} ${this.correctOptions.includes(o)?"rb-correct":""}`,f=this.correctOptions.length>0?!0:t.matchMax===1?!1:t.matchMax!==0&&l>=t.matchMax&&!c;return h`<td>
497
497
  <input
498
498
  type=${t.matchMax===1?"radio":"checkbox"}
499
499
  part=${u}
500
- name=${s}
500
+ name=${i}
501
501
  value=${o}
502
502
  .disabled=${f}
503
503
  @change=${g=>this.handleRadioChange(g)}
@@ -506,11 +506,11 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
506
506
  </td>`})}
507
507
  </tr>`)}
508
508
  </table>
509
- `:R}
509
+ `:D}
510
510
 
511
511
  <div role="alert" id="validationMessage"></div>
512
- `}};U.styles=Gt,n([d({type:String})],U.prototype,"class",2),n([C()],U.prototype,"_response",2),n([d({type:String,attribute:"response-identifier"})],U.prototype,"responseIdentifier",2),n([C()],U.prototype,"correctOptions",2),U=n([m("qti-match-interaction")],U);var He=class extends E{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return{...E.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
513
- <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};He.styles=[b``],He=n([m("qti-media-interaction")],He);var Qt=b`
512
+ `}};j.styles=rr,n([d({type:String})],j.prototype,"class",2),n([E()],j.prototype,"_response",2),n([d({type:String,attribute:"response-identifier"})],j.prototype,"responseIdentifier",2),n([E()],j.prototype,"correctOptions",2),j=n([m("qti-match-interaction")],j);var $e=class extends C{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return{...C.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
513
+ <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};$e.styles=[b``],$e=n([m("qti-media-interaction")],$e);var ir=b`
514
514
  [part='drags'] {
515
515
  display: flex;
516
516
  align-items: flex-start;
@@ -559,16 +559,16 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
559
559
  :host(.qti-choices-right) [part='container'] {
560
560
  flex-direction: row-reverse;
561
561
  }
562
- `;var B=class extends je(V(E,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
562
+ `;var X=class extends Je(N(C,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
563
563
  <div part="container">
564
564
  <slot part="drags"> </slot>
565
565
  <div part="drops">
566
566
  ${Array.from(Array(this.nrChoices)).map((t,r)=>h`<drop-list part="drop-list" identifier="droplist${r}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>r?ee(`<span part='correct-response'>${this.correctResponses[r]}</span>`):""}`)}
567
567
  </div>
568
- </div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(r=>{let s=this.querySelector(`qti-simple-choice[identifier="${r}"]`);s||(s=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${r}"]`));let a=s?.textContent.trim();this.correctResponses=[...this.correctResponses,a]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let s=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(o=>o.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};B.styles=Qt,n([C()],B.prototype,"nrChoices",2),n([C()],B.prototype,"correctResponses",2),n([C()],B.prototype,"showCorrectResponses",2),n([d({type:String})],B.prototype,"orientation",2),B=n([m("qti-order-interaction")],B);var oe=class extends E{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let a=await r.json();for(let o in a.paths)t&&(a.paths[o]=this.getResolvablePath(a.paths[o],t));return a}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(r=>this.getResolvablePathString(r,t)):this.getResolvablePathString(e,t)}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let s in r)if(r.hasOwnProperty(s)){let a=r[s];if(Array.isArray(a))return a.map(String);if(a!=null)return String(a)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),t=JSON.stringify(e);if(t!==this.rawResponse){this.rawResponse=t;let r=this.convertQtiVariableJSON(e);this.value=r,this.saveResponse(r)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}register(e){this.pci=e;let t=this.querySelector("qti-interaction-markup");t.classList.add("qti-customInteraction"),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let r={properties:this.dataset,onready:()=>{console.log("onready")}};if(e.getInstance)e.getInstance(t,r,void 0);else{let a=(o=>{let l={},u=(f=>{let g={};Object.entries(f.dataset).forEach(([T,x])=>{T.includes("__")||(g[T]=x)});let y={};return Object.entries(f.dataset).forEach(([T,x])=>{let j=T.split("__");if(j.length>1){let[M,W,pr]=j;y[M]=y[M]||{},y[M][W]=y[M][W]||{},y[M][W][pr]=x}}),Object.entries(y).forEach(([T,x])=>{g[T]=Object.values(x)}),g})(o);for(let f in u)if(Object.prototype.hasOwnProperty.call(u,f)){let g=u[f];f==="config"?l[f]=JSON.parse(g):l[f]=g}return l})(this);e.initialize(this.customInteractionTypeIdentifier,t.firstElementChild,Object.keys(a).length?a:null)}this.startChecking()}connectedCallback(){super.connectedCallback(),console.log("connectedCallback"),define("qtiCustomInteractionContext",()=>({register:r=>{this.register(r)},notifyReady:()=>{}}));let e=this.buildRequireConfig(),t=requirejs.config(e);requirejs.onError=function(r){throw console.error("RequireJS error:",r),r.requireType==="timeout"&&console.error("Modules that timed out:",r.requireModules),r},t(["require"],r=>{try{r([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),r=this.querySelector("qti-interaction-modules");if(r){let s=r.querySelectorAll("qti-interaction-module");for(let a of s){let o=a.getAttribute("id"),l=a.getAttribute("primary-path"),p=a.getAttribute("fallback-path");if(o&&l){let u=p?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(p,t)):this.getResolvablePath(l,t),f=e.paths[o]||[];e.paths[o]=this.combineRequireResolvePaths(f,u)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return r.concat(s).filter((a,o,l)=>l.indexOf(a)===o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return h`<slot></slot>${this._errorMessage&&h`<div style="color:red">
568
+ </div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(r=>{let i=this.querySelector(`qti-simple-choice[identifier="${r}"]`);i||(i=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${r}"]`));let a=i?.textContent.trim();this.correctResponses=[...this.correctResponses,a]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let i=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(i).map(o=>o.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};X.styles=ir,n([E()],X.prototype,"nrChoices",2),n([E()],X.prototype,"correctResponses",2),n([E()],X.prototype,"showCorrectResponses",2),n([d({type:String})],X.prototype,"orientation",2),X=n([m("qti-order-interaction")],X);var oe=class extends C{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let a=await r.json();for(let o in a.paths)t&&(a.paths[o]=this.getResolvablePath(a.paths[o],t));return a}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(r=>this.getResolvablePathString(r,t)):this.getResolvablePathString(e,t)}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let i in r)if(r.hasOwnProperty(i)){let a=r[i];if(Array.isArray(a))return a.map(String);if(a!=null)return String(a)}}}return null}addHyphenatedKeys(e){let t={...e};for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let i=r.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);t[i]=e[r]}return t}responseVariablesToQtiVariableJSON(e){return Array.isArray(e)?{list:{string:e}}:{base:{string:e||""}}}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),t=JSON.stringify(e);if(t!==this.rawResponse){this.rawResponse=t;let r=this.convertQtiVariableJSON(e);this.value=r,this.saveResponse(r)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}register(e){this.pci=e;let t=this.querySelector("qti-interaction-markup");t.classList.add("qti-customInteraction"),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let r=this.responseVariablesToQtiVariableJSON(this.value),i={properties:this.addHyphenatedKeys({...this.dataset}),onready:a=>{this.pci=a},responseIdentifier:this.responseIdentifier,boundTo:r.base||r.list};if(e.getInstance)e.getInstance(t,i,void 0);else{let o=(l=>{let c={},f=(g=>{let y={};Object.entries(g.dataset).forEach(([x,V])=>{x.includes("__")||(y[x]=V)});let w={};return Object.entries(g.dataset).forEach(([x,V])=>{let S=x.split("__");if(S.length>1){let[H,pt,mr]=S;w[H]=w[H]||{},w[H][pt]=w[H][pt]||{},w[H][pt][mr]=V}}),Object.entries(w).forEach(([x,V])=>{y[x]=Object.values(V)}),y})(l);for(let g in f)if(Object.prototype.hasOwnProperty.call(f,g)){let y=f[g];g==="config"?c[g]=JSON.parse(y):c[g]=y}return c})(this);e.initialize(this.customInteractionTypeIdentifier,t.firstElementChild,Object.keys(o).length?o:null)}this.startChecking()}connectedCallback(){super.connectedCallback(),console.log("connectedCallback"),define("qtiCustomInteractionContext",()=>({register:r=>{this.register(r)},notifyReady:()=>{}}));let e=this.buildRequireConfig(),t=requirejs.config(e);requirejs.onError=function(r){throw console.error("RequireJS error:",r),r.requireType==="timeout"&&console.error("Modules that timed out:",r.requireModules),r},t(["require"],r=>{try{r([this.module],()=>{},i=>{console.error("Error loading module:",i)})}catch(i){console.error("Error in require call:",i)}})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),r=this.querySelector("qti-interaction-modules");if(r){let i=r.querySelectorAll("qti-interaction-module");for(let a of i){let o=a.getAttribute("id"),l=a.getAttribute("primary-path"),c=a.getAttribute("fallback-path");if(o&&l){let u=c?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(c,t)):this.getResolvablePath(l,t),f=e.paths[o]||[];e.paths[o]=this.combineRequireResolvePaths(f,u)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t];return r.concat(i).filter((a,o,l)=>l.indexOf(a)===o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return h`<slot></slot>${this._errorMessage&&h`<div style="color:red">
569
569
  <h1>Error</h1>
570
570
  ${this._errorMessage}
571
- </div>`}`}};n([d({type:String,attribute:"module"})],oe.prototype,"module",2),n([d({type:String,attribute:"custom-interaction-type-identifier"})],oe.prototype,"customInteractionTypeIdentifier",2),n([C()],oe.prototype,"_errorMessage",2),oe=n([m("qti-portable-custom-interaction")],oe);var Je=class extends v{render(){return h`<slot></slot>`}};Je.styles=[b`
571
+ </div>`}`}};n([d({type:String,attribute:"module"})],oe.prototype,"module",2),n([d({type:String,attribute:"custom-interaction-type-identifier"})],oe.prototype,"customInteractionTypeIdentifier",2),n([E()],oe.prototype,"_errorMessage",2),oe=n([m("qti-portable-custom-interaction")],oe);var Ge=class extends v{render(){return h`<slot></slot>`}};Ge.styles=[b`
572
572
  :host {
573
573
  display: block;
574
574
  }
@@ -579,19 +579,19 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
579
579
  left: 50%;
580
580
  transform: translateX(-50%);
581
581
  }
582
- `];customElements.define("qti-position-object-interaction",Je);var Ve=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(i){i.preventDefault();let e=i.clientX-this.startX,t=i.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=i.clientX,this.startY=i.clientY}firstUpdated(i){super.firstUpdated(i),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};Ve.styles=[b`
582
+ `];customElements.define("qti-position-object-interaction",Ge);var Ne=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(s){s.preventDefault();let e=s.clientX-this.startX,t=s.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=s.clientX,this.startY=s.clientY}firstUpdated(s){super.firstUpdated(s),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};Ne.styles=[b`
583
583
  :host {
584
584
  display: inline-block;
585
585
  position: relative;
586
586
  }
587
- `],Ve=n([m("qti-position-object-stage")],Ve);var er="important",ur=" !"+er,tr=K(class extends le{constructor(c){if(super(c),c.type!==ae.ATTRIBUTE||c.name!=="style"||c.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(c){return Object.keys(c).reduce((i,e)=>{let t=c[e];return t==null?i:i+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(c,[i]){let{style:e}=c.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let t of this.ft)i[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in i){let r=i[t];if(r!=null){this.ft.add(t);let s=typeof r=="string"&&r.endsWith(ur);t.includes("-")||s?e.setProperty(t,s?r.slice(0,-11):r,s?er:""):e[t]=r}}return ne}});var ie=class extends E{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this.maxChoices===0||this._points.length<this.maxChoices){let t=e.offsetX,r=e.offsetY;this._points=[...this._points,`${t} ${r}`],this.saveResponse(this._points)}}}render(){return h` <slot name="prompt"></slot>
587
+ `],Ne=n([m("qti-position-object-stage")],Ne);var sr="important",gr=" !"+sr,or=J(class extends ce{constructor(p){if(super(p),p.type!==le.ATTRIBUTE||p.name!=="style"||p.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(p){return Object.keys(p).reduce((s,e)=>{let t=p[e];return t==null?s:s+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(p,[s]){let{style:e}=p.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(s)),this.render(s);for(let t of this.ft)s[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in s){let r=s[t];if(r!=null){this.ft.add(t);let i=typeof r=="string"&&r.endsWith(gr);t.includes("-")||i?e.setProperty(t,i?r.slice(0,-11):r,i?sr:""):e[t]=r}}return ae}});var ie=class extends C{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this.maxChoices===0||this._points.length<this.maxChoices){let t=e.offsetX,r=e.offsetY;this._points=[...this._points,`${t} ${r}`],this.saveResponse(this._points)}}}render(){return h` <slot name="prompt"></slot>
588
588
  <point-container>
589
- ${We(this._points,e=>e,(e,t)=>h`
589
+ ${Ke(this._points,e=>e,(e,t)=>h`
590
590
  <button
591
591
  part="point"
592
- style=${tr({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
592
+ style=${or({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
593
593
  aria-label="Remove point at ${e}"
594
- @click=${r=>{r.stopPropagation(),this._points=this._points.filter((s,a)=>a!==t),this.saveResponse(this._points)}}
594
+ @click=${r=>{r.stopPropagation(),this._points=this._points.filter((i,a)=>a!==t),this.saveResponse(this._points)}}
595
595
  ></button>
596
596
  `)}
597
597
  <slot></slot>
@@ -603,11 +603,11 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
603
603
  display: block;
604
604
  position: relative;
605
605
  }
606
- `],n([d({type:Number,attribute:"max-choices"})],ie.prototype,"maxChoices",2),n([d({type:Number,attribute:"min-choices"})],ie.prototype,"minChoices",2),n([C()],ie.prototype,"_points",2),ie=n([m("qti-select-point-interaction")],ie);var ve=class extends $(v,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
606
+ `],n([d({type:Number,attribute:"max-choices"})],ie.prototype,"maxChoices",2),n([d({type:Number,attribute:"min-choices"})],ie.prototype,"minChoices",2),n([E()],ie.prototype,"_points",2),ie=n([m("qti-select-point-interaction")],ie);var ye=class extends O(v,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
607
607
  <div part="cha"></div>
608
608
  </div>
609
- ${this.marker?h`<div id="label">${this.marker}</div>`:R}
610
- <slot part="slot"></slot> `}};ve.styles=b`
609
+ ${this.marker?h`<div id="label">${this.marker}</div>`:D}
610
+ <slot part="slot"></slot> `}};ye.styles=b`
611
611
  :host {
612
612
  display: flex;
613
613
  align-items: center;
@@ -624,7 +624,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
624
624
  align-items: center;
625
625
  justify-content: center;
626
626
  }
627
- `,n([d({type:String,attribute:!1})],ve.prototype,"marker",2),ve=n([m("qti-simple-choice")],ve);var rr=b`
627
+ `,n([d({type:String,attribute:!1})],ye.prototype,"marker",2),ye=n([m("qti-simple-choice")],ye);var nr=b`
628
628
  :host {
629
629
  display: block;
630
630
  --show-bounds: true;
@@ -692,7 +692,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
692
692
  text-align: center;
693
693
  color: #6b7280; /* text-gray-500 */
694
694
  }
695
- `;var N=class extends v{constructor(){super();this._value=0;this.min=0;this.max=100;this.step=1;this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get value(){return this._value.toString()}set value(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}_updateValue(e){this._value=Math.min(this.max,Math.max(this.min,e));let t=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${t}%`),this._internals.setFormValue(this.value),this.requestUpdate()}render(){return h`
695
+ `;var I=class extends v{constructor(){super();this._value=0;this.min=0;this.max=100;this.step=1;this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get value(){return this._value.toString()}set value(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}_updateValue(e){this._value=Math.min(this.max,Math.max(this.min,e));let t=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${t}%`),this._internals.setFormValue(this.value),this.requestUpdate()}render(){return h`
696
696
  <slot name="prompt"></slot>
697
697
  <div id="slider" part="slider">
698
698
  <div id="bounds" part="bounds">
@@ -706,7 +706,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
706
706
  <div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
707
707
  </div>
708
708
  </div>
709
- `}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",r)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),r=e-t.left,s=Math.min(1,Math.max(0,r/t.width)),a=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};N.formAssociated=!0,N.styles=rr,n([Ye("#rail")],N.prototype,"_rail",2),n([d({type:Number,attribute:"lower-bound"})],N.prototype,"min",2),n([d({type:Number,attribute:"upper-bound"})],N.prototype,"max",2),n([d({type:Number,attribute:"step"})],N.prototype,"step",2),N=n([m("qti-slider-interaction")],N);var ir=()=>new pt,pt=class{},ct=new WeakMap,Ia=K(class extends It{render(c){return R}update(c,[i]){let e=i!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=i,this.ht=c.options?.host,this.rt(this.ct=c.element)),R}rt(c){if(this.isConnected||(c=void 0),typeof this.Y=="function"){let i=this.ht??globalThis,e=ct.get(i);e===void 0&&(e=new WeakMap,ct.set(i,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,c),c!==void 0&&this.Y.call(this.ht,c)}else this.Y.value=c}get lt(){return typeof this.Y=="function"?ct.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var sr=b`
709
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=i=>this._onDrag(i.pageX),r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=i=>this._onDrag(i.touches[0].pageX),r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",r)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),r=e-t.left,i=Math.min(1,Math.max(0,r/t.width)),a=this.min+Math.round(i*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};I.formAssociated=!0,I.styles=nr,n([Ue("#rail")],I.prototype,"_rail",2),n([d({type:Number,attribute:"lower-bound"})],I.prototype,"min",2),n([d({type:Number,attribute:"upper-bound"})],I.prototype,"max",2),n([d({type:Number,attribute:"step"})],I.prototype,"step",2),I=n([m("qti-slider-interaction")],I);var ar=()=>new mt,mt=class{},ht=new WeakMap,Ba=J(class extends Bt{render(p){return D}update(p,[s]){let e=s!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=s,this.ht=p.options?.host,this.rt(this.ct=p.element)),D}rt(p){if(this.isConnected||(p=void 0),typeof this.Y=="function"){let s=this.ht??globalThis,e=ht.get(s);e===void 0&&(e=new WeakMap,ht.set(s,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,p),p!==void 0&&this.Y.call(this.ht,p)}else this.Y.value=p}get lt(){return typeof this.Y=="function"?ht.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var lr=b`
710
710
  :host {
711
711
  display: inline-block;
712
712
  }
@@ -788,7 +788,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
788
788
  width: 57rem;
789
789
  min-width: 57rem;
790
790
  }
791
- `;var O=class extends E{constructor(){super(...arguments);this._value="";this.inputRef=ir()}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return h`
791
+ `;var P=class extends C{constructor(){super(...arguments);this._value="";this.inputRef=ar()}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return h`
792
792
  <input
793
793
  part="input"
794
794
  name="${this.responseIdentifier}"
@@ -807,12 +807,12 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
807
807
  ?readonly="${this.readonly}"
808
808
  />
809
809
  <div part="correct">${this._correctResponse}</div>
810
- `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};O.styles=sr,n([d({type:Number,attribute:"expected-length"})],O.prototype,"expectedLength",2),n([d({type:String,attribute:"pattern-mask"})],O.prototype,"patternMask",2),n([d({type:String,attribute:"placeholder-text"})],O.prototype,"placeholderText",2),n([d({type:String,attribute:"data-patternmask-message"})],O.prototype,"dataPatternmaskMessage",2),n([C()],O.prototype,"_value",2),O=n([m("qti-text-entry-interaction")],O);var $e=class extends E{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get value(){return this._base64}set value(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...E.properties}}render(){return h`
810
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};P.styles=lr,n([d({type:Number,attribute:"expected-length"})],P.prototype,"expectedLength",2),n([d({type:String,attribute:"pattern-mask"})],P.prototype,"patternMask",2),n([d({type:String,attribute:"placeholder-text"})],P.prototype,"placeholderText",2),n([d({type:String,attribute:"data-patternmask-message"})],P.prototype,"dataPatternmaskMessage",2),n([E()],P.prototype,"_value",2),P=n([m("qti-text-entry-interaction")],P);var Oe=class extends C{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get value(){return this._base64}set value(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...C.properties}}render(){return h`
811
811
  <div>
812
812
  <slot name="prompt"></slot>
813
813
  <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
814
814
  </div>
815
- `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,r)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>r(s.error),s.readAsDataURL(e)})}};$e.styles=[b`
815
+ `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,r)=>{let i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}};Oe.styles=[b`
816
816
  :host {
817
817
  display: block;
818
818
  margin: 1em 0;
@@ -821,15 +821,15 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
821
821
  display: block;
822
822
  margin-top: 0.5em;
823
823
  }
824
- `],$e=n([m("qti-upload-interaction")],$e);var or=b`
824
+ `],Oe=n([m("qti-upload-interaction")],Oe);var cr=b`
825
825
  :host {
826
826
  display: block;
827
827
  }
828
- `;var Ne=class extends v{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};Ne.styles=or,Ne=n([m("qti-item-body")],Ne);var Oe=class extends v{render(){return h`<slot></slot>`}process(){let i=new dt,e=[...this.children];i.process(e)}};Oe.styles=[b`
828
+ `;var Ie=class extends v{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};Ie.styles=cr,Ie=n([m("qti-item-body")],Ie);var Pe=class extends v{render(){return h`<slot></slot>`}process(){let s=new ft,e=[...this.children];s.process(e)}};Pe.styles=[b`
829
829
  :host {
830
830
  display: none;
831
831
  }
832
- `],Oe=n([m("qti-outcome-processing")],Oe);var dt=class{process(i){for(let e of i)e.process()}};var Ze=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Ze=n([m("qti-prompt")],Ze);var nr=`<qti-response-processing>
832
+ `],Pe=n([m("qti-outcome-processing")],Pe);var ft=class{process(s){for(let e of s)e.process()}};var Qe=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Qe=n([m("qti-prompt")],Qe);var pr=`<qti-response-processing>
833
833
  <qti-response-condition>
834
834
  <qti-response-if>
835
835
  <qti-match>
@@ -846,7 +846,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
846
846
  </qti-set-outcome-value>
847
847
  </qti-response-else>
848
848
  </qti-response-condition>
849
- </qti-response-processing>`,ar=`<qti-response-processing>
849
+ </qti-response-processing>`,dr=`<qti-response-processing>
850
850
  <qti-response-condition>
851
851
  <qti-response-if>
852
852
  <qti-is-null>
@@ -862,7 +862,7 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
862
862
  </qti-set-outcome-value>
863
863
  </qti-response-else>
864
864
  </qti-response-condition>
865
- </qti-response-processing>`,lr=`<qti-response-processing>
865
+ </qti-response-processing>`,ur=`<qti-response-processing>
866
866
  <qti-response-condition>
867
867
  <qti-response-if>
868
868
  <qti-is-null>
@@ -878,23 +878,28 @@ import{a as Ue}from"./chunk-EHK76KRT.js";import{a as ae,b as K,c as le,e as ce,f
878
878
  </qti-set-outcome-value>
879
879
  </qti-response-else>
880
880
  </qti-response-condition>
881
- </qti-response-processing>`;var Ie=class extends v{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(i){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(ar).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(lr).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(nr).firstElementChild.firstElementChild);break}}}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};Ie.styles=[b`
881
+ </qti-response-processing>`;var Fe=class extends v{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(s){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(dr).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(ur).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(pr).firstElementChild.firstElementChild);break}}}fragmentFromString(s){return document.createRange().createContextualFragment(s)}};Fe.styles=[b`
882
882
  :host {
883
883
  display: none;
884
884
  }
885
- `],Ie=n([m("qti-response-processing")],Ie);var I=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};I=n([m("qti-rule")],I);var Ge=class extends I{get childExpression(){return this.firstElementChild}process(){let i=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(i),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 h`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ut);var ht=class extends I{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,r=new mt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:Array.isArray(r)?r.map(s=>Ee(s)):Ee(r)}}))}},mt=class{constructor(i){this.expression=i}process(){let i=this.expression?this.expression.calculate():null;if(i==null){console.warn("setOutcomeValue: value is null or undefined");return}return i}};customElements.define("qti-set-outcome-value",ht);var Pe=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Pe);var Fe=class extends Pe{calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Fe);var ft=class extends Fe{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",ft);var cr=class extends hr(H){calculate(){return this.calculateChildren(Array.from(this.children))}};function hr(c){return class extends c{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=s.calculate(),o=!1;if(typeof a=="string")if(a==="true")o=!0;else if(a==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(o=a);return o}).every(r=>typeof r=="boolean"&&r)}}}var Qe=class extends q{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 H{getResult(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,s=t.value;return r.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",gt);var bt=class extends q{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let i=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===i)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",bt);var et=class extends q{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),a=parseFloat(r.value);if(!isNaN(s)&&!isNaN(a))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(s*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: ${s}, ${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(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),s=parseInt(e,10);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),s=parseFloat(e);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),s=e.split(" ").sort();if(r.length===2&&s.length===2)return t==="pair"&&(r.sort(),s.sort()),r.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var tt=class extends q{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):A.compareSingleValues(t.value,r.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 q{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[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 H{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",yt);var xt=class extends q{getResult(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",xt);var Et=class extends q{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[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 H{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[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 rt=class extends q{getResult(){let i=this.context.variables.find(s=>s.identifier===this.identifier);if(!i||!i.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=i.mapping,t=Array.isArray(i.value)?i.value:[i.value],r=0;for(let s of t){let a=e.mapEntries.find(o=>A.compareSingleValues(o.mapKey,s,i.baseType));a==null||a.mappedValue==null?r+=e.defaultValue:r+=a.mappedValue}return e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};n([d({type:String})],rt.prototype,"identifier",2);customElements.define("qti-map-response",rt);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 q{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return c.match(e,t)}return console.error("unexpected number of children in match"),null}static match(i,e){switch(e.cardinality){case"single":return i.value===null?!1:Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):A.compareSingleValues(i.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;for(let t=0;t<i.value.length;t++)if(!A.compareSingleValues(e.value[t],i.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){let s=null,a=[...i.value];for(let o of a)if(A.compareSingleValues(r,o,e.baseType)){s=o;break}if(s!==null)a.splice(a.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",qt);var Tt=class extends q{getResult(){let i=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=i;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 r=e.value;return t.value.includes(r)}};customElements.define("qti-member",Tt);var Mt=class extends q{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Mt);var wt=class extends q{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",wt);var St=class extends H{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate(),s=!1;if(typeof r=="string")if(r==="true")s=!0;else if(r==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(s=r);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",St);var _t=class extends q{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",_t);var ze=class extends v{render(){let i=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(i,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}),C()],ze.prototype,"context",2);customElements.define("qti-printed-variable",ze);var kt=class extends q{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",kt);var it=class extends mr(q){getResult(){return this.calculateChildren(Array.from(this.children))}};function mr(c){return class extends c{calculateChildren(e){let t=e.map(r=>{if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=r.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(r=>r===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",it);var st=class extends q{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return A.compareSingleValues(s,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 q{constructor(){super(),this._expression=new Lt(Array.from(this.children))}getResult(){return this._expression.calculate()}},Lt=class{constructor(i){this.expressions=i}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Rt);var At=class extends q{getResult(){let i=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===i).value}};customElements.define("qti-variable",At);var ot=class extends v{render(){return h`<slot></slot>`}};ot=n([m("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 h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};P.styles=b`
885
+ `],Fe=n([m("qti-response-processing")],Fe);var F=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};F=n([m("qti-rule")],F);var et=class extends F{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:qe(t)}})),t)}};n([d({type:String})],et.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",et);var gt=class extends F{render(){return h`<slot></slot>`}process(){let s=[...this.children];for(let e=0;e<s.length;e++){let t=s[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",gt);var bt=class extends F{process(){let s=this.getAttribute("identifier"),e=this.firstElementChild,r=new vt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:s,value:Array.isArray(r)?r.map(i=>qe(i)):qe(r)}}))}},vt=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",bt);var ze=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let s=this.getSubRules();for(let e=0;e<s.length;e++)s[e].process()}};customElements.define("qti-response-else",ze);var Be=class extends ze{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",Be);var yt=class extends Be{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",yt);var hr=class extends br($){calculate(){return this.calculateChildren(Array.from(this.children))}};function br(p){return class extends p{calculateChildren(e){return e.map(r=>{let i=r;if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=i.calculate(),o=!1;if(typeof a=="string")if(a==="true")o=!0;else if(a==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(o=a);return o}).every(r=>typeof r=="boolean"&&r)}}}var tt=class extends q{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([d({type:String,attribute:"base-type"})],tt.prototype,"baseType",2);customElements.define("qti-base-value",tt);var xt=class extends ${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 r=e.value,i=t.value;return r.filter(l=>i.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}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",xt);var Et=class extends q{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let s=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===s)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Et);var rt=class extends q{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let i=parseFloat(t.value),a=parseFloat(r.value);if(!isNaN(i)&&!isNaN(a))return this.roundingMode==="significantFigures"?i.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(i*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: ${i}, ${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})],rt.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",rt);var M=class{static isPointInArea(s,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[r,i]=s.split(" ").map(Number),[a,...o]=e.split(","),l=o.map(Number);switch(a.toLowerCase()){case"circle":case"default":{let[c,u,f]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((r-c)**2+(i-u)**2)<=f}case"rect":{let[c,u,f,g]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):r>=c&&r<=f&&i>=u&&i<=g}case"ellipse":{let[c,u,f,g]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let y=(r-c)**2/f**2,w=(i-u)**2/g**2;return y+w<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let u=0;u<l.length;u+=2)c.push({x:l[u],y:l[u+1]});return this.isPointInPolygon({x:r,y:i},c)}default:return console.warn(`Unsupported shape type: ${a}`),!1}}static isPointInPolygon(s,e){let t=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let a=e[r].x,o=e[r].y,l=e[i].x,c=e[i].y;o>s.y!=c>s.y&&s.x<(l-a)*(s.y-o)/(c-o)+a&&(t=!t)}return t}static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let r=parseInt(s,10),i=parseInt(e,10);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let r=parseFloat(s),i=parseFloat(e);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=s.split(" ").sort(),i=e.split(" ").sort();if(r.length===2&&i.length===2)return t==="pair"&&(r.sort(),i.sort()),r.join(" ")===i.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${s} 2: ${e}`);break}}return!1}};var it=class extends q{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):M.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([d({type:String})],it.prototype,"toleranceMode",2);customElements.define("qti-equal",it);var Ct=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Ct);var qt=class extends ${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",qt);var wt=class extends q{getResult(){if(this.children.length===1){let s=this.getVariables();if(!s)return!0;let e=s[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",wt);var Tt=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Tt);var Mt=class extends ${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",Mt);var st=class extends q{getResult(){let s=this.context.variables.find(i=>i.identifier===this.identifier);if(!s||!s.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=s.mapping,t=Array.isArray(s.value)?s.value:[s.value],r=0;for(let i of t){let a=e.mapEntries.find(o=>M.compareSingleValues(o.mapKey,i,s.baseType));a==null||a.mappedValue==null?r+=e.defaultValue:r+=a.mappedValue}return e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};n([d({type:String})],st.prototype,"identifier",2);customElements.define("qti-map-response",st);var ne=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.context.variables.find(i=>i.identifier===t)||null}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(i=>i.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.context.variables.find(i=>i.identifier===t)||null;return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
886
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};ne.styles=b`
887
+ slot {
888
+ display: none;
889
+ }
890
+ `,n([E()],ne.prototype,"result",2),n([A({context:T,subscribe:!0}),E()],ne.prototype,"context",2);var ot=class extends ne{getResult(){let s=this.context.variables.find(a=>a.identifier===this.identifier);if(!s)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=s.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(s.value)?s.value:[s.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let r=0,i=new Set;for(let a of t)for(let o of e.mapEntries){if(i.has(o.coords))continue;M.isPointInArea(a,`${o.shape},${o.coords}`,s.baseType)&&(r+=o.mappedValue??0,i.add(o.coords))}return i.size<t.length&&(r+=e.defaultValue),e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};n([d({type:String})],ot.prototype,"identifier",2);customElements.define("qti-map-response-point",ot);var xe=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})],xe.prototype,"defaultValue",2),n([d({attribute:"lower-bound",type:Number})],xe.prototype,"lowerBound",2),n([d({attribute:"upper-bound",type:Number})],xe.prototype,"upperBound",2);customElements.define("qti-mapping",xe);var Ee=class extends v{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-area-map-entry")).map(e=>({shape:e.getAttribute("shape"),coords:e.getAttribute("coords"),mappedValue:+e.getAttribute("mapped-value"),defaultValue:e.getAttribute("default-value")?+e.getAttribute("default-value"):0}))}};n([d({attribute:"default-value",type:Number})],Ee.prototype,"defaultValue",2),n([d({attribute:"lower-bound",type:Number})],Ee.prototype,"lowerBound",2),n([d({attribute:"upper-bound",type:Number})],Ee.prototype,"upperBound",2);customElements.define("qti-area-mapping",Ee);var St=class p extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return p.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):M.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(!M.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 r of e.value){let i=null,a=[...s.value];for(let o of a)if(M.compareSingleValues(r,o,e.baseType)){i=o;break}if(i!==null)a.splice(a.indexOf(i),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",St);var _t=class extends q{getResult(){let s=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=s;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",_t);var Rt=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return s}};customElements.define("qti-multiple",Rt);var kt=class extends q{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",kt);var Lt=class extends ${getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate(),i=!1;if(typeof r=="string")if(r==="true")i=!0;else if(r==="false")i=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(i=r);return i}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Lt);var At=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return s}};customElements.define("qti-ordered",At);var Ye=class extends v{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([d({type:String})],Ye.prototype,"identifier",2),n([A({context:T,subscribe:!0}),E()],Ye.prototype,"context",2);customElements.define("qti-printed-variable",Ye);var Dt=class extends q{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",Dt);var nt=class extends vr(q){getResult(){return this.calculateChildren(Array.from(this.children))}};function vr(p){return class extends p{calculateChildren(e){let t=e.map(r=>{if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate();return Number.isNaN(i)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(i)});return t.some(r=>r===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",nt);var at=class extends q{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let i=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return M.compareSingleValues(i,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([d({type:String,attribute:"case-sensitive"})],at.prototype,"caseSensitive",2);customElements.define("qti-string-match",at);var Vt=class extends q{constructor(){super(),this._expression=new Ht(Array.from(this.children))}getResult(){return this._expression.calculate()}},Ht=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",Vt);var $t=class extends q{getResult(){let s=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===s).value}};customElements.define("qti-variable",$t);var lt=class extends v{render(){return h`<slot></slot>`}};lt=n([m("qti-content-body")],lt);var z=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 h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};z.styles=b`
886
891
  :host {
887
892
  display: block;
888
893
  }
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([m("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(r=>r.text()).then(r=>{let s=this.minifyCss(r);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(r=>{console.error("Failed to load stylesheet:",r)}),this.textContent!==null&&this.textContent.trim()!==""){let r=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}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([m("qti-stylesheet")],nt);var se=class extends v{render(){return h`<slot></slot>`}defaultValues(i){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML.trim());return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};se=n([m("qti-variabledeclaration")],se);var F=class extends se{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let s=parseInt(r.getAttribute("source-value")),a=parseInt(r.getAttribute("target-value"));(isNaN(s)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,a)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};F.styles=[b`
894
+ `,n([d({type:String})],z.prototype,"id",2),n([d({type:String})],z.prototype,"use",2),n([d({type:String})],z.prototype,"view",2),n([d({type:String,attribute:"class"})],z.prototype,"classNames",2),n([_("classNames",{waitUntilFirstUpdate:!0})],z.prototype,"handleclassNamesChange",1),z=n([m("qti-rubric-block")],z);var ct=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(r=>r.text()).then(r=>{let i=this.minifyCss(r);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.")}).catch(r=>{console.error("Failed to load stylesheet:",r)}),this.textContent!==null&&this.textContent.trim()!==""){let r=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}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()}};ct=n([m("qti-stylesheet")],ct);var se=class extends v{render(){return h`<slot></slot>`}defaultValues(s){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML.trim());return t.length>1||s.cardinality==="multiple"||s.cardinality==="ordered"?t:t[0]}};se=n([m("qti-variabledeclaration")],se);var B=class extends se{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let i=parseInt(r.getAttribute("source-value")),a=parseInt(r.getAttribute("target-value"));(isNaN(i)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(i,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}}))}};B.styles=[b`
890
895
  :host {
891
896
  display: none;
892
897
  }
893
- `],n([d({type:String,attribute:"base-type"})],F.prototype,"baseType",2),n([d({type:String,attribute:"external-scored"})],F.prototype,"externalScored",2),n([d({type:String})],F.prototype,"identifier",2),n([d({type:String})],F.prototype,"cardinality",2),n([D({context:L,subscribe:!0}),C()],F.prototype,"itemContext",2),F=n([m("qti-outcome-declaration")],F);var X=class extends se{render(){let i=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(i,null,2)}`}connectedCallback(){super.connectedCallback();let i={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};i.value=this.defaultValues(i),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:i}}))}get correctResponse(){let i,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)i=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){i=[];for(let r=0;r<t.length;r++)i.push(t[r].textContent.trim()),t[r].remove()}}return i}get mapping(){return this.querySelector("qti-mapping")}};X.styles=[b`
898
+ `],n([d({type:String,attribute:"base-type"})],B.prototype,"baseType",2),n([d({type:String,attribute:"external-scored"})],B.prototype,"externalScored",2),n([d({type:String})],B.prototype,"identifier",2),n([d({type:String})],B.prototype,"cardinality",2),n([A({context:T,subscribe:!0}),E()],B.prototype,"itemContext",2),B=n([m("qti-outcome-declaration")],B);var W=class extends se{render(){let s=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}connectedCallback(){super.connectedCallback();let s={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};s.value=this.defaultValues(s),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:s}}))}get correctResponse(){let s,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)s=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){s=[];for(let r=0;r<t.length;r++)s.push(t[r].textContent.trim()),t[r].remove()}}return s}get mapping(){return this.querySelector("qti-mapping")}get areaMapping(){return this.querySelector("qti-area-mapping")}};W.styles=[b`
894
899
  :host {
895
900
  display: none;
896
901
  }
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}),C()],X.prototype,"itemContext",2),X=n([m("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,G 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,te as y,De as z,re as A,U as B,He as C,B as D,oe as E,Je as F,Ve as G,ie 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,cr as Z,hr 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,rt 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,it as ta,mr 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};
902
+ `],n([d({type:String,attribute:"base-type"})],W.prototype,"baseType",2),n([d({type:String})],W.prototype,"identifier",2),n([d({type:String})],W.prototype,"cardinality",2),n([A({context:T,subscribe:!0}),E()],W.prototype,"itemContext",2),W=n([m("qti-response-declaration")],W);export{R as a,de as b,We as c,Ce as d,Te as e,Me as f,Se as g,_e as h,ue as i,he as j,Y as k,G as l,L as m,me as n,Re as o,fe as p,ge as q,U as r,ke as s,Le as t,ve as u,Ae as v,Ze as w,De as x,te as y,He as z,re as A,j as B,$e as C,X as D,oe as E,Ge as F,Ne as G,ie as H,ye as I,I as J,P as K,Oe as L,Ie as M,Pe as N,ft as O,Qe as P,Fe as Q,F as R,et as S,gt as T,bt as U,vt as V,ze as W,Be as X,yt as Y,hr as Z,br as _,tt as $,xt as aa,Et as ba,rt as ca,it as da,Ct as ea,qt as fa,wt as ga,Tt as ha,Mt as ia,st as ja,ot as ka,xe as la,Ee as ma,St as na,_t as oa,Rt as pa,kt as qa,Lt as ra,At as sa,Ye as ta,Dt as ua,nt as va,vr as wa,at as xa,Vt as ya,Ht as za,$t as Aa,lt as Ba,z as Ca,ct as Da,B as Ea,W as Fa};
898
903
  /*! Bundled license information:
899
904
 
900
905
  lit-html/node/directives/if-defined.js: