@pie-element/multiple-choice 13.2.1-next.2 → 13.2.1-next.29

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 (243) hide show
  1. package/CHANGELOG.json +1972 -0
  2. package/CHANGELOG.md +2716 -0
  3. package/LICENSE.md +5 -0
  4. package/PRINT.md +35 -0
  5. package/README.md +56 -0
  6. package/choice.png +0 -0
  7. package/configure/CHANGELOG.json +1387 -0
  8. package/configure/CHANGELOG.md +2064 -0
  9. package/configure/lib/defaults.js +203 -0
  10. package/configure/lib/defaults.js.map +1 -0
  11. package/configure/lib/index.js +202 -0
  12. package/configure/lib/index.js.map +1 -0
  13. package/configure/lib/main.js +484 -0
  14. package/configure/lib/main.js.map +1 -0
  15. package/configure/lib/utils.js +18 -0
  16. package/configure/lib/utils.js.map +1 -0
  17. package/configure/package.json +22 -0
  18. package/controller/CHANGELOG.json +527 -0
  19. package/controller/CHANGELOG.md +1401 -0
  20. package/controller/lib/defaults.js +33 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +288 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +15 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +15 -0
  27. package/docs/config-schema.json +2993 -0
  28. package/docs/config-schema.json.md +2217 -0
  29. package/docs/demo/config.js +8 -0
  30. package/docs/demo/generate.js +61 -0
  31. package/docs/demo/index.html +1 -0
  32. package/docs/demo/session.js +7 -0
  33. package/docs/pie-schema.json +1332 -0
  34. package/docs/pie-schema.json.md +1015 -0
  35. package/lib/choice-input.js +383 -0
  36. package/lib/choice-input.js.map +1 -0
  37. package/lib/choice.js +192 -0
  38. package/lib/choice.js.map +1 -0
  39. package/lib/feedback-tick.js +134 -0
  40. package/lib/feedback-tick.js.map +1 -0
  41. package/lib/index.js +402 -0
  42. package/lib/index.js.map +1 -0
  43. package/lib/main.js +63 -0
  44. package/lib/main.js.map +1 -0
  45. package/lib/multiple-choice.js +397 -0
  46. package/lib/multiple-choice.js.map +1 -0
  47. package/lib/print.js +94 -0
  48. package/lib/print.js.map +1 -0
  49. package/lib/session-updater.js +37 -0
  50. package/lib/session-updater.js.map +1 -0
  51. package/module/configure.js +1 -0
  52. package/module/controller.js +3045 -0
  53. package/module/demo.js +86 -0
  54. package/module/element.js +1 -0
  55. package/module/index.html +21 -0
  56. package/module/manifest.json +14 -0
  57. package/module/print-demo.js +124 -0
  58. package/module/print.html +18 -0
  59. package/module/print.js +1 -0
  60. package/package.json +25 -55
  61. package/dist/author/defaults.d.ts +0 -205
  62. package/dist/author/defaults.js +0 -151
  63. package/dist/author/index.d.ts +0 -26
  64. package/dist/author/index.js +0 -119
  65. package/dist/author/main.d.ts +0 -34
  66. package/dist/author/main.js +0 -287
  67. package/dist/author/utils.d.ts +0 -9
  68. package/dist/author/utils.js +0 -7
  69. package/dist/controller/defaults.d.ts +0 -35
  70. package/dist/controller/defaults.js +0 -29
  71. package/dist/controller/index.d.ts +0 -65
  72. package/dist/controller/index.js +0 -124
  73. package/dist/controller/utils.d.ts +0 -10
  74. package/dist/controller/utils.js +0 -8
  75. package/dist/delivery/choice-input.d.ts +0 -44
  76. package/dist/delivery/choice-input.js +0 -272
  77. package/dist/delivery/choice.d.ts +0 -20
  78. package/dist/delivery/choice.js +0 -105
  79. package/dist/delivery/feedback-tick.d.ts +0 -20
  80. package/dist/delivery/feedback-tick.js +0 -104
  81. package/dist/delivery/index.d.ts +0 -37
  82. package/dist/delivery/index.js +0 -214
  83. package/dist/delivery/main.d.ts +0 -31
  84. package/dist/delivery/main.js +0 -51
  85. package/dist/delivery/multiple-choice.d.ts +0 -61
  86. package/dist/delivery/multiple-choice.js +0 -244
  87. package/dist/delivery/session-updater.d.ts +0 -10
  88. package/dist/delivery/session-updater.js +0 -9
  89. package/dist/index.d.ts +0 -1
  90. package/dist/index.iife.d.ts +0 -8
  91. package/dist/index.iife.js +0 -148
  92. package/dist/index.js +0 -2
  93. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +0 -6
  94. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +0 -16
  95. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +0 -16
  96. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +0 -6
  97. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +0 -16
  98. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +0 -6
  99. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +0 -6
  100. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_SetCache.js +0 -11
  101. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +0 -14
  102. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +0 -5
  103. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +0 -5
  104. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +0 -6
  105. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_apply.js +0 -12
  106. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +0 -7
  107. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +0 -10
  108. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +0 -15
  109. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +0 -7
  110. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arraySome.js +0 -7
  111. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignMergeValue.js +0 -8
  112. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +0 -10
  113. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +0 -8
  114. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +0 -8
  115. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +0 -8
  116. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +0 -12
  117. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +0 -57
  118. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +0 -14
  119. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseFor.js +0 -5
  120. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +0 -9
  121. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +0 -10
  122. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +0 -9
  123. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqual.js +0 -8
  124. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsEqualDeep.js +0 -30
  125. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +0 -9
  126. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +0 -11
  127. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +0 -9
  128. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +0 -11
  129. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +0 -12
  130. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +0 -13
  131. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseMerge.js +0 -19
  132. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseMergeDeep.js +0 -31
  133. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseRest.js +0 -9
  134. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseSetToString.js +0 -14
  135. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +0 -7
  136. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +0 -8
  137. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +0 -8
  138. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cacheHas.js +0 -6
  139. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
  140. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +0 -10
  141. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +0 -8
  142. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +0 -8
  143. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +0 -8
  144. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +0 -8
  145. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +0 -8
  146. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +0 -14
  147. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +0 -8
  148. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +0 -8
  149. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +0 -5
  150. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_createAssigner.js +0 -15
  151. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_createBaseFor.js +0 -12
  152. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +0 -10
  153. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalArrays.js +0 -35
  154. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalByTag.js +0 -35
  155. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_equalObjects.js +0 -32
  156. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +0 -4
  157. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +0 -9
  158. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +0 -9
  159. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +0 -8
  160. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +0 -9
  161. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +0 -5
  162. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +0 -14
  163. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +0 -10
  164. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +0 -11
  165. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +0 -23
  166. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +0 -6
  167. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +0 -7
  168. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +0 -7
  169. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +0 -13
  170. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +0 -9
  171. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +0 -9
  172. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +0 -8
  173. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +0 -33
  174. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +0 -9
  175. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +0 -8
  176. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIterateeCall.js +0 -12
  177. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +0 -7
  178. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +0 -11
  179. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +0 -8
  180. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +0 -6
  181. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +0 -9
  182. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +0 -8
  183. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +0 -7
  184. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +0 -8
  185. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +0 -13
  186. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +0 -8
  187. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +0 -7
  188. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +0 -7
  189. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +0 -8
  190. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapToArray.js +0 -9
  191. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +0 -5
  192. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +0 -5
  193. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +0 -8
  194. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +0 -9
  195. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +0 -7
  196. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +0 -8
  197. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overRest.js +0 -13
  198. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +0 -5
  199. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_safeGet.js +0 -6
  200. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheAdd.js +0 -7
  201. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setCacheHas.js +0 -6
  202. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToArray.js +0 -9
  203. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_setToString.js +0 -6
  204. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_shortOut.js +0 -14
  205. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +0 -7
  206. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +0 -7
  207. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +0 -6
  208. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +0 -6
  209. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +0 -16
  210. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +0 -15
  211. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +0 -8
  212. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +0 -8
  213. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/constant.js +0 -8
  214. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +0 -50
  215. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/defaults.js +0 -16
  216. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +0 -6
  217. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/identity.js +0 -6
  218. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +0 -10
  219. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +0 -4
  220. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +0 -8
  221. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLikeObject.js +0 -8
  222. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +0 -6
  223. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEmpty.js +0 -21
  224. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isEqual.js +0 -7
  225. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +0 -11
  226. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +0 -7
  227. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +0 -7
  228. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +0 -7
  229. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +0 -6
  230. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isPlainObject.js +0 -14
  231. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +0 -7
  232. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +0 -9
  233. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +0 -7
  234. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +0 -9
  235. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +0 -9
  236. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/merge.js +0 -8
  237. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +0 -7
  238. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +0 -6
  239. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +0 -6
  240. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +0 -19
  241. package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toPlainObject.js +0 -8
  242. package/dist/print/index.d.ts +0 -15
  243. package/dist/print/index.js +0 -44
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
8
+ * functionalities are not defined yet - the value for those can belong to
9
+ * model or to configure
10
+ */
11
+ var _default = exports.default = {
12
+ model: {
13
+ choiceMode: 'checkbox',
14
+ choicePrefix: 'letters',
15
+ choices: [],
16
+ choicesLayout: 'vertical',
17
+ feedbackEnabled: false,
18
+ gridColumns: 2,
19
+ lockChoiceOrder: true,
20
+ partialScoring: true,
21
+ prompt: '',
22
+ promptEnabled: true,
23
+ rationale: '',
24
+ rationaleEnabled: true,
25
+ scoringType: 'auto',
26
+ studentInstructionsEnabled: true,
27
+ teacherInstructions: '',
28
+ teacherInstructionsEnabled: true,
29
+ toolbarEditorPosition: 'bottom',
30
+ selectedAnswerBackgroundColor: 'initial',
31
+ keyboardEventsEnabled: false
32
+ },
33
+ configuration: {
34
+ baseInputConfiguration: {
35
+ h3: {
36
+ disabled: true
37
+ },
38
+ audio: {
39
+ disabled: false
40
+ },
41
+ video: {
42
+ disabled: false
43
+ },
44
+ image: {
45
+ disabled: false
46
+ },
47
+ textAlign: {
48
+ disabled: true
49
+ },
50
+ showParagraphs: {
51
+ disabled: false
52
+ },
53
+ separateParagraphs: {
54
+ disabled: true
55
+ }
56
+ },
57
+ choices: {
58
+ inputConfiguration: {
59
+ audio: {
60
+ disabled: false
61
+ },
62
+ video: {
63
+ disabled: false
64
+ },
65
+ image: {
66
+ disabled: false
67
+ }
68
+ }
69
+ },
70
+ spellCheck: {
71
+ label: 'Spellcheck',
72
+ settings: false,
73
+ enabled: true
74
+ },
75
+ choicesLayout: {
76
+ settings: false,
77
+ label: 'Choices Layout'
78
+ },
79
+ gridColumns: {
80
+ label: 'Grid columns'
81
+ },
82
+ answerChoiceCount: 0,
83
+ addChoiceButton: {
84
+ settings: true,
85
+ label: 'Add a Choice'
86
+ },
87
+ choiceMode: {
88
+ settings: true,
89
+ label: 'Response Type'
90
+ },
91
+ choicePrefix: {
92
+ settings: true,
93
+ label: 'Choice Labels'
94
+ },
95
+ deleteChoice: {
96
+ settings: true
97
+ },
98
+ feedback: {
99
+ settings: true,
100
+ label: 'Feedback'
101
+ },
102
+ prompt: {
103
+ settings: true,
104
+ label: 'Prompt',
105
+ inputConfiguration: {
106
+ audio: {
107
+ disabled: false
108
+ },
109
+ video: {
110
+ disabled: false
111
+ },
112
+ image: {
113
+ disabled: false
114
+ }
115
+ },
116
+ required: false
117
+ },
118
+ lockChoiceOrder: {
119
+ settings: true,
120
+ label: 'Lock Choice Order'
121
+ },
122
+ partialScoring: {
123
+ settings: false,
124
+ label: 'Allow Partial Scoring'
125
+ },
126
+ rationale: {
127
+ settings: true,
128
+ label: 'Rationale',
129
+ inputConfiguration: {
130
+ audio: {
131
+ disabled: true
132
+ },
133
+ video: {
134
+ disabled: true
135
+ },
136
+ image: {
137
+ disabled: false
138
+ }
139
+ },
140
+ required: false
141
+ },
142
+ scoringType: {
143
+ settings: false,
144
+ label: 'Scoring Type'
145
+ },
146
+ studentInstructions: {
147
+ settings: false,
148
+ label: 'Student Instructions'
149
+ },
150
+ teacherInstructions: {
151
+ settings: true,
152
+ label: 'Teacher Instructions',
153
+ inputConfiguration: {
154
+ audio: {
155
+ disabled: false
156
+ },
157
+ video: {
158
+ disabled: false
159
+ },
160
+ image: {
161
+ disabled: false
162
+ }
163
+ },
164
+ required: false
165
+ },
166
+ toolbarEditorPosition: {
167
+ settings: false,
168
+ label: 'Toolbar Editor Position'
169
+ },
170
+ minAnswerChoices: 2,
171
+ maxAnswerChoices: 5,
172
+ maxImageWidth: {
173
+ teacherInstructions: 300,
174
+ prompt: 300,
175
+ rationale: 636,
176
+ choices: 900
177
+ },
178
+ maxImageHeight: {
179
+ teacherInstructions: 300,
180
+ prompt: 300,
181
+ rationale: 300,
182
+ choices: 300
183
+ },
184
+ withRubric: {
185
+ settings: false,
186
+ label: 'Add Rubric'
187
+ },
188
+ mathMlOptions: {
189
+ mmlOutput: false,
190
+ mmlEditing: false
191
+ },
192
+ language: {
193
+ settings: false,
194
+ label: 'Specify Language',
195
+ enabled: false
196
+ },
197
+ languageChoices: {
198
+ label: 'Language Choices',
199
+ options: []
200
+ }
201
+ }
202
+ };
203
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":["_default","exports","default","model","choiceMode","choicePrefix","choices","choicesLayout","feedbackEnabled","gridColumns","lockChoiceOrder","partialScoring","prompt","promptEnabled","rationale","rationaleEnabled","scoringType","studentInstructionsEnabled","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition","selectedAnswerBackgroundColor","keyboardEventsEnabled","configuration","baseInputConfiguration","h3","disabled","audio","video","image","textAlign","showParagraphs","separateParagraphs","inputConfiguration","spellCheck","label","settings","enabled","answerChoiceCount","addChoiceButton","deleteChoice","feedback","required","studentInstructions","minAnswerChoices","maxAnswerChoices","maxImageWidth","maxImageHeight","withRubric","mathMlOptions","mmlOutput","mmlEditing","language","languageChoices","options"],"sources":["../src/defaults.js"],"sourcesContent":["/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType\n * functionalities are not defined yet - the value for those can belong to\n * model or to configure\n */\nexport default {\n model: {\n choiceMode: 'checkbox',\n choicePrefix: 'letters',\n choices: [],\n choicesLayout: 'vertical',\n feedbackEnabled: false,\n gridColumns: 2,\n lockChoiceOrder: true,\n partialScoring: true,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n selectedAnswerBackgroundColor: 'initial',\n keyboardEventsEnabled: false,\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n choices: {\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n choicesLayout: {\n settings: false,\n label: 'Choices Layout',\n },\n gridColumns: {\n label: 'Grid columns',\n },\n answerChoiceCount: 0,\n addChoiceButton: {\n settings: true,\n label: 'Add a Choice',\n },\n choiceMode: {\n settings: true,\n label: 'Response Type',\n },\n choicePrefix: {\n settings: true,\n label: 'Choice Labels',\n },\n deleteChoice: {\n settings: true,\n },\n feedback: {\n settings: true,\n label: 'Feedback',\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n inputConfiguration: {\n audio: { disabled: true },\n video: { disabled: true },\n image: { disabled: false },\n },\n required: false,\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type',\n },\n studentInstructions: {\n settings: false,\n label: 'Student Instructions',\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n required: false,\n },\n toolbarEditorPosition: {\n settings: false,\n label: 'Toolbar Editor Position',\n },\n minAnswerChoices: 2,\n maxAnswerChoices: 5,\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 636,\n choices: 900,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n choices: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n },\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAHA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAIe;EACbC,KAAK,EAAE;IACLC,UAAU,EAAE,UAAU;IACt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,KAAK,EAAE;IACT,CAAC;IACDQ,mBAAmB,EAAE;MACnBP,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE;IACT,CAAC;IACDjB,mBAAmB,EAAE;MACnBkB,QAAQ,EAAE,IAAI;MACdD,KAAK,EAAE,sBAAsB;MAC7BF,kBAAkB,EAAE;QAClBN,KAAK,EAAE;UAAED,QAAQ,EAAE;QAAM,CAAC;QAC1BE,KAAK,EAAE;UAAEF,QAAQ,EAAE;QAAM,CAAC;QAC1BG,KAAK,EAAE;UAAEH,QAAQ,EAAE;QAAM;MAC3B,CAAC;MACDgB,QAAQ,EAAE;IACZ,CAAC;IACDtB,qBAAqB,EAAE;MACrBgB,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE;IACT,CAAC;IACDS,gBAAgB,EAAE,CAAC;IACnBC,gBAAgB,EAAE,CAAC;IACnBC,aAAa,EAAE;MACb5B,mBAAmB,EAAE,GAAG;MACxBN,MAAM,EAAE,GAAG;MACXE,SAAS,EAAE,GAAG;MACdR,OAAO,EAAE;IACX,CAAC;IACDyC,cAAc,EAAE;MACd7B,mBAAmB,EAAE,GAAG;MACxBN,MAAM,EAAE,GAAG;MACXE,SAAS,EAAE,GAAG;MACdR,OAAO,EAAE;IACX,CAAC;IACD0C,UAAU,EAAE;MACVZ,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE;IACT,CAAC;IACDc,aAAa,EAAE;MACbC,SAAS,EAAE,KAAK;MAChBC,UAAU,EAAE;IACd,CAAC;IACDC,QAAQ,EAAE;MACRhB,QAAQ,EAAE,KAAK;MACfD,KAAK,EAAE,kBAAkB;MACzBE,OAAO,EAAE;IACX,CAAC;IACDgB,eAAe,EAAE;MACflB,KAAK,EAAE,kBAAkB;MACzBmB,OAAO,EAAE;IACX;EACF;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _client = require("react-dom/client");
11
+ var _debug = _interopRequireDefault(require("debug"));
12
+ var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
13
+ var _main = _interopRequireDefault(require("./main"));
14
+ var _configUi = require("@pie-lib/config-ui");
15
+ var _lodashEs = require("lodash-es");
16
+ var _defaults = _interopRequireDefault(require("./defaults"));
17
+ const log = (0, _debug.default)('multiple-choice:configure');
18
+ const generateFormattedChoices = (choices, choiceCount = 0) => {
19
+ if (!choices || choices.length === 0) {
20
+ let formattedChoices = [];
21
+ for (let i = 0; i < choiceCount; i++) {
22
+ formattedChoices.push({
23
+ value: `${i}`,
24
+ label: '',
25
+ feedback: {
26
+ type: 'none',
27
+ value: ''
28
+ }
29
+ });
30
+ }
31
+ return formattedChoices;
32
+ }
33
+ return choices;
34
+ };
35
+ const prepareCustomizationObject = (config, model) => {
36
+ const configuration = (0, _lodashEs.defaults)(config, _defaults.default.configuration);
37
+ return {
38
+ configuration,
39
+ model: {
40
+ ...model,
41
+ choices: generateFormattedChoices(model && model.choices || [], configuration && configuration.answerChoiceCount)
42
+ }
43
+ };
44
+ };
45
+ class MultipleChoice extends HTMLElement {
46
+ constructor() {
47
+ super();
48
+ this._root = null;
49
+ this._reactContainer = null;
50
+ this._model = MultipleChoice.createDefaultModel();
51
+ this._configuration = _defaults.default.configuration;
52
+ this.onModelChanged = this.onModelChanged.bind(this);
53
+ this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
54
+ }
55
+ set model(s) {
56
+ this._model = MultipleChoice.createDefaultModel(s);
57
+ this._render();
58
+ }
59
+ set configuration(c) {
60
+ const info = prepareCustomizationObject(c, this._model);
61
+ this.onModelChanged(info.model);
62
+ const newConfiguration = {
63
+ ..._defaults.default.configuration,
64
+ ...info.configuration
65
+ };
66
+ this._configuration = newConfiguration;
67
+
68
+ // if language:enabled is true, then the corresponding default item model should include a language value;
69
+ // if it is false, then the language field should be omitted from the item model.
70
+ // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
71
+ // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
72
+ if (newConfiguration?.language?.enabled) {
73
+ if (newConfiguration?.languageChoices?.options?.length) {
74
+ this._model.language = newConfiguration?.languageChoices.options[0].value;
75
+ }
76
+ } else if (newConfiguration.language.settings && this._model.language) {
77
+ this._configuration.language.enabled = true;
78
+ if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
79
+ this._configuration.languageChoices.options = [];
80
+ }
81
+
82
+ // check if the language is already included in the languageChoices.options array
83
+ // and if not, then add it.
84
+ if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
85
+ this._configuration.languageChoices.options.push({
86
+ value: this._model.language,
87
+ label: this._model.language
88
+ });
89
+ }
90
+ } else {
91
+ delete this._model.language;
92
+ }
93
+ this._render();
94
+ }
95
+ set disableSidePanel(s) {
96
+ this._disableSidePanel = s;
97
+ this._render();
98
+ }
99
+ dispatchModelUpdated(reset) {
100
+ const resetValue = !!reset;
101
+ this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, resetValue));
102
+ }
103
+ onModelChanged(m, reset) {
104
+ this._model = {
105
+ ...this._model,
106
+ ...m
107
+ };
108
+ this._render();
109
+ this.dispatchModelUpdated(reset);
110
+ }
111
+ onConfigurationChanged(c) {
112
+ this._configuration = prepareCustomizationObject(c, this._model).configuration;
113
+ if (this._model) {
114
+ this.onModelChanged(this._model);
115
+ }
116
+ this._render();
117
+ }
118
+
119
+ /** @param {done, progress, file} handler */
120
+ insertImage(handler) {
121
+ this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
122
+ }
123
+ onDeleteImage(src, done) {
124
+ this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
125
+ }
126
+ insertSound(handler) {
127
+ this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
128
+ }
129
+ onDeleteSound(src, done) {
130
+ this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
131
+ }
132
+ _render() {
133
+ log('_render - Starting render');
134
+ log('_render - Model:', this._model ? 'present' : 'missing');
135
+ log('_render - Configuration:', this._configuration ? 'present' : 'missing');
136
+ log('_render - Root exists:', !!this._root);
137
+ try {
138
+ let element = /*#__PURE__*/_react.default.createElement(_main.default, {
139
+ model: this._model,
140
+ configuration: this._configuration,
141
+ onModelChanged: this.onModelChanged,
142
+ onConfigurationChanged: this.onConfigurationChanged,
143
+ disableSidePanel: this._disableSidePanel,
144
+ imageSupport: {
145
+ add: this.insertImage.bind(this),
146
+ delete: this.onDeleteImage.bind(this)
147
+ },
148
+ uploadSoundSupport: {
149
+ add: this.insertSound.bind(this),
150
+ delete: this.onDeleteSound.bind(this)
151
+ }
152
+ });
153
+ if (!this._root) {
154
+ log('_render - Creating React container');
155
+
156
+ // Create a container div for React to render into
157
+ this._reactContainer = document.createElement('div');
158
+ this._reactContainer.className = 'pie-configure-wrapper';
159
+ this.appendChild(this._reactContainer);
160
+ log('_render - Creating new React root');
161
+ this._root = (0, _client.createRoot)(this._reactContainer);
162
+ log('_render - React root created successfully');
163
+ }
164
+ log('_render - Calling root.render()');
165
+ this._root.render(element);
166
+ log('_render - Render completed successfully');
167
+ } catch (error) {
168
+ console.error('❌ [multiple-choice-configure] Render error:', error);
169
+ console.error('Error stack:', error.stack);
170
+ throw error;
171
+ }
172
+ }
173
+ connectedCallback() {
174
+ log('connectedCallback - Component connected to DOM');
175
+ log('connectedCallback - Model:', this._model ? 'present' : 'missing');
176
+ log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');
177
+ }
178
+ disconnectedCallback() {
179
+ log('disconnectedCallback - Component disconnected from DOM');
180
+ if (this._root) {
181
+ log('disconnectedCallback - Unmounting React root');
182
+ this._root.unmount();
183
+ this._root = null;
184
+ }
185
+ if (this._reactContainer) {
186
+ this._reactContainer = null;
187
+ }
188
+ }
189
+ }
190
+ exports.default = MultipleChoice;
191
+ (0, _defineProperty2.default)(MultipleChoice, "createDefaultModel", (model = {}) => {
192
+ const normalizedModel = _configUi.choiceUtils.normalizeChoices({
193
+ ..._defaults.default.model,
194
+ ...model,
195
+ choices: generateFormattedChoices(model && model.choices || [])
196
+ });
197
+
198
+ // This is used for offering support for old models which have the property "verticalMode"
199
+ normalizedModel.choicesLayout = model.choicesLayout || model.verticalMode === false && 'horizontal' || _defaults.default.model.choicesLayout;
200
+ return normalizedModel;
201
+ });
202
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_debug","_pieConfigureEvents","_main","_configUi","_lodashEs","_defaults","log","debug","generateFormattedChoices","choices","choiceCount","length","formattedChoices","i","push","value","label","feedback","type","prepareCustomizationObject","config","model","configuration","defaults","sensibleDefaults","answerChoiceCount","MultipleChoice","HTMLElement","constructor","_root","_reactContainer","_model","createDefaultModel","_configuration","onModelChanged","bind","onConfigurationChanged","s","_render","c","info","newConfiguration","language","enabled","languageChoices","options","settings","find","option","disableSidePanel","_disableSidePanel","dispatchModelUpdated","reset","resetValue","dispatchEvent","ModelUpdatedEvent","m","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","delete","uploadSoundSupport","document","className","appendChild","createRoot","render","error","console","stack","connectedCallback","disconnectedCallback","unmount","exports","default","_defineProperty2","normalizedModel","utils","normalizeChoices","choicesLayout","verticalMode"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\nimport {\n DeleteImageEvent,\n InsertImageEvent,\n ModelUpdatedEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './main';\nimport { choiceUtils as utils } from '@pie-lib/config-ui';\nimport { defaults } from 'lodash-es';\n\nimport sensibleDefaults from './defaults';\n\nconst log = debug('multiple-choice:configure');\n\nconst generateFormattedChoices = (choices, choiceCount = 0) => {\n if (!choices || choices.length === 0) {\n let formattedChoices = [];\n\n for (let i = 0; i < choiceCount; i++) {\n formattedChoices.push({\n value: `${i}`,\n label: '',\n feedback: {\n type: 'none',\n value: '',\n },\n });\n }\n\n return formattedChoices;\n }\n\n return choices;\n};\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, sensibleDefaults.configuration);\n\n return {\n configuration,\n model: {\n ...model,\n choices: generateFormattedChoices(\n (model && model.choices) || [],\n configuration && configuration.answerChoiceCount,\n ),\n },\n };\n};\n\nexport default class MultipleChoice extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const normalizedModel = utils.normalizeChoices({\n ...sensibleDefaults.model,\n ...model,\n choices: generateFormattedChoices((model && model.choices) || []),\n });\n\n // This is used for offering support for old models which have the property \"verticalMode\"\n normalizedModel.choicesLayout =\n model.choicesLayout || (model.verticalMode === false && 'horizontal') || sensibleDefaults.model.choicesLayout;\n\n return normalizedModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._reactContainer = null;\n this._model = MultipleChoice.createDefaultModel();\n this._configuration = sensibleDefaults.configuration;\n this.onModelChanged = this.onModelChanged.bind(this);\n this.onConfigurationChanged = this.onConfigurationChanged.bind(this);\n }\n\n set model(s) {\n this._model = MultipleChoice.createDefaultModel(s);\n\n this._render();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n\n const newConfiguration = {\n ...sensibleDefaults.configuration,\n ...info.configuration,\n };\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n set disableSidePanel(s) {\n this._disableSidePanel = s;\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged(m, reset) {\n this._model = {\n ...this._model,\n ...m,\n };\n this._render();\n\n this.dispatchModelUpdated(reset);\n }\n\n onConfigurationChanged(c) {\n this._configuration = prepareCustomizationObject(c, this._model).configuration;\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this._render();\n }\n\n /** @param {done, progress, file} handler */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n log('_render - Starting render');\n log('_render - Model:', this._model ? 'present' : 'missing');\n log('_render - Configuration:', this._configuration ? 'present' : 'missing');\n log('_render - Root exists:', !!this._root);\n\n try {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n disableSidePanel: this._disableSidePanel,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n log('_render - Creating React container');\n\n // Create a container div for React to render into\n this._reactContainer = document.createElement('div');\n this._reactContainer.className = 'pie-configure-wrapper';\n this.appendChild(this._reactContainer);\n\n log('_render - Creating new React root');\n this._root = createRoot(this._reactContainer);\n log('_render - React root created successfully');\n }\n\n log('_render - Calling root.render()');\n this._root.render(element);\n log('_render - Render completed successfully');\n } catch (error) {\n console.error('❌ [multiple-choice-configure] Render error:', error);\n console.error('Error stack:', error.stack);\n throw error;\n }\n }\n\n connectedCallback() {\n log('connectedCallback - Component connected to DOM');\n log('connectedCallback - Model:', this._model ? 'present' : 'missing');\n log('connectedCallback - Configuration:', this._configuration ? 'present' : 'missing');\n }\n\n disconnectedCallback() {\n log('disconnectedCallback - Component disconnected from DOM');\n if (this._root) {\n log('disconnectedCallback - Unmounting React root');\n this._root.unmount();\n this._root = null;\n }\n if (this._reactContainer) {\n this._reactContainer = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA,MAAMQ,GAAG,GAAG,IAAAC,cAAK,EAAC,2BAA2B,CAAC;AAE9C,MAAMC,wBAAwB,GAAGA,CAACC,OAAO,EAAEC,WAAW,GAAG,CAAC,KAAK;EAC7D,IAAI,CAACD,OAAO,IAAIA,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACpC,IAAIC,gBAAgB,GAAG,EAA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