@citolab/qti-components 3.0.69 → 3.0.70

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.
package/index.js CHANGED
@@ -4,11 +4,11 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
4
4
  :host {
5
5
  display: block;
6
6
  }
7
- `,O=q([s("qti-item-body")],O);class R extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function S(e,t){const i=Object.assign({waitUntilFirstUpdate:!1},t);return(t,s)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",R);const k=32;let A=class extends E{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.emit(b.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(b.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===k&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(b.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};q([n({reflect:!0}),x("design:type",String)],A.prototype,"identifier",void 0),q([n({type:Number,reflect:!0}),x("design:type",Object)],A.prototype,"tabindex",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],A.prototype,"disabled",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],A.prototype,"readonly",void 0),q([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),x("design:type",Object)],A.prototype,"checked",void 0),q([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],A.prototype,"handleDisabledChange",null),A=q([s("qti-choice")],A);class w extends e{render(){return t``}}customElements.define("qti-variabledeclaration",w);class N extends w{connectedCallback(){super.connectedCallback();const e=new f({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||g.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:e}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const i=t.querySelectorAll("qti-value");if(1===i.length)e=i[0].textContent,i[0].remove();else{e=[];for(let t=0;t<i.length;t++)e.push(i[t].textContent),i[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,i=e.querySelectorAll("qti-map-entry");for(let e=0;e<i.length;e++){const s=i[e],n=s.getAttribute("map-key"),r=s.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}q([n({type:String,attribute:"base-type"}),x("design:type",String)],N.prototype,"baseType",void 0),q([n({type:String,attribute:"identifier"}),x("design:type",String)],N.prototype,"identifier",void 0),q([n({type:String,attribute:"cardinality"}),x("design:type",String)],N.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",N);class I extends w{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new v;t.identifier=e,this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",I);let T=class extends E{};T=q([s("qti-companion-materials-info")],T);const L=l("logger");let D=class extends E{constructor(){super(...arguments),this.logger=new c(this,L,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};D.styles=i`
7
+ `,O=q([s("qti-item-body")],O);class S extends e{render(){return t` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function R(e,t){const i=Object.assign({waitUntilFirstUpdate:!1},t);return(t,s)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",S);const k=32;let A=class extends E{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.emit(b.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(b.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===k&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(b.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return a` <slot></slot> `}};q([n({reflect:!0}),x("design:type",String)],A.prototype,"identifier",void 0),q([n({type:Number,reflect:!0}),x("design:type",Object)],A.prototype,"tabindex",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],A.prototype,"disabled",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],A.prototype,"readonly",void 0),q([n({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),x("design:type",Object)],A.prototype,"checked",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],A.prototype,"handleDisabledChange",null),A=q([s("qti-choice")],A);class w extends e{render(){return t``}}customElements.define("qti-variabledeclaration",w);class N extends w{connectedCallback(){super.connectedCallback();const e=new f({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||g.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:e}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const i=t.querySelectorAll("qti-value");if(1===i.length)e=i[0].textContent,i[0].remove();else{e=[];for(let t=0;t<i.length;t++)e.push(i[t].textContent),i[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,i=e.querySelectorAll("qti-map-entry");for(let e=0;e<i.length;e++){const s=i[e],n=s.getAttribute("map-key"),r=s.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}q([n({type:String,attribute:"base-type"}),x("design:type",String)],N.prototype,"baseType",void 0),q([n({type:String,attribute:"identifier"}),x("design:type",String)],N.prototype,"identifier",void 0),q([n({type:String,attribute:"cardinality"}),x("design:type",String)],N.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",N);class I extends w{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new v;t.identifier=e,this.dispatchEvent(new CustomEvent(b.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",I);let T=class extends E{};T=q([s("qti-companion-materials-info")],T);const L=l("logger");let D=class extends E{constructor(){super(...arguments),this.logger=new c(this,L,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};D.styles=i`
8
8
  :host {
9
9
  display: block;
10
10
  }
11
- `,q([n({type:String}),x("design:type",Object)],D.prototype,"id",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"use",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"view",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],D.prototype,"classNames",void 0),q([S("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],D.prototype,"handleclassNamesChange",null),D=q([s("qti-rubric-block")],D);let M=class extends E{render(){return t`<slot></slot>`}};M=q([s("qti-content-body")],M);class j extends e{static get properties(){return{showStatus:{type:String,attribute:!0,reflect:!0},showHide:{type:String,attribute:"show-hide"},outcomeIdentifier:{type:String,attribute:"outcome-identifier"},identifier:{type:String}}}constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(b.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class H extends j{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}H.styles=i`
11
+ `,q([n({type:String}),x("design:type",Object)],D.prototype,"id",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"use",void 0),q([n({type:String}),x("design:type",String)],D.prototype,"view",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],D.prototype,"classNames",void 0),q([R("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],D.prototype,"handleclassNamesChange",null),D=q([s("qti-rubric-block")],D);let M=class extends E{render(){return t`<slot></slot>`}};M=q([s("qti-content-body")],M);class j extends e{static get properties(){return{showStatus:{type:String,attribute:!0,reflect:!0},showHide:{type:String,attribute:"show-hide"},outcomeIdentifier:{type:String,attribute:"outcome-identifier"},identifier:{type:String}}}constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(b.ON_REGISTER_FEEDBACK,{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){this.outcomeIdentifier===e&&(t instanceof Array?this.showFeedback(-1!==t.indexOf(this.identifier)):this.showFeedback(this.identifier===t))}showFeedback(e){this.showStatus=e?"on":"off"}}class H extends j{constructor(){super(...arguments),this.render=()=>t` <slot class="${this.showStatus}"></slot> `}}H.styles=i`
12
12
  .on {
13
13
  display: inline-block;
14
14
  }
@@ -152,7 +152,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
152
152
  ?disabled="${this.disabled}"
153
153
  ?readonly="${this.readonly}"
154
154
  .value=${this.value}
155
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}B.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],q([n({type:Number,attribute:"expected-length"}),x("design:type",Object)],B.prototype,"expectedLength",void 0),q([n({type:String,attribute:"pattern-mask"}),x("design:type",Object)],B.prototype,"patternMask",void 0),q([n({type:String,attribute:"placeholder-text"}),x("design:type",Object)],B.prototype,"placeholderText",void 0),q([n({type:String}),x("design:type",Object)],B.prototype,"value",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],B.prototype,"classNames",void 0),q([S("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],B.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",B);let G=class extends A{};G=q([s("qti-hottext")],G);class V extends F{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(b.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}q([n({type:Number,attribute:"min-choices"}),x("design:type",Number)],V.prototype,"_minChoices",void 0),q([n({type:Number,attribute:"max-choices"}),x("design:type",Number)],V.prototype,"_maxChoices",void 0),q([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleDisabledChange",void 0),q([S("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleReadonlyChange",void 0),q([S("_maxChoices",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleMaxChoicesChange",void 0);class Y extends V{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",Y);class z extends F{static get properties(){return Object.assign(Object.assign({},F.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[P,i`
155
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}B.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],q([n({type:Number,attribute:"expected-length"}),x("design:type",Object)],B.prototype,"expectedLength",void 0),q([n({type:String,attribute:"pattern-mask"}),x("design:type",Object)],B.prototype,"patternMask",void 0),q([n({type:String,attribute:"placeholder-text"}),x("design:type",Object)],B.prototype,"placeholderText",void 0),q([n({type:String}),x("design:type",Object)],B.prototype,"value",void 0),q([n({type:String,attribute:"class"}),x("design:type",Object)],B.prototype,"classNames",void 0),q([R("classNames",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],B.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",B);let G=class extends A{};G=q([s("qti-hottext")],G);class V extends F{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(b.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(b.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(b.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}q([n({type:Number,attribute:"min-choices"}),x("design:type",Number)],V.prototype,"_minChoices",void 0),q([n({type:Number,attribute:"max-choices"}),x("design:type",Number)],V.prototype,"_maxChoices",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleDisabledChange",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleReadonlyChange",void 0),q([R("_maxChoices",{waitUntilFirstUpdate:!0}),x("design:type",Object)],V.prototype,"_handleMaxChoicesChange",void 0);class Y extends V{constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",Y);class z extends F{static get properties(){return Object.assign(Object.assign({},F.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[P,i`
156
156
  :host {
157
157
  display: inline-block;
158
158
  }
@@ -173,7 +173,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
173
173
  </select>`}constructor(){super(),this.options=[],this.addEventListener(b.ON_DROPDOWN_SELECTED,this.choiceSelected);const e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map((e=>({textContent:e.innerHTML,value:e.getAttribute("identifier"),selected:!1})))]}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}z.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"],customElements.define("qti-inline-choice-interaction",z);class X extends V{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>t`
174
174
  <slot name="prompt"></slot>
175
175
  <slot></slot>`}}X.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],X.presentationClass=["","qti-input-control-hidden"],q([n({attribute:"orientation"}),x("design:type",String)],X.prototype,"_orientation",void 0),q([n({attribute:"shuffle",type:Boolean}),x("design:type",Boolean)],X.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",X);let K=class extends A{};K=q([s("qti-simple-choice")],K);class W extends e{render(){return t`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",W);class Q extends e{render(){return t``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",Q);class J extends Q{render(){return t`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const i=e[t];if(i.calculate())return void i.process()}}}customElements.define("qti-response-condition",J);class Z extends e{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return t`
176
- <slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",Z);class ee extends Z{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",ee);class te extends ee{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",te);class ie extends E{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ie);class se extends ie{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const i=t.mapping,s=t.value;let n=0;if(Array.isArray(s)){for(let e=0;e<s.length;e++)n+=ne(i,s[e],t.baseType);return n}return n+=ne(i,s,t.baseType),n}}function ne(e,t,i){let s=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=re(i,n,t);e===r&&(s+=n[1])}return s}function re(e,t,i){let s,n;switch(e){case m.string:case m.identifier:case m.directedPair:s=""+t[0],n=""+i;break;case m.float:s=parseFloat(t[0].replace(",",".")),n=parseFloat(i.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:s,valueTyped:n}}customElements.define("qti-map-response",se);class oe extends Q{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,i=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,i)}}customElements.define("qti-set-outcome-value",oe);class ae extends ie{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ae);class le extends ie{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",le);class ce extends ie{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let i=!0;return i=e instanceof Array?e.length===t.length&&e.filter(((e,i)=>e===t[i])).length===e.length:e==t,i}}customElements.define("qti-match",ce);class de extends ie{calculate(){return de.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let i;if(t===m.directedPair){const t=e.split(" ");i={destination:t[1],source:t[0]}}else i=e;return i}}customElements.define("qti-base-value",de);class he extends ie{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return he.calculate(e,t)}static calculate(e,t){const i=e.calculate(),s=t.calculate(),n=i.map((e=>e.source+" "+e.destination)),r=s.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",he);class pe extends ie{calculate(){return 2===this.children.length?pe.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",pe);class ue extends ie{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ue);class me extends ie{render(){return t``}calculate(){return me.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",me);class ge extends ie{render(){return t``}calculate(){return ge.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ge);class be extends ie{calculate(){return 1===this.children.length?be.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",be);class ye extends E{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){const t=e.querySelectorAll("properties");let i={};const s=e=>{const t={},i=e.getAttribute("key");if(i){const s=Array.from(e.children),r=s.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[i]=o?s.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const i of e.children)t=Object.assign(Object.assign({},t),s(i));return t}};for(const e of t){return e.getAttribute("key")||(i=Object.assign(Object.assign({},i),n(e))),i}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",i="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const s="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(i,s,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,s),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,i.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{this._errorMessage=e}))}),(e=>{this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ye);const fe=(e,t,i)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(t?this.shadowRoot.querySelectorAll(i):this.querySelectorAll(i));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,i=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`),s=i||this.shadowRoot.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},ve=(e,t,i)=>class extends e{};class Ee{constructor(){return 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(e,t){this.data[e]=t},getData:function(e){return this.data[e]},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,Ee._instance?Ee._instance:(Ee._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(e){e.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(e){this._touchBegin=Date.now();const{x:t,y:i}=this.getPositionFromEvent(e);this._touchDown={x:t,y:i},this._dragSrc=e.currentTarget,this._canDrag=!0,e.preventDefault()}_touchMove(e){if(this._canDrag&&this._dragSrc){const{x:i,y:s}=this.getPositionFromEvent(e),n={clientX:i,clientY:s};if(this._getDelta(n)>=this._DRAGDELTA&&(this._dragRunning=!0),null===this._dragCopy&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);const e=window.getComputedStyle(this._dragSrc);this._dragCopy.style="";for(const t of e)this._dragCopy.style[t]=e.getPropertyValue(t);this._calculateDragCopyPosition(n),this._dragCopy.style.top=n.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=n.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="absolute",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){const i=this;requestAnimationFrame((function(){i._touchEndCalled||null===i._dragCopy||(i._dragCopy.style.top=n.clientY-i._copyOffset.y+"px",i._dragCopy.style.left=n.clientX-i._copyOffset.x+"px")}));var t=this._findDroppable(e);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover"),e.preventDefault()}}}_touchEnd(e){var t;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){const e=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});e.dataTransfer={dropEffect:"none"},null===(t=this._dragSrc)||void 0===t||t.dispatchEvent(e)}this._reset()}_touchCancel(e){this._reset()}_findDroppable(e){let t;const i=e.composedPath().find((e=>{if(1===e.nodeType&&"SLOT"!==e.nodeName&&e.hasAttribute("dropzone"))return e}));if(i){const s=i.getRootNode(),n=this._getPoint(e);t=s.elementFromPoint(n.x,n.y)}return t}_getPoint(e,t){return e&&e.touches&&(e=e.touches[0]),{x:t?e.pageX:e.clientX,y:t?e.pageY:e.clientY}}_calculateDragCopyPosition(e){const t=this._dragSrc.getBoundingClientRect();this._copyOffset.x=e.clientX-t.left,this._copyOffset.y=e.clientY-t.top}_getDelta(e){return Math.abs(e.clientX-this._touchDown.x)+Math.abs(e.clientY-this._touchDown.y)}_dispatchEvent(e,t,i=!0){if(!e)return!1;const s=new CustomEvent(t,{bubbles:i,cancelable:!0});return s.dataTransfer=this._dataTransfer,e.dispatchEvent(s),s.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(e,t){this.data[e]=t},getData:function(e){return this.data[e]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(e){let t;if("touchstart"==e.type||"touchmove"==e.type||"touchend"==e.type||"touchcancel"==e.type){const i=void 0===e.originalEvent?e:e.originalEvent,s=i.touches[0]||i.changedTouches[0];t={x:s.pageX,y:s.pageY}}else"mousedown"!=e.type&&"mouseup"!=e.type&&"mousemove"!=e.type&&"mouseover"!=e.type&&"mouseout"!=e.type&&"mouseenter"!=e.type&&"mouseleave"!=e.type||(t={x:e.clientX,y:e.clientY});return t}}function _e(e,t){let i;return Object.assign({},t),(t,s)=>{const{connectedCallback:n,disconnectedCallback:r}=t;t.connectedCallback=function(){var t;n.call(this);i=new MutationObserver((t=>{const i=Array.from(this.querySelectorAll(e));for(const e of t){const t=Array.from(e.addedNodes).map((e=>e)),n=Array.from(e.addedNodes).map((e=>e));"childList"===e.type&&t.find((e=>i.includes(e)))&&this[s](t,n)}})),i.observe(this,{childList:!0,subtree:!0});const r=null!==(t=this.querySelectorAll(e))&&void 0!==t?t:[];this[s](Array.from(r),[])},t.disconnectedCallback=function(){r.call(this),i.disconnect()}}}const Ce=(e,t,i,s)=>{class r extends(ve(fe(e,i,s))){constructor(){super(...arguments),this.draggables=new Map,this.responseIdentifier="",this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1}reInitDragAndDrop(e,t){if(this.classList.contains("qti-match-tabular"))return;e.filter((e=>!this.draggables||!this.draggables.get(e))).length>0&&(this.dragDropApi.addDraggables(e),e.forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.setAttribute("qti-draggable","true"),e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),this.addDragEndEvent(e)})))}handleDisabledChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("disabled",""):i.removeAttribute("disabled"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}handleReadonlyChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("readonly",""):i.removeAttribute("readonly"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}firstUpdated(e){super.firstUpdated(e),this.droppables=Array.from(i?this.shadowRoot.querySelectorAll(s):this.querySelectorAll(s))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Ee,this.dispatchEvent(new CustomEvent(b.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}addDragEndEvent(e){e.addEventListener("dragend",(t=>{if(t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging"),"none"===t.dataTransfer.dropEffect){const e=t.currentTarget,i=this.draggables.get(e),s=i.index<i.parent.children.length?i.index:i.parent.children.length-1,n=i.parent,r=i.parent.children[s];n.insertBefore(e,r)}t.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const i=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[i])})),e&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach((e=>{const t=+(e.getAttribute("match-max")||1)<=(e.children.length||0);t?e.setAttribute("disabled",""):e.removeAttribute("disabled"),t?e.removeAttribute("dropzone"):e.setAttribute("dropzone","move")}))}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,...i]=e.split(" ").reverse();if(t){const e=this.droppables.find((e=>e.getAttribute("identifier")===t));i.forEach((i=>{const s=this.querySelector(`[identifier=${i}]`);e?s?(e.appendChild(s),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${i}`):console.error(`cannot find droppable with identifier: ${t}`)}))}})))}validate(){const e=(i?Array.from(this.shadowRoot.querySelectorAll(s)):Array.from(this.querySelectorAll(s))).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:this.droppables.map((e=>{var t;let i="";return(null===(t=e.children)||void 0===t?void 0:t.length)>0&&(i+=Array.from(e.children).map((e=>e.getAttribute("identifier"))).join(" ")+" "),i+=e.getAttribute("identifier"),i}))}};this.dispatchEvent(new CustomEvent(b.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}}return q([_e(t),x("design:type",Function),x("design:paramtypes",[Array,Array]),x("design:returntype",void 0)],r.prototype,"reInitDragAndDrop",null),q([n({type:String,attribute:"response-identifier"}),x("design:type",String)],r.prototype,"responseIdentifier",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"disabled",void 0),q([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],r.prototype,"handleDisabledChange",null),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"readonly",void 0),q([S("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],r.prototype,"handleReadonlyChange",null),q([n({type:Number,reflect:!0,attribute:"min-associations"}),x("design:type",Object)],r.prototype,"minAssociations",void 0),q([n({type:Number,reflect:!0,attribute:"max-associations"}),x("design:type",Object)],r.prototype,"maxAssociations",void 0),r};class qe extends(Ce(E,"qti-simple-associable-choice",!0,"drop-list")){render(){return t` <slot name="prompt"></slot>
176
+ <slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",Z);class ee extends Z{render(){return t`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",ee);class te extends ee{render(){return t`${super.render()}`}}customElements.define("qti-response-else-if",te);class ie extends E{render(){return t``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",ie);class se extends ie{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const i=t.mapping,s=t.value;let n=0;if(Array.isArray(s)){for(let e=0;e<s.length;e++)n+=ne(i,s[e],t.baseType);return n}return n+=ne(i,s,t.baseType),n}}function ne(e,t,i){let s=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=re(i,n,t);e===r&&(s+=n[1])}return s}function re(e,t,i){let s,n;switch(e){case m.string:case m.identifier:case m.directedPair:s=""+t[0],n=""+i;break;case m.float:s=parseFloat(t[0].replace(",",".")),n=parseFloat(i.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:s,valueTyped:n}}customElements.define("qti-map-response",se);class oe extends Q{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,i=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,i)}}customElements.define("qti-set-outcome-value",oe);class ae extends ie{render(){return t``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",ae);class le extends ie{render(){return t``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",le);class ce extends ie{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let i=!0;return i=e instanceof Array?e.length===t.length&&e.filter(((e,i)=>e===t[i])).length===e.length:e==t,i}}customElements.define("qti-match",ce);class de extends ie{calculate(){return de.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let i;if(t===m.directedPair){const t=e.split(" ");i={destination:t[1],source:t[0]}}else i=e;return i}}customElements.define("qti-base-value",de);class he extends ie{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return he.calculate(e,t)}static calculate(e,t){const i=e.calculate(),s=t.calculate(),n=i.map((e=>e.source+" "+e.destination)),r=s.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",he);class pe extends ie{calculate(){return 2===this.children.length?pe.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",pe);class ue extends ie{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",ue);class me extends ie{render(){return t``}calculate(){return me.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",me);class ge extends ie{render(){return t``}calculate(){return ge.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",ge);class be extends ie{calculate(){return 1===this.children.length?be.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",be);class ye extends E{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){const t=e.querySelectorAll("properties");let i={};const s=e=>{const t={},i=e.getAttribute("key");if(i){const s=Array.from(e.children),r=s.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[i]=o?s.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const i of e.children)t=Object.assign(Object.assign({},t),s(i));return t}};for(const e of t){return e.getAttribute("key")||(i=Object.assign(Object.assign({},i),n(e))),i}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",i="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const s="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(i,s,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,s),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,i.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{this._errorMessage=e}))}),(e=>{this._errorMessage=e}))}render(){return t`<slot></slot>${this._errorMessage&&t`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",ye);const fe=(e,t,i)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(t?this.shadowRoot.querySelectorAll(i):this.querySelectorAll(i));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,i=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`),s=i||this.shadowRoot.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},ve=(e,t,i)=>class extends e{};class Ee{constructor(){return 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(e,t){this.data[e]=t},getData:function(e){return this.data[e]},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,Ee._instance?Ee._instance:(Ee._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(e){e.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(e){this._touchBegin=Date.now();const{x:t,y:i}=this.getPositionFromEvent(e);this._touchDown={x:t,y:i},this._dragSrc=e.currentTarget,this._canDrag=!0,e.preventDefault()}_touchMove(e){if(this._canDrag&&this._dragSrc){const{x:i,y:s}=this.getPositionFromEvent(e),n={clientX:i,clientY:s};if(this._getDelta(n)>=this._DRAGDELTA&&(this._dragRunning=!0),null===this._dragCopy&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);const e=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(const t of e)this._dragCopy.style[t]=e.getPropertyValue(t);this._calculateDragCopyPosition(n),this._dragCopy.style.top=n.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=n.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="absolute",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){const i=this;requestAnimationFrame((function(){i._touchEndCalled||null===i._dragCopy||(i._dragCopy.style.top=n.clientY-i._copyOffset.y+"px",i._dragCopy.style.left=n.clientX-i._copyOffset.x+"px")}));var t=this._findDroppable(e);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover"),e.preventDefault()}}}_touchEnd(e){var t;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){const e=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});e.dataTransfer={dropEffect:"none"},null===(t=this._dragSrc)||void 0===t||t.dispatchEvent(e)}this._reset()}_touchCancel(e){this._reset()}_findDroppable(e){let t;const i=e.composedPath().find((e=>{if(1===e.nodeType&&"SLOT"!==e.nodeName&&e.hasAttribute("dropzone"))return e}));if(i){const s=i.getRootNode(),n=this._getPoint(e);t=s.elementFromPoint(n.x,n.y)}return t}_getPoint(e,t){return e&&e.touches&&(e=e.touches[0]),{x:t?e.pageX:e.clientX,y:t?e.pageY:e.clientY}}_calculateDragCopyPosition(e){const t=this._dragSrc.getBoundingClientRect();this._copyOffset.x=e.clientX-t.left,this._copyOffset.y=e.clientY-t.top}_getDelta(e){return Math.abs(e.clientX-this._touchDown.x)+Math.abs(e.clientY-this._touchDown.y)}_dispatchEvent(e,t,i=!0){if(!e)return!1;const s=new CustomEvent(t,{bubbles:i,cancelable:!0});return s.dataTransfer=this._dataTransfer,e.dispatchEvent(s),s.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(e,t){this.data[e]=t},getData:function(e){return this.data[e]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(e){let t;if("touchstart"==e.type||"touchmove"==e.type||"touchend"==e.type||"touchcancel"==e.type){const i=void 0===e.originalEvent?e:e.originalEvent,s=i.touches[0]||i.changedTouches[0];t={x:s.pageX,y:s.pageY}}else"mousedown"!=e.type&&"mouseup"!=e.type&&"mousemove"!=e.type&&"mouseover"!=e.type&&"mouseout"!=e.type&&"mouseenter"!=e.type&&"mouseleave"!=e.type||(t={x:e.clientX,y:e.clientY});return t}}function _e(e,t){let i;return Object.assign({},t),(t,s)=>{const{connectedCallback:n,disconnectedCallback:r}=t;t.connectedCallback=function(){var t;n.call(this);i=new MutationObserver((t=>{const i=Array.from(this.querySelectorAll(e));for(const e of t){const t=Array.from(e.addedNodes).map((e=>e)),n=Array.from(e.addedNodes).map((e=>e));"childList"===e.type&&t.find((e=>i.includes(e)))&&this[s](t,n)}})),i.observe(this,{childList:!0,subtree:!0});const r=null!==(t=this.querySelectorAll(e))&&void 0!==t?t:[];this[s](Array.from(r),[])},t.disconnectedCallback=function(){r.call(this),i.disconnect()}}}const Ce=(e,t,i,s)=>{class r extends(ve(fe(e,i,s))){constructor(){super(...arguments),this.draggables=new Map,this.responseIdentifier="",this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1}reInitDragAndDrop(e,t){if(this.classList.contains("qti-match-tabular"))return;e.filter((e=>!this.draggables||!this.draggables.get(e))).length>0&&(this.dragDropApi.addDraggables(e),e.forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.setAttribute("qti-draggable","true"),e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),this.addDragEndEvent(e)})))}handleDragOptionsChanged(e,t){const{copyStylesDragClone:i}=t;this.dragDropApi.copyStylesDragClone=i}handleDisabledChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("disabled",""):i.removeAttribute("disabled"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}handleReadonlyChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("readonly",""):i.removeAttribute("readonly"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}firstUpdated(e){super.firstUpdated(e),this.droppables=Array.from(i?this.shadowRoot.querySelectorAll(s):this.querySelectorAll(s))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new Ee,this.dispatchEvent(new CustomEvent(b.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}addDragEndEvent(e){e.addEventListener("dragend",(t=>{if(t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging"),"none"===t.dataTransfer.dropEffect){const e=t.currentTarget,i=this.draggables.get(e),s=i.index<i.parent.children.length?i.index:i.parent.children.length-1,n=i.parent,r=i.parent.children[s];n.insertBefore(e,r)}t.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const i=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[i])})),e&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach((e=>{const t=+(e.getAttribute("match-max")||1)<=(e.children.length||0);t?e.setAttribute("disabled",""):e.removeAttribute("disabled"),t?e.removeAttribute("dropzone"):e.setAttribute("dropzone","move")}))}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,...i]=e.split(" ").reverse();if(t){const e=this.droppables.find((e=>e.getAttribute("identifier")===t));i.forEach((i=>{const s=this.querySelector(`[identifier=${i}]`);e?s?(e.appendChild(s),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${i}`):console.error(`cannot find droppable with identifier: ${t}`)}))}})))}validate(){const e=(i?Array.from(this.shadowRoot.querySelectorAll(s)):Array.from(this.querySelectorAll(s))).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:this.droppables.map((e=>{var t;let i="";return(null===(t=e.children)||void 0===t?void 0:t.length)>0&&(i+=Array.from(e.children).map((e=>e.getAttribute("identifier"))).join(" ")+" "),i+=e.getAttribute("identifier"),i}))}};this.dispatchEvent(new CustomEvent(b.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}}return q([_e(t),x("design:type",Function),x("design:paramtypes",[Array,Array]),x("design:returntype",void 0)],r.prototype,"reInitDragAndDrop",null),q([n({type:String,attribute:"response-identifier"}),x("design:type",String)],r.prototype,"responseIdentifier",void 0),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"disabled",void 0),q([n({type:Object}),x("design:type",Object)],r.prototype,"dragOptions",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Object]),x("design:returntype",void 0)],r.prototype,"handleDragOptionsChanged",null),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],r.prototype,"handleDisabledChange",null),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],r.prototype,"readonly",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],r.prototype,"handleReadonlyChange",null),q([n({type:Number,reflect:!0,attribute:"min-associations"}),x("design:type",Object)],r.prototype,"minAssociations",void 0),q([n({type:Number,reflect:!0,attribute:"max-associations"}),x("design:type",Object)],r.prototype,"maxAssociations",void 0),r};class qe extends(Ce(E,"qti-simple-associable-choice",!0,"drop-list")){render(){return t` <slot name="prompt"></slot>
177
177
  <slot name="qti-simple-associable-choice"></slot>
178
178
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map(((e,i)=>t`<div part="associables-container">
179
179
  <drop-list part="drop-list" identifier="droplist${i}_left"></drop-list>
@@ -201,7 +201,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
201
201
  gap: var(--qti-gap, 0.5rem);
202
202
  padding: var(--qti-gap, 0.5rem) 0px;
203
203
  }
204
- `,customElements.define("qti-gap-match-interaction",Oe);class Re extends e{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return t`<slot></slot>`}}customElements.define("qti-gap-text",Re);class Se extends e{render(){return t` <slot name="qti-gap-text"></slot>`}}function ke(e,t,i,s){switch(e){case"circle":{const[e,n,r]=t,o=e/i.width*100,a=n/i.height*100,l=r/i.width*100;s.style.left=o-l+"%",s.style.top=a-l+"%",s.style.width=s.style.height=4*l+"px",s.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/i.width*100,l=n/i.height*100,c=r/i.width*100,d=o/i.height*100;s.style.left=a+"%",s.style.top=l+"%",s.style.width=c-a+"%",s.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,i,s)=>{if(i%2==1){const t=e.pop();e[e.length]={x:t,y:s[i]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/i.width*100,c=o/i.height*100,d=r/i.width*100,h=a/i.height*100;s.style.left=n/i.width*100+"%",s.style.top=o/i.height*100+"%",s.style.width=d-l+"%",s.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");s.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Se);class Ae extends V{render(){return t`
204
+ `,customElements.define("qti-gap-match-interaction",Oe);class Se extends e{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return t`<slot></slot>`}}customElements.define("qti-gap-text",Se);class Re extends e{render(){return t` <slot name="qti-gap-text"></slot>`}}function ke(e,t,i,s){switch(e){case"circle":{const[e,n,r]=t,o=e/i.width*100,a=n/i.height*100,l=r/i.width*100;s.style.left=o-l+"%",s.style.top=a-l+"%",s.style.width=s.style.height=4*l+"px",s.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/i.width*100,l=n/i.height*100,c=r/i.width*100,d=o/i.height*100;s.style.left=a+"%",s.style.top=l+"%",s.style.width=c-a+"%",s.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,i,s)=>{if(i%2==1){const t=e.pop();e[e.length]={x:t,y:s[i]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/i.width*100,c=o/i.height*100,d=r/i.width*100,h=a/i.height*100;s.style.left=n/i.width*100+"%",s.style.top=o/i.height*100+"%",s.style.width=d-l+"%",s.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");s.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Re);class Ae extends V{render(){return t`
205
205
  <slot name="prompt"></slot>
206
206
  <!-- slot for the prompt -->
207
207
  <slot></slot>
@@ -329,7 +329,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
329
329
  <div class="notification"></div>`}constructor(){super()}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}He.styles=[Le],customElements.define("qti-select-point-interaction",He);class $e extends F{constructor(){super(...arguments),this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=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){this.value=e}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);const e=(this.value-this.min)/(this.max-this.min)*100;return t`<slot name="prompt"></slot>
330
330
  <div id="rail" @mousedown=${this._onMouseDown} part="rail">
331
331
  <div id="knob" part="knob" style="left:${e}%"></div>
332
- </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=e=>{const t=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(t),e.preventDefault(),e.stopPropagation()},i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i);const s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,i=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=i}}$e.styles=[i``],q([o("#knob"),x("design:type",HTMLElement)],$e.prototype,"_knob",void 0),q([o("#rail"),x("design:type",HTMLElement)],$e.prototype,"_rail",void 0),q([n({type:Number}),x("design:type",Number)],$e.prototype,"value",void 0),q([n({type:Boolean,attribute:"step-label"}),x("design:type",Object)],$e.prototype,"stepLabel",void 0),q([n({type:Boolean}),x("design:type",Object)],$e.prototype,"reverse",void 0),q([n({type:Number,attribute:"lower-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"min",null),q([n({type:Number,attribute:"upper-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"max",null),q([n({type:Number,attribute:"step"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"step",null),q([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleDisabledChange",void 0),q([S("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",$e);class Fe extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}levenshtein(e,t){let i;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(i=e,e=t,t=i);const s=e.length,n=t.length,r=Array(s);let o,a,l;for(o=0;o<=s;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=s;a++)i=r[a-1],r[a-1]=l,l=Math.min(i+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,i=e.calculate(),s=t.calculate();return this.value=100-this.levenshtein(i.toString().trim(),s.toString().trim())/s.toString().length*100,this.value}}Fe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Fe);class Pe extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Pe);class Ue extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const i=Intl.NumberFormat(t).format(1.1),s=new RegExp(`[^-+0-9${i.charAt(1)}]`,"g"),n=e.replace(s,"").replace(i.charAt(1),".");return parseFloat(n)}}Ue.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ue);class Be extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Be);class Ge extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Ge);const Ve=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(Ve(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Ve(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Ve(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Ve(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Ve(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Ve(e,"on-show-correct")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const Ye={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var ze,Xe;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(ze||(ze={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(Xe||(Xe={}));let Ke=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=ze.nonlinear,this._submissionMode=Xe.simultaneous,this.items=[],this.itemIndex=0,this.provider=new d(this,L,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===ze.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(Ye.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===ze.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(Ye.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(Ye.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==ze.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(Ye.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(Ye.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Ye.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(Ye.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(Ye.ON_ITEM_READY,{detail:t}))}render(){return t`
332
+ </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=e=>{const t=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(t),e.preventDefault(),e.stopPropagation()},i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i);const s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,i=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=i}}$e.styles=[i``],q([o("#knob"),x("design:type",HTMLElement)],$e.prototype,"_knob",void 0),q([o("#rail"),x("design:type",HTMLElement)],$e.prototype,"_rail",void 0),q([n({type:Number}),x("design:type",Number)],$e.prototype,"value",void 0),q([n({type:Boolean,attribute:"step-label"}),x("design:type",Object)],$e.prototype,"stepLabel",void 0),q([n({type:Boolean}),x("design:type",Object)],$e.prototype,"reverse",void 0),q([n({type:Number,attribute:"lower-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"min",null),q([n({type:Number,attribute:"upper-bound"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"max",null),q([n({type:Number,attribute:"step"}),x("design:type",Number),x("design:paramtypes",[Number])],$e.prototype,"step",null),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleDisabledChange",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Object)],$e.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",$e);class Fe extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}levenshtein(e,t){let i;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(i=e,e=t,t=i);const s=e.length,n=t.length,r=Array(s);let o,a,l;for(o=0;o<=s;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=s;a++)i=r[a-1],r[a-1]=l,l=Math.min(i+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,i=e.calculate(),s=t.calculate();return this.value=100-this.levenshtein(i.toString().trim(),s.toString().trim())/s.toString().length*100,this.value}}Fe.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Fe);class Pe extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Pe);class Ue extends e{constructor(){super(...arguments),this.render=()=>t`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const i=Intl.NumberFormat(t).format(1.1),s=new RegExp(`[^-+0-9${i.charAt(1)}]`,"g"),n=e.replace(s,"").replace(i.charAt(1),".");return parseFloat(n)}}Ue.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ue);class Be extends e{render(){return t``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Be);class Ge extends e{render(){return t``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Ge);const Ve=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(Ve(e,"on-next-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Ve(e,"on-request-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Ve(e,"on-prev-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Ve(e,"on-check-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Ve(e,"on-score-item")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Ve(e,"on-show-correct")){constructor(){super(...arguments),this.render=()=>t`<slot></slot>`}});const Ye={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var ze,Xe;!function(e){e.linear="linear",e.nonlinear="nonlinear"}(ze||(ze={})),function(e){e.individual="individual",e.simultaneous="simultaneous"}(Xe||(Xe={}));let Ke=class extends e{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=ze.nonlinear,this._submissionMode=Xe.simultaneous,this.items=[],this.itemIndex=0,this.provider=new d(this,L,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===ze.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(Ye.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===ze.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(Ye.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(Ye.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==ze.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(Ye.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(Ye.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(Ye.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(Ye.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(Ye.ON_ITEM_READY,{detail:t}))}render(){return t`
333
333
  <slot
334
334
  @slotchange=${this._handleSlotchange}
335
335
  @on-prev-item=${this._onPrevItem}
@@ -340,7 +340,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
340
340
  @on-show-correct=${this._onShowCorrect}
341
341
  >
342
342
  </slot>
343
- `}emit(e,t){const i=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(i)}};q([o("qti-test-prev"),x("design:type",HTMLElement)],Ke.prototype,"prevButton",void 0),q([o("qti-test-next"),x("design:type",HTMLElement)],Ke.prototype,"nextButton",void 0),q([n({type:Boolean}),x("design:type",Object)],Ke.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Ke.prototype,"readonly",void 0),q([n({type:String,attribute:"navigation-mode"}),x("design:type",Object)],Ke.prototype,"_navigationMode",void 0),q([S("_navigationMode",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,String]),x("design:returntype",void 0)],Ke.prototype,"handleNavigationModeChange",null),q([n({type:String,attribute:"submission-mode"}),x("design:type",Object)],Ke.prototype,"_submissionMode",void 0),q([n(),x("design:type",Array)],Ke.prototype,"items",void 0),q([n({type:Number,attribute:"item-index",reflect:!0}),x("design:type",Object)],Ke.prototype,"itemIndex",void 0),q([S("itemIndex",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Number]),x("design:returntype",void 0)],Ke.prototype,"handleItemIndexChange",null),q([r(),x("design:type",_)],Ke.prototype,"_itemRef",void 0),Ke=q([s("qti-test")],Ke);const We=(e,t)=>class extends e{constructor(){super(...arguments),this.scale=1,this.ro=new ResizeObserver((e=>{for(const t of e)this.fitToParent(t.contentRect.width)}))}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(e){e.forEach(((e,t)=>{if("scales"===t)this.scales&&this.fitToParent()}))}fitToParent(e=this.clientWidth){const i=this.querySelector(t);if(i){const t=e/i.clientWidth;this.scale=t,this.marginY=-i.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{i.style.transform=`scale(${this.scale})`,i.style.margin=`0 0 ${this.marginY} 0`}))}}};class Qe extends(We(e,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>t`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("disabled","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("disabled"))}handleReadonlyChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("readonly","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}Qe.styles=i`
343
+ `}emit(e,t){const i=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(i)}};q([o("qti-test-prev"),x("design:type",HTMLElement)],Ke.prototype,"prevButton",void 0),q([o("qti-test-next"),x("design:type",HTMLElement)],Ke.prototype,"nextButton",void 0),q([n({type:Boolean}),x("design:type",Object)],Ke.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Ke.prototype,"readonly",void 0),q([n({type:String,attribute:"navigation-mode"}),x("design:type",Object)],Ke.prototype,"_navigationMode",void 0),q([R("_navigationMode",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,String]),x("design:returntype",void 0)],Ke.prototype,"handleNavigationModeChange",null),q([n({type:String,attribute:"submission-mode"}),x("design:type",Object)],Ke.prototype,"_submissionMode",void 0),q([n(),x("design:type",Array)],Ke.prototype,"items",void 0),q([n({type:Number,attribute:"item-index",reflect:!0}),x("design:type",Object)],Ke.prototype,"itemIndex",void 0),q([R("itemIndex",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Number]),x("design:returntype",void 0)],Ke.prototype,"handleItemIndexChange",null),q([r(),x("design:type",_)],Ke.prototype,"_itemRef",void 0),Ke=q([s("qti-test")],Ke);const We=(e,t)=>class extends e{constructor(){super(...arguments),this.scale=1,this.ro=new ResizeObserver((e=>{for(const t of e)this.fitToParent(t.contentRect.width)}))}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(e){e.forEach(((e,t)=>{if("scales"===t)this.scales&&this.fitToParent()}))}fitToParent(e=this.clientWidth){const i=this.querySelector(t);if(i){const t=e/i.clientWidth;this.scale=t,this.marginY=-i.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{i.style.transform=`scale(${this.scale})`,i.style.margin=`0 0 ${this.marginY} 0`}))}}};class Qe extends(We(e,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>t`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("disabled","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("disabled"))}handleReadonlyChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("readonly","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}Qe.styles=i`
344
344
  :host {
345
345
  display: block; /* necessary to calculate scaling position */
346
346
  width: 100%;
@@ -356,7 +356,7 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
356
356
  width: 1024px;
357
357
  transform-origin: 0 0;
358
358
  }
359
- `,q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Qe.prototype,"disabled",void 0),q([S("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Qe.prototype,"handleDisabledChange",null),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Qe.prototype,"readonly",void 0),q([S("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Qe.prototype,"handleReadonlyChange",null),q([n({type:Object,reflect:!0}),x("design:type",Object)],Qe.prototype,"responses",void 0),q([S("responses",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Object]),x("design:returntype",void 0)],Qe.prototype,"handleResponsesChange",null),q([r(),x("design:type",_)],Qe.prototype,"_item",void 0),customElements.define("qti-item",Qe);let Je=class extends E{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.logger=new c(this,L,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return t`<input
359
+ `,q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Qe.prototype,"disabled",void 0),q([R("disabled",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Qe.prototype,"handleDisabledChange",null),q([n({type:Boolean,reflect:!0}),x("design:type",Object)],Qe.prototype,"readonly",void 0),q([R("readonly",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Boolean]),x("design:returntype",void 0)],Qe.prototype,"handleReadonlyChange",null),q([n({type:Object,reflect:!0}),x("design:type",Object)],Qe.prototype,"responses",void 0),q([R("responses",{waitUntilFirstUpdate:!0}),x("design:type",Function),x("design:paramtypes",[Object,Object]),x("design:returntype",void 0)],Qe.prototype,"handleResponsesChange",null),q([r(),x("design:type",_)],Qe.prototype,"_item",void 0),customElements.define("qti-item",Qe);let Je=class extends E{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.logger=new c(this,L,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return t`<input
360
360
  part="input"
361
361
  type="number"
362
362
  spellcheck="false"
@@ -374,4 +374,4 @@ import{LitElement as e,html as t,css as i}from"lit";import{customElement as s,pr
374
374
  :host {
375
375
  display: none;
376
376
  }
377
- `,q([n({type:Boolean}),x("design:type",Object)],Je.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Je.prototype,"readonly",void 0),q([n({type:Number}),x("design:type",String)],Je.prototype,"value",void 0),q([n({type:Number}),x("design:type",Number)],Je.prototype,"min",void 0),q([n({type:Number}),x("design:type",Number)],Je.prototype,"max",void 0),Je=q([s("qti-manual-scoring")],Je);export{m as BaseType,g as Cardinality,V as Choices,Ce as DragDropInteractionMixin,fe as DroppablesMixin,b as Events,ve as FlippablesMixin,ze as NavigationMode,v as OutcomeVariable,me as QtiAnd,_ as QtiAssessmentItem,qe as QtiAssociateInteraction,de as QtiBaseValue,A as QtiChoice,X as QtiChoiceInteraction,T as QtiCompanionMaterialsInfo,he as QtiContains,ae as QtiCorrect,Fe as QtiCustomOperatorLevenshtein,Pe as QtiCustomOperatorNumericOnly,Ue as QtiCustomOperatorParseNumberLocalNl,Be as QtiCustomOperatorRemoveAllSpaces,Ge as QtiCustomOperatorTrim,ie as QtiExpression,B as QtiExtendedTextInteraction,H as QtiFeedbackInline,Se as QtiGap,Oe as QtiGapMatchInteraction,Re as QtiGapText,Ae as QtiGraphicAssociateInteraction,we as QtiGraphicGapMatchInteraction,Ne as QtiGraphicOrderInteraction,pe as QtiGte,Te as QtiHotspotChoice,Ie as QtiHotspotInteraction,G as QtiHottext,Y as QtiHottextInteraction,z as QtiInlineChoiceInteraction,be as QtiIsNull,Qe as QtiItem,O as QtiItemBody,Je as QtiManualScoring,se as QtiMapResponse,ce as QtiMatch,De as QtiMatchInteraction,Me as QtiMediaInteraction,$ as QtiModalFeedback,ue as QtiMultiple,ge as QtiOr,je as QtiOrderInteraction,I as QtiOutcomeDeclaration,ye as QtiPortableCustomInteraction,R as QtiPrompt,J as QtiResponseCondition,N as QtiResponseDeclaration,Z as QtiResponseElse,te as QtiResponseElseIf,ee as QtiResponseIf,W as QtiResponseProcessing,He as QtiSelectPointInteraction,oe as QtiSetOutcomeValue,K as QtiSimpleChoice,$e as QtiSliderInteraction,C as QtiStylesheet,Ke as QtiTest,U as QtiTextEntryInteraction,le as QtiVariable,f as ResponseVariable,y as Status,Xe as SubmissionMode,Ye as TestEvents,Ee as TouchDragAndDrop,M as qtiContentBody,D as qtiRubricBlock,xe as qtiSimpleAssociableChoice};
377
+ `,q([n({type:Boolean}),x("design:type",Object)],Je.prototype,"disabled",void 0),q([n({type:Boolean}),x("design:type",Object)],Je.prototype,"readonly",void 0),q([n({type:Number}),x("design:type",String)],Je.prototype,"value",void 0),q([n({type:Number}),x("design:type",Number)],Je.prototype,"min",void 0),q([n({type:Number}),x("design:type",Number)],Je.prototype,"max",void 0),Je=q([s("qti-manual-scoring")],Je);export{m as BaseType,g as Cardinality,V as Choices,Ce as DragDropInteractionMixin,fe as DroppablesMixin,b as Events,ve as FlippablesMixin,ze as NavigationMode,v as OutcomeVariable,me as QtiAnd,_ as QtiAssessmentItem,qe as QtiAssociateInteraction,de as QtiBaseValue,A as QtiChoice,X as QtiChoiceInteraction,T as QtiCompanionMaterialsInfo,he as QtiContains,ae as QtiCorrect,Fe as QtiCustomOperatorLevenshtein,Pe as QtiCustomOperatorNumericOnly,Ue as QtiCustomOperatorParseNumberLocalNl,Be as QtiCustomOperatorRemoveAllSpaces,Ge as QtiCustomOperatorTrim,ie as QtiExpression,B as QtiExtendedTextInteraction,H as QtiFeedbackInline,Re as QtiGap,Oe as QtiGapMatchInteraction,Se as QtiGapText,Ae as QtiGraphicAssociateInteraction,we as QtiGraphicGapMatchInteraction,Ne as QtiGraphicOrderInteraction,pe as QtiGte,Te as QtiHotspotChoice,Ie as QtiHotspotInteraction,G as QtiHottext,Y as QtiHottextInteraction,z as QtiInlineChoiceInteraction,be as QtiIsNull,Qe as QtiItem,O as QtiItemBody,Je as QtiManualScoring,se as QtiMapResponse,ce as QtiMatch,De as QtiMatchInteraction,Me as QtiMediaInteraction,$ as QtiModalFeedback,ue as QtiMultiple,ge as QtiOr,je as QtiOrderInteraction,I as QtiOutcomeDeclaration,ye as QtiPortableCustomInteraction,S as QtiPrompt,J as QtiResponseCondition,N as QtiResponseDeclaration,Z as QtiResponseElse,te as QtiResponseElseIf,ee as QtiResponseIf,W as QtiResponseProcessing,He as QtiSelectPointInteraction,oe as QtiSetOutcomeValue,K as QtiSimpleChoice,$e as QtiSliderInteraction,C as QtiStylesheet,Ke as QtiTest,U as QtiTextEntryInteraction,le as QtiVariable,f as ResponseVariable,y as Status,Xe as SubmissionMode,Ye as TestEvents,Ee as TouchDragAndDrop,M as qtiContentBody,D as qtiRubricBlock,xe as qtiSimpleAssociableChoice};
package/index.umd.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- var C;E.finalized=!0,E.elementProperties=new Map,E.elementStyles=[],E.shadowRootOptions={mode:"open"},null==v||v({ReactiveElement:E}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.5.0");const A=window,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:e=>e}):void 0,q=`lit$${(Math.random()+"").slice(9)}$`,O="?"+q,$=`<${O}>`,R=document,k=(e="")=>R.createComment(e),w=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,M=/>/g,L=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),H=/'/g,D=/"/g,P=/^(?:script|style|textarea|title)$/i,Q=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),U=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),B=new WeakMap,F=R.createTreeWalker(R,129,null,!1),G=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":"",o=N;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),null!==l);)d=o.lastIndex,o===N?"!--"===l[1]?o=I:void 0!==l[1]?o=M:void 0!==l[2]?(P.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=L):void 0!==l[3]&&(o=L):o===L?">"===l[0]?(o=null!=n?n:N,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?L:'"'===l[3]?D:H):o===D||o===H?o=L:o===I||o===M?o=N:(o=L,n=void 0);const h=o===L&&e[t+1].startsWith("/>")?" ":"";r+=o===N?i+$:c>=0?(s.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+q+h):i+q+(-2===c?(s.push(void 0),t):h)}const a=r+(e[i]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==S?S.createHTML(a):a,s]};class V{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=G(e,t);if(this.el=V.createElement(l,i),F.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=F.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(q)){const i=c[r++];if(e.push(t),void 0!==i){const e=s.getAttribute(i.toLowerCase()+"$lit$").split(q),t=/([.?@])?(.*)/.exec(i);a.push({type:1,index:n,name:t[2],strings:e,ctor:"."===t[1]?X:"?"===t[1]?Z:"@"===t[1]?ee:K})}else a.push({type:6,index:n})}for(const t of e)s.removeAttribute(t)}if(P.test(s.tagName)){const e=s.textContent.split(q),t=e.length-1;if(t>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],k()),F.nextNode(),a.push({type:2,index:++n});s.append(e[t],k())}}}else if(8===s.nodeType)if(s.data===O)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(q,e+1));)a.push({type:7,index:n}),e+=q.length-1}n++}}static createElement(e,t){const i=R.createElement("template");return i.innerHTML=e,i}}function z(e,t,i=e,s){var n,r,o,a;if(t===U)return t;let l=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const c=w(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(r=null==l?void 0:l._$AO)||void 0===r||r.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,i,s)),void 0!==s?(null!==(o=(a=i)._$Co)&&void 0!==o?o:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(t=z(e,l._$AS(e,t.values),l,s)),t}class Y{constructor(e,t){this.u=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(e){var t;const{el:{content:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:R).importNode(i,!0);F.currentNode=n;let r=F.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new W(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new te(r,this,e)),this.u.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=F.nextNode(),o++)}return n}p(e){let t=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class W{constructor(e,t,i,s){var n;this.type=2,this._$AH=j,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cm=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cm}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=z(this,e,t),w(e)?e===j||null==e||""===e?(this._$AH!==j&&this._$AR(),this._$AH=j):e!==this._$AH&&e!==U&&this.g(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>T(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this.g(e)}O(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}g(e){this._$AH!==j&&w(this._$AH)?this._$AA.nextSibling.data=e:this.T(R.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=V.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new Y(n,this),t=e.v(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return void 0===t&&B.set(e.strings,t=new V(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new W(this.O(k()),this.O(k()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cm=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class K{constructor(e,t,i,s,n){this.type=1,this._$AH=j,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=j}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=z(this,e,t,0),r=!w(e)||e!==this._$AH&&e!==U,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=z(this,s[i+o],t,o),a===U&&(a=this._$AH[o]),r||(r=!w(a)||a!==this._$AH[o]),a===j?e=j:e!==j&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===j?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class X extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===j?void 0:e}}const J=x?x.emptyScript:"";class Z extends K{constructor(){super(...arguments),this.type=4}j(e){e&&e!==j?this.element.setAttribute(this.name,J):this.element.removeAttribute(this.name)}}class ee extends K{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=z(this,e,t,0))&&void 0!==i?i:j)===U)return;const s=this._$AH,n=e===j&&s!==j||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==j&&(s===j||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class te{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){z(this,e)}}const ie=A.litHtmlPolyfillSupport;null==ie||ie(V,W),(null!==(C=A.litHtmlVersions)&&void 0!==C?C:A.litHtmlVersions=[]).push("2.5.0");
17
+ var C;E.finalized=!0,E.elementProperties=new Map,E.elementStyles=[],E.shadowRootOptions={mode:"open"},null==v||v({ReactiveElement:E}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.5.0");const A=window,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:e=>e}):void 0,O=`lit$${(Math.random()+"").slice(9)}$`,q="?"+O,$=`<${q}>`,R=document,k=(e="")=>R.createComment(e),w=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,M=/>/g,L=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),D=/'/g,H=/"/g,P=/^(?:script|style|textarea|title)$/i,Q=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),U=Symbol.for("lit-noChange"),j=Symbol.for("lit-nothing"),B=new WeakMap,F=R.createTreeWalker(R,129,null,!1),G=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":"",o=N;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),null!==l);)d=o.lastIndex,o===N?"!--"===l[1]?o=I:void 0!==l[1]?o=M:void 0!==l[2]?(P.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=L):void 0!==l[3]&&(o=L):o===L?">"===l[0]?(o=null!=n?n:N,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?L:'"'===l[3]?H:D):o===H||o===D?o=L:o===I||o===M?o=N:(o=L,n=void 0);const h=o===L&&e[t+1].startsWith("/>")?" ":"";r+=o===N?i+$:c>=0?(s.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+O+h):i+O+(-2===c?(s.push(void 0),t):h)}const a=r+(e[i]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==S?S.createHTML(a):a,s]};class V{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=G(e,t);if(this.el=V.createElement(l,i),F.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=F.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(O)){const i=c[r++];if(e.push(t),void 0!==i){const e=s.getAttribute(i.toLowerCase()+"$lit$").split(O),t=/([.?@])?(.*)/.exec(i);a.push({type:1,index:n,name:t[2],strings:e,ctor:"."===t[1]?X:"?"===t[1]?Z:"@"===t[1]?ee:K})}else a.push({type:6,index:n})}for(const t of e)s.removeAttribute(t)}if(P.test(s.tagName)){const e=s.textContent.split(O),t=e.length-1;if(t>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],k()),F.nextNode(),a.push({type:2,index:++n});s.append(e[t],k())}}}else if(8===s.nodeType)if(s.data===q)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(O,e+1));)a.push({type:7,index:n}),e+=O.length-1}n++}}static createElement(e,t){const i=R.createElement("template");return i.innerHTML=e,i}}function z(e,t,i=e,s){var n,r,o,a;if(t===U)return t;let l=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const c=w(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(r=null==l?void 0:l._$AO)||void 0===r||r.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,i,s)),void 0!==s?(null!==(o=(a=i)._$Co)&&void 0!==o?o:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(t=z(e,l._$AS(e,t.values),l,s)),t}class Y{constructor(e,t){this.u=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(e){var t;const{el:{content:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:R).importNode(i,!0);F.currentNode=n;let r=F.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new W(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new te(r,this,e)),this.u.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=F.nextNode(),o++)}return n}p(e){let t=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class W{constructor(e,t,i,s){var n;this.type=2,this._$AH=j,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cm=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cm}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=z(this,e,t),w(e)?e===j||null==e||""===e?(this._$AH!==j&&this._$AR(),this._$AH=j):e!==this._$AH&&e!==U&&this.g(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>T(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this.g(e)}O(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}g(e){this._$AH!==j&&w(this._$AH)?this._$AA.nextSibling.data=e:this.T(R.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=V.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new Y(n,this),t=e.v(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return void 0===t&&B.set(e.strings,t=new V(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new W(this.O(k()),this.O(k()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cm=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class K{constructor(e,t,i,s,n){this.type=1,this._$AH=j,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=j}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=z(this,e,t,0),r=!w(e)||e!==this._$AH&&e!==U,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=z(this,s[i+o],t,o),a===U&&(a=this._$AH[o]),r||(r=!w(a)||a!==this._$AH[o]),a===j?e=j:e!==j&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===j?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class X extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===j?void 0:e}}const J=x?x.emptyScript:"";class Z extends K{constructor(){super(...arguments),this.type=4}j(e){e&&e!==j?this.element.setAttribute(this.name,J):this.element.removeAttribute(this.name)}}class ee extends K{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=z(this,e,t,0))&&void 0!==i?i:j)===U)return;const s=this._$AH,n=e===j&&s!==j||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==j&&(s===j||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class te{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){z(this,e)}}const ie=A.litHtmlPolyfillSupport;null==ie||ie(V,W),(null!==(C=A.litHtmlVersions)&&void 0!==C?C:A.litHtmlVersions=[]).push("2.5.0");
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
@@ -63,7 +63,7 @@ function be(e,t){return(({finisher:e,descriptor:t})=>(i,s)=>{var n;if(void 0===s
63
63
  * Copyright 2020 Google LLC
64
64
  * SPDX-License-Identifier: BSD-3-Clause
65
65
  */
66
- const fe=Symbol.for(""),_e=e=>{if((null==e?void 0:e.r)===fe)return null==e?void 0:e._$litStatic$},Ee=new Map,Ce=(e=>(t,...i)=>{const s=i.length;let n,r;const o=[],a=[];let l,c=0,d=!1;for(;c<s;){for(l=t[c];c<s&&void 0!==(r=i[c],n=_e(r));)l+=n+t[++c],d=!0;a.push(r),o.push(l),c++}if(c===s&&o.push(t[s]),d){const e=o.join("$$lit$$");void 0===(t=Ee.get(e))&&(o.raw=o,Ee.set(e,t=o)),i=a}return e(t,...i)})(Q);function Ae(e,t){const i=Object.assign({waitUntilFirstUpdate:!1},t);return(t,s)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](t,n))}n.call(this,e)}}}}const xe=32;e.QtiChoice=class extends ae{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.emit(s.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(s.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===xe&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(s.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return Ce` <slot></slot> `}},de([me({reflect:!0}),he("design:type",String)],e.QtiChoice.prototype,"identifier",void 0),de([me({type:Number,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"tabindex",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"disabled",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"readonly",void 0),de([me({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),he("design:type",Object)],e.QtiChoice.prototype,"checked",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],e.QtiChoice.prototype,"handleDisabledChange",null),e.QtiChoice=de([pe("qti-choice")],e.QtiChoice);class Se extends re{render(){return Q``}}customElements.define("qti-variabledeclaration",Se);class qe extends Se{connectedCallback(){super.connectedCallback();const t=new n({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||e.Cardinality.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const i=t.querySelectorAll("qti-value");if(1===i.length)e=i[0].textContent,i[0].remove();else{e=[];for(let t=0;t<i.length;t++)e.push(i[t].textContent),i[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,i=e.querySelectorAll("qti-map-entry");for(let e=0;e<i.length;e++){const s=i[e],n=s.getAttribute("map-key"),r=s.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}de([me({type:String,attribute:"base-type"}),he("design:type",String)],qe.prototype,"baseType",void 0),de([me({type:String,attribute:"identifier"}),he("design:type",String)],qe.prototype,"identifier",void 0),de([me({type:String,attribute:"cardinality"}),he("design:type",String)],qe.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",qe);class Oe extends Se{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new r;t.identifier=e,this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",Oe),e.QtiCompanionMaterialsInfo=class extends ae{},e.QtiCompanionMaterialsInfo=de([pe("qti-companion-materials-info")],e.QtiCompanionMaterialsInfo);
66
+ const fe=Symbol.for(""),_e=e=>{if((null==e?void 0:e.r)===fe)return null==e?void 0:e._$litStatic$},Ee=new Map,Ce=(e=>(t,...i)=>{const s=i.length;let n,r;const o=[],a=[];let l,c=0,d=!1;for(;c<s;){for(l=t[c];c<s&&void 0!==(r=i[c],n=_e(r));)l+=n+t[++c],d=!0;a.push(r),o.push(l),c++}if(c===s&&o.push(t[s]),d){const e=o.join("$$lit$$");void 0===(t=Ee.get(e))&&(o.raw=o,Ee.set(e,t=o)),i=a}return e(t,...i)})(Q);function Ae(e,t){const i=Object.assign({waitUntilFirstUpdate:!1},t);return(t,s)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](t,n))}n.call(this,e)}}}}const xe=32;e.QtiChoice=class extends ae{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.emit(s.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(s.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===xe&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(s.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return Ce` <slot></slot> `}},de([me({reflect:!0}),he("design:type",String)],e.QtiChoice.prototype,"identifier",void 0),de([me({type:Number,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"tabindex",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"disabled",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],e.QtiChoice.prototype,"readonly",void 0),de([me({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),he("design:type",Object)],e.QtiChoice.prototype,"checked",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],e.QtiChoice.prototype,"handleDisabledChange",null),e.QtiChoice=de([pe("qti-choice")],e.QtiChoice);class Se extends re{render(){return Q``}}customElements.define("qti-variabledeclaration",Se);class Oe extends Se{connectedCallback(){super.connectedCallback();const t=new n({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||e.Cardinality.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const i=t.querySelectorAll("qti-value");if(1===i.length)e=i[0].textContent,i[0].remove();else{e=[];for(let t=0;t<i.length;t++)e.push(i[t].textContent),i[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,i=e.querySelectorAll("qti-map-entry");for(let e=0;e<i.length;e++){const s=i[e],n=s.getAttribute("map-key"),r=s.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}de([me({type:String,attribute:"base-type"}),he("design:type",String)],Oe.prototype,"baseType",void 0),de([me({type:String,attribute:"identifier"}),he("design:type",String)],Oe.prototype,"identifier",void 0),de([me({type:String,attribute:"cardinality"}),he("design:type",String)],Oe.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",Oe);class qe extends Se{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new r;t.identifier=e,this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",qe),e.QtiCompanionMaterialsInfo=class extends ae{},e.QtiCompanionMaterialsInfo=de([pe("qti-companion-materials-info")],e.QtiCompanionMaterialsInfo);
67
67
  /**
68
68
  * @license
69
69
  * Copyright 2021 Google LLC
@@ -119,7 +119,7 @@ class Re{constructor(e,t,i,s=!1){this.host=e,this.context=t,this.callback=i,this
119
119
  * Copyright 2018 Google LLC
120
120
  * SPDX-License-Identifier: BSD-3-Clause
121
121
  */
122
- const He=e=>null!=e?e:j;class De extends ae{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(s.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(s.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}de([me({attribute:"response-identifier"}),he("design:type",Object)],De.prototype,"responseIdentifier",void 0),de([me({reflect:!0,type:Boolean}),he("design:type",Object)],De.prototype,"disabled",void 0),de([me({reflect:!0,type:Boolean}),he("design:type",Object)],De.prototype,"readonly",void 0);const Pe=h`
122
+ const De=e=>null!=e?e:j;class He extends ae{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(s.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(s.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}de([me({attribute:"response-identifier"}),he("design:type",Object)],He.prototype,"responseIdentifier",void 0),de([me({reflect:!0,type:Boolean}),he("design:type",Object)],He.prototype,"disabled",void 0),de([me({reflect:!0,type:Boolean}),he("design:type",Object)],He.prototype,"readonly",void 0);const Pe=h`
123
123
  /***
124
124
  The new CSS reset - version 1.4.9 (last updated 11.2.2022)
125
125
  GitHub page: https://github.com/elad2412/the-new-css-reset
@@ -199,7 +199,7 @@ const He=e=>null!=e?e:j;class De extends ae{constructor(){super(...arguments),th
199
199
  :where([draggable='true']) {
200
200
  -webkit-user-drag: element;
201
201
  }
202
- `;class Qe extends De{static get properties(){return Object.assign(Object.assign({},De.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}constructor(){super(),this.value=""}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[Pe,h`
202
+ `;class Qe extends He{static get properties(){return Object.assign(Object.assign({},He.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}constructor(){super(),this.value=""}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[Pe,h`
203
203
  /* PK: display host as block, else design will be collapsed */
204
204
  :host {
205
205
  display: inline-block;
@@ -215,10 +215,10 @@ const He=e=>null!=e?e:j;class De extends ae{constructor(){super(...arguments),th
215
215
  @keyup="${this.textChanged}"
216
216
  @change="${this.textChanged}"
217
217
  type="text"
218
- placeholder="${He(this.placeholderText?this.placeholderText:void 0)}"
218
+ placeholder="${De(this.placeholderText?this.placeholderText:void 0)}"
219
219
  .value="${this.value}"
220
- size="${He(this.expectedLength?this.expectedLength:void 0)}"
221
- pattern="${He(this.patternMask?this.patternMask:void 0)}"
220
+ size="${De(this.expectedLength?this.expectedLength:void 0)}"
221
+ pattern="${De(this.patternMask?this.patternMask:void 0)}"
222
222
  ?disabled="${this.disabled}"
223
223
  ?readonly="${this.readonly}"
224
224
  />`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}Qe.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"],customElements.define("qti-text-entry-interaction",Qe);
@@ -242,7 +242,7 @@ const Ue=2;
242
242
  * @license
243
243
  * Copyright 2020 Google LLC
244
244
  * SPDX-License-Identifier: BSD-3-Clause
245
- */class Ke{}const Xe=new WeakMap,Je=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends We{render(e){return j}update(e,[t]){var i;const s=t!==this.Y;return s&&void 0!==this.Y&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.Y=t,this.dt=null===(i=e.options)||void 0===i?void 0:i.host,this.rt(this.ct=e.element)),j}rt(e){var t;if("function"==typeof this.Y){const i=null!==(t=this.dt)&&void 0!==t?t:globalThis;let s=Xe.get(i);void 0===s&&(s=new WeakMap,Xe.set(i,s)),void 0!==s.get(this.Y)&&this.Y.call(this.dt,void 0),s.set(this.Y,e),void 0!==e&&this.Y.call(this.dt,e)}else this.Y.value=e}get lt(){var e,t,i;return"function"==typeof this.Y?null===(t=Xe.get(null!==(e=this.dt)&&void 0!==e?e:globalThis))||void 0===t?void 0:t.get(this.Y):null===(i=this.Y)||void 0===i?void 0:i.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});class Ze extends De{constructor(){super(...arguments),this.textareaRef=new Ke,this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[Pe,h`
245
+ */class Ke{}const Xe=new WeakMap,Je=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends We{render(e){return j}update(e,[t]){var i;const s=t!==this.Y;return s&&void 0!==this.Y&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.Y=t,this.dt=null===(i=e.options)||void 0===i?void 0:i.host,this.rt(this.ct=e.element)),j}rt(e){var t;if("function"==typeof this.Y){const i=null!==(t=this.dt)&&void 0!==t?t:globalThis;let s=Xe.get(i);void 0===s&&(s=new WeakMap,Xe.set(i,s)),void 0!==s.get(this.Y)&&this.Y.call(this.dt,void 0),s.set(this.Y,e),void 0!==e&&this.Y.call(this.dt,e)}else this.Y.value=e}get lt(){var e,t,i;return"function"==typeof this.Y?null===(t=Xe.get(null!==(e=this.dt)&&void 0!==e?e:globalThis))||void 0===t?void 0:t.get(this.Y):null===(i=this.Y)||void 0===i?void 0:i.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});class Ze extends He{constructor(){super(...arguments),this.textareaRef=new Ke,this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[Pe,h`
246
246
  /* PK: display host as block, else design will be collapsed */
247
247
  :host {
248
248
  display: block;
@@ -259,13 +259,13 @@ const Ue=2;
259
259
  @keydown="${e=>e.stopImmediatePropagation()}"
260
260
  @keyup="${this.textChanged}"
261
261
  @change="${this.textChanged}"
262
- placeholder="${He(this.placeholderText?this.placeholderText:void 0)}"
263
- maxlength="${He(this.expectedLength?this.expectedLength:void 0)}"
264
- pattern="${He(this.patternMask?this.patternMask:void 0)}"
262
+ placeholder="${De(this.placeholderText?this.placeholderText:void 0)}"
263
+ maxlength="${De(this.expectedLength?this.expectedLength:void 0)}"
264
+ pattern="${De(this.patternMask?this.patternMask:void 0)}"
265
265
  ?disabled="${this.disabled}"
266
266
  ?readonly="${this.readonly}"
267
267
  .value=${this.value}
268
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}Ze.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],de([me({type:Number,attribute:"expected-length"}),he("design:type",Object)],Ze.prototype,"expectedLength",void 0),de([me({type:String,attribute:"pattern-mask"}),he("design:type",Object)],Ze.prototype,"patternMask",void 0),de([me({type:String,attribute:"placeholder-text"}),he("design:type",Object)],Ze.prototype,"placeholderText",void 0),de([me({type:String}),he("design:type",Object)],Ze.prototype,"value",void 0),de([me({type:String,attribute:"class"}),he("design:type",Object)],Ze.prototype,"classNames",void 0),de([Ae("classNames",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],Ze.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",Ze),e.QtiHottext=class extends e.QtiChoice{},e.QtiHottext=de([pe("qti-hottext")],e.QtiHottext);class et extends De{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(s.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}de([me({type:Number,attribute:"min-choices"}),he("design:type",Number)],et.prototype,"_minChoices",void 0),de([me({type:Number,attribute:"max-choices"}),he("design:type",Number)],et.prototype,"_maxChoices",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleDisabledChange",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleReadonlyChange",void 0),de([Ae("_maxChoices",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleMaxChoicesChange",void 0);class tt extends et{constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",tt);class it extends De{static get properties(){return Object.assign(Object.assign({},De.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Pe,h`
268
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}Ze.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],de([me({type:Number,attribute:"expected-length"}),he("design:type",Object)],Ze.prototype,"expectedLength",void 0),de([me({type:String,attribute:"pattern-mask"}),he("design:type",Object)],Ze.prototype,"patternMask",void 0),de([me({type:String,attribute:"placeholder-text"}),he("design:type",Object)],Ze.prototype,"placeholderText",void 0),de([me({type:String}),he("design:type",Object)],Ze.prototype,"value",void 0),de([me({type:String,attribute:"class"}),he("design:type",Object)],Ze.prototype,"classNames",void 0),de([Ae("classNames",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],Ze.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",Ze),e.QtiHottext=class extends e.QtiChoice{},e.QtiHottext=de([pe("qti-hottext")],e.QtiHottext);class et extends He{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(s.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}de([me({type:Number,attribute:"min-choices"}),he("design:type",Number)],et.prototype,"_minChoices",void 0),de([me({type:Number,attribute:"max-choices"}),he("design:type",Number)],et.prototype,"_maxChoices",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleDisabledChange",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleReadonlyChange",void 0),de([Ae("_maxChoices",{waitUntilFirstUpdate:!0}),he("design:type",Object)],et.prototype,"_handleMaxChoicesChange",void 0);class tt extends et{constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",tt);class it extends He{static get properties(){return Object.assign(Object.assign({},He.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Pe,h`
269
269
  :host {
270
270
  display: inline-block;
271
271
  }
@@ -286,7 +286,7 @@ const Ue=2;
286
286
  </select>`}constructor(){super(),this.options=[],this.addEventListener(s.ON_DROPDOWN_SELECTED,this.choiceSelected);const e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map((e=>({textContent:e.innerHTML,value:e.getAttribute("identifier"),selected:!1})))]}validate(){const e=this.options.find((e=>e.selected));return!!e&&""!==e.value}reset(){this.options=this.options.map(((e,t)=>Object.assign(Object.assign({},e),{selected:0===t})))}set response(e){this.options=this.options.map((t=>(e===t.value&&(t.selected=!0),t)))}choiceSelected(e){const t=e.target.value;this.options=this.options.map((e=>Object.assign(Object.assign({},e),{selected:e.value===t}))),this.saveResponse({base:{string:t}})}}it.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"],customElements.define("qti-inline-choice-interaction",it);class st extends et{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>Q`
287
287
  <slot name="prompt"></slot>
288
288
  <slot></slot>`}}st.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],st.presentationClass=["","qti-input-control-hidden"],de([me({attribute:"orientation"}),he("design:type",String)],st.prototype,"_orientation",void 0),de([me({attribute:"shuffle",type:Boolean}),he("design:type",Boolean)],st.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",st),e.QtiSimpleChoice=class extends e.QtiChoice{},e.QtiSimpleChoice=de([pe("qti-simple-choice")],e.QtiSimpleChoice);class nt extends re{render(){return Q`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){if(this.getAttribute("template")){const e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0.0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response identifier="RESPONSE"> </qti-map-response>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"map_response_point":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-is-null>\n <qti-variable identifier="RESPONSE"></qti-variable>\n </qti-is-null>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'));break;case"match_correct":this.appendChild(this.fragmentFromString('<qti-response-processing>\n <qti-response-condition>\n <qti-response-if>\n <qti-match>\n <qti-variable identifier="RESPONSE"></qti-variable>\n <qti-correct identifier="RESPONSE"></qti-correct>\n </qti-match>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">1</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-if>\n <qti-response-else>\n <qti-set-outcome-value identifier="SCORE">\n <qti-base-value base-type="float">0</qti-base-value>\n </qti-set-outcome-value>\n </qti-response-else>\n </qti-response-condition>\n</qti-response-processing>'))}}const e=[...this.children];for(let t=0;t<e.length;t++){e[t].process()}}fragmentFromString(e){return document.createRange().createContextualFragment(e)}}customElements.define("qti-response-processing",nt);class rt extends re{render(){return Q``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",rt);class ot extends rt{render(){return Q`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const i=e[t];if(i.calculate())return void i.process()}}}customElements.define("qti-response-condition",ot);class at extends re{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Q`
289
- <slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",at);class lt extends at{render(){return Q`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",lt);class ct extends lt{render(){return Q`${super.render()}`}}customElements.define("qti-response-else-if",ct);class dt extends ae{render(){return Q``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",dt);class ht extends dt{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const i=t.mapping,s=t.value;let n=0;if(Array.isArray(s)){for(let e=0;e<s.length;e++)n+=pt(i,s[e],t.baseType);return n}return n+=pt(i,s,t.baseType),n}}function pt(e,t,i){let s=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ut(i,n,t);e===r&&(s+=n[1])}return s}function ut(t,i,s){let n,r;switch(t){case e.BaseType.string:case e.BaseType.identifier:case e.BaseType.directedPair:n=""+i[0],r=""+s;break;case e.BaseType.float:n=parseFloat(i[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:n,valueTyped:r}}customElements.define("qti-map-response",ht);class mt extends rt{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,i=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,i)}}customElements.define("qti-set-outcome-value",mt);class gt extends dt{render(){return Q``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",gt);class bt extends dt{render(){return Q``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",bt);class vt extends dt{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let i=!0;return i=e instanceof Array?e.length===t.length&&e.filter(((e,i)=>e===t[i])).length===e.length:e==t,i}}customElements.define("qti-match",vt);class yt extends dt{calculate(){return yt.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(t,i){let s;if(i===e.BaseType.directedPair){const e=t.split(" ");s={destination:e[1],source:e[0]}}else s=t;return s}}customElements.define("qti-base-value",yt);class ft extends dt{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ft.calculate(e,t)}static calculate(e,t){const i=e.calculate(),s=t.calculate(),n=i.map((e=>e.source+" "+e.destination)),r=s.map((e=>e.source+" "+e.destination)),o=n.filter((e=>r.includes(e)));return o.length>0}}customElements.define("qti-contains",ft);class _t extends dt{calculate(){return 2===this.children.length?_t.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",_t);class Et extends dt{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Et);class Ct extends dt{render(){return Q``}calculate(){return Ct.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",Ct);class At extends dt{render(){return Q``}calculate(){return At.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",At);class xt extends dt{calculate(){return 1===this.children.length?xt.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",xt);class St extends ae{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){const t=e.querySelectorAll("properties");let i={};const s=e=>{const t={},i=e.getAttribute("key");if(i){const s=Array.from(e.children),r=s.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[i]=o?s.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const i of e.children)t=Object.assign(Object.assign({},t),s(i));return t}};for(const e of t){return e.getAttribute("key")||(i=Object.assign(Object.assign({},i),n(e))),i}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",i="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const s="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(i,s,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,s),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,i.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{this._errorMessage=e}))}),(e=>{this._errorMessage=e}))}render(){return Q`<slot></slot>${this._errorMessage&&Q`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",St);const qt=(e,t,i)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(t?this.shadowRoot.querySelectorAll(i):this.querySelectorAll(i));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,i=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`),s=i||this.shadowRoot.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},Ot=(e,t,i)=>class extends e{};class $t{constructor(){return 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(e,t){this.data[e]=t},getData:function(e){return this.data[e]},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,$t._instance?$t._instance:($t._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(e){e.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(e){this._touchBegin=Date.now();const{x:t,y:i}=this.getPositionFromEvent(e);this._touchDown={x:t,y:i},this._dragSrc=e.currentTarget,this._canDrag=!0,e.preventDefault()}_touchMove(e){if(this._canDrag&&this._dragSrc){const{x:i,y:s}=this.getPositionFromEvent(e),n={clientX:i,clientY:s};if(this._getDelta(n)>=this._DRAGDELTA&&(this._dragRunning=!0),null===this._dragCopy&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);const e=window.getComputedStyle(this._dragSrc);this._dragCopy.style="";for(const t of e)this._dragCopy.style[t]=e.getPropertyValue(t);this._calculateDragCopyPosition(n),this._dragCopy.style.top=n.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=n.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="absolute",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){const i=this;requestAnimationFrame((function(){i._touchEndCalled||null===i._dragCopy||(i._dragCopy.style.top=n.clientY-i._copyOffset.y+"px",i._dragCopy.style.left=n.clientX-i._copyOffset.x+"px")}));var t=this._findDroppable(e);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover"),e.preventDefault()}}}_touchEnd(e){var t;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){const e=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});e.dataTransfer={dropEffect:"none"},null===(t=this._dragSrc)||void 0===t||t.dispatchEvent(e)}this._reset()}_touchCancel(e){this._reset()}_findDroppable(e){let t;const i=e.composedPath().find((e=>{if(1===e.nodeType&&"SLOT"!==e.nodeName&&e.hasAttribute("dropzone"))return e}));if(i){const s=i.getRootNode(),n=this._getPoint(e);t=s.elementFromPoint(n.x,n.y)}return t}_getPoint(e,t){return e&&e.touches&&(e=e.touches[0]),{x:t?e.pageX:e.clientX,y:t?e.pageY:e.clientY}}_calculateDragCopyPosition(e){const t=this._dragSrc.getBoundingClientRect();this._copyOffset.x=e.clientX-t.left,this._copyOffset.y=e.clientY-t.top}_getDelta(e){return Math.abs(e.clientX-this._touchDown.x)+Math.abs(e.clientY-this._touchDown.y)}_dispatchEvent(e,t,i=!0){if(!e)return!1;const s=new CustomEvent(t,{bubbles:i,cancelable:!0});return s.dataTransfer=this._dataTransfer,e.dispatchEvent(s),s.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(e,t){this.data[e]=t},getData:function(e){return this.data[e]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(e){let t;if("touchstart"==e.type||"touchmove"==e.type||"touchend"==e.type||"touchcancel"==e.type){const i=void 0===e.originalEvent?e:e.originalEvent,s=i.touches[0]||i.changedTouches[0];t={x:s.pageX,y:s.pageY}}else"mousedown"!=e.type&&"mouseup"!=e.type&&"mousemove"!=e.type&&"mouseover"!=e.type&&"mouseout"!=e.type&&"mouseenter"!=e.type&&"mouseleave"!=e.type||(t={x:e.clientX,y:e.clientY});return t}}function Rt(e,t){let i;return Object.assign({},t),(t,s)=>{const{connectedCallback:n,disconnectedCallback:r}=t;t.connectedCallback=function(){var t;n.call(this);i=new MutationObserver((t=>{const i=Array.from(this.querySelectorAll(e));for(const e of t){const t=Array.from(e.addedNodes).map((e=>e)),n=Array.from(e.addedNodes).map((e=>e));"childList"===e.type&&t.find((e=>i.includes(e)))&&this[s](t,n)}})),i.observe(this,{childList:!0,subtree:!0});const r=null!==(t=this.querySelectorAll(e))&&void 0!==t?t:[];this[s](Array.from(r),[])},t.disconnectedCallback=function(){r.call(this),i.disconnect()}}}const kt=(e,t,i,n)=>{class r extends(Ot(qt(e,i,n))){constructor(){super(...arguments),this.draggables=new Map,this.responseIdentifier="",this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1}reInitDragAndDrop(e,t){if(this.classList.contains("qti-match-tabular"))return;const i=e.filter((e=>!this.draggables||!this.draggables.get(e)));i.length>0&&(this.dragDropApi.addDraggables(e),e.forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.setAttribute("qti-draggable","true"),e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),this.addDragEndEvent(e)})))}handleDisabledChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("disabled",""):i.removeAttribute("disabled"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}handleReadonlyChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("readonly",""):i.removeAttribute("readonly"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}firstUpdated(e){super.firstUpdated(e),this.droppables=Array.from(i?this.shadowRoot.querySelectorAll(n):this.querySelectorAll(n))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new $t,this.dispatchEvent(new CustomEvent(s.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}addDragEndEvent(e){e.addEventListener("dragend",(t=>{if(t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging"),"none"===t.dataTransfer.dropEffect){const e=t.currentTarget,i=this.draggables.get(e),s=i.index<i.parent.children.length?i.index:i.parent.children.length-1,n=i.parent,r=i.parent.children[s];n.insertBefore(e,r)}t.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const i=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[i])})),e&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach((e=>{const t=+(e.getAttribute("match-max")||1)<=(e.children.length||0);t?e.setAttribute("disabled",""):e.removeAttribute("disabled"),t?e.removeAttribute("dropzone"):e.setAttribute("dropzone","move")}))}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,...i]=e.split(" ").reverse();if(t){const e=this.droppables.find((e=>e.getAttribute("identifier")===t));i.forEach((i=>{const s=this.querySelector(`[identifier=${i}]`);e?s?(e.appendChild(s),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${i}`):console.error(`cannot find droppable with identifier: ${t}`)}))}})))}validate(){const e=(i?Array.from(this.shadowRoot.querySelectorAll(n)):Array.from(this.querySelectorAll(n))).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e=this.droppables.map((e=>{var t;let i="";return(null===(t=e.children)||void 0===t?void 0:t.length)>0&&(i+=Array.from(e.children).map((e=>e.getAttribute("identifier"))).join(" ")+" "),i+=e.getAttribute("identifier"),i})),t={list:{pair:e}};this.dispatchEvent(new CustomEvent(s.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:t}}))}}return de([Rt(t),he("design:type",Function),he("design:paramtypes",[Array,Array]),he("design:returntype",void 0)],r.prototype,"reInitDragAndDrop",null),de([me({type:String,attribute:"response-identifier"}),he("design:type",String)],r.prototype,"responseIdentifier",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],r.prototype,"disabled",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],r.prototype,"handleDisabledChange",null),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],r.prototype,"readonly",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],r.prototype,"handleReadonlyChange",null),de([me({type:Number,reflect:!0,attribute:"min-associations"}),he("design:type",Object)],r.prototype,"minAssociations",void 0),de([me({type:Number,reflect:!0,attribute:"max-associations"}),he("design:type",Object)],r.prototype,"maxAssociations",void 0),r};class wt extends(kt(ae,"qti-simple-associable-choice",!0,"drop-list")){render(){return Q` <slot name="prompt"></slot>
289
+ <slot></slot>`}calculate(){return this.debugCalculateResult=!0,!0}getSubRules(){return[...this.children]}process(){const e=this.getSubRules();for(let t=0;t<e.length;t++){e[t].process()}}}customElements.define("qti-response-else",at);class lt extends at{render(){return Q`${super.render()}`}calculate(){const e=this.firstElementChild.calculate();return this.debugCalculateResult=e,e}getSubRules(){const e=[];for(let t=1;t<this.children.length;t++)e.push(this.children[t]);return e}}customElements.define("qti-response-if",lt);class ct extends lt{render(){return Q`${super.render()}`}}customElements.define("qti-response-else-if",ct);class dt extends ae{render(){return Q``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",dt);class ht extends dt{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const i=t.mapping,s=t.value;let n=0;if(Array.isArray(s)){for(let e=0;e<s.length;e++)n+=pt(i,s[e],t.baseType);return n}return n+=pt(i,s,t.baseType),n}}function pt(e,t,i){let s=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=ut(i,n,t);e===r&&(s+=n[1])}return s}function ut(t,i,s){let n,r;switch(t){case e.BaseType.string:case e.BaseType.identifier:case e.BaseType.directedPair:n=""+i[0],r=""+s;break;case e.BaseType.float:n=parseFloat(i[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:n,valueTyped:r}}customElements.define("qti-map-response",ht);class mt extends rt{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,i=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,i)}}customElements.define("qti-set-outcome-value",mt);class gt extends dt{render(){return Q``}calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Can not find qti-response-identifier: ${e}`),null;return t.correctResponse}}customElements.define("qti-correct",gt);class bt extends dt{render(){return Q``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",bt);class vt extends dt{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let i=!0;return i=e instanceof Array?e.length===t.length&&e.filter(((e,i)=>e===t[i])).length===e.length:e==t,i}}customElements.define("qti-match",vt);class yt extends dt{calculate(){return yt.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(t,i){let s;if(i===e.BaseType.directedPair){const e=t.split(" ");s={destination:e[1],source:e[0]}}else s=t;return s}}customElements.define("qti-base-value",yt);class ft extends dt{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return ft.calculate(e,t)}static calculate(e,t){const i=e.calculate(),s=t.calculate(),n=i.map((e=>e.source+" "+e.destination)),r=s.map((e=>e.source+" "+e.destination)),o=n.filter((e=>r.includes(e)));return o.length>0}}customElements.define("qti-contains",ft);class _t extends dt{calculate(){return 2===this.children.length?_t.calculate(this.children[0],this.children[1]):(this.err("unexpected number of children in qte"),null)}static calculate(e,t){return+e.calculate()>=+t.calculate()}}customElements.define("qti-gte",_t);class Et extends dt{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Et);class Ct extends dt{render(){return Q``}calculate(){return Ct.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",Ct);class At extends dt{render(){return Q``}calculate(){return At.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",At);class xt extends dt{calculate(){return 1===this.children.length?xt.calculate(this.children[0]):(this.err("unexpected number of children in qte"),null)}static calculate(e){const t=e.calculate();return null==t||null==t||""===t}}customElements.define("qti-is-null",xt);class St extends ae{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){const t=e.querySelectorAll("properties");let i={};const s=e=>{const t={},i=e.getAttribute("key");if(i){const s=Array.from(e.children),r=s.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[i]=o?s.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const i of e.children)t=Object.assign(Object.assign({},t),s(i));return t}};for(const e of t){return e.getAttribute("key")||(i=Object.assign(Object.assign({},i),n(e))),i}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",i="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const s="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(i,s,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,s),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,i.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{this._errorMessage=e}))}),(e=>{this._errorMessage=e}))}render(){return Q`<slot></slot>${this._errorMessage&&Q`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",St);const Ot=(e,t,i)=>class extends e{static get properties(){return{disabled:{type:Boolean,reflect:!0}}}firstUpdated(e){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(e);const s=Array.from(t?this.shadowRoot.querySelectorAll(i):this.querySelectorAll(i));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),s.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of s)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,i=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`),s=i||this.shadowRoot.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?s.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(s):console.error(`cannot find droppable, target: ${e.target?JSON.stringify(e.target):"null"}`),t.removeAttribute("active"),!1}dragleaveHandler(e){e.preventDefault();return e.currentTarget.removeAttribute("active"),!1}},qt=(e,t,i)=>class extends e{};class $t{constructor(){return 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(e,t){this.data[e]=t},getData:function(e){return this.data[e]},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,$t._instance?$t._instance:($t._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(e){e.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(e){this._touchBegin=Date.now();const{x:t,y:i}=this.getPositionFromEvent(e);this._touchDown={x:t,y:i},this._dragSrc=e.currentTarget,this._canDrag=!0,e.preventDefault()}_touchMove(e){if(this._canDrag&&this._dragSrc){const{x:i,y:s}=this.getPositionFromEvent(e),n={clientX:i,clientY:s};if(this._getDelta(n)>=this._DRAGDELTA&&(this._dragRunning=!0),null===this._dragCopy&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);const e=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(const t of e)this._dragCopy.style[t]=e.getPropertyValue(t);this._calculateDragCopyPosition(n),this._dragCopy.style.top=n.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=n.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="absolute",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){const i=this;requestAnimationFrame((function(){i._touchEndCalled||null===i._dragCopy||(i._dragCopy.style.top=n.clientY-i._copyOffset.y+"px",i._dragCopy.style.left=n.clientX-i._copyOffset.x+"px")}));var t=this._findDroppable(e);t!=this._lastTarget&&(this._dispatchEvent(t,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=t),this._currentDropContainer=t,this._currentDropContainer&&this._dispatchEvent(t,"dragover"),e.preventDefault()}}}_touchEnd(e){var t;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){const e=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});e.dataTransfer={dropEffect:"none"},null===(t=this._dragSrc)||void 0===t||t.dispatchEvent(e)}this._reset()}_touchCancel(e){this._reset()}_findDroppable(e){let t;const i=e.composedPath().find((e=>{if(1===e.nodeType&&"SLOT"!==e.nodeName&&e.hasAttribute("dropzone"))return e}));if(i){const s=i.getRootNode(),n=this._getPoint(e);t=s.elementFromPoint(n.x,n.y)}return t}_getPoint(e,t){return e&&e.touches&&(e=e.touches[0]),{x:t?e.pageX:e.clientX,y:t?e.pageY:e.clientY}}_calculateDragCopyPosition(e){const t=this._dragSrc.getBoundingClientRect();this._copyOffset.x=e.clientX-t.left,this._copyOffset.y=e.clientY-t.top}_getDelta(e){return Math.abs(e.clientX-this._touchDown.x)+Math.abs(e.clientY-this._touchDown.y)}_dispatchEvent(e,t,i=!0){if(!e)return!1;const s=new CustomEvent(t,{bubbles:i,cancelable:!0});return s.dataTransfer=this._dataTransfer,e.dispatchEvent(s),s.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(e,t){this.data[e]=t},getData:function(e){return this.data[e]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}getPositionFromEvent(e){let t;if("touchstart"==e.type||"touchmove"==e.type||"touchend"==e.type||"touchcancel"==e.type){const i=void 0===e.originalEvent?e:e.originalEvent,s=i.touches[0]||i.changedTouches[0];t={x:s.pageX,y:s.pageY}}else"mousedown"!=e.type&&"mouseup"!=e.type&&"mousemove"!=e.type&&"mouseover"!=e.type&&"mouseout"!=e.type&&"mouseenter"!=e.type&&"mouseleave"!=e.type||(t={x:e.clientX,y:e.clientY});return t}}function Rt(e,t){let i;return Object.assign({},t),(t,s)=>{const{connectedCallback:n,disconnectedCallback:r}=t;t.connectedCallback=function(){var t;n.call(this);i=new MutationObserver((t=>{const i=Array.from(this.querySelectorAll(e));for(const e of t){const t=Array.from(e.addedNodes).map((e=>e)),n=Array.from(e.addedNodes).map((e=>e));"childList"===e.type&&t.find((e=>i.includes(e)))&&this[s](t,n)}})),i.observe(this,{childList:!0,subtree:!0});const r=null!==(t=this.querySelectorAll(e))&&void 0!==t?t:[];this[s](Array.from(r),[])},t.disconnectedCallback=function(){r.call(this),i.disconnect()}}}const kt=(e,t,i,n)=>{class r extends(qt(Ot(e,i,n))){constructor(){super(...arguments),this.draggables=new Map,this.responseIdentifier="",this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1}reInitDragAndDrop(e,t){if(this.classList.contains("qti-match-tabular"))return;const i=e.filter((e=>!this.draggables||!this.draggables.get(e)));i.length>0&&(this.dragDropApi.addDraggables(e),e.forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.setAttribute("qti-draggable","true"),e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),this.addDragEndEvent(e)})))}handleDragOptionsChanged(e,t){const{copyStylesDragClone:i}=t;this.dragDropApi.copyStylesDragClone=i}handleDisabledChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("disabled",""):i.removeAttribute("disabled"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}handleReadonlyChange(e,t){this.draggables.forEach(((e,i)=>{t?i.setAttribute("readonly",""):i.removeAttribute("readonly"),t?i.removeAttribute("qti-draggable"):i.setAttribute("qti-draggable","true")}))}firstUpdated(e){super.firstUpdated(e),this.droppables=Array.from(i?this.shadowRoot.querySelectorAll(n):this.querySelectorAll(n))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new $t,this.dispatchEvent(new CustomEvent(s.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}addDragEndEvent(e){e.addEventListener("dragend",(t=>{if(t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging"),"none"===t.dataTransfer.dropEffect){const e=t.currentTarget,i=this.draggables.get(e),s=i.index<i.parent.children.length?i.index:i.parent.children.length-1,n=i.parent,r=i.parent.children[s];n.insertBefore(e,r)}t.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const i=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[i])})),e&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach((e=>{const t=+(e.getAttribute("match-max")||1)<=(e.children.length||0);t?e.setAttribute("disabled",""):e.removeAttribute("disabled"),t?e.removeAttribute("dropzone"):e.setAttribute("dropzone","move")}))}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,...i]=e.split(" ").reverse();if(t){const e=this.droppables.find((e=>e.getAttribute("identifier")===t));i.forEach((i=>{const s=this.querySelector(`[identifier=${i}]`);e?s?(e.appendChild(s),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${i}`):console.error(`cannot find droppable with identifier: ${t}`)}))}})))}validate(){const e=(i?Array.from(this.shadowRoot.querySelectorAll(n)):Array.from(this.querySelectorAll(n))).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e=this.droppables.map((e=>{var t;let i="";return(null===(t=e.children)||void 0===t?void 0:t.length)>0&&(i+=Array.from(e.children).map((e=>e.getAttribute("identifier"))).join(" ")+" "),i+=e.getAttribute("identifier"),i})),t={list:{pair:e}};this.dispatchEvent(new CustomEvent(s.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:t}}))}}return de([Rt(t),he("design:type",Function),he("design:paramtypes",[Array,Array]),he("design:returntype",void 0)],r.prototype,"reInitDragAndDrop",null),de([me({type:String,attribute:"response-identifier"}),he("design:type",String)],r.prototype,"responseIdentifier",void 0),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],r.prototype,"disabled",void 0),de([me({type:Object}),he("design:type",Object)],r.prototype,"dragOptions",void 0),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Object]),he("design:returntype",void 0)],r.prototype,"handleDragOptionsChanged",null),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],r.prototype,"handleDisabledChange",null),de([me({type:Boolean,reflect:!0}),he("design:type",Object)],r.prototype,"readonly",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Function),he("design:paramtypes",[Object,Boolean]),he("design:returntype",void 0)],r.prototype,"handleReadonlyChange",null),de([me({type:Number,reflect:!0,attribute:"min-associations"}),he("design:type",Object)],r.prototype,"minAssociations",void 0),de([me({type:Number,reflect:!0,attribute:"max-associations"}),he("design:type",Object)],r.prototype,"maxAssociations",void 0),r};class wt extends(kt(ae,"qti-simple-associable-choice",!0,"drop-list")){render(){return Q` <slot name="prompt"></slot>
290
290
  <slot name="qti-simple-associable-choice"></slot>
291
291
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map(((e,t)=>Q`<div part="associables-container">
292
292
  <drop-list part="drop-list" identifier="droplist${t}_left"></drop-list>
@@ -314,12 +314,12 @@ const Ue=2;
314
314
  gap: var(--qti-gap, 0.5rem);
315
315
  padding: var(--qti-gap, 0.5rem) 0px;
316
316
  }
317
- `,customElements.define("qti-gap-match-interaction",Nt);class It extends re{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return Q`<slot></slot>`}}customElements.define("qti-gap-text",It);class Mt extends re{render(){return Q` <slot name="qti-gap-text"></slot>`}}function Lt(e,t,i,s){switch(e){case"circle":{const[e,n,r]=t,o=e/i.width*100,a=n/i.height*100,l=r/i.width*100;s.style.left=o-l+"%",s.style.top=a-l+"%",s.style.width=s.style.height=4*l+"px",s.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/i.width*100,l=n/i.height*100,c=r/i.width*100,d=o/i.height*100;s.style.left=a+"%",s.style.top=l+"%",s.style.width=c-a+"%",s.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,i,s)=>{if(i%2==1){const t=e.pop();e[e.length]={x:t,y:s[i]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/i.width*100,c=o/i.height*100,d=r/i.width*100,h=a/i.height*100;s.style.left=n/i.width*100+"%",s.style.top=o/i.height*100+"%",s.style.width=d-l+"%",s.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");s.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Mt);class Ht extends et{render(){return Q`
317
+ `,customElements.define("qti-gap-match-interaction",Nt);class It extends re{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return Q`<slot></slot>`}}customElements.define("qti-gap-text",It);class Mt extends re{render(){return Q` <slot name="qti-gap-text"></slot>`}}function Lt(e,t,i,s){switch(e){case"circle":{const[e,n,r]=t,o=e/i.width*100,a=n/i.height*100,l=r/i.width*100;s.style.left=o-l+"%",s.style.top=a-l+"%",s.style.width=s.style.height=4*l+"px",s.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/i.width*100,l=n/i.height*100,c=r/i.width*100,d=o/i.height*100;s.style.left=a+"%",s.style.top=l+"%",s.style.width=c-a+"%",s.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,i,s)=>{if(i%2==1){const t=e.pop();e[e.length]={x:t,y:s[i]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/i.width*100,c=o/i.height*100,d=r/i.width*100,h=a/i.height*100;s.style.left=n/i.width*100+"%",s.style.top=o/i.height*100+"%",s.style.width=d-l+"%",s.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");s.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Mt);class Dt extends et{render(){return Q`
318
318
  <slot name="prompt"></slot>
319
319
  <!-- slot for the prompt -->
320
320
  <slot></slot>
321
321
  <!-- slot for the image and hotspots -->
322
- `}positionHotspotOnRegister(e){const t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));Lt(n,r,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Ht.styles=[h`
322
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));Lt(n,r,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Dt.styles=[h`
323
323
  slot:not([name='prompt']) {
324
324
  position: relative; /* qti-hotspot-choice relative to the slot */
325
325
  display: block;
@@ -330,13 +330,13 @@ const Ue=2;
330
330
  pointer-events: none;
331
331
  user-select: none;
332
332
  }
333
- `],customElements.define("qti-graphic-associate-interaction",Ht);class Dt extends(kt(ae,"qti-gap-img",!1,"qti-associable-hotspot")){render(){return Q` <slot></slot>
334
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map((e=>parseInt(e)));switch(s){case"circle":{const[e,i,s]=n;t.style.left=e-s+"px",t.style.top=i-s+"px",t.style.width=t.style.height=2*s+"px"}break;case"rect":{const[e,i,s,r]=n;t.style.left=e+"px",t.style.top=i+"px",t.style.width=s-e+"px",t.style.height=r-i+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Dt.styles=h`
333
+ `],customElements.define("qti-graphic-associate-interaction",Dt);class Ht extends(kt(ae,"qti-gap-img",!1,"qti-associable-hotspot")){render(){return Q` <slot></slot>
334
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map((e=>parseInt(e)));switch(s){case"circle":{const[e,i,s]=n;t.style.left=e-s+"px",t.style.top=i-s+"px",t.style.width=t.style.height=2*s+"px"}break;case"rect":{const[e,i,s,r]=n;t.style.left=e+"px",t.style.top=i+"px",t.style.width=s-e+"px",t.style.height=r-i+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Ht.styles=h`
335
335
  slot[name="qti-gap-img"] {
336
336
  display: flex;
337
337
  gap: 1rem;
338
338
  }
339
- `,customElements.define("qti-graphic-gap-match-interaction",Dt);class Pt extends et{render(){return Q`
339
+ `,customElements.define("qti-graphic-gap-match-interaction",Ht);class Pt extends et{render(){return Q`
340
340
  <slot name="prompt"></slot>
341
341
  <!-- slot for the prompt -->
342
342
  <slot></slot>
@@ -396,7 +396,7 @@ const Ue=2;
396
396
  }
397
397
  `;class Bt extends(kt(re,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice")){render(){return Q`
398
398
  <slot name="prompt"></slot>
399
- <slot></slot>`}}Bt.styles=[jt],customElements.define("qti-match-interaction",Bt);class Ft extends De{reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},De.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Q`
399
+ <slot></slot>`}}Bt.styles=[jt],customElements.define("qti-match-interaction",Bt);class Ft extends He{reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},He.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Q`
400
400
  <slot name="prompt"></slot>
401
401
  <slot></slot>`}constructor(){super()}connectedCallback(){super.connectedCallback()}}Ft.styles=[jt,h``],customElements.define("qti-media-interaction",Ft);class Gt extends(kt(ae,"qti-simple-choice",!0,"drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return Q` <slot name="prompt"> </slot>
402
402
  <div class=${`container ${this._classNames}`}>
@@ -439,7 +439,7 @@ const Ue=2;
439
439
  color: var(--qti-placeholder-text);
440
440
  }
441
441
  `],customElements.define("qti-order-interaction",Gt);class Vt extends et{render(){return Q`<slot></slot>
442
- <div class="notification"></div>`}constructor(){super()}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Vt.styles=[jt],customElements.define("qti-select-point-interaction",Vt);class zt extends De{constructor(){super(...arguments),this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=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){this.value=e}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);const e=(this.value-this.min)/(this.max-this.min)*100;return Q`<slot name="prompt"></slot>
442
+ <div class="notification"></div>`}constructor(){super()}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}Vt.styles=[jt],customElements.define("qti-select-point-interaction",Vt);class zt extends He{constructor(){super(...arguments),this.stepLabel=!1,this.reverse=!1,this._handleDisabledChange=(e,t)=>{},this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=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){this.value=e}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);const e=(this.value-this.min)/(this.max-this.min)*100;return Q`<slot name="prompt"></slot>
443
443
  <div id="rail" @mousedown=${this._onMouseDown} part="rail">
444
444
  <div id="knob" part="knob" style="left:${e}%"></div>
445
445
  </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onMouseDown(e){const t=e=>{const t=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(t),e.preventDefault(),e.stopPropagation()},i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i);const s=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(s),e.preventDefault(),e.stopPropagation()}calculateValue(e){const t=this.min+(this.max-this.min)*e/this.offsetWidth,i=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=i}}zt.styles=[h``],de([be("#knob"),he("design:type",HTMLElement)],zt.prototype,"_knob",void 0),de([be("#rail"),he("design:type",HTMLElement)],zt.prototype,"_rail",void 0),de([me({type:Number}),he("design:type",Number)],zt.prototype,"value",void 0),de([me({type:Boolean,attribute:"step-label"}),he("design:type",Object)],zt.prototype,"stepLabel",void 0),de([me({type:Boolean}),he("design:type",Object)],zt.prototype,"reverse",void 0),de([me({type:Number,attribute:"lower-bound"}),he("design:type",Number),he("design:paramtypes",[Number])],zt.prototype,"min",null),de([me({type:Number,attribute:"upper-bound"}),he("design:type",Number),he("design:paramtypes",[Number])],zt.prototype,"max",null),de([me({type:Number,attribute:"step"}),he("design:type",Number),he("design:paramtypes",[Number])],zt.prototype,"step",null),de([Ae("disabled",{waitUntilFirstUpdate:!0}),he("design:type",Object)],zt.prototype,"_handleDisabledChange",void 0),de([Ae("readonly",{waitUntilFirstUpdate:!0}),he("design:type",Object)],zt.prototype,"_handleReadonlyChange",void 0),customElements.define("qti-slider-interaction",zt);class Yt extends re{constructor(){super(...arguments),this.render=()=>Q`${this.value}`}levenshtein(e,t){let i;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(i=e,e=t,t=i);const s=e.length,n=t.length,r=Array(s);let o,a,l;for(o=0;o<=s;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=s;a++)i=r[a-1],r[a-1]=l,l=Math.min(i+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,i=e.calculate(),s=t.calculate();return this.value=100-this.levenshtein(i.toString().trim(),s.toString().trim())/s.toString().length*100,this.value}}Yt.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Yt);class Wt extends re{render(){return Q``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/[^0-9$.,]/g,""):""}}customElements.define("qti-custom-operator-numeric",Wt);class Kt extends re{constructor(){super(...arguments),this.render=()=>Q`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const i=Intl.NumberFormat(t).format(1.1),s=new RegExp(`[^-+0-9${i.charAt(1)}]`,"g"),n=e.replace(s,"").replace(i.charAt(1),".");return parseFloat(n)}}Kt.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Kt);class Xt extends re{render(){return Q``}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return t?t.replace(/ /g,""):""}}customElements.define("qti-custom-operator-remove-spaces",Xt);class Jt extends re{render(){return Q``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Jt);const Zt=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(Zt(re,"on-next-item")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}}),customElements.define("qti-test-item",class extends(Zt(re,"on-request-item")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(Zt(re,"on-prev-item")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}}),customElements.define("qti-test-check",class extends(Zt(re,"on-check-item")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}}),customElements.define("qti-test-score",class extends(Zt(re,"on-score-item")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(Zt(re,"on-show-correct")){constructor(){super(...arguments),this.render=()=>Q`<slot></slot>`}});const ei={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var ti,ii;e.NavigationMode=void 0,(ti=e.NavigationMode||(e.NavigationMode={})).linear="linear",ti.nonlinear="nonlinear",e.SubmissionMode=void 0,(ii=e.SubmissionMode||(e.SubmissionMode={})).individual="individual",ii.simultaneous="simultaneous",e.QtiTest=class extends re{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=e.NavigationMode.nonlinear,this._submissionMode=e.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0,this.provider=new Te(this,Ne,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(t,i){this.prevButton.style.visibility=i===e.NavigationMode.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(ei.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(t){this._itemRef&&(this._itemRef.responses=t,this._navigationMode===e.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(ei.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(ei.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==e.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(ei.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(ei.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(ei.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(ei.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(ei.ON_ITEM_READY,{detail:t}))}render(){return Q`
@@ -487,4 +487,4 @@ const Ue=2;
487
487
  :host {
488
488
  display: none;
489
489
  }
490
- `,de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"disabled",void 0),de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"readonly",void 0),de([me({type:Number}),he("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"min",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"max",void 0),e.QtiManualScoring=de([pe("qti-manual-scoring")],e.QtiManualScoring),e.Choices=et,e.DragDropInteractionMixin=kt,e.DroppablesMixin=qt,e.Events=s,e.FlippablesMixin=Ot,e.OutcomeVariable=r,e.QtiAnd=Ct,e.QtiAssessmentItem=le,e.QtiAssociateInteraction=wt,e.QtiBaseValue=yt,e.QtiChoiceInteraction=st,e.QtiContains=ft,e.QtiCorrect=gt,e.QtiCustomOperatorLevenshtein=Yt,e.QtiCustomOperatorNumericOnly=Wt,e.QtiCustomOperatorParseNumberLocalNl=Kt,e.QtiCustomOperatorRemoveAllSpaces=Xt,e.QtiCustomOperatorTrim=Jt,e.QtiExpression=dt,e.QtiExtendedTextInteraction=Ze,e.QtiFeedbackInline=Me,e.QtiGap=Mt,e.QtiGapMatchInteraction=Nt,e.QtiGapText=It,e.QtiGraphicAssociateInteraction=Ht,e.QtiGraphicGapMatchInteraction=Dt,e.QtiGraphicOrderInteraction=Pt,e.QtiGte=_t,e.QtiHotspotChoice=Ut,e.QtiHotspotInteraction=Qt,e.QtiHottextInteraction=tt,e.QtiInlineChoiceInteraction=it,e.QtiIsNull=xt,e.QtiItem=ni,e.QtiMapResponse=ht,e.QtiMatch=vt,e.QtiMatchInteraction=Bt,e.QtiMediaInteraction=Ft,e.QtiModalFeedback=Le,e.QtiMultiple=Et,e.QtiOr=At,e.QtiOrderInteraction=Gt,e.QtiOutcomeDeclaration=Oe,e.QtiPortableCustomInteraction=St,e.QtiPrompt=ye,e.QtiResponseCondition=ot,e.QtiResponseDeclaration=qe,e.QtiResponseElse=at,e.QtiResponseElseIf=ct,e.QtiResponseIf=lt,e.QtiResponseProcessing=nt,e.QtiSelectPointInteraction=Vt,e.QtiSetOutcomeValue=mt,e.QtiSliderInteraction=zt,e.QtiStylesheet=ce,e.QtiTextEntryInteraction=Qe,e.QtiVariable=bt,e.ResponseVariable=n,e.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},e.TestEvents=ei,e.TouchDragAndDrop=$t,e.qtiSimpleAssociableChoice=Tt,Object.defineProperty(e,"__esModule",{value:!0})}));
490
+ `,de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"disabled",void 0),de([me({type:Boolean}),he("design:type",Object)],e.QtiManualScoring.prototype,"readonly",void 0),de([me({type:Number}),he("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"min",void 0),de([me({type:Number}),he("design:type",Number)],e.QtiManualScoring.prototype,"max",void 0),e.QtiManualScoring=de([pe("qti-manual-scoring")],e.QtiManualScoring),e.Choices=et,e.DragDropInteractionMixin=kt,e.DroppablesMixin=Ot,e.Events=s,e.FlippablesMixin=qt,e.OutcomeVariable=r,e.QtiAnd=Ct,e.QtiAssessmentItem=le,e.QtiAssociateInteraction=wt,e.QtiBaseValue=yt,e.QtiChoiceInteraction=st,e.QtiContains=ft,e.QtiCorrect=gt,e.QtiCustomOperatorLevenshtein=Yt,e.QtiCustomOperatorNumericOnly=Wt,e.QtiCustomOperatorParseNumberLocalNl=Kt,e.QtiCustomOperatorRemoveAllSpaces=Xt,e.QtiCustomOperatorTrim=Jt,e.QtiExpression=dt,e.QtiExtendedTextInteraction=Ze,e.QtiFeedbackInline=Me,e.QtiGap=Mt,e.QtiGapMatchInteraction=Nt,e.QtiGapText=It,e.QtiGraphicAssociateInteraction=Dt,e.QtiGraphicGapMatchInteraction=Ht,e.QtiGraphicOrderInteraction=Pt,e.QtiGte=_t,e.QtiHotspotChoice=Ut,e.QtiHotspotInteraction=Qt,e.QtiHottextInteraction=tt,e.QtiInlineChoiceInteraction=it,e.QtiIsNull=xt,e.QtiItem=ni,e.QtiMapResponse=ht,e.QtiMatch=vt,e.QtiMatchInteraction=Bt,e.QtiMediaInteraction=Ft,e.QtiModalFeedback=Le,e.QtiMultiple=Et,e.QtiOr=At,e.QtiOrderInteraction=Gt,e.QtiOutcomeDeclaration=qe,e.QtiPortableCustomInteraction=St,e.QtiPrompt=ye,e.QtiResponseCondition=ot,e.QtiResponseDeclaration=Oe,e.QtiResponseElse=at,e.QtiResponseElseIf=ct,e.QtiResponseIf=lt,e.QtiResponseProcessing=nt,e.QtiSelectPointInteraction=Vt,e.QtiSetOutcomeValue=mt,e.QtiSliderInteraction=zt,e.QtiStylesheet=ce,e.QtiTextEntryInteraction=Qe,e.QtiVariable=bt,e.ResponseVariable=n,e.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},e.TestEvents=ei,e.TouchDragAndDrop=$t,e.qtiSimpleAssociableChoice=Tt,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -29,6 +29,7 @@ export declare class TouchDragAndDrop {
29
29
  _DRAGDELTA: number;
30
30
  _COPYOPACITY: number;
31
31
  static _instance: TouchDragAndDrop;
32
+ copyStylesDragClone: boolean;
32
33
  constructor();
33
34
  addDraggables(draggables: Element[]): void;
34
35
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citolab/qti-components",
3
- "version": "3.0.69",
3
+ "version": "3.0.70",
4
4
  "repository": "@citolab/qti-components",
5
5
  "author": "Patrick de Klein",
6
6
  "license": "MIT",