@citolab/qti-components 7.24.0 → 7.26.0

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,12 +1,12 @@
1
- var nl=Object.defineProperty;var al=Object.getOwnPropertyDescriptor;var Fo=o=>{throw TypeError(o)};var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?al(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&&nl(r,e,i),i};var Ss=(o,r,e)=>r.has(o)||Fo("Cannot "+e);var x=(o,r,e)=>(Ss(o,r,"read from private field"),e?e.call(o):r.get(o)),T=(o,r,e)=>r.has(o)?Fo("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(o):r.set(o,e),$=(o,r,e,t)=>(Ss(o,r,"write to private field"),t?t.call(o,e):r.set(o,e),e),I=(o,r,e)=>(Ss(o,r,"access private method"),e);var jo=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 be=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},j=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)},wt,bi,vi,sr,Ms,or,yi,at,nr,He,xi,Wo,Xo=o=>typeof o=="boolean"?o:o?.capture??!1;var ks=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=Xo(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=Xo(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},...V},srcElement:{get(){return r.target},...V},currentTarget:{get(){return d},...V},eventPhase:{get(){return n},...V},composedPath:{value:()=>e,...V},stopPropagation:{value:()=>{i=!0,p.call(r)},...V},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...V}});let h=(q,k,P)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),k.once&&P.delete(q)},g=()=>(d=null,n=0,!r.defaultPrevented),v=e.slice().reverse();a=!this.__host||!r.composed?this:null;let E=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of v){!a&&(!l||l===q.__host)&&E(v.slice(v.indexOf(q))),d=q,n=q===r.target?2:1;let k=q.__captureEventListeners.get(r.type);if(k){for(let[P,H]of k)if(h(P,H,k),s)return g()}if(i)return g()}let A=r.bubbles?e:[this];l=null;for(let q of A){!a&&(!l||q===l.__host)&&E(A.slice(0,A.indexOf(q)+1)),d=q,n=q===r.target?2:3;let k=q.__eventListeners.get(r.type);if(k){for(let[P,H]of k)if(h(P,H,k),s)return g()}if(i)return g()}return g()}},Is=ks;var V={__proto__:null};V.enumerable=!0;Object.freeze(V);var Rs=(He=class{constructor(r,e={}){if(wt.set(this,!1),bi.set(this,!1),vi.set(this,!1),sr.set(this,!1),Ms.set(this,Date.now()),or.set(this,!1),yi.set(this,void 0),at.set(this,void 0),nr.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;be(this,wt,!!i,"f"),be(this,bi,!!t,"f"),be(this,vi,!!s,"f"),be(this,yi,`${r}`,"f"),be(this,at,null,"f"),be(this,nr,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){be(this,sr,!0,"f")}get target(){return j(this,at,"f")}get currentTarget(){return j(this,at,"f")}get srcElement(){return j(this,at,"f")}get type(){return j(this,yi,"f")}get cancelable(){return j(this,wt,"f")}get defaultPrevented(){return j(this,wt,"f")&&j(this,sr,"f")}get timeStamp(){return j(this,Ms,"f")}composedPath(){return j(this,nr,"f")?[j(this,at,"f")]:[]}get returnValue(){return!j(this,wt,"f")||!j(this,sr,"f")}get bubbles(){return j(this,bi,"f")}get composed(){return j(this,vi,"f")}get eventPhase(){return j(this,nr,"f")?He.AT_TARGET:He.NONE}get cancelBubble(){return j(this,or,"f")}set cancelBubble(r){r&&be(this,or,!0,"f")}stopPropagation(){be(this,or,!0,"f")}get isTrusted(){return!1}},wt=new WeakMap,bi=new WeakMap,vi=new WeakMap,sr=new WeakMap,Ms=new WeakMap,or=new WeakMap,yi=new WeakMap,at=new WeakMap,nr=new WeakMap,He.NONE=0,He.CAPTURING_PHASE=1,He.AT_TARGET=2,He.BUBBLING_PHASE=3,He);Object.defineProperties(Rs.prototype,{initEvent:V,stopImmediatePropagation:V,preventDefault:V,target:V,currentTarget:V,srcElement:V,type:V,cancelable:V,defaultPrevented:V,timeStamp:V,composedPath:V,returnValue:V,bubbles:V,composed:V,eventPhase:V,cancelBubble:V,stopPropagation:V,isTrusted:V});var Go=(Wo=class extends Rs{constructor(r,e={}){super(r,e),xi.set(this,void 0),be(this,xi,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return j(this,xi,"f")}},xi=new WeakMap,Wo);Object.defineProperties(Go.prototype,{detail:V});var _s=Rs,Ls=Go;globalThis.Event??=_s;globalThis.CustomEvent??=Ls;var Qo=new WeakMap,ar=o=>{let r=Qo.get(o);return r===void 0&&Qo.set(o,r=new Map),r},ll=class extends Is{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(ar(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){ar(this).set(r,String(e))}removeAttribute(r){ar(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 ar(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 jo(this);return this.__internals=r,r}getAttribute(r){return ar(this).get(r)??null}};var cl=class extends ll{},Os=cl;globalThis.litServerRoot??=Object.defineProperty(new Os,"localName",{get(){return"lit-server-root"}});function dl(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var $s=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=dl(),this.__pendingWhenDefineds.set(r,t)),t.promise}},pl=$s;var Yo=new pl;var lr=globalThis,qi=lr.ShadowRoot&&(lr.ShadyCSS===void 0||lr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ps=Symbol(),Jo=new WeakMap,cr=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ps)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(qi&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=Jo.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&Jo.set(e,r))}return r}toString(){return this.cssText}},Ko=o=>new cr(typeof o=="string"?o:o+"",void 0,Ps),y=(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 cr(e,o,Ps)},Zo=(o,r)=>{if(qi)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=lr.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},Vs=qi||lr.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ko(e)})(o):o;var{is:ul,defineProperty:ml,getOwnPropertyDescriptor:hl,getOwnPropertyNames:fl,getOwnPropertySymbols:gl,getPrototypeOf:bl}=Object,ur=globalThis;ur.customElements??=Yo;var en=ur.trustedTypes,vl=en?en.emptyScript:"",yl=ur.reactiveElementPolyfillSupport,dr=(o,r)=>o,pr={toAttribute(o,r){switch(r){case Boolean:o=o?vl: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}},Ci=(o,r)=>!ul(o,r),tn={attribute:!0,type:String,converter:pr,reflect:!1,useDefault:!1,hasChanged:Ci};Symbol.metadata??=Symbol("metadata"),ur.litPropertyMetadata??=new WeakMap;var ke=class extends(globalThis.HTMLElement??Os){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=tn){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&&ml(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=hl(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)??tn}static _$Ei(){if(this.hasOwnProperty(dr("elementProperties")))return;let r=bl(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(dr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dr("properties"))){let e=this.properties,t=[...fl(e),...gl(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(Vs(i))}else r!==void 0&&e.push(Vs(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 Zo(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:pr).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:pr;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??Ci)(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){}};ke.elementStyles=[],ke.shadowRootOptions={mode:"open"},ke[dr("elementProperties")]=new Map,ke[dr("finalized")]=new Map,yl?.({ReactiveElement:ke}),(ur.reactiveElementVersions??=[]).push("2.1.1");var ki=globalThis,wi=ki.trustedTypes,rn=wi?wi.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ds="$lit$",Ie=`lit$${Math.random().toFixed(9).slice(2)}$`,Hs="?"+Ie,xl=`<${Hs}>`,dt=ki.document===void 0?{createTreeWalker:()=>({})}:document,hr=()=>dt.createComment(""),fr=o=>o===null||typeof o!="object"&&typeof o!="function",zs=Array.isArray,cn=o=>zs(o)||typeof o?.[Symbol.iterator]=="function",Ns=`[
1
+ var al=Object.defineProperty;var ll=Object.getOwnPropertyDescriptor;var Fo=o=>{throw TypeError(o)};var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?ll(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&&al(r,e,i),i};var Ss=(o,r,e)=>r.has(o)||Fo("Cannot "+e);var x=(o,r,e)=>(Ss(o,r,"read from private field"),e?e.call(o):r.get(o)),T=(o,r,e)=>r.has(o)?Fo("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(o):r.set(o,e),$=(o,r,e,t)=>(Ss(o,r,"write to private field"),t?t.call(o,e):r.set(o,e),e),I=(o,r,e)=>(Ss(o,r,"access private method"),e);var jo=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 be=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},j=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)},wt,bi,vi,sr,ks,or,yi,at,nr,He,xi,Wo,Xo=o=>typeof o=="boolean"?o:o?.capture??!1;var Ms=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=Xo(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=Xo(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},...V},srcElement:{get(){return r.target},...V},currentTarget:{get(){return d},...V},eventPhase:{get(){return n},...V},composedPath:{value:()=>e,...V},stopPropagation:{value:()=>{i=!0,p.call(r)},...V},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...V}});let h=(q,M,P)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),M.once&&P.delete(q)},g=()=>(d=null,n=0,!r.defaultPrevented),v=e.slice().reverse();a=!this.__host||!r.composed?this:null;let E=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of v){!a&&(!l||l===q.__host)&&E(v.slice(v.indexOf(q))),d=q,n=q===r.target?2:1;let M=q.__captureEventListeners.get(r.type);if(M){for(let[P,H]of M)if(h(P,H,M),s)return g()}if(i)return g()}let A=r.bubbles?e:[this];l=null;for(let q of A){!a&&(!l||q===l.__host)&&E(A.slice(0,A.indexOf(q)+1)),d=q,n=q===r.target?2:3;let M=q.__eventListeners.get(r.type);if(M){for(let[P,H]of M)if(h(P,H,M),s)return g()}if(i)return g()}return g()}},Is=Ms;var V={__proto__:null};V.enumerable=!0;Object.freeze(V);var Rs=(He=class{constructor(r,e={}){if(wt.set(this,!1),bi.set(this,!1),vi.set(this,!1),sr.set(this,!1),ks.set(this,Date.now()),or.set(this,!1),yi.set(this,void 0),at.set(this,void 0),nr.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;be(this,wt,!!i,"f"),be(this,bi,!!t,"f"),be(this,vi,!!s,"f"),be(this,yi,`${r}`,"f"),be(this,at,null,"f"),be(this,nr,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){be(this,sr,!0,"f")}get target(){return j(this,at,"f")}get currentTarget(){return j(this,at,"f")}get srcElement(){return j(this,at,"f")}get type(){return j(this,yi,"f")}get cancelable(){return j(this,wt,"f")}get defaultPrevented(){return j(this,wt,"f")&&j(this,sr,"f")}get timeStamp(){return j(this,ks,"f")}composedPath(){return j(this,nr,"f")?[j(this,at,"f")]:[]}get returnValue(){return!j(this,wt,"f")||!j(this,sr,"f")}get bubbles(){return j(this,bi,"f")}get composed(){return j(this,vi,"f")}get eventPhase(){return j(this,nr,"f")?He.AT_TARGET:He.NONE}get cancelBubble(){return j(this,or,"f")}set cancelBubble(r){r&&be(this,or,!0,"f")}stopPropagation(){be(this,or,!0,"f")}get isTrusted(){return!1}},wt=new WeakMap,bi=new WeakMap,vi=new WeakMap,sr=new WeakMap,ks=new WeakMap,or=new WeakMap,yi=new WeakMap,at=new WeakMap,nr=new WeakMap,He.NONE=0,He.CAPTURING_PHASE=1,He.AT_TARGET=2,He.BUBBLING_PHASE=3,He);Object.defineProperties(Rs.prototype,{initEvent:V,stopImmediatePropagation:V,preventDefault:V,target:V,currentTarget:V,srcElement:V,type:V,cancelable:V,defaultPrevented:V,timeStamp:V,composedPath:V,returnValue:V,bubbles:V,composed:V,eventPhase:V,cancelBubble:V,stopPropagation:V,isTrusted:V});var Go=(Wo=class extends Rs{constructor(r,e={}){super(r,e),xi.set(this,void 0),be(this,xi,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return j(this,xi,"f")}},xi=new WeakMap,Wo);Object.defineProperties(Go.prototype,{detail:V});var _s=Rs,Ls=Go;globalThis.Event??=_s;globalThis.CustomEvent??=Ls;var Qo=new WeakMap,ar=o=>{let r=Qo.get(o);return r===void 0&&Qo.set(o,r=new Map),r},cl=class extends Is{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(ar(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){ar(this).set(r,String(e))}removeAttribute(r){ar(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 ar(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 jo(this);return this.__internals=r,r}getAttribute(r){return ar(this).get(r)??null}};var dl=class extends cl{},Os=dl;globalThis.litServerRoot??=Object.defineProperty(new Os,"localName",{get(){return"lit-server-root"}});function pl(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var $s=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=pl(),this.__pendingWhenDefineds.set(r,t)),t.promise}},ul=$s;var Yo=new ul;var lr=globalThis,qi=lr.ShadowRoot&&(lr.ShadyCSS===void 0||lr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ps=Symbol(),Jo=new WeakMap,cr=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ps)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(qi&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=Jo.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&Jo.set(e,r))}return r}toString(){return this.cssText}},Ko=o=>new cr(typeof o=="string"?o:o+"",void 0,Ps),y=(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 cr(e,o,Ps)},Zo=(o,r)=>{if(qi)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=lr.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},Vs=qi||lr.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ko(e)})(o):o;var{is:ml,defineProperty:hl,getOwnPropertyDescriptor:fl,getOwnPropertyNames:gl,getOwnPropertySymbols:bl,getPrototypeOf:vl}=Object,ur=globalThis;ur.customElements??=Yo;var en=ur.trustedTypes,yl=en?en.emptyScript:"",xl=ur.reactiveElementPolyfillSupport,dr=(o,r)=>o,pr={toAttribute(o,r){switch(r){case Boolean:o=o?yl: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}},Ci=(o,r)=>!ml(o,r),tn={attribute:!0,type:String,converter:pr,reflect:!1,useDefault:!1,hasChanged:Ci};Symbol.metadata??=Symbol("metadata"),ur.litPropertyMetadata??=new WeakMap;var Me=class extends(globalThis.HTMLElement??Os){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=tn){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&&hl(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=fl(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)??tn}static _$Ei(){if(this.hasOwnProperty(dr("elementProperties")))return;let r=vl(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(dr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dr("properties"))){let e=this.properties,t=[...gl(e),...bl(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(Vs(i))}else r!==void 0&&e.push(Vs(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 Zo(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:pr).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:pr;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??Ci)(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){}};Me.elementStyles=[],Me.shadowRootOptions={mode:"open"},Me[dr("elementProperties")]=new Map,Me[dr("finalized")]=new Map,xl?.({ReactiveElement:Me}),(ur.reactiveElementVersions??=[]).push("2.1.1");var Mi=globalThis,wi=Mi.trustedTypes,rn=wi?wi.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ds="$lit$",Ie=`lit$${Math.random().toFixed(9).slice(2)}$`,Hs="?"+Ie,ql=`<${Hs}>`,dt=Mi.document===void 0?{createTreeWalker:()=>({})}:document,hr=()=>dt.createComment(""),fr=o=>o===null||typeof o!="object"&&typeof o!="function",zs=Array.isArray,cn=o=>zs(o)||typeof o?.[Symbol.iterator]=="function",Ns=`[
3
3
  \f\r]`,mr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,sn=/-->/g,on=/>/g,lt=RegExp(`>|${Ns}(?:([^\\s"'>=/]+)(${Ns}*=${Ns}*(?:[^
4
- \f\r"'\`<>=]|("|')|))|$)`,"g"),nn=/'/g,an=/"/g,dn=/^(?:script|style|textarea|title)$/i,Us=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Us(1),Ii=Us(2),Tc=Us(3),z=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),ln=new WeakMap,ct=dt.createTreeWalker(dt,129);function pn(o,r){if(!zs(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return rn!==void 0?rn.createHTML(r):r}var un=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=mr;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,h=0;for(;h<l.length&&(n.lastIndex=h,p=n.exec(l),p!==null);)h=n.lastIndex,n===mr?p[1]==="!--"?n=sn:p[1]!==void 0?n=on:p[2]!==void 0?(dn.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=lt):p[3]!==void 0&&(n=lt):n===lt?p[0]===">"?(n=i??mr,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?lt:p[3]==='"'?an:nn):n===an||n===nn?n=lt:n===sn||n===on?n=mr:(n=lt,i=void 0);let g=n===lt&&o[a+1].startsWith("/>")?" ":"";s+=n===mr?l+xl:m>=0?(t.push(d),l.slice(0,m)+Ds+l.slice(m)+Ie+g):l+Ie+(m===-2?a:g)}return[pn(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},gr=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]=un(r,e);if(this.el=o.createElement(d,t),ct.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=ct.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ds)){let h=p[n++],g=i.getAttribute(m).split(Ie),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:v[2],strings:g,ctor:v[1]==="."?Ti:v[1]==="?"?Ai:v[1]==="@"?Si:ut}),i.removeAttribute(m)}else m.startsWith(Ie)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(dn.test(i.tagName)){let m=i.textContent.split(Ie),h=m.length-1;if(h>0){i.textContent=wi?wi.emptyScript:"";for(let g=0;g<h;g++)i.append(m[g],hr()),ct.nextNode(),l.push({type:2,index:++s});i.append(m[h],hr())}}}else if(i.nodeType===8)if(i.data===Hs)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(Ie,m+1))!==-1;)l.push({type:7,index:s}),m+=Ie.length-1}s++}}static createElement(r,e){let t=dt.createElement("template");return t.innerHTML=r,t}};function pt(o,r,e=o,t){if(r===z)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=fr(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=pt(o,i._$AS(o,r.values),i,t)),r}var Ei=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??dt).importNode(e,!0);ct.currentNode=i;let s=ct.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new Et(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new Mi(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=ct.nextNode(),n++)}return ct.currentNode=dt,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++}},Et=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=L,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=pt(this,r,e),fr(r)?r===L||r==null||r===""?(this._$AH!==L&&this._$AR(),this._$AH=L):r!==this._$AH&&r!==z&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):cn(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!==L&&fr(this._$AH)?this._$AA.nextSibling.data=r:this.T(dt.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=gr.createElement(pn(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Ei(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=ln.get(r.strings);return e===void 0&&ln.set(r.strings,e=new gr(r)),e}k(r){zs(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(hr()),this.O(hr()),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))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=L,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=L}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=pt(this,r,e,0),n=!fr(r)||r!==this._$AH&&r!==z,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=pt(this,a[t+l],e,l),d===z&&(d=this._$AH[l]),n||=!fr(d)||d!==this._$AH[l],d===L?r=L:r!==L&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===L?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Ti=class extends ut{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===L?void 0:r}},Ai=class extends ut{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==L)}},Si=class extends ut{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=pt(this,r,e,0)??L)===z)return;let t=this._$AH,i=r===L&&t!==L||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==L&&(t===L||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)}},Mi=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){pt(this,r)}},W={M:Ds,P:Ie,A:Hs,C:1,L:un,R:Ei,D:cn,V:pt,I:Et,H:ut,N:Ai,U:Si,B:Ti,F:Mi},ql=ki.litHtmlPolyfillSupport;ql?.(gr,Et),(ki.litHtmlVersions??=[]).push("3.3.1");var Bs=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new Et(r.insertBefore(hr(),s),s,void 0,e??{})}return i._$AI(o),i};var Fs=globalThis,b=class extends ke{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=Bs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};b._$litElement$=!0,b.finalized=!0,Fs.litElementHydrateSupport?.({LitElement:b});var Cl=Fs.litElementPolyfillSupport;Cl?.({LitElement:b});(Fs.litElementVersions??=[]).push("4.2.1");var C=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var wl={attribute:!0,type:String,converter:pr,reflect:!1,hasChanged:Ci},El=(o=wl,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"?El(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 w(o){return u({...o,state:!0,attribute:!1})}var ze=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function Tt(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 ze(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 ze(e,t,{get(){return s(this)}})}}function mn(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return ze(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 hn(o,r,e){Array.from(o.getElementsByTagName("*")).filter(s=>s.localName===r||s.localName?.toLowerCase()===r.toLowerCase()).forEach(s=>{let n=`${r}-${e}`,a=gn(s,n);s.replaceWith(a)})}function fn(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=gn(e,n);e.replaceWith(a)}})})}function gn(o,r){let e=o.ownerDocument.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function bn(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 At(o,r){return fetch(o,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function St(o){return new DOMParser().parseFromString(o,"text/xml")}function vn(o,r){if(o.nodeType===Node.ELEMENT_NODE){let e=o,t=r.createElement(e.localName);for(let i=0;i<e.attributes.length;i++){let s=e.attributes[i];t.setAttribute(s.localName,s.value)}for(let i=0;i<e.childNodes.length;i++)t.appendChild(vn(e.childNodes[i],r));return t}return o.cloneNode(!1)}function Mt(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(vn(o.childNodes[e],document));return r}function kt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("*").forEach(t=>{for(let i of["src","href"]){let s=t.getAttribute(i)?.trim();if(s&&!/^(data:|https?:|blob:)/.test(s)){let n=r+encodeURI(s);t.setAttribute(i,n)}}})}function yn(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 xn(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function qn(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:return null}}var ve=(o=!1)=>{let r,e="",t={load(i,s){e=i;let n=encodeURI(i);return o&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):At(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=St(i),t},path:i=>(kt(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);if(l.length===0)return t;let d=null,p=null,m=async()=>{if(d===null)try{d=await s(i,"/modules/module_resolution.js")}catch{d=null}if(p===null)try{p=await s(i,"/modules/fallback_module_resolution.js")}catch{p=null}};for(let h of Array.from(l)){h.setAttribute("data-base-url",i);let g=h.getAttribute("custom-interaction-type-identifier");g&&a.includes(g)&&(g=g+a.length,h.setAttribute("custom-interaction-type-identifier",g),a.push(g)),g&&a.push(g);let v=h.querySelector("qti-interaction-modules");if(v&&v.getAttribute("primary-configuration")){await m();let E=v.getAttribute("primary-configuration");if(E)try{let A=await s(i,`/${E}`),q=Array.from(v.querySelectorAll("qti-interaction-module"));for(let k of q){let P=k.getAttribute("id");if(P&&A.paths&&A.paths[P]){let H=A.paths[P],Z=Array.isArray(H)?H[0]:H;if(k.setAttribute("primary-path",Z),p&&p.paths&&p.paths[P]){let F=p.paths[P];Array.isArray(F)?k.setAttribute("fallback-path",F[0]):k.setAttribute("fallback-path",F)}}}if(A.paths){for(let k in A.paths)if(!v.querySelector(`qti-interaction-module[id="${k}"]`)){let H=r.createElement("qti-interaction-module");H.setAttribute("id",k);let Z=Array.isArray(A.paths[k])?A.paths[k][0]:A.paths[k];if(H.setAttribute("primary-path",Z),p&&p.paths&&p.paths[k]){let F=p.paths[k];Array.isArray(F)?H.setAttribute("fallback-path",F[0]):H.setAttribute("fallback-path",F)}v.appendChild(H)}}A.urlArgs&&v.setAttribute("url-args",A.urlArgs)}catch(A){console.warn(`Failed to load primary configuration: ${E}`,A)}}else if(await m(),d){h.querySelector("qti-interaction-modules")===null?(v=r.createElement("qti-interaction-modules"),h.appendChild(v)):v=h.querySelector("qti-interaction-modules");for(let E in d.paths){let A=d.paths[E],q="";p&&p.paths&&p.paths[E]&&(q=p.paths[E]);let k=Array.isArray(A)?A:[A],P=Array.isArray(q)?q:[q],H=k.map((Z,F)=>{let ol=P.length>F?P[F]:"";return{primaryPath:Z,fallbackPath:ol}});for(let Z of P)H.some(F=>F.fallbackPath===Z)||H.push({primaryPath:k.length>0?k[0]:Z,fallbackPath:Z});for(let Z of H){let F=r.createElement("qti-interaction-module");Z.fallbackPath&&F.setAttribute("fallback-path",Z.fallbackPath),F.setAttribute("id",E),F.setAttribute("primary-path",Z.primaryPath),v&&v.appendChild(F)}}}}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=qn(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,k)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:k})).filter(q=>q.fixed),h=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(h.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let g=[...h],v=!1,E=0;for(;!v&&E<20;){E++;for(let q=h.length-1;q>0;q--){let k=Math.floor(Math.random()*(q+1));[h[q],h[k]]=[h[k],h[q]]}v=!h.every((q,k)=>q===g[k])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let A=0;for(let q of h)q.parentElement.insertBefore(q,m[A]?.element),A++;for(let q of m)q.element.parentElement.insertBefore(q.element,h[q.originalOrder])}}return t},extendElementName:(i,s)=>(hn(r,i,s),t),extendElementsWithClass:(i="extend")=>(fn(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 yn(r),t},stripStyleSheets(){return xn(r),t},html(){return e!==null&&kt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(Mt(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&kt(r,e.substring(0,e.lastIndexOf("/"))),Mt(r)},xmlDoc(){return r}};return t};var Cn=()=>{let o,r={async load(e,t){return new Promise(i=>{At(e,t).then(s=>(o=s,i(r)))})},parse(e){o=St(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var It=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{At(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=St(e),r},path:e=>(kt(o,e),r),fn(e){return e(o),r},items(){return bn(o)},html(){return new XMLSerializer().serializeToString(Mt(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return Mt(o)},xmlDoc(){return o}};return r};var wn=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._navigationId=0;this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,s){let n=s||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let s=i.detail;this._loadingState.connectedItems++;let n=s.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:s,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:s.identifier,href:s.href,item:n.identifier}),this._loadedStimulusHrefs.has(s.href)){console.info("Stimulus already loaded, skipping:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(s.href)){console.info("Stimulus already loading, skipping duplicate:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(s.href),console.info("Starting stimulus load:",s.href);try{await this._loadStimulusRef(s,n),this._loadedStimulusHrefs.add(s.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",s.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${s.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(s.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(!i?.id)return;this._cancelPreviousNavigation();let s=++this._navigationId,n=new AbortController;try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=n,await this._executeNavigation(i.type,i.id,s,n)}catch(a){this._handleNavigationError(a,i.type,i.id)}finally{this._activeController===n&&(this._activeController=null),this._dispatchLoadingEnded(i.type,i.id)}}_handleNavigationError(i,s,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,s,n))}async _executeNavigation(i,s,n,a){i==="item"?await this._navigateToItem(s,n,a):await this._navigateToSection(s,n,a)}async _navigateToItem(i,s,n){let a=this._findItemRef(i);this._updateSessionContext(a,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i,s,n){let l=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:l,navSectionId:i,navItemRefId:null};let d=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=d.length,await this._loadItems(d,s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,s=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&s&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,s){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,s))return;await new Promise(n=>setTimeout(n,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,s){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,s)}_applyStimulusContent(i,s,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${s.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],d=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${s.identifier}"]`);if(d)l.push(d),console.info("Found specific target:",d);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${s.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let m=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=m,console.info("Using fallback targets:",m.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,m)=>{p.innerHTML="";let h=Array.from(a).map(g=>g.cloneNode(!0));p.append(...h),console.info(`Applied stimulus content to target ${m+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i,s,n){if(!this._testElement||i.length===0)return;let a=i.map(p=>this._findItemRef(p));this._clearLoadedItems(),this._clearStimulusRef();let d=(await Promise.all(a.map(p=>this._loadSingleItem(p,s,n)))).filter(Boolean);this._isStaleNavigation(s,n)||(d.forEach(({itemRef:p,doc:m})=>{p&&m&&(p.xmlDoc=m)}),d.forEach(({itemRef:p})=>{let m=p?.identifier;if(!p||!m)return;let h=this.testContext.items.find(g=>g.identifier===m)?.state;h!==void 0&&p.updateComplete.then(()=>{let g=p.assessmentItem;g&&(g.state=h)})}),this._loadResults=d)}async _loadSingleItem(i,s,n){try{let a=await ve(this.cacheTransform).load(i.href,n.signal);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(s,n)?null:{itemRef:i,doc:a.htmlDoc()}}catch(a){if(a.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),a;return console.warn(`Failed to load item ${i.identifier}:`,a),null}}async _loadStimulus(i){return(await ve().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw new Error(`Item with identifier "${i}" not found`);return s}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,s){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:s}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(s=>s.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,s){return s.signal.aborted||i!==this._navigationId}_createNavigationError(i,s,n){return{message:i.message||`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchLoadingStarted(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:s})=>({identifier:s?.identifier,element:s})),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({attribute:!1})],r.prototype,"postLoadTransformCallback",2),c([u({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var En=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 Ue=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 Rt=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 Ue(this.context,this.host,this.t,this.subscribe))}};var Ri=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 js=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},_t=class extends Ri{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 Ue(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 js(this.context,this.host))}};function ee({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 _t(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new _t(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 M({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new Rt(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new Rt(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Be=Symbol("computedItemContext");var N=Symbol("computedContext");var ae=Symbol("configContext");var Tn=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var D=Symbol("item");var Lt=Symbol("qtiContext");var Ws={view:"candidate"},Fe=Symbol("testContext");var Xs={items:[],testOutcomeVariables:[]},ye=Symbol("testContext");function _i(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let h=[],g=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(k=>{if(k.nodeType!==1)return;let P=k;P.matches?.(o)&&h.push(P),h.push(...P.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(k=>{if(k.nodeType!==1)return;let P=k;P.matches?.(o)&&g.push(P),g.push(...P.querySelectorAll?.(o)??[])}));let v=q=>Array.from(new Set(q)),E=v(h),A=v(g);(E.length||A.length)&&n.call(this,E,A)},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 O(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 je={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},te=o=>(...r)=>({_$litDirective$:o,values:r}),xe=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:Tl}=W,Sn=o=>o===null||typeof o!="object"&&typeof o!="function";var Mn=o=>o.strings===void 0,An=()=>document.createComment(""),$t=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(An(),i),n=t.insertBefore(An(),i);e=new Tl(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},We=(o,r,e=o)=>(o._$AI(r,e),o),Al={},kn=(o,r=Al)=>o._$AH=r,In=o=>o._$AH,Li=o=>{o._$AR(),o._$AA.remove()};var br=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),br(t,r);return!0},$i=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},Rn=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),kl(r)}};function Sl(o){this._$AN!==void 0?($i(this),this._$AM=o,Rn(this)):this._$AM=o}function Ml(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++)br(t[s],!1),$i(t[s]);else t!=null&&(br(t,!1),$i(t));else br(this,o)}var kl=o=>{o.type==je.CHILD&&(o._$AP??=Ml,o._$AQ??=Sl)},Xe=class extends xe{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),Rn(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(br(this,r),$i(this))}setValue(r){if(Mn(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 Gs=class extends Xe{constructor(){super(...arguments);this.prevData={}}render(e){return L}update(e,[t]){return this.element!==e.element&&(this.element=e.element),this.host=e.options?.host||this.element,this.apply(t),this.groom(t),this.prevData={...t},L}apply(e){let t=this.#e(e),{prevData:i,element:s}=this;for(let n in t){let a=t[n];a!==i[n]&&(a===!0?s.setAttribute(n,""):a===!1?s.removeAttribute(n):a!=null?s.setAttribute(n,String(a)):s.removeAttribute(n))}}groom(e){let{prevData:t,element:i}=this;if(!t)return;let s=e?this.#e(e):{};for(let n in t)(!s||!(n in s))&&i.removeAttribute(n)}#e(e){return Object.fromEntries(Object.entries(e).filter(([t,i])=>typeof i=="function"?!1:t==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Op=te(Gs);var _n=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(_n||{}),R=class extends b{constructor(){super();this.disabled=!1;this.readonly=!1;this.showCorrectResponse=!1;this._handleShowCorrectResponseChange=(e,t)=>{this.toggleInternalCorrectResponse(t)};this.showFullCorrectResponse=!1;this._handleShowFullCorrectResponseChange=(e,t)=>{this.toggleFullCorrectResponse(t)};this.showCandidateCorrection=!1;this._handleShowCandidateCorrectionChange=(e,t)=>{this.toggleCandidateCorrection(t)};this._correctResponse=null;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}set correctResponseAttr(e){e===null?this._correctResponse=null:e.includes(",")?this._correctResponse=e.split(",").map(t=>t.trim()):this._correctResponse=e}get correctResponseAttr(){return this._correctResponse===null||this._correctResponse===void 0?null:Array.isArray(this._correctResponse)?this._correctResponse.join(","):this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){let e=this.responseVariable;return e?.correctResponse?e.correctResponse:this._correctResponse}set correctResponse(e){let t=this._correctResponse;this._correctResponse=e,e==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(e)?e.join(","):e),this.requestUpdate("_correctResponse",t)}get correctness(){let e=this.correctResponse;if(!e)return null;let t=this.response;if(t==null||t===""||Array.isArray(t)&&t.length===0)return null;let i=Array.isArray(e)?e:[e],n=(Array.isArray(t)?t:[t]).filter(d=>d!=="");if(n.length===0)return null;let a=n.filter(d=>i.includes(d)).length,l=n.filter(d=>!i.includes(d)).length;return a===i.length&&l===0&&n.length===i.length?"correct":a>0&&(a<i.length||l>0)?"partially-correct":"incorrect"}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;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.correctResponse;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t);return}if(i)return;let a=this.cloneNode(!0);a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-candidate-correction");let l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(s)?[...s]:s}toggleInternalCorrectResponse(e){this._internals.states.delete("show-correct-response"),e&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(e){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}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}firstUpdated(){this.isFullCorrectResponse||(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0))}saveResponse(e,t){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e,...t!==void 0?{state:t}:{}}}))}};c([M({context:D,subscribe:!0})],R.prototype,"_context",2),c([M({context:ae,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([u({type:String})],R.prototype,"name",2),c([u({type:String,attribute:"correct-response",reflect:!0})],R.prototype,"correctResponseAttr",1),c([u({type:Boolean,attribute:"show-correct-response",reflect:!0})],R.prototype,"showCorrectResponse",2),c([O("showCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],R.prototype,"showFullCorrectResponse",2),c([O("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowFullCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],R.prototype,"showCandidateCorrection",2),c([O("showCandidateCorrection",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCandidateCorrectionChange",2),c([w()],R.prototype,"_isFullCorrectResponse",2),c([w()],R.prototype,"_correctResponse",2);var Ot=class extends b{render(){return f`<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]}};var S=class extends b{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=y`
4
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),nn=/'/g,an=/"/g,dn=/^(?:script|style|textarea|title)$/i,Us=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),f=Us(1),Ii=Us(2),Ac=Us(3),z=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),ln=new WeakMap,ct=dt.createTreeWalker(dt,129);function pn(o,r){if(!zs(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return rn!==void 0?rn.createHTML(r):r}var un=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=mr;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,h=0;for(;h<l.length&&(n.lastIndex=h,p=n.exec(l),p!==null);)h=n.lastIndex,n===mr?p[1]==="!--"?n=sn:p[1]!==void 0?n=on:p[2]!==void 0?(dn.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=lt):p[3]!==void 0&&(n=lt):n===lt?p[0]===">"?(n=i??mr,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?lt:p[3]==='"'?an:nn):n===an||n===nn?n=lt:n===sn||n===on?n=mr:(n=lt,i=void 0);let g=n===lt&&o[a+1].startsWith("/>")?" ":"";s+=n===mr?l+ql:m>=0?(t.push(d),l.slice(0,m)+Ds+l.slice(m)+Ie+g):l+Ie+(m===-2?a:g)}return[pn(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},gr=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]=un(r,e);if(this.el=o.createElement(d,t),ct.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=ct.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ds)){let h=p[n++],g=i.getAttribute(m).split(Ie),v=/([.?@])?(.*)/.exec(h);l.push({type:1,index:s,name:v[2],strings:g,ctor:v[1]==="."?Ti:v[1]==="?"?Ai:v[1]==="@"?Si:ut}),i.removeAttribute(m)}else m.startsWith(Ie)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(dn.test(i.tagName)){let m=i.textContent.split(Ie),h=m.length-1;if(h>0){i.textContent=wi?wi.emptyScript:"";for(let g=0;g<h;g++)i.append(m[g],hr()),ct.nextNode(),l.push({type:2,index:++s});i.append(m[h],hr())}}}else if(i.nodeType===8)if(i.data===Hs)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(Ie,m+1))!==-1;)l.push({type:7,index:s}),m+=Ie.length-1}s++}}static createElement(r,e){let t=dt.createElement("template");return t.innerHTML=r,t}};function pt(o,r,e=o,t){if(r===z)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=fr(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=pt(o,i._$AS(o,r.values),i,t)),r}var Ei=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??dt).importNode(e,!0);ct.currentNode=i;let s=ct.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new Et(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new ki(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=ct.nextNode(),n++)}return ct.currentNode=dt,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++}},Et=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=L,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=pt(this,r,e),fr(r)?r===L||r==null||r===""?(this._$AH!==L&&this._$AR(),this._$AH=L):r!==this._$AH&&r!==z&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):cn(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!==L&&fr(this._$AH)?this._$AA.nextSibling.data=r:this.T(dt.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=gr.createElement(pn(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Ei(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=ln.get(r.strings);return e===void 0&&ln.set(r.strings,e=new gr(r)),e}k(r){zs(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(hr()),this.O(hr()),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))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=L,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=L}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=pt(this,r,e,0),n=!fr(r)||r!==this._$AH&&r!==z,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=pt(this,a[t+l],e,l),d===z&&(d=this._$AH[l]),n||=!fr(d)||d!==this._$AH[l],d===L?r=L:r!==L&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===L?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Ti=class extends ut{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===L?void 0:r}},Ai=class extends ut{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==L)}},Si=class extends ut{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=pt(this,r,e,0)??L)===z)return;let t=this._$AH,i=r===L&&t!==L||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==L&&(t===L||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)}},ki=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){pt(this,r)}},W={M:Ds,P:Ie,A:Hs,C:1,L:un,R:Ei,D:cn,V:pt,I:Et,H:ut,N:Ai,U:Si,B:Ti,F:ki},Cl=Mi.litHtmlPolyfillSupport;Cl?.(gr,Et),(Mi.litHtmlVersions??=[]).push("3.3.1");var Bs=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new Et(r.insertBefore(hr(),s),s,void 0,e??{})}return i._$AI(o),i};var Fs=globalThis,b=class extends Me{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=Bs(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};b._$litElement$=!0,b.finalized=!0,Fs.litElementHydrateSupport?.({LitElement:b});var wl=Fs.litElementPolyfillSupport;wl?.({LitElement:b});(Fs.litElementVersions??=[]).push("4.2.1");var C=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var El={attribute:!0,type:String,converter:pr,reflect:!1,hasChanged:Ci},Tl=(o=El,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"?Tl(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 w(o){return u({...o,state:!0,attribute:!1})}var ze=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function Tt(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 ze(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 ze(e,t,{get(){return s(this)}})}}function mn(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return ze(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 hn(o,r,e){Array.from(o.getElementsByTagName("*")).filter(s=>s.localName===r||s.localName?.toLowerCase()===r.toLowerCase()).forEach(s=>{let n=`${r}-${e}`,a=gn(s,n);s.replaceWith(a)})}function fn(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=gn(e,n);e.replaceWith(a)}})})}function gn(o,r){let e=o.ownerDocument.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function bn(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 At(o,r){return fetch(o,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function St(o){return new DOMParser().parseFromString(o,"text/xml")}function vn(o,r){if(o.nodeType===Node.ELEMENT_NODE){let e=o,t=r.createElement(e.localName);for(let i=0;i<e.attributes.length;i++){let s=e.attributes[i];t.setAttribute(s.localName,s.value)}for(let i=0;i<e.childNodes.length;i++)t.appendChild(vn(e.childNodes[i],r));return t}return o.cloneNode(!1)}function kt(o){let r=document.createDocumentFragment();for(let e=0;e<o.childNodes.length;e++)r.appendChild(vn(o.childNodes[e],document));return r}function Mt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("*").forEach(t=>{for(let i of["src","href"]){let s=t.getAttribute(i)?.trim();if(s&&!/^(data:|https?:|blob:)/.test(s)){let n=r+encodeURI(s);t.setAttribute(i,n)}}})}function yn(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 xn(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function qn(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:return null}}var ve=(o=!1)=>{let r,e="",t={load(i,s){e=i;let n=encodeURI(i);return o&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):At(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=St(i),t},path:i=>(Mt(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);if(l.length===0)return t;let d=null,p=null,m=async()=>{if(d===null)try{d=await s(i,"/modules/module_resolution.js")}catch{d=null}if(p===null)try{p=await s(i,"/modules/fallback_module_resolution.js")}catch{p=null}};for(let h of Array.from(l)){h.setAttribute("data-base-url",i);let g=h.getAttribute("custom-interaction-type-identifier");g&&a.includes(g)&&(g=g+a.length,h.setAttribute("custom-interaction-type-identifier",g),a.push(g)),g&&a.push(g);let v=h.querySelector("qti-interaction-modules");if(v&&v.getAttribute("primary-configuration")){await m();let E=v.getAttribute("primary-configuration");if(E)try{let A=await s(i,`/${E}`),q=Array.from(v.querySelectorAll("qti-interaction-module"));for(let M of q){let P=M.getAttribute("id");if(P&&A.paths&&A.paths[P]){let H=A.paths[P],Z=Array.isArray(H)?H[0]:H;if(M.setAttribute("primary-path",Z),p&&p.paths&&p.paths[P]){let F=p.paths[P];Array.isArray(F)?M.setAttribute("fallback-path",F[0]):M.setAttribute("fallback-path",F)}}}if(A.paths){for(let M in A.paths)if(!v.querySelector(`qti-interaction-module[id="${M}"]`)){let H=r.createElement("qti-interaction-module");H.setAttribute("id",M);let Z=Array.isArray(A.paths[M])?A.paths[M][0]:A.paths[M];if(H.setAttribute("primary-path",Z),p&&p.paths&&p.paths[M]){let F=p.paths[M];Array.isArray(F)?H.setAttribute("fallback-path",F[0]):H.setAttribute("fallback-path",F)}v.appendChild(H)}}A.urlArgs&&v.setAttribute("url-args",A.urlArgs)}catch(A){console.warn(`Failed to load primary configuration: ${E}`,A)}}else if(await m(),d){h.querySelector("qti-interaction-modules")===null?(v=r.createElement("qti-interaction-modules"),h.appendChild(v)):v=h.querySelector("qti-interaction-modules");for(let E in d.paths){let A=d.paths[E],q="";p&&p.paths&&p.paths[E]&&(q=p.paths[E]);let M=Array.isArray(A)?A:[A],P=Array.isArray(q)?q:[q],H=M.map((Z,F)=>{let nl=P.length>F?P[F]:"";return{primaryPath:Z,fallbackPath:nl}});for(let Z of P)H.some(F=>F.fallbackPath===Z)||H.push({primaryPath:M.length>0?M[0]:Z,fallbackPath:Z});for(let Z of H){let F=r.createElement("qti-interaction-module");Z.fallbackPath&&F.setAttribute("fallback-path",Z.fallbackPath),F.setAttribute("id",E),F.setAttribute("primary-path",Z.primaryPath),v&&v.appendChild(F)}}}}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=qn(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,M)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:M})).filter(q=>q.fixed),h=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(h.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let g=[...h],v=!1,E=0;for(;!v&&E<20;){E++;for(let q=h.length-1;q>0;q--){let M=Math.floor(Math.random()*(q+1));[h[q],h[M]]=[h[M],h[q]]}v=!h.every((q,M)=>q===g[M])}if(!v)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let A=0;for(let q of h)q.parentElement.insertBefore(q,m[A]?.element),A++;for(let q of m)q.element.parentElement.insertBefore(q.element,h[q.originalOrder])}}return t},extendElementName:(i,s)=>(hn(r,i,s),t),extendElementsWithClass:(i="extend")=>(fn(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 yn(r),t},stripStyleSheets(){return xn(r),t},html(){return e!==null&&Mt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(kt(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&Mt(r,e.substring(0,e.lastIndexOf("/"))),kt(r)},xmlDoc(){return r}};return t};var Cn=()=>{let o,r={async load(e,t){return new Promise(i=>{At(e,t).then(s=>(o=s,i(r)))})},parse(e){o=St(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return r};var It=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{At(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=St(e),r},path:e=>(Mt(o,e),r),fn(e){return e(o),r},items(){return bn(o)},html(){return new XMLSerializer().serializeToString(kt(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return kt(o)},xmlDoc(){return o}};return r};var wn=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._navigationId=0;this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,s){let n=s||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let s=i.detail;this._loadingState.connectedItems++;let n=s.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:s,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:s.identifier,href:s.href,item:n.identifier}),this._loadedStimulusHrefs.has(s.href)){console.info("Stimulus already loaded, skipping:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(s.href)){console.info("Stimulus already loading, skipping duplicate:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(s.href),console.info("Starting stimulus load:",s.href);try{await this._loadStimulusRef(s,n),this._loadedStimulusHrefs.add(s.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",s.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${s.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(s.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(!i?.id)return;this._cancelPreviousNavigation();let s=++this._navigationId,n=new AbortController;try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=n,await this._executeNavigation(i.type,i.id,s,n)}catch(a){this._handleNavigationError(a,i.type,i.id)}finally{this._activeController===n&&(this._activeController=null),this._dispatchLoadingEnded(i.type,i.id)}}_handleNavigationError(i,s,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,s,n))}async _executeNavigation(i,s,n,a){i==="item"?await this._navigateToItem(s,n,a):await this._navigateToSection(s,n,a)}async _navigateToItem(i,s,n){let a=this._findItemRef(i);this._updateSessionContext(a,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i,s,n){let l=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:l,navSectionId:i,navItemRefId:null};let d=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=d.length,await this._loadItems(d,s,n),await this._waitForLoadingComplete(s,n),!this._isStaleNavigation(s,n)&&this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,s=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&s&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,s){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,s))return;await new Promise(n=>setTimeout(n,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,s){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,s)}_applyStimulusContent(i,s,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${s.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],d=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${s.identifier}"]`);if(d)l.push(d),console.info("Found specific target:",d);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${s.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let m=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=m,console.info("Using fallback targets:",m.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,m)=>{p.innerHTML="";let h=Array.from(a).map(g=>g.cloneNode(!0));p.append(...h),console.info(`Applied stimulus content to target ${m+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i,s,n){if(!this._testElement||i.length===0)return;let a=i.map(p=>this._findItemRef(p));this._clearLoadedItems(),this._clearStimulusRef();let d=(await Promise.all(a.map(p=>this._loadSingleItem(p,s,n)))).filter(Boolean);this._isStaleNavigation(s,n)||(d.forEach(({itemRef:p,doc:m})=>{p&&m&&(p.xmlDoc=m)}),d.forEach(({itemRef:p})=>{let m=p?.identifier;if(!p||!m)return;let h=this.testContext.items.find(g=>g.identifier===m)?.state;h!==void 0&&p.updateComplete.then(()=>{let g=p.assessmentItem;g&&(g.state=h)})}),this._loadResults=d)}async _loadSingleItem(i,s,n){try{let a=await ve(this.cacheTransform).load(i.href,n.signal);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(s,n)?null:{itemRef:i,doc:a.htmlDoc()}}catch(a){if(a.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),a;return console.warn(`Failed to load item ${i.identifier}:`,a),null}}async _loadStimulus(i){return(await ve().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw new Error(`Item with identifier "${i}" not found`);return s}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,s){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:s}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(s=>s.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,s){return s.signal.aborted||i!==this._navigationId}_createNavigationError(i,s,n){return{message:i.message||`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchLoadingStarted(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:s})=>({identifier:s?.identifier,element:s})),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({attribute:!1})],r.prototype,"postLoadTransformCallback",2),c([u({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var En=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 Ue=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 Rt=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 Ue(this.context,this.host,this.t,this.subscribe))}};var Ri=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 js=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},_t=class extends Ri{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 Ue(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 js(this.context,this.host))}};function ee({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 _t(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new _t(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 k({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new Rt(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new Rt(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var Be=Symbol("computedItemContext");var N=Symbol("computedContext");var le=Symbol("configContext");var Tn=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var D=Symbol("item");var Lt=Symbol("qtiContext");var Ws={view:"candidate"},Fe=Symbol("testContext");var Xs={items:[],testOutcomeVariables:[]},ye=Symbol("testContext");function _i(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let h=[],g=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(M=>{if(M.nodeType!==1)return;let P=M;P.matches?.(o)&&h.push(P),h.push(...P.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(M=>{if(M.nodeType!==1)return;let P=M;P.matches?.(o)&&g.push(P),g.push(...P.querySelectorAll?.(o)??[])}));let v=q=>Array.from(new Set(q)),E=v(h),A=v(g);(E.length||A.length)&&n.call(this,E,A)},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 O(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 je={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},te=o=>(...r)=>({_$litDirective$:o,values:r}),xe=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:Al}=W,Sn=o=>o===null||typeof o!="object"&&typeof o!="function";var kn=o=>o.strings===void 0,An=()=>document.createComment(""),$t=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(An(),i),n=t.insertBefore(An(),i);e=new Al(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},We=(o,r,e=o)=>(o._$AI(r,e),o),Sl={},Mn=(o,r=Sl)=>o._$AH=r,In=o=>o._$AH,Li=o=>{o._$AR(),o._$AA.remove()};var br=(o,r)=>{let e=o._$AN;if(e===void 0)return!1;for(let t of e)t._$AO?.(r,!1),br(t,r);return!0},$i=o=>{let r,e;do{if((r=o._$AM)===void 0)break;e=r._$AN,e.delete(o),o=r}while(e?.size===0)},Rn=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),Il(r)}};function kl(o){this._$AN!==void 0?($i(this),this._$AM=o,Rn(this)):this._$AM=o}function Ml(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++)br(t[s],!1),$i(t[s]);else t!=null&&(br(t,!1),$i(t));else br(this,o)}var Il=o=>{o.type==je.CHILD&&(o._$AP??=Ml,o._$AQ??=kl)},Xe=class extends xe{constructor(){super(...arguments),this._$AN=void 0}_$AT(r,e,t){super._$AT(r,e,t),Rn(this),this.isConnected=r._$AU}_$AO(r,e=!0){r!==this.isConnected&&(this.isConnected=r,r?this.reconnected?.():this.disconnected?.()),e&&(br(this,r),$i(this))}setValue(r){if(kn(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 Gs=class extends Xe{constructor(){super(...arguments);this.prevData={}}render(e){return L}update(e,[t]){return this.element!==e.element&&(this.element=e.element),this.host=e.options?.host||this.element,this.apply(t),this.groom(t),this.prevData={...t},L}apply(e){let t=this.#e(e),{prevData:i,element:s}=this;for(let n in t){let a=t[n];a!==i[n]&&(a===!0?s.setAttribute(n,""):a===!1?s.removeAttribute(n):a!=null?s.setAttribute(n,String(a)):s.removeAttribute(n))}}groom(e){let{prevData:t,element:i}=this;if(!t)return;let s=e?this.#e(e):{};for(let n in t)(!s||!(n in s))&&i.removeAttribute(n)}#e(e){return Object.fromEntries(Object.entries(e).filter(([t,i])=>typeof i=="function"?!1:t==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Pp=te(Gs);var _n=(t=>(t.Correct="correct",t.PartiallyCorrect="partially-correct",t.Incorrect="incorrect",t))(_n||{}),R=class extends b{constructor(){super();this.disabled=!1;this.readonly=!1;this.showCorrectResponse=!1;this._handleShowCorrectResponseChange=(e,t)=>{this.toggleInternalCorrectResponse(t)};this.showFullCorrectResponse=!1;this._handleShowFullCorrectResponseChange=(e,t)=>{this.toggleFullCorrectResponse(t)};this.showCandidateCorrection=!1;this._handleShowCandidateCorrectionChange=(e,t)=>{this.toggleCandidateCorrection(t)};this._correctResponse=null;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}set correctResponseAttr(e){e===null?this._correctResponse=null:e.includes(",")?this._correctResponse=e.split(",").map(t=>t.trim()):this._correctResponse=e}get correctResponseAttr(){return this._correctResponse===null||this._correctResponse===void 0?null:Array.isArray(this._correctResponse)?this._correctResponse.join(","):this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){let e=this.responseVariable;return e?.correctResponse?e.correctResponse:this._correctResponse}set correctResponse(e){let t=this._correctResponse;this._correctResponse=e,e==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(e)?e.join(","):e),this.requestUpdate("_correctResponse",t)}get correctness(){let e=this.correctResponse;if(!e)return null;let t=this.response;if(t==null||t===""||Array.isArray(t)&&t.length===0)return null;let i=Array.isArray(e)?e:[e],n=(Array.isArray(t)?t:[t]).filter(d=>d!=="");if(n.length===0)return null;let a=n.filter(d=>i.includes(d)).length,l=n.filter(d=>!i.includes(d)).length;return a===i.length&&l===0&&n.length===i.length?"correct":a>0&&(a<i.length||l>0)?"partially-correct":"incorrect"}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;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.correctResponse;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t);return}if(i)return;let a=this.cloneNode(!0);a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-candidate-correction");let l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(s)?[...s]:s}toggleInternalCorrectResponse(e){this._internals.states.delete("show-correct-response"),e&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(e){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}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}firstUpdated(){this.isFullCorrectResponse||(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0))}saveResponse(e,t){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e,...t!==void 0?{state:t}:{}}}))}};c([k({context:D,subscribe:!0})],R.prototype,"_context",2),c([k({context:le,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([u({type:String})],R.prototype,"name",2),c([u({type:String,attribute:"correct-response",reflect:!0})],R.prototype,"correctResponseAttr",1),c([u({type:Boolean,attribute:"show-correct-response",reflect:!0})],R.prototype,"showCorrectResponse",2),c([O("showCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],R.prototype,"showFullCorrectResponse",2),c([O("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowFullCorrectResponseChange",2),c([u({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],R.prototype,"showCandidateCorrection",2),c([O("showCandidateCorrection",{waitUntilFirstUpdate:!0})],R.prototype,"_handleShowCandidateCorrectionChange",2),c([w()],R.prototype,"_isFullCorrectResponse",2),c([w()],R.prototype,"_correctResponse",2);var Ot=class extends b{render(){return f`<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]}};var S=class extends b{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=y`
5
5
  slot {
6
6
  display: none;
7
7
  }
8
8
  `}render(){return f`<pre>${JSON.stringify(this.result,null,2)}</pre>
9
- <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([w()],S.prototype,"result",2),c([M({context:D,subscribe:!0}),w()],S.prototype,"context",2),c([M({context:Lt,subscribe:!0}),w()],S.prototype,"qtiContext",2);var le=class extends S{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Il=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),vr=o=>{if(typeof o=="string")return o;let r=Il();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Qs(o){return o==null}function Oi(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var re=class extends b{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=!Qs(this.identifier)&&!Qs(e?.value)&&this.identifier===e.value||!1,this.#e(t)}#e(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],re.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],re.prototype,"outcomeIdentifier",2),c([u({type:String})],re.prototype,"identifier",2),c([u({type:String,attribute:!1})],re.prototype,"showStatus",2),c([M({context:D,subscribe:!0}),w()],re.prototype,"_context",2);var Ln=class extends b{};var X=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,h]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=h}case"ellipse":{let[d,p,m,h]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let g=(i-d)**2/m**2,v=(s-p)**2/h**2;return g+v<=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 Ys=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Xs;this.sessionContext=Ws;this._updateItemInTestContext=i=>{let s=i._context,n=s.identifier,a=s.variables,l=this.testContext.items.find(d=>d?.identifier===n);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${n} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(n,a);else{let d=[...i.variables];for(let p of l.variables){let m=d.find(h=>h.identifier===p.identifier);m?m.value=p.value:d.push(p)}i.variables=d}};this._initializeEventListeners()}updateItemVariables(i,s){let n=this.testContext.items.find(l=>l.identifier===i);n&&(n.variables=n.variables.map(l=>{let d=s.find(p=>p.identifier===l.identifier);return d?{...l,...d}:l}));let a=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);a&&a.assessmentItem&&(a.assessmentItem.variables=s)}_initializeEventListeners(){this.addEventListener("qti-assessment-test-connected",i=>{if(this.testContext=Xs,this.sessionContext=Ws,this.testContext&&this.testContext.items.length>0)return;this._testElement=i.detail;let s=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(n=>({href:n.href,identifier:n.identifier,category:n.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:s}}),this.addEventListener("qti-assessment-item-connected",i=>{let s=i.detail,n=s.closest("qti-assessment-item-ref")?.identifier;n&&(s.assessmentItemRefId=n),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state)})}_updateItemVariablesInTestContext(i,s,n){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:s.map(l=>{let d=a.variables.find(p=>p.identifier===l.identifier);return d?{...d,...l}:l}),...n!==void 0?{state:n?{...n}:void 0}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return c([u({attribute:!1,type:Object}),ee({context:ye})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),ee({context:Fe})],r.prototype,"sessionContext",2),r},$n=class extends Ys(b){};var On=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 Pi=class extends wn(En(On(Ys(b)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};Pi=c([C("qti-test")],Pi);var Pn={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Re=class extends b{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),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})],Re.prototype,"category",2),c([u({type:String})],Re.prototype,"identifier",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"required",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"fixed",2),c([u({type:String})],Re.prototype,"href",2),c([u({type:Object,attribute:!1})],Re.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",Re);var Js={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends b{get title(){return this.#e}set title(r){this.#e=r,this.removeAttribute("title"),this.setAttribute("data-title",r)}#e="";async connectedCallback(){this.#e=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return f`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],_e.prototype,"identifier",2),c([u({type:String})],_e.prototype,"required",2),c([u({type:Boolean,converter:Js})],_e.prototype,"fixed",2),c([u({type:Boolean,converter:Js})],_e.prototype,"visible",2),c([u({type:Boolean,converter:Js,attribute:"keep-together"})],_e.prototype,"keepTogether",2),c([M({context:ye,subscribe:!0})],_e.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",_e);var yr,ht=class extends b{constructor(){super(...arguments);T(this,yr,"")}get title(){return x(this,yr)}set title(e){$(this,yr,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 f` <slot></slot>`}};yr=new WeakMap,c([u({type:String})],ht.prototype,"identifier",2),c([u({type:String})],ht.prototype,"title",1),c([M({context:ye,subscribe:!0})],ht.prototype,"_testContext",2),ht=c([C("qti-assessment-test")],ht);var xr,Le=class extends b{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";T(this,xr,"")}get title(){return x(this,xr)}set title(e){$(this,xr,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 f` <slot></slot>`}};xr=new WeakMap,c([u({type:String})],Le.prototype,"identifier",2),c([u({type:String})],Le.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Le.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Le.prototype,"submissionMode",2),Le=c([C("qti-test-part")],Le);customElements.get("qti-test-part")||customElements.define("qti-test-part",Le);var qr,Pt,Cr,Vt,ce,ue,Vn,Nn,wr,Er,Tr,Ar,Sr,Mr,Dn,Ks,ie=class extends b{constructor(){super(...arguments);T(this,ue);T(this,qr);T(this,Pt,null);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{x(this,ce).forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>x(this,ce).forEach(i=>i.readonly=t);this._context={variables:Tn};T(this,Cr,{...this._context,variables:this._context.variables});T(this,Vt,[]);T(this,ce,[]);T(this,wr,e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},$(this,Cr,this._context),e.stopPropagation()});T(this,Er,e=>{e.stopImmediatePropagation();let t=e.detail;x(this,Vt).push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)});T(this,Tr,e=>{e.stopImmediatePropagation(),x(this,ce).push(e.detail.interactionElement)});T(this,Ar,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)});T(this,Sr,e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()});T(this,Mr,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i,state:s}=e.detail;this.updateResponseVariable(t,i),s!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[t]:s}}),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))})}get title(){return x(this,qr)}set title(e){$(this,qr,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=x(this,ce).find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&x(this,Vt).forEach(i=>i.checkShowFeedback(t.identifier))})}get state(){return this._context.state}set state(e){this._context={...this._context,state:e?{...e}:void 0}}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=x(this,ce).find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return f`<slot></slot>`}connectedCallback(){I(this,ue,Vn).call(this),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),I(this,ue,Dn).call(this)})}disconnectedCallback(){I(this,ue,Nn).call(this),super.disconnectedCallback()}showCorrectResponse(e){for(let t of x(this,ce))t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of x(this,ce))t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing"),s=!!(i&&typeof i.process=="function");return s&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",I(this,ue,Ks).call(this)),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),s}resetResponses(){this._context=x(this,Cr)}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",I(this,ue,Ks).call(this))}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]})},x(this,Vt).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=x(this,ce).every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of x(this,ce))e.reportValidity()}};qr=new WeakMap,Pt=new WeakMap,Cr=new WeakMap,Vt=new WeakMap,ce=new WeakMap,ue=new WeakSet,Vn=function(){this.addEventListener("qti-register-variable",x(this,wr)),this.addEventListener("qti-register-feedback",x(this,Er)),this.addEventListener("qti-register-interaction",x(this,Tr)),this.addEventListener("end-attempt",x(this,Ar)),this.addEventListener("qti-set-outcome-value",x(this,Sr)),this.addEventListener("qti-interaction-response",x(this,Mr))},Nn=function(){this.removeEventListener("qti-register-variable",x(this,wr)),this.removeEventListener("qti-register-feedback",x(this,Er)),this.removeEventListener("qti-register-interaction",x(this,Tr)),this.removeEventListener("end-attempt",x(this,Ar)),this.removeEventListener("qti-set-outcome-value",x(this,Sr)),this.removeEventListener("qti-interaction-response",x(this,Mr))},wr=new WeakMap,Er=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,Sr=new WeakMap,Mr=new WeakMap,Dn=function(){$(this,Pt,this.querySelector("qti-template-processing")),x(this,Pt)&&x(this,Pt).process()},Ks=function(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"},c([u({type:String})],ie.prototype,"identifier",2),c([u({type:String})],ie.prototype,"adaptive",2),c([u({type:String})],ie.prototype,"timeDependent",2),c([u({type:String})],ie.prototype,"title",1),c([u({type:Boolean})],ie.prototype,"disabled",2),c([O("disabled",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],ie.prototype,"readonly",2),c([O("readonly",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleReadonlyChange",2),c([ee({context:D})],ie.prototype,"_context",2),ie=c([C("qti-assessment-item")],ie);var Zs=class o extends Event{constructor(e,t){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},Nt=class extends b{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Zs(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await ve().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],Nt.prototype,"identifier",2),c([u({type:String})],Nt.prototype,"href",2),Nt=c([C("qti-assessment-stimulus-ref")],Nt);var Vi=class extends b{};Vi=c([C("qti-companion-materials-info")],Vi);var Ir,kr=class extends b{constructor(){super(...arguments);T(this,Ir)}render(){return f`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let e=Array.from(this.firstElementChild?.childNodes??[]).find(t=>t.nodeType===Node.COMMENT_NODE);try{$(this,Ir,new Function("context","fn","item",e?.textContent??""))}catch(t){console.error("custom-operator contains invalid javascript code",t)}}calculate(){let e={variable:i=>this._context?.variables.find(s=>s.identifier===i)?.value??"",correct:i=>this._context?.variables.find(s=>s.identifier===i)?.correctResponse??""},t={getVariable:i=>this._context?.variables.find(s=>s.identifier===i),updateOutcomeVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:s}}))},updateResponseVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:i,response:s}}))}};return x(this,Ir).call(this,this._context,e,t)}};Ir=new WeakMap,c([M({context:D,subscribe:!0}),w()],kr.prototype,"_context",2),kr=c([C("qti-custom-operator")],kr);var Rr=class extends re{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Rr.styles=y`
9
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([w()],S.prototype,"result",2),c([k({context:D,subscribe:!0}),w()],S.prototype,"context",2),c([k({context:Lt,subscribe:!0}),w()],S.prototype,"qtiContext",2);var ce=class extends S{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Rl=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),vr=o=>{if(typeof o=="string")return o;let r=Rl();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Qs(o){return o==null}function Oi(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var re=class extends b{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=!Qs(this.identifier)&&!Qs(e?.value)&&this.identifier===e.value||!1,this.#e(t)}#e(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],re.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],re.prototype,"outcomeIdentifier",2),c([u({type:String})],re.prototype,"identifier",2),c([u({type:String,attribute:!1})],re.prototype,"showStatus",2),c([k({context:D,subscribe:!0}),w()],re.prototype,"_context",2);var Ln=class extends b{};var X=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,h]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=h}case"ellipse":{let[d,p,m,h]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let g=(i-d)**2/m**2,v=(s-p)**2/h**2;return g+v<=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 Ys=o=>{class r extends o{constructor(...i){super(...i);this.testContext=Xs;this.sessionContext=Ws;this._updateItemInTestContext=i=>{let s=i._context,n=s.identifier,a=s.variables,l=this.testContext.items.find(d=>d?.identifier===n);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${n} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(n,a);else{let d=[...i.variables];for(let p of l.variables){let m=d.find(h=>h.identifier===p.identifier);m?m.value=p.value:d.push(p)}i.variables=d}};this._initializeEventListeners()}updateItemVariables(i,s){let n=this.testContext.items.find(l=>l.identifier===i);n&&(n.variables=n.variables.map(l=>{let d=s.find(p=>p.identifier===l.identifier);return d?{...l,...d}:l}));let a=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);a&&a.assessmentItem&&(a.assessmentItem.variables=s)}_initializeEventListeners(){this.addEventListener("qti-assessment-test-connected",i=>{if(this.testContext=Xs,this.sessionContext=Ws,this.testContext&&this.testContext.items.length>0)return;this._testElement=i.detail;let s=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(n=>({href:n.href,identifier:n.identifier,category:n.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:s}}),this.addEventListener("qti-assessment-item-connected",i=>{let s=i.detail,n=s.closest("qti-assessment-item-ref")?.identifier;n&&(s.assessmentItemRefId=n),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state)})}_updateItemVariablesInTestContext(i,s,n){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:s.map(l=>{let d=a.variables.find(p=>p.identifier===l.identifier);return d?{...d,...l}:l}),...n!==void 0?{state:n?{...n}:void 0}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}}return c([u({attribute:!1,type:Object}),ee({context:ye})],r.prototype,"testContext",2),c([u({attribute:!1,type:Object}),ee({context:Fe})],r.prototype,"sessionContext",2),r},$n=class extends Ys(b){};var On=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 Pi=class extends wn(En(On(Ys(b)))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return f`<slot></slot>`}};Pi=c([C("qti-test")],Pi);var Pn={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Re=class extends b{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),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})],Re.prototype,"category",2),c([u({type:String})],Re.prototype,"identifier",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"required",2),c([u({type:Boolean,converter:Pn})],Re.prototype,"fixed",2),c([u({type:String})],Re.prototype,"href",2),c([u({type:Object,attribute:!1})],Re.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",Re);var Js={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends b{get title(){return this.#e}set title(r){this.#e=r,this.removeAttribute("title"),this.setAttribute("data-title",r)}#e="";async connectedCallback(){this.#e=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return f`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],_e.prototype,"identifier",2),c([u({type:String})],_e.prototype,"required",2),c([u({type:Boolean,converter:Js})],_e.prototype,"fixed",2),c([u({type:Boolean,converter:Js})],_e.prototype,"visible",2),c([u({type:Boolean,converter:Js,attribute:"keep-together"})],_e.prototype,"keepTogether",2),c([k({context:ye,subscribe:!0})],_e.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",_e);var yr,ht=class extends b{constructor(){super(...arguments);T(this,yr,"")}get title(){return x(this,yr)}set title(e){$(this,yr,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 f` <slot></slot>`}};yr=new WeakMap,c([u({type:String})],ht.prototype,"identifier",2),c([u({type:String})],ht.prototype,"title",1),c([k({context:ye,subscribe:!0})],ht.prototype,"_testContext",2),ht=c([C("qti-assessment-test")],ht);var xr,Le=class extends b{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";T(this,xr,"")}get title(){return x(this,xr)}set title(e){$(this,xr,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 f` <slot></slot>`}};xr=new WeakMap,c([u({type:String})],Le.prototype,"identifier",2),c([u({type:String})],Le.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Le.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Le.prototype,"submissionMode",2),Le=c([C("qti-test-part")],Le);customElements.get("qti-test-part")||customElements.define("qti-test-part",Le);var qr,Pt,Cr,Vt,de,se,Vn,Nn,wr,Er,Tr,Ar,Sr,kr,Dn,Ks,Hn,ie=class extends b{constructor(){super(...arguments);T(this,se);T(this,qr);T(this,Pt,null);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{x(this,de).forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>x(this,de).forEach(i=>i.readonly=t);this._context={variables:Tn};T(this,Cr,{...this._context,variables:this._context.variables});T(this,Vt,[]);T(this,de,[]);T(this,wr,e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},$(this,Cr,this._context),e.stopPropagation()});T(this,Er,e=>{e.stopImmediatePropagation();let t=e.detail;x(this,Vt).push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)});T(this,Tr,e=>{e.stopImmediatePropagation(),x(this,de).push(e.detail.interactionElement)});T(this,Ar,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)});T(this,Sr,e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()});T(this,kr,e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i,state:s}=e.detail;this.updateResponseVariable(t,i),s!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[t]:s}}),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))})}get title(){return x(this,qr)}set title(e){$(this,qr,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=x(this,de).find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&x(this,Vt).forEach(i=>i.checkShowFeedback(t.identifier))})}get state(){return this._context.state}set state(e){this._context={...this._context,state:e?{...e}:void 0}}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=x(this,de).find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return f`<slot></slot>`}connectedCallback(){I(this,se,Vn).call(this),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),I(this,se,Dn).call(this)})}disconnectedCallback(){I(this,se,Nn).call(this),super.disconnectedCallback()}showCorrectResponse(e){for(let t of x(this,de))t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of x(this,de))t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(n=>n.identifier==="numAttempts")?.value+1).toString()),this.adaptive==="false"&&I(this,se,Hn).call(this);let i=this.querySelector("qti-response-processing"),s=!!(i&&typeof i.process=="function");return s&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",I(this,se,Ks).call(this)),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),s}resetResponses(){this._context=x(this,Cr)}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",I(this,se,Ks).call(this))}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]})},x(this,Vt).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=x(this,de).every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of x(this,de))e.reportValidity()}};qr=new WeakMap,Pt=new WeakMap,Cr=new WeakMap,Vt=new WeakMap,de=new WeakMap,se=new WeakSet,Vn=function(){this.addEventListener("qti-register-variable",x(this,wr)),this.addEventListener("qti-register-feedback",x(this,Er)),this.addEventListener("qti-register-interaction",x(this,Tr)),this.addEventListener("end-attempt",x(this,Ar)),this.addEventListener("qti-set-outcome-value",x(this,Sr)),this.addEventListener("qti-interaction-response",x(this,kr))},Nn=function(){this.removeEventListener("qti-register-variable",x(this,wr)),this.removeEventListener("qti-register-feedback",x(this,Er)),this.removeEventListener("qti-register-interaction",x(this,Tr)),this.removeEventListener("end-attempt",x(this,Ar)),this.removeEventListener("qti-set-outcome-value",x(this,Sr)),this.removeEventListener("qti-interaction-response",x(this,kr))},wr=new WeakMap,Er=new WeakMap,Tr=new WeakMap,Ar=new WeakMap,Sr=new WeakMap,kr=new WeakMap,Dn=function(){$(this,Pt,this.querySelector("qti-template-processing")),x(this,Pt)&&x(this,Pt).process()},Ks=function(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"},Hn=function(){this._context={...this._context,variables:this._context.variables.map(e=>{if(e.type!=="outcome")return e;let s=("defaultValue"in e?e.defaultValue:null)??null;return s==null&&(e.baseType==="integer"||e.baseType==="float")&&(s="0"),{...e,value:s}})}},c([u({type:String})],ie.prototype,"identifier",2),c([u({type:String})],ie.prototype,"adaptive",2),c([u({type:String})],ie.prototype,"timeDependent",2),c([u({type:String})],ie.prototype,"title",1),c([u({type:Boolean})],ie.prototype,"disabled",2),c([O("disabled",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],ie.prototype,"readonly",2),c([O("readonly",{waitUntilFirstUpdate:!0})],ie.prototype,"_handleReadonlyChange",2),c([ee({context:D})],ie.prototype,"_context",2),ie=c([C("qti-assessment-item")],ie);var Zs=class o extends Event{constructor(e,t){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},Nt=class extends b{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Zs(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await ve().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],Nt.prototype,"identifier",2),c([u({type:String})],Nt.prototype,"href",2),Nt=c([C("qti-assessment-stimulus-ref")],Nt);var Vi=class extends b{};Vi=c([C("qti-companion-materials-info")],Vi);var Ir,Mr=class extends b{constructor(){super(...arguments);T(this,Ir)}render(){return f`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let e=Array.from(this.firstElementChild?.childNodes??[]).find(t=>t.nodeType===Node.COMMENT_NODE);try{$(this,Ir,new Function("context","fn","item",e?.textContent??""))}catch(t){console.error("custom-operator contains invalid javascript code",t)}}calculate(){let e={variable:i=>this._context?.variables.find(s=>s.identifier===i)?.value??"",correct:i=>this._context?.variables.find(s=>s.identifier===i)?.correctResponse??""},t={getVariable:i=>this._context?.variables.find(s=>s.identifier===i),updateOutcomeVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:s}}))},updateResponseVariable:(i,s)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:i,response:s}}))}};return x(this,Ir).call(this,this._context,e,t)}};Ir=new WeakMap,c([k({context:D,subscribe:!0}),w()],Mr.prototype,"_context",2),Mr=c([C("qti-custom-operator")],Mr);var Rr=class extends re{render(){return f` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Rr.styles=y`
10
10
  :host {
11
11
  display: block;
12
12
  }
@@ -69,23 +69,23 @@ Make sure to test your application with a production build as repeat registratio
69
69
  .button:focus {
70
70
  outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
71
71
  }
72
- `,ft=c([C("qti-modal-feedback")],ft);var Hn=y`
72
+ `,ft=c([C("qti-modal-feedback")],ft);var zn=y`
73
73
  :host {
74
74
  display: block;
75
75
  }
76
- `;var Lr=class extends b{render(){return f`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};Lr.styles=Hn,Lr=c([C("qti-item-body")],Lr);var Ni=class extends b{render(){return f`<slot></slot>`}};Ni=c([C("qti-content-body")],Ni);var Ce=class extends b{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 f`<slot></slot>`}};Ce.styles=y`
76
+ `;var Lr=class extends b{render(){return f`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};Lr.styles=zn,Lr=c([C("qti-item-body")],Lr);var Ni=class extends b{render(){return f`<slot></slot>`}};Ni=c([C("qti-content-body")],Ni);var Ce=class extends b{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 f`<slot></slot>`}};Ce.styles=y`
77
77
  :host {
78
78
  display: block;
79
79
  }
80
- `,c([u({type:String})],Ce.prototype,"id",2),c([u({type:String})],Ce.prototype,"use",2),c([u({type:String})],Ce.prototype,"view",2),c([u({type:String,attribute:"class"})],Ce.prototype,"classNames",2),c([O("classNames",{waitUntilFirstUpdate:!0})],Ce.prototype,"handleclassNamesChange",1),Ce=c([C("qti-rubric-block")],Ce);var se,$r,eo,Di=class extends b{constructor(){super(...arguments);T(this,$r);T(this,se,null)}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=I(this,$r,eo).call(this,i);$(this,se,document.createElement("style")),x(this,se).media="screen",x(this,se).textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(x(this,se)):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=I(this,$r,eo).call(this,this.textContent);$(this,se,document.createElement("style")),x(this,se).media="screen",x(this,se).textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(x(this,se)):console.warn("No parent element to append the scoped stylesheet to.")}}disconnectedCallback(){if(x(this,se))try{x(this,se).remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};se=new WeakMap,$r=new WeakSet,eo=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()},Di=c([C("qti-stylesheet")],Di);var Ge,zn,Un,Bn,$e=class extends Ot{constructor(){super(...arguments);T(this,Ge)}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return f`${JSON.stringify(e,null,2)}`}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={baseType:this.baseType,identifier:this.identifier,correctResponse:x(this,Ge,zn),cardinality:this.cardinality||"single",mapping:x(this,Ge,Un),defaultValue:e,areaMapping:x(this,Ge,Bn),value:null,type:"response",candidateResponse:null};t.value=e,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};Ge=new WeakSet,zn=function(){let e,t=this.querySelector("qti-correct-response");if(t){let i=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&i.length>0)e=i[0].textContent.trim(),i[0].remove();else if(this.cardinality!=="single"){e=[];for(let s=0;s<i.length;s++)e.push(i[s].textContent.trim()),i[s].remove()}}return e},Un=function(){let e=this.querySelector("qti-mapping"),t=parseFloat(e?.getAttribute("lower-bound")),i=parseFloat(e?.getAttribute("upper-bound"));return{defaultValue:Number(e?.getAttribute("default-value"))||0,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,mapEntries:Array.from(e?.querySelectorAll("qti-map-entry")||[]).map(n=>({mapKey:n.getAttribute("map-key")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,caseSensitive:n.hasAttribute("case-sensitive")?n.getAttribute("case-sensitive")!=="false":!1}))}},Bn=function(){let e=this.querySelector("qti-area-mapping"),t=Number(e?.getAttribute("default-value"))||0,i=parseFloat(e?.getAttribute("lower-bound")),s=parseFloat(e?.getAttribute("upper-bound")),n=Array.from(e?.querySelectorAll("qti-area-map-entry")||[]).map(a=>({shape:a.getAttribute("shape")||"default",coords:a.getAttribute("coords")||"",mappedValue:Number(a.getAttribute("mapped-value"))||0,defaultValue:Number(a.getAttribute("default-value"))||0}));return{defaultValue:t,lowerBound:isNaN(i)?null:i,upperBound:isNaN(s)?null:s,areaMapEntries:n}},$e.styles=[y`
80
+ `,c([u({type:String})],Ce.prototype,"id",2),c([u({type:String})],Ce.prototype,"use",2),c([u({type:String})],Ce.prototype,"view",2),c([u({type:String,attribute:"class"})],Ce.prototype,"classNames",2),c([O("classNames",{waitUntilFirstUpdate:!0})],Ce.prototype,"handleclassNamesChange",1),Ce=c([C("qti-rubric-block")],Ce);var oe,$r,eo,Di=class extends b{constructor(){super(...arguments);T(this,$r);T(this,oe,null)}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let s=I(this,$r,eo).call(this,i);$(this,oe,document.createElement("style")),x(this,oe).media="screen",x(this,oe).textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(x(this,oe)):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=I(this,$r,eo).call(this,this.textContent);$(this,oe,document.createElement("style")),x(this,oe).media="screen",x(this,oe).textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(x(this,oe)):console.warn("No parent element to append the scoped stylesheet to.")}}disconnectedCallback(){if(x(this,oe))try{x(this,oe).remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};oe=new WeakMap,$r=new WeakSet,eo=function(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()},Di=c([C("qti-stylesheet")],Di);var Ge,Un,Bn,Fn,$e=class extends Ot{constructor(){super(...arguments);T(this,Ge)}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return f`${JSON.stringify(e,null,2)}`}connectedCallback(){super.connectedCallback();let e=this.defaultValues(this.cardinality),t={baseType:this.baseType,identifier:this.identifier,correctResponse:x(this,Ge,Un),cardinality:this.cardinality||"single",mapping:x(this,Ge,Bn),defaultValue:e,areaMapping:x(this,Ge,Fn),value:null,type:"response",candidateResponse:null};t.value=e,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}};Ge=new WeakSet,Un=function(){let e,t=this.querySelector("qti-correct-response");if(t){let i=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&i.length>0)e=i[0].textContent.trim(),i[0].remove();else if(this.cardinality!=="single"){e=[];for(let s=0;s<i.length;s++)e.push(i[s].textContent.trim()),i[s].remove()}}return e},Bn=function(){let e=this.querySelector("qti-mapping"),t=parseFloat(e?.getAttribute("lower-bound")),i=parseFloat(e?.getAttribute("upper-bound"));return{defaultValue:Number(e?.getAttribute("default-value"))||0,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,mapEntries:Array.from(e?.querySelectorAll("qti-map-entry")||[]).map(n=>({mapKey:n.getAttribute("map-key")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,caseSensitive:n.hasAttribute("case-sensitive")?n.getAttribute("case-sensitive")!=="false":!1}))}},Fn=function(){let e=this.querySelector("qti-area-mapping"),t=Number(e?.getAttribute("default-value"))||0,i=parseFloat(e?.getAttribute("lower-bound")),s=parseFloat(e?.getAttribute("upper-bound")),n=Array.from(e?.querySelectorAll("qti-area-map-entry")||[]).map(a=>({shape:a.getAttribute("shape")||"default",coords:a.getAttribute("coords")||"",mappedValue:Number(a.getAttribute("mapped-value"))||0,defaultValue:Number(a.getAttribute("default-value"))||0}));return{defaultValue:t,lowerBound:isNaN(i)?null:i,upperBound:isNaN(s)?null:s,areaMapEntries:n}},$e.styles=[y`
81
81
  :host {
82
82
  display: none;
83
83
  }
84
- `],c([u({type:String,attribute:"base-type"})],$e.prototype,"baseType",2),c([u({type:String})],$e.prototype,"identifier",2),c([u({type:String})],$e.prototype,"cardinality",2),c([M({context:D,subscribe:!0}),w()],$e.prototype,"itemContext",2),$e=c([C("qti-response-declaration")],$e);var we=class extends Ot{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return f`${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}}))}};we.styles=[y`
84
+ `],c([u({type:String,attribute:"base-type"})],$e.prototype,"baseType",2),c([u({type:String})],$e.prototype,"identifier",2),c([u({type:String})],$e.prototype,"cardinality",2),c([k({context:D,subscribe:!0}),w()],$e.prototype,"itemContext",2),$e=c([C("qti-response-declaration")],$e);var we=class extends Ot{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return f`${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}}))}};we.styles=[y`
85
85
  :host {
86
86
  display: none;
87
87
  }
88
- `],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],we.prototype,"externalScored",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([M({context:D,subscribe:!0}),w()],we.prototype,"itemContext",2),we=c([C("qti-outcome-declaration")],we);var Fn=`<qti-response-processing>
88
+ `],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],we.prototype,"externalScored",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([k({context:D,subscribe:!0}),w()],we.prototype,"itemContext",2),we=c([C("qti-outcome-declaration")],we);var jn=`<qti-response-processing>
89
89
  <qti-response-condition>
90
90
  <qti-response-if>
91
91
  <qti-match>
@@ -102,7 +102,7 @@ Make sure to test your application with a production build as repeat registratio
102
102
  </qti-set-outcome-value>
103
103
  </qti-response-else>
104
104
  </qti-response-condition>
105
- </qti-response-processing>`,jn=`<qti-response-processing>
105
+ </qti-response-processing>`,Wn=`<qti-response-processing>
106
106
  <qti-response-condition>
107
107
  <qti-response-if>
108
108
  <qti-is-null>
@@ -118,7 +118,7 @@ Make sure to test your application with a production build as repeat registratio
118
118
  </qti-set-outcome-value>
119
119
  </qti-response-else>
120
120
  </qti-response-condition>
121
- </qti-response-processing>`,Wn=`<qti-response-processing>
121
+ </qti-response-processing>`,Xn=`<qti-response-processing>
122
122
  <qti-response-condition>
123
123
  <qti-response-if>
124
124
  <qti-is-null>
@@ -134,11 +134,11 @@ Make sure to test your application with a production build as repeat registratio
134
134
  </qti-set-outcome-value>
135
135
  </qti-response-else>
136
136
  </qti-response-condition>
137
- </qti-response-processing>`;var Dt,Hi,Or=class extends b{constructor(){super(...arguments);T(this,Dt)}render(){return f`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let t=[...this.children];for(let i of t)i.process()}firstUpdated(e){if(this.getAttribute("template")){let t=this.getAttribute("template").split("/"),i=t[t.length-1].replace(".xml","");switch(this.innerHTML="",i){case"map_response":{this.appendChild(I(this,Dt,Hi).call(this,jn).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(I(this,Dt,Hi).call(this,Wn).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(I(this,Dt,Hi).call(this,Fn).firstElementChild.firstElementChild);break}}}};Dt=new WeakSet,Hi=function(e){return document.createRange().createContextualFragment(e)},Or.styles=[y`
137
+ </qti-response-processing>`;var Dt,Hi,Or=class extends b{constructor(){super(...arguments);T(this,Dt)}render(){return f`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let t=[...this.children];for(let i of t)i.process()}firstUpdated(e){if(this.getAttribute("template")){let t=this.getAttribute("template").split("/"),i=t[t.length-1].replace(".xml","");switch(this.innerHTML="",i){case"map_response":{this.appendChild(I(this,Dt,Hi).call(this,Wn).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(I(this,Dt,Hi).call(this,Xn).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(I(this,Dt,Hi).call(this,jn).firstElementChild.firstElementChild);break}}}};Dt=new WeakSet,Hi=function(e){return document.createRange().createContextualFragment(e)},Or.styles=[y`
138
138
  :host {
139
139
  display: none;
140
140
  }
141
- `],Or=c([C("qti-response-processing")],Or);var Qe,Ye,Xn,Gn,Qn,Ee=class extends b{constructor(){super(...arguments);T(this,Ye);this.identifier="";this.cardinality="single";this.baseType="string";this.mathVariable=!1;this.paramVariable=!1;T(this,Qe,null)}render(){return f`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{I(this,Ye,Xn).call(this),I(this,Ye,Qn).call(this)})}getTemplateVariable(){return{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,value:x(this,Qe),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable}}};Qe=new WeakMap,Ye=new WeakSet,Xn=function(){let e=this.querySelector("qti-default-value");if(!e)return;let t=e.textContent?.trim()||"";$(this,Qe,I(this,Ye,Gn).call(this,t))},Gn=function(e){if(!e)return null;switch(this.baseType){case"integer":return parseInt(e,10);case"float":case"duration":return parseFloat(e);case"boolean":return e.toLowerCase()==="true";default:return e}},Qn=function(){let t={...{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:x(this,Qe),value:x(this,Qe),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable},value:x(this,Qe)?.toString()||""};this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))},Ee.styles=[y`
141
+ `],Or=c([C("qti-response-processing")],Or);var Qe,Ye,Gn,Qn,Yn,Ee=class extends b{constructor(){super(...arguments);T(this,Ye);this.identifier="";this.cardinality="single";this.baseType="string";this.mathVariable=!1;this.paramVariable=!1;T(this,Qe,null)}render(){return f`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{I(this,Ye,Gn).call(this),I(this,Ye,Yn).call(this)})}getTemplateVariable(){return{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,value:x(this,Qe),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable}}};Qe=new WeakMap,Ye=new WeakSet,Gn=function(){let e=this.querySelector("qti-default-value");if(!e)return;let t=e.textContent?.trim()||"";$(this,Qe,I(this,Ye,Qn).call(this,t))},Qn=function(e){if(!e)return null;switch(this.baseType){case"integer":return parseInt(e,10);case"float":case"duration":return parseFloat(e);case"boolean":return e.toLowerCase()==="true";default:return e}},Yn=function(){let t={...{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:x(this,Qe),value:x(this,Qe),type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable},value:x(this,Qe)?.toString()||""};this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))},Ee.styles=[y`
142
142
  :host {
143
143
  display: none;
144
144
  }
@@ -150,7 +150,7 @@ Make sure to test your application with a production build as repeat registratio
150
150
  :host {
151
151
  color: gray;
152
152
  }
153
- `,Pr=c([C("qti-test-feedback")],Pr);var oe,U,Yn,Jn,Kn,Zn,ea,ta,ra,ia,de=class extends b{constructor(){super();T(this,U);this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;T(this,oe);this.addEventListener("qti-assessment-test-connected",I(this,U,ta).bind(this)),this.addEventListener("qti-assessment-item-connected",I(this,U,ia).bind(this)),this.addEventListener("qti-interaction-changed",I(this,U,ea).bind(this)),this.addEventListener("test-end-attempt",I(this,U,Yn).bind(this)),this.addEventListener("test-show-correct-response",I(this,U,Jn).bind(this)),this.addEventListener("test-show-candidate-correction",I(this,U,Kn).bind(this)),this.addEventListener("test-update-outcome-variable",I(this,U,Zn).bind(this))}render(){return f`<slot></slot>`}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(k=>k.identifier===n.identifier),l={...n,...a,...this.initContext?.find(k=>k.identifier===n.identifier)},d=l.variables?.find(k=>k.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(k=>k.identifier==="completionStatus")?.value,h=l.variables?.find(k=>k.identifier==="RESPONSE")?.value||"",g=l.variables?.find(k=>k.identifier==="numAttempts")?.value||0,v=this._sessionContext?.navItemRefId===l.identifier||!1,E=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,A=n.variables?.find(k=>k.identifier=="MAXSCORE")?.value,q=A==null?null:parseFloat(A?.toString());return{...l,completionStatus:m,numAttempts:g,score:p,response:h,index:E,active:v,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};oe=new WeakMap,U=new WeakSet,Yn=function(e){let i=x(this,oe).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)},Jn=function(e){let i=x(this,oe).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)},Kn=function(e){x(this,oe).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)},Zn=function(e){x(this,oe).querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)},ea=function(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)}}},ta=function(e){if($(this,oe,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:x(this,oe).identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}x(this,oe).querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=I(this,U,ra).call(this,s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(x(this,oe)?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:x(this,oe).identifier,title:x(this,oe).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:[]}))}})}})}},ra=function(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;default:p=d;break}t[a]=p}}),t},ia=function(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(v=>v.querySelector("qti-correct-response")),m=Array.from(d).some(v=>{let E=v.querySelector("qti-mapping"),A=v.querySelector("qti-area-mapping");return E?.querySelector("qti-map-entry")||A?.querySelector("qti-area-map-entry")}),h=p||m,g=!!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:h,hasResponseProcessing:g}})}))}))}},c([u({type:String})],de.prototype,"identifier",2),c([w()],de.prototype,"initContext",2),c([w(),ee({context:Lt})],de.prototype,"qtiContext",2),c([w(),ee({context:ae})],de.prototype,"configContext",2),c([w(),M({context:ye,subscribe:!0})],de.prototype,"_testContext",2),c([w(),M({context:Fe,subscribe:!0})],de.prototype,"_sessionContext",2),c([w(),ee({context:N})],de.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],de.prototype,"autoScoreItems",2),de=c([C("test-navigation")],de);var sa=y`
153
+ `,Pr=c([C("qti-test-feedback")],Pr);var ne,U,Jn,Kn,Zn,ea,ta,ra,ia,sa,pe=class extends b{constructor(){super();T(this,U);this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;T(this,ne);this.addEventListener("qti-assessment-test-connected",I(this,U,ra).bind(this)),this.addEventListener("qti-assessment-item-connected",I(this,U,sa).bind(this)),this.addEventListener("qti-interaction-changed",I(this,U,ta).bind(this)),this.addEventListener("test-end-attempt",I(this,U,Jn).bind(this)),this.addEventListener("test-show-correct-response",I(this,U,Kn).bind(this)),this.addEventListener("test-show-candidate-correction",I(this,U,Zn).bind(this)),this.addEventListener("test-update-outcome-variable",I(this,U,ea).bind(this))}render(){return f`<slot></slot>`}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(M=>M.identifier===n.identifier),l={...n,...a,...this.initContext?.find(M=>M.identifier===n.identifier)},d=l.variables?.find(M=>M.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(M=>M.identifier==="completionStatus")?.value,h=l.variables?.find(M=>M.identifier==="RESPONSE")?.value||"",g=l.variables?.find(M=>M.identifier==="numAttempts")?.value||0,v=this._sessionContext?.navItemRefId===l.identifier||!1,E=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,A=n.variables?.find(M=>M.identifier=="MAXSCORE")?.value,q=A==null?null:parseFloat(A?.toString());return{...l,completionStatus:m,numAttempts:g,score:p,response:h,index:E,active:v,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};ne=new WeakMap,U=new WeakSet,Jn=function(e){let i=x(this,ne).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)},Kn=function(e){let i=x(this,ne).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)},Zn=function(e){x(this,ne).querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)},ea=function(e){x(this,ne).querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)},ta=function(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)}}},ra=function(e){if($(this,ne,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:x(this,ne).identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}x(this,ne).querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=I(this,U,ia).call(this,s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(x(this,ne)?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:x(this,ne).identifier,title:x(this,ne).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:[]}))}})}})}},ia=function(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;default:p=d;break}t[a]=p}}),t},sa=function(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(v=>v.querySelector("qti-correct-response")),m=Array.from(d).some(v=>{let E=v.querySelector("qti-mapping"),A=v.querySelector("qti-area-mapping");return E?.querySelector("qti-map-entry")||A?.querySelector("qti-area-map-entry")}),h=p||m,g=!!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:h,hasResponseProcessing:g}})}))}))}},c([u({type:String})],pe.prototype,"identifier",2),c([w()],pe.prototype,"initContext",2),c([w(),ee({context:Lt})],pe.prototype,"qtiContext",2),c([w(),ee({context:le})],pe.prototype,"configContext",2),c([w(),k({context:ye,subscribe:!0})],pe.prototype,"_testContext",2),c([w(),k({context:Fe,subscribe:!0})],pe.prototype,"_sessionContext",2),c([w(),ee({context:N})],pe.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],pe.prototype,"autoScoreItems",2),pe=c([C("test-navigation")],pe);var oa=y`
154
154
  display: inline-flex;
155
155
  align-items: center;
156
156
  cursor: pointer;
@@ -159,12 +159,12 @@ Make sure to test your application with a production build as repeat registratio
159
159
  user-select: none;
160
160
  `,Q=y`
161
161
  background-color: lightgray;
162
- ${sa};
162
+ ${oa};
163
163
  `,Y=y`
164
164
  cursor: not-allowed;
165
165
  opacity: 0.8;
166
- `,Df=y`
167
- ${sa};
166
+ `,Hf=y`
167
+ ${oa};
168
168
  border: 1px solid gray;
169
169
  `;var Ht,Je=class extends b{constructor(){super();this._internalDisabled=!0;T(this,Ht);$(this,Ht,this.attachInternals()),x(this,Ht).role="button",x(this,Ht).ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}connectedCallback(){super.connectedCallback(),this.checkDisabled()}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>=this.sectionItems?.length-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return f`<slot></slot>`}};Ht=new WeakMap,Je.styles=y`
170
170
  :host {
@@ -173,14 +173,14 @@ Make sure to test your application with a production build as repeat registratio
173
173
  :host([disabled]) {
174
174
  ${Y};
175
175
  }
176
- `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Je.prototype,"_internalDisabled",2),c([M({context:N,subscribe:!0})],Je.prototype,"computedContext",2),c([O("computedContext")],Je.prototype,"_handleTestElementChange",1),Je=c([C("test-next")],Je);var Ke=class extends b{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 f`<slot></slot>`}};Ke.styles=y`
176
+ `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Je.prototype,"_internalDisabled",2),c([k({context:N,subscribe:!0})],Je.prototype,"computedContext",2),c([O("computedContext")],Je.prototype,"_handleTestElementChange",1),Je=c([C("test-next")],Je);var Ke=class extends b{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 f`<slot></slot>`}};Ke.styles=y`
177
177
  :host {
178
178
  ${Q};
179
179
  }
180
180
  :host([disabled]) {
181
181
  ${Y};
182
182
  }
183
- `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ke.prototype,"_internalDisabled",2),c([M({context:N,subscribe:!0})],Ke.prototype,"computedContext",2),c([O("computedContext")],Ke.prototype,"_handleTestElementChange",1),Ke=c([C("test-prev")],Ke);var Vr,to,J=class extends b{constructor(){super(...arguments);T(this,Vr);this.label="view";this._handleViewOptionsChange=()=>{I(this,Vr,to).call(this)};this._viewOptions=J.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),I(this,Vr,to).call(this)}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return f`
183
+ `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ke.prototype,"_internalDisabled",2),c([k({context:N,subscribe:!0})],Ke.prototype,"computedContext",2),c([O("computedContext")],Ke.prototype,"_handleTestElementChange",1),Ke=c([C("test-prev")],Ke);var Vr,to,J=class extends b{constructor(){super(...arguments);T(this,Vr);this.label="view";this._handleViewOptionsChange=()=>{I(this,Vr,to).call(this)};this._viewOptions=J.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),I(this,Vr,to).call(this)}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return f`
184
184
  <label part="label" for="viewSelect">${this.label}</label>
185
185
  <select
186
186
  part="select"
@@ -189,7 +189,7 @@ Make sure to test your application with a production build as repeat registratio
189
189
  >
190
190
  ${this._viewOptions.map(e=>f`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
191
191
  </select>
192
- `}};Vr=new WeakSet,to=function(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>J.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=J.DEFAULT_VIEW_OPTIONS},J.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([M({context:Fe,subscribe:!0})],J.prototype,"sessionContext",2),c([u({type:String})],J.prototype,"label",2),c([u({type:String,attribute:"view-options"})],J.prototype,"viewOptions",2),c([O("viewOptions",{waitUntilFirstUpdate:!0})],J.prototype,"_handleViewOptionsChange",2),c([w()],J.prototype,"_viewOptions",2),J=c([C("test-view")],J);var zt=class extends b{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 f` <slot></slot> `}};zt.styles=y`
192
+ `}};Vr=new WeakSet,to=function(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>J.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=J.DEFAULT_VIEW_OPTIONS},J.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([k({context:Fe,subscribe:!0})],J.prototype,"sessionContext",2),c([u({type:String})],J.prototype,"label",2),c([u({type:String,attribute:"view-options"})],J.prototype,"viewOptions",2),c([O("viewOptions",{waitUntilFirstUpdate:!0})],J.prototype,"_handleViewOptionsChange",2),c([w()],J.prototype,"_viewOptions",2),J=c([C("test-view")],J);var zt=class extends b{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 f` <slot></slot> `}};zt.styles=y`
193
193
  :host {
194
194
  ${Q};
195
195
  }
@@ -203,15 +203,15 @@ Make sure to test your application with a production build as repeat registratio
203
203
  :host([disabled]) {
204
204
  ${Y};
205
205
  }
206
- `,Nr=c([C("test-end-attempt")],Nr);var Dr,Ut,oa,na,me=class extends b{constructor(){super(...arguments);T(this,Ut);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";T(this,Dr)}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(x(this,Dr)!==t&&(this.shown=!1,$(this,Dr,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}render(){return f` <div @click="${I(this,Ut,oa)}">${I(this,Ut,na).call(this)}</div> `}};Dr=new WeakMap,Ut=new WeakSet,oa=function(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))},na=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},me.styles=y`
206
+ `,Nr=c([C("test-end-attempt")],Nr);var Dr,Ut,na,aa,me=class extends b{constructor(){super(...arguments);T(this,Ut);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";T(this,Dr)}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(x(this,Dr)!==t&&(this.shown=!1,$(this,Dr,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}render(){return f` <div @click="${I(this,Ut,na)}">${I(this,Ut,aa).call(this)}</div> `}};Dr=new WeakMap,Ut=new WeakSet,na=function(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))},aa=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},me.styles=y`
207
207
  :host {
208
208
  ${Q};
209
209
  }
210
210
  :host([disabled]) {
211
211
  ${Y};
212
212
  }
213
- `,c([M({context:N,subscribe:!0})],me.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],me.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],me.prototype,"disabled",2),c([u({type:String})],me.prototype,"showCorrectText",2),c([u({type:String})],me.prototype,"hideCorrectText",2),c([u({type:String})],me.prototype,"noCorrectResponseText",2),me=c([C("test-show-correct-response")],me);var zi=["this"],aa=["+","-","!"],la=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],ro={"!":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},Ui=13;var Rl=["==","!=","<=",">=","||","&&","??","|>"],_l=["===","!=="],_;(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"})(_||(_={}));var Te=(o,r,e=0)=>({kind:o,value:r,precedence:e}),Ll=o=>o===9||o===10||o===13||o===32,ca=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),$l=o=>ca(o)||Hr(o),Ol=o=>zi.indexOf(o)!==-1,Pl=o=>o===34||o===39,Hr=o=>48<=o&&o<=57,Vl=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,Nl=o=>o===40||o===41||o===91||o===93||o===123||o===125,Dl=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
214
- `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Bi=class{#e;#t=-1;#r=0;#i;constructor(r){this.#e=r,this.#s()}nextToken(){for(;Ll(this.#i);)this.#s(!0);if(Pl(this.#i))return this.#a();if(ca(this.#i))return this.#u();if(Hr(this.#i))return this.#p();if(this.#i===46)return this.#l();if(this.#i===44)return this.#f();if(this.#i===58)return this.#m();if(Vl(this.#i))return this.#b();if(Nl(this.#i))return this.#h();if(this.#s(),this.#i!==void 0)throw new Error(`Expected end of input, got ${this.#i}`)}#s(r){this.#t++,this.#t<this.#e.length?(this.#i=this.#e.charCodeAt(this.#t),r===!0&&(this.#r=this.#t)):this.#i=void 0}#o(r=0){let e=this.#e.substring(this.#r,this.#t+r);return r===0&&this.#n(),e}#n(){this.#r=this.#t}#a(){let r="unterminated string",e=this.#i;for(this.#s(!0);this.#i!==e;){if(this.#i===void 0)throw new Error(r);if(this.#i===92&&(this.#s(),this.#i===void 0))throw new Error(r);this.#s()}let t=Te(_.STRING,Dl(this.#o()));return this.#s(),t}#u(){do this.#s();while($l(this.#i));let r=this.#o(),e=Ol(r)?_.KEYWORD:_.IDENTIFIER;return Te(e,r)}#p(){do this.#s();while(Hr(this.#i));return this.#i===46?this.#l():Te(_.INTEGER,this.#o())}#l(){return this.#s(),Hr(this.#i)?this.#g():(this.#n(),Te(_.DOT,".",Ui))}#f(){return this.#s(!0),Te(_.COMMA,",")}#m(){return this.#s(!0),Te(_.COLON,":")}#g(){do this.#s();while(Hr(this.#i));return Te(_.DECIMAL,this.#o())}#b(){this.#s();let r=this.#o(2);if(_l.indexOf(r)!==-1)this.#s(),this.#s();else{if(r=this.#o(1),r==="=>")return this.#s(),Te(_.ARROW,r);Rl.indexOf(r)!==-1&&this.#s()}return r=this.#o(),Te(_.OPERATOR,r,ro[r])}#h(){let r=String.fromCharCode(this.#i),e=Te(_.GROUPER,r,ro[r]);return this.#s(!0),e}};var io=(o,r)=>new zr(o,r).parse(),zr=class{#e;#t;#r;#i;#s;constructor(r,e){this.#t=new Bi(r),this.#r=e}parse(){return this.#o(),this.#n()}#o(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#i?.kind} (${this.#i?.value})`);let t=this.#t.nextToken();this.#i=t,this.#e=t?.kind,this.#s=t?.value}_matches(r,e){return!(r&&this.#e!==r||e&&this.#s!==e)}#n(){if(!this.#i)return this.#r.empty();let r=this.#l();return r===void 0?void 0:this.#a(r,0)}#a(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#i;)if(this._matches(_.GROUPER,"(")){let t=this.#c();r=this.#r.invoke(r,void 0,t)}else if(this._matches(_.GROUPER,"[")){let t=this.#d();r=this.#r.index(r,t)}else if(this._matches(_.DOT)){this.#o();let t=this.#l();r=this.#u(r,t)}else{if(this._matches(_.KEYWORD))break;if(this._matches(_.OPERATOR)&&this.#i.precedence>=e)r=this.#s==="?"?this.#f(r):this.#p(r,this.#i);else break}return r}#u(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#r.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#r.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(r,e){if(la.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#o();let t=this.#l();for(;(this.#e===_.OPERATOR||this.#e===_.DOT||this.#e===_.GROUPER)&&this.#i.precedence>e.precedence;)t=this.#a(t,this.#i.precedence);return this.#r.binary(r,e.value,t)}#l(){if(this._matches(_.OPERATOR)){let r=this.#s;if(this.#o(),r==="+"||r==="-"){if(this._matches(_.INTEGER))return this.#y(r);if(this._matches(_.DECIMAL))return this.#x(r)}if(aa.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#a(this.#m(),Ui);return this.#r.unary(r,e)}return this.#m()}#f(r){this.#o(_.OPERATOR,"?");let e=this.#n();this.#o(_.COLON);let t=this.#n();return this.#r.ternary(r,e,t)}#m(){switch(this.#e){case _.KEYWORD:let r=this.#s;if(r==="this")return this.#o(),this.#r.id(r);throw zi.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case _.IDENTIFIER:return this.#h();case _.STRING:return this.#C();case _.INTEGER:return this.#y();case _.DECIMAL:return this.#x();case _.GROUPER:return this.#s==="("?this.#q():this.#s==="{"?this.#b():this.#s==="["?this.#g():void 0;case _.COLON:throw new Error('unexpected token ":"');default:return}}#g(){let r=[];do{if(this.#o(),this._matches(_.GROUPER,"]"))break;r.push(this.#n())}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"]"),this.#r.list(r)}#b(){let r={};do{if(this.#o(),this._matches(_.GROUPER,"}"))break;let e=this.#s;(this._matches(_.STRING)||this._matches(_.IDENTIFIER))&&this.#o(),this.#o(_.COLON),r[e]=this.#n()}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"}"),this.#r.map(r)}#h(){let r=this.#s;if(r==="true")return this.#o(),this.#r.literal(!0);if(r==="false")return this.#o(),this.#r.literal(!1);if(r==="null")return this.#o(),this.#r.literal(null);if(r==="undefined")return this.#o(),this.#r.literal(void 0);let e=this.#v(),t=this.#c();return t?this.#r.invoke(e,void 0,t):e}#v(){if(!this._matches(_.IDENTIFIER))throw new Error(`expected identifier: ${this.#s}`);let r=this.#s;return this.#o(),this.#r.id(r)}#c(){if(!this._matches(_.GROUPER,"("))return;let r=[];do{if(this.#o(),this._matches(_.GROUPER,")"))break;let e=this.#n();r.push(e)}while(this._matches(_.COMMA));return this.#o(_.GROUPER,")"),r}#d(){this.#o();let r=this.#n();return this.#o(_.GROUPER,"]"),r}#q(){let r=this.#c();if(this._matches(_.ARROW)){this.#o();let e=this.#n(),t=r?.map(i=>i.value)??[];return this.#r.arrowFunction(t,e)}else return this.#r.paren(r[0])}#C(){let r=this.#r.literal(this.#s);return this.#o(),r}#y(r=""){let e=this.#r.literal(parseInt(`${r}${this.#s}`,10));return this.#o(),e}#x(r=""){let e=this.#r.literal(parseFloat(`${r}${this.#s}`));return this.#o(),e}};var{hasOwn:da,fromEntries:Hl}=Object,zl={"+":(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)},Ul={"+":o=>o,"-":o=>-o,"!":o=>!o},Fi=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=Ul[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=zl[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=Hl(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return da(a,p)&&(a[p]=m),d[p]=m},get(d,p){return da(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var so=null,pa={boundAttributeSuffix:W.M,marker:W.P,markerMatch:W.A,HTML_RESULT:W.C,getTemplateHtml:W.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){so??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(so))return void(e[so]=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=z;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:W.V,AttributePart:W.H,PropertyPart:W.B,BooleanAttributePart:W.N,EventPart:W.U,ElementPart:W.F,TemplateInstance:W.R,isIterable:W.D,ChildPart:W.I};var{AttributePart:Bl,PropertyPart:Fl,BooleanAttributePart:jl,EventPart:Wl}=pa,no=new Fi,oo=new Map,ua=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ji=(o,r)=>{let e=oo.get(o);if(e===void 0){if(oo.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new zr(t,no).parse(),oo.set(o,e)}}return e?.evaluate(r)},Xl=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ji(i,r))return Wi(o,r,e,t)},ma=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,ha=o=>/(?:\\{{)|(?:\\}})/g.test(o),Ur=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Gl=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ji(i,r);if(!s[Symbol.iterator])return L;let n=Br(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 g of n.parts){let v=g.update(p,e,t);g.type===1?m.push(...v):m.push(v)}let h={_$litType$:n,values:m};l.push(h)}return l}},ga={if:Xl,repeat:Gl},Ae=(o,r=ga,e={},t)=>{let s=Br(o).renderers;if(t){let a=Br(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,g,v)=>Wi(t,h,g,v)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>Wi(o,n,r,e)};var Wi=(o,r,e=ga,t={})=>{let i=Br(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}},fa=new Map,Br=o=>{let r=fa.get(o);return r===void 0&&fa.set(o,r=Ql(o)),r},Ql=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 h=p.trim(),g=h.startsWith("{{")&&h.endsWith("}}");m=(v,E,A)=>{let q=n.getAttribute("data"),k=q===null?void 0:ji(q,v);return(g?ji(h,v):A[p])?.(k,E,A)}}else l!==null?m=(h,g,v)=>{let E=g[l];return E?.(n,h,g,v)}:(d==="super"?r.renderers.super=(h,g,v)=>{let E=v.super,A=Br(n);return v={...v,...A.renderers},E(h,g,v)}:r.renderers[d]=(h,g,v)=>Wi(n,h,g,v),m=(h,g,v)=>{let E=v[d];return E?.(h,g,v)});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(ma);if(p.length===1){ha(d)&&n.setAttribute(l,Ur(d));continue}n.removeAttribute(l);let m=l,h=Bl,g=l[0];g==="."?(m=ua(l.substring(1)),h=Fl):g==="?"?(m=l.substring(1),h=jl):g==="@"&&(m=ua(l.substring(1)),h=Wl);let v=[Ur(p[0])],E=[];for(let A=1;A<p.length;A+=2){let q=p[A];E.push(io(q,no)),v.push(Ur(p[A+1]))}r.parts.push({type:1,index:i,name:m,strings:v,ctor:h,update:(A,q,k)=>E.map(P=>P.evaluate(A))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(ma);l.length>1?n.textContent=Ur(l[0]):ha(a)&&(n.textContent=Ur(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=io(p,no);r.parts.push({type:2,index:++i,update:(g,v)=>m.evaluate(g)});let h=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(h,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=h,e.currentNode=h}}for(let n of s)n.remove();return r};var jr,Fr=class extends b{constructor(){super();T(this,jr);$(this,jr,this.attachInternals()),x(this,jr).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=Ae(e)}render(){if(!this.computedContext)return f``;let e=this.computedContext.testParts.flatMap(t=>t.sections.flatMap(i=>i.items));return f` ${e.map(t=>this.myTemplate({item:t,view:this.computedContext.view}))} `}};jr=new WeakMap,c([M({context:N,subscribe:!0})],Fr.prototype,"computedContext",2),Fr=c([C("test-paging-buttons-stamp")],Fr);var Xi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},Gi=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 ba=o=>!Sn(o)&&typeof o.then=="function",va=1073741823,ao=class extends Xe{constructor(){super(...arguments),this._$Cwt=va,this._$Cbt=[],this._$CK=new Xi(this),this._$CX=new Gi}render(...r){return r.find((e=>!ba(e)))??z}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(!ba(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=va,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 z}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Qi=te(ao);var Yi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
213
+ `,c([k({context:N,subscribe:!0})],me.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],me.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],me.prototype,"disabled",2),c([u({type:String})],me.prototype,"showCorrectText",2),c([u({type:String})],me.prototype,"hideCorrectText",2),c([u({type:String})],me.prototype,"noCorrectResponseText",2),me=c([C("test-show-correct-response")],me);var zi=["this"],la=["+","-","!"],ca=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],ro={"!":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},Ui=13;var _l=["==","!=","<=",">=","||","&&","??","|>"],Ll=["===","!=="],_;(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"})(_||(_={}));var Te=(o,r,e=0)=>({kind:o,value:r,precedence:e}),$l=o=>o===9||o===10||o===13||o===32,da=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),Ol=o=>da(o)||Hr(o),Pl=o=>zi.indexOf(o)!==-1,Vl=o=>o===34||o===39,Hr=o=>48<=o&&o<=57,Nl=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,Dl=o=>o===40||o===41||o===91||o===93||o===123||o===125,Hl=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
214
+ `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Bi=class{#e;#t=-1;#i=0;#r;constructor(r){this.#e=r,this.#s()}nextToken(){for(;$l(this.#r);)this.#s(!0);if(Vl(this.#r))return this.#a();if(da(this.#r))return this.#p();if(Hr(this.#r))return this.#u();if(this.#r===46)return this.#l();if(this.#r===44)return this.#f();if(this.#r===58)return this.#m();if(Nl(this.#r))return this.#b();if(Dl(this.#r))return this.#h();if(this.#s(),this.#r!==void 0)throw new Error(`Expected end of input, got ${this.#r}`)}#s(r){this.#t++,this.#t<this.#e.length?(this.#r=this.#e.charCodeAt(this.#t),r===!0&&(this.#i=this.#t)):this.#r=void 0}#o(r=0){let e=this.#e.substring(this.#i,this.#t+r);return r===0&&this.#n(),e}#n(){this.#i=this.#t}#a(){let r="unterminated string",e=this.#r;for(this.#s(!0);this.#r!==e;){if(this.#r===void 0)throw new Error(r);if(this.#r===92&&(this.#s(),this.#r===void 0))throw new Error(r);this.#s()}let t=Te(_.STRING,Hl(this.#o()));return this.#s(),t}#p(){do this.#s();while(Ol(this.#r));let r=this.#o(),e=Pl(r)?_.KEYWORD:_.IDENTIFIER;return Te(e,r)}#u(){do this.#s();while(Hr(this.#r));return this.#r===46?this.#l():Te(_.INTEGER,this.#o())}#l(){return this.#s(),Hr(this.#r)?this.#g():(this.#n(),Te(_.DOT,".",Ui))}#f(){return this.#s(!0),Te(_.COMMA,",")}#m(){return this.#s(!0),Te(_.COLON,":")}#g(){do this.#s();while(Hr(this.#r));return Te(_.DECIMAL,this.#o())}#b(){this.#s();let r=this.#o(2);if(Ll.indexOf(r)!==-1)this.#s(),this.#s();else{if(r=this.#o(1),r==="=>")return this.#s(),Te(_.ARROW,r);_l.indexOf(r)!==-1&&this.#s()}return r=this.#o(),Te(_.OPERATOR,r,ro[r])}#h(){let r=String.fromCharCode(this.#r),e=Te(_.GROUPER,r,ro[r]);return this.#s(!0),e}};var io=(o,r)=>new zr(o,r).parse(),zr=class{#e;#t;#i;#r;#s;constructor(r,e){this.#t=new Bi(r),this.#i=e}parse(){return this.#o(),this.#n()}#o(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#r?.kind} (${this.#r?.value})`);let t=this.#t.nextToken();this.#r=t,this.#e=t?.kind,this.#s=t?.value}_matches(r,e){return!(r&&this.#e!==r||e&&this.#s!==e)}#n(){if(!this.#r)return this.#i.empty();let r=this.#l();return r===void 0?void 0:this.#a(r,0)}#a(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#r;)if(this._matches(_.GROUPER,"(")){let t=this.#c();r=this.#i.invoke(r,void 0,t)}else if(this._matches(_.GROUPER,"[")){let t=this.#v();r=this.#i.index(r,t)}else if(this._matches(_.DOT)){this.#o();let t=this.#l();r=this.#p(r,t)}else{if(this._matches(_.KEYWORD))break;if(this._matches(_.OPERATOR)&&this.#r.precedence>=e)r=this.#s==="?"?this.#f(r):this.#u(r,this.#r);else break}return r}#p(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}`)}#u(r,e){if(ca.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#o();let t=this.#l();for(;(this.#e===_.OPERATOR||this.#e===_.DOT||this.#e===_.GROUPER)&&this.#r.precedence>e.precedence;)t=this.#a(t,this.#r.precedence);return this.#i.binary(r,e.value,t)}#l(){if(this._matches(_.OPERATOR)){let r=this.#s;if(this.#o(),r==="+"||r==="-"){if(this._matches(_.INTEGER))return this.#x(r);if(this._matches(_.DECIMAL))return this.#d(r)}if(la.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#a(this.#m(),Ui);return this.#i.unary(r,e)}return this.#m()}#f(r){this.#o(_.OPERATOR,"?");let e=this.#n();this.#o(_.COLON);let t=this.#n();return this.#i.ternary(r,e,t)}#m(){switch(this.#e){case _.KEYWORD:let r=this.#s;if(r==="this")return this.#o(),this.#i.id(r);throw zi.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case _.IDENTIFIER:return this.#h();case _.STRING:return this.#C();case _.INTEGER:return this.#x();case _.DECIMAL:return this.#d();case _.GROUPER:return this.#s==="("?this.#q():this.#s==="{"?this.#b():this.#s==="["?this.#g():void 0;case _.COLON:throw new Error('unexpected token ":"');default:return}}#g(){let r=[];do{if(this.#o(),this._matches(_.GROUPER,"]"))break;r.push(this.#n())}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"]"),this.#i.list(r)}#b(){let r={};do{if(this.#o(),this._matches(_.GROUPER,"}"))break;let e=this.#s;(this._matches(_.STRING)||this._matches(_.IDENTIFIER))&&this.#o(),this.#o(_.COLON),r[e]=this.#n()}while(this._matches(_.COMMA));return this.#o(_.GROUPER,"}"),this.#i.map(r)}#h(){let r=this.#s;if(r==="true")return this.#o(),this.#i.literal(!0);if(r==="false")return this.#o(),this.#i.literal(!1);if(r==="null")return this.#o(),this.#i.literal(null);if(r==="undefined")return this.#o(),this.#i.literal(void 0);let e=this.#y(),t=this.#c();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(_.IDENTIFIER))throw new Error(`expected identifier: ${this.#s}`);let r=this.#s;return this.#o(),this.#i.id(r)}#c(){if(!this._matches(_.GROUPER,"("))return;let r=[];do{if(this.#o(),this._matches(_.GROUPER,")"))break;let e=this.#n();r.push(e)}while(this._matches(_.COMMA));return this.#o(_.GROUPER,")"),r}#v(){this.#o();let r=this.#n();return this.#o(_.GROUPER,"]"),r}#q(){let r=this.#c();if(this._matches(_.ARROW)){this.#o();let e=this.#n(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#C(){let r=this.#i.literal(this.#s);return this.#o(),r}#x(r=""){let e=this.#i.literal(parseInt(`${r}${this.#s}`,10));return this.#o(),e}#d(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#s}`));return this.#o(),e}};var{hasOwn:pa,fromEntries:zl}=Object,Ul={"+":(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)},Bl={"+":o=>o,"-":o=>-o,"!":o=>!o},Fi=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=Bl[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=Ul[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=zl(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return pa(a,p)&&(a[p]=m),d[p]=m},get(d,p){return pa(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var so=null,ua={boundAttributeSuffix:W.M,marker:W.P,markerMatch:W.A,HTML_RESULT:W.C,getTemplateHtml:W.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){so??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(so))return void(e[so]=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=z;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:W.V,AttributePart:W.H,PropertyPart:W.B,BooleanAttributePart:W.N,EventPart:W.U,ElementPart:W.F,TemplateInstance:W.R,isIterable:W.D,ChildPart:W.I};var{AttributePart:Fl,PropertyPart:jl,BooleanAttributePart:Wl,EventPart:Xl}=ua,no=new Fi,oo=new Map,ma=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ji=(o,r)=>{let e=oo.get(o);if(e===void 0){if(oo.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new zr(t,no).parse(),oo.set(o,e)}}return e?.evaluate(r)},Gl=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ji(i,r))return Wi(o,r,e,t)},ha=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,fa=o=>/(?:\\{{)|(?:\\}})/g.test(o),Ur=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Ql=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ji(i,r);if(!s[Symbol.iterator])return L;let n=Br(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 g of n.parts){let v=g.update(p,e,t);g.type===1?m.push(...v):m.push(v)}let h={_$litType$:n,values:m};l.push(h)}return l}},ba={if:Gl,repeat:Ql},Ae=(o,r=ba,e={},t)=>{let s=Br(o).renderers;if(t){let a=Br(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(h,g,v)=>Wi(t,h,g,v)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>Wi(o,n,r,e)};var Wi=(o,r,e=ba,t={})=>{let i=Br(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}},ga=new Map,Br=o=>{let r=ga.get(o);return r===void 0&&ga.set(o,r=Yl(o)),r},Yl=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 h=p.trim(),g=h.startsWith("{{")&&h.endsWith("}}");m=(v,E,A)=>{let q=n.getAttribute("data"),M=q===null?void 0:ji(q,v);return(g?ji(h,v):A[p])?.(M,E,A)}}else l!==null?m=(h,g,v)=>{let E=g[l];return E?.(n,h,g,v)}:(d==="super"?r.renderers.super=(h,g,v)=>{let E=v.super,A=Br(n);return v={...v,...A.renderers},E(h,g,v)}:r.renderers[d]=(h,g,v)=>Wi(n,h,g,v),m=(h,g,v)=>{let E=v[d];return E?.(h,g,v)});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(ha);if(p.length===1){fa(d)&&n.setAttribute(l,Ur(d));continue}n.removeAttribute(l);let m=l,h=Fl,g=l[0];g==="."?(m=ma(l.substring(1)),h=jl):g==="?"?(m=l.substring(1),h=Wl):g==="@"&&(m=ma(l.substring(1)),h=Xl);let v=[Ur(p[0])],E=[];for(let A=1;A<p.length;A+=2){let q=p[A];E.push(io(q,no)),v.push(Ur(p[A+1]))}r.parts.push({type:1,index:i,name:m,strings:v,ctor:h,update:(A,q,M)=>E.map(P=>P.evaluate(A))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(ha);l.length>1?n.textContent=Ur(l[0]):fa(a)&&(n.textContent=Ur(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=io(p,no);r.parts.push({type:2,index:++i,update:(g,v)=>m.evaluate(g)});let h=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(h,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=h,e.currentNode=h}}for(let n of s)n.remove();return r};var jr,Fr=class extends b{constructor(){super();T(this,jr);$(this,jr,this.attachInternals()),x(this,jr).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=Ae(e)}render(){if(!this.computedContext)return f``;let e=this.computedContext.testParts.flatMap(t=>t.sections.flatMap(i=>i.items));return f` ${e.map(t=>this.myTemplate({item:t,view:this.computedContext.view}))} `}};jr=new WeakMap,c([k({context:N,subscribe:!0})],Fr.prototype,"computedContext",2),Fr=c([C("test-paging-buttons-stamp")],Fr);var Xi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},Gi=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 va=o=>!Sn(o)&&typeof o.then=="function",ya=1073741823,ao=class extends Xe{constructor(){super(...arguments),this._$Cwt=ya,this._$Cbt=[],this._$CK=new Xi(this),this._$CX=new Gi}render(...r){return r.find((e=>!va(e)))??z}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(!va(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=ya,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 z}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Qi=te(ao);var Yi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
215
215
 
216
216
  /* https://www.imsglobal.org/sites/default/files/spec/qti/v3/guide/img/qti3p0.css */
217
217
 
@@ -3772,11 +3772,11 @@ div.full-correct-response-inline {
3772
3772
  margin-right: var(--qti-padding-horizontal);
3773
3773
  padding: 0.2rem;
3774
3774
  }
3775
- `;var Wr,Bt,ya,xa,Oe=class extends b{constructor(){super(...arguments);T(this,Bt);this.testURL=null;this.testDoc=null;this.testXML=null;T(this,Wr,null)}async handleTestURLChange(){if(this.testURL)try{let e=await It().load(this.testURL),t=this.closest("qti-test");if(t?.postLoadTestTransformCallback){let s=e.htmlDoc().querySelector("qti-assessment-test");s&&(e=await t.postLoadTestTransformCallback(e,s))}this.testDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleTestXMLChange(){if(this.testXML)try{this.testDoc=It().parse(this.testXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),I(this,Bt,ya).call(this),I(this,Bt,xa).call(this),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}render(){return f`
3775
+ `;var Wr,Bt,xa,qa,Oe=class extends b{constructor(){super(...arguments);T(this,Bt);this.testURL=null;this.testDoc=null;this.testXML=null;T(this,Wr,null)}async handleTestURLChange(){if(this.testURL)try{let e=await It().load(this.testURL),t=this.closest("qti-test");if(t?.postLoadTestTransformCallback){let s=e.htmlDoc().querySelector("qti-assessment-test");s&&(e=await t.postLoadTestTransformCallback(e,s))}this.testDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleTestXMLChange(){if(this.testXML)try{this.testDoc=It().parse(this.testXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),I(this,Bt,xa).call(this),I(this,Bt,qa).call(this),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}render(){return f`
3776
3776
  ${x(this,Wr)}
3777
3777
  <slot></slot>
3778
3778
  ${Qi(this.testDoc,f`<span>Loading...</span>`)}
3779
- `}};Wr=new WeakMap,Bt=new WeakSet,ya=function(){let e=this.querySelector("template");$(this,Wr,e?e.content:f``)},xa=function(){let e=new CSSStyleSheet;e.replaceSync(Yi),this.shadowRoot.adoptedStyleSheets=[e]},c([u({type:String,attribute:"test-url"})],Oe.prototype,"testURL",2),c([w()],Oe.prototype,"testDoc",2),c([w()],Oe.prototype,"testXML",2),c([O("testURL",{waitUntilFirstUpdate:!0})],Oe.prototype,"handleTestURLChange",1),c([O("testXML",{waitUntilFirstUpdate:!0})],Oe.prototype,"handleTestXMLChange",1),Oe=c([C("test-container")],Oe);var Ft=class extends b{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
3779
+ `}};Wr=new WeakMap,Bt=new WeakSet,xa=function(){let e=this.querySelector("template");$(this,Wr,e?e.content:f``)},qa=function(){let e=new CSSStyleSheet;e.replaceSync(Yi),this.shadowRoot.adoptedStyleSheets=[e]},c([u({type:String,attribute:"test-url"})],Oe.prototype,"testURL",2),c([w()],Oe.prototype,"testDoc",2),c([w()],Oe.prototype,"testXML",2),c([O("testURL",{waitUntilFirstUpdate:!0})],Oe.prototype,"handleTestURLChange",1),c([O("testXML",{waitUntilFirstUpdate:!0})],Oe.prototype,"handleTestXMLChange",1),Oe=c([C("test-container")],Oe);var Ft=class extends b{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
3780
3780
  <h3>${n}</h3>
3781
3781
  <table>
3782
3782
  <thead>
@@ -3823,37 +3823,37 @@ div.full-correct-response-inline {
3823
3823
  margin-top: 20px;
3824
3824
  font-size: 16px;
3825
3825
  }
3826
- `,c([M({context:N,subscribe:!0})],Ft.prototype,"computedContext",2),Ft=c([C("test-print-item-variables")],Ft);var Gr,Xr=class extends b{constructor(){super();T(this,Gr);$(this,Gr,this.attachInternals()),x(this,Gr).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=Ae(e)}render(){if(!this.computedContext)return f``;let e=this.computedContext.testParts.flatMap(t=>t.sections);return f` ${e.map(t=>this.myTemplate({item:t}))} `}};Gr=new WeakMap,c([M({context:N,subscribe:!0})],Xr.prototype,"computedContext",2),Xr=c([C("test-section-buttons-stamp")],Xr);var Ji,qa,jt=class extends b{constructor(){super();T(this,Ji);this.sectionId=null;this.addEventListener("click",()=>I(this,Ji,qa).call(this,this.sectionId))}render(){return f` <slot></slot> `}};Ji=new WeakSet,qa=function(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))},jt.styles=y`
3826
+ `,c([k({context:N,subscribe:!0})],Ft.prototype,"computedContext",2),Ft=c([C("test-print-item-variables")],Ft);var Gr,Xr=class extends b{constructor(){super();T(this,Gr);$(this,Gr,this.attachInternals()),x(this,Gr).ariaLabel="pagination"}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");this.myTemplate=Ae(e)}render(){if(!this.computedContext)return f``;let e=this.computedContext.testParts.flatMap(t=>t.sections);return f` ${e.map(t=>this.myTemplate({item:t}))} `}};Gr=new WeakMap,c([k({context:N,subscribe:!0})],Xr.prototype,"computedContext",2),Xr=c([C("test-section-buttons-stamp")],Xr);var Ji,Ca,jt=class extends b{constructor(){super();T(this,Ji);this.sectionId=null;this.addEventListener("click",()=>I(this,Ji,Ca).call(this,this.sectionId))}render(){return f` <slot></slot> `}};Ji=new WeakSet,Ca=function(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))},jt.styles=y`
3827
3827
  :host {
3828
3828
  ${Q};
3829
3829
  }
3830
3830
  :host([disabled]) {
3831
3831
  ${Y};
3832
3832
  }
3833
- `,c([u({type:String,attribute:"section-id"})],jt.prototype,"sectionId",2),jt=c([C("test-section-link")],jt);var Qr=class extends b{render(){return f` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([w(),M({context:N,subscribe:!0})],Qr.prototype,"computedContext",2),Qr=c([C("test-print-context")],Qr);var vt=class extends b{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=Ae(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(h=>h.active),i=t?.sections.find(h=>h.active),s=i?.items.find(h=>h.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(h=>h.items.map(({variables:g,...v})=>v)),sections:t.sections.map(h=>({...h,items:h.items.map(({variables:g,...v})=>v)}))},d={...i,items:i.items.map(({variables:h,...g})=>g)},{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 f` ${this.debug?f`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:L}
3834
- ${this.myTemplate?this.myTemplate(this.stampContext):L}`}};c([u({type:Boolean,reflect:!0})],vt.prototype,"debug",2),c([w(),M({context:N,subscribe:!0})],vt.prototype,"computedContext",2),c([w()],vt.prototype,"stampContext",2),vt=c([C("test-stamp")],vt);var Ki,Ca,yt=class extends b{constructor(){super();T(this,Ki);this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&I(this,Ki,Ca).call(this,i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Ae(e)}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return f``;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 L;let a=[...Array(Number(t)+1).keys()];return f`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):L}`}};Ki=new WeakSet,Ca=function(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}))},c([u({type:String,attribute:"view"})],yt.prototype,"view",2),c([u({type:Boolean})],yt.prototype,"disabled",2),c([M({context:N,subscribe:!0})],yt.prototype,"computedContext",2),yt=c([C("test-scoring-buttons")],yt);var Yr=class extends b{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=Ae(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 f`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):L}`}};c([M({context:Fe,subscribe:!0})],Yr.prototype,"sessionContext",2),Yr=c([C("test-view-toggle")],Yr);var Wt=class extends b{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 f``;if(e.category==="dep-informational")return f`<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 f`<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([M({context:N,subscribe:!0})],Wt.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],Wt.prototype,"view",2),Wt=c([C("test-scoring-feedback")],Wt);var Jr=class extends b{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 f` <slot></slot> `}};Jr.styles=y`
3833
+ `,c([u({type:String,attribute:"section-id"})],jt.prototype,"sectionId",2),jt=c([C("test-section-link")],jt);var Qr=class extends b{render(){return f` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([w(),k({context:N,subscribe:!0})],Qr.prototype,"computedContext",2),Qr=c([C("test-print-context")],Qr);var vt=class extends b{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=Ae(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(h=>h.active),i=t?.sections.find(h=>h.active),s=i?.items.find(h=>h.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(h=>h.items.map(({variables:g,...v})=>v)),sections:t.sections.map(h=>({...h,items:h.items.map(({variables:g,...v})=>v)}))},d={...i,items:i.items.map(({variables:h,...g})=>g)},{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 f` ${this.debug?f`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:L}
3834
+ ${this.myTemplate?this.myTemplate(this.stampContext):L}`}};c([u({type:Boolean,reflect:!0})],vt.prototype,"debug",2),c([w(),k({context:N,subscribe:!0})],vt.prototype,"computedContext",2),c([w()],vt.prototype,"stampContext",2),vt=c([C("test-stamp")],vt);var Ki,wa,yt=class extends b{constructor(){super();T(this,Ki);this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&I(this,Ki,wa).call(this,i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=Ae(e)}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return f``;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 L;let a=[...Array(Number(t)+1).keys()];return f`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):L}`}};Ki=new WeakSet,wa=function(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}))},c([u({type:String,attribute:"view"})],yt.prototype,"view",2),c([u({type:Boolean})],yt.prototype,"disabled",2),c([k({context:N,subscribe:!0})],yt.prototype,"computedContext",2),yt=c([C("test-scoring-buttons")],yt);var Yr=class extends b{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=Ae(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 f`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):L}`}};c([k({context:Fe,subscribe:!0})],Yr.prototype,"sessionContext",2),Yr=c([C("test-view-toggle")],Yr);var Wt=class extends b{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 f``;if(e.category==="dep-informational")return f`<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 f`<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([k({context:N,subscribe:!0})],Wt.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],Wt.prototype,"view",2),Wt=c([C("test-scoring-feedback")],Wt);var Jr=class extends b{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 f` <slot></slot> `}};Jr.styles=y`
3835
3835
  :host {
3836
3836
  ${Q};
3837
3837
  }
3838
3838
  :host([disabled]) {
3839
3839
  ${Y};
3840
3840
  }
3841
- `,Jr=c([C("test-check-item")],Jr);var Kr,Xt,wa,Ea,Pe=class extends b{constructor(){super(...arguments);T(this,Xt);this.itemURL=null;this.itemDoc=null;this.itemXML=null;T(this,Kr,null)}async handleItemURLChange(){if(this.itemURL)try{let e=await ve().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=ve().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),I(this,Xt,wa).call(this),I(this,Xt,Ea).call(this),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}render(){return f`
3841
+ `,Jr=c([C("test-check-item")],Jr);var Kr,Xt,Ea,Ta,Pe=class extends b{constructor(){super(...arguments);T(this,Xt);this.itemURL=null;this.itemDoc=null;this.itemXML=null;T(this,Kr,null)}async handleItemURLChange(){if(this.itemURL)try{let e=await ve().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=ve().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),I(this,Xt,Ea).call(this),I(this,Xt,Ta).call(this),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}render(){return f`
3842
3842
  ${x(this,Kr)}
3843
3843
  <slot></slot>
3844
3844
  ${Qi(this.itemDoc,f`<span>Loading...</span>`)}
3845
- `}};Kr=new WeakMap,Xt=new WeakSet,wa=function(){let e=this.querySelector("template");$(this,Kr,e?e.content:f``)},Ea=function(){let e=new CSSStyleSheet;e.replaceSync(Yi),this.shadowRoot.adoptedStyleSheets=[e]},c([u({type:String,attribute:"item-url"})],Pe.prototype,"itemURL",2),c([w()],Pe.prototype,"itemDoc",2),c([w()],Pe.prototype,"itemXML",2),c([O("itemURL",{waitUntilFirstUpdate:!0})],Pe.prototype,"handleItemURLChange",1),c([O("itemXML",{waitUntilFirstUpdate:!0})],Pe.prototype,"handleItemXMLChange",1),Pe=c([C("item-container")],Pe);var Zi,Ta,xt=class extends b{constructor(){super(...arguments);T(this,Zi);this.label="Correct response mode";this._options={internal:"Internal",full:"Full (copy)"}}render(){return f`
3845
+ `}};Kr=new WeakMap,Xt=new WeakSet,Ea=function(){let e=this.querySelector("template");$(this,Kr,e?e.content:f``)},Ta=function(){let e=new CSSStyleSheet;e.replaceSync(Yi),this.shadowRoot.adoptedStyleSheets=[e]},c([u({type:String,attribute:"item-url"})],Pe.prototype,"itemURL",2),c([w()],Pe.prototype,"itemDoc",2),c([w()],Pe.prototype,"itemXML",2),c([O("itemURL",{waitUntilFirstUpdate:!0})],Pe.prototype,"handleItemURLChange",1),c([O("itemXML",{waitUntilFirstUpdate:!0})],Pe.prototype,"handleItemXMLChange",1),Pe=c([C("item-container")],Pe);var Zi,Aa,xt=class extends b{constructor(){super(...arguments);T(this,Zi);this.label="Correct response mode";this._options={internal:"Internal",full:"Full (copy)"}}render(){return f`
3846
3846
  <label part="label" for="modeSelect">${this.label}</label>
3847
3847
  <select
3848
3848
  part="select"
3849
3849
  id="modeSelect"
3850
- @change=${e=>{let t=e.target;I(this,Zi,Ta).call(this,t.value)}}
3850
+ @change=${e=>{let t=e.target;I(this,Zi,Aa).call(this,t.value)}}
3851
3851
  >
3852
3852
  ${Object.keys(this._options).map(e=>f`<option value="${e}" ?selected=${e===this.itemContext?.correctResponseMode}>
3853
3853
  ${this._options[e]}
3854
3854
  </option>`)}
3855
3855
  </select>
3856
- `}};Zi=new WeakSet,Ta=function(e){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:e,bubbles:!0}))},c([M({context:ae,subscribe:!0})],xt.prototype,"itemContext",2),c([u({type:String})],xt.prototype,"label",2),c([w()],xt.prototype,"_options",2),xt=c([C("item-correct-response-mode")],xt);var Aa=y`
3856
+ `}};Zi=new WeakSet,Aa=function(e){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:e,bubbles:!0}))},c([k({context:le,subscribe:!0})],xt.prototype,"itemContext",2),c([u({type:String})],xt.prototype,"label",2),c([w()],xt.prototype,"_options",2),xt=c([C("item-correct-response-mode")],xt);var Sa=y`
3857
3857
  display: inline-flex;
3858
3858
  align-items: center;
3859
3859
  cursor: pointer;
@@ -3862,28 +3862,28 @@ div.full-correct-response-inline {
3862
3862
  user-select: none;
3863
3863
  `,es=y`
3864
3864
  background-color: lightgray;
3865
- ${Aa};
3865
+ ${Sa};
3866
3866
  `,ts=y`
3867
3867
  cursor: not-allowed;
3868
3868
  opacity: 0.8;
3869
- `,ey=y`
3870
- ${Aa};
3869
+ `,ty=y`
3870
+ ${Sa};
3871
3871
  border: 1px solid gray;
3872
- `;var Gt,Zr,Qt,Ma,ka,he=class extends b{constructor(){super();T(this,Qt);this.shown=!1;this.disabled=!1;this.showCandidateCorrectionText="Show candidate correction";this.hideCandidateCorrectionText="Hide candidate correction";this.noCorrectResponseText="No correct response specified";T(this,Gt,!1);T(this,Zr,"")}updated(){if(!x(this,Gt)||x(this,Zr)!==this.computedContext?.identifier){$(this,Zr,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);$(this,Gt,e||t)}this.disabled=!x(this,Gt)}render(){return f` <div @click="${I(this,Qt,Ma)}">${I(this,Qt,ka).call(this)}</div> `}};Gt=new WeakMap,Zr=new WeakMap,Qt=new WeakSet,Ma=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-candidate-correction",{detail:!this.shown,bubbles:!0}))},ka=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText},he.styles=y`
3872
+ `;var Gt,Zr,Qt,Ma,Ia,he=class extends b{constructor(){super();T(this,Qt);this.shown=!1;this.disabled=!1;this.showCandidateCorrectionText="Show candidate correction";this.hideCandidateCorrectionText="Hide candidate correction";this.noCorrectResponseText="No correct response specified";T(this,Gt,!1);T(this,Zr,"")}updated(){if(!x(this,Gt)||x(this,Zr)!==this.computedContext?.identifier){$(this,Zr,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);$(this,Gt,e||t)}this.disabled=!x(this,Gt)}render(){return f` <div @click="${I(this,Qt,Ma)}">${I(this,Qt,Ia).call(this)}</div> `}};Gt=new WeakMap,Zr=new WeakMap,Qt=new WeakSet,Ma=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-candidate-correction",{detail:!this.shown,bubbles:!0}))},Ia=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText},he.styles=y`
3873
3873
  :host {
3874
3874
  ${es};
3875
3875
  }
3876
3876
  :host([disabled]) {
3877
3877
  ${ts};
3878
3878
  }
3879
- `,c([M({context:Be,subscribe:!0})],he.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],he.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],he.prototype,"disabled",2),c([u({type:String})],he.prototype,"showCandidateCorrectionText",2),c([u({type:String})],he.prototype,"hideCandidateCorrectionText",2),c([u({type:String})],he.prototype,"noCorrectResponseText",2),he=c([C("item-show-candidate-correction")],he);var Yt,ei,Jt,Ia,Ra,fe=class extends b{constructor(){super(...arguments);T(this,Jt);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";T(this,Yt,!1);T(this,ei,"")}updated(){if(!x(this,Yt)||x(this,ei)!==this.computedContext?.identifier){$(this,ei,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);$(this,Yt,e||t)}this.disabled=!x(this,Yt)}render(){return f` <div @click="${I(this,Jt,Ia)}">${I(this,Jt,Ra).call(this)}</div> `}};Yt=new WeakMap,ei=new WeakMap,Jt=new WeakSet,Ia=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))},Ra=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},fe.styles=y`
3879
+ `,c([k({context:Be,subscribe:!0})],he.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],he.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],he.prototype,"disabled",2),c([u({type:String})],he.prototype,"showCandidateCorrectionText",2),c([u({type:String})],he.prototype,"hideCandidateCorrectionText",2),c([u({type:String})],he.prototype,"noCorrectResponseText",2),he=c([C("item-show-candidate-correction")],he);var Yt,ei,Jt,Ra,_a,fe=class extends b{constructor(){super(...arguments);T(this,Jt);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";T(this,Yt,!1);T(this,ei,"")}updated(){if(!x(this,Yt)||x(this,ei)!==this.computedContext?.identifier){$(this,ei,this.computedContext?.identifier);let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);$(this,Yt,e||t)}this.disabled=!x(this,Yt)}render(){return f` <div @click="${I(this,Jt,Ra)}">${I(this,Jt,_a).call(this)}</div> `}};Yt=new WeakMap,ei=new WeakMap,Jt=new WeakSet,Ra=function(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))},_a=function(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText},fe.styles=y`
3880
3880
  :host {
3881
3881
  ${es};
3882
3882
  }
3883
3883
  :host([disabled]) {
3884
3884
  ${ts};
3885
3885
  }
3886
- `,c([M({context:Be,subscribe:!0})],fe.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],fe.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],fe.prototype,"disabled",2),c([u({type:String})],fe.prototype,"showCorrectText",2),c([u({type:String})],fe.prototype,"hideCorrectText",2),c([u({type:String})],fe.prototype,"noCorrectResponseText",2),fe=c([C("item-show-correct-response")],fe);var Kt=class extends b{render(){let r=this.computedContext;if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
3886
+ `,c([k({context:Be,subscribe:!0})],fe.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],fe.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],fe.prototype,"disabled",2),c([u({type:String})],fe.prototype,"showCorrectText",2),c([u({type:String})],fe.prototype,"hideCorrectText",2),c([u({type:String})],fe.prototype,"noCorrectResponseText",2),fe=c([C("item-show-correct-response")],fe);var Kt=class extends b{render(){let r=this.computedContext;if(!r||!r.variables)return f``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>f`
3887
3887
  <h3>${n}</h3>
3888
3888
  <table>
3889
3889
  <thead>
@@ -3930,7 +3930,7 @@ div.full-correct-response-inline {
3930
3930
  margin-top: 20px;
3931
3931
  font-size: 16px;
3932
3932
  }
3933
- `,c([M({context:Be,subscribe:!0})],Kt.prototype,"computedContext",2),Kt=c([C("item-print-variables")],Kt);var K,ti,ri,rs,is,ss,G,_a,La,lo,$a,Oa,co,Zt=class extends b{constructor(){super();T(this,G);T(this,K);this.configContext={};T(this,ti,I(this,G,_a).bind(this));T(this,ri,I(this,G,La).bind(this));T(this,rs,I(this,G,lo).bind(this));T(this,is,I(this,G,$a).bind(this));T(this,ss,I(this,G,Oa).bind(this));this.addEventListener("qti-item-context-updated",x(this,ti)),this.addEventListener("qti-assessment-item-connected",x(this,ri)),this.addEventListener("item-show-correct-response",x(this,rs)),this.addEventListener("item-show-candidate-correction",x(this,is)),this.addEventListener("item-switch-correct-response-mode",x(this,ss))}render(){return f`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",x(this,ti)),this.removeEventListener("qti-assessment-item-connected",x(this,ri))}};K=new WeakMap,ti=new WeakMap,ri=new WeakMap,rs=new WeakMap,is=new WeakMap,ss=new WeakMap,G=new WeakSet,_a=function(e){I(this,G,co).call(this,e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])},La=function(e){let t=e.detail._context.variables;$(this,K,e.detail),this.computedContext=this.computedContext?.identifier===x(this,K).identifier?{...this.computedContext,title:x(this,K).title}:{identifier:x(this,K).identifier,title:x(this,K).title,adaptive:x(this,K).getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},I(this,G,co).call(this,x(this,K).identifier,t||[])},lo=function(e){x(this,K)&&x(this,K).showCorrectResponse(e.detail)},$a=function(e){x(this,K)&&x(this,K).showCandidateCorrection(e.detail)},Oa=function(e){I(this,G,lo).call(this,new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}},co=function(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}},c([w(),ee({context:Be})],Zt.prototype,"computedContext",2),c([w(),ee({context:ae})],Zt.prototype,"configContext",2),Zt=c([C("qti-item")],Zt);var Pa=(o,r,e)=>{class t extends o{}return t};var Se=(o,r,e,t)=>{class i extends Pa(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.dragMoveRaf=0;this.pendingMove=null;this.dragBounds=null;this.dragCloneRect=null;this.dropzoneRects=new Map;this.dropzoneRectsDirty=!1;this.dragBoundsDirty=!1;this.dragCloneStyleCache=new WeakMap;this.onScrollOrResize=()=>{this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0,this.dragBoundsDirty=!0};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.MAX_DRAGGABLE_WIDTH=600;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");this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}}}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));this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}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(){if(super.firstUpdated(),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 l=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),p=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(p,[]),this.droppablesModified(d,[]),this.draggablesModified(l,[]),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(h=>this.resizeObserver?.observe(h))}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;this.dropzoneRectsDirty=!0;let a=this.querySelectorAll(r),l=this.querySelector(t)||this.shadowRoot?.querySelector(t),d=this.querySelectorAll(e),p=d[0]?.parentElement,m=this.determineMaxWidth(l,p),h=0,g=0;for(let v of a){v.style.maxWidth=m+"px";let{width:E,height:A}=await this.measureIntrinsicSize(v);h=Math.max(h,A),g=Math.max(g,E)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${g}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${h}px`);for(let v of d){v.style.minHeight=`${h}px`,v.style.minWidth=`${g}px`;let E=v.shadowRoot?.querySelector('slot[part="dropslot"]');E&&(E.style.minHeight=`${h}px`)}}determineMaxWidth(a,l){let d=l??a;if(!d||d.clientWidth==0)return this.MAX_DRAGGABLE_WIDTH;let p=window.getComputedStyle(d),m=parseFloat(p.paddingLeft),h=parseFloat(p.paddingRight);return Math.min(this.MAX_DRAGGABLE_WIDTH,d.clientWidth-m-h)}async measureIntrinsicSize(a){let l=a.style.position;a.style.position="fixed";let d=a.getBoundingClientRect();return a.style.position=l,{width:d.width,height:d.height}}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),window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a);this.pendingMove={clientX:l,clientY:d},this.scheduleDragMove(),a.preventDefault()}}scheduleDragMove(){this.dragMoveRaf||(this.dragMoveRaf=requestAnimationFrame(()=>{if(this.dragMoveRaf=0,!this.pendingMove)return;let a=this.pendingMove;this.pendingMove=null,this.processDragMove(a),this.pendingMove&&this.scheduleDragMove()}))}processDragMove(a){if(!this.isDraggable||!this.dragClone||!this.touchStartPoint||(this.calculateDragDistance(a)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0),!this.isDragging))return;this.updateDragClonePosition(a),this.dropzoneRectsDirty&&this.refreshDropzoneRects();let l=this.findClosestDropzone();this.currentDropTarget=l,l!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),l&&(this.activateDroppable(l),this.dispatchCustomEvent(l,"dragenter")),this.lastTarget=l),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover")}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 null;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(h=>h.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.dragMoveRaf&&(cancelAnimationFrame(this.dragMoveRaf),this.dragMoveRaf=0),this.pendingMove=null,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.dragBounds=null,this.dragCloneRect=null,this.dropzoneRects.clear(),this.dropzoneRectsDirty=!1,this.dragBoundsDirty=!1,window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize),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(h=>{if(h==="")return;let g=p.find(E=>E.getAttribute("identifier")===h),v=m.find(E=>E.getAttribute("identifier")===l);this.dropDraggableInDroppable(g,v)})}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(h=>h.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(h=>`${h} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,h)=>h.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;(this.dragBoundsDirty||!this.dragBounds)&&this.refreshDragBounds();let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`;let h=this.dragBounds?.width??this.dragCloneRect?.width,g=this.dragBounds?.height??this.dragCloneRect?.height;if(!h||!g){let v=this.dragClone.getBoundingClientRect();h=v.width,g=v.height}this.dragCloneRect={left:p,top:m,right:p+h,bottom:m+g,width:h,height:g}}applyInteractionBoundaries(a,l){if(!this.dragBounds)return{newLeft:a,newTop:l};let d=Math.max(this.dragBounds.minLeft,Math.min(a,this.dragBounds.maxLeft)),p=Math.max(this.dragBounds.minTop,Math.min(l,this.dragBounds.maxTop));return{newLeft:d,newTop:p}}refreshDragBounds(){if(!this.dragClone)return;let a=this.getBoundingClientRect(),l=this.dragClone.getBoundingClientRect();this.dragBounds={minLeft:a.left,maxLeft:a.right-l.width,minTop:a.top,maxTop:a.bottom-l.height,width:l.width,height:l.height},this.dragCloneRect={left:l.left,top:l.top,right:l.left+l.width,bottom:l.top+l.height,width:l.width,height:l.height},this.dragBoundsDirty=!1}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}refreshDropzoneRects(){this.dropzoneRects.clear();let a=this.allDropzones.filter(l=>!l.hasAttribute("disabled"));for(let l of a)this.dropzoneRects.set(l,this.getDropzoneRect(l));this.dropzoneRectsDirty=!1}getCachedDropzoneRect(a){let l=this.dropzoneRects.get(a);if(l)return l;let d=this.getDropzoneRect(a);return this.dropzoneRects.set(a,d),d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(h=>!h.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragCloneRect??this.dragClone.getBoundingClientRect(),d=null,p=0,m=h=>{for(let g of h){let v=this.getCachedDropzoneRect(g),E=this.calculateOverlapArea(l,v);E>p&&(p=E,d=g)}};if(m(this.droppables.filter(h=>!h.hasAttribute("disabled"))),d||m(this.dragContainers.filter(h=>!h.hasAttribute("disabled"))),!d){let h=Number.POSITIVE_INFINITY;for(let g of a){let v=this.getCachedDropzoneRect(g),E=Math.hypot(l.left-v.left,l.top-v.top);E<h&&(h=E,d=g)}}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}getComputedStyleText(a){let l=this.dragCloneStyleCache.get(a);if(l)return l;let d=window.getComputedStyle(a),p="";for(let m=0;m<d.length;m++){let h=d[m];p+=`${h}:${d.getPropertyValue(h)};`}return this.dragCloneStyleCache.set(a,p),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.fullscreenElement??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(A=>Array.from(A.children).some(q=>q===this.dragSource)),h=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-h.left,this.cloneOffset.y=d-h.top,this.dragClone=p.cloneNode(!0),this.configuration.copyStylesDragClone&&(this.dragClone.style.cssText=this.getComputedStyleText(p));let g=p.getBoundingClientRect();this.dragClone.style.width=`${g.width}px`,this.dragClone.style.height=`${g.height}px`,h&&this.setDragCloneStyles(h),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone(),this.refreshDragBounds(),this.refreshDropzoneRects(),window.addEventListener("scroll",this.onScrollOrResize,!0),window.addEventListener("resize",this.onScrollOrResize);let v=this.getMatchMaxValue(this.dragSource),E=this.draggables.filter(A=>A.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&E.length>=v?(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(h=>h.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([_i(t)],i.prototype,"handleDraggableContainerChange",1),c([_i(r)],i.prototype,"handleDraggablesChange",1),c([_i(e)],i.prototype,"handleDroppablesChange",1),i};var Va=y`
3933
+ `,c([k({context:Be,subscribe:!0})],Kt.prototype,"computedContext",2),Kt=c([C("item-print-variables")],Kt);var K,ti,ri,rs,is,ss,G,La,$a,lo,Oa,Pa,co,Zt=class extends b{constructor(){super();T(this,G);T(this,K);this.configContext={};T(this,ti,I(this,G,La).bind(this));T(this,ri,I(this,G,$a).bind(this));T(this,rs,I(this,G,lo).bind(this));T(this,is,I(this,G,Oa).bind(this));T(this,ss,I(this,G,Pa).bind(this));this.addEventListener("qti-item-context-updated",x(this,ti)),this.addEventListener("qti-assessment-item-connected",x(this,ri)),this.addEventListener("item-show-correct-response",x(this,rs)),this.addEventListener("item-show-candidate-correction",x(this,is)),this.addEventListener("item-switch-correct-response-mode",x(this,ss))}render(){return f`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",x(this,ti)),this.removeEventListener("qti-assessment-item-connected",x(this,ri))}};K=new WeakMap,ti=new WeakMap,ri=new WeakMap,rs=new WeakMap,is=new WeakMap,ss=new WeakMap,G=new WeakSet,La=function(e){I(this,G,co).call(this,e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])},$a=function(e){let t=e.detail._context.variables;$(this,K,e.detail),this.computedContext=this.computedContext?.identifier===x(this,K).identifier?{...this.computedContext,title:x(this,K).title}:{identifier:x(this,K).identifier,title:x(this,K).title,adaptive:x(this,K).getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},I(this,G,co).call(this,x(this,K).identifier,t||[])},lo=function(e){x(this,K)&&x(this,K).showCorrectResponse(e.detail)},Oa=function(e){x(this,K)&&x(this,K).showCandidateCorrection(e.detail)},Pa=function(e){I(this,G,lo).call(this,new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}},co=function(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}},c([w(),ee({context:Be})],Zt.prototype,"computedContext",2),c([w(),ee({context:le})],Zt.prototype,"configContext",2),Zt=c([C("qti-item")],Zt);var Va=(o,r,e)=>{class t extends o{}return t};var Se=(o,r,e,t)=>{class i extends Va(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.dragMoveRaf=0;this.pendingMove=null;this.dragBounds=null;this.dragCloneRect=null;this.dropzoneRects=new Map;this.dropzoneRectsDirty=!1;this.dragBoundsDirty=!1;this.dragCloneStyleCache=new WeakMap;this.onScrollOrResize=()=>{this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0,this.dragBoundsDirty=!0};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.MAX_DRAGGABLE_WIDTH=600;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");this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}}}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));this.dropzoneRectsDirty=!0,this.dragBoundsDirty=!0}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(){if(super.firstUpdated(),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 l=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),p=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(p,[]),this.droppablesModified(d,[]),this.draggablesModified(l,[]),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(h=>this.resizeObserver?.observe(h))}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;this.dropzoneRectsDirty=!0;let a=this.querySelectorAll(r),l=this.querySelector(t)||this.shadowRoot?.querySelector(t),d=this.querySelectorAll(e),p=d[0]?.parentElement,m=this.determineMaxWidth(l,p),h=0,g=0;for(let v of a){v.style.maxWidth=m+"px";let{width:E,height:A}=await this.measureIntrinsicSize(v);h=Math.max(h,A),g=Math.max(g,E)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${g}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${h}px`);for(let v of d){v.style.minHeight=`${h}px`,v.style.minWidth=`${g}px`;let E=v.shadowRoot?.querySelector('slot[part="dropslot"]');E&&(E.style.minHeight=`${h}px`)}}determineMaxWidth(a,l){let d=l??a;if(!d||d.clientWidth==0)return this.MAX_DRAGGABLE_WIDTH;let p=window.getComputedStyle(d),m=parseFloat(p.paddingLeft),h=parseFloat(p.paddingRight);return Math.min(this.MAX_DRAGGABLE_WIDTH,d.clientWidth-m-h)}async measureIntrinsicSize(a){let l=a.style.position;a.style.position="fixed";let d=a.getBoundingClientRect();return a.style.position=l,{width:d.width,height:d.height}}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),window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a);this.pendingMove={clientX:l,clientY:d},this.scheduleDragMove(),a.preventDefault()}}scheduleDragMove(){this.dragMoveRaf||(this.dragMoveRaf=requestAnimationFrame(()=>{if(this.dragMoveRaf=0,!this.pendingMove)return;let a=this.pendingMove;this.pendingMove=null,this.processDragMove(a),this.pendingMove&&this.scheduleDragMove()}))}processDragMove(a){if(!this.isDraggable||!this.dragClone||!this.touchStartPoint||(this.calculateDragDistance(a)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0),!this.isDragging))return;this.updateDragClonePosition(a),this.dropzoneRectsDirty&&this.refreshDropzoneRects();let l=this.findClosestDropzone();this.currentDropTarget=l,l!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),l&&(this.activateDroppable(l),this.dispatchCustomEvent(l,"dragenter")),this.lastTarget=l),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover")}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 null;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(h=>h.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.dragMoveRaf&&(cancelAnimationFrame(this.dragMoveRaf),this.dragMoveRaf=0),this.pendingMove=null,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.dragBounds=null,this.dragCloneRect=null,this.dropzoneRects.clear(),this.dropzoneRectsDirty=!1,this.dragBoundsDirty=!1,window.removeEventListener("scroll",this.onScrollOrResize,!0),window.removeEventListener("resize",this.onScrollOrResize),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(h=>{if(h==="")return;let g=p.find(E=>E.getAttribute("identifier")===h),v=m.find(E=>E.getAttribute("identifier")===l);this.dropDraggableInDroppable(g,v)})}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(h=>h.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(h=>`${h} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,h)=>h.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;(this.dragBoundsDirty||!this.dragBounds)&&this.refreshDragBounds();let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`;let h=this.dragBounds?.width??this.dragCloneRect?.width,g=this.dragBounds?.height??this.dragCloneRect?.height;if(!h||!g){let v=this.dragClone.getBoundingClientRect();h=v.width,g=v.height}this.dragCloneRect={left:p,top:m,right:p+h,bottom:m+g,width:h,height:g}}applyInteractionBoundaries(a,l){if(!this.dragBounds)return{newLeft:a,newTop:l};let d=Math.max(this.dragBounds.minLeft,Math.min(a,this.dragBounds.maxLeft)),p=Math.max(this.dragBounds.minTop,Math.min(l,this.dragBounds.maxTop));return{newLeft:d,newTop:p}}refreshDragBounds(){if(!this.dragClone)return;let a=this.getBoundingClientRect(),l=this.dragClone.getBoundingClientRect();this.dragBounds={minLeft:a.left,maxLeft:a.right-l.width,minTop:a.top,maxTop:a.bottom-l.height,width:l.width,height:l.height},this.dragCloneRect={left:l.left,top:l.top,right:l.left+l.width,bottom:l.top+l.height,width:l.width,height:l.height},this.dragBoundsDirty=!1}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}refreshDropzoneRects(){this.dropzoneRects.clear();let a=this.allDropzones.filter(l=>!l.hasAttribute("disabled"));for(let l of a)this.dropzoneRects.set(l,this.getDropzoneRect(l));this.dropzoneRectsDirty=!1}getCachedDropzoneRect(a){let l=this.dropzoneRects.get(a);if(l)return l;let d=this.getDropzoneRect(a);return this.dropzoneRects.set(a,d),d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(h=>!h.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragCloneRect??this.dragClone.getBoundingClientRect(),d=null,p=0,m=h=>{for(let g of h){let v=this.getCachedDropzoneRect(g),E=this.calculateOverlapArea(l,v);E>p&&(p=E,d=g)}};if(m(this.droppables.filter(h=>!h.hasAttribute("disabled"))),d||m(this.dragContainers.filter(h=>!h.hasAttribute("disabled"))),!d){let h=Number.POSITIVE_INFINITY;for(let g of a){let v=this.getCachedDropzoneRect(g),E=Math.hypot(l.left-v.left,l.top-v.top);E<h&&(h=E,d=g)}}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}getComputedStyleText(a){let l=this.dragCloneStyleCache.get(a);if(l)return l;let d=window.getComputedStyle(a),p="";for(let m=0;m<d.length;m++){let h=d[m];p+=`${h}:${d.getPropertyValue(h)};`}return this.dragCloneStyleCache.set(a,p),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.fullscreenElement??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(A=>Array.from(A.children).some(q=>q===this.dragSource)),h=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-h.left,this.cloneOffset.y=d-h.top,this.dragClone=p.cloneNode(!0),this.configuration.copyStylesDragClone&&(this.dragClone.style.cssText=this.getComputedStyleText(p));let g=p.getBoundingClientRect();this.dragClone.style.width=`${g.width}px`,this.dragClone.style.height=`${g.height}px`,h&&this.setDragCloneStyles(h),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone(),this.refreshDragBounds(),this.refreshDropzoneRects(),window.addEventListener("scroll",this.onScrollOrResize,!0),window.addEventListener("resize",this.onScrollOrResize);let v=this.getMatchMaxValue(this.dragSource),E=this.draggables.filter(A=>A.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));v!==0&&E.length>=v?(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(h=>h.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([_i(t)],i.prototype,"handleDraggableContainerChange",1),c([_i(r)],i.prototype,"handleDraggablesChange",1),c([_i(e)],i.prototype,"handleDroppablesChange",1),i};var Na=y`
3934
3934
  :host {
3935
3935
  display: block; /* necessary to calculate scaling position */
3936
3936
  }
@@ -3969,7 +3969,7 @@ div.full-correct-response-inline {
3969
3969
  rgb(0 0 0 / 0%) calc(50% + 1px)
3970
3970
  );
3971
3971
  }
3972
- `;var ii=class extends Se(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)}static{this.styles=Va}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return f` <slot name="prompt"></slot>
3972
+ `;var ii=class extends Se(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)}static{this.styles=Na}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return f` <slot name="prompt"></slot>
3973
3973
  <slot name="qti-simple-associable-choice"></slot>
3974
3974
  <div part="drop-container">
3975
3975
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>f`<div part="associables-container">
@@ -3978,7 +3978,7 @@ div.full-correct-response-inline {
3978
3978
  </div>`)}
3979
3979
 
3980
3980
  <div role="alert" part="message" id="validation-message"></div>
3981
- </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};c([w()],ii.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ii);var Ze=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this._mutationObserver=null;this._validationMessageShown=!1;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.correctResponse;if(n){let a=Array.isArray(n)?n:[n];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.correctResponse;if(!n)return;let a=Array.isArray(n)?n:[n],l=this.response,d=Array.isArray(l)?l:l?[l]:[];this._choiceElements.forEach(p=>{p.internals.states.delete("candidate-correct"),p.internals.states.delete("candidate-incorrect"),s&&d.includes(p.identifier)&&(a.includes(p.identifier)?p.internals.states.add("candidate-correct"):p.internals.states.add("candidate-incorrect"))}),super.toggleCandidateCorrection(s)}connectedCallback(){super.connectedCallback(),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver=new MutationObserver(()=>this._syncChoicesFromDOM()),this._mutationObserver.observe(this,{childList:!0,subtree:!0}),this._syncChoicesFromDOM()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_syncChoicesFromDOM(){let s=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(r)),this._choiceElements.forEach(a=>{s.has(a)||(this.disabled&&(a.disabled=!0),a.readonly=this.readonly,a.internals&&!a.internals.ariaChecked&&(a.internals.ariaChecked="false"),this._setInputType(a))});let n=new Set(this._choiceElements.map(a=>a.identifier));if(Array.isArray(this.response)){let a=this.response.filter(l=>n.has(l));a.length!==this.response.length&&(this.response=a)}else this.response&&!n.has(this.response)&&(this.response="");this._updateChoiceSelection()}validate(){let n=this._choiceElements.filter(p=>this._getChoiceChecked(p)).length,a=!0,l="";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"}.`);let d=this._choiceElements.find(p=>this.contains(p))||this;return this._internals.setValidity(a?{}:{customError:!0},l,d),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._validationMessageShown=!0)),this._internals.validity.valid}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}async _setInputType(s){if(this._internals.role=this.maxChoices===1?"radiogroup":null,s.internals){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.maxChoices!==0&&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._validationMessageShown&&(this.reportValidity(),this._internals.validity.valid&&(this._validationMessageShown=!1)),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([Tt("#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([O("maxChoices")],e.prototype,"_handleMaxChoicesChange",1),c([O("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([O("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([w()],e.prototype,"response",2),c([O("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([w(),M({context:ae,subscribe:!0})],e.prototype,"_configContext",2),e};var Na=(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"];this._mutationObserver=null}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}connectedCallback(){super.connectedCallback(),this._mutationObserver=new MutationObserver(()=>this._addLabels()),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this._mutationObserver?.disconnect(),this._mutationObserver=null}_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})],e.prototype,"class",1),e};var Da=y`
3981
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};c([w()],ii.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ii);var Ze=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this._mutationObserver=null;this._validationMessageShown=!1;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.correctResponse;if(n){let a=Array.isArray(n)?n:[n];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.correctResponse;if(!n)return;let a=Array.isArray(n)?n:[n],l=this.response,d=Array.isArray(l)?l:l?[l]:[];this._choiceElements.forEach(p=>{p.internals.states.delete("candidate-correct"),p.internals.states.delete("candidate-incorrect"),s&&d.includes(p.identifier)&&(a.includes(p.identifier)?p.internals.states.add("candidate-correct"):p.internals.states.add("candidate-incorrect"))}),super.toggleCandidateCorrection(s)}connectedCallback(){super.connectedCallback(),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver=new MutationObserver(()=>this._syncChoicesFromDOM()),this._mutationObserver.observe(this,{childList:!0,subtree:!0}),this._syncChoicesFromDOM()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_syncChoicesFromDOM(){let s=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(r)),this._choiceElements.forEach(a=>{s.has(a)||(this.disabled&&(a.disabled=!0),a.readonly=this.readonly,a.internals&&!a.internals.ariaChecked&&(a.internals.ariaChecked="false"),this._setInputType(a))});let n=new Set(this._choiceElements.map(a=>a.identifier));if(Array.isArray(this.response)){let a=this.response.filter(l=>n.has(l));a.length!==this.response.length&&(this.response=a)}else this.response&&!n.has(this.response)&&(this.response="");this._updateChoiceSelection()}validate(){let n=this._choiceElements.filter(p=>this._getChoiceChecked(p)).length,a=!0,l="";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"}.`);let d=this._choiceElements.find(p=>this.contains(p))||this;return this._internals.setValidity(a?{}:{customError:!0},l,d),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._validationMessageShown=!0)),this._internals.validity.valid}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}async _setInputType(s){if(this._internals.role=this.maxChoices===1?"radiogroup":null,s.internals){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.maxChoices!==0&&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._validationMessageShown&&(this.reportValidity(),this._internals.validity.valid&&(this._validationMessageShown=!1)),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([Tt("#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([O("maxChoices")],e.prototype,"_handleMaxChoicesChange",1),c([O("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([O("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([w()],e.prototype,"response",2),c([O("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([w(),k({context:le,subscribe:!0})],e.prototype,"_configContext",2),e};var Da=(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"];this._mutationObserver=null}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}connectedCallback(){super.connectedCallback(),this._mutationObserver=new MutationObserver(()=>this._addLabels()),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this._mutationObserver?.disconnect(),this._mutationObserver=null}_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})],e.prototype,"class",1),e};var Ha=y`
3982
3982
  :host {
3983
3983
  display: block;
3984
3984
  }
@@ -4048,7 +4048,7 @@ div.full-correct-response-inline {
4048
4048
  :host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
4049
4049
  grid-row: auto;
4050
4050
  }
4051
- `;var si=class extends Na(Ze(R,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}static{this.styles=Da}#e(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return f`
4051
+ `;var si=class extends Da(Ze(R,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}static{this.styles=Ha}#e(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return f`
4052
4052
  <slot part="prompt" name="prompt"></slot>
4053
4053
  <slot part="slot" @slotchange=${this.#e}></slot>
4054
4054
  <div part="message" role="alert" id="validation-message"></div>
@@ -4119,7 +4119,7 @@ window.CES = {
4119
4119
  },
4120
4120
  };
4121
4121
  CES.load();
4122
- `,Jl=`
4122
+ `,Kl=`
4123
4123
  (function() {
4124
4124
  var blobUrlReceived = null;
4125
4125
 
@@ -4163,7 +4163,7 @@ CES.load();
4163
4163
  requestBlobUrl();
4164
4164
  }
4165
4165
  })();
4166
- `,Ve=class extends R{constructor(){super();this.#e="";this.#t=null;this.#r=null;this._errorMessage=null;this.#i=null;this.handlePostMessage=this.handlePostMessage.bind(this)}#e;#t;#r;#i;connectedCallback(){super.connectedCallback();let e=this.data;if(!e){let i=this.querySelector("object[data]");if(i){e=i.getAttribute("data");let s=i.getAttribute("width"),n=i.getAttribute("height");s&&this.setAttribute("width",s),n&&this.setAttribute("height",n)}}if(!e){this._errorMessage="No manifest path found (neither data attribute nor object child)";return}let t=e.startsWith("http")||e.startsWith("blob")?e:Oi((this.baseItemUrl||"")+"/"+e);this.#t=new URL(t,window.location.href).toString(),fetch(t).then(i=>i.json()).then(i=>{this.manifest=i,this.setupCES()}).catch(i=>{this._errorMessage=i})}async setupCES(){await this.updateComplete;let e=this.shadowRoot?.querySelector("#pciContainer");if(!e){this._errorMessage="pciContainer iframe not found";return}e.getAttribute("src")||e.setAttribute("src","about:blank");let t=e.contentDocument??e.contentWindow?.document??null;if(t||(await new Promise(m=>e.addEventListener("load",()=>m(),{once:!0})),t=e.contentDocument??e.contentWindow?.document??null),!t){this._errorMessage="pciContainer iframe document not available";return}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=this.#a(),n=await this.#l(i,s),a=n.url;if(n.baseUrl&&!this.#r&&(this.#r=n.baseUrl),!0){let m="";if(this.manifest.media&&this.manifest.media.length>0){let h=this.manifest.media[0],g=await this.#l(h,s,{returnText:!0});if(m=g.url,g.baseUrl&&!this.#r&&(this.#r=g.baseUrl),g.text){let v=g.text;if(!(v.includes("postToParentWindows")||v.includes("window.CES"))){let q="<script>"+po+"</script>",k=v.indexOf("<head>");k!==-1?v=v.slice(0,k+6)+q+v.slice(k+6):v=q+v}let A=new Blob([v],{type:"text/html"});this.#i=URL.createObjectURL(A)}}else{let h=this.data||"manifest.json",g=h.includes("/")?h.substring(0,h.lastIndexOf("/")):"",v=g?`${g}/index.html`:"index.html",E=await this.#l(v,s,{returnText:!0});if(m=E.url,E.baseUrl&&!this.#r&&(this.#r=E.baseUrl),E.text){let A=E.text;if(!(A.includes("postToParentWindows")||A.includes("window.CES"))){let P="<script>"+po+"</script>",H=A.indexOf("<head>");H!==-1?A=A.slice(0,H+6)+P+A.slice(H+6):A=P+A}let k=new Blob([A],{type:"text/html"});this.#i=URL.createObjectURL(k)}}if(m&&!this.#i)try{let h=await fetch(m);if(h.ok){let g=await h.text();if(!(g.includes("postToParentWindows")||g.includes("window.CES"))){let A="<script>"+po+"</script>",q=g.indexOf("<head>");q!==-1?g=g.slice(0,q+6)+A+g.slice(q+6):g=A+g}let E=new Blob([g],{type:"text/html"});this.#i=URL.createObjectURL(E)}else console.error(`Failed to fetch index.html: ${h.status}`)}catch(h){console.error(`Error fetching index.html: ${h}`)}}let d=`<script>${Jl}</script>`;window.addEventListener("message",this.handlePostMessage);let p=`
4166
+ `,Ve=class extends R{constructor(){super();this.#e="";this.#t=null;this.#i=null;this._errorMessage=null;this.#r=null;this.handlePostMessage=this.handlePostMessage.bind(this)}#e;#t;#i;#r;connectedCallback(){super.connectedCallback();let e=this.data;if(!e){let i=this.querySelector("object[data]");if(i){e=i.getAttribute("data");let s=i.getAttribute("width"),n=i.getAttribute("height");s&&this.setAttribute("width",s),n&&this.setAttribute("height",n)}}if(!e){this._errorMessage="No manifest path found (neither data attribute nor object child)";return}let t=e.startsWith("http")||e.startsWith("blob")?e:Oi((this.baseItemUrl||"")+"/"+e);this.#t=new URL(t,window.location.href).toString(),fetch(t).then(i=>i.json()).then(i=>{this.manifest=i,this.setupCES()}).catch(i=>{this._errorMessage=i})}async setupCES(){await this.updateComplete;let e=this.shadowRoot?.querySelector("#pciContainer");if(!e){this._errorMessage="pciContainer iframe not found";return}e.getAttribute("src")||e.setAttribute("src","about:blank");let t=e.contentDocument??e.contentWindow?.document??null;if(t||(await new Promise(m=>e.addEventListener("load",()=>m(),{once:!0})),t=e.contentDocument??e.contentWindow?.document??null),!t){this._errorMessage="pciContainer iframe document not available";return}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=this.#a(),n=await this.#l(i,s),a=n.url;if(n.baseUrl&&!this.#i&&(this.#i=n.baseUrl),!0){let m="";if(this.manifest.media&&this.manifest.media.length>0){let h=this.manifest.media[0],g=await this.#l(h,s,{returnText:!0});if(m=g.url,g.baseUrl&&!this.#i&&(this.#i=g.baseUrl),g.text){let v=g.text;if(!(v.includes("postToParentWindows")||v.includes("window.CES"))){let q="<script>"+po+"</script>",M=v.indexOf("<head>");M!==-1?v=v.slice(0,M+6)+q+v.slice(M+6):v=q+v}let A=new Blob([v],{type:"text/html"});this.#r=URL.createObjectURL(A)}}else{let h=this.data||"manifest.json",g=h.includes("/")?h.substring(0,h.lastIndexOf("/")):"",v=g?`${g}/index.html`:"index.html",E=await this.#l(v,s,{returnText:!0});if(m=E.url,E.baseUrl&&!this.#i&&(this.#i=E.baseUrl),E.text){let A=E.text;if(!(A.includes("postToParentWindows")||A.includes("window.CES"))){let P="<script>"+po+"</script>",H=A.indexOf("<head>");H!==-1?A=A.slice(0,H+6)+P+A.slice(H+6):A=P+A}let M=new Blob([A],{type:"text/html"});this.#r=URL.createObjectURL(M)}}if(m&&!this.#r)try{let h=await fetch(m);if(h.ok){let g=await h.text();if(!(g.includes("postToParentWindows")||g.includes("window.CES"))){let A="<script>"+po+"</script>",q=g.indexOf("<head>");q!==-1?g=g.slice(0,q+6)+A+g.slice(q+6):g=A+g}let E=new Blob([g],{type:"text/html"});this.#r=URL.createObjectURL(E)}else console.error(`Failed to fetch index.html: ${h.status}`)}catch(h){console.error(`Error fetching index.html: ${h}`)}}let d=`<script>${Kl}</script>`;window.addEventListener("message",this.handlePostMessage);let p=`
4167
4167
  <!DOCTYPE html>
4168
4168
  <html>
4169
4169
  <head>
@@ -4172,7 +4172,7 @@ CES.load();
4172
4172
  </head>
4173
4173
  <body></body>
4174
4174
  </html>
4175
- `;e.srcdoc=p}#s(){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.#o(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}#o(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.#o(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}#n(e,t){window.postMessage({type:e,data:t},"*");let i=this.#s();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.#e=i,this.saveResponse(i));break;case"getResponse":{this.#n("responseData",this.#e);break}case"getBlobUrl":{this.#i&&(this.#n("blobUrl",this.#i),e.source&&e.source!==window&&e.source.postMessage({type:"blobUrl",data:this.#i},"*"));break}case"getMedia":{let s=this.#a(),n=this.manifest.media.map(a=>{if(a.startsWith("http")||a.startsWith("blob"))return a;let l=this.#r||s[0];return l?new URL(a,l.endsWith("/")?l:`${l}/`).toString():a});this.#n("mediaData",n);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.#e)return!1;if(Array.isArray(this.#e)){if(this.#e.length===0)return!1;for(let e of this.#e)if(e!==""&&e!==null)return!0}return!0}get response(){return this.#e||null}set response(e){if(typeof e=="string")this.#e=e,this.saveResponse(e);else if(Array.isArray(e))this.#e=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 f`<iframe
4175
+ `;e.srcdoc=p}#s(){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.#o(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}#o(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.#o(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}#n(e,t){window.postMessage({type:e,data:t},"*");let i=this.#s();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.#e=i,this.saveResponse(i));break;case"getResponse":{this.#n("responseData",this.#e);break}case"getBlobUrl":{this.#r&&(this.#n("blobUrl",this.#r),e.source&&e.source!==window&&e.source.postMessage({type:"blobUrl",data:this.#r},"*"));break}case"getMedia":{let s=this.#a(),n=this.manifest.media.map(a=>{if(a.startsWith("http")||a.startsWith("blob"))return a;let l=this.#i||s[0];return l?new URL(a,l.endsWith("/")?l:`${l}/`).toString():a});this.#n("mediaData",n);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.#e)return!1;if(Array.isArray(this.#e)){if(this.#e.length===0)return!1;for(let e of this.#e)if(e!==""&&e!==null)return!0}return!0}get response(){return this.#e||null}set response(e){if(typeof e=="string")this.#e=e,this.saveResponse(e);else if(Array.isArray(e))this.#e=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 f`<iframe
4176
4176
  width=${this.getAttribute("width")}
4177
4177
  height=${this.getAttribute("height")}
4178
4178
  frameborder="0"
@@ -4183,7 +4183,7 @@ CES.load();
4183
4183
  ${this._errorMessage&&f`<div style="color:red">
4184
4184
  <h1>Error</h1>
4185
4185
  ${this._errorMessage}
4186
- </div>`}`}#a(){let t=[this.#r,this.baseRefUrl,this.baseItemUrl,this.#u()].filter(Boolean).map(s=>new URL(s,window.location.href).toString()),i=this.#p();return i&&t.push(i),[...new Set(t)]}#u(){return this.#t?new URL(".",this.#t).toString():null}#p(){return this.#t?new URL("..",this.#t).toString():null}async#l(e,t,i={}){if(!e)return{url:"",baseUrl:null};if(e.startsWith("http")||e.startsWith("blob"))return{url:e,baseUrl:null};for(let s of t){let n=new URL(s,window.location.href).toString(),a=new URL(e,n.endsWith("/")?n:`${n}/`).toString();try{let l=await fetch(a);if(l.ok){if(i.returnText){let d=await l.text();return{url:a,baseUrl:n,text:d}}return{url:a,baseUrl:n}}}catch{}}return{url:"",baseUrl:null}}};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([w()],Ve.prototype,"_errorMessage",2);customElements.define("qti-custom-interaction",Ve);var et=class extends b{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return f`<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"})],et.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],et.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],et.prototype,"countAttempt",2),c([u({type:String})],et.prototype,"title",2);customElements.define("qti-end-attempt-interaction",et);var Ha=y`
4186
+ </div>`}`}#a(){let t=[this.#i,this.baseRefUrl,this.baseItemUrl,this.#p()].filter(Boolean).map(s=>new URL(s,window.location.href).toString()),i=this.#u();return i&&t.push(i),[...new Set(t)]}#p(){return this.#t?new URL(".",this.#t).toString():null}#u(){return this.#t?new URL("..",this.#t).toString():null}async#l(e,t,i={}){if(!e)return{url:"",baseUrl:null};if(e.startsWith("http")||e.startsWith("blob"))return{url:e,baseUrl:null};for(let s of t){let n=new URL(s,window.location.href).toString(),a=new URL(e,n.endsWith("/")?n:`${n}/`).toString();try{let l=await fetch(a);if(l.ok){if(i.returnText){let d=await l.text();return{url:a,baseUrl:n,text:d}}return{url:a,baseUrl:n}}}catch{}}return{url:"",baseUrl:null}}};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([w()],Ve.prototype,"_errorMessage",2);customElements.define("qti-custom-interaction",Ve);var et=class extends b{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return f`<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"})],et.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],et.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],et.prototype,"countAttempt",2),c([u({type:String})],et.prototype,"title",2);customElements.define("qti-end-attempt-interaction",et);var za=y`
4187
4187
  /* PK: display host as block, else design will be collapsed */
4188
4188
  :host {
4189
4189
  display: block;
@@ -4194,7 +4194,7 @@ CES.load();
4194
4194
  height: 100%;
4195
4195
  border: 0;
4196
4196
  }
4197
- `;var ne=class extends R{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=Ha}handleclassNamesChange(e,t){let i=t.split(" "),s=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return f`<slot name="prompt"></slot
4197
+ `;var ae=class extends R{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=za}handleclassNamesChange(e,t){let i=t.split(" "),s=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return f`<slot name="prompt"></slot
4198
4198
  ><textarea
4199
4199
  part="textarea"
4200
4200
  name="${this.responseIdentifier}"
@@ -4210,7 +4210,7 @@ CES.load();
4210
4210
  ?disabled="${this.disabled}"
4211
4211
  ?readonly="${this.readonly}"
4212
4212
  .value=${this.response}
4213
- ></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")}};c([w()],ne.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],ne.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],ne.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],ne.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],ne.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],ne.prototype,"classNames",2),c([O("classNames")],ne.prototype,"handleclassNamesChange",1),c([w()],ne.prototype,"response",2),c([O("response",{waitUntilFirstUpdate:!0})],ne.prototype,"_handleResponseChange",2);customElements.define("qti-extended-text-interaction",ne);var za=y`
4213
+ ></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")}};c([w()],ae.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],ae.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],ae.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],ae.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],ae.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],ae.prototype,"classNames",2),c([O("classNames")],ae.prototype,"handleclassNamesChange",1),c([w()],ae.prototype,"response",2),c([O("response",{waitUntilFirstUpdate:!0})],ae.prototype,"_handleResponseChange",2);customElements.define("qti-extended-text-interaction",ae);var Ua=y`
4214
4214
  :host {
4215
4215
  display: flex;
4216
4216
  align-items: flex-start;
@@ -4244,10 +4244,10 @@ CES.load();
4244
4244
  border-radius: 0.3rem;
4245
4245
  gap: 0.5rem;
4246
4246
  }
4247
- `;var os=class extends Se(R,"qti-gap-text","qti-gap","slot[part='drags']"){static{this.styles=za}render(){return f`<slot name="prompt"> </slot>
4247
+ `;var os=class extends Se(R,"qti-gap-text","qti-gap","slot[part='drags']"){static{this.styles=Ua}render(){return f`<slot name="prompt"> </slot>
4248
4248
  <slot part="drags" name="drags"></slot>
4249
4249
  <slot part="drops"></slot>
4250
- <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()})}#e(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let s=i.split(" ");t.push({source:s[0],target:s[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.#e(e);Array.from(this.querySelectorAll("qti-gap")).forEach(s=>{let n=s.getAttribute("identifier"),a=t.filter(d=>d.target===n);s.querySelectorAll("qti-gap-text").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!r)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}};customElements.define("qti-gap-match-interaction",os);var Ua=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},er=te(class extends xe{constructor(o){if(super(o),o.type!==je.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=In(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,h=i.length-1,g=0,v=s.length-1;for(;m<=h&&g<=v;)if(i[m]===null)m++;else if(i[h]===null)h--;else if(a[m]===n[g])l[g]=We(i[m],s[g]),m++,g++;else if(a[h]===n[v])l[v]=We(i[h],s[v]),h--,v--;else if(a[m]===n[v])l[v]=We(i[m],s[v]),$t(o,l[v+1],i[m]),m++,v--;else if(a[h]===n[g])l[g]=We(i[h],s[g]),$t(o,i[m],i[h]),h--,g++;else if(d===void 0&&(d=Ua(n,g,v),p=Ua(a,m,h)),d.has(a[m]))if(d.has(a[h])){let E=p.get(n[g]),A=E!==void 0?i[E]:null;if(A===null){let q=$t(o,i[m]);We(q,s[g]),l[g]=q}else l[g]=We(A,s[g]),$t(o,i[m],A),i[E]=null;g++}else Li(i[h]),h--;else Li(i[m]),m++;for(;g<=v;){let E=$t(o,l[v+1]);We(E,s[g]),l[g++]=E}for(;m<=h;){let E=i[m++];E!==null&&Li(E)}return this.ut=n,kn(o,l),z}});function tt(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,h=l/s*100;t.style.left=d-m+"%",t.style.top=p-h+"%",t.style.width=2*m+"%",t.style.height=2*h+"%",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,h=l/i*100,g=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=h-p+"%",t.style.height=g-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,h=l/i*100,g=d/s*100;t.style.left=p-h+"%",t.style.top=m-g+"%",t.style.width=2*h+"%",t.style.height=2*g+"%",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,h=d/s*100,g=l/i*100,v=p/s*100;t.style.left=m+"%",t.style.top=h+"%",t.style.width=g-m+"%",t.style.height=v-h+"%";let A=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(${A})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var Ba=y`
4250
+ <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()})}#e(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let s=i.split(" ");t.push({source:s[0],target:s[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.#e(e);Array.from(this.querySelectorAll("qti-gap")).forEach(s=>{let n=s.getAttribute("identifier"),a=t.filter(d=>d.target===n);s.querySelectorAll("qti-gap-text").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!r)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}};customElements.define("qti-gap-match-interaction",os);var Ba=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},er=te(class extends xe{constructor(o){if(super(o),o.type!==je.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=In(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,h=i.length-1,g=0,v=s.length-1;for(;m<=h&&g<=v;)if(i[m]===null)m++;else if(i[h]===null)h--;else if(a[m]===n[g])l[g]=We(i[m],s[g]),m++,g++;else if(a[h]===n[v])l[v]=We(i[h],s[v]),h--,v--;else if(a[m]===n[v])l[v]=We(i[m],s[v]),$t(o,l[v+1],i[m]),m++,v--;else if(a[h]===n[g])l[g]=We(i[h],s[g]),$t(o,i[m],i[h]),h--,g++;else if(d===void 0&&(d=Ba(n,g,v),p=Ba(a,m,h)),d.has(a[m]))if(d.has(a[h])){let E=p.get(n[g]),A=E!==void 0?i[E]:null;if(A===null){let q=$t(o,i[m]);We(q,s[g]),l[g]=q}else l[g]=We(A,s[g]),$t(o,i[m],A),i[E]=null;g++}else Li(i[h]),h--;else Li(i[m]),m++;for(;g<=v;){let E=$t(o,l[v+1]);We(E,s[g]),l[g++]=E}for(;m<=h;){let E=i[m++];E!==null&&Li(E)}return this.ut=n,Mn(o,l),z}});function tt(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,h=l/s*100;t.style.left=d-m+"%",t.style.top=p-h+"%",t.style.width=2*m+"%",t.style.height=2*h+"%",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,h=l/i*100,g=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=h-p+"%",t.style.height=g-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,h=l/i*100,g=d/s*100;t.style.left=p-h+"%",t.style.top=m-g+"%",t.style.width=2*h+"%",t.style.height=2*g+"%",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,h=d/s*100,g=l/i*100,v=p/s*100;t.style.left=m+"%",t.style.top=h+"%",t.style.width=g-m+"%",t.style.height=v-h+"%";let A=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(${A})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var Fa=y`
4251
4251
  slot:not([name='prompt']) {
4252
4252
  // position: relative; /* qti-hotspot-choice relative to the slot */
4253
4253
  display: block;
@@ -4271,7 +4271,7 @@ CES.load();
4271
4271
  top: 0px;
4272
4272
  left: 0px;
4273
4273
  }
4274
- `;var Ne=class extends R{constructor(){super();this.#t=null;this.#r=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.#o)}static{this.styles=Ba}#e;#t;#r;reset(){this._response=[],this._correctLines=[]}validate(){return this.#s().length>0}set response(e){this._response=this.#i(e)}get response(){return this._response}#i(e){return e==null||e===""?[]:Array.isArray(e)?e:[e]}#s(){return this.#i(this._response)}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return f`<slot name="prompt"></slot>
4274
+ `;var Ne=class extends R{constructor(){super();this.#t=null;this.#i=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.#o)}static{this.styles=Fa}#e;#t;#i;reset(){this._response=[],this._correctLines=[]}validate(){return this.#s().length>0}set response(e){this._response=this.#r(e)}get response(){return this._response}#r(e){return e==null||e===""?[]:Array.isArray(e)?e:[e]}#s(){return this.#r(this._response)}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return f`<slot name="prompt"></slot>
4275
4275
  <line-container>
4276
4276
  <svg
4277
4277
  width=${qe(this.grImage[0]?.width)}
@@ -4314,7 +4314,7 @@ CES.load();
4314
4314
  </svg>
4315
4315
  <slot></slot>
4316
4316
  </line-container>
4317
- <div role="alert" part="message" id="validation-message"></div>`}#o(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));tt(n,a,t,i)}firstUpdated(){this.#e=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.#e.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.#t?this.#r||(this.#r=t.target,this._response=this.#s(),this._response=[...this._response,`${this.#t.getAttribute("identifier")} ${this.#r.getAttribute("identifier")}`],this.saveResponse(this.response),this.#t=null,this.#r=null):(this.#t=t.target,this.startCoord={x:parseInt(this.#t.getAttribute("coords").split(",")[0]),y:parseInt(this.#t.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#o)}};c([w()],Ne.prototype,"_correctLines",2),c([w()],Ne.prototype,"startCoord",2),c([w()],Ne.prototype,"mouseCoord",2),c([mn({selector:"img"})],Ne.prototype,"grImage",2),c([w()],Ne.prototype,"_response",2);customElements.define("qti-graphic-associate-interaction",Ne);var Fa=y`
4317
+ <div role="alert" part="message" id="validation-message"></div>`}#o(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));tt(n,a,t,i)}firstUpdated(){this.#e=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.#e.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.#t?this.#i||(this.#i=t.target,this._response=this.#s(),this._response=[...this._response,`${this.#t.getAttribute("identifier")} ${this.#i.getAttribute("identifier")}`],this.saveResponse(this.response),this.#t=null,this.#i=null):(this.#t=t.target,this.startCoord={x:parseInt(this.#t.getAttribute("coords").split(",")[0]),y:parseInt(this.#t.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#o)}};c([w()],Ne.prototype,"_correctLines",2),c([w()],Ne.prototype,"startCoord",2),c([w()],Ne.prototype,"mouseCoord",2),c([mn({selector:"img"})],Ne.prototype,"grImage",2),c([w()],Ne.prototype,"_response",2);customElements.define("qti-graphic-associate-interaction",Ne);var ja=y`
4318
4318
  :host {
4319
4319
  display: flex;
4320
4320
  align-items: flex-start;
@@ -4368,10 +4368,10 @@ CES.load();
4368
4368
  user-select: none;
4369
4369
  pointer-events: none;
4370
4370
  }
4371
- `;var ns=class extends Se(R,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){static{this.styles=Fa}render(){return f` <slot name="prompt"></slot>
4371
+ `;var ns=class extends Se(R,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){static{this.styles=ja}render(){return f` <slot name="prompt"></slot>
4372
4372
  <slot part="image"></slot>
4373
4373
  <slot part="drags" name="drags" class="hover-border"></slot>
4374
- <div role="alert" part="message" id="validation-message"></div>`}#e(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.#e)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#e)}};customElements.define("qti-graphic-gap-match-interaction",ns);var ja=y`
4374
+ <div role="alert" part="message" id="validation-message"></div>`}#e(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.#e)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#e)}};customElements.define("qti-graphic-gap-match-interaction",ns);var Wa=y`
4375
4375
  slot:not([name='prompt']) {
4376
4376
  position: relative; /* qti-hotspot-choice relative to the slot */
4377
4377
  display: block;
@@ -4382,11 +4382,11 @@ CES.load();
4382
4382
  pointer-events: none;
4383
4383
  user-select: none;
4384
4384
  }
4385
- `;var as=class extends Ze(R,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}static{this.styles=ja}render(){return f`
4385
+ `;var as=class extends Ze(R,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}static{this.styles=Wa}render(){return f`
4386
4386
  <slot name="prompt"></slot>
4387
4387
  <slot></slot>
4388
4388
  <div role="alert" part="message" id="validation-message"></div>
4389
- `}#e(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}#t(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));tt(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.#e),this.addEventListener("register-qti-hotspot-choice",this.#t)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.#e),this.removeEventListener("register-qti-hotspot-choice",this.#t)}};customElements.define("qti-graphic-order-interaction",as);var Wa=y`
4389
+ `}#e(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}#t(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));tt(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.#e),this.addEventListener("register-qti-hotspot-choice",this.#t)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.#e),this.removeEventListener("register-qti-hotspot-choice",this.#t)}};customElements.define("qti-graphic-order-interaction",as);var Xa=y`
4390
4390
  slot:not([name='prompt']) {
4391
4391
  position: relative; /* qti-hotspot-choice relative to the slot */
4392
4392
  display: inline-block;
@@ -4400,11 +4400,11 @@ CES.load();
4400
4400
  user-select: none;
4401
4401
  /* width:100%; */
4402
4402
  }
4403
- `;var ls=class extends Ze(R,"qti-hotspot-choice"){static{this.styles=Wa}render(){return f`
4403
+ `;var ls=class extends Ze(R,"qti-hotspot-choice"){static{this.styles=Xa}render(){return f`
4404
4404
  <slot name="prompt"></slot>
4405
4405
  <slot></slot>
4406
- `}#e=null;#t(r){return this.#e||(r.naturalWidth>0&&r.naturalHeight>0?this.#e=Promise.resolve(r):this.#e=new Promise(e=>{let t=()=>{r.removeEventListener("load",t),e(r)};r.addEventListener("load",t)})),this.#e}async#r(r){let e=this.querySelector("img"),t=r.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map(l=>parseInt(l)),a=await this.#t(e);tt(s,n,a,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.#r)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.#r)}};customElements.define("qti-hotspot-interaction",ls);var oi=class extends Ze(R,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>f`<slot></slot>
4407
- <div part="message" role="alert" id="validation-message"></div>`}get#e(){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.#t()}updated(e){super.updated(e),this.#t()}#t(){let e=Object.keys(this.#e).join(" ");this.className=e}};c([u({type:String,reflect:!0})],oi.prototype,"class",2);customElements.define("qti-hottext-interaction",oi);var ni=class extends xe{constructor(r){if(super(r),this.it=L,r.type!==je.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===L||r==null)return this._t=void 0,this.it=r;if(r===z)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:[]}}};ni.directiveName="unsafeHTML",ni.resultType=1;var qt=te(ni);var Kl=y`
4406
+ `}#e=null;#t(r){return this.#e||(r.naturalWidth>0&&r.naturalHeight>0?this.#e=Promise.resolve(r):this.#e=new Promise(e=>{let t=()=>{r.removeEventListener("load",t),e(r)};r.addEventListener("load",t)})),this.#e}async#i(r){let e=this.querySelector("img"),t=r.target,i=t.getAttribute("coords"),s=t.getAttribute("shape"),n=i.split(",").map(l=>parseInt(l)),a=await this.#t(e);tt(s,n,a,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.#i)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.#i)}};customElements.define("qti-hotspot-interaction",ls);var oi=class extends Ze(R,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>f`<slot></slot>
4407
+ <div part="message" role="alert" id="validation-message"></div>`}get#e(){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.#t()}updated(e){super.updated(e),this.#t()}#t(){let e=Object.keys(this.#e).join(" ");this.className=e}};c([u({type:String,reflect:!0})],oi.prototype,"class",2);customElements.define("qti-hottext-interaction",oi);var ni=class extends xe{constructor(r){if(super(r),this.it=L,r.type!==je.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===L||r==null)return this._t=void 0,this.it=r;if(r===z)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:[]}}};ni.directiveName="unsafeHTML",ni.resultType=1;var qt=te(ni);var Zl=y`
4408
4408
  :host {
4409
4409
  display: inline-block;
4410
4410
  vertical-align: baseline;
@@ -4460,7 +4460,7 @@ CES.load();
4460
4460
  display: inline-block;
4461
4461
  vertical-align: middle;
4462
4462
  }
4463
- `,Xa=Kl;var Zl=0,rt=class extends R{constructor(){super();this.options=[];this.correctOption="";this._dropdownOpen=!1;this._slotObserver=null;this._menuId=`qti-inline-choice-menu-${Zl++}`;this.#o=e=>{(this.disabled||this.readonly)&&e.preventDefault()};this.#n=e=>{this.disabled||this.readonly||(e.key==="ArrowDown"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.#s(!0))};this.#a=e=>{let i=e.newState==="open";this._dropdownOpen!==i&&(this._dropdownOpen=i)};this.#u=e=>{if(!this._dropdownOpen)return;if(e.key==="Escape"){e.preventDefault(),this.#s(!1),this.#p();return}let t=this.#d(),i=this.renderRoot.activeElement,s=this.#l(),n=i||(s instanceof HTMLElement&&this.#f(s)?s:null),a=t.findIndex(l=>l===n);if(e.key==="ArrowDown"&&(e.preventDefault(),t[Math.min(t.length-1,Math.max(0,a+1))]?.focus()),e.key==="ArrowUp"&&(e.preventDefault(),t[Math.max(0,a-1)]?.focus()),e.key==="Enter"||e.key===" "){if(!n)return;if(e.preventDefault(),n instanceof HTMLButtonElement)n.click();else{let l=n.getAttribute("identifier")??"";this.#i(l)}}};this.#b=()=>{this.#t()};this.#h=e=>{if(this.disabled||this.readonly)return;let i=e.currentTarget.getAttribute("identifier")??"";this.#i(i)};this.internals.role="listbox"}get isInline(){return!0}static get styles(){return[Xa]}render(){let e=this.#e();return f`
4463
+ `,Ga=Zl;var ec=0,rt=class extends R{constructor(){super();this.options=[];this.correctOption="";this._dropdownOpen=!1;this._slotObserver=null;this._menuId=`qti-inline-choice-menu-${ec++}`;this.#o=e=>{(this.disabled||this.readonly)&&e.preventDefault()};this.#n=e=>{this.disabled||this.readonly||(e.key==="ArrowDown"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.#s(!0))};this.#a=e=>{let i=e.newState==="open";this._dropdownOpen!==i&&(this._dropdownOpen=i)};this.#p=e=>{if(!this._dropdownOpen)return;if(e.key==="Escape"){e.preventDefault(),this.#s(!1),this.#u();return}let t=this.#v(),i=this.renderRoot.activeElement,s=this.#l(),n=i||(s instanceof HTMLElement&&this.#f(s)?s:null),a=t.findIndex(l=>l===n);if(e.key==="ArrowDown"&&(e.preventDefault(),t[Math.min(t.length-1,Math.max(0,a+1))]?.focus()),e.key==="ArrowUp"&&(e.preventDefault(),t[Math.max(0,a-1)]?.focus()),e.key==="Enter"||e.key===" "){if(!n)return;if(e.preventDefault(),n instanceof HTMLButtonElement)n.click();else{let l=n.getAttribute("identifier")??"";this.#r(l)}}};this.#b=()=>{this.#t()};this.#h=e=>{if(this.disabled||this.readonly)return;let i=e.currentTarget.getAttribute("identifier")??"";this.#r(i)};this.internals.role="listbox"}get isInline(){return!0}static get styles(){return[Ga]}render(){let e=this.#e();return f`
4464
4464
  <button
4465
4465
  part="trigger"
4466
4466
  type="button"
@@ -4485,21 +4485,21 @@ CES.load();
4485
4485
  role="listbox"
4486
4486
  popover="auto"
4487
4487
  @toggle=${this.#a}
4488
- @keydown=${this.#u}
4488
+ @keydown=${this.#p}
4489
4489
  >
4490
4490
  <button
4491
4491
  part="${this.options[0]?.selected?"option option-prompt option-selected":"option option-prompt"}"
4492
4492
  type="button"
4493
4493
  role="option"
4494
4494
  aria-selected="${this.options[0]?.selected?"true":"false"}"
4495
- @click=${()=>this.#i("")}
4495
+ @click=${()=>this.#r("")}
4496
4496
  >
4497
4497
  <span part="option-content">${qt(this.options[0]?.textContent??"")}</span>
4498
4498
  </button>
4499
4499
  <slot @slotchange=${this.#b}></slot>
4500
4500
  </div>
4501
4501
  ${qt(this.correctOption)}
4502
- `}async connectedCallback(){super.connectedCallback(),this.#t(),this.#g(),await this.updateComplete,this.#r()}disconnectedCallback(){super.disconnectedCallback(),this.#v(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(e){e.has("configContext")&&this.#t()}updated(e){e.has("_dropdownOpen")&&this._dropdownOpen&&(this.#c(),this.#d()[0]?.focus()),(e.has("disabled")||e.has("readonly"))&&this.#c()}#e(){return this.options.find(e=>e.selected)??this.options[0]}#t(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataset.prompt||this.configContext?.inlineChoicePrompt||"select",i=this.options.find(a=>a.selected)?.value??"",s=[{textContent:t,value:"",selected:i===""},...e.map(a=>{let l=a.getAttribute("identifier")??"";return{textContent:a.innerHTML,value:l,selected:l!==""&&l===i}})],n=s.some(a=>a.selected);this.options=n?s:s.map((a,l)=>({...a,selected:l===0})),this.#c(),this.#r()}#r(){let e=this.#m(),t=this.renderRoot.querySelector('button[part="trigger"]');if(!e||!t)return;let i=t.querySelector('span[part~="dropdown-icon"]'),s=i?i.getBoundingClientRect().width:0,n=e.matches(":popover-open"),a=e.style.visibility,l=e.style.display;n||(e.style.visibility="hidden",e.style.display="block",e.showPopover());let d=e.getBoundingClientRect().width,p=Math.max(d,e.scrollWidth);n||(e.hidePopover(),e.style.visibility=a,e.style.display=l),t.style.width=`${p+s}px`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.#s(!1),this.options=this.options.map((e,t)=>({...e,selected:t===0})),this.#c()}set response(e){let t=e??"";this.options=this.options.map(i=>({...i,selected:i.value===t})),this.#c()}get response(){let e=this.options.find(t=>t.selected)?.value??"";return e===""?null:e}toggleInternalCorrectResponse(e){super.toggleInternalCorrectResponse(e);let t=this.correctResponse;if(!e||!t){this.correctOption="";return}let i=this.options.find(s=>t===s.value);if(!i){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">${i.textContent}</span>`}#i(e){this.options=this.options.map(t=>({...t,selected:t.value===e})),this.#c(),this.saveResponse(e),this.#s(!1)}#s(e){let t=this.#m();if(t){if(e){t.matches(":popover-open")||t.showPopover();return}t.matches(":popover-open")&&t.hidePopover()}}#o;#n;#a;#u;#p(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#l(){let e=document.activeElement;for(;e&&e instanceof HTMLElement&&e.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}#f(e){return e===this||this.contains(e)||this.renderRoot.contains(e)}#m(){return this.renderRoot.querySelector(`#${this._menuId}`)}#g(){this._slotObserver=new MutationObserver(()=>this.#t()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#b;#h;#v(){let e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let t of e)t.removeEventListener("click",this.#h),t.removeAttribute("tabindex"),t.internals.role=null,t.internals.ariaSelected=null,t.internals.ariaChecked="false",t.internals.states.delete("--checked")}async#c(){await this.updateComplete;let e=this.options.find(i=>i.selected)?.value??"",t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let i of t){let n=(i.getAttribute("identifier")??"")===e;i.removeEventListener("click",this.#h),i.addEventListener("click",this.#h),i.disabled=this.disabled,i.readonly=this.readonly,i.internals.role="option",i.internals.ariaSelected=n?"true":"false",i.internals.ariaChecked=n?"true":"false",i.internals.ariaDisabled=this.disabled?"true":"false",i.internals.ariaReadOnly=this.readonly?"true":"false",i.removeAttribute("aria-disabled"),i.removeAttribute("aria-readonly"),n?i.internals.states.add("--checked"):i.internals.states.delete("--checked"),i.tabIndex=-1}}#d(){let e=this.renderRoot.querySelector('button[part~="option"]'),t=Array.from(this.querySelectorAll("qti-inline-choice"));return[...e?[e]:[],...t]}};c([w()],rt.prototype,"options",2),c([w()],rt.prototype,"correctOption",2),c([w()],rt.prototype,"_dropdownOpen",2),c([M({context:ae,subscribe:!0}),u({attribute:!1})],rt.prototype,"configContext",2);customElements.define("qti-inline-choice-interaction",rt);var Ga=y`
4502
+ `}async connectedCallback(){super.connectedCallback(),this.#t(),this.#g(),await this.updateComplete,this.#i()}disconnectedCallback(){super.disconnectedCallback(),this.#y(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(e){e.has("configContext")&&this.#t()}updated(e){e.has("_dropdownOpen")&&this._dropdownOpen&&(this.#c(),this.#v()[0]?.focus()),(e.has("disabled")||e.has("readonly"))&&this.#c()}#e(){return this.options.find(e=>e.selected)??this.options[0]}#t(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataset.prompt||this.configContext?.inlineChoicePrompt||"select",i=this.options.find(a=>a.selected)?.value??"",s=[{textContent:t,value:"",selected:i===""},...e.map(a=>{let l=a.getAttribute("identifier")??"";return{textContent:a.innerHTML,value:l,selected:l!==""&&l===i}})],n=s.some(a=>a.selected);this.options=n?s:s.map((a,l)=>({...a,selected:l===0})),this.#c(),this.#i()}#i(){let e=this.#m(),t=this.renderRoot.querySelector('button[part="trigger"]');if(!e||!t)return;let i=t.querySelector('span[part~="dropdown-icon"]'),s=i?i.getBoundingClientRect().width:0,n=e.matches(":popover-open"),a=e.style.visibility,l=e.style.display;n||(e.style.visibility="hidden",e.style.display="block",e.showPopover());let d=e.getBoundingClientRect().width,p=Math.max(d,e.scrollWidth);n||(e.hidePopover(),e.style.visibility=a,e.style.display=l),t.style.width=`${p+s}px`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.#s(!1),this.options=this.options.map((e,t)=>({...e,selected:t===0})),this.#c()}set response(e){let t=e??"";this.options=this.options.map(i=>({...i,selected:i.value===t})),this.#c()}get response(){let e=this.options.find(t=>t.selected)?.value??"";return e===""?null:e}toggleInternalCorrectResponse(e){super.toggleInternalCorrectResponse(e);let t=this.correctResponse;if(!e||!t){this.correctOption="";return}let i=this.options.find(s=>t===s.value);if(!i){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">${i.textContent}</span>`}#r(e){this.options=this.options.map(t=>({...t,selected:t.value===e})),this.#c(),this.saveResponse(e),this.#s(!1)}#s(e){let t=this.#m();if(t){if(e){t.matches(":popover-open")||t.showPopover();return}t.matches(":popover-open")&&t.hidePopover()}}#o;#n;#a;#p;#u(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#l(){let e=document.activeElement;for(;e&&e instanceof HTMLElement&&e.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}#f(e){return e===this||this.contains(e)||this.renderRoot.contains(e)}#m(){return this.renderRoot.querySelector(`#${this._menuId}`)}#g(){this._slotObserver=new MutationObserver(()=>this.#t()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#b;#h;#y(){let e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let t of e)t.removeEventListener("click",this.#h),t.removeAttribute("tabindex"),t.internals.role=null,t.internals.ariaSelected=null,t.internals.ariaChecked="false",t.internals.states.delete("--checked")}async#c(){await this.updateComplete;let e=this.options.find(i=>i.selected)?.value??"",t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let i of t){let n=(i.getAttribute("identifier")??"")===e;i.removeEventListener("click",this.#h),i.addEventListener("click",this.#h),i.disabled=this.disabled,i.readonly=this.readonly,i.internals.role="option",i.internals.ariaSelected=n?"true":"false",i.internals.ariaChecked=n?"true":"false",i.internals.ariaDisabled=this.disabled?"true":"false",i.internals.ariaReadOnly=this.readonly?"true":"false",i.removeAttribute("aria-disabled"),i.removeAttribute("aria-readonly"),n?i.internals.states.add("--checked"):i.internals.states.delete("--checked"),i.tabIndex=-1}}#v(){let e=this.renderRoot.querySelector('button[part~="option"]'),t=Array.from(this.querySelectorAll("qti-inline-choice"));return[...e?[e]:[],...t]}};c([w()],rt.prototype,"options",2),c([w()],rt.prototype,"correctOption",2),c([w()],rt.prototype,"_dropdownOpen",2),c([k({context:le,subscribe:!0}),u({attribute:!1})],rt.prototype,"configContext",2);customElements.define("qti-inline-choice-interaction",rt);var Qa=y`
4503
4503
  slot:not([hidden]) {
4504
4504
  /* slot where the */
4505
4505
  display: flex;
@@ -4525,7 +4525,7 @@ CES.load();
4525
4525
  /* Make sure the drag and drop container slots have the same width */
4526
4526
  flex: 1;
4527
4527
  }
4528
- `;var it=class extends Se(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}}))}}static{this.styles=Ga}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()}#e(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.#e(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.#e(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 f`
4528
+ `;var it=class extends Se(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}}))}}static{this.styles=Qa}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()}#e(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.#e(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.#e(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 f`
4529
4529
  <slot name="prompt"></slot>
4530
4530
  <slot ?hidden=${e}></slot>
4531
4531
 
@@ -4569,7 +4569,7 @@ CES.load();
4569
4569
 
4570
4570
  <div role="alert" part="message" id="validation-message"></div>
4571
4571
  `}};c([u({type:String})],it.prototype,"class",2),c([w()],it.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],it.prototype,"responseIdentifier",2),c([w()],it.prototype,"correctOptions",2);customElements.define("qti-match-interaction",it);var cs=class extends R{#e=null;reset(){this.#e=null}validate(){return!0}get response(){return this.#e?this.#e.toString():null}set response(r){if(r)if(!isNaN(parseInt(r?.toString())))this.#e=parseInt(r.toString());else throw new Error(`Value must be a number ${r}`)}static get properties(){return{...R.properties,step:{type:Number,attribute:"step",default:10}}}static{this.styles=[y``]}render(){return f` <slot name="prompt"></slot>
4572
- <slot></slot>`}constructor(){super()}connectedCallback(){super.connectedCallback();let r=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");r&&r.addEventListener("ended",()=>{this.#e++,this.saveResponse(this.value)})}};customElements.define("qti-media-interaction",cs);var Qa=y`
4572
+ <slot></slot>`}constructor(){super()}connectedCallback(){super.connectedCallback();let r=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");r&&r.addEventListener("ended",()=>{this.#e++,this.saveResponse(this.value)})}};customElements.define("qti-media-interaction",cs);var Ya=y`
4573
4573
  [part='drags'] {
4574
4574
  display: flex;
4575
4575
  align-items: flex-start;
@@ -4627,24 +4627,24 @@ CES.load();
4627
4627
  :host(.qti-choices-right) [part='container'] {
4628
4628
  flex-direction: row-reverse;
4629
4629
  }
4630
- `;var st=class extends Se(R,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}static{this.styles=Qa}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),f` <slot name="prompt"> </slot>
4630
+ `;var st=class extends Se(R,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}static{this.styles=Ya}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),f` <slot name="prompt"> </slot>
4631
4631
  <div part="container">
4632
4632
  <slot part="drags"> </slot>
4633
4633
  <div part="drops">
4634
4634
  ${[...Array(this.nrChoices)].map((t,i)=>f`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
4635
4635
  </div>
4636
- </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 h=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!h)return;let g=document.createElement("span");g.classList.add("correct-option"),g.textContent=m,g.style.border="1px solid var(--qti-correct)",g.style.borderRadius="4px",g.style.padding="2px 4px",g.style.display="inline-block",g.style.marginTop="4px",h.insertAdjacentElement("afterend",g)})}}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(){super.firstUpdated(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};c([w()],st.prototype,"nrChoices",2),c([w()],st.prototype,"correctResponses",2),c([w()],st.prototype,"showCorrectResponses",2),c([u({type:String})],st.prototype,"orientation",2);customElements.define("qti-order-interaction",st);var Ya=y`
4636
+ </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 h=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!h)return;let g=document.createElement("span");g.classList.add("correct-option"),g.textContent=m,g.style.border="1px solid var(--qti-correct)",g.style.borderRadius="4px",g.style.padding="2px 4px",g.style.display="inline-block",g.style.marginTop="4px",h.insertAdjacentElement("afterend",g)})}}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(){super.firstUpdated(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};c([w()],st.prototype,"nrChoices",2),c([w()],st.prototype,"correctResponses",2),c([w()],st.prototype,"showCorrectResponses",2),c([u({type:String})],st.prototype,"orientation",2);customElements.define("qti-order-interaction",st);var Ja=y`
4637
4637
  ::slotted(qti-interaction-markup) {
4638
4638
  display: none;
4639
4639
  }
4640
- `;var B=class extends R{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._iframeMessageOrigin=null;this._iframeObjectUrl=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=null;this.#t=null;this.#r=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||e.source!==this.iframe.contentWindow)&&!(t.responseIdentifier&&t.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=e.origin;else if(e.origin!==this._iframeMessageOrigin)return;switch(t.method){case"iframeReady":this.#c(),this.#g(),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"console":this.dispatchEvent(new CustomEvent("qti-pci-console",{detail:{level:t.level,args:t.args},bubbles:!0}));break;case"interactionChanged":{let i=t?.params?.value,s=i&&typeof i=="object"?this.#p(i):null,n=t?.params?.state,a;if(n===void 0)a=void 0;else if(n===null)a=null;else if(typeof n=="string")a=n;else try{a=`__qti_json__::${JSON.stringify(n)}`}catch{a=null}if(s===null){let l=this.responseVariable?.cardinality==="single"?"":[];this.response=l,this.validate(),this.saveResponse(l,a);break}this.response=s,this.validate(),this.saveResponse(s,a);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}}};this.#d=null}#e;static{this.styles=[Ya,y`
4640
+ `;var B=class extends R{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._iframeMessageOrigin=null;this._iframeObjectUrl=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=null;this.#t=null;this.#i=null;this.#r=null;this.#s="";this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||e.source!==this.iframe.contentWindow)&&!(t.responseIdentifier&&t.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=e.origin;else if(e.origin!==this._iframeMessageOrigin)return;switch(t.method){case"iframeReady":this.#x(),this.#c(),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"console":this.dispatchEvent(new CustomEvent("qti-pci-console",{detail:{level:t.level,args:t.args},bubbles:!0}));break;case"interactionChanged":{let i=t?.params?.value,s=i&&typeof i=="object"?this.#f(i):null,n=typeof t?.params?.valid=="boolean"?t.params.valid:null,a=typeof t?.params?.customValidity=="string"?t.params.customValidity:null;n!==null&&(this.#r=n,n&&a===null&&(this.#s="")),a!==null&&(this.#s=a);let l=t?.params?.state,d;if(l===void 0)d=void 0;else if(l===null)d=null;else if(typeof l=="string")d=l;else try{d=`__qti_json__::${JSON.stringify(l)}`}catch{d=null}if(s===null){let p=this.responseVariable?.cardinality==="single"?"":[];this.response=p,this.validate(),this.saveResponse(p,d);break}this.response=s,this.validate(),this.saveResponse(s,d);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}}};this.#d=null}#e;static{this.styles=[Ja,y`
4641
4641
  :host {
4642
4642
  display: block;
4643
4643
  width: 100%;
4644
4644
  min-height: 50px;
4645
4645
  }
4646
- `]}#t;#r;#i(){if(this.#t===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this.#t={},e.forEach(t=>{t.name&&t.value&&(this.#t[t.name]=t.value)})):this.#t=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this.#t={}}return this.#t||{}}#s(){if(this.#r===null&&this.requireShimJson)try{this.#r=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this.#r={}}return this.#r||{}}#o(){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/OAT/util/tpl":"/assets/pci-scripts/portableLib/OAT/util/tpl","taoQtiItem/portableLib/OAT/util/asset":"/assets/pci-scripts/portableLib/OAT/util/asset","taoQtiItem/portableLib/OAT/waitForMedia":"/assets/pci-scripts/portableLib/OAT/waitForMedia","taoQtiItem/portableLib/OAT/mediaPlayer":"/assets/pci-scripts/portableLib/OAT/mediaPlayer","taoQtiItem/portableLib/OAT/scale.raphael":"/assets/pci-scripts/portableLib/OAT/scale.raphael","taoQtiItem/portableLib/OAT/interact-rotate":"/assets/pci-scripts/portableLib/OAT/interact-rotate","taoQtiItem/portableLib/OAT/promise":"/assets/pci-scripts/portableLib/OAT/promise","taoQtiItem/portableLib/OAT/sts/common":"/assets/pci-scripts/portableLib/OAT/sts/common","taoQtiItem/portableLib/OAT/sts/transform-helper":"/assets/pci-scripts/portableLib/OAT/sts/transform-helper","taoQtiItem/portableLib/OAT/sts/stsEventManager":"/assets/pci-scripts/portableLib/OAT/sts/stsEventManager","taoQtiItem/portableLib/async":"/assets/pci-scripts/portableLib/async","taoQtiItem/portableLib/interact":"/assets/pci-scripts/portableLib/interact","taoQtiItem/portableLib/es6-promise":"/assets/pci-scripts/portableLib/es6-promise","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/portableLib/jquery.qtip":"/assets/pci-scripts/portableLib/jquery.qtip","taoQtiItem/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/portableLib/handlebars":"/assets/pci-scripts/portableLib/handlebars","taoQtiItem/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/pci-scripts/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"}}#n(){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}}}}#a(){let e=this.#o(),t=this.#i();return this.useDefaultPaths?{...e,...t}:t}#u(){let e=this.#s(),t=this.#n();return this.useDefaultShims?{...t,...e}:e}#p(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}getDirectChildrenByTag(e){let t=e.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===t)}coerceBaseValue(e,t){if(e==null)return e;switch(t){case"integer":{if(typeof e=="number")return e;let i=parseInt(String(e),10);return Number.isNaN(i)?e:i}case"float":case"duration":{if(typeof e=="number")return e;let i=parseFloat(String(e));return Number.isNaN(i)?e:i}case"boolean":{if(typeof e=="boolean")return e;if(typeof e=="string"){let i=e.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return e}default:return String(e)}}normalizeListValue(e){return e==null?[]:Array.isArray(e)?e:[e]}variableToQtiVariableJSON(e,t,i){if(t==="record"||i==="record")return this.recordToQtiVariableJSON(e);if(t!=="single"){let s=this.normalizeListValue(e).map(n=>this.coerceBaseValue(n,i));return{list:{[i]:s}}}return{base:{[i]:this.coerceBaseValue(e,i)}}}recordToQtiVariableJSON(e){if(!e||typeof e!="object")return{record:[]};let t=[];for(let[i,s]of Object.entries(e))t.push(this.recordEntryFromValue(i,s));return{record:t}}recordEntryFromValue(e,t){if(Array.isArray(t)){let i=t.filter(s=>s!=null);if(i.length&&i.every(s=>typeof s=="boolean"))return{name:e,list:{boolean:i}};if(i.length&&i.every(s=>typeof s=="number")){let s=i,n=s.every(a=>Number.isInteger(a));return{name:e,list:{[n?"integer":"float"]:s}}}return{name:e,list:{string:t.map(s=>s==null?"":String(s))}}}if(typeof t=="boolean")return{name:e,base:{boolean:t}};if(typeof t=="number")return Number.isInteger(t)?{name:e,base:{integer:t}}:{name:e,base:{float:t}};if(t==null)return{name:e,base:{string:""}};if(typeof t=="object")try{return{name:e,base:{string:JSON.stringify(t)}}}catch{return{name:e,base:{string:String(t)}}}return{name:e,base:{string:String(t)}}}getQtiContextDefaultsFromItem(){let e=this.closest("qti-assessment-item");if(!e)return{};let t={};return e.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=s.querySelector("qti-default-value");if(!n)return;n.querySelectorAll("qti-value[field-identifier]").forEach(l=>{let d=l.getAttribute("field-identifier");if(!d)return;let p=l.getAttribute("base-type")||"string",m=l.textContent?.trim()||"";t[d]=this.coerceBaseValue(m,p)})}),t}getQtiContextRecord(){let e=this.getQtiContextDefaultsFromItem(),t=this.qtiContext?.QTI_CONTEXT||{},i={...e,...t};if(!Object.keys(i).length)return null;let s={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(s)}getTemplateVariables(){let e={},t=this.getDirectChildrenByTag("qti-template-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!s)return;let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}getContextVariables(){let e={},t=this.getDirectChildrenByTag("qti-context-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("identifier")||"";if(!s)return;if(s==="QTI_CONTEXT"){let d=this.getQtiContextRecord();d&&(e[s]=d);return}let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}#l(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 this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(e=>e!==""&&e!==null&&e!==void 0):this.response!==""}set value(e){e===null?this.#e=[]:this.#e=Array.isArray(e)?e:e.split(",")}get value(){return this.#e===null||this.#e===void 0?null:Array.isArray(this.#e)?this.#e.join(","):String(this.#e)}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.#p(e[this.responseIdentifier]);this.#e=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}#f(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,"=")}#m(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.#f(s):t[i]=s;return t}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage),this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null)}sendMessageToIframe(e,t){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:e,params:t});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:e,params:t},"*")}#g(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),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._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.#v(),this.#b()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent();try{let i=new Blob([t],{type:"text/html"});this._iframeObjectUrl=URL.createObjectURL(i),this.iframe.src=this._iframeObjectUrl}catch{let i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`}this.appendChild(this.iframe)}#b(){let e=this.#l(this.#m({...this.dataset})),t=this.context?.state?.[this.responseIdentifier],i=typeof t=="string"&&t.length>0?t:null,s={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Oi(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:e,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#h(),boundTo:i?null:this.boundTo,state:i};this.sendMessageToIframe("initialize",s)}#h(){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}#v(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=Array.from(this.querySelectorAll("qti-stylesheet"));if(t.length){let s=t.map(n=>n.outerHTML).join(`
4647
- `);this.sendMessageToIframe("setStylesheets",s)}let i=this.querySelector("properties");i&&this.sendMessageToIframe("setProperties",i.innerHTML)}#c(){}connectedCallback(){super.connectedCallback(),this.response=this.responseVariable?.value??null,window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.#a()),i=JSON.stringify(this.#u()),s=this.dataset.baseUrl?this.dataset.baseUrl.startsWith("/")?`${window.location.origin}${this.dataset.baseUrl}`:this.dataset.baseUrl:"",n=this.dataset.forwardConsole==="true",a=`
4646
+ `]}#t;#i;#r;#s;#o(){if(this.#t===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this.#t={},e.forEach(t=>{t.name&&t.value&&(this.#t[t.name]=t.value)})):this.#t=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this.#t={}}return this.#t||{}}#n(){if(this.#i===null&&this.requireShimJson)try{this.#i=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this.#i={}}return this.#i||{}}#a(){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/OAT/util/tpl":"/assets/pci-scripts/portableLib/OAT/util/tpl","taoQtiItem/portableLib/OAT/util/asset":"/assets/pci-scripts/portableLib/OAT/util/asset","taoQtiItem/portableLib/OAT/waitForMedia":"/assets/pci-scripts/portableLib/OAT/waitForMedia","taoQtiItem/portableLib/OAT/mediaPlayer":"/assets/pci-scripts/portableLib/OAT/mediaPlayer","taoQtiItem/portableLib/OAT/scale.raphael":"/assets/pci-scripts/portableLib/OAT/scale.raphael","taoQtiItem/portableLib/OAT/interact-rotate":"/assets/pci-scripts/portableLib/OAT/interact-rotate","taoQtiItem/portableLib/OAT/promise":"/assets/pci-scripts/portableLib/OAT/promise","taoQtiItem/portableLib/OAT/sts/common":"/assets/pci-scripts/portableLib/OAT/sts/common","taoQtiItem/portableLib/OAT/sts/transform-helper":"/assets/pci-scripts/portableLib/OAT/sts/transform-helper","taoQtiItem/portableLib/OAT/sts/stsEventManager":"/assets/pci-scripts/portableLib/OAT/sts/stsEventManager","taoQtiItem/portableLib/async":"/assets/pci-scripts/portableLib/async","taoQtiItem/portableLib/interact":"/assets/pci-scripts/portableLib/interact","taoQtiItem/portableLib/es6-promise":"/assets/pci-scripts/portableLib/es6-promise","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/portableLib/jquery.qtip":"/assets/pci-scripts/portableLib/jquery.qtip","taoQtiItem/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/portableLib/handlebars":"/assets/pci-scripts/portableLib/handlebars","taoQtiItem/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/pci-scripts/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"}}#p(){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}}}}#u(){let e=this.#a(),t=this.#o();return this.useDefaultPaths?{...e,...t}:t}#l(){let e=this.#n(),t=this.#p();return this.useDefaultShims?{...t,...e}:e}#f(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}getDirectChildrenByTag(e){let t=e.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===t)}coerceBaseValue(e,t){if(e==null)return e;switch(t){case"integer":{if(typeof e=="number")return e;let i=parseInt(String(e),10);return Number.isNaN(i)?e:i}case"float":case"duration":{if(typeof e=="number")return e;let i=parseFloat(String(e));return Number.isNaN(i)?e:i}case"boolean":{if(typeof e=="boolean")return e;if(typeof e=="string"){let i=e.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return e}default:return String(e)}}normalizeListValue(e){return e==null?[]:Array.isArray(e)?e:[e]}variableToQtiVariableJSON(e,t,i){if(t==="record"||i==="record")return this.recordToQtiVariableJSON(e);if(t!=="single"){let s=this.normalizeListValue(e).map(n=>this.coerceBaseValue(n,i));return{list:{[i]:s}}}return{base:{[i]:this.coerceBaseValue(e,i)}}}recordToQtiVariableJSON(e){if(!e||typeof e!="object")return{record:[]};let t=[];for(let[i,s]of Object.entries(e))t.push(this.recordEntryFromValue(i,s));return{record:t}}recordEntryFromValue(e,t){if(Array.isArray(t)){let i=t.filter(s=>s!=null);if(i.length&&i.every(s=>typeof s=="boolean"))return{name:e,list:{boolean:i}};if(i.length&&i.every(s=>typeof s=="number")){let s=i,n=s.every(a=>Number.isInteger(a));return{name:e,list:{[n?"integer":"float"]:s}}}return{name:e,list:{string:t.map(s=>s==null?"":String(s))}}}if(typeof t=="boolean")return{name:e,base:{boolean:t}};if(typeof t=="number")return Number.isInteger(t)?{name:e,base:{integer:t}}:{name:e,base:{float:t}};if(t==null)return{name:e,base:{string:""}};if(typeof t=="object")try{return{name:e,base:{string:JSON.stringify(t)}}}catch{return{name:e,base:{string:String(t)}}}return{name:e,base:{string:String(t)}}}getQtiContextDefaultsFromItem(){let e=this.closest("qti-assessment-item");if(!e)return{};let t={};return e.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=s.querySelector("qti-default-value");if(!n)return;n.querySelectorAll("qti-value[field-identifier]").forEach(l=>{let d=l.getAttribute("field-identifier");if(!d)return;let p=l.getAttribute("base-type")||"string",m=l.textContent?.trim()||"";t[d]=this.coerceBaseValue(m,p)})}),t}getQtiContextRecord(){let e=this.getQtiContextDefaultsFromItem(),t=this.qtiContext?.QTI_CONTEXT||{},i={...e,...t};if(!Object.keys(i).length)return null;let s={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(s)}getTemplateVariables(){let e={},t=this.getDirectChildrenByTag("qti-template-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!s)return;let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}getContextVariables(){let e={},t=this.getDirectChildrenByTag("qti-context-variable");return t.length&&t.forEach(i=>{let s=i.getAttribute("identifier")||"";if(!s)return;if(s==="QTI_CONTEXT"){let d=this.getQtiContextRecord();d&&(e[s]=d);return}let n=this.context?.variables?.find(d=>d.identifier===s);if(!n)return;let a=n.cardinality||"single",l=n.baseType||"string";e[s]=this.variableToQtiVariableJSON(n.value,a,l)}),e}#m(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}}#g(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(e=>e!==""&&e!==null&&e!==void 0):this.response!==""}#b(e,t){let i=this.dataset.invalidresponsemessage||"Invalid response.",s=e?"":t&&t.trim().length>0?t:i;this._internals.setValidity(e?{}:{customError:!0},s)}validate(){let e=typeof this.#r=="boolean"?this.#r:this.#g();return this.#b(e,this.#s),e}set value(e){e===null?this.#e=[]:this.#e=Array.isArray(e)?e:e.split(",")}get value(){return this.#e===null||this.#e===void 0?null:Array.isArray(this.#e)?this.#e.join(","):String(this.#e)}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.#f(e[this.responseIdentifier]);this.#e=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}#h(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,"=")}#y(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.#h(s):t[i]=s;return t}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage),this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null)}sendMessageToIframe(e,t){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:e,params:t});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:e,params:t},"*")}#c(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),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._iframeObjectUrl&&(URL.revokeObjectURL(this._iframeObjectUrl),this._iframeObjectUrl=null),this.#C(),this.#v()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent();try{let i=new Blob([t],{type:"text/html"});this._iframeObjectUrl=URL.createObjectURL(i),this.iframe.src=this._iframeObjectUrl}catch{let i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`}this.appendChild(this.iframe)}#v(){let e=this.#m(this.#y({...this.dataset})),t=this.context?.state?.[this.responseIdentifier],i=typeof t=="string"&&t.length>0?t:null,s={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Oi(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:e,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#q(),boundTo:i?null:this.boundTo,state:i};this.sendMessageToIframe("initialize",s)}#q(){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}#C(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=Array.from(this.querySelectorAll("qti-stylesheet"));if(t.length){let s=t.map(n=>n.outerHTML).join(`
4647
+ `);this.sendMessageToIframe("setStylesheets",s)}let i=this.querySelector("properties");i&&this.sendMessageToIframe("setProperties",i.innerHTML)}#x(){}connectedCallback(){super.connectedCallback(),this.#r=null,this.#s="",this.response=this.responseVariable?.value??null,window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.#u()),i=JSON.stringify(this.#l()),s=this.dataset.baseUrl?this.dataset.baseUrl.startsWith("/")?`${window.location.origin}${this.dataset.baseUrl}`:this.dataset.baseUrl:"",n=this.dataset.forwardConsole==="true",a=`
4648
4648
  font-family: ${e.getPropertyValue("font-family")};
4649
4649
  font-size: ${e.getPropertyValue("font-size")};
4650
4650
  line-height: ${e.getPropertyValue("line-height")};
@@ -4863,11 +4863,37 @@ CES.load();
4863
4863
  self.interactionChangedViaEvent = true;
4864
4864
  const value = evt && evt.detail ? evt.detail.value : undefined;
4865
4865
  if (value !== undefined) {
4866
+ const validFromEvent =
4867
+ evt && evt.detail && typeof evt.detail.valid === 'boolean' ? evt.detail.valid : undefined;
4868
+ let valid = validFromEvent;
4869
+ if (valid === undefined && self.pciInstance && typeof self.pciInstance.checkValidity === 'function') {
4870
+ try {
4871
+ valid = self.pciInstance.checkValidity();
4872
+ } catch (e) {
4873
+ // Keep undefined on PCI validity read errors.
4874
+ }
4875
+ }
4876
+ const customValidityFromEvent =
4877
+ evt && evt.detail && typeof evt.detail.customValidity === 'string'
4878
+ ? evt.detail.customValidity
4879
+ : undefined;
4880
+ let customValidity = customValidityFromEvent;
4881
+ if (
4882
+ customValidity === undefined &&
4883
+ self.pciInstance &&
4884
+ typeof self.pciInstance.getCustomValidity === 'function'
4885
+ ) {
4886
+ try {
4887
+ customValidity = self.pciInstance.getCustomValidity();
4888
+ } catch (e) {
4889
+ // Keep undefined on PCI custom validity read errors.
4890
+ }
4891
+ }
4866
4892
  const state =
4867
4893
  self.pciInstance && typeof self.pciInstance.getState === 'function'
4868
4894
  ? self.pciInstance.getState()
4869
4895
  : null;
4870
- self.notifyInteractionChanged(value, state);
4896
+ self.notifyInteractionChanged(value, state, valid, customValidity);
4871
4897
  }
4872
4898
  } catch (e) {
4873
4899
  // ignore bridge errors, polling fallback may still work
@@ -4955,7 +4981,20 @@ CES.load();
4955
4981
  this.notifyReady();
4956
4982
  },
4957
4983
  ondone: (pciInstance, response, state, status) => {
4958
- this.notifyInteractionChanged(response, typeof state === 'string' ? state : null);
4984
+ const valid =
4985
+ this.pciInstance && typeof this.pciInstance.checkValidity === 'function'
4986
+ ? this.pciInstance.checkValidity()
4987
+ : undefined;
4988
+ const customValidity =
4989
+ this.pciInstance && typeof this.pciInstance.getCustomValidity === 'function'
4990
+ ? this.pciInstance.getCustomValidity()
4991
+ : undefined;
4992
+ this.notifyInteractionChanged(
4993
+ response,
4994
+ typeof state === 'string' ? state : null,
4995
+ valid,
4996
+ customValidity
4997
+ );
4959
4998
  },
4960
4999
  responseIdentifier: config.responseIdentifier,
4961
5000
  boundTo: config.boundTo
@@ -5079,13 +5118,18 @@ CES.load();
5079
5118
  );
5080
5119
  },
5081
5120
 
5082
- notifyInteractionChanged: function (response, state) {
5121
+ notifyInteractionChanged: function (response, state, valid, customValidity) {
5083
5122
  window.parent.postMessage(
5084
5123
  {
5085
5124
  source: 'qti-pci-iframe',
5086
5125
  responseIdentifier: this.responseIdentifier,
5087
5126
  method: 'interactionChanged',
5088
- params: { value: response, state: state }
5127
+ params: {
5128
+ value: response,
5129
+ state: state,
5130
+ valid: typeof valid === 'boolean' ? valid : undefined,
5131
+ customValidity: typeof customValidity === 'string' ? customValidity : undefined
5132
+ }
5089
5133
  },
5090
5134
  '*'
5091
5135
  );
@@ -5466,6 +5510,14 @@ CES.load();
5466
5510
  if (PCIManager.interactionChangedViaEvent) return;
5467
5511
  if (PCIManager.pciInstance && PCIManager.pciInstance.getResponse) {
5468
5512
  const response = PCIManager.pciInstance.getResponse();
5513
+ const valid =
5514
+ PCIManager.pciInstance && typeof PCIManager.pciInstance.checkValidity === 'function'
5515
+ ? PCIManager.pciInstance.checkValidity()
5516
+ : undefined;
5517
+ const customValidity =
5518
+ PCIManager.pciInstance && typeof PCIManager.pciInstance.getCustomValidity === 'function'
5519
+ ? PCIManager.pciInstance.getCustomValidity()
5520
+ : undefined;
5469
5521
  if (response === undefined) {
5470
5522
  // Don't emit an initial empty on load; only emit a clear if we previously had a value
5471
5523
  if (!PCIManager.hadResponse) return;
@@ -5480,7 +5532,7 @@ CES.load();
5480
5532
  source: 'qti-pci-iframe',
5481
5533
  responseIdentifier: PCIManager.responseIdentifier,
5482
5534
  method: 'interactionChanged',
5483
- params: { value: null, state: state }
5535
+ params: { value: null, state: state, valid: valid, customValidity: customValidity }
5484
5536
  },
5485
5537
  '*'
5486
5538
  );
@@ -5501,7 +5553,7 @@ CES.load();
5501
5553
  source: 'qti-pci-iframe',
5502
5554
  responseIdentifier: PCIManager.responseIdentifier,
5503
5555
  method: 'interactionChanged',
5504
- params: { value: response, state: state }
5556
+ params: { value: response, state: state, valid: valid, customValidity: customValidity }
5505
5557
  },
5506
5558
  '*'
5507
5559
  );
@@ -5519,7 +5571,7 @@ CES.load();
5519
5571
  <h1>Error</h1>
5520
5572
  ${this._errorMessage}
5521
5573
  </div>`:""}
5522
- `}};c([u({type:String,attribute:"module"})],B.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],B.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],B.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],B.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],B.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],B.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],B.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],B.prototype,"useDefaultPaths",2),c([w()],B.prototype,"_errorMessage",2),c([M({context:D,subscribe:!0}),w()],B.prototype,"context",2),c([M({context:Lt,subscribe:!0}),w()],B.prototype,"qtiContext",2),c([w()],B.prototype,"response",2);var ds=class extends B{#e=!1;async getIFrameContent(){return new Promise(r=>{let e=`get-content-${Date.now()}`,t=i=>{let{data:s}=i;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="getContentResponse"&&s?.messageId===e&&(window.removeEventListener("message",t),r(s.content))};window.addEventListener("message",t),this.sendMessageToIframe("getContent",{messageId:e}),setTimeout(()=>{window.removeEventListener("message",t),r("")},5e3)})}setTestContext(r){this.context=r,this.updateComplete.then(()=>{this.value=r?.variables?.find(e=>e.identifier===this.responseIdentifier).value})}async recreateIframe(){this.#e=!0;try{return this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),new Promise(r=>{let e=()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()};this.addEventListener("qti-portable-custom-interaction-loaded",e),setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()},5e3)})}finally{this.#e=!1}}disconnectedCallback(){this.#e||super.disconnectedCallback()}async iFrameMouseClick(r,e){return new Promise(t=>{let i=`click-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t())};window.addEventListener("message",s),this.sendMessageToIframe("simulateClick",{x:r,y:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t()},5e3)})}async iFrameClickOnElement(r){return new Promise(e=>{let t=`click-selector-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameClickOnElementByText(r){return new Promise(e=>{let t=`click-text-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickTextResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnElementByText",{text:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameSetValueElement(r,e){return new Promise(t=>{let i=`set-value-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("setValueElement",{selector:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameGetBoundingClientRect(r){return new Promise(e=>{let t=`get-bounding-rect-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="getBoundingRectResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.rect??null))};window.addEventListener("message",i),this.sendMessageToIframe("getBoundingRect",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(null)},5e3)})}async iFrameSetValueElementByText(r,e){return new Promise(t=>{let i=`set-value-text-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueByTextResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("setValueElementByText",{text:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameMousedownOnElement(r){return new Promise(e=>{let t=`mousedown-selector-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="mousedownSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("mousedownOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}generateIframeContent(){let r=super.generateIframeContent(),e=`
5574
+ `}};c([u({type:String,attribute:"module"})],B.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],B.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],B.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],B.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],B.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],B.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],B.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],B.prototype,"useDefaultPaths",2),c([w()],B.prototype,"_errorMessage",2),c([k({context:D,subscribe:!0}),w()],B.prototype,"context",2),c([k({context:Lt,subscribe:!0}),w()],B.prototype,"qtiContext",2),c([w()],B.prototype,"response",2);var ds=class extends B{#e=!1;async getIFrameContent(){return new Promise(r=>{let e=`get-content-${Date.now()}`,t=i=>{let{data:s}=i;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="getContentResponse"&&s?.messageId===e&&(window.removeEventListener("message",t),r(s.content))};window.addEventListener("message",t),this.sendMessageToIframe("getContent",{messageId:e}),setTimeout(()=>{window.removeEventListener("message",t),r("")},5e3)})}setTestContext(r){this.context=r,this.updateComplete.then(()=>{this.value=r?.variables?.find(e=>e.identifier===this.responseIdentifier).value})}async recreateIframe(){this.#e=!0;try{return this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),new Promise(r=>{let e=()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()};this.addEventListener("qti-portable-custom-interaction-loaded",e),setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",e),r()},5e3)})}finally{this.#e=!1}}disconnectedCallback(){this.#e||super.disconnectedCallback()}async iFrameMouseClick(r,e){return new Promise(t=>{let i=`click-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t())};window.addEventListener("message",s),this.sendMessageToIframe("simulateClick",{x:r,y:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t()},5e3)})}async iFrameClickOnElement(r){return new Promise(e=>{let t=`click-selector-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameClickOnElementByText(r){return new Promise(e=>{let t=`click-text-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="clickTextResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("clickOnElementByText",{text:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}async iFrameSetValueElement(r,e){return new Promise(t=>{let i=`set-value-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("setValueElement",{selector:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameGetBoundingClientRect(r){return new Promise(e=>{let t=`get-bounding-rect-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="getBoundingRectResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.rect??null))};window.addEventListener("message",i),this.sendMessageToIframe("getBoundingRect",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(null)},5e3)})}async iFrameSetValueElementByText(r,e){return new Promise(t=>{let i=`set-value-text-${Date.now()}`,s=n=>{let{data:a}=n;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueByTextResponse"&&a?.messageId===i&&(window.removeEventListener("message",s),t(a.success))};window.addEventListener("message",s),this.sendMessageToIframe("setValueElementByText",{text:r,value:e,messageId:i}),setTimeout(()=>{window.removeEventListener("message",s),t(!1)},5e3)})}async iFrameMousedownOnElement(r){return new Promise(e=>{let t=`mousedown-selector-${Date.now()}`,i=s=>{let{data:n}=s;n?.source==="qti-pci-iframe"&&(!n?.responseIdentifier||n?.responseIdentifier===this.responseIdentifier)&&n?.method==="mousedownSelectorResponse"&&n?.messageId===t&&(window.removeEventListener("message",i),e(n.success))};window.addEventListener("message",i),this.sendMessageToIframe("mousedownOnSelector",{selector:r,messageId:t}),setTimeout(()=>{window.removeEventListener("message",i),e(!1)},5e3)})}generateIframeContent(){let r=super.generateIframeContent(),e=`
5523
5575
  // Test helper functions for QtiPortableCustomInteractionTest
5524
5576
  // Base iframe implementation already provides PCIManager.getContent
5525
5577
 
@@ -5728,7 +5780,7 @@ CES.load();
5728
5780
  display: inline-block;
5729
5781
  position: relative;
5730
5782
  }
5731
- `]}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};customElements.define("qti-position-object-interaction",ps);customElements.define("qti-position-object-stage",us);var Ja="important",ec=" !"+Ja,uo=te(class extends xe{constructor(o){if(super(o),o.type!==je.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(ec);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?Ja:""):e[t]=i}}return z}});var De=class extends R{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this.#e=null;this.#t=1;this.#r=1;this.#i=0;this.#s=0;this.#o=e=>{if(this.disabled)return;if(!this.#e){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.#a();let t=this.#e.getBoundingClientRect(),i=(e.clientX-t.left)*this.#t,s=(e.clientY-t.top)*this.#r,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.#n=()=>{this.#a()}}static{this.styles=[y`
5783
+ `]}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};customElements.define("qti-position-object-interaction",ps);customElements.define("qti-position-object-stage",us);var Ka="important",tc=" !"+Ka,uo=te(class extends xe{constructor(o){if(super(o),o.type!==je.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(tc);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?Ka:""):e[t]=i}}return z}});var De=class extends R{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this.#e=null;this.#t=1;this.#i=1;this.#r=0;this.#s=0;this.#o=e=>{if(this.disabled)return;if(!this.#e){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.#a();let t=this.#e.getBoundingClientRect(),i=(e.clientX-t.left)*this.#t,s=(e.clientY-t.top)*this.#i,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.#n=()=>{this.#a()}}static{this.styles=[y`
5732
5784
  :host {
5733
5785
  display: block;
5734
5786
  }
@@ -5743,9 +5795,9 @@ CES.load();
5743
5795
  height: auto;
5744
5796
  display: block;
5745
5797
  }
5746
- `]}#e;#t;#r;#i;#s;#o;connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.#n)}#n;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=>X.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.#e;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.#a(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&tt(n,s.split(",").map(a=>+a),t,i)}))}render(){return f` <slot name="prompt"></slot>
5798
+ `]}#e;#t;#i;#r;#s;#o;connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.#n)}#n;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=>X.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.#e;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.#a(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&tt(n,s.split(",").map(a=>+a),t,i)}))}render(){return f` <slot name="prompt"></slot>
5747
5799
  <point-container>
5748
- ${er((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this.#i||1)*100,a=s/(this.#s||1)*100,l=16,d=l/(this.#i||1)*100,p=l/(this.#s||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),f`
5800
+ ${er((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this.#r||1)*100,a=s/(this.#s||1)*100,l=16,d=l/(this.#r||1)*100,p=l/(this.#s||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),f`
5749
5801
  <button
5750
5802
  part="point${m}"
5751
5803
  style=${uo({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"})}
@@ -5761,7 +5813,7 @@ CES.load();
5761
5813
  data-shape="${e.shape}"
5762
5814
  ></div>`)}
5763
5815
  <slot></slot>
5764
- </point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}#a(){this.#i=this.#e.getAttribute("width")?parseFloat(this.#e.getAttribute("width")):this.#e.naturalWidth,this.#s=this.#e.getAttribute("height")?parseFloat(this.#e.getAttribute("height")):this.#e.naturalHeight;let e=this.#e.getBoundingClientRect();this.#t=e.width===0?1:this.#i/e.width,this.#r=e.height===0?1:this.#s/e.height}firstUpdated(){this.#e=this.querySelector("img"),this.#e?(this.#a(),this.#e.addEventListener("click",this.#o)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.#n),this.#e&&this.#e.removeEventListener("click",this.#o)}};c([u({type:Number,attribute:"max-choices"})],De.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],De.prototype,"minChoices",2),c([w()],De.prototype,"response",2),c([w()],De.prototype,"_correctAreas",2),c([w()],De.prototype,"_responseCorrection",2);customElements.define("qti-select-point-interaction",De);var Ka=y`
5816
+ </point-container>`}validate(){return this.response!==null&&this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}#a(){this.#r=this.#e.getAttribute("width")?parseFloat(this.#e.getAttribute("width")):this.#e.naturalWidth,this.#s=this.#e.getAttribute("height")?parseFloat(this.#e.getAttribute("height")):this.#e.naturalHeight;let e=this.#e.getBoundingClientRect();this.#t=e.width===0?1:this.#r/e.width,this.#i=e.height===0?1:this.#s/e.height}firstUpdated(){this.#e=this.querySelector("img"),this.#e?(this.#a(),this.#e.addEventListener("click",this.#o)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.#n),this.#e&&this.#e.removeEventListener("click",this.#o)}};c([u({type:Number,attribute:"max-choices"})],De.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],De.prototype,"minChoices",2),c([w()],De.prototype,"response",2),c([w()],De.prototype,"_correctAreas",2),c([w()],De.prototype,"_responseCorrection",2);customElements.define("qti-select-point-interaction",De);var Za=y`
5765
5817
  :host {
5766
5818
  display: block;
5767
5819
  --show-bounds: true;
@@ -5841,7 +5893,7 @@ CES.load();
5841
5893
  text-align: center;
5842
5894
  color: #6b7280; /* text-gray-500 */
5843
5895
  }
5844
- `;var ot=class extends R{constructor(){super(...arguments);this.#e=0;this.#t=null;this.min=0;this.max=100;this.step=1}static{this.styles=Ka}#e;#t;validate(){return!0}connectedCallback(){super.connectedCallback(),this.#r(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this.#e.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this.#r(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this.#t=null;else{this.#t=i;let s=(this.#t-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this.#t=null;this.requestUpdate()}}#r(e){let t=this.#e;if(this.#e=Math.min(this.max,Math.max(this.min,e)),this.#e===t)return;let i=(this.#e-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return f`
5896
+ `;var ot=class extends R{constructor(){super(...arguments);this.#e=0;this.#t=null;this.min=0;this.max=100;this.step=1}static{this.styles=Za}#e;#t;validate(){return!0}connectedCallback(){super.connectedCallback(),this.#i(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this.#e.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this.#i(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this.#t=null;else{this.#t=i;let s=(this.#t-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this.#t=null;this.requestUpdate()}}#i(e){let t=this.#e;if(this.#e=Math.min(this.max,Math.max(this.min,e)),this.#e===t)return;let i=(this.#e-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return f`
5845
5897
  <slot name="prompt"></slot>
5846
5898
  <div id="slider" part="slider">
5847
5899
  <div id="bounds" part="bounds">
@@ -5851,7 +5903,7 @@ CES.load();
5851
5903
 
5852
5904
  <div id="ticks" part="ticks"></div>
5853
5905
 
5854
- <div id="rail" part="rail" @mousedown=${this.#i} @touchstart=${this.#s}>
5906
+ <div id="rail" part="rail" @mousedown=${this.#r} @touchstart=${this.#s}>
5855
5907
  <div id="knob" part="knob">
5856
5908
  <div id="value" part="value">${this.response}</div>
5857
5909
  </div>
@@ -5863,7 +5915,7 @@ CES.load();
5863
5915
  `:null}
5864
5916
  </div>
5865
5917
  </div>
5866
- `}#i(e){this.#o(e.pageX);let t=s=>this.#n(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.#a()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}#s(e){this.#o(e.touches[0].pageX);let t=s=>this.#n(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this.#a()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}#o(e){this.#n(e)}#n(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.#r(n)}#a(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};c([Tt("#rail")],ot.prototype,"_rail",2),c([u({type:Number,attribute:"lower-bound"})],ot.prototype,"min",2),c([u({type:Number,attribute:"upper-bound"})],ot.prototype,"max",2),c([u({type:Number,attribute:"step"})],ot.prototype,"step",2);customElements.define("qti-slider-interaction",ot);var Za=()=>new ho,ho=class{},mo=new WeakMap,_w=te(class extends Xe{render(o){return L}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)),L}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=mo.get(r);e===void 0&&(e=new WeakMap,mo.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"?mo.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 el=y`
5918
+ `}#r(e){this.#o(e.pageX);let t=s=>this.#n(s.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this.#a()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}#s(e){this.#o(e.touches[0].pageX);let t=s=>this.#n(s.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this.#a()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}#o(e){this.#n(e)}#n(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.#i(n)}#a(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};c([Tt("#rail")],ot.prototype,"_rail",2),c([u({type:Number,attribute:"lower-bound"})],ot.prototype,"min",2),c([u({type:Number,attribute:"upper-bound"})],ot.prototype,"max",2),c([u({type:Number,attribute:"step"})],ot.prototype,"step",2);customElements.define("qti-slider-interaction",ot);var el=()=>new ho,ho=class{},mo=new WeakMap,Lw=te(class extends Xe{render(o){return L}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)),L}rt(o){if(this.isConnected||(o=void 0),typeof this.G=="function"){let r=this.ht??globalThis,e=mo.get(r);e===void 0&&(e=new WeakMap,mo.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"?mo.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 tl=y`
5867
5919
  :host {
5868
5920
  display: inline-block;
5869
5921
  }
@@ -5971,7 +6023,7 @@ CES.load();
5971
6023
  bottom: 0;
5972
6024
  }
5973
6025
  }
5974
- `;var ge=class extends R{constructor(){super(...arguments);this.inputRef=Za();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=el}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,s)=>Math.max(s.mappedValue,i),0);for(let i of e.mapping.mapEntries){let s=i.mapKey,n=e.value;if(i.caseSensitive||(s=s.toLowerCase(),n=n.toLowerCase()),s===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return f`
6026
+ `;var ge=class extends R{constructor(){super(...arguments);this.inputRef=el();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=tl}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,s)=>Math.max(s.mappedValue,i),0);for(let i of e.mapping.mapEntries){let s=i.mapKey,n=e.value;if(i.caseSensitive||(s=s.toLowerCase(),n=n.toLowerCase()),s===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return f`
5975
6027
  <input
5976
6028
  part="input"
5977
6029
  name="${this.responseIdentifier}"
@@ -6002,9 +6054,9 @@ CES.load();
6002
6054
  `]}render(){return f`
6003
6055
  <div>
6004
6056
  <slot name="prompt"></slot>
6005
- <input type="file" @change="${this.#r}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
6057
+ <input type="file" @change="${this.#i}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
6006
6058
  </div>
6007
- `}async#r(r){let e=r.target;e.files&&e.files.length>0&&(this.#e=e.files[0],this.#t=await this.#i(this.#e),this.saveResponse(this.#t),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#t}})))}#i(r){return new Promise((e,t)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=()=>t(i.error),i.readAsDataURL(r)})}};customElements.define("qti-upload-interaction",ms);var hs=class extends b{static{this.styles=y`
6059
+ `}async#i(r){let e=r.target;e.files&&e.files.length>0&&(this.#e=e.files[0],this.#t=await this.#r(this.#e),this.saveResponse(this.#t),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#t}})))}#r(r){return new Promise((e,t)=>{let i=new FileReader;i.onload=()=>e(i.result),i.onerror=()=>t(i.error),i.readAsDataURL(r)})}};customElements.define("qti-upload-interaction",ms);var hs=class extends b{static{this.styles=y`
6008
6060
  :host {
6009
6061
  display: flex;
6010
6062
  user-select: none;
@@ -6020,24 +6072,24 @@ CES.load();
6020
6072
  display: flex;
6021
6073
  user-select: none;
6022
6074
  }
6023
- `}connectedCallback(){this.setAttribute("slot","drags")}};c([u({type:Number,reflect:!0})],li.prototype,"tabindex",2);customElements.define("qti-gap-img",li);var tl={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function pe(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.internals.ariaChecked="false",this.disabled&&(this.tabIndex=-1),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.code==="Enter")&&(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 f`<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:tl})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:tl})],e.prototype,"readonly",2),c([O("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ci=class extends pe(b,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}static{this.styles=y`
6075
+ `}connectedCallback(){this.setAttribute("slot","drags")}};c([u({type:Number,reflect:!0})],li.prototype,"tabindex",2);customElements.define("qti-gap-img",li);var rl={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ue(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.internals.ariaChecked="false",this.disabled&&(this.tabIndex=-1),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.code==="Enter")&&(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 f`<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:rl})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:rl})],e.prototype,"readonly",2),c([O("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ci=class extends ue(b,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}static{this.styles=y`
6024
6076
  :host {
6025
6077
  display: inline-flex;
6026
6078
  user-select: none;
6027
6079
  }
6028
- `}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return f`<slot></slot>`}};c([u({type:Number,reflect:!0})],ci.prototype,"tabindex",2);customElements.define("qti-gap-text",ci);var tr=class extends pe(b,"qti-hotspot-choice"){static{this.styles=y`
6080
+ `}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return f`<slot></slot>`}};c([u({type:Number,reflect:!0})],ci.prototype,"tabindex",2);customElements.define("qti-gap-text",ci);var tr=class extends ue(b,"qti-hotspot-choice"){static{this.styles=y`
6029
6081
  :host {
6030
6082
  display: flex;
6031
6083
  user-select: none;
6032
6084
  position: absolute;
6033
6085
  }
6034
- `}};c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],tr.prototype,"order",2),c([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],tr.prototype,"orderCorrect",2);customElements.define("qti-hotspot-choice",tr);var fs=class extends pe(b,"qti-hottext"){static{this.styles=y`
6086
+ `}};c([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],tr.prototype,"order",2),c([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],tr.prototype,"orderCorrect",2);customElements.define("qti-hotspot-choice",tr);var fs=class extends ue(b,"qti-hottext"){static{this.styles=y`
6035
6087
  :host {
6036
6088
  display: flex;
6037
6089
  user-select: none;
6038
6090
  }
6039
6091
  `}render(){return f`<div part="ch"><div part="cha"></div></div>
6040
- <slot></slot> `}};customElements.define("qti-hottext",fs);var tc=y`
6092
+ <slot></slot> `}};customElements.define("qti-hottext",fs);var rc=y`
6041
6093
  :host {
6042
6094
  display: block;
6043
6095
  box-sizing: border-box;
@@ -6046,7 +6098,7 @@ CES.load();
6046
6098
  slot {
6047
6099
  display: inline;
6048
6100
  }
6049
- `,rl=tc;var di=class extends pe(b,"qti-inline-choice"){static{this.styles=rl}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.#e),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this.#e)}render(){return f` <slot></slot> `}#e(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],di.prototype,"identifier",2);customElements.define("qti-inline-choice",di);var gs=class extends b{render(){return f`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",gs);var Ct=class extends pe(b,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}static{this.styles=y`
6101
+ `,il=rc;var di=class extends ue(b,"qti-inline-choice"){static{this.styles=il}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.#e),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this.#e)}render(){return f` <slot></slot> `}#e(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],di.prototype,"identifier",2);customElements.define("qti-inline-choice",di);var gs=class extends b{render(){return f`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",gs);var Ct=class extends ue(b,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}static{this.styles=y`
6050
6102
  :host {
6051
6103
  display: flex;
6052
6104
  user-select: none;
@@ -6061,7 +6113,7 @@ CES.load();
6061
6113
  `}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return f`
6062
6114
  <slot part="slot"></slot>
6063
6115
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
6064
- `}};c([u({type:Number,attribute:"match-min"})],Ct.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Ct.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ct.prototype,"fixed",2);customElements.define("qti-simple-associable-choice",Ct);var il=y`
6116
+ `}};c([u({type:Number,attribute:"match-min"})],Ct.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Ct.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ct.prototype,"fixed",2);customElements.define("qti-simple-associable-choice",Ct);var sl=y`
6065
6117
  :host {
6066
6118
  display: flex;
6067
6119
  align-items: center;
@@ -6078,11 +6130,11 @@ CES.load();
6078
6130
  align-items: center;
6079
6131
  justify-content: center;
6080
6132
  }
6081
- `;var nt=class extends pe(b,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}static{this.styles=il}get checked(){return this.internals.states.has("--checked")}render(){return f`<div part="ch">
6133
+ `;var nt=class extends ue(b,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}static{this.styles=sl}get checked(){return this.internals.states.has("--checked")}render(){return f`<div part="ch">
6082
6134
  <div part="cha"></div>
6083
6135
  </div>
6084
6136
  ${this.marker?f`<div id="label">${this.marker}</div>`:L}
6085
- <slot part="slot"></slot>`}};c([u({type:String,attribute:"template-identifier"})],nt.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],nt.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],nt.prototype,"fixed",2),c([u({type:String,attribute:!1})],nt.prototype,"marker",2);customElements.define("qti-simple-choice",nt);var HT=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await Cn().load(`${o}`).then(a=>a.assessmentTest()),t=await It().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await It().load(`${r}/${e.href}`).then(a=>a.items()),s=`${r}/${e.href}`,n=`${r}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:t,testURI:n,testURL:s,items:i,testIdentifier:e.identifier}},zT=async o=>ve().load(o).then(r=>r.htmlDoc().firstElementChild);var Me=class extends b{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};Me=c([C("qti-rule")],Me);var pi=class extends Me{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:vr(t)}})),t)}};c([u({type:String})],pi.prototype,"identifier",2),c([M({context:D,subscribe:!0}),w()],pi.prototype,"context",2);customElements.define("qti-lookup-outcome-value",pi);var fo=class extends Me{render(){return f`<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",fo);var go=class extends Me{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 bo(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.#e(i)}}))}#e(r){return Array.isArray(r)?r.map(vr):r!==null?vr(r):null}},bo=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",go);var ui=class extends b{render(){return f`<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",ui);var mi=class extends ui{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",mi);var vo=class extends mi{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",vo);var bs=class extends rc(le){calculate(){return this.calculateChildren(Array.from(this.children))}};bs=c([C("qti-and")],bs);function rc(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 vs=class extends S{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],vs.prototype,"baseType",2);customElements.define("qti-base-value",vs);var yo=class extends S{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",yo);var xo=class extends le{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",xo);var qo=class extends S{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",qo);var rr=class extends S{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})],rr.prototype,"identifier",2),c([M({context:D,subscribe:!0}),w()],rr.prototype,"context",2),c([w(),M({context:ye,subscribe:!0})],rr.prototype,"_testContext",2);customElements.define("qti-default",rr);var ys=class extends S{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})],ys.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",ys);var Co=class extends S{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",Co);var hi=class extends S{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.#e(i,this.figures):this.#t(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#e(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}#t(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"})],hi.prototype,"roundingMode",2),c([u({type:Number})],hi.prototype,"figures",2);customElements.define("qti-round-to",hi);var xs=class extends S{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):X.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],xs.prototype,"toleranceMode",2);customElements.define("qti-equal",xs);var wo=class extends S{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.#e(e)}#e(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.#t(e,Math.abs(r[t])),e!==1);t++);return e}#t(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",wo);var Eo=class extends S{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",Eo);var To=class extends le{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",To);var Ao=class extends S{getResult(){return null}};customElements.define("qti-null",Ao);var So=class extends S{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",So);var Mo=class extends S{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",Mo);var ko=class extends S{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",ko);var Io=class extends le{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",Io);var qs=class extends S{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?X.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):X.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})],qs.prototype,"identifier",2);customElements.define("qti-map-response",qs);var Cs=class extends S{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;X.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})],Cs.prototype,"identifier",2);customElements.define("qti-map-response-point",Cs);var ws=class extends S{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.#e(this.name,t)}#e(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})],ws.prototype,"name",2);customElements.define("qti-math-operator",ws);var Ro=class o extends S{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):X.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(!X.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(X.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",Ro);var _o=class extends S{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",_o);var Lo=class extends S{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",Lo);var $o=class extends S{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",$o);var Oo=class extends le{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",Oo);var Po=class extends S{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",Po);var Vo=class extends S{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",Vo);var fi=class extends b{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?L:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],fi.prototype,"identifier",2),c([M({context:D,subscribe:!0}),w()],fi.prototype,"context",2);customElements.define("qti-printed-variable",fi);var No=class extends S{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",No);var Es=class extends ic(S){getResult(){return this.calculateChildren(Array.from(this.children))}};function ic(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",Es);var Ts=class extends S{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 X.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],Ts.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ts);var Do=class extends S{#e;constructor(){super(),this.#e=new Ho(Array.from(this.children))}getResult(){return this.#e.calculate()}},Ho=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",Do);var zo=class extends S{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",zo);var ir=class extends S{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})],ir.prototype,"min",2),c([u({type:Number})],ir.prototype,"max",2),c([u({type:Number})],ir.prototype,"step",2);customElements.define("qti-random-integer",ir);var Uo=class extends S{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",Uo);var Bo=class extends S{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))}return null}};customElements.define("qti-delete",Bo);var As,sl,gi=class extends S{constructor(){super(...arguments);T(this,As)}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 e=this.getVariables()[0];if(!e)return console.error("qti-index: missing container"),null;let t;if(!isNaN(Number(this.n)))t=Number(this.n);else{let i=I(this,As,sl).call(this,this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;t=Number(i)}if(t<=0||!Number.isInteger(t))return console.error("qti-index: index must be a positive integer"),null;if(e.cardinality==="ordered"){let i=Array.isArray(e.value)?e.value:[e.value];return e.value===null||t>i.length?null:i[t-1]}else return console.error("qti-index: child must have ordered cardinality"),null}};As=new WeakSet,sl=function(e){let t=this.context.variables.find(i=>i.identifier===e)?.value;return t===null||isNaN(Number(t))?null:Number(t)},c([u({type:String})],gi.prototype,"n",2),gi=c([C("qti-index")],gi);export{_n as Correctness,Ws as INITIAL_SESSION_CONTEXT,Xs as INITIAL_TEST_CONTEXT,R as Interaction,Qs as IsNullOrUndefined,Pe as ItemContainer,xt as ItemCorrectResponseMode,Kt as ItemPrintVariables,he as ItemShowCandidateCorrection,fe as ItemShowCorrectResponse,bs as QtiAnd,ie as QtiAssessmentItem,Re as QtiAssessmentItemRef,_e as QtiAssessmentSection,Nt as QtiAssessmentStimulusRef,Zs as QtiAssessmentStimulusRefConnectedEvent,ht as QtiAssessmentTest,hs as QtiAssociableHotspot,ii as QtiAssociateInteraction,vs as QtiBaseValue,si as QtiChoiceInteraction,Vi as QtiCompanionMaterialsInfo,le as QtiConditionExpression,yo as QtiContainerSize,xo as QtiContains,Ni as QtiContentBody,gt as QtiContextDeclaration,qo as QtiCorrect,Ve as QtiCustomInteraction,kr as QtiCustomOperator,rr as QtiDefault,Bo as QtiDelete,et as QtiEndAttemptInteraction,xs as QtiEqual,ys as QtiEqualRounded,S as QtiExpression,ne as QtiExtendedTextInteraction,re as QtiFeedback,Rr as QtiFeedbackBlock,_r as QtiFeedbackInline,Mo as QtiFieldValue,ai as QtiGap,li as QtiGapImg,os as QtiGapMatchInteraction,ci as QtiGapText,wo as QtiGcd,Ne as QtiGraphicAssociateInteraction,ns as QtiGraphicGapMatchInteraction,as as QtiGraphicOrderInteraction,Eo as QtiGt,To as QtiGte,tr as QtiHotspotChoice,ls as QtiHotspotInteraction,fs as QtiHottext,oi as QtiHottextInteraction,gi as QtiIndex,di as QtiInlineChoice,rt as QtiInlineChoiceInteraction,So as QtiIsNull,Zt as QtiItem,Lr as QtiItemBody,pi as QtiLookupOutcomeValue,ko as QtiLt,Io as QtiLte,qs as QtiMapResponse,Cs as QtiMapResponsePoint,Ro as QtiMatch,it as QtiMatchInteraction,ws as QtiMathOperator,cs as QtiMediaInteraction,_o as QtiMember,ft as QtiModalFeedback,Lo as QtiMultiple,$o as QtiNot,Ao as QtiNull,Oo as QtiOr,st as QtiOrderInteraction,Po as QtiOrdered,we as QtiOutcomeDeclaration,B as QtiPortableCustomInteraction,ps as QtiPositionObjectInteraction,us as QtiPositionObjectStage,Vo as QtiPower,fi as QtiPrintedVariable,No as QtiProduct,gs as QtiPrompt,Uo as QtiRandom,ir as QtiRandomInteger,fo as QtiResponseCondition,$e as QtiResponseDeclaration,ui as QtiResponseElse,vo as QtiResponseElseIf,mi as QtiResponseIf,Or as QtiResponseProcessing,Co as QtiRound,hi as QtiRoundTo,Ce as QtiRubricBlock,Ln as QtiRuleElement,De as QtiSelectPointInteraction,go as QtiSetOutcomeValue,bo as QtiSetOutcomeValueRule,Ct as QtiSimpleAssociableChoice,nt as QtiSimpleChoice,ot as QtiSliderInteraction,Ts as QtiStringMatch,Di as QtiStylesheet,Es as QtiSubtract,Do as QtiSum,Ho as QtiSumExpression,Ee as QtiTemplateDeclaration,Pi as QtiTest,Pr as QtiTestFeedback,Le as QtiTestPart,ge as QtiTextEntryInteraction,ms as QtiUploadInteraction,zo as QtiVariable,Ot as QtiVariableDeclaration,X as ScoringHelper,Jr as TestCheckItem,Oe as TestContainer,Nr as TestEndAttempt,zt as TestItemLink,de as TestNavigation,Je as TestNext,Fr as TestPagingButtonsStamp,Ke as TestPrev,Qr as TestPrintContext,Ft as TestPrintVariables,yt as TestScoringButtons,Wt as TestScoringFeedback,Xr as TestSectionButtonsStamp,jt as TestSectionLink,me as TestShowCorrectResponse,vt as TestStamp,J as TestView,Yr as TestViewToggle,N as computedContext,Be as computedItemContext,ae as configContext,vr as convertNumberToUniversalFormat,Il as decimalSeparator,zT as getItemByUri,HT as getManifestInfo,D as itemContext,Tn as itemContextVariables,rc as qtiAndMixin,Lt as qtiContext,ic as qtiSubtractMixin,ve as qtiTransformItem,Cn as qtiTransformManifest,It as qtiTransformTest,Oi as removeDoubleSlashes,Fe as sessionContext,ye as testContext};
6137
+ <slot part="slot"></slot>`}};c([u({type:String,attribute:"template-identifier"})],nt.prototype,"templateIdentifier",2),c([u({type:String,attribute:"show-hide"})],nt.prototype,"showHide",2),c([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],nt.prototype,"fixed",2),c([u({type:String,attribute:!1})],nt.prototype,"marker",2);customElements.define("qti-simple-choice",nt);var zT=async o=>{let r=o.substring(0,o.lastIndexOf("/")),e=await Cn().load(`${o}`).then(a=>a.assessmentTest()),t=await It().load(`${r}/${e.href}`).then(a=>a.htmlDoc()),i=await It().load(`${r}/${e.href}`).then(a=>a.items()),s=`${r}/${e.href}`,n=`${r}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:t,testURI:n,testURL:s,items:i,testIdentifier:e.identifier}},UT=async o=>ve().load(o).then(r=>r.htmlDoc().firstElementChild);var ke=class extends b{render(){return f`<slot></slot>`}process(){throw new Error("Not implemented")}};ke=c([C("qti-rule")],ke);var pi=class extends ke{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:vr(t)}})),t)}};c([u({type:String})],pi.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],pi.prototype,"context",2);customElements.define("qti-lookup-outcome-value",pi);var fo=class extends ke{render(){return f`<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",fo);var go=class extends ke{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 bo(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.#e(i)}}))}#e(r){return Array.isArray(r)?r.map(vr):r!==null?vr(r):null}},bo=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",go);var ui=class extends b{render(){return f`<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",ui);var mi=class extends ui{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",mi);var vo=class extends mi{render(){return f`${super.render()}`}};customElements.define("qti-response-else-if",vo);var bs=class extends ic(ce){calculate(){return this.calculateChildren(Array.from(this.children))}};bs=c([C("qti-and")],bs);function ic(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 vs=class extends S{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],vs.prototype,"baseType",2);customElements.define("qti-base-value",vs);var yo=class extends S{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",yo);var xo=class extends ce{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",xo);var qo=class extends S{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",qo);var rr=class extends S{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})],rr.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],rr.prototype,"context",2),c([w(),k({context:ye,subscribe:!0})],rr.prototype,"_testContext",2);customElements.define("qti-default",rr);var ys=class extends S{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})],ys.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",ys);var Co=class extends S{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",Co);var hi=class extends S{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.#e(i,this.figures):this.#t(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#e(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}#t(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"})],hi.prototype,"roundingMode",2),c([u({type:Number})],hi.prototype,"figures",2);customElements.define("qti-round-to",hi);var xs=class extends S{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):X.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],xs.prototype,"toleranceMode",2);customElements.define("qti-equal",xs);var wo=class extends S{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.#e(e)}#e(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.#t(e,Math.abs(r[t])),e!==1);t++);return e}#t(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",wo);var Eo=class extends S{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",Eo);var To=class extends ce{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",To);var Ao=class extends S{getResult(){return null}};customElements.define("qti-null",Ao);var So=class extends S{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",So);var ko=class extends S{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",ko);var Mo=class extends S{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",Mo);var Io=class extends ce{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",Io);var qs=class extends S{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?X.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):X.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})],qs.prototype,"identifier",2);customElements.define("qti-map-response",qs);var Cs=class extends S{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;X.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})],Cs.prototype,"identifier",2);customElements.define("qti-map-response-point",Cs);var ws=class extends S{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.#e(this.name,t)}#e(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})],ws.prototype,"name",2);customElements.define("qti-math-operator",ws);var Ro=class o extends S{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):X.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(!X.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(X.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",Ro);var _o=class extends S{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",_o);var Lo=class extends S{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",Lo);var $o=class extends S{render(){return f`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",$o);var Oo=class extends ce{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",Oo);var Po=class extends S{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",Po);var Vo=class extends S{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",Vo);var fi=class extends b{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?L:f`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],fi.prototype,"identifier",2),c([k({context:D,subscribe:!0}),w()],fi.prototype,"context",2);customElements.define("qti-printed-variable",fi);var No=class extends S{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",No);var Es=class extends sc(S){getResult(){return this.calculateChildren(Array.from(this.children))}};function sc(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",Es);var Ts=class extends S{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 X.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],Ts.prototype,"caseSensitive",2);customElements.define("qti-string-match",Ts);var Do=class extends S{getResult(){return new Ho(Array.from(this.children)).calculate()}},Ho=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",Do);var zo=class extends S{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",zo);var ir=class extends S{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})],ir.prototype,"min",2),c([u({type:Number})],ir.prototype,"max",2),c([u({type:Number})],ir.prototype,"step",2);customElements.define("qti-random-integer",ir);var Uo=class extends S{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",Uo);var Bo=class extends S{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))}return null}};customElements.define("qti-delete",Bo);var As,ol,gi=class extends S{constructor(){super(...arguments);T(this,As)}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 e=this.getVariables()[0];if(!e)return console.error("qti-index: missing container"),null;let t;if(!isNaN(Number(this.n)))t=Number(this.n);else{let i=I(this,As,ol).call(this,this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;t=Number(i)}if(t<=0||!Number.isInteger(t))return console.error("qti-index: index must be a positive integer"),null;if(e.cardinality==="ordered"){let i=Array.isArray(e.value)?e.value:[e.value];return e.value===null||t>i.length?null:i[t-1]}else return console.error("qti-index: child must have ordered cardinality"),null}};As=new WeakSet,ol=function(e){let t=this.context.variables.find(i=>i.identifier===e)?.value;return t===null||isNaN(Number(t))?null:Number(t)},c([u({type:String})],gi.prototype,"n",2),gi=c([C("qti-index")],gi);export{_n as Correctness,Ws as INITIAL_SESSION_CONTEXT,Xs as INITIAL_TEST_CONTEXT,R as Interaction,Qs as IsNullOrUndefined,Pe as ItemContainer,xt as ItemCorrectResponseMode,Kt as ItemPrintVariables,he as ItemShowCandidateCorrection,fe as ItemShowCorrectResponse,bs as QtiAnd,ie as QtiAssessmentItem,Re as QtiAssessmentItemRef,_e as QtiAssessmentSection,Nt as QtiAssessmentStimulusRef,Zs as QtiAssessmentStimulusRefConnectedEvent,ht as QtiAssessmentTest,hs as QtiAssociableHotspot,ii as QtiAssociateInteraction,vs as QtiBaseValue,si as QtiChoiceInteraction,Vi as QtiCompanionMaterialsInfo,ce as QtiConditionExpression,yo as QtiContainerSize,xo as QtiContains,Ni as QtiContentBody,gt as QtiContextDeclaration,qo as QtiCorrect,Ve as QtiCustomInteraction,Mr as QtiCustomOperator,rr as QtiDefault,Bo as QtiDelete,et as QtiEndAttemptInteraction,xs as QtiEqual,ys as QtiEqualRounded,S as QtiExpression,ae as QtiExtendedTextInteraction,re as QtiFeedback,Rr as QtiFeedbackBlock,_r as QtiFeedbackInline,ko as QtiFieldValue,ai as QtiGap,li as QtiGapImg,os as QtiGapMatchInteraction,ci as QtiGapText,wo as QtiGcd,Ne as QtiGraphicAssociateInteraction,ns as QtiGraphicGapMatchInteraction,as as QtiGraphicOrderInteraction,Eo as QtiGt,To as QtiGte,tr as QtiHotspotChoice,ls as QtiHotspotInteraction,fs as QtiHottext,oi as QtiHottextInteraction,gi as QtiIndex,di as QtiInlineChoice,rt as QtiInlineChoiceInteraction,So as QtiIsNull,Zt as QtiItem,Lr as QtiItemBody,pi as QtiLookupOutcomeValue,Mo as QtiLt,Io as QtiLte,qs as QtiMapResponse,Cs as QtiMapResponsePoint,Ro as QtiMatch,it as QtiMatchInteraction,ws as QtiMathOperator,cs as QtiMediaInteraction,_o as QtiMember,ft as QtiModalFeedback,Lo as QtiMultiple,$o as QtiNot,Ao as QtiNull,Oo as QtiOr,st as QtiOrderInteraction,Po as QtiOrdered,we as QtiOutcomeDeclaration,B as QtiPortableCustomInteraction,ps as QtiPositionObjectInteraction,us as QtiPositionObjectStage,Vo as QtiPower,fi as QtiPrintedVariable,No as QtiProduct,gs as QtiPrompt,Uo as QtiRandom,ir as QtiRandomInteger,fo as QtiResponseCondition,$e as QtiResponseDeclaration,ui as QtiResponseElse,vo as QtiResponseElseIf,mi as QtiResponseIf,Or as QtiResponseProcessing,Co as QtiRound,hi as QtiRoundTo,Ce as QtiRubricBlock,Ln as QtiRuleElement,De as QtiSelectPointInteraction,go as QtiSetOutcomeValue,bo as QtiSetOutcomeValueRule,Ct as QtiSimpleAssociableChoice,nt as QtiSimpleChoice,ot as QtiSliderInteraction,Ts as QtiStringMatch,Di as QtiStylesheet,Es as QtiSubtract,Do as QtiSum,Ho as QtiSumExpression,Ee as QtiTemplateDeclaration,Pi as QtiTest,Pr as QtiTestFeedback,Le as QtiTestPart,ge as QtiTextEntryInteraction,ms as QtiUploadInteraction,zo as QtiVariable,Ot as QtiVariableDeclaration,X as ScoringHelper,Jr as TestCheckItem,Oe as TestContainer,Nr as TestEndAttempt,zt as TestItemLink,pe as TestNavigation,Je as TestNext,Fr as TestPagingButtonsStamp,Ke as TestPrev,Qr as TestPrintContext,Ft as TestPrintVariables,yt as TestScoringButtons,Wt as TestScoringFeedback,Xr as TestSectionButtonsStamp,jt as TestSectionLink,me as TestShowCorrectResponse,vt as TestStamp,J as TestView,Yr as TestViewToggle,N as computedContext,Be as computedItemContext,le as configContext,vr as convertNumberToUniversalFormat,Rl as decimalSeparator,UT as getItemByUri,zT as getManifestInfo,D as itemContext,Tn as itemContextVariables,ic as qtiAndMixin,Lt as qtiContext,sc as qtiSubtractMixin,ve as qtiTransformItem,Cn as qtiTransformManifest,It as qtiTransformTest,Oi as removeDoubleSlashes,Fe as sessionContext,ye as testContext};
6086
6138
  /*! Bundled license information:
6087
6139
 
6088
6140
  @lit-labs/ssr-dom-shim/lib/element-internals.js: