@citolab/qti-components 7.0.2 → 7.0.4
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.global.js +1 -1
- package/cdn/index.js +314 -212
- package/dist/custom-element-eslint-rules.js +8 -16
- package/dist/custom-elements.json +382 -199
- package/dist/index.d.ts +102 -63
- package/dist/index.js +592 -500
- package/dist/index.js.map +1 -1
- package/dist/item.css +34 -82
- package/dist/loader/index.d.ts +1 -1
- package/dist/loader/index.js +5 -0
- package/dist/loader/index.js.map +1 -1
- package/dist/qti-components-jsx.d.ts +109 -112
- package/dist/qti-simple-choice-CfgBEvdI.d.ts +1143 -0
- package/dist/qti-simple-choice-D0GiMrqD.d.ts +1168 -0
- package/dist/{qti-simple-choice-DG8ImdPz.d.ts → qti-simple-choice-UTrFa_RQ.d.ts} +9 -17
- package/dist/qti-simple-choice-zEsDq3c0.d.ts +1147 -0
- package/dist/transformers/index.d.ts +1 -0
- package/dist/transformers/index.js +5 -0
- package/dist/transformers/index.js.map +1 -1
- package/dist/vscode.css-custom-data.json +1 -37
- package/dist/vscode.html-custom-data.json +36 -21
- package/package.json +7 -4
- package/readme.md +55 -0
- package/README.md +0 -85
package/cdn/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
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 "${t}" has already been used with this registry`);e.__localName=t,this.__definitions.set(t,{ctor:e,observedAttributes:e.observedAttributes??[]})}get(t){return this.__definitions.get(t)?.ctor}},
|
|
3
|
-
\f\r]`,
|
|
4
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),Li=/'/g,$i=/"/g,Ni=/^(?:script|style|textarea|title)$/i,Pr=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),h=Pr(1),Hr=Pr(2),_n=Pr(3),R=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),Di=new WeakMap,Ee=Ce.createTreeWalker(Ce,129);function Pi(s,t){if(!Nr(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Si!==void 0?Si.createHTML(t):t}var Hi=(s,t)=>{let e=s.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=ot;for(let a=0;a<e;a++){let c=s[a],d,u,m=-1,f=0;for(;f<c.length&&(n.lastIndex=f,u=n.exec(c),u!==null);)f=n.lastIndex,n===ot?u[1]==="!--"?n=Ri:u[1]!==void 0?n=Mi:u[2]!==void 0?(Ni.test(u[2])&&(i=RegExp("</"+u[2],"g")),n=we):u[3]!==void 0&&(n=we):n===we?u[0]===">"?(n=i??ot,m=-1):u[1]===void 0?m=-2:(m=n.lastIndex-u[2].length,d=u[1],n=u[3]===void 0?we:u[3]==='"'?$i:Li):n===$i||n===Li?n=we:n===Ri||n===Mi?n=ot:(n=we,i=void 0);let y=n===we&&s[a+1].startsWith("/>")?" ":"";o+=n===ot?c+ro:m>=0?(r.push(d),c.slice(0,m)+Dr+c.slice(m)+oe+y):c+oe+(m===-2?a:y)}return[Pi(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},lt=class s{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[d,u]=Hi(t,e);if(this.el=s.createElement(d,r),Ee.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Ee.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Dr)){let f=u[n++],y=i.getAttribute(m).split(oe),x=/([.?@])?(.*)/.exec(f);c.push({type:1,index:o,name:x[2],strings:y,ctor:x[1]==="."?Wt:x[1]==="?"?Xt:x[1]==="@"?Yt:ke}),i.removeAttribute(m)}else m.startsWith(oe)&&(c.push({type:6,index:o}),i.removeAttribute(m));if(Ni.test(i.tagName)){let m=i.textContent.split(oe),f=m.length-1;if(f>0){i.textContent=Bt?Bt.emptyScript:"";for(let y=0;y<f;y++)i.append(m[y],nt()),Ee.nextNode(),c.push({type:2,index:++o});i.append(m[f],nt())}}}else if(i.nodeType===8)if(i.data===Ir)c.push({type:2,index:o});else{let m=-1;for(;(m=i.data.indexOf(oe,m+1))!==-1;)c.push({type:7,index:o}),m+=oe.length-1}o++}}static createElement(t,e){let r=Ce.createElement("template");return r.innerHTML=t,r}};function _e(s,t,e=s,r){if(t===R)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl,o=at(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=_e(s,i._$AS(s,t.values),i,r)),t}var jt=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??Ce).importNode(e,!0);Ee.currentNode=i;let o=Ee.nextNode(),n=0,a=0,c=r[0];for(;c!==void 0;){if(n===c.index){let d;c.type===2?d=new De(o,o.nextSibling,this,t):c.type===1?d=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(d=new Gt(o,this,t)),this._$AV.push(d),c=r[++a]}n!==c?.index&&(o=Ee.nextNode(),n++)}return Ee.currentNode=Ce,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},De=class s{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=_e(this,t,e),at(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==R&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ii(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==k&&at(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ce.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=lt.createElement(Pi(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new jt(i,this),n=o.u(this.options);o.p(e),this.T(n),this._$AH=o}}_$AC(t){let e=Di.get(t.strings);return e===void 0&&Di.set(t.strings,e=new lt(t)),e}k(t){Nr(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new s(this.O(nt()),this.O(nt()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},ke=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=k}_$AI(t,e=this,r,i){let o=this.strings,n=!1;if(o===void 0)t=_e(this,t,e,0),n=!at(t)||t!==this._$AH&&t!==R,n&&(this._$AH=t);else{let a=t,c,d;for(t=o[0],c=0;c<o.length-1;c++)d=_e(this,a[r+c],e,c),d===R&&(d=this._$AH[c]),n||(n=!at(d)||d!==this._$AH[c]),d===k?t=k:t!==k&&(t+=(d??"")+o[c+1]),this._$AH[c]=d}n&&!i&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Wt=class extends ke{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Xt=class extends ke{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Yt=class extends ke{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){if((t=_e(this,t,e,0)??k)===R)return;let r=this._$AH,i=t===k&&r!==k||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==k&&(r===k||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Gt=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){_e(this,t)}},M={M:Dr,P:oe,A:Ir,C:1,L:Hi,R:jt,D:Ii,V:_e,I:De,H:ke,N:Xt,U:Yt,B:Wt,F:Gt},io=$e.litHtmlPolyfillSupport;io?.(lt,De),($e.litHtmlVersions??($e.litHtmlVersions=[])).push("3.2.1");var Or=(s,t,e)=>{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let o=e?.renderBefore??null;r._$litPart$=i=new De(t.insertBefore(nt(),o),o,void 0,e??{})}return i._$AI(s),i};var v=class extends se{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Or(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};v._$litElement$=!0,v.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:v});var so=globalThis.litElementPolyfillSupport;so?.({LitElement:v});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");var g=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};var oo={attribute:!0,type:String,converter:st,reflect:!1,hasChanged:Ft},no=(s=oo,t,e)=>{let{kind:r,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(e.name,s),r==="accessor"){let{name:n}=e;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(r==="setter"){let{name:n}=e;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+r)};function p(s){return(t,e)=>typeof e=="object"?no(s,t,e):((r,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,n?{...r,wrapped:!0}:r),n?Object.getOwnPropertyDescriptor(i,o):void 0})(s,t,e)}function q(s){return p({...s,state:!0,attribute:!1})}var pe=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function Ie(s,t){return(e,r,i)=>{let o=n=>n.renderRoot?.querySelector(s)??null;if(t){let{get:n,set:a}=typeof r=="object"?e:i??(()=>{let c=Symbol();return{get(){return this[c]},set(d){this[c]=d}}})();return pe(e,r,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return pe(e,r,{get(){return o(this)}})}}function Oi(s){return(t,e)=>{let{slot:r,selector:i}=s??{},o="slot"+(r?`[name=${r}]`:":not([name])");return pe(t,e,{get(){let n=this.renderRoot?.querySelector(o),a=n?.assignedElements(s)??[];return i===void 0?a:a.filter(c=>c.matches(i))}})}}var B=Symbol("test"),Kt=Symbol("testElement");var Vi={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},j=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),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 h`${this.xmlDoc}`}};l([p({type:String})],j.prototype,"category",2),l([p({type:String})],j.prototype,"identifier",2),l([p({type:Boolean,converter:Vi})],j.prototype,"required",2),l([p({type:Boolean,converter:Vi})],j.prototype,"fixed",2),l([p({type:String})],j.prototype,"href",2),l([T({context:B,subscribe:!0})],j.prototype,"_testContext",2),l([p({type:Object,attribute:!1})],j.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",j);var Vr={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},W=class extends v{async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};l([p({type:String})],W.prototype,"identifier",2),l([p({type:String})],W.prototype,"required",2),l([p({type:Boolean,converter:Vr})],W.prototype,"fixed",2),l([p({type:String})],W.prototype,"title",2),l([p({type:Boolean,converter:Vr})],W.prototype,"visible",2),l([p({type:Boolean,converter:Vr,attribute:"keep-together"})],W.prototype,"keepTogether",2),l([T({context:B,subscribe:!0})],W.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",W);var Te=class extends v{async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([p({type:String})],Te.prototype,"identifier",2),l([p({type:String})],Te.prototype,"title",2),l([T({context:B,subscribe:!0})],Te.prototype,"_testContext",2),Te=l([g("qti-assessment-test")],Te);var X=class extends v{constructor(){super(...arguments);this.identifier="";this.title="";this.class="";this.NavigationMode="nonlinear";this.submissionMode="individual"}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([p({type:String})],X.prototype,"identifier",2),l([p({type:String})],X.prototype,"title",2),l([p({type:String})],X.prototype,"class",2),l([p({type:String,attribute:"navigation-mode"})],X.prototype,"NavigationMode",2),l([p({type:String,attribute:"submission-mode"})],X.prototype,"submissionMode",2),X=l([g("qti-test-part")],X);customElements.get("qti-test-part")||customElements.define("qti-test-part",X);var ao=String.raw,lo=ao`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
1
|
+
var ki=Object.defineProperty;var Bs=Object.getOwnPropertyDescriptor;var Xs=(s,t,e)=>t in s?ki(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var l=(s,t,e,r)=>{for(var i=r>1?void 0:r?Bs(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(i=(r?n(t,e,i):n(i))||i);return r&&i&&ki(t,e,i),i};var P=(s,t,e)=>Xs(s,typeof t!="symbol"?t+"":t,e);var ue=class extends Event{constructor(t,e,r){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=r??!1}};var $e=class{constructor(t,e,r,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(o,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=o,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(o,n)),this.unsubscribe=n},this.host=t,e.context!==void 0){let o=e;this.context=o.context,this.callback=o.callback,this.subscribe=o.subscribe??!1}else this.context=e,this.callback=r,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.t,this.subscribe))}};var Xt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let r=e||!Object.is(t,this.o);this.o=t,r&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:r}]of this.subscriptions)e(this.o,r)},t!==void 0&&(this.value=t)}addCallback(t,e,r){if(!r)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var Ir=class extends Event{constructor(t){super("context-provider",{bubbles:!0,composed:!0}),this.context=t}},De=class extends Xt{constructor(t,e,r){super(e.context!==void 0?e.initialValue:r),this.onContextRequest=i=>{let o=i.composedPath()[0];i.context===this.context&&o!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,o,i.subscribe))},this.onProviderRequest=i=>{let o=i.composedPath()[0];if(i.context!==this.context||o===this.host)return;let n=new Set;for(let[a,{consumerHost:c}]of this.subscriptions)n.has(a)||(n.add(a),c.dispatchEvent(new ue(this.context,a,!0)));i.stopPropagation()},this.host=t,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 Ir(this.context))}};function Ie({context:s}){return(t,e)=>{let r=new WeakMap;if(typeof e=="object")return e.addInitializer(function(){r.set(this,new De(this,{context:s}))}),{get(){return t.get.call(this)},set(i){return r.get(this)?.setValue(i),t.set.call(this,i)},init(i){return r.get(this)?.setValue(i),i}};{t.constructor.addInitializer(n=>{r.set(n,new De(n,{context:s}))});let i=Object.getOwnPropertyDescriptor(t,e),o;if(i===void 0){let n=new WeakMap;o={get(){return n.get(this)},set(a){r.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;o={...i,set(a){r.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(t,e,o)}}}function A({context:s,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer(function(){new $e(this,{context:s,callback:i=>{e.set.call(this,i)},subscribe:t})}):e.constructor.addInitializer(i=>{new $e(i,{context:s,callback:o=>{i[r]=o},subscribe:t})})}}var Ai=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(t){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=t}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var Si=new WeakMap,ot=s=>{let t=Si.get(s);return t===void 0&&Si.set(s,t=new Map),t},js=class{constructor(){this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(ot(this)).map(([t,e])=>({name:t,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(t,e){ot(this).set(t,String(e))}removeAttribute(t){ot(this).delete(t)}toggleAttribute(t,e){if(this.hasAttribute(t)){if(e===void 0||!e)return this.removeAttribute(t),!1}else return e===void 0||e?(this.setAttribute(t,""),!0):!1;return!0}hasAttribute(t){return ot(this).has(t)}attachShadow(t){let e={host:this};return this.__shadowRootMode=t.mode,t&&t.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 t=new Ai(this);return this.__internals=t,t}getAttribute(t){return ot(this).get(t)??null}};var Ws=class extends js{},Mi=Ws;var Ys=class{constructor(){this.__definitions=new Map}define(t,e){if(this.__definitions.has(t))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${t}" 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 "${t}" has already been used with this registry`);e.__localName=t,this.__definitions.set(t,{ctor:e,observedAttributes:e.observedAttributes??[]})}get(t){return this.__definitions.get(t)?.ctor}},Gs=Ys;var Ri=new Gs;var nt=globalThis,jt=nt.ShadowRoot&&(nt.ShadyCSS===void 0||nt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Nr=Symbol(),Li=new WeakMap,at=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Nr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(jt&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Li.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Li.set(e,t))}return t}toString(){return this.cssText}},$i=s=>new at(typeof s=="string"?s:s+"",void 0,Nr),b=(s,...t)=>{let e=s.length===1?s[0]:t.reduce((r,i,o)=>r+(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)+s[o+1],s[0]);return new at(e,s,Nr)},Hr=(s,t)=>{if(jt)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=nt.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,s.appendChild(r)}},Wt=jt||nt.CSSStyleSheet===void 0?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return $i(e)})(s):s;var{is:Ks,defineProperty:Js,getOwnPropertyDescriptor:Zs,getOwnPropertyNames:Qs,getOwnPropertySymbols:eo,getPrototypeOf:to}=Object,z=globalThis;z.customElements??(z.customElements=Ri);var Di=z.trustedTypes,ro=Di?Di.emptyScript:"",io=z.reactiveElementPolyfillSupport,lt=(s,t)=>s,ct={toAttribute(s,t){switch(t){case Boolean:s=s?ro:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},Yt=(s,t)=>!Ks(s,t),Ii={attribute:!0,type:String,converter:ct,reflect:!1,hasChanged:Yt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),z.litPropertyMetadata??(z.litPropertyMetadata=new WeakMap);var se=class extends(globalThis.HTMLElement??Mi){static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ii){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&Js(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){let{get:i,set:o}=Zs(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return i?.call(this)},set(n){let a=i?.call(this);o.call(this,n),this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ii}static _$Ei(){if(this.hasOwnProperty(lt("elementProperties")))return;let t=to(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(lt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(lt("properties"))){let e=this.properties,r=[...Qs(e),...eo(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let i of r)e.unshift(Wt(i))}else t!==void 0&&e.push(Wt(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.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(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Hr(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let o=(r.converter?.toAttribute!==void 0?r.converter:ct).toAttribute(e,r.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let o=r.getPropertyOptions(i),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:ct;this._$Em=i,this[i]=n.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){if(r??(r=this.constructor.getPropertyOptions(t)),!(r.hasChanged??Yt)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,o]of r)o.wrapped!==!0||this._$AL.has(i)||this[i]===void 0||this.P(i,this[i],o)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EU()}catch(r){throw t=!1,this._$EU(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};se.elementStyles=[],se.shadowRootOptions={mode:"open"},se[lt("elementProperties")]=new Map,se[lt("finalized")]=new Map,io?.({ReactiveElement:se}),(z.reactiveElementVersions??(z.reactiveElementVersions=[])).push("2.0.4");var Ne=globalThis,Gt=Ne.trustedTypes,Ni=Gt?Gt.createPolicy("lit-html",{createHTML:s=>s}):void 0,Vr="$lit$",oe=`lit$${Math.random().toFixed(9).slice(2)}$`,Pr="?"+oe,so=`<${Pr}>`,ke=Ne.document===void 0?{createTreeWalker:()=>({})}:document,pt=()=>ke.createComment(""),ht=s=>s===null||typeof s!="object"&&typeof s!="function",zr=Array.isArray,Ui=s=>zr(s)||typeof s?.[Symbol.iterator]=="function",Or=`[
|
|
3
|
+
\f\r]`,dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Hi=/-->/g,Oi=/>/g,Ce=RegExp(`>|${Or}(?:([^\\s"'>=/]+)(${Or}*=${Or}*(?:[^
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Vi=/'/g,Pi=/"/g,Fi=/^(?:script|style|textarea|title)$/i,Ur=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),h=Ur(1),Fr=Ur(2),Tn=Ur(3),M=Symbol.for("lit-noChange"),k=Symbol.for("lit-nothing"),zi=new WeakMap,_e=ke.createTreeWalker(ke,129);function Bi(s,t){if(!zr(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ni!==void 0?Ni.createHTML(t):t}var Xi=(s,t)=>{let e=s.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=dt;for(let a=0;a<e;a++){let c=s[a],d,m,g=-1,f=0;for(;f<c.length&&(n.lastIndex=f,m=n.exec(c),m!==null);)f=n.lastIndex,n===dt?m[1]==="!--"?n=Hi:m[1]!==void 0?n=Oi:m[2]!==void 0?(Fi.test(m[2])&&(i=RegExp("</"+m[2],"g")),n=Ce):m[3]!==void 0&&(n=Ce):n===Ce?m[0]===">"?(n=i??dt,g=-1):m[1]===void 0?g=-2:(g=n.lastIndex-m[2].length,d=m[1],n=m[3]===void 0?Ce:m[3]==='"'?Pi:Vi):n===Pi||n===Vi?n=Ce:n===Hi||n===Oi?n=dt:(n=Ce,i=void 0);let y=n===Ce&&s[a+1].startsWith("/>")?" ":"";o+=n===dt?c+so:g>=0?(r.push(d),c.slice(0,g)+Vr+c.slice(g)+oe+y):c+oe+(g===-2?a:y)}return[Bi(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},ut=class s{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[d,m]=Xi(t,e);if(this.el=s.createElement(d,r),_e.currentNode=this.el.content,e===2||e===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(i=_e.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let g of i.getAttributeNames())if(g.endsWith(Vr)){let f=m[n++],y=i.getAttribute(g).split(oe),x=/([.?@])?(.*)/.exec(f);c.push({type:1,index:o,name:x[2],strings:y,ctor:x[1]==="."?Jt:x[1]==="?"?Zt:x[1]==="@"?Qt:Ae}),i.removeAttribute(g)}else g.startsWith(oe)&&(c.push({type:6,index:o}),i.removeAttribute(g));if(Fi.test(i.tagName)){let g=i.textContent.split(oe),f=g.length-1;if(f>0){i.textContent=Gt?Gt.emptyScript:"";for(let y=0;y<f;y++)i.append(g[y],pt()),_e.nextNode(),c.push({type:2,index:++o});i.append(g[f],pt())}}}else if(i.nodeType===8)if(i.data===Pr)c.push({type:2,index:o});else{let g=-1;for(;(g=i.data.indexOf(oe,g+1))!==-1;)c.push({type:7,index:o}),g+=oe.length-1}o++}}static createElement(t,e){let r=ke.createElement("template");return r.innerHTML=t,r}};function Te(s,t,e=s,r){if(t===M)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl,o=ht(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=Te(s,i._$AS(s,t.values),i,r)),t}var Kt=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??ke).importNode(e,!0);_e.currentNode=i;let o=_e.nextNode(),n=0,a=0,c=r[0];for(;c!==void 0;){if(n===c.index){let d;c.type===2?d=new He(o,o.nextSibling,this,t):c.type===1?d=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(d=new er(o,this,t)),this._$AV.push(d),c=r[++a]}n!==c?.index&&(o=_e.nextNode(),n++)}return _e.currentNode=ke,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},He=class s{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=k,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Te(this,t,e),ht(t)?t===k||t==null||t===""?(this._$AH!==k&&this._$AR(),this._$AH=k):t!==this._$AH&&t!==M&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ui(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==k&&ht(this._$AH)?this._$AA.nextSibling.data=t:this.T(ke.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=ut.createElement(Bi(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new Kt(i,this),n=o.u(this.options);o.p(e),this.T(n),this._$AH=o}}_$AC(t){let e=zi.get(t.strings);return e===void 0&&zi.set(t.strings,e=new ut(t)),e}k(t){zr(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new s(this.O(pt()),this.O(pt()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Ae=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=k,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=k}_$AI(t,e=this,r,i){let o=this.strings,n=!1;if(o===void 0)t=Te(this,t,e,0),n=!ht(t)||t!==this._$AH&&t!==M,n&&(this._$AH=t);else{let a=t,c,d;for(t=o[0],c=0;c<o.length-1;c++)d=Te(this,a[r+c],e,c),d===M&&(d=this._$AH[c]),n||(n=!ht(d)||d!==this._$AH[c]),d===k?t=k:t!==k&&(t+=(d??"")+o[c+1]),this._$AH[c]=d}n&&!i&&this.j(t)}j(t){t===k?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Jt=class extends Ae{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===k?void 0:t}},Zt=class extends Ae{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==k)}},Qt=class extends Ae{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){if((t=Te(this,t,e,0)??k)===M)return;let r=this._$AH,i=t===k&&r!==k||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==k&&(r===k||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},er=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Te(this,t)}},R={M:Vr,P:oe,A:Pr,C:1,L:Xi,R:Kt,D:Ui,V:Te,I:He,H:Ae,N:Zt,U:Qt,B:Jt,F:er},oo=Ne.litHtmlPolyfillSupport;oo?.(ut,He),(Ne.litHtmlVersions??(Ne.litHtmlVersions=[])).push("3.2.1");var Br=(s,t,e)=>{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let o=e?.renderBefore??null;r._$litPart$=i=new He(t.insertBefore(pt(),o),o,void 0,e??{})}return i._$AI(s),i};var v=class extends se{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Br(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return M}};v._$litElement$=!0,v.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:v});var no=globalThis.litElementPolyfillSupport;no?.({LitElement:v});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");var u=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};var ao={attribute:!0,type:String,converter:ct,reflect:!1,hasChanged:Yt},lo=(s=ao,t,e)=>{let{kind:r,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(e.name,s),r==="accessor"){let{name:n}=e;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(r==="setter"){let{name:n}=e;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+r)};function p(s){return(t,e)=>typeof e=="object"?lo(s,t,e):((r,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,n?{...r,wrapped:!0}:r),n?Object.getOwnPropertyDescriptor(i,o):void 0})(s,t,e)}function q(s){return p({...s,state:!0,attribute:!1})}var me=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function Oe(s,t){return(e,r,i)=>{let o=n=>n.renderRoot?.querySelector(s)??null;if(t){let{get:n,set:a}=typeof r=="object"?e:i??(()=>{let c=Symbol();return{get(){return this[c]},set(d){this[c]=d}}})();return me(e,r,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return me(e,r,{get(){return o(this)}})}}function ji(s){return(t,e)=>{let{slot:r,selector:i}=s??{},o="slot"+(r?`[name=${r}]`:":not([name])");return me(t,e,{get(){let n=this.renderRoot?.querySelector(o),a=n?.assignedElements(s)??[];return i===void 0?a:a.filter(c=>c.matches(i))}})}}var F=Symbol("test"),tr=Symbol("testElement");var Wi={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},B=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),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 h`${this.xmlDoc}`}};l([p({type:String})],B.prototype,"category",2),l([p({type:String})],B.prototype,"identifier",2),l([p({type:Boolean,converter:Wi})],B.prototype,"required",2),l([p({type:Boolean,converter:Wi})],B.prototype,"fixed",2),l([p({type:String})],B.prototype,"href",2),l([A({context:F,subscribe:!0})],B.prototype,"_testContext",2),l([p({type:Object,attribute:!1})],B.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",B);var Xr={fromAttribute(s){return s==="true"},toAttribute(s){return s?"true":"false"}},X=class extends v{async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};l([p({type:String})],X.prototype,"identifier",2),l([p({type:String})],X.prototype,"required",2),l([p({type:Boolean,converter:Xr})],X.prototype,"fixed",2),l([p({type:String})],X.prototype,"title",2),l([p({type:Boolean,converter:Xr})],X.prototype,"visible",2),l([p({type:Boolean,converter:Xr,attribute:"keep-together"})],X.prototype,"keepTogether",2),l([A({context:F,subscribe:!0})],X.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",X);var Se=class extends v{async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([p({type:String})],Se.prototype,"identifier",2),l([p({type:String})],Se.prototype,"title",2),l([A({context:F,subscribe:!0})],Se.prototype,"_testContext",2),Se=l([u("qti-assessment-test")],Se);var j=class extends v{constructor(){super(...arguments);this.identifier="";this.title="";this.class="";this.NavigationMode="nonlinear";this.submissionMode="individual"}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};l([p({type:String})],j.prototype,"identifier",2),l([p({type:String})],j.prototype,"title",2),l([p({type:String})],j.prototype,"class",2),l([p({type:String,attribute:"navigation-mode"})],j.prototype,"NavigationMode",2),l([p({type:String,attribute:"submission-mode"})],j.prototype,"submissionMode",2),j=l([u("qti-test-part")],j);customElements.get("qti-test-part")||customElements.define("qti-test-part",j);var co=String.raw,po=co`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
5
5
|
<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" />
|
|
6
6
|
<xsl:template match="@*|node()">
|
|
7
7
|
<xsl:copy>
|
|
@@ -23,37 +23,37 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
23
23
|
<xsl:apply-templates/>
|
|
24
24
|
</xsl:element>
|
|
25
25
|
</xsl:template>
|
|
26
|
-
</xsl:stylesheet>`;function
|
|
26
|
+
</xsl:stylesheet>`;function Yi(s,t,e){s.querySelectorAll(t).forEach(r=>{let i=`${t}-${e}`,o=Ki(r,i);r.replaceWith(o)})}function Gi(s,t){s.querySelectorAll("*").forEach(e=>{let r=e.classList;r&&r.forEach(i=>{if(i.startsWith(`${t}:`)){let o=i.slice(`${t}:`.length),n=`${e.nodeName}-${o}`,a=Ki(e,n);e.replaceWith(a)}})})}function Ki(s,t){let e=document.createElement(t);for(let r of s.attributes)e.setAttribute(r.name,r.value);for(;s.firstChild;)e.appendChild(s.firstChild);return e}function Ji(s){let t=[];return s.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let r=e.getAttribute("identifier"),i=e.getAttribute("href"),o=e.getAttribute("category");t.push({identifier:r,href:i,category:o})}),t}var jr=null;function mt(s,t=!1){return t&&jr!==null&&jr.abort(),new Promise((e,r)=>{let i=new XMLHttpRequest;jr=i,i.open("GET",s,!0),i.responseType="document",i.onload=()=>{i.status>=200&&i.status<300?e(i.responseXML):r(i.statusText)},i.onerror=()=>{r(i.statusText)},i.send()})}function gt(s){return new DOMParser().parseFromString(s,"text/xml")}function Ve(s){let t=new XSLTProcessor,e=new DOMParser().parseFromString(po,"text/xml");return t.importStylesheet(e),t.transformToFragment(s,document)}function rr(s,t){t.endsWith("/")||(t+="/"),s.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let r="";e.getAttribute("src")&&(r="src"),e.getAttribute("href")&&(r="href"),e.getAttribute("primary-path")&&(r="primary-path");let i=e.getAttribute(r)?.trim();if(!i.startsWith("data:")&&!i.startsWith("http")){let o=t+encodeURI(i);e.setAttribute(r,o)}})}function Zi(s){s.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let r=document.createComment(e.textContent);e.replaceChild(r,e.firstChild)})}function Qi(s){s.querySelectorAll("qti-stylesheet").forEach(t=>t.remove())}var Me=()=>{let s,t={async load(e,r=!1){return new Promise(i=>{mt(e,r).then(o=>(s=o,t.path(e.substring(0,e.lastIndexOf("/"))),i(t)))})},parse(e){return s=gt(e),t},path:e=>(rr(s,e),t),fn(e){return e(s),t},pciHooks(e){let r=["hook","module"],i=e.substring(0,e.lastIndexOf("/"));for(let o of r)s.querySelectorAll("["+o+"]").forEach(a=>{let c=a.getAttribute(o);!c.startsWith("data:")&&!c.startsWith("http")&&(a.setAttribute("base-url",e),a.setAttribute("module",i+"/"+encodeURI(c+(c.endsWith(".js")?"":".js"))))});return t},extendElementName:(e,r)=>(Yi(s,e,r),t),extendElementsWithClass:(e="extend")=>(Gi(s,e),t),customInteraction(e,r){let i=s.querySelector("qti-custom-interaction"),o=i.querySelector("object");return i.setAttribute("data-base-ref",e),i.setAttribute("data-base-item",e+r),i.setAttribute("data",o.getAttribute("data")),i.setAttribute("width",o.getAttribute("width")),i.setAttribute("height",o.getAttribute("height")),i.removeChild(o),t},convertCDATAtoComment(){return Zi(s),t},stripStyleSheets(){return Qi(s),t},html(){return new XMLSerializer().serializeToString(Ve(s))},xml(){return new XMLSerializer().serializeToString(s)},htmlDoc(){return Ve(s)},xmlDoc(){return s}};return t};var Wr=()=>{let s,t={async load(e){return new Promise((r,i)=>{mt(e).then(o=>(s=o,t.path(e.substring(0,e.lastIndexOf("/"))),r(t)))})},parse(e){return s=gt(e),t},path:e=>(rr(s,e),t),fn(e){return e(s),t},items(){return Ji(s)},html(){return new XMLSerializer().serializeToString(Ve(s))},xml(){return new XMLSerializer().serializeToString(s)},htmlDoc(){return Ve(s)},xmlDoc(){return s}};return t};var es=s=>{class t extends s{constructor(...i){super(...i);this.testURL="";this.addEventListener("qti-assessment-test-connected",()=>{}),this.addEventListener("qti-load-item-request",({detail:o})=>{o.promise=(async()=>(await Me().load(`${o.href}`,o.cancelPreviousRequest)).htmlDoc())()}),this.addEventListener("qti-interaction-changed",o=>{}),this.addEventListener("qti-outcome-changed",()=>{})}}return t};var ts=s=>{class t extends s{constructor(...r){super(...r),this.addEventListener("qti-request-test-item",({detail:i})=>{if(!i)return;this._clearLoadedItems();let o=this.testElement.el.querySelector(`qti-assessment-item-ref[identifier="${i}"]`),n=this._loadItemRequest(o.href,!1),a=o.closest("qti-test-part").identifier,c=o.closest("qti-assessment-section").identifier;this._testContext={...this._testContext,navPartId:a,navSectionId:c,navItemId:i,navItemLoading:!0},n?n.then(d=>{o.xmlDoc=d,requestAnimationFrame(()=>this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0}))),this._testContext={...this._testContext,navItemLoading:!1}}).catch(d=>console.error("Failed to load item:",d)):console.info("Load item request was not handled:",o.href)}),this.addEventListener("qti-assessment-test-connected",()=>{let i=this._testContext.navItemId;i||(i=this.testElement.el.querySelector("qti-assessment-item-ref").identifier),this.dispatchEvent(new CustomEvent("qti-request-test-item",{detail:i,bubbles:!0,composed:!0}))})}_clearLoadedItems(){let r=this.testElement.el.querySelectorAll("qti-assessment-test qti-assessment-item-ref");Array.from(r).forEach(i=>{i.xmlDoc=null})}_loadItemRequest(r,i=!0){let o=new CustomEvent("qti-load-item-request",{bubbles:!0,composed:!0,detail:{href:r,promise:null,cancelPreviousRequest:i}});return this.dispatchEvent(o),o.detail.promise}}return t};var rs=s=>{class t extends s{constructor(...r){super(...r),this._testContext={...this._testContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this._testContext={...this._testContext,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(r){super.willUpdate(r),r.has("_testContext")&&this._updateElementView()}_updateElementView(){if(this.testElement&&this.testElement.el){Array.from(this.testElement.el.querySelectorAll("[view]")).forEach(o=>{o.classList.toggle("show",o.getAttribute("view")===this._testContext.view)});let i=this.testElement.el.querySelector(`qti-assessment-item[identifier="${this._testContext.navItemId}"]`);i&&i.showCorrectResponse(this._testContext.view==="scorer")}}_setCorrectResponseVisibility(r){r.showCorrectResponse(this._testContext.view==="scorer")}}return t};var Pe=class extends v{constructor(){super();this._testContext={items:[],testOutcomeVariables:[]};this.testElement={el:null};this._updateItemInTestContext=e=>{let{identifier:r,variables:i}=e,o=this._testContext.items.find(n=>n?.identifier===r);if(!o){console.warn(`Item IDs between assessment.xml and item.xml should match: ${r} is not found!`);return}o.variables?.length===1?this._updateItemVariablesInTestContext(r,i):e.variables=[...o.variables||[]]};this.addEventListener("qti-assessment-test-connected",e=>{let r=e.detail,i=Array.from(r.querySelectorAll("qti-assessment-item-ref")).map(o=>({href:o.href,identifier:o.identifier,category:o.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testElement={el:r},this._testContext={...this._testContext,items:i}}),this.addEventListener("qti-assessment-item-connected",e=>{this._updateItemInTestContext(e.detail)}),this.addEventListener("qti-outcome-changed",e=>{let r=e.composedPath()[0];this._updateItemVariablesInTestContext(r.identifier,r.variables)})}get context(){return this._testContext}set context(e){e!=null&&(this._testContext={...e},e.items?.forEach(r=>{let i=this._testContext.items.find(o=>o.identifier===r.identifier);i?i.variables=r.variables:this._testContext.items.push(r)}))}_updateItemVariablesInTestContext(e,r){this._testContext={...this._testContext,items:this._testContext.items.map(i=>i.identifier!==e?i:{...i,variables:r.map(o=>{let n=i.variables.find(a=>a.identifier===o.identifier);return n?{...n,...o}:o})})}}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-test","")}};l([q(),Ie({context:F})],Pe.prototype,"_testContext",2),l([q(),Ie({context:tr})],Pe.prototype,"testElement",2);var ir=class extends es(ts(rs(Pe))){render(){return h`<slot></slot>`}};ir=l([u("qti-test")],ir);var is=b`
|
|
27
27
|
display: inline-flex;
|
|
28
28
|
align-items: center;
|
|
29
29
|
cursor: pointer;
|
|
30
30
|
padding: 0.5rem 1rem;
|
|
31
31
|
border-radius: 0.25rem;
|
|
32
32
|
user-select: none;
|
|
33
|
-
`,
|
|
33
|
+
`,ze=b`
|
|
34
34
|
background-color: lightgray;
|
|
35
|
-
${
|
|
36
|
-
`,
|
|
35
|
+
${is};
|
|
36
|
+
`,Ue=b`
|
|
37
37
|
cursor: not-allowed;
|
|
38
38
|
opacity: 0.5;
|
|
39
|
-
`,
|
|
40
|
-
${
|
|
39
|
+
`,Al=b`
|
|
40
|
+
${is};
|
|
41
41
|
border: 1px solid gray;
|
|
42
|
-
`;function
|
|
42
|
+
`;function sr(s,t){let e;return(r,i)=>{let{connectedCallback:o,disconnectedCallback:n}=r;r.connectedCallback=function(){o.call(this);let a=d=>{let m=Array.from(this.querySelectorAll(s)).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[]));for(let g of d){let f=Array.from(g.addedNodes).map(x=>x),y=Array.from(g.addedNodes).map(x=>x);g.type==="childList"&&f.find(x=>m.includes(x))&&this[i](f,y)}};e=new MutationObserver(a),e.observe(this,{childList:!0,subtree:!0});let c=Array.from(this.querySelectorAll(s)).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[]));this[i](Array.from(c),[])},r.disconnectedCallback=function(){n.call(this),e.disconnect()}}}function T(s,t){let e={waitUntilFirstUpdate:!1,...t};return(r,i)=>{let{update:o}=r,n=Array.isArray(s)?s:[s];r.update=function(a){n.forEach(c=>{let d=c;if(a.has(d)){let m=a.get(d),g=this[d];m!==g&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](m,g)}}),o.call(this,a)}}}function ss(s){return(t,e)=>{p(s)(t,e);let r=`__${e}`;Object.defineProperty(t,e,{get(){return this[r]},set(i){let o=this[r];if(this[r]=i,o!==i){if(this._internals?.states){let n=e.toLowerCase();i?this._internals.states.add(`--${n}`):this._internals.states.delete(`--${n}`)}if(s.aria&&this._internals){let n=s.aria;i?this._internals[n]="true":this._internals[n]=null}this.requestUpdate(e,o)}},configurable:!0,enumerable:!0})}}var L=class extends v{constructor(){super();this.disabled=!0;this._internals=this.attachInternals()}_handleTestElementChange(e,r){r.el&&(this.disabled=!1)}willUpdate(e){if(e.has("_testContext")){let{items:r=[],navItemId:i}=this._testContext??{};this.itemIndex=r.findIndex(o=>o.identifier===i),this.items=r,this.view=this._testContext?.view}}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-test-item",{composed:!0,bubbles:!0,detail:e}))}};l([ss({type:Boolean,reflect:!0,aria:"ariaDisabled"})],L.prototype,"disabled",2),l([q(),A({context:F,subscribe:!0})],L.prototype,"_testContext",2),l([q(),A({context:tr,subscribe:!0})],L.prototype,"_testElement",2),l([T("_testElement")],L.prototype,"_handleTestElementChange",1);var ft=class extends L{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex+1].identifier)})}willUpdate(t){super.willUpdate(t),t.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex<0||this.itemIndex>=this.items.length-1)}render(){return h`<slot></slot>`}};ft.styles=b`
|
|
43
43
|
:host {
|
|
44
|
-
${
|
|
44
|
+
${ze};
|
|
45
45
|
}
|
|
46
46
|
:host([disabled]) {
|
|
47
|
-
${
|
|
47
|
+
${Ue};
|
|
48
48
|
}
|
|
49
|
-
`,
|
|
49
|
+
`,ft=l([u("test-next")],ft);var bt=class extends L{constructor(){super(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this.disabled||this._requestItem(this.items[this.itemIndex-1].identifier)})}willUpdate(t){super.willUpdate(t),t.has("_testContext")&&(this.disabled=!this._testElement?.el||this.itemIndex===0||this.itemIndex===-1)}render(){return h`<slot></slot>`}};bt.styles=b`
|
|
50
50
|
:host {
|
|
51
|
-
${
|
|
51
|
+
${ze};
|
|
52
52
|
}
|
|
53
53
|
:host([disabled]) {
|
|
54
|
-
${
|
|
54
|
+
${Ue};
|
|
55
55
|
}
|
|
56
|
-
`,
|
|
56
|
+
`,bt=l([u("test-prev")],bt);var W=class extends L{constructor(){super(...arguments);this.label="view";this.viewOptions="";this._handleViewOptionsChange=(e,r)=>{console.log(r)};this._viewOptions=W.DEFAULT_VIEW_OPTIONS}render(){return h`
|
|
57
57
|
<label part="label" for="viewSelect">${this.label}</label>
|
|
58
58
|
<select
|
|
59
59
|
part="select"
|
|
@@ -63,7 +63,14 @@ Make sure to test your application with a production build as repeat registratio
|
|
|
63
63
|
>
|
|
64
64
|
${this._viewOptions.map(e=>h`<option value="${e}" ?selected=${e===this.view}>${e}</option>`)}
|
|
65
65
|
</select>
|
|
66
|
-
`}};
|
|
66
|
+
`}};W.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],l([p({type:String})],W.prototype,"label",2),l([p({type:String,attribute:"view-options"})],W.prototype,"viewOptions",2),l([T("viewOptions")],W.prototype,"_handleViewOptionsChange",2),W=l([u("test-view")],W);var Fe=class extends L{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}render(){return h` <slot></slot> `}};Fe.styles=b`
|
|
67
|
+
:host {
|
|
68
|
+
${ze};
|
|
69
|
+
}
|
|
70
|
+
:host([disabled]) {
|
|
71
|
+
${Ue};
|
|
72
|
+
}
|
|
73
|
+
`,l([p({type:String,attribute:"item-id"})],Fe.prototype,"itemId",2),Fe=l([u("test-item-link")],Fe);var{I:ho}=R,ns=s=>s===null||typeof s!="object"&&typeof s!="function";var as=s=>s.strings===void 0,os=()=>document.createComment(""),Be=(s,t,e)=>{let r=s._$AA.parentNode,i=t===void 0?s._$AB:t._$AA;if(e===void 0){let o=r.insertBefore(os(),i),n=r.insertBefore(os(),i);e=new ho(o,n,s,s.options)}else{let o=e._$AB.nextSibling,n=e._$AM,a=n!==s;if(a){let c;e._$AQ?.(s),e._$AM=s,e._$AP!==void 0&&(c=s._$AU)!==n._$AU&&e._$AP(c)}if(o!==i||a){let c=e._$AA;for(;c!==o;){let d=c.nextSibling;r.insertBefore(c,i),c=d}}}return e},ge=(s,t,e=s)=>(s._$AI(t,e),s),uo={},ls=(s,t=uo)=>s._$AH=t,cs=s=>s._$AH,or=s=>{s._$AP?.(!1,!0);let t=s._$AA,e=s._$AB.nextSibling;for(;t!==e;){let r=t.nextSibling;t.remove(),t=r}};var fe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},U=s=>(...t)=>({_$litDirective$:s,values:t}),Y=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var vt=(s,t)=>{let e=s._$AN;if(e===void 0)return!1;for(let r of e)r._$AO?.(t,!1),vt(r,t);return!0},nr=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while(e?.size===0)},ds=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),fo(t)}};function mo(s){this._$AN!==void 0?(nr(this),this._$AM=s,ds(this)):this._$AM=s}function go(s,t=!1,e=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let o=e;o<r.length;o++)vt(r[o],!1),nr(r[o]);else r!=null&&(vt(r,!1),nr(r));else vt(this,s)}var fo=s=>{s.type==fe.CHILD&&(s._$AP??(s._$AP=go),s._$AQ??(s._$AQ=mo))},Xe=class extends Y{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),ds(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(vt(this,t),nr(this))}setValue(t){if(as(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var ar=class{constructor(t){this.Y=t}disconnect(){this.Y=void 0}reconnect(t){this.Y=t}deref(){return this.Y}},lr=class{constructor(){this.Z=void 0,this.q=void 0}get(){return this.Z}pause(){this.Z??(this.Z=new Promise(t=>this.q=t))}resume(){this.q?.(),this.Z=this.q=void 0}};var ps=s=>!ns(s)&&typeof s.then=="function",hs=1073741823,Gr=class extends Xe{constructor(){super(...arguments),this._$Cwt=hs,this._$Cbt=[],this._$CK=new ar(this),this._$CX=new lr}render(...t){return t.find(e=>!ps(e))??M}update(t,e){let r=this._$Cbt,i=r.length;this._$Cbt=e;let o=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let c=e[a];if(!ps(c))return this._$Cwt=a,c;a<i&&c===r[a]||(this._$Cwt=hs,i=0,Promise.resolve(c).then(async d=>{for(;n.get();)await n.get();let m=o.deref();if(m!==void 0){let g=m._$Cbt.indexOf(c);g>-1&&g<m._$Cwt&&(m._$Cwt=g,m.setValue(d))}}))}return M}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},cr=U(Gr);var dr=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
|
|
67
74
|
|
|
68
75
|
:root,
|
|
69
76
|
:host {
|
|
@@ -2411,20 +2418,6 @@ qti-response-declaration {
|
|
|
2411
2418
|
|
|
2412
2419
|
& qti-gap {
|
|
2413
2420
|
|
|
2414
|
-
&[enabled] {
|
|
2415
|
-
|
|
2416
|
-
/* Light theme override */
|
|
2417
|
-
.qti-selections-light & {
|
|
2418
|
-
border-color: var(--qti-light-border-active);
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
|
-
/* Dark theme override */
|
|
2422
|
-
.qti-selections-dark & {
|
|
2423
|
-
border-color: var(--qti-dark-border-active);
|
|
2424
|
-
}
|
|
2425
|
-
background-color: var(--qti-bg-active)
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2428
2421
|
&[disabled] {
|
|
2429
2422
|
|
|
2430
2423
|
&:not(:empty) {
|
|
@@ -2442,6 +2435,20 @@ qti-response-declaration {
|
|
|
2442
2435
|
outline: 4px solid var(--qti-disabled-bg)
|
|
2443
2436
|
}
|
|
2444
2437
|
|
|
2438
|
+
&[enabled] {
|
|
2439
|
+
|
|
2440
|
+
/* Light theme override */
|
|
2441
|
+
.qti-selections-light & {
|
|
2442
|
+
border-color: var(--qti-light-border-active);
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
/* Dark theme override */
|
|
2446
|
+
.qti-selections-dark & {
|
|
2447
|
+
border-color: var(--qti-dark-border-active);
|
|
2448
|
+
}
|
|
2449
|
+
background-color: var(--qti-bg-active)
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2445
2452
|
&[active] {
|
|
2446
2453
|
|
|
2447
2454
|
/* Light theme override */
|
|
@@ -2824,12 +2831,22 @@ qti-response-declaration {
|
|
|
2824
2831
|
}
|
|
2825
2832
|
|
|
2826
2833
|
qti-match-interaction:not(.qti-match-tabular) {
|
|
2834
|
+
&:state(--dragzone-enabled) qti-simple-match-set:first-of-type {
|
|
2835
|
+
background-color: var(--qti-bg-active);
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
&:state(--dragzone-active) qti-simple-match-set:first-of-type {
|
|
2839
|
+
border-color: var(--qti-border-active);
|
|
2840
|
+
background-color: var(--qti-bg-active);
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2827
2843
|
/* The draggables */
|
|
2828
2844
|
& qti-simple-match-set:first-of-type {
|
|
2829
2845
|
display: flex;
|
|
2830
2846
|
flex-wrap: wrap;
|
|
2831
2847
|
align-items: flex-start; /* Prevents children from stretching */
|
|
2832
2848
|
gap: var(--qti-gap-size);
|
|
2849
|
+
border: 2px solid transparent;
|
|
2833
2850
|
|
|
2834
2851
|
& qti-simple-associable-choice {
|
|
2835
2852
|
|
|
@@ -3221,6 +3238,16 @@ qti-response-declaration {
|
|
|
3221
3238
|
}
|
|
3222
3239
|
|
|
3223
3240
|
qti-associate-interaction {
|
|
3241
|
+
/* General styles for active and enabled states */
|
|
3242
|
+
&:state(--dragzone-active) slot[name='qti-simple-associable-choice'] {
|
|
3243
|
+
border-color: var(--qti-border-active);
|
|
3244
|
+
background-color: var(--qti-bg-active);
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
&:state(--dragzone-enabled) slot[name='qti-simple-associable-choice'] {
|
|
3248
|
+
background-color: var(--qti-bg-active);
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3224
3251
|
& qti-simple-associable-choice, /* drags when in lightdom */
|
|
3225
3252
|
&::part(qti-simple-associable-choice) /* drags when in shadowdom */ {
|
|
3226
3253
|
|
|
@@ -3523,76 +3550,8 @@ qti-response-declaration {
|
|
|
3523
3550
|
}
|
|
3524
3551
|
|
|
3525
3552
|
qti-slider-interaction {
|
|
3526
|
-
display: block;
|
|
3527
|
-
|
|
3528
3553
|
--qti-tick-color: rgb(229 231 235 / 100%);
|
|
3529
3554
|
--qti-tick-width: 1px;
|
|
3530
|
-
|
|
3531
|
-
&::part(slider) {
|
|
3532
|
-
margin-left: 2rem; /* mx-8 */
|
|
3533
|
-
margin-right: 2rem;
|
|
3534
|
-
padding-bottom: 1rem; /* pb-4 */
|
|
3535
|
-
padding-top: 1.25rem; /* pt-5 */
|
|
3536
|
-
}
|
|
3537
|
-
|
|
3538
|
-
--show-bounds: true;
|
|
3539
|
-
|
|
3540
|
-
&::part(bounds) {
|
|
3541
|
-
display: flex;
|
|
3542
|
-
width: 100%;
|
|
3543
|
-
justify-content: space-between;
|
|
3544
|
-
margin-bottom: 0.5rem; /* mb-2 */
|
|
3545
|
-
}
|
|
3546
|
-
|
|
3547
|
-
--show-ticks: true;
|
|
3548
|
-
|
|
3549
|
-
&::part(ticks) {
|
|
3550
|
-
margin-left: 0.125rem; /* mx-0.5 */
|
|
3551
|
-
margin-right: 0.125rem;
|
|
3552
|
-
margin-bottom: 0.25rem; /* mb-1 */
|
|
3553
|
-
height: 0.5rem; /* h-2 */
|
|
3554
|
-
background: linear-gradient(to right, var(--qti-tick-color) var(--qti-tick-width), transparent 1px) repeat-x 0
|
|
3555
|
-
center / calc(calc(100% - var(--qti-tick-width)) / ((var(--max) - var(--min)) / var(--step))) 100%;
|
|
3556
|
-
}
|
|
3557
|
-
|
|
3558
|
-
&::part(rail) {
|
|
3559
|
-
display: flex;
|
|
3560
|
-
align-items: center;
|
|
3561
|
-
box-sizing: border-box;
|
|
3562
|
-
height: 0.375rem; /* h-1.5 */
|
|
3563
|
-
width: 100%;
|
|
3564
|
-
cursor: pointer;
|
|
3565
|
-
border-radius: 9999px; /* rounded-full */
|
|
3566
|
-
border: 1px solid #d1d5db; /* border-gray-300 */
|
|
3567
|
-
background-color: #e5e7eb; /* bg-gray-200 */
|
|
3568
|
-
}
|
|
3569
|
-
|
|
3570
|
-
&::part(knob) {
|
|
3571
|
-
background-color: var(--qti-primary);
|
|
3572
|
-
position: relative;
|
|
3573
|
-
height: 1rem; /* h-4 */
|
|
3574
|
-
width: 1rem; /* w-4 */
|
|
3575
|
-
transform-origin: center;
|
|
3576
|
-
transform: translateX(-50%);
|
|
3577
|
-
cursor: pointer;
|
|
3578
|
-
border-radius: 9999px; /* rounded-full */
|
|
3579
|
-
left: var(--value-percentage);
|
|
3580
|
-
}
|
|
3581
|
-
|
|
3582
|
-
--show-value: true;
|
|
3583
|
-
|
|
3584
|
-
&::part(value) {
|
|
3585
|
-
position: absolute;
|
|
3586
|
-
bottom: 2rem; /* bottom-8 */
|
|
3587
|
-
left: 0.5rem; /* left-2 */
|
|
3588
|
-
transform: translateX(-50%);
|
|
3589
|
-
cursor: pointer;
|
|
3590
|
-
border-radius: 0.25rem; /* rounded */
|
|
3591
|
-
background-color: #f3f4f6; /* bg-gray-100 */
|
|
3592
|
-
padding: 0.25rem 0.5rem; /* px-2 py-1 */
|
|
3593
|
-
text-align: center;
|
|
3594
|
-
color: #6b7280; /* text-gray-500 */
|
|
3595
|
-
}
|
|
3596
3555
|
}
|
|
3597
3556
|
|
|
3598
3557
|
qti-select-point-interaction {
|
|
@@ -3633,30 +3592,34 @@ qti-response-declaration {
|
|
|
3633
3592
|
width: 100%;
|
|
3634
3593
|
}
|
|
3635
3594
|
}
|
|
3636
|
-
`;var
|
|
3637
|
-
${this.
|
|
3595
|
+
`;var ne=class extends v{constructor(){super(...arguments);this.testURL=null;this.testDoc=null;this.testXML=null;this.templateContent=null}async handleTestURLChange(){if(this.testURL)try{let e=await Wr().load(this.testURL);this.testDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleTestXMLChange(){if(this.testXML)try{this.testDoc=Wr().parse(this.testXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:h``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(dr),this.shadowRoot.adoptedStyleSheets=[e]}render(){return h`
|
|
3596
|
+
${this.templateContent}
|
|
3597
|
+
<slot></slot>
|
|
3598
|
+
${cr(this.testDoc,h`<span>Loading...</span>`)}
|
|
3599
|
+
`}};l([p({type:String,attribute:"test-url"})],ne.prototype,"testURL",2),l([q()],ne.prototype,"testDoc",2),l([q()],ne.prototype,"testXML",2),l([T("testURL",{waitUntilFirstUpdate:!0})],ne.prototype,"handleTestURLChange",1),l([T("testXML",{waitUntilFirstUpdate:!0})],ne.prototype,"handleTestXMLChange",1),ne=l([u("test-container")],ne);var pr=["this"],us=["+","-","!"],ms=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Kr={"!":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},hr=13;var vo=["==","!=","<=",">=","||","&&","??","|>"],yo=["===","!=="],E;(function(s){s[s.STRING=1]="STRING",s[s.IDENTIFIER=2]="IDENTIFIER",s[s.DOT=3]="DOT",s[s.COMMA=4]="COMMA",s[s.COLON=5]="COLON",s[s.INTEGER=6]="INTEGER",s[s.DECIMAL=7]="DECIMAL",s[s.OPERATOR=8]="OPERATOR",s[s.GROUPER=9]="GROUPER",s[s.KEYWORD=10]="KEYWORD",s[s.ARROW=11]="ARROW"})(E||(E={}));var G=(s,t,e=0)=>({kind:s,value:t,precedence:e}),xo=s=>s===9||s===10||s===13||s===32,gs=s=>s===95||s===36||(s&=-33,65<=s&&s<=90),qo=s=>gs(s)||yt(s),Eo=s=>pr.indexOf(s)!==-1,wo=s=>s===34||s===39,yt=s=>48<=s&&s<=57,Co=s=>s===43||s===45||s===42||s===47||s===33||s===38||s===37||s===60||s===61||s===62||s===63||s===94||s===124,_o=s=>s===40||s===41||s===91||s===93||s===123||s===125,ko=s=>s.replace(/\\(.)/g,(t,e)=>{switch(e){case"n":return`
|
|
3600
|
+
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),ur=class{constructor(t){P(this,"_input");P(this,"_index",-1);P(this,"_tokenStart",0);P(this,"_next");this._input=t,this._advance()}nextToken(){for(;xo(this._next);)this._advance(!0);if(wo(this._next))return this._tokenizeString();if(gs(this._next))return this._tokenizeIdentOrKeyword();if(yt(this._next))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(Co(this._next))return this._tokenizeOperator();if(_o(this._next))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),t===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){let e=this._input.substring(this._tokenStart,this._index+t);return t===0&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0)throw new Error(t);if(this._next===92&&(this._advance(),this._next===void 0))throw new Error(t);this._advance()}let r=G(E.STRING,ko(this._getValue()));return this._advance(),r}_tokenizeIdentOrKeyword(){do this._advance();while(qo(this._next));let t=this._getValue(),e=Eo(t)?E.KEYWORD:E.IDENTIFIER;return G(e,t)}_tokenizeNumber(){do this._advance();while(yt(this._next));return this._next===46?this._tokenizeDot():G(E.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),yt(this._next)?this._tokenizeFraction():(this._clearValue(),G(E.DOT,".",hr))}_tokenizeComma(){return this._advance(!0),G(E.COMMA,",")}_tokenizeColon(){return this._advance(!0),G(E.COLON,":")}_tokenizeFraction(){do this._advance();while(yt(this._next));return G(E.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(yo.indexOf(t)!==-1)this._advance(),this._advance();else{if(t=this._getValue(1),t==="=>")return this._advance(),G(E.ARROW,t);vo.indexOf(t)!==-1&&this._advance()}return t=this._getValue(),G(E.OPERATOR,t,Kr[t])}_tokenizeGrouper(){let t=String.fromCharCode(this._next),e=G(E.GROUPER,t,Kr[t]);return this._advance(!0),e}};var Jr=(s,t)=>new xt(s,t).parse(),xt=class{constructor(t,e){P(this,"_kind");P(this,"_tokenizer");P(this,"_ast");P(this,"_token");P(this,"_value");this._tokenizer=new ur(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);let r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();let t=this._parseUnary();return t===void 0?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(t===void 0)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(E.GROUPER,"(")){let r=this._parseArguments();t=this._ast.invoke(t,void 0,r)}else if(this._matches(E.GROUPER,"[")){let r=this._parseIndex();t=this._ast.index(t,r)}else if(this._matches(E.DOT)){this._advance();let r=this._parseUnary();t=this._makeInvokeOrGetter(t,r)}else{if(this._matches(E.KEYWORD))break;if(this._matches(E.OPERATOR)&&this._token.precedence>=e)t=this._value==="?"?this._parseTernary(t):this._parseBinary(t,this._token);else break}return t}_makeInvokeOrGetter(t,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this._ast.getter(t,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let r=e.receiver;return this._ast.invoke(t,r.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(ms.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===E.OPERATOR||this._kind===E.DOT||this._kind===E.GROUPER)&&this._token.precedence>e.precedence;)r=this._parsePrecedence(r,this._token.precedence);return this._ast.binary(t,e.value,r)}_parseUnary(){if(this._matches(E.OPERATOR)){let t=this._value;if(this._advance(),t==="+"||t==="-"){if(this._matches(E.INTEGER))return this._parseInteger(t);if(this._matches(E.DECIMAL))return this._parseDecimal(t)}if(us.indexOf(t)===-1)throw new Error(`unexpected token: ${t}`);let e=this._parsePrecedence(this._parsePrimary(),hr);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(E.OPERATOR,"?");let e=this._parseExpression();this._advance(E.COLON);let r=this._parseExpression();return this._ast.ternary(t,e,r)}_parsePrimary(){switch(this._kind){case E.KEYWORD:let t=this._value;if(t==="this")return this._advance(),this._ast.id(t);throw pr.indexOf(t)!==-1?new Error(`unexpected keyword: ${t}`):new Error(`unrecognized keyword: ${t}`);case E.IDENTIFIER:return this._parseInvokeOrIdentifier();case E.STRING:return this._parseString();case E.INTEGER:return this._parseInteger();case E.DECIMAL:return this._parseDecimal();case E.GROUPER:return this._value==="("?this._parseParenOrFunction():this._value==="{"?this._parseMap():this._value==="["?this._parseList():void 0;case E.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){let t=[];do{if(this._advance(),this._matches(E.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(E.COMMA));return this._advance(E.GROUPER,"]"),this._ast.list(t)}_parseMap(){let t={};do{if(this._advance(),this._matches(E.GROUPER,"}"))break;let e=this._value;(this._matches(E.STRING)||this._matches(E.IDENTIFIER))&&this._advance(),this._advance(E.COLON),t[e]=this._parseExpression()}while(this._matches(E.COMMA));return this._advance(E.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){let t=this._value;if(t==="true")return this._advance(),this._ast.literal(!0);if(t==="false")return this._advance(),this._ast.literal(!1);if(t==="null")return this._advance(),this._ast.literal(null);if(t==="undefined")return this._advance(),this._ast.literal(void 0);let e=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(e,void 0,r):e}_parseIdentifier(){if(!this._matches(E.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);let t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(E.GROUPER,"("))return;let t=[];do{if(this._advance(),this._matches(E.GROUPER,")"))break;let e=this._parseExpression();t.push(e)}while(this._matches(E.COMMA));return this._advance(E.GROUPER,")"),t}_parseIndex(){this._advance();let t=this._parseExpression();return this._advance(E.GROUPER,"]"),t}_parseParenOrFunction(){let t=this._parseArguments();if(this._matches(E.ARROW)){this._advance();let e=this._parseExpression(),r=t?.map(i=>i.value)??[];return this._ast.arrowFunction(r,e)}else return this._ast.paren(t[0])}_parseString(){let t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){let e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){let e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}};var To={"+":(s,t)=>s+t,"-":(s,t)=>s-t,"*":(s,t)=>s*t,"/":(s,t)=>s/t,"%":(s,t)=>s%t,"==":(s,t)=>s==t,"!=":(s,t)=>s!=t,"===":(s,t)=>s===t,"!==":(s,t)=>s!==t,">":(s,t)=>s>t,">=":(s,t)=>s>=t,"<":(s,t)=>s<t,"<=":(s,t)=>s<=t,"||":(s,t)=>s||t,"&&":(s,t)=>s&&t,"??":(s,t)=>s??t,"|":(s,t)=>t(s),"|>":(s,t)=>t(s)},Ao={"+":s=>s,"-":s=>-s,"!":s=>!s},mr=class{empty(){return{type:"Empty",evaluate(t){return t},getIds(t){return t}}}literal(t){return{type:"Literal",value:t,evaluate(e){return this.value},getIds(e){return e}}}id(t){return{type:"ID",value:t,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(t,e){let r=Ao[t];return{type:"Unary",operator:t,child:e,evaluate(i){return r(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(t,e,r){let i=To[e];return{type:"Binary",operator:e,left:t,right:r,evaluate(o){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(o),a,c;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(o),c=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(o),c=this.left.argument.evaluate(o)):this.left.type==="ID"&&(a=o,c=this.left.value),a===void 0?void 0:a[c]=n}return i(this.left.evaluate(o),this.right.evaluate(o))},getIds(o){return this.left.getIds(o),this.right.getIds(o),o}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(r){return this.receiver.evaluate(r)?.[this.name]},getIds(r){return this.receiver.getIds(r),r}}}invoke(t,e,r){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:r,evaluate(i){let o=this.receiver.evaluate(i),n=this.method?o:i?.this??i,a=this.method?o?.[e]:o,d=(this.arguments??[]).map(m=>m?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(o=>o?.getIds(i)),i}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(r){return this.receiver.evaluate(r)?.[this.argument.evaluate(r)]},getIds(r){return this.receiver.getIds(r),r}}}ternary(t,e,r){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:r,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(t){return{type:"Map",entries:t,evaluate(e){let r={};if(t&&this.entries)for(let i in t){let o=this.entries[i];o&&(r[i]=o.evaluate(e))}return r},getIds(e){if(t&&this.entries)for(let r in t){let i=this.entries[r];i&&i.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(e){return this.items?.map(r=>r?.evaluate(e))},getIds(e){return this.items?.forEach(r=>r?.getIds(e)),e}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(r){let i=this.params,o=this.body;return function(...n){let a=Object.fromEntries(i.map((d,m)=>[d,n[m]])),c=new Proxy(r??{},{set(d,m,g){return a.hasOwnProperty(m)&&(a[m]=g),d[m]=g},get(d,m){return a.hasOwnProperty(m)?a[m]:d[m]}});return o.evaluate(c)}},getIds(r){return this.body.getIds(r).filter(i=>!this.params.includes(i))}}}};var Zr=null,fs={boundAttributeSuffix:R.M,marker:R.P,markerMatch:R.A,HTML_RESULT:R.C,getTemplateHtml:R.L,overrideDirectiveResolve:(s,t)=>class extends s{_$AS(e,r){return t(this,r)}},patchDirectiveResolve:(s,t)=>{if(s.prototype._$AS!==t){Zr??(Zr=s.prototype._$AS.name);for(let e=s.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Zr))return void(e[Zr]=t);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(s,t){s._$litDirective$=t},getAttributePartCommittedValue:(s,t,e)=>{let r=M;return s.j=i=>r=i,s._$AI(t,s,e),r},connectedDisconnectable:s=>({...s,_$AU:!0}),resolveDirective:R.V,AttributePart:R.H,PropertyPart:R.B,BooleanAttributePart:R.N,EventPart:R.U,ElementPart:R.F,TemplateInstance:R.R,isIterable:R.D,ChildPart:R.I};var{AttributePart:So,PropertyPart:Mo,BooleanAttributePart:Ro,EventPart:Lo}=fs,ei=new mr,Qr=new Map,bs=s=>s.replace(/-(-|\w)/g,(t,e)=>e.toUpperCase()),gr=(s,t)=>{let e=Qr.get(s);if(e===void 0){if(Qr.has(s))return;if(s=s.trim(),s.startsWith("{{")&&s.endsWith("}}")){let r=s.substring(2,s.length-2).trim();e=new xt(r,ei).parse(),Qr.set(s,e)}}return e?.evaluate(t)},$o=(s,t,e,r)=>{let i=s.getAttribute("if");if(i!==null&&gr(i,t))return fr(s,t,e,r)},vs=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,ys=s=>/(?:\\{{)|(?:\\}})/g.test(s),qt=s=>s.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Do=(s,t,e,r)=>{let i=s.getAttribute("repeat");if(i!==null){let o=gr(i,t);if(!o[Symbol.iterator])return k;let n=Et(s),a=-1,c=[];for(let d of o){a++;let m=Object.create(t);m.item=d,m.index=a,m.this=t.this??t;let g=[];for(let y of n.parts){let x=y.update(m,e,r);y.type===1?g.push(...x):g.push(x)}let f={_$litType$:n,values:g};c.push(f)}return c}},qs={if:$o,repeat:Do},Es=(s,t=qs,e={},r)=>{let o=Et(s).renderers;if(r){let a=Et(r).renderers,c=o.super;c!==void 0?e={...o,...e,super:(d,m,g)=>(g={...a,...g,super:(f,y,x)=>fr(r,f,y,x)},c(d,m,g))}:(e={...a,...o,...e},s=r)}else e={...o,...e};return n=>fr(s,n,t,e)};var fr=(s,t,e=qs,r={})=>{let i=Et(s),o=[];for(let a of i.parts){let c=a.update(t,e,r);a.type===1?o.push(...c):o.push(c)}return{_$litType$:i,values:o}},xs=new Map,Et=s=>{let t=xs.get(s);return t===void 0&&xs.set(s,t=Io(s)),t},Io=s=>{let t={h:void 0,el:s.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(t.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),r=e.currentNode,i=-1,o=[];for(;(r=e.nextNode())!==null;)if(r.nodeType===Node.ELEMENT_NODE){i++;let n=r;if(n.tagName==="TEMPLATE"){let c=n.getAttribute("type"),d=n.getAttribute("name"),m=n.getAttribute("call");if(m!==null||c!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),o.push(n);let g;if(m!==null){let f=m.trim(),y=f.startsWith("{{")&&f.endsWith("}}");g=(x,C,S)=>{let D=n.getAttribute("data"),st=D===null?void 0:gr(D,x);return(y?gr(f,x):S[m])?.(st,C,S)}}else c!==null?g=(f,y,x)=>{let C=y[c];return C?.(n,f,y,x)}:(d==="super"?t.renderers.super=(f,y,x)=>{let C=x.super,S=Et(n);return x={...x,...S.renderers},C(f,y,x)}:t.renderers[d]=(f,y,x)=>fr(n,f,y,x),g=(f,y,x)=>{let C=x[d];return C?.(f,y,x)});t.parts.push({type:2,index:i,update:g});continue}}let a=n.getAttributeNames();for(let c of a){let d=n.getAttribute(c),m=d.split(vs);if(m.length===1){ys(d)&&n.setAttribute(c,qt(d));continue}n.removeAttribute(c);let g=c,f=So,y=c[0];y==="."?(g=bs(c.substring(1)),f=Mo):y==="?"?(g=c.substring(1),f=Ro):y==="@"&&(g=bs(c.substring(1)),f=Lo);let x=[qt(m[0])],C=[];for(let S=1;S<m.length;S+=2){let D=m[S];C.push(Jr(D,ei)),x.push(qt(m[S+1]))}t.parts.push({type:1,index:i,name:g,strings:x,ctor:f,update:(S,D,st)=>C.map(he=>he.evaluate(S))})}}else if(r.nodeType===Node.TEXT_NODE){let n=r,a=n.textContent,c=a.split(vs);c.length>1?n.textContent=qt(c[0]):ys(a)&&(n.textContent=qt(a));for(let d=1;d<c.length;d+=2){let m=c[d],g=Jr(m,ei);t.parts.push({type:2,index:++i,update:(y,x)=>g.evaluate(y)});let f=new Text(c[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of o)n.remove();return t};var je=class extends L{constructor(){super();this.maxDisplayedItems=2;this.skipOnCategory="dep-informational";this._internals.ariaLabel="pagination"}createRenderRoot(){return this}render(){let e=this._testContext.items.reduce((a,c)=>{let m=c.category?.split(" ").includes(this.skipOnCategory)?"i":a.counter++;return a.result.push({...c,newIndex:m}),a},{counter:0,result:[]}).result,r=e.findIndex(a=>a.identifier===this._testContext.navItemId),i=Math.max(0,r-this.maxDisplayedItems),o=Math.min(e.length,r+this.maxDisplayedItems+1),n=e.slice(i,o);return h`
|
|
3601
|
+
${n.map(a=>{let c=a.variables.find(he=>he.identifier=="SCORE"),d=parseInt(c?.value?.toString()),m=a.variables.find(he=>he.identifier==="completionStatus")?.value,g=a.category!==this.skipOnCategory?"regular":"info",f=this._testContext.navItemId===a.identifier,y=this._testContext.view==="scorer"&&g=="regular"&&d!==void 0&&!isNaN(d)&&d>0,x=this._testContext.view==="scorer"&&g=="regular"&&d!==void 0&&!isNaN(d)&&d<=0,C=this._testContext.view==="candidate"&&m==="completed"&&a.category!==this.skipOnCategory,S={...a,type:g,active:f,correct:y,incorrect:x,answered:C},D=this.firstElementChild;return Es(D)({item:S})})}
|
|
3602
|
+
`}};l([p({type:Number,attribute:"max-displayed-items"})],je.prototype,"maxDisplayedItems",2),l([p({type:String,attribute:"skip-on-category"})],je.prototype,"skipOnCategory",2),je=l([u("test-paging-buttons-stamp")],je);var br=class extends v{render(){return h`<slot></slot>`}};br=l([u("qti-item")],br);var ae=class extends v{constructor(){super(...arguments);this.itemURL=null;this.itemDoc=null;this.itemXML=null;this.templateContent=null}async handleItemURLChange(){if(this.itemURL)try{let e=await Me().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Me().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:h``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(dr),this.shadowRoot.adoptedStyleSheets=[e]}render(){return h`
|
|
3603
|
+
${this.templateContent}
|
|
3638
3604
|
<slot></slot>
|
|
3639
|
-
${
|
|
3640
|
-
`}};l([q()],
|
|
3641
|
-
`;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),lr=class{constructor(t){z(this,"_input");z(this,"_index",-1);z(this,"_tokenStart",0);z(this,"_next");this._input=t,this._advance()}nextToken(){for(;vo(this._next);)this._advance(!0);if(qo(this._next))return this._tokenizeString();if(us(this._next))return this._tokenizeIdentOrKeyword();if(gt(this._next))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(wo(this._next))return this._tokenizeOperator();if(Eo(this._next))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),t===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){let e=this._input.substring(this._tokenStart,this._index+t);return t===0&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0)throw new Error(t);if(this._next===92&&(this._advance(),this._next===void 0))throw new Error(t);this._advance()}let r=K(w.STRING,Co(this._getValue()));return this._advance(),r}_tokenizeIdentOrKeyword(){do this._advance();while(yo(this._next));let t=this._getValue(),e=xo(t)?w.KEYWORD:w.IDENTIFIER;return K(e,t)}_tokenizeNumber(){do this._advance();while(gt(this._next));return this._next===46?this._tokenizeDot():K(w.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),gt(this._next)?this._tokenizeFraction():(this._clearValue(),K(w.DOT,".",ar))}_tokenizeComma(){return this._advance(!0),K(w.COMMA,",")}_tokenizeColon(){return this._advance(!0),K(w.COLON,":")}_tokenizeFraction(){do this._advance();while(gt(this._next));return K(w.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(bo.indexOf(t)!==-1)this._advance(),this._advance();else{if(t=this._getValue(1),t==="=>")return this._advance(),K(w.ARROW,t);fo.indexOf(t)!==-1&&this._advance()}return t=this._getValue(),K(w.OPERATOR,t,Fr[t])}_tokenizeGrouper(){let t=String.fromCharCode(this._next),e=K(w.GROUPER,t,Fr[t]);return this._advance(!0),e}};var Br=(s,t)=>new ft(s,t).parse(),ft=class{constructor(t,e){z(this,"_kind");z(this,"_tokenizer");z(this,"_ast");z(this,"_token");z(this,"_value");this._tokenizer=new lr(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);let r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();let t=this._parseUnary();return t===void 0?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(t===void 0)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(w.GROUPER,"(")){let r=this._parseArguments();t=this._ast.invoke(t,void 0,r)}else if(this._matches(w.GROUPER,"[")){let r=this._parseIndex();t=this._ast.index(t,r)}else if(this._matches(w.DOT)){this._advance();let r=this._parseUnary();t=this._makeInvokeOrGetter(t,r)}else{if(this._matches(w.KEYWORD))break;if(this._matches(w.OPERATOR)&&this._token.precedence>=e)t=this._value==="?"?this._parseTernary(t):this._parseBinary(t,this._token);else break}return t}_makeInvokeOrGetter(t,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this._ast.getter(t,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let r=e.receiver;return this._ast.invoke(t,r.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(hs.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===w.OPERATOR||this._kind===w.DOT||this._kind===w.GROUPER)&&this._token.precedence>e.precedence;)r=this._parsePrecedence(r,this._token.precedence);return this._ast.binary(t,e.value,r)}_parseUnary(){if(this._matches(w.OPERATOR)){let t=this._value;if(this._advance(),t==="+"||t==="-"){if(this._matches(w.INTEGER))return this._parseInteger(t);if(this._matches(w.DECIMAL))return this._parseDecimal(t)}if(ps.indexOf(t)===-1)throw new Error(`unexpected token: ${t}`);let e=this._parsePrecedence(this._parsePrimary(),ar);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(w.OPERATOR,"?");let e=this._parseExpression();this._advance(w.COLON);let r=this._parseExpression();return this._ast.ternary(t,e,r)}_parsePrimary(){switch(this._kind){case w.KEYWORD:let t=this._value;if(t==="this")return this._advance(),this._ast.id(t);throw nr.indexOf(t)!==-1?new Error(`unexpected keyword: ${t}`):new Error(`unrecognized keyword: ${t}`);case w.IDENTIFIER:return this._parseInvokeOrIdentifier();case w.STRING:return this._parseString();case w.INTEGER:return this._parseInteger();case w.DECIMAL:return this._parseDecimal();case w.GROUPER:return this._value==="("?this._parseParenOrFunction():this._value==="{"?this._parseMap():this._value==="["?this._parseList():void 0;case w.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){let t=[];do{if(this._advance(),this._matches(w.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(w.COMMA));return this._advance(w.GROUPER,"]"),this._ast.list(t)}_parseMap(){let t={};do{if(this._advance(),this._matches(w.GROUPER,"}"))break;let e=this._value;(this._matches(w.STRING)||this._matches(w.IDENTIFIER))&&this._advance(),this._advance(w.COLON),t[e]=this._parseExpression()}while(this._matches(w.COMMA));return this._advance(w.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){let t=this._value;if(t==="true")return this._advance(),this._ast.literal(!0);if(t==="false")return this._advance(),this._ast.literal(!1);if(t==="null")return this._advance(),this._ast.literal(null);if(t==="undefined")return this._advance(),this._ast.literal(void 0);let e=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(e,void 0,r):e}_parseIdentifier(){if(!this._matches(w.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);let t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(w.GROUPER,"("))return;let t=[];do{if(this._advance(),this._matches(w.GROUPER,")"))break;let e=this._parseExpression();t.push(e)}while(this._matches(w.COMMA));return this._advance(w.GROUPER,")"),t}_parseIndex(){this._advance();let t=this._parseExpression();return this._advance(w.GROUPER,"]"),t}_parseParenOrFunction(){let t=this._parseArguments();if(this._matches(w.ARROW)){this._advance();let e=this._parseExpression(),r=t?.map(i=>i.value)??[];return this._ast.arrowFunction(r,e)}else return this._ast.paren(t[0])}_parseString(){let t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){let e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){let e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}};var _o={"+":(s,t)=>s+t,"-":(s,t)=>s-t,"*":(s,t)=>s*t,"/":(s,t)=>s/t,"%":(s,t)=>s%t,"==":(s,t)=>s==t,"!=":(s,t)=>s!=t,"===":(s,t)=>s===t,"!==":(s,t)=>s!==t,">":(s,t)=>s>t,">=":(s,t)=>s>=t,"<":(s,t)=>s<t,"<=":(s,t)=>s<=t,"||":(s,t)=>s||t,"&&":(s,t)=>s&&t,"??":(s,t)=>s??t,"|":(s,t)=>t(s),"|>":(s,t)=>t(s)},ko={"+":s=>s,"-":s=>-s,"!":s=>!s},cr=class{empty(){return{type:"Empty",evaluate(t){return t},getIds(t){return t}}}literal(t){return{type:"Literal",value:t,evaluate(e){return this.value},getIds(e){return e}}}id(t){return{type:"ID",value:t,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(t,e){let r=ko[t];return{type:"Unary",operator:t,child:e,evaluate(i){return r(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(t,e,r){let i=_o[e];return{type:"Binary",operator:e,left:t,right:r,evaluate(o){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(o),a,c;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(o),c=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(o),c=this.left.argument.evaluate(o)):this.left.type==="ID"&&(a=o,c=this.left.value),a===void 0?void 0:a[c]=n}return i(this.left.evaluate(o),this.right.evaluate(o))},getIds(o){return this.left.getIds(o),this.right.getIds(o),o}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(r){return this.receiver.evaluate(r)?.[this.name]},getIds(r){return this.receiver.getIds(r),r}}}invoke(t,e,r){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:r,evaluate(i){let o=this.receiver.evaluate(i),n=this.method?o:i?.this??i,a=this.method?o?.[e]:o,d=(this.arguments??[]).map(u=>u?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(o=>o?.getIds(i)),i}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(r){return this.receiver.evaluate(r)?.[this.argument.evaluate(r)]},getIds(r){return this.receiver.getIds(r),r}}}ternary(t,e,r){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:r,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(t){return{type:"Map",entries:t,evaluate(e){let r={};if(t&&this.entries)for(let i in t){let o=this.entries[i];o&&(r[i]=o.evaluate(e))}return r},getIds(e){if(t&&this.entries)for(let r in t){let i=this.entries[r];i&&i.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(e){return this.items?.map(r=>r?.evaluate(e))},getIds(e){return this.items?.forEach(r=>r?.getIds(e)),e}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(r){let i=this.params,o=this.body;return function(...n){let a=Object.fromEntries(i.map((d,u)=>[d,n[u]])),c=new Proxy(r??{},{set(d,u,m){return a.hasOwnProperty(u)&&(a[u]=m),d[u]=m},get(d,u){return a.hasOwnProperty(u)?a[u]:d[u]}});return o.evaluate(c)}},getIds(r){return this.body.getIds(r).filter(i=>!this.params.includes(i))}}}};var jr=null,ms={boundAttributeSuffix:M.M,marker:M.P,markerMatch:M.A,HTML_RESULT:M.C,getTemplateHtml:M.L,overrideDirectiveResolve:(s,t)=>class extends s{_$AS(e,r){return t(this,r)}},patchDirectiveResolve:(s,t)=>{if(s.prototype._$AS!==t){jr??(jr=s.prototype._$AS.name);for(let e=s.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(jr))return void(e[jr]=t);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(s,t){s._$litDirective$=t},getAttributePartCommittedValue:(s,t,e)=>{let r=R;return s.j=i=>r=i,s._$AI(t,s,e),r},connectedDisconnectable:s=>({...s,_$AU:!0}),resolveDirective:M.V,AttributePart:M.H,PropertyPart:M.B,BooleanAttributePart:M.N,EventPart:M.U,ElementPart:M.F,TemplateInstance:M.R,isIterable:M.D,ChildPart:M.I};var{AttributePart:To,PropertyPart:Ao,BooleanAttributePart:So,EventPart:Ro}=ms,Xr=new cr,Wr=new Map,gs=s=>s.replace(/-(-|\w)/g,(t,e)=>e.toUpperCase()),dr=(s,t)=>{let e=Wr.get(s);if(e===void 0){if(Wr.has(s))return;if(s=s.trim(),s.startsWith("{{")&&s.endsWith("}}")){let r=s.substring(2,s.length-2).trim();e=new ft(r,Xr).parse(),Wr.set(s,e)}}return e?.evaluate(t)},Mo=(s,t,e,r)=>{let i=s.getAttribute("if");if(i!==null&&dr(i,t))return pr(s,t,e,r)},fs=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,bs=s=>/(?:\\{{)|(?:\\}})/g.test(s),bt=s=>s.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Lo=(s,t,e,r)=>{let i=s.getAttribute("repeat");if(i!==null){let o=dr(i,t);if(!o[Symbol.iterator])return k;let n=vt(s),a=-1,c=[];for(let d of o){a++;let u=Object.create(t);u.item=d,u.index=a,u.this=t.this??t;let m=[];for(let y of n.parts){let x=y.update(u,e,r);y.type===1?m.push(...x):m.push(x)}let f={_$litType$:n,values:m};c.push(f)}return c}},ys={if:Mo,repeat:Lo},xs=(s,t=ys,e={},r)=>{let o=vt(s).renderers;if(r){let a=vt(r).renderers,c=o.super;c!==void 0?e={...o,...e,super:(d,u,m)=>(m={...a,...m,super:(f,y,x)=>pr(r,f,y,x)},c(d,u,m))}:(e={...a,...o,...e},s=r)}else e={...o,...e};return n=>pr(s,n,t,e)};var pr=(s,t,e=ys,r={})=>{let i=vt(s),o=[];for(let a of i.parts){let c=a.update(t,e,r);a.type===1?o.push(...c):o.push(c)}return{_$litType$:i,values:o}},vs=new Map,vt=s=>{let t=vs.get(s);return t===void 0&&vs.set(s,t=$o(s)),t},$o=s=>{let t={h:void 0,el:s.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(t.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),r=e.currentNode,i=-1,o=[];for(;(r=e.nextNode())!==null;)if(r.nodeType===Node.ELEMENT_NODE){i++;let n=r;if(n.tagName==="TEMPLATE"){let c=n.getAttribute("type"),d=n.getAttribute("name"),u=n.getAttribute("call");if(u!==null||c!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),o.push(n);let m;if(u!==null){let f=u.trim(),y=f.startsWith("{{")&&f.endsWith("}}");m=(x,_,S)=>{let D=n.getAttribute("data"),Qe=D===null?void 0:dr(D,x);return(y?dr(f,x):S[u])?.(Qe,_,S)}}else c!==null?m=(f,y,x)=>{let _=y[c];return _?.(n,f,y,x)}:(d==="super"?t.renderers.super=(f,y,x)=>{let _=x.super,S=vt(n);return x={...x,...S.renderers},_(f,y,x)}:t.renderers[d]=(f,y,x)=>pr(n,f,y,x),m=(f,y,x)=>{let _=x[d];return _?.(f,y,x)});t.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let c of a){let d=n.getAttribute(c),u=d.split(fs);if(u.length===1){bs(d)&&n.setAttribute(c,bt(d));continue}n.removeAttribute(c);let m=c,f=To,y=c[0];y==="."?(m=gs(c.substring(1)),f=Ao):y==="?"?(m=c.substring(1),f=So):y==="@"&&(m=gs(c.substring(1)),f=Ro);let x=[bt(u[0])],_=[];for(let S=1;S<u.length;S+=2){let D=u[S];_.push(Br(D,Xr)),x.push(bt(u[S+1]))}t.parts.push({type:1,index:i,name:m,strings:x,ctor:f,update:(S,D,Qe)=>_.map(ce=>ce.evaluate(S))})}}else if(r.nodeType===Node.TEXT_NODE){let n=r,a=n.textContent,c=a.split(fs);c.length>1?n.textContent=bt(c[0]):bs(a)&&(n.textContent=bt(a));for(let d=1;d<c.length;d+=2){let u=c[d],m=Br(u,Xr);t.parts.push({type:2,index:++i,update:(y,x)=>m.evaluate(y)});let f=new Text(c[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of o)n.remove();return t};var ze=class extends L{constructor(){super();this.maxDisplayedItems=2;this.skipOnCategory="dep-informational";this._internals.ariaLabel="pagination"}createRenderRoot(){return this}render(){let e=this._testContext.items.reduce((a,c)=>{let u=c.category?.split(" ").includes(this.skipOnCategory)?"i":a.counter++;return a.result.push({...c,newIndex:u}),a},{counter:0,result:[]}).result,r=e.findIndex(a=>a.identifier===this._testContext.navItemId),i=Math.max(0,r-this.maxDisplayedItems),o=Math.min(e.length,r+this.maxDisplayedItems+1),n=e.slice(i,o);return h`
|
|
3642
|
-
${n.map(a=>{let c=a.variables.find(ce=>ce.identifier=="SCORE"),d=parseInt(c?.value?.toString()),u=a.variables.find(ce=>ce.identifier==="completionStatus")?.value,m=a.category!==this.skipOnCategory?"regular":"info",f=this._testContext.navItemId===a.identifier,y=this._testContext.view==="scorer"&&m=="regular"&&d!==void 0&&!isNaN(d)&&d>0,x=this._testContext.view==="scorer"&&m=="regular"&&d!==void 0&&!isNaN(d)&&d<=0,_=this._testContext.view==="candidate"&&u==="completed"&&a.category!==this.skipOnCategory,S={...a,type:m,active:f,correct:y,incorrect:x,answered:_},D=this.firstElementChild;return xs(D)({item:S})})}
|
|
3643
|
-
`}};l([p({type:Number,attribute:"max-displayed-items"})],ze.prototype,"maxDisplayedItems",2),l([p({type:String,attribute:"skip-on-category"})],ze.prototype,"skipOnCategory",2),ze=l([g("test-paging-buttons-stamp")],ze);function qs(s){class t extends s{createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href}}))}render(){return h`${this.xmlDoc}`}}return l([p({type:String,reflect:!0})],t.prototype,"identifier",2),l([p({type:String})],t.prototype,"href",2),l([p({type:Object,attribute:!1})],t.prototype,"xmlDoc",2),t}var hr=class extends qs(v){};hr=l([g("qti-item")],hr);var ws=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],$=Symbol("item");var I=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,r)=>{this._interactionElements.forEach(i=>i.disabled=r)};this._handleReadonlyChange=(e,r)=>this._interactionElements.forEach(i=>i.readonly=r);this._context={identifier:this.getAttribute("identifier"),variables:ws};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let r=e.detail;this._feedbackElements.push(r),r.checkShowFeedback(r.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:r,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(r,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:r,value:i}=e.detail;this.updateOutcomeVariable(r,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}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(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(r=>{let i=e.find(o=>o.identifier===r.identifier);return i?{...r,...i}:r})},this._context.variables.forEach(r=>{if(r.type==="response"){let i=this._interactionElements.find(o=>o.responseIdentifier===r.identifier);i&&(i.value=r.value)}r.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(r.identifier))})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let r of e){this.getResponse(r.responseIdentifier)&&this.updateResponseVariable(r.responseIdentifier,r.response);let o=this._interactionElements.find(n=>n.getAttribute("response-identifier")===r.responseIdentifier);o&&(o.value=r.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(o=>"correctResponse"in o&&o.correctResponse).map(o=>({responseIdentifier:o.identifier,response:o.correctResponse}));for(let o of i){let n=this._interactionElements.find(a=>a.getAttribute("response-identifier")===o.responseIdentifier);n&&(n.correctResponse=e?o.response:"")}}processResponse(e=!0){this.validate();let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(i=>i.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(r=>r.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:r,response:i}=e.detail;this.updateResponseVariable(r,i)}updateResponseVariable(e,r){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:r})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(r)?[...r]:r}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,r){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(o=>o.identifier!==e?o:{...o,value:i.cardinality==="single"?r:[...o.value,r]})},this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(o=>o.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,r=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:r}))}};l([p({type:String})],I.prototype,"title",2),l([p({type:String})],I.prototype,"identifier",2),l([p({type:String})],I.prototype,"adaptive",2),l([p({type:String})],I.prototype,"timeDependent",2),l([p({type:Boolean})],I.prototype,"disabled",2),l([A("disabled",{waitUntilFirstUpdate:!0})],I.prototype,"_handleDisabledChange",2),l([p({type:Boolean})],I.prototype,"readonly",2),l([A("readonly",{waitUntilFirstUpdate:!0})],I.prototype,"_handleReadonlyChange",2),l([Le({context:$})],I.prototype,"_context",2),I=l([g("qti-assessment-item")],I);var Ue=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0});if(this.dispatchEvent(e)){let o=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);o?await this.updateStimulusRef(o):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let r=await Zt().load(this.href).then(i=>i.htmlDoc());if(r){let i=r.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};l([p({type:String})],Ue.prototype,"identifier",2),l([p({type:String})],Ue.prototype,"href",2),Ue=l([g("qti-assessment-stimulus-ref")],Ue);var Es={toAttribute:s=>s?"true":"false",fromAttribute:s=>s==="true"};function Z(s,t){class e extends s{constructor(...o){super(...o);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(o,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${t}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${t}`,{bubbles:!0,composed:!0}))}_onKeyUp(o){o.altKey||o.code==="Space"&&(o.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${t}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return l([p({type:String})],e.prototype,"identifier",2),l([p({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),l([p({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Es})],e.prototype,"disabled",2),l([p({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Es})],e.prototype,"readonly",2),l([A("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var Cs=b`
|
|
3605
|
+
${cr(this.itemDoc,h`<span>Loading...</span>`)}
|
|
3606
|
+
`}};l([p({type:String,attribute:"item-url"})],ae.prototype,"itemURL",2),l([q()],ae.prototype,"itemDoc",2),l([q()],ae.prototype,"itemXML",2),l([T("itemURL",{waitUntilFirstUpdate:!0})],ae.prototype,"handleItemURLChange",1),l([T("itemXML",{waitUntilFirstUpdate:!0})],ae.prototype,"handleItemXMLChange",1),ae=l([u("item-container")],ae);var ws=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],$=Symbol("item");var I=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,r)=>{this._interactionElements.forEach(i=>i.disabled=r)};this._handleReadonlyChange=(e,r)=>this._interactionElements.forEach(i=>i.readonly=r);this._context={identifier:this.getAttribute("identifier"),variables:ws};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let r=e.detail;this._feedbackElements.push(r),(Number(this._context.variables.find(o=>o.identifier==="numAttempts")?.value)||0)>0&&r.checkShowFeedback(r.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:r,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(r,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:r,value:i}=e.detail;this.updateOutcomeVariable(r,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}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(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(r=>{let i=e.find(o=>o.identifier===r.identifier);return i?{...r,...i}:r})},this._context.variables.forEach(r=>{if(r.type==="response"){let i=this._interactionElements.find(o=>o.responseIdentifier===r.identifier);i&&(i.value=r.value)}})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let r of e){this.getResponse(r.responseIdentifier)&&this.updateResponseVariable(r.responseIdentifier,r.response);let o=this._interactionElements.find(n=>n.getAttribute("response-identifier")===r.responseIdentifier);o&&(o.value=r.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(o=>"correctResponse"in o&&o.correctResponse).map(o=>({responseIdentifier:o.identifier,response:o.correctResponse}));for(let o of i){let n=this._interactionElements.find(a=>a.getAttribute("response-identifier")===o.responseIdentifier);n&&(n.correctResponse=e?o.response:"")}}processResponse(e=!0){this.validate();let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(i=>i.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(r=>r.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:r,response:i}=e.detail;this.updateResponseVariable(r,i)}updateResponseVariable(e,r){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:r})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(r)?[...r]:r}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,r){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(o=>o.identifier!==e?o:{...o,value:i.cardinality==="single"?r:[...o.value,r]})},this._feedbackElements.forEach(o=>o.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(o=>o.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,r=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:r}))}};l([p({type:String})],I.prototype,"title",2),l([p({type:String})],I.prototype,"identifier",2),l([p({type:String})],I.prototype,"adaptive",2),l([p({type:String})],I.prototype,"timeDependent",2),l([p({type:Boolean})],I.prototype,"disabled",2),l([T("disabled",{waitUntilFirstUpdate:!0})],I.prototype,"_handleDisabledChange",2),l([p({type:Boolean})],I.prototype,"readonly",2),l([T("readonly",{waitUntilFirstUpdate:!0})],I.prototype,"_handleReadonlyChange",2),l([Ie({context:$})],I.prototype,"_context",2),I=l([u("qti-assessment-item")],I);var We=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0});if(this.dispatchEvent(e)){let o=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);o?await this.updateStimulusRef(o):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let r=await Me().load(this.href).then(i=>i.htmlDoc());if(r){let i=r.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};l([p({type:String})],We.prototype,"identifier",2),l([p({type:String})],We.prototype,"href",2),We=l([u("qti-assessment-stimulus-ref")],We);var Cs={toAttribute:s=>s?"true":"false",fromAttribute:s=>s==="true"};function K(s,t){class e extends s{constructor(...o){super(...o);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(o,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${t}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${t}`,{bubbles:!0,composed:!0}))}_onKeyUp(o){o.altKey||o.code==="Space"&&(o.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${t}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return l([p({type:String})],e.prototype,"identifier",2),l([p({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),l([p({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Cs})],e.prototype,"disabled",2),l([p({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Cs})],e.prototype,"readonly",2),l([T("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var _s=b`
|
|
3644
3607
|
:host {
|
|
3645
3608
|
display: block;
|
|
3646
3609
|
}
|
|
3647
|
-
`;var
|
|
3610
|
+
`;var wt=class extends v{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};wt.styles=_s,wt=l([u("qti-item-body")],wt);var vr=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};vr=l([u("qti-prompt")],vr);var yr=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let r=this.getAttribute("href");if(r!==null&&fetch(r).then(i=>i.text()).then(i=>{let o=this.minifyCss(i);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${o}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};yr=l([u("qti-stylesheet")],yr);var be=class extends v{render(){return h`<slot></slot>`}defaultValues(t){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let r=e.map(i=>i.innerHTML.trim());return r.length>1||t.cardinality==="multiple"||t.cardinality==="ordered"?r:r[0]}};be=l([u("qti-variabledeclaration")],be);var J=class extends be{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(r=>r.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let r=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 o=parseInt(i.getAttribute("source-value")),n=parseInt(i.getAttribute("target-value"));(isNaN(o)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),r.set(o,n)}return r}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};J.styles=[b`
|
|
3648
3611
|
:host {
|
|
3649
3612
|
display: none;
|
|
3650
3613
|
}
|
|
3651
|
-
`],l([p({type:String,attribute:"base-type"})],J.prototype,"baseType",2),l([p({type:String,attribute:"external-scored"})],J.prototype,"externalScored",2),l([p({type:String})],J.prototype,"identifier",2),l([p({type:String})],J.prototype,"cardinality",2),l([
|
|
3614
|
+
`],l([p({type:String,attribute:"base-type"})],J.prototype,"baseType",2),l([p({type:String,attribute:"external-scored"})],J.prototype,"externalScored",2),l([p({type:String})],J.prototype,"identifier",2),l([p({type:String})],J.prototype,"cardinality",2),l([A({context:$,subscribe:!0}),q()],J.prototype,"itemContext",2),J=l([u("qti-outcome-declaration")],J);var le=class extends be{render(){let t=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(t,null,2)}`}connectedCallback(){super.connectedCallback();let t={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};t.value=this.defaultValues(t),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}get correctResponse(){let t,e=this.querySelector("qti-correct-response");if(e){let r=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)t=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){t=[];for(let i=0;i<r.length;i++)t.push(r[i].textContent),r[i].remove()}}return t}get mapping(){return this.querySelector("qti-mapping")}};le.styles=[b`
|
|
3652
3615
|
:host {
|
|
3653
3616
|
display: none;
|
|
3654
3617
|
}
|
|
3655
|
-
`],l([p({type:String,attribute:"base-type"})],
|
|
3618
|
+
`],l([p({type:String,attribute:"base-type"})],le.prototype,"baseType",2),l([p({type:String})],le.prototype,"identifier",2),l([p({type:String})],le.prototype,"cardinality",2),l([A({context:$,subscribe:!0}),q()],le.prototype,"itemContext",2),le=l([u("qti-response-declaration")],le);var xr=class extends v{};xr=l([u("qti-companion-materials-info")],xr);var qr=class extends v{render(){return h`<slot></slot>`}};qr=l([u("qti-content-body")],qr);var Z=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};Z.styles=b`
|
|
3656
3619
|
:host {
|
|
3657
3620
|
display: block;
|
|
3658
3621
|
}
|
|
3659
|
-
`,l([p({type:String})],
|
|
3622
|
+
`,l([p({type:String})],Z.prototype,"id",2),l([p({type:String})],Z.prototype,"use",2),l([p({type:String})],Z.prototype,"view",2),l([p({type:String,attribute:"class"})],Z.prototype,"classNames",2),l([T("classNames",{waitUntilFirstUpdate:!0})],Z.prototype,"handleclassNamesChange",1),Z=l([u("qti-rubric-block")],Z);var No=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Ct=s=>{if(typeof s=="string")return s;let t=No();return t==="."?s.toLocaleString():s.toString().replace(".","").replace(t,".")};function ti(s){return s==null}function _t(s){return s.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var N=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(t){let e=this._context.variables.find(i=>i.identifier===t)||null;if(this.outcomeIdentifier!==t||!e)return;let r=!1;Array.isArray(e.value)?r=e.value.includes(this.identifier):r=!ti(this.identifier)&&!ti(e?.value)&&this.identifier===e.value||!1,this.showFeedback(r)}showFeedback(t){this.showStatus=t&&this.showHide==="show"||!t&&this.showHide==="hide"?"on":"off"}};l([p({type:String,attribute:"show-hide"})],N.prototype,"showHide",2),l([p({type:String,attribute:"outcome-identifier"})],N.prototype,"outcomeIdentifier",2),l([p({type:String})],N.prototype,"identifier",2),l([p({type:String,attribute:!1})],N.prototype,"showStatus",2),l([A({context:$,subscribe:!0}),q()],N.prototype,"_context",2);var kt=class extends N{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(t){this.checkShowFeedback(this.outcomeIdentifier)}};kt.styles=b`
|
|
3660
3623
|
:host {
|
|
3661
3624
|
display: block;
|
|
3662
3625
|
}
|
|
@@ -3666,21 +3629,70 @@ qti-response-declaration {
|
|
|
3666
3629
|
.off {
|
|
3667
3630
|
display: none;
|
|
3668
3631
|
}
|
|
3669
|
-
`,
|
|
3632
|
+
`,kt=l([u("qti-feedback-block")],kt);var Tt=class extends N{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${this.showStatus}"></slot> `}};Tt.styles=b`
|
|
3670
3633
|
.on {
|
|
3671
3634
|
display: inline-block;
|
|
3672
3635
|
}
|
|
3673
3636
|
.off {
|
|
3674
3637
|
display: none;
|
|
3675
3638
|
}
|
|
3676
|
-
`,
|
|
3677
|
-
|
|
3639
|
+
`,Tt=l([u("qti-feedback-inline")],Tt);var At=class extends N{render(){return h`
|
|
3640
|
+
<dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
|
|
3641
|
+
<slot></slot>
|
|
3642
|
+
<div style="margin-top: var(--qti-gap-size); text-align: center;">
|
|
3643
|
+
<button class="button close-button" @click="${this.closeFeedback}"></button>
|
|
3644
|
+
</div>
|
|
3645
|
+
</dialog>
|
|
3646
|
+
`}openFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&!t.open&&t.showModal()}closeFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&t.open&&(t.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(t){t.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};At.styles=b`
|
|
3647
|
+
.qti-dialog {
|
|
3648
|
+
background: var(--qti-bg);
|
|
3649
|
+
border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
|
|
3650
|
+
border-radius: var(--qti-border-radius);
|
|
3651
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
3652
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
3653
|
+
position: fixed;
|
|
3654
|
+
top: 50%;
|
|
3655
|
+
left: 50%;
|
|
3656
|
+
transform: translate(-50%, -50%);
|
|
3657
|
+
z-index: 1000;
|
|
3658
|
+
width: auto;
|
|
3659
|
+
max-width: 90%;
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
.button {
|
|
3663
|
+
border-radius: var(--qti-border-radius);
|
|
3664
|
+
padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
|
|
3665
|
+
background-color: var(--qti-bg-active);
|
|
3666
|
+
border: var(--qti-border-active);
|
|
3667
|
+
cursor: pointer;
|
|
3668
|
+
position: relative;
|
|
3678
3669
|
display: inline-block;
|
|
3679
3670
|
}
|
|
3680
|
-
|
|
3681
|
-
|
|
3671
|
+
|
|
3672
|
+
.button:hover {
|
|
3673
|
+
background-color: var(--qti-hover-bg);
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
.button:disabled {
|
|
3677
|
+
background-color: var(--qti-disabled-bg);
|
|
3678
|
+
color: var(--qti-disabled-color);
|
|
3679
|
+
cursor: not-allowed;
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
.button:focus {
|
|
3683
|
+
outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
|
|
3682
3684
|
}
|
|
3683
|
-
|
|
3685
|
+
|
|
3686
|
+
/* Text content of the button */
|
|
3687
|
+
.button::after {
|
|
3688
|
+
content: var(--qti-close-text, 'Close');
|
|
3689
|
+
color: inherit;
|
|
3690
|
+
font-size: inherit;
|
|
3691
|
+
text-align: center;
|
|
3692
|
+
display: inline-block;
|
|
3693
|
+
line-height: 1.5;
|
|
3694
|
+
}
|
|
3695
|
+
`,At=l([u("qti-modal-feedback")],At);var ve=s=>s??k;var w=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}reportValidity(){return this._internals.reportValidity()}reset(){this.value=""}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};w.formAssociated=!0,l([p({type:String,attribute:"response-identifier"})],w.prototype,"responseIdentifier",2),l([p({reflect:!0,type:Boolean})],w.prototype,"disabled",2),l([p({reflect:!0,type:Boolean})],w.prototype,"readonly",2),l([q()],w.prototype,"_correctResponse",2);var H=class extends w{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,r){let i=r.split(" "),o=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),o=!0}}),!o&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let r=new FormData;r.append(this.responseIdentifier,e),this._internals.setFormValue(r),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let r=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(r);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let r=e.checkValidity();this._internals.setValidity(r?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let r=this.validate();return r||e.reportValidity(),r}static get styles(){return[b`
|
|
3684
3696
|
/* PK: display host as block, else design will be collapsed */
|
|
3685
3697
|
:host {
|
|
3686
3698
|
display: block;
|
|
@@ -3702,12 +3714,12 @@ qti-response-declaration {
|
|
|
3702
3714
|
@keyup="${this.textChanged}"
|
|
3703
3715
|
@change="${this.textChanged}"
|
|
3704
3716
|
@blur="${e=>{this.reportValidity()}}"
|
|
3705
|
-
placeholder="${
|
|
3717
|
+
placeholder="${ve(this.placeholderText?this.placeholderText:void 0)}"
|
|
3706
3718
|
rows="${this._rows}"
|
|
3707
3719
|
?disabled="${this.disabled}"
|
|
3708
3720
|
?readonly="${this.readonly}"
|
|
3709
3721
|
.value=${this._value}
|
|
3710
|
-
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;this.setEmptyAttribute(r.value),this._value!==r.value&&(this.value=r.value,this.saveResponse(r.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};l([q()],H.prototype,"_rows",2),l([p({type:Number,attribute:"expected-length"})],H.prototype,"expectedLength",2),l([p({type:String,attribute:"pattern-mask"})],H.prototype,"patternMask",2),l([p({type:String,attribute:"placeholder-text"})],H.prototype,"placeholderText",2),l([p({type:String,attribute:"data-patternmask-message"})],H.prototype,"dataPatternmaskMessage",2),l([q()],H.prototype,"_value",2),l([p({type:String,attribute:"class"})],H.prototype,"classNames",2),l([
|
|
3722
|
+
></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;this.setEmptyAttribute(r.value),this._value!==r.value&&(this.value=r.value,this.saveResponse(r.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};l([q()],H.prototype,"_rows",2),l([p({type:Number,attribute:"expected-length"})],H.prototype,"expectedLength",2),l([p({type:String,attribute:"pattern-mask"})],H.prototype,"patternMask",2),l([p({type:String,attribute:"placeholder-text"})],H.prototype,"placeholderText",2),l([p({type:String,attribute:"data-patternmask-message"})],H.prototype,"dataPatternmaskMessage",2),l([q()],H.prototype,"_value",2),l([p({type:String,attribute:"class"})],H.prototype,"classNames",2),l([T("classNames")],H.prototype,"handleclassNamesChange",1),H=l([u("qti-extended-text-interaction")],H);var ks=()=>new ii,ii=class{},ri=new WeakMap,Gh=U(class extends Xe{render(s){return k}update(s,[t]){let e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=s.options?.host,this.rt(this.ct=s.element)),k}rt(s){if(this.isConnected||(s=void 0),typeof this.Y=="function"){let t=this.ht??globalThis,e=ri.get(t);e===void 0&&(e=new WeakMap,ri.set(t,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,s),s!==void 0&&this.Y.call(this.ht,s)}else this.Y.value=s}get lt(){return typeof this.Y=="function"?ri.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Ts=b`
|
|
3711
3723
|
:host {
|
|
3712
3724
|
display: inline-block;
|
|
3713
3725
|
}
|
|
@@ -3789,7 +3801,7 @@ qti-response-declaration {
|
|
|
3789
3801
|
width: 57rem;
|
|
3790
3802
|
min-width: 57rem;
|
|
3791
3803
|
}
|
|
3792
|
-
`;var
|
|
3804
|
+
`;var Q=class extends w{constructor(){super(...arguments);this._value="";this.inputRef=ks()}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let r=new FormData;r.append(this.responseIdentifier,e),this._internals.setFormValue(r),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let r=e.checkValidity();this._internals.setValidity(r?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return h`
|
|
3793
3805
|
<input
|
|
3794
3806
|
part="input"
|
|
3795
3807
|
name="${this.responseIdentifier}"
|
|
@@ -3800,15 +3812,15 @@ qti-response-declaration {
|
|
|
3800
3812
|
@keyup="${this.textChanged}"
|
|
3801
3813
|
@change="${this.textChanged}"
|
|
3802
3814
|
type="${this.patternMask=="[0-9]*"?"number":"text"}"
|
|
3803
|
-
placeholder="${
|
|
3815
|
+
placeholder="${ve(this.placeholderText?this.placeholderText:void 0)}"
|
|
3804
3816
|
.value="${this._value}"
|
|
3805
|
-
pattern="${
|
|
3817
|
+
pattern="${ve(this.patternMask?this.patternMask:void 0)}"
|
|
3806
3818
|
maxlength=${1e3}
|
|
3807
3819
|
?disabled="${this.disabled}"
|
|
3808
3820
|
?readonly="${this.readonly}"
|
|
3809
3821
|
/>
|
|
3810
3822
|
<div part="correct">${this._correctResponse}</div>
|
|
3811
|
-
`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;this.setEmptyAttribute(r.value),this._value!==r.value&&(this.value=r.value,this.saveResponse(r.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let r=this.validate();return r||e.reportValidity(),r}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};
|
|
3823
|
+
`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;this.setEmptyAttribute(r.value),this._value!==r.value&&(this.value=r.value,this.saveResponse(r.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let r=this.validate();return r||e.reportValidity(),r}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};Q.styles=Ts,l([p({type:Number,attribute:"expected-length"})],Q.prototype,"expectedLength",2),l([p({type:String,attribute:"pattern-mask"})],Q.prototype,"patternMask",2),l([p({type:String,attribute:"placeholder-text"})],Q.prototype,"placeholderText",2),l([p({type:String,attribute:"data-patternmask-message"})],Q.prototype,"dataPatternmaskMessage",2),l([q()],Q.prototype,"_value",2),Q=l([u("qti-text-entry-interaction")],Q);var ye=(s,t)=>{class e extends s{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(o,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this._value=""}_handleMaxChoicesChange(o,n){this._determineInputType()}get value(){return Array.isArray(this._value)?this._value.join(","):this._value}set value(o){if(this.maxChoices>1&&typeof o=="string"?this._value=o.split(","):this._value=o,Array.isArray(this._value)){let n=new FormData;this._value.forEach(a=>{n.append(this.responseIdentifier,a)}),this._internals.setFormValue(n)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(o){this._correctResponse=o;let n=Array.isArray(o)?o:[o];this._choiceElements.forEach(a=>{a.internals.states.delete("correct-response"),a.internals.states.delete("incorrect-response"),n.length>0&&(n.includes(a.identifier)?a.internals.states.add("correct-response"):a.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${t}`,this._registerChoiceElement),this.addEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.addEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${t}`,this._registerChoiceElement),this.removeEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}validate(){let o=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=o.length,a=!0,c="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,c=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):n<this.minChoices&&(a=!1,c=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),o.length>0&&this._internals.setValidity(a?{}:{customError:!0},c,o[n-1]||this._choiceElements[0]||this),this.reportValidity(),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.display="block")),this._internals.validity.valid}_registerChoiceElement(o){o.stopPropagation();let n=o.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(o){o.stopPropagation();let n=o.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}_setInputType(o){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let n=this.maxChoices===1?"radio":"checkbox";o.internals.role=n,o.internals.states.delete(n==="radio"?"checkbox":"radio"),o.internals.states.add(n)}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1&&this._choiceElements.forEach(n=>{n.identifier!==o.detail.identifier&&this._setChoiceChecked(n,!1)}),this._handleChoiceSelection()}_setChoiceChecked(o,n){o.internals?.states&&(n?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let n=this._getChoiceChecked(o);this._setChoiceChecked(o,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.value=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let o=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(n=>{let a=o.includes(n.identifier);this._setChoiceChecked(n,a)})}}return l([Oe("#validationMessage")],e.prototype,"_validationMessageElement",2),l([p({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),l([p({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),l([T("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),l([T("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),l([T("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Er=class extends ye(w,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};Er=l([u("qti-hottext-interaction")],Er);var St=class extends Y{constructor(t){if(super(t),this.it=k,t.type!==fe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===k||t==null)return this._t=void 0,this.it=t;if(t===M)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};St.directiveName="unsafeHTML",St.resultType=1;var xe=U(St);var qe=class extends w{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[b`
|
|
3812
3824
|
:host {
|
|
3813
3825
|
display: inline-block;
|
|
3814
3826
|
}
|
|
@@ -3833,12 +3845,12 @@ qti-response-declaration {
|
|
|
3833
3845
|
`]}render(){return h`
|
|
3834
3846
|
<select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
|
|
3835
3847
|
${this.options.map(e=>h`
|
|
3836
|
-
<option value="${e.value}" ?selected="${e.selected}">${
|
|
3848
|
+
<option value="${e.value}" ?selected="${e.selected}">${xe(e.textContent)}</option>
|
|
3837
3849
|
`)}
|
|
3838
3850
|
</select>
|
|
3839
3851
|
|
|
3840
|
-
${
|
|
3841
|
-
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(r=>({textContent:r.innerHTML,value:r.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(r=>r.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,r)=>({...e,selected:r===0}))}set value(e){this.options=this.options.map(r=>(e===r.value&&(r.selected=!0),r))}get value(){return this.options.find(e=>e.selected).value}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(r=>e===r.value).textContent}</span>`}choiceSelected(e){let r=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===r})),this.saveResponse(r)}};
|
|
3852
|
+
${xe(this.correctOption)}
|
|
3853
|
+
`}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(r=>({textContent:r.innerHTML,value:r.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(r=>r.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,r)=>({...e,selected:r===0}))}set value(e){this.options=this.options.map(r=>(e===r.value&&(r.selected=!0),r))}get value(){return this.options.find(e=>e.selected).value}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(r=>e===r.value).textContent}</span>`}choiceSelected(e){let r=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===r})),this.saveResponse(r)}};qe.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],l([q()],qe.prototype,"options",2),l([q()],qe.prototype,"correctOption",2),l([p({attribute:"data-prompt",type:String})],qe.prototype,"dataPrompt",2),qe=l([u("qti-inline-choice-interaction")],qe);var wr=(s,t)=>{class e extends s{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(o){o.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let o=Array.from(this.querySelectorAll(t)),n=o.filter(f=>f.hasAttribute("fixed")),a=o.filter(f=>!f.hasAttribute("fixed"));if(a.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let c=[...a],d=!1,m=0;for(;!d&&m<10;){m++;for(let f=a.length-1;f>0;f--){let y=Math.floor(Math.random()*(f+1));[a[f],a[y]]=[a[y],a[f]]}d=!a.every((f,y)=>f===c[y])}d||console.warn("Failed to shuffle the choices after multiple attempts.");let g=1;[...n,...a].forEach(f=>{f.style.setProperty("order",String(g++))})}_resetShuffleChoices(){this.querySelectorAll(t).forEach(o=>{o.style.setProperty("order","initial")})}}return l([p({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var As=(s,t)=>{class e extends s{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(o){o&&(this._classes=o.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(o){super.updated(o),o.has("shuffle")&&this._addLabels()}_addLabels(){let o=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(o){let c=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,m)=>({el:d,order:n(d.style.order)?+d.style.order:m+1})).sort((d,m)=>d.order-m.order).map(d=>d.el);for(let d=0;d<c.length;d++)c[d].marker=this._getLabel(d+1)}}_getLabel(o){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let c="";switch(n){case"qti-labels-decimal":c=`${o}`;break;case"qti-labels-lower-alpha":c=`${String.fromCharCode(97+o-1)}`;break;case"qti-labels-upper-alpha":c=`${String.fromCharCode(65+o-1)}`;break}return a==="qti-labels-suffix-period"?c+=".":a==="qti-labels-suffix-parenthesis"&&(c+=")"),c}}return l([p({type:String,reflect:!0})],e.prototype,"class",1),e};var Ss=b`
|
|
3842
3854
|
[part='slot'] {
|
|
3843
3855
|
display: flex;
|
|
3844
3856
|
flex-direction: column;
|
|
@@ -3876,14 +3888,28 @@ qti-response-declaration {
|
|
|
3876
3888
|
:host([orientation='horizontal']) [part='slot'] {
|
|
3877
3889
|
flex-direction: row;
|
|
3878
3890
|
}
|
|
3879
|
-
`;var
|
|
3891
|
+
`;var Ye=class extends As(wr(ye(w,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return h`
|
|
3880
3892
|
<slot part="prompt" name="prompt"></slot><slot part="slot"></slot>
|
|
3881
3893
|
<div part="message" role="alert" id="validationMessage"></div>
|
|
3882
|
-
`}};
|
|
3894
|
+
`}};Ye.styles=Ss,l([p({type:String})],Ye.prototype,"orientation",2),Ye=l([u("qti-choice-interaction")],Ye);var Mt=class extends w{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get value(){return this._base64}set value(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...w.properties}}render(){return h`
|
|
3895
|
+
<div>
|
|
3896
|
+
<slot name="prompt"></slot>
|
|
3897
|
+
<input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
|
|
3898
|
+
</div>
|
|
3899
|
+
`}async _onFileChange(e){let r=e.target;r.files&&r.files.length>0&&(this._file=r.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((r,i)=>{let o=new FileReader;o.onload=()=>r(o.result),o.onerror=()=>i(o.error),o.readAsDataURL(e)})}};Mt.styles=[b`
|
|
3900
|
+
:host {
|
|
3901
|
+
display: block;
|
|
3902
|
+
margin: 1em 0;
|
|
3903
|
+
}
|
|
3904
|
+
input[type='file'] {
|
|
3905
|
+
display: block;
|
|
3906
|
+
margin-top: 0.5em;
|
|
3907
|
+
}
|
|
3908
|
+
`],Mt=l([u("qti-upload-interaction")],Mt);var Rt=class extends v{render(){return h`<slot></slot>`}process(){let t=new si,e=[...this.children];t.process(e)}};Rt.styles=[b`
|
|
3883
3909
|
:host {
|
|
3884
3910
|
display: none;
|
|
3885
3911
|
}
|
|
3886
|
-
`],
|
|
3912
|
+
`],Rt=l([u("qti-outcome-processing")],Rt);var si=class{process(t){for(let e of t)e.process()}};var Ms=`<qti-response-processing>
|
|
3887
3913
|
<qti-response-condition>
|
|
3888
3914
|
<qti-response-if>
|
|
3889
3915
|
<qti-match>
|
|
@@ -3916,7 +3942,7 @@ qti-response-declaration {
|
|
|
3916
3942
|
</qti-set-outcome-value>
|
|
3917
3943
|
</qti-response-else>
|
|
3918
3944
|
</qti-response-condition>
|
|
3919
|
-
</qti-response-processing>`,
|
|
3945
|
+
</qti-response-processing>`,Ls=`<qti-response-processing>
|
|
3920
3946
|
<qti-response-condition>
|
|
3921
3947
|
<qti-response-if>
|
|
3922
3948
|
<qti-is-null>
|
|
@@ -3932,19 +3958,19 @@ qti-response-declaration {
|
|
|
3932
3958
|
</qti-set-outcome-value>
|
|
3933
3959
|
</qti-response-else>
|
|
3934
3960
|
</qti-response-condition>
|
|
3935
|
-
</qti-response-processing>`;var
|
|
3961
|
+
</qti-response-processing>`;var Re=class extends v{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let r of e)r.process()}firstUpdated(t){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),r=e[e.length-1].replace(".xml","");switch(this.innerHTML="",r){case"map_response":{this.appendChild(this.fragmentFromString(Rs).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(Ls).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Ms).firstElementChild.firstElementChild);break}}}fragmentFromString(t){return document.createRange().createContextualFragment(t)}};Re.styles=[b`
|
|
3936
3962
|
:host {
|
|
3937
3963
|
display: none;
|
|
3938
3964
|
}
|
|
3939
|
-
`],
|
|
3940
|
-
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};
|
|
3965
|
+
`],Re=l([u("qti-response-processing")],Re);var ee=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};ee=l([u("qti-rule")],ee);var Cr=class extends ee{get childExpression(){return this.firstElementChild}process(){let t=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(t),r;return e.interpolationTable&&(r=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),r==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:Ct(r)}})),r)}};l([p({type:String})],Cr.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Cr);var oi=class extends ee{render(){return h`<slot></slot>`}process(){let t=[...this.children];for(let e=0;e<t.length;e++){let r=t[e];if(r.calculate()){r.process();return}}}};customElements.define("qti-response-condition",oi);var ni=class extends ee{process(){let t=this.getAttribute("identifier"),e=this.firstElementChild,i=new ai(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:Array.isArray(i)?i.map(o=>Ct(o)):Ct(i)}}))}},ai=class{constructor(t){this.expression=t}process(){let t=this.expression?this.expression.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}return t}};customElements.define("qti-set-outcome-value",ni);var Lt=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let t=this.getSubRules();for(let e=0;e<t.length;e++)t[e].process()}};customElements.define("qti-response-else",Lt);var $t=class extends Lt{calculate(){return this.firstElementChild.calculate()}getSubRules(){let t=[];for(let e=1;e<this.children.length;e++)t.push(this.children[e]);return t}};customElements.define("qti-response-if",$t);var li=class extends $t{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",li);var _=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let r=e.getAttribute("identifier")||"";return this.context.variables.find(o=>o.identifier===r)||null}case"qti-multiple":{let i=e.getResult();return i.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(o=>o.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let r=e.getAttribute("identifier")||"",i=this.context.variables.find(o=>o.identifier===r)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
|
|
3966
|
+
<slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};_.styles=b`
|
|
3941
3967
|
slot {
|
|
3942
3968
|
display: none;
|
|
3943
3969
|
}
|
|
3944
|
-
`,l([q()],C.prototype,"result",2),l([T({context:$,subscribe:!0}),q()],C.prototype,"context",2);var O=class extends C{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var xr=class extends Io(O){calculate(){return this.calculateChildren(Array.from(this.children))}};function Io(s){return class extends s{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.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)}}}customElements.define("qti-and",xr);var qr=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};l([p({type:String,attribute:"base-type"})],qr.prototype,"baseType",2);customElements.define("qti-base-value",qr);var ri=class extends O{getResult(){let t=this.getVariables();if(this.children.length===2){let e=t[0],r=t[1];if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,o=r.value;return i.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return r.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",ri);var ii=class extends C{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(r=>r.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",ii);var wr=class extends C{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let r=parseInt(this.getAttribute("figures")||"0");return isNaN(r)?(console.error("figures attribute is not a number"),null):r<0?(console.error("figures attribute is negative"),null):r<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):r}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(this.roundingMode===null)return null;if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(r.value),n=parseFloat(i.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*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: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};l([p({type:String})],wr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",wr);var V=class{static compareSingleValues(t,e,r){switch(r){case"identifier":case"string":return t===e;case"integer":{let i=parseInt(t,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let i=parseFloat(t),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=t.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return r==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Er=class extends C{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):V.compareSingleValues(r.value,i.value,r.baseType)}return console.error("unexpected number of children in qti-equal"),null}};l([p({type:String})],Er.prototype,"toleranceMode",2);customElements.define("qti-equal",Er);var si=class extends C{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float"))return+e.value>+r.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",si);var oi=class extends O{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float")?+e.value>=+r.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",oi);var ni=class extends C{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",ni);var ai=class extends C{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float"))return+e.value<+r.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",ai);var li=class extends O{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float")?+e.value<=+r.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",li);var Cr=class extends C{getResult(){let t=this.context.variables.find(o=>o.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} can not be found`),null;let e=t.mapping,r=Array.isArray(t.value)?t.value:[t.value],i=0;for(let o of r){let n=e.mapEntries.find(a=>V.compareSingleValues(a.mapKey,o,t.baseType));n==null||n.mappedValue==null?i+=e.defaultValue:i+=n.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};l([p({type:String})],Cr.prototype,"identifier",2);customElements.define("qti-map-response",Cr);var Be=class extends v{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};l([p({attribute:"default-value",type:Number})],Be.prototype,"defaultValue",2),l([p({attribute:"lower-bound",type:Number})],Be.prototype,"lowerBound",2),l([p({attribute:"upper-bound",type:Number})],Be.prototype,"upperBound",2);customElements.define("qti-mapping",Be);var ci=class s extends C{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return s.match(e,r)}return console.error("unexpected number of children in match"),null}static match(t,e){switch(e.cardinality){case"single":return t.value===null?!1:Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):V.compareSingleValues(t.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let r=0;r<t.value.length;r++)if(!V.compareSingleValues(e.value[r],t.value[r],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let r=0;for(let i of e.value){let o=null,n=[...t.value];for(let a of n)if(V.compareSingleValues(i,a,e.baseType)){o=a;break}if(o!==null)n.splice(n.indexOf(o),1);else return!1;r++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",ci);var di=class extends C{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,r]=t;if(e.baseType===r.baseType||e.baseType==="integer"&&r.baseType==="float"||e.baseType==="float"&&r.baseType==="integer"||console.warn("Which must both have the same base-type"),r.cardinality==="multiple"||r.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||r.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||r.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||r.value===null)return null;let i=e.value;return r.value.includes(i)}};customElements.define("qti-member",di);var pi=class extends C{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};customElements.define("qti-multiple",pi);var hi=class extends C{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",hi);var ui=class extends O{getResult(){return Array.from(this.children).map(e=>{let r=e;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",ui);var mi=class extends C{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};customElements.define("qti-ordered",mi);var St=class extends v{render(){let t=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(t,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};l([p({type:String})],St.prototype,"identifier",2),l([T({context:$,subscribe:!0}),q()],St.prototype,"context",2);customElements.define("qti-printed-variable",St);var gi=class extends C{getResult(){return this.getVariables().reduce((r,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return r*parseInt(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return r},1)}};customElements.define("qti-product",gi);var _r=class extends No(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function No(s){return class extends s{calculateChildren(e){let r=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=i.calculate();return Number.isNaN(o)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(o)});return r.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):r[0]-r[1]}}}customElements.define("qti-subtract",_r);var kr=class extends C{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let o=this.caseSensitive==="true"?r.value:r.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return V.compareSingleValues(o,n,r.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};l([p({type:String,attribute:"case-sensitive"})],kr.prototype,"caseSensitive",2);customElements.define("qti-string-match",kr);var fi=class extends C{constructor(){super(),this._expression=new bi(Array.from(this.children))}getResult(){return this._expression.calculate()}},bi=class{constructor(t){this.expressions=t}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=e.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,r)=>e+r,0)}};customElements.define("qti-sum",fi);var vi=class extends C{getResult(){let t=this.getAttribute("identifier");return this.context.variables.find(r=>r.identifier===t).value}};customElements.define("qti-variable",vi);var Se=class extends E{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)r&&(n.paths[a]=this.getResolvablePath(n.paths[a],r));return n}}catch{}return null};this.getResolvablePathString=(e,r)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`));this.getResolvablePath=(e,r)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,r)):this.getResolvablePathString(e,r)}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i){for(let o in i)if(i.hasOwnProperty(o)){let n=i[o];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),i=JSON.stringify(e);if(i!==this.rawResponse){this.rawResponse=i;let o=this.convertQtiVariableJSON(r);this.value=o,this.saveResponse(o)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let r=e.querySelectorAll("properties"),i={},o=a=>{let c={},d=a.getAttribute("key");if(d){let u=Array.from(a.children),m=u.map(y=>y.getAttribute("key"));m.length>0&&!m.find(y=>!Number.isInteger(+y))?c[d]=u.map(y=>n(y)):c[d]=a.textContent}return c},n=a=>{if(a){let c={};for(let d of a.children)c={...c,...o(d)};return c}};for(let a of r)return a.getAttribute("key")||(i={...i,...n(a)}),i;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",i=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(i,o,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,o),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(a=>a.getAttribute("href")).forEach(a=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=a,i.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:i=>{this.register(i)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],i=>{i([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let r=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let o=i.querySelectorAll("qti-interaction-module");for(let n of o){let a=n.getAttribute("id"),c=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&c){let u=d?this.combineRequireResolvePaths(this.getResolvablePath(c,r),this.getResolvablePath(d,r)):this.getResolvablePath(c,r),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,u)}}}return e}combineRequireResolvePaths(e,r){let i=Array.isArray(e)?e:[e],o=Array.isArray(r)?r:[r];return i.concat(o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return h`<slot></slot>${this._errorMessage&&h`<div style="color:red">
|
|
3970
|
+
`,l([q()],_.prototype,"result",2),l([A({context:$,subscribe:!0}),q()],_.prototype,"context",2);var O=class extends _{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var _r=class extends Ho(O){calculate(){return this.calculateChildren(Array.from(this.children))}};function Ho(s){return class extends s{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.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)}}}customElements.define("qti-and",_r);var kr=class extends _{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};l([p({type:String,attribute:"base-type"})],kr.prototype,"baseType",2);customElements.define("qti-base-value",kr);var ci=class extends O{getResult(){let t=this.getVariables();if(this.children.length===2){let e=t[0],r=t[1];if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,o=r.value;return i.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return r.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",ci);var di=class extends _{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(r=>r.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",di);var Tr=class extends _{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let r=parseInt(this.getAttribute("figures")||"0");return isNaN(r)?(console.error("figures attribute is not a number"),null):r<0?(console.error("figures attribute is negative"),null):r<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):r}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(this.roundingMode===null)return null;if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(r.value),n=parseFloat(i.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*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: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};l([p({type:String})],Tr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Tr);var V=class{static compareSingleValues(t,e,r){switch(r){case"identifier":case"string":return t===e;case"integer":{let i=parseInt(t,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let i=parseFloat(t),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=t.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return r==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Ar=class extends _{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):V.compareSingleValues(r.value,i.value,r.baseType)}return console.error("unexpected number of children in qti-equal"),null}};l([p({type:String})],Ar.prototype,"toleranceMode",2);customElements.define("qti-equal",Ar);var pi=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float"))return+e.value>+r.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",pi);var hi=class extends O{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float")?+e.value>=+r.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",hi);var ui=class extends _{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",ui);var mi=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float"))return+e.value<+r.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",mi);var gi=class extends O{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(r.baseType==="integer"||r.baseType==="float")?+e.value<=+r.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",gi);var Sr=class extends _{getResult(){let t=this.context.variables.find(o=>o.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} can not be found`),null;let e=t.mapping,r=Array.isArray(t.value)?t.value:[t.value],i=0;for(let o of r){let n=e.mapEntries.find(a=>V.compareSingleValues(a.mapKey,o,t.baseType));n==null||n.mappedValue==null?i+=e.defaultValue:i+=n.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};l([p({type:String})],Sr.prototype,"identifier",2);customElements.define("qti-map-response",Sr);var Ge=class extends v{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};l([p({attribute:"default-value",type:Number})],Ge.prototype,"defaultValue",2),l([p({attribute:"lower-bound",type:Number})],Ge.prototype,"lowerBound",2),l([p({attribute:"upper-bound",type:Number})],Ge.prototype,"upperBound",2);customElements.define("qti-mapping",Ge);var fi=class s extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return s.match(e,r)}return console.error("unexpected number of children in match"),null}static match(t,e){switch(e.cardinality){case"single":return t.value===null?!1:Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):V.compareSingleValues(t.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let r=0;r<t.value.length;r++)if(!V.compareSingleValues(e.value[r],t.value[r],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let r=0;for(let i of e.value){let o=null,n=[...t.value];for(let a of n)if(V.compareSingleValues(i,a,e.baseType)){o=a;break}if(o!==null)n.splice(n.indexOf(o),1);else return!1;r++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",fi);var bi=class extends _{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,r]=t;if(e.baseType===r.baseType||e.baseType==="integer"&&r.baseType==="float"||e.baseType==="float"&&r.baseType==="integer"||console.warn("Which must both have the same base-type"),r.cardinality==="multiple"||r.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||r.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||r.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||r.value===null)return null;let i=e.value;return r.value.includes(i)}};customElements.define("qti-member",bi);var vi=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};customElements.define("qti-multiple",vi);var yi=class extends _{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",yi);var xi=class extends O{getResult(){return Array.from(this.children).map(e=>{let r=e;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",xi);var qi=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};customElements.define("qti-ordered",qi);var Dt=class extends v{render(){let t=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(t,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};l([p({type:String})],Dt.prototype,"identifier",2),l([A({context:$,subscribe:!0}),q()],Dt.prototype,"context",2);customElements.define("qti-printed-variable",Dt);var Ei=class extends _{getResult(){return this.getVariables().reduce((r,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return r*parseInt(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return r},1)}};customElements.define("qti-product",Ei);var Mr=class extends Oo(_){getResult(){return this.calculateChildren(Array.from(this.children))}};function Oo(s){return class extends s{calculateChildren(e){let r=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let o=i.calculate();return Number.isNaN(o)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(o)});return r.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):r[0]-r[1]}}}customElements.define("qti-subtract",Mr);var Rr=class extends _{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let o=this.caseSensitive==="true"?r.value:r.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return V.compareSingleValues(o,n,r.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};l([p({type:String,attribute:"case-sensitive"})],Rr.prototype,"caseSensitive",2);customElements.define("qti-string-match",Rr);var wi=class extends _{constructor(){super(),this._expression=new Ci(Array.from(this.children))}getResult(){return this._expression.calculate()}},Ci=class{constructor(t){this.expressions=t}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=e.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,r)=>e+r,0)}};customElements.define("qti-sum",wi);var _i=class extends _{getResult(){let t=this.getAttribute("identifier");return this.context.variables.find(r=>r.identifier===t).value}};customElements.define("qti-variable",_i);var Le=class extends w{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)r&&(n.paths[a]=this.getResolvablePath(n.paths[a],r));return n}}catch{}return null};this.getResolvablePathString=(e,r)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`));this.getResolvablePath=(e,r)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,r)):this.getResolvablePathString(e,r)}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i){for(let o in i)if(i.hasOwnProperty(o)){let n=i[o];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),i=JSON.stringify(e);if(i!==this.rawResponse){this.rawResponse=i;let o=this.convertQtiVariableJSON(r);this.value=o,this.saveResponse(o)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let r=e.querySelectorAll("properties"),i={},o=a=>{let c={},d=a.getAttribute("key");if(d){let m=Array.from(a.children),g=m.map(y=>y.getAttribute("key"));g.length>0&&!g.find(y=>!Number.isInteger(+y))?c[d]=m.map(y=>n(y)):c[d]=a.textContent}return c},n=a=>{if(a){let c={};for(let d of a.children)c={...c,...o(d)};return c}};for(let a of r)return a.getAttribute("key")||(i={...i,...n(a)}),i;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",i=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(i,o,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,o),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(a=>a.getAttribute("href")).forEach(a=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=a,i.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:i=>{this.register(i)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],i=>{i([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let r=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let o=i.querySelectorAll("qti-interaction-module");for(let n of o){let a=n.getAttribute("id"),c=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&c){let m=d?this.combineRequireResolvePaths(this.getResolvablePath(c,r),this.getResolvablePath(d,r)):this.getResolvablePath(c,r),g=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(g,m)}}}return e}combineRequireResolvePaths(e,r){let i=Array.isArray(e)?e:[e],o=Array.isArray(r)?r:[r];return i.concat(o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return h`<slot></slot>${this._errorMessage&&h`<div style="color:red">
|
|
3945
3971
|
<h1>Error</h1>
|
|
3946
3972
|
${this._errorMessage}
|
|
3947
|
-
</div>`}`}};l([p({type:String,attribute:"module"})],Se.prototype,"module",2),l([p({type:String,attribute:"custom-interaction-type-identifier"})],Se.prototype,"customInteractionTypeIdentifier",2),l([q()],Se.prototype,"_errorMessage",2),Se=l([g("qti-portable-custom-interaction")],Se);var Tr=class s{constructor(){this.draggables=[];this.droppables=[];this.dragContainers=[];this.touchStartPoint=null;this.isDraggable=!1;this.dragSource=null;this.dragClone=null;this.touchEndTriggered=!1;this.isDragging=!1;this.initialTransform="";this.hasDispatchedDragStart=!1;this.rootNode=null;this.allDropzones=[];this.dataTransfer={data:{},setData(t,e){this.data[t]=e},getData(t){return this.data[t]},effectAllowed:"move"};this.cloneOffset={x:0,y:0};this.lastTarget=null;this.currentDropTarget=null;this.copyStylesForDragClone=!0;this.dragOnClickEnabled=!1;this.useDragClone=!1;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;if(s.instance)return s.instance;s.instance=this,document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1})}dragContainersModified(t,e){for(let r of e)this.dragContainers.includes(r)&&(this.dragContainers=this.dragContainers.filter(i=>i!==r),this.allDropzones=this.allDropzones.filter(i=>i!==r));for(let r of t)this.dragContainers.includes(r)||(this.dragContainers.push(r),this.allDropzones.push(r))}draggablesModified(t,e){for(let r of e)this.draggables.includes(r)&&(this.draggables=this.draggables.filter(i=>i!==r),r.removeAttribute("tabindex"),r.removeEventListener("touchstart",this.handleTouchStart.bind(this)),r.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let r of t)this.draggables.includes(r)||(this.draggables.push(r),r.setAttribute("tabindex","0"),r.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),r.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}))}droppablesModified(t,e){for(let r of e)this.droppables.includes(r)&&(this.droppables=this.droppables.filter(i=>i!==r),this.allDropzones=this.allDropzones.filter(i=>i!==r));for(let r of t)this.droppables.includes(r)||(this.droppables.push(r),this.allDropzones.push(r))}handleTouchStart(t){let{x:e,y:r}=this.getEventCoordinates(t);if(this.touchStartPoint={x:e,y:r},this.dragSource=t.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode(),this.dragOnClickEnabled&&(this.isDragging=!0,this.createDragClone(t,{clientX:e,clientY:r})),!this.useDragClone){let i=window.getComputedStyle(this.dragSource);this.initialTransform=i.transform==="none"?"":i.transform,this.initialTransition=i.transition||"",this.dragSource.style.transition="none";let o=this.dragSource.getBoundingClientRect();this.cloneOffset.x=e-o.left,this.cloneOffset.y=r-o.top,this.dragSource.style.zIndex="9999",this.dragSource.focus()}t.preventDefault()}handleTouchMove(t){if(this.isDraggable&&this.dragSource){let{x:e,y:r}=this.getEventCoordinates(t),i={clientX:e,clientY:r};this.calculateDragDistance(i)>=this.MIN_DRAG_DISTANCE&&(this.dragSource.style.pointerEvents="none",this.isDragging=!0),this.createDragClone(t,i),t.preventDefault();let o=this.findClosestDropzone();this.currentDropTarget=o,o!==this.lastTarget&&(this.lastTarget&&this.dispatchCustomEvent(this.lastTarget,"dragleave"),o&&this.dispatchCustomEvent(o,"dragenter"),this.lastTarget=o),this.lastTarget&&this.dispatchCustomEvent(this.lastTarget,"dragover")}}createDragClone(t,e){if(!this.isDragging)return;if(this.useDragClone){if(!this.dragClone){if(this.dragSource.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone=this.dragSource.cloneNode(!0),this.copyStylesForDragClone){let i=window.getComputedStyle(this.dragSource);for(let o of i)this.dragClone.style[o]=i.getPropertyValue(o)}this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),this.calculateClonePosition(e),this.setDragCloneStyles(e),this.dispatchCustomEvent(this.dragSource,"dragstart")}this.updateDragClonePosition(e)}else if(this.touchStartPoint){let i=e.clientX-this.touchStartPoint.x,o=e.clientY-this.touchStartPoint.y;this.dragSource.style.transform=`${this.initialTransform} translate(${i}px, ${o}px)`,this.hasDispatchedDragStart||(this.dispatchCustomEvent(this.dragSource,"dragstart"),this.hasDispatchedDragStart=!0)}let r=this.currentDropTarget;r!==this.lastTarget&&(this.dispatchCustomEvent(r,"dragenter"),this.dispatchCustomEvent(this.lastTarget,"dragleave"),this.lastTarget=r),this.currentDropTarget=r,this.currentDropTarget&&this.dispatchCustomEvent(r,"dragover")}handleTouchEnd(t){this.touchEndTriggered=!0,this.isDraggable=!1;let e=!1;if(this.currentDropTarget)this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),e=!0;else if(this.isDragging){let r=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});r.dataTransfer={dropEffect:"none"},this.dragSource?.dispatchEvent(r)}this.resetDragState(e)}handleTouchCancel(t){this.resetDragState()}findClosestDropzone(){if(!this.dragSource||this.allDropzones.length===0)return null;let t=this.dragSource.getBoundingClientRect(),e=this.getCorners(t),r=this.getCenter(t),i=null,o=1/0;for(let n of this.allDropzones){let a=n.getBoundingClientRect(),c=this.getCorners(a),d=this.getCenter(a),u=this.calculateTotalCornerDistance(e,c)/this.getRectDiagonal(a),m=this.calculateDistance(r,d),f=u*.5+m*.5;f<o&&(o=f,i=n)}return i}getCenter(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}getRectDiagonal(t){return Math.sqrt(t.width**2+t.height**2)}getCorners(t){return{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomLeft:{x:t.left,y:t.bottom},bottomRight:{x:t.right,y:t.bottom}}}calculateTotalCornerDistance(t,e){return this.calculateDistance(t.topLeft,e.topLeft)+this.calculateDistance(t.topRight,e.topRight)+this.calculateDistance(t.bottomLeft,e.bottomLeft)+this.calculateDistance(t.bottomRight,e.bottomRight)}calculateDistance(t,e){let r=t.x-e.x,i=t.y-e.y;return Math.sqrt(r*r+i*i)}getEventCoordinates(t,e=!1){let r=t.touches?t.touches[0]:t;return{x:e?r.pageX:r.clientX,y:e?r.pageY:r.clientY}}calculateClonePosition(t){let e=this.dragSource.getBoundingClientRect();this.cloneOffset.x=t.clientX-e.left,this.cloneOffset.y=t.clientY-e.top}setDragCloneStyles(t){this.dragClone.style.position="fixed",this.dragClone.style.top=`${t.clientY-this.cloneOffset.y}px`,this.dragClone.style.left=`${t.clientX-this.cloneOffset.x}px`,this.dragClone.style.pointerEvents="none",this.dragClone.style.zIndex="999999"}updateDragClonePosition(t){requestAnimationFrame(()=>{if(this.touchEndTriggered||!this.dragClone)return;let e=t.clientX-this.cloneOffset.x,r=t.clientY-this.cloneOffset.y,{newLeft:i,newTop:o}=this.applyBoundaries(e,r,this.dragClone);this.dragClone.style.left=`${i}px`,this.dragClone.style.top=`${o}px`})}applyBoundaries(t,e,r){let i;this.rootNode instanceof ShadowRoot?i=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?i=document.documentElement.getBoundingClientRect():i=new DOMRect(0,0,window.innerWidth,window.innerHeight);let o=r.getBoundingClientRect(),n=o.width,a=o.height,c=Math.max(i.left,Math.min(t,i.right-n)),d=Math.max(i.top,Math.min(e,i.bottom-a));return{newLeft:c,newTop:d}}calculateDragDistance(t){let e=Math.abs(t.clientX-this.touchStartPoint.x),r=Math.abs(t.clientY-this.touchStartPoint.y);return e+r}dispatchCustomEvent(t,e,r=!0){if(!t)return;let i=new CustomEvent(e,{bubbles:r,cancelable:!0});i.dataTransfer=this.dataTransfer,t.dispatchEvent(i)}resetDragState(t=!1){this.isDragging&&(this.useDragClone?(this.dragSource.style.opacity="1.0",this.dragClone?.parentElement.removeChild(this.dragClone)):(t||(this.dragSource.style.transform="translate(0, 0)"),this.dragSource.style.zIndex="",this.dragSource.style.pointerEvents="",this.dragSource.style.transition=this.initialTransition,this.initialTransition="")),this.isDragging=!1,this.dragSource=null,this.dragClone=null,this.isDraggable=!1,this.touchStartPoint=null,this.touchEndTriggered=!1,this.dataTransfer={data:{},setData(e,r){this.data[e]=r},getData(e){return this.data[e]},effectAllowed:"move"},this.cloneOffset={x:0,y:0},this.lastTarget=null,this.currentDropTarget=null,this.initialTransform="",this.hasDispatchedDragStart=!1,this.rootNode=null}};var Ls=(s,t)=>{class e extends s{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.isMatchTabular())return;super.firstUpdated(o);let n=this.getDroppableElements();this.initializeEventHandlers(),n.forEach(a=>{this.prepareDroppable(a),this.observeDroppableAttributes(a)})}isMatchTabular(){return this.classList.contains("qti-match-tabular")}getDroppableElements(){return Array.from(this.shadowRoot?.querySelectorAll(t)||[]).concat(Array.from(this.querySelectorAll(t)||[]))}initializeEventHandlers(){this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this)}prepareDroppable(o){o.addEventListener("dragleave",this.dragleaveHandler),this.attachEventListeners(o)}observeDroppableAttributes(o){this.observer=new MutationObserver(n=>{n.forEach(({attributeName:a})=>{a==="disabled"&&this.toggleDroppableHandlers(o)})}),this.observer.observe(o,{attributes:!0})}toggleDroppableHandlers(o){o.hasAttribute("disabled")?this.removeEventListeners(o):this.attachEventListeners(o)}attachEventListeners(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeEventListeners(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){this.isMatchTabular()||(super.disconnectedCallback(),this.observer?.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){let n=o.dataTransfer.getData("responseIdentifier");return o.preventDefault(),n===this.responseIdentifier&&(this.activateDroppable(o.currentTarget),o.dataTransfer.dropEffect="move"),!1}activateDroppable(o){this._internals.states.delete("--dragzone-active"),o.setAttribute("active","")}async dropHandler(o){o.preventDefault();let n=o.currentTarget,a=o.dataTransfer.getData("text"),c=o.dataTransfer.getData("responseIdentifier"),d=this.findDraggable(c,a);return d?d&&!this.isValidDrop(n,d,c)?(d.style.transform="translate(0, 0)",!1):(await this.moveDraggableToDroppable(d,n),this.deactivateDroppable(n,!1),!1):!1}findDraggable(o,n){return n?o===this.responseIdentifier?this.querySelector(`[identifier=${n}]`)||this.shadowRoot.querySelector(`[identifier=${n}]`):this.closest("qti-assessment-item").querySelector(`[response-identifier=${o}]`).querySelector(`[identifier=${n}]`):null}isValidDrop(o,n,a){return this.responseIdentifier===a}async moveDraggableToDroppable(o,n){console.log(`moveDraggableToDroppable, draggable: ${o.tagName}, droppable: ${n.tagName}`);let a=()=>{o.style.transform="translate(0, 0)",n.tagName==="SLOT"?o.setAttribute("slot",n.getAttribute("name")):n.appendChild(o),this.checkMaxAssociations(),this.saveResponse(null)};if(!document.startViewTransition){a();return}await document.startViewTransition(a).finished}deactivateDroppable(o,n=!0){n&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}dragleaveHandler(o){return o.preventDefault(),this.deactivateDroppable(o.currentTarget),o.dataTransfer.dropEffect="none",!1}}return l([p({type:Boolean,reflect:!0})],e.prototype,"disabled",2),e};var $s=(s,t,e)=>{class r extends s{}return r};var re=(s,t,e,r)=>{class i extends $s(Ls(s,e),e,t){constructor(){super(...arguments);this.draggables=new Map;this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.dragContainersModified=(a,c)=>{this.dragDropApi.dragContainersModified(a,c)};this.draggablesModified=(a,c)=>{this.dragDropApi.draggablesModified(a,c),this.dragDropApi.draggables.forEach(d=>{this.storeDraggable(d)})};this.droppablesModified=(a,c)=>{this.dragDropApi.droppablesModified(a,c);for(let d of this.dragDropApi.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")};this.handleDragStart=a=>{let c=a.currentTarget;a.dataTransfer.setData("text",c.getAttribute("identifier")),this.responseIdentifier&&a.dataTransfer.setData("responseIdentifier",this.responseIdentifier),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),c.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(c)};this.handleDragEnd=async a=>{a.preventDefault(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables();let c=a.currentTarget;c.removeAttribute("dragging"),await this.wasDropped(a)||this.configuration.dragCanBePlacedBack&&this.restoreInitialDraggablePosition(c)}}handleDraggableContainerChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.dragContainersModified(a||[],c||[])}handleDraggablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.draggablesModified(a||[],c||[])}handleDroppablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.droppablesModified(a||[],c||[])}firstUpdated(a){super.firstUpdated(a);let c=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),u=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[]));this.dragContainersModified(u,[]),this.droppablesModified(d,[]),this.draggablesModified(c,[])}connectedCallback(){super.connectedCallback(),this.initializeDragDropApi()}initializeDragDropApi(){this.dragDropApi=new Tr,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}isMatchTabular(){return this.classList.contains("qti-match-tabular")}storeDraggable(a){let c=Array.from(a.parentNode.children).indexOf(a);this.draggables.has(a)||this.draggables.set(a,{parent:a.parentElement,index:c}),a.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,a.setAttribute("qti-draggable","true"),a.addEventListener("dragstart",this.handleDragStart),a.addEventListener("dragend",this.handleDragEnd)}activateDroppables(a){this.dragDropApi.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.dragDropApi.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.dragDropApi.dragContainers.forEach(c=>{c.removeAttribute("enabled")}),this.dragDropApi.droppables.forEach(c=>c.removeAttribute("enabled"))}async wasDropped(a){return a.dataTransfer.dropEffect!=="none"}async restoreInitialDraggablePosition(a){let{parent:c,index:d}=this.draggables.get(a),u=(m,f,y)=>{console.log("moveDraggable",m,f,y);let x=Math.min(y,f.children.length);f.insertBefore(m,f.children[x]),m.style.transform="translate(0, 0)",this.checkMaxAssociations()};if(!document.startViewTransition){u(a,c,d);return}}validate(){let a=this.getValidAssociations(),c=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(c=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(c=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let u=this.lastElementChild;return this._internals.setValidity(c?{}:{customError:!0},d,u),this.reportValidity(),c}reportValidity(){let a=this.shadowRoot.querySelector("#validationMessage");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.display="block")),this._internals.validity.valid}checkMaxAssociations(){this.dragDropApi.droppables.forEach(a=>{let c=+(a.getAttribute("match-max")||1);a.querySelectorAll('[qti-draggable="true"]').length>=c?this.disableDroppable(a):this.enableDroppable(a)})}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(a){if(!this.isMatchTabular())if(this.resetDroppables(),a?.forEach(c=>this.placeResponse(c)),Array.isArray(a)){let c=new FormData;a.forEach(d=>{c.append(this.responseIdentifier,d)}),this._internals.setFormValue(c)}else this._internals.setFormValue(a)}placeResponse(a){let[c,...d]=a.split(" ").reverse(),u=this.findDroppableById(c);d.forEach(m=>this.placeDraggableInDroppable(m,u))}findDroppableById(a){return this.dragDropApi.droppables.find(c=>c.getAttribute("identifier")===a)}async placeDraggableInDroppable(a,c){let d=this.querySelector(`[identifier=${a}]`);if(!c||!d){console.error(`Cannot find draggable or droppable with the given identifier: ${a}`);return}let u=()=>{d.style.transform="translate(0, 0)",c.appendChild(d),this.checkMaxAssociations()};document.startViewTransition?await document.startViewTransition(u).finished:u()}getValidAssociations(){return this.dragDropApi.droppables.filter(a=>a.childElementCount>0).length}saveResponse(){this.validate();let a=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.dragDropApi.droppables.map(c=>{let d=c.querySelectorAll('[qti-draggable="true"]'),u=Array.from(d).map(f=>f.getAttribute("identifier")),m=c.getAttribute("identifier");return u.map(f=>`${f} ${m}`)}).flat()}reset(a=!0){this.resetDroppables(),a&&this.saveResponse()}async resetDroppables(){let a=(d,u,m)=>{d.style.transform="translate(0, 0)";let f=Math.min(m,u.children.length);u.insertBefore(d,u.children[f])};if(!document.startViewTransition){this.draggables.forEach(({parent:d,index:u},m)=>{a(m,d,u)});return}await document.startViewTransition(()=>{this.draggables.forEach(({parent:d,index:u},m)=>{a(m,d,u)})}).finished}}return l([p({attribute:!1,type:Object})],i.prototype,"configuration",2),l([p({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),l([p({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),l([tr(r)],i.prototype,"handleDraggableContainerChange",1),l([tr(t)],i.prototype,"handleDraggablesChange",1),l([tr(e)],i.prototype,"handleDroppablesChange",1),i};var Ds=b`
|
|
3973
|
+
</div>`}`}};l([p({type:String,attribute:"module"})],Le.prototype,"module",2),l([p({type:String,attribute:"custom-interaction-type-identifier"})],Le.prototype,"customInteractionTypeIdentifier",2),l([q()],Le.prototype,"_errorMessage",2),Le=l([u("qti-portable-custom-interaction")],Le);var Lr=class s{constructor(){this.draggables=[];this.droppables=[];this.dragContainers=[];this.touchStartPoint=null;this.isDraggable=!1;this.dragSource=null;this.dragClone=null;this.touchEndTriggered=!1;this.isDragging=!1;this.initialTransform="";this.hasDispatchedDragStart=!1;this.rootNode=null;this.allDropzones=[];this.dataTransfer={data:{},setData(t,e){this.data[t]=e},getData(t){return this.data[t]},effectAllowed:"move"};this.cloneOffset={x:0,y:0};this.lastTarget=null;this.currentDropTarget=null;this.copyStylesForDragClone=!0;this.dragOnClickEnabled=!1;this.useDragClone=!1;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;if(s.instance)return s.instance;s.instance=this,document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1})}dragContainersModified(t,e){for(let r of e)this.dragContainers.includes(r)&&(this.dragContainers=this.dragContainers.filter(i=>i!==r),this.allDropzones=this.allDropzones.filter(i=>i!==r));for(let r of t)this.dragContainers.includes(r)||(this.dragContainers.push(r),this.allDropzones.push(r))}draggablesModified(t,e){for(let r of e)this.draggables.includes(r)&&(this.draggables=this.draggables.filter(i=>i!==r),r.removeAttribute("tabindex"),r.removeEventListener("touchstart",this.handleTouchStart.bind(this)),r.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let r of t)this.draggables.includes(r)||(this.draggables.push(r),r.setAttribute("tabindex","0"),r.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),r.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}))}droppablesModified(t,e){for(let r of e)this.droppables.includes(r)&&(this.droppables=this.droppables.filter(i=>i!==r),this.allDropzones=this.allDropzones.filter(i=>i!==r));for(let r of t)this.droppables.includes(r)||(this.droppables.push(r),this.allDropzones.push(r))}handleTouchStart(t){let{x:e,y:r}=this.getEventCoordinates(t);if(this.touchStartPoint={x:e,y:r},this.dragSource=t.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode(),this.dragOnClickEnabled&&(this.isDragging=!0,this.createDragClone(t,{clientX:e,clientY:r})),!this.useDragClone){let i=window.getComputedStyle(this.dragSource);this.initialTransform=i.transform==="none"?"":i.transform,this.initialTransition=i.transition||"",this.dragSource.style.transition="none";let o=this.dragSource.getBoundingClientRect();this.cloneOffset.x=e-o.left,this.cloneOffset.y=r-o.top,this.dragSource.style.zIndex="9999",this.dragSource.focus()}t.preventDefault()}handleTouchMove(t){if(this.isDraggable&&this.dragSource){let{x:e,y:r}=this.getEventCoordinates(t),i={clientX:e,clientY:r};this.calculateDragDistance(i)>=this.MIN_DRAG_DISTANCE&&(this.dragSource.style.pointerEvents="none",this.isDragging=!0),this.createDragClone(t,i),t.preventDefault();let o=this.findClosestDropzone();this.currentDropTarget=o,o!==this.lastTarget&&(this.lastTarget&&this.dispatchCustomEvent(this.lastTarget,"dragleave"),o&&this.dispatchCustomEvent(o,"dragenter"),this.lastTarget=o),this.lastTarget&&this.dispatchCustomEvent(this.lastTarget,"dragover")}}createDragClone(t,e){if(!this.isDragging)return;if(this.useDragClone){if(!this.dragClone){if(this.dragSource.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone=this.dragSource.cloneNode(!0),this.copyStylesForDragClone){let i=window.getComputedStyle(this.dragSource);for(let o of i)this.dragClone.style[o]=i.getPropertyValue(o)}this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),this.calculateClonePosition(e),this.setDragCloneStyles(e),this.dispatchCustomEvent(this.dragSource,"dragstart")}this.updateDragClonePosition(e)}else if(this.touchStartPoint){let i=e.clientX-this.touchStartPoint.x,o=e.clientY-this.touchStartPoint.y;this.dragSource.style.transform=`${this.initialTransform} translate(${i}px, ${o}px)`,this.hasDispatchedDragStart||(this.dispatchCustomEvent(this.dragSource,"dragstart"),this.hasDispatchedDragStart=!0)}let r=this.currentDropTarget;r!==this.lastTarget&&(this.dispatchCustomEvent(r,"dragenter"),this.dispatchCustomEvent(this.lastTarget,"dragleave"),this.lastTarget=r),this.currentDropTarget=r,this.currentDropTarget&&this.dispatchCustomEvent(r,"dragover")}handleTouchEnd(t){this.touchEndTriggered=!0,this.isDraggable=!1;let e=!1;if(this.currentDropTarget)this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),e=!0;else if(this.isDragging){let r=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});r.dataTransfer={dropEffect:"none"},this.dragSource?.dispatchEvent(r)}this.resetDragState(e)}handleTouchCancel(t){this.resetDragState()}findClosestDropzone(){if(!this.dragSource||this.allDropzones.length===0)return null;let t=this.dragSource.getBoundingClientRect(),e=null,r=0;for(let i of this.allDropzones){let o=i.getBoundingClientRect(),n=this.calculateOverlapArea(t,o);n>r&&(r=n,e=i)}if(r===0){let i=this.getCenter(t),o=1/0;for(let n of this.allDropzones){let a=this.getCenter(n.getBoundingClientRect()),c=this.calculateDistance(i,a);c<o&&(o=c,e=n)}}return e}calculateOverlapArea(t,e){let r=Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left)),i=Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top));return r*i}getCenter(t){return{x:t.left+t.width/2,y:t.top+t.height/2}}calculateDistance(t,e){let r=t.x-e.x,i=t.y-e.y;return Math.sqrt(r*r+i*i)}getEventCoordinates(t,e=!1){let r=t.touches?t.touches[0]:t;return{x:e?r.pageX:r.clientX,y:e?r.pageY:r.clientY}}calculateClonePosition(t){let e=this.dragSource.getBoundingClientRect();this.cloneOffset.x=t.clientX-e.left,this.cloneOffset.y=t.clientY-e.top}setDragCloneStyles(t){this.dragClone.style.position="fixed",this.dragClone.style.top=`${t.clientY-this.cloneOffset.y}px`,this.dragClone.style.left=`${t.clientX-this.cloneOffset.x}px`,this.dragClone.style.pointerEvents="none",this.dragClone.style.zIndex="999999"}updateDragClonePosition(t){requestAnimationFrame(()=>{if(this.touchEndTriggered||!this.dragClone)return;let e=t.clientX-this.cloneOffset.x,r=t.clientY-this.cloneOffset.y,{newLeft:i,newTop:o}=this.applyBoundaries(e,r,this.dragClone);this.dragClone.style.left=`${i}px`,this.dragClone.style.top=`${o}px`})}applyBoundaries(t,e,r){let i;this.rootNode instanceof ShadowRoot?i=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?i=document.documentElement.getBoundingClientRect():i=new DOMRect(0,0,window.innerWidth,window.innerHeight);let o=r.getBoundingClientRect(),n=o.width,a=o.height,c=Math.max(i.left,Math.min(t,i.right-n)),d=Math.max(i.top,Math.min(e,i.bottom-a));return{newLeft:c,newTop:d}}calculateDragDistance(t){let e=Math.abs(t.clientX-this.touchStartPoint.x),r=Math.abs(t.clientY-this.touchStartPoint.y);return e+r}dispatchCustomEvent(t,e,r=!0){if(!t)return;let i=new CustomEvent(e,{bubbles:r,cancelable:!0});i.dataTransfer=this.dataTransfer,t.dispatchEvent(i)}resetDragState(t=!1){this.isDragging&&(this.useDragClone?(this.dragSource.style.opacity="1.0",this.dragClone?.parentElement.removeChild(this.dragClone)):(t||(this.dragSource.style.transform="translate(0, 0)"),this.dragSource.style.zIndex="",this.dragSource.style.pointerEvents="",this.dragSource.style.transition=this.initialTransition,this.initialTransition="")),this.isDragging=!1,this.dragSource=null,this.dragClone=null,this.isDraggable=!1,this.touchStartPoint=null,this.touchEndTriggered=!1,this.dataTransfer={data:{},setData(e,r){this.data[e]=r},getData(e){return this.data[e]},effectAllowed:"move"},this.cloneOffset={x:0,y:0},this.lastTarget=null,this.currentDropTarget=null,this.initialTransform="",this.hasDispatchedDragStart=!1,this.rootNode=null}};var $s=(s,t)=>{class e extends s{constructor(){super(...arguments);this.disabled=!1}firstUpdated(o){if(this.isMatchTabular())return;super.firstUpdated(o);let n=this.getDroppableElements();this.initializeEventHandlers(),n.forEach(a=>{this.prepareDroppable(a),this.observeDroppableAttributes(a)})}isMatchTabular(){return this.classList.contains("qti-match-tabular")}getDroppableElements(){return Array.from(this.shadowRoot?.querySelectorAll(t)||[]).concat(Array.from(this.querySelectorAll(t)||[]))}initializeEventHandlers(){this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this)}prepareDroppable(o){o.addEventListener("dragleave",this.dragleaveHandler),this.attachEventListeners(o)}observeDroppableAttributes(o){this.observer=new MutationObserver(n=>{n.forEach(({attributeName:a})=>{a==="disabled"&&this.toggleDroppableHandlers(o)})}),this.observer.observe(o,{attributes:!0})}toggleDroppableHandlers(o){o.hasAttribute("disabled")?this.removeEventListeners(o):this.attachEventListeners(o)}attachEventListeners(o){o.addEventListener("dragover",this.dragoverHandler),o.addEventListener("dragenter",this.dragenterHandler),o.addEventListener("drop",this.dropHandler)}removeEventListeners(o){o.removeEventListener("dragover",this.dragoverHandler),o.removeEventListener("dragenter",this.dragenterHandler),o.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){this.isMatchTabular()||(super.disconnectedCallback(),this.observer?.disconnect())}dragenterHandler(o){o.preventDefault()}dragoverHandler(o){return o.preventDefault(),this.activateDroppable(o.currentTarget),o.dataTransfer.dropEffect="move",!1}activateDroppable(o){this._internals.states.delete("--dragzone-active"),o.setAttribute("active","")}async dropHandler(o){o.preventDefault();let n=o.currentTarget,a=o.dataTransfer.getData("text"),c=o.dataTransfer.getData("responseIdentifier"),d=this.findDraggable(c,a);return d?d&&!this.isValidDrop(n,d,c)?(d.style.transform="translate(0, 0)",!1):(await this.moveDraggableToDroppable(d,n),this.deactivateDroppable(n,!1),!1):!1}findDraggable(o,n){return n?this.querySelector(`[identifier=${n}]`)||this.shadowRoot.querySelector(`[identifier=${n}]`):null}isValidDrop(o,n,a){return!0}async moveDraggableToDroppable(o,n){console.log(`moveDraggableToDroppable, draggable: ${o.tagName}, droppable: ${n.tagName}`);let a=()=>{o.style.transform="translate(0, 0)",n.tagName==="SLOT"?o.setAttribute("slot",n.getAttribute("name")):n.appendChild(o),this.checkMaxAssociations(),this.saveResponse(null)};if(!document.startViewTransition){a();return}await document.startViewTransition(a).finished}deactivateDroppable(o,n=!0){n&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}dragleaveHandler(o){return o.preventDefault(),this.deactivateDroppable(o.currentTarget),o.dataTransfer.dropEffect="none",!1}}return l([p({type:Boolean,reflect:!0})],e.prototype,"disabled",2),e};var Ds=(s,t,e)=>{class r extends s{}return r};var te=(s,t,e,r)=>{class i extends Ds($s(s,e),e,t){constructor(){super(...arguments);this.draggables=new Map;this.observer=null;this.resizeObserver=null;this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.dragContainersModified=(a,c)=>{this.dragDropApi.dragContainersModified(a,c)};this.draggablesModified=(a,c)=>{this.dragDropApi.draggablesModified(a,c),this.dragDropApi.draggables.forEach(d=>{this.storeDraggable(d)})};this.droppablesModified=(a,c)=>{this.dragDropApi.droppablesModified(a,c);for(let d of this.dragDropApi.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")};this.handleDragStart=a=>{let c=a.currentTarget;a.dataTransfer.setData("text",c.getAttribute("identifier")),this.responseIdentifier&&a.dataTransfer.setData("responseIdentifier",this.responseIdentifier),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),c.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(c)};this.handleDragEnd=async a=>{a.preventDefault();let c=a.currentTarget;this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),c.removeAttribute("dragging"),await this.wasDropped(a)||this.configuration.dragCanBePlacedBack&&this.restoreInitialDraggablePosition(c)}}handleDraggableContainerChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.dragContainersModified(a||[],c||[])}handleDraggablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.draggablesModified(a||[],c||[])}handleDroppablesChange(a,c){this.isMatchTabular()||(a.length>0||c.length>0)&&this.droppablesModified(a||[],c||[])}firstUpdated(a){super.firstUpdated(a);let c=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[]));this.dragContainersModified(m,[]),this.droppablesModified(d,[]),this.draggablesModified(c,[]),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(f=>this.resizeObserver?.observe(f))}connectedCallback(){super.connectedCallback(),this.initializeDragDropApi()}initializeDragDropApi(){this.dragDropApi=new Lr,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}isMatchTabular(){return this.classList.contains("qti-match-tabular")}storeDraggable(a){let c=Array.from(a.parentNode.children).indexOf(a);this.draggables.has(a)||this.draggables.set(a,{parent:a.parentElement,index:c}),a.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,a.setAttribute("qti-draggable","true"),a.addEventListener("dragstart",this.handleDragStart),a.addEventListener("dragend",this.handleDragEnd)}updateMinDimensionsForDropZones(){let a=this.querySelectorAll(t),c=Array.from(this.querySelectorAll(e)).map(f=>f),d=0,m=0;a.forEach(f=>{let y=f.getBoundingClientRect();d=Math.max(d,y.height),m=Math.max(m,y.width)});let g=this.querySelector(r)||this.shadowRoot?.querySelector(r);g&&(g.style.minHeight=`${d}px`,g.style.minWidth=`${m}px`);for(let f of c)f.style.minHeight=`${d}px`,f.style.minWidth=`${m}px`}activateDroppables(a){this.dragDropApi.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.dragDropApi.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.dragDropApi.dragContainers.forEach(c=>{c.removeAttribute("enabled")}),this.dragDropApi.droppables.forEach(c=>c.removeAttribute("enabled"))}wasDropped(a){return a.dataTransfer.dropEffect&&a.dataTransfer.dropEffect!=="none"}async restoreInitialDraggablePosition(a){let{parent:c,index:d}=this.draggables.get(a),m=(f,y,x)=>{let C=Math.min(x,y.children.length);y.insertBefore(f,y.children[C]),f.style.transform="translate(0, 0)",this.checkMaxAssociations()};if(!document.startViewTransition){m(a,c,d);return}let g=document.startViewTransition(()=>{a.style.transform="",m(a,c,d)})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}validate(){if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),c=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(c=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(c=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let m=this.lastElementChild;return this._internals.setValidity(c?{}:{customError:!0},d,m),this.reportValidity(),c}reportValidity(){let a=this.shadowRoot.querySelector("#validationMessage");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.display="block")),this._internals.validity.valid}checkMaxAssociations(){this.dragDropApi.droppables.forEach(a=>{let c=+(a.getAttribute("match-max")||1);a.querySelectorAll('[qti-draggable="true"]').length>=c?this.disableDroppable(a):this.enableDroppable(a)})}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(a){if(!this.isMatchTabular())if(this.resetDroppables(),Array.isArray(a)){a?.forEach(d=>this.placeResponse(d));let c=new FormData;a.forEach(d=>{c.append(this.responseIdentifier,d)}),this._internals.setFormValue(c)}else this._internals.setFormValue(a)}placeResponse(a){let[c,...d]=a.split(" ").reverse(),m=this.findDroppableById(c);d.forEach(g=>this.placeDraggableInDroppable(g,m))}findDroppableById(a){return this.dragDropApi.droppables.find(c=>c.getAttribute("identifier")===a)}async placeDraggableInDroppable(a,c){let d=this.querySelector(`[identifier=${a}]`);if(!c||!d){console.error(`Cannot find draggable or droppable with the given identifier: ${a}`);return}let m=()=>{d.style.transform="translate(0, 0)",c.appendChild(d),this.checkMaxAssociations()};document.startViewTransition?await document.startViewTransition(m).finished:m()}getValidAssociations(){return this.dragDropApi.droppables.filter(a=>a.childElementCount>0).length}saveResponse(){this.validate();let a=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.dragDropApi.droppables.map(c=>{let d=c.querySelectorAll('[qti-draggable="true"]'),m=Array.from(d).map(f=>f.getAttribute("identifier")),g=c.getAttribute("identifier");return m.map(f=>`${f} ${g}`)}).flat()}reset(a=!0){this.resetDroppables(),a&&this.saveResponse()}async resetDroppables(){let a=(d,m,g)=>{d.style.transform="translate(0, 0)";let f=Math.min(g,m.children.length);m.insertBefore(d,m.children[f])};if(!document.startViewTransition){this.draggables.forEach(({parent:d,index:m},g)=>{a(g,d,m)});return}await document.startViewTransition(()=>{this.draggables.forEach(({parent:d,index:m},g)=>{a(g,d,m)})}).finished}}return l([p({attribute:!1,type:Object})],i.prototype,"configuration",2),l([p({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),l([p({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),l([sr(r)],i.prototype,"handleDraggableContainerChange",1),l([sr(t)],i.prototype,"handleDraggablesChange",1),l([sr(e)],i.prototype,"handleDroppablesChange",1),i};var Is=b`
|
|
3948
3974
|
:host {
|
|
3949
3975
|
display: block; /* necessary to calculate scaling position */
|
|
3950
3976
|
}
|
|
@@ -3952,6 +3978,7 @@ qti-response-declaration {
|
|
|
3952
3978
|
display: flex;
|
|
3953
3979
|
flex-wrap: wrap;
|
|
3954
3980
|
gap: 0.5rem;
|
|
3981
|
+
border: 2px solid transparent;
|
|
3955
3982
|
}
|
|
3956
3983
|
|
|
3957
3984
|
:host::part(associables-container) {
|
|
@@ -3964,7 +3991,7 @@ qti-response-declaration {
|
|
|
3964
3991
|
rgb(0 0 0 / 0%) calc(50% + 1px)
|
|
3965
3992
|
);
|
|
3966
3993
|
}
|
|
3967
|
-
`;var
|
|
3994
|
+
`;var Ke=class extends te(w,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let r=e.target;this._childrenMap.push(r)}render(){return h` <slot name="prompt"></slot>
|
|
3968
3995
|
<slot name="qti-simple-associable-choice"></slot>
|
|
3969
3996
|
<div part="drop-container">
|
|
3970
3997
|
${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,r)=>h`<div part="associables-container">
|
|
@@ -3972,15 +3999,15 @@ qti-response-declaration {
|
|
|
3972
3999
|
<div name="right${r}" part="drop-list" class="dl" identifier="droplist${r}_right"></div>
|
|
3973
4000
|
</div>
|
|
3974
4001
|
<div role="alert" id="validationMessage"></div>`)}
|
|
3975
|
-
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};
|
|
4002
|
+
</div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};Ke.styles=Is,l([q()],Ke.prototype,"_childrenMap",2),Ke=l([u("qti-associate-interaction")],Ke);var ce=class extends w{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:_t(this.baseItemUrl+"/"+this.data);fetch(e).then(r=>r.json()).then(r=>{this.manifest=r,this.setupCES()}).catch(r=>{this._errorMessage=r})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),r=e.contentDocument;window.addEventListener("message",this.handlePostMessage),r.open(),r.write(`
|
|
3976
4003
|
<html>
|
|
3977
4004
|
<head>
|
|
3978
|
-
<link href='${
|
|
3979
|
-
<script src='${
|
|
4005
|
+
<link href='${_t(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
|
|
4006
|
+
<script src='${_t(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
|
|
3980
4007
|
</head>
|
|
3981
4008
|
<body></body>
|
|
3982
4009
|
</html>
|
|
3983
|
-
`),r.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),r=this.querySelectorAll("iframe"),i=[...e,...r];for(let o of i){let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=o.contentDocument||o.contentWindow.document;c&&this.getInnerIFrames(c,i)}catch(c){console.error("Error accessing nested iframe:",c)}}return i.forEach((o,n)=>{i.indexOf(o)!==n&&i.splice(n,1)}),i}getInnerIFrames(e,r=[]){return e.querySelectorAll("iframe").forEach(o=>{r.push(o);let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=o.contentDocument||o.contentWindow.document;this.getInnerIFrames(c,r)}catch(c){console.error("Error accessing nested iframe:",c)}else console.warn("Skipped cross-origin iframe:",n)}),r}postToWindowAndIframes(e,r){window.postMessage({type:e,data:r},"*");let i=this.getIFrames();for(let o of i)o.contentWindow&&o.contentWindow.postMessage({type:e,data:r},"*")}handlePostMessage(e){let{type:r,data:i}=e.data;switch(r){case"setResponse":this.rawResponse=i,this.saveResponse(i);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let o=this.manifest.media.map(n=>n.startsWith("http")?n:
|
|
4010
|
+
`),r.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),r=this.querySelectorAll("iframe"),i=[...e,...r];for(let o of i){let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=o.contentDocument||o.contentWindow.document;c&&this.getInnerIFrames(c,i)}catch(c){console.error("Error accessing nested iframe:",c)}}return i.forEach((o,n)=>{i.indexOf(o)!==n&&i.splice(n,1)}),i}getInnerIFrames(e,r=[]){return e.querySelectorAll("iframe").forEach(o=>{r.push(o);let n=o.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let c=o.contentDocument||o.contentWindow.document;this.getInnerIFrames(c,r)}catch(c){console.error("Error accessing nested iframe:",c)}else console.warn("Skipped cross-origin iframe:",n)}),r}postToWindowAndIframes(e,r){window.postMessage({type:e,data:r},"*");let i=this.getIFrames();for(let o of i)o.contentWindow&&o.contentWindow.postMessage({type:e,data:r},"*")}handlePostMessage(e){let{type:r,data:i}=e.data;switch(r){case"setResponse":this.rawResponse=i,this.saveResponse(i);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let o=this.manifest.media.map(n=>n.startsWith("http")?n:_t(this.baseRefUrl+"/"+n));this.postToWindowAndIframes("mediaData",o);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get value(){return this.rawResponse}set value(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else throw new Error("Value must be a string")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
|
|
3984
4011
|
width=${this.getAttribute("width")}
|
|
3985
4012
|
height=${this.getAttribute("height")}
|
|
3986
4013
|
frameborder="0"
|
|
@@ -3991,7 +4018,7 @@ qti-response-declaration {
|
|
|
3991
4018
|
${this._errorMessage&&h`<div style="color:red">
|
|
3992
4019
|
<h1>Error</h1>
|
|
3993
4020
|
${this._errorMessage}
|
|
3994
|
-
</div>`}`}};l([p({type:String,attribute:"data"})],
|
|
4021
|
+
</div>`}`}};l([p({type:String,attribute:"data"})],ce.prototype,"data",2),l([p({type:String,attribute:"data-base-item"})],ce.prototype,"baseItemUrl",2),l([p({type:String,attribute:"data-base-ref"})],ce.prototype,"baseRefUrl",2),l([p({type:String,attribute:"id"})],ce.prototype,"id",2),l([q()],ce.prototype,"_errorMessage",2),ce=l([u("qti-custom-interaction")],ce);var Je=class extends w{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}get value(){return""}set value(e){}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};l([p({type:String,attribute:"count-attempt"})],Je.prototype,"countAttempt",2),l([p({type:String})],Je.prototype,"title",2),Je=l([u("qti-end-attempt-interaction")],Je);var Ns=b`
|
|
3995
4022
|
:host {
|
|
3996
4023
|
display: flex;
|
|
3997
4024
|
align-items: flex-start;
|
|
@@ -4025,17 +4052,17 @@ qti-response-declaration {
|
|
|
4025
4052
|
border-radius: 0.3rem;
|
|
4026
4053
|
gap: 0.5rem;
|
|
4027
4054
|
}
|
|
4028
|
-
`;var
|
|
4055
|
+
`;var It=class extends te(w,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
|
|
4029
4056
|
<slot part="drags" name="drags"></slot>
|
|
4030
4057
|
<slot part="drops"></slot>
|
|
4031
|
-
<div role="alert" id="validationMessage"></div>`}
|
|
4058
|
+
<div role="alert" id="validationMessage"></div>`}set correctResponse(t){let e=[],r=Array.isArray(t)?t:[t];r&&(e=r.map(o=>{let n=o.split(" ");return{text:n[0],gap:n[1]}})),this.querySelectorAll("qti-gap").forEach(o=>{let n=o.getAttribute("identifier"),a=e.find(d=>d.gap===n)?.text,c=this.querySelector(`qti-gap-text[identifier="${a}"]`)?.textContent.trim();if(a&&c){if(!o.nextElementSibling?.classList.contains("correct-option")){let d=document.createElement("span");d.classList.add("correct-option"),d.textContent=c,o.insertAdjacentElement("afterend",d)}}else o.nextElementSibling?.classList.contains("correct-option")&&o.nextElementSibling.remove()})}};It.styles=Ns,It=l([u("qti-gap-match-interaction")],It);var Hs=(s,t,e)=>{let r=new Map;for(let i=t;i<=e;i++)r.set(s[i],i);return r},$r=U(class extends Y{constructor(s){if(super(s),s.type!==fe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);let i=[],o=[],n=0;for(let a of s)i[n]=r?r(a,n):n,o[n]=e(a,n),n++;return{values:o,keys:i}}render(s,t,e){return this.dt(s,t,e).values}update(s,[t,e,r]){let i=cs(s),{values:o,keys:n}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=n,o;let a=this.ut??(this.ut=[]),c=[],d,m,g=0,f=i.length-1,y=0,x=o.length-1;for(;g<=f&&y<=x;)if(i[g]===null)g++;else if(i[f]===null)f--;else if(a[g]===n[y])c[y]=ge(i[g],o[y]),g++,y++;else if(a[f]===n[x])c[x]=ge(i[f],o[x]),f--,x--;else if(a[g]===n[x])c[x]=ge(i[g],o[x]),Be(s,c[x+1],i[g]),g++,x--;else if(a[f]===n[y])c[y]=ge(i[f],o[y]),Be(s,i[g],i[f]),f--,y++;else if(d===void 0&&(d=Hs(n,y,x),m=Hs(a,g,f)),d.has(a[g]))if(d.has(a[f])){let C=m.get(n[y]),S=C!==void 0?i[C]:null;if(S===null){let D=Be(s,i[g]);ge(D,o[y]),c[y]=D}else c[y]=ge(S,o[y]),Be(s,i[g],S),i[C]=null;y++}else or(i[f]),f--;else or(i[g]),g++;for(;y<=x;){let C=Be(s,c[x+1]);ge(C,o[y]),c[y++]=C}for(;g<=f;){let C=i[g++];C!==null&&or(C)}return this.ut=n,ls(s,c),M}});function Ze(s,t,e,r){switch(s){case"circle":{let[i,o,n]=t,a=i/e.width*100,c=o/e.height*100,d=n/e.width*100;r.style.left=a-d+"%",r.style.top=c-d+"%",r.style.width=r.style.height=4*d+"px",r.style.borderRadius="9999px"}break;case"rect":{let[i,o,n,a]=t,c=i/e.width*100,d=o/e.height*100,m=n/e.width*100,g=a/e.height*100;r.style.left=c+"%",r.style.top=d+"%",r.style.width=m-c+"%",r.style.height=g-d+"%"}break;case"poly":{let i=t.reduce((C,S,D,st)=>{if(D%2===1){let he=C.pop();C[C.length]={x:he,y:st[D]}}else C.push(S);return C},[]),o=Math.min(...i.map(C=>C.x)),n=Math.max(...i.map(C=>C.x)),a=Math.min(...i.map(C=>C.y)),c=Math.max(...i.map(C=>C.y)),d=o/e.width*100,m=a/e.height*100,g=n/e.width*100,f=c/e.height*100;r.style.left=o/e.width*100+"%",r.style.top=a/e.height*100+"%",r.style.width=g-d+"%",r.style.height=f-m+"%";let x=i.map(C=>({x:(C.x-o)/(n-o)*100,y:(C.y-a)/(c-a)*100})).map(C=>Math.round(C.x)+"% "+Math.round(C.y)+"%").join(",");r.style.clipPath=`polygon(${x})`}break;default:break}}var re=class extends w{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){return h`<slot name="prompt"></slot>
|
|
4032
4059
|
<line-container>
|
|
4033
4060
|
<svg
|
|
4034
|
-
width=${
|
|
4035
|
-
height=${
|
|
4061
|
+
width=${ve(this.grImage[0]?.width)}
|
|
4062
|
+
height=${ve(this.grImage[0]?.height)}
|
|
4036
4063
|
viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
|
|
4037
4064
|
>
|
|
4038
|
-
${
|
|
4065
|
+
${$r(this._lines,e=>e,(e,r)=>Fr`
|
|
4039
4066
|
<line
|
|
4040
4067
|
part="line"
|
|
4041
4068
|
x1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.left)}
|
|
@@ -4047,7 +4074,7 @@ qti-response-declaration {
|
|
|
4047
4074
|
@click=${i=>{i.stopPropagation(),this._lines=this._lines.filter((o,n)=>n!==r),this.saveResponse(this._lines)}}
|
|
4048
4075
|
/>
|
|
4049
4076
|
`)}
|
|
4050
|
-
${this.startPoint&&
|
|
4077
|
+
${this.startPoint&&Fr`<line
|
|
4051
4078
|
part="point"
|
|
4052
4079
|
x1=${this.startCoord.x}
|
|
4053
4080
|
y1=${this.startCoord.y}
|
|
@@ -4059,7 +4086,7 @@ qti-response-declaration {
|
|
|
4059
4086
|
</svg>
|
|
4060
4087
|
<slot></slot>
|
|
4061
4088
|
</line-container>
|
|
4062
|
-
<div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));
|
|
4089
|
+
<div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));Ze(n,a,r,i)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",r=>{this.mouseCoord={x:r.clientX-this.grImage[0].getBoundingClientRect().left,y:r.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(r=>{r.style.left=r.getAttribute("coords").split(",")[0]+"px",r.style.top=r.getAttribute("coords").split(",")[1]+"px",r.addEventListener("click",i=>{this.startPoint?this.endPoint||(this.endPoint=i.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=i.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};re.styles=[b`
|
|
4063
4090
|
slot:not([name='prompt']) {
|
|
4064
4091
|
// position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4065
4092
|
display: block;
|
|
@@ -4082,7 +4109,7 @@ qti-response-declaration {
|
|
|
4082
4109
|
top: 0px;
|
|
4083
4110
|
left: 0px;
|
|
4084
4111
|
}
|
|
4085
|
-
`],l([q()],
|
|
4112
|
+
`],l([q()],re.prototype,"_lines",2),l([q()],re.prototype,"startCoord",2),l([q()],re.prototype,"mouseCoord",2),l([Oe("svg")],re.prototype,"svgContainer",2),l([ji({selector:"img"})],re.prototype,"grImage",2),re=l([u("qti-graphic-associate-interaction")],re);var Os=b`
|
|
4086
4113
|
:host {
|
|
4087
4114
|
display: flex;
|
|
4088
4115
|
align-items: flex-start;
|
|
@@ -4136,16 +4163,16 @@ qti-response-declaration {
|
|
|
4136
4163
|
user-select: none;
|
|
4137
4164
|
pointer-events: none;
|
|
4138
4165
|
}
|
|
4139
|
-
`;var
|
|
4166
|
+
`;var Nt=class extends te(w,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
|
|
4140
4167
|
<slot part="image"></slot>
|
|
4141
4168
|
<slot part="drags" name="drags" class="hover-border"></slot>
|
|
4142
|
-
<div role="alert" id="validationMessage"></div>`}
|
|
4169
|
+
<div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(t){let e=t.target,r=e.getAttribute("coords"),i=e.getAttribute("shape"),o=r.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,c]=o;e.style.left=n-c+"px",e.style.top=a-c+"px",e.style.width=e.style.height=2*c+"px"}break;case"rect":{let[n,a,c,d]=o;e.style.left=n+"px",e.style.top=a+"px",e.style.width=c-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Nt.styles=Os,Nt=l([u("qti-graphic-gap-match-interaction")],Nt);var Ht=class extends ye(w,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
|
|
4143
4170
|
<slot name="prompt"></slot>
|
|
4144
4171
|
<!-- slot for the prompt -->
|
|
4145
4172
|
<slot></slot>
|
|
4146
4173
|
<!-- slot for the image and hotspots -->
|
|
4147
4174
|
<div role="alert" id="validationMessage"></div>
|
|
4148
|
-
`}setHotspotOrder(e){let{identifier:r}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===r),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}i.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),i.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));
|
|
4175
|
+
`}setHotspotOrder(e){let{identifier:r}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===r),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}i.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),i.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));Ze(n,a,r,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ht.styles=[b`
|
|
4149
4176
|
slot:not([name='prompt']) {
|
|
4150
4177
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4151
4178
|
display: block;
|
|
@@ -4156,12 +4183,12 @@ qti-response-declaration {
|
|
|
4156
4183
|
pointer-events: none;
|
|
4157
4184
|
user-select: none;
|
|
4158
4185
|
}
|
|
4159
|
-
`],
|
|
4186
|
+
`],Ht=l([u("qti-graphic-order-interaction")],Ht);var Ot=class extends ye(w,"qti-hotspot-choice"){render(){return h`
|
|
4160
4187
|
<slot name="prompt"></slot>
|
|
4161
4188
|
<!-- slot for the prompt -->
|
|
4162
4189
|
<slot></slot>
|
|
4163
4190
|
<!-- slot for the image and hotspots -->
|
|
4164
|
-
`}positionHotspotOnRegister(t){let e=this.querySelector("img"),r=t.target,i=r.getAttribute("coords"),o=r.getAttribute("shape"),n=i.split(",").map(a=>parseInt(a));
|
|
4191
|
+
`}positionHotspotOnRegister(t){let e=this.querySelector("img"),r=t.target,i=r.getAttribute("coords"),o=r.getAttribute("shape"),n=i.split(",").map(a=>parseInt(a));Ze(o,n,e,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ot.styles=[b`
|
|
4165
4192
|
slot:not([name='prompt']) {
|
|
4166
4193
|
position: relative; /* qti-hotspot-choice relative to the slot */
|
|
4167
4194
|
display: block;
|
|
@@ -4173,10 +4200,10 @@ qti-response-declaration {
|
|
|
4173
4200
|
user-select: none;
|
|
4174
4201
|
/* width:100%; */
|
|
4175
4202
|
}
|
|
4176
|
-
`]
|
|
4203
|
+
`],Ot=l([u("qti-hotspot-interaction")],Ot);var Ee=class extends K(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
|
|
4177
4204
|
<slot part="slot"></slot>
|
|
4178
4205
|
<slot part="dropslot" name="qti-simple-associable-choice"></slot>
|
|
4179
|
-
`}};
|
|
4206
|
+
`}};Ee.styles=b`
|
|
4180
4207
|
:host {
|
|
4181
4208
|
display: flex;
|
|
4182
4209
|
user-select: none;
|
|
@@ -4188,8 +4215,8 @@ qti-response-declaration {
|
|
|
4188
4215
|
slot[name='qti-simple-associable-choice'] {
|
|
4189
4216
|
width: 100%;
|
|
4190
4217
|
}
|
|
4191
|
-
`,l([p({type:Number,attribute:"match-min"})],
|
|
4192
|
-
slot {
|
|
4218
|
+
`,l([p({type:Number,attribute:"match-min"})],Ee.prototype,"matchMin",2),l([p({type:Number,attribute:"match-max"})],Ee.prototype,"matchMax",2),l([p({type:Boolean,attribute:"fixed"})],Ee.prototype,"fixed",2),Ee=l([u("qti-simple-associable-choice")],Ee);var Vs=b`
|
|
4219
|
+
slot:not([hidden]) {
|
|
4193
4220
|
/* slot where the */
|
|
4194
4221
|
display: flex;
|
|
4195
4222
|
flex-direction: column;
|
|
@@ -4215,32 +4242,37 @@ qti-response-declaration {
|
|
|
4215
4242
|
/* Make sure the drag and drop container slots have the same width */
|
|
4216
4243
|
flex: 1;
|
|
4217
4244
|
}
|
|
4218
|
-
`;var
|
|
4245
|
+
`;var de=class extends te(w,"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=[];this.handleRadioClick=e=>{let r=e.target;this.lastCheckedRadio===r?(r.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=r};this.handleRadioChange=e=>{let r=e.target,i=r.value,o=r.name,n=r.type;r.checked?(this.value?this.value.indexOf(i)===-1&&(n==="radio"&&(this.value=this.value.filter(a=>a.indexOf(o)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=r):(this.value=this.value.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.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
|
|
4219
4246
|
<slot name="prompt"></slot>
|
|
4220
|
-
<
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4247
|
+
<slot ?hidden=${e}></slot>
|
|
4248
|
+
|
|
4249
|
+
${e?h`
|
|
4250
|
+
<table>
|
|
4251
|
+
<tr>
|
|
4252
|
+
<td></td>
|
|
4253
|
+
${this.cols.map(r=>h`<th part="r-header">${xe(r.innerHTML)}</th>`)}
|
|
4254
|
+
</tr>
|
|
4255
|
+
|
|
4256
|
+
${this.rows.map(r=>h`<tr>
|
|
4257
|
+
<td part="c-header">${xe(r.innerHTML)}</td>
|
|
4258
|
+
${this.cols.map(i=>{let o=r.getAttribute("identifier"),n=i.getAttribute("identifier"),a=`${o} ${n}`,c=this.value.filter(f=>f.split(" ")[0]===o).length||0,d=this.value.includes(a),m=`rb ${d?"rb-checked":""} ${this.correctOptions.includes(a)?"rb-correct":""}`,g=this.correctOptions.length>0?!0:r.matchMax===1?!1:c>=r.matchMax&&!d;return h`<td>
|
|
4259
|
+
<input
|
|
4260
|
+
type=${r.matchMax===1?"radio":"checkbox"}
|
|
4261
|
+
part=${m}
|
|
4262
|
+
name=${o}
|
|
4263
|
+
value=${a}
|
|
4264
|
+
.disabled=${g}
|
|
4265
|
+
@change=${f=>this.handleRadioChange(f)}
|
|
4266
|
+
@click=${f=>r.matchMax===1?this.handleRadioClick(f):null}
|
|
4267
|
+
/>
|
|
4268
|
+
</td>`})}
|
|
4269
|
+
</tr>`)}
|
|
4270
|
+
</table>
|
|
4271
|
+
`:k}
|
|
4272
|
+
|
|
4273
|
+
<div role="alert" id="validationMessage"></div>
|
|
4274
|
+
`}};de.styles=Vs,l([p({type:String})],de.prototype,"class",2),l([q()],de.prototype,"_response",2),l([p({type:String,attribute:"response-identifier"})],de.prototype,"responseIdentifier",2),l([q()],de.prototype,"correctOptions",2),de=l([u("qti-match-interaction")],de);var Vt=class extends w{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return{...w.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
|
|
4275
|
+
<slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};Vt.styles=[b``],Vt=l([u("qti-media-interaction")],Vt);var Ps=b`
|
|
4244
4276
|
[part='drags'] {
|
|
4245
4277
|
display: flex;
|
|
4246
4278
|
align-items: flex-start;
|
|
@@ -4289,13 +4321,13 @@ qti-response-declaration {
|
|
|
4289
4321
|
:host(.qti-choices-right) [part='container'] {
|
|
4290
4322
|
flex-direction: row-reverse;
|
|
4291
4323
|
}
|
|
4292
|
-
`;var
|
|
4324
|
+
`;var pe=class extends wr(te(w,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
|
|
4293
4325
|
<div part="container">
|
|
4294
4326
|
<slot part="drags"> </slot>
|
|
4295
4327
|
<div part="drops">
|
|
4296
|
-
${Array.from(Array(this.nrChoices)).map((r,i)=>h`<drop-list part="drop-list" identifier="droplist${i}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>i?
|
|
4328
|
+
${Array.from(Array(this.nrChoices)).map((r,i)=>h`<drop-list part="drop-list" identifier="droplist${i}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>i?xe(`<span part='correct-response'>${this.correctResponses[i]}</span>`):""}`)}
|
|
4297
4329
|
</div>
|
|
4298
|
-
</div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(i=>{let o=this.querySelector(`qti-simple-choice[identifier="${i}"]`);o||(o=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${i}"]`));let n=o?.textContent.trim();this.correctResponses=[...this.correctResponses,n]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let o=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(o).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(r=>r.setAttribute("part","qti-simple-choice"))}};
|
|
4330
|
+
</div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(i=>{let o=this.querySelector(`qti-simple-choice[identifier="${i}"]`);o||(o=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${i}"]`));let n=o?.textContent.trim();this.correctResponses=[...this.correctResponses,n]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let o=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(o).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(r=>r.setAttribute("part","qti-simple-choice"))}};pe.styles=Ps,l([q()],pe.prototype,"nrChoices",2),l([q()],pe.prototype,"correctResponses",2),l([q()],pe.prototype,"showCorrectResponses",2),l([p({type:String})],pe.prototype,"orientation",2),pe=l([u("qti-order-interaction")],pe);var Dr=class extends v{render(){return h`<slot></slot>`}};Dr.styles=[b`
|
|
4299
4331
|
:host {
|
|
4300
4332
|
display: block;
|
|
4301
4333
|
}
|
|
@@ -4306,23 +4338,23 @@ qti-response-declaration {
|
|
|
4306
4338
|
left: 50%;
|
|
4307
4339
|
transform: translateX(-50%);
|
|
4308
4340
|
}
|
|
4309
|
-
`];customElements.define("qti-position-object-interaction",
|
|
4341
|
+
`];customElements.define("qti-position-object-interaction",Dr);var Pt=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(t){t.preventDefault();let e=t.clientX-this.startX,r=t.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=t.clientX,this.startY=t.clientY}firstUpdated(t){super.firstUpdated(t),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)}};Pt.styles=[b`
|
|
4310
4342
|
:host {
|
|
4311
4343
|
display: inline-block;
|
|
4312
4344
|
position: relative;
|
|
4313
4345
|
}
|
|
4314
|
-
`],
|
|
4346
|
+
`],Pt=l([u("qti-position-object-stage")],Pt);var zs="important",Vo=" !"+zs,Us=U(class extends Y{constructor(s){if(super(s),s.type!==fe.ATTRIBUTE||s.name!=="style"||s.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(s){return Object.keys(s).reduce((t,e)=>{let r=s[e];return r==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(s,[t]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let r of this.ft)t[r]==null&&(this.ft.delete(r),r.includes("-")?e.removeProperty(r):e[r]=null);for(let r in t){let i=t[r];if(i!=null){this.ft.add(r);let o=typeof i=="string"&&i.endsWith(Vo);r.includes("-")||o?e.setProperty(r,o?i.slice(0,-11):i,o?zs:""):e[r]=i}}return M}});var we=class extends w{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this._points.length<this.maxChoices){let r=e.offsetX,i=e.offsetY;this._points=[...this._points,`${r} ${i}`],this.saveResponse(this._points)}}}render(){return h` <slot name="prompt"></slot>
|
|
4315
4347
|
<point-container>
|
|
4316
|
-
${
|
|
4348
|
+
${$r(this._points,e=>e,(e,r)=>h`
|
|
4317
4349
|
<button
|
|
4318
4350
|
part="point"
|
|
4319
|
-
style=${
|
|
4351
|
+
style=${Us({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
|
|
4320
4352
|
aria-label="Remove point at ${e}"
|
|
4321
4353
|
@click=${i=>{i.stopPropagation(),this._points=this._points.filter((o,n)=>n!==r),this.saveResponse(this._points)}}
|
|
4322
4354
|
></button>
|
|
4323
4355
|
`)}
|
|
4324
4356
|
<slot></slot>
|
|
4325
|
-
</point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};
|
|
4357
|
+
</point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};we.styles=[b`
|
|
4326
4358
|
:host {
|
|
4327
4359
|
display: block;
|
|
4328
4360
|
}
|
|
@@ -4330,61 +4362,131 @@ qti-response-declaration {
|
|
|
4330
4362
|
display: block;
|
|
4331
4363
|
position: relative;
|
|
4332
4364
|
}
|
|
4333
|
-
`],l([p({type:Number,attribute:"max-choices"})],
|
|
4365
|
+
`],l([p({type:Number,attribute:"max-choices"})],we.prototype,"maxChoices",2),l([p({type:Number,attribute:"min-choices"})],we.prototype,"minChoices",2),l([q()],we.prototype,"_points",2),we=l([u("qti-select-point-interaction")],we);var Fs=b`
|
|
4366
|
+
:host {
|
|
4367
|
+
display: block;
|
|
4368
|
+
--show-bounds: true;
|
|
4369
|
+
--show-ticks: true;
|
|
4370
|
+
--show-value: true;
|
|
4371
|
+
}
|
|
4372
|
+
|
|
4373
|
+
[part='slider'] {
|
|
4374
|
+
margin-left: 2rem; /* mx-8 */
|
|
4375
|
+
margin-right: 2rem;
|
|
4376
|
+
padding-bottom: 1rem; /* pb-4 */
|
|
4377
|
+
padding-top: 1.25rem; /* pt-5 */
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
[part='bounds'] {
|
|
4381
|
+
display: flex;
|
|
4382
|
+
width: 100%;
|
|
4383
|
+
justify-content: space-between;
|
|
4384
|
+
margin-bottom: 0.5rem; /* mb-2 */
|
|
4385
|
+
}
|
|
4386
|
+
|
|
4387
|
+
[part='ticks'] {
|
|
4388
|
+
margin-left: 0.125rem; /* mx-0.5 */
|
|
4389
|
+
margin-right: 0.125rem;
|
|
4390
|
+
margin-bottom: 0.25rem; /* mb-1 */
|
|
4391
|
+
height: 0.5rem; /* h-2 */
|
|
4392
|
+
background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
|
|
4393
|
+
0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
|
|
4394
|
+
}
|
|
4395
|
+
|
|
4396
|
+
[part='rail'] {
|
|
4397
|
+
display: flex;
|
|
4398
|
+
align-items: center;
|
|
4399
|
+
box-sizing: border-box;
|
|
4400
|
+
height: 0.375rem; /* h-1.5 */
|
|
4401
|
+
width: 100%;
|
|
4402
|
+
cursor: pointer;
|
|
4403
|
+
border-radius: 9999px; /* rounded-full */
|
|
4404
|
+
border: 1px solid #d1d5db; /* border-gray-300 */
|
|
4405
|
+
background-color: #e5e7eb; /* bg-gray-200 */
|
|
4406
|
+
}
|
|
4407
|
+
|
|
4408
|
+
[part='knob'] {
|
|
4409
|
+
background-color: var(--qti-bg-active);
|
|
4410
|
+
border: 2px solid var(--qti-border-active);
|
|
4411
|
+
position: relative;
|
|
4412
|
+
height: 1rem; /* h-4 */
|
|
4413
|
+
width: 1rem; /* w-4 */
|
|
4414
|
+
transform-origin: center;
|
|
4415
|
+
transform: translateX(-50%);
|
|
4416
|
+
cursor: pointer;
|
|
4417
|
+
border-radius: 9999px; /* rounded-full */
|
|
4418
|
+
left: var(--value-percentage);
|
|
4419
|
+
}
|
|
4420
|
+
|
|
4421
|
+
[part='value'] {
|
|
4422
|
+
position: absolute;
|
|
4423
|
+
bottom: 2rem; /* bottom-8 */
|
|
4424
|
+
left: 0.5rem; /* left-2 */
|
|
4425
|
+
transform: translateX(-50%);
|
|
4426
|
+
cursor: pointer;
|
|
4427
|
+
border-radius: 0.25rem; /* rounded */
|
|
4428
|
+
background-color: #f3f4f6; /* bg-gray-100 */
|
|
4429
|
+
padding: 0.25rem 0.5rem; /* px-2 py-1 */
|
|
4430
|
+
text-align: center;
|
|
4431
|
+
color: #6b7280; /* text-gray-500 */
|
|
4432
|
+
}
|
|
4433
|
+
`;var ie=class extends v{constructor(){super();this._value=0;this.min=0;this.max=100;this.step=1;this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get value(){return this._value.toString()}set value(e){let r=parseInt(e,10);isNaN(r)||this._updateValue(r)}_updateValue(e){this._value=Math.min(this.max,Math.max(this.min,e));let r=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${r}%`),this._internals.setFormValue(this.value),this.requestUpdate()}render(){return h`
|
|
4434
|
+
<slot name="prompt"></slot>
|
|
4334
4435
|
<div id="slider" part="slider">
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
</div>`:k}
|
|
4339
|
-
${this.csLive.getPropertyValue("--show-ticks")=="true"?h`<div id="ticks" part="ticks"></div>`:k}
|
|
4340
|
-
<div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove}>
|
|
4341
|
-
<div id="knob" part="knob">
|
|
4342
|
-
${this.csLive.getPropertyValue("--show-value")=="true"?h`<div id="value" part="value">${this.value}</div>`:k}
|
|
4343
|
-
</div>
|
|
4436
|
+
<div id="bounds" part="bounds">
|
|
4437
|
+
<div>${this.min}</div>
|
|
4438
|
+
<div>${this.max}</div>
|
|
4344
4439
|
</div>
|
|
4345
|
-
|
|
4440
|
+
|
|
4441
|
+
<div id="ticks" part="ticks"></div>
|
|
4442
|
+
|
|
4443
|
+
<div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
|
|
4444
|
+
<div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
|
|
4445
|
+
</div>
|
|
4446
|
+
</div>
|
|
4447
|
+
`}_onMouseDown(e){this._startDrag(e.pageX);let r=o=>this._onDrag(o.pageX),i=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let r=o=>this._onDrag(o.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",r),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",r,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let r=this._rail.getBoundingClientRect(),i=e-r.left,o=Math.min(1,Math.max(0,i/r.width)),n=this.min+Math.round(o*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};ie.formAssociated=!0,ie.styles=Fs,l([Oe("#rail")],ie.prototype,"_rail",2),l([p({type:Number,attribute:"lower-bound"})],ie.prototype,"min",2),l([p({type:Number,attribute:"upper-bound"})],ie.prototype,"max",2),l([p({type:Number,attribute:"step"})],ie.prototype,"step",2),ie=l([u("qti-slider-interaction")],ie);var zt=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let t=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",t.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let t={variable:r=>this._context?.variables.find(i=>i.identifier===r)?.value??"",correct:r=>this._context?.variables.find(i=>i.identifier===r)?.correctResponse??""},e={getVariable:r=>this._context?.variables.find(i=>i.identifier===r),updateOutcomeVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:i}}))},updateResponseVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:r,response:i}}))}};return this.operatorFunction(this._context,t,e)}};l([A({context:$,subscribe:!0}),q()],zt.prototype,"_context",2),zt=l([u("qti-custom-operator")],zt);var Ut=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Ut.styles=b`
|
|
4346
4448
|
:host {
|
|
4347
4449
|
display: flex;
|
|
4348
4450
|
user-select: none;
|
|
4349
4451
|
position: absolute;
|
|
4350
4452
|
}
|
|
4351
|
-
`,
|
|
4453
|
+
`,Ut=l([u("qti-associable-hotspot")],Ut);var Qe=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};Qe.styles=b`
|
|
4352
4454
|
:host {
|
|
4353
4455
|
display: flex;
|
|
4354
4456
|
user-select: none;
|
|
4355
4457
|
}
|
|
4356
|
-
`,l([p({type:Number,reflect:!0})],
|
|
4458
|
+
`,l([p({type:Number,reflect:!0})],Qe.prototype,"tabindex",2),Qe=l([u("qti-gap")],Qe);var et=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};et.styles=b`
|
|
4357
4459
|
:host {
|
|
4358
4460
|
display: flex;
|
|
4359
4461
|
user-select: none;
|
|
4360
4462
|
}
|
|
4361
|
-
`,l([p({type:Number,reflect:!0})],
|
|
4463
|
+
`,l([p({type:Number,reflect:!0})],et.prototype,"tabindex",2),et=l([u("qti-gap-img")],et);var tt=class extends K(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};tt.styles=b`
|
|
4362
4464
|
:host {
|
|
4363
4465
|
display: inline-flex;
|
|
4364
4466
|
user-select: none;
|
|
4365
4467
|
}
|
|
4366
|
-
`,l([p({type:Number,reflect:!0})],
|
|
4468
|
+
`,l([p({type:Number,reflect:!0})],tt.prototype,"tabindex",2),tt=l([u("qti-gap-text")],tt);var rt=class extends K(v,"qti-hotspot-choice"){};rt.styles=b`
|
|
4367
4469
|
:host {
|
|
4368
4470
|
display: flex;
|
|
4369
4471
|
user-select: none;
|
|
4370
4472
|
position: absolute;
|
|
4371
4473
|
}
|
|
4372
|
-
`,l([p({attribute:"aria-ordervalue",type:Number,reflect:!0})],
|
|
4373
|
-
<slot></slot> `}};
|
|
4474
|
+
`,l([p({attribute:"aria-ordervalue",type:Number,reflect:!0})],rt.prototype,"order",2),rt=l([u("qti-hotspot-choice")],rt);var Ft=class extends K(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
|
|
4475
|
+
<slot></slot> `}};Ft.styles=b`
|
|
4374
4476
|
:host {
|
|
4375
4477
|
display: flex;
|
|
4376
4478
|
user-select: none;
|
|
4377
4479
|
}
|
|
4378
|
-
`,
|
|
4480
|
+
`,Ft=l([u("qti-hottext")],Ft);var Bt=class extends v{static get styles(){return[b`
|
|
4379
4481
|
:host {
|
|
4380
4482
|
display: block;
|
|
4381
4483
|
cursor: pointer;
|
|
4382
4484
|
}
|
|
4383
|
-
`]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};l([p({type:String})],
|
|
4485
|
+
`]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};l([p({type:String})],Bt.prototype,"identifier",2),Bt=l([u("qti-inline-choice")],Bt);var it=class extends K(v,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
|
|
4384
4486
|
<div part="cha"></div>
|
|
4385
4487
|
</div>
|
|
4386
4488
|
${this.marker?h`<div id="label">${this.marker}</div>`:k}
|
|
4387
|
-
<slot part="slot"></slot> `}};
|
|
4489
|
+
<slot part="slot"></slot> `}};it.styles=b`
|
|
4388
4490
|
:host {
|
|
4389
4491
|
display: flex;
|
|
4390
4492
|
align-items: center;
|
|
@@ -4401,7 +4503,7 @@ qti-response-declaration {
|
|
|
4401
4503
|
align-items: center;
|
|
4402
4504
|
justify-content: center;
|
|
4403
4505
|
}
|
|
4404
|
-
`,l([p({type:String,attribute:!1})],
|
|
4506
|
+
`,l([p({type:String,attribute:!1})],it.prototype,"marker",2),it=l([u("qti-simple-choice")],it);console.log("%cC\xBFTO%cLab%c: qti-components loaded","font-weight:bold; color:green",'font-family: "PT Sans", font-weight:bold; color:green; font-size: smaller;vertical-align: sub',"font-weight:unset");export{K as ActiveElementMixin,w as Interaction,ae as ItemContainer,_r as QtiAnd,I as QtiAssessmentItem,B as QtiAssessmentItemRef,X as QtiAssessmentSection,We as QtiAssessmentStimulusRef,Se as QtiAssessmentTest,Ut as QtiAssociableHotspot,Ke as QtiAssociateInteraction,kr as QtiBaseValue,Ye as QtiChoiceInteraction,xr as QtiCompanionMaterialsInfo,O as QtiConditionExpression,ci as QtiContains,qr as QtiContentBody,di as QtiCorrect,ce as QtiCustomInteraction,zt as QtiCustomOperator,Je as QtiEndAttemptInteraction,Ar as QtiEqual,Tr as QtiEqualRounded,_ as QtiExpression,H as QtiExtendedTextInteraction,kt as QtiFeedbackBlock,Tt as QtiFeedbackInline,Qe as QtiGap,et as QtiGapImg,It as QtiGapMatchInteraction,tt as QtiGapText,re as QtiGraphicAssociateInteraction,Nt as QtiGraphicGapMatchInteraction,Ht as QtiGraphicOrderInteraction,pi as QtiGt,hi as QtiGte,rt as QtiHotspotChoice,Ot as QtiHotspotInteraction,Ft as QtiHottext,Er as QtiHottextInteraction,Bt as QtiInlineChoice,qe as QtiInlineChoiceInteraction,ui as QtiIsNull,br as QtiItem,wt as QtiItemBody,Cr as QtiLookupOutcomeValue,mi as QtiLt,gi as QtiLte,Sr as QtiMapResponse,Ge as QtiMapping,fi as QtiMatch,de as QtiMatchInteraction,Vt as QtiMediaInteraction,bi as QtiMember,At as QtiModalFeedback,vi as QtiMultiple,yi as QtiNot,xi as QtiOr,pe as QtiOrderInteraction,qi as QtiOrdered,J as QtiOutcomeDeclaration,Rt as QtiOutcomeProcessing,si as QtiOutcomeProcessingProcessor,Le as QtiPortableCustomInteraction,Dr as QtiPositionObjectInteraction,Pt as QtiPositionObjectStage,Dt as QtiPrintedVariable,Ei as QtiProduct,vr as QtiPrompt,oi as QtiResponseCondition,le as QtiResponseDeclaration,Lt as QtiResponseElse,li as QtiResponseElseIf,$t as QtiResponseIf,Re as QtiResponseProcessing,Z as QtiRubricBlock,ee as QtiRule,we as QtiSelectPointInteraction,ni as QtiSetOutcomeValue,ai as QtiSetOutcomeValueRule,Ee as QtiSimpleAssociableChoice,it as QtiSimpleChoice,ie as QtiSliderInteraction,Rr as QtiStringMatch,yr as QtiStylesheet,Mr as QtiSubtract,wi as QtiSum,Ci as QtiSumExpression,ir as QtiTest,j as QtiTestPart,Q as QtiTextEntryInteraction,Mt as QtiUploadInteraction,_i as QtiVariable,ne as TestContainer,Fe as TestItemLink,ft as TestNext,je as TestPagingButtonsStamp,bt as TestPrev,W as TestView,$ as itemContext,ws as itemContextVariables,Ho as qtiAndMixin,Oo as qtiSubtractMixin,F as testContext,tr as testElement};
|
|
4405
4507
|
/*! Bundled license information:
|
|
4406
4508
|
|
|
4407
4509
|
@lit/context/lib/context-request-event.js:
|