@citolab/qti-components 3.0.39 → 3.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/index.cjs +34 -34
  2. package/index.d.ts +1 -0
  3. package/index.js +27 -27
  4. package/package.json +2 -8
  5. package/lab/qti-api/qti-api.stories.d.ts +0 -7
  6. package/lab/qti-custom/qti-custom-operator/qti-custom-operator.stories.d.ts +0 -12
  7. package/lab/qti-dashboard/qti-item-dashboard.stories.d.ts +0 -8
  8. package/lab/qti-item/qti-item.stories.d.ts +0 -8
  9. package/lab/qti-test/qti-test.stories.d.ts +0 -9
  10. package/lib/qti-base/qti-feedback/qti-feedback.stories.d.ts +0 -8
  11. package/lib/qti-base/qti-interaction/qti-choice-interaction/qti-choice-interaction.stories.d.ts +0 -45
  12. package/lib/qti-base/qti-interaction/qti-extended-text-interaction/qti-extended-text-interaction.stories.d.ts +0 -9
  13. package/lib/qti-base/qti-interaction/qti-hottext-interaction/qti-hottext-interaction.stories.d.ts +0 -20
  14. package/lib/qti-base/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.stories.d.ts +0 -43
  15. package/lib/qti-base/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction.stories.d.ts +0 -31
  16. package/lib/qti-base/qti-preview/qti-associate-interaction/qti-associate-interaction.stories.d.ts +0 -7
  17. package/lib/qti-base/qti-preview/qti-custom-interaction/qti-portable-custom-interaction.stories.d.ts +0 -7
  18. package/lib/qti-base/qti-preview/qti-gap-match-interaction/qti-gap-match-interaction.stories.d.ts +0 -31
  19. package/lib/qti-base/qti-preview/qti-graphic-associate-interaction/qti-graphic-associate-interaction.stories.d.ts +0 -7
  20. package/lib/qti-base/qti-preview/qti-graphic-gap-match-interaction/qti-graphic-gap-match-interaction.stories.d.ts +0 -26
  21. package/lib/qti-base/qti-preview/qti-graphic-order-interaction/qti-graphic-order-interaction.stories.d.ts +0 -7
  22. package/lib/qti-base/qti-preview/qti-hotspot-interaction/qti-hotspot-interaction.stories.d.ts +0 -9
  23. package/lib/qti-base/qti-preview/qti-match-interaction/qti-match-interaction.stories.d.ts +0 -8
  24. package/lib/qti-base/qti-preview/qti-media-interaction/qti-media-interaction.stories.d.ts +0 -25
  25. package/lib/qti-base/qti-preview/qti-order-interaction/qti-order-interaction.stories.d.ts +0 -21
  26. package/lib/qti-base/qti-preview/qti-select-point-interaction/qti-select-point-interaction.stories.d.ts +0 -7
  27. package/lib/qti-base/qti-preview/qti-slider-interaction/qti-slider-interaction.stories.d.ts +0 -48
  28. package/styles/qti-classes.stories.d.ts +0 -5
  29. package/styles/qti-layout-styles.stories.d.ts +0 -6
  30. package/styles/qti-styles.stories.d.ts +0 -5
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,s=require("lit"),i=require("lit/decorators.js"),r=require("lit/static-html.js"),n=require("lit/directives/if-defined.js"),o=require("lit/directives/ref.js");exports.BaseType=void 0,(e=exports.BaseType||(exports.BaseType={})).boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair",exports.Cardinality=void 0,(t=exports.Cardinality||(exports.Cardinality={})).multiple="multiple",t.ordered="ordered",t.single="single";const a={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};class l{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:r}){this._basetype=exports.BaseType.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=r}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=l.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class c{}class d extends s.LitElement{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class p extends d{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return s.html`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}processResponse(){if(this.validateResponses()){const e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}return console.info("Item is not valid, call validateResponses first"),!1}set responses(e){if(e){e.interactions.forEach((e=>{const t=this.interactionElements.find((t=>t.getAttribute("response-identifier")===e.responseIdentifier)),s=this.getResponse(e.responseIdentifier);s&&(s.qtiVariable=e.responses);const i=l.getCandidateResponse(e.responses);t.response=i}))}}resetInteractions(){this.interactionElements.forEach((e=>e.reset()))}validateResponses(){let e=!0;return this.interactionElements.forEach((t=>{t.validate()||(e=!1)})),e}getVariableValue(e){return this.variables.find((t=>t.identifier===e)).value}getResponse(e){const t=this.variables.find((t=>t.identifier===e));if(t instanceof l)return t;this.err(`qti-response-variable ${e} not found, make sure you registered it`)}getOutcome(e){const t=this.variables.find((t=>t.identifier===e));return t instanceof c?t:(this.err(`qti-outcome-variable ${e} not found, make sure you registered it`),null)}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){const t=this.getResponse(e.detail.responseIdentifier);t&&(t.qtiVariable=e.detail.responses),e.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent(a.ON_INTERACTION_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.getAttribute("identifier"),interaction:{responseIdentifier:e.detail.responseIdentifier,responses:e.detail.responses}}}))}outcomeChanged(e){this.feedbackElements.forEach((t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)}))}setOutcomeValue(e,t){const s=this.getOutcome(e);s?(s.value=t,this.dispatchEvent(new CustomEvent(a.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))):this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`)}}customElements.define("qti-assessment-item",p);class h extends s.LitElement{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}customElements.define("qti-stylesheet",h);class u extends s.LitElement{render(){return s.html` <style>
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,s=require("lit"),i=require("lit/decorators.js"),n=require("lit/static-html.js"),r=require("lit/directives/if-defined.js"),o=require("lit/directives/ref.js");exports.BaseType=void 0,(e=exports.BaseType||(exports.BaseType={})).boolean="boolean",e.directedPair="directedPair",e.float="float",e.integer="integer",e.string="string",e.identifier="identifier",e.pair="pair",exports.Cardinality=void 0,(t=exports.Cardinality||(exports.Cardinality={})).multiple="multiple",t.ordered="ordered",t.single="single";const a={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};class l{constructor({mapping:e,correctResponse:t,cardinality:s,baseType:i,identifier:n}){this._basetype=exports.BaseType.string,this._mapping=e,this._correctResponse=t,this._cardinality=s,this._basetype=i,this._identifier=n}static getCandidateResponse(e){return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]]}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(e){this._candidateResponse=e}set qtiVariable(e){this._qtiVariable=e,this._candidateResponse=l.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class c{}class d extends s.LitElement{emit(e,t){const s=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}err(e){throw e}}class p extends d{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return s.html`<slot></slot>`}updated(e){e.forEach(((e,t)=>{switch(t){case"disabled":this.interactionElements.forEach((e=>e.disabled=this.disabled));break;case"readonly":this.interactionElements.forEach((e=>e.readonly=this.readonly))}}))}disconnectedCallback(){this.removeEventListener(a.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(a.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(a.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(a.ON_INTERACTION_RESPONSE,this.interactionResponse)}processResponse(){if(this.validateResponses()){const e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}return console.info("Item is not valid, call validateResponses first"),!1}set responses(e){if(e){e.interactions.forEach((e=>{const t=this.interactionElements.find((t=>t.getAttribute("response-identifier")===e.responseIdentifier)),s=this.getResponse(e.responseIdentifier);s&&(s.qtiVariable=e.responses);const i=l.getCandidateResponse(e.responses);t.response=i}))}}resetInteractions(){this.interactionElements.forEach((e=>e.reset()))}validateResponses(){let e=!0;return this.interactionElements.forEach((t=>{t.validate()||(e=!1)})),e}getVariableValue(e){return this.variables.find((t=>t.identifier===e)).value}getResponse(e){const t=this.variables.find((t=>t.identifier===e));if(t instanceof l)return t;this.err(`qti-response-variable ${e} not found, make sure you registered it`)}getOutcome(e){const t=this.variables.find((t=>t.identifier===e));return t instanceof c?t:(this.err(`qti-outcome-variable ${e} not found, make sure you registered it`),null)}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){const t=this.getResponse(e.detail.responseIdentifier);t&&(t.qtiVariable=e.detail.responses),e.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent(a.ON_INTERACTION_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.getAttribute("identifier"),interaction:{responseIdentifier:e.detail.responseIdentifier,responses:e.detail.responses}}}))}outcomeChanged(e){this.feedbackElements.forEach((t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)}))}setOutcomeValue(e,t){const s=this.getOutcome(e);s?(s.value=t,this.dispatchEvent(new CustomEvent(a.ON_OUTCOME_CHANGED,{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))):this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`)}}customElements.define("qti-assessment-item",p);class h extends s.LitElement{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.media="screen",s.href=t,e.appendChild(s),this.styleLink=s}disconnectedCallback(){const e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(e){console.log("could not remove stylesheet")}}}customElements.define("qti-stylesheet",h);class u extends s.LitElement{render(){return s.html` <style>
2
2
  :host {
3
3
  display: block;
4
4
  }
@@ -8,14 +8,14 @@
8
8
  <slot name="qti-rubric-block" />
9
9
  </header>
10
10
  -->
11
- <slot></slot>`}}customElements.define("qti-item-body",u);class m extends s.LitElement{render(){return s.html` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function g(e,t,s,i){var r,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o}function b(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{l(i.next(e))}catch(e){n(e)}}function a(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}function y(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{const{update:r}=t;if(e in t){const n=e;t.update=function(e){if(e.has(n)){const t=e.get(n),r=this[n];t!==r&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,r))}r.call(this,e)}}}}customElements.define("qti-prompt",m);const E=32;exports.QtiChoice=class extends d{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(a.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(a.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===E&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(a.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return r.html` <slot></slot> `}},g([i.property({reflect:!0}),b("design:type",String)],exports.QtiChoice.prototype,"identifier",void 0),g([i.property({type:Number,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"tabindex",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"disabled",void 0),g([i.property({type:Boolean,reflect:!0}),b("design:type",Object)],exports.QtiChoice.prototype,"readonly",void 0),g([i.property({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),b("design:type",Object)],exports.QtiChoice.prototype,"checked",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Function),b("design:paramtypes",[Object,Boolean]),b("design:returntype",void 0)],exports.QtiChoice.prototype,"handleDisabledChange",null),exports.QtiChoice=g([i.customElement("qti-choice")],exports.QtiChoice);class v extends s.LitElement{render(){return s.html``}}customElements.define("qti-variabledeclaration",v);class x extends v{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const e=new l({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||exports.Cardinality.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(e)}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const s=t.querySelectorAll("qti-value");if(1===s.length)e=s[0].textContent,s[0].remove();else{e=[];for(let t=0;t<s.length;t++)e.push(s[t].textContent),s[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,s=e.querySelectorAll("qti-map-entry");for(let e=0;e<s.length;e++){const i=s[e],r=i.getAttribute("map-key"),n=i.getAttribute("mapped-value");t.set(r,n?parseFloat(n):null)}return t}return null}}customElements.define("qti-response-declaration",x);class C extends v{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new c;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",C),exports.qtiCompanionMaterialsInfo=class extends d{},exports.qtiCompanionMaterialsInfo=g([i.customElement("qti-companion-materials-info")],exports.qtiCompanionMaterialsInfo),exports.qtiRubricBlock=class extends d{},exports.qtiRubricBlock=g([i.customElement("qti-rubric-block")],exports.qtiRubricBlock),exports.qtiContentBody=class extends d{},exports.qtiContentBody=g([i.customElement("qti-content-body")],exports.qtiContentBody);class q extends s.LitElement{constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}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}}}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.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 _ extends q{constructor(){super(...arguments),this.render=()=>s.html` <slot class="${this.showStatus}"></slot> `}}_.styles=s.css`
11
+ <slot></slot>`}}customElements.define("qti-item-body",u);class m extends s.LitElement{render(){return s.html` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}function f(e,t,s,i){var n,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,s,o):n(t,s))||o);return r>3&&o&&Object.defineProperty(t,s,o),o}function g(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function b(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}function x(e,t){const s=Object.assign({waitUntilFirstUpdate:!1},t);return(t,i)=>{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&&(s.waitUntilFirstUpdate&&!this.hasUpdated||this[i](t,n))}n.call(this,e)}}}}customElements.define("qti-prompt",m);const y=32;exports.QtiChoice=class extends d{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(a.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(a.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===y&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(a.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return n.html` <slot></slot> `}},f([i.property({reflect:!0}),g("design:type",String)],exports.QtiChoice.prototype,"identifier",void 0),f([i.property({type:Number,reflect:!0}),g("design:type",Object)],exports.QtiChoice.prototype,"tabindex",void 0),f([i.property({type:Boolean,reflect:!0}),g("design:type",Object)],exports.QtiChoice.prototype,"disabled",void 0),f([i.property({type:Boolean,reflect:!0}),g("design:type",Object)],exports.QtiChoice.prototype,"readonly",void 0),f([i.property({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),g("design:type",Object)],exports.QtiChoice.prototype,"checked",void 0),f([x("disabled",{waitUntilFirstUpdate:!0}),g("design:type",Function),g("design:paramtypes",[Object,Boolean]),g("design:returntype",void 0)],exports.QtiChoice.prototype,"handleDisabledChange",null),exports.QtiChoice=f([i.customElement("qti-choice")],exports.QtiChoice);class E extends s.LitElement{render(){return s.html``}}customElements.define("qti-variabledeclaration",E);class v extends E{static get properties(){return{baseType:{type:String,attribute:"base-type"},identifier:{type:String,attribute:"identifier"},cardinality:{type:String,attribute:"cardinality"}}}connectedCallback(){super.connectedCallback();const e=new l({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||exports.Cardinality.single,mapping:this.mapping});this.closest("qti-assessment-item").variables.push(e)}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const s=t.querySelectorAll("qti-value");if(1===s.length)e=s[0].textContent,s[0].remove();else{e=[];for(let t=0;t<s.length;t++)e.push(s[t].textContent),s[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,s=e.querySelectorAll("qti-map-entry");for(let e=0;e<s.length;e++){const i=s[e],n=i.getAttribute("map-key"),r=i.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}customElements.define("qti-response-declaration",v);class C extends E{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new c;t.identifier=e;this.closest("qti-assessment-item").variables.push(t)}}customElements.define("qti-outcome-declaration",C),exports.qtiCompanionMaterialsInfo=class extends d{},exports.qtiCompanionMaterialsInfo=f([i.customElement("qti-companion-materials-info")],exports.qtiCompanionMaterialsInfo),exports.qtiRubricBlock=class extends d{},exports.qtiRubricBlock=f([i.customElement("qti-rubric-block")],exports.qtiRubricBlock),exports.qtiContentBody=class extends d{},exports.qtiContentBody=f([i.customElement("qti-content-body")],exports.qtiContentBody);class q extends s.LitElement{constructor(){super(),this.showHide="show",this.showFeedback("hide"===this.showHide)}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}}}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.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 _ extends q{constructor(){super(...arguments),this.render=()=>s.html` <slot class="${this.showStatus}"></slot> `}}_.styles=s.css`
12
12
  .on {
13
13
  display: inline-block;
14
14
  }
15
15
  .off {
16
16
  display: none;
17
17
  }
18
- `,customElements.define("qti-feedback-inline",_);class O extends q{render(){return s.html`
18
+ `,customElements.define("qti-feedback-inline",_);class S extends q{render(){return s.html`
19
19
  <style>
20
20
  .on {
21
21
  display: inline-block;
@@ -27,7 +27,7 @@
27
27
  <div class="feedback ${this.showStatus}">
28
28
  <slot></slot>
29
29
  </div>
30
- `}}customElements.define("qti-modal-feedback",O);class S extends d{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(a.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(a.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}g([i.property({attribute:"response-identifier"}),b("design:type",Object)],S.prototype,"responseIdentifier",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"disabled",void 0),g([i.property({reflect:!0,type:Boolean}),b("design:type",Object)],S.prototype,"readonly",void 0);const R=s.css`
30
+ `}}customElements.define("qti-modal-feedback",S);class O extends d{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(a.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(a.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}f([i.property({attribute:"response-identifier"}),g("design:type",Object)],O.prototype,"responseIdentifier",void 0),f([i.property({reflect:!0,type:Boolean}),g("design:type",Object)],O.prototype,"disabled",void 0),f([i.property({reflect:!0,type:Boolean}),g("design:type",Object)],O.prototype,"readonly",void 0);const R=s.css`
31
31
  /***
32
32
  The new CSS reset - version 1.4.9 (last updated 11.2.2022)
33
33
  GitHub page: https://github.com/elad2412/the-new-css-reset
@@ -107,7 +107,7 @@
107
107
  :where([draggable='true']) {
108
108
  -webkit-user-drag: element;
109
109
  }
110
- `;class k extends S{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},S.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[R,s.css`
110
+ `;class k extends O{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},O.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String}})}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[R,s.css`
111
111
  /* PK: display host as block, else design will be collapsed */
112
112
  :host {
113
113
  display: inline-block;
@@ -123,13 +123,13 @@
123
123
  @keyup="${this.textChanged}"
124
124
  @change="${this.textChanged}"
125
125
  type="text"
126
- placeholder="${n.ifDefined(this.placeholderText?this.placeholderText:void 0)}"
126
+ placeholder="${r.ifDefined(this.placeholderText?this.placeholderText:void 0)}"
127
127
  .value="${this.value}"
128
- size="${n.ifDefined(this.expectedLength?this.expectedLength:void 0)}"
129
- pattern="${n.ifDefined(this.patternMask?this.patternMask:void 0)}"
128
+ size="${r.ifDefined(this.expectedLength?this.expectedLength:void 0)}"
129
+ pattern="${r.ifDefined(this.patternMask?this.patternMask:void 0)}"
130
130
  ?disabled="${this.disabled}"
131
131
  ?readonly="${this.readonly}"
132
- />`}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")}}k.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",k);class I extends S{constructor(){super(...arguments),this.value="",this.textareaRef=o.createRef()}static get properties(){return Object.assign(Object.assign({},S.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String},classNames:{type:String,attribute:"class"}})}updated(e){e.has("classNames")&&this.changeRowsOnClassChange()}changeRowsOnClassChange(){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[R,s.css`
132
+ />`}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")}}k.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",k);class T extends O{constructor(){super(...arguments),this.value="",this.textareaRef=o.createRef()}static get properties(){return Object.assign(Object.assign({},O.properties),{expectedLength:{type:Number,attribute:"expected-length"},patternMask:{type:String,attribute:"pattern-mask"},placeholderText:{type:String,attribute:"placeholder-text"},value:{type:String},classNames:{type:String,attribute:"class"}})}updated(e){e.has("classNames")&&this.changeRowsOnClassChange()}changeRowsOnClassChange(){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[R,s.css`
133
133
  /* PK: display host as block, else design will be collapsed */
134
134
  :host {
135
135
  display: block;
@@ -146,14 +146,14 @@
146
146
  @keydown="${e=>e.stopImmediatePropagation()}"
147
147
  @keyup="${this.textChanged}"
148
148
  @change="${this.textChanged}"
149
- placeholder="${n.ifDefined(this.placeholderText?this.placeholderText:void 0)}"
150
- maxlength="${n.ifDefined(this.expectedLength?this.expectedLength:void 0)}"
151
- pattern="${n.ifDefined(this.patternMask?this.patternMask:void 0)}"
149
+ placeholder="${r.ifDefined(this.placeholderText?this.placeholderText:void 0)}"
150
+ maxlength="${r.ifDefined(this.expectedLength?this.expectedLength:void 0)}"
151
+ pattern="${r.ifDefined(this.patternMask?this.patternMask:void 0)}"
152
152
  ?disabled="${this.disabled}"
153
153
  ?readonly="${this.readonly}"
154
154
  .value=${this.value}
155
155
  ></textarea
156
- >`}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")}}I.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",I),exports.QtiHottext=class extends exports.QtiChoice{},exports.QtiHottext=g([i.customElement("qti-hottext")],exports.QtiHottext);class T extends S{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(a.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(a.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(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(a.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)}}g([i.property({type:Number,attribute:"min-choices"}),b("design:type",Number)],T.prototype,"_minChoices",void 0),g([i.property({type:Number,attribute:"max-choices"}),b("design:type",Number)],T.prototype,"_maxChoices",void 0),g([y("disabled",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleDisabledChange",void 0),g([y("readonly",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleReadonlyChange",void 0),g([y("_maxChoices",{waitUntilFirstUpdate:!0}),b("design:type",Object)],T.prototype,"_handleMaxChoicesChange",void 0);class A extends T{constructor(){super(...arguments),this.render=()=>s.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",A);class N extends S{constructor(){super(),this.options=[],this.addEventListener(a.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})))]}static get properties(){return Object.assign(Object.assign({},S.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[R,s.css`
156
+ >`}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")}}T.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],customElements.define("qti-extended-text-interaction",T),exports.QtiHottext=class extends exports.QtiChoice{},exports.QtiHottext=f([i.customElement("qti-hottext")],exports.QtiHottext);class w extends O{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(a.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(a.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(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(a.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)}}f([i.property({type:Number,attribute:"min-choices"}),g("design:type",Number)],w.prototype,"_minChoices",void 0),f([i.property({type:Number,attribute:"max-choices"}),g("design:type",Number)],w.prototype,"_maxChoices",void 0),f([x("disabled",{waitUntilFirstUpdate:!0}),g("design:type",Object)],w.prototype,"_handleDisabledChange",void 0),f([x("readonly",{waitUntilFirstUpdate:!0}),g("design:type",Object)],w.prototype,"_handleReadonlyChange",void 0),f([x("_maxChoices",{waitUntilFirstUpdate:!0}),g("design:type",Object)],w.prototype,"_handleMaxChoicesChange",void 0);class I extends w{constructor(){super(...arguments),this.render=()=>s.html`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",I);class A extends O{constructor(){super(),this.options=[],this.addEventListener(a.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})))]}static get properties(){return Object.assign(Object.assign({},O.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[R,s.css`
157
157
  :host {
158
158
  display: inline-block;
159
159
  }
@@ -171,10 +171,10 @@
171
171
  ${this.options.map((e=>s.html`
172
172
  <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
173
173
  `))}
174
- </select>`}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}})}}N.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",N);class w extends T{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>s.html`
174
+ </select>`}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}})}}A.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",A);class N extends w{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>s.html`
175
175
  <slot name="prompt"></slot>
176
- <slot></slot>`}}w.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],w.presentationClass=["","qti-input-control-hidden"],g([i.property({attribute:"orientation"}),b("design:type",String)],w.prototype,"_orientation",void 0),g([i.property({attribute:"shuffle",type:Boolean}),b("design:type",Boolean)],w.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",w),exports.QtiSimpleChoice=class extends exports.QtiChoice{},exports.QtiSimpleChoice=g([i.customElement("qti-simple-choice")],exports.QtiSimpleChoice);class L extends s.LitElement{render(){return s.html`<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",L);class M extends s.LitElement{render(){return s.html``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",M);class H extends M{render(){return s.html`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",H);class Q extends s.LitElement{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return s.html`
177
- <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",Q);class $ extends Q{render(){return s.html`${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",$);class D extends ${render(){return s.html`${super.render()}`}}customElements.define("qti-response-else-if",D);class P extends d{render(){return s.html``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",P);class j extends P{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 s=t.mapping,i=t.value;let r=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)r+=B(s,i[e],t.baseType);return r}return r+=B(s,i,t.baseType),r}}function B(e,t,s){let i=0;for(const r of e.entries()){const{entryTyped:e,valueTyped:n}=F(s,r,t);e===n&&(i+=r[1])}return i}function F(e,t,s){let i,r;switch(e){case exports.BaseType.string:case exports.BaseType.identifier:case exports.BaseType.directedPair:i=""+t[0],r=""+s;break;case exports.BaseType.float:i=parseFloat(t[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:r}}customElements.define("qti-map-response",j);class U extends M{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",U);class G extends P{render(){return s.html``}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",G);class V extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",V);class z extends P{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",z);class W extends P{calculate(){return W.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===exports.BaseType.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",W);class K extends P{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return K.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),r=s.map((e=>e.source+" "+e.destination)),n=i.map((e=>e.source+" "+e.destination));return r.filter((e=>n.includes(e))).length>0}}customElements.define("qti-contains",K);class X extends P{calculate(){return 2===this.children.length?X.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",X);class Y extends P{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Y);class J extends P{render(){return s.html``}calculate(){return J.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",J);class Z extends P{render(){return s.html``}calculate(){return Z.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",Z);class ee extends P{calculate(){return 1===this.children.length?ee.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",ee);class te extends d{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 s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),n=i.map((e=>e.getAttribute("key"))),o=n.length>0&&!n.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>r(e))):e.textContent}return t},r=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),r(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"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,s.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=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return s.html`<slot></slot>${this._errorMessage&&s.html`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",te);const se=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},ie=(e,t)=>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(this.querySelectorAll(t));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,s=this.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}},re=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:r,height:n}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:r,height:n});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/r,d=o.height/n;this.state.set(t,{left:s,top:i,width:r,height:n});const{duration:p,easing:h}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:p,easing:h})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return f(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:r}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:r})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},ne=(e,t,i)=>{class r extends(re(ie(se(e,t),i),i,t)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,r=s.parent,n=s.parent.children[i];r.insertBefore(t,n)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return s.html` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(a.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return r},oe=s.css`
176
+ <slot></slot>`}}N.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],N.presentationClass=["","qti-input-control-hidden"],f([i.property({attribute:"orientation"}),g("design:type",String)],N.prototype,"_orientation",void 0),f([i.property({attribute:"shuffle",type:Boolean}),g("design:type",Boolean)],N.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",N),exports.QtiSimpleChoice=class extends exports.QtiChoice{},exports.QtiSimpleChoice=f([i.customElement("qti-simple-choice")],exports.QtiSimpleChoice);class L extends s.LitElement{render(){return s.html`<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",L);class M extends s.LitElement{render(){return s.html``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",M);class $ extends M{render(){return s.html`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const s=e[t];if(s.calculate())return void s.process()}}}customElements.define("qti-response-condition",$);class H extends s.LitElement{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return s.html`
177
+ <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",H);class Q extends H{render(){return s.html`${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",Q);class D extends Q{render(){return s.html`${super.render()}`}}customElements.define("qti-response-else-if",D);class P extends d{render(){return s.html``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",P);class j extends P{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 s=t.mapping,i=t.value;let n=0;if(Array.isArray(i)){for(let e=0;e<i.length;e++)n+=B(s,i[e],t.baseType);return n}return n+=B(s,i,t.baseType),n}}function B(e,t,s){let i=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=F(s,n,t);e===r&&(i+=n[1])}return i}function F(e,t,s){let i,n;switch(e){case exports.BaseType.string:case exports.BaseType.identifier:case exports.BaseType.directedPair:i=""+t[0],n=""+s;break;case exports.BaseType.float:i=parseFloat(t[0].replace(",",".")),n=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:i,valueTyped:n}}customElements.define("qti-map-response",j);class U extends M{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,s=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,s)}}customElements.define("qti-set-outcome-value",U);class G extends P{render(){return s.html``}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",G);class z extends P{render(){return s.html``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",z);class W extends P{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let s=!0;return s=e instanceof Array?e.length===t.length&&e.filter(((e,s)=>e===t[s])).length===e.length:e==t,s}}customElements.define("qti-match",W);class V extends P{calculate(){return V.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(e,t){let s;if(t===exports.BaseType.directedPair){const t=e.split(" ");s={destination:t[1],source:t[0]}}else s=e;return s}}customElements.define("qti-base-value",V);class K extends P{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return K.calculate(e,t)}static calculate(e,t){const s=e.calculate(),i=t.calculate(),n=s.map((e=>e.source+" "+e.destination)),r=i.map((e=>e.source+" "+e.destination));return n.filter((e=>r.includes(e))).length>0}}customElements.define("qti-contains",K);class X extends P{calculate(){return 2===this.children.length?X.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",X);class Y extends P{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",Y);class J extends P{render(){return s.html``}calculate(){return J.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",J);class Z extends P{render(){return s.html``}calculate(){return Z.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",Z);class ee extends P{calculate(){return 1===this.children.length?ee.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",ee);class te extends d{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 s={};const i=e=>{const t={},s=e.getAttribute("key");if(s){const i=Array.from(e.children),r=i.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[s]=o?i.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const s of e.children)t=Object.assign(Object.assign({},t),i(s));return t}};for(const e of t){return e.getAttribute("key")||(s=Object.assign(Object.assign({},s),n(e))),s}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",s="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");s.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const i="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(s,i,void 0):e.initialize(this.customInteractionTypeIdentifier,s.firstElementChild,i),"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,s.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=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return s.html`<slot></slot>${this._errorMessage&&s.html`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",te);const se=(e,t)=>class extends e{connectedCallback(){if(super.connectedCallback(),this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{e.addEventListener("dragstart",(t=>{t.dataTransfer.setData("text",t.currentTarget.getAttribute("identifier")),e.setAttribute("dragging","")})),e.addEventListener("dragend",(t=>{t.preventDefault(),e.removeAttribute("over"),e.removeAttribute("dragging")})),e.setAttribute("draggable","true")}))}},ie=(e,t)=>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(this.querySelectorAll(t));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,s=this.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}},ne=(e,t,s)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:s,top:i,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:s,top:i,width:n,height:r});const o=this.state.get(t),a=o.left-s,l=o.top-i,c=o.width/n,d=o.height/r;this.state.set(t,{left:s,top:i,width:n,height:r});const{duration:p,easing:h}={duration:350,easing:"cubic-bezier(0.26, 0.86, 0.44, 0.985)"};t.animate([{transformOrigin:"top left",transform:`\n translate(${a}px, ${l}px)\n scale(${c}, ${d})\n `},{transformOrigin:"top left",transform:"none"}],{duration:p,easing:h})}))}}firstUpdated(e){const i=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return b(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(s)).forEach((e=>{const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:s,width:i,height:n})})),this.observer=new MutationObserver(this.animateMe);Array.from(this.querySelectorAll(t)).forEach((e=>{this.observer.observe(e,{childList:!0})})),this.observer.observe(this,{childList:!0}),i.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},re=(e,t,i)=>{class n extends(ne(ie(se(e,t),i),i,t)){constructor(){if(super(),this.draggables=new Map,this.disabled=!1,this.readonly=!1,this.minAssociations=1,this.maxAssociations=1,this.classList.contains("qti-match-tabular"))return;Array.from(this.querySelectorAll(t)).forEach((e=>{this.draggables.set(e,{parent:e.parentElement,index:Array.from(e.parentNode.children).indexOf(e)}),e.addEventListener("dragend",(e=>{if("none"===e.dataTransfer.dropEffect){const t=e.currentTarget,s=this.draggables.get(t),i=s.index<s.parent.children.length?s.index:s.parent.children.length-1,n=s.parent,r=s.parent.children[i];n.insertBefore(t,r)}e.dataTransfer.dropEffect,this.saveResponse(),this.checkMaxMatchAssociations()}))}))}static get properties(){return{responseIdentifier:{type:String,value:"",attribute:"response-identifier"},disabled:{type:Boolean,reflect:!0},readonly:{type:Boolean,reflect:!0},minAssociations:{type:Number,reflect:!0,attribute:"min-associations"},maxAssociations:{type:Number,reflect:!0,attribute:"max-associations"}}}render(){return s.html` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i));if(e.filter((e=>e.childElementCount>0)).length>=this.maxAssociations)e.forEach((e=>this.setDisableStateDroppable(e,!0)));else for(const t of e){const e=+(t.getAttribute("match-max")||1)<=(t.children.length||0);this.setDisableStateDroppable(t,e)}}setDisableStateDroppable(e,t){t?(e.setAttribute("disabled",""),e.removeAttribute("dropzone")):(e.removeAttribute("disabled"),e.setAttribute("dropzone","move"))}updated(e){this.classList.contains("qti-match-tabular")||e.forEach(((e,t)=>{switch(t){case"disabled":this.draggables.forEach(((e,t)=>{this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),this.disabled?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}));break;case"readonly":this.draggables.forEach(((e,t)=>{this.readonly?t.setAttribute("readonly",""):t.removeAttribute("readonly"),this.readonly?t.removeAttribute("draggable"):t.setAttribute("draggable","true")}))}}))}reset(e=!0){this.draggables.forEach(((e,t)=>{const s=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[s])})),e&&this.saveResponse()}set response(e){this.classList.contains("qti-match-tabular")||(this.reset(!1),null!==e&&Array.isArray(e)&&e.forEach((e=>{const[t,s]=e.split(" ");if(s){const e=this.querySelector(`[identifier=${s}]`),i=this.querySelector(`[identifier=${t}]`);e?i?(e.appendChild(i),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${s}`)}})))}validate(){const e=Array.from(this.querySelectorAll(i)).filter((e=>e.childElementCount>0)).length;return this.minAssociations<=0||this.minAssociations<=e}saveResponse(){const e={list:{pair:Array.from(this.querySelectorAll(i)).map((e=>Array.from(e.children).map((e=>e.getAttribute("identifier")+" "))+e.getAttribute("identifier")))}};this.dispatchEvent(new CustomEvent(a.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(a.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},oe=s.css`
178
178
  .notification {
179
179
  position: absolute;
180
180
  z-index: 100000;
@@ -196,7 +196,7 @@
196
196
  border-radius: 99999px;
197
197
  content: 'preview not interactive';
198
198
  }
199
- `;class ae extends(ne(d,"qti-simple-associable-choice","drop-list")){render(){return s.html`
199
+ `;class ae extends(re(d,"qti-simple-associable-choice","drop-list")){render(){return s.html`
200
200
  <slot name="prompt"></slot>
201
201
  <slot></slot>`}firstUpdated(e){s.render(s.html`
202
202
  ${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,t)=>s.html`<div class="associables-container">
@@ -205,7 +205,7 @@
205
205
  </div>`))}
206
206
  `,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}ae.styles=[oe],customElements.define("qti-associate-interaction",ae);class le extends s.LitElement{render(){return s.html`
207
207
  <slot></slot>
208
- `}}customElements.define("qti-simple-associable-choice",le);class ce extends(ne(s.LitElement,"qti-gap-text","qti-gap")){render(){return s.html`<slot></slot>`}}ce.styles=[oe],customElements.define("qti-gap-match-interaction",ce);class de extends HTMLElement{}customElements.define("qti-gap-text",de);class pe extends HTMLElement{}function he(e,t,s,i){switch(e){case"circle":{const[e,r,n]=t,o=e/s.width*100,a=r/s.height*100,l=n/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,r,n,o]=t,a=e/s.width*100,l=r/s.height*100,c=n/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}else e.push(t);return e}),[]),r=Math.min(...e.map((e=>e.x))),n=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=r/s.width*100,c=o/s.height*100,d=n/s.width*100,p=a/s.height*100;i.style.left=r/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=p-c+"%";const h=e.map((e=>({x:(e.x-r)/(n-r)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");i.style.clipPath=`polygon(${h})`}}}customElements.define("qti-gap",pe);class ue extends T{render(){return s.html`
208
+ `}}customElements.define("qti-simple-associable-choice",le);class ce extends(re(s.LitElement,"qti-gap-text","qti-gap")){render(){return s.html`<slot></slot>`}}ce.styles=[oe],customElements.define("qti-gap-match-interaction",ce);class de extends HTMLElement{}customElements.define("qti-gap-text",de);class pe extends HTMLElement{}function he(e,t,s,i){switch(e){case"circle":{const[e,n,r]=t,o=e/s.width*100,a=n/s.height*100,l=r/s.width*100;i.style.left=o-l+"%",i.style.top=a-l+"%",i.style.width=i.style.height=4*l+"px",i.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/s.width*100,l=n/s.height*100,c=r/s.width*100,d=o/s.height*100;i.style.left=a+"%",i.style.top=l+"%",i.style.width=c-a+"%",i.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,s,i)=>{if(s%2==1){const t=e.pop();e[e.length]={x:t,y:i[s]}}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/s.width*100,c=o/s.height*100,d=r/s.width*100,p=a/s.height*100;i.style.left=n/s.width*100+"%",i.style.top=o/s.height*100+"%",i.style.width=d-l+"%",i.style.height=p-c+"%";const h=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(",");i.style.clipPath=`polygon(${h})`}}}customElements.define("qti-gap",pe);class ue extends w{render(){return s.html`
209
209
  <slot name="prompt"></slot>
210
210
  <!-- slot for the prompt -->
211
211
  <slot></slot>
@@ -221,18 +221,18 @@
221
221
  pointer-events: none;
222
222
  user-select: none;
223
223
  }
224
- `],customElements.define("qti-graphic-associate-interaction",ue);class me extends(ne(d,"qti-gap-img","qti-associable-hotspot")){render(){return s.html` <slot></slot>
225
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=r;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,n]=r;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=n-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}me.styles=s.css`
224
+ `],customElements.define("qti-graphic-associate-interaction",ue);class me extends(re(d,"qti-gap-img","qti-associable-hotspot")){render(){return s.html` <slot></slot>
225
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,s=t.getAttribute("coords"),i=t.getAttribute("shape"),n=s.split(",").map((e=>parseInt(e)));switch(i){case"circle":{const[e,s,i]=n;t.style.left=e-i+"px",t.style.top=s-i+"px",t.style.width=t.style.height=2*i+"px"}break;case"rect":{const[e,s,i,r]=n;t.style.left=e+"px",t.style.top=s+"px",t.style.width=i-e+"px",t.style.height=r-s+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}me.styles=s.css`
226
226
  slot[name="qti-gap-img"] {
227
227
  display: flex;
228
228
  gap: 1rem;
229
229
  }
230
- `,customElements.define("qti-graphic-gap-match-interaction",me);class ge extends T{render(){return s.html`
230
+ `,customElements.define("qti-graphic-gap-match-interaction",me);class fe extends w{render(){return s.html`
231
231
  <slot name="prompt"></slot>
232
232
  <!-- slot for the prompt -->
233
233
  <slot></slot>
234
234
  <!-- slot for the image and hotspots -->
235
- `}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");he(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ge.styles=[s.css`
235
+ `}setHotspotOrder(e){const{identifier:t}=e.detail,s=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==s.order)return this._choiceElements.filter((e=>e.order>0)).length>=i||(s.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),s.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");he(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}fe.styles=[s.css`
236
236
  slot:not([name='prompt']) {
237
237
  position: relative; /* qti-hotspot-choice relative to the slot */
238
238
  display: block;
@@ -243,12 +243,12 @@
243
243
  pointer-events: none;
244
244
  user-select: none;
245
245
  }
246
- `],customElements.define("qti-graphic-order-interaction",ge);class be extends T{render(){return s.html`
246
+ `],customElements.define("qti-graphic-order-interaction",fe);class ge extends w{render(){return s.html`
247
247
  <slot name="prompt"></slot>
248
248
  <!-- slot for the prompt -->
249
249
  <slot></slot>
250
250
  <!-- slot for the image and hotspots -->
251
- `}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");he(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}be.styles=[s.css`
251
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),s=e.target,i=s.getAttribute("coords");he(s.getAttribute("shape"),i.split(",").map((e=>parseInt(e))),t,s)}connectedCallback(){super.connectedCallback(),this.addEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(a.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}ge.styles=[s.css`
252
252
  slot:not([name='prompt']) {
253
253
  position: relative; /* qti-hotspot-choice relative to the slot */
254
254
  display: block;
@@ -259,21 +259,21 @@
259
259
  pointer-events: none;
260
260
  user-select: none;
261
261
  }
262
- `],customElements.define("qti-hotspot-interaction",be);class fe extends exports.QtiChoice{}fe.styles=s.css`
262
+ `],customElements.define("qti-hotspot-interaction",ge);class be extends exports.QtiChoice{}be.styles=s.css`
263
263
  :host {
264
264
  position: absolute;
265
265
  }
266
- `,g([i.property({attribute:"aria-ordervalue",type:Number,reflect:!0}),b("design:type",Number)],fe.prototype,"order",void 0),customElements.define("qti-hotspot-choice",fe);class ye extends(ne(s.LitElement,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return s.html`
266
+ `,f([i.property({attribute:"aria-ordervalue",type:Number,reflect:!0}),g("design:type",Number)],be.prototype,"order",void 0),customElements.define("qti-hotspot-choice",be);class xe extends(re(s.LitElement,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return s.html`
267
267
  <slot name="prompt"></slot>
268
- <slot></slot>`}}ye.styles=[oe],customElements.define("qti-match-interaction",ye);class Ee extends S{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},S.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return s.html`
268
+ <slot></slot>`}}xe.styles=[oe],customElements.define("qti-match-interaction",xe);class ye extends O{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},O.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return s.html`
269
269
  <slot name="prompt"></slot>
270
- <slot></slot>`}connectedCallback(){super.connectedCallback()}}Ee.styles=[oe,s.css``],customElements.define("qti-media-interaction",Ee);class ve extends(ne(d,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return s.html` <slot name="prompt"> </slot>
270
+ <slot></slot>`}connectedCallback(){super.connectedCallback()}}ye.styles=[oe,s.css``],customElements.define("qti-media-interaction",ye);class Ee extends(re(d,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return s.html` <slot name="prompt"> </slot>
271
271
  <div class=${`container ${this._classNames}`}>
272
272
  <slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
273
273
  <div class=${"vertical"===this._orientation?"ver":"hor"}>
274
274
  ${this.childrenMap.map(((e,t)=>s.html`<drop-list identifier="droplist${t}"></drop-list>`))}
275
275
  </div>
276
- </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}ve.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],ve.styles=[oe,s.css`
276
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Ee.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Ee.styles=[oe,s.css`
277
277
  .hor {
278
278
  display: grid;
279
279
  gap: var(--qti-gap, 2px);
@@ -312,10 +312,10 @@
312
312
  content: 'drop here';
313
313
  color: var(--qti-placeholder-text);
314
314
  }
315
- `],customElements.define("qti-order-interaction",ve);class xe extends T{constructor(){super()}render(){return s.html`<slot></slot>
316
- <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}xe.styles=[oe],customElements.define("qti-select-point-interaction",xe);const Ce=37,qe=38,_e=39,Oe=40,Se=33,Re=34,ke=35,Ie=36;class Te extends S{constructor(){super(),this.addEventListener("keydown",this._onKeyDown.bind(this))}reset(){}validate(){return!0}set response(e){}set min(e){this._min=e,this.style.setProperty("--qti-slider-interaction-lower-bounds",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--qti-slider-interaction-upper-bounds",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--qti-slider-interaction-step",`${this._step}`)}get step(){return this._step}render(){return s.html`
315
+ `],customElements.define("qti-order-interaction",Ee);class ve extends w{constructor(){super()}render(){return s.html`<slot></slot>
316
+ <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}ve.styles=[oe],customElements.define("qti-select-point-interaction",ve);const Ce=37,qe=38,_e=39,Se=40,Oe=33,Re=34,ke=35,Te=36;class we extends O{constructor(){super(),this.addEventListener("keydown",this._onKeyDown.bind(this))}reset(){}validate(){return!0}set response(e){}set min(e){this._min=e,this.style.setProperty("--qti-slider-interaction-lower-bounds",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--qti-slider-interaction-upper-bounds",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--qti-slider-interaction-step",`${this._step}`)}get step(){return this._step}render(){return s.html`
317
317
  <slot name="prompt"></slot>
318
- <slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case Ce:case Oe:this._moveSliderTo(s-this.step),t=!0;break;case _e:case qe:this._moveSliderTo(s+this.step),t=!0;break;case Re:this._moveSliderTo(s-this.step),t=!0;break;case Se:this._moveSliderTo(s+this.step),t=!0;break;case Ie:this._moveSliderTo(this.min),t=!0;break;case ke:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,s=this.min,i=this.max,r=e=>{const r=e.pageX-t.offsetLeft,n=s+(i-s)*r/this.RAIL_WIDTH;this._moveSliderTo(n),e.preventDefault(),e.stopPropagation()},n=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),e.preventDefault(),e.stopPropagation(),e.target.focus();const o=e.pageX-t.offsetLeft,a=s+(i-s)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,s=this.max;let i=Number(e);i<t&&(i=t),i>s&&(i=s);const r=(i-t)/(s-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${r}%`)}}Te.styles=[oe,s.css``],g([i.property({type:Number,attribute:"lower-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"min",null),g([i.property({type:Number,attribute:"upper-bound"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"max",null),g([i.property({type:Number,attribute:"step"}),b("design:type",Number),b("design:paramtypes",[Number])],Te.prototype,"step",null),customElements.define("qti-slider-interaction",Te);class Ae extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${this.value}`}levenshtein(e,t){let s;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(s=e,e=t,t=s);const i=e.length,r=t.length,n=Array(i);let o,a,l;for(o=0;o<=i;o++)n[o]=o;for(o=1;o<=r;o++){for(l=o,a=1;a<=i;a++)s=n[a-1],n[a-1]=l,l=Math.min(s+(t[o-1]!==e[a-1]),l+1,n[a]+1);n[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,s=e.calculate(),i=t.calculate();return this.value=100-this.levenshtein(s.toString().trim(),i.toString().trim())/i.toString().length*100,this.value}}Ae.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Ae);class Ne extends s.LitElement{render(){return s.html``}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",Ne);class we extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${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 s=Intl.NumberFormat(t).format(1.1),i=new RegExp(`[^-+0-9${s.charAt(1)}]`,"g"),r=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(r)}}we.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",we);class Le extends s.LitElement{render(){return s.html``}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",Le);class Me extends s.LitElement{render(){return s.html``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Me);const He={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var Qe,$e;exports.NavigationMode=void 0,(Qe=exports.NavigationMode||(exports.NavigationMode={})).linear="linear",Qe.nonlinear="nonlinear",exports.SubmissionMode=void 0,($e=exports.SubmissionMode||(exports.SubmissionMode={})).individual="individual",$e.simultaneous="simultaneous",exports.QtiTest=class extends s.LitElement{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=exports.NavigationMode.nonlinear,this._submissionMode=exports.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===exports.NavigationMode.linear?"hidden":"visible"}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===exports.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(He.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this._dispatchRequestItem(this.itemIndex-1)}_onNextItem(){this._navigationMode!==exports.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this._dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent(He.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(He.ON_NO_RESPONSE_ON_SUBMIT))}_dispatchRequestItem(e){this.dispatchEvent(new CustomEvent(He.ON_REQUEST_ITEM,{bubbles:!0,composed:!0,detail:e}))}_onRequestItem(e){this._dispatchRequestItem(e.detail)}_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",""))}render(){return s.html`
318
+ <slot></slot>`}firstUpdated(){this.addEventListener("mousedown",this._onMouseDown.bind(this)),this.style.setProperty("--qti-slider-interaction-step",this.step?this.step.toString():"10");const e=this.getAttribute("value");this._moveSliderTo(e)}connectedCallback(){super.connectedCallback(),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get RAIL_WIDTH(){return this.offsetWidth}_onKeyDown(e){let t=!1;const s=this.value;switch(e.keyCode){case Ce:case Se:this._moveSliderTo(s-this.step),t=!0;break;case _e:case qe:this._moveSliderTo(s+this.step),t=!0;break;case Re:this._moveSliderTo(s-this.step),t=!0;break;case Oe:this._moveSliderTo(s+this.step),t=!0;break;case Te:this._moveSliderTo(this.min),t=!0;break;case ke:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,s=this.min,i=this.max,n=e=>{const n=e.pageX-t.offsetLeft,r=s+(i-s)*n/this.RAIL_WIDTH;this._moveSliderTo(r),e.preventDefault(),e.stopPropagation()},r=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),this.saveResponse({base:{float:this.value}})};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r),e.preventDefault(),e.stopPropagation(),e.target.focus();const o=e.pageX-t.offsetLeft,a=s+(i-s)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,s=this.max;let i=Number(e);i<t&&(i=t),i>s&&(i=s);const n=(i-t)/(s-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${n}%`)}}we.styles=[oe,s.css``],f([i.property({type:Number,attribute:"lower-bound"}),g("design:type",Number),g("design:paramtypes",[Number])],we.prototype,"min",null),f([i.property({type:Number,attribute:"upper-bound"}),g("design:type",Number),g("design:paramtypes",[Number])],we.prototype,"max",null),f([i.property({type:Number,attribute:"step"}),g("design:type",Number),g("design:paramtypes",[Number])],we.prototype,"step",null),customElements.define("qti-slider-interaction",we);class Ie extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${this.value}`}levenshtein(e,t){let s;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(s=e,e=t,t=s);const i=e.length,n=t.length,r=Array(i);let o,a,l;for(o=0;o<=i;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=i;a++)s=r[a-1],r[a-1]=l,l=Math.min(s+(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,s=e.calculate(),i=t.calculate();return this.value=100-this.levenshtein(s.toString().trim(),i.toString().trim())/i.toString().length*100,this.value}}Ie.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",Ie);class Ae extends s.LitElement{render(){return s.html``}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",Ae);class Ne extends s.LitElement{constructor(){super(...arguments),this.render=()=>s.html`${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 s=Intl.NumberFormat(t).format(1.1),i=new RegExp(`[^-+0-9${s.charAt(1)}]`,"g"),n=e.replace(i,"").replace(s.charAt(1),".");return parseFloat(n)}}Ne.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",Ne);class Le extends s.LitElement{render(){return s.html``}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",Le);class Me extends s.LitElement{render(){return s.html``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",Me);const $e={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished"};var He,Qe;exports.NavigationMode=void 0,(He=exports.NavigationMode||(exports.NavigationMode={})).linear="linear",He.nonlinear="nonlinear",exports.SubmissionMode=void 0,(Qe=exports.SubmissionMode||(exports.SubmissionMode={})).individual="individual",Qe.simultaneous="simultaneous",exports.QtiTest=class extends s.LitElement{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=exports.NavigationMode.nonlinear,this._submissionMode=exports.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0}handleNavigationModeChange(e,t){this.prevButton.style.visibility=t===exports.NavigationMode.linear?"hidden":"visible"}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set itemResponse(e){this._itemRef&&(this._itemRef.responses=e,this._navigationMode===exports.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent($e.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this._dispatchRequestItem(this.itemIndex-1)}_onNextItem(){this._navigationMode!==exports.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this._dispatchRequestItem(this.itemIndex+1):this.dispatchEvent(new CustomEvent($e.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent($e.ON_NO_RESPONSE_ON_SUBMIT))}_dispatchRequestItem(e){this.dispatchEvent(new CustomEvent($e.ON_REQUEST_ITEM,{bubbles:!0,composed:!0,detail:e}))}_onRequestItem(e){this._dispatchRequestItem(e.detail)}_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",""))}render(){return s.html`
319
319
  <slot
320
320
  @slotchange=${this._handleSlotchange}
321
321
  @on-prev-item=${this._onPrevItem}
@@ -325,7 +325,7 @@
325
325
  @on-request-item=${this._onRequestItem}
326
326
  >
327
327
  </slot>
328
- `}},g([i.query("qti-test-prev"),b("design:type",HTMLElement)],exports.QtiTest.prototype,"prevButton",void 0),g([i.query("qti-test-next"),b("design:type",HTMLElement)],exports.QtiTest.prototype,"nextButton",void 0),g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"disabled",void 0),g([i.property({type:Boolean}),b("design:type",Object)],exports.QtiTest.prototype,"readonly",void 0),g([i.property({type:String,attribute:"navigation-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_navigationMode",void 0),g([y("_navigationMode",{waitUntilFirstUpdate:!0}),b("design:type",Function),b("design:paramtypes",[Object,String]),b("design:returntype",void 0)],exports.QtiTest.prototype,"handleNavigationModeChange",null),g([i.property({type:String,attribute:"submission-mode"}),b("design:type",Object)],exports.QtiTest.prototype,"_submissionMode",void 0),g([i.property(),b("design:type",Array)],exports.QtiTest.prototype,"items",void 0),g([i.property({type:Number,attribute:"item-index",reflect:!0}),b("design:type",Object)],exports.QtiTest.prototype,"itemIndex",void 0),g([i.state(),b("design:type",p)],exports.QtiTest.prototype,"_itemRef",void 0),exports.QtiTest=g([i.customElement("qti-test")],exports.QtiTest);const De=(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 s=this.querySelector(t);if(s){const t=e/s.clientWidth;this.scale=t,this.marginY=-s.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{s.style.transform=`scale(${this.scale})`,s.style.margin=`0 0 ${this.marginY} 0`}))}}};class Pe extends(De(s.LitElement,"qti-assessment-item")){constructor(){super(...arguments),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=()=>s.html`<slot @slotchange=${this.handleSlotchange}></slot>`}static get properties(){return{disabled:{type:Boolean},readonly:{type:Boolean},responses:{type:Object}}}updated(e){e.forEach(((e,t)=>{var s,i;switch(t){case"disabled":null===(s=this._item)||void 0===s||s.setAttribute("disabled","");break;case"readonly":null===(i=this._item)||void 0===i||i.setAttribute("readonly","");break;case"responses":this._item&&(this._item.responses=this.responses)}}))}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))}))}}Pe.styles=s.css`
328
+ `}},f([i.query("qti-test-prev"),g("design:type",HTMLElement)],exports.QtiTest.prototype,"prevButton",void 0),f([i.query("qti-test-next"),g("design:type",HTMLElement)],exports.QtiTest.prototype,"nextButton",void 0),f([i.property({type:Boolean}),g("design:type",Object)],exports.QtiTest.prototype,"disabled",void 0),f([i.property({type:Boolean}),g("design:type",Object)],exports.QtiTest.prototype,"readonly",void 0),f([i.property({type:String,attribute:"navigation-mode"}),g("design:type",Object)],exports.QtiTest.prototype,"_navigationMode",void 0),f([x("_navigationMode",{waitUntilFirstUpdate:!0}),g("design:type",Function),g("design:paramtypes",[Object,String]),g("design:returntype",void 0)],exports.QtiTest.prototype,"handleNavigationModeChange",null),f([i.property({type:String,attribute:"submission-mode"}),g("design:type",Object)],exports.QtiTest.prototype,"_submissionMode",void 0),f([i.property(),g("design:type",Array)],exports.QtiTest.prototype,"items",void 0),f([i.property({type:Number,attribute:"item-index",reflect:!0}),g("design:type",Object)],exports.QtiTest.prototype,"itemIndex",void 0),f([i.state(),g("design:type",p)],exports.QtiTest.prototype,"_itemRef",void 0),exports.QtiTest=f([i.customElement("qti-test")],exports.QtiTest);const De=(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 s=this.querySelector(t);if(s){const t=e/s.clientWidth;this.scale=t,this.marginY=-s.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{s.style.transform=`scale(${this.scale})`,s.style.margin=`0 0 ${this.marginY} 0`}))}}};class Pe extends(De(s.LitElement,"qti-assessment-item")){constructor(){super(...arguments),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=()=>s.html`<slot @slotchange=${this.handleSlotchange}></slot>`}static get properties(){return{disabled:{type:Boolean},readonly:{type:Boolean},responses:{type:Object}}}updated(e){e.forEach(((e,t)=>{var s,i;switch(t){case"disabled":null===(s=this._item)||void 0===s||s.setAttribute("disabled","");break;case"readonly":null===(i=this._item)||void 0===i||i.setAttribute("readonly","");break;case"responses":this._item&&(this._item.responses=this.responses)}}))}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))}))}}Pe.styles=s.css`
329
329
  :host {
330
330
  display: block; /* necessary to calculate scaling position */
331
331
  width: 100%;
@@ -339,4 +339,4 @@
339
339
  width: 640px !important;
340
340
  transform-origin: 0 0;
341
341
  }
342
- `,customElements.define("qti-item",Pe),exports.AssessmentTestEvents=He,exports.Choices=T,exports.Events=a,exports.OutcomeVariable=c,exports.QtiAnd=J,exports.QtiAssessmentItem=p,exports.QtiAssociateInteraction=ae,exports.QtiBaseValue=W,exports.QtiChoiceInteraction=w,exports.QtiContains=K,exports.QtiCorrect=G,exports.QtiCustomOperatorLevenshtein=Ae,exports.QtiCustomOperatorNumericOnly=Ne,exports.QtiCustomOperatorParseNumberLocalNl=we,exports.QtiCustomOperatorRemoveAllSpaces=Le,exports.QtiCustomOperatorTrim=Me,exports.QtiExpression=P,exports.QtiExtendedTextInteraction=I,exports.QtiFeedbackInline=_,exports.QtiGap=pe,exports.QtiGapMatchInteraction=ce,exports.QtiGapText=de,exports.QtiGraphicAssociateInteraction=ue,exports.QtiGraphicGapMatchInteraction=me,exports.QtiGraphicOrderInteraction=ge,exports.QtiGte=X,exports.QtiHotspotChoice=fe,exports.QtiHotspotInteraction=be,exports.QtiHottextInteraction=A,exports.QtiInlineChoiceInteraction=N,exports.QtiIsNull=ee,exports.QtiItem=Pe,exports.QtiItemBody=u,exports.QtiMapResponse=j,exports.QtiMatch=z,exports.QtiMatchInteraction=ye,exports.QtiMediaInteraction=Ee,exports.QtiModalFeedback=O,exports.QtiMultiple=Y,exports.QtiOr=Z,exports.QtiOrderInteraction=ve,exports.QtiOutcomeDeclaration=C,exports.QtiPortableCustomInteraction=te,exports.QtiPrompt=m,exports.QtiResponseCondition=H,exports.QtiResponseDeclaration=x,exports.QtiResponseElse=Q,exports.QtiResponseElseIf=D,exports.QtiResponseIf=$,exports.QtiResponseProcessing=L,exports.QtiSelectPointInteraction=xe,exports.QtiSetOutcomeValue=U,exports.QtiSliderInteraction=Te,exports.QtiStylesheet=h,exports.QtiTextEntryInteraction=k,exports.QtiVariable=V,exports.ResponseVariable=l,exports.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},exports.qtiSimpleAssociableChoice=le;
342
+ `,customElements.define("qti-item",Pe);const je=e=>{const t=e.split("/>");let s="";for(let e=0;e<t.length-1;e++){const i=t[e].split("<");s+=t[e]+"></"+i[i.length-1].split(" ")[0]+">"}return s+t[t.length-1]};exports.AssessmentTestEvents=$e,exports.Choices=w,exports.Events=a,exports.OutcomeVariable=c,exports.QtiAnd=J,exports.QtiAssessmentItem=p,exports.QtiAssociateInteraction=ae,exports.QtiBaseValue=V,exports.QtiChoiceInteraction=N,exports.QtiContains=K,exports.QtiCorrect=G,exports.QtiCustomOperatorLevenshtein=Ie,exports.QtiCustomOperatorNumericOnly=Ae,exports.QtiCustomOperatorParseNumberLocalNl=Ne,exports.QtiCustomOperatorRemoveAllSpaces=Le,exports.QtiCustomOperatorTrim=Me,exports.QtiExpression=P,exports.QtiExtendedTextInteraction=T,exports.QtiFeedbackInline=_,exports.QtiGap=pe,exports.QtiGapMatchInteraction=ce,exports.QtiGapText=de,exports.QtiGraphicAssociateInteraction=ue,exports.QtiGraphicGapMatchInteraction=me,exports.QtiGraphicOrderInteraction=fe,exports.QtiGte=X,exports.QtiHotspotChoice=be,exports.QtiHotspotInteraction=ge,exports.QtiHottextInteraction=I,exports.QtiInlineChoiceInteraction=A,exports.QtiIsNull=ee,exports.QtiItem=Pe,exports.QtiItemBody=u,exports.QtiMapResponse=j,exports.QtiMatch=W,exports.QtiMatchInteraction=xe,exports.QtiMediaInteraction=ye,exports.QtiModalFeedback=S,exports.QtiMultiple=Y,exports.QtiOr=Z,exports.QtiOrderInteraction=Ee,exports.QtiOutcomeDeclaration=C,exports.QtiPortableCustomInteraction=te,exports.QtiPrompt=m,exports.QtiResponseCondition=$,exports.QtiResponseDeclaration=v,exports.QtiResponseElse=H,exports.QtiResponseElseIf=D,exports.QtiResponseIf=Q,exports.QtiResponseProcessing=L,exports.QtiSelectPointInteraction=ve,exports.QtiSetOutcomeValue=U,exports.QtiSliderInteraction=we,exports.QtiStylesheet=h,exports.QtiTextEntryInteraction=k,exports.QtiVariable=z,exports.ResponseVariable=l,exports.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},exports.fixSelfClosingTags=je,exports.qtiSimpleAssociableChoice=le,exports.qtiTransform=e=>{let t=e;const s=e=>{const s=(new DOMParser).parseFromString(t,"text/xml"),i=new XSLTProcessor,n=(new DOMParser).parseFromString(e,"text/xml");i.importStylesheet(n);const r=i.transformToFragment(s,document);t=(new XMLSerializer).serializeToString(r)},i={mathml:()=>(s(""),i),pciHooks(e){const s=["hook","module"],n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const t of s){r.querySelectorAll("["+t+"]").forEach((s=>{const i=s.getAttribute(t);i.startsWith("data:")||i.startsWith("http")||(s.setAttribute("base-url",e),s.setAttribute("module",n+"/"+i+(i.endsWith(".js")?"":".js")))}))}return t=(new XMLSerializer).serializeToString(r),i},assetsLocation(e,s=["src","href","data"]){const n=e.substring(0,e.lastIndexOf("/")),r=(new DOMParser).parseFromString(t,"text/xml");for(const e of s){r.querySelectorAll("["+e+"]").forEach((t=>{const s=t.getAttribute(e);s.startsWith("data:")||s.startsWith("http")||t.setAttribute(e,n+"/"+encodeURIComponent(s))}))}return t=(new XMLSerializer).serializeToString(r),i},customTypes:()=>(s('<?xml version="1.0" encoding="utf-8"?>\n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:qti="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:m="http://www.w3.org/1998/Math/MathML">\n <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>\t \n <xsl:param name="separator" select="\' \'" />\n <xsl:param name="prefix" select="\'type:\'" />\n <xsl:variable name="prefixElements"></xsl:variable>\n <xsl:variable name="suffixElements"></xsl:variable>\n \x3c!-- passthrough --\x3e\n <xsl:template match="*">\n <xsl:copy>\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:copy>\n </xsl:template>\n <xsl:template match="@* | text()">\n <xsl:copy-of select="." />\n </xsl:template>\n \n <xsl:template match="*">\n <xsl:variable name="elementName">\n <xsl:call-template name="getTypedElementName">\n <xsl:with-param name="input" select="." />\n </xsl:call-template>\n </xsl:variable>\n <xsl:element name="{$elementName}">\n <xsl:apply-templates select="* | @* | text()" />\n </xsl:element>\n </xsl:template>\n \n \x3c!-- custom names --\x3e\n <xsl:template name="getType">\n <xsl:param name="input" />\n <xsl:param name="separator" select="$separator" />\n <xsl:param name="prefix" select="$prefix" />\n <xsl:variable name="output">\n <xsl:choose>\n <xsl:when test="contains($input, $separator)">\n <xsl:value-of select="substring-before($input, $separator)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:value-of select="$input" />\n </xsl:otherwise>\n </xsl:choose>\n </xsl:variable>\n <xsl:choose>\n <xsl:when test="starts-with($output, $prefix) and $output != $prefix">\n <xsl:value-of select="substring-after($output, $prefix)" />\n </xsl:when>\n <xsl:otherwise>\n <xsl:variable name="after" select="substring-after($input, $separator)" />\n <xsl:if test="$after">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$after" />\n <xsl:with-param name="separator" select="$separator" />\n <xsl:with-param name="prefix" select="$prefix" />\n </xsl:call-template>\n </xsl:if>\n </xsl:otherwise>\n </xsl:choose>\n </xsl:template>\n \n <xsl:template name="getTypedElementName">\n <xsl:param name="input" />\n <xsl:variable name="prefixElements" select="document(\'\')//xsl:variable[@name = \'prefixElements\']/element" />\n <xsl:variable name="suffixElements" select="document(\'\')//xsl:variable[@name = \'suffixElements\']/element" />\n <xsl:variable name="originalName" select="name($input)" />\n <xsl:variable name="type">\n <xsl:call-template name="getType">\n <xsl:with-param name="input" select="$input/@class" />\n </xsl:call-template>\n </xsl:variable>\n <xsl:value-of select="$originalName" />\n \x3c!-- Add prefix elements --\x3e\n <xsl:if test="$prefixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n \x3c!-- Add suffix to typed elements --\x3e\n <xsl:if test="string-length($type)">\n <xsl:text>-</xsl:text>\n <xsl:value-of select="$type" />\n </xsl:if>\n \x3c!-- Add suffix to elements --\x3e\n <xsl:if test="$suffixElements[text() = $originalName]">\n <xsl:text>-</xsl:text>\n </xsl:if>\n </xsl:template>\n </xsl:stylesheet>'),i),suffix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,e+"-"+s)})),i),prefix:(e,s)=>(e.forEach((e=>{t=t.replaceAll(e,s+"-"+e)})),i),fn:e=>(t=e(t),i),elementNameAttributes:e=>(e.forEach((e=>{t=t.replaceAll(e,e+` data-element="${e}" `)})),i),print:()=>(console.log(t),i),xml:()=>(t=je(t),t)};return i};
package/index.d.ts CHANGED
@@ -48,3 +48,4 @@ export * from './lab/qti-custom/qti-custom-operator/qti-custom-operator-trim';
48
48
  export * from './lab/qti-test/qti-test';
49
49
  export * from './lab/qti-item/qti-item';
50
50
  export * from './lib/utilities/choice/choices';
51
+ export * from './lab/qti-transform/qti-transform';