@citolab/qti-components 6.5.0 → 6.5.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.
@@ -1,56 +1,46 @@
1
- import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as Wt,property as $}from"lit/decorators.js";import{html as Jt,LitElement as Zt}from"lit";function g(a,i){let e=b({waitUntilFirstUpdate:!1},i);return(t,r)=>{let{update:o}=t,n=Array.isArray(a)?a:[a];t.update=function(l){n.forEach(c=>{let p=c;if(l.has(p)){let d=l.get(p),m=this[p];d!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[r](d,m)}}),o.call(this,l)}}}import{createContext as zt}from"@lit/context";var yt=zt("item");import{provide as Gt}from"@lit/context";var _=class extends Zt{constructor(){super();this.identifier=void 0;this.adaptive="false";this.timeDependent="false";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:[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}]};this._initialContext=C(b({},this.context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",({detail:e})=>{this._context=C(b({},this._context),{variables:[...this._context.variables,e.variable]}),this._initialContext=this._context}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:r}=e.detail;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)}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get context(){return b({},this._context)}set variables(e){this._context=C(b({},this.context),{variables:e}),this.context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(o=>o.responseIdentifier===t.identifier);r&&(r.response=t.value)}t.type==="outcome"&&this._feedbackElements.forEach(r=>r.checkShowFeedback(t.identifier))})}firstUpdated(e){super.firstUpdated(e),this._emit("qti-item-first-updated",this)}disconnectedCallback(){super.disconnectedCallback(),this._emit("qti-item-disconnected")}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let o=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);o&&(o.response=t.response)}}render(){return Jt`<slot></slot>`}showCorrectResponse(e){let r=this.context.variables.filter(o=>"correctResponse"in o&&o.correctResponse).map(o=>({responseIdentifier:o.identifier,response:o.correctResponse}));for(let o of r){let n=this._interactionElements.find(l=>l.getAttribute("response-identifier")===o.responseIdentifier);n&&(n.correctResponse=e?o.response:"")}}processResponse(e=!0){var r;let t=this.querySelector("qti-response-processing");return t?t.process?(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+((r=this._context.variables.find(o=>o.identifier==="numAttempts"))==null?void 0:r.value)+1).toString()),this._emit("qti-response-processed"),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}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=C(b({},this._context),{variables:this._context.variables.map(r=>r.identifier!==e?r:C(b({},r),{value:t}))}),this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:t})}updateOutcomeVariable(e,t){var o;let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context=C(b({},this._context),{variables:this._context.variables.map(n=>n.identifier!==e?n:C(b({},n),{value:r.cardinality==="single"?t:[...n.value,t]}))}),this._feedbackElements.forEach(n=>n.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:(o=this._context.variables.find(n=>n.identifier===e))==null?void 0:o.value})}_getCompletionStatus(){return this._interactionElements.every(e=>e.validate())?"completed":this._interactionElements.some(e=>e.validate())?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};s([$({type:String})],_.prototype,"title",2),s([$({type:String})],_.prototype,"identifier",2),s([$({type:String})],_.prototype,"adaptive",2),s([$({type:String})],_.prototype,"timeDependent",2),s([$({type:Boolean})],_.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"_handleDisabledChange",2),s([$({type:Boolean})],_.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],_.prototype,"_handleReadonlyChange",2),s([Gt({context:yt}),$({attribute:!1})],_.prototype,"_context",2),_=s([Wt("qti-assessment-item")],_);import{LitElement as Qt}from"lit";var Oe=class extends Qt{constructor(){super()}firstUpdated(e){super.firstUpdated(e);let t=this.closest("qti-assessment-item"),r=this.getAttribute("href");if(r!==null){let o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.media="screen",o.href=r,t.appendChild(o),this.styleLink=o}if(this.textContent!==null){let o=document.createElement("style");o.media="screen",o.textContent=this.textContent,t.appendChild(o),this.styleLink=o}}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",Oe);import{customElement as tr}from"lit/decorators.js";import{html as rr,LitElement as ir}from"lit";import{css as er}from"lit";var xt=er`
1
+ import{a as f,b as q,c as n}from"../chunk-343LZK3D.js";import{provide as wr}from"@lit/context";import{LitElement as $r,html as Tr}from"lit";import{customElement as Rr,property as I}from"lit/decorators.js";function y(a,i){let e=f({waitUntilFirstUpdate:!1},i);return(t,r)=>{let{update:s}=t,o=Array.isArray(a)?a:[a];t.update=function(c){o.forEach(l=>{let p=l;if(c.has(p)){let d=c.get(p),u=this[p];d!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[r](d,u)}}),s.call(this,c)}}}import{createContext as kr}from"@lit/context";var P=kr("item");var A=class extends $r{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent="false";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:[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}]};this._initialContext=q(f({},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",({detail:e})=>{this._context=q(f({},this._context),{variables:[...this._context.variables,e.variable]}),this._initialContext=this._context}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:r}=e.detail;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)}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type}))}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=q(f({},this._context),{variables:this._context.variables.map(t=>{let r=e.find(s=>s.identifier===t.identifier);return r?f(f({},t),r):t})}),this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);r&&(r.response=t.value)}t.type==="outcome"&&this._feedbackElements.forEach(r=>r.checkShowFeedback(t.identifier))})}firstUpdated(e){super.firstUpdated(e),this._emit("qti-item-first-updated",this)}disconnectedCallback(){super.disconnectedCallback(),this._emit("qti-item-disconnected")}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(o=>o.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return Tr`<slot></slot>`}showCorrectResponse(e){let r=this._context.variables.filter(s=>"correctResponse"in s&&s.correctResponse).map(s=>({responseIdentifier:s.identifier,response:s.correctResponse}));for(let s of r){let o=this._interactionElements.find(c=>c.getAttribute("response-identifier")===s.responseIdentifier);o&&(o.correctResponse=e?s.response:"")}}processResponse(e=!0){var r;let t=this.querySelector("qti-response-processing");return t?t.process?(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+((r=this._context.variables.find(s=>s.identifier==="numAttempts"))==null?void 0:r.value)+1).toString()),this._emit("qti-response-processed"),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}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=q(f({},this._context),{variables:this._context.variables.map(r=>r.identifier!==e?r:q(f({},r),{value:t}))}),this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:t})}updateOutcomeVariable(e,t){var s;let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context=q(f({},this._context),{variables:this._context.variables.map(o=>o.identifier!==e?o:q(f({},o),{value:r.cardinality==="single"?t:[...o.value,t]}))}),this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:(s=this._context.variables.find(o=>o.identifier===e))==null?void 0:s.value})}_getCompletionStatus(){return this._interactionElements.every(e=>e.validate())?"completed":this._interactionElements.some(e=>e.validate())?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};n([I({type:String})],A.prototype,"title",2),n([I({type:String})],A.prototype,"identifier",2),n([I({type:String})],A.prototype,"adaptive",2),n([I({type:String})],A.prototype,"timeDependent",2),n([I({type:Boolean})],A.prototype,"disabled",2),n([y("disabled",{waitUntilFirstUpdate:!0})],A.prototype,"_handleDisabledChange",2),n([I({type:Boolean})],A.prototype,"readonly",2),n([y("readonly",{waitUntilFirstUpdate:!0})],A.prototype,"_handleReadonlyChange",2),n([wr({context:P}),I({attribute:!1})],A.prototype,"_context",2),A=n([Rr("qti-assessment-item")],A);import{html as Sr}from"lit/static-html.js";import{property as ae}from"lit/decorators.js";import{LitElement as Lr}from"lit";var Mr={SPACE:32},_=class extends Lr{constructor(){super(...arguments);this.tabindex=0;this.disabled=!1;this.readonly=!1;this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case Mr.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),Sr` <slot></slot> `}};n([ae({type:String})],_.prototype,"identifier",2),n([ae({type:Number,reflect:!0})],_.prototype,"tabindex",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:a=>a}})],_.prototype,"disabled",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:a=>a}})],_.prototype,"readonly",2),n([ae({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:a=>a}})],_.prototype,"checked",2),n([y("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"handleDisabledChange",1);import{customElement as Nr}from"lit/decorators.js";import{html as Vr,LitElement as Pr}from"lit";import{css as Hr}from"lit";var Ut=Hr`
2
2
  :host {
3
3
  display: block;
4
4
  }
5
- `;var U=class extends ir{render(){return rr`<slot name="qti-rubric-block"></slot><slot></slot>`}};U.styles=xt,U=s([tr("qti-item-body")],U);import{html as sr,LitElement as or}from"lit";var Pe=class extends or{render(){return sr`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Pe);import{html as nr}from"lit/static-html.js";import{property as G}from"lit/decorators.js";import{LitElement as ar}from"lit";var lr={SPACE:32},x=class extends ar{constructor(){super(...arguments);this.tabindex=0;this.disabled=!1;this.readonly=!1;this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case lr.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),nr` <slot></slot> `}};s([G({type:String})],x.prototype,"identifier",2),s([G({type:Number,reflect:!0})],x.prototype,"tabindex",2),s([G({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:a=>a}})],x.prototype,"disabled",2),s([G({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:a=>a}})],x.prototype,"readonly",2),s([G({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:a=>a}})],x.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"handleDisabledChange",1);import{html as cr,LitElement as pr}from"lit";var N=class extends pr{render(){return cr`<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);return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};customElements.define("qti-variabledeclaration",N);import{property as Ue}from"lit/decorators.js";var F=class extends N{connectedCallback(){super.connectedCallback();let e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let o=0;o<r.length;o++)e.push(r[o].textContent),r[o].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};s([Ue({type:String,attribute:"base-type"})],F.prototype,"baseType",2),s([Ue({type:String})],F.prototype,"identifier",2),s([Ue({type:String})],F.prototype,"cardinality",2);customElements.define("qti-response-declaration",F);import{property as Fe}from"lit/decorators.js";var I=class extends N{constructor(){super()}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 o=parseInt(r.getAttribute("source-value")),n=parseInt(r.getAttribute("target-value"));(isNaN(o)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(o,n)}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};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};s([Fe({type:String,attribute:"base-type"})],I.prototype,"baseType",2),s([Fe({type:String})],I.prototype,"identifier",2),s([Fe({type:String})],I.prototype,"cardinality",2);customElements.define("qti-outcome-declaration",I);import{LitElement as dr}from"lit";import{customElement as ur}from"lit/decorators.js";var le=class extends dr{};le=s([ur("qti-companion-materials-info")],le);import{LitElement as mr,css as hr,html as fr}from"lit";import{customElement as br,property as ce}from"lit/decorators.js";var L=class extends mr{handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{switch(o){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return fr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};L.styles=hr`
5
+ `;var z=class extends Pr{render(){return Vr`<slot name="qti-rubric-block"></slot><slot></slot>`}};z.styles=Ut,z=n([Nr("qti-item-body")],z);import{html as Dr,LitElement as Or}from"lit";var Qe=class extends Or{render(){return Dr`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Qe);import{LitElement as Ur}from"lit";var et=class extends Ur{constructor(){super()}firstUpdated(e){super.firstUpdated(e);let t=this.closest("qti-assessment-item"),r=this.getAttribute("href");if(r!==null){let s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=r,t.appendChild(s),this.styleLink=s}if(this.textContent!==null){let s=document.createElement("style");s.media="screen",s.textContent=this.textContent,t.appendChild(s),this.styleLink=s}}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",et);import{consume as Xr}from"@lit/context";import{css as Yr,html as Br}from"lit";import{property as tt,state as jr}from"lit/decorators.js";import{html as Ir,LitElement as Fr}from"lit";var F=class extends Fr{render(){return Ir`<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);return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};customElements.define("qti-variabledeclaration",F);var D=class extends F{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return Br`${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")),o=parseInt(r.getAttribute("target-value"));(isNaN(s)||isNaN(o))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,o)}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};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};D.styles=[Yr`
6
+ :host {
7
+ display: none;
8
+ }
9
+ `],n([tt({type:String,attribute:"base-type"})],D.prototype,"baseType",2),n([tt({type:String})],D.prototype,"identifier",2),n([tt({type:String})],D.prototype,"cardinality",2),n([Xr({context:P,subscribe:!0}),jr()],D.prototype,"itemContext",2);customElements.define("qti-outcome-declaration",D);import{consume as Jr}from"@lit/context";import{css as Zr}from"lit";var W=globalThis,xe=W.trustedTypes,It=xe?xe.createPolicy("lit-html",{createHTML:a=>a}):void 0,zt="$lit$",O=`lit$${(Math.random()+"").slice(9)}$`,Wt="?"+O,Kr=`<${Wt}>`,B=W.document===void 0?{createTreeWalker:()=>({})}:document,Ee=()=>B.createComment(""),ce=a=>a===null||typeof a!="object"&&typeof a!="function",Jt=Array.isArray,zr=a=>Jt(a)||typeof(a==null?void 0:a[Symbol.iterator])=="function",rt=`[
10
+ \f\r]`,le=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ft=/-->/g,Xt=/>/g,X=RegExp(`>|${rt}(?:([^\\s"'>=/]+)(${rt}*=${rt}*(?:[^
11
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Yt=/'/g,Bt=/"/g,Zt=/^(?:script|style|textarea|title)$/i,Gt=a=>(i,...e)=>({_$litType$:a,strings:i,values:e}),Qt=Gt(1),mn=Gt(2),pe=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),jt=new WeakMap,Y=B.createTreeWalker(B,129);function er(a,i){if(!Array.isArray(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return It!==void 0?It.createHTML(i):i}var Wr=(a,i)=>{let e=a.length-1,t=[],r,s=i===2?"<svg>":"",o=le;for(let c=0;c<e;c++){let l=a[c],p,d,u=-1,b=0;for(;b<l.length&&(o.lastIndex=b,d=o.exec(l),d!==null);)b=o.lastIndex,o===le?d[1]==="!--"?o=Ft:d[1]!==void 0?o=Xt:d[2]!==void 0?(Zt.test(d[2])&&(r=RegExp("</"+d[2],"g")),o=X):d[3]!==void 0&&(o=X):o===X?d[0]===">"?(o=r!=null?r:le,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?X:d[3]==='"'?Bt:Yt):o===Bt||o===Yt?o=X:o===Ft||o===Xt?o=le:(o=X,r=void 0);let h=o===X&&a[c+1].startsWith("/>")?" ":"";s+=o===le?l+Kr:u>=0?(t.push(p),l.slice(0,u)+zt+l.slice(u)+O+h):l+O+(u===-2?c:h)}return[er(a,s+(a[e]||"<?>")+(i===2?"</svg>":"")),t]},de=class a{constructor({strings:i,_$litType$:e},t){let r;this.parts=[];let s=0,o=0,c=i.length-1,l=this.parts,[p,d]=Wr(i,e);if(this.el=a.createElement(p,t),Y.currentNode=this.el.content,e===2){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(r=Y.nextNode())!==null&&l.length<c;){if(r.nodeType===1){if(r.hasAttributes())for(let u of r.getAttributeNames())if(u.endsWith(zt)){let b=d[o++],h=r.getAttribute(u).split(O),T=/([.?@])?(.*)/.exec(b);l.push({type:1,index:s,name:T[2],strings:h,ctor:T[1]==="."?ot:T[1]==="?"?nt:T[1]==="@"?at:Z}),r.removeAttribute(u)}else u.startsWith(O)&&(l.push({type:6,index:s}),r.removeAttribute(u));if(Zt.test(r.tagName)){let u=r.textContent.split(O),b=u.length-1;if(b>0){r.textContent=xe?xe.emptyScript:"";for(let h=0;h<b;h++)r.append(u[h],Ee()),Y.nextNode(),l.push({type:2,index:++s});r.append(u[b],Ee())}}}else if(r.nodeType===8)if(r.data===Wt)l.push({type:2,index:s});else{let u=-1;for(;(u=r.data.indexOf(O,u+1))!==-1;)l.push({type:7,index:s}),u+=O.length-1}s++}}static createElement(i,e){let t=B.createElement("template");return t.innerHTML=i,t}};function J(a,i,e=a,t){var o,c,l;if(i===pe)return i;let r=t!==void 0?(o=e._$Co)==null?void 0:o[t]:e._$Cl,s=ce(i)?void 0:i._$litDirective$;return(r==null?void 0:r.constructor)!==s&&((c=r==null?void 0:r._$AO)==null||c.call(r,!1),s===void 0?r=void 0:(r=new s(a),r._$AT(a,e,t)),t!==void 0?((l=e._$Co)!=null?l:e._$Co=[])[t]=r:e._$Cl=r),r!==void 0&&(i=J(a,r._$AS(a,i.values),r,t)),i}var st=class{constructor(i,e){this._$AV=[],this._$AN=void 0,this._$AD=i,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(i){var p;let{el:{content:e},parts:t}=this._$AD,r=((p=i==null?void 0:i.creationScope)!=null?p:B).importNode(e,!0);Y.currentNode=r;let s=Y.nextNode(),o=0,c=0,l=t[0];for(;l!==void 0;){if(o===l.index){let d;l.type===2?d=new _e(s,s.nextSibling,this,i):l.type===1?d=new l.ctor(s,l.name,l.strings,this,i):l.type===6&&(d=new lt(s,this,i)),this._$AV.push(d),l=t[++c]}o!==(l==null?void 0:l.index)&&(s=Y.nextNode(),o++)}return Y.currentNode=B,r}p(i){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(i,t,e),e+=t.strings.length-2):t._$AI(i[e])),e++}},_e=class a{get _$AU(){var i,e;return(e=(i=this._$AM)==null?void 0:i._$AU)!=null?e:this._$Cv}constructor(i,e,t,r){var s;this.type=2,this._$AH=x,this._$AN=void 0,this._$AA=i,this._$AB=e,this._$AM=t,this.options=r,this._$Cv=(s=r==null?void 0:r.isConnected)!=null?s:!0}get parentNode(){let i=this._$AA.parentNode,e=this._$AM;return e!==void 0&&(i==null?void 0:i.nodeType)===11&&(i=e.parentNode),i}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(i,e=this){i=J(this,i,e),ce(i)?i===x||i==null||i===""?(this._$AH!==x&&this._$AR(),this._$AH=x):i!==this._$AH&&i!==pe&&this._(i):i._$litType$!==void 0?this.g(i):i.nodeType!==void 0?this.$(i):zr(i)?this.T(i):this._(i)}k(i){return this._$AA.parentNode.insertBefore(i,this._$AB)}$(i){this._$AH!==i&&(this._$AR(),this._$AH=this.k(i))}_(i){this._$AH!==x&&ce(this._$AH)?this._$AA.nextSibling.data=i:this.$(B.createTextNode(i)),this._$AH=i}g(i){var s;let{values:e,_$litType$:t}=i,r=typeof t=="number"?this._$AC(i):(t.el===void 0&&(t.el=de.createElement(er(t.h,t.h[0]),this.options)),t);if(((s=this._$AH)==null?void 0:s._$AD)===r)this._$AH.p(e);else{let o=new st(r,this),c=o.u(this.options);o.p(e),this.$(c),this._$AH=o}}_$AC(i){let e=jt.get(i.strings);return e===void 0&&jt.set(i.strings,e=new de(i)),e}T(i){Jt(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,r=0;for(let s of i)r===e.length?e.push(t=new a(this.k(Ee()),this.k(Ee()),this,this.options)):t=e[r],t._$AI(s),r++;r<e.length&&(this._$AR(t&&t._$AB.nextSibling,r),e.length=r)}_$AR(i=this._$AA.nextSibling,e){var t;for((t=this._$AP)==null?void 0:t.call(this,!1,!0,e);i&&i!==this._$AB;){let r=i.nextSibling;i.remove(),i=r}}setConnected(i){var e;this._$AM===void 0&&(this._$Cv=i,(e=this._$AP)==null||e.call(this,i))}},Z=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(i,e,t,r,s){this.type=1,this._$AH=x,this._$AN=void 0,this.element=i,this.name=e,this._$AM=r,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=x}_$AI(i,e=this,t,r){let s=this.strings,o=!1;if(s===void 0)i=J(this,i,e,0),o=!ce(i)||i!==this._$AH&&i!==pe,o&&(this._$AH=i);else{let c=i,l,p;for(i=s[0],l=0;l<s.length-1;l++)p=J(this,c[t+l],e,l),p===pe&&(p=this._$AH[l]),o||(o=!ce(p)||p!==this._$AH[l]),p===x?i=x:i!==x&&(i+=(p!=null?p:"")+s[l+1]),this._$AH[l]=p}o&&!r&&this.j(i)}j(i){i===x?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,i!=null?i:"")}},ot=class extends Z{constructor(){super(...arguments),this.type=3}j(i){this.element[this.name]=i===x?void 0:i}},nt=class extends Z{constructor(){super(...arguments),this.type=4}j(i){this.element.toggleAttribute(this.name,!!i&&i!==x)}},at=class extends Z{constructor(i,e,t,r,s){super(i,e,t,r,s),this.type=5}_$AI(i,e=this){var o;if((i=(o=J(this,i,e,0))!=null?o:x)===pe)return;let t=this._$AH,r=i===x&&t!==x||i.capture!==t.capture||i.once!==t.once||i.passive!==t.passive,s=i!==x&&(t===x||r);r&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,i),this._$AH=i}handleEvent(i){var e,t;typeof this._$AH=="function"?this._$AH.call((t=(e=this.options)==null?void 0:e.host)!=null?t:this.element,i):this._$AH.handleEvent(i)}},lt=class{constructor(i,e,t){this.element=i,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(i){J(this,i)}};var it=W.litHtmlPolyfillSupport,Kt;it==null||it(de,_e),((Kt=W.litHtmlVersions)!=null?Kt:W.litHtmlVersions=[]).push("3.0.0");import{property as ct,state as Gr}from"lit/decorators.js";var U=class extends F{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return Qt`${JSON.stringify(e,null,2)}`}connectedCallback(){super.connectedCallback();let e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let s=0;s<r.length;s++)e.push(r[s].textContent),r[s].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};U.styles=[Zr`
12
+ :host {
13
+ display: none;
14
+ }
15
+ `],n([ct({type:String,attribute:"base-type"})],U.prototype,"baseType",2),n([ct({type:String})],U.prototype,"identifier",2),n([ct({type:String})],U.prototype,"cardinality",2),n([Jr({context:P,subscribe:!0}),Gr()],U.prototype,"itemContext",2);customElements.define("qti-response-declaration",U);import{LitElement as Qr}from"lit";import{customElement as ei}from"lit/decorators.js";var Ce=class extends Qr{};Ce=n([ei("qti-companion-materials-info")],Ce);import{LitElement as ti,html as ri}from"lit";import{customElement as ii}from"lit/decorators.js";var qe=class extends ti{render(){return ri`<slot></slot>`}};qe=n([ii("qti-content-body")],qe);import{LitElement as si,css as oi,html as ni}from"lit";import{customElement as ai,property as Ae}from"lit/decorators.js";var S=class extends si{handleclassNamesChange(e,t){this.classNames.split(" ").forEach(s=>{switch(s){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return ni`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};S.styles=oi`
16
+ :host {
17
+ display: block;
18
+ }
19
+ `,n([Ae({type:String})],S.prototype,"id",2),n([Ae({type:String})],S.prototype,"use",2),n([Ae({type:String})],S.prototype,"view",2),n([Ae({type:String,attribute:"class"})],S.prototype,"classNames",2),n([y("classNames",{waitUntilFirstUpdate:!0})],S.prototype,"handleclassNamesChange",1),S=n([ai("qti-rubric-block")],S);import{css as pi,html as di}from"lit";import{LitElement as ci}from"lit";import{property as ke}from"lit/decorators.js";var li=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),ue=a=>{if(typeof a=="string")return a;let i=li();return i==="."?a.toLocaleString():a.toString().replace(".","").replace(i,".")};function pt(a){return a==null}var k=class extends ci{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e){let t=this.closest("qti-assessment-item").getOutcome(e);if(this.outcomeIdentifier!==e||!t)return;let r=!1;Array.isArray(t.value)?r=t.value.includes(this.identifier):r=!pt(this.identifier)&&!pt(t==null?void 0:t.value)&&this.identifier===t.value||!1,this.showFeedback(r)}showFeedback(e){this.showStatus=e&&this.showHide==="show"||!e&&this.showHide==="hide"?"on":"off"}};n([ke({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),n([ke({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),n([ke({type:String})],k.prototype,"identifier",2),n([ke({type:String,attribute:!1})],k.prototype,"showStatus",2);var we=class extends k{render(){return di` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};we.styles=pi`
6
20
  :host {
7
21
  display: block;
8
22
  }
9
- `,s([ce({type:String})],L.prototype,"id",2),s([ce({type:String})],L.prototype,"use",2),s([ce({type:String})],L.prototype,"view",2),s([ce({type:String,attribute:"class"})],L.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],L.prototype,"handleclassNamesChange",1),L=s([br("qti-rubric-block")],L);import{LitElement as gr,html as vr}from"lit";import{customElement as yr}from"lit/decorators.js";var pe=class extends gr{render(){return vr`<slot></slot>`}};pe=s([yr("qti-content-body")],pe);import{css as qr,html as Cr}from"lit";import{LitElement as Er}from"lit";import{property as de}from"lit/decorators.js";var xr=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Q=a=>{if(typeof a=="string")return a;let i=xr();return i==="."?a.toLocaleString():a.toString().replace(".","").replace(i,".")};function Ie(a){return a==null}var k=class extends Er{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e){let t=this.closest("qti-assessment-item").getOutcome(e);if(this.outcomeIdentifier!==e||!t)return;let r=!1;Array.isArray(t.value)?r=t.value.includes(this.identifier):r=!Ie(this.identifier)&&!Ie(t==null?void 0:t.value)&&this.identifier===t.value||!1,this.showFeedback(r)}showFeedback(e){this.showStatus=e&&this.showHide==="show"||!e&&this.showHide==="hide"?"on":"off"}};s([de({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([de({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([de({type:String})],k.prototype,"identifier",2),s([de({type:String,attribute:!1})],k.prototype,"showStatus",2);var ue=class extends k{constructor(){super(...arguments);this.render=()=>Cr` <slot part="feedback" class="${this.showStatus}"></slot> `}};ue.styles=qr`
10
23
  .on {
11
- display: inline-block;
24
+ display: block;
12
25
  }
13
26
  .off {
14
27
  display: none;
15
28
  }
16
- `;customElements.define("qti-feedback-inline",ue);import{css as _r,html as kr}from"lit";var me=class extends k{constructor(){super(...arguments);this.render=()=>kr` <slot part="feedback" class="${this.showStatus}"></slot> `}};me.styles=_r`
29
+ `;customElements.define("qti-feedback-block",we);import{css as ui,html as mi}from"lit";var $e=class extends k{constructor(){super(...arguments);this.render=()=>mi` <slot part="feedback" class="${this.showStatus}"></slot> `}};$e.styles=ui`
17
30
  .on {
18
31
  display: inline-block;
19
32
  }
20
33
  .off {
21
34
  display: none;
22
35
  }
23
- `;customElements.define("qti-modal-feedback",me);import{css as Ar,html as wr}from"lit";var he=class extends k{render(){return wr` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};he.styles=Ar`
24
- :host {
25
- display: block;
26
- }
36
+ `;customElements.define("qti-feedback-inline",$e);import{css as hi,html as fi}from"lit";var Te=class extends k{constructor(){super(...arguments);this.render=()=>fi` <slot part="feedback" class="${this.showStatus}"></slot> `}};Te.styles=hi`
27
37
  .on {
28
- display: block;
38
+ display: inline-block;
29
39
  }
30
40
  .off {
31
41
  display: none;
32
42
  }
33
- `;customElements.define("qti-feedback-block",he);import{css as Lr,html as Rr}from"lit";import{ifDefined as qt}from"lit/directives/if-defined.js";import{property as Xe}from"lit/decorators.js";import{LitElement as Tr}from"lit";var h=class extends Tr{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}set correctResponse(e){console.warn("correctResponse is not implemented")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};s([Xe({attribute:"response-identifier"})],h.prototype,"responseIdentifier",2),s([Xe({reflect:!0,type:Boolean})],h.prototype,"disabled",2),s([Xe({reflect:!0,type:Boolean})],h.prototype,"readonly",2);import{customElement as Sr,property as fe,state as Ct}from"lit/decorators.js";function Et(a,i){let e,t=b({},i);return(r,o)=>{let{connectedCallback:n,disconnectedCallback:l}=r;r.connectedCallback=function(){var d;n.call(this);let c=m=>{let q=Array.from(this.querySelectorAll(a));for(let v of m){let P=Array.from(v.addedNodes).map(V=>V),f=Array.from(v.addedNodes).map(V=>V);v.type==="childList"&&P.find(V=>q.includes(V))&&this[o](P,f)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){l.call(this),e.disconnect()}}}import{createRef as Mr}from"lit/directives/ref.js";var T=class extends h{constructor(){super(...arguments);this._value="";this._size=5;this.inputRef=Mr()}handleclassNamesChange(e,t){t.split(" ").forEach(o=>{if(o.startsWith("qti-input-width")){let n=o.replace("qti-input-width-","");this._size=parseInt(n)}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Lr`
34
- :host {
35
- display: inline-flex;
36
- }
37
- `]}render(){return Rr`
38
- <input
39
- part="input"
40
- spellcheck="false"
41
- autocomplete="off"
42
- @keydown="${e=>e.stopImmediatePropagation()}"
43
- @keyup="${this.textChanged}"
44
- @change="${this.textChanged}"
45
- type="${this.patternMask=="[0-9]*"?"number":"text"}"
46
- placeholder="${qt(this.placeholderText?this.placeholderText:void 0)}"
47
- .value="${this._value}"
48
- size="${this._size}"
49
- pattern="${qt(this.patternMask?this.patternMask:void 0)}"
50
- ?disabled="${this.disabled}"
51
- ?readonly="${this.readonly}"
52
- />
53
- `}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([fe({type:Number,attribute:"expected-length"})],T.prototype,"expectedLength",2),s([fe({type:String,attribute:"pattern-mask"})],T.prototype,"patternMask",2),s([fe({type:String,attribute:"placeholder-text"})],T.prototype,"placeholderText",2),s([Ct()],T.prototype,"_value",2),s([Ct()],T.prototype,"_size",2),s([fe({type:String,attribute:"class"})],T.prototype,"classNames",2),s([g("classNames")],T.prototype,"handleclassNamesChange",1),T=s([Sr("qti-text-entry-interaction")],T);import{css as Vr,html as Hr}from"lit";import{ifDefined as Ye}from"lit/directives/if-defined.js";import{ref as $r,createRef as Nr}from"lit/directives/ref.js";import{customElement as Dr,property as be,state as Or}from"lit/decorators.js";var R=class extends h{constructor(){super(...arguments);this.textareaRef=Nr();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let n=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(n))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Vr`
43
+ `;customElements.define("qti-modal-feedback",Te);import{css as bi,html as vi}from"lit";import{ifDefined as ut}from"lit/directives/if-defined.js";import{property as dt}from"lit/decorators.js";import{LitElement as gi}from"lit";var g=class extends gi{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}set correctResponse(e){console.warn("correctResponse is not implemented")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};n([dt({attribute:"response-identifier"})],g.prototype,"responseIdentifier",2),n([dt({reflect:!0,type:Boolean})],g.prototype,"disabled",2),n([dt({reflect:!0,type:Boolean})],g.prototype,"readonly",2);import{ref as yi,createRef as xi}from"lit/directives/ref.js";import{customElement as Ei,property as Re,state as _i}from"lit/decorators.js";var L=class extends g{constructor(){super(...arguments);this.textareaRef=xi();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(s=>{if(s.startsWith("qti-height-lines")){let o=s.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(o))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[bi`
54
44
  /* PK: display host as block, else design will be collapsed */
55
45
  :host {
56
46
  display: block;
@@ -61,39 +51,59 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
61
51
  height: 100%;
62
52
  border: 0;
63
53
  }
64
- `]}render(){return Hr`<textarea
54
+ `]}render(){return vi`<textarea
65
55
  part="textarea"
66
- ${$r(this.textareaRef)}
56
+ ${yi(this.textareaRef)}
67
57
  spellcheck="false"
68
58
  autocomplete="off"
69
59
  @keydown="${e=>e.stopImmediatePropagation()}"
70
60
  @keyup="${this.textChanged}"
71
61
  @change="${this.textChanged}"
72
- placeholder="${Ye(this.placeholderText?this.placeholderText:void 0)}"
73
- maxlength="${Ye(this.expectedLength?this.expectedLength:void 0)}"
74
- pattern="${Ye(this.patternMask?this.patternMask:void 0)}"
62
+ placeholder="${ut(this.placeholderText?this.placeholderText:void 0)}"
63
+ maxlength="${ut(this.expectedLength?this.expectedLength:void 0)}"
64
+ pattern="${ut(this.patternMask?this.patternMask:void 0)}"
75
65
  ?disabled="${this.disabled}"
76
66
  ?readonly="${this.readonly}"
77
67
  .value=${this._value}
78
- ></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([be({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),s([be({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),s([be({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),s([Or()],R.prototype,"_value",2),s([be({type:String,attribute:"class"})],R.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],R.prototype,"handleclassNamesChange",1),R=s([Dr("qti-extended-text-interaction")],R);import{html as Pr}from"lit";import{property as _t}from"lit/decorators.js";var y=class extends h{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){let t=Array.isArray(e)?e:[e];this._choiceElements.forEach(r=>{r.checked=!!t.find(o=>o===r.identifier)})}set correctResponse(e){let t=Array.isArray(e)?e:[e];if(e==""){this._choiceElements.forEach(r=>{r.removeAttribute("data-correct-response")});return}this._choiceElements.forEach(r=>{r.setAttribute("data-correct-response",t.find(o=>o===r.identifier)?"true":"false")})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};s([_t({type:Number,attribute:"min-choices"})],y.prototype,"minChoices",2),s([_t({type:Number,attribute:"max-choices"})],y.prototype,"maxChoices",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],y.prototype,"_handleReadonlyChange",2),s([g("maxChoices",{waitUntilFirstUpdate:!0})],y.prototype,"_handleMaxChoicesChange",2);var Be=class extends y{constructor(){super(...arguments);this.render=()=>Pr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",Be);import{css as Ur,html as kt}from"lit";import{property as Fr,state as At}from"lit/decorators.js";import{unsafeHTML as wt}from"lit/directives/unsafe-html.js";var D=class extends h{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[Ur`
68
+ ></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};n([Re({type:Number,attribute:"expected-length"})],L.prototype,"expectedLength",2),n([Re({type:String,attribute:"pattern-mask"})],L.prototype,"patternMask",2),n([Re({type:String,attribute:"placeholder-text"})],L.prototype,"placeholderText",2),n([_i()],L.prototype,"_value",2),n([Re({type:String,attribute:"class"})],L.prototype,"classNames",2),n([y("classNames",{waitUntilFirstUpdate:!0})],L.prototype,"handleclassNamesChange",1),L=n([Ei("qti-extended-text-interaction")],L);import{css as Ci,html as qi}from"lit";import{ifDefined as rr}from"lit/directives/if-defined.js";import{customElement as Ai,property as Se,state as ir}from"lit/decorators.js";function tr(a,i){let e,t=f({},i);return(r,s)=>{let{connectedCallback:o,disconnectedCallback:c}=r;r.connectedCallback=function(){var d;o.call(this);let l=u=>{let b=Array.from(this.querySelectorAll(a));for(let h of u){let T=Array.from(h.addedNodes).map(N=>N),v=Array.from(h.addedNodes).map(N=>N);h.type==="childList"&&T.find(N=>b.includes(N))&&this[s](T,v)}};e=new MutationObserver(l),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[s](Array.from(p),[])},r.disconnectedCallback=function(){c.call(this),e.disconnect()}}}import{createRef as ki}from"lit/directives/ref.js";var R=class extends g{constructor(){super(...arguments);this._value="";this._size=5;this.inputRef=ki()}handleclassNamesChange(e,t){t.split(" ").forEach(s=>{if(s.startsWith("qti-input-width")){let o=s.replace("qti-input-width-","");this._size=parseInt(o)}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Ci`
69
+ :host {
70
+ display: inline-flex;
71
+ }
72
+ `]}render(){return qi`
73
+ <input
74
+ part="input"
75
+ spellcheck="false"
76
+ autocomplete="off"
77
+ @keydown="${e=>e.stopImmediatePropagation()}"
78
+ @keyup="${this.textChanged}"
79
+ @change="${this.textChanged}"
80
+ type="${this.patternMask=="[0-9]*"?"number":"text"}"
81
+ placeholder="${rr(this.placeholderText?this.placeholderText:void 0)}"
82
+ .value="${this._value}"
83
+ size="${this._size}"
84
+ pattern="${rr(this.patternMask?this.patternMask:void 0)}"
85
+ ?disabled="${this.disabled}"
86
+ ?readonly="${this.readonly}"
87
+ />
88
+ `}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};n([Se({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),n([Se({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),n([Se({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),n([ir()],R.prototype,"_value",2),n([ir()],R.prototype,"_size",2),n([Se({type:String,attribute:"class"})],R.prototype,"classNames",2),n([y("classNames")],R.prototype,"handleclassNamesChange",1),R=n([Ai("qti-text-entry-interaction")],R);import{html as wi}from"lit";import{property as sr}from"lit/decorators.js";var E=class extends g{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){let t=Array.isArray(e)?e:[e];this._choiceElements.forEach(r=>{r.checked=!!t.find(s=>s===r.identifier)})}set correctResponse(e){let t=Array.isArray(e)?e:[e];if(e==""){this._choiceElements.forEach(r=>{r.removeAttribute("data-correct-response")});return}this._choiceElements.forEach(r=>{r.setAttribute("data-correct-response",t.find(s=>s===r.identifier)?"true":"false")})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};n([sr({type:Number,attribute:"min-choices"})],E.prototype,"minChoices",2),n([sr({type:Number,attribute:"max-choices"})],E.prototype,"maxChoices",2),n([y("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),n([y("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2),n([y("maxChoices",{waitUntilFirstUpdate:!0})],E.prototype,"_handleMaxChoicesChange",2);var mt=class extends E{constructor(){super(...arguments);this.render=()=>wi`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",mt);import{css as $i,html as or}from"lit";import{property as Ti,state as nr}from"lit/decorators.js";import{unsafeHTML as ar}from"lit/directives/unsafe-html.js";var j=class extends g{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[$i`
79
89
  :host {
80
90
  display: inline-block;
81
91
  }
82
- `]}render(){return kt`
92
+ `]}render(){return or`
83
93
  <select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
84
- ${this.options.map(e=>kt`
85
- <option value="${e.value}" ?selected="${e.selected}">${wt(e.textContent)}</option>
94
+ ${this.options.map(e=>or`
95
+ <option value="${e.value}" ?selected="${e.selected}">${ar(e.textContent)}</option>
86
96
  `)}
87
97
  </select>
88
98
 
89
- ${wt(this.correctOption)}
90
- `}firstUpdated(e){super.firstUpdated(e),this.addEventListener("on-dropdown-selected",this.choiceSelected);let t=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...t.map(r=>({textContent:r.innerHTML,value:r.getAttribute("identifier"),selected:!1}))]}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>C(b({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}set correctResponse(e){if(e===""){this.correctOption="";return}console.log("correctResponse",e),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=>C(b({},r),{selected:r.value===t})),this.saveResponse(t)}};D.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"],s([At()],D.prototype,"options",2),s([At()],D.prototype,"correctOption",2),s([Fr({attribute:"data-prompt",type:String})],D.prototype,"dataPrompt",2);customElements.define("qti-inline-choice-interaction",D);import{customElement as Xr,property as Yr}from"lit/decorators.js";import{html as Br}from"lit";import{css as Ir}from"lit";var Tt=Ir`
99
+ ${ar(this.correctOption)}
100
+ `}firstUpdated(e){super.firstUpdated(e),this.addEventListener("on-dropdown-selected",this.choiceSelected);let t=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...t.map(r=>({textContent:r.innerHTML,value:r.getAttribute("identifier"),selected:!1}))]}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>q(f({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}set correctResponse(e){if(e===""){this.correctOption="";return}console.log("correctResponse",e),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=>q(f({},r),{selected:r.value===t})),this.saveResponse(t)}};j.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([nr()],j.prototype,"options",2),n([nr()],j.prototype,"correctOption",2),n([Ti({attribute:"data-prompt",type:String})],j.prototype,"dataPrompt",2);customElements.define("qti-inline-choice-interaction",j);import{customElement as Si,property as Li}from"lit/decorators.js";import{html as Mi}from"lit";import{css as Ri}from"lit";var lr=Ri`
91
101
  :host {
92
102
  display: flex;
93
103
  flex-direction: column;
94
104
  // align-items: flex-start;
95
105
  }
96
- `;var X=class extends y{render(){return Br` <slot name="prompt"></slot><slot part="slot"></slot>`}};X.styles=Tt,s([Yr({type:String})],X.prototype,"orientation",2),X=s([Xr("qti-choice-interaction")],X);import{customElement as Kr}from"lit/decorators.js";import{html as jr,LitElement as zr}from"lit";var Lt=`<qti-response-processing>
106
+ `;var G=class extends E{render(){return Mi` <slot name="prompt"></slot><slot part="slot"></slot>`}};G.styles=lr,n([Li({type:String})],G.prototype,"orientation",2),G=n([Si("qti-choice-interaction")],G);import{html as Hi,LitElement as Ni}from"lit";import{customElement as Vi}from"lit/decorators.js";var cr=`<qti-response-processing>
97
107
  <qti-response-condition>
98
108
  <qti-response-if>
99
109
  <qti-match>
@@ -110,7 +120,7 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
110
120
  </qti-set-outcome-value>
111
121
  </qti-response-else>
112
122
  </qti-response-condition>
113
- </qti-response-processing>`,Rt=`<qti-response-processing>
123
+ </qti-response-processing>`,pr=`<qti-response-processing>
114
124
  <qti-response-condition>
115
125
  <qti-response-if>
116
126
  <qti-is-null>
@@ -126,7 +136,7 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
126
136
  </qti-set-outcome-value>
127
137
  </qti-response-else>
128
138
  </qti-response-condition>
129
- </qti-response-processing>`,St=`<qti-response-processing>
139
+ </qti-response-processing>`,dr=`<qti-response-processing>
130
140
  <qti-response-condition>
131
141
  <qti-response-if>
132
142
  <qti-is-null>
@@ -142,29 +152,20 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
142
152
  </qti-set-outcome-value>
143
153
  </qti-response-else>
144
154
  </qti-response-condition>
145
- </qti-response-processing>`;var Y=class extends zr{render(){return jr`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){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(Rt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(St));break}case"match_correct":this.appendChild(this.fragmentFromString(Lt));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};Y=s([Kr("qti-response-processing")],Y);import{property as Gr}from"lit/decorators.js";import{customElement as Wr}from"lit/decorators.js";import{html as Jr,LitElement as Zr}from"lit";var S=class extends Zr{render(){return Jr`<slot></slot>`}process(){throw new Error("Not implemented")}};S=s([Wr("qti-rule")],S);var ge=class extends S{get childExpression(){return this.firstElementChild}process(){let e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getVariable(e),r;return t.interpolationTable&&(r=t.interpolationTable.get(parseInt(this.childExpression.calculate()))),r?(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Q(r)}})),r):(console.warn("lookupOutcomeValue: value is null or undefined"),0)}};s([Gr({type:String})],ge.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",ge);import{html as Qr}from"lit";var Ke=class extends S{render(){return Qr`<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",Ke);var je=class extends S{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:Array.isArray(t)?t.map(r=>Q(r)):Q(t)}}))}};customElements.define("qti-set-outcome-value",je);import{html as ei,LitElement as ti}from"lit";var ee=class extends ti{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return ei` <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",ee);import{html as ii}from"lit";import{html as ri}from"lit";var te=class extends ee{render(){return ri`${super.render()}`}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",te);var ze=class extends te{render(){return ii`${super.render()}`}};customElements.define("qti-response-else-if",ze);import{LitElement as si,css as oi,html as re,nothing as We}from"lit";import{state as Mt}from"lit/decorators.js";var u=class extends si{constructor(){super(...arguments);this._error=[];this._debug=!1;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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getVariable(t)}case"qti-multiple":{let r=e.calculate();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(o=>o.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.calculate().toString(),cardinality:"single"}}catch(t){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}set error(e){let t=this._error;this._error.push(e),this.requestUpdate("error",t)}render(){return re`${this._debug?re`${this._error.map(e=>re`<div role="alert">${e}</div>`)}`:We}
146
- ${this._debug?re`${JSON.stringify(this._result)}`:We} ${this._debug?re`<slot></slot>`:We}`}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};u.styles=oi`
147
- :host {
148
- display: inline;
149
- }
150
- [role='alert'] {
151
- border: 1px solid red;
152
- background: pink;
153
- color: red;
154
- padding: 0.5rem 0.25rem;
155
- font-size: small;
156
- border-radius: 5px;
157
- margin-bottom: 3px;
155
+ </qti-response-processing>`;var Q=class extends Ni{render(){return Hi`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){let i=[...this.children];for(let e of i)e.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(pr).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(dr).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(cr).firstElementChild.firstElementChild);break}}}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};Q=n([Vi("qti-response-processing")],Q);import{property as Ui}from"lit/decorators.js";import{customElement as Pi}from"lit/decorators.js";import{html as Di,LitElement as Oi}from"lit";var M=class extends Oi{render(){return Di`<slot></slot>`}process(){throw new Error("Not implemented")}};M=n([Pi("qti-rule")],M);var Le=class extends M{get childExpression(){return this.firstElementChild}process(){let e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getVariable(e),r;return t.interpolationTable&&(r=t.interpolationTable.get(parseInt(this.childExpression.calculate()))),r?(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:ue(r)}})),r):(console.warn("lookupOutcomeValue: value is null or undefined"),0)}};n([Ui({type:String})],Le.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Le);import{html as Ii}from"lit";var ht=class extends M{render(){return Ii`<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",ht);var ft=class extends M{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:Array.isArray(t)?t.map(r=>ue(r)):ue(t)}}))}};customElements.define("qti-set-outcome-value",ft);import{LitElement as Fi,html as Xi}from"lit";var me=class extends Fi{render(){return Xi`<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",me);import{html as Yi}from"lit";var he=class extends me{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",he);var gt=class extends he{render(){return Yi`${super.render()}`}};customElements.define("qti-response-else-if",gt);import{LitElement as Bi,css as ji,html as Ki}from"lit";import{state as zi}from"lit/decorators.js";var m=class extends Bi{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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getVariable(t)}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch(t){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return Ki`<pre>${JSON.stringify(this.result,null,2)}</pre>
156
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};m.styles=ji`
157
+ slot {
158
+ display: none;
158
159
  }
159
- `,s([Mt()],u.prototype,"_result",2),s([Mt()],u.prototype,"error",1);var A=class extends u{calculate(){throw new Error("Not implemented")}};var ve=class extends ni(A){calculate(){return this.calculateChildren(Array.from(this.children))}};function ni(a){return class extends a{calculateChildren(e){return e.map(r=>{let o=r;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.calculate();if(typeof n=="string")if(n==="true")n=!0;else if(n==="false")n=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return n}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",ve);import{property as ai}from"lit/decorators.js";var ye=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([ai({type:String,attribute:"base-type"})],ye.prototype,"baseType",2);customElements.define("qti-base-value",ye);var Je=class extends A{calculate(){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,o=t.value;return r.filter(c=>o.includes(c)).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",Je);var Ze=class extends u{get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Ze);import{property as li}from"lit/decorators.js";var xe=class extends u{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}calculate(){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 o=parseFloat(t.value),n=parseFloat(r.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);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}};s([li({type:String})],xe.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",xe);import{property as ci}from"lit/decorators.js";var w=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var Ee=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){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):w.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([ci({type:String})],Ee.prototype,"toleranceMode",2);customElements.define("qti-equal",Ee);var Ge=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ge);var Qe=class extends A{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Qe);var et=class extends u{calculate(){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",et);var tt=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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 rt=class extends A{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",rt);import{property as pi}from"lit/decorators.js";var qe=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let n of r){let l=t.mapEntries.find(c=>w.compareSingleValues(c.mapKey,n,e.baseType));l==null||l.mappedValue==null?o+=t.defaultValue:o+=l.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([pi({type:String})],qe.prototype,"identifier",2);customElements.define("qti-map-response",qe);import{property as it}from"lit/decorators.js";import{LitElement as di}from"lit";var B=class extends di{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")}))}};s([it({attribute:"default-value",type:Number})],B.prototype,"defaultValue",2),s([it({attribute:"lower-bound",type:Number})],B.prototype,"lowerBound",2),s([it({attribute:"upper-bound",type:Number})],B.prototype,"upperBound",2);customElements.define("qti-mapping",B);var st=class a extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return this._result=a.match(e,t),this._result}return console.error("unexpected number of children in match"),null}static match(i,e){var t;if(e.cardinality==="single")return i.value===null?!1:Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):w.compareSingleValues((t=i.value)==null?void 0:t.toString(),e.value.toString(),e.baseType);{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 r=0;for(let o of e.value){if(e.cardinality==="ordered"){let n=i[r];if(!w.compareSingleValues(o,n,e.baseType))return!1}else{let n=null;for(let l of i.value)if(w.compareSingleValues(o,l,e.baseType)){n=l;break}if(n!==null)i.value.splice(i.value.indexOf(n),1);else return!1}r++}return!0}}};customElements.define("qti-match",st);var ot=class extends u{calculate(){let i=this.getVariables();this.children.length!==2&&(this.error="The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType!==t.baseType&&(this.error="Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||(this.error="and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&(this.error="The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&(this.error="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",ot);var nt=class extends u{calculate(){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",nt);import{html as ui}from"lit";var at=class extends u{render(){return ui`${super.render()}`}calculate(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",at);import{html as mi}from"lit";var lt=class extends A{render(){return mi``}calculate(){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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-or, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",lt);var ct=class extends u{calculate(){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",ct);import{LitElement as hi,html as Vt}from"lit";import{property as fi,state as bi}from"lit/decorators.js";var ie=class extends hi{constructor(){super();this.value="";this.closest("qti-assessment-item").addEventListener("qti-response-processed",()=>{this.value=this.calculate()})}render(){return Vt`${Array.isArray(this.value)?this.value.map(e=>Vt`${e}`):this.value}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};s([fi({type:String})],ie.prototype,"identifier",2),s([bi()],ie.prototype,"value",2);customElements.define("qti-printed-variable",ie);var pt=class extends u{calculate(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(o){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",pt);import{property as gi}from"lit/decorators.js";var Ce=class extends u{constructor(){super(...arguments);this.caseSensitive="true"}calculate(){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 o=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return w.compareSingleValues(o,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};s([gi({type:String,attribute:"case-sensitive"})],Ce.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ce);var dt=class extends u{calculate(){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();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",dt);var ut=class extends u{calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",ut);import{LitElement as vi,html as Ht}from"lit";var mt=class extends vi{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},o=l=>{let c={},p=l.getAttribute("key");if(p){let d=Array.from(l.children),m=d.map(v=>v.getAttribute("key"));m.length>0&&!m.find(v=>!Number.isInteger(+v))?c[p]=d.map(v=>n(v)):c[p]=l.textContent}return c},n=l=>{if(l){let c={};for(let p of l.children)c=b(b({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=b(b({},r),n(l))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,o,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,o),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,r.appendChild(c)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{!r.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:n=>{this.register(n)},notifyReady:()=>{}}));let o=r.defined(this.module);r([this.module],n=>{o&&this.register(n)},n=>{this._errorMessage=n})},r=>{this._errorMessage=r})}render(){return Ht`<slot></slot>${this._errorMessage&&Ht`<div style="color:red">
160
+ `,n([zi()],m.prototype,"result",2);var w=class extends m{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Me=class extends Wi(w){calculate(){return this.calculateChildren(Array.from(this.children))}};function Wi(a){return class extends a{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=s.calculate();if(typeof o=="string")if(o==="true")o=!0;else if(o==="false")o=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return o}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",Me);import{property as Ji}from"lit/decorators.js";var He=class extends m{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent}};n([Ji({type:String,attribute:"base-type"})],He.prototype,"baseType",2);customElements.define("qti-base-value",He);var bt=class extends w{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",bt);var vt=class extends m{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",vt);import{property as Zi}from"lit/decorators.js";var Ne=class extends m{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),o=parseFloat(r.value);if(!isNaN(s)&&!isNaN(o))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===o.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${o}`);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([Zi({type:String})],Ne.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Ne);import{property as Gi}from"lit/decorators.js";var $=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 Ve=class extends m{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):$.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([Gi({type:String})],Ve.prototype,"toleranceMode",2);customElements.define("qti-equal",Ve);var yt=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",yt);var xt=class extends w{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",xt);var Et=class extends m{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",Et);var _t=class extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",_t);var Ct=class extends w{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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);import{property as Qi}from"lit/decorators.js";var Pe=class extends m{getResult(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],s=0;for(let o of r){let c=t.mapEntries.find(l=>$.compareSingleValues(l.mapKey,o,e.baseType));c==null||c.mappedValue==null?s+=t.defaultValue:s+=c.mappedValue}return t.lowerBound!=null&&(s=Math.max(t.lowerBound,s)),t.upperBound!=null&&(s=Math.min(t.upperBound,s)),s}};n([Qi({type:String})],Pe.prototype,"identifier",2);customElements.define("qti-map-response",Pe);import{property as qt}from"lit/decorators.js";import{LitElement as es}from"lit";var ee=class extends es{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([qt({attribute:"default-value",type:Number})],ee.prototype,"defaultValue",2),n([qt({attribute:"lower-bound",type:Number})],ee.prototype,"lowerBound",2),n([qt({attribute:"upper-bound",type:Number})],ee.prototype,"upperBound",2);customElements.define("qti-mapping",ee);var At=class a extends m{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return a.match(e,t)}return console.error("unexpected number of children in match"),null}static match(i,e){var t;if(e.cardinality==="single")return i.value===null?!1:Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):$.compareSingleValues((t=i.value)==null?void 0:t.toString(),e.value.toString(),e.baseType);{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 r=0;for(let s of e.value){if(e.cardinality==="ordered"){let o=i[r];if(!$.compareSingleValues(s,o,e.baseType))return!1}else{let o=null;for(let c of i.value)if($.compareSingleValues(s,c,e.baseType)){o=c;break}if(o!==null)i.value.splice(i.value.indexOf(o),1);else return!1}r++}return!0}}};customElements.define("qti-match",At);var kt=class extends m{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&&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",kt);var wt=class extends m{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",wt);import{html as ts}from"lit";var $t=class extends m{render(){return ts`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",$t);var Tt=class extends w{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();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-or, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Tt);var Rt=class extends m{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",Rt);import{consume as rs}from"@lit/context";import{LitElement as is,html as ss}from"lit";import{property as os,state as ns}from"lit/decorators.js";var fe=class extends is{render(){var t,r;let e=(r=(t=this.itemContext)==null?void 0:t.variables.find(s=>s.identifier===this.identifier))==null?void 0:r.value;return ss`${JSON.stringify(e,null,2)}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.identifier;return e.getVariable(t).value}};n([os({type:String})],fe.prototype,"identifier",2),n([rs({context:P,subscribe:!0}),ns()],fe.prototype,"itemContext",2);customElements.define("qti-printed-variable",fe);var St=class extends m{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch(s){console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",St);import{property as as}from"lit/decorators.js";var De=class extends m{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(),o=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return $.compareSingleValues(s,o,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([as({type:String,attribute:"case-sensitive"})],De.prototype,"caseSensitive",2);customElements.define("qti-string-match",De);var Lt=class extends m{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();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Lt);var Mt=class extends m{getResult(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariable(i).value}};customElements.define("qti-variable",Mt);import{LitElement as ls,html as ur}from"lit";var Ht=class extends ls{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},s=c=>{let l={},p=c.getAttribute("key");if(p){let d=Array.from(c.children),u=d.map(h=>h.getAttribute("key"));u.length>0&&!u.find(h=>!Number.isInteger(+h))?l[p]=d.map(h=>o(h)):l[p]=c.textContent}return l},o=c=>{if(c){let l={};for(let p of c.children)l=f(f({},l),s(p));return l}};for(let c of t)return c.getAttribute("key")||(r=f(f({},r),o(c))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let s=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,s,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,s),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(c=>c.getAttribute("href")).forEach(c=>{let l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.media="screen",l.href=c,r.appendChild(l)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{!r.defined("qtiCustomInteractionContext")&&define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}}));let s=r.defined(this.module);r([this.module],o=>{s&&this.register(o)},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return ur`<slot></slot>${this._errorMessage&&ur`<div style="color:red">
160
161
  <h1>Error</h1>
161
162
  ${this._errorMessage}
162
- </div>`}`}};customElements.define("qti-portable-custom-interaction",mt);import{LitElement as xi,css as Ei,html as Dt}from"lit";var _e=class a{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return a._instance?a._instance:(a._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPoint(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPoint(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e=this._getPoint(i);return this.elementFromPoint(e.x,e.y)}elementFromPoint(i,e){let t=document.elementFromPoint(i,e);if(t){for(;t.shadowRoot;){let r=t.shadowRoot.elementFromPoint(i,e);if(r===null||r===t)break;t=r}return t}return null}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}};import{property as yi}from"lit/decorators.js";var $t=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(n);let l=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),l.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of l)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("dragenter",this.dragenterHandler),n.addEventListener("drop",this.dropHandler)}removeHandler(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("dragenter",this.dragenterHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragenterHandler(n){n.preventDefault()}dragoverHandler(n){return n.preventDefault(),n.currentTarget.setAttribute("active",""),n.dataTransfer.dropEffect="move",!1}dropHandler(n){n.preventDefault();let l=n.currentTarget,c=this.querySelector(`[identifier=${n.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${n.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${n.target?JSON.stringify(n.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(n){return n.preventDefault(),n.currentTarget.removeAttribute("active"),n.dataTransfer.dropEffect="none",!1}}return s([yi({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Nt=(a,i,e)=>{class t extends a{}return t};import{property as K}from"lit/decorators.js";var M=(a,i,e,t)=>{class r extends Nt($t(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(l,c){if(this.classList.contains("qti-match-tabular"))return;l.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(l),l.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",m=>{m.dataTransfer.setData("text",m.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",m=>{if(m.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),(m.dataTransfer.dropEffect==="none"||m.dataTransfer.dropEffect===void 0)&&this.configuration.dragCanBePlacedBack){let q=m.currentTarget,v=this.draggables.get(q),P=v.index<v.parent.children.length?v.index:v.parent.children.length-1,f=v.parent,V=v.parent.children[P];f.insertBefore(q,V),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(l,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("disabled",""):d.removeAttribute("disabled"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("readonly",""):d.removeAttribute("readonly"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(l){super.firstUpdated(l),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new _e,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(l=!0){this.draggables.forEach((c,p)=>{let d=c.parent.children,m=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[m])}),l&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(l=>{let p=+(l.getAttribute("match-max")||1)<=(l.children.length||0);p?l.setAttribute("disabled",""):l.removeAttribute("disabled"),p?l.removeAttribute("dropzone"):l.setAttribute("dropzone","move")})}set response(l){this.classList.contains("qti-match-tabular")||(this.reset(!1),l!==null&&Array.isArray(l)&&l.forEach(c=>{let[p,...d]=c.split(" ").reverse();if(p){let m=this.droppables.find(q=>q.getAttribute("identifier")===p);d.forEach(q=>{let v=this.querySelector(`[identifier=${q}]`);m?v?(m.appendChild(v),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${q}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let l=this.droppables.map(c=>{var d;let p="";return((d=c.children)==null?void 0:d.length)>0&&(p+=Array.from(c.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=c.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:l}}))}}return s([Et(i)],r.prototype,"reInitDragAndDrop",1),s([K({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([K({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([K({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([K({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([K({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([K({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as qi}from"lit/decorators.js";var se=class extends M(xi,"qti-simple-associable-choice",!0,".dl"){render(){return Dt` <slot name="prompt"></slot>
163
+ </div>`}`}};customElements.define("qti-portable-custom-interaction",Ht);import{LitElement as ps,css as ds,html as fr}from"lit";var Oe=class a{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return a._instance?a._instance:(a._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPoint(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPoint(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e=this._getPoint(i);return this.elementFromPoint(e.x,e.y)}elementFromPoint(i,e){let t=document.elementFromPoint(i,e);if(t){for(;t.shadowRoot;){let r=t.shadowRoot.elementFromPoint(i,e);if(r===null||r===t)break;t=r}return t}return null}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}};import{property as cs}from"lit/decorators.js";var mr=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(o);let c=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),c.forEach(l=>{l.setAttribute("dropzone","move"),l.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(l)});for(let l of c)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{l.hasAttribute("disabled")?this.removeHandler(l):this.attachHandler(l);break}}})}),this.observer.observe(l,{attributes:!0})}attachHandler(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeHandler(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var o;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(o=this.observer)==null||o.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){return o.preventDefault(),o.currentTarget.setAttribute("active",""),o.dataTransfer.dropEffect="move",!1}dropHandler(o){o.preventDefault();let c=o.currentTarget,l=this.querySelector(`[identifier=${o.dataTransfer.getData("text")}`),p=l||this.shadowRoot.querySelector(`[identifier=${o.dataTransfer.getData("text")}`);return c?p.parentElement.getAttribute("identifier")!==c.getAttribute("identifier")&&c.appendChild(p):console.error(`cannot find droppable, target: ${o.target?JSON.stringify(o.target):"null"}`),c.removeAttribute("active"),!1}dragleaveHandler(o){return o.preventDefault(),o.currentTarget.removeAttribute("active"),o.dataTransfer.dropEffect="none",!1}}return n([cs({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var hr=(a,i,e)=>{class t extends a{}return t};import{property as te}from"lit/decorators.js";var H=(a,i,e,t)=>{class r extends hr(mr(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(c,l){if(this.classList.contains("qti-match-tabular"))return;c.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(c),c.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",u=>{u.dataTransfer.setData("text",u.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",u=>{if(u.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),(u.dataTransfer.dropEffect==="none"||u.dataTransfer.dropEffect===void 0)&&this.configuration.dragCanBePlacedBack){let b=u.currentTarget,h=this.draggables.get(b),T=h.index<h.parent.children.length?h.index:h.parent.children.length-1,v=h.parent,N=h.parent.children[T];v.insertBefore(b,N),this.saveResponse(),this.checkMaxMatchAssociations()}u.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(c,l){this.dragDropApi.copyStylesDragClone=l.copyStylesDragClone,this.dragDropApi.dragOnClick=l.dragOnClick}handleDisabledChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("disabled",""):d.removeAttribute("disabled"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(c,l){this.draggables.forEach((p,d)=>{l?d.setAttribute("readonly",""):d.removeAttribute("readonly"),l?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(c){super.firstUpdated(c),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Oe,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(c=!0){this.draggables.forEach((l,p)=>{let d=l.parent.children,u=l.index<d.length?l.index:d.length;l.parent.insertBefore(p,d[u])}),c&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(c=>{let p=+(c.getAttribute("match-max")||1)<=(c.children.length||0);p?c.setAttribute("disabled",""):c.removeAttribute("disabled"),p?c.removeAttribute("dropzone"):c.setAttribute("dropzone","move")})}set response(c){this.classList.contains("qti-match-tabular")||(this.reset(!1),c!==null&&Array.isArray(c)&&c.forEach(l=>{let[p,...d]=l.split(" ").reverse();if(p){let u=this.droppables.find(b=>b.getAttribute("identifier")===p);d.forEach(b=>{let h=this.querySelector(`[identifier=${b}]`);u?h?(u.appendChild(h),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${b}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let l=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=l}saveResponse(){let c=this.droppables.map(l=>{var d;let p="";return((d=l.children)==null?void 0:d.length)>0&&(p+=Array.from(l.children).map(u=>u.getAttribute("identifier")).join(" ")+" "),p+=l.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:c}}))}}return n([tr(i)],r.prototype,"reInitDragAndDrop",1),n([te({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),n([te({attribute:!1,type:Object})],r.prototype,"configuration",2),n([y("configuration")],r.prototype,"handleDragOptionsChanged",1),n([te({type:Boolean,reflect:!0})],r.prototype,"disabled",2),n([y("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),n([te({type:Boolean,reflect:!0})],r.prototype,"readonly",2),n([y("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),n([te({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),n([te({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as us}from"lit/decorators.js";var ge=class extends H(ps,"qti-simple-associable-choice",!0,".dl"){render(){return fr` <slot name="prompt"></slot>
163
164
  <slot name="qti-simple-associable-choice"></slot>
164
- ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Dt`<div part="associables-container">
165
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>fr`<div part="associables-container">
165
166
  <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
166
167
  <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
167
- </div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};se.styles=Ei`
168
+ </div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};ge.styles=ds`
168
169
  :host {
169
170
  display: block; /* necessary to calculate scaling position */
170
171
  }
@@ -173,8 +174,8 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
173
174
  flex-wrap: wrap;
174
175
  gap: 0.5rem;
175
176
  }
176
- `,s([qi()],se.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",se);import{css as Ci,html as _i,LitElement as ki}from"lit";var ke=class extends M(ki,"qti-gap-text",!1,"qti-gap"){render(){return _i` <slot part="drags" name="qti-gap-text"></slot>
177
- <slot part="drops"></slot>`}};ke.styles=[Ci`
177
+ `,n([us()],ge.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ge);import{css as ms,html as hs,LitElement as fs}from"lit";var Ue=class extends H(fs,"qti-gap-text",!1,"qti-gap"){render(){return hs` <slot part="drags" name="qti-gap-text"></slot>
178
+ <slot part="drops"></slot>`}};Ue.styles=[ms`
178
179
  :host {
179
180
  display: flex;
180
181
  align-items: flex-start;
@@ -197,26 +198,26 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
197
198
  align-items: flex-start;
198
199
  flex: 1;
199
200
  }
200
- `];customElements.define("qti-gap-match-interaction",ke);import{css as Ai,svg as Ot,html as wi}from"lit";function j(a,i,e,t){switch(a){case"circle":{let[r,o,n]=i,l=r/e.width*100,c=o/e.height*100,p=n/e.width*100;t.style.left=l-p+"%",t.style.top=c-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,o,n,l]=i,c=r/e.width*100,p=o/e.height*100,d=n/e.width*100,m=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=m-p+"%"}break;case"poly":{let r=i.reduce((f,V,vt,Kt)=>{if(vt%2===1){let jt=f.pop();f[f.length]={x:jt,y:Kt[vt]}}else f.push(V);return f},[]),o=Math.min(...r.map(f=>f.x)),n=Math.max(...r.map(f=>f.x)),l=Math.min(...r.map(f=>f.y)),c=Math.max(...r.map(f=>f.y)),p=o/e.width*100,d=l/e.height*100,m=n/e.width*100,q=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=l/e.height*100+"%",t.style.width=m-p+"%",t.style.height=q-d+"%";let P=r.map(f=>({x:(f.x-o)/(n-o)*100,y:(f.y-l)/(c-l)*100})).map(f=>Math.round(f.x)+"% "+Math.round(f.y)+"%").join(",");t.style.clipPath=`polygon(${P})`}break;default:break}}import{query as Ti,queryAssignedElements as Li,state as ht}from"lit/decorators.js";import{repeat as Ri}from"lit/directives/repeat.js";import{ifDefined as Pt}from"lit/directives/if-defined.js";var H=class extends h{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 response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return wi`<slot name="prompt"></slot>
201
+ `];customElements.define("qti-gap-match-interaction",Ue);import{css as gs,svg as gr,html as bs}from"lit";function re(a,i,e,t){switch(a){case"circle":{let[r,s,o]=i,c=r/e.width*100,l=s/e.height*100,p=o/e.width*100;t.style.left=c-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,o,c]=i,l=r/e.width*100,p=s/e.height*100,d=o/e.width*100,u=c/e.height*100;t.style.left=l+"%",t.style.top=p+"%",t.style.width=d-l+"%",t.style.height=u-p+"%"}break;case"poly":{let r=i.reduce((v,N,Ot,qr)=>{if(Ot%2===1){let Ar=v.pop();v[v.length]={x:Ar,y:qr[Ot]}}else v.push(N);return v},[]),s=Math.min(...r.map(v=>v.x)),o=Math.max(...r.map(v=>v.x)),c=Math.min(...r.map(v=>v.y)),l=Math.max(...r.map(v=>v.y)),p=s/e.width*100,d=c/e.height*100,u=o/e.width*100,b=l/e.height*100;t.style.left=s/e.width*100+"%",t.style.top=c/e.height*100+"%",t.style.width=u-p+"%",t.style.height=b-d+"%";let T=r.map(v=>({x:(v.x-s)/(o-s)*100,y:(v.y-c)/(l-c)*100})).map(v=>Math.round(v.x)+"% "+Math.round(v.y)+"%").join(",");t.style.clipPath=`polygon(${T})`}break;default:break}}import{query as vs,queryAssignedElements as ys,state as Nt}from"lit/decorators.js";import{repeat as xs}from"lit/directives/repeat.js";import{ifDefined as br}from"lit/directives/if-defined.js";var V=class extends g{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 response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,s;return bs`<slot name="prompt"></slot>
201
202
  <line-container>
202
203
  <svg
203
- width=${Pt((e=this.grImage[0])==null?void 0:e.width)}
204
- height=${Pt((t=this.grImage[0])==null?void 0:t.height)}
205
- viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(o=this.grImage[0])==null?void 0:o.height}"
204
+ width=${br((e=this.grImage[0])==null?void 0:e.width)}
205
+ height=${br((t=this.grImage[0])==null?void 0:t.height)}
206
+ viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(s=this.grImage[0])==null?void 0:s.height}"
206
207
  >
207
- ${Ri(this._lines,n=>n,(n,l)=>Ot`
208
+ ${xs(this._lines,o=>o,(o,c)=>gr`
208
209
  <line
209
210
  part="line"
210
- x1=${parseInt(this.querySelector("[identifier="+n.split(" ")[0]+"]").style.left)}
211
- y1=${parseInt(this.querySelector("[identifier="+n.split(" ")[0]+"]").style.top)}
212
- x2=${parseInt(this.querySelector("[identifier="+n.split(" ")[1]+"]").style.left)}
213
- y2=${parseInt(this.querySelector("[identifier="+n.split(" ")[1]+"]").style.top)}
211
+ x1=${parseInt(this.querySelector("[identifier="+o.split(" ")[0]+"]").style.left)}
212
+ y1=${parseInt(this.querySelector("[identifier="+o.split(" ")[0]+"]").style.top)}
213
+ x2=${parseInt(this.querySelector("[identifier="+o.split(" ")[1]+"]").style.left)}
214
+ y2=${parseInt(this.querySelector("[identifier="+o.split(" ")[1]+"]").style.top)}
214
215
  stroke="red"
215
216
  stroke-width="3"
216
- @click=${c=>{c.stopPropagation(),this._lines=this._lines.filter((p,d)=>d!==l),this.saveResponse(this._lines)}}
217
+ @click=${l=>{l.stopPropagation(),this._lines=this._lines.filter((p,d)=>d!==c),this.saveResponse(this._lines)}}
217
218
  />
218
219
  `)}
219
- ${this.startPoint&&Ot`<line
220
+ ${this.startPoint&&gr`<line
220
221
  part="point"
221
222
  x1=${this.startCoord.x}
222
223
  y1=${this.startCoord.y}
@@ -227,7 +228,7 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
227
228
  />`}
228
229
  </svg>
229
230
  <slot></slot>
230
- </line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.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)}};H.styles=[Ai`
231
+ </line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.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)}};V.styles=[gs`
231
232
  slot:not([name='prompt']) {
232
233
  // position: relative; /* qti-hotspot-choice relative to the slot */
233
234
  display: block;
@@ -250,8 +251,8 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
250
251
  top: 0px;
251
252
  left: 0px;
252
253
  }
253
- `],s([ht()],H.prototype,"_lines",2),s([ht()],H.prototype,"startCoord",2),s([ht()],H.prototype,"mouseCoord",2),s([Ti("svg")],H.prototype,"svgContainer",2),s([Li({selector:"img"})],H.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",H);import{css as Si,html as Mi,LitElement as Vi}from"lit";var Ae=class extends M(Vi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return Mi` <slot></slot>
254
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=n;t.style.left=l-p+"px",t.style.top=c-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[l,c,p,d]=n;t.style.left=l+"px",t.style.top=c+"px",t.style.width=p-l+"px",t.style.height=d-c+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Ae.styles=Si`
254
+ `],n([Nt()],V.prototype,"_lines",2),n([Nt()],V.prototype,"startCoord",2),n([Nt()],V.prototype,"mouseCoord",2),n([vs("svg")],V.prototype,"svgContainer",2),n([ys({selector:"img"})],V.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",V);import{css as Es,html as _s,LitElement as Cs}from"lit";var Ie=class extends H(Cs,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return _s` <slot></slot>
255
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));switch(s){case"circle":{let[c,l,p]=o;t.style.left=c-p+"px",t.style.top=l-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[c,l,p,d]=o;t.style.left=c+"px",t.style.top=l+"px",t.style.width=p-c+"px",t.style.height=d-l+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Ie.styles=Es`
255
256
  :host {
256
257
  display: inline-block;
257
258
  position: relative;
@@ -260,12 +261,12 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
260
261
  display: flex;
261
262
  gap: 1rem;
262
263
  }
263
- `;customElements.define("qti-graphic-gap-match-interaction",Ae);import{css as Hi,html as $i}from"lit";var we=class extends y{render(){return $i`
264
+ `;customElements.define("qti-graphic-gap-match-interaction",Ie);import{css as qs,html as As}from"lit";var Fe=class extends E{render(){return As`
264
265
  <slot name="prompt"></slot>
265
266
  <!-- slot for the prompt -->
266
267
  <slot></slot>
267
268
  <!-- slot for the image and hotspots -->
268
- `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(n=>n.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));j(n,l,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};we.styles=[Hi`
269
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(o=>o.getAttribute("identifier")===t),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(o=>o.order>0).length>=s){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(o=>!!o.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(o=>(o.order>o.order&&o.order--,o)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),o=r.getAttribute("shape"),c=s.split(",").map(l=>parseInt(l));re(o,c,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Fe.styles=[qs`
269
270
  slot:not([name='prompt']) {
270
271
  position: relative; /* qti-hotspot-choice relative to the slot */
271
272
  display: block;
@@ -276,12 +277,12 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
276
277
  pointer-events: none;
277
278
  user-select: none;
278
279
  }
279
- `];customElements.define("qti-graphic-order-interaction",we);import{css as Ni,html as Di}from"lit";var Te=class extends y{render(){return Di`
280
+ `];customElements.define("qti-graphic-order-interaction",Fe);import{css as ks,html as ws}from"lit";var Xe=class extends E{render(){return ws`
280
281
  <slot name="prompt"></slot>
281
282
  <!-- slot for the prompt -->
282
283
  <slot></slot>
283
284
  <!-- slot for the image and hotspots -->
284
- `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));j(o,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Te.styles=[Ni`
285
+ `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),o=r.split(",").map(c=>parseInt(c));re(s,o,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Xe.styles=[ks`
285
286
  slot:not([name='prompt']) {
286
287
  position: relative; /* qti-hotspot-choice relative to the slot */
287
288
  display: block;
@@ -293,36 +294,36 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
293
294
  user-select: none;
294
295
  /* width:100%; */
295
296
  }
296
- `];customElements.define("qti-hotspot-interaction",Te);import{html as oe,LitElement as Ui}from"lit";import{html as Oi,LitElement as Pi}from"lit";var ft=class extends Pi{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Oi`
297
+ `];customElements.define("qti-hotspot-interaction",Xe);import{html as be,LitElement as Rs}from"lit";import{html as $s,LitElement as Ts}from"lit";var Vt=class extends Ts{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return $s`
297
298
  <slot></slot>
298
299
  <slot name="qti-simple-associable-choice"></slot>
299
- `}};customElements.define("qti-simple-associable-choice",ft);import{property as Fi,state as Ii}from"lit/decorators.js";import{unsafeHTML as Ut}from"lit/directives/unsafe-html.js";var z=class extends M(Ui,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){constructor(){super(...arguments);this.response=[];this.responseIdentifier=""}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.response=[]}render(){return this.classList.contains("qti-match-tabular")?oe`
300
+ `}};customElements.define("qti-simple-associable-choice",Vt);import{property as Ss,state as Ls}from"lit/decorators.js";import{unsafeHTML as vr}from"lit/directives/unsafe-html.js";var ie=class extends H(Rs,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){constructor(){super(...arguments);this.response=[];this.responseIdentifier=""}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.response=[]}render(){return this.classList.contains("qti-match-tabular")?be`
300
301
  <slot name="prompt"></slot>
301
302
  <table>
302
303
  <tr>
303
304
  <td></td>
304
- ${this.cols.map((e,t)=>oe`<th part="r-header">${Ut(e.innerHTML)}</th>`)}
305
+ ${this.cols.map((e,t)=>be`<th part="r-header">${vr(e.innerHTML)}</th>`)}
305
306
  </tr>
306
- ${this.rows.map((e,t)=>oe`<tr>
307
- <td part="c-header">${Ut(e.innerHTML)}</td>
308
- ${this.cols.map((r,o)=>{let n=`${e.getAttribute("identifier")} ${r.getAttribute("identifier")}`;return oe`<td>
307
+ ${this.rows.map((e,t)=>be`<tr>
308
+ <td part="c-header">${vr(e.innerHTML)}</td>
309
+ ${this.cols.map((r,s)=>{let o=`${e.getAttribute("identifier")} ${r.getAttribute("identifier")}`;return be`<td>
309
310
  <input
310
311
  type="checkbox"
311
312
  value=${r.getAttribute("identifier")}
312
- .checked=${this.response.includes(n)}
313
- @change=${l=>{l.target.checked?this.response.push(n):this.response=this.response.filter(p=>p!==n),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:this.response}}))}}
313
+ .checked=${this.response.includes(o)}
314
+ @change=${c=>{c.target.checked?this.response.push(o):this.response=this.response.filter(p=>p!==o),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:this.response}}))}}
314
315
  />
315
316
  </td>`})}
316
317
  </tr>`)}
317
318
  </table>
318
- `:oe`<slot name="prompt"></slot> <slot></slot>`}};z.styles=[],s([Ii()],z.prototype,"response",2),s([Fi({type:String,attribute:"response-identifier"})],z.prototype,"responseIdentifier",2);customElements.define("qti-match-interaction",z);import{css as Xi,html as Yi}from"lit";var Le=class extends h{constructor(){super();this.value=0}reset(){}validate(){return!0}set response(e){}static get properties(){return C(b({},h.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Yi` <slot name="prompt"></slot>
319
- <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.toString())})}};Le.styles=[Xi``];customElements.define("qti-media-interaction",Le);import{css as Bi,html as Ft,LitElement as Ki}from"lit";import{property as ji}from"lit/decorators.js";var W=class extends M(Ki,"qti-simple-choice",!0,"drop-list"){render(){return Ft` <slot name="prompt"> </slot>
319
+ `:be`<slot name="prompt"></slot> <slot></slot>`}};ie.styles=[],n([Ls()],ie.prototype,"response",2),n([Ss({type:String,attribute:"response-identifier"})],ie.prototype,"responseIdentifier",2);customElements.define("qti-match-interaction",ie);import{css as Ms,html as Hs}from"lit";var Ye=class extends g{constructor(){super();this.value=0}reset(){}validate(){return!0}set response(e){}static get properties(){return q(f({},g.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Hs` <slot name="prompt"></slot>
320
+ <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.toString())})}};Ye.styles=[Ms``];customElements.define("qti-media-interaction",Ye);import{css as Ns,html as yr,LitElement as Vs}from"lit";import{property as Ps}from"lit/decorators.js";var se=class extends H(Vs,"qti-simple-choice",!0,"drop-list"){render(){return yr` <slot name="prompt"> </slot>
320
321
  <div part="container">
321
322
  <slot part="drags"> </slot>
322
323
  <div part="drops">
323
- ${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>Ft`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
324
+ ${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>yr`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
324
325
  </div>
325
- </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};W.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],W.styles=[Bi`
326
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};se.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],se.styles=[Ns`
326
327
  [part='drags'] {
327
328
  display: flex;
328
329
  align-items: flex-start;
@@ -370,7 +371,7 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
370
371
  :host(.qti-choices-right) [part='container'] {
371
372
  flex-direction: row-reverse;
372
373
  }
373
- `],s([ji({type:String})],W.prototype,"orientation",2);customElements.define("qti-order-interaction",W);import{LitElement as zi,css as Wi,html as Ji}from"lit";var Re=class extends zi{render(){return Ji`<slot></slot>`}};Re.styles=[Wi`
374
+ `],n([Ps({type:String})],se.prototype,"orientation",2);customElements.define("qti-order-interaction",se);import{LitElement as Ds,css as Os,html as Us}from"lit";var Be=class extends Ds{render(){return Us`<slot></slot>`}};Be.styles=[Os`
374
375
  :host {
375
376
  display: block;
376
377
  }
@@ -381,23 +382,23 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
381
382
  left: 50%;
382
383
  transform: translateX(-50%);
383
384
  }
384
- `];customElements.define("qti-position-object-interaction",Re);import{LitElement as Zi,css as Gi,html as Qi}from"lit";var Se=class extends Zi{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Qi`<slot></slot>`}dragElementHandler(e){e.preventDefault();let t=e.clientX-this.startX,r=e.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+t+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=e.clientX,this.startY=e.clientY}firstUpdated(e){super.firstUpdated(e),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",t=>{this.startX=t.clientX,this.startY=t.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(e){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};Se.styles=[Gi`
385
+ `];customElements.define("qti-position-object-interaction",Be);import{LitElement as Is,css as Fs,html as Xs}from"lit";var je=class extends Is{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Xs`<slot></slot>`}dragElementHandler(e){e.preventDefault();let t=e.clientX-this.startX,r=e.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+t+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=e.clientX,this.startY=e.clientY}firstUpdated(e){super.firstUpdated(e),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",t=>{this.startX=t.clientX,this.startY=t.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(e){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};je.styles=[Fs`
385
386
  :host {
386
387
  display: inline-block;
387
388
  position: relative;
388
389
  }
389
- `];customElements.define("qti-position-object-stage",Se);import{css as es,html as It}from"lit";import{property as Xt,state as ts}from"lit/decorators.js";import{repeat as rs}from"lit/directives/repeat.js";import{styleMap as is}from"lit/directives/style-map.js";var O=class extends h{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return It` <slot name="prompt"></slot>
390
+ `];customElements.define("qti-position-object-stage",je);import{css as Ys,html as xr}from"lit";import{property as Er,state as Bs}from"lit/decorators.js";import{repeat as js}from"lit/directives/repeat.js";import{styleMap as Ks}from"lit/directives/style-map.js";var K=class extends g{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return xr` <slot name="prompt"></slot>
390
391
  <point-container>
391
- ${rs(this._points,e=>e,(e,t)=>It`
392
+ ${js(this._points,e=>e,(e,t)=>xr`
392
393
  <button
393
394
  part="point"
394
- style=${is({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
395
+ style=${Ks({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
395
396
  aria-label="Remove point at ${e}"
396
- @click=${r=>{r.stopPropagation(),this._points=this._points.filter((o,n)=>n!==t),this.saveResponse(this._points)}}
397
+ @click=${r=>{r.stopPropagation(),this._points=this._points.filter((s,o)=>o!==t),this.saveResponse(this._points)}}
397
398
  ></button>
398
399
  `)}
399
400
  <slot></slot>
400
- </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set response(e){this._points=Array.isArray(e)?e:[e]}connectedCallback(){super.connectedCallback(),this.querySelector("img").addEventListener("click",t=>{let r=t.offsetX,o=t.offsetY;this._points=[...this._points,r+" "+o],this.saveResponse(this._points)})}disconnectedCallback(){super.disconnectedCallback()}};O.styles=[es`
401
+ </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set response(e){this._points=Array.isArray(e)?e:[e]}connectedCallback(){super.connectedCallback(),this.querySelector("img").addEventListener("click",t=>{let r=t.offsetX,s=t.offsetY;this._points=[...this._points,r+" "+s],this.saveResponse(this._points)})}disconnectedCallback(){super.disconnectedCallback()}};K.styles=[Ys`
401
402
  :host {
402
403
  display: block;
403
404
  }
@@ -405,29 +406,29 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
405
406
  display: block;
406
407
  position: relative;
407
408
  }
408
- `],s([Xt({type:Number,attribute:"max-choices"})],O.prototype,"maxChoices",2),s([Xt({type:Number,attribute:"min-choices"})],O.prototype,"minChoices",2),s([ts()],O.prototype,"_points",2);customElements.define("qti-select-point-interaction",O);import{css as ss,html as Me,nothing as bt}from"lit";import{property as J,query as Yt}from"lit/decorators.js";var E=class extends h{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),Me`<slot name="prompt"></slot>
409
+ `],n([Er({type:Number,attribute:"max-choices"})],K.prototype,"maxChoices",2),n([Er({type:Number,attribute:"min-choices"})],K.prototype,"minChoices",2),n([Bs()],K.prototype,"_points",2);customElements.define("qti-select-point-interaction",K);import{css as zs,html as Ke,nothing as Pt}from"lit";import{property as oe,query as _r}from"lit/decorators.js";var C=class extends g{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),Ke`<slot name="prompt"></slot>
409
410
  <div id="slider" part="slider">
410
- ${this.csLive.getPropertyValue("--show-bounds")=="true"?Me`<div id="bounds" part="bounds">
411
+ ${this.csLive.getPropertyValue("--show-bounds")=="true"?Ke`<div id="bounds" part="bounds">
411
412
  <div>${this._min}</div>
412
413
  <div>${this._max}</div>
413
- </div>`:bt}
414
- ${this.csLive.getPropertyValue("--show-ticks")=="true"?Me`<div id="ticks" part="ticks"></div>`:bt}
414
+ </div>`:Pt}
415
+ ${this.csLive.getPropertyValue("--show-ticks")=="true"?Ke`<div id="ticks" part="ticks"></div>`:Pt}
415
416
  <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove}>
416
417
  <div id="knob" part="knob">
417
- ${this.csLive.getPropertyValue("--show-value")=="true"?Me`<div id="value" part="value">${this.value}</div>`:bt}
418
+ ${this.csLive.getPropertyValue("--show-value")=="true"?Ke`<div id="value" part="value">${this.value}</div>`:Pt}
418
419
  </div>
419
420
  </div>
420
- </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=l=>{let{x:c}=this.getPositionFromEvent(l),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),l.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),n=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let t=n=>{let l=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),n.preventDefault(),n.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};E.styles=[ss``],s([Yt("#knob")],E.prototype,"_knob",2),s([Yt("#rail")],E.prototype,"_rail",2),s([J({type:Number})],E.prototype,"value",2),s([J({type:Boolean,attribute:"step-label"})],E.prototype,"stepLabel",2),s([J({type:Boolean})],E.prototype,"reverse",2),s([J({type:Number,attribute:"lower-bound"})],E.prototype,"min",1),s([J({type:Number,attribute:"upper-bound"})],E.prototype,"max",1),s([J({type:Number,attribute:"step"})],E.prototype,"step",1),s([g("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",E);import{html as os}from"lit";import{customElement as ns,property as Bt}from"lit/decorators.js";var Z=class extends h{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}set response(e){}render(){return os`<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"}}))}};s([Bt({type:String,attribute:"count-attempt"})],Z.prototype,"countAttempt",2),s([Bt({type:String})],Z.prototype,"title",2),Z=s([ns("qti-end-attempt-interaction")],Z);import{LitElement as as,css as ls,html as cs}from"lit";var Ve=class extends as{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return cs` <slot name="qti-gap-img"></slot> `}};Ve.styles=ls`
421
+ </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=c=>{let{x:l}=this.getPositionFromEvent(c),p=l-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),c.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:s}=this.getPositionFromEvent(e),o=s-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.stopPropagation()}_onMouseDown(e){let t=o=>{let c=o.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(c),o.preventDefault(),o.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,s=r.touches[0]||r.changedTouches[0];t={x:s.pageX,y:s.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};C.styles=[zs``],n([_r("#knob")],C.prototype,"_knob",2),n([_r("#rail")],C.prototype,"_rail",2),n([oe({type:Number})],C.prototype,"value",2),n([oe({type:Boolean,attribute:"step-label"})],C.prototype,"stepLabel",2),n([oe({type:Boolean})],C.prototype,"reverse",2),n([oe({type:Number,attribute:"lower-bound"})],C.prototype,"min",1),n([oe({type:Number,attribute:"upper-bound"})],C.prototype,"max",1),n([oe({type:Number,attribute:"step"})],C.prototype,"step",1),n([y("disabled",{waitUntilFirstUpdate:!0})],C.prototype,"_handleDisabledChange",2),n([y("readonly",{waitUntilFirstUpdate:!0})],C.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",C);import{html as Ws}from"lit";import{customElement as Js,property as Cr}from"lit/decorators.js";var ne=class extends g{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}set response(e){}render(){return Ws`<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([Cr({type:String,attribute:"count-attempt"})],ne.prototype,"countAttempt",2),n([Cr({type:String})],ne.prototype,"title",2),ne=n([Js("qti-end-attempt-interaction")],ne);import{LitElement as Zs,css as Gs,html as Qs}from"lit";var ze=class extends Zs{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return Qs` <slot name="qti-gap-img"></slot> `}};ze.styles=Gs`
421
422
  :host {
422
423
  position: absolute;
423
424
  }
424
- `;customElements.define("qti-associable-hotspot",Ve);import{LitElement as ps}from"lit";import{property as ds}from"lit/decorators.js";var He=class extends ps{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([ds({type:Number,reflect:!0})],He.prototype,"tabindex",2);customElements.define("qti-gap-img",He);import{html as us,LitElement as ms}from"lit";import{property as hs}from"lit/decorators.js";var $e=class extends ms{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return us`<slot></slot>`}};s([hs({type:Number,reflect:!0})],$e.prototype,"tabindex",2);customElements.define("qti-gap-text",$e);import{html as fs,LitElement as bs}from"lit";import{property as gs}from"lit/decorators.js";var Ne=class extends bs{constructor(){super(...arguments);this.tabindex=0}render(){return fs` <slot name="qti-gap-text"></slot>`}};s([gs({type:Number,reflect:!0})],Ne.prototype,"tabindex",2);customElements.define("qti-gap",Ne);import{css as vs}from"lit";import{property as ys}from"lit/decorators.js";var ne=class extends x{};ne.styles=vs`
425
+ `;customElements.define("qti-associable-hotspot",ze);import{html as eo,LitElement as to}from"lit";import{property as ro}from"lit/decorators.js";var We=class extends to{constructor(){super(...arguments);this.tabindex=0}render(){return eo` <slot name="qti-gap-text"></slot>`}};n([ro({type:Number,reflect:!0})],We.prototype,"tabindex",2);customElements.define("qti-gap",We);import{LitElement as io}from"lit";import{property as so}from"lit/decorators.js";var Je=class extends io{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};n([so({type:Number,reflect:!0})],Je.prototype,"tabindex",2);customElements.define("qti-gap-img",Je);import{html as oo,LitElement as no}from"lit";import{property as ao}from"lit/decorators.js";var Ze=class extends no{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return oo`<slot></slot>`}};n([ao({type:Number,reflect:!0})],Ze.prototype,"tabindex",2);customElements.define("qti-gap-text",Ze);import{css as lo}from"lit";import{property as co}from"lit/decorators.js";var ve=class extends _{};ve.styles=lo`
425
426
  :host {
426
427
  position: absolute;
427
428
  }
428
- `,s([ys({attribute:"aria-ordervalue",type:Number,reflect:!0})],ne.prototype,"order",2);customElements.define("qti-hotspot-choice",ne);import{customElement as xs}from"lit/decorators.js";import{html as Es}from"lit";var De=class extends x{render(){return Es`<div part="ch"><div part="cha"></div></div>
429
- <slot></slot> `}};De=s([xs("qti-hottext")],De);import{LitElement as qs}from"lit";var gt=class extends qs{};customElements.define("qti-inline-choice",gt);import{customElement as Cs}from"lit/decorators.js";import{css as _s,html as ks}from"lit";var ae=class extends x{render(){return ks`<div part="ch"><div part="cha"></div></div>
430
- <slot part="slot"></slot> `}};ae.styles=_s`
429
+ `,n([co({attribute:"aria-ordervalue",type:Number,reflect:!0})],ve.prototype,"order",2);customElements.define("qti-hotspot-choice",ve);import{customElement as po}from"lit/decorators.js";import{html as uo}from"lit";var Ge=class extends _{render(){return uo`<div part="ch"><div part="cha"></div></div>
430
+ <slot></slot> `}};Ge=n([po("qti-hottext")],Ge);import{LitElement as mo}from"lit";var Dt=class extends mo{};customElements.define("qti-inline-choice",Dt);import{customElement as ho}from"lit/decorators.js";import{css as fo,html as go}from"lit";var ye=class extends _{render(){return go`<div part="ch"><div part="cha"></div></div>
431
+ <slot part="slot"></slot> `}};ye.styles=fo`
431
432
  :host {
432
433
  display: flex;
433
434
  }
@@ -435,4 +436,13 @@ import{a as b,b as C,c as s}from"../chunk-343LZK3D.js";import{customElement as W
435
436
  width: 100%;
436
437
  display: block;
437
438
  }
438
- `,ae=s([Cs("qti-simple-choice")],ae);export{h as Interaction,ie as QtPrintedVariable,ve as QtiAnd,_ as QtiAssessmentItem,Ve as QtiAssociableHotspot,se as QtiAssociateInteraction,ye as QtiBaseValue,x as QtiChoice,X as QtiChoiceInteraction,le as QtiCompanionMaterialsInfo,A as QtiConditionExpression,Je as QtiContains,Ze as QtiCorrect,Z as QtiEndAttemptInteraction,Ee as QtiEqual,xe as QtiEqualRounded,u as QtiExpression,R as QtiExtendedTextInteraction,he as QtiFeedbackBlock,ue as QtiFeedbackInline,Ne as QtiGap,He as QtiGapImg,ke as QtiGapMatchInteraction,$e as QtiGapText,H as QtiGraphicAssociateInteraction,Ae as QtiGraphicGapMatchInteraction,we as QtiGraphicOrderInteraction,Ge as QtiGt,Qe as QtiGte,ne as QtiHotspotChoice,Te as QtiHotspotInteraction,De as QtiHottext,Be as QtiHottextInteraction,gt as QtiInlineChoice,D as QtiInlineChoiceInteraction,et as QtiIsNull,ge as QtiLookupOutcomeValue,tt as QtiLt,rt as QtiLte,qe as QtiMapResponse,B as QtiMapping,st as QtiMatch,z as QtiMatchInteraction,Le as QtiMediaInteraction,ot as QtiMember,me as QtiModalFeedback,nt as QtiMultiple,at as QtiNot,lt as QtiOr,W as QtiOrderInteraction,ct as QtiOrdered,I as QtiOutcomeDeclaration,mt as QtiPortableCustomInteraction,Se as QtiPositionObjectStage,pt as QtiProduct,Pe as QtiPrompt,Ke as QtiResponseCondition,F as QtiResponseDeclaration,ee as QtiResponseElse,ze as QtiResponseElseIf,te as QtiResponseIf,Y as QtiResponseProcessing,S as QtiRule,Re as QtiSPositionObjectInteraction,O as QtiSelectPointInteraction,je as QtiSetOutcomeValue,ft as QtiSimpleAssociableChoice,ae as QtiSimpleChoice,E as QtiSliderInteraction,Ce as QtiStringMatch,Oe as QtiStylesheet,dt as QtiSum,T as QtiTextEntryInteraction,ut as QtiVariable,yt as itemContext,ni as qtiAndMixin,pe as qtiContentBody,L as qtiRubricBlock};
439
+ `,ye=n([ho("qti-simple-choice")],ye);export{g as Interaction,fe as QtPrintedVariable,Me as QtiAnd,A as QtiAssessmentItem,ze as QtiAssociableHotspot,ge as QtiAssociateInteraction,He as QtiBaseValue,_ as QtiChoice,G as QtiChoiceInteraction,Ce as QtiCompanionMaterialsInfo,w as QtiConditionExpression,bt as QtiContains,vt as QtiCorrect,ne as QtiEndAttemptInteraction,Ve as QtiEqual,Ne as QtiEqualRounded,m as QtiExpression,L as QtiExtendedTextInteraction,we as QtiFeedbackBlock,$e as QtiFeedbackInline,We as QtiGap,Je as QtiGapImg,Ue as QtiGapMatchInteraction,Ze as QtiGapText,V as QtiGraphicAssociateInteraction,Ie as QtiGraphicGapMatchInteraction,Fe as QtiGraphicOrderInteraction,yt as QtiGt,xt as QtiGte,ve as QtiHotspotChoice,Xe as QtiHotspotInteraction,Ge as QtiHottext,mt as QtiHottextInteraction,Dt as QtiInlineChoice,j as QtiInlineChoiceInteraction,Et as QtiIsNull,Le as QtiLookupOutcomeValue,_t as QtiLt,Ct as QtiLte,Pe as QtiMapResponse,ee as QtiMapping,At as QtiMatch,ie as QtiMatchInteraction,Ye as QtiMediaInteraction,kt as QtiMember,Te as QtiModalFeedback,wt as QtiMultiple,$t as QtiNot,Tt as QtiOr,se as QtiOrderInteraction,Rt as QtiOrdered,D as QtiOutcomeDeclaration,Ht as QtiPortableCustomInteraction,je as QtiPositionObjectStage,St as QtiProduct,Qe as QtiPrompt,ht as QtiResponseCondition,U as QtiResponseDeclaration,me as QtiResponseElse,gt as QtiResponseElseIf,he as QtiResponseIf,Q as QtiResponseProcessing,M as QtiRule,Be as QtiSPositionObjectInteraction,K as QtiSelectPointInteraction,ft as QtiSetOutcomeValue,Vt as QtiSimpleAssociableChoice,ye as QtiSimpleChoice,C as QtiSliderInteraction,De as QtiStringMatch,et as QtiStylesheet,Lt as QtiSum,R as QtiTextEntryInteraction,Mt as QtiVariable,P as itemContext,Wi as qtiAndMixin,qe as qtiContentBody,S as qtiRubricBlock};
440
+ /*! Bundled license information:
441
+
442
+ lit-html/node/lit-html.js:
443
+ (**
444
+ * @license
445
+ * Copyright 2017 Google LLC
446
+ * SPDX-License-Identifier: BSD-3-Clause
447
+ *)
448
+ */