@citolab/qti-components 7.6.0 → 7.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cdn/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var tn=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var l=(o,r,e,t)=>{for(var i=t>1?void 0:t?rn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&tn(r,e,i),i};var Se=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var st=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Se(this.context,this.host,this.t,this.subscribe))}};var kr=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var vi=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ot=class extends kr{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let s=i.contextTarget??i.composedPath()[0];s!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,s,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Se(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new vi(this.context,this.host))}};function X({context:o}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new ot(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer(n=>{t.set(n,new ot(n,{context:o}))});let i=Object.getOwnPropertyDescriptor(r,e),s;if(i===void 0){let n=new WeakMap;s={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;s={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,s)}}}function _({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer(function(){new st(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})}):e.constructor.addInitializer(i=>{new st(i,{context:o,callback:s=>{i[t]=s},subscribe:r})})}}var As=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(r){this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColSpan="",this.ariaCurrent="",this.ariaDescription="",this.ariaDisabled="",this.ariaExpanded="",this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=r}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var ie=function(o,r,e,t,i){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},D=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},nt,Sr,Mr,Mt,yi,It,Ir,Be,Lt,Me,Lr,Rs,ks=o=>typeof o=="boolean"?o:o?.capture??!1;var xi=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=ks(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=ks(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.size||i.delete(r))}dispatchEvent(r){let e=[this],t=this.__eventTargetParent;if(r.composed)for(;t;)e.push(t),t=t.__eventTargetParent;else for(;t&&t!==this.__host;)e.push(t),t=t.__eventTargetParent;let i=!1,s=!1,n=0,a=null,c=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??c},...I},srcElement:{get(){return r.target},...I},currentTarget:{get(){return d},...I},eventPhase:{get(){return n},...I},composedPath:{value:()=>e,...I},stopPropagation:{value:()=>{i=!0,p.call(r)},...I},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...I}});let f=(q,T,L)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),T.once&&L.delete(q)},b=()=>(d=null,n=0,!r.defaultPrevented),y=e.slice().reverse();a=!this.__host||!r.composed?this:null;let w=q=>{for(c=this;c.__host&&q.includes(c.__host);)c=c.__host};for(let q of y){!a&&(!c||c===q.__host)&&w(y.slice(y.indexOf(q))),d=q,n=q===r.target?2:1;let T=q.__captureEventListeners.get(r.type);if(T){for(let[L,N]of T)if(f(L,N,T),s)return b()}if(i)return b()}let k=r.bubbles?e:[this];c=null;for(let q of k){!a&&(!c||q===c.__host)&&w(k.slice(0,k.indexOf(q)+1)),d=q,n=q===r.target?2:3;let T=q.__eventListeners.get(r.type);if(T){for(let[L,N]of T)if(f(L,N,T),s)return b()}if(i)return b()}return b()}},qi=xi;var I={__proto__:null};I.enumerable=!0;Object.freeze(I);var Ei=(Me=class{constructor(r,e={}){if(nt.set(this,!1),Sr.set(this,!1),Mr.set(this,!1),Mt.set(this,!1),yi.set(this,Date.now()),It.set(this,!1),Ir.set(this,void 0),Be.set(this,void 0),Lt.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,arguments.length===0)throw new Error("The type argument must be specified");if(typeof e!="object"||!e)throw new Error('The "options" argument must be an object');let{bubbles:t,cancelable:i,composed:s}=e;ie(this,nt,!!i,"f"),ie(this,Sr,!!t,"f"),ie(this,Mr,!!s,"f"),ie(this,Ir,`${r}`,"f"),ie(this,Be,null,"f"),ie(this,Lt,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){ie(this,Mt,!0,"f")}get target(){return D(this,Be,"f")}get currentTarget(){return D(this,Be,"f")}get srcElement(){return D(this,Be,"f")}get type(){return D(this,Ir,"f")}get cancelable(){return D(this,nt,"f")}get defaultPrevented(){return D(this,nt,"f")&&D(this,Mt,"f")}get timeStamp(){return D(this,yi,"f")}composedPath(){return D(this,Lt,"f")?[D(this,Be,"f")]:[]}get returnValue(){return!D(this,nt,"f")||!D(this,Mt,"f")}get bubbles(){return D(this,Sr,"f")}get composed(){return D(this,Mr,"f")}get eventPhase(){return D(this,Lt,"f")?Me.AT_TARGET:Me.NONE}get cancelBubble(){return D(this,It,"f")}set cancelBubble(r){r&&ie(this,It,!0,"f")}stopPropagation(){ie(this,It,!0,"f")}get isTrusted(){return!1}},nt=new WeakMap,Sr=new WeakMap,Mr=new WeakMap,Mt=new WeakMap,yi=new WeakMap,It=new WeakMap,Ir=new WeakMap,Be=new WeakMap,Lt=new WeakMap,Me.NONE=0,Me.CAPTURING_PHASE=1,Me.AT_TARGET=2,Me.BUBBLING_PHASE=3,Me);Object.defineProperties(Ei.prototype,{initEvent:I,stopImmediatePropagation:I,preventDefault:I,target:I,currentTarget:I,srcElement:I,type:I,cancelable:I,defaultPrevented:I,timeStamp:I,composedPath:I,returnValue:I,bubbles:I,composed:I,eventPhase:I,cancelBubble:I,stopPropagation:I,isTrusted:I});var Ss=(Rs=class extends Ei{constructor(r,e={}){super(r,e),Lr.set(this,void 0),ie(this,Lr,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return D(this,Lr,"f")}},Lr=new WeakMap,Rs);Object.defineProperties(Ss.prototype,{detail:I});var Ci=Ei,wi=Ss;globalThis.Event??=Ci;globalThis.CustomEvent??=wi;var Ms=new WeakMap,$t=o=>{let r=Ms.get(o);return r===void 0&&Ms.set(o,r=new Map),r},sn=class extends qi{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from($t(this)).map(([r,e])=>({name:r,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(r,e){$t(this).set(r,String(e))}removeAttribute(r){$t(this).delete(r)}toggleAttribute(r,e){if(this.hasAttribute(r)){if(e===void 0||!e)return this.removeAttribute(r),!1}else return e===void 0||e?(this.setAttribute(r,""),!0):!1;return!0}hasAttribute(r){return $t(this).has(r)}attachShadow(r){let e={host:this};return this.__shadowRootMode=r.mode,r&&r.mode==="open"&&(this.__shadowRoot=e),e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let r=new As(this);return this.__internals=r,r}getAttribute(r){return $t(this).get(r)??null}};var on=class extends sn{},Ti=on;globalThis.litServerRoot??=Object.defineProperty(new Ti,"localName",{get(){return"lit-server-root"}});function nn(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var _i=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(r,e){if(this.__definitions.has(r))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${r}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
2
- Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=nn(),this.__pendingWhenDefineds.set(r,t)),t.promise}},an=_i;var Is=new an;var Ot=globalThis,$r=Ot.ShadowRoot&&(Ot.ShadyCSS===void 0||Ot.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ai=Symbol(),Ls=new WeakMap,Pt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ai)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if($r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=Ls.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&Ls.set(e,r))}return r}toString(){return this.cssText}},$s=o=>new Pt(typeof o=="string"?o:o+"",void 0,Ai),x=(o,...r)=>{let e=o.length===1?o[0]:r.reduce((t,i,s)=>t+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+o[s+1],o[0]);return new Pt(e,o,Ai)},Os=(o,r)=>{if($r)o.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of r){let t=document.createElement("style"),i=Ot.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},Ri=$r||Ot.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return $s(e)})(o):o;var{is:ln,defineProperty:cn,getOwnPropertyDescriptor:dn,getOwnPropertyNames:pn,getOwnPropertySymbols:un,getPrototypeOf:mn}=Object,Dt=globalThis;Dt.customElements??=Is;var Ps=Dt.trustedTypes,hn=Ps?Ps.emptyScript:"",fn=Dt.reactiveElementPolyfillSupport,Nt=(o,r)=>o,Vt={toAttribute(o,r){switch(r){case Boolean:o=o?hn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Or=(o,r)=>!ln(o,r),Ns={attribute:!0,type:String,converter:Vt,reflect:!1,useDefault:!1,hasChanged:Or};Symbol.metadata??=Symbol("metadata"),Dt.litPropertyMetadata??=new WeakMap;var ge=class extends(globalThis.HTMLElement??Ti){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Ns){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let t=Symbol(),i=this.getPropertyDescriptor(r,t,e);i!==void 0&&cn(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=dn(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);s?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Ns}static _$Ei(){if(this.hasOwnProperty(Nt("elementProperties")))return;let r=mn(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Nt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Nt("properties"))){let e=this.properties,t=[...pn(e),...un(e)];for(let i of t)this.createProperty(i,e[i])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let i=this._$Eu(e,t);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let t=new Set(r.flat(1/0).reverse());for(let i of t)e.unshift(Ri(i))}else r!==void 0&&e.push(Ri(r));return e}static _$Eu(r,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(r=>r(this))}addController(r){(this._$EO??=new Set).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(r.set(t,this[t]),delete this[t]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Os(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(r=>r.hostConnected?.())}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach(r=>r.hostDisconnected?.())}attributeChangedCallback(r,e,t){this._$AK(r,t)}_$ET(r,e){let t=this.constructor.elementProperties.get(r),i=this.constructor._$Eu(r,t);if(i!==void 0&&t.reflect===!0){let s=(t.converter?.toAttribute!==void 0?t.converter:Vt).toAttribute(e,t.type);this._$Em=r,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let s=t.getPropertyOptions(i),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Vt;this._$Em=i;let a=n.fromAttribute(e,s.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,s=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Or)(s,e)||t.useDefault&&t.reflect&&s===this._$Ej?.get(r)&&!this.hasAttribute(i._$Eu(r,t))))return;this.C(r,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:t,reflect:i,wrapped:s},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),s!==!0||n!==void 0)||(this._$AL.has(r)||(this.hasUpdated||t||(e=void 0),this._$AL.set(r,e)),i===!0&&this._$Em!==r&&(this._$Eq??=new Set).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,s]of t){let{wrapped:n}=s,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,s,a)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(t){throw r=!1,this._$EM(),t}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(r){}firstUpdated(r){}};ge.elementStyles=[],ge.shadowRootOptions={mode:"open"},ge[Nt("elementProperties")]=new Map,ge[Nt("finalized")]=new Map,fn?.({ReactiveElement:ge}),(Dt.reactiveElementVersions??=[]).push("2.1.1");var Fr=globalThis,Pr=Fr.trustedTypes,Vs=Pr?Pr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Si="$lit$",be=`lit$${Math.random().toFixed(9).slice(2)}$`,Mi="?"+be,gn=`<${Mi}>`,Xe=Fr.document===void 0?{createTreeWalker:()=>({})}:document,zt=()=>Xe.createComment(""),Ft=o=>o===null||typeof o!="object"&&typeof o!="function",Ii=Array.isArray,Bs=o=>Ii(o)||typeof o?.[Symbol.iterator]=="function",ki=`[
1
+ var tn=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?rn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&tn(r,e,i),i};var Se=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var st=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Se(this.context,this.host,this.t,this.subscribe))}};var kr=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var vi=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ot=class extends kr{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let s=i.contextTarget??i.composedPath()[0];s!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,s,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Se(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new vi(this.context,this.host))}};function X({context:o}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new ot(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new ot(n,{context:o}))}));let i=Object.getOwnPropertyDescriptor(r,e),s;if(i===void 0){let n=new WeakMap;s={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;s={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,s)}}}function _({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new st(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new st(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var As=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(r){this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColSpan="",this.ariaCurrent="",this.ariaDescription="",this.ariaDisabled="",this.ariaExpanded="",this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=r}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var ie=function(o,r,e,t,i){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},D=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},nt,Sr,Mr,Mt,yi,It,Ir,Be,Lt,Me,Lr,Rs,ks=o=>typeof o=="boolean"?o:o?.capture??!1;var xi=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=ks(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=ks(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.size||i.delete(r))}dispatchEvent(r){let e=[this],t=this.__eventTargetParent;if(r.composed)for(;t;)e.push(t),t=t.__eventTargetParent;else for(;t&&t!==this.__host;)e.push(t),t=t.__eventTargetParent;let i=!1,s=!1,n=0,a=null,l=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...L},srcElement:{get(){return r.target},...L},currentTarget:{get(){return d},...L},eventPhase:{get(){return n},...L},composedPath:{value:()=>e,...L},stopPropagation:{value:()=>{i=!0,p.call(r)},...L},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...L}});let f=(q,T,M)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),T.once&&M.delete(q)},b=()=>(d=null,n=0,!r.defaultPrevented),y=e.slice().reverse();a=!this.__host||!r.composed?this:null;let C=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of y){!a&&(!l||l===q.__host)&&C(y.slice(y.indexOf(q))),d=q,n=q===r.target?2:1;let T=q.__captureEventListeners.get(r.type);if(T){for(let[M,N]of T)if(f(M,N,T),s)return b()}if(i)return b()}let k=r.bubbles?e:[this];l=null;for(let q of k){!a&&(!l||q===l.__host)&&C(k.slice(0,k.indexOf(q)+1)),d=q,n=q===r.target?2:3;let T=q.__eventListeners.get(r.type);if(T){for(let[M,N]of T)if(f(M,N,T),s)return b()}if(i)return b()}return b()}},qi=xi;var L={__proto__:null};L.enumerable=!0;Object.freeze(L);var Ei=(Me=class{constructor(r,e={}){if(nt.set(this,!1),Sr.set(this,!1),Mr.set(this,!1),Mt.set(this,!1),yi.set(this,Date.now()),It.set(this,!1),Ir.set(this,void 0),Be.set(this,void 0),Lt.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,arguments.length===0)throw new Error("The type argument must be specified");if(typeof e!="object"||!e)throw new Error('The "options" argument must be an object');let{bubbles:t,cancelable:i,composed:s}=e;ie(this,nt,!!i,"f"),ie(this,Sr,!!t,"f"),ie(this,Mr,!!s,"f"),ie(this,Ir,`${r}`,"f"),ie(this,Be,null,"f"),ie(this,Lt,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){ie(this,Mt,!0,"f")}get target(){return D(this,Be,"f")}get currentTarget(){return D(this,Be,"f")}get srcElement(){return D(this,Be,"f")}get type(){return D(this,Ir,"f")}get cancelable(){return D(this,nt,"f")}get defaultPrevented(){return D(this,nt,"f")&&D(this,Mt,"f")}get timeStamp(){return D(this,yi,"f")}composedPath(){return D(this,Lt,"f")?[D(this,Be,"f")]:[]}get returnValue(){return!D(this,nt,"f")||!D(this,Mt,"f")}get bubbles(){return D(this,Sr,"f")}get composed(){return D(this,Mr,"f")}get eventPhase(){return D(this,Lt,"f")?Me.AT_TARGET:Me.NONE}get cancelBubble(){return D(this,It,"f")}set cancelBubble(r){r&&ie(this,It,!0,"f")}stopPropagation(){ie(this,It,!0,"f")}get isTrusted(){return!1}},nt=new WeakMap,Sr=new WeakMap,Mr=new WeakMap,Mt=new WeakMap,yi=new WeakMap,It=new WeakMap,Ir=new WeakMap,Be=new WeakMap,Lt=new WeakMap,Me.NONE=0,Me.CAPTURING_PHASE=1,Me.AT_TARGET=2,Me.BUBBLING_PHASE=3,Me);Object.defineProperties(Ei.prototype,{initEvent:L,stopImmediatePropagation:L,preventDefault:L,target:L,currentTarget:L,srcElement:L,type:L,cancelable:L,defaultPrevented:L,timeStamp:L,composedPath:L,returnValue:L,bubbles:L,composed:L,eventPhase:L,cancelBubble:L,stopPropagation:L,isTrusted:L});var Ss=(Rs=class extends Ei{constructor(r,e={}){super(r,e),Lr.set(this,void 0),ie(this,Lr,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return D(this,Lr,"f")}},Lr=new WeakMap,Rs);Object.defineProperties(Ss.prototype,{detail:L});var Ci=Ei,wi=Ss;globalThis.Event??=Ci;globalThis.CustomEvent??=wi;var Ms=new WeakMap,$t=o=>{let r=Ms.get(o);return r===void 0&&Ms.set(o,r=new Map),r},sn=class extends qi{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from($t(this)).map(([r,e])=>({name:r,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(r,e){$t(this).set(r,String(e))}removeAttribute(r){$t(this).delete(r)}toggleAttribute(r,e){if(this.hasAttribute(r)){if(e===void 0||!e)return this.removeAttribute(r),!1}else return e===void 0||e?(this.setAttribute(r,""),!0):!1;return!0}hasAttribute(r){return $t(this).has(r)}attachShadow(r){let e={host:this};return this.__shadowRootMode=r.mode,r&&r.mode==="open"&&(this.__shadowRoot=e),e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let r=new As(this);return this.__internals=r,r}getAttribute(r){return $t(this).get(r)??null}};var on=class extends sn{},Ti=on;globalThis.litServerRoot??=Object.defineProperty(new Ti,"localName",{get(){return"lit-server-root"}});function nn(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var _i=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(r,e){if(this.__definitions.has(r))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${r}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
2
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=nn(),this.__pendingWhenDefineds.set(r,t)),t.promise}},an=_i;var Is=new an;var Ot=globalThis,$r=Ot.ShadowRoot&&(Ot.ShadyCSS===void 0||Ot.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ai=Symbol(),Ls=new WeakMap,Pt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ai)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if($r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=Ls.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&Ls.set(e,r))}return r}toString(){return this.cssText}},$s=o=>new Pt(typeof o=="string"?o:o+"",void 0,Ai),x=(o,...r)=>{let e=o.length===1?o[0]:r.reduce(((t,i,s)=>t+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+o[s+1]),o[0]);return new Pt(e,o,Ai)},Os=(o,r)=>{if($r)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=Ot.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},Ri=$r||Ot.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return $s(e)})(o):o;var{is:ln,defineProperty:cn,getOwnPropertyDescriptor:dn,getOwnPropertyNames:pn,getOwnPropertySymbols:un,getPrototypeOf:mn}=Object,Dt=globalThis;Dt.customElements??=Is;var Ps=Dt.trustedTypes,hn=Ps?Ps.emptyScript:"",fn=Dt.reactiveElementPolyfillSupport,Nt=(o,r)=>o,Vt={toAttribute(o,r){switch(r){case Boolean:o=o?hn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Or=(o,r)=>!ln(o,r),Ns={attribute:!0,type:String,converter:Vt,reflect:!1,useDefault:!1,hasChanged:Or};Symbol.metadata??=Symbol("metadata"),Dt.litPropertyMetadata??=new WeakMap;var ge=class extends(globalThis.HTMLElement??Ti){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Ns){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let t=Symbol(),i=this.getPropertyDescriptor(r,t,e);i!==void 0&&cn(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=dn(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);s?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Ns}static _$Ei(){if(this.hasOwnProperty(Nt("elementProperties")))return;let r=mn(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Nt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Nt("properties"))){let e=this.properties,t=[...pn(e),...un(e)];for(let i of t)this.createProperty(i,e[i])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let i=this._$Eu(e,t);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let t=new Set(r.flat(1/0).reverse());for(let i of t)e.unshift(Ri(i))}else r!==void 0&&e.push(Ri(r));return e}static _$Eu(r,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((r=>this.enableUpdating=r)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((r=>r(this)))}addController(r){(this._$EO??=new Set).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(r.set(t,this[t]),delete this[t]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Os(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((r=>r.hostConnected?.()))}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach((r=>r.hostDisconnected?.()))}attributeChangedCallback(r,e,t){this._$AK(r,t)}_$ET(r,e){let t=this.constructor.elementProperties.get(r),i=this.constructor._$Eu(r,t);if(i!==void 0&&t.reflect===!0){let s=(t.converter?.toAttribute!==void 0?t.converter:Vt).toAttribute(e,t.type);this._$Em=r,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let s=t.getPropertyOptions(i),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Vt;this._$Em=i;let a=n.fromAttribute(e,s.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,s=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Or)(s,e)||t.useDefault&&t.reflect&&s===this._$Ej?.get(r)&&!this.hasAttribute(i._$Eu(r,t))))return;this.C(r,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:t,reflect:i,wrapped:s},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),s!==!0||n!==void 0)||(this._$AL.has(r)||(this.hasUpdated||t||(e=void 0),this._$AL.set(r,e)),i===!0&&this._$Em!==r&&(this._$Eq??=new Set).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,s]of t){let{wrapped:n}=s,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,s,a)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw r=!1,this._$EM(),t}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(r){}firstUpdated(r){}};ge.elementStyles=[],ge.shadowRootOptions={mode:"open"},ge[Nt("elementProperties")]=new Map,ge[Nt("finalized")]=new Map,fn?.({ReactiveElement:ge}),(Dt.reactiveElementVersions??=[]).push("2.1.1");var Fr=globalThis,Pr=Fr.trustedTypes,Vs=Pr?Pr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Si="$lit$",be=`lit$${Math.random().toFixed(9).slice(2)}$`,Mi="?"+be,gn=`<${Mi}>`,Xe=Fr.document===void 0?{createTreeWalker:()=>({})}:document,zt=()=>Xe.createComment(""),Ft=o=>o===null||typeof o!="object"&&typeof o!="function",Ii=Array.isArray,Bs=o=>Ii(o)||typeof o?.[Symbol.iterator]=="function",ki=`[
3
3
  \f\r]`,Ht=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ds=/-->/g,Hs=/>/g,je=RegExp(`>|${ki}(?:([^\\s"'>=/]+)(${ki}*=${ki}*(?:[^
4
- \f\r"'\`<>=]|("|')|))|$)`,"g"),zs=/'/g,Fs=/"/g,js=/^(?:script|style|textarea|title)$/i,Li=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),h=Li(1),Ur=Li(2),Ua=Li(3),P=Symbol.for("lit-noChange"),S=Symbol.for("lit-nothing"),Us=new WeakMap,We=Xe.createTreeWalker(Xe,129);function Ws(o,r){if(!Ii(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Vs!==void 0?Vs.createHTML(r):r}var Xs=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Ht;for(let a=0;a<e;a++){let c=o[a],d,p,m=-1,f=0;for(;f<c.length&&(n.lastIndex=f,p=n.exec(c),p!==null);)f=n.lastIndex,n===Ht?p[1]==="!--"?n=Ds:p[1]!==void 0?n=Hs:p[2]!==void 0?(js.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=je):p[3]!==void 0&&(n=je):n===je?p[0]===">"?(n=i??Ht,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?je:p[3]==='"'?Fs:zs):n===Fs||n===zs?n=je:n===Ds||n===Hs?n=Ht:(n=je,i=void 0);let b=n===je&&o[a+1].startsWith("/>")?" ":"";s+=n===Ht?c+gn:m>=0?(t.push(d),c.slice(0,m)+Si+c.slice(m)+be+b):c+be+(m===-2?a:b)}return[Ws(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=class o{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let s=0,n=0,a=r.length-1,c=this.parts,[d,p]=Xs(r,e);if(this.el=o.createElement(d,t),We.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=We.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Si)){let f=p[n++],b=i.getAttribute(m).split(be),y=/([.?@])?(.*)/.exec(f);c.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Vr:y[1]==="?"?Dr:y[1]==="@"?Hr:Ye}),i.removeAttribute(m)}else m.startsWith(be)&&(c.push({type:6,index:s}),i.removeAttribute(m));if(js.test(i.tagName)){let m=i.textContent.split(be),f=m.length-1;if(f>0){i.textContent=Pr?Pr.emptyScript:"";for(let b=0;b<f;b++)i.append(m[b],zt()),We.nextNode(),c.push({type:2,index:++s});i.append(m[f],zt())}}}else if(i.nodeType===8)if(i.data===Mi)c.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(be,m+1))!==-1;)c.push({type:7,index:s}),m+=be.length-1}s++}}static createElement(r,e){let t=Xe.createElement("template");return t.innerHTML=r,t}};function Ge(o,r,e=o,t){if(r===P)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=Ft(r)?void 0:r._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(o),i._$AT(o,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=Ge(o,i._$AS(o,r.values),i,t)),r}var Nr=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??Xe).importNode(e,!0);We.currentNode=i;let s=We.nextNode(),n=0,a=0,c=t[0];for(;c!==void 0;){if(n===c.index){let d;c.type===2?d=new at(s,s.nextSibling,this,r):c.type===1?d=new c.ctor(s,c.name,c.strings,this,r):c.type===6&&(d=new zr(s,this,r)),this._$AV.push(d),c=t[++a]}n!==c?.index&&(s=We.nextNode(),n++)}return We.currentNode=Xe,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},at=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=S,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=Ge(this,r,e),Ft(r)?r===S||r==null||r===""?(this._$AH!==S&&this._$AR(),this._$AH=S):r!==this._$AH&&r!==P&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Bs(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==S&&Ft(this._$AH)?this._$AA.nextSibling.data=r:this.T(Xe.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=Ut.createElement(Ws(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Nr(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=Us.get(r.strings);return e===void 0&&Us.set(r.strings,e=new Ut(r)),e}k(r){Ii(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let s of r)i===e.length?e.push(t=new o(this.O(zt()),this.O(zt()),this,this.options)):t=e[i],t._$AI(s),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Ye=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=S,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=S}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Ge(this,r,e,0),n=!Ft(r)||r!==this._$AH&&r!==P,n&&(this._$AH=r);else{let a=r,c,d;for(r=s[0],c=0;c<s.length-1;c++)d=Ge(this,a[t+c],e,c),d===P&&(d=this._$AH[c]),n||=!Ft(d)||d!==this._$AH[c],d===S?r=S:r!==S&&(r+=(d??"")+s[c+1]),this._$AH[c]=d}n&&!i&&this.j(r)}j(r){r===S?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Vr=class extends Ye{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===S?void 0:r}},Dr=class extends Ye{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==S)}},Hr=class extends Ye{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ge(this,r,e,0)??S)===P)return;let t=this._$AH,i=r===S&&t!==S||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==S&&(t===S||i);i&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},zr=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){Ge(this,r)}},H={M:Si,P:be,A:Mi,C:1,L:Xs,R:Nr,D:Bs,V:Ge,I:at,H:Ye,N:Dr,U:Hr,B:Vr,F:zr},bn=Fr.litHtmlPolyfillSupport;bn?.(Ut,at),(Fr.litHtmlVersions??=[]).push("3.3.1");var $i=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new at(r.insertBefore(zt(),s),s,void 0,e??{})}return i._$AI(o),i};var Oi=globalThis,v=class extends ge{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=$i(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return P}};v._$litElement$=!0,v.finalized=!0,Oi.litElementHydrateSupport?.({LitElement:v});var vn=Oi.litElementPolyfillSupport;vn?.({LitElement:v});(Oi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(o,r)}):customElements.define(o,r)};var yn={attribute:!0,type:String,converter:Vt,reflect:!1,hasChanged:Or},xn=(o=yn,r,e)=>{let{kind:t,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(e.name,o),t==="accessor"){let{name:n}=e;return{set(a){let c=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,c,o)},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let c=this[n];r.call(this,a),this.requestUpdate(n,c,o)}}throw Error("Unsupported decorator location: "+t)};function u(o){return(r,e)=>typeof e=="object"?xn(o,r,e):((t,i,s)=>{let n=i.hasOwnProperty(s);return i.constructor.createProperty(s,t),n?Object.getOwnPropertyDescriptor(i,s):void 0})(o,r,e)}function E(o){return u({...o,state:!0,attribute:!1})}var Ie=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function lt(o,r){return(e,t,i)=>{let s=n=>n.renderRoot?.querySelector(o)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let c=Symbol();return{get(){return this[c]},set(d){this[c]=d}}})();return Ie(e,t,{get(){let c=n.call(this);return c===void 0&&(c=s(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return Ie(e,t,{get(){return s(this)}})}}function Gs(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Ie(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter(c=>c.matches(i))}})}}function Br(o,r){let e;return(t,i)=>{let{connectedCallback:s,disconnectedCallback:n}=t;t.connectedCallback=function(){s.call(this);let a=d=>{let p=Array.from(this.querySelectorAll(o)).concat(Array.from(this.shadowRoot?.querySelectorAll(o)||[]));for(let m of d){let f=Array.from(m.addedNodes).map(y=>y),b=Array.from(m.addedNodes).map(y=>y);m.type==="childList"&&f.find(y=>p.includes(y))&&this[i](f,b)}};e=new MutationObserver(a),e.observe(this,{childList:!0,subtree:!0});let c=Array.from(this.querySelectorAll(o)).concat(Array.from(this.shadowRoot?.querySelectorAll(o)||[]));this[i](Array.from(c),[])},t.disconnectedCallback=function(){n.call(this),e.disconnect()}}}function M(o,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:s}=t,n=Array.isArray(o)?o:[o];t.update=function(a){n.forEach(c=>{let d=c;if(a.has(d)){let p=a.get(d),m=this[d];p!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,m)}}),s.call(this,a)}}}var $=Symbol("item");var Ys=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var G=class extends v{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:Ys};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(s=>s.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return h`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this._processTemplates(),this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this}))})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(s=>s.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};l([u({type:String})],G.prototype,"identifier",2),l([u({type:String})],G.prototype,"adaptive",2),l([u({type:String})],G.prototype,"timeDependent",2),l([u({type:String})],G.prototype,"title",1),l([u({type:Boolean})],G.prototype,"disabled",2),l([M("disabled",{waitUntilFirstUpdate:!0})],G.prototype,"_handleDisabledChange",2),l([u({type:Boolean})],G.prototype,"readonly",2),l([M("readonly",{waitUntilFirstUpdate:!0})],G.prototype,"_handleReadonlyChange",2),l([X({context:$})],G.prototype,"_context",2),G=l([g("qti-assessment-item")],G);var qn=String.raw,En=qn`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),zs=/'/g,Fs=/"/g,js=/^(?:script|style|textarea|title)$/i,Li=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),h=Li(1),Ur=Li(2),Ua=Li(3),P=Symbol.for("lit-noChange"),S=Symbol.for("lit-nothing"),Us=new WeakMap,We=Xe.createTreeWalker(Xe,129);function Ws(o,r){if(!Ii(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Vs!==void 0?Vs.createHTML(r):r}var Xs=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Ht;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,f=0;for(;f<l.length&&(n.lastIndex=f,p=n.exec(l),p!==null);)f=n.lastIndex,n===Ht?p[1]==="!--"?n=Ds:p[1]!==void 0?n=Hs:p[2]!==void 0?(js.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=je):p[3]!==void 0&&(n=je):n===je?p[0]===">"?(n=i??Ht,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?je:p[3]==='"'?Fs:zs):n===Fs||n===zs?n=je:n===Ds||n===Hs?n=Ht:(n=je,i=void 0);let b=n===je&&o[a+1].startsWith("/>")?" ":"";s+=n===Ht?l+gn:m>=0?(t.push(d),l.slice(0,m)+Si+l.slice(m)+be+b):l+be+(m===-2?a:b)}return[Ws(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=class o{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let s=0,n=0,a=r.length-1,l=this.parts,[d,p]=Xs(r,e);if(this.el=o.createElement(d,t),We.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=We.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Si)){let f=p[n++],b=i.getAttribute(m).split(be),y=/([.?@])?(.*)/.exec(f);l.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Vr:y[1]==="?"?Dr:y[1]==="@"?Hr:Ye}),i.removeAttribute(m)}else m.startsWith(be)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(js.test(i.tagName)){let m=i.textContent.split(be),f=m.length-1;if(f>0){i.textContent=Pr?Pr.emptyScript:"";for(let b=0;b<f;b++)i.append(m[b],zt()),We.nextNode(),l.push({type:2,index:++s});i.append(m[f],zt())}}}else if(i.nodeType===8)if(i.data===Mi)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(be,m+1))!==-1;)l.push({type:7,index:s}),m+=be.length-1}s++}}static createElement(r,e){let t=Xe.createElement("template");return t.innerHTML=r,t}};function Ge(o,r,e=o,t){if(r===P)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=Ft(r)?void 0:r._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(o),i._$AT(o,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=Ge(o,i._$AS(o,r.values),i,t)),r}var Nr=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??Xe).importNode(e,!0);We.currentNode=i;let s=We.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new at(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new zr(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=We.nextNode(),n++)}return We.currentNode=Xe,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},at=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=S,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=Ge(this,r,e),Ft(r)?r===S||r==null||r===""?(this._$AH!==S&&this._$AR(),this._$AH=S):r!==this._$AH&&r!==P&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Bs(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==S&&Ft(this._$AH)?this._$AA.nextSibling.data=r:this.T(Xe.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=Ut.createElement(Ws(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Nr(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=Us.get(r.strings);return e===void 0&&Us.set(r.strings,e=new Ut(r)),e}k(r){Ii(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let s of r)i===e.length?e.push(t=new o(this.O(zt()),this.O(zt()),this,this.options)):t=e[i],t._$AI(s),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Ye=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=S,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=S}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Ge(this,r,e,0),n=!Ft(r)||r!==this._$AH&&r!==P,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Ge(this,a[t+l],e,l),d===P&&(d=this._$AH[l]),n||=!Ft(d)||d!==this._$AH[l],d===S?r=S:r!==S&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===S?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Vr=class extends Ye{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===S?void 0:r}},Dr=class extends Ye{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==S)}},Hr=class extends Ye{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ge(this,r,e,0)??S)===P)return;let t=this._$AH,i=r===S&&t!==S||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==S&&(t===S||i);i&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},zr=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){Ge(this,r)}},H={M:Si,P:be,A:Mi,C:1,L:Xs,R:Nr,D:Bs,V:Ge,I:at,H:Ye,N:Dr,U:Hr,B:Vr,F:zr},bn=Fr.litHtmlPolyfillSupport;bn?.(Ut,at),(Fr.litHtmlVersions??=[]).push("3.3.1");var $i=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new at(r.insertBefore(zt(),s),s,void 0,e??{})}return i._$AI(o),i};var Oi=globalThis,v=class extends ge{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=$i(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return P}};v._$litElement$=!0,v.finalized=!0,Oi.litElementHydrateSupport?.({LitElement:v});var vn=Oi.litElementPolyfillSupport;vn?.({LitElement:v});(Oi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var yn={attribute:!0,type:String,converter:Vt,reflect:!1,hasChanged:Or},xn=(o=yn,r,e)=>{let{kind:t,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(e.name,o),t==="accessor"){let{name:n}=e;return{set(a){let l=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,l,o)},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let l=this[n];r.call(this,a),this.requestUpdate(n,l,o)}}throw Error("Unsupported decorator location: "+t)};function u(o){return(r,e)=>typeof e=="object"?xn(o,r,e):((t,i,s)=>{let n=i.hasOwnProperty(s);return i.constructor.createProperty(s,t),n?Object.getOwnPropertyDescriptor(i,s):void 0})(o,r,e)}function E(o){return u({...o,state:!0,attribute:!1})}var Ie=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function lt(o,r){return(e,t,i)=>{let s=n=>n.renderRoot?.querySelector(o)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(d){this[l]=d}}})();return Ie(e,t,{get(){let l=n.call(this);return l===void 0&&(l=s(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return Ie(e,t,{get(){return s(this)}})}}function Gs(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Ie(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}function Br(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let f=[],b=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&f.push(M),f.push(...M.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&b.push(M),b.push(...M.querySelectorAll?.(o)??[])}));let y=q=>Array.from(new Set(q)),C=y(f),k=y(b);(C.length||k.length)&&n.call(this,C,k)},l=new MutationObserver(a);l.observe(this,{childList:!0,subtree:!0});let d=this.shadowRoot?new MutationObserver(a):null;d?.observe(this.shadowRoot,{childList:!0,subtree:!0}),this.__lqObservers=[l,d].filter(m=>!!m),(async()=>{r?.waitUntilFirstUpdate&&"updateComplete"in this&&await this.updateComplete;let m=[...this.querySelectorAll(o),...this.shadowRoot?.querySelectorAll(o)??[]];m.length&&n.call(this,m,[])})()},e.disconnectedCallback=function(){s.call(this),this.__lqObservers?.forEach(n=>n.disconnect()),this.__lqObservers=void 0}}}function I(o,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:s}=t,n=Array.isArray(o)?o:[o];t.update=function(a){n.forEach(l=>{let d=l;if(a.has(d)){let p=a.get(d),m=this[d];p!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,m)}}),s.call(this,a)}}}var $=Symbol("item");var Ys=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var G=class extends v{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:Ys};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(s=>s.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return h`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this._processTemplates(),this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this}))})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(s=>s.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};c([u({type:String})],G.prototype,"identifier",2),c([u({type:String})],G.prototype,"adaptive",2),c([u({type:String})],G.prototype,"timeDependent",2),c([u({type:String})],G.prototype,"title",1),c([u({type:Boolean})],G.prototype,"disabled",2),c([I("disabled",{waitUntilFirstUpdate:!0})],G.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],G.prototype,"readonly",2),c([I("readonly",{waitUntilFirstUpdate:!0})],G.prototype,"_handleReadonlyChange",2),c([X({context:$})],G.prototype,"_context",2),G=c([g("qti-assessment-item")],G);var qn=String.raw,En=qn`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
5
  <xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" />
6
6
  <xsl:template match="@*|node()">
7
7
  <xsl:copy>
@@ -23,7 +23,7 @@ Make sure to test your application with a production build as repeat registratio
23
23
  <xsl:apply-templates/>
24
24
  </xsl:element>
25
25
  </xsl:template>
26
- </xsl:stylesheet>`;function Js(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=Zs(t,i);t.replaceWith(s)})}function Ks(o,r){o.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let s=i.slice(`${r}:`.length),n=`${e.nodeName}-${s}`,a=Zs(e,n);e.replaceWith(a)}})})}function Zs(o,r){let e=document.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function Qs(o){let r=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),s=e.getAttribute("category");r.push({identifier:t,href:i,category:s})}),r}function Bt(o){let r=new XMLHttpRequest;return{promise:new Promise((t,i)=>{r.open("GET",o,!0),r.responseType="document",r.onload=()=>{r.status>=200&&r.status<300?t(r.responseXML):i(r.statusText)},r.onerror=()=>{i(r.statusText)},r.send()}),xhr:r}}function jt(o){return new DOMParser().parseFromString(o,"text/xml")}function ct(o){let r=new XSLTProcessor,e=new DOMParser().parseFromString(En,"text/xml");return r.importStylesheet(e),r.transformToFragment(o,document)}function dt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function eo(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function to(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function ro(o){switch(o){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:}}var Je=(o=!1)=>{let r,e="",t={load(i){e=i;let s=encodeURI(i);if(o&&sessionStorage.getItem(s))return{promise:Promise.resolve(t.parse(sessionStorage.getItem(s))),request:null};let{promise:n,xhr:a}=Bt(i);return{promise:new Promise(d=>{n.then(p=>(r=p,t.shuffleInteractions(),o&&sessionStorage.setItem(s,new XMLSerializer().serializeToString(r)),d(t)))}),request:a}},parse(i){return r=jt(i),t},path:i=>(dt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let s=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of s)r.querySelectorAll("["+a+"]").forEach(d=>{let p=d.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(d.setAttribute("base-url",i),d.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,s,n="qti-portable-custom-interaction"){let a=[],c=r.querySelectorAll(n),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(c.length>0)for(let m of Array.from(c)){m.setAttribute("data-base-url",i);let f=m.getAttribute("custom-interaction-type-identifier");f&&a.includes(f)&&(f=f+a.length,m.setAttribute("custom-interaction-type-identifier",f),a.push(f)),f&&a.push(f);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let w=await s(i,`/${y}`),k=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of k){let T=q.getAttribute("id");if(T&&w.paths&&w.paths[T]){let L=w.paths[T],N=Array.isArray(L)?L[0]:L;if(q.setAttribute("primary-path",N),p&&p.paths&&p.paths[T]){let V=p.paths[T];Array.isArray(V)?q.setAttribute("fallback-path",V[0]):q.setAttribute("fallback-path",V)}}}if(w.paths){for(let q in w.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let L=r.createElement("qti-interaction-module");L.setAttribute("id",q);let N=Array.isArray(w.paths[q])?w.paths[q][0]:w.paths[q];if(L.setAttribute("primary-path",N),p&&p.paths&&p.paths[q]){let V=p.paths[q];Array.isArray(V)?L.setAttribute("fallback-path",V[0]):L.setAttribute("fallback-path",V)}b.appendChild(L)}}w.urlArgs&&b.setAttribute("url-args",w.urlArgs)}catch(w){console.warn(`Failed to load primary configuration: ${y}`,w)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let w=d.paths[y],k="";p&&p.paths&&p.paths[y]&&(k=p.paths[y]);let q=Array.isArray(w)?w:[w],T=Array.isArray(k)?k:[k],L=q.map((N,V)=>{let en=T.length>V?T[V]:"";return{primaryPath:N,fallbackPath:en}});for(let N of T)L.some(V=>V.fallbackPath===N)||L.push({primaryPath:q.length>0?q[0]:N,fallbackPath:N});for(let N of L){let V=r.createElement("qti-interaction-module");N.fallbackPath&&V.setAttribute("fallback-path",N.fallbackPath),V.setAttribute("id",y),V.setAttribute("primary-path",N.primaryPath),b&&b.appendChild(V)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),s=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of s){let a=ro(n.tagName.toLowerCase()),c=Array.isArray(a)?a:[a];for(let d of c){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),f=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(f.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...f],y=!1,w=0;for(;!y&&w<20;){w++;for(let q=f.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[f[q],f[T]]=[f[T],f[q]]}y=!f.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let k=0;for(let q of f)q.parentElement.insertBefore(q,m[k]?.element),k++;for(let q of m)q.element.parentElement.insertBefore(q.element,f[q.originalOrder])}}return t},extendElementName:(i,s)=>(Js(r,i,s),t),extendElementsWithClass:(i="extend")=>(Ks(r,i),t),customInteraction(i,s){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+s),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return eo(r),t},stripStyleSheets(){return to(r),t},html(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ct(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),ct(r)},xmlDoc(){return r}};return t};var Pi=()=>{let o,r={async load(e){return new Promise((t,i)=>{Bt(e).promise.then(s=>(o=s,r.path(e.substring(0,e.lastIndexOf("/"))),t(r)))})},parse(e){return o=jt(e),r},path:e=>(dt(o,e),r),fn(e){return e(o),r},items(){return Qs(o)},html(){return new XMLSerializer().serializeToString(ct(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ct(o)},xmlDoc(){return o}};return r};var pt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let s=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);s?await this.updateStimulusRef(s):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Je().load(this.href).promise.then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};l([u({type:String})],pt.prototype,"identifier",2),l([u({type:String})],pt.prototype,"href",2),pt=l([g("qti-assessment-stimulus-ref")],pt);var jr=class extends v{};jr=l([g("qti-companion-materials-info")],jr);var Wt=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};l([_({context:$,subscribe:!0}),E()],Wt.prototype,"_context",2),Wt=l([g("qti-custom-operator")],Wt);var Cn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Xt=o=>{if(typeof o=="string")return o;let r=Cn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Ni(o){return o==null}function Ke(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var Y=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Ni(this.identifier)&&!Ni(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};l([u({type:String,attribute:"show-hide"})],Y.prototype,"showHide",2),l([u({type:String,attribute:"outcome-identifier"})],Y.prototype,"outcomeIdentifier",2),l([u({type:String})],Y.prototype,"identifier",2),l([u({type:String,attribute:!1})],Y.prototype,"showStatus",2),l([_({context:$,subscribe:!0}),E()],Y.prototype,"_context",2);var Gt=class extends Y{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Gt.styles=x`
26
+ </xsl:stylesheet>`;function Js(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=Zs(t,i);t.replaceWith(s)})}function Ks(o,r){o.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let s=i.slice(`${r}:`.length),n=`${e.nodeName}-${s}`,a=Zs(e,n);e.replaceWith(a)}})})}function Zs(o,r){let e=document.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function Qs(o){let r=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),s=e.getAttribute("category");r.push({identifier:t,href:i,category:s})}),r}function Bt(o){let r=new XMLHttpRequest;return{promise:new Promise((t,i)=>{r.open("GET",o,!0),r.responseType="document",r.onload=()=>{r.status>=200&&r.status<300?t(r.responseXML):i(r.statusText)},r.onerror=()=>{i(r.statusText)},r.send()}),xhr:r}}function jt(o){return new DOMParser().parseFromString(o,"text/xml")}function ct(o){let r=new XSLTProcessor,e=new DOMParser().parseFromString(En,"text/xml");return r.importStylesheet(e),r.transformToFragment(o,document)}function dt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function eo(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function to(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function ro(o){switch(o){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:}}var Je=(o=!1)=>{let r,e="",t={load(i){e=i;let s=encodeURI(i);if(o&&sessionStorage.getItem(s))return{promise:Promise.resolve(t.parse(sessionStorage.getItem(s))),request:null};let{promise:n,xhr:a}=Bt(i);return{promise:new Promise(d=>{n.then(p=>(r=p,t.shuffleInteractions(),o&&sessionStorage.setItem(s,new XMLSerializer().serializeToString(r)),d(t)))}),request:a}},parse(i){return r=jt(i),t},path:i=>(dt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let s=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of s)r.querySelectorAll("["+a+"]").forEach(d=>{let p=d.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(d.setAttribute("base-url",i),d.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,s,n="qti-portable-custom-interaction"){let a=[],l=r.querySelectorAll(n),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(l.length>0)for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let f=m.getAttribute("custom-interaction-type-identifier");f&&a.includes(f)&&(f=f+a.length,m.setAttribute("custom-interaction-type-identifier",f),a.push(f)),f&&a.push(f);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let C=await s(i,`/${y}`),k=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of k){let T=q.getAttribute("id");if(T&&C.paths&&C.paths[T]){let M=C.paths[T],N=Array.isArray(M)?M[0]:M;if(q.setAttribute("primary-path",N),p&&p.paths&&p.paths[T]){let V=p.paths[T];Array.isArray(V)?q.setAttribute("fallback-path",V[0]):q.setAttribute("fallback-path",V)}}}if(C.paths){for(let q in C.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let M=r.createElement("qti-interaction-module");M.setAttribute("id",q);let N=Array.isArray(C.paths[q])?C.paths[q][0]:C.paths[q];if(M.setAttribute("primary-path",N),p&&p.paths&&p.paths[q]){let V=p.paths[q];Array.isArray(V)?M.setAttribute("fallback-path",V[0]):M.setAttribute("fallback-path",V)}b.appendChild(M)}}C.urlArgs&&b.setAttribute("url-args",C.urlArgs)}catch(C){console.warn(`Failed to load primary configuration: ${y}`,C)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let C=d.paths[y],k="";p&&p.paths&&p.paths[y]&&(k=p.paths[y]);let q=Array.isArray(C)?C:[C],T=Array.isArray(k)?k:[k],M=q.map((N,V)=>{let en=T.length>V?T[V]:"";return{primaryPath:N,fallbackPath:en}});for(let N of T)M.some(V=>V.fallbackPath===N)||M.push({primaryPath:q.length>0?q[0]:N,fallbackPath:N});for(let N of M){let V=r.createElement("qti-interaction-module");N.fallbackPath&&V.setAttribute("fallback-path",N.fallbackPath),V.setAttribute("id",y),V.setAttribute("primary-path",N.primaryPath),b&&b.appendChild(V)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),s=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of s){let a=ro(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),f=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(f.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...f],y=!1,C=0;for(;!y&&C<20;){C++;for(let q=f.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[f[q],f[T]]=[f[T],f[q]]}y=!f.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let k=0;for(let q of f)q.parentElement.insertBefore(q,m[k]?.element),k++;for(let q of m)q.element.parentElement.insertBefore(q.element,f[q.originalOrder])}}return t},extendElementName:(i,s)=>(Js(r,i,s),t),extendElementsWithClass:(i="extend")=>(Ks(r,i),t),customInteraction(i,s){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+s),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return eo(r),t},stripStyleSheets(){return to(r),t},html(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ct(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),ct(r)},xmlDoc(){return r}};return t};var Pi=()=>{let o,r={async load(e){return new Promise((t,i)=>{Bt(e).promise.then(s=>(o=s,r.path(e.substring(0,e.lastIndexOf("/"))),t(r)))})},parse(e){return o=jt(e),r},path:e=>(dt(o,e),r),fn(e){return e(o),r},items(){return Qs(o)},html(){return new XMLSerializer().serializeToString(ct(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ct(o)},xmlDoc(){return o}};return r};var pt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let s=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);s?await this.updateStimulusRef(s):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Je().load(this.href).promise.then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],pt.prototype,"identifier",2),c([u({type:String})],pt.prototype,"href",2),pt=c([g("qti-assessment-stimulus-ref")],pt);var jr=class extends v{};jr=c([g("qti-companion-materials-info")],jr);var Wt=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};c([_({context:$,subscribe:!0}),E()],Wt.prototype,"_context",2),Wt=c([g("qti-custom-operator")],Wt);var Cn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Xt=o=>{if(typeof o=="string")return o;let r=Cn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Ni(o){return o==null}function Ke(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var Y=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Ni(this.identifier)&&!Ni(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],Y.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],Y.prototype,"outcomeIdentifier",2),c([u({type:String})],Y.prototype,"identifier",2),c([u({type:String,attribute:!1})],Y.prototype,"showStatus",2),c([_({context:$,subscribe:!0}),E()],Y.prototype,"_context",2);var Gt=class extends Y{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Gt.styles=x`
27
27
  :host {
28
28
  display: block;
29
29
  }
@@ -33,14 +33,14 @@ Make sure to test your application with a production build as repeat registratio
33
33
  .off {
34
34
  display: none;
35
35
  }
36
- `,Gt=l([g("qti-feedback-block")],Gt);var se=o=>o??S;var Yt=class extends Y{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${se(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Yt.styles=x`
36
+ `,Gt=c([g("qti-feedback-block")],Gt);var se=o=>o??S;var Yt=class extends Y{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${se(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Yt.styles=x`
37
37
  .on {
38
38
  display: inline-block;
39
39
  }
40
40
  .off {
41
41
  display: none;
42
42
  }
43
- `,Yt=l([g("qti-feedback-inline")],Yt);var Ze=class extends Y{render(){return h`
43
+ `,Yt=c([g("qti-feedback-inline")],Yt);var Ze=class extends Y{render(){return h`
44
44
  <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
45
45
  <slot></slot>
46
46
  <div style="margin-top: var(--qti-gap-size); text-align: center;">
@@ -86,13 +86,13 @@ Make sure to test your application with a production build as repeat registratio
86
86
  .button:focus {
87
87
  outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
88
88
  }
89
- `,Ze=l([g("qti-modal-feedback")],Ze);var Jt=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Jt.styles=x`
89
+ `,Ze=c([g("qti-modal-feedback")],Ze);var Jt=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Jt.styles=x`
90
90
  :host {
91
91
  display: flex;
92
92
  user-select: none;
93
93
  position: absolute;
94
94
  }
95
- `,Jt=l([g("qti-associable-hotspot")],Jt);var io=(o,r,e)=>{class t extends o{}return t};var oe=(o,r,e,t)=>{class i extends io(o,e,r){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(a,c){this.data[a]=c},getData(a){return this.data[a]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(a,c)=>{if(this.isMatchTabular())return;for(let p of c)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(m=>m!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of a)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let d=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${d}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),d++})};this.droppablesModified=(a,c)=>{if(!this.isMatchTabular()){for(let d of c)this.droppables.includes(d)&&(this.droppables=this.droppables.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.droppables.includes(d)||(this.droppables.push(d),this.allDropzones.push(d));for(let d of this.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")}}}handleDraggableContainerChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.dragContainersModified(a||[],c||[])}dragContainersModified(a,c){for(let d of c)this.dragContainers.includes(d)&&(this.dragContainers=this.dragContainers.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.dragContainers.includes(d)||(this.dragContainers.push(d),this.allDropzones.push(d))}handleDraggablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.draggablesModified(a||[],c||[])}handleDroppablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.droppablesModified(a||[],c||[])}firstUpdated(a){if(super.firstUpdated(a),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(b=>this.resizeObserver?.observe(b))}async moveDraggableToDroppable(a,c){if(this.isMatchTabular())return;(()=>{a.style.transform="translate(0, 0)",c.tagName==="SLOT"?a.setAttribute("slot",c.getAttribute("name")):c.appendChild(a),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(a){this.dragContainers.includes(a)?(this._internals.states.add("--dragzone-active"),a.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),a.setAttribute("active",""))}deactivateDroppable(a,c=!0){c&&this._internals.states.add("--dragzone-active"),a.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}async updateMinDimensionsForDropZones(){if(await this.updateComplete,this.isMatchTabular())return;let a=this.querySelectorAll(r),c=Array.from(this.querySelectorAll(e)).map(b=>b),d=0,p=0;a.forEach(b=>{let y=b.getBoundingClientRect();d=Math.max(d,y.height),p=Math.max(p,y.width)});let m=this.querySelector(t)||this.shadowRoot?.querySelector(t),f=c[0]?.parentElement;f&&(f.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(${p}px + 2 * var(--qti-dropzone-padding)), 1fr))`),m&&(m.style.minHeight=`${d}px`,m.style.minWidth=`${p}px`);for(let b of c){b.style.minHeight=`${d}px`,b.style.minWidth=`${p}px`;let y=b.shadowRoot?.querySelector('slot[part="dropslot"]');y&&(y.style.minHeight=`${d}px`,y.style.minWidth=`${p}px`)}}activateDroppables(a){if(this.isMatchTabular())return;this.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.droppables.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(c=>{c.removeAttribute("enabled"),c.removeAttribute("active")}),this.droppables.forEach(c=>{c.removeAttribute("enabled"),c.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:c,y:d}=this.getEventCoordinates(a),p={clientX:c,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}handleTouchEnd(a){this.isMatchTabular()||(this.isDragging&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(c=>{c.removeAttribute("dragging")}),a.preventDefault())}handleTouchCancel(a){this.resetDragState()}validate(){if(this.isMatchTabular())return;if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),c=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(c=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(c=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(c?{}:{customError:!0},d,p),c}reportValidity(){let a=this.shadowRoot.querySelector("#validation-message");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(a){let c=this.getMatchMaxValue(a),d=a.querySelectorAll('[qti-draggable="true"]').length;return!(c===0)&&d>=c}dropDraggableInDroppable(a,c){let d=a.cloneNode(!0);d.removeAttribute("style"),this.moveDraggableToDroppable(d,c),this.draggablesModified([d],[]);let p=this.getMatchMaxValue(a),m=this.draggables.filter(f=>f.getAttribute("identifier")===a.getAttribute("identifier"));p!==0&&m.length>=p?(a.style.opacity="0.0",a.style.pointerEvents="none"):a.style.opacity="1.0"}resetDragState(){if(this.dragClone){let a=this.currentDropTarget!==null,c=!a||this.dragContainers.includes(this.currentDropTarget);a&&this.currentDropTarget&&!c&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),c&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let a=this.getValidAssociations(),c=this.maxAssociations!==0&&a>=this.maxAssociations;this.droppables.forEach(d=>{c?this.disableDroppable(d):this.checkMaxAssociations(d)?this.disableDroppable(d):this.enableDroppable(d)})}getMatchMaxValue(a){let c=a.getAttribute("match-max");return c?parseInt(c,10):1}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get response(){let a;return typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),a.join(",")}set response(a){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(a=this.getValue(a)),Array.isArray(a)){this.reset(!1),a?.forEach(d=>this.placeResponse(d));let c=new FormData;a.forEach(d=>{c.append(this.responseIdentifier,d)}),this._internals.setFormValue(c)}else this._internals.setFormValue(a||"")}placeResponse(a){let[c,...d]=a.split(" ").reverse(),p=Array.from(this.draggables),m=Array.from(this.droppables);d.forEach(f=>{if(f==="")return;let b=p.find(w=>w.getAttribute("identifier")===f),y=m.find(w=>w.getAttribute("identifier")===c);this.dropDraggableInDroppable(b,y)})}getValidAssociations(){let a=0;for(let c of this.droppables)a=a+this.getDraggablesFromDroppable(c).length;return a}saveResponse(){let a;typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.droppables.map(c=>{let p=this.getDraggablesFromDroppable(c).map(f=>f.getAttribute("identifier")),m=c.getAttribute("identifier");return p.map(f=>`${f} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,f)=>f.indexOf(p)===m).flatMap(p=>Array.from(a.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(a=!0){this.droppables.forEach(c=>{this.getDraggablesFromDroppable(c).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(c=>{Array.from(c.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,a&&this.saveResponse()}updateDragClonePosition(a){if(!this.isDragging||!this.dragClone)return;let c=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(c,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,c,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),f=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-f)),w=Math.max(p.top,Math.min(c,p.bottom-b));return{newLeft:y,newTop:w}}getEventCoordinates(a,c=!1){let d=a.touches?a.touches[0]:a;return{x:c?d.pageX:d.clientX,y:c?d.pageY:d.clientY}}calculateDragDistance(a){let c=Math.abs(a.clientX-this.touchStartPoint.x),d=Math.abs(a.clientY-this.touchStartPoint.y);return c+d}findClosestDropzone(){let a=this.allDropzones.filter(m=>!m.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let c=this.dragClone.getBoundingClientRect(),d=null,p=0;for(let m of a){let f=m.getBoundingClientRect(),b=this.calculateOverlapArea(c,f);b>p&&(p=b,d=m)}if(!d){let m=200;for(let f of a){let b=f.getBoundingClientRect(),y=Math.sqrt(Math.pow(c.left-b.left,2)+Math.pow(c.top-b.top,2));y<m&&(m=y,d=f)}}return d}calculateOverlapArea(a,c){let d=Math.max(0,Math.min(a.right,c.right)-Math.max(a.left,c.left)),p=Math.max(0,Math.min(a.bottom,c.bottom)-Math.max(a.top,c.top));return d*p}dispatchCustomEvent(a,c,d=!0){if(!a)return;let p=new CustomEvent(c,{bubbles:d,cancelable:!0});p.dataTransfer=this.dataTransfer,a.dispatchEvent(p)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(a){if(this.isMatchTabular()||a instanceof MouseEvent&&a.button!==0||this.isDragging)return;let{x:c,y:d}=this.getEventCoordinates(a);this.touchStartPoint={x:c,y:d},this.dragSource=a.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(q=>Array.from(q.children).some(T=>T===this.dragSource)),f=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=c-f.left,this.cloneOffset.y=d-f.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,f&&this.setDragCloneStyles(f),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let w=this.getMatchMaxValue(this.dragSource),k=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));w!==0&&k.length>=w?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",a.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(a){let c=this.dragContainers.flat();for(let d of c){if(d.getAttribute("identifier")===a)return d;let p;d instanceof HTMLSlotElement?p=Array.from(d?.assignedElements()||[]):p=Array.from(d.querySelectorAll(r));let m=p.find(f=>f.getAttribute("identifier")===a);if(m)return m}}setDragCloneStyles(a){this.dragClone.style.position="fixed",this.dragClone.style.top=`${a.top}px`,this.dragClone.style.left=`${a.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return l([u({attribute:!1,type:Object})],i.prototype,"configuration",2),l([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),l([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),l([Br(t)],i.prototype,"handleDraggableContainerChange",1),l([Br(r)],i.prototype,"handleDraggablesChange",1),l([Br(e)],i.prototype,"handleDroppablesChange",1),i};var so=x`
95
+ `,Jt=c([g("qti-associable-hotspot")],Jt);var io=(o,r,e)=>{class t extends o{}return t};var oe=(o,r,e,t)=>{class i extends io(o,e,r){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.onMove=this.handleTouchMove.bind(this);this.onEnd=this.handleTouchEnd.bind(this);this.onCancel=this.handleTouchCancel.bind(this);this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(a,l){this.data[a]=l},getData(a){return this.data[a]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(a,l)=>{if(this.isMatchTabular())return;for(let p of l)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(m=>m!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of a)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let d=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${d}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),d++})};this.droppablesModified=(a,l)=>{if(!this.isMatchTabular()){for(let d of l)this.droppables.includes(d)&&(this.droppables=this.droppables.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.droppables.includes(d)||(this.droppables.push(d),this.allDropzones.push(d));for(let d of this.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")}}}handleDraggableContainerChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.dragContainersModified(a||[],l||[])}dragContainersModified(a,l){for(let d of l)this.dragContainers.includes(d)&&(this.dragContainers=this.dragContainers.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.dragContainers.includes(d)||(this.dragContainers.push(d),this.allDropzones.push(d))}handleDraggablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.draggablesModified(a||[],l||[])}handleDroppablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.droppablesModified(a||[],l||[])}firstUpdated(a){if(super.firstUpdated(a),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("mousemove",this.onMove,{passive:!1}),document.addEventListener("mouseup",this.onEnd,{passive:!1}),document.addEventListener("touchmove",this.onMove,{passive:!1}),document.addEventListener("touchend",this.onEnd,{passive:!1}),document.addEventListener("touchcancel",this.onCancel,{passive:!1}));let d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(b=>this.resizeObserver?.observe(b))}async moveDraggableToDroppable(a,l){if(this.isMatchTabular())return;(()=>{a.style.transform="translate(0, 0)",l.tagName==="SLOT"?a.setAttribute("slot",l.getAttribute("name")):l.appendChild(a),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(a){this.dragContainers.includes(a)?(this._internals.states.add("--dragzone-active"),a.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),a.setAttribute("active",""))}deactivateDroppable(a,l=!0){l&&this._internals.states.add("--dragzone-active"),a.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}async updateMinDimensionsForDropZones(){if(await this.updateComplete,this.isMatchTabular())return;let a=this.querySelectorAll(r),l=Array.from(this.querySelectorAll(e)).map(b=>b),d=0,p=0;a.forEach(b=>{let y=b.getBoundingClientRect();d=Math.max(d,y.height),p=Math.max(p,y.width)});let m=this.querySelector(t)||this.shadowRoot?.querySelector(t),f=l[0]?.parentElement;f&&(f.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(${p}px + 2 * var(--qti-dropzone-padding)), 1fr))`),m&&(m.style.minHeight=`${d}px`,m.style.minWidth=`${p}px`);for(let b of l){b.style.minHeight=`${d}px`,b.style.minWidth=`${p}px`;let y=b.shadowRoot?.querySelector('slot[part="dropslot"]');y&&(y.style.minHeight=`${d}px`,y.style.minWidth=`${p}px`)}}activateDroppables(a){if(this.isMatchTabular())return;this.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.droppables.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),document.removeEventListener("touchcancel",this.onCancel)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a),p={clientX:l,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}handleTouchEnd(a){this.isMatchTabular()||((this.isDragging||this.isDraggable||this.dragClone)&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),a.preventDefault())}handleTouchCancel(a){this.resetDragState()}validate(){if(this.isMatchTabular())return;if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),l=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(l=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(l=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},d,p),l}reportValidity(){let a=this.shadowRoot.querySelector("#validation-message");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(a){let l=this.getMatchMaxValue(a),d=a.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&d>=l}dropDraggableInDroppable(a,l){let d=a.cloneNode(!0);d.removeAttribute("style"),this.moveDraggableToDroppable(d,l),this.draggablesModified([d],[]);let p=this.getMatchMaxValue(a),m=this.draggables.filter(f=>f.getAttribute("identifier")===a.getAttribute("identifier"));p!==0&&m.length>=p?(a.style.opacity="0.0",a.style.pointerEvents="none"):a.style.opacity="1.0"}resetDragState(){if(this.dragClone){let a=this.currentDropTarget!==null,l=!a||this.dragContainers.includes(this.currentDropTarget);a&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let a=this.getValidAssociations(),l=this.maxAssociations!==0&&a>=this.maxAssociations;this.droppables.forEach(d=>{l?this.disableDroppable(d):this.checkMaxAssociations(d)?this.disableDroppable(d):this.enableDroppable(d)})}getMatchMaxValue(a){let l=a.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get response(){let a;return typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),a.join(",")}set response(a){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(a=this.getValue(a)),Array.isArray(a)){this.reset(!1),a?.forEach(d=>this.placeResponse(d));let l=new FormData;a.forEach(d=>{l.append(this.responseIdentifier,d)}),this._internals.setFormValue(l)}else this._internals.setFormValue(a||"")}placeResponse(a){let[l,...d]=a.split(" ").reverse(),p=Array.from(this.draggables),m=Array.from(this.droppables);d.forEach(f=>{if(f==="")return;let b=p.find(C=>C.getAttribute("identifier")===f),y=m.find(C=>C.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,y)})}getValidAssociations(){let a=0;for(let l of this.droppables)a=a+this.getDraggablesFromDroppable(l).length;return a}saveResponse(){let a;typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.droppables.map(l=>{let p=this.getDraggablesFromDroppable(l).map(f=>f.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(f=>`${f} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,f)=>f.indexOf(p)===m).flatMap(p=>Array.from(a.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(a=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,a&&this.saveResponse()}updateDragClonePosition(a){if(!this.isDragging||!this.dragClone)return;let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,l,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),f=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-f)),C=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:y,newTop:C}}getEventCoordinates(a,l=!1){let d=a.touches?a.touches[0]:a;return{x:l?d.pageX:d.clientX,y:l?d.pageY:d.clientY}}calculateDragDistance(a){let l=Math.abs(a.clientX-this.touchStartPoint.x),d=Math.abs(a.clientY-this.touchStartPoint.y);return l+d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragClone.getBoundingClientRect(),d=null,p=0,m=f=>{for(let b of f){let y=this.getDropzoneRect(b),C=this.calculateOverlapArea(l,y);C>p&&(p=C,d=b)}};if(m(this.droppables.filter(f=>!f.hasAttribute("disabled"))),d||m(this.dragContainers.filter(f=>!f.hasAttribute("disabled"))),!d){let f=Number.POSITIVE_INFINITY;for(let b of a){let y=this.getDropzoneRect(b),C=Math.hypot(l.left-y.left,l.top-y.top);C<f&&(f=C,d=b)}}return d}calculateOverlapArea(a,l){let d=Math.max(0,Math.min(a.right,l.right)-Math.max(a.left,l.left)),p=Math.max(0,Math.min(a.bottom,l.bottom)-Math.max(a.top,l.top));return d*p}dispatchCustomEvent(a,l,d=!0){if(!a)return;let p=new CustomEvent(l,{bubbles:d,cancelable:!0});p.dataTransfer=this.dataTransfer,a.dispatchEvent(p)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(a){if(this.isMatchTabular()||a instanceof MouseEvent&&a.button!==0||this.isDragging)return;let{x:l,y:d}=this.getEventCoordinates(a);this.touchStartPoint={x:l,y:d},this.dragSource=a.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(q=>Array.from(q.children).some(T=>T===this.dragSource)),f=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-f.left,this.cloneOffset.y=d-f.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,f&&this.setDragCloneStyles(f),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let C=this.getMatchMaxValue(this.dragSource),k=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));C!==0&&k.length>=C?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",a.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(a){let l=this.dragContainers.flat();for(let d of l){if(d.getAttribute("identifier")===a)return d;let p;d instanceof HTMLSlotElement?p=Array.from(d?.assignedElements()||[]):p=Array.from(d.querySelectorAll(r));let m=p.find(f=>f.getAttribute("identifier")===a);if(m)return m}}setDragCloneStyles(a){this.dragClone.style.position="fixed",this.dragClone.style.top=`${a.top}px`,this.dragClone.style.left=`${a.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return c([u({attribute:!1,type:Object})],i.prototype,"configuration",2),c([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),c([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),c([Br(t)],i.prototype,"handleDraggableContainerChange",1),c([Br(r)],i.prototype,"handleDraggablesChange",1),c([Br(e)],i.prototype,"handleDroppablesChange",1),i};var so=x`
96
96
  :host {
97
97
  display: block; /* necessary to calculate scaling position */
98
98
  }
@@ -106,6 +106,15 @@ Make sure to test your application with a production build as repeat registratio
106
106
  gap: 0.5rem;
107
107
  }
108
108
 
109
+ [part='drop-list'][active] {
110
+ border-color: var(--qti-border-active) !important;
111
+ background-color: var(--qti-bg-active) !important;
112
+ }
113
+
114
+ [part='drop-list'][enabled] {
115
+ background-color: var(--qti-bg-active) !important;
116
+ }
117
+
109
118
  :host::part(associables-container) {
110
119
  display: flex;
111
120
  padding: 0.5rem;
@@ -117,7 +126,7 @@ Make sure to test your application with a production build as repeat registratio
117
126
  rgb(0 0 0 / 0%) calc(50% + 1px)
118
127
  );
119
128
  }
120
- `;var ne=Symbol("configContext");var R=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!1}get responseVariable(){let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),s=this.responseVariable;if(!s)return;if(!e||this.correctness==="correct"){if(!i)return;this.parentElement?.removeChild(t)}if(i||this.correctness==="correct")return;let n=this.cloneNode(!0),a=document.createElement("div");a.classList.add("full-correct-response"),this.isInline?a.classList.add("full-correct-response-inline"):a.classList.add("full-correct-response-block"),a.role="full-correct-response",a.appendChild(n),n.isFullCorrectResponse=!0,this.parentElement?.insertBefore(a,this.nextSibling),await n.updateComplete,n.response=Array.isArray(s.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect")))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};l([_({context:$,subscribe:!0})],R.prototype,"_context",2),l([_({context:ne,subscribe:!0})],R.prototype,"configContext",2),l([u({type:String,attribute:"response-identifier"})],R.prototype,"responseIdentifier",2),l([u({reflect:!0,type:Boolean})],R.prototype,"disabled",2),l([u({reflect:!0,type:Boolean})],R.prototype,"readonly",2),l([E()],R.prototype,"_isFullCorrectResponse",2),l([E()],R.prototype,"_correctResponse",2);var ut=class extends oe(R,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
129
+ `;var ne=Symbol("configContext");var R=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!1}get responseVariable(){let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),s=this.responseVariable;if(!s)return;if(!e||this.correctness==="correct"){if(!i)return;this.parentElement?.removeChild(t)}if(i||this.correctness==="correct")return;let n=this.cloneNode(!0),a=document.createElement("div");a.classList.add("full-correct-response"),this.isInline?a.classList.add("full-correct-response-inline"):a.classList.add("full-correct-response-block"),a.role="full-correct-response",a.appendChild(n),n.isFullCorrectResponse=!0,this.parentElement?.insertBefore(a,this.nextSibling),await n.updateComplete,n.response=Array.isArray(s.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect")))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};c([_({context:$,subscribe:!0})],R.prototype,"_context",2),c([_({context:ne,subscribe:!0})],R.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],R.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],R.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],R.prototype,"readonly",2),c([E()],R.prototype,"_isFullCorrectResponse",2),c([E()],R.prototype,"_correctResponse",2);var ut=class extends oe(R,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
121
130
  <slot name="qti-simple-associable-choice"></slot>
122
131
  <div part="drop-container">
123
132
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
@@ -126,7 +135,7 @@ Make sure to test your application with a production build as repeat registratio
126
135
  </div>`)}
127
136
 
128
137
  <div role="alert" part="message" id="validation-message"></div>
129
- </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ut.styles=so,l([E()],ut.prototype,"_childrenMap",2),ut=l([g("qti-associate-interaction")],ut);var Le=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleInternalCorrectResponse(s){let n=this.responseVariable;if(n?.correctResponse){let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse];this._choiceElements.forEach(c=>{c.internals.states.delete("correct-response"),c.internals.states.delete("incorrect-response"),s&&a.length>0&&(a.includes(c.identifier)?c.internals.states.add("correct-response"):c.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(s){let n=this.responseVariable;if(!n?.correctResponse)return;let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse],c=Array.isArray(n.value)?n.value:[n.value];this._choiceElements.forEach(d=>{d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),s&&c.includes(d.identifier)&&(a.includes(d.identifier)?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${r}`,this._registerChoiceElement),this.addEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${r}`,this._registerChoiceElement),this.removeEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=s.length,a=!0,c="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,c=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(a=!1,c=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(a?{}:{customError:!0},c,s[n-1]||this._choiceElements[0]||this),a}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.setProperty("display","block","important"))),this._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.detail.identifier&&this._setChoiceChecked(n,!1)}):this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(a=>this._getChoiceChecked(a)).length>=this.maxChoices?this._choiceElements.forEach(a=>{this._getChoiceChecked(a)||(a.disabled=!0)}):this._choiceElements.forEach(a=>a.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=s.includes(n.identifier);this._setChoiceChecked(n,a)})}}return l([lt("#validation-message")],e.prototype,"_validationMessageElement",2),l([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),l([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),l([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),l([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),l([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),l([E()],e.prototype,"response",2),l([M("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),l([E(),_({context:ne,subscribe:!0})],e.prototype,"_configContext",2),e};var oo=(o,r)=>{class e extends o{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(s){let c=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,p)=>({el:d,order:n(d.style.order)?+d.style.order:p+1})).sort((d,p)=>d.order-p.order).map(d=>d.el);for(let d=0;d<c.length;d++)c[d].marker=this._getLabel(d+1)}}_getLabel(s){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let c="";switch(n){case"qti-labels-decimal":c=`${s}`;break;case"qti-labels-lower-alpha":c=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":c=`${String.fromCharCode(65+s-1)}`;break}return a==="qti-labels-suffix-period"?c+=".":a==="qti-labels-suffix-parenthesis"&&(c+=")"),c}}return l([u({type:String,reflect:!0})],e.prototype,"class",1),e};var no=x`
138
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ut.styles=so,c([E()],ut.prototype,"_childrenMap",2),ut=c([g("qti-associate-interaction")],ut);var Le=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleInternalCorrectResponse(s){let n=this.responseVariable;if(n?.correctResponse){let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),s&&a.length>0&&(a.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(s){let n=this.responseVariable;if(!n?.correctResponse)return;let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse],l=Array.isArray(n.value)?n.value:[n.value];this._choiceElements.forEach(d=>{d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),s&&l.includes(d.identifier)&&(a.includes(d.identifier)?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${r}`,this._registerChoiceElement),this.addEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${r}`,this._registerChoiceElement),this.removeEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=s.length,a=!0,l="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(a=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(a?{}:{customError:!0},l,s[n-1]||this._choiceElements[0]||this),a}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.setProperty("display","block","important"))),this._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.detail.identifier&&this._setChoiceChecked(n,!1)}):this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(a=>this._getChoiceChecked(a)).length>=this.maxChoices?this._choiceElements.forEach(a=>{this._getChoiceChecked(a)||(a.disabled=!0)}):this._choiceElements.forEach(a=>a.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=s.includes(n.identifier);this._setChoiceChecked(n,a)})}}return c([lt("#validation-message")],e.prototype,"_validationMessageElement",2),c([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),c([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),c([I("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([I("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([E()],e.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([E(),_({context:ne,subscribe:!0})],e.prototype,"_configContext",2),e};var oo=(o,r)=>{class e extends o{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,p)=>({el:d,order:n(d.style.order)?+d.style.order:p+1})).sort((d,p)=>d.order-p.order).map(d=>d.el);for(let d=0;d<l.length;d++)l[d].marker=this._getLabel(d+1)}}_getLabel(s){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return a==="qti-labels-suffix-period"?l+=".":a==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return c([u({type:String,reflect:!0})],e.prototype,"class",1),e};var no=x`
130
139
  :host {
131
140
  display: block;
132
141
  }
@@ -200,7 +209,7 @@ Make sure to test your application with a production build as repeat registratio
200
209
  <slot part="prompt" name="prompt"></slot>
201
210
  <slot part="slot" @slotchange=${this._handleSlotChange}></slot>
202
211
  <div part="message" role="alert" id="validation-message"></div>
203
- `}};mt.styles=no,l([u({type:String})],mt.prototype,"orientation",2),mt=l([g("qti-choice-interaction")],mt);var ve=class extends R{constructor(){super();this.rawResponse="";this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:Ke(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let i=this.manifest.style[0],s=i.startsWith("http")||i.startsWith("blob")?i:Ke(`${this.baseRefUrl}/${i}`),n=this.manifest.script[0],a=n.startsWith("http")||n.startsWith("blob")?n:Ke(`${this.baseRefUrl}/${n}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
212
+ `}};mt.styles=no,c([u({type:String})],mt.prototype,"orientation",2),mt=c([g("qti-choice-interaction")],mt);var ve=class extends R{constructor(){super();this.rawResponse="";this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:Ke(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let i=this.manifest.style[0],s=i.startsWith("http")||i.startsWith("blob")?i:Ke(`${this.baseRefUrl}/${i}`),n=this.manifest.script[0],a=n.startsWith("http")||n.startsWith("blob")?n:Ke(`${this.baseRefUrl}/${n}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
204
213
  <html>
205
214
  <head>
206
215
  <link href='${s}' rel="stylesheet" />
@@ -208,7 +217,7 @@ Make sure to test your application with a production build as repeat registratio
208
217
  </head>
209
218
  <body></body>
210
219
  </html>
211
- `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),i=[...e,...t];for(let s of i){let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=s.contentDocument||s.contentWindow.document;c&&this.getInnerIFrames(c,i)}catch(c){console.error("Error accessing nested iframe:",c)}}return i.forEach((s,n)=>{i.indexOf(s)!==n&&i.splice(n,1)}),i}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(c,t)}catch(c){console.error("Error accessing nested iframe:",c)}else console.warn("Skipped cross-origin iframe:",n)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let i=this.getIFrames();for(let s of i)s.contentWindow&&s.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:i}=e.data;switch(t){case"setResponse":(i===null||!(Array.isArray(i)&&i.length===1&&i[0]===""))&&(this.rawResponse=i,this.saveResponse(i));break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let s=this.manifest.media.map(n=>n.startsWith("http")||n.startsWith("blob")?n:Ke(this.baseRefUrl+"/"+n));this.postToWindowAndIframes("mediaData",s);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.rawResponse)return!1;if(Array.isArray(this.rawResponse)){if(this.rawResponse.length===0)return!1;for(let e of this.rawResponse)if(e!==""&&e!==null)return!0}return!0}get response(){return this.rawResponse||null}set response(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else if(Array.isArray(e))this.rawResponse=e;else if(e)throw new Error("Value must be a string or an array of strings")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
220
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),i=[...e,...t];for(let s of i){let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;l&&this.getInnerIFrames(l,i)}catch(l){console.error("Error accessing nested iframe:",l)}}return i.forEach((s,n)=>{i.indexOf(s)!==n&&i.splice(n,1)}),i}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let i=this.getIFrames();for(let s of i)s.contentWindow&&s.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:i}=e.data;switch(t){case"setResponse":(i===null||!(Array.isArray(i)&&i.length===1&&i[0]===""))&&(this.rawResponse=i,this.saveResponse(i));break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let s=this.manifest.media.map(n=>n.startsWith("http")||n.startsWith("blob")?n:Ke(this.baseRefUrl+"/"+n));this.postToWindowAndIframes("mediaData",s);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.rawResponse)return!1;if(Array.isArray(this.rawResponse)){if(this.rawResponse.length===0)return!1;for(let e of this.rawResponse)if(e!==""&&e!==null)return!0}return!0}get response(){return this.rawResponse||null}set response(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else if(Array.isArray(e))this.rawResponse=e;else if(e)throw new Error("Value must be a string or an array of strings")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
212
221
  width=${this.getAttribute("width")}
213
222
  height=${this.getAttribute("height")}
214
223
  frameborder="0"
@@ -219,7 +228,7 @@ Make sure to test your application with a production build as repeat registratio
219
228
  ${this._errorMessage&&h`<div style="color:red">
220
229
  <h1>Error</h1>
221
230
  ${this._errorMessage}
222
- </div>`}`}};l([u({type:String,attribute:"data"})],ve.prototype,"data",2),l([u({type:String,attribute:"data-base-item"})],ve.prototype,"baseItemUrl",2),l([u({type:String,attribute:"data-base-ref"})],ve.prototype,"baseRefUrl",2),l([u({type:String,attribute:"id"})],ve.prototype,"id",2),l([E()],ve.prototype,"_errorMessage",2),ve=l([g("qti-custom-interaction")],ve);var $e=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};l([u({type:String,attribute:"response-identifier"})],$e.prototype,"responseIdentifier",2),l([u({reflect:!0,type:Boolean})],$e.prototype,"disabled",2),l([u({type:String,attribute:"count-attempt"})],$e.prototype,"countAttempt",2),l([u({type:String})],$e.prototype,"title",2),$e=l([g("qti-end-attempt-interaction")],$e);var ao=x`
231
+ </div>`}`}};c([u({type:String,attribute:"data"})],ve.prototype,"data",2),c([u({type:String,attribute:"data-base-item"})],ve.prototype,"baseItemUrl",2),c([u({type:String,attribute:"data-base-ref"})],ve.prototype,"baseRefUrl",2),c([u({type:String,attribute:"id"})],ve.prototype,"id",2),c([E()],ve.prototype,"_errorMessage",2),ve=c([g("qti-custom-interaction")],ve);var $e=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};c([u({type:String,attribute:"response-identifier"})],$e.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],$e.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],$e.prototype,"countAttempt",2),c([u({type:String})],$e.prototype,"title",2),$e=c([g("qti-end-attempt-interaction")],$e);var ao=x`
223
232
  /* PK: display host as block, else design will be collapsed */
224
233
  :host {
225
234
  display: block;
@@ -246,12 +255,12 @@ Make sure to test your application with a production build as repeat registratio
246
255
  ?disabled="${this.disabled}"
247
256
  ?readonly="${this.readonly}"
248
257
  .value=${this.response}
249
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};U.styles=ao,l([E()],U.prototype,"_rows",2),l([u({type:Number,attribute:"expected-length"})],U.prototype,"expectedLength",2),l([u({type:String,attribute:"pattern-mask"})],U.prototype,"patternMask",2),l([u({type:String,attribute:"placeholder-text"})],U.prototype,"placeholderText",2),l([u({type:String,attribute:"data-patternmask-message"})],U.prototype,"dataPatternmaskMessage",2),l([u({type:String,attribute:"class"})],U.prototype,"classNames",2),l([M("classNames")],U.prototype,"handleclassNamesChange",1),l([E()],U.prototype,"response",2),l([M("response",{waitUntilFirstUpdate:!0})],U.prototype,"_handleResponseChange",2),U=l([g("qti-extended-text-interaction")],U);var ht=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ht.styles=x`
258
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};U.styles=ao,c([E()],U.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],U.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],U.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],U.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],U.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],U.prototype,"classNames",2),c([I("classNames")],U.prototype,"handleclassNamesChange",1),c([E()],U.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],U.prototype,"_handleResponseChange",2),U=c([g("qti-extended-text-interaction")],U);var ht=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ht.styles=x`
250
259
  :host {
251
260
  display: flex;
252
261
  user-select: none;
253
262
  }
254
- `,l([u({type:Number,reflect:!0})],ht.prototype,"tabindex",2),ht=l([g("qti-gap-img")],ht);var lo=x`
263
+ `,c([u({type:Number,reflect:!0})],ht.prototype,"tabindex",2),ht=c([g("qti-gap-img")],ht);var lo=x`
255
264
  :host {
256
265
  display: flex;
257
266
  align-items: flex-start;
@@ -288,17 +297,17 @@ Make sure to test your application with a production build as repeat registratio
288
297
  `;var Kt=class extends oe(R,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
289
298
  <slot part="drags" name="drags"></slot>
290
299
  <slot part="drops"></slot>
291
- <div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),c=t.find(p=>p.gap===a)?.text,d=this.querySelector(`qti-gap-text[identifier="${c}"]`)?.textContent.trim();if(c&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(i=>{i.remove()})}};Kt.styles=lo,Kt=l([g("qti-gap-match-interaction")],Kt);var co={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ae(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return l([u({type:String})],e.prototype,"identifier",2),l([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),l([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:co})],e.prototype,"disabled",2),l([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:co})],e.prototype,"readonly",2),l([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ft=class extends ae(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ft.styles=x`
300
+ <div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),l=t.find(p=>p.gap===a)?.text,d=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(i=>{i.remove()})}};Kt.styles=lo,Kt=c([g("qti-gap-match-interaction")],Kt);var co={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ae(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return c([u({type:String})],e.prototype,"identifier",2),c([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),c([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:co})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:co})],e.prototype,"readonly",2),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ft=class extends ae(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ft.styles=x`
292
301
  :host {
293
302
  display: inline-flex;
294
303
  user-select: none;
295
304
  }
296
- `,l([u({type:Number,reflect:!0})],ft.prototype,"tabindex",2),ft=l([g("qti-gap-text")],ft);var gt=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};gt.styles=x`
305
+ `,c([u({type:Number,reflect:!0})],ft.prototype,"tabindex",2),ft=c([g("qti-gap-text")],ft);var gt=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};gt.styles=x`
297
306
  :host {
298
307
  display: flex;
299
308
  user-select: none;
300
309
  }
301
- `,l([u({type:Number,reflect:!0})],gt.prototype,"tabindex",2),gt=l([g("qti-gap")],gt);var Oe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ee=o=>(...r)=>({_$litDirective$:o,values:r}),le=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:wn}=H,uo=o=>o===null||typeof o!="object"&&typeof o!="function";var mo=o=>o.strings===void 0,po=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(po(),i),n=t.insertBefore(po(),i);e=new wn(s,n,o,o.options)}else{let s=e._$AB.nextSibling,n=e._$AM,a=n!==o;if(a){let c;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(c=o._$AU)!==n._$AU&&e._$AP(c)}if(s!==i||a){let c=e._$AA;for(;c!==s;){let d=c.nextSibling;t.insertBefore(c,i),c=d}}}return e},Pe=(o,r,e=o)=>(o._$AI(r,e),o),_n={},ho=(o,r=_n)=>o._$AH=r,fo=o=>o._$AH,Wr=o=>{o._$AR(),o._$AA.remove()};var go=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},vt=ee(class extends le{constructor(o){if(super(o),o.type!==Oe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=fo(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],c=[],d,p,m=0,f=i.length-1,b=0,y=s.length-1;for(;m<=f&&b<=y;)if(i[m]===null)m++;else if(i[f]===null)f--;else if(a[m]===n[b])c[b]=Pe(i[m],s[b]),m++,b++;else if(a[f]===n[y])c[y]=Pe(i[f],s[y]),f--,y--;else if(a[m]===n[y])c[y]=Pe(i[m],s[y]),bt(o,c[y+1],i[m]),m++,y--;else if(a[f]===n[b])c[b]=Pe(i[f],s[b]),bt(o,i[m],i[f]),f--,b++;else if(d===void 0&&(d=go(n,b,y),p=go(a,m,f)),d.has(a[m]))if(d.has(a[f])){let w=p.get(n[b]),k=w!==void 0?i[w]:null;if(k===null){let q=bt(o,i[m]);Pe(q,s[b]),c[b]=q}else c[b]=Pe(k,s[b]),bt(o,i[m],k),i[w]=null;b++}else Wr(i[f]),f--;else Wr(i[m]),m++;for(;b<=y;){let w=bt(o,c[y+1]);Pe(w,s[b]),c[b++]=w}for(;m<=f;){let w=i[m++];w!==null&&Wr(w)}return this.ut=n,ho(o,c),P}});function Ne(o,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(o){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,c]=r,d=n/i*100,p=a/s*100,m=c/i*100,f=c/s*100;t.style.left=d-m+"%",t.style.top=p-f+"%",t.style.width=2*m+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,c,d]=r,p=n/i*100,m=a/s*100,f=c/i*100,b=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=f-p+"%",t.style.height=b-m+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,c,d]=r,p=n/i*100,m=a/s*100,f=c/i*100,b=d/s*100;t.style.left=p-f+"%",t.style.top=m-b+"%",t.style.width=2*f+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"poly":{if(r.length<6||r.length%2!==0){console.error("Invalid polygon coordinates:",r);return}let n=[];for(let q=0;q<r.length;q+=2)n.push({x:r[q],y:r[q+1]});let a=Math.min(...n.map(q=>q.x)),c=Math.max(...n.map(q=>q.x)),d=Math.min(...n.map(q=>q.y)),p=Math.max(...n.map(q=>q.y)),m=a/i*100,f=d/s*100,b=c/i*100,y=p/s*100;t.style.left=m+"%",t.style.top=f+"%",t.style.width=b-m+"%",t.style.height=y-f+"%";let k=n.map(q=>({x:(q.x-a)/(c-a)*100,y:(q.y-d)/(p-d)*100})).map(q=>`${q.x}% ${q.y}%`).join(",");t.style.clipPath=`polygon(${k})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var bo=x`
310
+ `,c([u({type:Number,reflect:!0})],gt.prototype,"tabindex",2),gt=c([g("qti-gap")],gt);var Oe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ee=o=>(...r)=>({_$litDirective$:o,values:r}),le=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:wn}=H,uo=o=>o===null||typeof o!="object"&&typeof o!="function";var mo=o=>o.strings===void 0,po=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(po(),i),n=t.insertBefore(po(),i);e=new wn(s,n,o,o.options)}else{let s=e._$AB.nextSibling,n=e._$AM,a=n!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==n._$AU&&e._$AP(l)}if(s!==i||a){let l=e._$AA;for(;l!==s;){let d=l.nextSibling;t.insertBefore(l,i),l=d}}}return e},Pe=(o,r,e=o)=>(o._$AI(r,e),o),_n={},ho=(o,r=_n)=>o._$AH=r,fo=o=>o._$AH,Wr=o=>{o._$AR(),o._$AA.remove()};var go=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},vt=ee(class extends le{constructor(o){if(super(o),o.type!==Oe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=fo(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],l=[],d,p,m=0,f=i.length-1,b=0,y=s.length-1;for(;m<=f&&b<=y;)if(i[m]===null)m++;else if(i[f]===null)f--;else if(a[m]===n[b])l[b]=Pe(i[m],s[b]),m++,b++;else if(a[f]===n[y])l[y]=Pe(i[f],s[y]),f--,y--;else if(a[m]===n[y])l[y]=Pe(i[m],s[y]),bt(o,l[y+1],i[m]),m++,y--;else if(a[f]===n[b])l[b]=Pe(i[f],s[b]),bt(o,i[m],i[f]),f--,b++;else if(d===void 0&&(d=go(n,b,y),p=go(a,m,f)),d.has(a[m]))if(d.has(a[f])){let C=p.get(n[b]),k=C!==void 0?i[C]:null;if(k===null){let q=bt(o,i[m]);Pe(q,s[b]),l[b]=q}else l[b]=Pe(k,s[b]),bt(o,i[m],k),i[C]=null;b++}else Wr(i[f]),f--;else Wr(i[m]),m++;for(;b<=y;){let C=bt(o,l[y+1]);Pe(C,s[b]),l[b++]=C}for(;m<=f;){let C=i[m++];C!==null&&Wr(C)}return this.ut=n,ho(o,l),P}});function Ne(o,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(o){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,l]=r,d=n/i*100,p=a/s*100,m=l/i*100,f=l/s*100;t.style.left=d-m+"%",t.style.top=p-f+"%",t.style.width=2*m+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=f-p+"%",t.style.height=b-m+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p-f+"%",t.style.top=m-b+"%",t.style.width=2*f+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"poly":{if(r.length<6||r.length%2!==0){console.error("Invalid polygon coordinates:",r);return}let n=[];for(let q=0;q<r.length;q+=2)n.push({x:r[q],y:r[q+1]});let a=Math.min(...n.map(q=>q.x)),l=Math.max(...n.map(q=>q.x)),d=Math.min(...n.map(q=>q.y)),p=Math.max(...n.map(q=>q.y)),m=a/i*100,f=d/s*100,b=l/i*100,y=p/s*100;t.style.left=m+"%",t.style.top=f+"%",t.style.width=b-m+"%",t.style.height=y-f+"%";let k=n.map(q=>({x:(q.x-a)/(l-a)*100,y:(q.y-d)/(p-d)*100})).map(q=>`${q.x}% ${q.y}%`).join(",");t.style.clipPath=`polygon(${k})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var bo=x`
302
311
  slot:not([name='prompt']) {
303
312
  // position: relative; /* qti-hotspot-choice relative to the slot */
304
313
  display: block;
@@ -365,7 +374,7 @@ Make sure to test your application with a production build as repeat registratio
365
374
  </svg>
366
375
  <slot></slot>
367
376
  </line-container>
368
- <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(c=>parseInt(c));Ne(n,a,t,i)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let i=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-i.left,y:e.clientY-i.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ce.styles=bo,l([E()],ce.prototype,"_correctLines",2),l([E()],ce.prototype,"startCoord",2),l([E()],ce.prototype,"mouseCoord",2),l([Gs({selector:"img"})],ce.prototype,"grImage",2),l([E()],ce.prototype,"_response",2),ce=l([g("qti-graphic-associate-interaction")],ce);var vo=x`
377
+ <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));Ne(n,a,t,i)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let i=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-i.left,y:e.clientY-i.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ce.styles=bo,c([E()],ce.prototype,"_correctLines",2),c([E()],ce.prototype,"startCoord",2),c([E()],ce.prototype,"mouseCoord",2),c([Gs({selector:"img"})],ce.prototype,"grImage",2),c([E()],ce.prototype,"_response",2),ce=c([g("qti-graphic-associate-interaction")],ce);var vo=x`
369
378
  :host {
370
379
  display: flex;
371
380
  align-items: flex-start;
@@ -422,7 +431,7 @@ Make sure to test your application with a production build as repeat registratio
422
431
  `;var Zt=class extends oe(R,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
423
432
  <slot part="image"></slot>
424
433
  <slot part="drags" name="drags" class="hover-border"></slot>
425
- <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,c]=s;e.style.left=n-c+"px",e.style.top=a-c+"px",e.style.width=e.style.height=2*c+"px"}break;case"rect":{let[n,a,c,d]=s;e.style.left=n+"px",e.style.top=a+"px",e.style.width=c-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Zt.styles=vo,Zt=l([g("qti-graphic-gap-match-interaction")],Zt);var yo=x`
434
+ <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,l]=s;e.style.left=n-l+"px",e.style.top=a-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,a,l,d]=s;e.style.left=n+"px",e.style.top=a+"px",e.style.width=l-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Zt.styles=vo,Zt=c([g("qti-graphic-gap-match-interaction")],Zt);var yo=x`
426
435
  slot:not([name='prompt']) {
427
436
  position: relative; /* qti-hotspot-choice relative to the slot */
428
437
  display: block;
@@ -437,35 +446,37 @@ Make sure to test your application with a production build as repeat registratio
437
446
  <slot name="prompt"></slot>
438
447
  <slot></slot>
439
448
  <div role="alert" part="message" id="validation-message"></div>
440
- `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(c=>parseInt(c));Ne(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Qt.styles=yo,Qt=l([g("qti-graphic-order-interaction")],Qt);var Qe=class extends ae(v,"qti-hotspot-choice"){};Qe.styles=x`
449
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));Ne(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Qt.styles=yo,Qt=c([g("qti-graphic-order-interaction")],Qt);var Qe=class extends ae(v,"qti-hotspot-choice"){};Qe.styles=x`
441
450
  :host {
442
451
  display: flex;
443
452
  user-select: none;
444
453
  position: absolute;
445
454
  }
446
- `,l([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],Qe.prototype,"order",2),l([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],Qe.prototype,"orderCorrect",2),Qe=l([g("qti-hotspot-choice")],Qe);var xo=x`
455
+ `,c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],Qe.prototype,"order",2),c([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],Qe.prototype,"orderCorrect",2),Qe=c([g("qti-hotspot-choice")],Qe);var xo=x`
447
456
  slot:not([name='prompt']) {
448
457
  position: relative; /* qti-hotspot-choice relative to the slot */
449
- display: block;
458
+ display: inline-block;
450
459
  width: fit-content; /* hotspots not stretching further if image is at max size */
460
+ line-height: 0; /* remove gaps below image */
451
461
  }
452
462
  ::slotted(img) {
453
463
  /* image not selectable anymore */
464
+ display: block;
454
465
  pointer-events: none;
455
466
  user-select: none;
456
467
  /* width:100%; */
457
468
  }
458
- `;var er=class extends Le(R,"qti-hotspot-choice"){render(){return h`
469
+ `;var er=class extends Le(R,"qti-hotspot-choice"){constructor(){super(...arguments);this.imageLoadPromise=null}render(){return h`
459
470
  <slot name="prompt"></slot>
460
471
  <slot></slot>
461
- `}positionHotspotOnRegister(r){let e=this.querySelector("img"),t=r.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map(a=>parseInt(a));Ne(s,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};er.styles=xo,er=l([g("qti-hotspot-interaction")],er);var tr=class extends Le(R,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>h`<slot></slot>
462
- <div part="message" role="alert" id="validation-message"></div>`}get classObject(){let e={"qti-input-control-hidden":!0};return this.class&&this.class.split(" ").forEach(t=>{t.trim()&&(e[t.trim()]=!0)}),e}connectedCallback(){super.connectedCallback(),this.updateHostClasses()}updated(e){super.updated(e),this.updateHostClasses()}updateHostClasses(){let e=Object.keys(this.classObject).join(" ");this.className=e}};l([u({type:String,reflect:!0})],tr.prototype,"class",2),tr=l([g("qti-hottext-interaction")],tr);var rr=class extends ae(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
472
+ `}getImageLoadPromise(e){return this.imageLoadPromise||(e.naturalWidth>0&&e.naturalHeight>0?this.imageLoadPromise=Promise.resolve(e):this.imageLoadPromise=new Promise(t=>{let i=()=>{e.removeEventListener("load",i),t(e)};e.addEventListener("load",i)})),this.imageLoadPromise}async positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(d=>parseInt(d)),l=await this.getImageLoadPromise(t);Ne(n,a,l,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};er.styles=xo,er=c([g("qti-hotspot-interaction")],er);var tr=class extends Le(R,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>h`<slot></slot>
473
+ <div part="message" role="alert" id="validation-message"></div>`}get classObject(){let e={"qti-input-control-hidden":!0};return this.class&&this.class.split(" ").forEach(t=>{t.trim()&&(e[t.trim()]=!0)}),e}connectedCallback(){super.connectedCallback(),this.updateHostClasses()}updated(e){super.updated(e),this.updateHostClasses()}updateHostClasses(){let e=Object.keys(this.classObject).join(" ");this.className=e}};c([u({type:String,reflect:!0})],tr.prototype,"class",2),tr=c([g("qti-hottext-interaction")],tr);var rr=class extends ae(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
463
474
  <slot></slot> `}};rr.styles=x`
464
475
  :host {
465
476
  display: flex;
466
477
  user-select: none;
467
478
  }
468
- `,rr=l([g("qti-hottext")],rr);var ir=class extends le{constructor(r){if(super(r),this.it=S,r.type!==Oe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===S||r==null)return this._t=void 0,this.it=r;if(r===P)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let e=[r];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ir.directiveName="unsafeHTML",ir.resultType=1;var yt=ee(ir);var ye=class extends R{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt=""}get isInline(){return!0}static get styles(){return[x`
479
+ `,rr=c([g("qti-hottext")],rr);var ir=class extends le{constructor(r){if(super(r),this.it=S,r.type!==Oe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===S||r==null)return this._t=void 0,this.it=r;if(r===P)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let e=[r];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ir.directiveName="unsafeHTML",ir.resultType=1;var yt=ee(ir);var ye=class extends R{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt=""}get isInline(){return!0}static get styles(){return[x`
469
480
  :host {
470
481
  display: inline-block;
471
482
  }
@@ -495,12 +506,12 @@ Make sure to test your application with a production build as repeat registratio
495
506
  </select>
496
507
 
497
508
  ${yt(this.correctOption)}
498
- `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};ye.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"],l([E()],ye.prototype,"options",2),l([E()],ye.prototype,"correctOption",2),l([u({attribute:"data-prompt",type:String})],ye.prototype,"dataPrompt",2),l([_({context:ne,subscribe:!0}),u({attribute:!1})],ye.prototype,"configContext",2),ye=l([g("qti-inline-choice-interaction")],ye);var sr=class extends v{static get styles(){return[x`
509
+ `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};ye.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"],c([E()],ye.prototype,"options",2),c([E()],ye.prototype,"correctOption",2),c([u({attribute:"data-prompt",type:String})],ye.prototype,"dataPrompt",2),c([_({context:ne,subscribe:!0}),u({attribute:!1})],ye.prototype,"configContext",2),ye=c([g("qti-inline-choice-interaction")],ye);var sr=class extends v{static get styles(){return[x`
499
510
  :host {
500
511
  display: block;
501
512
  cursor: pointer;
502
513
  }
503
- `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};l([u({type:String})],sr.prototype,"identifier",2),sr=l([g("qti-inline-choice")],sr);var Ve=class extends ae(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
514
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],sr.prototype,"identifier",2),sr=c([g("qti-inline-choice")],sr);var Ve=class extends ae(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
504
515
  <slot part="slot"></slot>
505
516
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
506
517
  `}};Ve.styles=x`
@@ -515,7 +526,7 @@ Make sure to test your application with a production build as repeat registratio
515
526
  slot[name='qti-simple-associable-choice'] {
516
527
  width: auto;
517
528
  }
518
- `,l([u({type:Number,attribute:"match-min"})],Ve.prototype,"matchMin",2),l([u({type:Number,attribute:"match-max"})],Ve.prototype,"matchMax",2),l([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ve.prototype,"fixed",2),Ve=l([g("qti-simple-associable-choice")],Ve);var qo=x`
529
+ `,c([u({type:Number,attribute:"match-min"})],Ve.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Ve.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ve.prototype,"fixed",2),Ve=c([g("qti-simple-associable-choice")],Ve);var qo=x`
519
530
  slot:not([hidden]) {
520
531
  /* slot where the */
521
532
  display: flex;
@@ -541,7 +552,7 @@ Make sure to test your application with a production build as repeat registratio
541
552
  /* Make sure the drag and drop container slots have the same width */
542
553
  flex: 1;
543
554
  }
544
- `;var xe=class extends oe(R,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(s)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getMatches(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(s=>{let n=s.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(s=>s.remove());return}let i=this.getMatches(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(s=>s.remove()),this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.find(c=>c.target===n);if(a?.source){let d=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(d&&!s.previousElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",s.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.getMatches(t);this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.filter(d=>d.target===n);s.querySelectorAll("qti-simple-associable-choice").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!e)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return h`
555
+ `;var xe=class extends oe(R,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(s)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getMatches(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(s=>{let n=s.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(s=>s.remove());return}let i=this.getMatches(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(s=>s.remove()),this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.find(l=>l.target===n);if(a?.source){let d=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(d&&!s.previousElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",s.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.getMatches(t);this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.filter(d=>d.target===n);s.querySelectorAll("qti-simple-associable-choice").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!e)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return h`
545
556
  <slot name="prompt"></slot>
546
557
  <slot ?hidden=${e}></slot>
547
558
 
@@ -554,7 +565,7 @@ Make sure to test your application with a production build as repeat registratio
554
565
 
555
566
  ${this.sourceChoices.map(i=>h`<tr part="row">
556
567
  <td part="c-header">${yt(i.innerHTML)}</td>
557
- ${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),c=`${n} ${a}`,d=(this.response||[]).filter(w=>w.split(" ")[0]===n).length||0,p=this.response?.includes(c)||!1,m=i.matchMax===1?"radio":"checkbox",f=!!this.correctOptions?.find(w=>w.source===n&&w.target===a),b=m==="radio"?`rb ${p?"rb-checked":""} ${t?f?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?f?"cb-correct":"cb-incorrect":""}`,y=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return h`<td part="input-cell">
568
+ ${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(C=>C.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",f=!!this.correctOptions?.find(C=>C.source===n&&C.target===a),b=m==="radio"?`rb ${p?"rb-checked":""} ${t?f?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?f?"cb-correct":"cb-incorrect":""}`,y=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return h`<td part="input-cell">
558
569
  <div
559
570
  class="input-container"
560
571
  style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
@@ -563,10 +574,10 @@ Make sure to test your application with a production build as repeat registratio
563
574
  type=${m}
564
575
  part=${b}
565
576
  name=${n}
566
- value=${c}
577
+ value=${l}
567
578
  .disabled=${y}
568
- @change=${w=>this.handleRadioChange(w)}
569
- @click=${w=>i.matchMax===1?this.handleRadioClick(w):null}
579
+ @change=${C=>this.handleRadioChange(C)}
580
+ @click=${C=>i.matchMax===1?this.handleRadioClick(C):null}
570
581
  />
571
582
  ${m==="checkbox"&&p?h`
572
583
  <svg
@@ -584,8 +595,8 @@ Make sure to test your application with a production build as repeat registratio
584
595
  `:S}
585
596
 
586
597
  <div role="alert" part="message" id="validation-message"></div>
587
- `}};xe.styles=qo,l([u({type:String})],xe.prototype,"class",2),l([E()],xe.prototype,"_response",2),l([u({type:String,attribute:"response-identifier"})],xe.prototype,"responseIdentifier",2),l([E()],xe.prototype,"correctOptions",2),xe=l([g("qti-match-interaction")],xe);var or=class extends R{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...R.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
588
- <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};or.styles=[x``],or=l([g("qti-media-interaction")],or);var Eo=x`
598
+ `}};xe.styles=qo,c([u({type:String})],xe.prototype,"class",2),c([E()],xe.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],xe.prototype,"responseIdentifier",2),c([E()],xe.prototype,"correctOptions",2),xe=c([g("qti-match-interaction")],xe);var or=class extends R{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...R.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
599
+ <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};or.styles=[x``],or=c([g("qti-media-interaction")],or);var Eo=x`
589
600
  [part='drags'] {
590
601
  display: flex;
591
602
  align-items: flex-start;
@@ -618,6 +629,15 @@ Make sure to test your application with a production build as repeat registratio
618
629
  flex: 1;
619
630
  }
620
631
 
632
+ [part='drop-list'][active] {
633
+ border-color: var(--qti-border-active) !important;
634
+ background-color: var(--qti-bg-active) !important;
635
+ }
636
+
637
+ [part='drop-list'][enabled] {
638
+ background-color: var(--qti-bg-active) !important;
639
+ }
640
+
621
641
  [part='container'] {
622
642
  display: flex;
623
643
  gap: 0.5rem;
@@ -640,11 +660,11 @@ Make sure to test your application with a production build as repeat registratio
640
660
  <div part="drops">
641
661
  ${[...Array(this.nrChoices)].map((t,i)=>h`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
642
662
  </div>
643
- </div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(c=>c.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((c,d)=>{let p=c.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=c.textContent?.trim();if(!m)return;let f=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!f)return;let b=document.createElement("span");b.classList.add("correct-option"),b.textContent=m,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",f.insertAdjacentElement("afterend",b)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};qe.styles=Eo,l([E()],qe.prototype,"nrChoices",2),l([E()],qe.prototype,"correctResponses",2),l([E()],qe.prototype,"showCorrectResponses",2),l([u({type:String})],qe.prototype,"orientation",2),qe=l([g("qti-order-interaction")],qe);var Co=x`
663
+ </div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,d)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=l.textContent?.trim();if(!m)return;let f=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!f)return;let b=document.createElement("span");b.classList.add("correct-option"),b.textContent=m,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",f.insertAdjacentElement("afterend",b)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};qe.styles=Eo,c([E()],qe.prototype,"nrChoices",2),c([E()],qe.prototype,"correctResponses",2),c([E()],qe.prototype,"showCorrectResponses",2),c([u({type:String})],qe.prototype,"orientation",2),qe=c([g("qti-order-interaction")],qe);var Co=x`
644
664
  ::slotted(qti-interaction-markup) {
645
665
  display: none;
646
666
  }
647
- `;var z=class extends R{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=this.convertQtiVariableJSON(t.params.value);this.response=i,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)t&&(n.paths[a]=this.getResolvablePath(n.paths[a],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(c=>c.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(c=>c.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(c=>c.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:i=>{this.pci=i;try{let s=new ResizeObserver(n=>{for(let a of n)a.contentRect&&a.contentRect.height>0&&(this.style.height=`${a.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(i,s,n,a)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let a={},d=(p=>{let m={};Object.entries(p.dataset).forEach(([b,y])=>{b.includes("__")||(m[b]=y)});let f={};return Object.entries(p.dataset).forEach(([b,y])=>{let w=b.split("__");if(w.length>1){let[k,q,T]=w;f[k]=f[k]||{},f[k][q]=f[k][q]||{},f[k][q][T]=y}}),Object.entries(f).forEach(([b,y])=>{m[b]=Object.values(y)}),m})(n);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let m=d[p];p==="config"?a[p]=JSON.parse(m):a[p]=m}return a})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ke(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let s=i.querySelectorAll("qti-interaction-module");for(let n of s){let a=n.getAttribute("id"),c=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&c){let p=d?this.combineRequireResolvePaths(this.getResolvablePath(c,t),this.getResolvablePath(d,t)):this.getResolvablePath(c,t),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,p)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return i.concat(s).filter((n,a,c)=>c.indexOf(n)===a)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
667
+ `;var z=class extends R{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=this.convertQtiVariableJSON(t.params.value);this.response=i,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)t&&(n.paths[a]=this.getResolvablePath(n.paths[a],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:i=>{this.pci=i;try{let s=new ResizeObserver(n=>{for(let a of n)a.contentRect&&a.contentRect.height>0&&(this.style.height=`${a.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(i,s,n,a)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let a={},d=(p=>{let m={};Object.entries(p.dataset).forEach(([b,y])=>{b.includes("__")||(m[b]=y)});let f={};return Object.entries(p.dataset).forEach(([b,y])=>{let C=b.split("__");if(C.length>1){let[k,q,T]=C;f[k]=f[k]||{},f[k][q]=f[k][q]||{},f[k][q][T]=y}}),Object.entries(f).forEach(([b,y])=>{m[b]=Object.values(y)}),m})(n);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let m=d[p];p==="config"?a[p]=JSON.parse(m):a[p]=m}return a})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ke(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let s=i.querySelectorAll("qti-interaction-module");for(let n of s){let a=n.getAttribute("id"),l=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&l){let p=d?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(d,t)):this.getResolvablePath(l,t),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,p)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return i.concat(s).filter((n,a,l)=>l.indexOf(n)===a)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
648
668
  font-family: ${e.getPropertyValue("font-family")};
649
669
  font-size: ${e.getPropertyValue("font-size")};
650
670
  line-height: ${e.getPropertyValue("line-height")};
@@ -1065,7 +1085,7 @@ Make sure to test your application with a production build as repeat registratio
1065
1085
  <body>
1066
1086
  <div id="pci-container"></div>
1067
1087
  </body>
1068
- </html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,s=this.parentElement?.querySelectorAll(`#${i}`);if(s&&s.forEach(m=>{m.remove()}),e)this.disable();else{this.enable();return}if(!e||!t?.correctResponse)return;let n=document.createElement("div");n.id=i,n.className="pci-correct-response-container",n.style.position="relative",n.style.marginTop="20px",n.style.border="2px solid green",n.style.padding="16px",n.style.borderRadius="4px",n.style.backgroundColor="rgba(0, 128, 0, 0.05)";let a=document.createElement("div");a.textContent="Correct Response:",a.style.fontWeight="bold",a.style.marginBottom="10px",a.style.color="green",n.appendChild(a);let c=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(m=>{m.name!=="id"&&m.name!=="response-identifier"&&c.setAttribute(m.name,m.value)});let d=this.responseIdentifier;c.responseIdentifier=`${d}-correct`,Array.from(this.children).forEach(m=>{let f=m.cloneNode(!0);c.appendChild(f)});let p=t.correctResponse;if(this.useIframe){let m=c.connectedCallback;c.connectedCallback=function(){m.call(this);let f=()=>this._iframeLoaded?(setTimeout(()=>{let b=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);this.sendMessageToIframe("setBoundTo",{[d]:b}),this.sendMessageToIframe("setState",{state:"review"})},1e3),!0):!1;if(!f()){let b=setInterval(()=>{f()&&clearInterval(b)},100);setTimeout(()=>{clearInterval(b)},1e4)}}}else{let m=c.register;c.register=function(f){m.call(this,f);let b=()=>{if(this.pci&&typeof this.pci.setResponse=="function"){let y=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);return this.pci.setResponse(y),typeof this.pci.setState=="function"&&this.pci.setState("review"),!0}return!1};setTimeout(()=>{if(!b()){let y=setInterval(()=>{b()&&clearInterval(y)},200);setTimeout(()=>{clearInterval(y)},5e3)}},500)}}c.style.pointerEvents="none",n.appendChild(c),this.after(n)}disable(){if(this._previousState={pointerEvents:this.style.pointerEvents,position:this.style.position},this.useIframe&&this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this._previousState&&(this._previousState.pointerEvents&&(this.style.pointerEvents=this._previousState.pointerEvents),this._previousState.position&&(this.style.position=this._previousState.position),this._previousState=null),this.useIframe&&this.sendMessageToIframe("setState",{state:"interacting"})}render(){return h`
1088
+ </html>`}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t.cardinality==="single"?"":[];let i=`correct-response-container-${this.responseIdentifier}`,s=this.parentElement?.querySelectorAll(`#${i}`);if(s&&s.forEach(m=>{m.remove()}),e)this.disable();else{this.enable();return}if(!e||!t?.correctResponse)return;let n=document.createElement("div");n.id=i,n.className="pci-correct-response-container",n.style.position="relative",n.style.marginTop="20px",n.style.border="2px solid green",n.style.padding="16px",n.style.borderRadius="4px",n.style.backgroundColor="rgba(0, 128, 0, 0.05)";let a=document.createElement("div");a.textContent="Correct Response:",a.style.fontWeight="bold",a.style.marginBottom="10px",a.style.color="green",n.appendChild(a);let l=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(m=>{m.name!=="id"&&m.name!=="response-identifier"&&l.setAttribute(m.name,m.value)});let d=this.responseIdentifier;l.responseIdentifier=`${d}-correct`,Array.from(this.children).forEach(m=>{let f=m.cloneNode(!0);l.appendChild(f)});let p=t.correctResponse;if(this.useIframe){let m=l.connectedCallback;l.connectedCallback=function(){m.call(this);let f=()=>this._iframeLoaded?(setTimeout(()=>{let b=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);this.sendMessageToIframe("setBoundTo",{[d]:b}),this.sendMessageToIframe("setState",{state:"review"})},1e3),!0):!1;if(!f()){let b=setInterval(()=>{f()&&clearInterval(b)},100);setTimeout(()=>{clearInterval(b)},1e4)}}}else{let m=l.register;l.register=function(f){m.call(this,f);let b=()=>{if(this.pci&&typeof this.pci.setResponse=="function"){let y=this.responseVariablesToQtiVariableJSON(p,t.cardinality,t.baseType);return this.pci.setResponse(y),typeof this.pci.setState=="function"&&this.pci.setState("review"),!0}return!1};setTimeout(()=>{if(!b()){let y=setInterval(()=>{b()&&clearInterval(y)},200);setTimeout(()=>{clearInterval(y)},5e3)}},500)}}l.style.pointerEvents="none",n.appendChild(l),this.after(n)}disable(){if(this._previousState={pointerEvents:this.style.pointerEvents,position:this.style.position},this.useIframe&&this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this._previousState&&(this._previousState.pointerEvents&&(this.style.pointerEvents=this._previousState.pointerEvents),this._previousState.position&&(this.style.position=this._previousState.position),this._previousState=null),this.useIframe&&this.sendMessageToIframe("setState",{state:"interacting"})}render(){return h`
1069
1089
  <slot></slot>
1070
1090
  ${this._errorMessage?h`<div style="color:red">
1071
1091
  <h1>Error</h1>
@@ -1082,7 +1102,7 @@ Make sure to test your application with a production build as repeat registratio
1082
1102
  width: 100%;
1083
1103
  min-height: 50px;
1084
1104
  }
1085
- `],l([u({type:String,attribute:"module"})],z.prototype,"module",2),l([u({type:String,attribute:"custom-interaction-type-identifier"})],z.prototype,"customInteractionTypeIdentifier",2),l([u({type:String,attribute:"data-require-paths"})],z.prototype,"requirePathsJson",2),l([u({type:String,attribute:"data-require-shim"})],z.prototype,"requireShimJson",2),l([u({type:String,attribute:"data-require-js-url"})],z.prototype,"requireJsUrl",2),l([u({type:String,attribute:"data-base-url"})],z.prototype,"baseUrl",2),l([u({type:Boolean,attribute:"data-use-iframe"})],z.prototype,"useIframe",2),l([u({type:Boolean,attribute:"data-use-default-shims"})],z.prototype,"useDefaultShims",2),l([u({type:Boolean,attribute:"data-use-default-paths"})],z.prototype,"useDefaultPaths",2),l([E()],z.prototype,"_errorMessage",2),l([_({context:$,subscribe:!0}),E()],z.prototype,"context",2),l([E()],z.prototype,"response",2),z=l([g("qti-portable-custom-interaction")],z);var Vi=class extends v{render(){return h`<slot></slot>`}static{this.styles=[x`
1105
+ `],c([u({type:String,attribute:"module"})],z.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],z.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],z.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],z.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],z.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],z.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-iframe"})],z.prototype,"useIframe",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],z.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],z.prototype,"useDefaultPaths",2),c([E()],z.prototype,"_errorMessage",2),c([_({context:$,subscribe:!0}),E()],z.prototype,"context",2),c([E()],z.prototype,"response",2),z=c([g("qti-portable-custom-interaction")],z);var Vi=class extends v{render(){return h`<slot></slot>`}static{this.styles=[x`
1086
1106
  :host {
1087
1107
  display: block;
1088
1108
  }
@@ -1098,9 +1118,9 @@ Make sure to test your application with a production build as repeat registratio
1098
1118
  display: inline-block;
1099
1119
  position: relative;
1100
1120
  }
1101
- `],nr=l([g("qti-position-object-stage")],nr);var wo="important",Tn=" !"+wo,Di=ee(class extends le{constructor(o){if(super(o),o.type!==Oe.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(o,[r]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(r)),this.render(r);for(let t of this.ft)r[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in r){let i=r[t];if(i!=null){this.ft.add(t);let s=typeof i=="string"&&i.endsWith(Tn);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?wo:""):e[t]=i}}return P}});var F=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,s]=r.split(" ").map(Number),[n,...a]=e.split(","),c=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[d,p,m]=c;return c.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-d)**2+(s-p)**2)<=m}case"rect":{let[d,p,m,f]=c;return c.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=f}case"ellipse":{let[d,p,m,f]=c;if(c.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(i-d)**2/m**2,y=(s-p)**2/f**2;return b+y<=1}case"poly":{if(c.length<6||c.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let d=[];for(let p=0;p<c.length;p+=2)d.push({x:c[p],y:c[p+1]});return this.isPointInPolygon({x:i,y:s},d)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){let n=e[i].x,a=e[i].y,c=e[s].x,d=e[s].y;a>r.y!=d>r.y&&r.x<(c-n)*(r.y-a)/(d-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),s=parseInt(e,10);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),s=parseFloat(e);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),s=e.split(" ").sort();if(i.length===2&&s.length===2)return t==="pair"&&(i.sort(),s.sort()),i.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var de=class extends R{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOriginal=0;this._imageHeightOriginal=0;this._onImageClick=e=>{if(this.disabled)return;if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${i.toFixed()} ${s.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||(this.response||[]).length<this.maxChoices)&&(this.response=[...this.response||[],n]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(s=>F.isPointInArea(`${t.x} ${t.y}`,`${s.shape},${s.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,s=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=i.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&Ne(n,s.split(",").map(a=>+a),t,i)}))}render(){return h` <slot name="prompt"></slot>
1121
+ `],nr=c([g("qti-position-object-stage")],nr);var wo="important",Tn=" !"+wo,Di=ee(class extends le{constructor(o){if(super(o),o.type!==Oe.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce(((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(o,[r]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(r)),this.render(r);for(let t of this.ft)r[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in r){let i=r[t];if(i!=null){this.ft.add(t);let s=typeof i=="string"&&i.endsWith(Tn);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?wo:""):e[t]=i}}return P}});var F=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,s]=r.split(" ").map(Number),[n,...a]=e.split(","),l=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[d,p,m]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-d)**2+(s-p)**2)<=m}case"rect":{let[d,p,m,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=f}case"ellipse":{let[d,p,m,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(i-d)**2/m**2,y=(s-p)**2/f**2;return b+y<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let d=[];for(let p=0;p<l.length;p+=2)d.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:i,y:s},d)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){let n=e[i].x,a=e[i].y,l=e[s].x,d=e[s].y;a>r.y!=d>r.y&&r.x<(l-n)*(r.y-a)/(d-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),s=parseInt(e,10);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),s=parseFloat(e);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),s=e.split(" ").sort();if(i.length===2&&s.length===2)return t==="pair"&&(i.sort(),s.sort()),i.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var de=class extends R{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOriginal=0;this._imageHeightOriginal=0;this._onImageClick=e=>{if(this.disabled)return;if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${i.toFixed()} ${s.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||(this.response||[]).length<this.maxChoices)&&(this.response=[...this.response||[],n]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(s=>F.isPointInArea(`${t.x} ${t.y}`,`${s.shape},${s.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,s=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=i.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&Ne(n,s.split(",").map(a=>+a),t,i)}))}render(){return h` <slot name="prompt"></slot>
1102
1122
  <point-container>
1103
- ${vt((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this._imageWidthOriginal||1)*100,a=s/(this._imageHeightOriginal||1)*100,c=16,d=c/(this._imageWidthOriginal||1)*100,p=c/(this._imageHeightOriginal||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),h`
1123
+ ${vt((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this._imageWidthOriginal||1)*100,a=s/(this._imageHeightOriginal||1)*100,l=16,d=l/(this._imageWidthOriginal||1)*100,p=l/(this._imageHeightOriginal||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),h`
1104
1124
  <button
1105
1125
  part="point${m}"
1106
1126
  style=${Di({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${n}%`,top:`${a}%`,width:`min(${d}%, 1rem)`,height:`min(${p}%, 1rem)`,minWidth:`min(${d}%, 1rem)`,minHeight:`min(${p}%, 1rem)`,borderRadius:"50%",background:"red"})}
@@ -1131,7 +1151,7 @@ Make sure to test your application with a production build as repeat registratio
1131
1151
  height: auto;
1132
1152
  display: block;
1133
1153
  }
1134
- `],l([u({type:Number,attribute:"max-choices"})],de.prototype,"maxChoices",2),l([u({type:Number,attribute:"min-choices"})],de.prototype,"minChoices",2),l([E()],de.prototype,"response",2),l([E()],de.prototype,"_correctAreas",2),l([E()],de.prototype,"_responseCorrection",2),de=l([g("qti-select-point-interaction")],de);var Ee=class extends ae(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
1154
+ `],c([u({type:Number,attribute:"max-choices"})],de.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],de.prototype,"minChoices",2),c([E()],de.prototype,"response",2),c([E()],de.prototype,"_correctAreas",2),c([E()],de.prototype,"_responseCorrection",2),de=c([g("qti-select-point-interaction")],de);var Ee=class extends ae(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
1135
1155
  <div part="cha"></div>
1136
1156
  </div>
1137
1157
  ${this.marker?h`<div id="label">${this.marker}</div>`:S}
@@ -1152,7 +1172,7 @@ Make sure to test your application with a production build as repeat registratio
1152
1172
  align-items: center;
1153
1173
  justify-content: center;
1154
1174
  }
1155
- `,l([u({type:String,attribute:"template-identifier"})],Ee.prototype,"templateIdentifier",2),l([u({type:String,attribute:"show-hide"})],Ee.prototype,"showHide",2),l([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ee.prototype,"fixed",2),l([u({type:String,attribute:!1})],Ee.prototype,"marker",2),Ee=l([g("qti-simple-choice")],Ee);var _o=x`
1175
+ `,c([u({type:String,attribute:"template-identifier"})],Ee.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],Ee.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ee.prototype,"fixed",2),c([u({type:String,attribute:!1})],Ee.prototype,"marker",2),Ee=c([g("qti-simple-choice")],Ee);var _o=x`
1156
1176
  :host {
1157
1177
  display: block;
1158
1178
  --show-bounds: true;
@@ -1254,7 +1274,7 @@ Make sure to test your application with a production build as repeat registratio
1254
1274
  `:null}
1255
1275
  </div>
1256
1276
  </div>
1257
- `}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,s=Math.min(1,Math.max(0,i/t.width)),n=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};Ce.styles=_o,l([lt("#rail")],Ce.prototype,"_rail",2),l([u({type:Number,attribute:"lower-bound"})],Ce.prototype,"min",2),l([u({type:Number,attribute:"upper-bound"})],Ce.prototype,"max",2),l([u({type:Number,attribute:"step"})],Ce.prototype,"step",2),Ce=l([g("qti-slider-interaction")],Ce);var ar=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),ar(t,r);return!0},Xr=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},To=o=>{for(let r;r=o._$AM;o=r){let e=r._$AN;if(e===void 0)r._$AN=e=new Set;else if(e.has(o))break;e.add(o),kn(r)}};function An(o){this._$AN!==void 0?(Xr(this),this._$AM=o,To(this)):this._$AM=o}function Rn(o,r=!1,e=0){let t=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(r)if(Array.isArray(t))for(let s=e;s<t.length;s++)ar(t[s],!1),Xr(t[s]);else t!=null&&(ar(t,!1),Xr(t));else ar(this,o)}var kn=o=>{o.type==Oe.CHILD&&(o._$AP??=Rn,o._$AQ??=An)},xt=class extends le{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),To(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(ar(this,r),Xr(this))}setValue(r){if(mo(this._$Ct))this._$Ct._$AI(r,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=r,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Ao=()=>new zi,zi=class{},Hi=new WeakMap,Bh=ee(class extends xt{render(o){return S}update(o,[r]){let e=r!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=r,this.ht=o.options?.host,this.rt(this.ct=o.element)),S}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=Hi.get(r);e===void 0&&(e=new WeakMap,Hi.set(r,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,o),o!==void 0&&this.G.call(this.ht,o)}else this.G.value=o}get lt(){return typeof this.G=="function"?Hi.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ro=x`
1277
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,s=Math.min(1,Math.max(0,i/t.width)),n=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};Ce.styles=_o,c([lt("#rail")],Ce.prototype,"_rail",2),c([u({type:Number,attribute:"lower-bound"})],Ce.prototype,"min",2),c([u({type:Number,attribute:"upper-bound"})],Ce.prototype,"max",2),c([u({type:Number,attribute:"step"})],Ce.prototype,"step",2),Ce=c([g("qti-slider-interaction")],Ce);var ar=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),ar(t,r);return!0},Xr=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},To=o=>{for(let r;r=o._$AM;o=r){let e=r._$AN;if(e===void 0)r._$AN=e=new Set;else if(e.has(o))break;e.add(o),kn(r)}};function An(o){this._$AN!==void 0?(Xr(this),this._$AM=o,To(this)):this._$AM=o}function Rn(o,r=!1,e=0){let t=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(r)if(Array.isArray(t))for(let s=e;s<t.length;s++)ar(t[s],!1),Xr(t[s]);else t!=null&&(ar(t,!1),Xr(t));else ar(this,o)}var kn=o=>{o.type==Oe.CHILD&&(o._$AP??=Rn,o._$AQ??=An)},xt=class extends le{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),To(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(ar(this,r),Xr(this))}setValue(r){if(mo(this._$Ct))this._$Ct._$AI(r,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=r,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Ao=()=>new zi,zi=class{},Hi=new WeakMap,Bh=ee(class extends xt{render(o){return S}update(o,[r]){let e=r!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=r,this.ht=o.options?.host,this.rt(this.ct=o.element)),S}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=Hi.get(r);e===void 0&&(e=new WeakMap,Hi.set(r,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,o),o!==void 0&&this.G.call(this.ht,o)}else this.G.value=o}get lt(){return typeof this.G=="function"?Hi.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ro=x`
1258
1278
  :host {
1259
1279
  display: inline-block;
1260
1280
  }
@@ -1381,7 +1401,7 @@ Make sure to test your application with a production build as repeat registratio
1381
1401
  ?readonly="${this.readonly}"
1382
1402
  />
1383
1403
  ${this._correctResponse?h`<div part="correct">${this._correctResponse}</div>`:S}
1384
- `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};J.styles=Ro,l([u({type:Number,attribute:"expected-length"})],J.prototype,"expectedLength",2),l([u({type:String,attribute:"pattern-mask"})],J.prototype,"patternMask",2),l([u({type:String,attribute:"placeholder-text"})],J.prototype,"placeholderText",2),l([u({type:String,attribute:"data-patternmask-message"})],J.prototype,"dataPatternmaskMessage",2),l([E()],J.prototype,"response",2),l([lt("input")],J.prototype,"_input",2),l([M("response",{waitUntilFirstUpdate:!0})],J.prototype,"_handleValueChange",2),J=l([g("qti-text-entry-interaction")],J);var lr=class extends R{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...R.properties}}render(){return h`
1404
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};J.styles=Ro,c([u({type:Number,attribute:"expected-length"})],J.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],J.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],J.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],J.prototype,"dataPatternmaskMessage",2),c([E()],J.prototype,"response",2),c([lt("input")],J.prototype,"_input",2),c([I("response",{waitUntilFirstUpdate:!0})],J.prototype,"_handleValueChange",2),J=c([g("qti-text-entry-interaction")],J);var lr=class extends R{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...R.properties}}render(){return h`
1385
1405
  <div>
1386
1406
  <slot name="prompt"></slot>
1387
1407
  <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
@@ -1395,15 +1415,15 @@ Make sure to test your application with a production build as repeat registratio
1395
1415
  display: block;
1396
1416
  margin-top: 0.5em;
1397
1417
  }
1398
- `],lr=l([g("qti-upload-interaction")],lr);var ko=x`
1418
+ `],lr=c([g("qti-upload-interaction")],lr);var ko=x`
1399
1419
  :host {
1400
1420
  display: block;
1401
1421
  }
1402
- `;var cr=class extends v{render(){return h`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};cr.styles=ko,cr=l([g("qti-item-body")],cr);var dr=class extends v{render(){return h`<slot></slot>`}process(){let r=new Fi,e=[...this.children];r.process(e)}};dr.styles=[x`
1422
+ `;var cr=class extends v{render(){return h`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};cr.styles=ko,cr=c([g("qti-item-body")],cr);var dr=class extends v{render(){return h`<slot></slot>`}process(){let r=new Fi,e=[...this.children];r.process(e)}};dr.styles=[x`
1403
1423
  :host {
1404
1424
  display: none;
1405
1425
  }
1406
- `],dr=l([g("qti-outcome-processing")],dr);var Fi=class{process(r){for(let e of r)e.process()}};var Gr=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Gr=l([g("qti-prompt")],Gr);var So=`<qti-response-processing>
1426
+ `],dr=c([g("qti-outcome-processing")],dr);var Fi=class{process(r){for(let e of r)e.process()}};var Gr=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Gr=c([g("qti-prompt")],Gr);var So=`<qti-response-processing>
1407
1427
  <qti-response-condition>
1408
1428
  <qti-response-if>
1409
1429
  <qti-match>
@@ -1456,29 +1476,29 @@ Make sure to test your application with a production build as repeat registratio
1456
1476
  :host {
1457
1477
  display: none;
1458
1478
  }
1459
- `],pr=l([g("qti-response-processing")],pr);var pe=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};pe=l([g("qti-rule")],pe);var ur=class extends pe{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Xt(t)}})),t)}};l([u({type:String})],ur.prototype,"identifier",2),l([_({context:$,subscribe:!0}),E()],ur.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ur);var Ui=class extends pe{render(){return h`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",Ui);var Bi=class extends pe{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new ji(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Xt):r!==null?Xt(r):null}},ji=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",Bi);var mr=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",mr);var hr=class extends mr{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",hr);var Wi=class extends hr{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",Wi);var Yr=Symbol("qtiContext");var C=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(s=>s.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context.variables.find(s=>s.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=x`
1479
+ `],pr=c([g("qti-response-processing")],pr);var pe=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};pe=c([g("qti-rule")],pe);var ur=class extends pe{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Xt(t)}})),t)}};c([u({type:String})],ur.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],ur.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ur);var Ui=class extends pe{render(){return h`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",Ui);var Bi=class extends pe{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new ji(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Xt):r!==null?Xt(r):null}},ji=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",Bi);var mr=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",mr);var hr=class extends mr{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",hr);var Wi=class extends hr{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",Wi);var Yr=Symbol("qtiContext");var w=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(s=>s.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context.variables.find(s=>s.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=x`
1460
1480
  slot {
1461
1481
  display: none;
1462
1482
  }
1463
1483
  `}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
1464
- <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};l([E()],C.prototype,"result",2),l([_({context:$,subscribe:!0}),E()],C.prototype,"context",2),l([_({context:Yr,subscribe:!0}),E()],C.prototype,"qtiContext",2);var K=class extends C{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Jr=class extends Sn(K){calculate(){return this.calculateChildren(Array.from(this.children))}};Jr=l([g("qti-and")],Jr);function Sn(o){return class extends o{calculateChildren(e){return e.map(i=>{let s=i;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}var Kr=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};l([u({type:String,attribute:"base-type"})],Kr.prototype,"baseType",2);customElements.define("qti-base-value",Kr);var Xi=class extends C{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",Xi);var Gi=class extends K{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,s=t.value;return i.filter(c=>s.includes(c)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Gi);var Yi=class extends C{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Yi);var Ji={items:[],testOutcomeVariables:[]},ue=Symbol("testContext");var qt=class extends C{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(c=>c.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(c=>c.identifier===t)?.variables.find(c=>c.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let s=this.context.variables.find(n=>n.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};l([u({type:String})],qt.prototype,"identifier",2),l([_({context:$,subscribe:!0}),E()],qt.prototype,"context",2),l([E(),_({context:ue,subscribe:!0})],qt.prototype,"_testContext",2);customElements.define("qti-default",qt);var Zr=class extends C{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};l([u({type:String})],Zr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Zr);var Ki=class extends C{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Ki);var fr=class extends C{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),s=Math.pow(10,t-i-1);return Math.round(e*s)/s}};l([u({type:String,attribute:"rounding-mode"})],fr.prototype,"roundingMode",2),l([u({type:Number})],fr.prototype,"figures",2);customElements.define("qti-round-to",fr);var Qr=class extends C{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):F.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};l([u({type:String})],Qr.prototype,"toleranceMode",2);customElements.define("qti-equal",Qr);var Zi=class extends C{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let s=parseInt(i,10);if(isNaN(s))return console.error("qti-gcd non-numerical value"),null;e.push(s)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this._calculateGcd(e)}_calculateGcd(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",Zi);var Qi=class extends C{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Qi);var es=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",es);var ts=class extends C{getResult(){return null}};customElements.define("qti-null",ts);var rs=class extends C{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",rs);var is=class extends C{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",is);var ss=class extends C{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",ss);var os=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",os);var ei=class extends C{getResult(){let r=this.context.variables.find(s=>s.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let s of t){let n=e.mapEntries.filter(c=>r.baseType==="string"&&!c.caseSensitive?F.compareSingleValues(c.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):F.compareSingleValues(c.mapKey,s,r.baseType)),a=n.reduce((c,d)=>c.mappedValue>d.mappedValue?c:d,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};l([u({type:String})],ei.prototype,"identifier",2);customElements.define("qti-map-response",ei);var ti=class extends C{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,s=new Set;for(let n of t)for(let a of e.areaMapEntries){if(s.has(a.coords))continue;F.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,s.add(a.coords))}return s.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};l([u({type:String})],ti.prototype,"identifier",2);customElements.define("qti-map-response-point",ti);var ri=class extends C{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let s=parseFloat(i.value);if(isNaN(s))return console.error("qti-math-operator non-numerical value"),null;t.push(s)}return this._performOperation(this.name,t)}_performOperation(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],s=t[1];return i===0&&s<=0||i<0&&!Number.isInteger(s)?null:Math.pow(i,s)}case"log_base":{if(t.length!==2)return null;let i=t[0],s=t[1];return i<=0||s<=0||s===1?null:Math.log(i)/Math.log(s)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};l([u({type:String})],ri.prototype,"name",2);customElements.define("qti-math-operator",ri);var ns=class o extends C{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return o.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):F.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!F.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let s=null,n=[...r.value];for(let a of n)if(F.compareSingleValues(i,a,e.baseType)){s=a;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",ns);var as=class extends C{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",as);var ls=class extends C{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",ls);var cs=class extends C{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",cs);var ds=class extends K{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),s=!1;if(typeof i=="string")if(i==="true")s=!0;else if(i==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(s=i);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",ds);var ps=class extends C{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",ps);var us=class extends C{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),s=parseFloat(t.value);if(isNaN(i)||isNaN(s))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&s<=0||i<0&&!Number.isInteger(s))return null;let n;try{n=Math.pow(i,s)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),c=Math.max(0,14-a),d=Math.pow(10,c);n=Math.round(n*d)/d}return n}};customElements.define("qti-power",us);var gr=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?S:h`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};l([u({type:String})],gr.prototype,"identifier",2),l([_({context:$,subscribe:!0}),E()],gr.prototype,"context",2);customElements.define("qti-printed-variable",gr);var ms=class extends C{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",ms);var ii=class extends Mn(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function Mn(o){return class extends o{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=i.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ii);var si=class extends C{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return F.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};l([u({type:String,attribute:"case-sensitive"})],si.prototype,"caseSensitive",2);customElements.define("qti-string-match",si);var hs=class extends C{constructor(){super(),this._expression=new fs(Array.from(this.children))}getResult(){return this._expression.calculate()}},fs=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",hs);var gs=class extends C{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",gs);var Et=class extends C{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let s=this.min+this.step*t;if(s>this.max)break;Number.isInteger(s)&&e.push(s),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};l([u({type:Number})],Et.prototype,"min",2),l([u({type:Number})],Et.prototype,"max",2),l([u({type:Number})],Et.prototype,"step",2);customElements.define("qti-random-integer",Et);var bs=class extends C{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",bs);var vs=class extends C{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}}};customElements.define("qti-delete",vs);var br=class extends C{getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};l([u({type:String})],br.prototype,"n",2),br=l([g("qti-index")],br);var oi=class extends v{render(){return h`<slot></slot>`}};oi=l([g("qti-content-body")],oi);var me=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}};me.styles=x`
1484
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([E()],w.prototype,"result",2),c([_({context:$,subscribe:!0}),E()],w.prototype,"context",2),c([_({context:Yr,subscribe:!0}),E()],w.prototype,"qtiContext",2);var K=class extends w{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Jr=class extends Sn(K){calculate(){return this.calculateChildren(Array.from(this.children))}};Jr=c([g("qti-and")],Jr);function Sn(o){return class extends o{calculateChildren(e){return e.map(i=>{let s=i;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}var Kr=class extends w{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],Kr.prototype,"baseType",2);customElements.define("qti-base-value",Kr);var Xi=class extends w{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",Xi);var Gi=class extends K{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,s=t.value;return i.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Gi);var Yi=class extends w{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Yi);var Ji={items:[],testOutcomeVariables:[]},ue=Symbol("testContext");var qt=class extends w{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(l=>l.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(l=>l.identifier===t)?.variables.find(l=>l.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let s=this.context.variables.find(n=>n.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};c([u({type:String})],qt.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],qt.prototype,"context",2),c([E(),_({context:ue,subscribe:!0})],qt.prototype,"_testContext",2);customElements.define("qti-default",qt);var Zr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};c([u({type:String})],Zr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Zr);var Ki=class extends w{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Ki);var fr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),s=Math.pow(10,t-i-1);return Math.round(e*s)/s}};c([u({type:String,attribute:"rounding-mode"})],fr.prototype,"roundingMode",2),c([u({type:Number})],fr.prototype,"figures",2);customElements.define("qti-round-to",fr);var Qr=class extends w{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):F.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],Qr.prototype,"toleranceMode",2);customElements.define("qti-equal",Qr);var Zi=class extends w{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let s=parseInt(i,10);if(isNaN(s))return console.error("qti-gcd non-numerical value"),null;e.push(s)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this._calculateGcd(e)}_calculateGcd(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",Zi);var Qi=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Qi);var es=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",es);var ts=class extends w{getResult(){return null}};customElements.define("qti-null",ts);var rs=class extends w{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",rs);var is=class extends w{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",is);var ss=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",ss);var os=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",os);var ei=class extends w{getResult(){let r=this.context.variables.find(s=>s.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let s of t){let n=e.mapEntries.filter(l=>r.baseType==="string"&&!l.caseSensitive?F.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):F.compareSingleValues(l.mapKey,s,r.baseType)),a=n.reduce((l,d)=>l.mappedValue>d.mappedValue?l:d,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ei.prototype,"identifier",2);customElements.define("qti-map-response",ei);var ti=class extends w{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,s=new Set;for(let n of t)for(let a of e.areaMapEntries){if(s.has(a.coords))continue;F.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,s.add(a.coords))}return s.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ti.prototype,"identifier",2);customElements.define("qti-map-response-point",ti);var ri=class extends w{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let s=parseFloat(i.value);if(isNaN(s))return console.error("qti-math-operator non-numerical value"),null;t.push(s)}return this._performOperation(this.name,t)}_performOperation(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],s=t[1];return i===0&&s<=0||i<0&&!Number.isInteger(s)?null:Math.pow(i,s)}case"log_base":{if(t.length!==2)return null;let i=t[0],s=t[1];return i<=0||s<=0||s===1?null:Math.log(i)/Math.log(s)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};c([u({type:String})],ri.prototype,"name",2);customElements.define("qti-math-operator",ri);var ns=class o extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return o.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):F.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!F.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let s=null,n=[...r.value];for(let a of n)if(F.compareSingleValues(i,a,e.baseType)){s=a;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",ns);var as=class extends w{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",as);var ls=class extends w{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",ls);var cs=class extends w{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",cs);var ds=class extends K{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),s=!1;if(typeof i=="string")if(i==="true")s=!0;else if(i==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(s=i);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",ds);var ps=class extends w{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",ps);var us=class extends w{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),s=parseFloat(t.value);if(isNaN(i)||isNaN(s))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&s<=0||i<0&&!Number.isInteger(s))return null;let n;try{n=Math.pow(i,s)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),l=Math.max(0,14-a),d=Math.pow(10,l);n=Math.round(n*d)/d}return n}};customElements.define("qti-power",us);var gr=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?S:h`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],gr.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],gr.prototype,"context",2);customElements.define("qti-printed-variable",gr);var ms=class extends w{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",ms);var ii=class extends Mn(w){getResult(){return this.calculateChildren(Array.from(this.children))}};function Mn(o){return class extends o{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=i.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ii);var si=class extends w{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return F.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],si.prototype,"caseSensitive",2);customElements.define("qti-string-match",si);var hs=class extends w{constructor(){super(),this._expression=new fs(Array.from(this.children))}getResult(){return this._expression.calculate()}},fs=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",hs);var gs=class extends w{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",gs);var Et=class extends w{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let s=this.min+this.step*t;if(s>this.max)break;Number.isInteger(s)&&e.push(s),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};c([u({type:Number})],Et.prototype,"min",2),c([u({type:Number})],Et.prototype,"max",2),c([u({type:Number})],Et.prototype,"step",2);customElements.define("qti-random-integer",Et);var bs=class extends w{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",bs);var vs=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}}};customElements.define("qti-delete",vs);var br=class extends w{getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};c([u({type:String})],br.prototype,"n",2),br=c([g("qti-index")],br);var oi=class extends v{render(){return h`<slot></slot>`}};oi=c([g("qti-content-body")],oi);var me=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}};me.styles=x`
1465
1485
  :host {
1466
1486
  display: block;
1467
1487
  }
1468
- `,l([u({type:String})],me.prototype,"id",2),l([u({type:String})],me.prototype,"use",2),l([u({type:String})],me.prototype,"view",2),l([u({type:String,attribute:"class"})],me.prototype,"classNames",2),l([M("classNames",{waitUntilFirstUpdate:!0})],me.prototype,"handleclassNamesChange",1),me=l([g("qti-rubric-block")],me);var ni=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};ni=l([g("qti-stylesheet")],ni);var De=class extends v{render(){return h`<slot></slot>`}defaultValues(r){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||r==="multiple"||r==="ordered"?t:t[0]}};De=l([g("qti-variabledeclaration")],De);var he=class extends De{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let s=parseFloat(i.getAttribute("source-value")),n=parseFloat(i.getAttribute("target-value"));(isNaN(s)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,n)}return t}return null}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:e,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};t.value=e,(t.value===null||t.value==null)&&(t.baseType==="integer"||t.baseType==="float")&&(t.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};he.styles=[x`
1488
+ `,c([u({type:String})],me.prototype,"id",2),c([u({type:String})],me.prototype,"use",2),c([u({type:String})],me.prototype,"view",2),c([u({type:String,attribute:"class"})],me.prototype,"classNames",2),c([I("classNames",{waitUntilFirstUpdate:!0})],me.prototype,"handleclassNamesChange",1),me=c([g("qti-rubric-block")],me);var ni=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};ni=c([g("qti-stylesheet")],ni);var De=class extends v{render(){return h`<slot></slot>`}defaultValues(r){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||r==="multiple"||r==="ordered"?t:t[0]}};De=c([g("qti-variabledeclaration")],De);var he=class extends De{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let s=parseFloat(i.getAttribute("source-value")),n=parseFloat(i.getAttribute("target-value"));(isNaN(s)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,n)}return t}return null}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:e,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};t.value=e,(t.value===null||t.value==null)&&(t.baseType==="integer"||t.baseType==="float")&&(t.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};he.styles=[x`
1469
1489
  :host {
1470
1490
  display: none;
1471
1491
  }
1472
- `],l([u({type:String,attribute:"base-type"})],he.prototype,"baseType",2),l([u({type:String,attribute:"external-scored"})],he.prototype,"externalScored",2),l([u({type:String})],he.prototype,"identifier",2),l([u({type:String})],he.prototype,"cardinality",2),l([_({context:$,subscribe:!0}),E()],he.prototype,"itemContext",2),he=l([g("qti-outcome-declaration")],he);var we=class extends De{render(){let r=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(r,null,2)}`}connectedCallback(){super.connectedCallback();let r=this.defaultValues(this.cardinality),e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,defaultValue:r,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};e.value=r,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let r,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)r=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){r=[];for(let i=0;i<t.length;i++)r.push(t[i].textContent.trim()),t[i].remove()}}return r}get mapping(){let r=this.querySelector("qti-mapping"),e=parseFloat(r?.getAttribute("lower-bound")),t=parseFloat(r?.getAttribute("upper-bound"));return{defaultValue:Number(r?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(r?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!1}))}}get areaMapping(){let r=this.querySelector("qti-area-mapping"),e=Number(r?.getAttribute("default-value"))||0,t=parseFloat(r?.getAttribute("lower-bound")),i=parseFloat(r?.getAttribute("upper-bound")),s=Array.from(r?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,areaMapEntries:s}}};we.styles=[x`
1492
+ `],c([u({type:String,attribute:"base-type"})],he.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],he.prototype,"externalScored",2),c([u({type:String})],he.prototype,"identifier",2),c([u({type:String})],he.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),E()],he.prototype,"itemContext",2),he=c([g("qti-outcome-declaration")],he);var we=class extends De{render(){let r=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(r,null,2)}`}connectedCallback(){super.connectedCallback();let r=this.defaultValues(this.cardinality),e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,defaultValue:r,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};e.value=r,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let r,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)r=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){r=[];for(let i=0;i<t.length;i++)r.push(t[i].textContent.trim()),t[i].remove()}}return r}get mapping(){let r=this.querySelector("qti-mapping"),e=parseFloat(r?.getAttribute("lower-bound")),t=parseFloat(r?.getAttribute("upper-bound"));return{defaultValue:Number(r?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(r?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!1}))}}get areaMapping(){let r=this.querySelector("qti-area-mapping"),e=Number(r?.getAttribute("default-value"))||0,t=parseFloat(r?.getAttribute("lower-bound")),i=parseFloat(r?.getAttribute("upper-bound")),s=Array.from(r?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,areaMapEntries:s}}};we.styles=[x`
1473
1493
  :host {
1474
1494
  display: none;
1475
1495
  }
1476
- `],l([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),l([u({type:String})],we.prototype,"identifier",2),l([u({type:String})],we.prototype,"cardinality",2),l([_({context:$,subscribe:!0}),E()],we.prototype,"itemContext",2),we=l([g("qti-response-declaration")],we);var Lo=(s=>(s.ITEM_NOT_FOUND="item-not-found",s.SECTION_NOT_FOUND="section-not-found",s.LOAD_ERROR="load-error",s.NETWORK_ERROR="network-error",s.TIMEOUT_ERROR="timeout-error",s))(Lo||{}),$o=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.showLoadingIndicators=!0;this.postLoadTransformCallback=null;this._navigationInProgress=!1;this._activeRequests=[];this._lastError=null;this._lastNavigationRequestId=null;this._targetNavigation=null;this.addEventListener("qti-request-navigation",async({detail:s})=>{if(!s?.id)return;let n=`nav_${Date.now()}_${Math.random()}`;this._lastNavigationRequestId=n;try{if(this._navigationInProgress=!0,this._lastError=null,this._dispatchStatusEvent({loading:!0,type:s.type,id:s.id}),this._cancelActiveRequests(),this._targetNavigation={type:s.type,id:s.id},s.type==="item"?await this._navigateToItem(s.id):s.type==="section"&&await this._navigateToSection(s.id),this._lastNavigationRequestId!==n){console.log("Navigation was superseded by a newer request");return}}catch(a){if(this._lastNavigationRequestId===n){let c=this._normalizeError(a,s.type,s.id);this._lastError=c,this._dispatchErrorEvent(c),console.error(`Navigation error (${c.type}):`,c.message,c.details)}}finally{this._lastNavigationRequestId===n&&(this._navigationInProgress=!1,this._dispatchStatusEvent({loading:!1,type:s.type,id:s.id}))}}),this.addEventListener("qti-assessment-test-connected",s=>{this._testElement=s.detail,this._initializeNavigation()})}_initializeNavigation(){let i;this.navigate==="section"&&(i=this._testElement.querySelector("qti-assessment-section")?.identifier),this.navigate==="item"&&(i=this.sessionContext.navItemRefId??this._testElement.querySelector("qti-assessment-item-ref")?.identifier),i&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:this.navigate==="section"?"section":"item",id:i},bubbles:!0,composed:!0}))}navigateTo(i,s){s||(i==="section"&&(s=this._testElement?.querySelector("qti-assessment-section")?.identifier),i==="item"&&(s=this._testElement?.querySelector("qti-assessment-item-ref")?.identifier)),this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}async _navigateToItem(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw{type:"item-not-found",message:`Item with identifier "${i}" not found.`,itemId:i};let n=s.closest("qti-test-part")?.identifier,a=s.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:i,navItemLoading:!0};try{await this._loadItems([i])}finally{this.sessionContext={...this.sessionContext,navItemLoading:!1}}}async _navigateToSection(i){let s=this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`);if(!s)throw{type:"section-not-found",message:`Section with identifier "${i}" not found.`,sectionId:i};let n=s.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:i,navItemRefId:null,navItemLoading:!0};try{let a=this._getSectionItemIds(i);await this._loadItems(a)}finally{this.sessionContext={...this.sessionContext,navItemLoading:!1}}}_normalizeError(i,s,n){return i&&i.type&&Object.values(Lo).includes(i.type)?i:i instanceof DOMException&&i.name==="AbortError"?{type:"network-error",message:"Navigation was cancelled because a new navigation was requested.",details:i}:i.name==="TimeoutError"||i.message&&i.message.includes("timeout")?{type:"timeout-error",message:"Request timed out. Please check your network connection.",details:i}:i instanceof TypeError&&i.message.includes("network")?{type:"network-error",message:"A network error occurred. Please check your connection.",details:i}:{type:"load-error",message:`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchErrorEvent(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchStatusEvent(i){this.showLoadingIndicators&&this.dispatchEvent(new CustomEvent("qti-navigation-status",{detail:i,bubbles:!0,composed:!0}))}_cancelActiveRequests(){this._activeRequests.length>0&&(console.info(`Cancelling ${this._activeRequests.length} pending requests`),this._activeRequests.forEach(i=>{i&&i.readyState!==4&&i.abort()}),this._activeRequests=[])}async _loadItems(i){if(!this._testElement||i.length===0)return;let s=i.map(c=>this._testElement.querySelector(`qti-assessment-item-ref[identifier="${c}"]`)),n=s.reduce((c,d,p)=>(d||c.push(i[p]),c),[]);if(n.length>0)throw{type:"item-not-found",message:`One or more items not found: ${n.join(", ")}`,details:{missingItems:n}};this._clearLoadedItems();let a=s.map(async c=>{if(!c)return null;let d=new Promise((p,m)=>{setTimeout(()=>{m({name:"TimeoutError",message:`Request for item ${c.identifier} timed out after ${this.requestTimeout}ms`})},this.requestTimeout)});try{let{promise:p,request:m}=Je(this.cacheTransform).load(c.href);m instanceof XMLHttpRequest&&this._activeRequests.push(m);let f=await Promise.race([p,d]),b=f;return console.log(`Loaded item 123: ${c.identifier}`),this.postLoadTransformCallback&&(b=await this.postLoadTransformCallback(f,c)),{itemRef:c,doc:b.htmlDoc(),request:m}}catch(p){if(p instanceof DOMException&&p.name==="AbortError"||p&&p.name==="TimeoutError")return console.log(`Request for item ${c.identifier} was ${p.name==="TimeoutError"?"timed out":"aborted"}`),null;throw p.itemId=c.identifier,p}});try{let d=(await Promise.all(a)).filter(p=>p!==null);if(d.forEach(({itemRef:p,doc:m})=>{p&&m&&(p.xmlDoc=m)}),this._activeRequests=[],requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:d.map(({itemRef:p})=>({identifier:p?.identifier,element:p})),bubbles:!0,composed:!0}))}),d.length===0&&i.length>0)throw{type:"load-error",message:"All item requests failed to load",details:{itemIds:i}};return d}catch(c){throw console.error("Error loading items:",c),c}}_getSectionItemIds(i){if(!this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`))throw{type:"section-not-found",message:`Section with identifier "${i}" not found.`,sectionId:i};return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(n=>n.identifier)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-test qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}retryNavigation(){if(this._lastError){let i=this._lastError.itemId?"item":"section",s=this._lastError.itemId||this._lastError.sectionId;s&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}else this._targetNavigation&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:this._targetNavigation,bubbles:!0,composed:!0}))}}return l([u({type:String})],r.prototype,"navigate",2),l([u({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),l([u({type:Number})],r.prototype,"requestTimeout",2),l([u({type:Boolean})],r.prototype,"showLoadingIndicators",2),l([u({type:Function})],r.prototype,"postLoadTransformCallback",2),r};var Oo=o=>{class r extends o{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;s&&s.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var ys={view:"candidate"},He=Symbol("testContext");var Ct=class extends v{constructor(){super();this.testContext=Ji;this.sessionContext=ys;this._updateItemInTestContext=e=>{let t=e._context,i=t.identifier,s=t.variables,n=this.testContext.items.find(a=>a?.identifier===i);if(!n){console.warn(`Item IDs between assessment.xml and item.xml should match: ${i} is not found!`);return}n.variables?.length===1?this._updateItemVariablesInTestContext(i,s):e.variables=[...n.variables||[]]};this.addEventListener("qti-assessment-test-connected",e=>{if(this.testContext=Ji,this.sessionContext=ys,this.testContext&&this.testContext.items.length>0)return;this._testElement=e.detail;let t=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(i=>({href:i.href,identifier:i.identifier,category:i.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:t}}),this.addEventListener("qti-assessment-item-connected",e=>{let t=e.detail,i=t.closest("qti-assessment-item-ref")?.identifier;i&&(t.assessmentItemRefId=i),this._updateItemInTestContext(e.detail)}),this.addEventListener("qti-item-context-updated",e=>{this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail.itemContext.variables)})}updateItemVariables(e,t){let i=this.testContext.items.find(n=>n.identifier===e);i&&(i.variables=i.variables.map(n=>{let a=t.find(c=>c.identifier===n.identifier);return a?{...n,...a}:n}));let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e}"]`);s&&s.assessmentItem&&s.assessmentItem&&(s.assessmentItem.variables=t)}_updateItemVariablesInTestContext(e,t){this.testContext={...this.testContext,items:this.testContext.items.map(i=>i.identifier!==e?i:{...i,variables:t.map(s=>{let n=i.variables.find(a=>a.identifier===s.identifier);return n?{...n,...s}:s})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}};l([u({attribute:!1,type:Object}),X({context:ue})],Ct.prototype,"testContext",2),l([u({attribute:!1,type:Object}),X({context:He})],Ct.prototype,"sessionContext",2);var Po=o=>{class r extends o{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:s,value:n}=i.detail;this.updateOutcomeVariable(s,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let s=this.getOutcome(t);if(!s){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:s.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var ai=class extends $o(Oo(Po(Ct))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return h`<slot></slot>`}};ai=l([g("qti-test")],ai);var li=["this"],No=["+","-","!"],Vo=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],xs={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},ci=13;var In=["==","!=","<=",">=","||","&&","??","|>"],Ln=["===","!=="],A;(function(o){o[o.STRING=1]="STRING",o[o.IDENTIFIER=2]="IDENTIFIER",o[o.DOT=3]="DOT",o[o.COMMA=4]="COMMA",o[o.COLON=5]="COLON",o[o.INTEGER=6]="INTEGER",o[o.DECIMAL=7]="DECIMAL",o[o.OPERATOR=8]="OPERATOR",o[o.GROUPER=9]="GROUPER",o[o.KEYWORD=10]="KEYWORD",o[o.ARROW=11]="ARROW"})(A||(A={}));var fe=(o,r,e=0)=>({kind:o,value:r,precedence:e}),$n=o=>o===9||o===10||o===13||o===32,Do=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),On=o=>Do(o)||vr(o),Pn=o=>li.indexOf(o)!==-1,Nn=o=>o===34||o===39,vr=o=>48<=o&&o<=57,Vn=o=>o===43||o===45||o===42||o===47||o===33||o===38||o===37||o===60||o===61||o===62||o===63||o===94||o===124,Dn=o=>o===40||o===41||o===91||o===93||o===123||o===125,Hn=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
1477
- `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),di=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;$n(this.#t);)this.#e(!0);if(Nn(this.#t))return this.#l();if(Do(this.#t))return this.#d();if(vr(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Vn(this.#t))return this.#h();if(Dn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=fe(A.STRING,Hn(this.#r()));return this.#e(),t}#d(){do this.#e();while(On(this.#t));let r=this.#r(),e=Pn(r)?A.KEYWORD:A.IDENTIFIER;return fe(e,r)}#p(){do this.#e();while(vr(this.#t));return this.#t===46?this.#a():fe(A.INTEGER,this.#r())}#a(){return this.#e(),vr(this.#t)?this.#m():(this.#o(),fe(A.DOT,".",ci))}#u(){return this.#e(!0),fe(A.COMMA,",")}#c(){return this.#e(!0),fe(A.COLON,":")}#m(){do this.#e();while(vr(this.#t));return fe(A.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(Ln.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),fe(A.ARROW,r);In.indexOf(r)!==-1&&this.#e()}return r=this.#r(),fe(A.OPERATOR,r,xs[r])}#f(){let r=String.fromCharCode(this.#t),e=fe(A.GROUPER,r,xs[r]);return this.#e(!0),e}};var qs=(o,r)=>new yr(o,r).parse(),yr=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new di(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(A.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(A.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(A.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(A.KEYWORD))break;if(this._matches(A.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#i.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(r,e){if(Vo.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===A.OPERATOR||this.#s===A.DOT||this.#s===A.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(A.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(A.INTEGER))return this.#b(r);if(this._matches(A.DECIMAL))return this.#v(r)}if(No.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),ci);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(A.OPERATOR,"?");let e=this.#o();this.#r(A.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case A.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw li.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case A.IDENTIFIER:return this.#f();case A.STRING:return this.#E();case A.INTEGER:return this.#b();case A.DECIMAL:return this.#v();case A.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case A.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(A.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(A.GROUPER,"}"))break;let e=this.#e;(this._matches(A.STRING)||this._matches(A.IDENTIFIER))&&this.#r(),this.#r(A.COLON),r[e]=this.#o()}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(A.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(A.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(A.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(A.COMMA));return this.#r(A.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(A.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(A.ARROW)){this.#r();let e=this.#o(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#E(){let r=this.#i.literal(this.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:Ho,fromEntries:zn}=Object,Fn={"+":(o,r)=>o+r,"-":(o,r)=>o-r,"*":(o,r)=>o*r,"/":(o,r)=>o/r,"%":(o,r)=>o%r,"==":(o,r)=>o==r,"!=":(o,r)=>o!=r,"===":(o,r)=>o===r,"!==":(o,r)=>o!==r,">":(o,r)=>o>r,">=":(o,r)=>o>=r,"<":(o,r)=>o<r,"<=":(o,r)=>o<=r,"||":(o,r)=>o||r,"&&":(o,r)=>o&&r,"??":(o,r)=>o??r,"|":(o,r)=>r(o),"|>":(o,r)=>r(o)},Un={"+":o=>o,"-":o=>-o,"!":o=>!o},pi=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=Un[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Fn[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(s){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(s),a,c;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(s),c=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(s),c=this.left.argument.evaluate(s)):this.left.type==="ID"&&(a=s,c=this.left.value),a===void 0?void 0:a[c]=n}return i(this.left.evaluate(s),this.right.evaluate(s))},getIds(s){return this.left.getIds(s),this.right.getIds(s),s}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let s=this.receiver.evaluate(i),n=this.method?s:i?.this??i,a=this.method?s?.[e]:s,d=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(s=>s?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let s=this.entries[i];s&&(t[i]=s.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,s=this.body;return function(...n){let a=zn(i.map((d,p)=>[d,n[p]])),c=new Proxy(t??{},{set(d,p,m){return Ho(a,p)&&(a[p]=m),d[p]=m},get(d,p){return Ho(a,p)?a[p]:d[p]}});return s.evaluate(c)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Es=null,zo={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){Es??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Es))return void(e[Es]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(o,r){o._$litDirective$=r},getAttributePartCommittedValue:(o,r,e)=>{let t=P;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:Bn,PropertyPart:jn,BooleanAttributePart:Wn,EventPart:Xn}=zo,ws=new pi,Cs=new Map,Fo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ui=(o,r)=>{let e=Cs.get(o);if(e===void 0){if(Cs.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new yr(t,ws).parse(),Cs.set(o,e)}}return e?.evaluate(r)},Gn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ui(i,r))return mi(o,r,e,t)},Uo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Bo=o=>/(?:\\{{)|(?:\\}})/g.test(o),xr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Yn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ui(i,r);if(!s[Symbol.iterator])return S;let n=qr(o),a=-1,c=[];for(let d of s){a++;let p=Object.create(r);p.item=d,p.index=a,p.this=r.this??r;let m=[];for(let b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let f={_$litType$:n,values:m};c.push(f)}return c}},Wo={if:Gn,repeat:Yn},Z=(o,r=Wo,e={},t)=>{let s=qr(o).renderers;if(t){let a=qr(t).renderers,c=s.super;c!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(f,b,y)=>mi(t,f,b,y)},c(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>mi(o,n,r,e)};var mi=(o,r,e=Wo,t={})=>{let i=qr(o),s=[];for(let a of i.parts){let c=a.update(r,e,t);a.type===1?s.push(...c):s.push(c)}return{_$litType$:i,values:s}},jo=new Map,qr=o=>{let r=jo.get(o);return r===void 0&&jo.set(o,r=Jn(o)),r},Jn=o=>{let r={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,s=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let c=n.getAttribute("type"),d=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||c!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),s.push(n);let m;if(p!==null){let f=p.trim(),b=f.startsWith("{{")&&f.endsWith("}}");m=(y,w,k)=>{let q=n.getAttribute("data"),T=q===null?void 0:ui(q,y);return(b?ui(f,y):k[p])?.(T,w,k)}}else c!==null?m=(f,b,y)=>{let w=b[c];return w?.(n,f,b,y)}:(d==="super"?r.renderers.super=(f,b,y)=>{let w=y.super,k=qr(n);return y={...y,...k.renderers},w(f,b,y)}:r.renderers[d]=(f,b,y)=>mi(n,f,b,y),m=(f,b,y)=>{let w=y[d];return w?.(f,b,y)});r.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let c of a){let d=n.getAttribute(c),p=d.split(Uo);if(p.length===1){Bo(d)&&n.setAttribute(c,xr(d));continue}n.removeAttribute(c);let m=c,f=Bn,b=c[0];b==="."?(m=Fo(c.substring(1)),f=jn):b==="?"?(m=c.substring(1),f=Wn):b==="@"&&(m=Fo(c.substring(1)),f=Xn);let y=[xr(p[0])],w=[];for(let k=1;k<p.length;k+=2){let q=p[k];w.push(qs(q,ws)),y.push(xr(p[k+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:f,update:(k,q,T)=>w.map(L=>L.evaluate(k))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,c=a.split(Uo);c.length>1?n.textContent=xr(c[0]):Bo(a)&&(n.textContent=xr(a));for(let d=1;d<c.length;d+=2){let p=c[d],m=qs(p,ws);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});let f=new Text(c[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of s)n.remove();return r};var Xo={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback();let e=this.getRootNode().host.closest("qti-test").querySelector("template[item-ref]");e&&(this.myTemplate=Z(e)),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};l([u({type:String})],_e.prototype,"category",2),l([u({type:String})],_e.prototype,"identifier",2),l([u({type:Boolean,converter:Xo})],_e.prototype,"required",2),l([u({type:Boolean,converter:Xo})],_e.prototype,"fixed",2),l([u({type:String})],_e.prototype,"href",2),l([u({type:Object,attribute:!1})],_e.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",_e);var _s={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Te=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};l([u({type:String})],Te.prototype,"identifier",2),l([u({type:String})],Te.prototype,"required",2),l([u({type:Boolean,converter:_s})],Te.prototype,"fixed",2),l([u({type:Boolean,converter:_s})],Te.prototype,"visible",2),l([u({type:Boolean,converter:_s,attribute:"keep-together"})],Te.prototype,"keepTogether",2),l([_({context:ue,subscribe:!0})],Te.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",Te);var et=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([u({type:String})],et.prototype,"identifier",2),l([u({type:String})],et.prototype,"title",1),l([_({context:ue,subscribe:!0})],et.prototype,"_testContext",2),et=l([g("qti-assessment-test")],et);var Ae=class extends v{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([u({type:String})],Ae.prototype,"identifier",2),l([u({type:String})],Ae.prototype,"class",2),l([u({type:String,attribute:"navigation-mode"})],Ae.prototype,"navigationMode",2),l([u({type:String,attribute:"submission-mode"})],Ae.prototype,"submissionMode",2),Ae=l([g("qti-test-part")],Ae);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ae);var Er=class extends Ze{render(){return h``}};Er.styles=x`
1496
+ `],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),E()],we.prototype,"itemContext",2),we=c([g("qti-response-declaration")],we);var Lo=(s=>(s.ITEM_NOT_FOUND="item-not-found",s.SECTION_NOT_FOUND="section-not-found",s.LOAD_ERROR="load-error",s.NETWORK_ERROR="network-error",s.TIMEOUT_ERROR="timeout-error",s))(Lo||{}),$o=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.showLoadingIndicators=!0;this.postLoadTransformCallback=null;this._navigationInProgress=!1;this._activeRequests=[];this._lastError=null;this._lastNavigationRequestId=null;this._targetNavigation=null;this.addEventListener("qti-request-navigation",async({detail:s})=>{if(!s?.id)return;let n=`nav_${Date.now()}_${Math.random()}`;this._lastNavigationRequestId=n;try{if(this._navigationInProgress=!0,this._lastError=null,this._dispatchStatusEvent({loading:!0,type:s.type,id:s.id}),this._cancelActiveRequests(),this._targetNavigation={type:s.type,id:s.id},s.type==="item"?await this._navigateToItem(s.id):s.type==="section"&&await this._navigateToSection(s.id),this._lastNavigationRequestId!==n){console.log("Navigation was superseded by a newer request");return}}catch(a){if(this._lastNavigationRequestId===n){let l=this._normalizeError(a,s.type,s.id);this._lastError=l,this._dispatchErrorEvent(l),console.error(`Navigation error (${l.type}):`,l.message,l.details)}}finally{this._lastNavigationRequestId===n&&(this._navigationInProgress=!1,this._dispatchStatusEvent({loading:!1,type:s.type,id:s.id}))}}),this.addEventListener("qti-assessment-test-connected",s=>{this._testElement=s.detail,this._initializeNavigation()})}_initializeNavigation(){let i;this.navigate==="section"&&(i=this._testElement.querySelector("qti-assessment-section")?.identifier),this.navigate==="item"&&(i=this.sessionContext.navItemRefId??this._testElement.querySelector("qti-assessment-item-ref")?.identifier),i&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:this.navigate==="section"?"section":"item",id:i},bubbles:!0,composed:!0}))}navigateTo(i,s){s||(i==="section"&&(s=this._testElement?.querySelector("qti-assessment-section")?.identifier),i==="item"&&(s=this._testElement?.querySelector("qti-assessment-item-ref")?.identifier)),this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}async _navigateToItem(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw{type:"item-not-found",message:`Item with identifier "${i}" not found.`,itemId:i};let n=s.closest("qti-test-part")?.identifier,a=s.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:i,navItemLoading:!0};try{await this._loadItems([i])}finally{this.sessionContext={...this.sessionContext,navItemLoading:!1}}}async _navigateToSection(i){let s=this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`);if(!s)throw{type:"section-not-found",message:`Section with identifier "${i}" not found.`,sectionId:i};let n=s.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:i,navItemRefId:null,navItemLoading:!0};try{let a=this._getSectionItemIds(i);await this._loadItems(a)}finally{this.sessionContext={...this.sessionContext,navItemLoading:!1}}}_normalizeError(i,s,n){return i&&i.type&&Object.values(Lo).includes(i.type)?i:i instanceof DOMException&&i.name==="AbortError"?{type:"network-error",message:"Navigation was cancelled because a new navigation was requested.",details:i}:i.name==="TimeoutError"||i.message&&i.message.includes("timeout")?{type:"timeout-error",message:"Request timed out. Please check your network connection.",details:i}:i instanceof TypeError&&i.message.includes("network")?{type:"network-error",message:"A network error occurred. Please check your connection.",details:i}:{type:"load-error",message:`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchErrorEvent(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchStatusEvent(i){this.showLoadingIndicators&&this.dispatchEvent(new CustomEvent("qti-navigation-status",{detail:i,bubbles:!0,composed:!0}))}_cancelActiveRequests(){this._activeRequests.length>0&&(console.info(`Cancelling ${this._activeRequests.length} pending requests`),this._activeRequests.forEach(i=>{i&&i.readyState!==4&&i.abort()}),this._activeRequests=[])}async _loadItems(i){if(!this._testElement||i.length===0)return;let s=i.map(l=>this._testElement.querySelector(`qti-assessment-item-ref[identifier="${l}"]`)),n=s.reduce((l,d,p)=>(d||l.push(i[p]),l),[]);if(n.length>0)throw{type:"item-not-found",message:`One or more items not found: ${n.join(", ")}`,details:{missingItems:n}};this._clearLoadedItems();let a=s.map(async l=>{if(!l)return null;let d=new Promise((p,m)=>{setTimeout(()=>{m({name:"TimeoutError",message:`Request for item ${l.identifier} timed out after ${this.requestTimeout}ms`})},this.requestTimeout)});try{let{promise:p,request:m}=Je(this.cacheTransform).load(l.href);m instanceof XMLHttpRequest&&this._activeRequests.push(m);let f=await Promise.race([p,d]),b=f;return console.log(`Loaded item 123: ${l.identifier}`),this.postLoadTransformCallback&&(b=await this.postLoadTransformCallback(f,l)),{itemRef:l,doc:b.htmlDoc(),request:m}}catch(p){if(p instanceof DOMException&&p.name==="AbortError"||p&&p.name==="TimeoutError")return console.log(`Request for item ${l.identifier} was ${p.name==="TimeoutError"?"timed out":"aborted"}`),null;throw p.itemId=l.identifier,p}});try{let d=(await Promise.all(a)).filter(p=>p!==null);if(d.forEach(({itemRef:p,doc:m})=>{p&&m&&(p.xmlDoc=m)}),this._activeRequests=[],requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:d.map(({itemRef:p})=>({identifier:p?.identifier,element:p})),bubbles:!0,composed:!0}))}),d.length===0&&i.length>0)throw{type:"load-error",message:"All item requests failed to load",details:{itemIds:i}};return d}catch(l){throw console.error("Error loading items:",l),l}}_getSectionItemIds(i){if(!this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`))throw{type:"section-not-found",message:`Section with identifier "${i}" not found.`,sectionId:i};return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(n=>n.identifier)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-test qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}retryNavigation(){if(this._lastError){let i=this._lastError.itemId?"item":"section",s=this._lastError.itemId||this._lastError.sectionId;s&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}else this._targetNavigation&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:this._targetNavigation,bubbles:!0,composed:!0}))}}return c([u({type:String})],r.prototype,"navigate",2),c([u({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),c([u({type:Number})],r.prototype,"requestTimeout",2),c([u({type:Boolean})],r.prototype,"showLoadingIndicators",2),c([u({type:Function})],r.prototype,"postLoadTransformCallback",2),r};var Oo=o=>{class r extends o{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;s&&s.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var ys={view:"candidate"},He=Symbol("testContext");var Ct=class extends v{constructor(){super();this.testContext=Ji;this.sessionContext=ys;this._updateItemInTestContext=e=>{let t=e._context,i=t.identifier,s=t.variables,n=this.testContext.items.find(a=>a?.identifier===i);if(!n){console.warn(`Item IDs between assessment.xml and item.xml should match: ${i} is not found!`);return}n.variables?.length===1?this._updateItemVariablesInTestContext(i,s):e.variables=[...n.variables||[]]};this.addEventListener("qti-assessment-test-connected",e=>{if(this.testContext=Ji,this.sessionContext=ys,this.testContext&&this.testContext.items.length>0)return;this._testElement=e.detail;let t=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(i=>({href:i.href,identifier:i.identifier,category:i.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:t}}),this.addEventListener("qti-assessment-item-connected",e=>{let t=e.detail,i=t.closest("qti-assessment-item-ref")?.identifier;i&&(t.assessmentItemRefId=i),this._updateItemInTestContext(e.detail)}),this.addEventListener("qti-item-context-updated",e=>{this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail.itemContext.variables)})}updateItemVariables(e,t){let i=this.testContext.items.find(n=>n.identifier===e);i&&(i.variables=i.variables.map(n=>{let a=t.find(l=>l.identifier===n.identifier);return a?{...n,...a}:n}));let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e}"]`);s&&s.assessmentItem&&s.assessmentItem&&(s.assessmentItem.variables=t)}_updateItemVariablesInTestContext(e,t){this.testContext={...this.testContext,items:this.testContext.items.map(i=>i.identifier!==e?i:{...i,variables:t.map(s=>{let n=i.variables.find(a=>a.identifier===s.identifier);return n?{...n,...s}:s})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}};c([u({attribute:!1,type:Object}),X({context:ue})],Ct.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:He})],Ct.prototype,"sessionContext",2);var Po=o=>{class r extends o{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:s,value:n}=i.detail;this.updateOutcomeVariable(s,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let s=this.getOutcome(t);if(!s){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:s.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var ai=class extends $o(Oo(Po(Ct))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return h`<slot></slot>`}};ai=c([g("qti-test")],ai);var li=["this"],No=["+","-","!"],Vo=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],xs={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},ci=13;var In=["==","!=","<=",">=","||","&&","??","|>"],Ln=["===","!=="],A;(function(o){o[o.STRING=1]="STRING",o[o.IDENTIFIER=2]="IDENTIFIER",o[o.DOT=3]="DOT",o[o.COMMA=4]="COMMA",o[o.COLON=5]="COLON",o[o.INTEGER=6]="INTEGER",o[o.DECIMAL=7]="DECIMAL",o[o.OPERATOR=8]="OPERATOR",o[o.GROUPER=9]="GROUPER",o[o.KEYWORD=10]="KEYWORD",o[o.ARROW=11]="ARROW"})(A||(A={}));var fe=(o,r,e=0)=>({kind:o,value:r,precedence:e}),$n=o=>o===9||o===10||o===13||o===32,Do=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),On=o=>Do(o)||vr(o),Pn=o=>li.indexOf(o)!==-1,Nn=o=>o===34||o===39,vr=o=>48<=o&&o<=57,Vn=o=>o===43||o===45||o===42||o===47||o===33||o===38||o===37||o===60||o===61||o===62||o===63||o===94||o===124,Dn=o=>o===40||o===41||o===91||o===93||o===123||o===125,Hn=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
1497
+ `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),di=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;$n(this.#t);)this.#e(!0);if(Nn(this.#t))return this.#l();if(Do(this.#t))return this.#d();if(vr(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Vn(this.#t))return this.#h();if(Dn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=fe(A.STRING,Hn(this.#r()));return this.#e(),t}#d(){do this.#e();while(On(this.#t));let r=this.#r(),e=Pn(r)?A.KEYWORD:A.IDENTIFIER;return fe(e,r)}#p(){do this.#e();while(vr(this.#t));return this.#t===46?this.#a():fe(A.INTEGER,this.#r())}#a(){return this.#e(),vr(this.#t)?this.#m():(this.#o(),fe(A.DOT,".",ci))}#u(){return this.#e(!0),fe(A.COMMA,",")}#c(){return this.#e(!0),fe(A.COLON,":")}#m(){do this.#e();while(vr(this.#t));return fe(A.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if(Ln.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),fe(A.ARROW,r);In.indexOf(r)!==-1&&this.#e()}return r=this.#r(),fe(A.OPERATOR,r,xs[r])}#f(){let r=String.fromCharCode(this.#t),e=fe(A.GROUPER,r,xs[r]);return this.#e(!0),e}};var qs=(o,r)=>new yr(o,r).parse(),yr=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new di(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(A.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(A.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(A.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(A.KEYWORD))break;if(this._matches(A.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#i.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(r,e){if(Vo.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===A.OPERATOR||this.#s===A.DOT||this.#s===A.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(A.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(A.INTEGER))return this.#b(r);if(this._matches(A.DECIMAL))return this.#v(r)}if(No.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),ci);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(A.OPERATOR,"?");let e=this.#o();this.#r(A.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case A.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw li.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case A.IDENTIFIER:return this.#f();case A.STRING:return this.#E();case A.INTEGER:return this.#b();case A.DECIMAL:return this.#v();case A.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case A.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(A.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(A.GROUPER,"}"))break;let e=this.#e;(this._matches(A.STRING)||this._matches(A.IDENTIFIER))&&this.#r(),this.#r(A.COLON),r[e]=this.#o()}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(A.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(A.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(A.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(A.COMMA));return this.#r(A.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(A.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(A.ARROW)){this.#r();let e=this.#o(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#E(){let r=this.#i.literal(this.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:Ho,fromEntries:zn}=Object,Fn={"+":(o,r)=>o+r,"-":(o,r)=>o-r,"*":(o,r)=>o*r,"/":(o,r)=>o/r,"%":(o,r)=>o%r,"==":(o,r)=>o==r,"!=":(o,r)=>o!=r,"===":(o,r)=>o===r,"!==":(o,r)=>o!==r,">":(o,r)=>o>r,">=":(o,r)=>o>=r,"<":(o,r)=>o<r,"<=":(o,r)=>o<=r,"||":(o,r)=>o||r,"&&":(o,r)=>o&&r,"??":(o,r)=>o??r,"|":(o,r)=>r(o),"|>":(o,r)=>r(o)},Un={"+":o=>o,"-":o=>-o,"!":o=>!o},pi=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=Un[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Fn[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(s){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(s),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(s),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(s),l=this.left.argument.evaluate(s)):this.left.type==="ID"&&(a=s,l=this.left.value),a===void 0?void 0:a[l]=n}return i(this.left.evaluate(s),this.right.evaluate(s))},getIds(s){return this.left.getIds(s),this.right.getIds(s),s}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let s=this.receiver.evaluate(i),n=this.method?s:i?.this??i,a=this.method?s?.[e]:s,d=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(s=>s?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let s=this.entries[i];s&&(t[i]=s.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,s=this.body;return function(...n){let a=zn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return Ho(a,p)&&(a[p]=m),d[p]=m},get(d,p){return Ho(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var Es=null,zo={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){Es??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Es))return void(e[Es]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(o,r){o._$litDirective$=r},getAttributePartCommittedValue:(o,r,e)=>{let t=P;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:Bn,PropertyPart:jn,BooleanAttributePart:Wn,EventPart:Xn}=zo,ws=new pi,Cs=new Map,Fo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ui=(o,r)=>{let e=Cs.get(o);if(e===void 0){if(Cs.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new yr(t,ws).parse(),Cs.set(o,e)}}return e?.evaluate(r)},Gn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ui(i,r))return mi(o,r,e,t)},Uo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Bo=o=>/(?:\\{{)|(?:\\}})/g.test(o),xr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Yn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ui(i,r);if(!s[Symbol.iterator])return S;let n=qr(o),a=-1,l=[];for(let d of s){a++;let p=Object.create(r);p.item=d,p.index=a,p.this=r.this??r;let m=[];for(let b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let f={_$litType$:n,values:m};l.push(f)}return l}},Wo={if:Gn,repeat:Yn},Z=(o,r=Wo,e={},t)=>{let s=qr(o).renderers;if(t){let a=qr(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(f,b,y)=>mi(t,f,b,y)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>mi(o,n,r,e)};var mi=(o,r,e=Wo,t={})=>{let i=qr(o),s=[];for(let a of i.parts){let l=a.update(r,e,t);a.type===1?s.push(...l):s.push(l)}return{_$litType$:i,values:s}},jo=new Map,qr=o=>{let r=jo.get(o);return r===void 0&&jo.set(o,r=Jn(o)),r},Jn=o=>{let r={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,s=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let l=n.getAttribute("type"),d=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||l!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),s.push(n);let m;if(p!==null){let f=p.trim(),b=f.startsWith("{{")&&f.endsWith("}}");m=(y,C,k)=>{let q=n.getAttribute("data"),T=q===null?void 0:ui(q,y);return(b?ui(f,y):k[p])?.(T,C,k)}}else l!==null?m=(f,b,y)=>{let C=b[l];return C?.(n,f,b,y)}:(d==="super"?r.renderers.super=(f,b,y)=>{let C=y.super,k=qr(n);return y={...y,...k.renderers},C(f,b,y)}:r.renderers[d]=(f,b,y)=>mi(n,f,b,y),m=(f,b,y)=>{let C=y[d];return C?.(f,b,y)});r.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let l of a){let d=n.getAttribute(l),p=d.split(Uo);if(p.length===1){Bo(d)&&n.setAttribute(l,xr(d));continue}n.removeAttribute(l);let m=l,f=Bn,b=l[0];b==="."?(m=Fo(l.substring(1)),f=jn):b==="?"?(m=l.substring(1),f=Wn):b==="@"&&(m=Fo(l.substring(1)),f=Xn);let y=[xr(p[0])],C=[];for(let k=1;k<p.length;k+=2){let q=p[k];C.push(qs(q,ws)),y.push(xr(p[k+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:f,update:(k,q,T)=>C.map(M=>M.evaluate(k))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(Uo);l.length>1?n.textContent=xr(l[0]):Bo(a)&&(n.textContent=xr(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=qs(p,ws);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});let f=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of s)n.remove();return r};var Xo={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback();let e=this.getRootNode().host.closest("qti-test").querySelector("template[item-ref]");e&&(this.myTemplate=Z(e)),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};c([u({type:String})],_e.prototype,"category",2),c([u({type:String})],_e.prototype,"identifier",2),c([u({type:Boolean,converter:Xo})],_e.prototype,"required",2),c([u({type:Boolean,converter:Xo})],_e.prototype,"fixed",2),c([u({type:String})],_e.prototype,"href",2),c([u({type:Object,attribute:!1})],_e.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",_e);var _s={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Te=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],Te.prototype,"identifier",2),c([u({type:String})],Te.prototype,"required",2),c([u({type:Boolean,converter:_s})],Te.prototype,"fixed",2),c([u({type:Boolean,converter:_s})],Te.prototype,"visible",2),c([u({type:Boolean,converter:_s,attribute:"keep-together"})],Te.prototype,"keepTogether",2),c([_({context:ue,subscribe:!0})],Te.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",Te);var et=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],et.prototype,"identifier",2),c([u({type:String})],et.prototype,"title",1),c([_({context:ue,subscribe:!0})],et.prototype,"_testContext",2),et=c([g("qti-assessment-test")],et);var Ae=class extends v{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],Ae.prototype,"identifier",2),c([u({type:String})],Ae.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Ae.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Ae.prototype,"submissionMode",2),Ae=c([g("qti-test-part")],Ae);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ae);var Er=class extends Ze{render(){return h``}};Er.styles=x`
1478
1498
  :host {
1479
1499
  color: gray;
1480
1500
  }
1481
- `,Er=l([g("qti-test-feedback")],Er);var O=Symbol("computedContext");var Q=class extends v{constructor(){super();this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-interaction-changed",this._handleInteractionChanged.bind(this)),this.addEventListener("test-end-attempt",this._handleTestEndAttempt.bind(this)),this.addEventListener("test-show-correct-response",this._handleTestShowCorrectResponse.bind(this)),this.addEventListener("test-show-candidate-correction",this._handleTestShowCandidateCorrection.bind(this)),this.addEventListener("test-update-outcome-variable",this._handleTestUpdateOutcomeVariable.bind(this))}_handleTestEndAttempt(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)}_handleTestShowCorrectResponse(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)}_handleTestShowCandidateCorrection(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)}_handleTestUpdateOutcomeVariable(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)}_handleInteractionChanged(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(s=>s.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let s=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,s)}}}render(){return h`<slot></slot>`}_handleTestConnected(e){if(this._testElement=e.detail,!this.qtiContext.QTI_CONTEXT?.testIdentifier){let s=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...s,testIdentifier:this._testElement.identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=this._extractDefaultValues(s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this._testElement?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:this._testElement.identifier,title:this._testElement.title,view:this._sessionContext?.view,testParts:i.map(s=>{let n=[...s.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:s.identifier,navigationMode:s.navigationMode,submissionMode:s.submissionMode,sections:n.map(a=>{let c=[...a.querySelectorAll("qti-assessment-item-ref")];return{active:!1,identifier:a.identifier,title:a.title,items:c.map(d=>({...this.initContext?.find(p=>p.identifier===d.identifier),active:!1,identifier:d.identifier,categories:d.category?d.category?.split(" "):[],href:d.href,variables:[]}))}})}})}}_extractDefaultValues(e){let t={},i=e.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(n=>{let a=n.getAttribute("field-identifier"),c=n.getAttribute("base-type")||"string",d=n.textContent?.trim()||"";if(a){let p=d;switch(c){case"integer":p=parseInt(d,10);break;case"float":case"duration":p=parseFloat(d);break;case"boolean":p=d.toLowerCase()==="true";break;case"string":default:p=d;break}t[a]=p}}),t}_handleItemConnected(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(s=>({...s,items:s.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let c=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),d=t.querySelectorAll("qti-response-declaration"),p=Array.from(d).some(y=>y.querySelector("qti-correct-response")),m=Array.from(d).some(y=>{let w=y.querySelector("qti-mapping"),k=y.querySelector("qti-area-mapping");return w?.querySelector("qti-map-entry")||k?.querySelector("qti-area-map-entry")}),f=p||m,b=!!t.querySelector("qti-response-processing");return{...n,assessmentItemIdentifier:t.getAttribute("identifier"),label:t.getAttribute("label"),title:t.title,externalScored:c,adaptive:t.adaptive=="true"||!1,timeDependent:t.timeDependent=="true"||!1,variables:t.variables,hasCorrectResponse:f,hasResponseProcessing:b}})}))}))}}willUpdate(e){if(!this.computedContext)return;let t=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(s=>({...s,active:this._sessionContext?.navSectionId===s.identifier||!1,completed:s.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:s.items.map(n=>{let a=this._testContext?.items.find(T=>T.identifier===n.identifier),c={...n,...a,...this.initContext?.find(T=>T.identifier===n.identifier)},d=c.variables?.find(T=>T.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=c.variables?.find(T=>T.identifier==="completionStatus")?.value,f=c.variables?.find(T=>T.identifier==="RESPONSE")?.value||"",b=c.variables?.find(T=>T.identifier==="numAttempts")?.value||0,y=this._sessionContext?.navItemRefId===c.identifier||!1,w=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,k=n.variables?.find(T=>T.identifier=="MAXSCORE")?.value,q=k==null?null:parseFloat(k?.toString());return{...c,completionStatus:m,numAttempts:b,score:p,response:f,index:w,active:y,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};l([u({type:String})],Q.prototype,"identifier",2),l([E()],Q.prototype,"initContext",2),l([E(),X({context:Yr})],Q.prototype,"qtiContext",2),l([E(),X({context:ne})],Q.prototype,"configContext",2),l([E(),_({context:ue,subscribe:!0})],Q.prototype,"_testContext",2),l([E(),_({context:He,subscribe:!0})],Q.prototype,"_sessionContext",2),l([E(),X({context:O})],Q.prototype,"computedContext",2),l([u({type:Boolean,attribute:"auto-score-items"})],Q.prototype,"autoScoreItems",2),Q=l([g("test-navigation")],Q);var Go=x`
1501
+ `,Er=c([g("qti-test-feedback")],Er);var O=Symbol("computedContext");var Q=class extends v{constructor(){super();this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-interaction-changed",this._handleInteractionChanged.bind(this)),this.addEventListener("test-end-attempt",this._handleTestEndAttempt.bind(this)),this.addEventListener("test-show-correct-response",this._handleTestShowCorrectResponse.bind(this)),this.addEventListener("test-show-candidate-correction",this._handleTestShowCandidateCorrection.bind(this)),this.addEventListener("test-update-outcome-variable",this._handleTestUpdateOutcomeVariable.bind(this))}_handleTestEndAttempt(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)}_handleTestShowCorrectResponse(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)}_handleTestShowCandidateCorrection(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)}_handleTestUpdateOutcomeVariable(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)}_handleInteractionChanged(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(s=>s.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let s=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,s)}}}render(){return h`<slot></slot>`}_handleTestConnected(e){if(this._testElement=e.detail,!this.qtiContext.QTI_CONTEXT?.testIdentifier){let s=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...s,testIdentifier:this._testElement.identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=this._extractDefaultValues(s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this._testElement?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:this._testElement.identifier,title:this._testElement.title,view:this._sessionContext?.view,testParts:i.map(s=>{let n=[...s.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:s.identifier,navigationMode:s.navigationMode,submissionMode:s.submissionMode,sections:n.map(a=>{let l=[...a.querySelectorAll("qti-assessment-item-ref")];return{active:!1,identifier:a.identifier,title:a.title,items:l.map(d=>({...this.initContext?.find(p=>p.identifier===d.identifier),active:!1,identifier:d.identifier,categories:d.category?d.category?.split(" "):[],href:d.href,variables:[]}))}})}})}}_extractDefaultValues(e){let t={},i=e.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(n=>{let a=n.getAttribute("field-identifier"),l=n.getAttribute("base-type")||"string",d=n.textContent?.trim()||"";if(a){let p=d;switch(l){case"integer":p=parseInt(d,10);break;case"float":case"duration":p=parseFloat(d);break;case"boolean":p=d.toLowerCase()==="true";break;case"string":default:p=d;break}t[a]=p}}),t}_handleItemConnected(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(s=>({...s,items:s.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let l=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),d=t.querySelectorAll("qti-response-declaration"),p=Array.from(d).some(y=>y.querySelector("qti-correct-response")),m=Array.from(d).some(y=>{let C=y.querySelector("qti-mapping"),k=y.querySelector("qti-area-mapping");return C?.querySelector("qti-map-entry")||k?.querySelector("qti-area-map-entry")}),f=p||m,b=!!t.querySelector("qti-response-processing");return{...n,assessmentItemIdentifier:t.getAttribute("identifier"),label:t.getAttribute("label"),title:t.title,externalScored:l,adaptive:t.adaptive=="true"||!1,timeDependent:t.timeDependent=="true"||!1,variables:t.variables,hasCorrectResponse:f,hasResponseProcessing:b}})}))}))}}willUpdate(e){if(!this.computedContext)return;let t=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(s=>({...s,active:this._sessionContext?.navSectionId===s.identifier||!1,completed:s.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:s.items.map(n=>{let a=this._testContext?.items.find(T=>T.identifier===n.identifier),l={...n,...a,...this.initContext?.find(T=>T.identifier===n.identifier)},d=l.variables?.find(T=>T.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(T=>T.identifier==="completionStatus")?.value,f=l.variables?.find(T=>T.identifier==="RESPONSE")?.value||"",b=l.variables?.find(T=>T.identifier==="numAttempts")?.value||0,y=this._sessionContext?.navItemRefId===l.identifier||!1,C=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,k=n.variables?.find(T=>T.identifier=="MAXSCORE")?.value,q=k==null?null:parseFloat(k?.toString());return{...l,completionStatus:m,numAttempts:b,score:p,response:f,index:C,active:y,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};c([u({type:String})],Q.prototype,"identifier",2),c([E()],Q.prototype,"initContext",2),c([E(),X({context:Yr})],Q.prototype,"qtiContext",2),c([E(),X({context:ne})],Q.prototype,"configContext",2),c([E(),_({context:ue,subscribe:!0})],Q.prototype,"_testContext",2),c([E(),_({context:He,subscribe:!0})],Q.prototype,"_sessionContext",2),c([E(),X({context:O})],Q.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],Q.prototype,"autoScoreItems",2),Q=c([g("test-navigation")],Q);var Go=x`
1482
1502
  display: inline-flex;
1483
1503
  align-items: center;
1484
1504
  cursor: pointer;
@@ -1501,14 +1521,14 @@ Make sure to test your application with a production build as repeat registratio
1501
1521
  :host([disabled]) {
1502
1522
  ${j};
1503
1523
  }
1504
- `,l([u({type:Boolean,reflect:!0,attribute:"disabled"})],ze.prototype,"_internalDisabled",2),l([_({context:O,subscribe:!0})],ze.prototype,"computedContext",2),l([M("computedContext")],ze.prototype,"_handleTestElementChange",1),ze=l([g("test-next")],ze);var Fe=class extends v{constructor(){super();this._internalDisabled=!0;this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h`<slot></slot>`}};Fe.styles=x`
1524
+ `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],ze.prototype,"_internalDisabled",2),c([_({context:O,subscribe:!0})],ze.prototype,"computedContext",2),c([I("computedContext")],ze.prototype,"_handleTestElementChange",1),ze=c([g("test-next")],ze);var Fe=class extends v{constructor(){super();this._internalDisabled=!0;this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h`<slot></slot>`}};Fe.styles=x`
1505
1525
  :host {
1506
1526
  ${B};
1507
1527
  }
1508
1528
  :host([disabled]) {
1509
1529
  ${j};
1510
1530
  }
1511
- `,l([u({type:Boolean,reflect:!0,attribute:"disabled"})],Fe.prototype,"_internalDisabled",2),l([_({context:O,subscribe:!0})],Fe.prototype,"computedContext",2),l([M("computedContext")],Fe.prototype,"_handleTestElementChange",1),Fe=l([g("test-prev")],Fe);var W=class extends v{constructor(){super(...arguments);this.label="view";this._handleViewOptionsChange=()=>{this.updateViewOptions()};this._viewOptions=W.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),this.updateViewOptions()}updateViewOptions(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>W.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=W.DEFAULT_VIEW_OPTIONS}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return h`
1531
+ `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Fe.prototype,"_internalDisabled",2),c([_({context:O,subscribe:!0})],Fe.prototype,"computedContext",2),c([I("computedContext")],Fe.prototype,"_handleTestElementChange",1),Fe=c([g("test-prev")],Fe);var W=class extends v{constructor(){super(...arguments);this.label="view";this._handleViewOptionsChange=()=>{this.updateViewOptions()};this._viewOptions=W.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),this.updateViewOptions()}updateViewOptions(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>W.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=W.DEFAULT_VIEW_OPTIONS}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return h`
1512
1532
  <label part="label" for="viewSelect">${this.label}</label>
1513
1533
  <select
1514
1534
  part="select"
@@ -1517,28 +1537,28 @@ Make sure to test your application with a production build as repeat registratio
1517
1537
  >
1518
1538
  ${this._viewOptions.map(e=>h`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
1519
1539
  </select>
1520
- `}};W.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],l([_({context:He,subscribe:!0})],W.prototype,"sessionContext",2),l([u({type:String})],W.prototype,"label",2),l([u({type:String,attribute:"view-options"})],W.prototype,"viewOptions",2),l([M("viewOptions",{waitUntilFirstUpdate:!0})],W.prototype,"_handleViewOptionsChange",2),l([E()],W.prototype,"_viewOptions",2),W=l([g("test-view")],W);var wt=class extends v{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h` <slot></slot> `}};wt.styles=x`
1540
+ `}};W.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([_({context:He,subscribe:!0})],W.prototype,"sessionContext",2),c([u({type:String})],W.prototype,"label",2),c([u({type:String,attribute:"view-options"})],W.prototype,"viewOptions",2),c([I("viewOptions",{waitUntilFirstUpdate:!0})],W.prototype,"_handleViewOptionsChange",2),c([E()],W.prototype,"_viewOptions",2),W=c([g("test-view")],W);var wt=class extends v{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h` <slot></slot> `}};wt.styles=x`
1521
1541
  :host {
1522
1542
  ${B};
1523
1543
  }
1524
1544
  :host([disabled]) {
1525
1545
  ${j};
1526
1546
  }
1527
- `,l([u({type:String,attribute:"item-id"})],wt.prototype,"itemId",2),wt=l([g("test-item-link")],wt);var Cr=class extends v{constructor(){super(),this.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})))}render(){return h` <slot></slot> `}};Cr.styles=x`
1547
+ `,c([u({type:String,attribute:"item-id"})],wt.prototype,"itemId",2),wt=c([g("test-item-link")],wt);var Cr=class extends v{constructor(){super(),this.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})))}render(){return h` <slot></slot> `}};Cr.styles=x`
1528
1548
  :host {
1529
1549
  ${B};
1530
1550
  }
1531
1551
  :host([disabled]) {
1532
1552
  ${j};
1533
1553
  }
1534
- `,Cr=l([g("test-end-attempt")],Cr);var te=class extends v{constructor(){super(...arguments);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified"}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(this._previousActiveItem!==t&&(this.shown=!1,this._previousActiveItem=t),t){let i=!!t?.variables?.some(n=>n.correctResponse),s=!!t?.variables?.some(n=>n.mapping?.mapEntries?.length>0||n.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!s}else this.disabled=!0}_toggleState(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return h` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};te.styles=x`
1554
+ `,Cr=c([g("test-end-attempt")],Cr);var te=class extends v{constructor(){super(...arguments);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified"}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(this._previousActiveItem!==t&&(this.shown=!1,this._previousActiveItem=t),t){let i=!!t?.variables?.some(n=>n.correctResponse),s=!!t?.variables?.some(n=>n.mapping?.mapEntries?.length>0||n.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!s}else this.disabled=!0}_toggleState(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return h` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};te.styles=x`
1535
1555
  :host {
1536
1556
  ${B};
1537
1557
  }
1538
1558
  :host([disabled]) {
1539
1559
  ${j};
1540
1560
  }
1541
- `,l([_({context:O,subscribe:!0})],te.prototype,"computedContext",2),l([u({type:Boolean,reflect:!0})],te.prototype,"shown",2),l([u({type:Boolean,reflect:!0})],te.prototype,"disabled",2),l([u({type:String})],te.prototype,"showCorrectText",2),l([u({type:String})],te.prototype,"hideCorrectText",2),l([u({type:String})],te.prototype,"noCorrectResponseText",2),te=l([g("test-show-correct-response")],te);var wr=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=Z(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return h` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};l([_({context:O,subscribe:!0})],wr.prototype,"computedContext",2),wr=l([g("test-paging-buttons-stamp")],wr);var hi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},fi=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(r=>this.Z=r)}resume(){this.Z?.(),this.Y=this.Z=void 0}};var Yo=o=>!uo(o)&&typeof o.then=="function",Jo=1073741823,Ts=class extends xt{constructor(){super(...arguments),this._$Cwt=Jo,this._$Cbt=[],this._$CK=new hi(this),this._$CX=new fi}render(...r){return r.find(e=>!Yo(e))??P}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let s=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let c=e[a];if(!Yo(c))return this._$Cwt=a,c;a<i&&c===t[a]||(this._$Cwt=Jo,i=0,Promise.resolve(c).then(async d=>{for(;n.get();)await n.get();let p=s.deref();if(p!==void 0){let m=p._$Cbt.indexOf(c);m>-1&&m<p._$Cwt&&(p._$Cwt=m,p.setValue(d))}}))}return P}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},gi=ee(Ts);var bi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
1561
+ `,c([_({context:O,subscribe:!0})],te.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],te.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],te.prototype,"disabled",2),c([u({type:String})],te.prototype,"showCorrectText",2),c([u({type:String})],te.prototype,"hideCorrectText",2),c([u({type:String})],te.prototype,"noCorrectResponseText",2),te=c([g("test-show-correct-response")],te);var wr=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=Z(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return h` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([_({context:O,subscribe:!0})],wr.prototype,"computedContext",2),wr=c([g("test-paging-buttons-stamp")],wr);var hi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},fi=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((r=>this.Z=r))}resume(){this.Z?.(),this.Y=this.Z=void 0}};var Yo=o=>!uo(o)&&typeof o.then=="function",Jo=1073741823,Ts=class extends xt{constructor(){super(...arguments),this._$Cwt=Jo,this._$Cbt=[],this._$CK=new hi(this),this._$CX=new fi}render(...r){return r.find((e=>!Yo(e)))??P}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let s=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!Yo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Jo,i=0,Promise.resolve(l).then((async d=>{for(;n.get();)await n.get();let p=s.deref();if(p!==void 0){let m=p._$Cbt.indexOf(l);m>-1&&m<p._$Cwt&&(p._$Cwt=m,p.setValue(d))}})))}return P}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},gi=ee(Ts);var bi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
1542
1562
 
1543
1563
  :root,
1544
1564
  :host {
@@ -1698,11 +1718,13 @@ Make sure to test your application with a production build as repeat registratio
1698
1718
 
1699
1719
  .spot {
1700
1720
 
1701
- box-sizing: border-box;
1702
1721
  width: 100%;
1703
1722
  height: 100%;
1704
1723
  background-color: transparent;
1705
- padding: 0;
1724
+ margin: 0 !important;
1725
+ padding: 0 !important;
1726
+ border: 0 !important;
1727
+ box-sizing: border-box !important;
1706
1728
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
1707
1729
  outline: none;
1708
1730
  }
@@ -3492,12 +3514,6 @@ qti-response-declaration {
3492
3514
  box-sizing: border-box;
3493
3515
  }
3494
3516
 
3495
- *,
3496
- *::before,
3497
- *::after {
3498
- box-sizing: inherit;
3499
- }
3500
-
3501
3517
  /* components */
3502
3518
 
3503
3519
  @layer qti-components {
@@ -4047,16 +4063,20 @@ qti-response-declaration {
4047
4063
  outline: 4px solid var(--qti-disabled-bg);
4048
4064
  }
4049
4065
 
4050
- box-sizing: border-box;
4051
-
4052
4066
  width: 100%;
4053
4067
 
4054
4068
  height: 100%;
4055
4069
 
4056
4070
  background-color: transparent;
4057
4071
 
4072
+ margin: 0;
4073
+
4058
4074
  padding: 0;
4059
4075
 
4076
+ border: 0;
4077
+
4078
+ box-sizing: border-box;
4079
+
4060
4080
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
4061
4081
 
4062
4082
  outline: none
@@ -4092,16 +4112,20 @@ qti-response-declaration {
4092
4112
  outline: 4px solid var(--qti-disabled-bg);
4093
4113
  }
4094
4114
 
4095
- box-sizing: border-box;
4096
-
4097
4115
  width: 100%;
4098
4116
 
4099
4117
  height: 100%;
4100
4118
 
4101
4119
  background-color: transparent;
4102
4120
 
4121
+ margin: 0;
4122
+
4103
4123
  padding: 0;
4104
4124
 
4125
+ border: 0;
4126
+
4127
+ box-sizing: border-box;
4128
+
4105
4129
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
4106
4130
 
4107
4131
  outline: none
@@ -4663,16 +4687,16 @@ qti-response-declaration {
4663
4687
  }
4664
4688
  }
4665
4689
 
4666
- qti-order-interaction:state(--dragzone-active)::part(drags) {
4667
- border-color: var(--qti-border-active);
4668
- background-color: var(--qti-bg-active);
4669
- }
4690
+ qti-order-interaction {
4691
+ &:state(--dragzone-active)::part(drags) {
4692
+ border-color: var(--qti-border-active);
4693
+ background-color: var(--qti-bg-active);
4694
+ }
4670
4695
 
4671
- qti-order-interaction:state(--dragzone-enabled)::part(drags) {
4672
- background-color: var(--qti-bg-active);
4673
- }
4696
+ &:state(--dragzone-enabled)::part(drags) {
4697
+ background-color: var(--qti-bg-active);
4698
+ }
4674
4699
 
4675
- qti-order-interaction {
4676
4700
  &::part(qti-simple-choice),
4677
4701
  & qti-simple-choice {
4678
4702
 
@@ -4793,16 +4817,20 @@ qti-response-declaration {
4793
4817
  outline: 4px solid var(--qti-disabled-bg);
4794
4818
  }
4795
4819
 
4796
- box-sizing: border-box;
4797
-
4798
4820
  width: 100%;
4799
4821
 
4800
4822
  height: 100%;
4801
4823
 
4802
4824
  background-color: transparent;
4803
4825
 
4826
+ margin: 0;
4827
+
4804
4828
  padding: 0;
4805
4829
 
4830
+ border: 0;
4831
+
4832
+ box-sizing: border-box;
4833
+
4806
4834
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
4807
4835
 
4808
4836
  outline: none
@@ -4837,16 +4865,20 @@ qti-response-declaration {
4837
4865
  outline: 4px solid var(--qti-disabled-bg);
4838
4866
  }
4839
4867
 
4840
- box-sizing: border-box;
4841
-
4842
4868
  width: 100%;
4843
4869
 
4844
4870
  height: 100%;
4845
4871
 
4846
4872
  background-color: transparent;
4847
4873
 
4874
+ margin: 0;
4875
+
4848
4876
  padding: 0;
4849
4877
 
4878
+ border: 0;
4879
+
4880
+ box-sizing: border-box;
4881
+
4850
4882
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
4851
4883
 
4852
4884
  outline: none
@@ -5067,16 +5099,20 @@ qti-response-declaration {
5067
5099
  outline: 4px solid var(--qti-disabled-bg);
5068
5100
  }
5069
5101
 
5070
- box-sizing: border-box;
5071
-
5072
5102
  width: 100%;
5073
5103
 
5074
5104
  height: 100%;
5075
5105
 
5076
5106
  background-color: transparent;
5077
5107
 
5108
+ margin: 0;
5109
+
5078
5110
  padding: 0;
5079
5111
 
5112
+ border: 0;
5113
+
5114
+ box-sizing: border-box;
5115
+
5080
5116
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
5081
5117
 
5082
5118
  outline: none
@@ -5111,16 +5147,20 @@ qti-response-declaration {
5111
5147
  outline: 4px solid var(--qti-disabled-bg);
5112
5148
  }
5113
5149
 
5114
- box-sizing: border-box;
5115
-
5116
5150
  width: 100%;
5117
5151
 
5118
5152
  height: 100%;
5119
5153
 
5120
5154
  background-color: transparent;
5121
5155
 
5156
+ margin: 0;
5157
+
5122
5158
  padding: 0;
5123
5159
 
5160
+ border: 0;
5161
+
5162
+ box-sizing: border-box;
5163
+
5124
5164
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
5125
5165
 
5126
5166
  outline: none
@@ -5256,7 +5296,7 @@ div.full-correct-response-inline {
5256
5296
  ${this.templateContent}
5257
5297
  <slot></slot>
5258
5298
  ${gi(this.testDoc,h`<span>Loading...</span>`)}
5259
- `}};l([u({type:String,attribute:"test-url"})],Re.prototype,"testURL",2),l([E()],Re.prototype,"testDoc",2),l([E()],Re.prototype,"testXML",2),l([M("testURL",{waitUntilFirstUpdate:!0})],Re.prototype,"handleTestURLChange",1),l([M("testXML",{waitUntilFirstUpdate:!0})],Re.prototype,"handleTestXMLChange",1),Re=l([g("test-container")],Re);var _t=class extends v{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5299
+ `}};c([u({type:String,attribute:"test-url"})],Re.prototype,"testURL",2),c([E()],Re.prototype,"testDoc",2),c([E()],Re.prototype,"testXML",2),c([I("testURL",{waitUntilFirstUpdate:!0})],Re.prototype,"handleTestURLChange",1),c([I("testXML",{waitUntilFirstUpdate:!0})],Re.prototype,"handleTestXMLChange",1),Re=c([g("test-container")],Re);var _t=class extends v{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5260
5300
  <h3>${n}</h3>
5261
5301
  <table>
5262
5302
  <thead>
@@ -5269,13 +5309,13 @@ div.full-correct-response-inline {
5269
5309
  </tr>
5270
5310
  </thead>
5271
5311
  <tbody>
5272
- ${s.map(a=>{let c=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return h`
5312
+ ${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return h`
5273
5313
  <tr>
5274
5314
  <td>${a.identifier}</td>
5275
5315
  <td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
5276
5316
  <td>${a.cardinality}</td>
5277
5317
  <td>${a.baseType}</td>
5278
- <td>${c||d||p}</td>
5318
+ <td>${l||d||p}</td>
5279
5319
  </tr>
5280
5320
  `})}
5281
5321
  </tbody>
@@ -5303,26 +5343,26 @@ div.full-correct-response-inline {
5303
5343
  margin-top: 20px;
5304
5344
  font-size: 16px;
5305
5345
  }
5306
- `,l([_({context:O,subscribe:!0})],_t.prototype,"computedContext",2),_t=l([g("test-print-item-variables")],_t);var _r=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=Z(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections);return h` ${r.map(e=>this.myTemplate({item:e}))} `}};l([_({context:O,subscribe:!0})],_r.prototype,"computedContext",2),_r=l([g("test-section-buttons-stamp")],_r);var Tt=class extends v{constructor(){super();this.sectionId=null;this.addEventListener("click",()=>this._requestItem(this.sectionId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))}render(){return h` <slot></slot> `}};Tt.styles=x`
5346
+ `,c([_({context:O,subscribe:!0})],_t.prototype,"computedContext",2),_t=c([g("test-print-item-variables")],_t);var _r=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=Z(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections);return h` ${r.map(e=>this.myTemplate({item:e}))} `}};c([_({context:O,subscribe:!0})],_r.prototype,"computedContext",2),_r=c([g("test-section-buttons-stamp")],_r);var Tt=class extends v{constructor(){super();this.sectionId=null;this.addEventListener("click",()=>this._requestItem(this.sectionId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))}render(){return h` <slot></slot> `}};Tt.styles=x`
5307
5347
  :host {
5308
5348
  ${B};
5309
5349
  }
5310
5350
  :host([disabled]) {
5311
5351
  ${j};
5312
5352
  }
5313
- `,l([u({type:String,attribute:"section-id"})],Tt.prototype,"sectionId",2),Tt=l([g("test-section-link")],Tt);var Tr=class extends v{render(){return h` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};l([E(),_({context:O,subscribe:!0})],Tr.prototype,"computedContext",2),Tr=l([g("test-print-context")],Tr);var rt=class extends v{constructor(){super(...arguments);this.debug=!1;this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Z(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(f=>f.active),i=t?.sections.find(f=>f.active),s=i?.items.find(f=>f.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let c={...t,items:t.sections.flatMap(f=>f.items.map(({variables:b,...y})=>y)),sections:t.sections.map(f=>({...f,items:f.items.map(({variables:b,...y})=>y)}))},d={...i,items:i.items.map(({variables:f,...b})=>b)},{testParts:p,...m}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:d,activeTestpart:c,test:m}}render(){return h` ${this.debug?h`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:S}
5314
- ${this.myTemplate?this.myTemplate(this.stampContext):S}`}};l([u({type:Boolean,reflect:!0})],rt.prototype,"debug",2),l([E(),_({context:O,subscribe:!0})],rt.prototype,"computedContext",2),l([E()],rt.prototype,"stampContext",2),rt=l([g("test-stamp")],rt);var it=class extends v{constructor(){super();this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&this._changeOutcomeScore(i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Z(e)}_changeOutcomeScore(e){let s=(this.computedContext?.testParts.find(n=>n.active)).sections.flatMap(n=>n.items).find(n=>n.active)?.identifier;this.dispatchEvent(new CustomEvent("test-update-outcome-variable",{detail:{assessmentItemRefId:s,outcomeVariableId:"SCORE",value:e},bubbles:!0}))}render(){let e=this.computedContext?.testParts.flatMap(c=>c.sections.flatMap(d=>d.items)).find(c=>c.active);if(!e||!e.variables)return h``;let t=e.variables.find(c=>c.identifier=="MAXSCORE")?.value,i=e.variables.find(c=>c.identifier=="SCORE"),s=i?.value,n=i?.externalScored!=="human";if(!t||!i)return S;let a=[...Array(Number(t)+1).keys()];return h`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):S}`}};l([u({type:String,attribute:"view"})],it.prototype,"view",2),l([u({type:Boolean})],it.prototype,"disabled",2),l([_({context:O,subscribe:!0})],it.prototype,"computedContext",2),it=l([g("test-scoring-buttons")],it);var Ar=class extends v{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=Z(r)}_switchView(r){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:r}))}firstUpdated(r){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return h`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):S}`}};l([_({context:He,subscribe:!0})],Ar.prototype,"sessionContext",2),Ar=l([g("test-view-toggle")],Ar);var At=class extends v{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(c=>c.sections.flatMap(d=>d.items)).find(c=>c.active);if(!e||!e.variables)return h``;if(e.category==="dep-informational")return h`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(c=>c.identifier==="completionStatus")?.value,i=e?.variables.find(c=>c.identifier=="SCORE"),s=parseFloat(i?.value),n=e.externalScored;return h`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&s!==void 0&&!Number.isNaN(s)?s>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(s)||s===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${s===0?"geen punten":s==1?"\xE9\xE9n punt":`${s} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(s)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};l([_({context:O,subscribe:!0})],At.prototype,"computedContext",2),l([u({type:String,attribute:"view"})],At.prototype,"view",2),At=l([g("test-scoring-feedback")],At);var Rr=class extends v{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})),this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}));let e=this.closest("qti-test").querySelector("test-container");Array.from(e.shadowRoot.querySelectorAll("[view]")).forEach(i=>{i.classList.toggle("show",!0)})})}render(){return h` <slot></slot> `}};Rr.styles=x`
5353
+ `,c([u({type:String,attribute:"section-id"})],Tt.prototype,"sectionId",2),Tt=c([g("test-section-link")],Tt);var Tr=class extends v{render(){return h` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([E(),_({context:O,subscribe:!0})],Tr.prototype,"computedContext",2),Tr=c([g("test-print-context")],Tr);var rt=class extends v{constructor(){super(...arguments);this.debug=!1;this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Z(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(f=>f.active),i=t?.sections.find(f=>f.active),s=i?.items.find(f=>f.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(f=>f.items.map(({variables:b,...y})=>y)),sections:t.sections.map(f=>({...f,items:f.items.map(({variables:b,...y})=>y)}))},d={...i,items:i.items.map(({variables:f,...b})=>b)},{testParts:p,...m}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:d,activeTestpart:l,test:m},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return h` ${this.debug?h`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:S}
5354
+ ${this.myTemplate?this.myTemplate(this.stampContext):S}`}};c([u({type:Boolean,reflect:!0})],rt.prototype,"debug",2),c([E(),_({context:O,subscribe:!0})],rt.prototype,"computedContext",2),c([E()],rt.prototype,"stampContext",2),rt=c([g("test-stamp")],rt);var it=class extends v{constructor(){super();this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&this._changeOutcomeScore(i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Z(e)}_changeOutcomeScore(e){let s=(this.computedContext?.testParts.find(n=>n.active)).sections.flatMap(n=>n.items).find(n=>n.active)?.identifier;this.dispatchEvent(new CustomEvent("test-update-outcome-variable",{detail:{assessmentItemRefId:s,outcomeVariableId:"SCORE",value:e},bubbles:!0}))}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;let t=e.variables.find(l=>l.identifier=="MAXSCORE")?.value,i=e.variables.find(l=>l.identifier=="SCORE"),s=i?.value,n=i?.externalScored!=="human";if(!t||!i)return S;let a=[...Array(Number(t)+1).keys()];return h`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):S}`}};c([u({type:String,attribute:"view"})],it.prototype,"view",2),c([u({type:Boolean})],it.prototype,"disabled",2),c([_({context:O,subscribe:!0})],it.prototype,"computedContext",2),it=c([g("test-scoring-buttons")],it);var Ar=class extends v{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=Z(r)}_switchView(r){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:r}))}firstUpdated(r){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return h`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):S}`}};c([_({context:He,subscribe:!0})],Ar.prototype,"sessionContext",2),Ar=c([g("test-view-toggle")],Ar);var At=class extends v{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;if(e.category==="dep-informational")return h`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(l=>l.identifier==="completionStatus")?.value,i=e?.variables.find(l=>l.identifier=="SCORE"),s=parseFloat(i?.value),n=e.externalScored;return h`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&s!==void 0&&!Number.isNaN(s)?s>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(s)||s===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${s===0?"geen punten":s==1?"\xE9\xE9n punt":`${s} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(s)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};c([_({context:O,subscribe:!0})],At.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],At.prototype,"view",2),At=c([g("test-scoring-feedback")],At);var Rr=class extends v{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})),this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}));let e=this.closest("qti-test").querySelector("test-container");Array.from(e.shadowRoot.querySelectorAll("[view]")).forEach(i=>{i.classList.toggle("show",!0)})})}render(){return h` <slot></slot> `}};Rr.styles=x`
5315
5355
  :host {
5316
5356
  ${B};
5317
5357
  }
5318
5358
  :host([disabled]) {
5319
5359
  ${j};
5320
5360
  }
5321
- `,Rr=l([g("test-check-item")],Rr);var ke=class extends v{constructor(){super(...arguments);this.itemURL=null;this.itemDoc=null;this.itemXML=null;this.templateContent=null}async handleItemURLChange(){if(this.itemURL)try{let{promise:e}=await Je().load(this.itemURL);this.itemDoc=(await e).htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Je().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:h``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(bi),this.shadowRoot.adoptedStyleSheets=[e]}render(){return h`
5361
+ `,Rr=c([g("test-check-item")],Rr);var ke=class extends v{constructor(){super(...arguments);this.itemURL=null;this.itemDoc=null;this.itemXML=null;this.templateContent=null}async handleItemURLChange(){if(this.itemURL)try{let{promise:e}=await Je().load(this.itemURL);this.itemDoc=(await e).htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Je().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:h``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(bi),this.shadowRoot.adoptedStyleSheets=[e]}render(){return h`
5322
5362
  ${this.templateContent}
5323
5363
  <slot></slot>
5324
5364
  ${gi(this.itemDoc,h`<span>Loading...</span>`)}
5325
- `}};l([u({type:String,attribute:"item-url"})],ke.prototype,"itemURL",2),l([E()],ke.prototype,"itemDoc",2),l([E()],ke.prototype,"itemXML",2),l([M("itemURL",{waitUntilFirstUpdate:!0})],ke.prototype,"handleItemURLChange",1),l([M("itemXML",{waitUntilFirstUpdate:!0})],ke.prototype,"handleItemXMLChange",1),ke=l([g("item-container")],ke);var Rt=Symbol("computedItemContext");var kt=class extends v{render(){let r=this.computedContext;if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5365
+ `}};c([u({type:String,attribute:"item-url"})],ke.prototype,"itemURL",2),c([E()],ke.prototype,"itemDoc",2),c([E()],ke.prototype,"itemXML",2),c([I("itemURL",{waitUntilFirstUpdate:!0})],ke.prototype,"handleItemURLChange",1),c([I("itemXML",{waitUntilFirstUpdate:!0})],ke.prototype,"handleItemXMLChange",1),ke=c([g("item-container")],ke);var Rt=Symbol("computedItemContext");var kt=class extends v{render(){let r=this.computedContext;if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5326
5366
  <h3>${n}</h3>
5327
5367
  <table>
5328
5368
  <thead>
@@ -5335,13 +5375,13 @@ div.full-correct-response-inline {
5335
5375
  </tr>
5336
5376
  </thead>
5337
5377
  <tbody>
5338
- ${s.map(a=>{let c=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return h`
5378
+ ${s.map(a=>{let l=a.correctResponse?Array.isArray(a.correctResponse)?a.correctResponse.join(", "):a.correctResponse:"",d=a.mapping?.mapEntries?.map(m=>`${m.mapKey}=${m.mappedValue}pt`).join(", ")||"",p=a.areaMapping?.areaMapEntries?.map(m=>`${m.shape}(${m.coords})=${m.mappedValue}pt`).join(", ")||"";return h`
5339
5379
  <tr>
5340
5380
  <td>${a.identifier}</td>
5341
5381
  <td>${Array.isArray(a.value)?a.value.join(", "):a.value}</td>
5342
5382
  <td>${a.cardinality}</td>
5343
5383
  <td>${a.baseType}</td>
5344
- <td>${c||d||p}</td>
5384
+ <td>${l||d||p}</td>
5345
5385
  </tr>
5346
5386
  `})}
5347
5387
  </tbody>
@@ -5369,7 +5409,7 @@ div.full-correct-response-inline {
5369
5409
  margin-top: 20px;
5370
5410
  font-size: 16px;
5371
5411
  }
5372
- `,l([_({context:Rt,subscribe:!0})],kt.prototype,"computedContext",2),kt=l([g("print-item-variables")],kt);var Ko=x`
5412
+ `,c([_({context:Rt,subscribe:!0})],kt.prototype,"computedContext",2),kt=c([g("print-item-variables")],kt);var Ko=x`
5373
5413
  display: inline-flex;
5374
5414
  align-items: center;
5375
5415
  cursor: pointer;
@@ -5392,7 +5432,7 @@ div.full-correct-response-inline {
5392
5432
  :host([disabled]) {
5393
5433
  ${Qo};
5394
5434
  }
5395
- `,l([_({context:Rt,subscribe:!0})],re.prototype,"computedContext",2),l([u({type:Boolean,reflect:!0})],re.prototype,"shown",2),l([u({type:Boolean,reflect:!0})],re.prototype,"disabled",2),l([u({type:String})],re.prototype,"showCorrectText",2),l([u({type:String})],re.prototype,"hideCorrectText",2),l([u({type:String})],re.prototype,"noCorrectResponseText",2),re=l([g("item-show-correct-response")],re);var St=class extends v{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,s=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=s!==void 0&&!isNaN(s)&&s>0,c=s!==void 0&&!isNaN(s)&&s<=0,d=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:c,completed:d,variables:t}}render(){return h`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};l([E(),X({context:Rt})],St.prototype,"computedContext",2),l([E(),X({context:ne})],St.prototype,"configContext",2),St=l([g("qti-item")],St);export{Ji as INITIAL_TEST_CONTEXT,ke as ItemContainer,re as ItemShowCorrectResponse,kt as PrintItemVariables,Jr as QtiAnd,G as QtiAssessmentItem,_e as QtiAssessmentItemRef,Te as QtiAssessmentSection,pt as QtiAssessmentStimulusRef,et as QtiAssessmentTest,Jt as QtiAssociableHotspot,ut as QtiAssociateInteraction,Kr as QtiBaseValue,mt as QtiChoiceInteraction,jr as QtiCompanionMaterialsInfo,Xi as QtiContainerSize,Gi as QtiContains,oi as QtiContentBody,Yi as QtiCorrect,ve as QtiCustomInteraction,Wt as QtiCustomOperator,qt as QtiDefault,vs as QtiDelete,$e as QtiEndAttemptInteraction,Qr as QtiEqual,Zr as QtiEqualRounded,U as QtiExtendedTextInteraction,Gt as QtiFeedbackBlock,Yt as QtiFeedbackInline,is as QtiFieldValue,gt as QtiGap,ht as QtiGapImg,Kt as QtiGapMatchInteraction,ft as QtiGapText,Zi as QtiGcd,ce as QtiGraphicAssociateInteraction,Zt as QtiGraphicGapMatchInteraction,Qt as QtiGraphicOrderInteraction,Qi as QtiGt,es as QtiGte,Qe as QtiHotspotChoice,er as QtiHotspotInteraction,rr as QtiHottext,tr as QtiHottextInteraction,br as QtiIndex,sr as QtiInlineChoice,ye as QtiInlineChoiceInteraction,rs as QtiIsNull,St as QtiItem,cr as QtiItemBody,ur as QtiLookupOutcomeValue,ss as QtiLt,os as QtiLte,ei as QtiMapResponse,ti as QtiMapResponsePoint,ns as QtiMatch,xe as QtiMatchInteraction,ri as QtiMathOperator,or as QtiMediaInteraction,as as QtiMember,Ze as QtiModalFeedback,ls as QtiMultiple,cs as QtiNot,ts as QtiNull,ds as QtiOr,qe as QtiOrderInteraction,ps as QtiOrdered,he as QtiOutcomeDeclaration,dr as QtiOutcomeProcessing,Fi as QtiOutcomeProcessingProcessor,z as QtiPortableCustomInteraction,Vi as QtiPositionObjectInteraction,nr as QtiPositionObjectStage,us as QtiPower,gr as QtiPrintedVariable,ms as QtiProduct,Gr as QtiPrompt,bs as QtiRandom,Et as QtiRandomInteger,Ui as QtiResponseCondition,we as QtiResponseDeclaration,mr as QtiResponseElse,Wi as QtiResponseElseIf,hr as QtiResponseIf,pr as QtiResponseProcessing,Ki as QtiRound,fr as QtiRoundTo,me as QtiRubricBlock,pe as QtiRule,de as QtiSelectPointInteraction,Bi as QtiSetOutcomeValue,ji as QtiSetOutcomeValueRule,Ve as QtiSimpleAssociableChoice,Ee as QtiSimpleChoice,Ce as QtiSliderInteraction,si as QtiStringMatch,ni as QtiStylesheet,ii as QtiSubtract,hs as QtiSum,fs as QtiSumExpression,ai as QtiTest,Er as QtiTestFeedback,Ae as QtiTestPart,J as QtiTextEntryInteraction,lr as QtiUploadInteraction,gs as QtiVariable,Rr as TestCheckItem,Re as TestContainer,Cr as TestEndAttempt,wt as TestItemLink,Q as TestNavigation,ze as TestNext,wr as TestPagingButtonsStamp,Fe as TestPrev,Tr as TestPrintContext,_t as TestPrintVariables,it as TestScoringButtons,At as TestScoringFeedback,_r as TestSectionButtonsStamp,Tt as TestSectionLink,te as TestShowCorrectResponse,rt as TestStamp,W as TestView,Ar as TestViewToggle,Sn as qtiAndMixin,Mn as qtiSubtractMixin,ue as testContext};
5435
+ `,c([_({context:Rt,subscribe:!0})],re.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],re.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],re.prototype,"disabled",2),c([u({type:String})],re.prototype,"showCorrectText",2),c([u({type:String})],re.prototype,"hideCorrectText",2),c([u({type:String})],re.prototype,"noCorrectResponseText",2),re=c([g("item-show-correct-response")],re);var St=class extends v{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,s=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=s!==void 0&&!isNaN(s)&&s>0,l=s!==void 0&&!isNaN(s)&&s<=0,d=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:l,completed:d,variables:t}}render(){return h`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([E(),X({context:Rt})],St.prototype,"computedContext",2),c([E(),X({context:ne})],St.prototype,"configContext",2),St=c([g("qti-item")],St);export{Ji as INITIAL_TEST_CONTEXT,ke as ItemContainer,re as ItemShowCorrectResponse,kt as PrintItemVariables,Jr as QtiAnd,G as QtiAssessmentItem,_e as QtiAssessmentItemRef,Te as QtiAssessmentSection,pt as QtiAssessmentStimulusRef,et as QtiAssessmentTest,Jt as QtiAssociableHotspot,ut as QtiAssociateInteraction,Kr as QtiBaseValue,mt as QtiChoiceInteraction,jr as QtiCompanionMaterialsInfo,Xi as QtiContainerSize,Gi as QtiContains,oi as QtiContentBody,Yi as QtiCorrect,ve as QtiCustomInteraction,Wt as QtiCustomOperator,qt as QtiDefault,vs as QtiDelete,$e as QtiEndAttemptInteraction,Qr as QtiEqual,Zr as QtiEqualRounded,U as QtiExtendedTextInteraction,Gt as QtiFeedbackBlock,Yt as QtiFeedbackInline,is as QtiFieldValue,gt as QtiGap,ht as QtiGapImg,Kt as QtiGapMatchInteraction,ft as QtiGapText,Zi as QtiGcd,ce as QtiGraphicAssociateInteraction,Zt as QtiGraphicGapMatchInteraction,Qt as QtiGraphicOrderInteraction,Qi as QtiGt,es as QtiGte,Qe as QtiHotspotChoice,er as QtiHotspotInteraction,rr as QtiHottext,tr as QtiHottextInteraction,br as QtiIndex,sr as QtiInlineChoice,ye as QtiInlineChoiceInteraction,rs as QtiIsNull,St as QtiItem,cr as QtiItemBody,ur as QtiLookupOutcomeValue,ss as QtiLt,os as QtiLte,ei as QtiMapResponse,ti as QtiMapResponsePoint,ns as QtiMatch,xe as QtiMatchInteraction,ri as QtiMathOperator,or as QtiMediaInteraction,as as QtiMember,Ze as QtiModalFeedback,ls as QtiMultiple,cs as QtiNot,ts as QtiNull,ds as QtiOr,qe as QtiOrderInteraction,ps as QtiOrdered,he as QtiOutcomeDeclaration,dr as QtiOutcomeProcessing,Fi as QtiOutcomeProcessingProcessor,z as QtiPortableCustomInteraction,Vi as QtiPositionObjectInteraction,nr as QtiPositionObjectStage,us as QtiPower,gr as QtiPrintedVariable,ms as QtiProduct,Gr as QtiPrompt,bs as QtiRandom,Et as QtiRandomInteger,Ui as QtiResponseCondition,we as QtiResponseDeclaration,mr as QtiResponseElse,Wi as QtiResponseElseIf,hr as QtiResponseIf,pr as QtiResponseProcessing,Ki as QtiRound,fr as QtiRoundTo,me as QtiRubricBlock,pe as QtiRule,de as QtiSelectPointInteraction,Bi as QtiSetOutcomeValue,ji as QtiSetOutcomeValueRule,Ve as QtiSimpleAssociableChoice,Ee as QtiSimpleChoice,Ce as QtiSliderInteraction,si as QtiStringMatch,ni as QtiStylesheet,ii as QtiSubtract,hs as QtiSum,fs as QtiSumExpression,ai as QtiTest,Er as QtiTestFeedback,Ae as QtiTestPart,J as QtiTextEntryInteraction,lr as QtiUploadInteraction,gs as QtiVariable,Rr as TestCheckItem,Re as TestContainer,Cr as TestEndAttempt,wt as TestItemLink,Q as TestNavigation,ze as TestNext,wr as TestPagingButtonsStamp,Fe as TestPrev,Tr as TestPrintContext,_t as TestPrintVariables,it as TestScoringButtons,At as TestScoringFeedback,_r as TestSectionButtonsStamp,Tt as TestSectionLink,te as TestShowCorrectResponse,rt as TestStamp,W as TestView,Ar as TestViewToggle,Sn as qtiAndMixin,Mn as qtiSubtractMixin,ue as testContext};
5396
5436
  /*! Bundled license information:
5397
5437
 
5398
5438
  @lit/context/lib/context-request-event.js: