@citolab/qti-components 7.3.17 → 7.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/cdn/chunks/chunk-23JT53R2.js +1 -0
  2. package/cdn/chunks/chunk-2OA2G5PN.js +5 -0
  3. package/cdn/chunks/chunk-3HIY5HSB.js +1 -0
  4. package/cdn/chunks/chunk-3ZLIRREM.js +1466 -0
  5. package/cdn/chunks/chunk-4F3OLGZ4.js +5 -0
  6. package/cdn/chunks/chunk-4VCDR5BV.js +1460 -0
  7. package/cdn/chunks/chunk-5RZUSJSN.js +5 -0
  8. package/cdn/chunks/chunk-6IY26BVE.js +23 -0
  9. package/cdn/chunks/chunk-7HEAECQ2.js +1466 -0
  10. package/cdn/chunks/chunk-7T6OJ2OQ.js +1482 -0
  11. package/cdn/chunks/chunk-ALSHUDQZ.js +5 -0
  12. package/cdn/chunks/chunk-B7NVY4AR.js +23 -0
  13. package/cdn/chunks/chunk-BFMN6REI.js +5 -0
  14. package/cdn/chunks/chunk-BSK7IIBZ.js +1 -0
  15. package/cdn/chunks/chunk-CSEUTSSH.js +5 -0
  16. package/cdn/chunks/chunk-CYSQXIRZ.js +5 -0
  17. package/cdn/chunks/chunk-E6IOJ4MV.js +23 -0
  18. package/cdn/chunks/chunk-ECKBRC27.js +1482 -0
  19. package/cdn/chunks/chunk-ECLB2ECD.js +5 -0
  20. package/cdn/chunks/chunk-FDOVZYP4.js +5 -0
  21. package/cdn/chunks/chunk-FVIBMJDJ.js +5 -0
  22. package/cdn/chunks/chunk-GTSQO7SP.js +1 -0
  23. package/cdn/chunks/chunk-GVZHKB2Y.js +1482 -0
  24. package/cdn/chunks/chunk-IMHR3S57.js +1 -0
  25. package/cdn/chunks/chunk-JG53AUXR.js +1 -0
  26. package/cdn/chunks/chunk-JVW572MO.js +1 -0
  27. package/cdn/chunks/chunk-KM5SOM7G.js +1482 -0
  28. package/cdn/chunks/chunk-KY6SSNGO.js +5 -0
  29. package/cdn/chunks/chunk-M544CJHK.js +5 -0
  30. package/cdn/chunks/chunk-N223O4WD.js +5 -0
  31. package/cdn/chunks/chunk-N4LMZHIZ.js +5 -0
  32. package/cdn/chunks/chunk-ODYPYZCY.js +5 -0
  33. package/cdn/chunks/chunk-OGVSHQLH.js +1460 -0
  34. package/cdn/chunks/chunk-P5MQE2M6.js +5 -0
  35. package/cdn/chunks/chunk-QNBLY7TQ.js +1460 -0
  36. package/cdn/chunks/chunk-RKU2XDKG.js +2 -0
  37. package/cdn/chunks/chunk-SVVO2SFS.js +1 -0
  38. package/cdn/chunks/chunk-UYFLYVQK.js +5 -0
  39. package/cdn/chunks/chunk-UZZLQGLW.js +1460 -0
  40. package/cdn/chunks/chunk-V2NH5MXS.js +5 -0
  41. package/cdn/chunks/chunk-VB3GRBCX.js +1 -0
  42. package/cdn/chunks/chunk-XHSJOTCJ.js +5 -0
  43. package/cdn/chunks/chunk-XLFLYMNJ.js +1482 -0
  44. package/cdn/exports/qti-test.js +0 -0
  45. package/cdn/index.global.js +1 -1
  46. package/cdn/index.js +1 -1
  47. package/cdn/qti-components/index.js +1 -1
  48. package/cdn/qti-item/components/item-container.js +1 -1
  49. package/cdn/qti-item/core/index.js +1 -1
  50. package/cdn/qti-loader/index.js +1 -1
  51. package/cdn/qti-test/components/index.js +1 -1
  52. package/cdn/qti-test/components/test-container.js +1 -1
  53. package/cdn/qti-test/components/test-navigation.js +1 -1
  54. package/cdn/qti-test/components/test-scoring-buttons.js +1 -1
  55. package/cdn/qti-test/components/test-scoring-feedback.js +1 -1
  56. package/cdn/qti-test/core/index.js +1 -1
  57. package/cdn/qti-transformers/index.js +1 -1
  58. package/dist/chunks/chunk-2EGQQQHL.js +31 -0
  59. package/dist/chunks/chunk-2EGQQQHL.js.map +1 -0
  60. package/dist/chunks/chunk-45FDEM7M.js +94 -0
  61. package/dist/chunks/chunk-45FDEM7M.js.map +1 -0
  62. package/dist/chunks/chunk-4B4DRCXO.js +94 -0
  63. package/dist/chunks/chunk-4B4DRCXO.js.map +1 -0
  64. package/dist/chunks/chunk-4MTF6JXS.js +913 -0
  65. package/dist/chunks/chunk-4MTF6JXS.js.map +1 -0
  66. package/dist/chunks/chunk-5IYIGX6A.js +94 -0
  67. package/dist/chunks/chunk-5IYIGX6A.js.map +1 -0
  68. package/dist/chunks/chunk-5QP5YUXY.js +913 -0
  69. package/dist/chunks/chunk-5QP5YUXY.js.map +1 -0
  70. package/dist/chunks/chunk-5XONMCVB.js +8012 -0
  71. package/dist/chunks/chunk-5XONMCVB.js.map +1 -0
  72. package/dist/chunks/chunk-AH3ZDQHQ.js +913 -0
  73. package/dist/chunks/chunk-AH3ZDQHQ.js.map +1 -0
  74. package/dist/chunks/chunk-BAZMB7Z3.js +8009 -0
  75. package/dist/chunks/chunk-BAZMB7Z3.js.map +1 -0
  76. package/dist/chunks/chunk-BO6KBXLI.js +913 -0
  77. package/dist/chunks/chunk-BO6KBXLI.js.map +1 -0
  78. package/dist/chunks/chunk-BXUNJ6XB.js +78 -0
  79. package/dist/chunks/chunk-BXUNJ6XB.js.map +1 -0
  80. package/dist/chunks/chunk-CTESMSQO.js +56 -0
  81. package/dist/chunks/chunk-CTESMSQO.js.map +1 -0
  82. package/dist/chunks/chunk-CVMIO3DA.js +913 -0
  83. package/dist/chunks/chunk-CVMIO3DA.js.map +1 -0
  84. package/dist/chunks/chunk-DJWEI2NH.js +502 -0
  85. package/dist/chunks/chunk-DJWEI2NH.js.map +1 -0
  86. package/dist/chunks/chunk-E6V3JHVT.js +31 -0
  87. package/dist/chunks/chunk-E6V3JHVT.js.map +1 -0
  88. package/dist/chunks/chunk-EFY3NEXY.js +94 -0
  89. package/dist/chunks/chunk-EFY3NEXY.js.map +1 -0
  90. package/dist/chunks/chunk-EXBK4TXV.js +273 -0
  91. package/dist/chunks/chunk-EXBK4TXV.js.map +1 -0
  92. package/dist/chunks/chunk-FXO6HW6L.js +8084 -0
  93. package/dist/chunks/chunk-FXO6HW6L.js.map +1 -0
  94. package/dist/chunks/chunk-GIY6GNXQ.js +913 -0
  95. package/dist/chunks/chunk-GIY6GNXQ.js.map +1 -0
  96. package/dist/chunks/chunk-GT6TR4B6.js +94 -0
  97. package/dist/chunks/chunk-GT6TR4B6.js.map +1 -0
  98. package/dist/chunks/chunk-H67RKRFW.js +94 -0
  99. package/dist/chunks/chunk-H67RKRFW.js.map +1 -0
  100. package/dist/chunks/chunk-I5EA6DJB.js +92 -0
  101. package/dist/chunks/chunk-I5EA6DJB.js.map +1 -0
  102. package/dist/chunks/chunk-LU5A5PN5.js +8084 -0
  103. package/dist/chunks/chunk-LU5A5PN5.js.map +1 -0
  104. package/dist/chunks/chunk-NBENQI27.js +273 -0
  105. package/dist/chunks/chunk-NBENQI27.js.map +1 -0
  106. package/dist/chunks/chunk-NEAO4XCM.js +913 -0
  107. package/dist/chunks/chunk-NEAO4XCM.js.map +1 -0
  108. package/dist/chunks/chunk-NHJUBMZ4.js +913 -0
  109. package/dist/chunks/chunk-NHJUBMZ4.js.map +1 -0
  110. package/dist/chunks/chunk-NPZ3WHOS.js +94 -0
  111. package/dist/chunks/chunk-NPZ3WHOS.js.map +1 -0
  112. package/dist/chunks/chunk-OGAKPUCC.js +502 -0
  113. package/dist/chunks/chunk-OGAKPUCC.js.map +1 -0
  114. package/dist/chunks/chunk-OP5LKZIM.js +913 -0
  115. package/dist/chunks/chunk-OP5LKZIM.js.map +1 -0
  116. package/dist/chunks/chunk-RL3NBBKW.js +913 -0
  117. package/dist/chunks/chunk-RL3NBBKW.js.map +1 -0
  118. package/dist/chunks/chunk-SA3X6RSE.js +8002 -0
  119. package/dist/chunks/chunk-SA3X6RSE.js.map +1 -0
  120. package/dist/chunks/chunk-SV356YP4.js +31 -0
  121. package/dist/chunks/chunk-SV356YP4.js.map +1 -0
  122. package/dist/chunks/chunk-TU6COU44.js +82 -0
  123. package/dist/chunks/chunk-TU6COU44.js.map +1 -0
  124. package/dist/chunks/chunk-VEASE2VL.js +913 -0
  125. package/dist/chunks/chunk-VEASE2VL.js.map +1 -0
  126. package/dist/chunks/chunk-VFPUMDJK.js +8002 -0
  127. package/dist/chunks/chunk-VFPUMDJK.js.map +1 -0
  128. package/dist/chunks/chunk-VHSCCVNF.js +8024 -0
  129. package/dist/chunks/chunk-VHSCCVNF.js.map +1 -0
  130. package/dist/chunks/chunk-VRR4ODZY.js +8009 -0
  131. package/dist/chunks/chunk-VRR4ODZY.js.map +1 -0
  132. package/dist/chunks/chunk-WFUXZ4UT.js +502 -0
  133. package/dist/chunks/chunk-WFUXZ4UT.js.map +1 -0
  134. package/dist/chunks/chunk-WOCRTIKW.js +8012 -0
  135. package/dist/chunks/chunk-WOCRTIKW.js.map +1 -0
  136. package/dist/chunks/chunk-Y3UM2YVB.js +8025 -0
  137. package/dist/chunks/chunk-Y3UM2YVB.js.map +1 -0
  138. package/dist/chunks/chunk-YRYQIUNT.js +913 -0
  139. package/dist/chunks/chunk-YRYQIUNT.js.map +1 -0
  140. package/dist/exports/computed-item.context.d.ts +1 -1
  141. package/dist/exports/computed.context.d.ts +2 -2
  142. package/dist/exports/interaction.d.ts +1 -1
  143. package/dist/exports/item.context.d.ts +1 -1
  144. package/dist/exports/qti-assessment-item.context.d.ts +1 -1
  145. package/dist/exports/qti-condition-expression.d.ts +1 -1
  146. package/dist/exports/qti-expression.d.ts +1 -1
  147. package/dist/exports/qti-test.d.ts +34 -0
  148. package/dist/exports/qti-test.js +1 -0
  149. package/dist/exports/qti-test.js.map +1 -0
  150. package/dist/exports/session.context.d.ts +2 -2
  151. package/dist/exports/test.context.d.ts +1 -1
  152. package/dist/exports/variables.d.ts +1 -1
  153. package/dist/index.d.ts +4 -3
  154. package/dist/index.js +24 -24
  155. package/dist/qti-components/index.d.ts +2 -2
  156. package/dist/qti-components/index.js +2 -2
  157. package/dist/qti-item/components/item-container.js +2 -2
  158. package/dist/qti-item/components/item-show-correct-response.d.ts +1 -1
  159. package/dist/qti-item/components/print-item-variables.d.ts +1 -1
  160. package/dist/qti-item/core/index.d.ts +1 -1
  161. package/dist/qti-item/core/index.js +3 -3
  162. package/dist/qti-loader/index.d.ts +1 -1
  163. package/dist/qti-loader/index.js +2 -2
  164. package/dist/qti-response-declaration-BSUPHx0G.d.ts +1358 -0
  165. package/dist/qti-response-declaration-CIPGNbno.d.ts +1361 -0
  166. package/dist/qti-response-declaration-CXb5CI4-.d.ts +1361 -0
  167. package/dist/qti-response-declaration-DNXsTvKe.d.ts +1358 -0
  168. package/dist/qti-response-declaration-q716ty5y.d.ts +1358 -0
  169. package/dist/qti-test/components/index.d.ts +2 -2
  170. package/dist/qti-test/components/index.js +13 -13
  171. package/dist/qti-test/components/test-container.js +2 -2
  172. package/dist/qti-test/components/test-navigation.d.ts +2 -2
  173. package/dist/qti-test/components/test-navigation.js +1 -1
  174. package/dist/qti-test/components/test-next.d.ts +2 -2
  175. package/dist/qti-test/components/test-prev.d.ts +2 -2
  176. package/dist/qti-test/components/test-print-context.d.ts +2 -2
  177. package/dist/qti-test/components/test-print-item-variables.d.ts +2 -2
  178. package/dist/qti-test/components/test-scoring-buttons.d.ts +2 -2
  179. package/dist/qti-test/components/test-scoring-buttons.js +1 -1
  180. package/dist/qti-test/components/test-scoring-feedback.d.ts +2 -2
  181. package/dist/qti-test/components/test-scoring-feedback.js +1 -1
  182. package/dist/qti-test/components/test-show-correct-response.d.ts +2 -2
  183. package/dist/qti-test/core/index.d.ts +5 -4
  184. package/dist/qti-test/core/index.js +3 -3
  185. package/dist/qti-test-feedback-D-vBFqJ5.d.ts +91 -0
  186. package/dist/qti-test-feedback-DTIDvsS-.d.ts +91 -0
  187. package/dist/qti-test-feedback-Ddb0QQyz.d.ts +91 -0
  188. package/dist/qti-test-feedback-TcrkevLg.d.ts +91 -0
  189. package/dist/qti-test-feedback-hJuvW_Ei.d.ts +91 -0
  190. package/dist/qti-transformers/index.d.ts +17 -1
  191. package/dist/qti-transformers/index.js +1 -1
  192. package/package.json +1 -1
@@ -0,0 +1,1482 @@
1
+ import{a as We}from"./chunk-IMHR3S57.js";import{a as de,b as Z,c as ue,e as he,f as Q,g as Ft,h as Ut,i as Xe,j as jt}from"./chunk-6BGG2JJR.js";import{a as M}from"./chunk-XUJ7TXHW.js";import{a as Pt}from"./chunk-6IY26BVE.js";import{a as N}from"./chunk-KPDSL2FK.js";import{a as C}from"./chunk-MEYBMNBF.js";import{a as k}from"./chunk-QQCGUVEV.js";import{a as zt}from"./chunk-7ME56ODO.js";import{a as Nt,b as S}from"./chunk-7WJYJA45.js";import{a as q}from"./chunk-3BEVQM67.js";import{a as f,b as u,c as x,d as pe,e as Ht}from"./chunk-42P7F3FC.js";import{a as v,d as m,e as Je,f as ce,g as _,i as y}from"./chunk-65CZNGQC.js";import{a as Ot}from"./chunk-KWPDTFYH.js";import{a}from"./chunk-JR322KXH.js";var V=class extends y{constructor(){super(...arguments);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={variables:Ot};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:r}=e.detail;this.updateResponseVariable(t,r),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let r=e.find(s=>s.identifier===t.identifier);return r?{...t,...r,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);r&&(r.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(r=>r.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return m`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this}))})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){let t=this._context.variables.filter(r=>r.type==="response");for(let r of this._interactionElements){let s=r.getAttribute("response-identifier"),n=t.find(o=>o.identifier===s);n&&r.toggleCorrectResponse(n,e)}}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(s=>s.identifier==="numAttempts")?.value+1).toString());let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:t})},this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:r.cardinality==="single"||Array.isArray(t)?t:[t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=this._interactionElements.every(r=>r.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};a([u({type:String})],V.prototype,"identifier",2),a([u({type:String})],V.prototype,"adaptive",2),a([u({type:String})],V.prototype,"timeDependent",2),a([u({type:String})],V.prototype,"title",1),a([u({type:Boolean})],V.prototype,"disabled",2),a([M("disabled",{waitUntilFirstUpdate:!0})],V.prototype,"_handleDisabledChange",2),a([u({type:Boolean})],V.prototype,"readonly",2),a([M("readonly",{waitUntilFirstUpdate:!0})],V.prototype,"_handleReadonlyChange",2),a([Nt({context:k})],V.prototype,"_context",2),V=a([f("qti-assessment-item")],V);var me=class extends y{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let s=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);s?await this.updateStimulusRef(s):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Pt().load(this.href).promise.then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};a([u({type:String})],me.prototype,"identifier",2),a([u({type:String})],me.prototype,"href",2),me=a([f("qti-assessment-stimulus-ref")],me);var Ye=class extends y{};Ye=a([f("qti-companion-materials-info")],Ye);var Ce=class extends y{render(){return m`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let i=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",i?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let i={variable:t=>this._context?.variables.find(r=>r.identifier===t)?.value??"",correct:t=>this._context?.variables.find(r=>r.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(r=>r.identifier===t),updateOutcomeVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:r}}))},updateResponseVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:r}}))}};return this.operatorFunction(this._context,i,e)}};a([S({context:k,subscribe:!0}),x()],Ce.prototype,"_context",2),Ce=a([f("qti-custom-operator")],Ce);var mr=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),qe=d=>{if(typeof d=="string")return d;let i=mr();return i==="."?d.toLocaleString():d.toString().replace(".","").replace(i,".")};function ct(d){return d==null}function ne(d){return d.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var I=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(i){let e=this._context.variables.find(r=>r.identifier===i)||null;if(this.outcomeIdentifier!==i||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!ct(this.identifier)&&!ct(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(i){this.showStatus=i&&this.showHide==="show"||!i&&this.showHide==="hide"?"on":"off"}};a([u({type:String,attribute:"show-hide"})],I.prototype,"showHide",2),a([u({type:String,attribute:"outcome-identifier"})],I.prototype,"outcomeIdentifier",2),a([u({type:String})],I.prototype,"identifier",2),a([u({type:String,attribute:!1})],I.prototype,"showStatus",2),a([S({context:k,subscribe:!0}),x()],I.prototype,"_context",2);var we=class extends I{render(){return m` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};we.styles=v`
2
+ :host {
3
+ display: block;
4
+ }
5
+ .on {
6
+ display: block;
7
+ }
8
+ .off {
9
+ display: none;
10
+ }
11
+ `,we=a([f("qti-feedback-block")],we);var H=d=>d??_;var Re=class extends I{constructor(){super(...arguments);this.render=()=>m` <slot part="feedback" class="${H(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Re.styles=v`
12
+ .on {
13
+ display: inline-block;
14
+ }
15
+ .off {
16
+ display: none;
17
+ }
18
+ `,Re=a([f("qti-feedback-inline")],Re);var Me=class extends I{render(){return m`
19
+ <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
20
+ <slot></slot>
21
+ <div style="margin-top: var(--qti-gap-size); text-align: center;">
22
+ <button class="button close-button" @click="${this.closeFeedback}">Close</button>
23
+ </div>
24
+ </dialog>
25
+ `}openFeedback(){let i=this.shadowRoot?.querySelector("dialog");i&&!i.open&&i.showModal()}closeFeedback(){let i=this.shadowRoot?.querySelector("dialog");i&&i.open&&(i.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(i){i.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Me.styles=v`
26
+ .qti-dialog {
27
+ background: var(--qti-bg);
28
+ border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
29
+ border-radius: var(--qti-border-radius);
30
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
31
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
32
+ position: fixed;
33
+ top: 50%;
34
+ left: 50%;
35
+ transform: translate(-50%, -50%);
36
+ z-index: 1000;
37
+ width: auto;
38
+ max-width: 90%;
39
+ }
40
+
41
+ .button {
42
+ border-radius: var(--qti-border-radius);
43
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
44
+ background-color: var(--qti-bg-active);
45
+ border: var(--qti-border-active);
46
+ cursor: pointer;
47
+ position: relative;
48
+ display: inline-block;
49
+ }
50
+
51
+ .button:hover {
52
+ background-color: var(--qti-hover-bg);
53
+ }
54
+
55
+ .button:disabled {
56
+ background-color: var(--qti-disabled-bg);
57
+ color: var(--qti-disabled-color);
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ .button:focus {
62
+ outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
63
+ }
64
+ `,Me=a([f("qti-modal-feedback")],Me);var Te=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return m` <slot name="drags"></slot> `}};Te.styles=v`
65
+ :host {
66
+ display: flex;
67
+ user-select: none;
68
+ position: absolute;
69
+ }
70
+ `,Te=a([f("qti-associable-hotspot")],Te);var Bt=(d,i,e)=>{class t extends d{}return t};var O=(d,i,e,t)=>{class r extends Bt(d,typeof e=="string"?e:"",typeof i=="string"?i:""){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(o,l){this.data[o]=l},getData(o){return this.data[o]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(o,l)=>{if(this.isMatchTabular())return;for(let p of l)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(h=>h!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of o)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let c=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),c++})};this.droppablesModified=(o,l)=>{if(!this.isMatchTabular()){for(let c of l)this.droppables.includes(c)&&(this.droppables=this.droppables.filter(p=>p!==c),this.allDropzones=this.allDropzones.filter(p=>p!==c));for(let c of o)this.droppables.includes(c)||(this.droppables.push(c),this.allDropzones.push(c));for(let c of this.droppables)this.dataset.choicesContainerWidth&&(c.style.width=`${this.dataset.choicesContainerWidth}px`,c.style.boxSizing="border-box")}}}getElementsFromSelector(o){return typeof o=="function"?o():Array.from(this.querySelectorAll(o)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(o)||[]))}getDragContainersElements(){return this.getElementsFromSelector(t)}handleDraggableContainerChange(o,l){if(!this.isMatchTabular()){if(typeof t=="function"){let c=this.getDragContainersElements(),p=c.filter(g=>!this.dragContainers.includes(g)),h=this.dragContainers.filter(g=>!c.includes(g));(p.length>0||h.length>0)&&this.dragContainersModified(p,h);return}(o.length>0||l.length>0)&&this.dragContainersModified(o||[],l||[])}}dragContainersModified(o,l){for(let c of l)this.dragContainers.includes(c)&&(this.dragContainers=this.dragContainers.filter(p=>p!==c),this.allDropzones=this.allDropzones.filter(p=>p!==c));for(let c of o)this.dragContainers.includes(c)||(this.dragContainers.push(c),this.allDropzones.push(c))}handleDraggablesChange(o,l){if(!this.isMatchTabular()){if(typeof i=="function"){let c=this.getElementsFromSelector(i),p=c.filter(g=>!this.draggables.includes(g)),h=this.draggables.filter(g=>!c.includes(g));(p.length>0||h.length>0)&&this.draggablesModified(p,h);return}(o.length>0||l.length>0)&&this.draggablesModified(o||[],l||[])}}handleDroppablesChange(o,l){if(!this.isMatchTabular()){if(typeof e=="function"){let c=this.getElementsFromSelector(e),p=c.filter(g=>!this.droppables.includes(g)),h=this.droppables.filter(g=>!c.includes(g));(p.length>0||h.length>0)&&this.droppablesModified(p,h);return}(o.length>0||l.length>0)&&this.droppablesModified(o||[],l||[])}}firstUpdated(o){if(super.firstUpdated(o),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let c=this.getElementsFromSelector(i),p=this.getElementsFromSelector(e),h=this.getElementsFromSelector(t);this.dragContainersModified(h,[]),this.droppablesModified(p,[]),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(b=>this.resizeObserver?.observe(b))}updateMinDimensionsForDropZones(){if(this.isMatchTabular())return;let o=this.getElementsFromSelector(i),l=this.getElementsFromSelector(e),c=0,p=0;o.forEach(b=>{let E=b.getBoundingClientRect();c=Math.max(c,E.height),p=Math.max(p,E.width),console.debug(`Gap Text: ${b.tagName}, Height: ${E.height}, Width: ${E.width}`)});let g=this.getElementsFromSelector(t)[0];g&&(g.style.minHeight=`${c}px`,g.style.minWidth=`${p}px`);for(let b of l)b.style.minHeight=`${c}px`,b.style.minWidth=`${p}px`,console.debug(`Gap: ${b.tagName}, Min Height: ${c}, Min Width: ${p}`)}findDraggableInDraggableContainer(o){let l=this.dragContainers.flat();for(let c of l){if(c.getAttribute("identifier")===o)return c;let p;c instanceof HTMLSlotElement?p=Array.from(c?.assignedElements()||[]):typeof i=="function"?p=this.getElementsFromSelector(i).filter(b=>c.contains(b)):p=Array.from(c.querySelectorAll(i));let h=p.find(g=>g.getAttribute("identifier")===o);if(h)return h}}async moveDraggableToDroppable(o,l){if(this.isMatchTabular())return;(()=>{o.style.transform="translate(0, 0)",l.tagName==="SLOT"?o.setAttribute("slot",l.getAttribute("name")):l.appendChild(o),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(o){this.dragContainers.includes(o)?(this._internals.states.add("--dragzone-active"),o.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),o.setAttribute("active",""))}deactivateDroppable(o,l=!0){l&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}activateDroppables(o){if(this.isMatchTabular())return;this.dragContainers.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")}),this.droppables.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(o){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:c}=this.getEventCoordinates(o),p={clientX:l,clientY:c};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let h=this.findClosestDropzone();this.currentDropTarget=h,h!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),h&&(this.activateDroppable(h),this.dispatchCustomEvent(h,"dragenter")),this.lastTarget=h),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),o.preventDefault()}}handleTouchEnd(o){this.isMatchTabular()||(this.isDragging&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),o.preventDefault())}handleTouchCancel(o){this.resetDragState()}validate(){if(this.isMatchTabular())return;if(!this.shadowRoot)return!1;let o=this.getValidAssociations(),l=!0,c="";this.maxAssociations>0&&o>this.maxAssociations?(l=!1,c=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&o<this.minAssociations&&(l=!1,c=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},c,p),l}reportValidity(){let o=this.shadowRoot.querySelector("#validation-message");return o&&(this._internals.validity.valid?(o.textContent="",o.style.display="none"):(o.textContent=this._internals.validationMessage,o.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(o){let l=this.getMatchMaxValue(o),c=o.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&c>=l}dropDraggableInDroppable(o,l){let c=o.cloneNode(!0);c.removeAttribute("style"),this.moveDraggableToDroppable(c,l),this.draggablesModified([c],[]);let p=this.getMatchMaxValue(o),h=this.draggables.filter(g=>g.getAttribute("identifier")===o.getAttribute("identifier"));p!==0&&h.length>=p?(o.style.opacity="0.0",o.style.pointerEvents="none"):o.style.opacity="1.0"}resetDragState(){if(this.dragClone){let o=this.currentDropTarget!==null,l=!o||this.dragContainers.includes(this.currentDropTarget);o&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let o=this.getValidAssociations(),l=this.maxAssociations!==0&&o>=this.maxAssociations;this.droppables.forEach(c=>{l?this.disableDroppable(c):this.checkMaxAssociations(c)?this.disableDroppable(c):this.enableDroppable(c)})}getMatchMaxValue(o){let l=o.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(o){o.setAttribute("disabled","")}enableDroppable(o){o.removeAttribute("disabled")}get response(){let o;return typeof this.getResponse=="function"?o=this.getResponse():o=this.collectResponseData(),o.join(",")}set response(o){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(o=this.getValue(o)),Array.isArray(o)){this.reset(!1),o?.forEach(c=>this.placeResponse(c));let l=new FormData;o.forEach(c=>{l.append(this.responseIdentifier,c)}),this._internals.setFormValue(l)}else this._internals.setFormValue(o||"")}placeResponse(o){let[l,...c]=o.split(" ").reverse(),p=Array.from(this.draggables),h=Array.from(this.droppables);c.forEach(g=>{if(g==="")return;let b=p.find(R=>R.getAttribute("identifier")===g),E=h.find(R=>R.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,E)})}getValidAssociations(){let o=0;for(let l of this.droppables)o=o+this.getDraggablesFromDroppable(l).length;return o}saveResponse(){let o;typeof this.getResponse=="function"?o=this.getResponse():o=this.collectResponseData(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:o}}))}collectResponseData(){return this.droppables.map(l=>{let p=this.getDraggablesFromDroppable(l).map(g=>g.getAttribute("identifier")),h=l.getAttribute("identifier");return p.map(g=>`${g} ${h}`)}).flat()}getDraggablesFromDroppable(o){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,h,g)=>g.indexOf(p)===h).flatMap(p=>Array.from(o.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(o=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,o&&this.saveResponse()}updateDragClonePosition(o){if(!this.isDragging||!this.dragClone)return;let l=o.clientX-this.cloneOffset.x,c=o.clientY-this.cloneOffset.y,{newLeft:p,newTop:h}=this.applyInteractionBoundaries(l,c,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${h}px`}applyInteractionBoundaries(o,l,c){let p=this.getBoundingClientRect(),h=c.getBoundingClientRect(),g=h.width,b=h.height,E=Math.max(p.left,Math.min(o,p.right-g)),R=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:E,newTop:R}}getEventCoordinates(o,l=!1){let c=o.touches?o.touches[0]:o;return{x:l?c.pageX:c.clientX,y:l?c.pageY:c.clientY}}calculateDragDistance(o){let l=Math.abs(o.clientX-this.touchStartPoint.x),c=Math.abs(o.clientY-this.touchStartPoint.y);return l+c}findClosestDropzone(){let o=this.allDropzones.filter(h=>!h.hasAttribute("disabled"));if(!this.dragClone||o.length===0)return null;let l=this.dragClone.getBoundingClientRect(),c=null,p=0;for(let h of o){let g=h.getBoundingClientRect(),b=this.calculateOverlapArea(l,g);b>p&&(p=b,c=h)}if(!c){let h=200;for(let g of o){let b=g.getBoundingClientRect(),E=Math.sqrt(Math.pow(l.left-b.left,2)+Math.pow(l.top-b.top,2));E<h&&(h=E,c=g)}}return c}calculateOverlapArea(o,l){let c=Math.max(0,Math.min(o.right,l.right)-Math.max(o.left,l.left)),p=Math.max(0,Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top));return c*p}dispatchCustomEvent(o,l,c=!0){if(!o)return;let p=new CustomEvent(l,{bubbles:c,cancelable:!0});p.dataTransfer=this.dataTransfer,o.dispatchEvent(p)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(o){if(this.isMatchTabular()||this.isDragging)return;let{x:l,y:c}=this.getEventCoordinates(o);this.touchStartPoint={x:l,y:c},this.dragSource=o.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),h=this.droppables.some(w=>Array.from(w.children).some(le=>le===this.dragSource)),g=this.dragSource.getBoundingClientRect();h&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-g.left,this.cloneOffset.y=c-g.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let w=0;w<b.length;w++){let le=b[w];this.dragClone.style.setProperty(le,b.getPropertyValue(le))}let E=p.getBoundingClientRect();this.dragClone.style.width=`${E.width}px`,this.dragClone.style.height=`${E.height}px`,g&&this.setDragCloneStyles(g),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let R=this.getMatchMaxValue(this.dragSource),D=this.draggables.filter(w=>w.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));R!==0&&D.length>=R?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",o.preventDefault(),this.dragClone.setAttribute("dragging","")}setDragCloneStyles(o){this.dragClone.style.position="fixed",this.dragClone.style.top=`${o.top}px`,this.dragClone.style.left=`${o.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return a([u({attribute:!1,type:Object})],r.prototype,"configuration",2),a([u({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),a([u({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),a([We(t,{waitUntilFirstUpdate:!0})],r.prototype,"handleDraggableContainerChange",1),a([We(i,{waitUntilFirstUpdate:!0})],r.prototype,"handleDraggablesChange",1),a([We(e,{waitUntilFirstUpdate:!0})],r.prototype,"handleDroppablesChange",1),r};var Jt=v`
71
+ :host {
72
+ display: block; /* necessary to calculate scaling position */
73
+ }
74
+ slot[name='qti-simple-associable-choice'] {
75
+ display: flex;
76
+ align-items: flex-start;
77
+ flex: 1;
78
+ border: 2px solid transparent;
79
+ padding: 0.3rem;
80
+ border-radius: 0.3rem;
81
+ gap: 0.5rem;
82
+ }
83
+
84
+ :host::part(associables-container) {
85
+ display: flex;
86
+ padding: 0.5rem;
87
+ justify-content: space-between;
88
+ background: linear-gradient(
89
+ 180deg,
90
+ rgb(0 0 0 / 0%) calc(50% - 1px),
91
+ var(--qti-border-color-gray) calc(50%),
92
+ rgb(0 0 0 / 0%) calc(50% + 1px)
93
+ );
94
+ }
95
+ `;var fe=class extends O(q,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return m` <slot name="prompt"></slot>
96
+ <slot name="qti-simple-associable-choice"></slot>
97
+ <div part="drop-container">
98
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>m`<div part="associables-container">
99
+ <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
100
+ <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
101
+ </div>`)}
102
+
103
+ <div role="alert" part="message" id="validation-message"></div>
104
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};fe.styles=Jt,a([x()],fe.prototype,"_childrenMap",2),fe=a([f("qti-associate-interaction")],fe);var ee=(d,i)=>{class e extends d{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(o=>o.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(o=>o.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleCorrectResponse(s,n){if(s.correctResponse){let o=Array.isArray(s.correctResponse)?s.correctResponse:[s.correctResponse];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),n&&o.length>0&&(o.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${i}`,this._registerChoiceElement),this.addEventListener(`unregister-${i}`,this._unregisterChoiceElement),this.addEventListener(`activate-${i}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${i}`,this._registerChoiceElement),this.removeEventListener(`unregister-${i}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${i}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(c=>this._getChoiceChecked(c)),n=s.length,o=!0,l="";return this.maxChoices!==0&&n>this.maxChoices?(o=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(o=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(o?{}:{customError:!0},l,s[n-1]||this._choiceElements[0]||this),o}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.setProperty("display","block","important"))),this._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(o=>o!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.detail.identifier&&this._setChoiceChecked(n,!1)}):this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(o=>this._getChoiceChecked(o)).length>=this.maxChoices?this._choiceElements.forEach(o=>{this._getChoiceChecked(o)||(o.disabled=!0)}):this._choiceElements.forEach(o=>o.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(o=>this._getChoiceChecked(o)).map(o=>o.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let o=s.includes(n.identifier);this._setChoiceChecked(n,o)})}}return a([pe("#validation-message")],e.prototype,"_validationMessageElement",2),a([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),a([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),a([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),a([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),a([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),a([x()],e.prototype,"response",2),a([M("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),a([x(),S({context:zt,subscribe:!0})],e.prototype,"_configContext",2),e};var Wt=(d,i)=>{class e extends d{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(o=>this._allLabels.includes(o)||this._allLabelSuffixes.includes(o)),n=o=>!isNaN(+o);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,p)=>({el:c,order:n(c.style.order)?+c.style.order:p+1})).sort((c,p)=>c.order-p.order).map(c=>c.el);for(let c=0;c<l.length;c++)l[c].marker=this._getLabel(c+1)}}_getLabel(s){let n=this._classes.filter(c=>this._allLabels.includes(c)).pop(),o=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!n&&o&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return o==="qti-labels-suffix-period"?l+=".":o==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return a([u({type:String,reflect:!0})],e.prototype,"class",1),e};var Xt=v`
105
+ :host {
106
+ display: block;
107
+ }
108
+
109
+ [part='slot'] {
110
+ display: grid;
111
+ gap: 10px;
112
+ }
113
+
114
+ /* Define the number of columns dynamically */
115
+ :host([class*='qti-choices-stacking-']) [part='slot'] {
116
+ grid-template-columns: repeat(var(--stacking-count, 1), 1fr);
117
+ }
118
+
119
+ /* Apply dynamic stacking count based on class */
120
+ :host(.qti-choices-stacking-1) {
121
+ --stacking-count: 1;
122
+ }
123
+ :host(.qti-choices-stacking-2) {
124
+ --stacking-count: 2;
125
+ }
126
+ :host(.qti-choices-stacking-3) {
127
+ --stacking-count: 3;
128
+ }
129
+ :host(.qti-choices-stacking-4) {
130
+ --stacking-count: 4;
131
+ }
132
+ :host(.qti-choices-stacking-5) {
133
+ --stacking-count: 5;
134
+ }
135
+ :host(.qti-choices-stacking-6) {
136
+ --stacking-count: 6;
137
+ }
138
+
139
+ /* Default slot item layout */
140
+ ::slotted(qti-simple-choice) {
141
+ display: flex;
142
+ align-items: center;
143
+ white-space: normal;
144
+ }
145
+
146
+ /* Orientation styles */
147
+ :host(.qti-orientation-horizontal) [part='slot'] {
148
+ grid-auto-flow: dense column;
149
+ grid-auto-columns: 1fr;
150
+ }
151
+
152
+ :host(.qti-orientation-vertical) [part='slot'] {
153
+ grid-auto-flow: row;
154
+ }
155
+
156
+ /* Vertical and horizontal stacking logic */
157
+ :host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part='slot'] {
158
+ grid-auto-flow: dense column;
159
+ grid-auto-columns: 1fr;
160
+ grid-template-columns: repeat(var(--stacking-count), 1fr);
161
+ grid-template-rows: repeat(calc(var(--item-count) / var(--stacking-count)), 1fr);
162
+ }
163
+
164
+ :host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part='slot'] {
165
+ grid-auto-flow: row;
166
+ grid-template-columns: repeat(var(--stacking-count), 1fr);
167
+ grid-template-rows: unset;
168
+ }
169
+
170
+ /* Ensure even distribution in vertical mode */
171
+ :host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
172
+ grid-row: auto;
173
+ }
174
+ `;var ge=class extends Wt(ee(q,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}_handleSlotChange(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return m`
175
+ <slot part="prompt" name="prompt"></slot><slot part="slot" @slotchange=${this._handleSlotChange}></slot>
176
+ <div part="message" role="alert" id="validation-message"></div>
177
+ `}};ge.styles=Xt,a([u({type:String})],ge.prototype,"orientation",2),ge=a([f("qti-choice-interaction")],ge);var B=class extends q{constructor(){super();this.rawResponse="";this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:ne(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let r=this.manifest.style[0],s=r.startsWith("http")||r.startsWith("blob")?r:ne(`${this.baseRefUrl}/${r}`),n=this.manifest.script[0],o=n.startsWith("http")||n.startsWith("blob")?n:ne(`${this.baseRefUrl}/${n}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
178
+ <html>
179
+ <head>
180
+ <link href='${s}' rel="stylesheet" />
181
+ <script src='${o}'></script>
182
+ </head>
183
+ <body></body>
184
+ </html>
185
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let s of r){let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;l&&this.getInnerIFrames(l,r)}catch(l){console.error("Error accessing nested iframe:",l)}}return r.forEach((s,n)=>{r.indexOf(s)!==n&&r.splice(n,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let n=s.src;if(new URL(n,window.location.href).origin===window.location.origin)try{let l=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",n)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let s of r)s.contentWindow&&s.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:r}=e.data;switch(t){case"setResponse":(r===null||!(Array.isArray(r)&&r.length===1&&r[0]===""))&&(this.rawResponse=r,this.saveResponse(r));break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let s=this.manifest.media.map(n=>n.startsWith("http")||n.startsWith("blob")?n:ne(this.baseRefUrl+"/"+n));this.postToWindowAndIframes("mediaData",s);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){if(!this.rawResponse)return!1;if(Array.isArray(this.rawResponse)){if(this.rawResponse.length===0)return!1;for(let e of this.rawResponse)if(e!==""&&e!==null)return!0}return!0}get response(){return this.rawResponse||null}set response(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else if(Array.isArray(e))this.rawResponse=e;else if(e)throw new Error("Value must be a string or an array of strings")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return m`<iframe
186
+ width=${this.getAttribute("width")}
187
+ height=${this.getAttribute("height")}
188
+ frameborder="0"
189
+ title="pciContainer"
190
+ id="pciContainer"
191
+ >
192
+ </iframe>
193
+ ${this._errorMessage&&m`<div style="color:red">
194
+ <h1>Error</h1>
195
+ ${this._errorMessage}
196
+ </div>`}`}};a([u({type:String,attribute:"data"})],B.prototype,"data",2),a([u({type:String,attribute:"data-base-item"})],B.prototype,"baseItemUrl",2),a([u({type:String,attribute:"data-base-ref"})],B.prototype,"baseRefUrl",2),a([u({type:String,attribute:"id"})],B.prototype,"id",2),a([x()],B.prototype,"_errorMessage",2),B=a([f("qti-custom-interaction")],B);var te=class extends y{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return m`<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"}}))}};a([u({type:String,attribute:"response-identifier"})],te.prototype,"responseIdentifier",2),a([u({reflect:!0,type:Boolean})],te.prototype,"disabled",2),a([u({type:String,attribute:"count-attempt"})],te.prototype,"countAttempt",2),a([u({type:String})],te.prototype,"title",2),te=a([f("qti-end-attempt-interaction")],te);var Yt=v`
197
+ /* PK: display host as block, else design will be collapsed */
198
+ :host {
199
+ display: block;
200
+ }
201
+ textarea {
202
+ box-sizing: border-box;
203
+ width: 100%;
204
+ height: 100%;
205
+ border: 0;
206
+ }
207
+ `;var L=class extends q{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}handleclassNamesChange(e,t){let r=t.split(" "),s=!1;if(r.forEach(n=>{if(n.startsWith("qti-height-lines-")){let o=n.replace("qti-height-lines-","");this._rows=parseInt(o),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(t);e.checkValidity()&&r.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return m`<slot name="prompt"></slot
208
+ ><textarea
209
+ part="textarea"
210
+ name="${this.responseIdentifier}"
211
+ spellcheck="false"
212
+ autocomplete="off"
213
+ maxlength="${5e3}"
214
+ @keydown="${e=>e.stopImmediatePropagation()}"
215
+ @keyup="${this.textChanged}"
216
+ @change="${this.textChanged}"
217
+ @blur="${e=>{this.reportValidity()}}"
218
+ placeholder="${H(this.placeholderText?this.placeholderText:void 0)}"
219
+ rows="${this._rows}"
220
+ ?disabled="${this.disabled}"
221
+ ?readonly="${this.readonly}"
222
+ .value=${this.response}
223
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};L.styles=Yt,a([x()],L.prototype,"_rows",2),a([u({type:Number,attribute:"expected-length"})],L.prototype,"expectedLength",2),a([u({type:String,attribute:"pattern-mask"})],L.prototype,"patternMask",2),a([u({type:String,attribute:"placeholder-text"})],L.prototype,"placeholderText",2),a([u({type:String,attribute:"data-patternmask-message"})],L.prototype,"dataPatternmaskMessage",2),a([u({type:String,attribute:"class"})],L.prototype,"classNames",2),a([M("classNames")],L.prototype,"handleclassNamesChange",1),a([x()],L.prototype,"response",2),a([M("response",{waitUntilFirstUpdate:!0})],L.prototype,"_handleResponseChange",2),L=a([f("qti-extended-text-interaction")],L);var be=class extends y{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};be.styles=v`
224
+ :host {
225
+ display: flex;
226
+ user-select: none;
227
+ }
228
+ `,a([u({type:Number,reflect:!0})],be.prototype,"tabindex",2),be=a([f("qti-gap-img")],be);var Gt=v`
229
+ :host {
230
+ display: flex;
231
+ align-items: flex-start;
232
+ flex-direction: column;
233
+ flex-wrap: wrap;
234
+ gap: 0.5rem;
235
+ }
236
+
237
+ :host(.qti-choices-top) {
238
+ flex-direction: column;
239
+ }
240
+ :host(.qti-choices-bottom) {
241
+ flex-direction: column-reverse;
242
+ }
243
+ :host(.qti-choices-left) {
244
+ flex-direction: row;
245
+ }
246
+ :host(.qti-choices-right) {
247
+ flex-direction: row-reverse;
248
+ }
249
+ /* [part='drops'] , */
250
+ [name='prompt'] {
251
+ width: 100%;
252
+ }
253
+ [name='drags'] {
254
+ display: flex;
255
+ align-items: flex-start;
256
+ flex: 1;
257
+ border: 2px solid transparent;
258
+ padding: 0.3rem;
259
+ border-radius: 0.3rem;
260
+ gap: 0.5rem;
261
+ }
262
+ `;var Se=class extends O(q,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return m`<slot name="prompt"> </slot>
263
+ <slot part="drags" name="drags"></slot>
264
+ <slot part="drops"></slot>
265
+ <div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(i,e){if(e&&i.correctResponse){let t=[],r=Array.isArray(i.correctResponse)?i.correctResponse:[i.correctResponse];r&&(t=r.map(n=>{let o=n.split(" ");return{text:o[0],gap:o[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let o=n.getAttribute("identifier"),l=t.find(p=>p.gap===o)?.text,c=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&c){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=c,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(r=>{r.remove()})}};Se.styles=Gt,Se=a([f("qti-gap-match-interaction")],Se);var Kt={toAttribute:d=>d?"true":"false",fromAttribute:d=>d==="true"};function P(d,i){class e extends d{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${i}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${i}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${i}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return m`<slot></slot>`}}return a([u({type:String})],e.prototype,"identifier",2),a([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),a([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Kt})],e.prototype,"disabled",2),a([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Kt})],e.prototype,"readonly",2),a([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ve=class extends P(y,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return m`<slot></slot>`}};ve.styles=v`
266
+ :host {
267
+ display: inline-flex;
268
+ user-select: none;
269
+ }
270
+ `,a([u({type:Number,reflect:!0})],ve.prototype,"tabindex",2),ve=a([f("qti-gap-text")],ve);var ye=class extends y{constructor(){super(...arguments);this.tabindex=0}render(){return m` <slot name="drags"></slot>`}};ye.styles=v`
271
+ :host {
272
+ display: flex;
273
+ user-select: none;
274
+ }
275
+ `,a([u({type:Number,reflect:!0})],ye.prototype,"tabindex",2),ye=a([f("qti-gap")],ye);var Zt=(d,i,e)=>{let t=new Map;for(let r=i;r<=e;r++)t.set(d[r],r);return t},xe=Z(class extends ue{constructor(d){if(super(d),d.type!==de.CHILD)throw Error("repeat() can only be used in text expressions")}dt(d,i,e){let t;e===void 0?e=i:i!==void 0&&(t=i);let r=[],s=[],n=0;for(let o of d)r[n]=t?t(o,n):n,s[n]=e(o,n),n++;return{values:s,keys:r}}render(d,i,e){return this.dt(d,i,e).values}update(d,[i,e,t]){let r=Ut(d),{values:s,keys:n}=this.dt(i,e,t);if(!Array.isArray(r))return this.ut=n,s;let o=this.ut??(this.ut=[]),l=[],c,p,h=0,g=r.length-1,b=0,E=s.length-1;for(;h<=g&&b<=E;)if(r[h]===null)h++;else if(r[g]===null)g--;else if(o[h]===n[b])l[b]=Q(r[h],s[b]),h++,b++;else if(o[g]===n[E])l[E]=Q(r[g],s[E]),g--,E--;else if(o[h]===n[E])l[E]=Q(r[h],s[E]),he(d,l[E+1],r[h]),h++,E--;else if(o[g]===n[b])l[b]=Q(r[g],s[b]),he(d,r[h],r[g]),g--,b++;else if(c===void 0&&(c=Zt(n,b,E),p=Zt(o,h,g)),c.has(o[h]))if(c.has(o[g])){let R=p.get(n[b]),D=R!==void 0?r[R]:null;if(D===null){let w=he(d,r[h]);Q(w,s[b]),l[b]=w}else l[b]=Q(D,s[b]),he(d,r[h],D),r[R]=null;b++}else Xe(r[g]),g--;else Xe(r[h]),h++;for(;b<=E;){let R=he(d,l[E+1]);Q(R,s[b]),l[b++]=R}for(;h<=g;){let R=r[h++];R!==null&&Xe(R)}return this.ut=n,Ft(d,l),ce}});function re(d,i,e,t){let r=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(d){case"circle":{if(i.length!==3){console.error("Invalid cirlce coordinates:",i);return}let[n,o,l]=i,c=n/r*100,p=o/s*100,h=l/r*100;t.style.left=c-h+"%",t.style.top=p-h+"%";let g=l/r*100,b=l/s*100;t.style.width=2*g+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"rect":{if(i.length!==4){console.error("Invalid rectangle coordinates:",i);return}let[n,o,l,c]=i,p=n/r*100,h=o/s*100,g=l/r*100,b=c/s*100;t.style.left=p+"%",t.style.top=h+"%",t.style.width=g-p+"%",t.style.height=b-h+"%"}break;case"ellipse":{if(i.length!==4){console.error("Invalid ellipse coordinates:",i);return}let[n,o,l,c]=i,p=n/r*100,h=o/s*100,g=l/r*100,b=c/s*100;t.style.left=p-g+"%",t.style.top=h-b+"%",t.style.width=2*g+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"poly":{if(i.length<6||i.length%2!==0){console.error("Invalid polygon coordinates:",i);return}let n=[];for(let w=0;w<i.length;w+=2)n.push({x:i[w],y:i[w+1]});let o=Math.min(...n.map(w=>w.x)),l=Math.max(...n.map(w=>w.x)),c=Math.min(...n.map(w=>w.y)),p=Math.max(...n.map(w=>w.y)),h=o/r*100,g=c/s*100,b=l/r*100,E=p/s*100;t.style.left=h+"%",t.style.top=g+"%",t.style.width=b-h+"%",t.style.height=E-g+"%";let D=n.map(w=>({x:(w.x-o)/(l-o)*100,y:(w.y-c)/(p-c)*100})).map(w=>`${w.x}% ${w.y}%`).join(",");t.style.clipPath=`polygon(${D})`}break;default:console.error(`Unsupported shape: ${d}`);break}}var Qt=v`
276
+ slot:not([name='prompt']) {
277
+ // position: relative; /* qti-hotspot-choice relative to the slot */
278
+ display: block;
279
+ width: fit-content; /* hotspots not stretching further if image is at max size */
280
+ }
281
+ ::slotted(img) {
282
+ /* image not selectable anymore */
283
+ pointer-events: none;
284
+ user-select: none;
285
+ }
286
+ ::slotted(qti-associable-hotspot) {
287
+ transform: translate(-50%, -50%);
288
+ }
289
+ line-container {
290
+ display: block;
291
+ position: relative;
292
+ width: fit-content;
293
+ }
294
+ svg {
295
+ position: absolute;
296
+ top: 0px;
297
+ left: 0px;
298
+ }
299
+ `;var z=class extends q{constructor(){super();this.startPoint=null;this.endPoint=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._response=[],this._correctLines=[]}validate(){return this.response.length>0}set response(e){this._response=e}get response(){return this._response}toggleCorrectResponse(e,t){if(!t){this._correctLines=[];return}if(!e.correctResponse){console.error("No correct response found for this interaction.");return}let r=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];this._correctLines=r}render(){return m`<slot name="prompt"></slot>
300
+ <line-container>
301
+ <svg
302
+ width=${H(this.grImage[0]?.width)}
303
+ height=${H(this.grImage[0]?.height)}
304
+ viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
305
+ >
306
+ ${xe(this.response||[],e=>e,(e,t)=>Je`
307
+ <line
308
+ part="line"
309
+ x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
310
+ y1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.top)}
311
+ x2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.left)}
312
+ y2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.top)}
313
+ stroke="red"
314
+ stroke-width="3"
315
+ @click=${r=>{r.stopPropagation(),this._response=this._response.filter((s,n)=>n!==t),this.saveResponse(this.response)}}
316
+ />
317
+ `)}
318
+ ${xe(this._correctLines||[],e=>e,(e,t)=>Je`
319
+ <line
320
+ part="correct-line"
321
+ x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
322
+ y1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.top)}
323
+ x2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.left)}
324
+ y2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.top)}
325
+ stroke="var(--qti-correct)"
326
+ stroke-width="3"
327
+ stroke-dasharray="5,5"
328
+ />
329
+ `)}
330
+ ${this.startPoint&&Je`<line
331
+ part="point"
332
+ x1=${this.startCoord.x}
333
+ y1=${this.startCoord.y}
334
+ x2=${this.mouseCoord.x}
335
+ y2=${this.mouseCoord.y}
336
+ stroke="var(--qti-border-active)"
337
+ stroke-width="3"
338
+ />`}
339
+ </svg>
340
+ <slot></slot>
341
+ </line-container>
342
+ <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),n=r.getAttribute("shape"),o=s.split(",").map(l=>parseInt(l));re(n,o,t,r)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let r=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-r.left,y:e.clientY-r.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};z.styles=Qt,a([x()],z.prototype,"_correctLines",2),a([x()],z.prototype,"startCoord",2),a([x()],z.prototype,"mouseCoord",2),a([Ht({selector:"img"})],z.prototype,"grImage",2),a([x()],z.prototype,"_response",2),z=a([f("qti-graphic-associate-interaction")],z);var er=v`
343
+ :host {
344
+ display: flex;
345
+ align-items: flex-start;
346
+ flex-direction: column;
347
+ flex-wrap: wrap;
348
+ gap: 0.5rem;
349
+ }
350
+
351
+ :host(.qti-choices-top) {
352
+ flex-direction: column-reverse;
353
+ }
354
+ :host(.qti-choices-bottom) {
355
+ flex-direction: column;
356
+ }
357
+ :host(.qti-choices-left) {
358
+ flex-direction: row-reverse;
359
+ & [name='drags'] {
360
+ width: 25%;
361
+ }
362
+ & [part='image'] {
363
+ width: 75%;
364
+ }
365
+ }
366
+ :host(.qti-choices-right) {
367
+ flex-direction: row;
368
+ & [name='drags'] {
369
+ width: 25%;
370
+ }
371
+ & [part='image'] {
372
+ width: 75%;
373
+ }
374
+ }
375
+ [part='image'] {
376
+ display: block;
377
+ position: relative;
378
+ }
379
+ /* [part='drops'] , */
380
+
381
+ [name='drags'] {
382
+ display: flex;
383
+ align-items: flex-start;
384
+ flex-wrap: wrap;
385
+ flex: 1;
386
+ border: 2px solid transparent;
387
+ padding: 0.3rem;
388
+ border-radius: 0.3rem;
389
+ gap: 0.5rem;
390
+ }
391
+ ::slotted(img) {
392
+ display: inline-block;
393
+ user-select: none;
394
+ pointer-events: none;
395
+ }
396
+ `;var _e=class extends O(q,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return m` <slot name="prompt"></slot>
397
+ <slot part="image"></slot>
398
+ <slot part="drags" name="drags" class="hover-border"></slot>
399
+ <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(i){let e=i.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(r){case"circle":{let[n,o,l]=s;e.style.left=n-l+"px",e.style.top=o-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,o,l,c]=s;e.style.left=n+"px",e.style.top=o+"px",e.style.width=l-n+"px",e.style.height=c-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};_e.styles=er,_e=a([f("qti-graphic-gap-match-interaction")],_e);var tr=v`
400
+ slot:not([name='prompt']) {
401
+ position: relative; /* qti-hotspot-choice relative to the slot */
402
+ display: block;
403
+ width: fit-content; /* hotspots not stretching further if image is at max size */
404
+ }
405
+ ::slotted(img) {
406
+ /* image not selectable anymore */
407
+ pointer-events: none;
408
+ user-select: none;
409
+ }
410
+ `;var ke=class extends ee(q,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return m`
411
+ <slot name="prompt"></slot>
412
+ <slot></slot>
413
+ <div role="alert" part="message" id="validation-message"></div>
414
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!r)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){let n=this._choiceElements.filter(o=>o.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}r.order=n+1}else{let n=r.order;r.order=null,this._choiceElements.forEach(o=>{o.order!=null&&o.order>n&&o.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e,t){let r=this._choiceElements;for(let s of r)if(t&&e.correctResponse?.length>0&&Array.isArray(e.correctResponse)){let n=e.correctResponse.findIndex(o=>o===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),n=r.getAttribute("shape"),o=s.split(",").map(l=>parseInt(l));re(n,o,t,r)}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)}};ke.styles=tr,ke=a([f("qti-graphic-order-interaction")],ke);var ae=class extends P(y,"qti-hotspot-choice"){};ae.styles=v`
415
+ :host {
416
+ display: flex;
417
+ user-select: none;
418
+ position: absolute;
419
+ }
420
+ `,a([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],ae.prototype,"order",2),a([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],ae.prototype,"orderCorrect",2),ae=a([f("qti-hotspot-choice")],ae);var rr=v`
421
+ slot:not([name='prompt']) {
422
+ position: relative; /* qti-hotspot-choice relative to the slot */
423
+ display: block;
424
+ width: fit-content; /* hotspots not stretching further if image is at max size */
425
+ }
426
+ ::slotted(img) {
427
+ /* image not selectable anymore */
428
+ pointer-events: none;
429
+ user-select: none;
430
+ /* width:100%; */
431
+ }
432
+ `;var Ae=class extends ee(q,"qti-hotspot-choice"){render(){return m`
433
+ <slot name="prompt"></slot>
434
+ <slot></slot>
435
+ `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),n=r.split(",").map(o=>parseInt(o));re(s,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ae.styles=rr,Ae=a([f("qti-hotspot-interaction")],Ae);var Ge=class extends ee(q,"qti-hottext"){constructor(){super(...arguments);this.render=()=>m` <slot></slot>
436
+ <div part="message" role="alert" id="validation-message"></div>`}};Ge=a([f("qti-hottext-interaction")],Ge);var Le=class extends P(y,"qti-hottext"){render(){return m`<div part="ch"><div part="cha"></div></div>
437
+ <slot></slot> `}};Le.styles=v`
438
+ :host {
439
+ display: flex;
440
+ user-select: none;
441
+ }
442
+ `,Le=a([f("qti-hottext")],Le);var De=class extends ue{constructor(i){if(super(i),this.it=_,i.type!==de.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===_||i==null)return this._t=void 0,this.it=i;if(i===ce)return i;if(typeof i!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this._t;this.it=i;let e=[i];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};De.directiveName="unsafeHTML",De.resultType=1;var Ee=Z(De);var ie=class extends q{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[v`
443
+ :host {
444
+ display: inline-block;
445
+ }
446
+ slot {
447
+ display: flex;
448
+ flex-direction: column;
449
+ }
450
+ [role='menu'] {
451
+ position: absolute;
452
+ z-index: 1000;
453
+ }
454
+ .anchor {
455
+ /* anchor-name: --infobox; */
456
+ width: fit-content;
457
+ }
458
+
459
+ .positionedElement {
460
+ position: absolute;
461
+ /* position-anchor: --infobox; */
462
+ /* top: anchor(bottom); */
463
+ }
464
+ `]}render(){return m`
465
+ <select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
466
+ ${this.options.map(e=>m`
467
+ <option value="${e.value}" ?selected="${e.selected}">${Ee(e.textContent)}</option>
468
+ `)}
469
+ </select>
470
+
471
+ ${Ee(this.correctOption)}
472
+ `}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(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleCorrectResponse(e,t){if(this.correctResponse=t&&e.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(r=>this.correctResponse===r.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};ie.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"],a([x()],ie.prototype,"options",2),a([x()],ie.prototype,"correctOption",2),a([u({attribute:"data-prompt",type:String})],ie.prototype,"dataPrompt",2),ie=a([f("qti-inline-choice-interaction")],ie);var Ve=class extends y{static get styles(){return[v`
473
+ :host {
474
+ display: block;
475
+ cursor: pointer;
476
+ }
477
+ `]}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 m` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};a([u({type:String})],Ve.prototype,"identifier",2),Ve=a([f("qti-inline-choice")],Ve);var se=class extends P(y,"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 m`
478
+ <slot part="slot"></slot>
479
+ <slot part="dropslot" name="qti-simple-associable-choice"></slot>
480
+ `}};se.styles=v`
481
+ :host {
482
+ display: flex;
483
+ user-select: none;
484
+ }
485
+ slot {
486
+ width: 100%;
487
+ display: block;
488
+ }
489
+ slot[name='qti-simple-associable-choice'] {
490
+ /* width: 100%; */
491
+ }
492
+ `,a([u({type:Number,attribute:"match-min"})],se.prototype,"matchMin",2),a([u({type:Number,attribute:"match-max"})],se.prototype,"matchMax",2),a([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],se.prototype,"fixed",2),se=a([f("qti-simple-associable-choice")],se);var ir=v`
493
+ slot:not([hidden]) {
494
+ /* slot where the */
495
+ display: flex;
496
+ flex-direction: column;
497
+ gap: 0.5rem;
498
+ align-items: flex-start; /* prevents the drag and drop container slots having the same height */
499
+ }
500
+ :host(.qti-choices-top) slot {
501
+ flex-direction: column;
502
+ }
503
+ :host(.qti-choices-bottom) slot {
504
+ flex-direction: column-reverse;
505
+ }
506
+ :host(.qti-choices-left) slot {
507
+ flex-direction: row;
508
+ }
509
+ :host(.qti-choices-right) slot {
510
+ flex-direction: row-reverse;
511
+ }
512
+ slot[name='prompt'] {
513
+ display: block;
514
+ }
515
+ ::slotted(qti-simple-match-set) {
516
+ /* Make sure the drag and drop container slots have the same width */
517
+ flex: 1;
518
+ }
519
+ `;var J=class extends O(q,"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",()=>{let e=document.querySelector("qti-simple-match-set:last-of-type");if(!e)return[];let t=e.querySelectorAll("qti-simple-associable-choice"),r=[];for(let s of t)if(s.shadowRoot){let n=s.shadowRoot.querySelector('slot[part="dropslot"]');console.log("slot:",n),n&&r.push(n)}return r},"qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,r=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(r)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(o=>o.indexOf(s)===-1)),this.response=[...this.response,r]):this.response=[r],this.lastCheckedRadio=t):(this.response=(this.response||[]).filter(o=>o!==r),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.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.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.rows.length:super.validate()}toggleCorrectResponse(e,t){if(e.correctResponse){let s=(Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse]).map(n=>{let[o,l]=n.split(" ");return{text:o,gap:l}});this.class.split(" ").includes("qti-match-tabular")?t?this.correctOptions=s||[]:this.correctOptions=null:t?(this.querySelectorAll(".correct-option").forEach(n=>n.remove()),this.cols.forEach(n=>{let o=n.getAttribute("identifier"),l=s.find(c=>c.gap===o);if(l?.text){let p=this.querySelector(`qti-simple-associable-choice[identifier="${l.text}"]`)?.textContent?.trim();if(p&&!n.previousElementSibling?.classList.contains("correct-option")){let h=document.createElement("span");h.classList.add("correct-option"),h.textContent=p,h.style.border="1px solid var(--qti-correct)",h.style.borderRadius="4px",h.style.padding="2px 4px",h.style.display="inline-block",n.insertAdjacentElement("beforebegin",h)}}})):this.correctOptions=null}else this.querySelectorAll(".correct-option").forEach(r=>r.remove())}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return m`
520
+ <slot name="prompt"></slot>
521
+ <slot ?hidden=${e}></slot>
522
+
523
+ ${e?m`
524
+ <table part="table">
525
+ <tr part="r-header">
526
+ <td></td>
527
+ ${this.cols.map(r=>m`<th part="r-header">${Ee(r.innerHTML)}</th>`)}
528
+ </tr>
529
+
530
+ ${this.rows.map(r=>m`<tr part="row">
531
+ <td part="c-header">${Ee(r.innerHTML)}</td>
532
+ ${this.cols.map(s=>{let n=r.getAttribute("identifier"),o=s.getAttribute("identifier"),l=`${n} ${o}`,c=(this.response||[]).filter(R=>R.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,h=r.matchMax===1?"radio":"checkbox",g=!!this.correctOptions?.find(R=>R.text===n&&R.gap===o),b=h==="radio"?`rb ${p?"rb-checked":""} ${t?g?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?g?"cb-correct":"cb-incorrect":""}`,E=this.correctOptions?.length>0?!0:r.matchMax===1?!1:r.matchMax!==0&&c>=r.matchMax&&!p;return m`<td part="input-cell">
533
+ <div
534
+ class="input-container"
535
+ style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
536
+ >
537
+ <input
538
+ type=${h}
539
+ part=${b}
540
+ name=${n}
541
+ value=${l}
542
+ .disabled=${E}
543
+ @change=${R=>this.handleRadioChange(R)}
544
+ @click=${R=>r.matchMax===1?this.handleRadioClick(R):null}
545
+ />
546
+ ${h==="checkbox"&&p?m`
547
+ <svg
548
+ part="checkmark"
549
+ viewBox="0 0 24 24"
550
+ style="position: absolute; width: 20px; height: 20px; top: 2px; left: 2px; pointer-events: none;"
551
+ >
552
+ <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z" fill="white" />
553
+ </svg>
554
+ `:""}
555
+ </div>
556
+ </td>`})}
557
+ </tr>`)}
558
+ </table>
559
+ `:_}
560
+
561
+ <div role="alert" part="message" id="validation-message"></div>
562
+ `}};J.styles=ir,a([u({type:String})],J.prototype,"class",2),a([x()],J.prototype,"_response",2),a([u({type:String,attribute:"response-identifier"})],J.prototype,"responseIdentifier",2),a([x()],J.prototype,"correctOptions",2),J=a([f("qti-match-interaction")],J);var Ie=class extends q{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...q.properties,step:{type:Number,attribute:"step",default:10}}}render(){return m` <slot name="prompt"></slot>
563
+ <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)})}};Ie.styles=[v``],Ie=a([f("qti-media-interaction")],Ie);var sr=v`
564
+ [part='drags'] {
565
+ display: flex;
566
+ align-items: flex-start;
567
+ flex: 1;
568
+ flex-wrap: wrap;
569
+ }
570
+
571
+ [part='drops'] {
572
+ flex: 1;
573
+ display: grid;
574
+ grid-auto-flow: column;
575
+ grid-auto-columns: 1fr;
576
+ }
577
+
578
+ :host([orientation='horizontal']) [part='drags'] {
579
+ flex-direction: row;
580
+ }
581
+ :host([orientation='horizontal']) [part='drops'] {
582
+ grid-auto-flow: column;
583
+ }
584
+ :host([orientation='vertical']) [part='drags'] {
585
+ flex-direction: column;
586
+ }
587
+ :host([orientation='vertical']) [part='drops'] {
588
+ grid-auto-flow: row;
589
+ }
590
+
591
+ [part='drop-list'] {
592
+ display: block;
593
+ flex: 1;
594
+ }
595
+
596
+ [part='container'] {
597
+ display: flex;
598
+ gap: 0.5rem;
599
+ }
600
+ :host(.qti-choices-top) [part='container'] {
601
+ flex-direction: column;
602
+ }
603
+ :host(.qti-choices-bottom) [part='container'] {
604
+ flex-direction: column-reverse;
605
+ }
606
+ :host(.qti-choices-left) [part='container'] {
607
+ flex-direction: row;
608
+ }
609
+ :host(.qti-choices-right) [part='container'] {
610
+ flex-direction: row-reverse;
611
+ }
612
+ `;var W=class extends O(q,"qti-simple-choice","drop-list","slot[part='drags']"){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),m` <slot name="prompt"> </slot>
613
+ <div part="container">
614
+ <slot part="drags"> </slot>
615
+ <div part="drops">
616
+ ${[...Array(this.nrChoices)].map((t,r)=>m`<drop-list role="region" part="drop-list" identifier="droplist${r}"></drop-list>`)}
617
+ </div>
618
+ </div>`}toggleCorrectResponse(e,t){if(this.shadowRoot.querySelectorAll(".correct-option").forEach(r=>r.remove()),t&&e.correctResponse){let s=(Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,c)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let h=l.textContent?.trim();if(!h)return;let g=this.shadowRoot.querySelector(`drop-list[identifier="droplist${c}"]`);if(!g)return;let b=document.createElement("span");b.classList.add("correct-option"),b.textContent=h,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",g.insertAdjacentElement("afterend",b)})}}getValue(e){return e?.map((t,r)=>`${t} droplist${r}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let s=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(o=>o.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};W.styles=sr,a([x()],W.prototype,"nrChoices",2),a([x()],W.prototype,"correctResponses",2),a([x()],W.prototype,"showCorrectResponses",2),a([u({type:String})],W.prototype,"orientation",2),W=a([f("qti-order-interaction")],W);var or=v`
619
+ ::slotted(qti-interaction-markup) {
620
+ display: none;
621
+ }
622
+ `;var T=class extends q{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let r=this.convertQtiVariableJSON(t.params.value);this.response=r,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let n=await r.json();for(let o in n.paths)t&&(n.paths[o]=this.getResolvablePath(n.paths[o],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(r=>this.getResolvablePathString(r,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let s in r)if(r.hasOwnProperty(s)){let n=r[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let s=r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[r]}return t}responseVariablesToQtiVariableJSON(e,t,r){if(t!=="single"){let s={list:{}};return s.list[r]=e,s}else{let s={base:{}};return s.base[r]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(r=>r.identifier===this.responseIdentifier)){let r=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,o=this.responseVariablesToQtiVariableJSON(n,r,s);e[this.responseIdentifier]=o}return e}unescapeHtml(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}unescapeDataAttributes(e){let t={};for(let[r,s]of Object.entries(e))typeof s=="string"?t[r]=this.unescapeHtml(s):t[r]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:r=>{this.pci=r;try{let s=new ResizeObserver(n=>{for(let o of n)o.contentRect&&o.contentRect.height>0&&(this.style.height=`${o.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(r,s,n,o)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let o={},c=(p=>{let h={};Object.entries(p.dataset).forEach(([b,E])=>{b.includes("__")||(h[b]=E)});let g={};return Object.entries(p.dataset).forEach(([b,E])=>{let R=b.split("__");if(R.length>1){let[D,w,le]=R;g[D]=g[D]||{},g[D][w]=g[D][w]||{},g[D][w][le]=E}}),Object.entries(g).forEach(([b,E])=>{h[b]=Object.values(E)}),h})(n);for(let p in c)if(Object.prototype.hasOwnProperty.call(c,p)){let h=c[p];p==="config"?o[p]=JSON.parse(h):o[p]=h}return o})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),r=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${r}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:ne(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let r=t.querySelectorAll("qti-interaction-module");for(let s of r)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(r){throw console.error("RequireJS error:",r),r.requireType==="timeout"&&console.error("Modules that timed out:",r.requireModules),r},t(["require"],r=>{try{r([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),r=this.querySelector("qti-interaction-modules");if(r){let s=r.querySelectorAll("qti-interaction-module");for(let n of s){let o=n.getAttribute("id"),l=n.getAttribute("primary-path"),c=n.getAttribute("fallback-path");if(o&&l){let p=c?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(c,t)):this.getResolvablePath(l,t),h=e.paths[o]||[];e.paths[o]=this.combineRequireResolvePaths(h,p)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return r.concat(s).filter((n,o,l)=>l.indexOf(n)===o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),r=JSON.stringify(this.getFinalRequireShim()),s=`
623
+ font-family: ${e.getPropertyValue("font-family")};
624
+ font-size: ${e.getPropertyValue("font-size")};
625
+ line-height: ${e.getPropertyValue("line-height")};
626
+ font-weight: ${e.getPropertyValue("font-weight")};
627
+ color: ${e.getPropertyValue("color")};
628
+ `;return`<!DOCTYPE html>
629
+ <html lang="en">
630
+ <head>
631
+ <meta charset="utf-8" />
632
+ <title>QTI PCI Container</title>
633
+ <base href="${window.location.origin}" />
634
+ <style>
635
+ body, html {
636
+ margin: 0;
637
+ padding: 0;
638
+ width: 100%;
639
+ height: auto;
640
+ overflow: hidden;
641
+ /* Add the extracted font styles here */
642
+ ${s}
643
+ }
644
+ .qti-customInteraction {
645
+ width: 100%;
646
+ height: 100%;
647
+ }
648
+ #pci-container {
649
+ width: 100%;
650
+ </style>
651
+ <script src="${this.requireJsUrl}"></script>
652
+ <script>
653
+ // Define standard paths and shims
654
+ window.requirePaths = ${t};
655
+
656
+ window.requireShim = ${r};
657
+
658
+ // Single initial RequireJS configuration with error handling
659
+ window.requirejs.config({
660
+ catchError: true,
661
+ waitSeconds: 30,
662
+ paths: window.requirePaths,
663
+ baseUrl: '${this.dataset.baseUrl}',
664
+ shim: window.requireShim,
665
+ onNodeCreated: function(node, config, moduleName, url) {
666
+ console.log('RequireJS creating node for module:', moduleName, 'URL:', url);
667
+
668
+ // Add error handler to script node
669
+ node.addEventListener('error', function(evt) {
670
+ console.error('Script load error for module:', moduleName, 'URL:', url, 'Event:', evt);
671
+ });
672
+ },
673
+ onError: function(err) {
674
+ console.error('RequireJS error:', {
675
+ type: err.requireType,
676
+ modules: err.requireModules,
677
+ error: err
678
+ });
679
+
680
+ if (err.requireType === 'scripterror') {
681
+ console.error('Script error usually indicates a network or CORS issue with:', err.requireModules);
682
+ }
683
+
684
+ // Notify parent window about the error
685
+ window.parent.postMessage({
686
+ source: 'qti-pci-iframe',
687
+ method: 'error',
688
+ params: {
689
+ message: 'RequireJS ' + err.requireType + ' error for modules: ' + err.requireModules,
690
+ details: {
691
+ type: err.requireType,
692
+ modules: err.requireModules,
693
+ error: err.toString()
694
+ }
695
+ }
696
+ }, '*');
697
+ }
698
+ });
699
+
700
+ // PCI Manager for iframe implementation
701
+ window.PCIManager = {
702
+ pciInstance: null,
703
+ container: null,
704
+ customInteractionTypeIdentifier: null,
705
+
706
+ initialize: function(config) {
707
+ this.customInteractionTypeIdentifier = config.customInteractionTypeIdentifier;
708
+ this.container = document.getElementById('pci-container');
709
+ this.container.classList.add('qti-customInteraction');
710
+
711
+ function getResolvablePath(path, basePath) {
712
+ if (Array.isArray(path)) {
713
+ return path.map(p => getResolvablePathString(p, basePath));
714
+ } else {
715
+ return getResolvablePathString(path, basePath);
716
+ }
717
+ }
718
+
719
+ function removeDoubleSlashes(str) {
720
+ return str
721
+ .replace(/([^:\\/])\\/\\/+/g, '$1/')
722
+ .replace(/\\/\\//g, '/')
723
+ .replace('http:/', 'http://')
724
+ .replace('https:/', 'https://');
725
+ }
726
+
727
+ function getResolvablePathString(path, basePath) {
728
+ path = path.replace(/\\.js$/, '');
729
+ return path?.toLocaleLowerCase().startsWith('http') || !basePath
730
+ ? path
731
+ : removeDoubleSlashes(\`\${basePath}/\${path}\`);
732
+ }
733
+
734
+ function combineRequireResolvePaths(path1, path2, baseUrl) {
735
+ path1 = getResolvablePath(path1, baseUrl);
736
+ const path1Array = Array.isArray(path1) ? path1 : [path1];
737
+ if (!path2) {
738
+ return path1Array;
739
+ }
740
+ path2 = getResolvablePath(path2, baseUrl);
741
+ const path2Array = Array.isArray(path2) ? path2 : [path2];
742
+ return path1Array.concat(path2Array).filter((value, index, self) => self.indexOf(value) === index);
743
+ }
744
+
745
+ // Update paths with modules from the config
746
+ if (config.interactionModules && config.interactionModules.length > 0) {
747
+ config.interactionModules.forEach(module => {
748
+ if (module.id && module.primaryPath) {
749
+ const currentPath = window.requirePaths[module.id] || [];
750
+ const currentPaths = Array.isArray(currentPath) ? currentPath : [currentPath];
751
+ const newPath = combineRequireResolvePaths(
752
+ module.primaryPath, module.fallbackPath, config.baseUrl
753
+ );
754
+ window.requirePaths[module.id] = currentPaths.concat(newPath).filter((value, index, self) => self.indexOf(value) === index);
755
+ }
756
+ });
757
+ }
758
+
759
+ // The ONLY other requirejs.config call - with the context for this specific PCI
760
+ window.requirejs.config({
761
+ context: this.customInteractionTypeIdentifier,
762
+ paths: window.requirePaths,
763
+ shim: window.requireShim
764
+ });
765
+
766
+ // Define qtiCustomInteractionContext for the PCI
767
+ define('qtiCustomInteractionContext', () => {
768
+ return {
769
+ register: pciInstance => {
770
+ this.pciInstance = pciInstance;
771
+ // Configure PCI instance
772
+ const pciConfig = {
773
+ properties: this.addHyphenatedKeys(this.unescapeDataAttributes({ ...config.dataAttributes })),
774
+ contextVariables: config.contextVariables || {},
775
+ templateVariables: config.templateVariables || {},
776
+ onready: pciInstance => {
777
+ this.pciInstance = pciInstance;
778
+ this.notifyReady();
779
+ },
780
+ ondone: (pciInstance, response, state, status) => {
781
+ this.notifyInteractionChanged(response);
782
+ },
783
+ responseIdentifier: config.responseIdentifier,
784
+ boundTo: config.boundTo,
785
+ };
786
+
787
+ if (pciInstance.getInstance) {
788
+ pciInstance.getInstance(this.container, pciConfig, undefined);
789
+ } else {
790
+ // TAO custom interaction initialization
791
+ const restoreTAOConfig = (dataset) => {
792
+ const config = {};
793
+ const parseDataAttributes = () => {
794
+ const result = {};
795
+
796
+ // Separate direct attributes from nested ones
797
+ Object.entries(dataset || []).forEach(([key, value]) => {
798
+ if (!key.includes('__')) {
799
+ // Direct attributes (like version)
800
+ result[key] = value;
801
+ }
802
+ });
803
+
804
+ // Parse nested attributes
805
+ const nestedData = {};
806
+
807
+ Object.entries(dataset || []).forEach(([key, value]) => {
808
+ const parts = key.split('__');
809
+ if (parts.length > 1) {
810
+ const [group, index, prop] = parts;
811
+ nestedData[group] = nestedData[group] || {};
812
+ nestedData[group][index] = nestedData[group][index] || {};
813
+ nestedData[group][index][prop] = value;
814
+ }
815
+ });
816
+
817
+ // Convert nested groups to arrays
818
+ Object.entries(nestedData).forEach(([key, group]) => {
819
+ result[key] = Object.values(group);
820
+ });
821
+ return result;
822
+ };
823
+ const data = parseDataAttributes();
824
+ for (const key in data) {
825
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
826
+ const value = data[key];
827
+ if (key === 'config') {
828
+ config[key] = JSON.parse(value);
829
+ } else {
830
+ config[key] = value;
831
+ }
832
+ }
833
+ }
834
+ return config;
835
+ };
836
+ const taoConfig = restoreTAOConfig(config.dataAttributes);
837
+
838
+ this.pciInstance.initialize(
839
+ this.customInteractionTypeIdentifier,
840
+ this.container.firstElementChild || this.container,
841
+ Object.keys(taoConfig).length ? taoConfig : null
842
+ );
843
+ }
844
+ },
845
+ notifyReady: () => {
846
+ // Notify parent that the PCI is ready
847
+ window.parent.postMessage({
848
+ source: 'qti-pci-iframe',
849
+ method: 'pciReady'
850
+ }, '*');
851
+ }
852
+ };
853
+ });
854
+
855
+ // Load the PCI module
856
+ this.loadModule(config.module);
857
+ },
858
+
859
+ loadModule: function(modulePath) {
860
+ try {
861
+ // Get the context-specific require
862
+ const contextRequire = window.requirejs.config({
863
+ context: this.customInteractionTypeIdentifier
864
+ });
865
+ contextRequire(['require'], require => {
866
+ // Now load the actual module
867
+ require([modulePath], () => {
868
+ }, err => {
869
+ console.error('Error loading module:', modulePath, err);
870
+ this.notifyError('Module load error: ' + err.toString());
871
+ });
872
+ });
873
+ } catch (error) {
874
+ console.error('Exception in loadModule:', modulePath);
875
+ console.error(error);
876
+ this.notifyError('Error in require call: ' + error.toString());
877
+ }
878
+ },
879
+
880
+ notifyReady: function() {
881
+ window.parent.postMessage({
882
+ source: 'qti-pci-iframe',
883
+ method: 'iframeReady'
884
+ }, '*');
885
+ },
886
+
887
+ notifyInteractionChanged: function(response) {
888
+ window.parent.postMessage({
889
+ source: 'qti-pci-iframe',
890
+ method: 'interactionChanged',
891
+ params: { value: response }
892
+ }, '*');
893
+ },
894
+
895
+ notifyError: function(message) {
896
+ console.error('PCI Error:', message);
897
+ window.parent.postMessage({
898
+ source: 'qti-pci-iframe',
899
+ method: 'error',
900
+ params: { message: message }
901
+ }, '*');
902
+ },
903
+
904
+ setMarkup: function(markupHtml) {
905
+ this.container = document.getElementById('pci-container');
906
+ this.container.innerHTML = markupHtml;
907
+ },
908
+
909
+ addHyphenatedKeys: function(properties) {
910
+ const updatedProperties = { ...properties };
911
+ for (const key in properties) {
912
+ if (Object.prototype.hasOwnProperty.call(properties, key)) {
913
+ const hyphenatedKey = key.replace(/[A-Z]/g, char => \`-\${char.toLowerCase()}\`);
914
+ updatedProperties[hyphenatedKey] = properties[key];
915
+ }
916
+ }
917
+ return updatedProperties;
918
+ },
919
+ unescapeDataAttributes: function(obj) {
920
+ const unescaped = {};
921
+ for (const [key, value] of Object.entries(obj)) {
922
+ if (typeof value === 'string') {
923
+ unescaped[key] = value
924
+ .replace(/&amp;/g, '&')
925
+ .replace(/&lt;/g, '<')
926
+ .replace(/&gt;/g, '>')
927
+ .replace(/&quot;/g, '"')
928
+ .replace(/&#x27;/g, "'")
929
+ .replace(/&#x2F;/g, '/')
930
+ .replace(/&#x60;/g, '\`')
931
+ .replace(/&#x3D;/g, '=');
932
+ } else {
933
+ unescaped[key] = value;
934
+ }
935
+ }
936
+ return unescaped;
937
+ },
938
+ };
939
+
940
+ // Set up message listener for communication with parent
941
+ window.addEventListener('message', function(event) {
942
+ const { data } = event;
943
+
944
+ // Ensure the message is from our parent
945
+ if (!data || data.source !== 'qti-portable-custom-interaction') {
946
+ return;
947
+ }
948
+
949
+ switch(data.method) {
950
+ case 'initialize':
951
+ PCIManager.initialize(data.params);
952
+ break;
953
+
954
+ case 'setMarkup':
955
+ PCIManager.setMarkup(data.params);
956
+ break;
957
+
958
+ case 'setBoundTo':
959
+ // Handle setting boundTo
960
+ break;
961
+
962
+ case 'setProperties':
963
+ // Handle setting properties
964
+ break;
965
+ }
966
+ });
967
+
968
+ // Notify parent that iframe has loaded
969
+ window.addEventListener('load', function() {
970
+ window.parent.postMessage({
971
+ source: 'qti-pci-iframe',
972
+ method: 'iframeLoaded'
973
+ }, '*');
974
+ });
975
+ let resizeTimeout;
976
+ let previousHeight = 0;
977
+ const notifyResize = () => {
978
+ const container = document.getElementById('pci-container');
979
+ const newHeight = container.scrollHeight + 100;
980
+ if (newHeight !== previousHeight) {
981
+ previousHeight = newHeight;
982
+ clearTimeout(resizeTimeout);
983
+ resizeTimeout = setTimeout(() => {
984
+ window.parent.postMessage({
985
+ source: 'qti-pci-iframe',
986
+ method: 'resize',
987
+ height: newHeight,
988
+ width: container.scrollWidth
989
+ }, '*');
990
+ }, 100); // Adjust debounce time as needed
991
+ }
992
+ };
993
+
994
+ function setupResizeObserver() {
995
+ const container = document.getElementById('pci-container');
996
+ if (!container || !(container instanceof Element)) {
997
+ console.warn('ResizeObserver: document.container is not an Element');
998
+ return;
999
+ }
1000
+
1001
+ const resizeObserver = new ResizeObserver(() => {
1002
+ notifyResize();
1003
+ });
1004
+
1005
+ resizeObserver.observe(container);
1006
+ }
1007
+
1008
+ // Run setup once DOM is ready
1009
+ if (document.readyState === 'loading') {
1010
+ document.addEventListener('DOMContentLoaded', () => {
1011
+ notifyResize(); // initial resize
1012
+ setupResizeObserver();
1013
+ });
1014
+ } else {
1015
+ notifyResize();
1016
+ setupResizeObserver();
1017
+ }
1018
+
1019
+ window.addEventListener('load', () => {
1020
+ notifyResize();
1021
+ });
1022
+ let lastResponseStr = '';
1023
+ setInterval(() => {
1024
+ if (PCIManager.pciInstance && PCIManager.pciInstance.getResponse) {
1025
+ const response = PCIManager.pciInstance.getResponse();
1026
+ const responseStr = JSON.stringify(response);
1027
+
1028
+ if (responseStr !== lastResponseStr) {
1029
+ lastResponseStr = responseStr;
1030
+ window.parent.postMessage({
1031
+ source: 'qti-pci-iframe',
1032
+ method: 'interactionChanged',
1033
+ params: { value: response }
1034
+ }, '*');
1035
+ }
1036
+ }
1037
+ }, 500); // Check every 500ms
1038
+ </script>
1039
+ </head>
1040
+ <body>
1041
+ <div id="pci-container"></div>
1042
+ </body>
1043
+ </html>`}toggleCorrectResponse(e,t){this.correctResponse=t?e?.correctResponse:e.cardinality==="single"?"":[];let r=`correct-response-container-${this.responseIdentifier}`,s=this.parentElement?.querySelectorAll(`#${r}`);if(s&&s.forEach(h=>{h.remove()}),t)this.disable();else{this.enable();return}if(!t||!e?.correctResponse)return;let n=document.createElement("div");n.id=r,n.className="pci-correct-response-container",n.style.position="relative",n.style.marginTop="20px",n.style.border="2px solid green",n.style.padding="16px",n.style.borderRadius="4px",n.style.backgroundColor="rgba(0, 128, 0, 0.05)";let o=document.createElement("div");o.textContent="Correct Response:",o.style.fontWeight="bold",o.style.marginBottom="10px",o.style.color="green",n.appendChild(o);let l=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(h=>{h.name!=="id"&&h.name!=="response-identifier"&&l.setAttribute(h.name,h.value)});let c=this.responseIdentifier;l.responseIdentifier=`${c}-correct`,Array.from(this.children).forEach(h=>{let g=h.cloneNode(!0);l.appendChild(g)});let p=e.correctResponse;if(this.useIframe){let h=l.connectedCallback;l.connectedCallback=function(){h.call(this);let g=()=>this._iframeLoaded?(setTimeout(()=>{let b=this.responseVariablesToQtiVariableJSON(p,e.cardinality,e.baseType);this.sendMessageToIframe("setBoundTo",{[c]:b}),this.sendMessageToIframe("setState",{state:"review"})},1e3),!0):!1;if(!g()){let b=setInterval(()=>{g()&&clearInterval(b)},100);setTimeout(()=>{clearInterval(b)},1e4)}}}else{let h=l.register;l.register=function(g){h.call(this,g);let b=()=>{if(this.pci&&typeof this.pci.setResponse=="function"){let E=this.responseVariablesToQtiVariableJSON(p,e.cardinality,e.baseType);return this.pci.setResponse(E),typeof this.pci.setState=="function"&&this.pci.setState("review"),!0}return!1};setTimeout(()=>{if(!b()){let E=setInterval(()=>{b()&&clearInterval(E)},200);setTimeout(()=>{clearInterval(E)},5e3)}},500)}}l.style.pointerEvents="none",n.appendChild(l),this.after(n)}disable(){if(this._previousState={pointerEvents:this.style.pointerEvents,position:this.style.position},this.useIframe&&this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this._previousState&&(this._previousState.pointerEvents&&(this.style.pointerEvents=this._previousState.pointerEvents),this._previousState.position&&(this.style.position=this._previousState.position),this._previousState=null),this.useIframe&&this.sendMessageToIframe("setState",{state:"interacting"})}render(){return m`
1044
+ <slot></slot>
1045
+ ${this._errorMessage?m`<div style="color:red">
1046
+ <h1>Error</h1>
1047
+ ${this._errorMessage}
1048
+ </div>`:""}
1049
+ `}};T.styles=[or,v`
1050
+ :host {
1051
+ display: block;
1052
+ width: 100%;
1053
+ min-height: 50px;
1054
+ }
1055
+ .qti-customInteraction {
1056
+ display: block;
1057
+ width: 100%;
1058
+ min-height: 50px;
1059
+ }
1060
+ `],a([u({type:String,attribute:"module"})],T.prototype,"module",2),a([u({type:String,attribute:"custom-interaction-type-identifier"})],T.prototype,"customInteractionTypeIdentifier",2),a([u({type:String,attribute:"data-require-paths"})],T.prototype,"requirePathsJson",2),a([u({type:String,attribute:"data-require-shim"})],T.prototype,"requireShimJson",2),a([u({type:String,attribute:"data-require-js-url"})],T.prototype,"requireJsUrl",2),a([u({type:String,attribute:"data-base-url"})],T.prototype,"baseUrl",2),a([u({type:Boolean,attribute:"data-use-iframe"})],T.prototype,"useIframe",2),a([u({type:Boolean,attribute:"data-use-default-shims"})],T.prototype,"useDefaultShims",2),a([u({type:Boolean,attribute:"data-use-default-paths"})],T.prototype,"useDefaultPaths",2),a([x()],T.prototype,"_errorMessage",2),a([S({context:k,subscribe:!0}),x()],T.prototype,"context",2),a([x()],T.prototype,"response",2),T=a([f("qti-portable-custom-interaction")],T);var Ke=class extends y{render(){return m`<slot></slot>`}};Ke.styles=[v`
1061
+ :host {
1062
+ display: block;
1063
+ }
1064
+ ::slotted(img) {
1065
+ position: absolute;
1066
+ cursor: move;
1067
+ user-select: none;
1068
+ left: 50%;
1069
+ transform: translateX(-50%);
1070
+ }
1071
+ `];customElements.define("qti-position-object-interaction",Ke);var $e=class extends y{render(){return m`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(i){i.preventDefault();let e=i.clientX-this.startX,t=i.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=i.clientX,this.startY=i.clientY}firstUpdated(i){super.firstUpdated(i),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)}};$e.styles=[v`
1072
+ :host {
1073
+ display: inline-block;
1074
+ position: relative;
1075
+ }
1076
+ `],$e=a([f("qti-position-object-stage")],$e);var nr="important",fr=" !"+nr,pt=Z(class extends ue{constructor(d){if(super(d),d.type!==de.ATTRIBUTE||d.name!=="style"||d.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(d){return Object.keys(d).reduce((i,e)=>{let t=d[e];return t==null?i:i+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(d,[i]){let{style:e}=d.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(i)),this.render(i);for(let t of this.ft)i[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in i){let r=i[t];if(r!=null){this.ft.add(t);let s=typeof r=="string"&&r.endsWith(fr);t.includes("-")||s?e.setProperty(t,s?r.slice(0,-11):r,s?nr:""):e[t]=r}}return ce}});var X=class extends q{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=[];this._correctAreas=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOrginal=0;this._imageHeightOrginal=0;this._onImageClick=e=>{if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),r=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${r.toFixed()} ${s.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||this.response.length<this.maxChoices)&&(this.response=[...this.response,n]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}toggleCorrectResponse(e,t){if(!t){this._correctAreas=[];return}let r=e.areaMapping,s=[];if(!r||r.areaMapEntries.length===0)if(e.correctResponse){let n=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];if(n.length===0||n.find(o=>o.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(o=>({shape:"circle",coords:o.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=r.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(r=>{let s=r.dataset.coord,n=r.dataset.shape;s&&n&&re(n,s.split(",").map(o=>+o),t,r)}))}render(){return m` <slot name="prompt"></slot>
1077
+ <point-container>
1078
+ ${xe(this.response?.filter(e=>e)||[],e=>e,(e,t)=>{let[r,s]=e.split(" ").map(Number),n=r/(this._imageWidthOrginal||1)*100,o=s/(this._imageHeightOrginal||1)*100,l=16,c=l/(this._imageWidthOrginal||1)*100,p=l/(this._imageHeightOrginal||1)*100;return m`
1079
+ <button
1080
+ part="point"
1081
+ style=${pt({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${n}%`,top:`${o}%`,width:`min(${c}%, 1rem)`,height:`min(${p}%, 1rem)`,minWidth:`min(${c}%, 1rem)`,minHeight:`min(${p}%, 1rem)`,borderRadius:"50%",background:"red"})}
1082
+ aria-label="Remove point at ${e}"
1083
+ @click=${h=>{h.stopPropagation(),this.response=(this.response||[]).filter((g,b)=>b!==t),this.saveResponse(this.response)}}
1084
+ ></button>
1085
+ `})}
1086
+ ${xe(this._correctAreas?.filter(e=>e)||[],e=>e,(e,t)=>m`<div
1087
+ style=${pt({position:"absolute",pointerEvents:"none",backgroundColor:"var(--qti-correct)",opacity:"0.5"})}
1088
+ data-coord="${e.coords}"
1089
+ alt=${`correct-response-${t+1}`}
1090
+ data-shape="${e.shape}"
1091
+ ></div>`)}
1092
+ <slot></slot>
1093
+ </point-container>`}reset(){this.response=null}validate(){return this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}calculateScale(){this._imageWidthOrginal=this._imgElement.getAttribute("width")?parseFloat(this._imgElement.getAttribute("width")):this._imgElement.naturalWidth,this._imageHeightOrginal=this._imgElement.getAttribute("height")?parseFloat(this._imgElement.getAttribute("height")):this._imgElement.naturalHeight;let e=this._imgElement.getBoundingClientRect();this._scaleX=e.width===0?1:this._imageWidthOrginal/e.width,this._scaleY=e.height===0?1:this._imageHeightOrginal/e.height}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?(this.calculateScale(),this._imgElement.addEventListener("click",this._onImageClick)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};X.styles=[v`
1094
+ :host {
1095
+ display: block;
1096
+ }
1097
+ point-container {
1098
+ display: block;
1099
+ position: relative;
1100
+ width: fit-content;
1101
+ }
1102
+
1103
+ ::slotted(img) {
1104
+ max-width: 100%;
1105
+ height: auto;
1106
+ display: block;
1107
+ }
1108
+ `],a([u({type:Number,attribute:"max-choices"})],X.prototype,"maxChoices",2),a([u({type:Number,attribute:"min-choices"})],X.prototype,"minChoices",2),a([x()],X.prototype,"response",2),a([x()],X.prototype,"_correctAreas",2),X=a([f("qti-select-point-interaction")],X);var Y=class extends P(y,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return m`<div part="ch">
1109
+ <div part="cha"></div>
1110
+ </div>
1111
+ ${this.marker?m`<div id="label">${this.marker}</div>`:_}
1112
+ <slot part="slot"></slot>`}};Y.styles=v`
1113
+ :host {
1114
+ display: flex;
1115
+ align-items: center;
1116
+ user-select: none;
1117
+ }
1118
+ slot {
1119
+ width: 100%;
1120
+ display: flex;
1121
+ align-items: center;
1122
+ }
1123
+ [part='ch'] {
1124
+ display: flex;
1125
+ flex-shrink: 0;
1126
+ align-items: center;
1127
+ justify-content: center;
1128
+ }
1129
+ `,a([u({type:String,attribute:"template-identifier"})],Y.prototype,"templateIdentifier",2),a([u({type:String,attribute:"show-hide"})],Y.prototype,"showHide",2),a([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Y.prototype,"fixed",2),a([u({type:String,attribute:!1})],Y.prototype,"marker",2),Y=a([f("qti-simple-choice")],Y);var ar=v`
1130
+ :host {
1131
+ display: block;
1132
+ --show-bounds: true;
1133
+ --show-ticks: true;
1134
+ --show-value: true;
1135
+ }
1136
+
1137
+ [part='slider'] {
1138
+ margin-left: 2rem; /* mx-8 */
1139
+ margin-right: 2rem;
1140
+ padding-bottom: 1rem; /* pb-4 */
1141
+ padding-top: 1.25rem; /* pt-5 */
1142
+ }
1143
+
1144
+ [part='bounds'] {
1145
+ display: flex;
1146
+ width: 100%;
1147
+ justify-content: space-between;
1148
+ margin-bottom: 0.5rem; /* mb-2 */
1149
+ }
1150
+
1151
+ [part='ticks'] {
1152
+ margin-left: 0.125rem; /* mx-0.5 */
1153
+ margin-right: 0.125rem;
1154
+ margin-bottom: 0.25rem; /* mb-1 */
1155
+ height: 0.5rem; /* h-2 */
1156
+ background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
1157
+ 0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
1158
+ }
1159
+
1160
+ [part='rail'] {
1161
+ display: flex;
1162
+ align-items: center;
1163
+ box-sizing: border-box;
1164
+ height: 0.375rem; /* h-1.5 */
1165
+ width: 100%;
1166
+ cursor: pointer;
1167
+ border-radius: 9999px; /* rounded-full */
1168
+ border: 1px solid #d1d5db; /* border-gray-300 */
1169
+ background-color: #e5e7eb; /* bg-gray-200 */
1170
+ }
1171
+
1172
+ [part='knob'] {
1173
+ background-color: var(--qti-bg-active);
1174
+ border: 2px solid var(--qti-border-active);
1175
+ position: relative;
1176
+ height: 1rem; /* h-4 */
1177
+ width: 1rem; /* w-4 */
1178
+ transform-origin: center;
1179
+ transform: translateX(-50%);
1180
+ cursor: pointer;
1181
+ border-radius: 9999px; /* rounded-full */
1182
+ left: var(--value-percentage);
1183
+ }
1184
+ [part='knob-correct'] {
1185
+ background-color: var(--qti-correct-light);
1186
+ border: 2px solid var(--qti-correct);
1187
+ position: relative;
1188
+ height: 1rem; /* h-4 */
1189
+ width: 1rem; /* w-4 */
1190
+ transform-origin: center;
1191
+ transform: translateX(-50%);
1192
+ cursor: pointer;
1193
+ border-radius: 9999px; /* rounded-full */
1194
+ left: var(--value-percentage-correct);
1195
+ }
1196
+
1197
+ [part='value'] {
1198
+ position: absolute;
1199
+ bottom: 2rem; /* bottom-8 */
1200
+ left: 0.5rem; /* left-2 */
1201
+ transform: translateX(-50%);
1202
+ cursor: pointer;
1203
+ border-radius: 0.25rem; /* rounded */
1204
+ background-color: #f3f4f6; /* bg-gray-100 */
1205
+ padding: 0.25rem 0.5rem; /* px-2 py-1 */
1206
+ text-align: center;
1207
+ color: #6b7280; /* text-gray-500 */
1208
+ }
1209
+ `;var G=class extends q{constructor(){super(...arguments);this._value=0;this._correctResponseNumber=null;this.min=0;this.max=100;this.step=1}validate(){return!0}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this._value.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}toggleCorrectResponse(e,t){if(t){this._correctResponse=e.correctResponse.toString();let r=parseFloat(e.correctResponse.toString());if(isNaN(r))this._correctResponseNumber=null;else{this._correctResponseNumber=r;let s=(this._correctResponseNumber-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this._correctResponseNumber=null;this.requestUpdate()}_updateValue(e){let t=this._value;if(this._value=Math.min(this.max,Math.max(this.min,e)),this._value===t)return;let r=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${r}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return m`
1210
+ <slot name="prompt"></slot>
1211
+ <div id="slider" part="slider">
1212
+ <div id="bounds" part="bounds">
1213
+ <div>${this.min}</div>
1214
+ <div>${this.max}</div>
1215
+ </div>
1216
+
1217
+ <div id="ticks" part="ticks"></div>
1218
+
1219
+ <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
1220
+ <div id="knob" part="knob">
1221
+ <div id="value" part="value">${this.response}</div>
1222
+ </div>
1223
+
1224
+ ${this._correctResponseNumber!==null?m`
1225
+ <div id="knob-correct" part="knob-correct">
1226
+ <div id="value" part="value">${this._correctResponseNumber}</div>
1227
+ </div>
1228
+ `:null}
1229
+ </div>
1230
+ </div>
1231
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.pageX),r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=s=>this._onDrag(s.touches[0].pageX),r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",r)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),r=e-t.left,s=Math.min(1,Math.max(0,r/t.width)),n=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(n)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};G.styles=ar,a([pe("#rail")],G.prototype,"_rail",2),a([u({type:Number,attribute:"lower-bound"})],G.prototype,"min",2),a([u({type:Number,attribute:"upper-bound"})],G.prototype,"max",2),a([u({type:Number,attribute:"step"})],G.prototype,"step",2),G=a([f("qti-slider-interaction")],G);var lr=()=>new ut,ut=class{},dt=new WeakMap,Wa=Z(class extends jt{render(d){return _}update(d,[i]){let e=i!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=i,this.ht=d.options?.host,this.rt(this.ct=d.element)),_}rt(d){if(this.isConnected||(d=void 0),typeof this.G=="function"){let i=this.ht??globalThis,e=dt.get(i);e===void 0&&(e=new WeakMap,dt.set(i,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,d),d!==void 0&&this.G.call(this.ht,d)}else this.G.value=d}get lt(){return typeof this.G=="function"?dt.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var cr=v`
1232
+ :host {
1233
+ display: inline-block;
1234
+ }
1235
+
1236
+ :host(.qti-input-width-1) [part='input'] {
1237
+ width: 1.1rem;
1238
+ min-width: 1.1rem;
1239
+ }
1240
+
1241
+ :host(.qti-input-width-2) [part='input'] {
1242
+ width: 2.3rem;
1243
+ min-width: 2.3rem;
1244
+ }
1245
+
1246
+ :host(.qti-input-width-3) [part='input'] {
1247
+ width: 3.3rem;
1248
+ min-width: 3.3rem;
1249
+ }
1250
+
1251
+ :host(.qti-input-width-4) [part='input'] {
1252
+ width: 4.2rem;
1253
+ min-width: 4.2rem;
1254
+ }
1255
+
1256
+ :host(.qti-input-width-6) [part='input'] {
1257
+ width: 6.6rem;
1258
+ min-width: 6.6rem;
1259
+ }
1260
+
1261
+ :host(.qti-input-width-10) [part='input'] {
1262
+ width: 8rem;
1263
+ min-width: 8rem;
1264
+ }
1265
+
1266
+ :host(.qti-input-width-15) [part='input'] {
1267
+ width: 12rem;
1268
+ min-width: 12rem;
1269
+ }
1270
+
1271
+ :host(.qti-input-width-20) [part='input'] {
1272
+ width: 17rem;
1273
+ min-width: 17rem;
1274
+ }
1275
+
1276
+ :host(.qti-input-width-25) [part='input'] {
1277
+ width: 20rem;
1278
+ min-width: 20rem;
1279
+ }
1280
+
1281
+ :host(.qti-input-width-30) [part='input'] {
1282
+ width: 24rem;
1283
+ min-width: 24rem;
1284
+ }
1285
+
1286
+ :host(.qti-input-width-35) [part='input'] {
1287
+ width: 28rem;
1288
+ min-width: 28rem;
1289
+ }
1290
+
1291
+ :host(.qti-input-width-40) [part='input'] {
1292
+ width: 32rem;
1293
+ min-width: 32rem;
1294
+ }
1295
+
1296
+ :host(.qti-input-width-45) [part='input'] {
1297
+ width: 36rem;
1298
+ min-width: 36rem;
1299
+ }
1300
+
1301
+ :host(.qti-input-width-50) [part='input'] {
1302
+ width: 40rem;
1303
+ min-width: 40rem;
1304
+ }
1305
+
1306
+ :host(.qti-input-width-72) [part='input'] {
1307
+ width: 57rem;
1308
+ min-width: 57rem;
1309
+ }
1310
+
1311
+ :host {
1312
+ position: relative;
1313
+ }
1314
+ input {
1315
+ anchor-name: --text-entry-input;
1316
+ z-index: 100;
1317
+ position: relative;
1318
+ }
1319
+
1320
+ [part='correct'] {
1321
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
1322
+ background-color: var(--qti-bg);
1323
+ z-index: 0;
1324
+ position: absolute;
1325
+ left: 0;
1326
+ right: 0;
1327
+ position-anchor: --text-entry-input;
1328
+ bottom: anchor(top);
1329
+ left: anchor(left);
1330
+ /* opacity: 1; */
1331
+ transition: all 1s;
1332
+
1333
+ @starting-style {
1334
+ display: grid;
1335
+ /* opacity: 0; */
1336
+ bottom: 0;
1337
+ }
1338
+ }
1339
+ `;var $=class extends q{constructor(){super(...arguments);this.inputRef=lr();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleCorrectResponse(e,t){if(t&&e.correctResponse){let r=e.correctResponse.toString();this._correctResponse=r}else this._correctResponse=null}render(){return m`
1340
+ <input
1341
+ part="input"
1342
+ name="${this.responseIdentifier}"
1343
+ spellcheck="false"
1344
+ autocomplete="off"
1345
+ @blur="${e=>{this.reportValidity()}}"
1346
+ @keydown="${e=>e.stopImmediatePropagation()}"
1347
+ @keyup="${this.textChanged}"
1348
+ @change="${this.textChanged}"
1349
+ type="${this.patternMask=="[0-9]*"?"number":"text"}"
1350
+ placeholder="${H(this.placeholderText?this.placeholderText:void 0)}"
1351
+ .value="${this.response}"
1352
+ pattern="${H(this.patternMask?this.patternMask:void 0)}"
1353
+ maxlength=${1e3}
1354
+ ?disabled="${this.disabled}"
1355
+ ?readonly="${this.readonly}"
1356
+ />
1357
+ ${this._correctResponse?m`<div part="correct">${this._correctResponse}</div>`:_}
1358
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};$.styles=cr,a([u({type:Number,attribute:"expected-length"})],$.prototype,"expectedLength",2),a([u({type:String,attribute:"pattern-mask"})],$.prototype,"patternMask",2),a([u({type:String,attribute:"placeholder-text"})],$.prototype,"placeholderText",2),a([u({type:String,attribute:"data-patternmask-message"})],$.prototype,"dataPatternmaskMessage",2),a([x()],$.prototype,"response",2),a([pe("input")],$.prototype,"_input",2),a([M("response",{waitUntilFirstUpdate:!0})],$.prototype,"_handleValueChange",2),$=a([f("qti-text-entry-interaction")],$);var Ne=class extends q{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...q.properties}}render(){return m`
1359
+ <div>
1360
+ <slot name="prompt"></slot>
1361
+ <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
1362
+ </div>
1363
+ `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.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((t,r)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>r(s.error),s.readAsDataURL(e)})}};Ne.styles=[v`
1364
+ :host {
1365
+ display: block;
1366
+ margin: 1em 0;
1367
+ }
1368
+ input[type='file'] {
1369
+ display: block;
1370
+ margin-top: 0.5em;
1371
+ }
1372
+ `],Ne=a([f("qti-upload-interaction")],Ne);var pr=v`
1373
+ :host {
1374
+ display: block;
1375
+ }
1376
+ `;var He=class extends y{render(){return m`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};He.styles=pr,He=a([f("qti-item-body")],He);var Oe=class extends y{render(){return m`<slot></slot>`}process(){let i=new ht,e=[...this.children];i.process(e)}};Oe.styles=[v`
1377
+ :host {
1378
+ display: none;
1379
+ }
1380
+ `],Oe=a([f("qti-outcome-processing")],Oe);var ht=class{process(i){for(let e of i)e.process()}};var Ze=class extends y{render(){return m`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Ze=a([f("qti-prompt")],Ze);var dr=`<qti-response-processing>
1381
+ <qti-response-condition>
1382
+ <qti-response-if>
1383
+ <qti-match>
1384
+ <qti-variable identifier="RESPONSE"></qti-variable>
1385
+ <qti-correct identifier="RESPONSE"></qti-correct>
1386
+ </qti-match>
1387
+ <qti-set-outcome-value identifier="SCORE">
1388
+ <qti-base-value base-type="float">1</qti-base-value>
1389
+ </qti-set-outcome-value>
1390
+ </qti-response-if>
1391
+ <qti-response-else>
1392
+ <qti-set-outcome-value identifier="SCORE">
1393
+ <qti-base-value base-type="float">0</qti-base-value>
1394
+ </qti-set-outcome-value>
1395
+ </qti-response-else>
1396
+ </qti-response-condition>
1397
+ </qti-response-processing>`,ur=`<qti-response-processing>
1398
+ <qti-response-condition>
1399
+ <qti-response-if>
1400
+ <qti-is-null>
1401
+ <qti-variable identifier="RESPONSE"></qti-variable>
1402
+ </qti-is-null>
1403
+ <qti-set-outcome-value identifier="SCORE">
1404
+ <qti-base-value base-type="float">0.0</qti-base-value>
1405
+ </qti-set-outcome-value>
1406
+ </qti-response-if>
1407
+ <qti-response-else>
1408
+ <qti-set-outcome-value identifier="SCORE">
1409
+ <qti-map-response identifier="RESPONSE"> </qti-map-response>
1410
+ </qti-set-outcome-value>
1411
+ </qti-response-else>
1412
+ </qti-response-condition>
1413
+ </qti-response-processing>`,hr=`<qti-response-processing>
1414
+ <qti-response-condition>
1415
+ <qti-response-if>
1416
+ <qti-is-null>
1417
+ <qti-variable identifier="RESPONSE"></qti-variable>
1418
+ </qti-is-null>
1419
+ <qti-set-outcome-value identifier="SCORE">
1420
+ <qti-base-value base-type="float">0</qti-base-value>
1421
+ </qti-set-outcome-value>
1422
+ </qti-response-if>
1423
+ <qti-response-else>
1424
+ <qti-set-outcome-value identifier="SCORE">
1425
+ <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
1426
+ </qti-set-outcome-value>
1427
+ </qti-response-else>
1428
+ </qti-response-condition>
1429
+ </qti-response-processing>`;var Pe=class extends y{render(){return m`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(i){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(ur).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(hr).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(dr).firstElementChild.firstElementChild);break}}}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};Pe.styles=[v`
1430
+ :host {
1431
+ display: none;
1432
+ }
1433
+ `],Pe=a([f("qti-response-processing")],Pe);var F=class extends y{render(){return m`<slot></slot>`}process(){throw new Error("Not implemented")}};F=a([f("qti-rule")],F);var ze=class extends F{get childExpression(){return this.firstElementChild}process(){let i=this.getAttribute("identifier"),e=this.context.variables.find(r=>r.identifier===i)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:qe(t)}})),t)}};a([u({type:String})],ze.prototype,"identifier",2),a([S({context:k,subscribe:!0}),x()],ze.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ze);var mt=class extends F{render(){return m`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",mt);var ft=class extends F{process(){let i=this.getAttribute("identifier");if(!i){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let r=new gt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:i,value:this.formatValue(r)}}))}formatValue(i){return Array.isArray(i)?i.map(qe):i!==null?qe(i):null}},gt=class{constructor(i){this.expression=i}process(){let i=this.expression.calculate()??null;return i===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(i)?i.map(e=>e.value?e.value:e):i}};customElements.define("qti-set-outcome-value",ft);var Fe=class extends y{render(){return m`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Fe);var Ue=class extends Fe{calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Ue);var bt=class extends Ue{render(){return m`${super.render()}`}};customElements.define("qti-response-else-if",bt);var Qe=class extends gr(N){calculate(){return this.calculateChildren(Array.from(this.children))}};Qe=a([f("qti-and")],Qe);function gr(d){return class extends d{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.calculate(),o=!1;if(typeof n=="string")if(n==="true")o=!0;else if(n==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(o=n);return o}).every(r=>typeof r=="boolean"&&r)}}}var et=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};a([u({type:String,attribute:"base-type"})],et.prototype,"baseType",2);customElements.define("qti-base-value",et);var vt=class extends N{getResult(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,s=t.value;return r.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}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",vt);var yt=class extends C{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let i=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===i)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",yt);var tt=class extends C{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(r.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};a([u({type:String})],tt.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",tt);var A=class{static isPointInArea(i,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[r,s]=i.split(" ").map(Number),[n,...o]=e.split(","),l=o.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[c,p,h]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((r-c)**2+(s-p)**2)<=h}case"rect":{let[c,p,h,g]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):r>=c&&r<=h&&s>=p&&s<=g}case"ellipse":{let[c,p,h,g]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(r-c)**2/h**2,E=(s-p)**2/g**2;return b+E<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let p=0;p<l.length;p+=2)c.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:r,y:s},c)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(i,e){let t=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let n=e[r].x,o=e[r].y,l=e[s].x,c=e[s].y;o>i.y!=c>i.y&&i.x<(l-n)*(i.y-o)/(c-o)+n&&(t=!t)}return t}static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),s=parseInt(e,10);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),s=parseFloat(e);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),s=e.split(" ").sort();if(r.length===2&&s.length===2)return t==="pair"&&(r.sort(),s.sort()),r.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var rt=class extends C{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):A.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};a([u({type:String})],rt.prototype,"toleranceMode",2);customElements.define("qti-equal",rt);var xt=class extends C{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",xt);var Et=class extends N{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",Et);var Ct=class extends C{getResult(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Ct);var qt=class extends C{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",qt);var wt=class extends N{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",wt);var it=class extends C{getResult(){let i=this.context.variables.find(s=>s.identifier===this.identifier);if(!i||!i.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=i.mapping,t=Array.isArray(i.value)?i.value:[i.value],r=0;for(let s of t){let n=e.mapEntries.filter(l=>i.baseType==="string"&&!l.caseSensitive?A.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),i.baseType):A.compareSingleValues(l.mapKey,s,i.baseType)),o=n.reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,n.length>0?n[0]:{mapKey:null,mappedValue:null});o===null||o.mappedValue==null?r+=e.defaultValue:r+=o.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(r=Math.max(e.lowerBound,r)),e?.upperBound!==null&&e?.upperBound!==void 0&&(r=Math.min(e.upperBound,r)),r}};a([u({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var st=class extends C{getResult(){let i=this.context.variables.find(n=>n.identifier===this.identifier);if(!i)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=i.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(i.value)?i.value:[i.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let r=0,s=new Set;for(let n of t)for(let o of e.areaMapEntries){if(s.has(o.coords))continue;A.isPointInArea(n,`${o.shape},${o.coords}`,i.baseType)&&(r+=o.mappedValue??0,s.add(o.coords))}return s.size<t.length&&(r+=e.defaultValue),e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};a([u({type:String})],st.prototype,"identifier",2);customElements.define("qti-map-response-point",st);var Rt=class d extends C{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return d.match(e,t)}return console.error("unexpected number of children in match"),null}static match(i,e){if(i.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(i.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):A.compareSingleValues(i.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;for(let t=0;t<i.value.length;t++)if(!A.compareSingleValues(e.value[t],i.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(i.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(i.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){let s=null,n=[...i.value];for(let o of n)if(A.compareSingleValues(r,o,e.baseType)){s=o;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",Rt);var Mt=class extends C{getResult(){let i=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=i;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",Mt);var Tt=class extends C{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Tt);var St=class extends C{render(){return m`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",St);var _t=class extends N{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate(),s=!1;if(typeof r=="string")if(r==="true")s=!0;else if(r==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(s=r);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",_t);var kt=class extends C{getResult(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",kt);var je=class extends y{render(){let i=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return i===null?_:m`${JSON.stringify(i,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};a([u({type:String})],je.prototype,"identifier",2),a([S({context:k,subscribe:!0}),x()],je.prototype,"context",2);customElements.define("qti-printed-variable",je);var At=class extends C{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseFloat(r.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",At);var ot=class extends br(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function br(d){return class extends d{calculateChildren(e){let t=e.map(r=>{if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=r.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(r=>r===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ot);var nt=class extends C{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return A.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};a([u({type:String,attribute:"case-sensitive"})],nt.prototype,"caseSensitive",2);customElements.define("qti-string-match",nt);var Lt=class extends C{constructor(){super(),this._expression=new Dt(Array.from(this.children))}getResult(){return this._expression.calculate()}},Dt=class{constructor(i){this.expressions=i}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Lt);var Vt=class extends C{getResult(){let i=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===i).value}};customElements.define("qti-variable",Vt);var It=class extends C{getResult(){let i=this.getVariables();if(i.length===1){let e=i[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",It);var $t=class extends C{getResult(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):i[0].baseType!==i[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}}};customElements.define("qti-delete",$t);var Be=class extends C{getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let i=this.getVariables()[0];if(!i)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(i.cardinality==="ordered"){let t=Array.isArray(i.value)?i.value:[i.value];return i.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(i){let e=this.context.variables.find(t=>t.identifier===i)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};a([u({type:String})],Be.prototype,"n",2),Be=a([f("qti-index")],Be);var at=class extends y{render(){return m`<slot></slot>`}};at=a([f("qti-content-body")],at);var U=class extends y{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return m`<slot></slot>`}};U.styles=v`
1434
+ :host {
1435
+ display: block;
1436
+ }
1437
+ `,a([u({type:String})],U.prototype,"id",2),a([u({type:String})],U.prototype,"use",2),a([u({type:String})],U.prototype,"view",2),a([u({type:String,attribute:"class"})],U.prototype,"classNames",2),a([M("classNames",{waitUntilFirstUpdate:!0})],U.prototype,"handleclassNamesChange",1),U=a([f("qti-rubric-block")],U);var lt=class extends y{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(r=>r.text()).then(r=>{let s=this.minifyCss(r);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(r=>{console.error("Failed to load stylesheet:",r)}),this.textContent!==null&&this.textContent.trim()!==""){let r=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,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()}};lt=a([f("qti-stylesheet")],lt);var oe=class extends y{render(){return m`<slot></slot>`}defaultValues(i){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML.trim());return t.length>1||i.cardinality==="multiple"||i.cardinality==="ordered"?t:t[0]}};oe=a([f("qti-variabledeclaration")],oe);var j=class extends oe{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return m`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let s=parseFloat(r.getAttribute("source-value")),n=parseFloat(r.getAttribute("target-value"));(isNaN(s)||isNaN(n))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,n)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),(e.value===null||e.value==null)&&(e.baseType==="integer"||e.baseType==="float")&&(e.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};j.styles=[v`
1438
+ :host {
1439
+ display: none;
1440
+ }
1441
+ `],a([u({type:String,attribute:"base-type"})],j.prototype,"baseType",2),a([u({type:String,attribute:"external-scored"})],j.prototype,"externalScored",2),a([u({type:String})],j.prototype,"identifier",2),a([u({type:String})],j.prototype,"cardinality",2),a([S({context:k,subscribe:!0}),x()],j.prototype,"itemContext",2),j=a([f("qti-outcome-declaration")],j);var K=class extends oe{render(){let i=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return m`${JSON.stringify(i,null,2)}`}connectedCallback(){super.connectedCallback();let i={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};i.value=this.defaultValues(i),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:i}}))}get correctResponse(){let i,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)i=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){i=[];for(let r=0;r<t.length;r++)i.push(t[r].textContent.trim()),t[r].remove()}}return i}get mapping(){let i=this.querySelector("qti-mapping"),e=parseFloat(i?.getAttribute("lower-bound")),t=parseFloat(i?.getAttribute("upper-bound"));return{defaultValue:Number(i?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(i?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!0}))}}get areaMapping(){let i=this.querySelector("qti-area-mapping"),e=Number(i?.getAttribute("default-value"))||0,t=parseFloat(i?.getAttribute("lower-bound")),r=parseFloat(i?.getAttribute("upper-bound")),s=Array.from(i?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(r)?null:r,areaMapEntries:s}}};K.styles=[v`
1442
+ :host {
1443
+ display: none;
1444
+ }
1445
+ `],a([u({type:String,attribute:"base-type"})],K.prototype,"baseType",2),a([u({type:String})],K.prototype,"identifier",2),a([u({type:String})],K.prototype,"cardinality",2),a([S({context:k,subscribe:!0}),x()],K.prototype,"itemContext",2),K=a([f("qti-response-declaration")],K);export{V as a,me as b,Ye as c,Ce as d,we as e,Re as f,Me as g,Te as h,fe as i,ge as j,B as k,te as l,L as m,be as n,Se as o,ve as p,ye as q,z as r,_e as s,ke as t,ae as u,Ae as v,Ge as w,Le as x,ie as y,Ve as z,se as A,J as B,Ie as C,W as D,T as E,Ke as F,$e as G,X as H,Y as I,G as J,$ as K,Ne as L,He as M,Oe as N,ht as O,Ze as P,Pe as Q,F as R,ze as S,mt as T,ft as U,gt as V,Fe as W,Ue as X,bt as Y,Qe as Z,gr as _,et as $,vt as aa,yt as ba,tt as ca,rt as da,xt as ea,Et as fa,Ct as ga,qt as ha,wt as ia,it as ja,st as ka,Rt as la,Mt as ma,Tt as na,St as oa,_t as pa,kt as qa,je as ra,At as sa,ot as ta,br as ua,nt as va,Lt as wa,Dt as xa,Vt as ya,It as za,$t as Aa,Be as Ba,at as Ca,U as Da,lt as Ea,j as Fa,K as Ga};
1446
+ /*! Bundled license information:
1447
+
1448
+ lit-html/node/directives/if-defined.js:
1449
+ (**
1450
+ * @license
1451
+ * Copyright 2018 Google LLC
1452
+ * SPDX-License-Identifier: BSD-3-Clause
1453
+ *)
1454
+
1455
+ lit-html/node/directives/repeat.js:
1456
+ (**
1457
+ * @license
1458
+ * Copyright 2017 Google LLC
1459
+ * SPDX-License-Identifier: BSD-3-Clause
1460
+ *)
1461
+
1462
+ lit-html/node/directives/unsafe-html.js:
1463
+ (**
1464
+ * @license
1465
+ * Copyright 2017 Google LLC
1466
+ * SPDX-License-Identifier: BSD-3-Clause
1467
+ *)
1468
+
1469
+ lit-html/node/directives/style-map.js:
1470
+ (**
1471
+ * @license
1472
+ * Copyright 2018 Google LLC
1473
+ * SPDX-License-Identifier: BSD-3-Clause
1474
+ *)
1475
+
1476
+ lit-html/node/directives/ref.js:
1477
+ (**
1478
+ * @license
1479
+ * Copyright 2020 Google LLC
1480
+ * SPDX-License-Identifier: BSD-3-Clause
1481
+ *)
1482
+ */