@citolab/qti-components 3.0.50 → 3.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.umd.js ADDED
@@ -0,0 +1,472 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QtiComponents={})}(this,(function(e){"use strict";var t,i;e.BaseType=void 0,(t=e.BaseType||(e.BaseType={})).boolean="boolean",t.directedPair="directedPair",t.float="float",t.integer="integer",t.string="string",t.identifier="identifier",t.pair="pair",e.Cardinality=void 0,(i=e.Cardinality||(e.Cardinality={})).multiple="multiple",i.ordered="ordered",i.single="single";const s={ON_OUTCOME_CHANGED:"on-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_VARIABLE:"on-register-variable",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 n{constructor({mapping:t,correctResponse:i,cardinality:s,baseType:n,identifier:r}){this._basetype=e.BaseType.string,this._mapping=t,this._correctResponse=i,this._cardinality=s,this._basetype=n,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=n.getCandidateResponse(e)}get qtiVariable(){return this._qtiVariable}}class r{}
2
+ /**
3
+ * @license
4
+ * Copyright 2019 Google LLC
5
+ * SPDX-License-Identifier: BSD-3-Clause
6
+ */const o=window,a=o.ShadowRoot&&(void 0===o.ShadyCSS||o.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),c=new WeakMap;class d{constructor(e,t,i){if(this._$cssResult$=!0,i!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(a&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=c.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&c.set(t,e))}return e}toString(){return this.cssText}}const h=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new d(i,e,l)},p=a?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new d("string"==typeof e?e:e+"",void 0,l))(t)})(e):e
7
+ /**
8
+ * @license
9
+ * Copyright 2017 Google LLC
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ */;var u;const m=window,g=m.trustedTypes,b=g?g.emptyScript:"",f=m.reactiveElementPolyfillSupport,v={toAttribute(e,t){switch(t){case Boolean:e=e?b:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},y=(e,t)=>t!==e&&(t==t||e==e),E={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:y};class _ extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=E){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const n=this[e];this[t]=s,this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||E}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(p(e))}else void 0!==e&&t.push(p(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{a?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const i=document.createElement("style"),s=o.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=t.cssText,e.appendChild(i)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=E){var s;const n=this.constructor._$Ep(e,i);if(void 0!==n&&!0===i.reflect){const r=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:v).toAttribute(t,i.type);this._$El=e,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var i;const s=this.constructor,n=s._$Ev.get(e);if(void 0!==n&&this._$El!==n){const e=s.getPropertyOptions(n),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(i=e.converter)||void 0===i?void 0:i.fromAttribute)?e.converter:v;this._$El=n,this[n]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,i){let s=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||y)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}
12
+ /**
13
+ * @license
14
+ * Copyright 2017 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ var C;_.finalized=!0,_.elementProperties=new Map,_.elementStyles=[],_.shadowRootOptions={mode:"open"},null==f||f({ReactiveElement:_}),(null!==(u=m.reactiveElementVersions)&&void 0!==u?u:m.reactiveElementVersions=[]).push("1.4.2");const A=window,S=A.trustedTypes,x=S?S.createPolicy("lit-html",{createHTML:e=>e}):void 0,q=`lit$${(Math.random()+"").slice(9)}$`,$="?"+q,O=`<${$}>`,k=document,R=(e="")=>k.createComment(e),w=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,N=/-->/g,M=/>/g,H=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),L=/'/g,P=/"/g,Q=/^(?:script|style|textarea|title)$/i,U=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),j=Symbol.for("lit-noChange"),B=Symbol.for("lit-nothing"),D=new WeakMap,F=k.createTreeWalker(k,129,null,!1),G=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":"",o=I;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,l=o.exec(i),null!==l);)d=o.lastIndex,o===I?"!--"===l[1]?o=N:void 0!==l[1]?o=M:void 0!==l[2]?(Q.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=H):void 0!==l[3]&&(o=H):o===H?">"===l[0]?(o=null!=n?n:I,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?H:'"'===l[3]?P:L):o===P||o===L?o=H:o===N||o===M?o=I:(o=H,n=void 0);const h=o===H&&e[t+1].startsWith("/>")?" ":"";r+=o===I?i+O:c>=0?(s.push(a),i.slice(0,c)+"$lit$"+i.slice(c)+q+h):i+q+(-2===c?(s.push(void 0),t):h)}const a=r+(e[i]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==x?x.createHTML(a):a,s]};class V{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,c]=G(e,t);if(this.el=V.createElement(l,i),F.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=F.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes()){const e=[];for(const t of s.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(q)){const i=c[r++];if(e.push(t),void 0!==i){const e=s.getAttribute(i.toLowerCase()+"$lit$").split(q),t=/([.?@])?(.*)/.exec(i);a.push({type:1,index:n,name:t[2],strings:e,ctor:"."===t[1]?X:"?"===t[1]?Z:"@"===t[1]?ee:Y})}else a.push({type:6,index:n})}for(const t of e)s.removeAttribute(t)}if(Q.test(s.tagName)){const e=s.textContent.split(q),t=e.length-1;if(t>0){s.textContent=S?S.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],R()),F.nextNode(),a.push({type:2,index:++n});s.append(e[t],R())}}}else if(8===s.nodeType)if(s.data===$)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(q,e+1));)a.push({type:7,index:n}),e+=q.length-1}n++}}static createElement(e,t){const i=k.createElement("template");return i.innerHTML=e,i}}function z(e,t,i=e,s){var n,r,o,a;if(t===j)return t;let l=void 0!==s?null===(n=i._$Co)||void 0===n?void 0:n[s]:i._$Cl;const c=w(t)?void 0:t._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(r=null==l?void 0:l._$AO)||void 0===r||r.call(l,!1),void 0===c?l=void 0:(l=new c(e),l._$AT(e,i,s)),void 0!==s?(null!==(o=(a=i)._$Co)&&void 0!==o?o:a._$Co=[])[s]=l:i._$Cl=l),void 0!==l&&(t=z(e,l._$AS(e,t.values),l,s)),t}class W{constructor(e,t){this.u=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(e){var t;const{el:{content:i},parts:s}=this._$AD,n=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:k).importNode(i,!0);F.currentNode=n;let r=F.nextNode(),o=0,a=0,l=s[0];for(;void 0!==l;){if(o===l.index){let t;2===l.type?t=new K(r,r.nextSibling,this,e):1===l.type?t=new l.ctor(r,l.name,l.strings,this,e):6===l.type&&(t=new te(r,this,e)),this.u.push(t),l=s[++a]}o!==(null==l?void 0:l.index)&&(r=F.nextNode(),o++)}return n}p(e){let t=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class K{constructor(e,t,i,s){var n;this.type=2,this._$AH=B,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cm=null===(n=null==s?void 0:s.isConnected)||void 0===n||n}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cm}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=z(this,e,t),w(e)?e===B||null==e||""===e?(this._$AH!==B&&this._$AR(),this._$AH=B):e!==this._$AH&&e!==j&&this.g(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>T(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this.g(e)}O(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}g(e){this._$AH!==B&&w(this._$AH)?this._$AA.nextSibling.data=e:this.T(k.createTextNode(e)),this._$AH=e}$(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=V.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.p(i);else{const e=new W(n,this),t=e.v(this.options);e.p(i),this.T(t),this._$AH=e}}_$AC(e){let t=D.get(e.strings);return void 0===t&&D.set(e.strings,t=new V(e)),t}k(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new K(this.O(R()),this.O(R()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cm=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class Y{constructor(e,t,i,s,n){this.type=1,this._$AH=B,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=B}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=z(this,e,t,0),r=!w(e)||e!==this._$AH&&e!==j,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=z(this,s[i+o],t,o),a===j&&(a=this._$AH[o]),r||(r=!w(a)||a!==this._$AH[o]),a===B?e=B:e!==B&&(e+=(null!=a?a:"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===B?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class X extends Y{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===B?void 0:e}}const J=S?S.emptyScript:"";class Z extends Y{constructor(){super(...arguments),this.type=4}j(e){e&&e!==B?this.element.setAttribute(this.name,J):this.element.removeAttribute(this.name)}}class ee extends Y{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=z(this,e,t,0))&&void 0!==i?i:B)===j)return;const s=this._$AH,n=e===B&&s!==B||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,r=e!==B&&(s===B||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class te{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){z(this,e)}}const ie=A.litHtmlPolyfillSupport;null==ie||ie(V,K),(null!==(C=A.litHtmlVersions)&&void 0!==C?C:A.litHtmlVersions=[]).push("2.4.0");const se=(e,t,i)=>{var s,n;const r=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:t;let o=r._$litPart$;if(void 0===o){const e=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:null;r._$litPart$=o=new K(t.insertBefore(R(),e),e,void 0,null!=i?i:{})}return o._$AI(e),o
18
+ /**
19
+ * @license
20
+ * Copyright 2017 Google LLC
21
+ * SPDX-License-Identifier: BSD-3-Clause
22
+ */};var ne,re;class oe extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const i=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=i.firstChild),i}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=se(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return j}}oe.finalized=!0,oe._$litElement$=!0,null===(ne=globalThis.litElementHydrateSupport)||void 0===ne||ne.call(globalThis,{LitElement:oe});const ae=globalThis.litElementPolyfillSupport;null==ae||ae({LitElement:oe}),(null!==(re=globalThis.litElementVersions)&&void 0!==re?re:globalThis.litElementVersions=[]).push("3.2.2");class le extends oe{emit(e,t){const i=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(i),i}err(e){throw e}}class ce extends le{constructor(){super(),this.variables=[],this.feedbackElements=[],this.interactionElements=[],this.identifier="",this.addEventListener(s.ON_REGISTER_VARIABLE,this._registerVariable),this.addEventListener(s.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.addEventListener(s.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.addEventListener(s.ON_OUTCOME_CHANGED,this.outcomeChanged),this.addEventListener(s.ON_INTERACTION_RESPONSE,this.interactionResponse)}static get properties(){return{title:{type:String},identifier:{type:String},disabled:{type:Boolean},readonly:{type:Boolean}}}render(){return U`<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(s.ON_REGISTER_VARIABLE,this._registerVariable),this.removeEventListener(s.ON_REGISTER_FEEDBACK,this.registerFeedbackElement),this.removeEventListener(s.ON_REGISTER_INTERACTION,this.registerInteractionElement),this.removeEventListener(s.ON_OUTCOME_CHANGED,this.outcomeChanged),this.removeEventListener(s.ON_INTERACTION_RESPONSE,this.interactionResponse)}_registerVariable(e){this.variables.push(e.detail)}showCorrectResponse(){const e=this.variables.filter((e=>e.correctResponse)),t={item:this.identifier,interactions:e.map((e=>({responseIdentifier:e.identifier,responses:{base:{identifier:e.correctResponse}}})))};this.responses=t}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)),i=this.getResponse(e.responseIdentifier);i&&(i.qtiVariable=e.responses);const s=n.getCandidateResponse(e.responses);t.response=s}))}}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 n)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 r?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(s.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 i=this.getOutcome(e);i?(i.value=t,this.dispatchEvent(new CustomEvent(s.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",ce);class de extends oe{constructor(){super()}connectedCallback(){super.connectedCallback();const e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.media="screen",i.href=t,e.appendChild(i),this.styleLink=i}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")}}}function he(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o}function pe(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function ue(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{l(s.next(e))}catch(e){r(e)}}function a(e){try{l(s.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))}
23
+ /**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */customElements.define("qti-stylesheet",de);const me=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:i,elements:s}=t;return{kind:i,elements:s,finisher(t){customElements.define(e,t)}}})(e,t)
28
+ /**
29
+ * @license
30
+ * Copyright 2017 Google LLC
31
+ * SPDX-License-Identifier: BSD-3-Clause
32
+ */,ge=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function be(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):ge(e,t)
33
+ /**
34
+ * @license
35
+ * Copyright 2017 Google LLC
36
+ * SPDX-License-Identifier: BSD-3-Clause
37
+ */}function fe(e){return be({...e,state:!0})}
38
+ /**
39
+ * @license
40
+ * Copyright 2017 Google LLC
41
+ * SPDX-License-Identifier: BSD-3-Clause
42
+ */
43
+ /**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */
48
+ function ve(e,t){return(({finisher:e,descriptor:t})=>(i,s)=>{var n;if(void 0===s){const s=null!==(n=i.originalKey)&&void 0!==n?n:i.key,r=null!=t?{kind:"method",placement:"prototype",key:s,descriptor:t(i.key)}:{...i,key:s};return null!=e&&(r.finisher=function(t){e(t,s)}),r}{const n=i.constructor;void 0!==t&&Object.defineProperty(i,s,t(s)),null==e||e(n,s)}})({descriptor:i=>{const s={get(){var t,i;return null!==(i=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(e))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(t){const t="symbol"==typeof i?Symbol():"__"+i;s.get=function(){var i,s;return void 0===this[t]&&(this[t]=null!==(s=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(e))&&void 0!==s?s:null),this[t]}}return s}})}
49
+ /**
50
+ * @license
51
+ * Copyright 2021 Google LLC
52
+ * SPDX-License-Identifier: BSD-3-Clause
53
+ */var ye;null===(ye=window.HTMLSlotElement)||void 0===ye||ye.prototype.assignedElements,e.QtiItemBody=class extends oe{render(){return U`
54
+ <slot name="qti-rubric-block"></slot>
55
+ <slot></slot>`}},e.QtiItemBody.styles=h`
56
+ :host {
57
+ display: block;
58
+ }
59
+ `,e.QtiItemBody=he([me("qti-item-body")],e.QtiItemBody);class Ee extends oe{render(){return U` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}}customElements.define("qti-prompt",Ee);
60
+ /**
61
+ * @license
62
+ * Copyright 2020 Google LLC
63
+ * SPDX-License-Identifier: BSD-3-Clause
64
+ */
65
+ const _e=Symbol.for(""),Ce=e=>{if((null==e?void 0:e.r)===_e)return null==e?void 0:e._$litStatic$},Ae=new Map,Se=(e=>(t,...i)=>{const s=i.length;let n,r;const o=[],a=[];let l,c=0,d=!1;for(;c<s;){for(l=t[c];c<s&&void 0!==(r=i[c],n=Ce(r));)l+=n+t[++c],d=!0;a.push(r),o.push(l),c++}if(c===s&&o.push(t[s]),d){const e=o.join("$$lit$$");void 0===(t=Ae.get(e))&&(o.raw=o,Ae.set(e,t=o)),i=a}return e(t,...i)})(U);function xe(e,t){const i=Object.assign({waitUntilFirstUpdate:!1},t);return(t,s)=>{const{update:n}=t;if(e in t){const r=e;t.update=function(e){if(e.has(r)){const t=e.get(r),n=this[r];t!==n&&(i.waitUntilFirstUpdate&&!this.hasUpdated||this[s](t,n))}n.call(this,e)}}}}const qe=32;e.QtiChoice=class extends le{constructor(){super(...arguments),this.tabindex=0,this.disabled=!1,this.readonly=!1,this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.emit(s.ON_REGISTER_CHOICE)}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.emit(s.ON_LOOSE_CHOICE)}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){e.altKey||e.keyCode===qe&&(e.preventDefault(),this._toggleChecked())}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.emit(s.ON_CHOICE_ELEMENT_SELECTED,{detail:{identifier:this.identifier,checked:this.checked}}))}render(){return Se` <slot></slot> `}},he([be({reflect:!0}),pe("design:type",String)],e.QtiChoice.prototype,"identifier",void 0),he([be({type:Number,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"tabindex",void 0),he([be({type:Boolean,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"disabled",void 0),he([be({type:Boolean,reflect:!0}),pe("design:type",Object)],e.QtiChoice.prototype,"readonly",void 0),he([be({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:e=>`${e}`}}),pe("design:type",Object)],e.QtiChoice.prototype,"checked",void 0),he([xe("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],e.QtiChoice.prototype,"handleDisabledChange",null),e.QtiChoice=he([me("qti-choice")],e.QtiChoice);class $e extends oe{render(){return U``}}customElements.define("qti-variabledeclaration",$e);class Oe extends $e{connectedCallback(){super.connectedCallback();const t=new n({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||e.Cardinality.single,mapping:this.mapping});this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}get correctResponse(){let e;const t=this.querySelector("qti-correct-response");if(t){const i=t.querySelectorAll("qti-value");if(1===i.length)e=i[0].textContent,i[0].remove();else{e=[];for(let t=0;t<i.length;t++)e.push(i[t].textContent),i[t].remove()}}return e}get mapping(){const e=this.querySelector("qti-mapping");if(e){const t=new Map,i=e.querySelectorAll("qti-map-entry");for(let e=0;e<i.length;e++){const s=i[e],n=s.getAttribute("map-key"),r=s.getAttribute("mapped-value");t.set(n,r?parseFloat(r):null)}return t}return null}}he([be({type:String,attribute:"base-type"}),pe("design:type",String)],Oe.prototype,"baseType",void 0),he([be({type:String,attribute:"identifier"}),pe("design:type",String)],Oe.prototype,"identifier",void 0),he([be({type:String,attribute:"cardinality"}),pe("design:type",String)],Oe.prototype,"cardinality",void 0),customElements.define("qti-response-declaration",Oe);class ke extends $e{static get observedAttributes(){return["identifier","cardinality","base-type"]}connectedCallback(){super.connectedCallback();const e=this.getAttribute("identifier"),t=new r;t.identifier=e,this.dispatchEvent(new CustomEvent(s.ON_REGISTER_VARIABLE,{bubbles:!0,composed:!0,detail:t}))}}customElements.define("qti-outcome-declaration",ke),e.QtiCompanionMaterialsInfo=class extends le{},e.QtiCompanionMaterialsInfo=he([me("qti-companion-materials-info")],e.QtiCompanionMaterialsInfo);
66
+ /**
67
+ * @license
68
+ * Copyright 2021 Google LLC
69
+ * SPDX-License-Identifier: BSD-3-Clause
70
+ */
71
+ class Re extends Event{constructor(e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.callback=t,this.subscribe=i}}
72
+ /**
73
+ * @license
74
+ * Copyright 2021 Google LLC
75
+ * SPDX-License-Identifier: BSD-3-Clause
76
+ */
77
+ /**
78
+ * @license
79
+ * Copyright 2021 Google LLC
80
+ * SPDX-License-Identifier: BSD-3-Clause
81
+ */
82
+ class we{constructor(e,t,i,s=!1){this.host=e,this.context=t,this.callback=i,this.subscribe=s,this.provided=!1,this.value=void 0,this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Re(this.context,((e,t)=>{this.unsubscribe&&(this.unsubscribe!==t&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=e,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(e,t)),this.unsubscribe=t}),this.subscribe))}}
83
+ /**
84
+ * @license
85
+ * Copyright 2021 Google LLC
86
+ * SPDX-License-Identifier: BSD-3-Clause
87
+ */class Te{constructor(e){this.callbacks=new Map,this.updateObservers=()=>{for(const[e,t]of this.callbacks)e(this.t,t)},void 0!==e&&(this.value=e)}get value(){return this.t}set value(e){this.setValue(e)}setValue(e,t=!1){const i=t||!Object.is(e,this.t);this.t=e,i&&this.updateObservers()}addCallback(e,t){t&&(this.callbacks.has(e)||this.callbacks.set(e,(()=>{this.callbacks.delete(e)}))),e(this.value)}clearCallbacks(){this.callbacks.clear()}}
88
+ /**
89
+ * @license
90
+ * Copyright 2021 Google LLC
91
+ * SPDX-License-Identifier: BSD-3-Clause
92
+ */class Ie extends Event{constructor(e){super("context-provider",{bubbles:!0,composed:!0}),this.context=e}}class Ne extends Te{constructor(e,t,i){super(i),this.host=e,this.context=t,this.onContextRequest=e=>{e.context===this.context&&e.composedPath()[0]!==this.host&&(e.stopPropagation(),this.addCallback(e.callback,e.subscribe))},this.host.addController(this),this.attachListeners()}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest)}hostConnected(){this.host.dispatchEvent(new Ie(this.context))}}const Me="logger";e.qtiRubricBlock=class extends le{constructor(){super(...arguments),this.logger=new we(this,Me,(e=>this.style.display=this.view===e.view?"block":"none"),!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","")}}))}render(){return U`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}},e.qtiRubricBlock.styles=h`
93
+ :host {
94
+ display: block;
95
+ }
96
+ `,he([be({type:String}),pe("design:type",Object)],e.qtiRubricBlock.prototype,"id",void 0),he([be({type:String}),pe("design:type",String)],e.qtiRubricBlock.prototype,"use",void 0),he([be({type:String}),pe("design:type",String)],e.qtiRubricBlock.prototype,"view",void 0),he([be({type:String,attribute:"class"}),pe("design:type",Object)],e.qtiRubricBlock.prototype,"classNames",void 0),he([xe("classNames",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],e.qtiRubricBlock.prototype,"handleclassNamesChange",null),e.qtiRubricBlock=he([me("qti-rubric-block")],e.qtiRubricBlock),e.qtiContentBody=class extends le{render(){return U`<slot></slot>`}},e.qtiContentBody=he([me("qti-content-body")],e.qtiContentBody);class He extends oe{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(s.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 Le extends He{constructor(){super(...arguments),this.render=()=>U` <slot class="${this.showStatus}"></slot> `}}Le.styles=h`
97
+ .on {
98
+ display: inline-block;
99
+ }
100
+ .off {
101
+ display: none;
102
+ }
103
+ `,customElements.define("qti-feedback-inline",Le);class Pe extends He{render(){return U`
104
+ <style>
105
+ .on {
106
+ display: inline-block;
107
+ }
108
+ .off {
109
+ display: none;
110
+ }
111
+ </style>
112
+ <div class="feedback ${this.showStatus}">
113
+ <slot></slot>
114
+ </div>
115
+ `}}customElements.define("qti-modal-feedback",Pe);
116
+ /**
117
+ * @license
118
+ * Copyright 2018 Google LLC
119
+ * SPDX-License-Identifier: BSD-3-Clause
120
+ */
121
+ const Qe=e=>null!=e?e:B;class Ue extends le{constructor(){super(...arguments),this.responseIdentifier="",this.disabled=!1,this.readonly=!1}connectedCallback(){super.connectedCallback(),this.emit(s.ON_REGISTER_INTERACTION)}saveResponse(e){this.emit(s.ON_INTERACTION_RESPONSE,{detail:{responseIdentifier:this.responseIdentifier,responses:e}})}}he([be({attribute:"response-identifier"}),pe("design:type",Object)],Ue.prototype,"responseIdentifier",void 0),he([be({reflect:!0,type:Boolean}),pe("design:type",Object)],Ue.prototype,"disabled",void 0),he([be({reflect:!0,type:Boolean}),pe("design:type",Object)],Ue.prototype,"readonly",void 0);const je=h`
122
+ /***
123
+ The new CSS reset - version 1.4.9 (last updated 11.2.2022)
124
+ GitHub page: https://github.com/elad2412/the-new-css-reset
125
+ ***/
126
+
127
+ /*
128
+ Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
129
+ - The "symbol *" part is to solve Firefox SVG sprite bug
130
+ */
131
+ *:where(:not(iframe, canvas, img, svg, video, object):not(svg *, symbol *)) {
132
+ all: unset;
133
+ display: revert;
134
+ }
135
+
136
+ /* Preferred box-sizing value */
137
+ *,
138
+ *::before,
139
+ *::after {
140
+ box-sizing: border-box;
141
+ }
142
+
143
+ /* Reapply the pointer cursor for anchor tags */
144
+ a,
145
+ button {
146
+ cursor: revert;
147
+ }
148
+
149
+ /* Remove list styles (bullets/numbers) */
150
+ ol,
151
+ ul,
152
+ menu {
153
+ list-style: none;
154
+ }
155
+
156
+ /* For images to not be able to exceed their container */
157
+ img {
158
+ max-width: 100%;
159
+ }
160
+
161
+ /* removes spacing between cells in tables */
162
+ table {
163
+ border-collapse: collapse;
164
+ }
165
+
166
+ /* revert the 'white-space' property for textarea elements on Safari */
167
+ textarea {
168
+ white-space: revert;
169
+ }
170
+
171
+ /* minimum style to allow to style meter element */
172
+ meter {
173
+ -webkit-appearance: revert;
174
+ appearance: revert;
175
+ }
176
+
177
+ /* reset default text opacity of input placeholder */
178
+ ::placeholder {
179
+ all: unset;
180
+ }
181
+
182
+ /* fix the feature of 'hidden' attribute.
183
+ display:revert; revert to element instead of attribute */
184
+ :where([hidden]) {
185
+ display: none;
186
+ }
187
+
188
+ /* revert for bug in Chromium browsers
189
+ - fix for the content editable attribute will work properly. */
190
+ :where([contenteditable]) {
191
+ -moz-user-modify: read-write;
192
+ -webkit-user-modify: read-write;
193
+ overflow-wrap: break-word;
194
+ -webkit-line-break: after-white-space;
195
+ }
196
+
197
+ /* apply back the draggable feature - exist only in Chromium and Safari */
198
+ :where([draggable='true']) {
199
+ -webkit-user-drag: element;
200
+ }
201
+ `;class Be extends Ue{constructor(){super(),this.value=""}static get properties(){return Object.assign(Object.assign({},Ue.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[je,h`
202
+ /* PK: display host as block, else design will be collapsed */
203
+ :host {
204
+ display: inline-block;
205
+ }
206
+ input {
207
+ padding: var(--qti-padding, 0.5rem);
208
+ }
209
+ `]}render(){return U`
210
+ <input
211
+ spellcheck="false"
212
+ autocomplete="off"
213
+ @keydown="${e=>e.stopImmediatePropagation()}"
214
+ @keyup="${this.textChanged}"
215
+ @change="${this.textChanged}"
216
+ type="text"
217
+ placeholder="${Qe(this.placeholderText?this.placeholderText:void 0)}"
218
+ .value="${this.value}"
219
+ size="${Qe(this.expectedLength?this.expectedLength:void 0)}"
220
+ pattern="${Qe(this.patternMask?this.patternMask:void 0)}"
221
+ ?disabled="${this.disabled}"
222
+ ?readonly="${this.readonly}"
223
+ />`}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")}}Be.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",Be);
224
+ /**
225
+ * @license
226
+ * Copyright 2020 Google LLC
227
+ * SPDX-License-Identifier: BSD-3-Clause
228
+ */
229
+ const De=2;
230
+ /**
231
+ * @license
232
+ * Copyright 2017 Google LLC
233
+ * SPDX-License-Identifier: BSD-3-Clause
234
+ */class Fe{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
235
+ /**
236
+ * @license
237
+ * Copyright 2017 Google LLC
238
+ * SPDX-License-Identifier: BSD-3-Clause
239
+ */const Ge=(e,t)=>{var i,s;const n=e._$AN;if(void 0===n)return!1;for(const e of n)null===(s=(i=e)._$AO)||void 0===s||s.call(i,t,!1),Ge(e,t);return!0},Ve=e=>{let t,i;do{if(void 0===(t=e._$AM))break;i=t._$AN,i.delete(e),e=t}while(0===(null==i?void 0:i.size))},ze=e=>{for(let t;t=e._$AM;e=t){let i=t._$AN;if(void 0===i)t._$AN=i=new Set;else if(i.has(e))break;i.add(e),Ye(t)}};function We(e){void 0!==this._$AN?(Ve(this),this._$AM=e,ze(this)):this._$AM=e}function Ke(e,t=!1,i=0){const s=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(s))for(let e=i;e<s.length;e++)Ge(s[e],!1),Ve(s[e]);else null!=s&&(Ge(s,!1),Ve(s));else Ge(this,e)}const Ye=e=>{var t,i,s,n;e.type==De&&(null!==(t=(s=e)._$AP)&&void 0!==t||(s._$AP=Ke),null!==(i=(n=e)._$AQ)&&void 0!==i||(n._$AQ=We))};class Xe extends Fe{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),ze(this),this.isConnected=e._$AU}_$AO(e,t=!0){var i,s;e!==this.isConnected&&(this.isConnected=e,e?null===(i=this.reconnected)||void 0===i||i.call(this):null===(s=this.disconnected)||void 0===s||s.call(this)),t&&(Ge(this,e),Ve(this))}setValue(e){if((e=>void 0===e.strings)(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}
240
+ /**
241
+ * @license
242
+ * Copyright 2020 Google LLC
243
+ * SPDX-License-Identifier: BSD-3-Clause
244
+ */class Je{}const Ze=new WeakMap,et=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends Xe{render(e){return B}update(e,[t]){var i;const s=t!==this.Y;return s&&void 0!==this.Y&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.Y=t,this.dt=null===(i=e.options)||void 0===i?void 0:i.host,this.rt(this.ct=e.element)),B}rt(e){var t;if("function"==typeof this.Y){const i=null!==(t=this.dt)&&void 0!==t?t:globalThis;let s=Ze.get(i);void 0===s&&(s=new WeakMap,Ze.set(i,s)),void 0!==s.get(this.Y)&&this.Y.call(this.dt,void 0),s.set(this.Y,e),void 0!==e&&this.Y.call(this.dt,e)}else this.Y.value=e}get lt(){var e,t,i;return"function"==typeof this.Y?null===(t=Ze.get(null!==(e=this.dt)&&void 0!==e?e:globalThis))||void 0===t?void 0:t.get(this.Y):null===(i=this.Y)||void 0===i?void 0:i.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});class tt extends Ue{constructor(){super(...arguments),this.textareaRef=new Je,this.value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach((e=>{if(e.startsWith("qti-height-lines")){const t=e.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(t))}}))}set response(e){this.value=void 0!==e?e:""}validate(){return""!==this.value}static get styles(){return[je,h`
245
+ /* PK: display host as block, else design will be collapsed */
246
+ :host {
247
+ display: block;
248
+ }
249
+ textarea {
250
+ padding: var(--qti-padding, 0.5rem);
251
+ width: 100%;
252
+ height: 100%;
253
+ }
254
+ `]}render(){return U`<textarea
255
+ ${et(this.textareaRef)}
256
+ spellcheck="false"
257
+ autocomplete="off"
258
+ @keydown="${e=>e.stopImmediatePropagation()}"
259
+ @keyup="${this.textChanged}"
260
+ @change="${this.textChanged}"
261
+ placeholder="${Qe(this.placeholderText?this.placeholderText:void 0)}"
262
+ maxlength="${Qe(this.expectedLength?this.expectedLength:void 0)}"
263
+ pattern="${Qe(this.patternMask?this.patternMask:void 0)}"
264
+ ?disabled="${this.disabled}"
265
+ ?readonly="${this.readonly}"
266
+ .value=${this.value}
267
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.setEmptyAttribute(t.value),this.value=t.value,this.saveResponse({base:{string:t.value}})}reset(){this.value=""}setEmptyAttribute(e){this.setAttribute("empty",""===e?"true":"false")}}tt.rowHeightClass=["","qti-height-lines-3","qti-height-lines-6","qti-height-lines-15"],he([be({type:Number,attribute:"expected-length"}),pe("design:type",Object)],tt.prototype,"expectedLength",void 0),he([be({type:String,attribute:"pattern-mask"}),pe("design:type",Object)],tt.prototype,"patternMask",void 0),he([be({type:String,attribute:"placeholder-text"}),pe("design:type",Object)],tt.prototype,"placeholderText",void 0),he([be({type:String}),pe("design:type",Object)],tt.prototype,"value",void 0),he([be({type:String,attribute:"class"}),pe("design:type",Object)],tt.prototype,"classNames",void 0),he([xe("classNames",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],tt.prototype,"handleclassNamesChange",null),customElements.define("qti-extended-text-interaction",tt),e.QtiHottext=class extends e.QtiChoice{},e.QtiHottext=he([me("qti-hottext")],e.QtiHottext);class it extends Ue{constructor(){super(),this._choiceElements=[],this._minChoices=0,this._maxChoices=1,this._handleDisabledChange=(e,t)=>this._choiceElements.forEach((e=>e.disabled=t)),this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach((e=>e.readonly=t)),this._handleMaxChoicesChange=()=>this._determineInputType(),this.addEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement),this.addEventListener(s.ON_LOOSE_CHOICE,this._looseChoiceElement)}reset(){this._choiceElements.forEach((e=>{e.reset()}))}validate(){return this._choiceElements.reduce(((e,t)=>e+(!0===t.checked?1:0)),0)>=this._minChoices}set response(e){this._choiceElements.forEach((e=>{e.checked=!1}));(Array.isArray(e)?e:[e]).forEach((e=>{const t=this.querySelector("[identifier='"+e+"']");t&&(t.checked=!0)}))}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this._choiceElementSelectedHandler),this.removeEventListener(s.ON_REGISTER_CHOICE,this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();const t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter((e=>e!==t))}_determineInputType(){this._choiceElements.forEach((e=>{this._setInputType(e)}))}_setInputType(e){1===this._maxChoices?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){1===this._maxChoices&&this._choiceElements.filter((t=>t.identifier!==e.detail.identifier)).forEach((e=>{e.checked=!1})),this._choiceElementSelected()}_choiceElementSelected(){const e=this._choiceElements.filter((e=>1==e.checked)).map((e=>e.identifier));let t;this._maxChoices>1&&(this._maxChoices===e.length?this._choiceElements.forEach((e=>e.disabled=!(1==e.checked))):this._choiceElements.forEach((e=>e.disabled=!1))),t=1===this._maxChoices?{base:{identifier:e.length>0?e[0]:""}}:{list:{identifier:e}},this.saveResponse(t)}}he([be({type:Number,attribute:"min-choices"}),pe("design:type",Number)],it.prototype,"_minChoices",void 0),he([be({type:Number,attribute:"max-choices"}),pe("design:type",Number)],it.prototype,"_maxChoices",void 0),he([xe("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],it.prototype,"_handleDisabledChange",void 0),he([xe("readonly",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],it.prototype,"_handleReadonlyChange",void 0),he([xe("_maxChoices",{waitUntilFirstUpdate:!0}),pe("design:type",Object)],it.prototype,"_handleMaxChoicesChange",void 0);class st extends it{constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}}customElements.define("qti-hottext-interaction",st);class nt extends Ue{constructor(){super(),this.options=[],this.addEventListener(s.ON_DROPDOWN_SELECTED,this.choiceSelected);const e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map((e=>({textContent:e.innerHTML,value:e.getAttribute("identifier"),selected:!1})))]}static get properties(){return Object.assign(Object.assign({},Ue.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[je,h`
268
+ :host {
269
+ display: inline-block;
270
+ }
271
+ select {
272
+ width:100%;
273
+ padding: var(--qti-padding-y) var(--qti-padding-x);
274
+ padding-right: calc(var(--qti-padding-x) + 1ch)
275
+ }
276
+ `]}render(){return U`
277
+ <select
278
+ @change="${this.choiceSelected}"
279
+ ?disabled="${this.disabled}"
280
+ ?readonly="${this.readonly}"
281
+ >
282
+ ${this.options.map((e=>U`
283
+ <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
284
+ `))}
285
+ </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}})}}nt.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",nt);class rt extends it{constructor(){super(...arguments),this._shuffle=!1,this.render=()=>U`
286
+ <slot name="prompt"></slot>
287
+ <slot></slot>`}}rt.layoutClass=["","qti-choices-stacking-2","qti-choices-stacking-3","qti-choices-stacking-4","qti-orientation-vertical","qti-orientation-horizontal"],rt.presentationClass=["","qti-input-control-hidden"],he([be({attribute:"orientation"}),pe("design:type",String)],rt.prototype,"_orientation",void 0),he([be({attribute:"shuffle",type:Boolean}),pe("design:type",Boolean)],rt.prototype,"_shuffle",void 0),customElements.define("qti-choice-interaction",rt),e.QtiSimpleChoice=class extends e.QtiChoice{},e.QtiSimpleChoice=he([me("qti-simple-choice")],e.QtiSimpleChoice);class ot extends oe{render(){return U`<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",ot);class at extends oe{render(){return U``}process(){throw new Error("Not implemented")}}customElements.define("qti-rule",at);class lt extends at{render(){return U`<slot></slot>`}process(){const e=[...this.children];for(let t=0;t<e.length;t++){const i=e[t];if(i.calculate())return void i.process()}}}customElements.define("qti-response-condition",lt);class ct extends oe{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return U`
288
+ <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",ct);class dt extends ct{render(){return U`${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",dt);class ht extends dt{render(){return U`${super.render()}`}}customElements.define("qti-response-else-if",ht);class pt extends le{render(){return U``}calculate(){throw new Error("Not implemented")}}customElements.define("qti-expression",pt);class ut extends pt{calculate(){const e=this.getAttribute("identifier"),t=this.closest("qti-assessment-item").getResponse(e);if(!t)return this.err(`Response ${e} can not be found`),null;const i=t.mapping,s=t.value;let n=0;if(Array.isArray(s)){for(let e=0;e<s.length;e++)n+=mt(i,s[e],t.baseType);return n}return n+=mt(i,s,t.baseType),n}}function mt(e,t,i){let s=0;for(const n of e.entries()){const{entryTyped:e,valueTyped:r}=gt(i,n,t);e===r&&(s+=n[1])}return s}function gt(t,i,s){let n,r;switch(t){case e.BaseType.string:case e.BaseType.identifier:case e.BaseType.directedPair:n=""+i[0],r=""+s;break;case e.BaseType.float:n=parseFloat(i[0].replace(",",".")),r=parseFloat(s.replace(",","."));break;default:console.warn("no base-type identifier")}return{entryTyped:n,valueTyped:r}}customElements.define("qti-map-response",ut);class bt extends at{process(){const e=this.getAttribute("identifier"),t=this.firstElementChild,i=t?t.calculate():null;this.closest("qti-assessment-item").setOutcomeValue(e,i)}}customElements.define("qti-set-outcome-value",bt);class ft extends pt{render(){return U``}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",ft);class vt extends pt{render(){return U``}calculate(){const e=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(e)}}customElements.define("qti-variable",vt);class yt extends pt{calculate(){const e=this.firstElementChild.calculate(),t=this.lastElementChild.calculate();let i=!0;return i=e instanceof Array?e.length===t.length&&e.filter(((e,i)=>e===t[i])).length===e.length:e==t,i}}customElements.define("qti-match",yt);class Et extends pt{calculate(){return Et.calculate(this.textContent,this.getAttribute("base-type"))}static calculate(t,i){let s;if(i===e.BaseType.directedPair){const e=t.split(" ");s={destination:e[1],source:e[0]}}else s=t;return s}}customElements.define("qti-base-value",Et);class _t extends pt{calculate(){const e=this.firstElementChild,t=this.lastElementChild;return _t.calculate(e,t)}static calculate(e,t){const i=e.calculate(),s=t.calculate(),n=i.map((e=>e.source+" "+e.destination)),r=s.map((e=>e.source+" "+e.destination)),o=n.filter((e=>r.includes(e)));return o.length>0}}customElements.define("qti-contains",_t);class Ct extends pt{calculate(){return 2===this.children.length?Ct.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",Ct);class At extends pt{calculate(){return Array.from(this.children).map((e=>e.calculate()))}}customElements.define("qti-multiple",At);class St extends pt{render(){return U``}calculate(){return St.calculate(Array.from(this.children))}static calculate(e){return e.every((e=>e.calculate()))}}customElements.define("qti-and",St);class xt extends pt{render(){return U``}calculate(){return xt.calculate(Array.from(this.children))}static calculate(e){return!!e.find((e=>e.calculate()))}}customElements.define("qti-or",xt);class qt extends pt{calculate(){return 1===this.children.length?qt.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",qt);class $t extends le{constructor(){super(...arguments),this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){const t=e.querySelectorAll("properties");let i={};const s=e=>{const t={},i=e.getAttribute("key");if(i){const s=Array.from(e.children),r=s.map((e=>e.getAttribute("key"))),o=r.length>0&&!r.find((e=>!Number.isInteger(+e)));t[i]=o?s.map((e=>n(e))):e.textContent}return t},n=e=>{if(e){let t={};for(const i of e.children)t=Object.assign(Object.assign({},t),s(i));return t}};for(const e of t){return e.getAttribute("key")||(i=Object.assign(Object.assign({},i),n(e))),i}this.err("Can not find qti-custom-interaction config")}register(e){const t="QTI-CUSTOM-INTERACTION"===this.parentElement.tagName?"TAO":"IMS",i="IMS"==t?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),"TAO"==t&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");const s="IMS"==t?{properties:this.dataset}:this.getTAOConfig(this);if("IMS"==t?e.getInstance(i,s,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,s),"TAO"==t){Array.from(this.querySelectorAll("link")).map((e=>e.getAttribute("href"))).forEach((e=>{const t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.media="screen",t.href=e,i.appendChild(t)}))}}connectedCallback(){super.connectedCallback();const e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim);requirejs.config(e)(["require"],(e=>{define("qtiCustomInteractionContext",(()=>({register:e=>{this.register(e)},notifyReady:()=>{}}))),e([this.module],(()=>{}),(e=>{console.log("WAH",e),this._errorMessage=e}))}),(e=>{console.log("BAH",e),this._errorMessage=e}))}render(){return U`<slot></slot>${this._errorMessage&&U`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`}}customElements.define("qti-portable-custom-interaction",$t);const Ot=(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")}))}},kt=(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 i=Array.from(this.querySelectorAll(t));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),i.forEach((e=>{e.setAttribute("dropzone","move"),e.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(e)}));for(const e of i)this.observer=new MutationObserver((t=>{t.forEach((t=>{if("attributes"===t.type){switch(t.attributeName){case"disabled":e.hasAttribute("disabled")?this.removeHandler(e):this.attachHandler(e);break}}}))})),this.observer.observe(e,{attributes:!0})}attachHandler(e){e.addEventListener("dragover",this.dragoverHandler),e.addEventListener("drop",this.dropHandler)}removeHandler(e){e.removeEventListener("dragover",this.dragoverHandler),e.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var e;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),null===(e=this.observer)||void 0===e||e.disconnect())}dragoverHandler(e){e.preventDefault();return e.currentTarget.setAttribute("active",""),e.dataTransfer.dropEffect="move",!1}dropHandler(e){e.preventDefault();const t=e.currentTarget,i=this.querySelector(`[identifier=${e.dataTransfer.getData("text")}`);return t?i.parentElement.getAttribute("identifier")!==t.getAttribute("identifier")&&t.appendChild(i):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}},Rt=(e,t,i)=>class extends e{constructor(){super(...arguments),this.state=new Map,this.animateMe=()=>{this.state.forEach(((e,t)=>{const{left:i,top:s,width:n,height:r}=t.getBoundingClientRect();null==this.state.get(t)&&this.state.set(t,{left:i,top:s,width:n,height:r});const o=this.state.get(t),a=o.left-i,l=o.top-s,c=o.width/n,d=o.height/r;this.state.set(t,{left:i,top:s,width:n,height:r});const{duration:h,easing:p}={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:h,easing:p})}))}}firstUpdated(e){const s=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return ue(this,void 0,void 0,(function*(){if(this.classList.contains("qti-match-tabular"))return;yield this.updateComplete;Array.from(this.querySelectorAll(i)).forEach((e=>{const{left:t,top:i,width:s,height:n}=e.getBoundingClientRect();this.state.set(e,{left:t,top:i,width:s,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}),s.firstUpdated.call(this,e)}))}disconnectedCallback(){this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),this.observer.disconnect())}},wt=(e,t,i)=>{class n extends(Rt(kt(Ot(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,i=this.draggables.get(t),s=i.index<i.parent.children.length?i.index:i.parent.children.length-1,n=i.parent,r=i.parent.children[s];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 U` <slot></slot> `}checkMaxMatchAssociations(){const e=Array.from(this.querySelectorAll(i)),t=e.filter((e=>e.childElementCount>0)).length;if(t>=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 i=e.index<e.parent.children.length?e.index:e.parent.children.length;e.parent.insertBefore(t,e.parent.children[i])})),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,i]=e.split(" ");if(i){const e=this.querySelector(`[identifier=${i}]`),s=this.querySelector(`[identifier=${t}]`);e?s?(e.appendChild(s),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${t}`):console.error(`cannot find droppable with identifier: ${i}`)}})))}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(s.ON_INTERACTION_RESPONSE,{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,responses:e}}))}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent(s.ON_REGISTER_INTERACTION,{bubbles:!0,composed:!0,detail:this}))}}return n},Tt=h`
289
+ .notification {
290
+ position: absolute;
291
+ z-index: 100000;
292
+ top: 0;
293
+ bottom: 0;
294
+ right: 0;
295
+ left: 0;
296
+ /* background: repeating-linear-gradient(45deg, #606cbc00, #606cbc00 10px, #4652980f 10px, #4652980f 20px); */
297
+ }
298
+ .notification:after {
299
+ position: absolute;
300
+ right: 1rem;
301
+ top: 1rem;
302
+ background-color: #222222;
303
+ color: #dddddd;
304
+ font-size: 14px;
305
+ width: fit-content;
306
+ padding: 0.4rem 0.6rem;
307
+ border-radius: 99999px;
308
+ content: 'preview not interactive';
309
+ }
310
+ `;class It extends(wt(le,"qti-simple-associable-choice","drop-list")){render(){return U`
311
+ <slot name="prompt"></slot>
312
+ <slot></slot>`}firstUpdated(e){se(U`
313
+ ${this.childrenMap.length>0&&Array.from(Array(Math.ceil(this.childrenMap.length/2)).keys()).map(((e,t)=>U`<div class="associables-container">
314
+ <drop-list class="associables-gap" identifier="droplist${t}_left"></drop-list>
315
+ <drop-list class="associables-gap" identifier="droplist${t}_right"></drop-list>
316
+ </div>`))}
317
+ `,this),super.firstUpdated(e)}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}}It.styles=[Tt],customElements.define("qti-associate-interaction",It);class Nt extends oe{render(){return U`
318
+ <slot></slot>
319
+ `}}customElements.define("qti-simple-associable-choice",Nt);class Mt extends(wt(oe,"qti-gap-text","qti-gap")){render(){return U`<slot></slot>`}}Mt.styles=[Tt],customElements.define("qti-gap-match-interaction",Mt);class Ht extends HTMLElement{}customElements.define("qti-gap-text",Ht);class Lt extends HTMLElement{}function Pt(e,t,i,s){switch(e){case"circle":{const[e,n,r]=t,o=e/i.width*100,a=n/i.height*100,l=r/i.width*100;s.style.left=o-l+"%",s.style.top=a-l+"%",s.style.width=s.style.height=4*l+"px",s.style.clipPath="circle(50% at 50% 50%)"}break;case"rect":{const[e,n,r,o]=t,a=e/i.width*100,l=n/i.height*100,c=r/i.width*100,d=o/i.height*100;s.style.left=a+"%",s.style.top=l+"%",s.style.width=c-a+"%",s.style.height=d-l+"%"}break;case"poly":{const e=t.reduce(((e,t,i,s)=>{if(i%2==1){const t=e.pop();e[e.length]={x:t,y:s[i]}}else e.push(t);return e}),[]),n=Math.min(...e.map((e=>e.x))),r=Math.max(...e.map((e=>e.x))),o=Math.min(...e.map((e=>e.y))),a=Math.max(...e.map((e=>e.y))),l=n/i.width*100,c=o/i.height*100,d=r/i.width*100,h=a/i.height*100;s.style.left=n/i.width*100+"%",s.style.top=o/i.height*100+"%",s.style.width=d-l+"%",s.style.height=h-c+"%";const p=e.map((e=>({x:(e.x-n)/(r-n)*100,y:(e.y-o)/(a-o)*100}))).map((e=>Math.round(e.x)+"% "+Math.round(e.y)+"%")).join(",");s.style.clipPath=`polygon(${p})`}}}customElements.define("qti-gap",Lt);class Qt extends it{render(){return U`
320
+ <slot name="prompt"></slot>
321
+ <!-- slot for the prompt -->
322
+ <slot></slot>
323
+ <!-- slot for the image and hotspots -->
324
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));Pt(n,r,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Qt.styles=[h`
325
+ slot:not([name='prompt']) {
326
+ position: relative; /* qti-hotspot-choice relative to the slot */
327
+ display: block;
328
+ width: fit-content; /* hotspots not stretching further if image is at max size */
329
+ }
330
+ ::slotted(img) {
331
+ /* image not selectable anymore */
332
+ pointer-events: none;
333
+ user-select: none;
334
+ }
335
+ `],customElements.define("qti-graphic-associate-interaction",Qt);class Ut extends(wt(le,"qti-gap-img","qti-associable-hotspot")){render(){return U` <slot></slot>
336
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(e){const t=e.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map((e=>parseInt(e)));switch(s){case"circle":{const[e,i,s]=n;t.style.left=e-s+"px",t.style.top=i-s+"px",t.style.width=t.style.height=2*s+"px"}break;case"rect":{const[e,i,s,r]=n;t.style.left=e+"px",t.style.top=i+"px",t.style.width=s-e+"px",t.style.height=r-i+"px"}}}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_HOTSPOT,this.positionHotspotOnRegister)}}Ut.styles=h`
337
+ slot[name="qti-gap-img"] {
338
+ display: flex;
339
+ gap: 1rem;
340
+ }
341
+ `,customElements.define("qti-graphic-gap-match-interaction",Ut);class jt extends it{render(){return U`
342
+ <slot name="prompt"></slot>
343
+ <!-- slot for the prompt -->
344
+ <slot></slot>
345
+ <!-- slot for the image and hotspots -->
346
+ `}setHotspotOrder(e){const{identifier:t}=e.detail,i=this._choiceElements.find((e=>e.getAttribute("identifier")===t)),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,null==i.order)return this._choiceElements.filter((e=>e.order>0)).length>=s||(i.order=this._choiceElements.filter((e=>!!e.order)).length+1),void(this.choiceOrdering=!1);this._choiceElements.forEach((e=>(e.order>e.order&&e.order--,e))),i.order=null,this.choiceOrdering=!1}}positionHotspotOnRegister(e){const t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));Pt(n,r,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.addEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_CHOICE_ELEMENT_SELECTED,this.setHotspotOrder),this.removeEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}jt.styles=[h`
347
+ slot:not([name='prompt']) {
348
+ position: relative; /* qti-hotspot-choice relative to the slot */
349
+ display: block;
350
+ width: fit-content; /* hotspots not stretching further if image is at max size */
351
+ }
352
+ ::slotted(img) {
353
+ /* image not selectable anymore */
354
+ pointer-events: none;
355
+ user-select: none;
356
+ }
357
+ `],customElements.define("qti-graphic-order-interaction",jt);class Bt extends it{render(){return U`
358
+ <slot name="prompt"></slot>
359
+ <!-- slot for the prompt -->
360
+ <slot></slot>
361
+ <!-- slot for the image and hotspots -->
362
+ `}positionHotspotOnRegister(e){const t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),r=s.split(",").map((e=>parseInt(e)));Pt(n,r,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(s.ON_REGISTER_CHOICE,this.positionHotspotOnRegister)}}Bt.styles=[h`
363
+ slot:not([name='prompt']) {
364
+ position: relative; /* qti-hotspot-choice relative to the slot */
365
+ display: block;
366
+ width: fit-content; /* hotspots not stretching further if image is at max size */
367
+ }
368
+ ::slotted(img) {
369
+ /* image not selectable anymore */
370
+ pointer-events: none;
371
+ user-select: none;
372
+ }
373
+ `],customElements.define("qti-hotspot-interaction",Bt);class Dt extends e.QtiChoice{}Dt.styles=h`
374
+ :host {
375
+ position: absolute;
376
+ }
377
+ `,he([be({attribute:"aria-ordervalue",type:Number,reflect:!0}),pe("design:type",Number)],Dt.prototype,"order",void 0),customElements.define("qti-hotspot-choice",Dt);class Ft extends(wt(oe,":first-of-type > qti-simple-associable-choice",":last-of-type > qti-simple-associable-choice")){render(){return U`
378
+ <slot name="prompt"></slot>
379
+ <slot></slot>`}}Ft.styles=[Tt],customElements.define("qti-match-interaction",Ft);class Gt extends Ue{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return Object.assign(Object.assign({},Ue.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return U`
380
+ <slot name="prompt"></slot>
381
+ <slot></slot>`}connectedCallback(){super.connectedCallback()}}Gt.styles=[Tt,h``],customElements.define("qti-media-interaction",Gt);class Vt extends(wt(le,"qti-simple-choice","drop-list")){static get properties(){return{_classNames:{type:String,attribute:"class"},_orientation:{type:String,attribute:"orientation"}}}render(){return U` <slot name="prompt"> </slot>
382
+ <div class=${`container ${this._classNames}`}>
383
+ <slot class=${"vertical"===this._orientation?"ver":"hor"}> </slot>
384
+ <div class=${"vertical"===this._orientation?"ver":"hor"}>
385
+ ${this.childrenMap.map(((e,t)=>U`<drop-list identifier="droplist${t}"></drop-list>`))}
386
+ </div>
387
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice"))}}Vt.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],Vt.styles=[Tt,h`
388
+ .hor {
389
+ display: grid;
390
+ gap: var(--qti-gap, 2px);
391
+ grid-auto-flow: column;
392
+ grid-auto-columns: 1fr;
393
+ }
394
+ .ver {
395
+ width:50%;
396
+ display: grid;
397
+ gap: var(--qti-gap, 2px);
398
+ grid-auto-flow: row;
399
+ grid-auto-columns: 1fr;
400
+ }
401
+ .container {
402
+ display: flex;
403
+ gap: var(--qti-gap, 2px);
404
+ }
405
+ .qti-choices-top {
406
+ flex-direction: column;
407
+ }
408
+ .qti-choices-bottom {
409
+ flex-direction: column-reverse;
410
+ }
411
+ .qti-choices-left {
412
+ flex-direction: row;
413
+ }
414
+ .qti-choices-right {
415
+ flex-direction: row-reverse;
416
+ }
417
+ drop-list {
418
+ display: block;
419
+ background: var(--qti-background, #eee);
420
+ padding: var(--qti-padding-x, 0.7rem) var(--qti-padding-y, 0.5rem);
421
+ }
422
+ drop-list:empty::before {
423
+ content: 'drop here';
424
+ color: var(--qti-placeholder-text);
425
+ }
426
+ `],customElements.define("qti-order-interaction",Vt);class zt extends it{constructor(){super()}render(){return U`<slot></slot>
427
+ <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}}zt.styles=[Tt],customElements.define("qti-select-point-interaction",zt);const Wt=37,Kt=38,Yt=39,Xt=40,Jt=33,Zt=34,ei=35,ti=36;class ii extends Ue{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 U`
428
+ <slot name="prompt"></slot>
429
+ <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 i=this.value;switch(e.keyCode){case Wt:case Xt:this._moveSliderTo(i-this.step),t=!0;break;case Yt:case Kt:this._moveSliderTo(i+this.step),t=!0;break;case Zt:this._moveSliderTo(i-this.step),t=!0;break;case Jt:this._moveSliderTo(i+this.step),t=!0;break;case ti:this._moveSliderTo(this.min),t=!0;break;case ei:this._moveSliderTo(this.max),t=!0}t&&(e.preventDefault(),e.stopPropagation())}_onMouseDown(e){const t=e.target,i=this.min,s=this.max,n=e=>{const n=e.pageX-t.offsetLeft,r=i+(s-i)*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=i+(s-i)*o/this.RAIL_WIDTH;this._moveSliderTo(a)}_moveSliderTo(e){const t=this.min,i=this.max;let s=Number(e);s<t&&(s=t),s>i&&(s=i);const n=(s-t)/(i-t)*100;this.style.setProperty("--qti-slider-interaction-aria-valuenow",`${n}%`)}}ii.styles=[Tt,h``],he([be({type:Number,attribute:"lower-bound"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ii.prototype,"min",null),he([be({type:Number,attribute:"upper-bound"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ii.prototype,"max",null),he([be({type:Number,attribute:"step"}),pe("design:type",Number),pe("design:paramtypes",[Number])],ii.prototype,"step",null),customElements.define("qti-slider-interaction",ii);class si extends oe{constructor(){super(...arguments),this.render=()=>U`${this.value}`}levenshtein(e,t){let i;if(0===e.length)return t.length;if(0===t.length)return e.length;e.length>t.length&&(i=e,e=t,t=i);const s=e.length,n=t.length,r=Array(s);let o,a,l;for(o=0;o<=s;o++)r[o]=o;for(o=1;o<=n;o++){for(l=o,a=1;a<=s;a++)i=r[a-1],r[a-1]=l,l=Math.min(i+(t[o-1]!==e[a-1]),l+1,r[a]+1);r[a-1]=l}return l}calculate(){const e=this.firstElementChild,t=this.lastElementChild,i=e.calculate(),s=t.calculate();return this.value=100-this.levenshtein(i.toString().trim(),s.toString().trim())/s.toString().length*100,this.value}}si.properties={value:{}},customElements.define("qti-custom-operator-levenshtein",si);class ni extends oe{render(){return U``}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",ni);class ri extends oe{constructor(){super(...arguments),this.render=()=>U`${this.value}`}calculate(){var e;const t=null===(e=this.firstElementChild.calculate())||void 0===e?void 0:e.toString();return this.value=t?this.parseNumber(t,undefined):"",this.value}parseNumber(e,t=navigator.languages){const i=Intl.NumberFormat(t).format(1.1),s=new RegExp(`[^-+0-9${i.charAt(1)}]`,"g"),n=e.replace(s,"").replace(i.charAt(1),".");return parseFloat(n)}}ri.properties={value:{}},customElements.define("qti-custom-operator-parse-numeric-nl",ri);class oi extends oe{render(){return U``}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",oi);class ai extends oe{render(){return U``}calculate(){return this.firstElementChild.calculate().toString().trim()}}customElements.define("qti-custom-operator-trim",ai);const li=(e,t)=>class extends e{_dispatch(){this.dispatchEvent(new CustomEvent(t,{composed:!0,bubbles:!0,detail:+this.getAttribute("index")}))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._dispatch)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._dispatch)}};customElements.define("qti-test-next",class extends(li(oe,"on-next-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-item",class extends(li(oe,"on-request-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-prev",class extends(li(oe,"on-prev-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-check",class extends(li(oe,"on-check-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-score",class extends(li(oe,"on-score-item")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}}),customElements.define("qti-test-show-correct",class extends(li(oe,"on-show-correct")){constructor(){super(...arguments),this.render=()=>U`<slot></slot>`}});const ci={ON_ITEM_WAS_FINISHED:"onItemWasFinished",ON_NO_RESPONSE_ON_SUBMIT:"onNoResponseOnSubmit",ON_REQUEST_ITEM:"onRequestItem",ON_TEST_FINISHED:"onTestFinished",ON_ITEM_READY:"onItemReady"};var di,hi;e.NavigationMode=void 0,(di=e.NavigationMode||(e.NavigationMode={})).linear="linear",di.nonlinear="nonlinear",e.SubmissionMode=void 0,(hi=e.SubmissionMode||(e.SubmissionMode={})).individual="individual",hi.simultaneous="simultaneous",e.QtiTest=class extends oe{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this._navigationMode=e.NavigationMode.nonlinear,this._submissionMode=e.SubmissionMode.simultaneous,this.items=[],this.itemIndex=0,this.provider=new Ne(this,Me,{log:e=>{console.log(`[my-app] ${e}`)},view:"candidate"})}handleNavigationModeChange(t,i){this.prevButton.style.visibility=i===e.NavigationMode.linear?"hidden":"visible"}handleItemIndexChange(e,t){this.emit(ci.ON_REQUEST_ITEM,{detail:t})}set qtiContext(e){this.provider.value.view=e.view,this.provider.updateObservers()}set itemXML(e){this._itemRef&&this._itemRef.remove(),this.insertAdjacentHTML("afterbegin",e)}set manualOutcomeValue(e){this._itemRef.setOutcomeValue("SCORE",e)}set itemResponse(t){this._itemRef&&(this._itemRef.responses=t,this._navigationMode===e.NavigationMode.linear&&(this._itemRef.style.filter="blur(5px)",this._itemRef.setAttribute("disabled",""),this.dispatchEvent(new CustomEvent(ci.ON_ITEM_WAS_FINISHED))))}_onCheckItem(){return!!this._itemRef.validateResponses()&&(this._itemRef.processResponse(),!0)}_onScoreItem(){this._onCheckItem()&&this._itemRef.processResponse()}_onPrevItem(){this.itemIndex>0&&this.emit(ci.ON_REQUEST_ITEM,{detail:this.itemIndex-1})}_onNextItem(){this._navigationMode!==e.NavigationMode.linear||this._itemRef.validateResponses()?this.itemIndex<this.items.length-1?this.emit(ci.ON_REQUEST_ITEM,{detail:this.itemIndex+1}):this.dispatchEvent(new CustomEvent(ci.ON_TEST_FINISHED)):this.dispatchEvent(new CustomEvent(ci.ON_NO_RESPONSE_ON_SUBMIT))}_onShowCorrect(){this._itemRef.showCorrectResponse()}_onRequestItem({detail:e}){this.emit(ci.ON_REQUEST_ITEM,{detail:e})}_handleSlotchange(e){const t=this.querySelector("qti-assessment-item");t&&(this._itemRef=t,this.disabled&&this._itemRef.setAttribute("disabled",""),this.readonly&&this._itemRef.setAttribute("readonly",""),this.emit(ci.ON_ITEM_READY,{detail:t}))}render(){return U`
430
+ <slot
431
+ @slotchange=${this._handleSlotchange}
432
+ @on-prev-item=${this._onPrevItem}
433
+ @on-next-item=${this._onNextItem}
434
+ @on-check-item=${this._onCheckItem}
435
+ @on-score-item=${this._onScoreItem}
436
+ @on-request-item=${this._onRequestItem}
437
+ @on-show-correct=${this._onShowCorrect}
438
+ >
439
+ </slot>
440
+ `}emit(e,t){const i=new CustomEvent(e,Object.assign({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));this.dispatchEvent(i)}},he([ve("qti-test-prev"),pe("design:type",HTMLElement)],e.QtiTest.prototype,"prevButton",void 0),he([ve("qti-test-next"),pe("design:type",HTMLElement)],e.QtiTest.prototype,"nextButton",void 0),he([be({type:Boolean}),pe("design:type",Object)],e.QtiTest.prototype,"disabled",void 0),he([be({type:Boolean}),pe("design:type",Object)],e.QtiTest.prototype,"readonly",void 0),he([be({type:String,attribute:"navigation-mode"}),pe("design:type",Object)],e.QtiTest.prototype,"_navigationMode",void 0),he([xe("_navigationMode",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,String]),pe("design:returntype",void 0)],e.QtiTest.prototype,"handleNavigationModeChange",null),he([be({type:String,attribute:"submission-mode"}),pe("design:type",Object)],e.QtiTest.prototype,"_submissionMode",void 0),he([be(),pe("design:type",Array)],e.QtiTest.prototype,"items",void 0),he([be({type:Number,attribute:"item-index",reflect:!0}),pe("design:type",Object)],e.QtiTest.prototype,"itemIndex",void 0),he([xe("itemIndex",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Number]),pe("design:returntype",void 0)],e.QtiTest.prototype,"handleItemIndexChange",null),he([fe(),pe("design:type",ce)],e.QtiTest.prototype,"_itemRef",void 0),e.QtiTest=he([me("qti-test")],e.QtiTest);const pi=(e,t)=>class extends e{constructor(){super(...arguments),this.scale=1,this.ro=new ResizeObserver((e=>{for(const t of e)this.fitToParent(t.contentRect.width)}))}connectedCallback(){super.connectedCallback(),this.ro.observe(this),this.fitToParent()}static get properties(){return{scales:{type:Boolean,reflect:!0}}}updated(e){e.forEach(((e,t)=>{if("scales"===t)this.scales&&this.fitToParent()}))}fitToParent(e=this.clientWidth){const i=this.querySelector(t);if(i){const t=e/i.clientWidth;this.scale=t,this.marginY=-i.clientHeight*(1-t)+"px",requestAnimationFrame((()=>{i.style.transform=`scale(${this.scale})`,i.style.margin=`0 0 ${this.marginY} 0`}))}}};class ui extends(pi(oe,"qti-assessment-item")){constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.processResponse=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.processResponse()},this.validateResponses=()=>!!this._item&&this._item.validateResponses(),this.resetInteractions=()=>{var e;return null===(e=this._item)||void 0===e?void 0:e.resetInteractions()},this.render=()=>U`<slot @slotchange=${this.handleSlotchange}></slot>`}handleDisabledChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("disabled","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("disabled"))}handleReadonlyChange(e,t){var i,s;t&&(null===(i=this._item)||void 0===i||i.setAttribute("readonly","")),!t&&(null===(s=this._item)||void 0===s||s.removeAttribute("readonly"))}handleResponsesChange(e,t){this._item&&(this._item.responses=t)}handleSlotchange(e){const t=e.target.assignedNodes({flatten:!0});this._item=null,t.forEach((e=>{"QTI-ASSESSMENT-ITEM"==e.nodeName&&(this._item=e,this.disabled&&this._item.setAttribute("disabled",""),this.readonly&&this._item.setAttribute("readonly",""),this.responses&&(this._item.responses=this.responses))}))}}ui.styles=h`
441
+ :host {
442
+ display: block; /* necessary to calculate scaling position */
443
+ width: 100%;
444
+ height: 100%;
445
+ overflow: auto;
446
+ }
447
+ ::slotted(qti-assessment-item) {
448
+ display: block; /* necessary to calculate scaling position */
449
+ width: 100%;
450
+ }
451
+ :host([scales]) ::slotted(qti-assessment-item) {
452
+ aspect-ratio: 4 / 3;
453
+ width: 1024px;
454
+ transform-origin: 0 0;
455
+ }
456
+ `,he([be({type:Boolean,reflect:!0}),pe("design:type",Object)],ui.prototype,"disabled",void 0),he([xe("disabled",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],ui.prototype,"handleDisabledChange",null),he([be({type:Boolean,reflect:!0}),pe("design:type",Object)],ui.prototype,"readonly",void 0),he([xe("readonly",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Boolean]),pe("design:returntype",void 0)],ui.prototype,"handleReadonlyChange",null),he([be({type:Object,reflect:!0}),pe("design:type",Object)],ui.prototype,"responses",void 0),he([xe("responses",{waitUntilFirstUpdate:!0}),pe("design:type",Function),pe("design:paramtypes",[Object,Object]),pe("design:returntype",void 0)],ui.prototype,"handleResponsesChange",null),he([fe(),pe("design:type",ce)],ui.prototype,"_item",void 0),customElements.define("qti-item",ui),e.QtiManualScoring=class extends le{constructor(){super(...arguments),this.disabled=!1,this.readonly=!1,this.logger=new we(this,Me,(e=>this.style.display="scorer"===e.view?"block":"none"),!0)}textChanged(e){if(this.disabled||this.readonly)return;const t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return U`<input
457
+ part="input"
458
+ type="number"
459
+ spellcheck="false"
460
+ autocomplete="off"
461
+ @keyup=${this.textChanged}
462
+ @change=${this.textChanged}
463
+ placeholder="score"
464
+ .value=${this.value}
465
+ size="10"
466
+ ?disabled=${this.disabled}
467
+ ?readonly=${this.readonly}
468
+ />`}},e.QtiManualScoring.styles=h`
469
+ :host {
470
+ display: none;
471
+ }
472
+ `,he([be({type:Boolean}),pe("design:type",Object)],e.QtiManualScoring.prototype,"disabled",void 0),he([be({type:Boolean}),pe("design:type",Object)],e.QtiManualScoring.prototype,"readonly",void 0),he([be({type:Number}),pe("design:type",String)],e.QtiManualScoring.prototype,"value",void 0),e.QtiManualScoring=he([me("qti-manual-scoring")],e.QtiManualScoring),e.Choices=it,e.Events=s,e.OutcomeVariable=r,e.QtiAnd=St,e.QtiAssessmentItem=ce,e.QtiAssociateInteraction=It,e.QtiBaseValue=Et,e.QtiChoiceInteraction=rt,e.QtiContains=_t,e.QtiCorrect=ft,e.QtiCustomOperatorLevenshtein=si,e.QtiCustomOperatorNumericOnly=ni,e.QtiCustomOperatorParseNumberLocalNl=ri,e.QtiCustomOperatorRemoveAllSpaces=oi,e.QtiCustomOperatorTrim=ai,e.QtiExpression=pt,e.QtiExtendedTextInteraction=tt,e.QtiFeedbackInline=Le,e.QtiGap=Lt,e.QtiGapMatchInteraction=Mt,e.QtiGapText=Ht,e.QtiGraphicAssociateInteraction=Qt,e.QtiGraphicGapMatchInteraction=Ut,e.QtiGraphicOrderInteraction=jt,e.QtiGte=Ct,e.QtiHotspotChoice=Dt,e.QtiHotspotInteraction=Bt,e.QtiHottextInteraction=st,e.QtiInlineChoiceInteraction=nt,e.QtiIsNull=qt,e.QtiItem=ui,e.QtiMapResponse=ut,e.QtiMatch=yt,e.QtiMatchInteraction=Ft,e.QtiMediaInteraction=Gt,e.QtiModalFeedback=Pe,e.QtiMultiple=At,e.QtiOr=xt,e.QtiOrderInteraction=Vt,e.QtiOutcomeDeclaration=ke,e.QtiPortableCustomInteraction=$t,e.QtiPrompt=Ee,e.QtiResponseCondition=lt,e.QtiResponseDeclaration=Oe,e.QtiResponseElse=ct,e.QtiResponseElseIf=ht,e.QtiResponseIf=dt,e.QtiResponseProcessing=ot,e.QtiSelectPointInteraction=zt,e.QtiSetOutcomeValue=bt,e.QtiSliderInteraction=ii,e.QtiStylesheet=de,e.QtiTextEntryInteraction=Be,e.QtiVariable=vt,e.ResponseVariable=n,e.Status={EMPTY:"empty",USER:"user",FEEDBACK:"feedback",EXPECTED:"expected"},e.TestEvents=ci,e.qtiSimpleAssociableChoice=Nt,Object.defineProperty(e,"__esModule",{value:!0})}));