@doenet/doenetml 0.7.27-dev.712 → 0.7.27-dev.713

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 (113) hide show
  1. package/{AnswerResponseButton-CoJgVZoz.js → AnswerResponseButton-BxnI9k31.js} +2 -2
  2. package/{ClickTarget-B3N2i5Am.js → ClickTarget-BjMAMv4O.js} +1 -1
  3. package/{Description-XhC-nlDC.js → Description-BI26L-_l.js} +1 -1
  4. package/{EditorViewer-0HASaTLE.js → EditorViewer-DhrmuAWq.js} +5 -5
  5. package/{GraphFrame-BDN79X8M.js → GraphFrame-CpWx0zmQ.js} +2 -2
  6. package/{JSXGraphRenderer-CJVk_GUE.js → JSXGraphRenderer-BDmRnUZ9.js} +1 -1
  7. package/{NonInlineMediaWrapper-qbq1sMkL.js → NonInlineMediaWrapper-Bo6iMedY.js} +1 -1
  8. package/{_error-CYuva54-.js → _error-BHX8Lr6x.js} +2 -2
  9. package/{alert-DkyS3TKY.js → alert-CEchrsnA.js} +3 -3
  10. package/{angle-DaoA2JUC.js → angle-BdbO_G6c.js} +6 -6
  11. package/{answer-DFPKYXgA.js → answer-CoPEQQWw.js} +6 -6
  12. package/{asList-Gz4W_rKm.js → asList-CQcCX-9V.js} +2 -2
  13. package/{blockQuote-DkyM129q.js → blockQuote-C735leuk.js} +3 -3
  14. package/{boolean-BEJ3xn49.js → boolean-DTwQRgbA.js} +2 -2
  15. package/{booleanInput-lYSnR3Sy.js → booleanInput-C9RBxUEJ.js} +7 -7
  16. package/{br-IRHxn6I1.js → br-DxvBnw9K.js} +2 -2
  17. package/{button-DgCgZsio.js → button-BlCZ4u6R.js} +5 -5
  18. package/{c-DsbSVjyk.js → c-Dn800Ryh.js} +3 -3
  19. package/{cell-DxW2dcPX.js → cell-oY7x8sq3.js} +3 -3
  20. package/{chart-BIPieWIZ.js → chart-Dh2fnk02.js} +4 -4
  21. package/{choiceInput-C_kB1LvQ.js → choiceInput-hDd0SUnW.js} +7 -7
  22. package/{circle-CQr4YvR7.js → circle-DEyxUS2m.js} +6 -6
  23. package/{cobwebPolyline-BPO7eAwM.js → cobwebPolyline-BFVVdXFp.js} +4 -4
  24. package/{codeEditor-Dvvk_3D-.js → codeEditor-YSq6gBeh.js} +2 -2
  25. package/{composites-CDBfszxr.js → composites-D8uLouvx.js} +1 -1
  26. package/{containerBlock-C9kVncqi.js → containerBlock-DmHzDNrX.js} +4 -4
  27. package/{containerInline-4XwOUdJ5.js → containerInline-CGYys78N.js} +4 -4
  28. package/{curve-KrJKcpfk.js → curve-BvqsVnPM.js} +4 -4
  29. package/{delete-Bxirxd_w.js → delete-DXji0Avo.js} +3 -3
  30. package/{doenetml-Doy-wdFu.js → doenetml-BMc3C95Z.js} +3 -3
  31. package/doenetml-external-worker.js +2 -2
  32. package/doenetml-inline-worker.js +3 -3
  33. package/doenetml-worker/index.esm.js +1 -1
  34. package/doenetml-worker/index.js +1 -1
  35. package/{ellipsis-IBA9W2tN.js → ellipsis-4CLt_gyU.js} +2 -2
  36. package/{em-BfKmfHpc.js → em-vd5blaiu.js} +3 -3
  37. package/{embed-hYoe9GlW.js → embed-BmaUeuWp.js} +2 -2
  38. package/{feedback-za2_RwTA.js → feedback-BXU4TcRA.js} +4 -4
  39. package/{figure-B1Ds8JYF.js → figure-OFufy8iF.js} +3 -3
  40. package/{fillPatterns-C_ln9x30.js → fillPatterns-C4vdUE5P.js} +1 -1
  41. package/{footnote-kQJrCuZ_.js → footnote-BBx4IxkB.js} +3 -3
  42. package/{fractionInput-xUBk_iZf.js → fractionInput-Cc2MPqRu.js} +5 -5
  43. package/{graph-DN5clGQR.js → graph-BIChPgGr.js} +5 -5
  44. package/{hint-OItaB1aq.js → hint-EirS0dL1.js} +5 -5
  45. package/{hovercard-store-6PhnAa8d.js → hovercard-store-f7_vrbGD.js} +1 -1
  46. package/{hr-yGf5peS2.js → hr-Doh2BxVr.js} +2 -2
  47. package/{image-CtpszdTo.js → image-CTsGgp0S.js} +8 -8
  48. package/{index-DX6ZipEP.js → index-Cu2_6eIv.js} +1 -1
  49. package/{index.es-CmoULcQe.js → index.es-D0tisaBf.js} +1 -1
  50. package/index.js +1 -1
  51. package/{inputLabel-BBceJcfI.js → inputLabel-BHfcg157.js} +3 -3
  52. package/{insert-Cxvug1PB.js → insert-GjgddvwT.js} +3 -3
  53. package/{label-lBfpmZjD.js → label-D51XDYqf.js} +9 -9
  54. package/{legend-Kp1jRGOa.js → legend-DBKKJ90W.js} +4 -4
  55. package/{line-CN3Lat_I.js → line-36EdD32F.js} +6 -6
  56. package/{lineFamilyDragHandlers-DCpjxxQH.js → lineFamilyDragHandlers-DzdvpzTL.js} +1 -1
  57. package/{lineSegment-DiZtbgeG.js → lineSegment-BcfF8zx9.js} +5 -5
  58. package/{list-64CfxH_d.js → list-BdF5viGH.js} +4 -4
  59. package/{lq-Dn9z3YKp.js → lq-BGyQUjfS.js} +2 -2
  60. package/{lsq-CtDjwQvN.js → lsq-CSdVr6uF.js} +2 -2
  61. package/{markupRenderer-xOGE_1v2.js → markupRenderer-CAptf3o9.js} +1 -1
  62. package/{math-DDRwSg4Q.js → math-B9y8FP79.js} +8 -8
  63. package/{mathInput-DdPkEct4.js → mathInput-Cr7UEf2m.js} +9 -9
  64. package/{mathInputSlots-CJgIDA-a.js → mathInputSlots-CWtkCmqd.js} +1 -1
  65. package/{matrixInput-BYR6Qs0d.js → matrixInput-Bo8xvQ6T.js} +5 -5
  66. package/{mdash-B-YPFSKR.js → mdash-ns1slIS6.js} +2 -2
  67. package/{nbsp-DN9rywjQ.js → nbsp-D69KIgzV.js} +2 -2
  68. package/{ndash-CK5x5V5K.js → ndash-CCjf3V2t.js} +2 -2
  69. package/{number-CkECSHrj.js → number-Br9JaIV6.js} +8 -8
  70. package/{orbitalDiagram-Bq005YBz.js → orbitalDiagram-DgWsMFXW.js} +2 -2
  71. package/{orbitalDiagramInput-B2pDnTQY.js → orbitalDiagramInput-B_PZFCAG.js} +2 -2
  72. package/{p-260YxM6Q.js → p-Bq_l7ygZ.js} +4 -4
  73. package/package.json +1 -1
  74. package/{paginatorControls-bNb4vdmv.js → paginatorControls-t5VzBYlk.js} +2 -2
  75. package/{pegboard-BYpQiuC_.js → pegboard-DiQtBbRW.js} +3 -3
  76. package/{point-Ckem_usr.js → point-Cx--xKbO.js} +6 -6
  77. package/{polygon-Bwtsg6-h.js → polygon-C2jMessE.js} +6 -6
  78. package/{polyline-C3veW8WL.js → polyline-CHBvRD4l.js} +5 -5
  79. package/{pre-D1CKi_7Z.js → pre-Bb3fL4Hv.js} +3 -3
  80. package/{prefigure-BNzgMAt0.js → prefigure-C1MLw2zm.js} +1 -1
  81. package/{pretzel-CV7eWIaB.js → pretzel-YgnWawPH.js} +4 -4
  82. package/{q-y3ytycf8.js → q-Cnq1Uyce.js} +3 -3
  83. package/{ray-DvvU1Nze.js → ray-D27ZdI1G.js} +5 -5
  84. package/{ref-BtYlc5Fn.js → ref-BbXCq6Kd.js} +3 -3
  85. package/{regionBetweenCurveXAxis-DpT2OaF0.js → regionBetweenCurveXAxis-B8EZiOJJ.js} +5 -5
  86. package/{regionBetweenCurves-CpE-Wone.js → regionBetweenCurves-CmHJ-3Sw.js} +5 -5
  87. package/{row-Dp2mWYq0.js → row-21NIJKrk.js} +2 -2
  88. package/{rq-C1cYxk28.js → rq-DRG6yH25.js} +2 -2
  89. package/{rsq-B_i2B1YN.js → rsq-BROAZX1a.js} +2 -2
  90. package/{section-CBuAVDAk.js → section-SDV1ldQY.js} +6 -6
  91. package/{sha256-8sXzDnE0-CNKuyQyg.js → sha256-8sXzDnE0-Cl95lTOx.js} +1 -1
  92. package/{sideBySide-CO6Oia9J.js → sideBySide-CoGvDN4G.js} +2 -2
  93. package/{slider-DWsC8rtm.js → slider-BqcIWr44.js} +4 -4
  94. package/{slopeField-Cj3-Xw19.js → slopeField-CYrXdA4W.js} +2 -2
  95. package/{solution-B5l4RFsx.js → solution-CF2WKo9e.js} +4 -4
  96. package/{spreadsheet-yKbmi3j6.js → spreadsheet-BNzVrJvP.js} +2 -2
  97. package/{sq-D8RH6TN1.js → sq-D6yKTcGl.js} +3 -3
  98. package/{subsetOfRealsInput-BNIqzxVz.js → subsetOfRealsInput-BKPHaErJ.js} +2 -2
  99. package/{summaryStatistics-DIJAL2Tf.js → summaryStatistics-CZo4pc3-.js} +2 -2
  100. package/{table-Cb9QpvG3.js → table-C5FkHHxB.js} +2 -2
  101. package/{tabular-D-xb4Drw.js → tabular-CSHvHxba.js} +2 -2
  102. package/{tag-DEKWzwkl.js → tag-BzZgC7n6.js} +2 -2
  103. package/{text-IZxN_O5u.js → text-geaEpKP_.js} +8 -8
  104. package/{textInput-B7oDipR2.js → textInput-p9I5XX-X.js} +8 -8
  105. package/{tooltip-provider-CXKtdkdB.js → tooltip-provider-B_YuPG1Y.js} +2 -2
  106. package/{useAnchoredGraphDragHandler-DNaorlAE.js → useAnchoredGraphDragHandler-o72nXJ78.js} +1 -1
  107. package/useDoenetRenderer-B2pfaJvR.js +114 -0
  108. package/{useFieldCurve-aONqKYiX.js → useFieldCurve-DGGLRs_S.js} +2 -2
  109. package/{useSubmitActionWithDelay-zTUwIif_.js → useSubmitActionWithDelay-CBlar6Bm.js} +2 -2
  110. package/{vector-ClfPL8nw.js → vector-BRyOwZLK.js} +6 -6
  111. package/{vectorField-BqGkyH_S.js → vectorField-PxFasKY8.js} +2 -2
  112. package/{video-X0al9w8f.js → video-D3h6DYga.js} +4 -4
  113. package/useDoenetRenderer-lKyLYnZl.js +0 -114
@@ -2796,5 +2796,5 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
2796
2796
  `};return lineEndings.LINE_ENDINGS=nA,lineEndings}var generator={},util={},capitalize={},hasRequiredCapitalize;function requireCapitalize(){return hasRequiredCapitalize||(hasRequiredCapitalize=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=function(iA){var rA=iA.trim();return rA.charAt(0).toUpperCase()+rA.slice(1)},AA=eA;nA.default=AA})(capitalize)),capitalize}var isNode={exports:{}},hasRequiredIsNode;function requireIsNode(){return hasRequiredIsNode||(hasRequiredIsNode=1,(function(nA,eA){Object.defineProperty(eA,"__esModule",{value:!0}),eA.default=void 0;var AA=function(){return!!nA.exports},tA=AA;eA.default=tA})(isNode,isNode.exports)),isNode.exports}var isReactNative={},hasRequiredIsReactNative;function requireIsReactNative(){return hasRequiredIsReactNative||(hasRequiredIsReactNative=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=function(){var iA=!1;try{iA=navigator.product==="ReactNative"}catch{iA=!1}return iA},AA=eA;nA.default=AA})(isReactNative)),isReactNative}var isWindows={},platforms={},hasRequiredPlatforms;function requirePlatforms(){if(hasRequiredPlatforms)return platforms;hasRequiredPlatforms=1,Object.defineProperty(platforms,"__esModule",{value:!0}),platforms.SUPPORTED_PLATFORMS=void 0;var nA={DARWIN:"darwin",LINUX:"linux",WIN32:"win32"};return platforms.SUPPORTED_PLATFORMS=nA,platforms}var hasRequiredIsWindows;function requireIsWindows(){return hasRequiredIsWindows||(hasRequiredIsWindows=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=requirePlatforms(),AA=function(){var rA=!1;try{rA=process.platform===eA.SUPPORTED_PLATFORMS.WIN32}catch{rA=!1}return rA},tA=AA;nA.default=tA})(isWindows)),isWindows}var makeArrayOfLength={},hasRequiredMakeArrayOfLength;function requireMakeArrayOfLength(){return hasRequiredMakeArrayOfLength||(hasRequiredMakeArrayOfLength=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=function(){var iA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return Array.apply(null,Array(iA)).map(function(rA,aA){return aA})},AA=eA;nA.default=AA})(makeArrayOfLength)),makeArrayOfLength}var makeArrayOfStrings={},hasRequiredMakeArrayOfStrings;function requireMakeArrayOfStrings(){return hasRequiredMakeArrayOfStrings||(hasRequiredMakeArrayOfStrings=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=AA(requireMakeArrayOfLength());function AA(rA){return rA&&rA.__esModule?rA:{default:rA}}var tA=function(aA,oA){var sA=(0,eA.default)(aA);return sA.map(function(){return oA()})},iA=tA;nA.default=iA})(makeArrayOfStrings)),makeArrayOfStrings}var hasRequiredUtil;function requireUtil(){return hasRequiredUtil||(hasRequiredUtil=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),Object.defineProperty(nA,"capitalize",{enumerable:!0,get:function(){return eA.default}}),Object.defineProperty(nA,"isNode",{enumerable:!0,get:function(){return AA.default}}),Object.defineProperty(nA,"isReactNative",{enumerable:!0,get:function(){return tA.default}}),Object.defineProperty(nA,"isWindows",{enumerable:!0,get:function(){return iA.default}}),Object.defineProperty(nA,"makeArrayOfLength",{enumerable:!0,get:function(){return rA.default}}),Object.defineProperty(nA,"makeArrayOfStrings",{enumerable:!0,get:function(){return aA.default}});var eA=oA(requireCapitalize()),AA=oA(requireIsNode()),tA=oA(requireIsReactNative()),iA=oA(requireIsWindows()),rA=oA(requireMakeArrayOfLength()),aA=oA(requireMakeArrayOfStrings());function oA(sA){return sA&&sA.__esModule?sA:{default:sA}}})(util)),util}var hasRequiredGenerator;function requireGenerator(){return hasRequiredGenerator||(hasRequiredGenerator=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=requireWords(),AA=requireUtil();function tA(lA,gA){if(!(lA instanceof gA))throw new TypeError("Cannot call a class as a function")}function iA(lA,gA){for(var cA=0;cA<gA.length;cA++){var IA=gA[cA];IA.enumerable=IA.enumerable||!1,IA.configurable=!0,"value"in IA&&(IA.writable=!0),Object.defineProperty(lA,IA.key,IA)}}function rA(lA,gA,cA){return gA&&iA(lA.prototype,gA),Object.defineProperty(lA,"prototype",{writable:!1}),lA}function aA(lA,gA,cA){return gA in lA?Object.defineProperty(lA,gA,{value:cA,enumerable:!0,configurable:!0,writable:!0}):lA[gA]=cA,lA}var oA=(function(){function lA(){var gA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},cA=gA.sentencesPerParagraph,IA=cA===void 0?{max:7,min:3}:cA,uA=gA.wordsPerSentence,CA=uA===void 0?{max:15,min:5}:uA,dA=gA.random;gA.seed;var pA=gA.words,mA=pA===void 0?eA.WORDS:pA;if(tA(this,lA),aA(this,"sentencesPerParagraph",void 0),aA(this,"wordsPerSentence",void 0),aA(this,"random",void 0),aA(this,"words",void 0),IA.min>IA.max)throw new Error("Minimum number of sentences per paragraph (".concat(IA.min,") cannot exceed maximum (").concat(IA.max,")."));if(CA.min>CA.max)throw new Error("Minimum number of words per sentence (".concat(CA.min,") cannot exceed maximum (").concat(CA.max,")."));this.sentencesPerParagraph=IA,this.words=mA,this.wordsPerSentence=CA,this.random=dA||Math.random}return rA(lA,[{key:"generateRandomInteger",value:function(cA,IA){return Math.floor(this.random()*(IA-cA+1)+cA)}},{key:"generateRandomWords",value:function(cA){var IA=this,uA=this.wordsPerSentence,CA=uA.min,dA=uA.max,pA=cA||this.generateRandomInteger(CA,dA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,QA){return"".concat(IA.pluckRandomWord()," ").concat(mA)},"").trim()}},{key:"generateRandomSentence",value:function(cA){return"".concat((0,AA.capitalize)(this.generateRandomWords(cA)),".")}},{key:"generateRandomParagraph",value:function(cA){var IA=this,uA=this.sentencesPerParagraph,CA=uA.min,dA=uA.max,pA=cA||this.generateRandomInteger(CA,dA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,QA){return"".concat(IA.generateRandomSentence()," ").concat(mA)},"").trim()}},{key:"pluckRandomWord",value:function(){var cA=0,IA=this.words.length-1,uA=this.generateRandomInteger(cA,IA);return this.words[uA]}}]),lA})(),sA=oA;nA.default=sA})(generator)),generator}var hasRequiredLoremIpsum;function requireLoremIpsum(){return hasRequiredLoremIpsum||(hasRequiredLoremIpsum=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),nA.default=void 0;var eA=requireFormats(),AA=requireLineEndings(),tA=rA(requireGenerator()),iA=requireUtil();function rA(IA){return IA&&IA.__esModule?IA:{default:IA}}function aA(IA,uA){if(!(IA instanceof uA))throw new TypeError("Cannot call a class as a function")}function oA(IA,uA){for(var CA=0;CA<uA.length;CA++){var dA=uA[CA];dA.enumerable=dA.enumerable||!1,dA.configurable=!0,"value"in dA&&(dA.writable=!0),Object.defineProperty(IA,dA.key,dA)}}function sA(IA,uA,CA){return uA&&oA(IA.prototype,uA),Object.defineProperty(IA,"prototype",{writable:!1}),IA}function lA(IA,uA,CA){return uA in IA?Object.defineProperty(IA,uA,{value:CA,enumerable:!0,configurable:!0,writable:!0}):IA[uA]=CA,IA}var gA=(function(){function IA(){var uA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},CA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:eA.FORMAT_PLAIN,dA=arguments.length>2?arguments[2]:void 0;if(aA(this,IA),this.format=CA,this.suffix=dA,lA(this,"generator",void 0),eA.FORMATS.indexOf(CA.toLowerCase())===-1)throw new Error("".concat(CA," is an invalid format. Please use ").concat(eA.FORMATS.join(" or "),"."));this.generator=new tA.default(uA)}return sA(IA,[{key:"getLineEnding",value:function(){return this.suffix?this.suffix:!(0,iA.isReactNative)()&&(0,iA.isNode)()&&(0,iA.isWindows)()?AA.LINE_ENDINGS.WIN32:AA.LINE_ENDINGS.POSIX}},{key:"formatString",value:function(CA){return this.format===eA.FORMAT_HTML?"<p>".concat(CA,"</p>"):CA}},{key:"formatStrings",value:function(CA){var dA=this;return CA.map(function(pA){return dA.formatString(pA)})}},{key:"generateWords",value:function(CA){return this.formatString(this.generator.generateRandomWords(CA))}},{key:"generateSentences",value:function(CA){return this.formatString(this.generator.generateRandomParagraph(CA))}},{key:"generateParagraphs",value:function(CA){var dA=this.generator.generateRandomParagraph.bind(this.generator);return this.formatStrings((0,iA.makeArrayOfStrings)(CA,dA)).join(this.getLineEnding())}}]),IA})(),cA=gA;nA.default=cA})(LoremIpsum)),LoremIpsum}var hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,(function(nA){Object.defineProperty(nA,"__esModule",{value:!0}),Object.defineProperty(nA,"LoremIpsum",{enumerable:!0,get:function(){return iA.default}}),nA.loremIpsum=void 0;var eA=requireFormats(),AA=requireUnits(),tA=requireWords(),iA=rA(requireLoremIpsum());function rA(oA){return oA&&oA.__esModule?oA:{default:oA}}var aA=function(){var sA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},lA=sA.count,gA=lA===void 0?1:lA,cA=sA.format,IA=cA===void 0?eA.FORMAT_PLAIN:cA,uA=sA.paragraphLowerBound,CA=uA===void 0?3:uA,dA=sA.paragraphUpperBound,pA=dA===void 0?7:dA,mA=sA.random,QA=sA.sentenceLowerBound,BA=QA===void 0?5:QA,hA=sA.sentenceUpperBound,DA=hA===void 0?15:hA,EA=sA.units,fA=EA===void 0?AA.UNIT_SENTENCES:EA,NA=sA.words,yA=NA===void 0?tA.WORDS:NA,bA=sA.suffix,wA=bA===void 0?"":bA,MA={random:mA,sentencesPerParagraph:{max:pA,min:CA},words:yA,wordsPerSentence:{max:DA,min:BA}},vA=new iA.default(MA,IA,wA);switch(fA){case AA.UNIT_PARAGRAPHS:case AA.UNIT_PARAGRAPH:return vA.generateParagraphs(gA);case AA.UNIT_SENTENCES:case AA.UNIT_SENTENCE:return vA.generateSentences(gA);case AA.UNIT_WORDS:case AA.UNIT_WORD:return vA.generateWords(gA);default:return""}};nA.loremIpsum=aA})(dist)),dist}var distExports=requireDist();class Lorem extends CompositeComponent{static componentType="lorem";static componentDocs={summary:"Generates lorem ipsum placeholder text"};static allowInSchemaAsComponent=["text","p"];static createsVariants=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.minSentencesPerParagraph={description:"Minimum number of sentences per generated paragraph.",createComponentOfType:"number",createStateVariable:"minSentencesPerParagraph",defaultValue:4,public:!0},eA.maxSentencesPerParagraph={description:"Maximum number of sentences per generated paragraph.",createComponentOfType:"number",createStateVariable:"maxSentencesPerParagraph",defaultValue:8,public:!0},eA.minWordsPerSentence={description:"Minimum number of words per generated sentence.",createComponentOfType:"number",createStateVariable:"minWordsPerSentence",defaultValue:4,public:!0},eA.maxWordsPerSentence={description:"Maximum number of words per generated sentence.",createComponentOfType:"number",createStateVariable:"maxWordsPerSentence",defaultValue:8,public:!0},eA.generateWords={createComponentOfType:"number",createStateVariable:"generateWords",defaultValue:null,description:"Number of words of lorem-ipsum to generate."},eA.generateSentences={createComponentOfType:"number",createStateVariable:"generateSentences",defaultValue:null,description:"Number of sentences of lorem-ipsum to generate."},eA.generateParagraphs={createComponentOfType:"number",createStateVariable:"generateParagraphs",defaultValue:null,description:"Number of paragraphs of lorem-ipsum to generate."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.readyToExpandWhenResolved={returnDependencies:()=>({minSentencesPerParagraph:{dependencyType:"stateVariable",variableName:"minSentencesPerParagraph"},maxSentencesPerParagraph:{dependencyType:"stateVariable",variableName:"maxSentencesPerParagraph"},minWordsPerSentence:{dependencyType:"stateVariable",variableName:"minWordsPerSentence"},maxWordsPerSentence:{dependencyType:"stateVariable",variableName:"maxWordsPerSentence"},generateWords:{dependencyType:"stateVariable",variableName:"generateWords"},generateSentences:{dependencyType:"stateVariable",variableName:"generateSentences"},generateParagraphs:{dependencyType:"stateVariable",variableName:"generateParagraphs"}}),markStale:()=>({updateReplacements:!0}),definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.isVariantComponent={returnDependencies:()=>({}),definition:()=>({setValue:{isVariantComponent:!0}})},eA.generatedVariantInfo={returnDependencies:({sharedParameters:AA,componentInfoObjects:tA})=>({variantSeed:{dependencyType:"value",value:AA.variantSeed}}),definition({dependencyValues:AA,componentIdx:tA}){return{setValue:{generatedVariantInfo:{seed:AA.variantSeed,meta:{createdBy:tA}}}}}},eA}static async createSerializedReplacements({component:eA,workspace:AA,nComponents:tA}){AA.replacementsCreated===void 0&&(AA.replacementsCreated=0);const iA={prefix:`${eA.stateId}|`,num:AA.replacementsCreated};let rA=[];const aA=new distExports.LoremIpsum({sentencesPerParagraph:{max:await eA.stateValues.maxSentencesPerParagraph,min:await eA.stateValues.minSentencesPerParagraph},wordsPerSentence:{max:await eA.stateValues.maxWordsPerSentence,min:await eA.stateValues.minWordsPerSentence},random:eA.sharedParameters.variantRng});let oA=[];if(await eA.stateValues.generateParagraphs!==null){let sA=await eA.stateValues.generateParagraphs;Number.isInteger(sA)&&sA>0&&(oA=aA.generateParagraphs(sA).split(`
2797
2797
  `).map(gA=>({type:"serialized",componentType:"p",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA]})))}else if(await eA.stateValues.generateSentences!==null){let sA=await eA.stateValues.generateSentences;if(Number.isInteger(sA)&&sA>0){let lA=aA.generateSentences(sA).split(". ");for(let gA of lA.slice(0,lA.length-1))oA.push({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA+"."]}),oA.push(" ");oA.push({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[lA[lA.length-1]]})}}else if(await eA.stateValues.generateWords!==null){let sA=await eA.stateValues.generateWords;if(Number.isInteger(sA)&&sA>0){let lA=aA.generateWords(sA).split(" ").map(gA=>({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[gA]}));oA.push(lA[0]);for(let gA of lA.slice(1))oA.push(" "),oA.push(gA)}}return AA.replacementsCreated=iA.num,{replacements:oA,diagnostics:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA}){let rA=[],aA=await this.createSerializedReplacements({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA});return rA.push(...aA.diagnostics),tA=aA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:aA.replacements}],diagnostics:rA,nComponents:tA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}}class UpdateValue extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{updateValue:this.updateValue.bind(this),updateValueIfTriggerNewlyTrue:this.updateValueIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="updateValue";static componentDocs={summary:"Updates one or more state variables on a target component"};static rendererType="button";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();eA.target={createReferences:!0,description:"Reference to the state variable that will be updated."},eA.type={createPrimitiveOfType:"string",createStateVariable:"type",defaultPrimitiveValue:"math",toLowerCase:!0,validValues:[{value:"math",description:"Treat the new value as a math expression."},{value:"number",description:"Treat the new value as a number."},{value:"boolean",description:"Treat the new value as a boolean."},{value:"text",description:"Treat the new value as text."}],description:"Component type used to interpret the new value."},eA.newValue={createComponentOfType:"_componentWithSelectableType",description:"New value to assign to the target."},eA.draggable={description:"Whether the update button can be dragged on a graph.",createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},Object.assign(eA,returnAnchorAttributes()),Object.assign(eA,returnLabelAttributes());let AA=returnStandardTriggeringAttributes("updateValueIfTriggerNewlyTrue");return Object.assign(eA,AA),eA.simplify={description:"Level of simplification applied to the new value.",createComponentOfType:"text",createStateVariable:"simplify",defaultValue:"none",public:!0,toLowerCase:!0,valueForTrue:"full",valueForFalse:"none",validValues:[{value:"none",description:"No simplification is applied."},{value:"full",description:"Fully simplify the new value."},{value:"numbers",description:"Simplify numeric subexpressions only, leaving symbolic structure intact."},{value:"numbersPreserveOrder",description:"Like `numbers`, but does not reorder commutative operands."},{value:"normalizeOrder",description:"Reorder commutative operands into a canonical form without simplifying values."}]},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"updateValue");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let iA=returnAnchorStateVariableDefinition();return Object.assign(eA,iA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"updateValue"}})},eA.targetComponentIdx={additionalStateVariablesDefined:["unresolvedPath","targetOriginalPath"],returnDependencies:()=>({target:{dependencyType:"attributeRefResolutions",attributeName:"target"}}),definition({dependencyValues:rA}){if(rA.target?.length===1){const aA=rA.target[0];return{setValue:{targetComponentIdx:aA.componentIdx,unresolvedPath:aA.unresolvedPath,targetOriginalPath:aA.originalPath}}}else return{setValue:{targetComponentIdx:null,unresolvedPath:null,targetOriginalPath:null}}}},eA.targetComponent={stateVariablesDeterminingDependencies:["targetComponentIdx"],returnDependencies({stateValues:rA}){return rA.targetComponentIdx!=null?{targetComponent:{dependencyType:"componentIdentity",componentIdx:rA.targetComponentIdx}}:{}},definition:function({dependencyValues:rA}){let aA=null;return rA.targetComponent&&(aA=rA.targetComponent),{setValue:{targetComponent:aA}}}},eA.targetIdentities={stateVariablesDeterminingDependencies:["targetComponent","unresolvedPath"],returnDependencies:function({stateValues:rA,componentInfoObjects:aA}){let oA={};if(rA.targetComponent!==null){const sA=aA.allComponentClasses[rA.targetComponent.componentType];sA?.listEntryComponentType!==void 0&&!picksListEntry(rA.unresolvedPath)?(oA.numEntries={dependencyType:"stateVariable",componentIdx:rA.targetComponent.componentIdx,variableName:sA.listEntryCountVariable},oA.targets={dependencyType:"stateVariable",variableName:"targetComponent"}):aA.isCompositeComponent({componentType:rA.targetComponent.componentType,includeNonStandard:!1})?oA.targets={dependencyType:"replacement",compositeIdx:rA.targetComponent.componentIdx,recursive:!0}:oA.targets={dependencyType:"stateVariable",variableName:"targetComponent"}}return oA},definition({dependencyValues:rA}){let aA=null;if(rA.targets&&(aA=rA.targets,Array.isArray(aA)||(aA=[aA])),rA.numEntries!==void 0){const sA=rA.targets;aA=Array.from({length:rA.numEntries??0},(lA,gA)=>({componentIdx:sA.componentIdx,componentType:sA.componentType,listEntryIndex:gA}))}let oA=[];return(aA===null||aA.length===0)&&oA.push(codedDiagnostic({type:"warning",code:"doenet-w0043",args:{source:"updateValue"}})),{setValue:{targetIdentities:aA},sendDiagnostics:oA}}},eA.targets={stateVariablesDeterminingDependencies:["targetIdentities","unresolvedPath","targetOriginalPath"],returnDependencies:function({stateValues:rA}){let aA={targetIdentities:{dependencyType:"stateVariable",variableName:"targetIdentities"},unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"}};if(rA.targetIdentities!==null)for(let[oA,sA]of rA.targetIdentities.entries()){let lA;if(sA.listEntryIndex!==void 0){const gA=[{name:"",index:[{value:[`${sA.listEntryIndex+1}`]}]}];lA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:sA.componentIdx,unresolvedPath:[...gA,...rA.unresolvedPath??[]],referenceOriginalPath:rA.targetOriginalPath,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else if(rA.unresolvedPath){let gA=rA.propIndex;gA&&(gA=[...gA]),lA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:sA.componentIdx,unresolvedPath:rA.unresolvedPath,referenceOriginalPath:rA.targetOriginalPath,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else lA={dependencyType:"stateVariable",componentIdx:sA.componentIdx,variableName:"value",returnAsComponentObject:!0,variablesOptional:!0};aA["target"+oA]=lA}return aA},definition({dependencyValues:rA}){let aA=null,oA=[];if(rA.targetIdentities!==null){aA=[];for(let sA in rA.targetIdentities){let lA=rA["target"+sA];if(lA==null){oA.push(codedDiagnostic({type:"warning",code:"doenet-w0043",args:{source:"updateValue"}}));continue}if(aA.push(lA),Object.keys(lA.stateValues)[0]===void 0)if(rA.unresolvedPath){let gA=rA.unresolvedPath[0].name;if(rA.unresolvedPath[0].index.length>0)for(const cA of rA.unresolvedPath[0].index)gA+="[idx]";oA.push(codedDiagnostic({type:"warning",code:"doenet-w0044",args:{source:"updateValue",property:gA,component:lA.componentType}}))}else oA.push(codedDiagnostic({type:"warning",code:"doenet-w0044",args:{source:"updateValue",property:"value",component:lA.componentType}}))}}return{setValue:{targets:aA},sendDiagnostics:oA}}},eA.newValue={returnDependencies:()=>({newValueAttr:{dependencyType:"attributeComponent",attributeName:"newValue",variableNames:["value"]},type:{dependencyType:"stateVariable",variableName:"type"},simplify:{dependencyType:"stateVariable",variableName:"simplify"}}),definition:function({dependencyValues:rA}){if(rA.newValueAttr===null)return{setValue:{newValue:null}};let aA=rA.newValueAttr.stateValues.value;return rA.type==="math"&&(aA=normalizeMathExpression({value:aA,simplify:rA.simplify})),{setValue:{newValue:aA}}}},eA}async updateValue({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let iA=await this.stateValues.targets,rA=await this.stateValues.newValue;if(iA===null||rA===null)return;let aA=[];for(let oA of iA){let sA=Object.keys(oA.stateValues)[0];sA!==void 0&&aA.push({updateType:"updateValue",componentIdx:oA.componentIdx,stateVariable:sA,value:rA})}return await this.coreFunctions.performUpdate({updateInstructions:aA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"selected",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{response:rA,responseText:rA.toString()}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}async updateValueIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(await eA.triggerWhen&&AA.triggerWhen===!1&&!await this.stateValues.insideTriggerSet)return await this.updateValue({actionId:tA,skipRendererUpdate:!0})}async moveButton({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,component:this,componentType:this.componentType,coreFunctions:this.coreFunctions})}}function picksListEntry(nA){const eA=nA?.[0];return eA?.name===""&&eA.index?.length>0}class CallAction extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{callAction:this.callAction.bind(this),callActionIfTriggerNewlyTrue:this.callActionIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="callAction";static componentDocs={summary:"Triggers an action when clicked or in response to a specified user interaction"};static rendererType="button";static renderChildren=!0;static additionalSchemaChildren=["_base"];static keepChildrenSerialized({serializedComponent:eA,componentInfoObjects:AA}){if(eA.children===void 0)return[];{let tA=[];for(let[iA,rA]of eA.children.entries())AA.componentIsSpecifiedType(rA,"label")||tA.push(iA);return tA}}static createAttributesObject(){let eA=super.createAttributesObject();eA.target={createReferences:!0,description:"Reference to the component whose action will be invoked."},eA.actionName={createComponentOfType:"text",createStateVariable:"actionName",defaultValue:null,public:!0,description:"Name of the action to invoke on the target component."},eA.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0,description:"Whether the action button can be dragged on a graph."},Object.assign(eA,returnLabelAttributes()),Object.assign(eA,returnAnchorAttributes());let AA=returnStandardTriggeringAttributes("callActionIfTriggerNewlyTrue");return Object.assign(eA,AA),eA.numbers={createComponentOfType:"numberList",description:"Numeric arguments passed to the invoked action."},eA.number={createComponentOfType:"number",description:"Numeric argument passed to the invoked action."},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"callAction");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let iA=returnAnchorStateVariableDefinition();return Object.assign(eA,iA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"callAction"}})},eA.targetComponentIdx={additionalStateVariablesDefined:["unresolvedPath","targetOriginalPath"],returnDependencies:()=>({target:{dependencyType:"attributeRefResolutions",attributeName:"target"}}),definition({dependencyValues:rA}){if(rA.target?.length===1){const aA=rA.target[0],oA=targetIdxOfRefResolution(aA);if(oA!==null)return{setValue:{targetComponentIdx:oA,unresolvedPath:null,targetOriginalPath:aA.originalPath}}}return{setValue:{targetComponentIdx:null,unresolvedPath:null,targetOriginalPath:null}}}},eA}async callAction({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let iA=await this.stateValues.targetComponentIdx,rA=await this.stateValues.actionName;if(iA!=null&&rA!=null){let aA={sourceInformation:AA,skipRendererUpdate:!0};this.serializedChildren.length>0&&(aA.serializedComponents=deepClone(this.serializedChildren)),this.attributes.number&&(aA.number=this.attributes.number.type==="literal"?literalAttributeValue(this.attributes.number,this.componentInfoObjects):await this.attributes.number.component.stateValues.value),this.attributes.numbers&&(aA.numbers=await this.attributes.numbers.component.stateValues.numbers),eA&&(aA.actionId=eA),(await this.coreFunctions.performAction({componentIdx:iA,actionName:rA,args:aA,event:{verb:"selected",object:{componentIdx:this.componentIdx,componentType:this.componentType}},caseInsensitiveMatch:!0}))?.actionUnavailable&&await this.warnActionUnavailable(rA),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}async warnActionUnavailable(eA){const AA=this.coreFunctions.doenetMLStringForReference(await this.stateValues.targetOriginalPath);AA&&this.coreFunctions.addDiagnostic(codedDiagnostic({type:"warning",code:"doenet-w0102",args:{action:eA,reference:`$${AA}`},position:this.position,sourceDoc:this.sourceDoc}))}async callActionIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(eA.triggerWhen&&AA.triggerWhen===!1&&!await this.stateValues.insideTriggerSet)return await this.callAction({actionId:tA})}async moveButton({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,component:this,componentType:this.componentType,coreFunctions:this.coreFunctions})}}class triggerSet extends InlineComponent{constructor(eA){super(eA),Object.assign(this.actions,{triggerActions:this.triggerActions.bind(this),triggerActionsIfTriggerNewlyTrue:this.triggerActionsIfTriggerNewlyTrue.bind(this),moveButton:this.moveButton.bind(this)})}static componentType="triggerSet";static componentDocs={summary:"Groups a set of `<updateValue>` or `<callAction>` components which share a single trigger condition"};static rendererType="button";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();eA.draggable={description:"Whether the trigger set's button can be dragged on a graph.",createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},Object.assign(eA,returnAnchorAttributes()),Object.assign(eA,returnLabelAttributes());let AA=returnStandardTriggeringAttributes("triggerActionsIfTriggerNewlyTrue");return Object.assign(eA,AA),eA}static returnChildGroups(){return[{group:"updateValuesCallActions",componentTypes:["updateValue","callAction"]},{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA),addStandardTriggeringStateVariableDefinitions(eA,"triggerActions");let tA=returnLabelStateVariableDefinitions();Object.assign(eA,tA),Object.assign(eA,returnRenderOnlyLabelChildDefinitions());let iA=returnAnchorStateVariableDefinition();return Object.assign(eA,iA),eA.clickAction={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{clickAction:"triggerActions"}})},eA.updateValueAndActionsToTrigger={returnDependencies:()=>({updateValueAndCallActionChildren:{dependencyType:"child",childGroups:["updateValuesCallActions"]}}),definition({dependencyValues:rA}){return{setValue:{updateValueAndActionsToTrigger:rA.updateValueAndCallActionChildren}}}},eA}async triggerActions({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){for(let iA of await this.stateValues.updateValueAndActionsToTrigger)this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:iA.componentType,baseComponentType:"updateValue"})?await this.coreFunctions.performAction({componentIdx:iA.componentIdx,actionName:"updateValue",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0}}):this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:iA.componentType,baseComponentType:"callAction"})&&await this.coreFunctions.performAction({componentIdx:iA.componentIdx,actionName:"callAction",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0}});return await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}async triggerActionsIfTriggerNewlyTrue({stateValues:eA,previousValues:AA,actionId:tA}){if(eA.triggerWhen&&AA.triggerWhen===!1)return await this.triggerActions({actionId:tA,skipRendererUpdate:!0})}async moveButton({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA={},skipRendererUpdate:oA=!1}){return await moveGraphicalObjectWithAnchorAction({x:eA,y:AA,z:tA,transient:iA,actionId:rA,sourceInformation:aA,skipRendererUpdate:oA,componentIdx:this.componentIdx,component:this,componentType:this.componentType,coreFunctions:this.coreFunctions})}}class FunctionIterates extends InlineComponent{static componentType="functionIterates";static componentDocs={summary:"List of values produced by iterating a function"};static rendererType=void 0;static variableForIndexAsProp="iterates";static createAttributesObject(){let eA=super.createAttributesObject();return eA.numIterates={description:"Number of iterations to compute.",createComponentOfType:"integer",createStateVariable:"numIterates",defaultValue:0,public:!0},eA.forceSymbolic={description:"Whether to force symbolic evaluation.",createComponentOfType:"boolean",createStateVariable:"forceSymbolic",defaultValue:!1,public:!0},eA.forceNumeric={description:"Whether to force numeric evaluation.",createComponentOfType:"boolean",createStateVariable:"forceNumeric",defaultValue:!1,public:!0},eA.initialValue={createComponentOfType:"math",createStateVariable:"initialValue",defaultValue:context.fromAst("_"),description:"Starting value passed to the function on the first iteration."},eA.function={createComponentOfType:"function",description:"The function to iterate."},Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.numDimensions={description:"Number of dimensions of each iterate.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numInputs","numOutputs"]}}),definition({dependencyValues:AA}){if(AA.functionAttr)if(AA.functionAttr.stateValues.numInputs!==AA.functionAttr.stateValues.numOutputs){let tA=AA.functionAttr.stateValues.numInputs,iA=AA.functionAttr.stateValues.numOutputs,rA=codedDiagnostic({type:"warning",code:"doenet-w0056",args:{inputs:tA,outputs:iA},position:AA.functionAttr.position||void 0});return{setValue:{numDimensions:0},sendDiagnostics:[rA]}}else return{setValue:{numDimensions:AA.functionAttr.stateValues.numInputs}};else return{setValue:{numDimensions:0}}}},eA.allIterates={description:"All computed iterates of the function.",public:!0,shadowingInstructions:{createComponentOfType:"mathList",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["symbolicfs","numericalfs","symbolic"]},forceSymbolic:{dependencyType:"stateVariable",variableName:"forceSymbolic"},forceNumeric:{dependencyType:"stateVariable",variableName:"forceNumeric"},numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"},initialValue:{dependencyType:"stateVariable",variableName:"initialValue"},numIterates:{dependencyType:"stateVariable",variableName:"numIterates"}}),definition({dependencyValues:AA}){let tA=[],iA=AA.functionAttr,rA=AA.initialValue,aA=!AA.forceNumeric&&(iA.stateValues.symbolic||AA.forceSymbolic),oA=AA.numIterates;if(!iA||AA.numDimensions===0||!(AA.numDimensions===1||Array.isArray(rA.tree)&&vectorOperators.includes(rA.tree[0])&&rA.tree.length===AA.numDimensions+1))return tA=Array(oA).fill(context.fromAst("_")),{setValue:{allIterates:tA}};if(aA)if(AA.numDimensions===1){let sA=iA.stateValues.symbolicfs[0],lA=rA;for(let gA=0;gA<oA;gA++)lA=sA(lA),tA.push(lA)}else{let sA=iA.stateValues.symbolicfs,lA=rA.tree.slice(1).map(gA=>context.fromAst(gA));for(let gA=0;gA<oA;gA++){let cA=[];for(let IA=0;IA<AA.numDimensions;IA++)cA.push(sA[IA](...lA).tree);tA.push(context.fromAst(["vector",...cA])),lA=cA.map(IA=>context.fromAst(IA))}}else if(AA.numDimensions===1){let sA=iA.stateValues.numericalfs[0],lA=rA.evaluate_to_constant();if(!isNumericConstant(lA))tA=Array(oA).fill(context.fromAst("_"));else for(let gA=0;gA<oA;gA++)lA=sA(lA),tA.push(context.fromAst(lA))}else{let sA=iA.stateValues.numericalfs,lA=rA.tree.slice(1).map(gA=>evaluateToNumber(context.fromAst(gA)));for(let gA=0;gA<oA;gA++){let cA=[];for(let IA=0;IA<AA.numDimensions;IA++)cA.push(sA[IA](...lA));tA.push(context.fromAst(["vector",...cA])),lA=cA}}return{setValue:{allIterates:tA}}}},eA.allIteratesWithInitial={description:"All iterates including the initial value.",public:!0,shadowingInstructions:{createComponentOfType:"mathList",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({initialValue:{dependencyType:"stateVariable",variableName:"initialValue"},allIterates:{dependencyType:"stateVariable",variableName:"allIterates"}}),definition({dependencyValues:AA}){return{setValue:{allIteratesWithInitial:[AA.initialValue,...AA.allIterates]}}}},eA.iterates={description:"The list of iterate values.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["iterate"],returnArraySizeDependencies:()=>({numIterates:{dependencyType:"stateVariable",variableName:"numIterates"}}),returnArraySize({dependencyValues:AA}){return[AA.numIterates]},returnArrayDependenciesByKey(){return{globalDependencies:{allIterates:{dependencyType:"stateVariable",variableName:"allIterates"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let iA={};for(let rA=0;rA<tA[0];rA++)iA[rA]=AA.allIterates[rA];return{setValue:{iterates:iA}}}},eA.finalIterate={description:"The last iterate value.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},stateVariablesDeterminingDependencies:["numIterates"],returnDependencies({stateValues:AA}){return!Number.isFinite(AA.numIterates)||AA.numIterates<0?{}:AA.numIterates>0?{finalIterate:{dependencyType:"stateVariable",variableName:`iterate${AA.numIterates}`}}:{finalIterate:{dependencyType:"stateVariable",variableName:"initialValue"}}},definition({dependencyValues:AA}){return{setValue:{finalIterate:AA.finalIterate}}}},eA}}class Module extends Group{static componentType="module";static componentDocs={summary:"A reusable group with parameterized attributes; can be copied elsewhere with new parameter values"};static acceptAnyAttribute=!0;static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.styleNumber,eA}}class ModuleAttributes extends CompositeComponent{static componentType="moduleAttributes";static componentDocs={summary:"Declares attributes accepted by an enclosing `<module>`"};static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static additionalSchemaChildren=["_base"];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.moduleIdx={returnDependencies:()=>({sourceCompositeIdentity:{dependencyType:"sourceCompositeIdentity"}}),definition({dependencyValues:AA}){let tA=null;return AA.sourceCompositeIdentity&&AA.sourceCompositeIdentity.componentType==="module"&&(tA=AA.sourceCompositeIdentity.componentIdx),{setValue:{moduleIdx:tA}}}},eA.serializedChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedChildren:AA.serializedChildren}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({componentIdentity:{dependencyType:"stateVariable",variableName:"moduleIdx"}}),definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,nComponents:iA,workspace:rA}){rA.replacementsCreated===void 0&&(rA.replacementsCreated=0);const aA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated},oA=[],sA=await eA.stateValues.moduleIdx;if(sA===null)return{replacements:[],diagnostics:oA,nComponents:iA};const lA=AA[sA],gA={};for(let dA in lA.attributes)gA[dA.toLowerCase()]=dA;const cA=Object.keys(lA.constructor.createAttributesObject()).map(dA=>dA.toLowerCase());cA.push("name");const IA=[],uA=deepClone(await eA.state.serializedChildren.value);for(const dA of uA){const pA=dA.attributes.name?.primitive?.value;if(!pA){IA.push(dA),oA.push(codedDiagnostic({type:"warning",code:"doenet-w0074",args:{component:dA.componentType},position:dA.position}));continue}let mA=gA[pA.toLowerCase()],QA=lA.attributes[mA];if(QA===void 0){IA.push(dA);continue}if(cA.includes(mA)){oA.push(codedDiagnostic({type:"warning",code:"doenet-w0075",args:{component:dA.componentType,name:pA},position:dA.position})),IA.push(dA);continue}if(QA.type!=="unresolved")throw Error("A module attribute that isn't an existing attribute must be unresolved!");const BA=deepClone(QA.children);setUnflattenedReferenceOrigins(BA,sA);const hA=expandUnflattenedToSerializedComponents({serializedComponents:BA,componentInfoObjects:tA,nComponents:iA,stateIdInfo:aA});oA.push(...hA.diagnostics),iA=hA.nComponents,dA.children=hA.components;const DA=applySugar({serializedComponents:[dA],componentInfoObjects:tA,nComponents:iA,stateIdInfo:aA});oA.push(...DA.diagnostics),iA=DA.nComponents,IA.push(DA.components[0])}const CA={type:"serialized",componentType:"setup",componentIdx:iA++,stateId:`${aA.prefix}${aA.num++}`,children:IA,attributes:{},doenetAttributes:{},state:{}};return rA.replacementsCreated=aA.num,{replacements:[CA],diagnostics:oA,nComponents:iA}}}class Footnote extends InlineComponent{static componentType="footnote";static renderChildren=!0;static componentDocs={summary:"Inline footnote whose body is shown on demand and is auto-numbered in the document"};static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"inlines",componentTypes:["_inline"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.text={description:"The footnote's body as plain text.",public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:function({dependencyValues:AA}){return{setValue:{text:textFromChildren(AA.inlineChildren)}}}},eA.footnoteTag={description:"The auto-generated marker (number) used to reference this footnote.",public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,mustEvaluate:!0,returnDependencies:()=>({footnoteCounter:{dependencyType:"counter",counterName:"footnote"}}),definition({dependencyValues:AA}){return{setValue:{footnoteTag:String(AA.footnoteCounter)}}}},eA}}class Caption extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="caption";static rendererType="containerInline";static canDisplayChildErrors=!0;static componentDocs={summary:"A caption attached to a figure or table"};static renderChildren=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"inlinesBlocks",componentTypes:["_inline","_block"]},{group:"errors",componentTypes:["_error"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.text={description:"The caption rendered as a plain text string.",public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlinesBlocks"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:function({dependencyValues:AA}){return{setValue:{text:textFromChildren(AA.inlineChildren)}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Endpoint extends Point{static componentType="endpoint";static rendererType="point";static componentDocs={summary:"A point that marks the endpoint of an interval, rendered open or closed"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.markerStyle={...eA.markerStyle,validValues:markerStyleValuesWithFillVariants},delete eA.markerFilled,eA.open={createComponentOfType:"boolean",createStateVariable:"open",defaultValue:!1,public:!0,forRenderer:!0,description:"Whether the endpoint is open (excluded) rather than closed (included)."},eA.switchable={createComponentOfType:"boolean",createStateVariable:"switchable",defaultValue:!1,public:!0,forRenderer:!0,description:"Whether the user can toggle the endpoint between open and closed by clicking it."},eA}async switchPoint({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.switchable)return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"open",value:!await this.stateValues.open}],actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{open:!await this.stateValues.open}}})}}function sortListClass(nA){return class extends reorderedValueListClass(nA){static componentType="_sortList";static createAttributesObject(){let AA=super.createAttributesObject();return Object.assign(AA,returnSortAttributes()),AA}static reorderedListClassFor(AA){return sortListClass(AA)}static returnEntryOrderDefinitions(){const AA=this.listEntryComponentType,tA=entryKind(AA),iA=this.listChildGroups.map(aA=>aA.group),rA={entryOrder:{stateVariablesDeterminingDependencies:["sortVectorsBy"],returnDependencies:({stateValues:aA})=>({childOrderValues:{dependencyType:"stateVariable",variableName:"childOrderValues"},sortByComponent:{dependencyType:"stateVariable",variableName:"sortByComponent"},...AA==="vector"&&aA.sortVectorsBy==="tail"?{childOrderTails:{dependencyType:"stateVariable",variableName:"childOrderTails"}}:{}}),definition({dependencyValues:aA}){const sA=(aA.childOrderTails??aA.childOrderValues).map(cA=>AA==="point"||AA==="vector"?comparableCoordinate(cA,aA.sortByComponent):comparableEntryValue(cA,tA)),lA=sA.every(cA=>cA.numeric);return{setValue:{entryOrder:[...sA.keys()].sort((cA,IA)=>compareExtractedValues(sA[cA],sA[IA],lA))},checkForActualChange:{entryOrder:!0}}}}};return AA==="vector"&&(rA.childOrderTails={returnDependencies:()=>({entryStructure:{dependencyType:"stateVariable",variableName:"childOrderEntryStructure"},children:{dependencyType:"child",childGroups:iA,variableNames:["tail"],variablesOptional:!0}}),definition:({dependencyValues:aA})=>({setValue:{childOrderTails:aA.entryStructure.map(oA=>coordinatesValue(aA.children[oA.componentInd]?.stateValues.tail??[0,0,0]))}})}),rA}}}function comparableEntryValue(nA,eA){if(eA==="number")return{numericalValue:nA,textValue:String(nA),numeric:!0};if(eA==="math"){const AA=nA.evaluate_to_constant();return{numericalValue:AA,textValue:nA.toString(),numeric:!Number.isNaN(AA)}}return{numericalValue:NaN,textValue:String(nA),numeric:!1}}function comparableCoordinate(nA,eA){const AA=coordinatesOf(nA)[eA-1];if(!AA)return{numericalValue:NaN,textValue:"",numeric:!0};const tA=AA.evaluate_to_constant();return{numericalValue:tA,textValue:AA.toString(),numeric:!Number.isNaN(tA)}}class SortList extends sortListClass(RegisteredNumberEntries){}function shuffledSource(nA,eA){if(typeof nA=="string"){const[AA,tA]=nA.split("|").map(Number),iA=eA[AA];return iA?{list:iA,listInd:tA}:void 0}return eA[nA]}class Shuffle extends CompositeComponent{static componentType="shuffle";static componentDocs={summary:"Randomly shuffles its children"};static takesIndex=!0;static allowInSchemaAnywhere=!0;static createsVariants=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.type={highlighted:!0,createPrimitiveOfType:"string",description:"Component type to read bare string children as. Omit it and they are read as what they look like: every piece naming a number makes them numbers, anything else makes them text.",validValues:[{value:"number",description:"Read bare strings as numbers."},{value:"math",description:"Read bare strings as math expressions."},{value:"text",description:"Read bare strings as text."},{value:"boolean",description:"Read bare strings as booleans."}]},eA.asList={highlighted:!0,createPrimitiveOfType:"boolean",createStateVariable:"asList",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoTypeSugarInstruction(this.componentType)),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.originalComponentIndices={additionalStateVariablesDefined:["numComponents"],returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["componentIndicesInList"],variablesOptional:!0}}),definition({dependencyValues:AA}){let tA=[];const iA=[];for(let rA of AA.children)typeof rA=="string"&&iA.push(codedDiagnostic({type:"warning",code:"doenet-w0015",args:{value:rA,component:"shuffle"}})),rA.stateValues?.componentIndicesInList?tA.push(...rA.stateValues.componentIndicesInList):rA.listEntryIndex!==void 0?tA.push(`${rA.componentIdx}|${rA.listEntryIndex}`):tA.push(rA.componentIdx);return{setValue:{originalComponentIndices:tA,numComponents:tA.length},sendDiagnostics:iA}}},eA.componentOrder={returnDependencies({sharedParameters:AA}){return{variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},numComponents:{dependencyType:"stateVariable",variableName:"numComponents"},variants:{dependencyType:"variants"}}},definition({dependencyValues:AA}){let tA=[],iA=AA.numComponents,rA=AA.variants?.desiredVariant?.indices;if(rA!==void 0)if(rA.length!==iA)tA.push(codedDiagnostic({type:"info",code:"doenet-i0006"}));else{if(rA=rA.map(Number),!rA.every(Number.isInteger))throw Error("All indices specified for shuffle must be integers");if(!rA.every(sA=>sA>=1&&sA<=iA))tA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"shuffle"}}));else return{setValue:{componentOrder:rA.filter(sA=>sA!==void 0)}}}let aA=AA.rngClass(AA.variantSeed+"co"),oA=[...Array(iA).keys()].map(sA=>sA+1);for(let sA=iA-1;sA>0;sA--){const lA=aA(),gA=Math.floor(lA*(sA+1));[oA[sA],oA[gA]]=[oA[gA],oA[sA]]}return{setValue:{componentOrder:oA},sendDiagnostics:tA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({sortedValues:{dependencyType:"stateVariable",variableName:"componentOrder"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},componentOrder:{dependencyType:"stateVariable",variableName:"componentOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let iA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.componentOrder},rA=iA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:iA,isVariantComponent:!0}}}},eA}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static async createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:iA,nComponents:rA}){let aA=[],oA=[],sA=[];iA.replacementsCreated===void 0&&(iA.replacementsCreated=0);const lA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};let gA=await eA.stateValues.originalComponentIndices;const cA=[];for(let IA of await eA.stateValues.componentOrder){const uA=gA[IA-1];let CA=shuffledSource(uA,AA);CA&&(sA.push(uA),cA.push(CA))}return{replacements:oA,nComponents:rA}=await this.copyReplacementSources({component:eA,replacementSources:cA,nComponents:rA,stateIdInfo:lA}),iA.componentsCopied=sA,iA.replacementsCreated=lA.num,{replacements:oA,diagnostics:aA,nComponents:rA}}static async copyReplacementSources({component:eA,replacementSources:AA,nComponents:tA,stateIdInfo:iA}){let rA=[];for(const aA of AA){if(aA.list){const lA=listEntryReplacement({list:aA.list,listInd:aA.listInd,nComponents:tA,stateIdInfo:iA});tA=lA.nComponents,rA.push(lA.serializedComponent);continue}const oA=await aA.serialize(),sA=createNewComponentIndices([oA],tA,iA);tA=sA.nComponents,rA.push(...sA.components)}return rA=postProcessCopy({serializedComponents:rA,componentIdx:eA.componentIdx,addShadowDependencies:!0,markAsPrimaryShadow:!0}),{replacements:rA,nComponents:tA}}static async recreateMissingReplacements({component:eA,components:AA,workspace:tA,nComponents:iA,diagnostics:rA}){const aA=[],oA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated};let sA=0;for(const[lA,gA]of tA.componentsCopied.entries()){const cA=eA.replacements[sA];if(typeof gA=="string"?cA!==void 0:cA?.shadows?.componentIdx===gA){sA++;continue}const IA=shuffledSource(gA,AA);if(!IA)continue;const uA=await this.copyReplacementSources({component:eA,replacementSources:[IA],nComponents:iA,stateIdInfo:oA});iA=uA.nComponents,aA.push({changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:lA,numberReplacementsToReplace:0,numberDeletedReplacementsToReplace:1,serializedReplacements:uA.replacements})}return tA.replacementsCreated=oA.num,{replacementChanges:aA,diagnostics:rA,nComponents:iA}}static async calculateReplacementChanges({component:eA,components:AA,componentInfoObjects:tA,workspace:iA,nComponents:rA}){let aA=[],oA=[],sA=await eA.stateValues.originalComponentIndices;for(let IA of await eA.stateValues.componentOrder){const uA=sA[IA-1];shuffledSource(uA,AA)&&oA.push(uA)}if(oA.length==iA.componentsCopied.length&&iA.componentsCopied.every((IA,uA)=>IA===oA[uA]))return await this.recreateMissingReplacements({component:eA,components:AA,workspace:iA,nComponents:rA,diagnostics:aA});let lA=await this.createSerializedReplacements({component:eA,components:AA,componentInfoObjects:tA,workspace:iA,nComponents:rA}),gA=lA.replacements;return aA.push(...lA.diagnostics),rA=lA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:gA}],diagnostics:aA,nComponents:rA}}static numberOfShuffledChildren({serializedComponent:eA,componentInfoObjects:AA}){let tA=0;for(let iA of eA.children){if(AA.allComponentClasses[iA.componentType]?.listEntryComponentType!==void 0)return;if(AA.isInheritedComponentType({inheritedComponentType:iA.componentType,baseComponentType:"_composite"}))if(iA.attributes.createComponentOfType?.primitive)if(iA.attributes.numComponents?.primitive!==void 0){let rA=Number(iA.attributes.numComponents?.primitive.value);if(Number.isInteger(rA)&&rA>=0)tA+=rA;else return}else tA++;else return;else tA++}return tA}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){const iA=this.numberOfShuffledChildren({serializedComponent:eA,componentInfoObjects:AA});if(iA===void 0)return{success:!1};let rA=1;for(let sA=2;sA<=iA;sA++)rA*=sA;let aA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!aA.success)return{success:!1};let oA=aA.numVariants*rA;return oA>0?(eA.variants.numVariants=oA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:rA,numComponents:iA},{success:!0,numVariants:oA}):{success:!1}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let iA=eA.variants?.numVariants;if(iA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>iA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numComponents,lA=[...rA];lA.push(oA);let gA=enumerateCombinations({numberOfOptionsByIndex:lA,maxNumber:AA})[AA-1].map(QA=>QA+1),cA=gA.pop(),IA=gA,uA=[...Array(sA).keys()].map(QA=>QA+1),CA=enumeratePermutations({values:uA,maxNumber:cA})[cA-1],dA=!1,pA=[];for(let QA=0;QA<rA.length;QA++)if(rA[QA]>1){let BA=aA[QA],DA=tA.allComponentClasses[BA.componentType].getUniqueVariant({serializedComponent:BA,variantIndex:IA[QA],componentInfoObjects:tA});if(!DA.success)return{success:!1};pA.push(DA.desiredVariant),dA=!0}else pA.push({});let mA={indices:CA};return dA&&(mA.subvariants=pA),{success:!0,desiredVariant:mA}}}function shuffleListClass(nA){return class extends reorderedValueListClass(nA){static componentType="_shuffleList";static createsVariants=!0;static createAttributesObject(){let AA=super.createAttributesObject();return AA.type=Shuffle.createAttributesObject().type,AA}static reorderedListClassFor(AA){return shuffleListClass(AA)}static returnEntryOrderDefinitions(){const AA=Shuffle.returnStateVariableDefinitions(),tA=AA.componentOrder;return{numValuesShuffled:{returnDependencies:()=>({childOrderEntryStructure:{dependencyType:"stateVariable",variableName:"childOrderEntryStructure"}}),definition:({dependencyValues:iA})=>({setValue:{numValuesShuffled:iA.childOrderEntryStructure.length}})},componentOrder:{...tA,returnDependencies(iA){return{...tA.returnDependencies(iA),numComponents:{dependencyType:"stateVariable",variableName:"numValuesShuffled"}}}},generatedVariantInfo:AA.generatedVariantInfo,entryOrder:{returnDependencies:()=>({componentOrder:{dependencyType:"stateVariable",variableName:"componentOrder"}}),definition:({dependencyValues:iA})=>({setValue:{entryOrder:iA.componentOrder.map(rA=>rA-1)},checkForActualChange:{entryOrder:!0}})}}}static setUpVariant(AA){return Shuffle.setUpVariant(AA)}static getUniqueVariant(AA){return Shuffle.getUniqueVariant(AA)}static determineNumberOfUniqueVariants(AA){return Shuffle.determineNumberOfUniqueVariants.call(this,AA)}static numberOfShuffledChildren({serializedComponent:AA,componentInfoObjects:tA}){let iA=0;const rA=[];for(const oA of AA.children)typeof oA=="string"?iA+=this.splitTextIntoPieces(oA)?.length??0:rA.push(oA);const aA=Shuffle.numberOfShuffledChildren({serializedComponent:{...AA,children:rA},componentInfoObjects:tA});return aA===void 0?void 0:aA+iA}}}class ShuffleList extends shuffleListClass(RegisteredNumberEntries){}class SortIndices extends ValueListComponent{static componentType="sortIndices";static componentDocs={summary:"The indices that put a list in sorted order, rather than the sorted values"};static listEntryComponentType="number";static listEntryValuesVariable="sortedIndices";static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnSortAttributes()),eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoTypeSugarInstruction(this.componentType)),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnListValueStateVariableDefinitions({componentName:this.componentType,supportProps:!0})),eA.sortedValues=returnSortedValuesDefinition(),eA.sortedIndices={returnDependencies:()=>({sortedValues:{dependencyType:"stateVariable",variableName:"sortedValues"},componentIndicesForValues:{dependencyType:"stateVariable",variableName:"componentIndicesForValues"}}),definition({dependencyValues:AA}){let tA=new Map;for(let[rA,aA]of AA.componentIndicesForValues.entries()){const oA=typeof aA=="object"?`${aA.componentIdx}|${aA.listInd}`:aA;tA.has(oA)||tA.set(oA,rA+1)}let iA=[];for(let rA of AA.sortedValues){const aA=rA.listInd!==void 0?`${rA.componentIdx}|${rA.listInd}`:rA.componentIdx;let oA=tA.get(aA);oA!==void 0&&iA.push(oA)}return{setValue:{sortedIndices:iA}}}},eA}}class SolveEquations extends InlineComponent{static componentType="solveEquations";static componentDocs={summary:"Numerically solves a system of equations"};static rendererType=void 0;static variableForIndexAsProp="solutions";static createAttributesObject(){let eA=super.createAttributesObject();return eA.variables={createComponentOfType:"_variableNameList",description:"Names of the variables to solve for."},eA.numDiscretizationPoints={description:"Number of points used when searching for solutions numerically.",createComponentOfType:"number",createStateVariable:"numDiscretizationPoints",defaultValue:100,public:!0},eA.minVar={createComponentOfType:"number",createStateVariable:"minVar",defaultValue:null,description:"Lower bound of the variable's search range."},eA.maxVar={createComponentOfType:"number",createStateVariable:"maxVar",defaultValue:null,description:"Upper bound of the variable's search range."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){return tA.every(aA=>typeof aA=="string"||aA.extending&&"Ref"in aA.extending)?tA.length===1&&typeof tA[0]!="string"?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:iA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]},{group:"strings",componentTypes:["string"]}]}static returnStateVariableDefinitions(eA){let AA=super.returnStateVariableDefinitions(eA);return AA.variables={description:"The variables of the equations.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},entryPrefixes:["variable"],returnArraySizeDependencies:()=>({}),returnArraySize({dependencyValues:tA}){return[1]},returnArrayDependenciesByKey({arrayKeys:tA}){return{globalDependencies:{variablesAttr:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["variables"]}}}},arrayDefinitionByKey({globalDependencyValues:tA,arraySize:iA,arrayKeys:rA,usedDefault:aA}){let oA=[];return tA.variablesAttr!==null&&(oA=tA.variablesAttr.stateValues.variables),{setValue:{variables:returnNVariables(iA[0],oA)}}}},AA.variable={isAlias:!0,targetVariableName:"variable1",description:"The first variable being solved for."},AA.allSolutions={returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},variables:{dependencyType:"stateVariable",variableName:"variables"},minVar:{dependencyType:"stateVariable",variableName:"minVar"},maxVar:{dependencyType:"stateVariable",variableName:"maxVar"},numDiscretizationPoints:{dependencyType:"stateVariable",variableName:"numDiscretizationPoints"}}),definition({dependencyValues:tA}){if(tA.mathChild.length===0)return{setValue:{allSolutions:[]}};let iA=tA.mathChild[0].stateValues.value;if(!(Array.isArray(iA.tree)&&iA.tree.length===3&&iA.tree[0]==="="))return{setValue:{allSolutions:[]}};let rA=tA.minVar,aA=tA.maxVar,oA=[],sA=tA.variables[0].subscripts_to_strings().tree,lA=context.fromAst(["+",iA.tree[1],["-",iA.tree[2]]]).subscripts_to_strings(),gA;try{gA=lA.f()}catch{let NA=[codedDiagnostic({type:"warning",code:"doenet-w0057",args:{equation:iA.toString()}})];return{setValue:{allSolutions:[]},sendDiagnostics:NA}}let cA=fA=>gA({[sA]:fA}),IA=fA=>normalizeMathExpression({value:lA.substitute({[sA]:fA}).strings_to_subscripts(),simplify:!0,expand:!0}).evaluate_to_constant(),uA=function(fA){try{return cA(fA)}catch{return NaN}},CA=function(fA){try{return cA(fA)}catch{return toNumberOrNaN(IA(fA))}};if(Number.isFinite(rA)||(rA=-10),Number.isFinite(aA)||(aA=10),rA>aA)return{setValue:{allSolutions:[]}};let dA=[rA,aA],pA=[rA];for(let fA=0;fA<dA.length-1;fA++){let NA=dA[fA],yA=dA[fA+1],bA=tA.numDiscretizationPoints,wA=(yA-NA)/bA;for(let MA=1;MA<bA;MA++)pA.push(NA+MA*wA);pA.push(yA)}let mA=2*pA[0]-pA[1],QA=2*pA[pA.length-1]-pA[pA.length-2];pA=[mA,...pA,QA];let BA=pA.map(CA),hA=pA[0],DA=BA[0];for(let fA=0;fA<pA.length;fA++){let NA=pA[fA],yA=BA[fA];if(!Number.isFinite(yA)||!Number.isFinite(DA)){let bA,wA;if(Number.isFinite(yA)?(bA=NA,wA=hA):Number.isFinite(DA)&&(bA=hA,wA=NA),bA!==void 0){for(;;){let MA=(bA+wA)/2;if(MA===bA||MA===wA)break;Number.isFinite(uA(MA))?bA=MA:wA=MA}[NA,hA].includes(bA)||(pA.splice(fA,0,bA),BA.splice(fA,0,uA(bA)))}}hA=NA,DA=yA}oA=[],hA=pA[0],DA=BA[0],DA===0&&oA.push(hA);for(let fA=1;fA<pA.length;fA++){let NA=pA[fA],yA=BA[fA];if(yA===0){let bA=!1;if(fA<pA.length-1){let wA=pA[fA+1],MA=BA[fA+1],vA=hA,kA=DA;if(DA*MA>0){for(let TA=0;TA<10;TA++)if(hA=.1*hA+.9*NA,wA=.1*wA+.9*NA,DA=uA(hA),MA=uA(wA),DA*MA<0){DA*kA<0?(oA.push(eA.fzero(uA,[vA,hA])),oA.push(NA)):(oA.includes(NA)||oA.push(NA),NA=wA,yA=MA),bA=!0;break}}}!bA&&!oA.includes(NA)&&oA.push(NA)}else if(yA*DA<0)oA.push(eA.fzero(uA,[hA,NA]));else if(DA!==0&&fA<pA.length-1){let bA=pA[fA+1],wA=BA[fA+1];if((DA-yA)*(wA-yA)>0&&(yA>0&&DA>yA||yA<0&&DA<yA)){let MA;DA>yA?MA=uA:MA=kA=>-uA(kA);let vA=eA.fminbr(MA,[hA,bA],void 0,1e-10);if(vA.success){let kA=vA.x,TA=uA(kA);TA*DA<0?(oA.push(eA.fzero(uA,[hA,kA])),NA=kA,yA=TA):TA===0&&oA.push(kA)}}}hA=NA,DA=yA}return oA=oA.filter(fA=>fA>=rA&&fA<=aA),{setValue:{allSolutions:oA.map(fA=>context.fromAst(fA))}}}},AA.numSolutions={description:"The number of numerical solutions found.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({allSolutions:{dependencyType:"stateVariable",variableName:"allSolutions"}}),definition({dependencyValues:tA}){return{setValue:{numSolutions:tA.allSolutions.length}}}},AA.solutions={description:"The numerical solutions of the equations.",public:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["solution"],returnArraySizeDependencies:()=>({numSolutions:{dependencyType:"stateVariable",variableName:"numSolutions"}}),returnArraySize({dependencyValues:tA}){return[tA.numSolutions]},returnArrayDependenciesByKey(){return{globalDependencies:{allSolutions:{dependencyType:"stateVariable",variableName:"allSolutions"}}}},arrayDefinitionByKey({globalDependencyValues:tA}){let iA={};for(let rA=0;rA<tA.__array_size[0];rA++)iA[rA]=tA.allSolutions[rA];return{setValue:{solutions:iA}}}},AA}}class PostponeRenderContainer extends Group{static componentType="_postponeRenderContainer";static componentDocs={summary:"Internal container that postpones rendering of its children."};static inSchemaOnlyInheritAs=[];static allowInSchemaAnywhere=!1;static renderedDefault=!1;static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.rendered,eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.rendered={returnDependencies:()=>({parentRendered:{dependencyType:"parentStateVariable",variableName:"rendered"}}),markStale:()=>({updateReplacements:!0}),definition({dependencyValues:AA}){return{setValue:{rendered:!!AA.parentRendered}}}},eA}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA}){let rA=[];if(await eA.stateValues.rendered&&eA.replacements.length===0){let aA=await this.createSerializedReplacements({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA}),oA=aA.replacements;return rA.push(...aA.diagnostics),tA=aA.nComponents,oA.length>0?{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:0,serializedReplacements:oA}],diagnostics:rA,nComponents:tA}:{replacementChanges:[],diagnostics:rA,nComponents:tA}}else return{replacementChanges:[],diagnostics:rA,nComponents:tA}}}class SubsetOfReals extends MathComponent{static componentType="subsetOfReals";static componentDocs={summary:"A subset of the real numbers, defined by intervals and points"};static rendererType="math";static primaryStateVariableForDefinition="subsetValue";static stateVariableToBeShadowed="subsetValue";static createAttributesObject(){let eA=super.createAttributesObject();return eA.createIntervals.defaultValue=!0,eA.variable={createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),description:"Name of the variable used when expressing the subset."},eA.displayMode={description:"How the subset is displayed.",createComponentOfType:"text",createStateVariable:"displayMode",defaultValue:"intervals",public:!0,toLowerCase:!0,validValues:[{value:"intervals",description:"Display the subset using interval notation (e.g., `(0, 1]`)."},{value:"inequalities",description:"Display the subset using inequalities (e.g., `0 < x ≤ 1`)."}]},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();renameStateVariable({stateVariableDefinitions:eA,oldName:"unnormalizedValue",newName:"unnormalizedValuePreliminary"}),eA.value.shadowingInstructions.createComponentOfType="math",eA.haveSingleSubsetChild={returnDependencies:()=>({mathChildren:{dependencyType:"child",childGroups:["maths"]}}),definition({dependencyValues:tA,componentInfoObjects:iA}){return{setValue:{haveSingleSubsetChild:tA.mathChildren.length===1&&tA.mathChildren.filter(aA=>iA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:"subsetOfReals"})).length===1}}}},eA.subsetValue={stateVariablesDeterminingDependencies:["haveSingleSubsetChild"],returnDependencies({stateValues:tA}){let iA={haveSingleSubsetChild:{dependencyType:"stateVariable",variableName:"haveSingleSubsetChild"}};return tA.haveSingleSubsetChild?iA.subsetChild={dependencyType:"child",childGroups:["maths"],variableNames:["subsetValue"]}:(iA.unnormalizedValuePreliminary={dependencyType:"stateVariable",variableName:"unnormalizedValuePreliminary"},iA.variable={dependencyType:"stateVariable",variableName:"variable"}),iA},definition({dependencyValues:tA}){let iA;return tA.haveSingleSubsetChild?iA=tA.subsetChild[0].stateValues.subsetValue:iA=buildSubsetFromMathExpression(tA.unnormalizedValuePreliminary,tA.variable),{setValue:{subsetValue:iA}}},async inverseDefinition({desiredStateVariableValues:tA,dependencyValues:iA,stateValues:rA}){return iA.haveSingleSubsetChild?{success:!0,instructions:[{setDependency:"subsetChild",desiredValue:tA.subsetValue,childIndex:0,variableIndex:0}]}:{success:!0,instructions:[{setDependency:"unnormalizedValuePreliminary",desiredValue:mathExpressionFromSubsetValue({subsetValue:tA.subsetValue,variable:iA.variable,displayMode:await rA.displayMode})}]}}},eA.unnormalizedValue={returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"},displayMode:{dependencyType:"stateVariable",variableName:"displayMode"},variable:{dependencyType:"stateVariable",variableName:"variable"}}),definition({dependencyValues:tA}){return{setValue:{unnormalizedValue:mathExpressionFromSubsetValue(tA)}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:iA}){return{success:!0,instructions:[{setDependency:"subsetValue",desiredValue:buildSubsetFromMathExpression(tA.unnormalizedValue,iA.variable)}]}}};const AA=returnPointsIntervalsFromSubsetStateVariableDefinitions();return Object.assign(eA,AA),eA}}function returnPointsIntervalsFromSubsetStateVariableDefinitions(){let nA={};return nA.pointsFromSubset={additionalStateVariablesDefined:["intervalsFromSubset"],returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"}}),definition({dependencyValues:eA}){let{points:AA,intervals:tA}=determinePointAndIntervalsFromSubset(eA.subsetValue);return{setValue:{pointsFromSubset:AA,intervalsFromSubset:tA}}}},nA.points={additionalStateVariablesDefined:[{variableName:"pointsClosed",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"boolean"},description:"Whether each boundary point of the subset is a closed (included) endpoint."}],description:"The boundary points that delimit the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["point"],returnArraySizeDependencies:()=>({pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"}}),returnArraySize({dependencyValues:eA}){return[eA.pointsFromSubset.length]},returnArrayDependenciesByKey(){return{globalDependencies:{pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"}}}},arrayDefinitionByKey({globalDependencyValues:eA,arrayKeys:AA}){let tA={},iA={};for(let rA of AA){let aA=eA.pointsFromSubset[rA];tA[rA]=context.fromAst(aA.value),iA[rA]=aA.inSubset}return{setValue:{points:tA,pointsClosed:iA}}}},nA.allIntervals={additionalStateVariablesDefined:["allIsolatedPoints"],returnDependencies:()=>({subsetValue:{dependencyType:"stateVariable",variableName:"subsetValue"}}),definition({dependencyValues:eA}){let AA=[],tA=[],iA=mergeIntervals(eA.subsetValue);for(let rA of iA)rA.type==="closedInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!0,!0]])):rA.type==="openClosedInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!1,!0]])):rA.type==="closedOpenInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!0,!1]])):rA.type==="openInterval"?AA.push(context.fromAst(["interval",["tuple",rA.left,rA.right],["tuple",!1,!1]])):rA.type==="realLine"?AA.push(context.fromAst(["interval",["tuple",-1/0,1/0],["tuple",!1,!1]])):rA.type==="singleton"&&tA.push(rA.element);return{setValue:{allIntervals:AA,allIsolatedPoints:tA}}}},nA.intervals={description:"The intervals (non-degenerate components) of the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["interval"],returnArraySizeDependencies:()=>({allIntervals:{dependencyType:"stateVariable",variableName:"allIntervals"}}),returnArraySize({dependencyValues:eA}){return[eA.allIntervals.length]},returnArrayDependenciesByKey(){return{globalDependencies:{allIntervals:{dependencyType:"stateVariable",variableName:"allIntervals"}}}},arrayDefinitionByKey({globalDependencyValues:eA}){return{setValue:{intervals:eA.allIntervals}}}},nA.isolatedPoints={description:"The isolated (non-interval) points of the subset.",public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,entryPrefixes:["isolatedPoint"],returnArraySizeDependencies:()=>({allIsolatedPoints:{dependencyType:"stateVariable",variableName:"allIsolatedPoints"}}),returnArraySize({dependencyValues:eA}){return[eA.allIsolatedPoints.length]},returnArrayDependenciesByKey(){return{globalDependencies:{allIsolatedPoints:{dependencyType:"stateVariable",variableName:"allIsolatedPoints"}}}},arrayDefinitionByKey({globalDependencyValues:eA}){return{setValue:{isolatedPoints:eA.allIsolatedPoints}}}},nA}function determinePointAndIntervalsFromSubset(nA){function eA(rA,aA){let oA=[],sA=[];if(rA.points&&(oA=rA.points),rA.intervals&&(sA=rA.intervals),aA.points){let lA=oA.map(gA=>gA.value);for(let gA of aA.points){let cA=lA.indexOf(gA.value);cA===-1?oA.push(gA):oA[cA].inSubset||=gA.inSubset}}return aA.intervals&&sA.push(...aA.intervals),{points:oA,intervals:sA}}function AA(rA){if(rA===null||rA.isEmpty())return{};if(rA.type==="union"){let aA=[],oA=[];for(let sA of rA.subsets){let lA=AA(sA);({points:aA,intervals:oA}=eA({points:aA,intervals:oA},lA))}return{points:aA,intervals:oA}}else{if(rA.type==="realLine")return{intervals:[[-1/0,1/0]]};if(rA.type==="singleton")return{points:[{value:rA.element,inSubset:!0}]};if(rA.type==="openInterval"){let aA=[[rA.left,rA.right]],oA=[];return Number.isFinite(rA.left)&&oA.push({value:rA.left,inSubset:!1}),Number.isFinite(rA.right)&&oA.push({value:rA.right,inSubset:!1}),{intervals:aA,points:oA}}}return{}}let{points:tA,intervals:iA}=AA(nA);return tA||=[],iA||=[],tA.sort((rA,aA)=>rA.value-aA.value),iA.sort((rA,aA)=>rA[0]-aA[0]),{points:tA,intervals:iA}}class SubsetOfRealsInput extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{addPoint:this.addPoint.bind(this),deletePoint:this.deletePoint.bind(this),movePoint:this.movePoint.bind(this),togglePoint:this.togglePoint.bind(this),toggleInterval:this.toggleInterval.bind(this),clear:this.clear.bind(this),setToR:this.setToR.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="subsetOfRealsInput";static componentDocs={summary:"An interactive number-line widget for entering a subset of real numbers (block-level; does not inherit from Input)"};static variableForImplicitProp="subsetValue";static createAttributesObject(){let eA=super.createAttributesObject();return eA.xMin={description:"Left endpoint of the visible number line.",createComponentOfType:"number",createStateVariable:"xMin",defaultValue:-10,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.xMax={description:"Right endpoint of the visible number line.",createComponentOfType:"number",createStateVariable:"xMax",defaultValue:10,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.width={description:"Display width of the input.",createComponentOfType:"componentSize",createStateVariable:"width",defaultValue:800,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.height={description:"Display height of the input.",createComponentOfType:"componentSize",createStateVariable:"height",defaultValue:300,public:!0,forRenderer:!0,excludeFromSchema:!0},eA.xlabel={description:"Label rendered for the x axis.",createComponentOfType:"text",createStateVariable:"xlabel",defaultValue:"",public:!0,forRenderer:!0,excludeFromSchema:!0},eA.dx={description:"Tick spacing along the number line.",createComponentOfType:"number",createStateVariable:"dx",defaultValue:.5,public:!0,excludeFromSchema:!0},eA.variable={description:"Variable name displayed on the number line.",createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),public:!0},eA.format={description:"Input format used for parsing entered subsets.",createComponentOfType:"text",createStateVariable:"format",defaultValue:"text",public:!0,toLowerCase:!0,validValues:[{value:"text",description:"Parse entered subsets as plain-text notation."},{value:"latex",description:"Parse entered subsets as LaTeX notation."}]},eA.prefill={description:"Initial subset displayed in the input.",createComponentOfType:"text",createStateVariable:"prefill",defaultValue:"",public:!0},eA.bindValueTo={createComponentOfType:"subsetOfReals",description:"Two-way binding target for the input's value."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();eA.subsetValue={description:"The current subset of the reals entered by the user.",public:!0,shadowingInstructions:{createComponentOfType:"subsetOfReals",addAttributeComponentsShadowingStateVariables:{variable:{stateVariableToShadow:"variable"}}},hasEssential:!0,returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo",variableNames:["subsetValue"]},prefill:{dependencyType:"stateVariable",variableName:"prefill"},variable:{dependencyType:"stateVariable",variableName:"variable"},format:{dependencyType:"stateVariable",variableName:"format"}}),definition:function({dependencyValues:tA}){return tA.bindValueTo?{setValue:{subsetValue:tA.bindValueTo.stateValues.subsetValue}}:{useEssentialOrDefaultValue:{subsetValue:{get defaultValue(){return parseValueIntoSubset({inputString:tA.prefill,format:tA.format,variable:tA.variable})}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:iA}){return iA.bindValueTo?{success:!0,instructions:[{setDependency:"bindValueTo",desiredValue:tA.subsetValue,variableIndex:0}]}:{success:!0,instructions:[{setEssentialValue:"subsetValue",value:tA.subsetValue}]}}},eA.additionalPoints={defaultValue:[],hasEssential:!0,returnDependencies:()=>({}),definition(){return{useEssentialOrDefaultValue:{additionalPoints:!0}}},inverseDefinition({desiredStateVariableValues:tA}){return tA.additionalPoints.every(Number.isFinite)?{success:!0,instructions:[{setEssentialValue:"additionalPoints",value:[...tA.additionalPoints].sort((iA,rA)=>iA-rA)}]}:{success:!1}}},eA.pointsDisplayed={additionalStateVariablesDefined:[{variableName:"intervalsDisplayed",forRenderer:!0}],forRenderer:!0,returnDependencies:()=>({pointsFromSubset:{dependencyType:"stateVariable",variableName:"pointsFromSubset"},intervalsFromSubset:{dependencyType:"stateVariable",variableName:"intervalsFromSubset"},additionalPoints:{dependencyType:"stateVariable",variableName:"additionalPoints"}}),definition({dependencyValues:tA}){let iA=[...tA.pointsFromSubset],rA=[...tA.intervalsFromSubset],aA=[...tA.additionalPoints].sort((CA,dA)=>CA-dA),oA=[],sA=[],lA=0,gA=1/0,cA=0;aA.length>0&&(gA=aA[0]);let IA=rA[0],uA=-1/0;iA.push({value:1/0,inSubset:!1});for(let CA of iA){let dA=!1;for(IA&&IA[0]<CA.value&&(dA=!0);gA<CA.value;)gA!==uA&&(oA.push({value:gA,inSubset:dA,isAdditional:!0,additionalPointInd:cA}),sA.push({left:uA,right:gA,inSubset:dA}),uA=gA),cA++,gA=aA[cA],gA===void 0&&(gA=1/0);oA.push(CA),sA.push({left:uA,right:CA.value,inSubset:dA}),uA=CA.value,dA&&(lA++,IA=rA[lA])}return oA=oA.slice(0,oA.length-1),{setValue:{pointsDisplayed:oA,intervalsDisplayed:sA}}}};const AA=returnPointsIntervalsFromSubsetStateVariableDefinitions();return Object.assign(eA,AA),eA}async addPoint({value:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){let rA=await this.stateValues.dx,aA=Math.round(Math.max(await this.stateValues.xMin,Math.min(await this.stateValues.xMax,eA))/rA)*rA,oA=[...await this.stateValues.pointsFromSubset],sA=[...await this.stateValues.intervalsFromSubset],lA=[...await this.stateValues.additionalPoints];if(!lA.includes(aA)&&!oA.map(cA=>cA.value).includes(aA)){let cA=!1;for(let IA of sA)if(IA[0]<aA&&IA[1]>aA){cA=!0;break}if(cA)return lA.push(aA),await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:lA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{addedPoint:aA,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:lA}}});{oA.push({value:aA,inSubset:!0});let IA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:!1,additionalPoints:lA});return await this.coreFunctions.performUpdate({updateInstructions:IA,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{addedPoint:aA,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:lA}}})}}}async deletePoint({pointInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){let rA=await this.stateValues.pointsDisplayed[eA],aA=[...await this.stateValues.additionalPoints],oA=[...await this.stateValues.pointsFromSubset],sA=[...await this.stateValues.intervalsFromSubset];if(rA.isAdditional)return aA.splice(rA.additionalPointInd,1),await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:aA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{deletedPoint:rA.value,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:aA}}});{let lA=!1,gA=oA.map(CA=>CA.value).indexOf(rA.value),cA=sA.map(CA=>CA[1]).indexOf(rA.value),IA=sA.map(CA=>CA[0]).indexOf(rA.value);if(cA!==-1)if(IA!==-1)sA[cA]=[sA[cA][0],sA[IA][1]],sA.splice(IA,1),oA.splice(gA,1);else{let CA=(await this.stateValues.pointsDisplayed)[eA-1];CA&&CA.isAdditional?(sA[cA]=[sA[cA][0],CA.value],aA.splice(CA.additionalPointInd,1),lA=!0,oA.splice(gA,1,CA)):(sA.splice(cA,1),oA.splice(gA,1),CA&&!CA.inSubset&&sA.map(pA=>pA[1]).indexOf(CA.value)===-1&&(aA.push(CA.value),lA=!0))}else if(IA!==-1){let CA=(await this.stateValues.pointsDisplayed)[eA+1];CA&&CA.isAdditional?(sA[IA]=[CA.value,sA[IA][1]],aA.splice(CA.additionalPointInd,1),lA=!0,oA.splice(gA,1,CA)):(sA.splice(IA,1),oA.splice(gA,1),CA&&!CA.inSubset&&sA.map(pA=>pA[0]).indexOf(CA.value)===-1&&(aA.push(CA.value),lA=!0))}else oA.splice(gA,1);let uA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:lA,additionalPoints:aA});return await this.coreFunctions.performUpdate({updateInstructions:uA,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{deletedPoint:rA.value,intervalsFromSubset:sA,pointsFromSubset:oA,additionalPoints:aA}}})}}async createUpdateInstructions({intervalsFromSubset:eA,pointsFromSubset:AA,modifiedAdditionalPoints:tA,additionalPoints:iA}){let rA=await this.stateValues.dx,aA=gA=>Math.round(gA/rA)*rA,oA=[];for(let gA of eA)oA.push(subsetOfReals.OpenInterval(aA(gA[0]),aA(gA[1])));for(let gA of AA)gA.inSubset&&oA.push(subsetOfReals.Singleton(aA(gA.value)));let sA;oA.length===0?sA=subsetOfReals.EmptySet():oA.length===1?sA=oA[0]:sA=subsetOfReals.Union(oA);let lA=[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"subsetValue",value:sA}];return tA&&lA.push({componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:iA.map(aA)}),lA}async movePoint({pointInd:eA,value:AA,transient:tA,actionId:iA,sourceInformation:rA={},skipRendererUpdate:aA=!1}){let oA=await this.stateValues.dx,sA=Math.round(Math.max(await this.stateValues.xMin,Math.min(await this.stateValues.xMax,AA))/oA)*oA,lA=await this.stateValues.pointsDisplayed,gA=lA[eA],cA=lA[eA-1];cA&&(sA=Math.max(sA,cA.value+oA));let IA=lA[eA+1];IA&&(sA=Math.min(sA,IA.value-oA));let uA=[...await this.stateValues.additionalPoints],CA=[...await this.stateValues.pointsFromSubset],dA=[...await this.stateValues.intervalsFromSubset];if(gA.isAdditional)return uA[gA.additionalPointInd]=sA,tA?await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:uA}],transient:!0,actionId:iA,sourceInformation:rA,skipRendererUpdate:aA}):await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:uA}],actionId:iA,sourceInformation:rA,skipRendererUpdate:aA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{movedPoint:sA,intervalsFromSubset:dA,pointsFromSubset:CA,additionalPoints:uA}}});{let pA=CA.map(hA=>hA.value).indexOf(gA.value),mA=dA.map(hA=>hA[1]).indexOf(gA.value),QA=dA.map(hA=>hA[0]).indexOf(gA.value);CA[pA]={value:sA,inSubset:CA[pA].inSubset},mA!==-1&&(dA[mA]=[dA[mA][0],sA]),QA!==-1&&(dA[QA]=[sA,dA[QA][1]]);let BA=await this.createUpdateInstructions({intervalsFromSubset:dA,pointsFromSubset:CA,modifiedAdditionalPoints:!1});return tA?await this.coreFunctions.performUpdate({updateInstructions:BA,transient:!0,actionId:iA,sourceInformation:rA,skipRendererUpdate:aA}):await this.coreFunctions.performUpdate({updateInstructions:BA,actionId:iA,sourceInformation:rA,skipRendererUpdate:aA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{movedPoint:sA,intervalsFromSubset:dA,pointsFromSubset:CA,additionalPoints:uA}}})}}async togglePoint({pointInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){let rA=(await this.stateValues.pointsDisplayed)[eA],aA=[...await this.stateValues.pointsFromSubset],oA=[...await this.stateValues.intervalsFromSubset],sA=[...await this.stateValues.additionalPoints],lA=!1;if(rA.isAdditional)if(sA.splice(rA.additionalPointInd,1),lA=!0,rA.inSubset){for(let[cA,IA]of oA.entries())if(IA[0]<rA.value&&IA[1]>rA.value){let uA=[[IA[0],rA.value],[rA.value,IA[1]]];oA.splice(cA,1,...uA);break}}else aA.push({value:rA.value,inSubset:!0});else{let cA=aA.map(CA=>CA.value).indexOf(rA.value),IA=oA.map(CA=>CA[1]).indexOf(rA.value),uA=oA.map(CA=>CA[0]).indexOf(rA.value);IA!==-1?uA!==-1?(oA[IA]=[oA[IA][0],oA[uA][1]],oA.splice(uA,1),aA.splice(cA,1),sA.push(rA.value),lA=!0):aA[cA]={value:rA.value,inSubset:!rA.inSubset}:uA!==-1?aA[cA]={value:rA.value,inSubset:!rA.inSubset}:(aA.splice(cA,1),sA.push(rA.value),lA=!0)}let gA=await this.createUpdateInstructions({intervalsFromSubset:oA,pointsFromSubset:aA,modifiedAdditionalPoints:lA,additionalPoints:sA});return await this.coreFunctions.performUpdate({updateInstructions:gA,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{toggledPoint:rA.value,intervalsFromSubset:oA,pointsFromSubset:aA,additionalPoints:sA}}})}async toggleInterval({intervalInd:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){let rA=(await this.stateValues.intervalsDisplayed)[eA],aA=await this.stateValues.pointsDisplayed,oA=aA[eA-1],sA=aA[eA],lA=[...await this.stateValues.pointsFromSubset],gA=[...await this.stateValues.intervalsFromSubset],cA=[...await this.stateValues.additionalPoints],IA=!1;if(rA.inSubset){let CA,dA;for(let[pA,mA]of gA.entries())if(mA[0]<=rA.left&&mA[1]>=rA.right){dA=mA,CA=pA;break}if(rA.left===dA[0])if(rA.right===dA[1]){if(gA.splice(CA,1),oA&&!oA.inSubset&&gA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(oA.value);lA.splice(mA,1),cA.push(oA.value),IA=!0}if(sA&&!sA.inSubset&&gA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(sA.value);lA.splice(mA,1),cA.push(sA.value),IA=!0}}else{if(gA[CA]=[rA.right,dA[1]],oA&&!oA.inSubset&&gA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(oA.value);lA.splice(mA,1),cA.push(oA.value),IA=!0}lA.push({value:sA.value,inSubset:!0}),cA.splice(sA.additionalPointInd,1),IA=!0}else if(rA.right===dA[1]){if(gA[CA]=[dA[0],rA.left],sA&&!sA.inSubset&&gA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(QA=>QA.value).indexOf(sA.value);lA.splice(mA,1),cA.push(sA.value),IA=!0}lA.push({value:oA.value,inSubset:!0}),cA.splice(oA.additionalPointInd,1),IA=!0}else{let pA=[[dA[0],rA.left],[rA.right,dA[1]]];gA.splice(CA,1,...pA),lA.push({value:oA.value,inSubset:!0}),lA.push({value:sA.value,inSubset:!0}),cA.splice(sA.additionalPointInd,1),cA.splice(oA.additionalPointInd,1),IA=!0}}else{let CA=gA.map(pA=>pA[1]).indexOf(rA.left),dA=gA.map(pA=>pA[0]).indexOf(rA.right);if(CA===-1)dA===-1?(gA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(cA.splice(sA.additionalPointInd,1),IA=!0),oA&&oA.isAdditional&&(cA.splice(oA.additionalPointInd,1),IA=!0)):(sA.inSubset?(gA[dA]=[rA.left,gA[dA][1]],cA.push(sA.value),IA=!0):gA.push([rA.left,rA.right]),oA&&oA.isAdditional&&(cA.splice(oA.additionalPointInd,1),IA=!0));else if(dA===-1)oA.inSubset?(gA[CA]=[gA[CA][0],rA.right],cA.push(oA.value),IA=!0):gA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(cA.splice(sA.additionalPointInd,1),IA=!0);else if(oA.inSubset)if(sA.inSubset){let pA=[gA[CA][0],gA[dA][1]];gA.splice(CA,2,pA),cA.push(oA.value),cA.push(sA.value),IA=!0}else gA[CA]=[gA[CA][0],rA.right],cA.push(oA.value),IA=!0;else sA.inSubset?(gA[dA]=[rA.left,gA[dA][1]],cA.push(sA.value),IA=!0):gA.push([rA.left,rA.right])}let uA=await this.createUpdateInstructions({intervalsFromSubset:gA,pointsFromSubset:lA,modifiedAdditionalPoints:IA,additionalPoints:cA});return await this.coreFunctions.performUpdate({updateInstructions:uA,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{toggledInterval:[rA.left,rA.right],intervalsFromSubset:gA,pointsFromSubset:lA,additionalPoints:cA}}})}async clear({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let iA=await this.createUpdateInstructions({intervalsFromSubset:[],pointsFromSubset:[],modifiedAdditionalPoints:!0,additionalPoints:[]});return await this.coreFunctions.performUpdate({updateInstructions:iA,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{cleared:!0,intervalsFromSubset:[],pointsFromSubset:[],additionalPoints:[]}}})}async setToR({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){let iA=await this.createUpdateInstructions({intervalsFromSubset:[[-1/0,1/0]],pointsFromSubset:[],modifiedAdditionalPoints:!0,additionalPoints:[]});return await this.coreFunctions.performUpdate({updateInstructions:iA,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{setToR:!0,intervalsFromSubset:[[-1/0,1/0]],pointsFromSubset:[],additionalPoints:[]}}})}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function parseValueIntoSubset({inputString:nA,format:eA,variable:AA}){if(!nA)return subsetOfReals.EmptySet();let tA;if(eA==="latex")try{tA=context.fromLatex(nA)}catch{return subsetOfReals.EmptySet()}else if(eA==="text")try{tA=context.fromText(nA)}catch{return subsetOfReals.EmptySet()}return buildSubsetFromMathExpression(tA,AA)}class Split extends CompositeComponent{static componentType="split";static componentDocs={summary:"Splits a string or list into pieces"};static allowInSchemaAsComponent=["text"];static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.type={createPrimitiveOfType:"string",createStateVariable:"type",defaultPrimitiveValue:"text",toLowerCase:!0,validValues:[{value:"text",description:"Split text values."}],description:"Type of value being split."},eA.splitBy={createComponentOfType:"text",createStateVariable:"splitBy",defaultValue:"letter",toLowerCase:!0,validValues:[{value:"letter",description:"Split into individual characters."},{value:"word",description:"Split into whitespace-separated words."},{value:"comma",description:"Split on comma boundaries."}],description:"How to break the input string into pieces."},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asList",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static returnSugarInstructions(){let eA=[];function AA({matchedChildren:tA,componentAttributes:iA,nComponents:rA,stateIdInfo:aA}){let oA=iA.type?.value;return["text"].includes(oA)||(oA="text"),{success:!0,newChildren:[{type:"serialized",componentType:oA,componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}}return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.originalValue={returnDependencies:()=>({child:{dependencyType:"child",childGroups:["anything"],variableNames:["value"]}}),definition({dependencyValues:AA}){return AA.child.length>0?{setValue:{originalValue:AA.child[0].stateValues.value}}:{setValue:{originalValue:null}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){return tA.child.length>0?{success:!0,instructions:[{setDependency:"child",desiredValue:AA.originalValue,childIndex:0,variableIndex:0}]}:{success:!1}}},eA.allSplitValues={returnDependencies:()=>({type:{dependencyType:"stateVariable",variableName:"type"},originalValue:{dependencyType:"stateVariable",variableName:"originalValue"},splitBy:{dependencyType:"stateVariable",variableName:"splitBy"}}),definition({dependencyValues:AA}){if(AA.originalValue===null)return{setValue:{allSplitValues:[]}};let tA=[];return AA.splitBy==="letter"?tA=[...AA.originalValue]:AA.splitBy==="word"?tA=AA.originalValue.split(/\s+/):AA.splitBy==="comma"?tA=AA.originalValue.split(/\s*,\s*/):tA=[AA.originalValue],{setValue:{allSplitValues:tA}}}},eA.numValues={returnDependencies:()=>({allSplitValues:{dependencyType:"stateVariable",variableName:"allSplitValues"}}),definition({dependencyValues:AA}){return{setValue:{numValues:AA.allSplitValues.length}}}},eA.values={isArray:!0,entryPrefixes:["value"],returnArraySizeDependencies:()=>({numValues:{dependencyType:"stateVariable",variableName:"numValues"}}),returnArraySize({dependencyValues:AA}){return[AA.numValues]},returnArrayDependenciesByKey(){return{globalDependencies:{allSplitValues:{dependencyType:"stateVariable",variableName:"allSplitValues"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let iA={};for(let rA of tA)iA[rA]=AA.allSplitValues[rA];return{setValue:{values:iA}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({values:{dependencyType:"stateVariable",variableName:"values"}}),markStale:()=>({updateReplacements:!0}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const iA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[],aA=await eA.stateValues.values,oA=aA.map((sA,lA)=>({type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{value:sA},downstreamDependencies:{[eA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:eA.componentIdx,propVariable:`value${lA+1}`}]}}));return tA.values=[...aA],tA.replacementsCreated=iA.num,{replacements:oA,diagnostics:rA,nComponents:AA}}static async calculateReplacementChanges({component:eA,components:AA,workspace:tA,nComponents:iA}){let rA=[];const aA=await eA.stateValues.values;if(aA.length===tA.values.length&&tA.values.every((gA,cA)=>gA===aA[cA]))return{replacementChanges:[],diagnostics:rA,nComponents:iA};let oA=await this.createSerializedReplacements({component:eA,components:AA,workspace:tA,nComponents:iA}),sA=oA.replacements;return rA.push(...oA.diagnostics),iA=oA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:sA}],diagnostics:rA,nComponents:iA}}}const{matrix,transpose,multiply,lusolve,subset,index}=context.math;class BestFitLine extends Line{static componentType="bestFitLine";static componentDocs={summary:"The best-fit line for a set of points"};static rendererType="line";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.draggable,delete eA.equation,delete eA.through,delete eA.slope,eA.data={createComponentOfType:"pointList",description:"The data points to fit a line to."},eA}static additionalSchemaChildren=[];static returnSugarInstructions(){return[]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.draggable={description:"Whether the line can be dragged (always false for a best-fit line).",shadowingInstructions:{createComponentOfType:"boolean"},public:!0,forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{draggable:!1}})},eA.numDimensions={description:"Number of dimensions of the line (always 2 for a best-fit line).",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({}),definition:()=>({setValue:{numDimensions:2}})},delete eA.numPointsPrescribed,delete eA.basedOnSlope,delete eA.basedOnParallel,delete eA.basedOnPerpendicular,delete eA.distForSecondPt,delete eA.essentialPoint1x,delete eA.essentialPoint1y,delete eA.equationIdentity,delete eA.equation.stateVariablesDeterminingDependencies,eA.equation.returnDependencies=()=>({data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["points","numDimensions"]},variables:{dependencyType:"stateVariable",variableName:"variables"}}),eA.equation.definition=function({dependencyValues:AA}){if(!AA.data||AA.data.stateValues.numDimensions<2||AA.data.stateValues.points.length<1){let dA=context.fromAst("_");return{setValue:{equation:dA,coeff0:dA,coeffvar1:dA,coeffvar2:dA}}}let tA=[],iA=[];for(let dA of AA.data.stateValues.points){let pA=dA.slice(0,2).map(mA=>mA&&mA.evaluate_to_constant());pA.every(Number.isFinite)&&(tA.push([1,pA[0]]),iA.push([pA[1]]))}if(tA.length===0){let dA=context.fromAst("_");return{setValue:{equation:dA,coeff0:dA,coeffvar1:dA,coeffvar2:dA}}}tA=matrix(tA),iA=matrix(iA);let rA=transpose(tA),aA=multiply(rA,iA),oA=multiply(rA,tA),sA=lusolve(oA,aA),lA=context.fromAst(subset(sA,index(0,0))),gA=context.fromAst(subset(sA,index(1,0))),cA=context.fromAst(-1),IA=AA.variables,uA=context.fromAst(["+",["*","a","x"],"c"]).substitute({a:gA,c:lA,x:IA[0]}).simplify();return{setValue:{equation:context.fromAst(["=",IA[1].tree,"r"]).substitute({r:uA}),coeff0:lA,coeffvar1:gA,coeffvar2:cA}}},delete eA.equation.inverseDefinition,delete eA.points.stateVariablesDeterminingDependencies,eA.points.returnArrayDependenciesByKey=function(){return{globalDependencies:{coeff0:{dependencyType:"stateVariable",variableName:"coeff0"},coeffvar1:{dependencyType:"stateVariable",variableName:"coeffvar1"},coeffvar2:{dependencyType:"stateVariable",variableName:"coeffvar2"},variables:{dependencyType:"stateVariable",variableName:"variables"},lastPointsFromInverting:{dependencyType:"stateVariable",variableName:"lastPointsFromInverting"}}}},eA.data={description:"The data points used to compute the best-fit line.",public:!0,isLocation:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="datumX"?[]:[["point",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,numDimensions:2,entryPrefixes:["datumX","datum"],returnEntryDimensions:AA=>AA==="datum"?1:0,getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:iA}){if(AA==="datumX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?iA?rA.every((aA,oA)=>aA<iA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?iA?rA<iA[0]?Array.from(Array(iA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="data")return AA.length===1?"datum"+AA[0]:`datumX${AA[0]}_${AA[1]}`;if(tA.slice(0,5)==="datum"){let iA=Number(tA.slice(5));if(Number.isInteger(iA)&&iA>0)return`datumX${iA}_${AA[0]}`}return null},returnArraySizeDependencies:()=>({data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["numPoints","numDimensions"]}}),returnArraySize({dependencyValues:AA}){let tA=AA.data;return tA?[tA.stateValues.numPoints,tA.stateValues.numDimensions]:[0,0]},returnArrayDependenciesByKey(){return{globalDependencies:{data:{dependencyType:"attributeComponent",attributeName:"data",variableNames:["points"]}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=AA.data.stateValues.points,iA={};for(let rA in tA){let aA=tA[rA];for(let oA in tA)iA[`${rA},${oA}`]=aA[oA]}return{setValue:{data:iA}}}},eA}}class RegionBetweenCurveXAxis extends GraphicalComponent{static componentType="regionBetweenCurveXAxis";static styleOverrideCategories=["fill"];static componentDocs={summary:"A region bounded between a curve and the x-axis"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.boundaryValues={description:"Boundary values defining the region's left/right edges.",createComponentOfType:"numberList",createStateVariable:"boundaryValues",defaultValue:[0,1],forRenderer:!0,public:!0},eA.function={createComponentOfType:"function",description:"The function whose graph bounds the region."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"region",noun:"region"})),eA.function={additionalStateVariablesDefined:[{variableName:"haveFunction",forRenderer:!0},{variableName:"fDefinition",forRenderer:!0}],returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numericalfs","numInputs","numOutputs","fDefinition"]}}),definition({dependencyValues:AA}){return AA.functionAttr===null||AA.functionAttr.stateValues.numInputs!==1||AA.functionAttr.stateValues.numOutputs!==1?{setValue:{function:()=>NaN,haveFunction:!1,fDefinition:{}}}:{setValue:{function:AA.functionAttr.stateValues.numericalfs[0],haveFunction:!0,fDefinition:AA.functionAttr.stateValues.fDefinition}}}},eA.nearestPoint={returnDependencies:()=>({function:{dependencyType:"stateVariable",variableName:"function"},boundaryValues:{dependencyType:"stateVariable",variableName:"boundaryValues"},haveFunction:{dependencyType:"stateVariable",variableName:"haveFunction"}}),definition({dependencyValues:AA}){if(!AA.haveFunction)return{setValue:{nearestPoint:()=>({})}};const tA=Math.min(AA.boundaryValues[0],AA.boundaryValues[1]),iA=Math.max(AA.boundaryValues[0],AA.boundaryValues[1]),rA=AA.function;return{setValue:{nearestPoint:function({variables:oA}){let sA=oA.x1?.evaluate_to_constant(),lA=oA.x2?.evaluate_to_constant();if(!(Number.isFinite(sA)&&Number.isFinite(lA)))return{};sA=Math.max(tA,Math.min(iA,sA));let[gA,cA]=[0,rA(sA)].sort((IA,uA)=>IA-uA);return lA=Math.max(gA,Math.min(cA,lA)),{x1:sA,x2:lA}}}}}},eA}}class RegionBetweenCurves extends GraphicalComponent{static componentType="regionBetweenCurves";static styleOverrideCategories=["fill"];static componentDocs={summary:"A region bounded between two curves"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.boundaryValues={description:"Boundary values defining the region's edges.",createComponentOfType:"numberList",createStateVariable:"boundaryValues",defaultValue:[0,1],forRenderer:!0,public:!0},eA.flipFunctions={description:"Whether to swap the role of x and y for the input functions.",createComponentOfType:"boolean",createStateVariable:"flipFunctions",defaultValue:!1,public:!0,forRenderer:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"functions",componentTypes:["function"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"region",noun:"region"})),eA.functions={additionalStateVariablesDefined:[{variableName:"haveFunctions",forRenderer:!0},{variableName:"fDefinitions",forRenderer:!0}],returnDependencies:()=>({functions:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalfs","numInputs","numOutputs","fDefinition"]}}),definition({dependencyValues:AA}){return AA.functions.length<2||AA.functions[0].stateValues.numInputs!==1||AA.functions[0].stateValues.numOutputs!==1||AA.functions[1].stateValues.numInputs!==1||AA.functions[1].stateValues.numOutputs!==1?{setValue:{functions:[()=>NaN,()=>NaN],haveFunctions:!1,fDefinitions:[{},{}]}}:{setValue:{functions:[AA.functions[0].stateValues.numericalfs[0],AA.functions[1].stateValues.numericalfs[0]],haveFunctions:!0,fDefinitions:[AA.functions[0].stateValues.fDefinition,AA.functions[1].stateValues.fDefinition]}}}},eA.nearestPoint={returnDependencies:()=>({functions:{dependencyType:"stateVariable",variableName:"functions"},boundaryValues:{dependencyType:"stateVariable",variableName:"boundaryValues"},flipFunctions:{dependencyType:"stateVariable",variableName:"flipFunctions"},haveFunctions:{dependencyType:"stateVariable",variableName:"haveFunctions"}}),definition({dependencyValues:AA}){if(!AA.haveFunctions)return{setValue:{nearestPoint:()=>({})}};const tA=Math.min(AA.boundaryValues[0],AA.boundaryValues[1]),iA=Math.max(AA.boundaryValues[0],AA.boundaryValues[1]),rA=AA.functions[0],aA=AA.functions[1];return{setValue:{nearestPoint:function({variables:sA}){let lA=sA.x1?.evaluate_to_constant(),gA=sA.x2?.evaluate_to_constant();if(!(Number.isFinite(lA)&&Number.isFinite(gA)))return{};AA.flipFunctions&&([lA,gA]=[gA,lA]),lA=Math.max(tA,Math.min(iA,lA));let[cA,IA]=[rA(lA),aA(lA)].sort((uA,CA)=>uA-CA);return gA=Math.max(cA,Math.min(IA,gA)),AA.flipFunctions&&([lA,gA]=[gA,lA]),{x1:lA,x2:gA}}}}}},eA}}function returnFieldFunctionChildGroup(){return{group:"functions",componentTypes:["function"]}}function returnFieldVariablesAttribute(){return{variables:{createComponentOfType:"_variableNameList",description:'Names of the variables a bare expression is read as a function of. Defaults to "x y". Ignored when the function is given as a <function> child, which names its own variables.'}}}function returnFieldLatticeAttributes({markNoun:nA,markLengthDefault:eA,markLengthDescription:AA}){return{dx:{createComponentOfType:"number",createStateVariable:"dx",defaultValue:1,public:!0,forRenderer:!0,description:`Horizontal spacing between ${nA}.`},dy:{createComponentOfType:"number",createStateVariable:"dy",defaultValue:1,public:!0,forRenderer:!0,description:`Vertical spacing between ${nA}.`},xoffset:{createComponentOfType:"number",createStateVariable:"xoffset",defaultValue:0,public:!0,forRenderer:!0,description:"Horizontal offset of the lattice origin."},yoffset:{createComponentOfType:"number",createStateVariable:"yoffset",defaultValue:0,public:!0,forRenderer:!0,description:"Vertical offset of the lattice origin."},markLength:{createComponentOfType:"number",createStateVariable:"markLength",defaultValue:eA,public:!0,forRenderer:!0,description:AA},maxMarks:{createComponentOfType:"number",createStateVariable:"maxMarks",defaultValue:2500,public:!0,forRenderer:!0,description:`Upper bound on how many ${nA} are drawn. Zooming out past this coarsens the lattice rather than drawing an unbounded number of ${nA}.`}}}function returnFieldFunctionStateVariableDefinitions({numOutputs:nA}){const eA=nA===1,AA=eA?"slopeField":"vectorField",tA=eA?"vectorField":"slopeField",iA=eA?2:1;return{haveFunction:{forRenderer:!0,additionalStateVariablesDefined:[{variableName:"fDefinitions",forRenderer:!0}],returnDependencies:()=>({functionChildren:{dependencyType:"child",childGroups:["functions"],variableNames:["numOutputs","fDefinitions"]}}),definition({dependencyValues:rA}){const aA=rA.functionChildren[0]??null;if(aA===null||aA.stateValues.numOutputs!==nA){const oA=[];if(aA!==null){const sA=aA.stateValues.numOutputs;oA.push(codedDiagnostic({type:"warning",code:"doenet-w0122",args:{component:AA,expected:nA,found:sA,alternative:sA===iA?tA:"none"},position:aA.position||void 0}))}return{setValue:{haveFunction:!1,fDefinitions:Array.from({length:nA},()=>({}))},sendDiagnostics:oA}}return{setValue:{haveFunction:!0,fDefinitions:aA.stateValues.fDefinitions}}}}}}class SlopeField extends GraphicalComponent{static componentType="slopeField";static styleOverrideCategories=["line"];static includeLabels=!1;static componentDocs={summary:"A slope field for a differential equation y' = f(x,y), drawn as tick marks on a lattice"};static additionalSchemaChildren=["math","number","string"];static returnChildGroups(){let eA=super.returnChildGroups();return eA.push(returnFieldFunctionChildGroup()),eA}static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnFieldVariablesAttribute(),returnFieldLatticeAttributes({markNoun:"marks",markLengthDefault:20,markLengthDescription:"Length of each mark, in pixels. Marks keep this length whatever the axis scaling, so slopes are drawn at their true visual angle."})),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"line",noun:"slope-field"}),returnFieldFunctionStateVariableDefinitions({numOutputs:1})),eA}}class VectorField extends GraphicalComponent{static componentType="vectorField";static styleOverrideCategories=["line"];static includeLabels=!1;static componentDocs={summary:"A vector field drawn as arrows on a lattice, from a function with two outputs"};static additionalSchemaChildren=["math","number","string"];static returnChildGroups(){let eA=super.returnChildGroups();return eA.push(returnFieldFunctionChildGroup()),eA}static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnFieldVariablesAttribute(),returnFieldLatticeAttributes({markNoun:"arrows",markLengthDefault:24,markLengthDescription:"Length in pixels of the longest arrow, or of every arrow when normalize is set. Arrows keep this length whatever the axis scaling."})),eA.normalize={createComponentOfType:"boolean",createStateVariable:"normalize",defaultValue:!1,public:!0,forRenderer:!0,description:"Draw every arrow the same length, showing direction only rather than magnitude."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnGraphicalStyleDescriptionDefinitions({kind:"line",noun:"vector-field"}),returnFieldFunctionStateVariableDefinitions({numOutputs:2})),eA}}class RegionHalfPlane extends GraphicalComponent{static componentType="regionHalfPlane";static componentDocs={summary:"A half-plane region bounded by a line"};static rendererType=void 0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.horizontal={description:"Whether the half-plane extends horizontally, bounded by the vertical line x = boundaryValue. If false, the half-plane extends vertically, bounded by the horizontal line y = boundaryValue.",createComponentOfType:"boolean",createStateVariable:"horizontal",defaultValue:!0,public:!0},eA.boundaryValue={description:"Position of the bounding line: x = boundaryValue when horizontal is true, y = boundaryValue when horizontal is false.",createComponentOfType:"number",createStateVariable:"boundaryValue",defaultValue:0,public:!0},eA.greaterThan={description:"Whether the region is the side where the inequality is greater than the boundary.",createComponentOfType:"boolean",createStateVariable:"greaterThan",defaultValue:!0,public:!0},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.nearestPoint={returnDependencies:()=>({horizontal:{dependencyType:"stateVariable",variableName:"horizontal"},boundaryValue:{dependencyType:"stateVariable",variableName:"boundaryValue"},greaterThan:{dependencyType:"stateVariable",variableName:"greaterThan"}}),definition({dependencyValues:AA}){let tA=AA.boundaryValue;return{setValue:{nearestPoint:function({variables:iA,scales:rA}){if(!Number.isFinite(tA))return{};if(AA.horizontal)if(AA.greaterThan)if(iA.x1<tA){let aA=Object.assign({},iA);return aA.x1=tA,aA}else return{};else if(iA.x1>tA){let aA=Object.assign({},iA);return aA.x1=tA,aA}else return{};else if(AA.greaterThan)if(iA.x2<tA){let aA=Object.assign({},iA);return aA.x2=tA,aA}else return{};else if(iA.x2>tA){let aA=Object.assign({},iA);return aA.x2=tA,aA}else return{}}}}}},eA}}class CodeEditor extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{updateImmediateValue:inputUpdateImmediateValue.bind(this),updateValue:inputUpdateValue.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="codeEditor";static componentDocs={summary:"An interactive DoenetML code editor"};static variableForImplicitProp="value";static renderChildren=!0;static ignoreVariantsFromChildren=!0;static processWhenJustUpdatedForNewComponent=!0;static ignoreErrorsFromChildren=!0;static get stateVariablesShadowedForReference(){return["value"]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.prefill={description:"Initial code shown in the editor before the user types.",createComponentOfType:"text",createStateVariable:"prefill",defaultValue:"",public:!0},eA.bindValueTo={createComponentOfType:"text",description:"Two-way binding target for the input's value."},eA.width={description:'Editor width (e.g. "100%" or "600px").',createComponentOfType:"componentSize",createStateVariable:"width",defaultValue:{size:"100",isAbsolute:!1},forRenderer:!0,public:!0},eA.height={description:'Editor height (e.g. "500px").',createComponentOfType:"componentSize",createStateVariable:"height",defaultValue:{size:400,isAbsolute:!0},forRenderer:!0,public:!0},eA.viewerRatio={createComponentOfType:"number",description:"Fraction of the editor area allotted to the live viewer."},eA.showResults={description:"Whether to render the results panel alongside the editor.",createComponentOfType:"boolean",createStateVariable:"showResults",defaultValue:!1,forRenderer:!0,public:!0},eA.showFormatter={description:"Whether to show a code formatter button.",createComponentOfType:"boolean",createStateVariable:"showFormatter",defaultValue:!1,forRenderer:!0,public:!0},eA.resultsLocation={description:"Position of the results panel relative to the editor.",createComponentOfType:"text",createStateVariable:"resultsLocation",defaultValue:"bottom",forRenderer:!0,public:!0,toLowerCase:!0,validValues:[{value:"bottom",description:"Place the results panel below the editor."},{value:"start",description:"Place the results panel before the editor: to its left in a left-to-right document, to its right in a right-to-left one."},{value:"end",description:"Place the results panel after the editor: to its right in a left-to-right document, to its left in a right-to-left one."}]},eA.readOnly={description:"Whether the editor is read-only.",createComponentOfType:"boolean",createStateVariable:"readOnly",defaultValue:!1,forRenderer:!0,public:!0},eA.initialOpenTab={description:"Which diagnostics/responses tab to open initially.",createComponentOfType:"text",createStateVariable:"initialOpenTab",defaultValue:"first",forRenderer:!0,public:!0,toLowerCase:!0,validValues:[{value:"none",description:"Panel starts closed."},{value:"first",description:"Open the first available tab."},{value:"errors",description:"Open the errors tab."},{value:"warnings",description:"Open the warnings tab."},{value:"info",description:"Open the info tab."},{value:"accessibility",description:"Open the accessibility tab."},{value:"responses",description:"Open the responses tab."},{value:"help",description:"Open the help tab."}]},eA.renderedName={createPrimitiveOfType:"string",description:"Name to assign to the dynamically-rendered DoenetML output."},eA.staticName={createPrimitiveOfType:"string",description:"Name to assign to the static DoenetML source."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnInputValueChangedStateVariableDefinitions({valueChangedDescription:"Whether the value has been changed from its initial state.",immediateValueChangedDescription:"Whether the value, including in-progress edits, has been changed from its initial state."})),eA.prefillFromChildren={returnDependencies:()=>({childrenDoenetML:{dependencyType:"doenetML",displayOnlyChildren:!0}}),definition({dependencyValues:AA}){let tA=AA.childrenDoenetML;return tA&&(tA+=`
2798
2798
  `),{setValue:{prefillFromChildren:tA}}}},eA.value={description:"The code value of the input.",public:!0,shadowingInstructions:{createComponentOfType:"text"},hasEssential:!0,forRenderer:!0,returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo",variableNames:["value"]},prefill:{dependencyType:"stateVariable",variableName:"prefill"},prefillFromChildren:{dependencyType:"stateVariable",variableName:"prefillFromChildren"},valueChanged:{dependencyType:"stateVariable",variableName:"valueChanged",onlyToSetInInverseDefinition:!0},immediateValueChanged:{dependencyType:"stateVariable",variableName:"immediateValueChanged",onlyToSetInInverseDefinition:!0}}),definition:function({dependencyValues:AA,usedDefault:tA}){return AA.bindValueTo?{setValue:{value:AA.bindValueTo.stateValues.value}}:{useEssentialOrDefaultValue:{value:{variablesToCheck:"value",get defaultValue(){return tA.prefill?AA.prefillFromChildren:AA.prefill}}}}},inverseDefinition:function({desiredStateVariableValues:AA,dependencyValues:tA}){let iA=[{setDependency:"valueChanged",desiredValue:!0},{setDependency:"immediateValueChanged",desiredValue:!0}];return tA.bindValueTo?iA.push({setDependency:"bindValueTo",desiredValue:AA.value,variableIndex:0}):iA.push({setEssentialValue:"value",value:AA.value}),{success:!0,instructions:iA}}},Object.assign(eA,returnImmediateValueStateVariableDefinition({description:"The code value reflecting the user's in-progress edits.",createComponentOfType:"text"})),eA.text={description:"The current code as a plain text string.",public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),definition:function({dependencyValues:AA}){return{setValue:{text:AA.value}}}},eA.componentType={returnDependencies:()=>({}),definition:()=>({setValue:{componentType:"text"}})},eA.allChildren={returnDependencies:()=>({allChildren:{dependencyType:"child",childGroups:["anything"]}}),definition({dependencyValues:AA}){return{setValue:{allChildren:AA.allChildren}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class HasSameFactoring extends BooleanComponent{static componentType="hasSameFactoring";static componentDocs={summary:"Boolean condition that tests for equivalent factoring"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.variable={createComponentOfType:"_variableName",createStateVariable:"variable",defaultValue:context.fromAst("x"),description:"Variable used when comparing factored expressions."},eA.restrictDivision={createComponentOfType:"boolean",createStateVariable:"restrictDivision",defaultValue:!1,description:"Whether to disallow dividing through to match factored forms."},eA.monomialFactorMustMatch={createComponentOfType:"boolean",createStateVariable:"monomialFactorMustMatch",defaultValue:!1,description:"Whether monomial factors must match exactly (implies restrictDivision)."},eA.allowOnlySignDifferences={createComponentOfType:"boolean",createStateVariable:"allowOnlySignDifferences",defaultValue:!1,description:"Whether to count factorizations as equivalent when they differ only by sign."},eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.value={public:!0,description:"Whether the input math expressions share the same factoring.",shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowedErrorInNumbers:{dependencyType:"stateVariable",variableName:"allowedErrorInNumbers"},includeErrorInNumberExponents:{dependencyType:"stateVariable",variableName:"includeErrorInNumberExponents"},allowedErrorIsAbsolute:{dependencyType:"stateVariable",variableName:"allowedErrorIsAbsolute"},numSignErrorsMatched:{dependencyType:"stateVariable",variableName:"numSignErrorsMatched"},variable:{dependencyType:"stateVariable",variableName:"variable"},restrictDivision:{dependencyType:"stateVariable",variableName:"restrictDivision"},monomialFactorMustMatch:{dependencyType:"stateVariable",variableName:"monomialFactorMustMatch"},allowOnlySignDifferences:{dependencyType:"stateVariable",variableName:"allowOnlySignDifferences"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length!==2)return{setValue:{value:!1}};let tA=AA.mathChildren[0].stateValues.value,iA=AA.mathChildren[1].stateValues.value;if(checkEquality({object1:tA,object2:iA,isUnordered:!1,partialMatches:!1,symbolicEquality:!1,allowedErrorInNumbers:AA.allowedErrorInNumbers,includeErrorInNumberExponents:AA.includeErrorInNumberExponents,allowedErrorIsAbsolute:AA.allowedErrorIsAbsolute,numSignErrorsMatched:AA.numSignErrorsMatched}).fraction_equal!==1)return{setValue:{value:!1}};if(Array.isArray(tA.tree)&&tA.tree[0]==="-"&&(tA=context.fromAst(tA.tree[1])),Array.isArray(iA.tree)&&iA.tree[0]==="-"&&(iA=context.fromAst(iA.tree[1])),!AA.restrictDivision&&!AA.monomialFactorMustMatch&&!AA.allowOnlySignDifferences&&(Array.isArray(tA.tree)&&tA.tree[0]==="/"&&context.fromAst(tA.tree[2]).variables().length===0&&(tA=context.fromAst(tA.tree[1]),Array.isArray(tA.tree)&&tA.tree[0]==="-"&&(tA=context.fromAst(tA.tree[1]))),Array.isArray(iA.tree)&&iA.tree[0]==="/"&&context.fromAst(iA.tree[2]).variables().length===0&&(iA=context.fromAst(iA.tree[1]),Array.isArray(iA.tree)&&iA.tree[0]==="-"&&(iA=context.fromAst(iA.tree[1])))),tA=context.fromAst(expandPositiveIntegerPowers(tA.tree)),iA=context.fromAst(expandPositiveIntegerPowers(iA.tree)),Array.isArray(tA.tree)&&tA.tree[0]==="*"){if(!(Array.isArray(iA.tree)&&iA.tree[0]==="*"))return{setValue:{value:!1}}}else return Array.isArray(iA.tree)&&iA.tree[0]==="*"?{setValue:{value:!1}}:{setValue:{value:!0}};if(AA.monomialFactorMustMatch||AA.allowOnlySignDifferences){let CA=findMonomialFromFactors(tA.tree.slice(1)),dA=findMonomialFromFactors(iA.tree.slice(1));if(!CA.equals(dA)){let pA=context.fromAst(["-",dA.tree]);if(!CA.equals(pA))return{setValue:{value:!1}}}}if(AA.allowOnlySignDifferences){let CA=normalizeFactorSigns(tA),dA=normalizeFactorSigns(iA);return{setValue:{value:CA.equalsViaSyntax(dA,{allowed_error_in_numbers:AA.allowedErrorInNumbers,include_error_in_number_exponents:AA.includeErrorInNumberExponents,allowed_error_is_absolute:AA.allowedErrorIsAbsolute})}}}let aA=tA.tree.slice(1).filter(CA=>context.fromAst(CA).variables().length>0),oA=iA.tree.slice(1).filter(CA=>context.fromAst(CA).variables().length>0);if(aA.length!==oA.length)return{setValue:{value:!1}};let sA=0,lA=0,gA=0,cA=0,IA=AA.variable.subscripts_to_strings().tree;for(let CA of aA){let dA=context.fromAst(CA).subscripts_to_strings().derivative(IA).derivative(IA).simplify();if(dA.tree===0)lA++;else if(dA.variables().length===0)sA++;else return{setValue:{value:!1}}}for(let CA of oA){let dA=context.fromAst(CA).subscripts_to_strings().derivative(IA).derivative(IA).simplify();if(dA.tree===0)cA++;else if(dA.variables().length===0)gA++;else return{setValue:{value:!1}}}return{setValue:{value:lA===cA&&sA===gA}}}},eA}}function expandPositiveIntegerPowers(nA){if(!Array.isArray(nA))return nA;if(nA[0]==="^"){let eA=nA[1],AA=nA[2];Number.isInteger(AA)&&AA>0&&(nA=["*",...Array(AA).fill(eA)])}if(nA[0]==="*"){let eA=nA;nA=["*"];for(let AA of eA.slice(1))if(Array.isArray(AA)&&AA[0]==="^"){let tA=AA[1],iA=AA[2];Number.isInteger(iA)&&iA>0?nA.push(...Array(iA).fill(tA)):nA.push(AA)}else nA.push(AA)}return nA}function findMonomialFromFactors(nA){let eA=[],AA=!1;for(let iA of nA)if(typeof iA=="string"||context.fromAst(iA).variables().length===0){if(!AA){if(eA.length>0)return context.fromAst("_");AA=!0}eA.push(iA)}else AA=!1;let tA;return eA.length===0?tA=1:eA.length===1?tA=eA[0]:tA=["*",...eA],context.fromAst(tA)}function normalizeFactorSigns(nA){let eA=nA.simplify().tree;if(eA[0]==="-"&&(eA=eA[1]),eA[0]!=="*")return context.fromAst(eA).simplify();let AA=["*"];for(let tA of eA.slice(1))if(typeof tA=="number")tA<0?AA.push(-tA):AA.push(tA);else if(!Array.isArray(tA))AA.push(tA);else if(tA[0]==="-")AA.push(tA[1]);else if(tA[0]==="+"){let iA=!1,rA=tA[1];if(typeof rA=="number")rA<0&&(iA=!0);else if(Array.isArray(rA)){if(rA[0]==="-")iA=!0;else if(rA[0]==="*"){let aA=rA[1];typeof aA=="number"?aA<0&&(iA=!0):Array.isArray(aA)&&aA[0]==="-"&&(iA=!0)}}iA?AA.push(context.fromAst(["-",tA]).simplify().tree):AA.push(tA)}else AA.push(tA);return context.fromAst(AA).simplify()}class DataFrame extends BaseComponent{static componentType="dataFrame";static excludeFromSchema=!0;static componentDocs={summary:"A 2D table of typed data values."};static rendererType=void 0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.source={description:"URL or identifier of the data source.",createComponentOfType:"text",createStateVariable:"source",required:!0,public:!0,forRenderer:!0},eA.hasHeader={description:"Whether the first row of data contains column headers.",createComponentOfType:"boolean",createStateVariable:"hasHeader",defaultValue:!0,public:!0},eA.columnTypes={createComponentOfType:"textList",createStateVariable:"columnTypesPrelim",defaultValue:[],description:"Override the inferred type of each column."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.cid={forRenderer:!0,returnDependencies:()=>({source:{dependencyType:"stateVariable",variableName:"source"}}),definition:function({dependencyValues:AA}){if(!AA.source||AA.source.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null}};let tA=null,iA=AA.source.match(/[:&]cid=([^&]+)/i);return iA&&(tA=iA[1]),{setValue:{cid:tA}}}},eA.dataFrame={stateVariablesDeterminingDependencies:["cid","source"],additionalStateVariablesDefined:[{variableName:"numRows",public:!0,description:"The number of rows in the data frame.",shadowingInstructions:{createComponentOfType:"integer"}},{variableName:"numColumns",public:!0,description:"The number of columns in the data frame.",shadowingInstructions:{createComponentOfType:"integer"}},{variableName:"columnTypes",public:!0,description:"The data type of each column in the data frame.",shadowingInstructions:{createComponentOfType:"textList"}},{variableName:"columnNames",public:!0,description:"The name of each column in the data frame.",shadowingInstructions:{createComponentOfType:"textList"}}],returnDependencies:({stateValues:AA})=>({fileContents:{dependencyType:"file",cid:AA.cid,uri:AA.source,fileType:"csv"},hasHeader:{dependencyType:"stateVariable",variableName:"hasHeader"},columnTypesPrelim:{dependencyType:"stateVariable",variableName:"columnTypesPrelim"}}),definition:function({dependencyValues:AA,componentIdx:tA}){let iA=[],rA=[],aA=AA.fileContents.trim().split(`
2799
- `).map(IA=>IA.trim().split(",").map(uA=>uA.trim())),oA=aA[0]?.length,sA=!1;for(let IA of aA.slice(1))if(IA.length!==oA){sA=!0;break}if(sA){let IA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}let lA={},gA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(IA=>(['"',"'"].includes(IA[0])&&IA[IA.length-1]===IA[0]&&(IA=IA.substring(1,IA.length-1)),IA)),gA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(IA=>`col${IA+1}`),gA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let IA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}if(lA.columnNames.includes("")){let IA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}let cA=gA.length;lA.shape=[cA,oA];for(let IA=0;IA<oA;IA++){let uA=AA.columnTypesPrelim[IA]?.toLowerCase();if(["number","string"].includes(uA)||(uA="auto"),uA==="auto"){let CA=!1;for(let dA=0;dA<cA;dA++){let pA=gA[dA][IA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){CA=!0;break}}}CA?uA="string":uA="number"}if(uA==="number")for(let CA=0;CA<cA;CA++)gA[CA][IA]===""?gA[CA][IA]=null:gA[CA][IA]=Number(gA[CA][IA]);else for(let CA=0;CA<cA;CA++){let dA=gA[CA][IA];['"',"'"].includes(dA[0])&&dA[dA.length-1]===dA[0]&&(dA=dA.substring(1,dA.length-1)),gA[CA][IA]=dA}iA.push(uA)}return lA.data=gA,lA.columnTypes=iA,{setValue:{dataFrame:lA,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:lA.columnNames}}}},eA.means={description:"Mean of each numeric column in the data frame.",public:!0,shadowingInstructions:{createComponentOfType:"number"},isArray:!0,entryPrefixes:["mean"],returnArraySizeDependencies:()=>({numColumns:{dependencyType:"stateVariable",variableName:"numColumns"}}),returnArraySize({dependencyValues:AA}){return[AA.numColumns]},returnArrayDependenciesByKey(){return{globalDependencies:{dataFrame:{dependencyType:"stateVariable",variableName:"dataFrame"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"},numRows:{dependencyType:"stateVariable",variableName:"numRows"},columnTypes:{dependencyType:"stateVariable",variableName:"columnTypes"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let iA={};for(let rA of tA){let aA=0,oA=0;if(AA.columnTypes[rA]==="number"){for(let sA=0;sA<AA.numRows;sA++){let lA=AA.dataFrame.data[sA][rA];lA!==null&&(aA+=lA,oA++)}aA/=oA}else aA=NaN;iA[rA]=aA}return{setValue:{means:iA}}}},eA}}const{mean,std,variance}=context.math,STATISTICS=[{value:"mean",description:"The arithmetic mean of the values.",compute:mean},{value:"stdev",description:"The sample standard deviation.",compute:std},{value:"variance",description:"The sample variance.",compute:variance},{value:"stderr",description:"The standard error of the mean."},{value:"count",description:"The number of non-missing values."},{value:"minimum",description:"The smallest value.",compute:smallest},{value:"quartile1",description:"The first quartile (25th percentile).",compute:quartile1},{value:"median",description:"The median value.",compute:median},{value:"quartile3",description:"The third quartile (75th percentile).",compute:quartile3},{value:"maximum",description:"The largest value.",compute:largest},{value:"range",description:"The maximum minus the minimum."},{value:"sum",description:"The sum of the values.",compute:nA=>nA.reduce((eA,AA)=>eA+AA)}],FIVE_NUMBER_SUMMARY=["minimum","quartile1","median","quartile3","maximum"],DEFAULT_STATISTICS=["mean","stdev","count","minimum","quartile1","median","quartile3","maximum"];function returnColumnStatisticDefinition({value:nA,description:eA,compute:AA}){return{description:eA,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){const iA=tA.dataColumn;return{setValue:{[nA]:iA.length?AA(iA):null}}}}}function displayedStatistic(nA,eA,AA){return eA===null?null:nA==="count"?eA:roundForDisplay({value:numberToMathExpression(eA),dependencyValues:AA}).toString(buildNumberDisplayParameters(AA))}class SummaryStatistics extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="summaryStatistics";static componentDocs={summary:"Summary statistics (mean, median, etc.) for a list of numbers."};static createAttributesObject(){let eA=super.createAttributesObject();return eA.statisticsToDisplay={createComponentOfType:"textList",createStateVariable:"statisticsToDisplayPrelim",defaultValue:["default"],toLowerCase:!0,highlighted:!0,validValues:[{value:"default",description:`The default selection: ${DEFAULT_STATISTICS.join(", ")}.`},{value:"all",description:"Every statistic listed here."},{value:"fiveNumberSummary",description:`The five-number summary: ${FIVE_NUMBER_SUMMARY.join(", ")}.`},...STATISTICS.map(({value:AA,description:tA})=>({value:AA,description:tA}))],description:'Which summary statistics to display (or "default" / "all" / "fiveNumberSummary").'},Object.assign(eA,returnNumberDisplayAttributes()),eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoMathsBySpacesSugarInstruction()),eA}static returnChildGroups(){return[{group:"numbers",componentTypes:["number"]},{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.statisticsToDisplay={description:"Which summary statistics to display.",public:!0,shadowingInstructions:{createComponentOfType:"textList"},returnDependencies:()=>({statisticsToDisplayPrelim:{dependencyType:"stateVariable",variableName:"statisticsToDisplayPrelim"}}),definition:function({dependencyValues:tA}){const iA=STATISTICS.map(sA=>sA.value),rA=tA.statisticsToDisplayPrelim,aA=new Set;for(const sA of rA)if(sA==="default")for(const lA of DEFAULT_STATISTICS)aA.add(lA);else if(sA==="all")for(const lA of iA)aA.add(lA);else if(sA==="fivenumbersummary")for(const lA of FIVE_NUMBER_SUMMARY)aA.add(lA);else aA.add(sA);return{setValue:{statisticsToDisplay:iA.filter(sA=>aA.has(sA))}}}},eA.dataColumn={description:"The numeric values being summarized.",returnDependencies:()=>({valueChildren:{dependencyType:"child",childGroups:["numbers","maths"],variableNames:["value"]}}),definition({dependencyValues:tA}){const iA=[];for(let rA of tA.valueChildren){const aA=rA.stateValues.value,oA=typeof aA?.evaluate_to_constant=="function"?aA.evaluate_to_constant():aA;Number.isFinite(oA)&&iA.push(oA)}return{setValue:{dataColumn:iA}}}};const AA={};AA.count={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){return{setValue:{count:tA.dataColumn.length}}}},AA.stderr={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({stdev:{dependencyType:"stateVariable",variableName:"stdev"},count:{dependencyType:"stateVariable",variableName:"count"}}),definition({dependencyValues:tA}){let iA=null;return tA.stdev!==null&&(iA=tA.stdev/Math.sqrt(tA.count)),{setValue:{stderr:iA}}}},AA.range={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({minimum:{dependencyType:"stateVariable",variableName:"minimum"},maximum:{dependencyType:"stateVariable",variableName:"maximum"}}),definition({dependencyValues:tA}){let iA=null;return tA.minimum!==null&&(iA=tA.maximum-tA.minimum),{setValue:{range:iA}}}};for(let tA of STATISTICS)eA[tA.value]={...tA.compute?returnColumnStatisticDefinition(tA):{description:tA.description,...AA[tA.value]},highlighted:!0};return eA.summaryStatistics={description:"The statistics being displayed, as the table should show them, keyed by statistic.",forRenderer:!0,stateVariablesDeterminingDependencies:["statisticsToDisplay"],returnDependencies({stateValues:tA}){let iA={};for(let rA of["displayDigits","displayDecimals","displaySmallAsZero","padZeros","avoidScientificNotation"])iA[rA]={dependencyType:"stateVariable",variableName:rA};for(let rA of tA.statisticsToDisplay)iA[rA]={dependencyType:"stateVariable",variableName:rA};return iA},definition({dependencyValues:tA}){let iA={};for(let{value:rA}of STATISTICS){const aA=tA[rA];aA!==void 0&&(iA[rA]=displayedStatistic(rA,aA,tA))}return{setValue:{summaryStatistics:iA}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Legend extends GraphicalComponent{static componentType="legend";static componentDocs={summary:"A legend describing the contents of a graph"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.layer.defaultValue=1,eA.position={description:"Position of the legend on the graph.",createComponentOfType:"text",createStateVariable:"position",defaultValue:"upperRight",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"upperRight",description:"Place the legend in the upper-right corner."},{value:"upperLeft",description:"Place the legend in the upper-left corner."},{value:"lowerRight",description:"Place the legend in the lower-right corner."},{value:"lowerLeft",description:"Place the legend in the lower-left corner."}]},eA.boxed={description:"Whether to draw an opaque box behind the legend so that graph contents passing behind it stay hidden.",createComponentOfType:"boolean",createStateVariable:"boxed",defaultValue:!1,public:!0,forRenderer:!0},eA.displayClosedSwatches={description:"Whether to render closed/filled swatches in the legend.",createComponentOfType:"boolean",createStateVariable:"displayClosedSwatches",defaultValue:!1,public:!0},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.graphicalElementNames={returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["graphicalDescendants"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphicalElementNames:AA.graphAncestor.stateValues.graphicalDescendants.map(tA=>tA.componentIdx)}}:{setValue:{graphicalElementNames:null}}}},eA.legendElements={forRenderer:!0,stateVariablesDeterminingDependencies:["graphicalElementNames"],returnDependencies:({stateValues:AA})=>{let tA={labelChildren:{dependencyType:"child",childGroups:["labels"],variableNames:["value","hasLatex","forObjectComponentIdx","forObjectListEntry"]},displayClosedSwatches:{dependencyType:"stateVariable",variableName:"displayClosedSwatches"}};if(AA.graphicalElementNames){tA.numGraphicalElements={dependencyType:"value",value:AA.graphicalElementNames.length};for(let[iA,rA]of AA.graphicalElementNames.entries())tA[`graphicalElement${iA}`]={dependencyType:"multipleStateVariables",componentIdx:rA,variableNames:["selectedStyle","styleNumber","filled","entrySelectedStyle","numEntries"],variablesOptional:!0},tA[`graphicalElement${iA}AdapterSource`]={dependencyType:"adapterSource",componentIdx:rA},tA[`graphicalElement${iA}ShadowSource`]={dependencyType:"shadowSource",componentIdx:rA}}return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){let iA=[];if(AA.numGraphicalElements>0){let rA=[],aA=[],oA=[],sA=[];for(let IA=0;IA<AA.numGraphicalElements;IA++){let uA=AA[`graphicalElement${IA}`];const CA=tA.allComponentClasses[uA?.componentType]?.listEntryComponentType;CA!==void 0&&(uA={...uA,componentType:CA});let dA=AA[`graphicalElement${IA}AdapterSource`];dA&&(uA={...uA},uA.componentIdx=dA.componentIdx);let pA=AA[`graphicalElement${IA}ShadowSource`];if(pA){const mA=JSON.parse(JSON.stringify(uA));mA.componentIdx=pA.componentIdx,sA.push(mA)}sA.push(uA),CA!==void 0&&sA.push(...listEntryElementsForLabels({list:uA,listIndices:[uA.componentIdx,pA?.componentIdx],labelChildren:AA.labelChildren}))}let lA=sA.map(IA=>IA.componentIdx),gA=[],cA={};for(let IA of AA.labelChildren){let uA={value:IA.stateValues.value,hasLatex:IA.stateValues.hasLatex};if(IA.stateValues.forObjectComponentIdx){cA[IA.stateValues.forObjectComponentIdx]=uA;let CA=lA.indexOf(IA.stateValues.forObjectComponentIdx);if(CA!==-1){let dA=sA[CA];tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})?rA.push(dA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath?aA.push(dA.stateValues.styleNumber):dA.componentType!=="legend"&&oA.push(dA.stateValues.styleNumber)}}gA.push({labelInfo:uA,forObject:IA.stateValues.forObjectComponentIdx})}for(let IA of gA){let uA;if(IA.forObject){let CA=lA.indexOf(IA.forObject);CA!==-1&&(uA=sA[CA],sA.splice(CA,1),lA.splice(CA,1))}else for(let CA=0;CA<sA.length;CA++){let dA=sA[CA];if(!(dA.componentIdx in cA)){if(tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})){if(!rA.includes(dA.stateValues.styleNumber)){uA=dA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath){if(!aA.includes(dA.stateValues.styleNumber)){uA=dA;break}}else if(dA.componentType!=="legend"&&!oA.includes(dA.stateValues.styleNumber)){uA=dA;break}}}if(uA){let CA=uA.stateValues.selectedStyle,dA=uA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:uA.componentType,baseComponentType:"point"})?(rA.push(dA),iA.push({swatchType:"marker",markerStyle:CA.markerStyle,markerColor:CA.markerColor,markerColorDarkMode:CA.markerColorDarkMode,markerSize:CA.markerSize,lineOpacity:CA.lineOpacity,label:IA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[uA.componentType].representsClosedPath?(aA.push(dA),iA.push({swatchType:"rectangle",lineStyle:CA.lineStyle,lineColor:CA.lineColor,lineColorDarkMode:CA.lineColorDarkMode,lineWidth:CA.lineWidth,lineOpacity:CA.lineOpacity,fillColor:CA.fillColor,fillColorDarkMode:CA.fillColorDarkMode,filled:uA.stateValues.filled,fillOpacity:CA.fillOpacity,label:IA.labelInfo})):(oA.push(dA),iA.push({swatchType:"line",lineStyle:CA.lineStyle,lineColor:CA.lineColor,lineColorDarkMode:CA.lineColorDarkMode,lineWidth:CA.lineWidth,lineOpacity:CA.lineOpacity,label:IA.labelInfo}))}}}return{setValue:{legendElements:iA}}}},eA.graphLimits={forRenderer:!0,returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xMin","xMax","yMin","yMax"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphLimits:AA.graphAncestor.stateValues}}:{setValue:{graphLimits:null}}}},eA}}function listEntryElementsForLabels({list:nA,listIndices:eA,labelChildren:AA}){const tA=[],iA=new Set;for(const rA of AA){const aA=rA.stateValues.forObjectListEntry,oA=rA.stateValues.forObjectComponentIdx;if(!aA||!eA.includes(aA.listIdx)||!(aA.entryIndex<nA.stateValues.numEntries)||iA.has(oA))continue;iA.add(oA);const sA=nA.stateValues.entrySelectedStyle?.[aA.entryIndex],lA=sA===void 0||JSON.stringify(sA)===JSON.stringify(nA.stateValues.selectedStyle);tA.push({componentType:nA.componentType,componentIdx:oA,stateValues:{selectedStyle:sA??nA.stateValues.selectedStyle,styleNumber:lA?nA.stateValues.styleNumber:void 0,filled:nA.stateValues.filled}})}return tA}function parameterKey(nA){if(isValidVariable({tree:nA}))return typeof nA=="string"?"s"+nA:"t"+JSON.stringify(nA)}function replacePlaceholders(nA,eA){let AA=eA(nA);return AA!==void 0?AA:Array.isArray(nA)?[nA[0],...nA.slice(1).map(tA=>replacePlaceholders(tA,eA))]:nA}class MatchesPattern extends BooleanComponent{static componentType="matchesPattern";static componentDocs={summary:"Boolean condition that tests whether input matches a math pattern"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.pattern={createComponentOfType:"math",description:"Math expression pattern to match against.",highlighted:!0},eA.parameters={createComponentOfType:"_variableNameList",description:"Variables in the pattern that act as placeholders. Repeating one in the pattern requires the same subexpression at each occurrence. When specified, blanks in the pattern are matched literally.",highlighted:!0},eA.allowImplicitIdentities={description:"Whether to allow implicit identity transformations when matching.",createComponentOfType:"boolean",createStateVariable:"allowImplicitIdentities",defaultValue:!1,public:!0,highlighted:!0},eA.allowPermutations={description:"Whether to allow permutations of operands when matching.",createComponentOfType:"boolean",createStateVariable:"allowPermutations",defaultValue:!0,public:!0,highlighted:!0},eA.requireNumericMatches={description:"Whether numeric placeholders must match numbers.",createComponentOfType:"boolean",createStateVariable:"requireNumericMatches",defaultValue:!1,public:!0,highlighted:!0},eA.requireVariableMatches={description:"Whether variable placeholders must match variables.",createComponentOfType:"boolean",createStateVariable:"requireVariableMatches",defaultValue:!1,public:!0,highlighted:!0},eA.excludeMatches={description:"Patterns whose matches are excluded.",createComponentOfType:"mathList",createStateVariable:"excludeMatches",defaultValue:[],public:!0,highlighted:!0},eA.matchExpressionWithBlanks={description:"Whether to allow expressions with blanks to match.",createComponentOfType:"boolean",createStateVariable:"matchExpressionWithBlanks",defaultValue:!1,public:!0,highlighted:!0},eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,componentInfoObjects:iA,nComponents:rA,stateIdInfo:aA}){return tA.length===0||tA.length===1&&iA.componentIsSpecifiedType(tA[0],"math")?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.pattern={additionalStateVariablesDefined:["patternVariables"],returnDependencies:()=>({patternAttr:{dependencyType:"attributeComponent",attributeName:"pattern",variableNames:["value"]},parametersAttr:{dependencyType:"attributeComponent",attributeName:"parameters",variableNames:["variables"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK$1,patternVariables:tA}};let iA=AA.patternAttr.stateValues.value,rA=iA.variables(),aA=703;function oA(){let dA=numberToLetters(aA);for(aA++;rA.includes(dA);)dA=numberToLetters(aA),aA++;return dA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(iA.tree,pA=>{if(pA!==BLANK$1)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],gA=new Map,cA=new Map;for(let dA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(dA.tree);if(pA===void 0||gA.has(pA))continue;let mA=oA();gA.set(pA,mA),cA.set(mA,dA.toString()),tA.push(mA)}let IA=new Set,uA=replacePlaceholders(iA.tree,dA=>{let pA=gA.get(parameterKey(dA));return pA!==void 0&&IA.add(pA),pA}),CA=[...cA].filter(([dA])=>!IA.has(dA)).map(([dA,pA])=>pA);return CA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0117",args:{parameters:CA},position:sA})),{setValue:{pattern:uA,patternVariables:tA},sendDiagnostics:lA}}},eA.value={description:"Whether the input matches the pattern.",additionalStateVariablesDefined:[{variableName:"allPatternMatches"}],public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({pattern:{dependencyType:"stateVariable",variableName:"pattern"},patternVariables:{dependencyType:"stateVariable",variableName:"patternVariables"},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowImplicitIdentities:{dependencyType:"stateVariable",variableName:"allowImplicitIdentities"},allowPermutations:{dependencyType:"stateVariable",variableName:"allowPermutations"},requireNumericMatches:{dependencyType:"stateVariable",variableName:"requireNumericMatches"},requireVariableMatches:{dependencyType:"stateVariable",variableName:"requireVariableMatches"},excludeMatches:{dependencyType:"stateVariable",variableName:"excludeMatches"},matchExpressionWithBlanks:{dependencyType:"stateVariable",variableName:"matchExpressionWithBlanks"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length===0)return{setValue:{value:!1,allPatternMatches:[]}};let tA=AA.mathChildren[0].stateValues.value;if(treeContainsBlank(tA.tree)&&!AA.matchExpressionWithBlanks)return{setValue:{value:!1,allPatternMatches:[]}};let iA="any";AA.requireNumericMatches?iA="number":AA.requireVariableMatches&&(iA="variable");let rA={};AA.patternVariables.forEach(gA=>rA[gA]=iA);let aA={variables:rA,allow_permutations:AA.allowPermutations};AA.allowImplicitIdentities&&(aA.allow_implicit_identities=AA.patternVariables);let oA=tA.match(AA.pattern,aA),sA=!1,lA=[];return oA&&(Object.values(oA).map(gA=>context.fromAst(gA)).some(gA=>AA.excludeMatches.some(cA=>gA.variables().some(IA=>cA.equalsViaSyntax(context.fromAst(IA)))))||(sA=!0,lA=AA.patternVariables.map(gA=>context.fromAst(oA[gA]??BLANK$1)))),{setValue:{value:sA,allPatternMatches:lA}}}},eA.numMatches={description:"The number of matches found.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}),definition({dependencyValues:AA}){return{setValue:{numMatches:AA.allPatternMatches.length},checkForActualChange:{numMatches:!0}}}},eA.patternMatches={description:"The list of matched sub-expressions.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,numDimensions:1,entryPrefixes:["patternMatch"],returnArraySizeDependencies:()=>({numMatches:{dependencyType:"stateVariable",variableName:"numMatches"}}),returnArraySize({dependencyValues:AA}){return[AA.numMatches]},returnArrayDependenciesByKey(){return{globalDependencies:{allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA={};for(let iA=0;iA<AA.__array_size[0];iA++)tA[iA]=AA.allPatternMatches[iA];return{setValue:{patternMatches:tA}}}},eA}}class Matrix extends MathComponent{static componentType="matrix";static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static additionalSchemaChildren=["row","column"];static returnChildGroups(){return[{group:"rows",componentTypes:["matrixRow"]},{group:"columns",componentTypes:["matrixColumn"]},{group:"maths",componentTypes:["math"],excludeFromSchema:!0}]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.defaultEntry={createComponentOfType:"math",createStateVariable:"defaultEntry",defaultValue:context.fromAst(0),description:"Value used for entries that aren't explicitly specified."},eA.numRows={createComponentOfType:"integer",description:"Number of rows in the matrix."},eA.numColumns={createComponentOfType:"integer",description:"Number of columns in the matrix."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,componentInfoObjects:iA,nComponents:rA,stateIdInfo:aA}){if(tA.length===0)return{success:!1};let oA=[],sA=!1;for(let lA of tA)typeof lA!="string"&&(lA.doenetAttributes||(lA.doenetAttributes={}),lA.componentType==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.componentType="matrixColumn",sA=!0):lA.componentType==="row"?(lA.doenetAttributes.createNameFromComponentType="row",lA.componentType="matrixRow",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.attributes.createComponentOfType.primitive.value="matrixColumn",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="row"&&(lA.doenetAttributes.createNameFromComponentType="row",lA.attributes.createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(lA));return sA||(tA.length>1||!iA.componentIsSpecifiedType(tA[0],"math"))&&(oA=[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}]),{success:!0,newChildren:oA,nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.codePre,delete eA.mathChildrenFunctionSymbols,delete eA.expressionWithCodes,delete eA.mathChildrenWithCanBeModified,delete eA.codesAdjacentToStrings,delete eA.canBeModified,delete eA.mathChildrenByVectorComponent,Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.unordered={description:"Whether matrix entries should be treated as unordered.",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({}),definition(){return{setValue:{unordered:!1}}}},eA.matrixSizePre={returnDependencies:()=>({rowChildren:{dependencyType:"child",childGroups:["rows"],variableNames:["numComponents"]},colChildren:{dependencyType:"child",childGroups:["columns"],variableNames:["numComponents"]},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["matrixSize"]},numRowsAttr:{dependencyType:"attributeComponent",attributeName:"numRows",variableNames:["value"]},numColumnsAttr:{dependencyType:"attributeComponent",attributeName:"numColumns",variableNames:["value"]}}),definition({dependencyValues:AA}){let tA=null,iA=null;return AA.numRowsAttr&&(tA=AA.numRowsAttr.stateValues.value,Number.isFinite(tA)&&tA>0||(tA=null)),AA.numColumnsAttr&&(iA=AA.numColumnsAttr.stateValues.value,Number.isFinite(iA)&&iA>0||(iA=null)),AA.rowChildren.length>0?(tA===null&&(tA=AA.rowChildren.length),iA===null&&(iA=Math.max(1,...AA.rowChildren.map(rA=>rA.stateValues.numComponents)))):AA.colChildren.length>0?(iA===null&&(iA=AA.colChildren.length),tA===null&&(tA=Math.max(1,...AA.colChildren.map(rA=>rA.stateValues.numComponents)))):AA.mathChildren.length===1?(tA===null&&(tA=AA.mathChildren[0].stateValues.matrixSize[0]),iA===null&&(iA=AA.mathChildren[0].stateValues.matrixSize[1])):tA===null?iA===null?(tA=0,iA=0):tA=1:iA===null&&(iA=1),{setValue:{matrixSizePre:[tA,iA]}}}},eA.matrixPre={isArray:!0,numDimensions:2,hasEssential:!0,returnArraySizeDependencies:()=>({matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),returnArraySize({dependencyValues:AA}){return AA.matrixSizePre},returnArrayDependenciesByKey:({arrayKeys:AA})=>{let tA={defaultEntry:{dependencyType:"stateVariable",variableName:"defaultEntry"},rowChildIdentities:{dependencyType:"child",childGroups:["rows"]},colChildIdentities:{dependencyType:"child",childGroups:["columns"]}},iA={};for(let rA of AA){let[aA,oA]=rA.split(",");iA[rA]={rowChild:{dependencyType:"child",childGroups:["rows"],childIndices:[aA],variableNames:["math"+(Number(oA)+1)]},colChild:{dependencyType:"child",childGroups:["columns"],childIndices:[oA],variableNames:["math"+(Number(aA)+1)]},mathChild:{dependencyType:"child",childGroups:["maths"],childIndices:[0],variableNames:["matrixEntry"+(Number(aA)+1)+"_"+(Number(oA)+1)]}}}return{globalDependencies:tA,dependenciesByKey:iA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA,arraySize:rA}){let aA={},oA={},sA=AA.rowChildIdentities.length>0,lA=AA.colChildIdentities.length>0;for(let gA of iA){let[cA,IA]=gA.split(","),uA;sA?uA=tA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]:lA?uA=tA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]:uA=tA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)],uA===void 0?oA[gA]={defaultValue:AA.defaultEntry}:aA[gA]=uA}return{setValue:{matrixPre:aA},useEssentialOrDefaultValue:{matrixPre:oA}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:iA,dependencyNamesByKey:rA}){let aA=[],oA={},sA=tA.rowChildIdentities.length>0,lA=tA.colChildIdentities.length>0;for(let gA in AA.matrixPre){let[cA,IA]=gA.split(",");sA?iA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].rowChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):lA?iA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].colChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):iA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].mathChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0})}return Object.keys(oA).length>0&&aA.push({setEssentialValue:"matrixPre",value:oA}),{success:!0,instructions:aA}}},eA.unnormalizedValue={returnDependencies:()=>({matrixPre:{dependencyType:"stateVariable",variableName:"matrixPre"},matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),hasEssential:!0,defaultValue:context.fromAst(["matrix",["tuple",0,0],["tuple"]]),definition({dependencyValues:AA}){let tA=["tuple"];for(let rA=0;rA<AA.matrixSizePre[0];rA++)tA.push(["tuple",...AA.matrixPre[rA].map(aA=>aA.tree)]);return{setValue:{unnormalizedValue:context.fromAst(["matrix",["tuple",...AA.matrixSizePre],tA])}}},inverseDefinition({dependencyValues:AA,desiredStateVariableValues:tA}){let iA=tA.unnormalizedValue.tree;if(!(Array.isArray(iA)&&iA[0]==="matrix"&&iA[1]?.[1]===AA.matrixSizePre[0]&&iA[1]?.[2]===AA.matrixSizePre[1]))return{success:!1};let rA={};for(let aA=0;aA<AA.matrixSizePre[0];aA++)for(let oA=0;oA<AA.matrixSizePre[1];oA++)rA[`${aA},${oA}`]=context.fromAst(iA[2][aA+1][oA+1]);return{success:!0,instructions:[{setDependency:"matrixPre",desiredValue:rA}]}}},eA.canBeModified={returnDependencies:()=>({modifyIndirectly:{dependencyType:"stateVariable",variableName:"modifyIndirectly"},fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:AA.modifyIndirectly&&!AA.fixed}}}},eA}}const{eigs,square,abs,divide}=context.math;class EigenDecomposition extends BaseComponent{static componentType="eigenDecomposition";static rendererType=void 0;static componentDocs={summary:"Computes the eigenvalues and eigenvectors of a square matrix"};static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.decomposition={description:"The eigendecomposition of the matrix as a list of eigenvalue/eigenvector pairs.",additionalStateVariablesDefined:[{variableName:"numEigenvectors",description:"The number of eigenvectors found in the decomposition.",public:!0,shadowingInstructions:{createComponentOfType:"integer"}}],returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]}}),definition({dependencyValues:AA}){if(AA.mathChild.length===0)return{setValue:{decomposition:null,numEigenvectors:0}};let tA=AA.mathChild[0].stateValues.value.tree;if(!Array.isArray(tA)||tA[0]!=="matrix")return{setValue:{decomposition:null,numEigenvectors:0}};let iA=tA[1][1],rA=tA[1][2];if(!(Number.isInteger(iA)&&rA===iA))return{setValue:{decomposition:null,numEigenvectors:0}};let aA=[];for(let sA=0;sA<iA;sA++){let lA=[],gA=tA[2][sA+1]||[];for(let cA=0;cA<rA;cA++){let IA=gA[cA+1];if(IA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number")lA.push(IA);else try{IA=context.fromAst(IA).evaluate_to_constant(),typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number"?lA.push(IA):lA.push(NaN)}catch{lA.push(NaN)}}aA.push(lA)}let oA;try{oA=eigs(aA)}catch(sA){console.error("Could nt calculate eigenvalues of matrix",sA);let lA=codedDiagnostic({type:"warning",code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},sendDiagnostics:[lA]}}return{setValue:{decomposition:oA,numEigenvectors:oA.eigenvectors.length}}}},eA.eigenvalues={description:"The eigenvalues of the matrix.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["eigenvalue"],returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA;return AA.decomposition?tA=AA.decomposition.values.length:tA=0,[tA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let iA=[];for(let rA=0;rA<tA[0];rA++)iA.push(AA.decomposition.values[rA]);return{setValue:{eigenvalues:iA}}}},eA.eigenvectors={description:"The eigenvectors of the matrix, as a 2D array (one column per eigenvalue).",isArray:!0,public:!0,numDimensions:2,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="eigenvectorX"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:iA}){if(AA==="eigenvectorX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?iA?rA.every((aA,oA)=>aA<iA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?iA?rA<iA[0]?Array.from(Array(iA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="eigenvectors")return AA.length===1?"eigenvector"+AA[0]:`eigenvectorX${AA[0]}_${AA[1]}`;if(tA.slice(0,11)==="eigenvector"){let iA=Number(tA.slice(11));if(Number.isInteger(iA)&&iA>0)return`eigenvectorX${iA}_${AA[0]}`}return null},indexAliases:[[],["x","y","z"]],entryPrefixes:["eigenvectorX","eigenvector"],returnEntryDimensions:AA=>AA==="eigenvector"?1:0,returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA,iA;return AA.decomposition?(tA=AA.decomposition.eigenvectors.length,iA=AA.decomposition.eigenvectors[0].vector.length):(tA=0,iA=0),[tA,iA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let iA={};for(let rA=0;rA<tA[0];rA++){let aA=[],oA=0;for(let sA=0;sA<tA[1];sA++){let lA=AA.decomposition.eigenvectors[rA].vector[sA];aA.push(lA),oA+=square(abs(lA))}oA=Math.sqrt(oA),aA=aA.map(sA=>divide(sA,oA));for(let sA=0;sA<tA[1];sA++)iA[`${rA},${sA}`]=aA[sA]}return{setValue:{eigenvectors:iA}}}},eA}}class Latex extends Text{static componentType="latex";static componentDocs={summary:"A snippet of LaTeX that can be rendered as math"};static rendererType="text";static createAttributesObject(){let eA=super.createAttributesObject();return eA.isLatex.defaultValue=!0,eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA[0].componentTypes.push("math","m","md"),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.value.returnDependencies=()=>({mathTextLikeChildren:{dependencyType:"child",childGroups:["textLike"],variableNames:["text","latex"],variablesOptional:!0}}),eA.value.definition=function({dependencyValues:AA}){if(AA.mathTextLikeChildren.length===0)return{useEssentialOrDefaultValue:{value:!0}};let tA=[];for(let rA of AA.mathTextLikeChildren)if(typeof rA=="string"){let aA=rA.trim();aA&&tA.push(aA)}else if(rA.stateValues.latex!==void 0){let aA=rA.stateValues.latex.trim();aA&&tA.push(aA)}else{let aA=rA.stateValues.text.trim();aA&&tA.push(aA)}return{setValue:{value:tA.join(" ")}}},eA.value.inverseDefinition=function({desiredStateVariableValues:AA,dependencyValues:tA}){let iA=tA.mathTextLikeChildren.length;return iA>1?{success:!1}:iA===1?{success:!0,instructions:[{setDependency:"textLikeChildren",desiredValue:AA.value,childIndex:0,variableIndex:tA.textLikeChildren[0].stateValues?.latex===void 0?0:1}]}:{success:!0,instructions:[{setEssentialValue:"value",value:AA.value===null?"":String(AA.value)}]}},eA.latex={isAlias:!0,targetVariableName:"value",description:"The LaTeX content as a string."},eA}}class BlockQuote extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="blockQuote";static rendererType="blockQuote";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static componentDocs={summary:"A block-level quotation"};static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Description extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="description";static componentDocs={summary:"Extra information about an enclosing component, shown to all users in a popup or disclosure"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static inSchemaOnlyInheritAs=[];static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}const{mod:mod$1}=context.math;function findAttractedSegmentPointsSub({point1:nA,point2:eA,scales:AA,threshold2:tA,numericalNearestPointFunction:iA,numericalNearestPointAsLineFunction:rA,verifyNotOneSided:aA=!0}){let oA=1e-6,sA=oA**2,lA=rA(nA,AA);if(!lA)return{success:!1};let gA=lA.reduce((IA,uA,CA)=>IA+Math.pow(uA-nA[CA],2),0);if(gA>=tA)return{success:!1};let cA=rA(eA,AA);if(!cA)return{success:!1};if(gA=cA.reduce((IA,uA,CA)=>IA+Math.pow(uA-eA[CA],2),0),gA>=tA)return{success:!1};if(aA){let IA=iA(nA,AA),uA=IA&&IA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),CA=iA(eA,AA),dA=CA&&CA.every((pA,mA)=>Math.abs(pA-cA[mA])<oA);if(!(uA||dA)&&(gA=IA.reduce((pA,mA,QA)=>pA+Math.pow(mA-CA[QA],2),0),gA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:cA}}function findAttractedSegmentPoints({point1:nA,point2:eA,allowRotation:AA,scales:tA,threshold2:iA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA}){let oA=findAttractedSegmentPointsSub({point1:nA,point2:eA,scales:tA,threshold2:iA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!0});if(!oA.success)return{success:!1};let sA=1e-6,lA=sA**2,{nearestPoint1:gA,nearestPoint2:cA}=oA;if(!AA){let NA=[eA[0]-nA[0],eA[1]-nA[1]],yA=[cA[0]-gA[0],cA[1]-gA[1]],bA=Math.atan2(yA[1],yA[0])-Math.atan2(NA[1],NA[0]);if(bA=mod$1(bA+Math.PI,2*Math.PI)-Math.PI,Math.abs(bA)>sA)return{success:!1}}let IA=nA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0),uA=gA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0);if(Math.abs(IA-uA)<lA){let NA=gA.reduce((yA,bA,wA)=>yA+Math.pow(bA-nA[wA],2),0)+cA.reduce((yA,bA,wA)=>yA+Math.pow(bA-eA[wA],2),0);return NA<iA?{success:!0,distance2:NA,segment:[gA,cA]}:{success:!1}}if(uA>IA)return{success:!1};let CA=Math.sqrt(IA/uA),dA=Math.sqrt(nA.reduce((NA,yA,bA)=>NA+Math.pow(yA-gA[bA],2),0)),pA=Math.sqrt(eA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0)),mA=dA/(dA+pA),QA=1-mA,BA=(CA-1)*mA+1,hA=(CA-1)*QA+1,DA=cA.map((NA,yA)=>NA+(gA[yA]-NA)*BA),EA=gA.map((NA,yA)=>NA+(cA[yA]-NA)*hA);if(oA=findAttractedSegmentPointsSub({point1:DA,point2:EA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let fA=DA.reduce((NA,yA,bA)=>NA+Math.pow(yA-nA[bA],2),0)+EA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0);return fA<iA?{success:!0,distance2:fA,segment:[DA,EA]}:{success:!1}}function attractSegment({segment:nA,allowRotation:eA,scales:AA,threshold2:tA,numericalNearestPointFunctions:iA,numericalNearestPointAsLineFunctions:rA}){let aA=nA[0],oA=nA[1];if(aA.length!=oA.length)return{};let sA,lA=1/0,gA=eA?tA*1e3:tA;for(let[cA,IA]of iA.entries()){let uA=rA[cA],CA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:gA,numericalNearestPointFunction:IA,numericalNearestPointAsLineFunction:uA});CA.success&&CA.distance2<lA&&(lA=CA.distance2,sA=CA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<gA?{constrained:!1,distance2:lA,segment:sA}:{}}function nearestPointForSegment({point:nA,segment:eA,scales:AA}){let tA=eA[0][0],iA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(iA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===iA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-iA)/lA,IA=gA*gA+cA*cA,uA=((nA[0]-tA)/sA*gA+(nA[1]-iA)/lA*cA)/IA;return uA<=0?[tA,iA]:uA>=1?[rA,aA]:[tA+uA*gA*sA,iA+uA*cA*lA]}function nearestPointForSegmentAsLine({point:nA,segment:eA,scales:AA}){let tA=eA[0][0],iA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(iA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===iA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-iA)/lA,IA=gA*gA+cA*cA,uA=((nA[0]-tA)/sA*gA+(nA[1]-iA)/lA*cA)/IA;return[tA+uA*gA*sA,iA+uA*cA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentDocs={summary:"Constrains group members to attract to each other when nearby"};static rendererType="containerInline";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.relativeToGraphScales={description:"Whether the snapping threshold is interpreted relative to graph scales.",createComponentOfType:"boolean",createStateVariable:"relativeToGraphScales",defaultValue:!1,public:!0},eA.threshold={createComponentOfType:"number",description:"Distance threshold within which group members snap together."},eA.angleThreshold={description:"Angular distance within which group members snap together.",createComponentOfType:"number",createStateVariable:"angleThreshold",defaultValue:Math.PI*.03,public:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"graphical",componentTypes:["_graphical"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnConstraintGraphInfoDefinitions();return Object.assign(eA,AA),eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.pointsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","numericalXs","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let iA=[];for(let rA of tA.graphicalChildren)rA.stateValues.numericalVertices?iA.push(rA.stateValues.numericalVertices):rA.stateValues.numericalXs?iA.push([rA.stateValues.numericalXs]):rA.stateValues.numericalEndpoints?iA.push(rA.stateValues.numericalEndpoints):iA.push([]);return{setValue:{pointsByObject:iA}}}},eA.getPointsForObject={returnDependencies:()=>({pointsByObject:{dependencyType:"stateVariable",variableName:"pointsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getPointsForObject:function(rA){return tA.pointsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.segmentsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","closed","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let iA=[];for(let rA of tA.graphicalChildren)if(rA.stateValues.numericalVertices){let aA=rA.stateValues.numericalVertices,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);rA.stateValues.closed&&sA.push([aA[oA-1],aA[0]]),iA.push(sA)}else if(rA.stateValues.numericalEndpoints){let aA=rA.stateValues.numericalEndpoints,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);iA.push(sA)}else iA.push([]);return{setValue:{segmentsByObject:iA}}}},eA.getSegmentsForObject={returnDependencies:()=>({segmentsByObject:{dependencyType:"stateVariable",variableName:"segmentsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getSegmentsForObject:function(rA){return tA.segmentsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.threshold={description:"Distance within which group members attract each other.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,returnDependencies:()=>({thresholdAttr:{dependencyType:"attributeComponent",attributeName:"threshold",variableNames:["value"]},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"}}),definition({dependencyValues:tA}){return tA.thresholdAttr?{setValue:{threshold:tA.thresholdAttr.stateValues.value}}:{useEssentialOrDefaultValue:{threshold:{get defaultValue(){return tA.relativeToGraphScales&&tA.graphXmin!==null?.02:.5}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:iA}){return iA.thresholdAttr?{success:!0,instructions:[{setDependency:"thresholdAttr",desiredValue:tA.threshold}]}:{success:!0,instructions:[{setEssentialValue:"threshold",value:tA.threshold}]}}},eA.verticesConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},angleThreshold:{dependencyType:"stateVariable",variableName:"angleThreshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let iA;tA.relativeToGraphScales?iA=tA.scales||[1,1,1]:iA=[1,1,1];let rA=tA.angleThreshold,aA=function({numericalUnconstrainedEdges:cA,allowRotation:IA,enforceRigid:uA,shrinkThreshold:CA,rotationPoint:dA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),QA=[],BA=[],hA=!1,DA={distance2:1/0},EA=tA.threshold;CA&&(EA*=.2);let fA=EA*EA;for(let[NA,yA]of cA.entries()){let bA=[],wA=[];for(let vA of mA)bA.push((kA,TA)=>nearestPointForSegment({point:kA,segment:vA,scales:TA})),wA.push((kA,TA)=>nearestPointForSegmentAsLine({point:kA,segment:vA,scales:TA}));let MA=attractSegment({segment:yA,allowRotation:IA,scales:iA,threshold2:fA,numericalNearestPointFunctions:bA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(QA.push(MA.segment),BA.push(!0),hA=!0):(QA.push(yA),BA.push(!1),!hA&&MA.distance2<DA.distance2&&(DA=MA,DA.edgeInd=NA))}if(IA&&uA&&!hA&&DA.distance2<1/0){let NA=DA.edgeInd,yA=rotateIfClose({attractedEdgeInd:NA,attractingSegment:DA.segment,angleThreshold:rA,rotationPoint:dA,numericalUnconstrainedEdges:cA});yA&&(QA[NA]=yA,BA[NA]=!0,hA=!0)}if(IA&&uA&&!hA){let NA=[0,Math.PI/2],yA=rotateToAttractAngles({numericalUnconstrainedEdges:cA,anglesToAttract:NA,angleThreshold:rA,rotationPoint:dA});if(yA){let bA=yA.rotatedEdgeInd;QA[bA]=yA.rotatedEdge,BA[bA]=!0,hA=!0}}return{numericalConstrainedEdges:QA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:cA,closed:IA,shrinkThreshold:uA,onlyMoveVertexInd:CA=null},{objectInd:dA}){let pA=tA.getPointsForObject(dA),mA=tA.getSegmentsForObject(dA),QA=[],BA=[],hA=tA.threshold;uA&&(hA*=.2);let DA=hA*hA;for(let[yA,bA]of cA.entries()){if(CA!==null&&yA!==CA){QA.push(bA),BA.push(!1);continue}let wA=1/0,MA={};for(let TA of pA){if(bA.length!==TA.length)continue;let OA=bA.reduce((FA,RA,xA)=>FA+Math.pow((RA-TA[xA])/iA[xA],2),0);OA<wA&&(MA=TA,wA=OA)}let vA=!1,kA;if(wA<DA)vA=!0,kA=MA;else{wA=1/0,MA={};for(let TA of mA){let OA=nearestPointForSegment({point:bA,segment:TA,scales:iA});if(OA){let FA=bA.reduce((RA,xA,jA)=>RA+Math.pow((xA-OA[jA])/iA[jA],2),0);FA<wA&&(MA=OA,wA=FA)}}wA<DA?(vA=!0,kA=MA):kA=bA}QA.push(kA),BA.push(vA)}let EA=cA.length,fA=IA?EA:EA-1,NA=[];for(let yA=0;yA<fA;yA++){let bA=(yA+1)%EA;if(!(CA!==null&&!(CA===yA||CA===bA))&&!(BA[yA]||BA[bA])){let wA=cA[yA],MA=cA[bA],vA,kA=1/0;for(let TA of pA){let OA=nearestPointForSegment({point:TA,segment:[wA,MA],scales:iA});if(OA){let FA=OA.reduce((RA,xA,jA)=>RA+Math.pow(xA-TA[jA],2),0);if(FA<kA)if(CA===null){let RA=wA.map((jA,HA)=>jA+TA[HA]-OA[HA]),xA=MA.map((jA,HA)=>jA+TA[HA]-OA[HA]);vA=[RA,xA],kA=FA}else{let RA;CA===yA?RA=MA:RA=wA;let xA=[TA[0]-RA[0],TA[1]-RA[1]],jA=Math.sqrt(Math.pow(xA[0],2)+Math.pow(xA[1],2)),zA=Math.sqrt(Math.pow(wA[0]-MA[0],2)+Math.pow(wA[1]-MA[1],2))/jA;if(zA<1)continue;let GA=RA.map((JA,Or)=>JA+xA[Or]*zA),KA;CA===yA?(KA=[GA,MA],FA=Math.pow(wA[0]-GA[0],2)+Math.pow(wA[1]-GA[1],2)):(KA=[wA,GA],FA=Math.pow(MA[0]-GA[0],2)+Math.pow(MA[1]-GA[1],2)),FA<kA&&(kA=FA,vA=KA)}}}kA<DA&&NA.push({vertexInd1:yA,vertexInd2:bA,distance2:kA,movedSegment:vA})}}NA.sort((yA,bA)=>yA.distance2-bA.distance2);for(let{vertexInd1:yA,vertexInd2:bA,movedSegment:wA}of NA)BA[yA]||BA[bA]||(BA[yA]=!0,BA[bA]=!0,QA[yA]=wA[0],QA[bA]=wA[1]);return{numericalConstrainedVertices:QA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:cA,closed:IA,enforceRigid:uA,allowRotation:CA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}){let BA=sA({unconstrainedVertices:cA,closed:IA,enforceRigid:uA,allowRotation:CA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA});return BA=lA({unconstrainedVertices:BA,closed:IA,enforceRigid:uA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}),BA}}}}},eA.pointConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let iA;return tA.relativeToGraphScales?iA=tA.scales||[1,1,1]:iA=[1,1,1],{setValue:{pointConstraintFunction:function(aA,oA){let sA=aA.map(uA=>findFiniteNumericalValue(uA)),lA=tA.getPointsForObject(oA),gA=tA.getSegmentsForObject(oA),cA=1/0,IA={};for(let uA of lA){if(sA.length!==uA.length)continue;let CA=sA.reduce((dA,pA,mA)=>dA+Math.pow((pA-uA[mA])/iA[mA],2),0);CA<cA&&(IA=uA,cA=CA)}if(cA<tA.threshold*tA.threshold)return IA.map(uA=>context.fromAst(uA));cA=1/0,IA={};for(let uA of gA){let CA=nearestPointForSegment({point:sA,segment:uA,scales:iA});if(CA){let dA=sA.reduce((pA,mA,QA)=>pA+Math.pow((mA-CA[QA])/iA[QA],2),0);dA<cA&&(IA=CA,cA=dA)}}return cA<tA.threshold*tA.threshold?IA.map(uA=>context.fromAst(uA)):aA}}}}},eA}async addChildren(eA){return await addChildrenToDynamicChild(this,eA)}async deleteChildren(eA){return await deleteChildrenFromDynamicChild(this,eA)}}function rotateToAttractAngles({numericalUnconstrainedEdges:nA,anglesToAttract:eA,angleThreshold:AA,rotationPoint:tA}){let iA=1/0,rA;for(let[cA,IA]of nA.entries()){let uA=Math.atan((IA[1][1]-IA[0][1])/(IA[1][0]-IA[0][0]));for(let CA of eA){let dA=mod$6(CA-uA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(dA)<Math.abs(iA)&&(iA=dA,rA=cA)}}if(!(Math.abs(iA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(iA),lA=Math.sin(iA),gA=nA[rA].map(cA=>{let IA=cA[0]-aA,uA=cA[1]-oA;return[IA*sA-uA*lA+aA,IA*lA+uA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:gA}}function rotateIfClose({attractedEdgeInd:nA,attractingSegment:eA,angleThreshold:AA,rotationPoint:tA,numericalUnconstrainedEdges:iA}){let rA=Math.atan((eA[1][1]-eA[0][1])/(eA[1][0]-eA[0][0])),aA=iA[nA],oA=Math.atan((aA[1][1]-aA[0][1])/(aA[1][0]-aA[0][0])),sA=mod$6(rA-oA+Math.PI/2,Math.PI)-Math.PI/2;if(!(Math.abs(sA)<AA))return null;let[lA,gA]=tA,cA=Math.cos(sA),IA=Math.sin(sA);return iA[nA].map(CA=>{let dA=CA[0]-lA,pA=CA[1]-gA;return[dA*cA-pA*IA+lA,dA*IA+pA*cA+gA]})}class BlockScoredComponent extends BlockComponent{static componentType="_blockScoredComponent";static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnStandardAnswerAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"disabled",newName:"disabledOriginal"}),Object.assign(eA,returnStandardAnswerStateVariableDefinition()),eA}}function parseIntegerResponse(nA){const eA=nA.trim();if(eA==="")return null;const AA=Number(eA);return Number.isInteger(AA)?AA:null}function isDistractorResponse(nA){return nA.trim().toLowerCase()==="x"}function calculateResponseOffset({numericResponse:nA,effectiveProblemNum:eA,numEffectiveProblems:AA}){return(nA-eA+AA)%AA}function calculatePretzelCredit({problemOrder:nA,currentResponses:eA,distractors:AA,mode:tA}){const iA=new Set(AA),rA=nA.length,aA=rA-iA.size;if(aA===0)return eA.every(isDistractorResponse)?1:0;const oA=Array(rA).fill(null);let sA=0;for(let uA=0;uA<rA;uA++)iA.has(uA)||(oA[uA]=sA,sA++);const lA=[],gA=tA==="circuit"?aA===1?0:1:null;for(let uA=0;uA<rA;uA++){const CA=nA[uA],dA=eA[uA]??"";if(iA.has(CA)){if(!isDistractorResponse(dA))return 0;continue}const pA=parseIntegerResponse(dA);if(pA===null)return 0;const mA=oA[CA],QA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(QA!==gA)return 0;continue}lA.push(QA)}if(tA==="circuit")return 1;const cA=lA[0];return lA.every(uA=>uA===cA)?1:0}class Pretzel extends BlockScoredComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this),submitAnswer:this.submitAnswer.bind(this)})}static componentType="pretzel";static componentDocs={summary:"A response-matching component where students enter a sequence to match statements and answers"};static renderChildren=!0;static additionalSchemaChildren=["problem"];static additionalSchemaChildrenDoNotInherit=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.maxNumColumns={description:"Maximum number of columns when arranging child problems.",createComponentOfType:"integer",createStateVariable:"maxNumColumns",defaultValue:2,public:!0,forRenderer:!0,clamp:[1,4]},eA.mode={description:"Arrangement mode for the child problems.",createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static returnChildGroups(){return[{group:"problems",componentTypes:["statement"],excludeFromSchema:!0},{group:"textInputs",componentTypes:["textInput"],excludeFromSchema:!0},{group:"givenAnswers",componentTypes:["span"],excludeFromSchema:!0}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.textInputs={returnDependencies:()=>({textInputs:{dependencyType:"child",childGroups:["textInputs"]}}),definition:function({dependencyValues:AA}){return{setValue:{textInputs:AA.textInputs}}}},eA.problemOrder={stateVariablesDeterminingDependencies:["textInputs"],additionalStateVariablesDefined:["distractors"],returnDependencies({stateValues:AA}){return AA.textInputs.length>0?{problemOrder:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"problemOrder"},distractors:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"distractors"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{problemOrder:AA.problemOrder??[],distractors:AA.distractors??[]}}}},eA.numProblems={description:"The number of child problems.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({problemChildren:{dependencyType:"child",childGroups:["problems"]}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.problemChildren.length}}}},eA.currentResponses={description:"The current responses across all child problems.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,entryPrefixes:["currentResponse"],returnArraySizeDependencies:()=>({numProblems:{dependencyType:"stateVariable",variableName:"numProblems"}}),returnArraySize({dependencyValues:AA}){return[AA.numProblems]},returnArrayDependenciesByKey({arrayKeys:AA}){const tA={};for(const iA of AA)tA[iA]={textInput:{dependencyType:"child",childGroups:["textInputs"],childIndices:[iA],variableNames:["value"]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA}){const tA={};for(const iA in AA)tA[iA]=AA[iA].textInput[0].stateValues.value;return{setValue:{currentResponses:tA}}}},eA.creditAchievedIfSubmit={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},currentResponses:{dependencyType:"stateVariable",variableName:"currentResponses"},distractors:{dependencyType:"stateVariable",variableName:"distractors"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=AA.problemOrder.map(iA=>iA-1);return{setValue:{creditAchievedIfSubmit:calculatePretzelCredit({problemOrder:tA,currentResponses:AA.currentResponses,distractors:AA.distractors,mode:AA.mode})}}}},eA.numSubmittedResponses={description:"The number of responses submitted.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,defaultValue:0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{numSubmittedResponses:!0}}),inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"numSubmittedResponses",value:AA.numSubmittedResponses}]}}},eA.submittedResponses={description:"The most recently submitted responses.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,allowExtraArrayKeysInInverse:!0,entryPrefixes:["submittedResponse"],defaultValueByArrayKey:()=>"_",hasEssential:!0,inverseShadowToSetEntireArray:!0,doNotCombineInverseArrayInstructions:!0,returnArraySizeDependencies:()=>({numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}),returnArraySize({dependencyValues:AA}){return[AA.numSubmittedResponses]},returnArrayDependenciesByKey(){return{globalDependencies:{numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=[];AA.submittedResponsesComponentType&&tA.push(...AA.submittedResponsesComponentType.slice(0,AA.numSubmittedResponses));let iA={};for(let rA=0;rA<AA.numSubmittedResponses;rA++)iA[rA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:iA}}},inverseArrayDefinitionByKey:function({desiredStateVariableValues:AA,initialChange:tA}){return tA?{success:!0,instructions:[{setDependency:"numSubmittedResponses",desiredValue:AA.submittedResponses.length},{setEssentialValue:"submittedResponses",value:[...AA.submittedResponses]}]}:{success:!1}}},eA.showCheckWork={forRenderer:!0,returnDependencies:()=>({suppressCheckWork:{dependencyType:"stateVariable",variableName:"suppressCheckWork"}}),definition({dependencyValues:AA}){return{setValue:{showCheckWork:!AA.suppressCheckWork}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}async submitAnswer({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.numAttemptsLeft<1||await this.stateValues.disabled)return;const aA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let oA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:aA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],sA=await this.stateValues.currentResponses;oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:sA}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:await this.stateValues.numSubmissions+1}),aA<1&&oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const lA=[];for(const gA of sA)if(gA.toString)try{lA.push(gA.toString())}catch{lA.push("_")}else lA.push(gA);return oA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:sA,responseText:lA,creditAchieved:aA}),await this.coreFunctions.performUpdate({updateInstructions:oA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:sA,responseText:lA,componentTypes:Array(sA.length).fill("text"),creditAchieved:aA}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function getCorrespondingAnswerIdx({problemIdx:nA,numProblems:eA,distractorSet:AA}){if(AA.has(nA))return nA;let tA=(nA-1+eA)%eA,iA=0;for(;AA.has(tA)&&iA<eA;)tA=(tA-1+eA)%eA,iA++;return tA}function normalizePretzelMode(nA){return nA?.toLowerCase()==="circuit"?"circuit":"pretzel"}function getProblemIndicesToPermute({numProblems:nA,mode:eA}){const AA=eA==="circuit"?2:1;return[...Array(Math.max(nA-AA+1,0)).keys()].map(tA=>tA+AA)}function buildProblemOrderFromPermutedIndices({permutedIndices:nA,numProblems:eA,mode:AA}){return AA==="circuit"?eA===0?[]:[1,...nA]:nA}function determineNumberOfPermutations({numProblems:nA,mode:eA}){const AA=getProblemIndicesToPermute({numProblems:nA,mode:eA}).length;let tA=1;for(let iA=2;iA<=AA;iA++)tA*=iA;return tA}function shuffleProblemOrder({numProblems:nA,variantRng:eA,mode:AA}){const tA=getProblemIndicesToPermute({numProblems:nA,mode:AA});for(let iA=tA.length-1;iA>0;iA--){const rA=eA(),aA=Math.floor(rA*(iA+1));[tA[iA],tA[aA]]=[tA[aA],tA[iA]]}return buildProblemOrderFromPermutedIndices({permutedIndices:tA,numProblems:nA,mode:AA})}class PretzelArranger extends CompositeComponent{static componentType="_pretzelArranger";static componentDocs={summary:"Internal arranger that lays out subset visualizations within <pretzel>."};static createsVariants=!0;static serializeReplacementsForChildren=!0;static replacementsAlreadyInResolver=!0;static useSerializedChildrenComponentIndices=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.mode={createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.serializedProblemChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedProblemChildren:AA.serializedChildren.filter(tA=>tA.componentType==="problem")}}}},eA.numProblems={description:"The number of problems arranged.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.serializedProblemChildren.length}}}},eA.problemOrder={forRenderer:!0,shadowVariable:!0,returnDependencies:({sharedParameters:AA})=>({mode:{dependencyType:"stateVariable",variableName:"mode"},numProblems:{dependencyType:"stateVariable",variableName:"numProblems"},variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},variants:{dependencyType:"variants"}}),definition:function({dependencyValues:AA}){let tA=AA.numProblems,iA=[],rA;const aA=AA.mode;let oA=AA.variants?.desiredVariant?.indices;if(oA!==void 0)if(oA.length!==tA)iA.push(codedDiagnostic({type:"info",code:"doenet-i0005"}));else{if(oA=oA.map(Number),!oA.every(Number.isInteger))throw Error("All indices specified for pretzel must be integers");if(!oA.every(lA=>lA>=1&&lA<=tA))iA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"pretzel"}}));else if(new Set(oA).size!==tA)iA.push(codedDiagnostic({type:"info",code:"doenet-i0008"}));else if(aA==="circuit"&&tA>0&&oA[0]!==1)iA.push(codedDiagnostic({type:"info",code:"doenet-i0009"}));else return{setValue:{problemOrder:oA}}}let sA=AA.rngClass(AA.variantSeed+"co");return rA=shuffleProblemOrder({numProblems:tA,variantRng:sA,mode:aA}),{setValue:{problemOrder:rA},sendDiagnostics:iA}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let iA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.problemOrder},rA=iA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:iA,isVariantComponent:!0}}}},eA.statements={additionalStateVariablesDefined:["givenAnswers","validProblems","distractors"],returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=[],iA=[],rA=[];let aA=!0;const oA=[];for(const[sA,lA]of AA.serializedProblemChildren.entries()){let gA=null,cA=null;for(const IA of lA.children)if(IA.componentType==="statement")gA=IA;else if(IA.componentType==="givenAnswer"){const uA=IA.children.find(CA=>CA.componentType==="_postponeRenderContainer");uA&&(cA={...uA,componentType:"span",attributes:{...uA.attributes},children:(uA.children??[]).filter(CA=>CA.componentType!=="label"&&CA.componentType!=="shortDescription")},cA.componentIdx=IA.componentIdx,IA.attributes.name&&(cA.attributes.name=IA.attributes.name))}(gA===null||cA===null)&&(aA=!1),tA.push(gA),iA.push(cA),lA.attributes.isDistractor?.primitive.value&&rA.push(sA)}return aA||oA.push(codedDiagnostic({type:"warning",code:"doenet-w0076"})),AA.mode==="circuit"&&rA.includes(0)&&oA.push(codedDiagnostic({type:"error",code:"doenet-e0001"})),{setValue:{statements:tA,givenAnswers:iA,validProblems:aA,distractors:rA},sendDiagnostics:oA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},statements:{dependencyType:"stateVariable",variableName:"statements"},givenAnswers:{dependencyType:"stateVariable",variableName:"givenAnswers"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const iA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[];let aA=[];const oA=await eA.stateValues.numProblems,sA=await eA.stateValues.problemOrder,lA=await eA.stateValues.statements,gA=await eA.stateValues.givenAnswers,cA=await eA.stateValues.distractors,IA=await eA.stateValues.mode,uA=new Set(cA);for(let CA=0;CA<oA;CA++){const dA=sA[CA]-1,pA=lA[dA],mA=getCorrespondingAnswerIdx({problemIdx:dA,numProblems:oA,distractorSet:uA}),QA=gA[mA];QA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(QA),aA.push({type:"serialized",componentType:"textInput",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{width:{type:"component",name:"width",component:{type:"serialized",componentType:"componentSize",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{componentSize:{size:15,isAbsolute:!0}},children:[],attributes:{},doenetAttributes:{}}}},doenetAttributes:{},state:IA==="circuit"&&CA===0?{value:"1",disabledPreliminary:!0}:{},children:[{type:"serialized",componentType:"shortDescription",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{},children:[{type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{value:"Enter number in sequence for this answer or X if it is a distractor"},children:[],attributes:{},doenetAttributes:{}}],attributes:{},doenetAttributes:{}}]}),pA===null?aA.push({type:"serialized",componentType:"statement",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(pA)}return tA.replacementsCreated=iA.num,{replacements:aA,diagnostics:rA,nComponents:AA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){let iA=0;const rA=normalizePretzelMode(eA.attributes.mode?.primitive?.value);for(let lA of eA.children)if(lA.componentType==="problem")iA++;else if(AA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:"_composite"})&&lA.attributes.createComponentOfType?.primitive.value==="problem")if(lA.attributes.numProblems?.primitive!==void 0){let gA=Number(lA.attributes.numProblems?.primitive.value);if(Number.isInteger(gA)&&gA>=0)iA+=gA;else return{success:!1}}else iA++;else return{success:!1};let aA=determineNumberOfPermutations({numProblems:iA,mode:rA}),oA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!oA.success)return{success:!1};let sA=oA.numVariants*aA;return eA.variants.numVariants=sA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:aA,numProblems:iA,mode:rA},{success:!0,numVariants:sA}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let iA=eA.variants?.numVariants;if(iA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>iA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numProblems;const lA=normalizePretzelMode(eA.variants.uniqueVariantData.mode);let gA=[...rA];gA.push(oA);let cA=enumerateCombinations({numberOfOptionsByIndex:gA,maxNumber:AA})[AA-1].map(BA=>BA+1),IA=cA.pop(),uA=cA;const CA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),dA=buildProblemOrderFromPermutedIndices({permutedIndices:enumeratePermutations({values:CA,maxNumber:IA})[IA-1],numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let hA=aA[BA],EA=tA.allComponentClasses[hA.componentType].getUniqueVariant({serializedComponent:hA,variantIndex:uA[BA],componentInfoObjects:tA});if(!EA.success)return{success:!1};mA.push(EA.desiredVariant),pA=!0}else mA.push({});let QA={indices:dA};return pA&&(QA.subvariants=mA),{success:!0,desiredVariant:QA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static componentDocs={summary:"Reveals its children one step at a time, each once the steps before it are complete"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!1;static createAttributesObject(){let eA=super.createAttributesObject();return eA.hideFutureSections={createComponentOfType:"boolean",createStateVariable:"hideFutureSections",defaultValue:!1,public:!0,description:"Whether to hide later cascade sections until previous ones are completed."},eA.revealAll={createComponentOfType:"boolean",createStateVariable:"revealAllPreliminary",defaultValue:!1,description:"Whether all cascade entries should be revealed regardless of progress."},eA.boxAll={createComponentOfType:"boolean",createStateVariable:"boxAll",defaultValue:!1,description:"Whether to draw boxes around all cascade entries regardless of progress."},Object.assign(eA,returnSectionTitleStateColorAttributes()),eA}static returnChildGroups(){return[{group:"titles",componentTypes:["title"]},{group:"setups",componentTypes:["setup"]},{group:"cascadeMessages",componentTypes:["cascadeMessage"]},{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnCascadeStepStateVariableDefinitions()),Object.assign(eA,returnSectionTitleStateColorStateVariableDefinitions()),eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},titleChildren:{dependencyType:"child",childGroups:["titles"]},asList:{dependencyType:"stateVariable",variableName:"asList"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"}}),definition({dependencyValues:tA,componentInfoObjects:iA}){const rA=new Set(tA.titleChildren.map(sA=>sA.componentIdx)),aA=[];for(const[sA,lA]of tA.allChildren.entries()){if(typeof lA=="string"){!tA.hideChildren&&!tA.asList&&aA.push(sA);continue}rA.has(lA.componentIdx)||tA.asList&&!LIST_CONTAINER_TYPES.some(gA=>iA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:gA}))&&!["introduction","conclusion"].includes(lA.componentType)||aA.push(sA)}const oA=tA.titleChildren.map(sA=>codedDiagnostic({type:"warning",code:"doenet-w0167",position:sA.position||void 0}));return{setValue:{childIndicesToRender:aA},sendDiagnostics:oA}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this cascade's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:tA}){return{setValue:{asList:!!tA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA.childrenAggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{childrenAggregateScores:!0}})};const AA=returnScoredSectionStateVariableDefinition();return eA.aggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{aggregateScores:!0}})},eA.scoredDescendants=AA.scoredDescendants,eA.creditAchievedForProgress=AA.creditAchievedForProgress,eA.childCreditAchieved={returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["creditAchievedForProgress"],variablesOptional:!0}}),definition({dependencyValues:tA}){return{setValue:{childCreditAchieved:tA.children.map(rA=>rA.stateValues?.creditAchievedForProgress??null)}}}},eA.numCompleted={description:"The number of cascade sections currently completed.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({childCreditAchieved:{dependencyType:"stateVariable",variableName:"childCreditAchieved"}}),definition({dependencyValues:tA}){let iA=0;for(const rA of tA.childCreditAchieved)if(rA===1||rA===null)iA++;else break;return{setValue:{numCompleted:iA}}}},eA.revealAll={returnDependencies:()=>({cascadeAncestor:{dependencyType:"ancestor",componentType:"cascade",variableNames:["revealAll"]},revealAllPreliminary:{dependencyType:"stateVariable",variableName:"revealAllPreliminary"}}),definition({dependencyValues:tA,usedDefault:iA}){let rA=!1;return iA.revealAllPreliminary?tA.cascadeAncestor&&(rA=tA.cascadeAncestor.stateValues.revealAll):rA=tA.revealAllPreliminary,{setValue:{revealAll:rA}}}},eA.childrenToHide={additionalStateVariablesDefined:["childrenToHideChildren","sectionToShowCascadeMessage"],returnDependencies:()=>({hideFutureSections:{dependencyType:"stateVariable",variableName:"hideFutureSections"},numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"],variableNames:["hasCascadeMessageToShow"],variablesOptional:!0},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"},showCascadeMessage:{dependencyType:"stateVariable",variableName:"showCascadeMessage"}}),definition({dependencyValues:tA,componentInfoObjects:iA}){const rA=tA.childrenWithCascadeMessages.filter(cA=>cA.componentType==="cascadeMessage").map(cA=>cA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[cA,IA]of tA.children.entries())cA<=tA.numCompleted?tA.hideChildren&&aA.push(IA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(uA=>iA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:uA}))?oA.push(IA.componentIdx):aA.push(IA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,gA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(cA=>cA!==gA)),{setValue:{childrenToHide:aA,childrenToHideChildren:oA,sectionToShowCascadeMessage:lA}}}},eA.hasCascadeMessageToShow={returnDependencies:()=>({numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"]},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"}}),definition({dependencyValues:tA}){return{setValue:{hasCascadeMessageToShow:nextOwnCascadeMessage(tA)!==null}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function nextOwnCascadeMessage(nA){if(nA.revealAll||nA.numCompleted>nA.children.length-2)return null;const eA=nA.children[nA.numCompleted].componentIdx,AA=nA.childrenWithCascadeMessages.findIndex(tA=>tA.componentIdx===eA);return nA.childrenWithCascadeMessages.slice(AA+1).find(tA=>tA.componentType==="cascadeMessage")?.componentIdx??null}class Page extends BlockComponent{static componentType="page";static componentDocs={summary:"The content of one printed page"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},asList:{dependencyType:"stateVariable",variableName:"asList"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){const iA=[];for(const[rA,aA]of AA.allChildren.entries())(!AA.asList||typeof aA!="string"&&(LIST_CONTAINER_TYPES.some(oA=>tA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:oA}))||["introduction","conclusion"].includes(aA.componentType)))&&iA.push(rA);return{setValue:{childIndicesToRender:iA}}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this page's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:AA}){return{setValue:{asList:!!AA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA}}class DynamicChildren extends CompositeComponent{constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentType="_dynamicChildren";static componentDocs={summary:"Internal container for dynamically-generated children."};static treatAsComponentForRecursiveReplacements=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.deferUntilParentRendered={createComponentOfType:"boolean",createStateVariable:"deferUntilParentRendered",defaultValue:!1,description:"Whether to wait until the parent is rendered before creating dynamic children."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.dynamicChildren={hasEssential:!0,defaultValue:[],returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{dynamicChildren:!0}}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"dynamicChildren",value:AA.dynamicChildren}]}}},eA.createReplacements={stateVariablesDeterminingDependencies:["deferUntilParentRendered"],returnDependencies:({stateValues:AA})=>{const tA={deferUntilParentRendered:{dependencyType:"stateVariable",variableName:"deferUntilParentRendered"}};return AA.deferUntilParentRendered&&(tA.parentRendered={dependencyType:"parentStateVariable",variableName:"rendered"}),tA},definition({dependencyValues:AA}){return{setValue:{createReplacements:!AA.deferUntilParentRendered||AA.parentRendered!==!1}}},markStale(){return{updateReplacements:!0}}},eA.nGroups={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"}}),definition({dependencyValues:AA}){return{setValue:{nGroups:AA.dynamicChildren.length}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"},createReplacements:{dependencyType:"stateVariable",variableName:"createReplacements"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}},markStale(){return{updateReplacements:!0}}},eA}async addChildren({serializedComponents:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){if(eA&&eA.length>0){const rA=[...await this.stateValues.dynamicChildren];return rA.push({type:"serialized",componentType:"group",componentIdx:0,attributes:{},doenetAttributes:{},state:{},children:deepClone(eA)}),await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:rA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}else return}async deleteChildren({number:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){const rA=await this.stateValues.nGroups;let aA=Math.min(eA,rA);if(aA>0){const oA=(await this.stateValues.dynamicChildren).slice(0,rA-aA);return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:oA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}else return}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){let iA=[];tA.replacementsCreated===void 0&&(tA.replacementsCreated=0),tA.replacementsCreatedThroughGroup=[];let rA=[];if(!await eA.stateValues.createReplacements)return tA.nGroups=0,{replacements:rA,diagnostics:iA,nComponents:AA};const aA=await eA.stateValues.nGroups;for(let oA=0;oA<aA;oA++){let sA=await this.replacementForGroup({component:eA,groupNum:oA,nComponents:AA,workspace:tA}),lA=sA.replacements;AA=sA.nComponents,rA.push(...lA)}return tA.nGroups=aA,{replacements:rA,diagnostics:iA,nComponents:AA}}static async replacementForGroup({component:eA,groupNum:AA,nComponents:tA,workspace:iA}){let rA=[deepClone((await eA.stateValues.dynamicChildren)[AA])];const aA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated},oA=createNewComponentIndices(rA,tA,aA);return rA=oA.components,tA=oA.nComponents,iA.replacementsCreated=aA.num,iA.replacementsCreatedThroughGroup=[...iA.replacementsCreatedThroughGroup,iA.replacementsCreated],{replacements:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,nComponents:AA,workspace:tA}){const rA=await eA.stateValues.createReplacements?await eA.stateValues.nGroups:0;if(rA===tA.nGroups)return{replacementChanges:[],nComponents:AA};if(rA<tA.nGroups){const sA=[{changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:rA,numberReplacementsToDelete:tA.nGroups-rA}];return tA.nGroups=rA,tA.replacementsCreated=tA.replacementsCreatedThroughGroup[rA-1]||0,tA.replacementsCreatedThroughGroup=tA.replacementsCreatedThroughGroup.slice(0,rA),{replacementChanges:sA,nComponents:AA}}let aA=[];for(let sA=tA.nGroups;sA<rA;sA++){let lA=await this.replacementForGroup({component:eA,groupNum:sA,nComponents:AA,workspace:tA}),gA=lA.replacements;AA=lA.nComponents,aA.push(...gA)}let oA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA.nGroups,numberReplacementsToReplace:0,serializedReplacements:aA,replacementsToWithhold:0};return tA.nGroups=rA,{replacementChanges:[oA],nComponents:AA}}}class ShortDescription extends TextOrInline{static componentType="shortDescription";static componentDocs={summary:"A short accessibility description (e.g. for a `<graph>`) read by screen readers"};static rendererType=void 0;static inSchemaOnlyInheritAs=[];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.inlineChildren={returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:({dependencyValues:AA})=>({setValue:{inlineChildren:AA.inlineChildren}})},eA.value={description:"The short description text.",public:!0,shadowingInstructions:{createComponentOfType:this.componentType},stateVariablesDeterminingDependencies:["inlineChildren"],returnDependencies:({stateValues:AA})=>{const tA={inlineChildren:{dependencyType:"stateVariable",variableName:"inlineChildren"}};for(const[iA,rA]of AA.inlineChildren.entries())typeof rA=="object"&&(tA[`adapterSource${iA}`]={dependencyType:"adapterSource",componentIdx:rA.componentIdx});return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){const iA=textFromChildren(AA.inlineChildren);let rA;for(let oA=0;oA<AA.inlineChildren.length;oA++){const sA=AA.inlineChildren[oA];if(typeof sA!="object")continue;const lA=AA[`adapterSource${oA}`]?.componentType??sA.componentType;if(tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"math"})||tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"m"})){rA=lA;break}}const aA=[];return rA&&aA.push(codedDiagnostic({type:"accessibility",level:2,code:"doenet-a0005",args:{component:rA}})),{setValue:{value:iA},sendDiagnostics:aA}}},eA}}const unitConversions={"":1,px:1,pixel:1,pixels:1,"%":1,em:100,in:96,inch:96,inches:96,pt:1.333333333333,mm:3.7795296,millimeter:3.7795296,millimeters:3.7795296,cm:37.795296,centimeter:37.795296,centimeters:37.795296};class ComponentSize extends InlineComponent{static componentType="componentSize";static rendererType="text";static excludeFromSchema=!0;static primaryStateVariableForDefinition="componentSize";static stateVariableToBeShadowed="componentSize";static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=tA[tA.length-1];if(typeof aA=="string"){let oA=/([a-zA-z]+|%)$/,sA=aA.trim(),lA=sA.match(oA);if(lA){let gA=lA[1];if(gA in unitConversions){let cA=sA.slice(0,lA.index),IA=tA.slice(0,tA.length-1);return cA.length>0&&IA.push(cA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:IA,attributes:{},doenetAttributes:{},state:{}},gA],nComponents:iA}}}}return{success:!0,newChildren:[{componentType:"number",children:tA}]}};return eA.push({childrenRegex:/..+/,replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"strings",componentTypes:["string"]},{group:"numbers",componentTypes:["number"]},{group:"componentSizes",componentTypes:["componentSize"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA);let tA=returnTextStyleDescriptionDefinitions();return Object.assign(eA,tA),eA.componentSize={description:"The size value with its associated unit (absolute pixels or relative percent).",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},hasEssential:!0,returnDependencies:()=>({componentSizeChild:{dependencyType:"child",childGroups:["componentSizes"],variableNames:["componentSize"]},numberChild:{dependencyType:"child",childGroups:["numbers"],variableNames:["value"]},stringChild:{dependencyType:"child",childGroups:["strings"],variableNames:["value"]},parentDefaultAbsoluteSize:{dependencyType:"parentStateVariable",variableName:"defaultAbsoluteSize"}}),definition({dependencyValues:iA}){let rA=iA.parentDefaultAbsoluteSize===void 0?!1:iA.parentDefaultAbsoluteSize;if(iA.stringChild.length===0)return iA.numberChild.length===0?iA.componentSizeChild.length===0?{useEssentialOrDefaultValue:{componentSize:{defaultValue:{size:100,isAbsolute:rA}}}}:{setValue:{componentSize:iA.componentSizeChild[0].stateValues.componentSize}}:{setValue:{componentSize:{size:iA.numberChild[0].stateValues.value,isAbsolute:!0}}};{let aA,oA;if(iA.numberChild.length>0)aA=iA.numberChild[0].stateValues.value,oA=iA.stringChild[0].trim();else{let cA=iA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(cA===null)return{setValue:{componentSize:null}};aA=cA[1],oA=cA[2].trim()}if(aA=Number(aA),!Number.isFinite(aA))return{setValue:{componentSize:null}};let sA=!(oA==="%"||oA==="em"),lA=unitConversions[oA];return lA===void 0&&(lA=1),{setValue:{componentSize:{size:lA*aA,isAbsolute:sA}}}}},inverseDefinition({desiredStateVariableValues:iA,dependencyValues:rA}){if(rA.stringChild.length===0)return rA.numberChild.length===0?rA.componentSizeChild.length===0?{success:!0,instructions:[{setEssentialValue:"componentSize",value:iA.componentSize}]}:{success:!0,instructions:[{setDependency:"componentSizeChild",desiredValue:iA.componentSize,childIndex:0,variableIndex:0}]}:iA.componentSize.isAbsolute?{success:!0,instructions:[{setDependency:"numberChild",desiredValue:iA.componentSize.size,childIndex:0,variableIndex:0}]}:{success:!1};if(rA.numberChild.length>0){let aA=rA.stringChild[0].trim(),oA=!(aA==="%"||aA==="em");if(iA.componentSize.isAbsolute!==oA)return{success:!1};let sA=unitConversions[aA];return sA===void 0&&(sA=1),{success:!0,instructions:[{setDependency:"numberChild",desiredValue:iA.componentSize.size/sA,childIndex:0,variableIndex:0}]}}else{let aA=iA.componentSize.size;return iA.componentSize.isAbsolute?aA+="px":aA+="%",{success:!0,instructions:[{setDependency:"stringChild",desiredValue:aA,childIndex:0,variableIndex:0}]}}}},eA.number={description:"The numeric portion of the size.",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA=null;return iA.componentSize&&(rA=iA.componentSize.size),{setValue:{number:rA}}},inverseDefinition({desiredStateVariableValues:iA,dependencyValues:rA}){return rA.componentSize?{success:!0,instructions:[{setDependency:"componentSize",desiredValue:{size:iA.number,isAbsolute:rA.componentSize.isAbsolute}}]}:{success:!1}}},eA.math=mathStateVariableFromNumberStateVariable({numberVariableName:"number",mathVariableName:"math",isPublic:!0}),eA.math.description="The size as a math expression.",eA.isAbsolute={description:"Whether the size uses absolute units (pixels) rather than relative units (percent).",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA=null;return iA.componentSize&&(rA=iA.componentSize.isAbsolute),{setValue:{isAbsolute:rA}}}},eA.text={forRenderer:!0,returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA="";return iA.componentSize&&(rA=iA.componentSize.size,iA.componentSize.isAbsolute?rA+="px":rA+="%"),{setValue:{text:rA}}}},eA}static adapters=["number","math"]}class ComponentSizeList extends BaseComponent{static componentType="_componentSizeList";static rendererType="asList";static renderChildren=!0;static stateVariableToBeShadowed="componentSizes";static additionalSchemaChildren=["string","number"];static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=[],oA=[],sA=function(){oA.length>0&&(aA.push({type:"serialized",componentType:"componentSize",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}}),oA=[])};for(let lA of tA)if(typeof lA=="string"){let gA=lA.split(/\s+/);gA[0].length===0&&(sA(),gA=gA.slice(1));for(let[cA,IA]of gA.entries())IA.length>0?(oA.push(IA),cA<gA.length-1&&sA()):sA()}else oA.push(lA);return sA(),{success:!0,newChildren:aA,nComponents:iA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"componentSizes",componentTypes:["componentSize"]},{group:"componentSizeLists",componentTypes:["_componentSizeList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.overrideChildHide={returnDependencies:()=>({}),definition:()=>({setValue:{overrideChildHide:!0}})},eA.numComponents={description:"The number of size values in the list.",public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:["childIndexByArrayKey"],returnDependencies(){return{componentSizeListChildren:{dependencyType:"child",childGroups:["componentSizeLists"],variableNames:["numComponents"]},componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],skipComponentIndices:!0}}},definition:function({dependencyValues:AA,componentInfoObjects:tA}){let iA=0,rA=[],aA=0;for(let[oA,sA]of AA.componentSizeAndComponentSizeListChildren.entries())if(tA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.componentSizeListChildren[aA];aA++;for(let gA=0;gA<lA.stateValues.numComponents;gA++)rA[iA+gA]=[oA,gA];iA+=lA.stateValues.numComponents}else rA[iA]=[oA,0],iA+=1;return{setValue:{numComponents:iA,childIndexByArrayKey:rA},checkForActualChange:{numComponents:!0}}}},eA.componentSizes={description:"The list of component sizes.",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},isArray:!0,entryPrefixes:["componentSize"],stateVariablesDeterminingDependencies:["childIndexByArrayKey"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA,stateValues:tA}){let iA={},rA={childIndexByArrayKey:{dependencyType:"stateVariable",variableName:"childIndexByArrayKey"}};for(let aA of AA){let oA=[],sA="1";tA.childIndexByArrayKey[aA]&&(oA=[tA.childIndexByArrayKey[aA][0]],sA=tA.childIndexByArrayKey[aA][1]+1),iA[aA]={componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],variableNames:["componentSize","componentSize"+sA],variablesOptional:!0,childIndices:oA}}}return{globalDependencies:rA,dependenciesByKey:iA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA,componentInfoObjects:rA}){let aA={};for(let oA of iA){let sA=tA[oA].componentSizeAndComponentSizeListChildren[0];if(sA)if(rA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.childIndexByArrayKey[oA][1]+1;aA[oA]=sA.stateValues["componentSize"+lA]}else aA[oA]=sA.stateValues.componentSize}return{setValue:{componentSizes:aA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:iA,dependencyNamesByKey:rA,arraySize:aA,componentInfoObjects:oA}){let sA=[];for(let lA in AA.componentSizes){if(!iA[lA])continue;let gA=iA[lA].componentSizeAndComponentSizeListChildren[0];gA&&(oA.isInheritedComponentType({inheritedComponentType:gA.componentType,baseComponentType:"_componentSizeList"})?sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:1}):sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:0}))}return{success:!0,instructions:sA}}},eA.numValues={isAlias:!0,targetVariableName:"numComponents",description:"The number of component sizes in the list."},eA.values={isAlias:!0,targetVariableName:"componentSizes",description:"The list's component sizes."},eA}}const ComponentSize$1=Object.freeze(Object.defineProperty({__proto__:null,ComponentSize,ComponentSizeList},Symbol.toStringTag,{value:"Module"}));class Copy extends CompositeComponent{static componentType="_copy";static excludeFromSchema=!0;static acceptAnyAttribute=!0;static includeBlankStringChildren=!0;static stateVariableToEvaluateAfterReplacements="needsReplacementsUpdatedWhenStale";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.disabled,delete eA.modifyIndirectly,delete eA.fixed,delete eA.fixLocation,delete eA.styleNumber,delete eA.isResponse,delete eA.isPotentialResponse,delete eA.hide,eA.createComponentOfType={createPrimitiveOfType:"string"},eA.createComponentIdx={createPrimitiveOfType:"integer"},eA.createComponentName={createPrimitiveOfType:"string"},eA.numComponents={createPrimitiveOfType:"number"},eA.copyInChildren={createPrimitiveOfType:"boolean"},eA.uri={createPrimitiveOfType:"string",createStateVariable:"uri",defaultValue:null,public:!0},eA.link={createPrimitiveOfType:"boolean",createStateVariable:"link",defaultValue:!0},eA.removeEmptyArrayEntries={createPrimitiveOfType:"boolean",createStateVariable:"removeEmptyArrayEntries",defaultValue:!1},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asListPreliminary",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.refResolutionIndexDependencies={returnDependencies:()=>({refResolutionIndexDependencies:{dependencyType:"refResolutionIndexDependencies"}}),definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencies:AA.refResolutionIndexDependencies}})},eA.refResolutionIndexDependencyValues={stateVariablesDeterminingDependencies:["refResolutionIndexDependencies"],returnDependencies:({stateValues:AA})=>{const tA={};for(const iA of AA.refResolutionIndexDependencies)tA[iA]={dependencyType:"stateVariable",componentIdx:iA,variableName:"value"};return tA},definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencyValues:AA}})},eA.extendIdx={additionalStateVariablesDefined:["unresolvedPath","originalPath"],stateVariablesDeterminingDependencies:["refResolutionIndexDependencyValues"],returnDependencies:({stateValues:AA})=>({refResolution:{dependencyType:"refResolution",indexDependencyValues:AA.refResolutionIndexDependencyValues}}),definition:({dependencyValues:AA})=>({setValue:{extendIdx:AA.refResolution.extendIdx,unresolvedPath:AA.refResolution.unresolvedPath,originalPath:AA.refResolution.originalPath}})},eA.extendedComponent={shadowVariable:!0,stateVariablesDeterminingDependencies:["extendIdx"],returnDependencies({stateValues:AA}){return AA.extendIdx!==-1?{extendedComponent:{dependencyType:"componentIdentity",componentIdx:AA.extendIdx}}:{}},definition:function({dependencyValues:AA}){let tA=null;return AA.extendedComponent&&(tA=AA.extendedComponent),{setValue:{extendedComponent:tA}}}},eA.targetInactive={stateVariablesDeterminingDependencies:["extendedComponent"],returnDependencies({stateValues:AA}){return AA.extendedComponent?{targetIsInactiveCompositeReplacement:{dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"isInactiveCompositeReplacement"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{targetInactive:!!AA.targetIsInactiveCompositeReplacement}}}},eA.cid={additionalStateVariablesDefined:["doenetId"],returnDependencies:()=>({uri:{dependencyType:"stateVariable",variableName:"uri"}}),definition:function({dependencyValues:AA}){if(!AA.uri||AA.uri.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null,doenetId:null}};let tA=null,iA=null,rA=AA.uri.match(/[:&]cid=([^&]+)/i);return rA&&(tA=rA[1]),rA=AA.uri.match(/[:&]doenetid=([^&]+)/i),rA&&(iA=rA[1]),{setValue:{cid:tA,doenetId:iA}}}},eA.createComponentOfType={returnDependencies:()=>({typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA}){let tA=null;return AA.typeAttr&&(tA=AA.typeAttr),{setValue:{createComponentOfType:tA}}}},eA.replacementSourceIdentities={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","createComponentOfType"],additionalStateVariablesDefined:["usedReplacements"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let iA={numComponentsSpecified:{dependencyType:"stateVariable",variableName:"numComponentsSpecified"}},rA=!1;if(AA.extendedComponent!==null){if(AA.extendedComponent.componentType==="_copy"||tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!0})&&AA.extendedComponent.componentType!==AA.createComponentOfType){rA=!0;let aA=AA.unresolvedPath?.[0]?.name;aA===""&&(aA=null),iA.targets={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:AA.unresolvedPath!=null,stopAtListComposites:AA.unresolvedPath==null,includeWithheldReplacements:!0,stopIfHaveProp:aA}}rA||(iA.targets={dependencyType:"stateVariable",variableName:"extendedComponent"}),iA.usedReplacements={dependencyType:"value",value:rA}}return iA},definition({dependencyValues:AA}){let tA=null;if(AA.targets&&(tA=AA.targets,Array.isArray(tA)||(tA=[tA]),AA.numComponentsSpecified===1&&tA.length>1)){const iA=tA.findIndex(aA=>typeof aA!="string"||aA.trim()!==""),rA=tA.findLastIndex(aA=>typeof aA!="string"||aA.trim()!=="");iA!==-1&&rA!==-1&&(tA=tA.slice(iA,rA+1))}return{setValue:{replacementSourceIdentities:tA,usedReplacements:!!AA.usedReplacements}}}},eA.asList={stateVariablesDeterminingDependencies:["usedReplacements","extendedComponent"],returnDependencies({stateValues:AA}){const tA={asListPreliminary:{dependencyType:"stateVariable",variableName:"asListPreliminary"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.usedReplacements&&(tA.extendedComponentAsList={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"asList",variablesOptional:!0}),tA},definition({dependencyValues:AA,usedDefault:tA}){return tA.asListPreliminary&&AA.usedReplacements&&typeof AA.extendedComponentAsList=="boolean"?{setValue:{asList:AA.extendedComponentAsList}}:{setValue:{asList:AA.asListPreliminary}}}},eA.implicitProp={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath"],returnDependencies({stateValues:AA}){let tA={unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.unresolvedPath||(tA.replacementSourceIdentities={dependencyType:"stateVariable",variableName:"replacementSourceIdentities"},tA.typeAttr={dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}),tA},definition({dependencyValues:AA,componentInfoObjects:tA}){if(AA.unresolvedPath||AA.usedReplacements||!(AA.replacementSourceIdentities?.length>0))return{setValue:{implicitProp:null}};let iA=AA.replacementSourceIdentities[0],rA=tA.allComponentClasses[iA.componentType]?.variableForImplicitProp;if(!rA)return{setValue:{implicitProp:null}};if(AA.typeAttr){let aA=tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()];if(aA===iA.componentType)return{setValue:{implicitProp:null}};let oA=tA.publicStateVariableInfo[iA.componentType].stateVariableDescriptions[rA];if(oA.createComponentOfType!==void 0&&oA.createComponentOfType!==aA)return{setValue:{implicitProp:null}}}return{setValue:{implicitProp:rA}}}},eA.replacementSources={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath","implicitProp","usedReplacements","extendedComponent"],additionalStateVariablesDefined:["effectivePropNameBySource"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let iA={replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};const rA=AA.usedReplacements&&AA.extendedComponent?.componentType!=="_copy"&&!AA.implicitProp&&AA.unresolvedPath?.[0]?.name==="";if(AA.replacementSourceIdentities!==null)for(let[aA,oA]of AA.replacementSourceIdentities.entries()){let sA=AA.unresolvedPath;AA.implicitProp&&(sA=[{name:AA.implicitProp,index:[]}]);let lA;if(sA){if(sA=[...sA],iA["unresolvedPath"+aA]={dependencyType:"value",value:sA},typeof oA=="string"||rA&&tA.allComponentClasses[oA.componentType]?.listEntryComponentType!==void 0)continue;lA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:oA.componentIdx,unresolvedPath:sA,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else{if(typeof oA=="string")continue;lA={dependencyType:"componentIdentity",componentIdx:oA.componentIdx}}iA["target"+aA]=lA}return iA},definition({dependencyValues:AA}){let tA=null,iA=null;if(AA.replacementSourceIdentities!==null){tA=[],iA=[];for(let rA in AA.replacementSourceIdentities){let aA=AA["target"+rA];if(aA){tA.push(aA);let oA;aA.stateValues&&(oA=Object.keys(aA.stateValues)[0]),!oA&&AA["unresolvedPath"+rA]&&(oA="__prop_name_not_found"),iA.push(oA)}else{const oA=AA.replacementSourceIdentities[rA];typeof oA=="string"?AA["unresolvedPath"+rA]?iA.push("__prop_name_not_found"):(tA.push(oA),iA.push(void 0)):(tA.push(void 0),iA.push("__no_target_found"))}}}return{setValue:{replacementSources:tA,effectivePropNameBySource:iA}}}},eA.numComponentsSpecified={returnDependencies:()=>({numComponentsAttr:{dependencyType:"attributePrimitive",attributeName:"numComponents"},typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){let iA;if(AA.typeAttr){if(!(tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()]in tA.allComponentClasses))return{setValue:{numComponentsSpecified:null},sendDiagnostics:[codedDiagnostic({type:"warning",code:"doenet-w0065",args:{type:AA.typeAttr}})]};AA.numComponentsAttr!==null?iA=AA.numComponentsAttr:iA=1}else{if(AA.numComponentsAttr!==null)throw Error("You must specify createComponentOfType when specifying numComponents for a copy.");iA=null}return{setValue:{numComponentsSpecified:iA}}}},eA.unlinkedDescendants={stateVariablesDeterminingDependencies:["extendIdx","link"],returnDependencies({stateValues:AA}){let tA={};return AA.link?tA.targetItself={dependencyType:"componentIdentity",componentIdx:AA.extendIdx}:tA.targetDescendants={dependencyType:"descendant",ancestorIdx:AA.extendIdx,componentTypes:["_composite"]},tA},definition(){return{setValue:{unlinkedDescendants:!0}}}},eA.unlinkedTargetsExpanded={stateVariablesDeterminingDependencies:["extendedComponent","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let iA={};return!AA.link&&AA.extendedComponent&&tA.isInheritedComponentType({inheritedComponentType:AA.extendedComponent.componentType,baseComponentType:"_composite"})&&(iA.targetReplacements={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:!0}),iA},definition(){return{setValue:{unlinkedTargetsExpanded:!0}}}},eA.readyToExpandWhenResolved={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let iA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},needsReplacementsUpdatedWhenStale:{dependencyType:"stateVariable",variableName:"needsReplacementsUpdatedWhenStale"},link:{dependencyType:"stateVariable",variableName:"link"},unlinkedTargetsExpanded:{dependencyType:"stateVariable",variableName:"unlinkedTargetsExpanded"},unlinkedDescendants:{dependencyType:"stateVariable",variableName:"unlinkedDescendants"}};return AA.extendedComponent&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(iA.targetReadyToExpandWhenResolved={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"readyToExpandWhenResolved"}),AA.extendedComponent&&AA.unresolvedPath===null&&(iA.extendedVariantInfo={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"generatedVariantInfo",variablesOptional:!0}),AA.link||(iA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),iA},definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.needsReplacementsUpdatedWhenStale={stateVariablesDeterminingDependencies:["extendedComponent","replacementSourceIdentities","effectivePropNameBySource","unresolvedPath","link","removeEmptyArrayEntries"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){if(!AA.link)return{};let iA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},targetInactive:{dependencyType:"stateVariable",variableName:"targetInactive"},replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.effectivePropNameBySource!==null){for(let[rA,aA]of AA.effectivePropNameBySource.entries())if(aA){let oA=AA.replacementSourceIdentities[rA];iA["sourceArraySize"+rA]={dependencyType:"stateVariableArraySize",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0},iA["sourceComponentType"+rA]={dependencyType:"stateVariableComponentType",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0}}}return AA.extendedComponent!==null&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(iA.allReplacementIdentities={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,variableNames:["isInactiveCompositeReplacement"]}),AA.removeEmptyArrayEntries&&(iA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),iA},markStale(){return{updateReplacements:!0}},definition:()=>({setValue:{needsReplacementsUpdatedWhenStale:!0}})},eA}static async createSerializedReplacements(eA){const AA=await this.createReplacementsFromSources(eA),{component:tA}=eA;if(await tA.stateValues.link===!1){const iA=tA.coreFunctions.savedCopySnapshot?.(tA.stateId);iA&&applyCopySnapshot(AA.replacements,iA),tA.unlinkedSnapshot=copySnapshotOf(AA.replacements),tA.freshUnlinkedSnapshot=async()=>copySnapshotOf((await this.createReplacementsFromSources({...eA,workspace:{}})).replacements)}return AA}static async createReplacementsFromSources({component:eA,components:AA,nComponents:tA,workspace:iA,allDoenetMLs:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){iA.replacementsCreated===void 0&&(iA.replacementsCreated=0);let lA=[];await eA.stateValues.numComponentsSpecified,iA.numReplacementsBySource=[],iA.numNonStringReplacementsBySource=[],iA.propVariablesCopiedBySource=[],iA.sourceIndices=[];let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let DA=[];const EA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};if(eA.attributes.copyInChildren?.primitive.value){let NA=aA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],yA=aA.allComponentClasses[NA];const bA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:NA,componentInfoObjects:aA,compositeAttributesObj:gA,nComponents:tA,stateIdInfo:EA}),wA=bA.attributes;tA=bA.nComponents;let MA=deepClone(eA.serializedChildren);yA.includeBlankStringChildren||(MA=MA.filter(kA=>typeof kA!="string"||kA.trim()!==""));let vA=wA;DA=[{type:"serialized",componentType:NA,componentIdx:tA++,stateId:`${EA.prefix}${EA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:MA}],iA.numReplacementsBySource.push(DA.length),iA.numNonStringReplacementsBySource.push(DA.filter(kA=>typeof kA!="string").length)}let fA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:DA,workspace:iA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:EA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...fA.diagnostics),tA=fA.nComponents,addAttributesToSingleReplacement(fA.replacements,eA),iA.replacementsCreated=EA.num,{replacements:fA.replacements,diagnostics:lA,nComponents:tA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let uA=await eA.stateValues.effectivePropNameBySource;for(let DA in cA)if(uA[DA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+DA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${DA} of replacementSources of ${eA.componentIdx}`);let CA=[];const dA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};let pA=[],mA=[],QA=0,BA=0;for(let DA in cA){let EA;if(eA.attributes.createComponentOfType?.primitive){let yA=await eA.stateValues.numComponentsSpecified,bA=cA.length;EA=Math.floor(yA/bA);let wA=yA%bA;DA<wA&&EA++}let fA=await this.createReplacementForSource({component:eA,sourceNum:DA,components:AA,nComponents:tA,stateIdInfo:dA,allDoenetMLs:rA,numReplacementsSoFar:QA,numNonStringReplacementsSoFar:BA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:EA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(DA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...fA.diagnostics),tA=fA.nComponents,iA.propVariablesCopiedBySource[DA]=fA.propVariablesCopiedByReplacement;let NA=fA.serializedReplacements;pA[DA]=NA.length,mA[DA]=NA.filter(yA=>typeof yA!="string").length,QA+=pA[DA],BA+=mA[DA],CA.push(...NA)}iA.numReplacementsBySource=pA,iA.numNonStringReplacementsBySource=mA,iA.sourceIndices=cA.map(DA=>DA.componentIdx);let hA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:CA,workspace:iA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...hA.diagnostics),tA=hA.nComponents,CA=hA.replacements,addAttributesToSingleReplacement(CA,eA),iA.replacementsCreated=dA.num,{replacements:CA,diagnostics:lA,nComponents:tA}}static async createReplacementForSource({component:eA,sourceNum:AA,components:tA,nComponents:iA,stateIdInfo:rA,allDoenetMLs:aA,numReplacementsSoFar:oA,numNonStringReplacementsSoFar:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:uA}){let CA=[],dA=(await eA.stateValues.replacementSourceIdentities)[AA];if(typeof dA!="object")return eA.stateValues.effectivePropNameBySource[AA]?{serializedReplacements:[],diagnostics:CA,nComponents:iA}:{serializedReplacements:[dA],diagnostics:CA,nComponents:iA};const pA=tA[dA.componentIdx];if(await pA.stateValues.isInactiveCompositeReplacement)return{serializedReplacements:[],diagnostics:CA,nComponents:iA};let mA=(await eA.stateValues.effectivePropNameBySource)[AA],QA=await eA.stateValues.link;if(!QA||mA&&await eA.stateValues.removeEmptyArrayEntries){const hA=(await eA.stateValues.replacementSources)[AA];hA&&(dA=hA)}if(mA){let hA=await replacementFromProp({component:eA,components:tA,nComponents:iA,stateIdInfo:rA,replacementSource:dA,propName:mA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});CA.push(...hA.diagnostics),iA=hA.nComponents;let DA=hA.serializedReplacements,EA=hA.propVariablesCopiedByReplacement;if(uA&&eA.serializedChildren.length>0)if(DA.length===0){let fA=gA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],NA=gA.allComponentClasses[fA];const yA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:fA,componentInfoObjects:gA,compositeAttributesObj:lA,nComponents:iA,stateIdInfo:rA}),bA=yA.attributes;iA=yA.nComponents;let wA=deepClone(eA.serializedChildren);NA.includeBlankStringChildren||(wA=wA.filter(vA=>typeof vA!="string"||vA.trim()!==""));let MA=bA;DA=[{type:"serialized",componentType:fA,componentIdx:iA++,stateId:`${rA.prefix}${rA.num++}`,attributes:MA,doenetAttributes:{},state:{},children:wA}],EA=[[]]}else DA.length===1&&addChildrenFromComposite({replacements:DA,children:eA.serializedChildren,componentInfoObjects:gA});return{serializedReplacements:DA,propVariablesCopiedByReplacement:EA,diagnostics:CA,nComponents:iA}}let BA;try{BA=[await pA.serialize({valueReferenceAsComponent:!0,components:QA?void 0:tA,copyAll:!QA,componentSourceAttributesToIgnore:["labelIsName"],copyVariants:!QA,copyPrimaryEssentialIfShadow:!QA,copyEssentialStateIfShadow:!QA,errorIfEncounterComponent:[eA.componentIdx]})];let hA=createNewComponentIndices(BA,iA,rA);BA=hA.components,iA=hA.nComponents}catch(hA){if(hA.message?.startsWith(SERIALIZE_ENCOUNTERED_COMPONENT_PREFIX)){const EA=getSelfReferentialFallbackPropName({componentAncestors:eA.ancestors,componentInfoObjects:gA,replacementSourceComponentType:pA.componentType});if(EA)try{let fA=await replacementFromProp({component:eA,components:tA,nComponents:iA,stateIdInfo:rA,replacementSource:pA,propName:EA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});return CA.push(...fA.diagnostics),iA=fA.nComponents,{serializedReplacements:fA.serializedReplacements,propVariablesCopiedByReplacement:fA.propVariablesCopiedByReplacement,diagnostics:CA,nComponents:iA}}catch{}}console.error("we're calling this circular",hA);const DA=codedDiagnostic({type:"error",code:"doenet-e0005",args:{componentType:eA.attributes.createComponentOfType?.primitive?.value??"none"}});return BA=[{type:"serialized",componentType:"_error",componentIdx:iA++,stateId:`${rA.prefix}${rA.num++}`,state:errorComponentState(DA.message,DA),attributes:{},doenetAttributes:{},children:[]}],CA.push(DA),{serializedReplacements:BA,diagnostics:CA,nComponents:iA}}if(!QA&&typeof BA[0]=="object")for(const hA of CONTEXT_ATTRIBUTES)delete BA[0].state?.[hA],delete BA[0].state?.[`${hA}Preliminary`];BA=postProcessCopy({serializedComponents:BA,componentIdx:eA.componentIdx,addShadowDependencies:QA,unlinkExternalCopies:!1});for(let hA of BA){if(typeof hA!="object")continue;hA.attributes||(hA.attributes={});const DA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:hA.componentType,componentInfoObjects:gA,compositeAttributesObj:lA,dontSkipAttributes:["asList"],nComponents:iA,stateIdInfo:rA}),EA=DA.attributes;if(iA=DA.nComponents,deleteReplacedAttributes({attributes:hA.attributes,attributesFromComposite:EA,componentType:hA.componentType,componentInfoObjects:gA}),QA&&uA){const fA=extendIgnoresAttributesAndChildren({replacementType:hA.componentType,attributeNames:Object.keys(EA),copyAttributeNames:Object.keys(lA),children:eA.serializedChildren,componentInfoObjects:gA});CA.push(...fA.diagnostics);for(const NA of fA.attributeNames)delete EA[NA]}Object.assign(hA.attributes,EA)}return uA&&BA.length===1&&eA.serializedChildren.length>0&&addChildrenFromComposite({replacements:BA,children:eA.serializedChildren,componentInfoObjects:gA}),{serializedReplacements:BA,diagnostics:CA,nComponents:iA}}static async calculateReplacementChanges({component:eA,nComponents:AA,componentChanges:tA,components:iA,workspace:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){let lA=[];if(await eA.stateValues.link===!1)return{replacementChanges:[],diagnostics:lA,nComponents:AA};let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacements.length>0){let vA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToDelete:eA.replacements.length};yA.push(vA)}let wA=rA.sourceIndices.length===0;rA.sourceIndices=[],rA.numReplacementsBySource=[],rA.numNonStringReplacementsBySource=[],rA.propVariablesCopiedBySource=[];let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...MA.diagnostics),AA=MA.nComponents,wA?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,MA.replacementChanges),rA.replacementsCreated=bA.num,{replacementChanges:MA.replacementChanges,diagnostics:lA,nComponents:AA})}if(await eA.stateValues.targetInactive){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};let wA=eA.replacements.length;if(wA>0){if(eA.replacementsToWithhold!==wA){let vA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:wA};yA.push(vA)}let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...MA.diagnostics),AA=MA.nComponents,yA=MA.replacementChanges}return addAttributesToSingleReplacementChange(eA,yA),rA.replacementsCreated=bA.num,{replacementChanges:yA,diagnostics:lA,nComponents:AA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let uA=await eA.stateValues.effectivePropNameBySource;for(let yA in cA)if(uA[yA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+yA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${yA} of replacementSources of ${eA.componentIdx}`);let CA=[];const dA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacementsToWithhold>0){let yA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:0};CA.push(yA)}let pA=0,mA=0,QA=[],BA=[],hA=[],DA=Math.max(cA.length,rA.numReplacementsBySource.length),EA=!1;for(let yA=0;yA<DA;yA++){let bA;if(eA.attributes.createComponentOfType?.primitive){let zA=await eA.stateValues.numComponentsSpecified,GA=cA.length;bA=Math.floor(zA/GA);let KA=zA%GA;yA<KA&&bA++}let wA=cA[yA];if(!EA&&await iA[wA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){let zA=!0;for(let GA=yA+1;GA<DA;GA++){const KA=cA[GA];if(!await iA[KA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){zA=!1;break}}if(zA){let GA=rA.numReplacementsBySource.slice(yA).reduce((KA,JA)=>KA+JA,0);if(GA>0){let KA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:GA};CA.push(KA)}for(let KA=yA;KA<DA;KA++)QA[KA]=rA.numReplacementsBySource[KA],BA[KA]=rA.numNonStringReplacementsBySource[KA],hA[KA]=rA.propVariablesCopiedBySource[KA];break}else wA=void 0}if(wA===void 0){if(rA.numReplacementsBySource[yA]>0&&!EA){let zA=rA.numReplacementsBySource.slice(yA).reduce((GA,KA)=>GA+KA,0);if(zA>0){let GA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToDelete:zA};CA.push(GA)}EA=!0,rA.numReplacementsBySource.slice(yA).forEach((GA,KA)=>rA.numReplacementsBySource[KA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((GA,KA)=>rA.numNonStringReplacementsBySource[KA]=0)}QA[yA]=0,BA[yA]=0,hA.push([]);continue}let MA=rA.sourceIndices[yA],vA=MA===void 0||wA.componentIdx!==MA||EA;if(!vA)for(let zA=0;zA<rA.numReplacementsBySource[yA];zA++){let GA=eA.replacements[pA+zA];if(GA){if(!uA[yA]&&GA.shadows?.componentIdx!==cA[yA].componentIdx){vA=!0;break}}else{vA=!0;break}}if(vA){let zA=0;yA in rA.numReplacementsBySource&&(zA=rA.numReplacementsBySource[yA]);let GA=zA;EA&&(GA=0);let KA=await this.recreateReplacements({component:eA,sourceNum:yA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,numReplacementsToDelete:GA,components:iA,nComponents:AA,stateIdInfo:dA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...KA.diagnostics),AA=KA.nComponents,pA+=KA.numReplacements,mA+=KA.numNonStringReplacements,QA[yA]=KA.numReplacements,BA[yA]=KA.numNonStringReplacements,hA[yA]=KA.propVariablesCopiedByReplacement;let JA=KA.replacementInstruction;if(!EA&&KA.numReplacements!==zA){let Or=rA.numReplacementsBySource.slice(yA).reduce((As,WA)=>As+WA,0);JA.numberReplacementsToReplace=Or,EA=!0,rA.numReplacementsBySource.slice(yA).forEach((As,WA)=>rA.numReplacementsBySource[WA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((As,WA)=>rA.numNonStringReplacementsBySource[WA]=0)}JA&&CA.push(JA);continue}if(!uA[yA]&&rA.numReplacementsBySource[yA]>0){pA+=rA.numReplacementsBySource[yA],mA+=rA.numNonStringReplacementsBySource[yA],QA[yA]=rA.numReplacementsBySource[yA],BA[yA]=rA.numNonStringReplacementsBySource[yA];continue}const kA={prefix:`${eA.stateId}|`,num:dA.num};let TA=await this.createReplacementForSource({component:eA,sourceNum:yA,components:iA,nComponents:AA,stateIdInfo:kA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(yA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...TA.diagnostics);const OA=TA.nComponents;let FA=TA.propVariablesCopiedByReplacement,RA=TA.serializedReplacements,xA=RA.length,jA=rA.numReplacementsBySource[yA];if(xA!==jA){let zA=rA.numReplacementsBySource.slice(yA).reduce((KA,JA)=>KA+JA,0),GA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToReplace:zA,serializedReplacements:RA};CA.push(GA),EA=!0,AA=OA,dA.num=kA.num,rA.numReplacementsBySource.slice(yA).forEach((KA,JA)=>rA.numReplacementsBySource[JA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((KA,JA)=>rA.numNonStringReplacementsBySource[JA]=0)}else for(let zA=0;zA<xA;zA++){let GA=FA[zA].length!==rA.propVariablesCopiedBySource[yA][zA].length,KA=!GA;if(!GA)if(rA.propVariablesCopiedBySource[yA][zA].some((JA,Or)=>JA!==FA[zA][Or]))KA=!1,GA=!0;else{let JA=eA.replacements[pA+zA];(JA.componentType!==RA[zA].componentType||valueReferenceDiffers(JA,RA[zA]))&&(GA=!0)}if(zA==0&&GA&&KA&&await eA.stateValues.numComponentsSpecified===1&&xA===1&&!(eA.replacementsToWithhold>0)&&rA.sourceIndices.length===1&&(GA=!1),GA){AA=OA,dA.num=kA.num;let JA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA+zA,numberReplacementsToReplace:1,serializedReplacements:[RA[zA]]};CA.push(JA)}RA[zA]}let HA=RA.filter(zA=>typeof zA!="string").length;pA+=xA,mA+=HA,QA[yA]=xA,BA[yA]=HA,hA[yA]=FA}let fA=rA.sourceIndices.length===0;rA.numReplacementsBySource=QA,rA.numNonStringReplacementsBySource=BA,rA.sourceIndices=cA.map(yA=>yA.componentIdx),rA.propVariablesCopiedBySource=hA;let NA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:CA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...NA.diagnostics),AA=NA.nComponents,CA=NA.replacementChanges,fA&&rA.sourceIndices.length===0?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,CA),rA.replacementsCreated=dA.num,{replacementChanges:CA,diagnostics:lA,nComponents:AA})}static async recreateReplacements({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:iA,numReplacementsToDelete:rA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA}){let uA=[],CA=await this.createReplacementForSource({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:iA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:Number(AA)===0&&eA.attributes.copyInChildren?.primitive.value});uA.push(...CA.diagnostics),oA=CA.nComponents;let dA=CA.propVariablesCopiedByReplacement,pA=CA.serializedReplacements;if(pA.length>0||rA>0){let mA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA,numberReplacementsToReplace:rA,serializedReplacements:pA};return{numReplacements:pA.length,numNonStringReplacements:pA.filter(QA=>typeof QA!="string").length,propVariablesCopiedByReplacement:dA,replacementInstruction:mA,diagnostics:uA,nComponents:oA}}else return{numReplacements:0,numNonStringReplacements:0,propVariablesCopiedByReplacement:dA,replacementInstruction:null,diagnostics:uA,nComponents:oA}}}async function replacementFromProp({component:nA,components:eA,nComponents:AA,stateIdInfo:tA,replacementSource:iA,propName:rA,allDoenetMLs:aA,compositeAttributesObj:oA,componentInfoObjects:sA,numComponentsForSource:lA,publicCaseInsensitiveAliasSubstitutions:gA}){let cA=[],IA=[],uA=[],CA=-1,dA,pA;if(iA&&(dA=eA[iA.componentIdx],pA=isListEntryArrayVariable(dA,rA)?rA:gA({stateVariables:[rA],componentClass:dA.constructor})[0]),pA===void 0||pA.slice(0,12)==="__not_public"){if(rA==="__no_target_found"){const fA=await nA.stateValues.unresolvedPath,NA=fA[0].position?.start.offset,yA=fA[fA.length-1].position?.end.offset;let bA="";if(NA!=null&&yA!=null){const wA=fA[0].sourceDoc??0;bA=aA?.[wA]?.substring(NA,yA)}cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:bA,component:iA.componentType}}))}else rA!=="__prop_name_not_found"&&cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:rA,component:iA.componentType}}));return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA}}let mA=dA.state[pA],QA=await mA.value,BA=await nA.stateValues.link;const hA=await nA.stateValues.implicitProp,DA=nA.ancestors[0]?.componentClass,EA=BA&&!nA.attributes.createComponentOfType?.primitive;if(mA.isArray||mA.isArrayEntry){let fA,NA,yA,bA;if(mA.isArray?(fA=mA,yA=await mA.arraySize,NA=mA.getAllArrayKeys(yA,!1)):(fA=dA.state[mA.arrayStateVariable],NA=await mA.unflattenedArrayKeys,bA=await mA.arrayKeys),fA.shadowingInstructions?.hasVariableComponentType&&(await nA.stateValues.replacementSources,!fA.shadowingInstructions.createComponentOfType))return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};let wA=mA.wrappingComponents,MA=wA.length,vA=lA;if(mA.isArray)yA.some(TA=>TA===0)?vA=0:vA=yA.slice(0,yA.length-MA).reduce((TA,OA)=>TA*OA,1);else if(bA.length===0)vA=0;else if(MA===0)vA=bA.length;else if(MA>=mA.numDimensions)vA=1;else if(MA===mA.numDimensions-1)vA=NA.length;else{let TA=mA.numDimensions-MA-1;vA=flattenLevels(NA,TA).length}const kA=mA.isArray?await arrayListReplacement({component:nA,components:eA,target:dA,varName:pA,arrayStateVarObj:fA,numWrappingComponents:MA,link:BA,mayBeValueReference:EA,parentClass:DA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}):void 0;if(kA)return{serializedReplacements:[kA.serializedComponent],propVariablesCopiedByReplacement:[[pA]],diagnostics:cA,nComponents:kA.nComponents};if(MA===0){let TA=flattenDeep(NA);for(let OA=0;OA<vA;OA++){let FA=TA[OA];if(await nA.stateValues.removeEmptyArrayEntries){if(!FA)continue;let jA=fA.keyToIndex(FA);Array.isArray(jA)||(jA=[jA]);let HA=await fA.value;for(let zA of jA)HA=HA[zA];if(HA==null)continue}CA++;let RA=uA[CA]=[],xA=fA.shadowingInstructions.createComponentOfType;if(Array.isArray(xA)&&(xA[fA.keyToIndex(FA)]?xA=xA[fA.keyToIndex(FA)]:xA=xA[0]),FA){let jA=fA.arrayVarNameFromArrayKey(FA);RA.push(jA);const HA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:xA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),zA=HA.attributes;AA=HA.nComponents;let GA;if(fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){GA={};for(let WA in fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let YA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[WA].stateVariableToShadow,ZA=dA.state[YA];ZA.isArray&&(YA=ZA.arrayVarNameFromArrayKey(FA)),GA[WA]={stateVariableToShadow:YA}}}let KA;if(fA.shadowingInstructions.addStateVariablesShadowingStateVariables){KA={};for(let WA in fA.shadowingInstructions.addStateVariablesShadowingStateVariables){let YA=fA.shadowingInstructions.addStateVariablesShadowingStateVariables[WA].stateVariableToShadow,ZA=dA.state[YA];ZA.isArray&&(YA=ZA.arrayVarNameFromArrayKey(FA)),KA[WA]={stateVariableToShadow:YA}}}const{responseMarks:JA,otherAttributes:Or}=separateResponseMarks(zA),As=EA?planValueReference({parentClass:DA,targetComponentType:dA.componentType,valueComponentType:xA,fromImplicitProp:!1,hasAttributes:Object.keys(Or).length>0,allowDrawn:!0,componentInfoObjects:sA}):void 0;if(As)IA.push(serializeValueReference({...As,referencedVariable:jA,valueComponentType:xA,target:dA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,responseMarks:JA}));else if(BA){let WA={};const YA=listEntrySourceDoenetAttributes({arrayStateVarObj:fA,arrayKey:FA,target:dA}),ZA=YA.listEntrySource?.variables??{};if(GA){let XA=sA.allComponentClasses[xA].createAttributesObject();for(let Br in GA){if(Br in ZA)continue;let Hr=GA[Br].stateVariableToShadow,rs=XA[Br]?.createComponentOfType;if(attributeShadowIsReference(rs))WA[Br]=shadowAttributeReference({attrName:Br,attributeComponentType:rs,target:dA,stateVariableToShadow:Hr});else if(rs){let os={type:"serialized",componentType:rs,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:Hr}]}};WA[Br]={component:os}}}}deleteReplacedAttributes({attributes:WA,attributesFromComposite:zA,componentType:xA,componentInfoObjects:sA}),Object.assign(WA,zA),IA.push({type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:WA,doenetAttributes:YA,children:[],state:{},downstreamDependencies:{[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:jA,additionalStateVariableShadowing:KA}]}})}else{let WA={};if(GA){let Cs=sA.allComponentClasses[xA].createAttributesObject(),cs={};for(let VA in GA)if(Cs[VA]?.createComponentOfType){let LA=GA[VA].stateVariableToShadow,_A=dA.state[LA],Li,ns;if(_A)Li=await _A.value,ns=_A.usedDefault;else{const ts=dA.state[fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[VA].stateVariableToShadow];Li=(await ts.value)[fA.keyToIndex(FA)],ns=!!ts.usedDefaultByArrayKey?.[FA]}ns||(cs[VA]=Li)}const UA=convertAttributeValuesForComponentType({attributeValues:cs,componentType:xA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),qA=UA.attributes;if(AA=UA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let VA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[VA]?.component){const LA=await dA.attributes[VA].component.serialize({copyAll:!0,copyVariants:!0});let _A=createNewComponentIndices([LA],AA,tA);AA=_A.nComponents,qA[VA]={type:"component",name:VA,component:_A.components[0]}}else dA.attributes[VA]?.type==="literal"?qA[VA]=copyOfLiteralAttribute(dA.attributes[VA],dA):dA.attributes[VA]?.primitive!==void 0&&(qA[VA]={type:"primitive",name:VA,primitive:JSON.parse(JSON.stringify(dA.attributes[VA].primitive))});Object.assign(WA,qA)}const YA=sA.allComponentClasses[xA].createAttributesObject(),ZA=fA.keyToIndex(FA);for(const as of CONTEXT_ATTRIBUTES){if(!YA[as]||!Number.isInteger(ZA)||!isListEntryArrayVariable(dA,pA))continue;const Cs=await writtenEntryAttributeComponent({list:dA,index:ZA,attributeName:as,components:eA});if(!Cs)continue;if(Cs.literal){WA[as]=Cs.literal;continue}const cs=createNewComponentIndices([await Cs.serialize({copyAll:!0,copyVariants:!0,components:eA})],AA,tA);AA=cs.nComponents,WA[as]={type:"component",name:as,component:cs.components[0]}}deleteReplacedAttributes({attributes:WA,attributesFromComposite:zA,componentType:xA,componentInfoObjects:sA}),Object.assign(WA,zA);const PA=primaryEssentialStateVariableOf({componentType:xA,componentInfoObjects:sA});let XA=fA.keyToIndex(FA);Array.isArray(XA)||(XA=[XA]);let Br=await fA.value;for(let as of XA)Br=Br[as];const Hr=AA++,rs=`${tA.prefix}${tA.num++}`,os=await listEntrySourceSnapshot({arrayStateVarObj:fA,arrayKey:FA,target:dA,nComponents:AA,stateIdInfo:tA});AA=os.nComponents;let Is={type:"serialized",componentType:xA,componentIdx:Hr,stateId:rs,attributes:WA,doenetAttributes:{},state:{...os.state,[PA]:Br},children:os.children};IA.push(Is)}}else IA.push({type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{}})}}else{let TA=async function(RA,xA,jA=!1){let HA=[],zA=[];if(xA>1)for(let KA of RA){let JA=await TA(KA,xA-1);HA.push(...JA.pieces),zA.push(...JA.propVariablesCopiedByPiece)}else for(let KA of RA){let JA=fA.arrayVarNameFromArrayKey(KA),Or=[JA],As=fA.shadowingInstructions.createComponentOfType;Array.isArray(As)&&(As=As[fA.keyToIndex(KA)]);let WA;if(fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){WA={};let ZA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let PA in ZA)if(!ZA[PA].addToOuterIfWrappedArray){let XA=ZA[PA].stateVariableToShadow,Br=dA.state[XA];Br.isArray&&(XA=Br.arrayVarNameFromArrayKey(KA)),WA[PA]={stateVariableToShadow:XA}}}let YA;if(fA.shadowingInstructions.addStateVariablesShadowingStateVariables){YA={};for(let ZA in fA.shadowingInstructions.addStateVariablesShadowingStateVariables){let PA=fA.shadowingInstructions.addStateVariablesShadowingStateVariables[ZA].stateVariableToShadow,XA=dA.state[PA];XA.isArray&&(PA=XA.arrayVarNameFromArrayKey(KA)),YA[ZA]={stateVariableToShadow:PA}}}if(BA){let ZA={};if(WA){let XA=sA.allComponentClasses[As].createAttributesObject();for(let Br in WA){let Hr=WA[Br].stateVariableToShadow,rs=XA[Br]?.createComponentOfType;if(attributeShadowIsReference(rs))ZA[Br]=shadowAttributeReference({attrName:Br,attributeComponentType:rs,target:dA,stateVariableToShadow:Hr});else if(rs){let os={type:"serialized",componentType:rs,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:Hr}]}};ZA[Br]={component:os}}}}HA.push({type:"serialized",componentType:As,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:ZA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:JA,additionalStateVariableShadowing:YA}]}})}else{let ZA={};if(WA){let os=sA.allComponentClasses[As].createAttributesObject(),Is={};for(let cs in WA)if(os[cs]?.createComponentOfType){let UA=WA[cs].stateVariableToShadow,qA=dA.state[UA],VA=await qA.value;qA.isArray&&(VA=VA[qA.keyToIndex[KA]]),dA.state[UA].usedDefault||(Is[cs]=VA)}const as=convertAttributeValuesForComponentType({attributeValues:Is,componentType:As,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),Cs=as.attributes;if(AA=as.nComponents,mA.shadowingInstructions.attributesToShadow)for(let cs of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[cs]?.component){let UA=await dA.attributes[cs].component.serialize({copyAll:!0,copyVariants:!0}),qA=createNewComponentIndices([UA],AA,tA);AA=qA.nComponents,Cs[cs]={type:"component",name:cs,component:qA.components[0]}}else dA.attributes[cs]?.type==="literal"?Cs[cs]=copyOfLiteralAttribute(dA.attributes[cs],dA):dA.attributes[cs]?.primitive!==void 0&&(Cs[cs]={type:"primitive",name:cs,primitive:JSON.parse(JSON.stringify(dA.attributes[cs].primitive))});Object.assign(ZA,Cs)}const PA=primaryEssentialStateVariableOf({componentType:As,componentInfoObjects:sA});let XA=fA.keyToIndex(KA);Array.isArray(XA)||(XA=[XA]);let Br=await fA.value;for(let rs of XA)Br=Br[rs];let Hr={type:"serialized",componentType:As,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:ZA,doenetAttributes:{},children:[],state:{[PA]:Br}};HA.push(Hr)}zA.push(Or)}let GA=wA[xA-1];if(HA.length>0&&GA&&GA.length>0){for(let KA=GA.length-1;KA>=0;KA--){let JA=typeof GA[KA]=="object"?GA[KA].componentType:GA[KA],Or=[],As={};for(let WA of HA)if(WA.isAttributeNamed){let YA=WA.isAttributeNamed;delete WA.isAttributeNamed,As[YA]={component:WA}}else Or.push(WA);HA=[{type:"serialized",componentType:JA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,children:Or,attributes:As,doenetAttributes:{},state:{},skipSugar:!0}],typeof GA[KA]=="object"&&GA[KA].isAttributeNamed&&(HA[0].isAttributeNamed=GA[KA].isAttributeNamed)}zA=[flattenDeep(zA)]}if(jA&&fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let KA={},JA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let Or in JA)if(JA[Or].addToOuterIfWrappedArray){let As=JA[Or].stateVariableToShadow;KA[Or]={stateVariableToShadow:As}}if(Object.keys(KA).length>0)for(let Or of HA){let As=Or.attributes;As||(As=Or.attributes={});let YA=sA.allComponentClasses[Or.componentType].createAttributesObject();if(BA)for(let ZA in KA){let PA=KA[ZA].stateVariableToShadow,XA=YA[ZA]?.createComponentOfType;if(attributeShadowIsReference(XA))As[ZA]=shadowAttributeReference({attrName:ZA,attributeComponentType:XA,target:dA,stateVariableToShadow:PA});else if(XA){let Br={type:"serialized",componentType:XA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:PA}]}};As[ZA]={component:Br}}}else{let ZA={};for(let PA in KA)if(YA[PA]?.createComponentOfType){let XA=KA[PA].stateVariableToShadow,Hr=await dA.state[XA].value;dA.state[XA].usedDefault||(ZA[PA]=Hr)}if(Object.keys(ZA).length>0){const PA=convertAttributeValuesForComponentType({attributeValues:ZA,componentType:Or.componentType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA});ZA=PA.attributes,AA=PA.nComponents,Object.assign(As,ZA)}}}}return{pieces:HA,propVariablesCopiedByPiece:zA}},OA=await TA(NA,mA.numDimensions,!0),FA=OA.pieces;uA=OA.propVariablesCopiedByPiece;for(let RA of FA){if(typeof RA!="object")continue;RA.attributes||(RA.attributes={});const xA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:RA.componentType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),jA=xA.attributes;AA=xA.nComponents,deleteReplacedAttributes({attributes:RA.attributes,attributesFromComposite:jA,componentType:RA.componentType,componentInfoObjects:sA}),Object.assign(RA.attributes,jA),BA&&(RA.downstreamDependencies={[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:pA,ignorePrimaryStateVariable:!0}]})}if(CA+=FA.length,IA.push(...FA),FA.length<vA)for(let RA=FA.length;RA<vA;RA++){CA++,uA[CA]=[];let xA,jA=wA[0],HA;jA&&jA.length>0?typeof jA[0]=="object"?(xA=jA[0].componentType,HA=Object.assign({},jA[0].doenetAttributes)):xA=jA[0]:(xA=fA.shadowingInstructions.createComponentOfType,Array.isArray(xA)&&(mA.isArrayEntry?xA=xA[fA.keyToIndex(bA[RA])]:xA=xA[RA]));let zA={type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]};HA&&(zA.doenetAttributes=HA),IA.push(zA)}else if(FA>vA)throw Error(`Something went wrong when creating replacements for ${nA.componentIdx} as we ended up with too many replacements`)}}else{if(mA.shadowingInstructions?.hasVariableComponentType&&await mA.value,!mA.shadowingInstructions?.createComponentOfType)return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};if(CA++,(uA[CA]=[]).push(pA),mA.shadowingInstructions.createComponentOfType==="string")IA.push(await mA.value);else{const NA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),yA=NA.attributes;AA=NA.nComponents;const{responseMarks:bA,otherAttributes:wA}=separateResponseMarks(yA),MA=EA?planValueReference({parentClass:DA,targetComponentType:dA.componentType,valueComponentType:mA.shadowingInstructions.createComponentOfType,fromImplicitProp:!!hA,hasAttributes:Object.keys(wA).length>0,allowDrawn:!0,componentInfoObjects:sA}):void 0;if(MA)IA.push(serializeValueReference({...MA,referencedVariable:pA,valueComponentType:mA.shadowingInstructions.createComponentOfType,target:dA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,responseMarks:bA,copiesReferent:copiesReferent({fromImplicitProp:!!hA,targetClass:dA.constructor,plan:MA})}));else if(BA){let vA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let TA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject();for(let OA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let FA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[OA].stateVariableToShadow,RA=TA[OA]?.createComponentOfType;if(attributeShadowIsReference(RA))vA[OA]=shadowAttributeReference({attrName:OA,attributeComponentType:RA,target:dA,stateVariableToShadow:FA});else if(RA){let xA={type:"serialized",componentType:RA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:FA}]}};vA[OA]={component:xA}}}}deleteReplacedAttributes({attributes:vA,attributesFromComposite:yA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA}),Object.assign(vA,yA),IA.push({type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:pA,additionalStateVariableShadowing:mA.shadowingInstructions.addStateVariablesShadowingStateVariables}]}})}else{let vA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let FA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject(),RA={};for(let HA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables)if(FA[HA]?.createComponentOfType&&!CONTEXT_ATTRIBUTES.includes(HA)){let zA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[HA].stateVariableToShadow,GA=await dA.state[zA].value;dA.state[zA].usedDefault||(RA[HA]={type:"unresolved",name:HA,children:[GA.toString()]})}const xA=convertUnresolvedAttributesForComponentType({attributes:RA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),jA=xA.attributes;if(AA=xA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let HA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[HA]?.component){let zA=await dA.attributes[HA].component.serialize({copyAll:!0,copyVariants:!0}),GA=createNewComponentIndices([zA],AA,tA);AA=GA.nComponents,jA[HA]={type:"component",name:HA,component:GA.components[0]}}else dA.attributes[HA]?.type==="literal"?jA[HA]=copyOfLiteralAttribute(dA.attributes[HA],dA):dA.attributes[HA]?.primitive!==void 0&&(jA[HA]={type:"primitive",name:HA,primitive:JSON.parse(JSON.stringify(dA.attributes[HA].primitive))});Object.assign(vA,jA)}deleteReplacedAttributes({attributes:vA,attributesFromComposite:yA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA}),Object.assign(vA,yA);const kA=primaryEssentialStateVariableOf({componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA});let TA={type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:vA,doenetAttributes:{},children:[],state:{[kA]:QA}};IA.push(TA)}}}if(hA)for(let fA of IA)fA.componentType!=="_ref"&&(fA.doenetAttributes||(fA.doenetAttributes={}),fA.doenetAttributes.fromImplicitProp=!0,fA.downstreamDependencies?.[dA.componentIdx]?.[0]&&(fA.downstreamDependencies[dA.componentIdx][0].fromImplicitProp=!0));return{serializedReplacements:IA,propVariablesCopiedByReplacement:uA,diagnostics:cA,nComponents:AA}}function extendIgnoresAttributesAndChildren({replacementType:nA,attributeNames:eA,copyAttributeNames:AA,children:tA,componentInfoObjects:iA}){const rA=iA.allComponentClasses[nA];if(!rA)return{attributeNames:[],diagnostics:[]};const aA=iA.isCompositeComponent({componentType:nA}),oA=rA.prototype instanceof ValueListComponent;if(!aA&&!oA)return{attributeNames:[],diagnostics:[]};const sA=rA.createAttributesObject(),lA=new Set([...Object.keys((aA?CompositeComponent:ValueListComponent).createAttributesObject()),...Object.keys(returnNumberDisplayAttributes()).filter(IA=>nA==="collect"||IA in sA),...rA===Group||rA.prototype instanceof Group?Object.keys(Group.createAttributesObject()):[],...AA]),gA=[],cA=eA.filter(IA=>!lA.has(IA));for(const IA of cA)gA.push(codedDiagnostic({type:"warning",code:"doenet-w0168",args:{attribute:IA,componentType:nA}}));return aA&&!rA.addExtraSerializedChildrenWhenShadowing&&tA.some(IA=>typeof IA!="string"||IA.trim()!=="")&&gA.push(codedDiagnostic({type:"warning",code:"doenet-w0169",args:{componentType:nA}})),{attributeNames:cA,diagnostics:gA}}function addChildrenFromComposite({replacements:nA,children:eA,componentInfoObjects:AA}){let tA=nA[0];tA.children||(tA.children=[]);let iA=deepClone(eA);AA.allComponentClasses[tA.componentType].includeBlankStringChildren||(iA=iA.filter(aA=>typeof aA!="string"||aA.trim()!=="")),tA.children.push(...iA)}const LIST_TYPE_OF_VALUE_TYPE={math:"mathList",number:"numberList",text:"textList",boolean:"booleanList"};async function arrayListReplacement({component:nA,components:eA,target:AA,varName:tA,arrayStateVarObj:iA,numWrappingComponents:rA,link:aA,mayBeValueReference:oA,parentClass:sA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:cA,stateIdInfo:IA}){const uA=iA.shadowingInstructions?.createComponentOfType,CA=typeof uA=="string"?LIST_TYPE_OF_VALUE_TYPE[uA]:void 0;if(CA===void 0||(iA.numDimensions??1)!==1||rA>0||!aA||!oA||await nA.stateValues.removeEmptyArrayEntries||eA[nA.parentIdx]?.sharedParameters?.compositesMustHaveAReplacement||Object.values(iA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{}).some(({stateVariableToShadow:DA})=>AA.state[DA]?.companionOfEachEntry))return;const dA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:CA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:0,stateIdInfo:{prefix:"",num:0}}),{otherAttributes:pA}=separateResponseMarks(dA.attributes);if(Object.keys(pA).length>0||planValueReference({parentClass:sA,targetComponentType:AA.componentType,valueComponentType:uA,fromImplicitProp:!1,hasAttributes:!1,componentInfoObjects:lA}))return;const mA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:CA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:cA,stateIdInfo:IA});cA=mA.nComponents;const QA={},BA=lA.allComponentClasses[CA].createAttributesObject(),hA=iA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{};for(const DA in hA){const EA=hA[DA].stateVariableToShadow,fA=BA[DA]?.createComponentOfType;if(!(!fA||AA.state[EA]?.isArray)){if(attributeShadowIsReference(fA)){QA[DA]=shadowAttributeReference({attrName:DA,attributeComponentType:fA,target:AA,stateVariableToShadow:EA});continue}QA[DA]={component:{type:"serialized",componentType:fA,componentIdx:cA++,stateId:`${IA.prefix}${IA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[AA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:EA}]}}}}}return Object.assign(QA,mA.attributes),{serializedComponent:{type:"serialized",componentType:CA,componentIdx:cA++,stateId:`${IA.prefix}${IA.num++}`,attributes:QA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[AA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:tA}]}},nComponents:cA}}function listEntrySourceDoenetAttributes({arrayStateVarObj:nA,arrayKey:eA,target:AA}){const tA=nA.shadowingInstructions.listEntrySourceVariables,iA=nA.keyToIndex(eA);return!tA||!Number.isInteger(iA)?{}:{listEntrySource:{componentIdx:AA.componentIdx,index:iA,variables:tA}}}async function listEntrySourceSnapshot({arrayStateVarObj:nA,arrayKey:eA,target:AA,nComponents:tA,stateIdInfo:iA}){const rA=[],aA={},oA=nA.shadowingInstructions.listEntrySourceVariables,sA=nA.keyToIndex(eA);if(!oA||!Number.isInteger(sA))return{children:rA,state:aA,nComponents:tA};const lA=nA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{};for(const[gA,cA]of Object.entries(oA)){if(gA==="labelHasLatex"||gA in lA||CONTEXT_ATTRIBUTES.includes(gA))continue;const IA=(await AA.state[cA].value)[sA];gA==="label"?typeof IA=="string"&&IA!==""&&rA.push({type:"serialized",componentType:"label",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{valueShadow:IA},children:[]}):IA!=null&&(aA[gA]=IA)}return{children:rA,state:aA,nComponents:tA}}function deleteReplacedAttributes({attributes:nA,attributesFromComposite:eA,componentType:AA,componentInfoObjects:tA}){const iA=tA.allComponentClasses[AA]?.createAttributesObject()??{};for(const rA in eA)for(const aA of iA[rA]?.replacesOnReference??[])delete nA[aA]}class ValueRef extends BaseComponent{static componentType="_ref";static rendererType=void 0;static excludeFromSchema=!0;static primaryStateVariableForDefinition="value";constructor(eA){if(super(eA),this.state.value.shadowingInstructions={createComponentOfType:this.presentedComponentType},this.doenetAttributes.copiesReferent&&this.isDrawn)for(const AA of this._referentActionNames())this.actions[AA]=(tA={})=>this._performOnReferent(AA,tA);if((this.doenetAttributes.fixedReferent||!this.isDrawn)&&(this.state.hidden.stateVariablesDeterminingDependencies=void 0),this.doenetAttributes.fixedReferent)for(const AA of["referentInfo","value","canBeModified","unordered","isNumber"])this.state[AA].stateVariablesDeterminingDependencies=void 0;else if(!pathHasIndexComponents(this.refResolution))for(const AA of["extendIdx","unresolvedPath","originalPath"])this.state[AA].stateVariablesDeterminingDependencies=void 0}get fixedReferent(){return this.doenetAttributes.fixedReferent}static createAttributesObject(){return{}}static returnChildGroups(){return[]}get presentedComponentType(){return this.doenetAttributes.presentedComponentType}get isDrawn(){if(this.doenetAttributes.isAttributeChildFor!==void 0)return!1;const eA=this.ancestors?.[0]?.componentClass;return this._drawnInParentClass!==eA&&(this._drawnInParentClass=eA,this._isDrawn=parentDrawsValueReferences(eA,this.componentInfoObjects)),this._isDrawn}get rendererType(){if(this.isDrawn)return this.componentInfoObjects.allComponentClasses[this.presentedComponentType]?.rendererType}get rendererVariables(){if(!this.isDrawn)return NO_RENDERER_VARIABLES;if(this._rendererVariables===void 0){this._rendererVariables={};for(const eA of this._presentedRendererVariableNames())(DRAWN_REFERENCE_VARIABLES.has(eA)||this.doenetAttributes.copiesReferent&&COPIED_REFERENT_VARIABLES.has(eA))&&(this._rendererVariables[eA]=!0)}return this._rendererVariables}get rendererConstants(){const eA={};for(const AA of this._presentedRendererVariableNames())AA in DRAWN_REFERENCE_CONSTANTS&&!(AA in this.rendererVariables)&&(eA[AA]=DRAWN_REFERENCE_CONSTANTS[AA]);return eA}async _performOnReferent(eA,{actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}={}){const rA=this.fixedReferent??await this.stateValues.referentInfo;!rA||await this.stateValues.fixed||await this.coreFunctions.triggerChainedActions({triggeringAction:eA.endsWith("Clicked")?"click":"focus",componentIdx:rA.componentIdx,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}_referentActionNames(){for(const eA in REFERENT_ACTIONS)if(this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:this.presentedComponentType,baseComponentType:eA}))return REFERENT_ACTIONS[eA];return[]}_presentedRendererVariableNames(){if(this._presentedRendererNames===void 0){const eA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType];this._presentedRendererNames=Object.keys(eA?.returnStateVariableInfo({onlyForRenderer:!0}).stateVariableDescriptions??{})}return this._presentedRendererNames}get presentsAsAdapter(){return this.doenetAttributes.adapterVariable!==void 0}static returnStateVariableDefinitions(){const eA=super.returnStateVariableDefinitions(),AA={},tA=referenceSlotDefinitions({fixedReferentOf:iA=>iA.fixedReferent,readPlanOf:iA=>iA.doenetAttributes,emptyValueOf:(iA,rA)=>emptyValueOfType(iA.presentedComponentType,rA)});return Object.assign(AA,tA),AA.hidden={stateVariablesDeterminingDependencies:["referentInfo"],returnDependencies({stateValues:iA={}}){const rA={parentHidden:{dependencyType:"parentStateVariable",variableName:"hidden"},sourceCompositeHidden:{dependencyType:"sourceCompositeStateVariable",variableName:"hidden"}},aA=this.svComponent;if(!aA.isDrawn)return rA;aA.fixedReferent||(rA.valueMissing={dependencyType:"stateVariable",variableName:"valueMissing"});const oA=aA.fixedReferent??iA.referentInfo;return aA.doenetAttributes.copiesReferent&&oA&&(rA.referentHide={dependencyType:"stateVariable",componentIdx:oA.componentIdx,variableName:"hide",variablesOptional:!0}),Object.assign(rA,listEntryHideDependencies(oA)),rA},definition:({dependencyValues:iA})=>{const rA=listEntryHide(iA);return{setValue:{hidden:!!(iA.parentHidden||iA.sourceCompositeHidden||iA.valueMissing||iA.referentHide||rA)}}},markStale:()=>({updateParentRenderedChildren:!0})},AA.isInactiveCompositeReplacement=eA.isInactiveCompositeReplacement,AA.unordered=unorderedDefinition(),AA.isNumber=referentOrFallback({stateVariable:"isNumber",fallbackDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),fallback:({value:iA})=>Number.isFinite(typeof iA=="number"?iA:iA?.tree)}),AA}async serialize(eA={}){const AA=await super.serialize(eA);if(!eA.valueReferenceAsComponent||eA.serializingDescendant)return AA;AA.componentType=this.presentedComponentType,delete AA.extending;for(const aA of VALUE_REFERENCE_DOENET_ATTRIBUTES)delete AA.doenetAttributes[aA],delete AA.originalDoenetAttributes[aA];const tA=this.fixedReferent??await this.stateValues.referentInfo,iA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType]?.createAttributesObject()??{},rA=eA.copyAll?eA.components?.[tA?.componentIdx]:void 0;for(const aA in tA?.companions??{}){const oA=iA[aA]?.createComponentOfType;if(!oA||aA in AA.attributes)continue;if(!eA.copyAll&&attributeShadowIsReference(oA)){AA.attributes[aA]=shadowAttributeReference({attrName:aA,attributeComponentType:oA,target:{componentIdx:tA.componentIdx},stateVariableToShadow:tA.companions[aA]});continue}const sA={type:"serialized",componentType:oA,componentIdx:-1,attributes:{},doenetAttributes:{},state:{},children:[]};if(eA.copyAll){if(!rA)continue;sA.state.value=await currentReferentValue(rA,tA.companions[aA]),sA.dontShadowOriginalIndex=!0}else sA.shadowsVariableOf={componentIdx:tA.componentIdx,variableName:tA.companions[aA]};AA.attributes[aA]={type:"component",name:aA,component:sA}}if(tA&&(this.fixedReferent||!pathHasIndexComponents(this.refResolution))&&(AA.shadowsVariableOf={componentIdx:tA.componentIdx,variableName:tA.variableName},this.doenetAttributes.copiesReferent&&(AA.shadowsVariableOf.fromImplicitProp=!0,AA.doenetAttributes.fromImplicitProp=!0)),eA.copyAll){if(this.doenetAttributes.copiesReferent&&rA)for(const aA in rA.state){if(!rA.state[aA].hasEssential||aA==="literalAttributeWrites")continue;const sA=await rA.stateValues[aA];rA.state[aA].usedDefault||(AA.state[aA]=sA)}AA.state.value=await this.stateValues.value}return AA}returnMatchedChildIndices(){return[]}createOnDemandStateVariableDefinitions({stateVariable:eA,classDefinitions:AA}){if(eA==="valueMissing")return this.fixedReferent?[]:[[eA,valueMissingDefinition()]];if(eA==="pastEndOfList")return this.fixedReferent?[]:[[eA,pastEndOfListDefinition()]];if(eA==="valueAsResponse")return[[eA,valueAsResponseDefinition(this.doenetAttributes.referencedComponentType,this.fixedReferent)]];if(eA==="componentTypeAsResponse")return[[eA,componentTypeAsResponseDefinition(this.doenetAttributes.referencedComponentType,this.fixedReferent)]];if(CONTEXT_ATTRIBUTES.includes(eA))return[[eA,contextAttributeDefinition({attributeName:eA,base:{hasEssential:!0,defaultValue:!1},ownAttribute:!1,sourceDependency:referentContextDependency(eA),stateVariablesDeterminingDependencies:this.fixedReferent?void 0:["referentInfo"]})]];if(this.doenetAttributes.copiesReferent&&this.isDrawn&&COPIED_REFERENT_VARIABLES.has(eA))return[[eA,readsReferentVariable(eA,eA,this.fixedReferent)]];const tA=variableOfCopiedReferentVariable(eA);if(tA!==void 0)return[[eA,this.doenetAttributes.copiesReferent?readsReferentVariable(eA,tA,this.fixedReferent):{returnDependencies:()=>({}),definition:()=>({setValue:{[eA]:null}})}]];const iA=variableOfReferentVariable(eA);if(iA!==void 0)return[[eA,readsReferentVariable(eA,iA,this.fixedReferent)]];const rA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType];if(!rA)return[];const aA=AA(rA);let oA=eA;if(!aA[oA]){const gA=this.componentInfoObjects.stateVariableInfo[this.presentedComponentType].arrayEntryPrefixes,cA=Object.keys(gA).filter(IA=>oA.startsWith(IA)).sort((IA,uA)=>uA.length-IA.length)[0];if(cA!==void 0&&(oA=gA[cA].arrayVariableName,oA in this.state))return[]}const sA=aA[oA];if(!sA||sA.isAlias)return[];const lA=[oA,...sA.additionalStateVariablesDefined??[]];return lA.length===1&&!sA.isArray?[[oA,companionOrBorrowed(oA,sA,this.fixedReferent)]]:lA.map(gA=>[gA,Object.create(aA[gA])])}}const VALUE_REFERENCE_DOENET_ATTRIBUTES=["presentedComponentType","referencedComponentType","adapterVariable","fixedReferent","copiesReferent","listEntryAdapterProperty","readsReferentAdapter"],NO_RENDERER_VARIABLES=Object.freeze({}),DRAWN_REFERENCE_VARIABLES=new Set(["hidden","text","latex","value","selectedStyle"]),DRAWN_REFERENCE_CONSTANTS=Object.freeze({renderAsMath:!1,renderMode:"inline",clickTarget:!1}),COPIED_REFERENT_VARIABLES=new Set(["selectedStyle","fixed",...Object.keys(DRAWN_REFERENCE_CONSTANTS)]);function referentContextDependency(nA){return(eA,AA)=>{const tA=eA.fixedReferent??AA.referentInfo;return!tA||tA.variableName===nA?null:{dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:nA==="fixed"&&tA.listEntryPosition!==void 0?"entriesFixed":nA,variablesOptional:!0}}}const REFERENT_ACTIONS={number:["numberClicked","numberFocused"],math:["mathClicked","mathFocused"],text:["textClicked","textFocused"]};function pastEndOfListDefinition(){return{stateVariablesDeterminingDependencies:["referentInfo"],returnDependencies({stateValues:nA,componentInfoObjects:eA}){const AA=nA.referentInfo,tA=AA?.listEntryPosition===void 0?void 0:eA.allComponentClasses[AA.componentType]?.listEntryCountVariable;return tA===void 0?{}:{referentInfo:{dependencyType:"stateVariable",variableName:"referentInfo"},numEntries:{dependencyType:"stateVariable",componentIdx:AA.componentIdx,variableName:tA}}},definition({dependencyValues:nA}){return{setValue:{pastEndOfList:nA.numEntries!==void 0&&nA.referentInfo.listEntryPosition>nA.numEntries}}}}}function valueAsResponseDefinition(nA,eA){const AA={returnDependencies({stateValues:tA={}}){const iA=eA??tA.referentInfo,rA=eA?{}:{valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA&&(rA.referenced={dependencyType:"stateVariable",componentIdx:iA.componentIdx,variableName:iA.referencedVariable,variablesOptional:!0}),rA},definition({dependencyValues:tA,componentInfoObjects:iA}){let rA=tA.referenced;return tA.valueMissing?rA=context.fromAst("_"):rA==null&&(rA=emptyValueOfType(nA,iA)),{setValue:{valueAsResponse:rA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function componentTypeAsResponseDefinition(nA,eA){return{returnDependencies:()=>eA?{}:{valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}},definition({dependencyValues:AA}){return{setValue:{componentTypeAsResponse:AA.valueMissing?"math":nA}}}}}function companionOrBorrowed(nA,eA,AA){const tA=Object.create(eA);return AA||(tA.stateVariablesDeterminingDependencies=[...eA.stateVariablesDeterminingDependencies??[],"referentInfo"]),tA.returnDependencies=function(iA){const rA=AA??iA.stateValues?.referentInfo,aA=rA?.companions?.[nA];return aA?{fromReferent:{dependencyType:"stateVariable",componentIdx:rA.componentIdx,variableName:aA,variablesOptional:!0}}:eA.returnDependencies.call(this,iA)},tA.definition=function(iA){if(!("fromReferent"in iA.dependencyValues))return eA.definition.call(this,iA);const rA=iA.dependencyValues.fromReferent;return iA.usedDefault.fromReferent&&this.hasEssential&&this.defaultValue!==void 0?{useEssentialOrDefaultValue:{[nA]:{defaultValue:rA}}}:{setValue:{[nA]:rA}}},tA.inverseDefinition=async function(iA){return(await iA.stateValues.referentInfo)?.companions?.[nA]?{success:!0,instructions:[{setDependency:"fromReferent",desiredValue:iA.desiredStateVariableValues[nA],shadowedVariable:!0}]}:eA.inverseDefinition?eA.inverseDefinition.call(this,iA):{success:!1}},tA}function listEntryHideDependencies(nA){return nA?.listEntryPosition===void 0?{}:{entryPosition:{dependencyType:"value",value:nA.listEntryPosition},referentVariable:{dependencyType:"value",value:nA.variableName},referentEntryPrefix:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"listEntryVariablePrefix",variablesOptional:!0},referentEntryHides:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"entryHides",variablesOptional:!0}}}function listEntryHide(nA){const eA=nA.entryPosition;if(!(!nA.referentEntryHides||nA.referentVariable!==`${nA.referentEntryPrefix}${eA}`&&nA.referentVariable!==`${LIST_ENTRY_PREFIX}value_${eA}`))return!!nA.referentEntryHides[eA-1]}function readsReferentVariable(nA,eA,AA){const tA={hasEssential:!0,defaultValue:null,returnDependencies({stateValues:iA={}}){const rA=AA??iA.referentInfo;return rA?{fromReferent:{dependencyType:"stateVariable",componentIdx:rA.componentIdx,variableName:eA,variablesOptional:!0}}:{}},definition({dependencyValues:iA,usedDefault:rA}){const aA=iA.fromReferent;return aA==null?{setValue:{[nA]:null}}:rA.fromReferent?{useEssentialOrDefaultValue:{[nA]:{defaultValue:aA}}}:{setValue:{[nA]:aA}}},async inverseDefinition({desiredStateVariableValues:iA,stateValues:rA}){return await rA.referentInfo?{success:!0,instructions:[{setDependency:"fromReferent",desiredValue:iA[nA]}]}:{success:!1}}};return AA||(tA.stateVariablesDeterminingDependencies=["referentInfo"]),tA}class SegmentConstraintComponent extends BaseComponent{static componentType="_segmentConstraint";static rendererType=void 0;static inSchemaOnlyInheritAs=["_segmentConstraint"]}class VariableNameList extends MathList{static componentType="_variableNameList";static stateVariableToBeShadowed="variables";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.variables={description:"The list of variable names.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},isArray:!0,entryPrefixes:["var"],additionalStateVariablesDefined:["validVariables"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let iA of AA)tA[iA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(iA)+1)}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let iA={},rA={},aA=[];for(let oA of tA){let sA=AA[oA].math,lA=isValidVariable(sA);lA||(aA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:sA.toString()}})),lA=!1),iA[oA]=sA,rA[oA]=lA}return{setValue:{variables:iA,validVariables:rA},sendDiagnostics:aA}}},eA}}class Variable extends MathComponent{static componentType="_variableName";static rendererType="math";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"value",newName:"valuePreValidate"}),eA.valuePreValidate.essentialVarName="value",eA.value={description:"The variable as a math expression.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},additionalStateVariablesDefined:["validVariable"],returnDependencies:()=>({valuePreValidate:{dependencyType:"stateVariable",variableName:"valuePreValidate"}}),definition({dependencyValues:AA}){let tA=[],iA=isValidVariable(AA.valuePreValidate);return iA||tA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:iA},sendDiagnostics:tA}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setDependency:"valuePreValidate",desiredValue:AA.value}]}}},eA}}class ListOfNumberLists extends InlineComponent{static componentType="_listOfNumberLists";static includeBlankStringChildren=!0;static removeBlankStringChildrenPostSugar=!0;static additionalSchemaChildren=["math","string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=breakEmbeddedStringsIntoParensPieces({componentList:tA,removeParens:!0});return aA.success!==!0?{success:!1}:{success:!0,newChildren:aA.pieces.map(oA=>({type:"serialized",componentType:"numberList",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}})),nComponents:iA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"lists",componentTypes:["numberList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.value,eA.numLists={returnDependencies:()=>({listChildren:{dependencyType:"child",childGroups:["lists"]}}),definition({dependencyValues:AA}){return{setValue:{numLists:AA.listChildren.length}}}},eA.lists={isArray:!0,entryPrefixes:["list"],returnArraySizeDependencies:()=>({numLists:{dependencyType:"stateVariable",variableName:"numLists"}}),returnArraySize({dependencyValues:AA}){return[AA.numLists]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let iA of AA)tA[iA]={listChildren:{dependencyType:"child",childGroups:["lists"],variableNames:["values"],childIndices:[iA]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let iA={};for(let rA of tA)if(AA[rA].listChildren&&AA[rA].listChildren.length===1){let aA=AA[rA].listChildren[0];iA[rA]=aA.stateValues.values}return{setValue:{lists:iA}}}},eA}}class DirectionComponent extends BaseComponent{static componentType="_directionComponent";static rendererType=void 0;static primaryStateVariableForDefinition="directionShadow";static additionalSchemaChildren=["math","string"];static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){return tA.length===0?{success:!1}:tA.length>1||typeof tA[0]=="string"?{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:iA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"directions",componentTypes:["_directionComponent"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.directionShadow={defaultValue:context.fromAst(["vector",1,0]),hasEssential:!0,essentialVarName:"direction",set:convertValueToMathExpression,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{directionShadow:!0}}),inverseDefinition:function({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"directionShadow",value:convertValueToMathExpression(AA.directionShadow)}]}}},eA.unnormalizedDirection={returnDependencies:()=>({directionChild:{dependencyType:"child",childGroups:["directions"],variableNames:["unnormalizedDirection"]},directionShadow:{dependencyType:"stateVariable",variableName:"directionShadow"}}),definition({dependencyValues:AA}){let tA;return AA.directionChild.length>0?tA=AA.directionChild[0].stateValues.unnormalizedDirection:tA=AA.directionShadow,tA=tA.tuples_to_vectors().expand().simplify(),{setValue:{unnormalizedDirection:tA}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){let iA;return tA.directionChild.length>0?iA=[{setDependency:"directionChild",desiredValue:AA.unnormalizedDirection,childIndex:0,variableIndex:0}]:iA=[{setDependency:"directionShadow",desiredValue:AA.unnormalizedDirection}],{success:!0,instructions:iA}}},eA.numDimensions={returnDependencies:()=>({unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}),definition({dependencyValues:AA}){let tA=AA.unnormalizedDirection.tree,iA;return Array.isArray(tA)&&vectorOperators.includes(tA[0])?iA=tA.length-1:iA=1,{setValue:{numDimensions:iA}}}},eA.direction={description:"The normalized direction as a unit vector.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="x"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,entryPrefixes:["x"],hasEssential:!0,essentialVarName:"direction2",set:convertValueToMathExpression,returnArraySizeDependencies:()=>({numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"}}),returnArraySize({dependencyValues:AA}){return[AA.numDimensions]},returnArrayDependenciesByKey(){return{globalDependencies:{unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}}},arrayDefinitionByKey:function({globalDependencyValues:AA,arraySize:tA}){let iA={},rA=AA.unnormalizedDirection.tree;if(Array.isArray(rA)&&vectorOperators.includes(rA[0])){let aA=[],oA=tA[0],sA=0,lA=!0;for(let gA=0;gA<oA;gA++){let cA=AA.unnormalizedDirection.get_component(gA).evaluate_to_constant();if(Number.isFinite(cA))aA.push(cA),sA+=cA*cA;else{lA=!1;break}}if(lA){let gA=Math.sqrt(sA);for(let cA=0;cA<oA;cA++)iA[cA.toString()]=context.fromAst(aA[cA]/gA)}else for(let gA=0;gA<oA;gA++)iA[gA.toString()]=context.fromAst("_")}else iA[0]=context.fromAst(1);return{setValue:{direction:iA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,arraySize:iA}){let rA=[];if(iA[0]>1){let aA=0;for(let sA=0;sA<iA[0];sA++){let lA=evaluateToNumber(tA.unnormalizedDirection.get_component(sA));aA+=lA*lA}Number.isFinite(aA)?aA=Math.sqrt(aA):aA=1;let oA=["vector"];for(let sA in AA.direction)oA[Number(sA)+1]=AA.direction[sA].tree*aA;oA.length=iA[0]+1,rA.push({setDependency:"unnormalizedDirection",desiredValue:context.fromAst(markUnspecifiedComponents(oA))})}return{success:!0,instructions:rA}}},eA}}class ErrorComponent extends BlockComponent{static componentType="_error";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.message={createComponentOfType:"text",createStateVariable:"message",defaultValue:"",public:!0,forRenderer:!0,description:"The error message describing what went wrong."},eA}static returnChildGroups(){return[{group:"errors",componentTypes:["_error"]},{group:"any",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.hidden={returnDependencies:()=>({}),definition:()=>({setValue:{hidden:!1}})},eA.code={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{code:!0}})},eA.args={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{args:!0}})},eA.rangeMessage={description:"A message describing where in the source document the error was found.",forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"text"},additionalStateVariablesDefined:[{variableName:"rangeArgs",forRenderer:!0}],returnDependencies:()=>({position:{dependencyType:"position"}}),definition({dependencyValues:AA}){let tA=AA.position;return tA?.start.line===void 0?{setValue:{rangeMessage:"",rangeArgs:null}}:{setValue:{rangeMessage:"Found on "+printDoenetMLrange(tA)+".",rangeArgs:{span:tA.start.line===tA.end.line?"line":"lines",startLine:String(tA.start.line),endLine:String(tA.end.line)}}}}},eA.showMessage={forRenderer:!0,returnDependencies:()=>({childErrors:{dependencyType:"child",childGroups:["errors"],variableNames:["message"]},message:{dependencyType:"stateVariable",variableName:"message"}}),definition({dependencyValues:AA}){return{setValue:{showMessage:!AA.childErrors.some(iA=>iA.stateValues.message===AA.message)}}}},eA}}class Comment extends BaseComponent{static componentType="_comment";static rendererType=void 0;static returnChildGroups(){return[{group:"any",componentTypes:["_base"]}]}}const componentTypeArray=[...Object.values(Aliases),...Object.values(MMeMen),...Object.values(MdMdnMrow),...Object.values(BooleanOperators),...Object.values(BooleanOperatorsOfMath),...Object.values(MathOperators),...Object.values(MathListOperators),...Object.values(ListIndexOperators),...Object.values(CountOperators),Chart,Series,...Object.values(FunctionOperators),...Object.values(TextOperatorsOfMath),...Object.values(Extrema$1),...Object.values(ParagraphMarkup),...Object.values(SingleCharacterComponents),...Object.values(Sectioning),...Object.values(Lists),...Object.values(DynamicalSystems),...Object.values(Chemistry),...Object.values(FeedbackDefinitions$1),...Object.values(StyleDefinitions$1),...Object.values(StylePalette$1),...Object.values(SideBySide$1),...Object.values(ComponentWithSelectableType$1),...Object.values(Indexing),...Object.values(Divisions),...Object.values(Verbatim),...Object.values(Paginator$1),...Object.values(MatrixInput$1),...Object.values(FractionInput$1),...Object.values(Solution$1),Document,Text,TextList$1,TextList2,P$2,BooleanComponent,BooleanList,MathComponent,MathList,TupleList,NumberList,Copy,ValueRef,Collect,RegisteredCollectList,Ref,Point,Coords,Line,LineSegment,Ray,Polyline,Polygon,Triangle,Rectangle,RegularPolygon,Circle,Parabola,Curve,BezierControls,ControlVectors,Vector,Angle,Answer,Award,When,MathInput,Textinput,BooleanInput,Choiceinput,Choice,NumberComponent,Integer,Graph$1,Annotations,Annotation,Function$1,PiecewiseFunction,Interval,Option$1,Sequence,Slider,Spreadsheet,DiscreteSimulationResultList,DiscreteSimulationResultPolyline,Cell,Row,Column,Col,CellBlock,Tabular,Table,Figure,Markers,Panel,Repeat,RepeatForSequence,RepeatValues,RepeatValueList,RepeatPointList,RepeatIndices,Pegboard,Constraints,ConstrainToGrid,ConstrainToGraph,AttractToGrid,ConstrainTo,AttractTo,ConstraintUnion,AttractToConstraint,ConstrainToInterior,Intersection,ConstrainToAngles,AttractToAngles,ConditionalContent,AsList,VariantControl,TextListFromString,SelectFromSequence,Select,Group,AnimateFromSequence,Evaluate,SelectRandomNumbers,SampleRandomNumbers,SampleMultivariateRandomNumber,SelectPrimeNumbers,SamplePrimeNumbers,Substitute,PeriodicSet,Image,Video,Embed,Hint,IntComma,Pluralize,Feedback,CollaborateGroups,CollaborateGroupSetup,ConsiderAsResponses,Case,Lorem,UpdateValue,CallAction,triggerSet,FunctionIterates,Module,ModuleAttributes,Setup,Footnote,Caption,Endpoint,Sort,SortList,SortIndices,Shuffle,ShuffleList,SolveEquations,PostponeRenderContainer,SubsetOfRealsInput,SubsetOfReals,Split,BestFitLine,RegionBetweenCurveXAxis,RegionBetweenCurves,SlopeField,VectorField,RegionHalfPlane,CodeEditor,HasSameFactoring,DataFrame,SummaryStatistics,Legend,Label,MatchesPattern,Matrix,EigenDecomposition,Latex,BlockQuote,Description,StickyGroup,Pretzel,PretzelArranger,Cascade,Page,DynamicChildren,ShortDescription,BaseComponent,InlineComponent,BlockComponent,BlockScoredComponent,GraphicalComponent,ConstraintComponent,SegmentConstraintComponent,Input,CompositeComponent,PointList,IntervalList,LineListComponent,VectorList,AngleListComponent,BooleanOperator,BooleanBaseOperatorOfMath,MathOperator,MathOperatorOneInput,FunctionOperator,...Object.values(ComponentSize$1),...Object.values(SectioningComponent$1),InlineRenderInlineChildren,TextOrInline,SingleCharacter,VariableNameList,Variable,ListOfNumberLists,DirectionComponent,ErrorComponent,Comment];function allComponentClasses(){const nA={},eA=new Set;for(let AA of componentTypeArray){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let iA=tA.toLowerCase();if(eA.has(iA))throw Error("component type "+tA+" defined in two classes");nA[tA]=AA,eA.add(iA)}return nA}function componentTypesCreatingVariants(){const nA={},eA=new Set;for(let AA of componentTypeArray)if(AA.createsVariants){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let iA=tA.toLowerCase();if(eA.has(iA))throw Error("component type "+tA+" defined in two classes");nA[tA]=AA,eA.add(iA)}return nA}function createComponentInfoObjects(){const nA=allComponentClasses(),eA=componentTypesCreatingVariants(),AA={};for(const lA in nA)AA[lA.toLowerCase()]=lA;const tA={};for(const lA in nA)Object.defineProperty(tA,lA,{get:(function(){const gA=nA[lA].returnStateVariableInfo();return delete tA[lA],tA[lA]=gA}).bind(this),configurable:!0});const iA={};for(const lA in nA)Object.defineProperty(iA,lA,{get:(function(){const gA=nA[lA].returnStateVariableInfo({onlyPublic:!0});return delete iA[lA],iA[lA]=gA}).bind(this),configurable:!0});function rA({inheritedComponentType:lA,baseComponentType:gA}){if(lA===gA)return!0;if(lA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let cA=nA[gA];return cA?cA.isPrototypeOf(nA[lA]):!1}function aA({componentType:lA,includeNonStandard:gA=!0}){const cA=nA[lA];return cA?rA({inheritedComponentType:lA,baseComponentType:"_composite"})&&(gA||!cA.treatAsComponentForRecursiveReplacements):!1}const oA=(lA,gA)=>rA({inheritedComponentType:lA,baseComponentType:gA});return{allComponentClasses:nA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,isInheritedComponentType:rA,isCompositeComponent:aA,stateVariableInfo:tA,publicStateVariableInfo:iA,componentIsSpecifiedType:(lA,gA)=>oA(lA.componentType,gA)||lA.attributes?.createComponentOfType?.primitive!==void 0&&oA(lA.attributes?.createComponentOfType?.primitive.value,gA)}}async function returnAllPossibleVariants(nA,eA,AA){let iA=getNumVariants({serializedComponent:nA,componentInfoObjects:eA,infoDiagnostics:AA}).numVariants,rA;return nA.variants?.allPossibleVariants?rA=nA.variants.allPossibleVariants:rA=[...Array(iA).keys()].map(aA=>indexToLowercaseLetters(aA+1)),rA}function indexToLowercaseLetters(nA){return numberToLetters(nA,!0)}class PublicDoenetMLCore{constructor(){this.core=null,this.initialized=!1,this.doenetML="",this.flags={},this.localeData=DEFAULT_LOCALE_DATA}setSource(eA){this.doenetML=eA}setFlags(eA){this.flags=eA}setLocaleData(eA){this.localeData=eA}async initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:rA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:lA,updateRootNames:gA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=gA;let cA=createComponentInfoObjects();const{document:IA,nComponents:uA,diagnostics:CA,sources:dA}=await normalizedDastToSerializedComponents(rA,cA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,serializedDocument:IA,nComponentsInit:uA,allDoenetMLs:dA,preliminaryDiagnostics:CA,componentInfoObjects:cA},this.initialized=!0;let pA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,CA);const mA=this.coreBaseArgs.serializedDocument.children.reduce((QA,BA)=>(typeof BA=="object"&&(QA[BA.componentType]=(QA[BA.componentType]??0)+1),QA),{});return{allPossibleVariants:pA,baseComponentCounts:mA}}async createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA){if(this.initialized&&!this.coreBaseArgs?.serializedDocument)return{success:!1,errMsg:"Cannot create the core a second time from the same worker; the serialized document was released after the first core was created."};let lA={...this.coreBaseArgs,...eA,addNodesToResolver:this.addNodesToResolver,replaceIndexResolutionsInResolver:this.replaceIndexResolutionsInResolver,deleteNodesFromResolver:this.deleteNodesFromResolver,resolvePath:this.resolvePath,updateRootNames:this.updateRootNames,updateRenderersCallback:AA,reportScoreAndStateCallback:tA,requestAnimationFrame:iA,cancelAnimationFrame:rA,copyToClipboard:aA,sendEvent:oA,requestSolutionView:sA};if(this.initialized){this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{return{success:!0,...await this.core.generateDast()}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async requestAction(eA){if(!this.core)return{success:!1,errMsg:"Cannot request action before core is created"};try{return await this.core.requestAction(eA)}catch(AA){return console.error(AA),{success:!1,errMsg:typeof AA=="string"?AA:typeof AA=="object"&&AA&&"message"in AA&&typeof AA.message=="string"?AA.message:"",actionId:eA.args?.actionId}}}async returnAllStateVariables(eA=!1,AA=!1){if(!this.core?.components)return{};const tA=this.core.processQueue.stoppedByError;if(tA!==null)throw Error(tA);const iA={},rA=this.core.components;eA&&console.log(rA);for(let aA in rA){const oA=Number(aA);let sA=rA[oA];if(!sA)continue;iA[oA]={componentIdx:oA,componentType:sA.componentType,stateValues:{},activeChildren:[],sharedParameters:null};let lA=iA[oA];for(let gA in sA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(gA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType})&&!sA.isExpanded)continue;const cA=await sA.state[gA].value;lA.stateValues[gA]=AA?cA:removeFunctionsMathExpressionClass(cA)}lA.activeChildren=sA.activeChildren.map(gA=>gA.componentIdx?{componentIdx:gA.componentIdx,componentType:gA.componentType}:gA),sA.replacements&&(lA.replacements=sA.replacements.map(gA=>gA.componentIdx?{componentIdx:gA.componentIdx,componentType:gA.componentType}:gA),sA.replacementsToWithhold!==void 0&&(lA.replacementsToWithhold=sA.replacementsToWithhold)),sA.replacementOf&&(lA.replacementOf=sA.replacementOf.componentIdx),lA.sharedParameters=AA?sA.sharedParameters:removeFunctionsMathExpressionClass(sA.sharedParameters)}return iA}async terminate(){this.core&&(await this.core.terminate(),this.core=null)}handleVisibilityChange(eA){this.core?.handleVisibilityChange(eA)}navigatingToComponent(eA,AA){this.core&&handleNavigatingToComponent({core:this.core,componentIdx:eA,hash:AA}).catch(reportTimerError(TimerLabels.navigateToComponent))}async submitAllAnswers(){await this.core?.requestAction({componentIdx:this.core.documentIdx,actionName:"submitAllAnswers",args:{}}),await this.core?.saveImmediately()}async saveImmediately(){await this.core?.saveImmediately()}async flushState(){return await this.core?.flushState()??!1}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(nA){return nA&&nA.__esModule&&Object.prototype.hasOwnProperty.call(nA,"default")?nA.default:nA}var colorName$1,hasRequiredColorName;function requireColorName(){return hasRequiredColorName||(hasRequiredColorName=1,colorName$1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),colorName$1}var colorNameExports=requireColorName();const colorName=getDefaultExportFromCjs(colorNameExports);var r$2={grad:.9,turn:360,rad:360/(2*Math.PI)},t$3=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},n$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},e$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},u$2=function(nA){return(nA=isFinite(nA)?nA%360:0)>0?nA:nA+360},a$2=function(nA){return{r:e$2(nA.r,0,255),g:e$2(nA.g,0,255),b:e$2(nA.b,0,255),a:e$2(nA.a)}},o$3=function(nA){return{r:n$2(nA.r),g:n$2(nA.g),b:n$2(nA.b),a:n$2(nA.a,3)}},i$2=/^#([0-9a-f]{3,8})$/i,s$1=function(nA){var eA=nA.toString(16);return eA.length<2?"0"+eA:eA},h$2=function(nA){var eA=nA.r,AA=nA.g,tA=nA.b,iA=nA.a,rA=Math.max(eA,AA,tA),aA=rA-Math.min(eA,AA,tA),oA=aA?rA===eA?(AA-tA)/aA:rA===AA?2+(tA-eA)/aA:4+(eA-AA)/aA:0;return{h:60*(oA<0?oA+6:oA),s:rA?aA/rA*100:0,v:rA/255*100,a:iA}},b$2=function(nA){var eA=nA.h,AA=nA.s,tA=nA.v,iA=nA.a;eA=eA/360*6,AA/=100,tA/=100;var rA=Math.floor(eA),aA=tA*(1-AA),oA=tA*(1-(eA-rA)*AA),sA=tA*(1-(1-eA+rA)*AA),lA=rA%6;return{r:255*[tA,oA,aA,aA,sA,tA][lA],g:255*[sA,tA,tA,oA,aA,aA][lA],b:255*[aA,aA,sA,tA,tA,oA][lA],a:iA}},g=function(nA){return{h:u$2(nA.h),s:e$2(nA.s,0,100),l:e$2(nA.l,0,100),a:e$2(nA.a)}},d$1=function(nA){return{h:n$2(nA.h),s:n$2(nA.s),l:n$2(nA.l),a:n$2(nA.a,3)}},f$1=function(nA){return b$2((AA=(eA=nA).s,{h:eA.h,s:(AA*=((tA=eA.l)<50?tA:100-tA)/100)>0?2*AA/(tA+AA)*100:0,v:tA+AA,a:eA.a}));var eA,AA,tA},c$1=function(nA){return{h:(eA=h$2(nA)).h,s:(iA=(200-(AA=eA.s))*(tA=eA.v)/100)>0&&iA<200?AA*tA/100/(iA<=100?iA:200-iA)*100:0,l:iA/2,a:eA.a};var eA,AA,tA,iA},l$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v$1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y$1={string:[[function(nA){var eA=i$2.exec(nA);return eA?(nA=eA[1]).length<=4?{r:parseInt(nA[0]+nA[0],16),g:parseInt(nA[1]+nA[1],16),b:parseInt(nA[2]+nA[2],16),a:nA.length===4?n$2(parseInt(nA[3]+nA[3],16)/255,2):1}:nA.length===6||nA.length===8?{r:parseInt(nA.substr(0,2),16),g:parseInt(nA.substr(2,2),16),b:parseInt(nA.substr(4,2),16),a:nA.length===8?n$2(parseInt(nA.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(nA){var eA=v$1.exec(nA)||m.exec(nA);return eA?eA[2]!==eA[4]||eA[4]!==eA[6]?null:a$2({r:Number(eA[1])/(eA[2]?100/255:1),g:Number(eA[3])/(eA[4]?100/255:1),b:Number(eA[5])/(eA[6]?100/255:1),a:eA[7]===void 0?1:Number(eA[7])/(eA[8]?100:1)}):null},"rgb"],[function(nA){var eA=l$2.exec(nA)||p$2.exec(nA);if(!eA)return null;var AA,tA,iA=g({h:(AA=eA[1],tA=eA[2],tA===void 0&&(tA="deg"),Number(AA)*(r$2[tA]||1)),s:Number(eA[3]),l:Number(eA[4]),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return f$1(iA)},"hsl"]],object:[[function(nA){var eA=nA.r,AA=nA.g,tA=nA.b,iA=nA.a,rA=iA===void 0?1:iA;return t$3(eA)&&t$3(AA)&&t$3(tA)?a$2({r:Number(eA),g:Number(AA),b:Number(tA),a:Number(rA)}):null},"rgb"],[function(nA){var eA=nA.h,AA=nA.s,tA=nA.l,iA=nA.a,rA=iA===void 0?1:iA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=g({h:Number(eA),s:Number(AA),l:Number(tA),a:Number(rA)});return f$1(aA)},"hsl"],[function(nA){var eA=nA.h,AA=nA.s,tA=nA.v,iA=nA.a,rA=iA===void 0?1:iA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=(function(oA){return{h:u$2(oA.h),s:e$2(oA.s,0,100),v:e$2(oA.v,0,100),a:e$2(oA.a)}})({h:Number(eA),s:Number(AA),v:Number(tA),a:Number(rA)});return b$2(aA)},"hsv"]]},N=function(nA,eA){for(var AA=0;AA<eA.length;AA++){var tA=eA[AA][0](nA);if(tA)return[tA,eA[AA][1]]}return[null,void 0]},x$1=function(nA){return typeof nA=="string"?N(nA.trim(),y$1.string):typeof nA=="object"&&nA!==null?N(nA,y$1.object):[null,void 0]},M$2=function(nA,eA){var AA=c$1(nA);return{h:AA.h,s:e$2(AA.s+100*eA,0,100),l:AA.l,a:AA.a}},H=function(nA){return(299*nA.r+587*nA.g+114*nA.b)/1e3/255},$=function(nA,eA){var AA=c$1(nA);return{h:AA.h,s:AA.s,l:e$2(AA.l+100*eA,0,100),a:AA.a}},j=(function(){function nA(eA){this.parsed=x$1(eA)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return nA.prototype.isValid=function(){return this.parsed!==null},nA.prototype.brightness=function(){return n$2(H(this.rgba),2)},nA.prototype.isDark=function(){return H(this.rgba)<.5},nA.prototype.isLight=function(){return H(this.rgba)>=.5},nA.prototype.toHex=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,iA=eA.b,aA=(rA=eA.a)<1?s$1(n$2(255*rA)):"","#"+s$1(AA)+s$1(tA)+s$1(iA)+aA;var eA,AA,tA,iA,rA,aA},nA.prototype.toRgb=function(){return o$3(this.rgba)},nA.prototype.toRgbString=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,iA=eA.b,(rA=eA.a)<1?"rgba("+AA+", "+tA+", "+iA+", "+rA+")":"rgb("+AA+", "+tA+", "+iA+")";var eA,AA,tA,iA,rA},nA.prototype.toHsl=function(){return d$1(c$1(this.rgba))},nA.prototype.toHslString=function(){return eA=d$1(c$1(this.rgba)),AA=eA.h,tA=eA.s,iA=eA.l,(rA=eA.a)<1?"hsla("+AA+", "+tA+"%, "+iA+"%, "+rA+")":"hsl("+AA+", "+tA+"%, "+iA+"%)";var eA,AA,tA,iA,rA},nA.prototype.toHsv=function(){return eA=h$2(this.rgba),{h:n$2(eA.h),s:n$2(eA.s),v:n$2(eA.v),a:n$2(eA.a,3)};var eA},nA.prototype.invert=function(){return w$1({r:255-(eA=this.rgba).r,g:255-eA.g,b:255-eA.b,a:eA.a});var eA},nA.prototype.saturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,eA))},nA.prototype.desaturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,-eA))},nA.prototype.grayscale=function(){return w$1(M$2(this.rgba,-1))},nA.prototype.lighten=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,eA))},nA.prototype.darken=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,-eA))},nA.prototype.rotate=function(eA){return eA===void 0&&(eA=15),this.hue(this.hue()+eA)},nA.prototype.alpha=function(eA){return typeof eA=="number"?w$1({r:(AA=this.rgba).r,g:AA.g,b:AA.b,a:eA}):n$2(this.rgba.a,3);var AA},nA.prototype.hue=function(eA){var AA=c$1(this.rgba);return typeof eA=="number"?w$1({h:eA,s:AA.s,l:AA.l,a:AA.a}):n$2(AA.h)},nA.prototype.isEqual=function(eA){return this.toHex()===w$1(eA).toHex()},nA})(),w$1=function(nA){return nA instanceof j?nA:new j(nA)},S=[],k=function(nA){nA.forEach(function(eA){S.indexOf(eA)<0&&(eA(j,y$1),S.push(eA))})},a$1=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},t$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},o$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},r$1=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h$1=function(nA){return 255*(nA>.0031308?1.055*Math.pow(nA,1/2.4)-.055:12.92*nA)},n$1=96.422,p$1=100,M$1=82.521,u$1=function(nA){var eA,AA,tA={x:.9555766*(eA=nA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h$1(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h$1(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h$1(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:nA.a},{r:o$2(AA.r,0,255),g:o$2(AA.g,0,255),b:o$2(AA.b,0,255),a:o$2(AA.a)}},e$1=function(nA){var eA=r$1(nA.r),AA=r$1(nA.g),tA=r$1(nA.b);return(function(iA){return{x:o$2(iA.x,0,n$1),y:o$2(iA.y,0,p$1),z:o$2(iA.z,0,M$1),a:o$2(iA.a)}})((function(iA){return{x:1.0478112*iA.x+.0228866*iA.y+-.050127*iA.z,y:.0295424*iA.x+.9904844*iA.y+-.0170491*iA.z,z:-.0092345*iA.x+.0150436*iA.y+.7521316*iA.z,a:iA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:nA.a}))},w=216/24389,b$1=24389/27,i$1=function(nA){var eA=nA.l,AA=nA.a,tA=nA.b,iA=nA.alpha,rA=iA===void 0?1:iA;if(!a$1(eA)||!a$1(AA)||!a$1(tA))return null;var aA=(function(oA){return{l:o$2(oA.l,0,400),a:oA.a,b:oA.b,alpha:o$2(oA.alpha)}})({l:Number(eA),a:Number(AA),b:Number(tA),alpha:Number(rA)});return l$1(aA)},l$1=function(nA){var eA=(nA.l+16)/116,AA=nA.a/500+eA,tA=eA-nA.b/200;return u$1({x:(Math.pow(AA,3)>w?Math.pow(AA,3):(116*AA-16)/b$1)*n$1,y:(nA.l>8?Math.pow((nA.l+16)/116,3):nA.l/b$1)*p$1,z:(Math.pow(tA,3)>w?Math.pow(tA,3):(116*tA-16)/b$1)*M$1,a:nA.alpha})};function labPlugin(nA,eA){nA.prototype.toLab=function(){return tA=e$1(this.rgba),rA=tA.y/p$1,aA=tA.z/M$1,iA=(iA=tA.x/n$1)>w?Math.cbrt(iA):(b$1*iA+16)/116,AA={l:116*(rA=rA>w?Math.cbrt(rA):(b$1*rA+16)/116)-16,a:500*(iA-rA),b:200*(rA-(aA=aA>w?Math.cbrt(aA):(b$1*aA+16)/116)),alpha:tA.a},{l:t$2(AA.l,2),a:t$2(AA.a,2),b:t$2(AA.b,2),alpha:t$2(AA.alpha,3)};var AA,tA,iA,rA,aA},nA.prototype.delta=function(AA){AA===void 0&&(AA="#FFF");var tA=AA instanceof nA?AA:new nA(AA),iA=(function(rA,aA){var oA=rA.l,sA=rA.a,lA=rA.b,gA=aA.l,cA=aA.a,IA=aA.b,uA=180/Math.PI,CA=Math.PI/180,dA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(cA,2)+Math.pow(IA,2),.5),mA=(oA+gA)/2,QA=Math.pow((dA+pA)/2,7),BA=.5*(1-Math.pow(QA/(QA+Math.pow(25,7)),.5)),hA=sA*(1+BA),DA=cA*(1+BA),EA=Math.pow(Math.pow(hA,2)+Math.pow(lA,2),.5),fA=Math.pow(Math.pow(DA,2)+Math.pow(IA,2),.5),NA=(EA+fA)/2,yA=hA===0&&lA===0?0:Math.atan2(lA,hA)*uA,bA=DA===0&&IA===0?0:Math.atan2(IA,DA)*uA;yA<0&&(yA+=360),bA<0&&(bA+=360);var wA=bA-yA,MA=Math.abs(bA-yA);MA>180&&bA<=yA?wA+=360:MA>180&&bA>yA&&(wA-=360);var vA=yA+bA;MA<=180?vA/=2:vA=(yA+bA<360?vA+360:vA-360)/2;var kA=1-.17*Math.cos(CA*(vA-30))+.24*Math.cos(2*CA*vA)+.32*Math.cos(CA*(3*vA+6))-.2*Math.cos(CA*(4*vA-63)),TA=gA-oA,OA=fA-EA,FA=2*Math.sin(CA*wA/2)*Math.pow(EA*fA,.5),RA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),xA=1+.045*NA,jA=1+.015*NA*kA,HA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),zA=-2*Math.pow(QA/(QA+Math.pow(25,7)),.5)*Math.sin(2*CA*HA);return Math.pow(Math.pow(TA/1/RA,2)+Math.pow(OA/1/xA,2)+Math.pow(FA/1/jA,2)+zA*OA*FA/(1*xA*1*jA),.5)})(this.toLab(),tA.toLab())/100;return o$2(t$2(iA,3))},eA.object.push([i$1,"lab"])}var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t$1=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},a=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},n=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},u=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h=function(nA){return 255*(nA>.0031308?1.055*Math.pow(nA,1/2.4)-.055:12.92*nA)},o$1=96.422,e=100,c=82.521,i=function(nA){var eA,AA,tA={x:.9555766*(eA=nA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:nA.a},{r:n(AA.r,0,255),g:n(AA.g,0,255),b:n(AA.b,0,255),a:n(AA.a)}},l=function(nA){var eA=u(nA.r),AA=u(nA.g),tA=u(nA.b);return(function(iA){return{x:n(iA.x,0,o$1),y:n(iA.y,0,e),z:n(iA.z,0,c),a:n(iA.a)}})((function(iA){return{x:1.0478112*iA.x+.0228866*iA.y+-.050127*iA.z,y:.0295424*iA.x+.9904844*iA.y+-.0170491*iA.z,z:-.0092345*iA.x+.0150436*iA.y+.7521316*iA.z,a:iA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:nA.a}))},f=216/24389,b=24389/27,d=function(nA){return{l:n(nA.l,0,100),c:nA.c,h:(eA=nA.h,(eA=isFinite(eA)?eA%360:0)>0?eA:eA+360),a:nA.a};var eA},p=function(nA){return{l:a(nA.l,2),c:a(nA.c,2),h:a(nA.h,2),a:a(nA.a,3)}},v=function(nA){var eA=nA.l,AA=nA.c,tA=nA.h,iA=nA.a,rA=iA===void 0?1:iA;if(!t$1(eA)||!t$1(AA)||!t$1(tA))return null;var aA=d({l:Number(eA),c:Number(AA),h:Number(tA),a:Number(rA)});return M(aA)},y=function(nA){var eA=(function(rA){var aA=l(rA),oA=aA.x/o$1,sA=aA.y/e,lA=aA.z/c;return oA=oA>f?Math.cbrt(oA):(b*oA+16)/116,{l:116*(sA=sA>f?Math.cbrt(sA):(b*sA+16)/116)-16,a:500*(oA-sA),b:200*(sA-(lA=lA>f?Math.cbrt(lA):(b*lA+16)/116)),alpha:aA.a}})(nA),AA=a(eA.a,3),tA=a(eA.b,3),iA=Math.atan2(tA,AA)/Math.PI*180;return{l:eA.l,c:Math.sqrt(AA*AA+tA*tA),h:iA<0?iA+360:iA,a:eA.alpha}},M=function(nA){return eA={l:nA.l,a:nA.c*Math.cos(nA.h*Math.PI/180),b:nA.c*Math.sin(nA.h*Math.PI/180),alpha:nA.a},tA=eA.a/500+(AA=(eA.l+16)/116),iA=AA-eA.b/200,i({x:(Math.pow(tA,3)>f?Math.pow(tA,3):(116*tA-16)/b)*o$1,y:(eA.l>8?Math.pow((eA.l+16)/116,3):eA.l/b)*e,z:(Math.pow(iA,3)>f?Math.pow(iA,3):(116*iA-16)/b)*c,a:eA.alpha});var eA,AA,tA,iA},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(nA){var eA=x.exec(nA);if(!eA)return null;var AA,tA,iA=d({l:Number(eA[1]),c:Number(eA[2]),h:(AA=eA[3],tA=eA[4],tA===void 0&&(tA="deg"),Number(AA)*(r[tA]||1)),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return M(iA)};function lchPlugin(nA,eA){nA.prototype.toLch=function(){return p(y(this.rgba))},nA.prototype.toLchString=function(){return AA=p(y(this.rgba)),tA=AA.l,iA=AA.c,rA=AA.h,(aA=AA.a)<1?"lch("+tA+"% "+iA+" "+rA+" / "+aA+")":"lch("+tA+"% "+iA+" "+rA+")";var AA,tA,iA,rA,aA},eA.string.push([s,"lch"]),eA.object.push([v,"lch"])}k([labPlugin,lchPlugin]);const canonicalColorHexByKey={black:"#000000",white:"#ffffff",gray:"#808080",red:"#ff0000",orange:"#ffa500",yellow:"#ffff00",green:"#008000",cyan:"#00ffff",blue:"#0000ff",purple:"#800080",pink:"#ffc0cb",brown:"#a52a2a"},canonicalAnchorDefinitions=Object.fromEntries(Object.entries(canonicalColorHexByKey).map(([nA,eA])=>[nA,{hex:eA,canonical:nA}])),extraAnchorDefinitions={silver:{hex:"#c0c0c0",canonical:"gray"},grayDark:{hex:"#4d4d4d",canonical:"gray"},grayCustom:{hex:"#757575",canonical:"gray"},grayLight:{hex:"#c8c8c8",canonical:"gray"},grayLighter:{hex:"#dcdcdc",canonical:"gray"},maroon:{hex:"#800000",canonical:"red"},redLight:{hex:"#f08080",canonical:"red"},redCustom:{hex:"#D4042D",canonical:"red"},redDark:{hex:"#8b0000",canonical:"red"},crimson:{hex:"#dc143c",canonical:"red"},wine:{hex:"#993355",canonical:"red"},orangeLight:{hex:"#ffa07a",canonical:"orange"},orangeCustom:{hex:"#F19143",canonical:"orange"},orangePresetAccessible:{hex:"#a6510c",canonical:"orange"},orangeDark:{hex:"#ff8c00",canonical:"orange"},yellowLight:{hex:"#ffffe0",canonical:"yellow"},yellowDark:{hex:"#bdb76b",canonical:"yellow"},yellowgreen:{hex:"#9acd32",canonical:"green"},olive:{hex:"#808000",canonical:"green"},lime:{hex:"#00ff00",canonical:"green"},greenLight:{hex:"#90ee90",canonical:"green"},greenCustom:{hex:"#2ca02c",canonical:"green"},greenDark:{hex:"#006400",canonical:"green"},teal:{hex:"#008080",canonical:"green"},aqua:{hex:"#00ffff",canonical:"cyan"},cyanLight:{hex:"#e0ffff",canonical:"cyan"},cyanMid:{hex:"#25b0c0",canonical:"cyan"},cyanDark:{hex:"#008b8b",canonical:"cyan"},navy:{hex:"#000080",canonical:"blue"},blueMid:{hex:"#4477aa",canonical:"blue"},blueSky:{hex:"#56b4e9",canonical:"blue"},blueCustom:{hex:"#648FFF",canonical:"blue"},bluePresetAccessible:{hex:"#1f5dff",canonical:"blue"},blueLight:{hex:"#add8e6",canonical:"blue"},blueDark:{hex:"#00008b",canonical:"blue"},fuchsia:{hex:"#ff00ff",canonical:"purple"},purpleCustom:{hex:"#644CD6",canonical:"purple"},purpleMuted:{hex:"#9c5686",canonical:"purple"},purpleLight:{hex:"#dda0dd",canonical:"purple"},purpleDark:{hex:"#8b008b",canonical:"purple"},hotpink:{hex:"#ff69b4",canonical:"pink"},pinkDark:{hex:"#ff1493",canonical:"pink"},brownLight:{hex:"#deb887",canonical:"brown"},brownDark:{hex:"#8b4513",canonical:"brown"}},anchorDefinitions={...canonicalAnchorDefinitions,...extraAnchorDefinitions};Object.values(anchorDefinitions).map(nA=>({color:w$1(nA.hex),canonical:nA.canonical})),[...Object.keys(colorName)];const DEFAULT_STYLE_VALUES={lineOpacity:.7,lineWidth:4,lineWidthWord:"thick",lineStyle:"solid",lineStyleWord:"",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,markerFilled:!0,fillOpacity:.3,fillPatternOpacity:1,fillStyle:"solid",fillStyleWord:"",lineColor:"#1f5dff",lineColorDarkMode:"#648FFF",markerColor:"#1f5dff",markerColorDarkMode:"#648FFF",fillColor:"#1f5dff",fillColorDarkMode:"#648FFF",textColor:"black",textColorDarkMode:"white",highContrastColor:"#2963FF",highContrastColorDarkMode:"#92B4FF"},defaultPalette={name:"default",description:"The standard Doenet styles: blue, red, orange, purple, black, and gray.",styles:{1:{...DEFAULT_STYLE_VALUES},2:{lineColor:"#D4042D",lineColorDarkMode:"#F1466A",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#D4042D",markerColorDarkMode:"#F1466A",markerOpacity:.7,markerStyle:"square",markerStyleWord:"square",markerSize:5,fillColor:"#D4042D",fillColorDarkMode:"#F1466A",fillOpacity:.3,textColor:"#D4042D",textColorDarkMode:"#FF7A7A",highContrastColor:"#D4042D",highContrastColorDarkMode:"#FF7A7A"},3:{lineColor:"#a6510c",lineColorDarkMode:"#F19143",lineOpacity:.7,lineWidth:3,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#a6510c",markerColorDarkMode:"#F19143",markerOpacity:.7,markerStyle:"triangle",markerStyleWord:"triangle",markerSize:5,fillColor:"#a6510c",fillColorDarkMode:"#F19143",fillOpacity:.3,textColor:"#BE5A0E",textColorDarkMode:"#FFA94D",highContrastColor:"#BE5A0E",highContrastColorDarkMode:"#FFA94D"},4:{lineColor:"#644CD6",lineColorDarkMode:"#9F8FE8",lineColorWordDarkMode:"purple",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#644CD6",markerColorDarkMode:"#9F8FE8",markerColorWordDarkMode:"purple",markerOpacity:.7,markerStyle:"diamond",markerStyleWord:"diamond",markerSize:5,fillColor:"#644CD6",fillColorDarkMode:"#9F8FE8",fillColorWordDarkMode:"purple",fillOpacity:.3,textColor:"#644CD6",textColorDarkMode:"#B0A4EE",highContrastColor:"#644CD6",highContrastColorDarkMode:"#B0A4EE"},5:{lineColor:"black",lineColorDarkMode:"white",lineOpacity:1,lineWidth:1,lineWidthWord:"thin",lineStyle:"solid",lineStyleWord:"",markerColor:"black",markerColorDarkMode:"white",markerOpacity:1,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"black",fillColorDarkMode:"white",fillOpacity:.7,textColor:"black",textColorDarkMode:"white",highContrastColor:"black",highContrastColorDarkMode:"white"},6:{lineColor:"#636363",lineColorDarkMode:"#CCCCCC",lineOpacity:.7,lineWidth:1,lineWidthWord:"thin",lineStyle:"dotted",lineStyleWord:"dotted",markerColor:"#636363",markerColorDarkMode:"#CCCCCC",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"#636363",fillColorDarkMode:"#CCCCCC",fillOpacity:.3,textColor:"#757575",textColorDarkMode:"#B0B0B0",highContrastColor:"#757575",highContrastColorDarkMode:"#B0B0B0"}}},okabeItoPalette={name:"okabeIto",description:"Colorblind-friendly blues, oranges, greens, and purples adapted from the Okabe-Ito palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#0072b2",markerColor:"#0072b2",fillColor:"#0072b2",highContrastColor:"#0072b2",lineColorDarkMode:"#0072b2",markerColorDarkMode:"#0072b2",fillColorDarkMode:"#0072b2",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#c15400",markerColor:"#c15400",fillColor:"#c15400",textColor:"#c15400",highContrastColor:"#c15400",lineColorDarkMode:"#d55e00",markerColorDarkMode:"#d55e00",fillColorDarkMode:"#d55e00",textColorDarkMode:"#d55e00",lineWidth:2,markerStyle:"square"},3:{lineColor:"#009e73",markerColor:"#009e73",fillColor:"#009e73",textColor:"#008561",highContrastColor:"#008561",lineColorDarkMode:"#009e73",markerColorDarkMode:"#009e73",fillColorDarkMode:"#009e73",textColorDarkMode:"#009e73",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#cc79a7",markerColor:"#cc79a7",fillColor:"#cc79a7",textColor:"#a35f85",highContrastColor:"#a35f85",lineColorWord:"purple",markerColorWord:"purple",fillColorWord:"purple",lineColorDarkMode:"#cc79a7",markerColorDarkMode:"#cc79a7",fillColorDarkMode:"#cc79a7",textColorDarkMode:"#cc79a7",lineColorWordDarkMode:"purple",markerColorWordDarkMode:"purple",fillColorWordDarkMode:"purple",textColorWordDarkMode:"purple",highContrastColorWordDarkMode:"purple",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#5a5513",markerColor:"#5a5513",fillColor:"#5a5513",textColor:"#5a5513",highContrastColor:"#5a5513",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#f0e442",markerColorDarkMode:"#f0e442",fillColorDarkMode:"#f0e442",textColorDarkMode:"#f0e442",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#499bca",markerColor:"#499bca",fillColor:"#499bca",textColor:"#397ba1",highContrastColor:"#397ba1",lineColorWord:"skyblue",markerColorWord:"skyblue",fillColorWord:"skyblue",textColorWord:"skyblue",highContrastColorWord:"skyblue",lineColorDarkMode:"#56b4e9",markerColorDarkMode:"#56b4e9",fillColorDarkMode:"#56b4e9",textColorDarkMode:"#56b4e9",lineColorWordDarkMode:"skyblue",markerColorWordDarkMode:"skyblue",fillColorWordDarkMode:"skyblue",textColorWordDarkMode:"skyblue",highContrastColorWordDarkMode:"skyblue",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#c58700",markerColor:"#c58700",fillColor:"#c58700",textColor:"#9d6b00",highContrastColor:"#9d6b00",lineColorWord:"goldenrod",markerColorWord:"goldenrod",fillColorWord:"goldenrod",textColorWord:"goldenrod",highContrastColorWord:"goldenrod",lineColorDarkMode:"#e69f00",markerColorDarkMode:"#e69f00",fillColorDarkMode:"#e69f00",textColorDarkMode:"#e69f00",lineColorWordDarkMode:"goldenrod",markerColorWordDarkMode:"goldenrod",fillColorWordDarkMode:"goldenrod",textColorWordDarkMode:"goldenrod",highContrastColorWordDarkMode:"goldenrod",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"}}},tolBrightPalette={name:"tolBright",description:"Colorblind-friendly bright blues, reds, greens, and purples from Paul Tol's bright palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#4477aa",markerColor:"#4477aa",fillColor:"#4477aa",highContrastColor:"#4477aa",lineColorDarkMode:"#4477aa",markerColorDarkMode:"#4477aa",fillColorDarkMode:"#4477aa",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#ee6677",markerColor:"#ee6677",fillColor:"#ee6677",textColor:"#bf515e",highContrastColor:"#bf515e",lineColorDarkMode:"#ee6677",markerColorDarkMode:"#ee6677",fillColorDarkMode:"#ee6677",textColorDarkMode:"#ee6677",lineWidth:2,markerStyle:"square"},3:{lineColor:"#228833",markerColor:"#228833",fillColor:"#228833",textColor:"#228833",highContrastColor:"#228833",lineColorDarkMode:"#228833",markerColorDarkMode:"#228833",fillColorDarkMode:"#228833",textColorDarkMode:"#3d8e47",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#a29534",markerColor:"#a29534",fillColor:"#a29534",textColor:"#817628",highContrastColor:"#817628",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#ccbb44",markerColorDarkMode:"#ccbb44",fillColorDarkMode:"#ccbb44",textColorDarkMode:"#ccbb44",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#4d9db8",markerColor:"#4d9db8",fillColor:"#4d9db8",textColor:"#3c7d94",highContrastColor:"#3c7d94",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#66ccee",markerColorDarkMode:"#66ccee",fillColorDarkMode:"#66ccee",textColorDarkMode:"#66ccee",lineColorWordDarkMode:"cyan",markerColorWordDarkMode:"cyan",fillColorWordDarkMode:"cyan",textColorWordDarkMode:"cyan",highContrastColorWordDarkMode:"cyan",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#aa3377",markerColor:"#aa3377",fillColor:"#aa3377",textColor:"#aa3377",highContrastColor:"#aa3377",lineColorDarkMode:"#aa3377",markerColorDarkMode:"#aa3377",fillColorDarkMode:"#aa3377",textColorDarkMode:"#b5648c",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#bbbbbb",markerColorDarkMode:"#bbbbbb",fillColorDarkMode:"#bbbbbb",textColorDarkMode:"#bbbbbb",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"}}},tolMutedPalette={name:"tolMuted",description:"Nine colorblind-friendly muted styles from Paul Tol's muted palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#332288",markerColor:"#332288",fillColor:"#332288",highContrastColor:"#332288",lineColorWord:"indigo",markerColorWord:"indigo",fillColorWord:"indigo",highContrastColorWord:"indigo",lineColorDarkMode:"#8a86e8",markerColorDarkMode:"#8a86e8",fillColorDarkMode:"#8a86e8",lineColorWordDarkMode:"indigo",markerColorWordDarkMode:"indigo",fillColorWordDarkMode:"indigo",highContrastColorWordDarkMode:"indigo",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#669ab5",markerColor:"#669ab5",fillColor:"#669ab5",textColor:"#507a90",highContrastColor:"#507a90",lineColorDarkMode:"#88ccee",markerColorDarkMode:"#88ccee",fillColorDarkMode:"#88ccee",textColorDarkMode:"#88ccee",lineWidth:2,markerStyle:"square"},3:{lineColor:"#41a393",markerColor:"#41a393",fillColor:"#41a393",textColor:"#328175",highContrastColor:"#328175",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#44aa99",markerColorDarkMode:"#44aa99",fillColorDarkMode:"#44aa99",textColorDarkMode:"#44aa99",lineColorWordDarkMode:"teal",markerColorWordDarkMode:"teal",fillColorWordDarkMode:"teal",textColorWordDarkMode:"teal",highContrastColorWordDarkMode:"teal",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#117733",markerColor:"#117733",fillColor:"#117733",textColor:"#117733",highContrastColor:"#117733",lineColorDarkMode:"#117733",markerColorDarkMode:"#117733",fillColorDarkMode:"#117733",textColorDarkMode:"#548a5f",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#989833",markerColor:"#989833",fillColor:"#989833",textColor:"#787827",highContrastColor:"#787827",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#999933",markerColorDarkMode:"#999933",fillColorDarkMode:"#999933",textColorDarkMode:"#999933",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#867c46",markerColor:"#867c46",fillColor:"#867c46",textColor:"#7f7542",highContrastColor:"#7f7542",lineColorWord:"tan",markerColorWord:"tan",fillColorWord:"tan",textColorWord:"tan",highContrastColorWord:"tan",lineColorDarkMode:"#ddcc77",markerColorDarkMode:"#ddcc77",fillColorDarkMode:"#ddcc77",textColorDarkMode:"#ddcc77",lineColorWordDarkMode:"tan",markerColorWordDarkMode:"tan",fillColorWordDarkMode:"tan",textColorWordDarkMode:"tan",highContrastColorWordDarkMode:"tan",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#cc6677",markerColor:"#cc6677",fillColor:"#cc6677",textColor:"#b35968",highContrastColor:"#b35968",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#cc6677",markerColorDarkMode:"#cc6677",fillColorDarkMode:"#cc6677",textColorDarkMode:"#cc6677",lineColorWordDarkMode:"pink",markerColorWordDarkMode:"pink",fillColorWordDarkMode:"pink",textColorWordDarkMode:"pink",highContrastColorWordDarkMode:"pink",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#882255",markerColor:"#882255",fillColor:"#882255",textColor:"#882255",highContrastColor:"#882255",lineColorWord:"maroon",markerColorWord:"maroon",fillColorWord:"maroon",textColorWord:"maroon",highContrastColorWord:"maroon",lineColorDarkMode:"#924b69",markerColorDarkMode:"#924b69",fillColorDarkMode:"#924b69",textColorDarkMode:"#a17083",lineColorWordDarkMode:"maroon",markerColorWordDarkMode:"maroon",fillColorWordDarkMode:"maroon",textColorWordDarkMode:"maroon",highContrastColorWordDarkMode:"maroon",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#aa4499",markerColor:"#aa4499",fillColor:"#aa4499",textColor:"#aa4499",highContrastColor:"#aa4499",lineColorDarkMode:"#aa4499",markerColorDarkMode:"#aa4499",fillColorDarkMode:"#aa4499",textColorDarkMode:"#b262a3",lineWidth:2,lineStyle:"dashed",markerStyle:"square"}}},tolHighContrastPalette={name:"tolHighContrast",description:"Four maximum-distinction styles from Paul Tol's high-contrast palette, distinguishable even in grayscale.",styles:{1:{lineColor:"#004488",markerColor:"#004488",fillColor:"#004488",highContrastColor:"#004488",lineColorDarkMode:"#496194",markerColorDarkMode:"#496194",fillColorDarkMode:"#496194",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#b88d29",markerColor:"#b88d29",fillColor:"#b88d29",textColor:"#92701f",highContrastColor:"#92701f",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ddaa33",markerColorDarkMode:"#ddaa33",fillColorDarkMode:"#ddaa33",textColorDarkMode:"#ddaa33",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"square"},3:{lineColor:"#bb5566",markerColor:"#bb5566",fillColor:"#bb5566",textColor:"#bb5566",highContrastColor:"#bb5566",lineColorDarkMode:"#c06976",markerColorDarkMode:"#c06976",fillColorDarkMode:"#c06976",textColorDarkMode:"#c06976",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"diamond"}}},ibmPalette={name:"ibm",description:"Five colorblind-friendly styles from the IBM Design Library accessible palette, with varied marker shapes.",styles:{1:{lineColor:"#648fff",markerColor:"#648fff",fillColor:"#648fff",highContrastColor:"#4f71cb",lineColorDarkMode:"#648fff",markerColorDarkMode:"#648fff",fillColorDarkMode:"#648fff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#6a53d5",markerColor:"#6a53d5",fillColor:"#6a53d5",textColor:"#6a53d5",highContrastColor:"#6a53d5",lineColorDarkMode:"#785ef0",markerColorDarkMode:"#785ef0",fillColorDarkMode:"#785ef0",textColorDarkMode:"#7f69f0",lineWidth:2,markerStyle:"square"},3:{lineColor:"#dc267f",markerColor:"#dc267f",fillColor:"#dc267f",textColor:"#dc267f",highContrastColor:"#dc267f",lineColorWord:"magenta",markerColorWord:"magenta",fillColorWord:"magenta",textColorWord:"magenta",highContrastColorWord:"magenta",lineColorDarkMode:"#dc267f",markerColorDarkMode:"#dc267f",fillColorDarkMode:"#dc267f",textColorDarkMode:"#dd4186",lineColorWordDarkMode:"magenta",markerColorWordDarkMode:"magenta",fillColorWordDarkMode:"magenta",textColorWordDarkMode:"magenta",highContrastColorWordDarkMode:"magenta",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#fe6100",markerColor:"#fe6100",fillColor:"#fe6100",textColor:"#cb4b00",highContrastColor:"#cb4b00",lineColorDarkMode:"#fe6100",markerColorDarkMode:"#fe6100",fillColorDarkMode:"#fe6100",textColorDarkMode:"#fe6100",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#865a00",markerColor:"#865a00",fillColor:"#865a00",textColor:"#865a00",highContrastColor:"#865a00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffb000",markerColorDarkMode:"#ffb000",fillColorDarkMode:"#ffb000",textColorDarkMode:"#ffb000",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"triangleDown"}}},grayscalePalette={name:"grayscale",description:"Four grays with maximum luminance separation, for readers who distinguish styles by lightness alone.",styles:{1:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",highContrastColorDarkMode:"#ffffff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#323232",markerColor:"#323232",fillColor:"#323232",textColor:"#323232",highContrastColor:"#323232",lineColorWord:"dark gray",markerColorWord:"dark gray",fillColorWord:"dark gray",textColorWord:"dark gray",highContrastColorWord:"dark gray",lineColorDarkMode:"#c7c7c7",markerColorDarkMode:"#c7c7c7",fillColorDarkMode:"#c7c7c7",textColorDarkMode:"#c7c7c7",highContrastColorDarkMode:"#c7c7c7",lineColorWordDarkMode:"light gray",markerColorWordDarkMode:"light gray",fillColorWordDarkMode:"light gray",textColorWordDarkMode:"light gray",highContrastColorWordDarkMode:"light gray",lineWidth:2,markerStyle:"square"},3:{lineColor:"#616161",markerColor:"#616161",fillColor:"#616161",textColor:"#616161",highContrastColor:"#616161",lineColorDarkMode:"#929292",markerColorDarkMode:"#929292",fillColorDarkMode:"#929292",textColorDarkMode:"#929292",highContrastColorDarkMode:"#929292",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#767676",highContrastColor:"#767676",lineColorWord:"light gray",markerColorWord:"light gray",fillColorWord:"light gray",textColorWord:"light gray",highContrastColorWord:"light gray",lineColorDarkMode:"#626262",markerColorDarkMode:"#626262",fillColorDarkMode:"#626262",textColorDarkMode:"#7d7d7d",highContrastColorDarkMode:"#7d7d7d",lineColorWordDarkMode:"dark gray",markerColorWordDarkMode:"dark gray",fillColorWordDarkMode:"dark gray",textColorWordDarkMode:"dark gray",highContrastColorWordDarkMode:"dark gray",lineWidth:2,markerStyle:"diamond"}}},categoricalPalette={name:"categorical",description:"Ten maximally varied hues adapted from the Category10 sequence, for documents needing many obviously distinct styles.",styles:{1:{lineColor:"#1f77b4",markerColor:"#1f77b4",fillColor:"#1f77b4",highContrastColor:"#1f77b4",lineColorDarkMode:"#5ba3dd",markerColorDarkMode:"#5ba3dd",fillColorDarkMode:"#5ba3dd",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#e7730c",markerColor:"#e7730c",fillColor:"#e7730c",textColor:"#b95b07",highContrastColor:"#b95b07",lineColorDarkMode:"#ff9d3c",markerColorDarkMode:"#ff9d3c",fillColorDarkMode:"#ff9d3c",textColorDarkMode:"#ff9d3c",lineWidth:2,markerStyle:"square"},3:{lineColor:"#217a21",markerColor:"#217a21",fillColor:"#217a21",textColor:"#217a21",highContrastColor:"#217a21",lineColorDarkMode:"#2ca02c",markerColorDarkMode:"#2ca02c",fillColorDarkMode:"#2ca02c",textColorDarkMode:"#2ca02c",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#d62728",markerColor:"#d62728",fillColor:"#d62728",textColor:"#d62728",highContrastColor:"#d62728",lineColorDarkMode:"#e2494a",markerColorDarkMode:"#e2494a",fillColorDarkMode:"#e2494a",textColorDarkMode:"#e2494a",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#9467bd",markerColor:"#9467bd",fillColor:"#9467bd",textColor:"#8e62b5",highContrastColor:"#8e62b5",lineColorDarkMode:"#b48fd6",markerColorDarkMode:"#b48fd6",fillColorDarkMode:"#b48fd6",textColorDarkMode:"#b48fd6",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#7a4a41",markerColor:"#7a4a41",fillColor:"#7a4a41",textColor:"#7a4a41",highContrastColor:"#7a4a41",lineColorDarkMode:"#a9705f",markerColorDarkMode:"#a9705f",fillColorDarkMode:"#a9705f",textColorDarkMode:"#a9705f",lineColorWordDarkMode:"brown",markerColorWordDarkMode:"brown",fillColorWordDarkMode:"brown",textColorWordDarkMode:"brown",highContrastColorWordDarkMode:"brown",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#d670b7",markerColor:"#d670b7",fillColor:"#d670b7",textColor:"#ab5892",highContrastColor:"#ab5892",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#e377c2",markerColorDarkMode:"#e377c2",fillColorDarkMode:"#e377c2",textColorDarkMode:"#e377c2",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#7f7f7f",markerColor:"#7f7f7f",fillColor:"#7f7f7f",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#a8a8a8",markerColorDarkMode:"#a8a8a8",fillColorDarkMode:"#a8a8a8",textColorDarkMode:"#a8a8a8",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#6e6e12",markerColor:"#6e6e12",fillColor:"#6e6e12",textColor:"#6e6e12",highContrastColor:"#6e6e12",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#bcbd22",markerColorDarkMode:"#bcbd22",fillColorDarkMode:"#bcbd22",textColorDarkMode:"#bcbd22",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,lineStyle:"dashed",markerStyle:"square"},10:{lineColor:"#12a2b1",markerColor:"#12a2b1",fillColor:"#12a2b1",textColor:"#0c818e",highContrastColor:"#0c818e",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#17becf",markerColorDarkMode:"#17becf",fillColorDarkMode:"#17becf",textColorDarkMode:"#17becf",lineWidth:2,lineStyle:"dotted",markerStyle:"diamond"}}},grumpyNarwhalPalette={name:"grumpyNarwhal",description:"Six saturated hues — burnt orange, forest green, deep pink, arctic teal, gold, and purple — going neon in dark mode.",styles:{1:{lineColor:"#b34700",markerColor:"#b34700",fillColor:"#b34700",highContrastColor:"#b34700",lineColorDarkMode:"#ff5f00",markerColorDarkMode:"#ff5f00",fillColorDarkMode:"#ff5f00",lineColorWordDarkMode:"orange",markerColorWordDarkMode:"orange",fillColorWordDarkMode:"orange",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#1b7a1b",markerColor:"#1b7a1b",fillColor:"#1b7a1b",textColor:"#1b7a1b",highContrastColor:"#1b7a1b",lineColorDarkMode:"#39ff14",markerColorDarkMode:"#39ff14",fillColorDarkMode:"#39ff14",textColorDarkMode:"#39ff14",lineWidth:2,markerStyle:"square"},3:{lineColor:"#c20e67",markerColor:"#c20e67",fillColor:"#c20e67",textColor:"#c20e67",highContrastColor:"#c20e67",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#ff1493",markerColorDarkMode:"#ff1493",fillColorDarkMode:"#ff1493",textColorDarkMode:"#ff1493",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#007a8c",markerColor:"#007a8c",fillColor:"#007a8c",textColor:"#007a8c",highContrastColor:"#007a8c",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#00e5ff",markerColorDarkMode:"#00e5ff",fillColorDarkMode:"#00e5ff",textColorDarkMode:"#00e5ff",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#8a6d00",markerColor:"#8a6d00",fillColor:"#8a6d00",textColor:"#8a6d00",highContrastColor:"#8a6d00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffea00",markerColorDarkMode:"#ffea00",fillColorDarkMode:"#ffea00",textColorDarkMode:"#ffea00",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#b026ff",markerColor:"#b026ff",fillColor:"#b026ff",textColor:"#b026ff",highContrastColor:"#b026ff",lineColorDarkMode:"#b026ff",markerColorDarkMode:"#b026ff",fillColorDarkMode:"#b026ff",textColorDarkMode:"#b445ff",highContrastColorDarkMode:"#b445ff",lineWidth:2,markerStyle:"triangleLeft"}}};function deepFreezePalette(nA){for(const eA of Object.values(nA.styles)){for(const AA of Object.values(eA))typeof AA=="object"&&AA!==null&&Object.freeze(AA);Object.freeze(eA)}return Object.freeze(nA.styles),Object.freeze(nA)}function registerByKey(nA){return[nA.name.toLowerCase(),deepFreezePalette(nA)]}const STYLE_PALETTES=Object.assign(Object.create(null),Object.fromEntries([defaultPalette,okabeItoPalette,tolBrightPalette,tolMutedPalette,tolHighContrastPalette,ibmPalette,grayscalePalette,categoricalPalette,grumpyNarwhalPalette].map(registerByKey)));Object.freeze(STYLE_PALETTES),defaultPalette.name.toLowerCase(),Object.freeze(Object.keys(STYLE_PALETTES));var o=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},t=function(nA){return .2126*o(nA.r)+.7152*o(nA.g)+.0722*o(nA.b)};function a11yPlugin(nA){nA.prototype.luminance=function(){return eA=t(this.rgba),(AA=2)===void 0&&(AA=0),tA===void 0&&(tA=Math.pow(10,AA)),Math.round(tA*eA)/tA+0;var eA,AA,tA},nA.prototype.contrast=function(eA){eA===void 0&&(eA="#FFF");var AA,tA,iA,rA,aA,oA,sA,lA=eA instanceof nA?eA:new nA(eA);return rA=this.rgba,aA=lA.toRgb(),oA=t(rA),sA=t(aA),AA=oA>sA?(oA+.05)/(sA+.05):(sA+.05)/(oA+.05),(tA=2)===void 0&&(tA=0),iA===void 0&&(iA=Math.pow(10,tA)),Math.floor(iA*AA)/iA+0},nA.prototype.isReadable=function(eA,AA){return eA===void 0&&(eA="#FFF"),AA===void 0&&(AA={}),this.contrast(eA)>=(oA=(aA=(tA=AA).size)===void 0?"normal":aA,(rA=(iA=tA.level)===void 0?"AA":iA)==="AAA"&&oA==="normal"?7:rA==="AA"&&oA==="large"?3:4.5);var tA,iA,rA,aA,oA}}function namesPlugin(nA,eA){var AA={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},tA={};for(var iA in AA)tA[AA[iA]]=iA;var rA={};nA.prototype.toName=function(aA){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var oA,sA,lA=tA[this.toHex()];if(lA)return lA;if(aA?.closest){var gA=this.toRgb(),cA=1/0,IA="black";if(!rA.length)for(var uA in AA)rA[uA]=new nA(AA[uA]).toRgb();for(var CA in AA){var dA=(oA=gA,sA=rA[CA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));dA<cA&&(cA=dA,IA=CA)}return IA}},eA.string.push([function(aA){var oA=aA.toLowerCase(),sA=oA==="transparent"?"#0000":AA[oA];return sA?new nA(sA).toRgb():null},"name"])}k([a11yPlugin,namesPlugin]);let styleAttributes={lineColor:{componentType:"text",description:"Color used for line strokes (light mode)."},lineColorWord:{componentType:"text",description:"Human-readable name of the line color (light mode)."},lineColorDarkMode:{componentType:"text",description:"Color used for line strokes (dark mode)."},lineColorWordDarkMode:{componentType:"text",description:"Human-readable name of the line color (dark mode)."},lineOpacity:{componentType:"number",description:"Opacity of line strokes, 0 to 1."},lineWidth:{componentType:"number",description:"Stroke width for lines, in pixels."},lineWidthWord:{componentType:"text",description:"Human-readable name of the line width."},lineStyle:{componentType:"text",description:"Stroke style for lines.",toLowerCase:!0,validValues:[{value:"solid",description:"Continuous, unbroken stroke."},{value:"dashed",description:"Stroke composed of evenly-spaced dashes."},{value:"dotted",description:"Stroke composed of evenly-spaced dots."}]},lineStyleWord:{componentType:"text",description:"Human-readable name of the line style."},markerColor:{componentType:"text",description:"Color used for markers/points (light mode)."},markerColorWord:{componentType:"text",description:"Human-readable name of the marker color (light mode)."},markerColorDarkMode:{componentType:"text",description:"Color used for markers/points (dark mode)."},markerColorWordDarkMode:{componentType:"text",description:"Human-readable name of the marker color (dark mode)."},markerOpacity:{componentType:"number",description:"Opacity of markers/points, 0 to 1."},markerStyle:{componentType:"text",description:"Marker shape.",toLowerCase:!0,validValues:[{value:"circle",description:"Circular marker."},{value:"square",description:"Square marker."},{value:"triangle",description:'Triangular marker pointing up (alias for "triangleUp").'},{value:"triangleUp",description:"Triangular marker pointing up."},{value:"triangleDown",description:"Triangular marker pointing down."},{value:"triangleLeft",description:"Triangular marker pointing left."},{value:"triangleRight",description:"Triangular marker pointing right."},{value:"diamond",description:"Diamond-shaped marker."},{value:"cross",description:"Cross-shaped marker (×)."},{value:"plus",description:"Plus-shaped marker (+)."}]},markerStyleWord:{componentType:"text",description:"Human-readable name of the marker style."},markerSize:{componentType:"number",description:"Marker size in pixels."},markerFilled:{componentType:"boolean",description:"Whether the marker is rendered filled (true) or open (false). Has no effect when markerStyle is cross or plus, which have no interior."},fillColor:{componentType:"text",description:"Fill color used inside closed shapes (light mode)."},fillColorWord:{componentType:"text",description:"Human-readable name of the fill color (light mode)."},fillColorDarkMode:{componentType:"text",description:"Fill color used inside closed shapes (dark mode)."},fillColorWordDarkMode:{componentType:"text",description:"Human-readable name of the fill color (dark mode)."},fillOpacity:{componentType:"number",description:"Opacity of solid fills, 0 to 1."},fillPatternOpacity:{componentType:"number",description:"Opacity of pattern fills (non-solid fillStyle), 0 to 1."},fillStyle:{componentType:"text",description:"Fill pattern used inside closed shapes.",toLowerCase:!0,validValues:[{value:"solid",description:"Solid fill."},{value:"horizontal",description:"Horizontal line pattern."},{value:"vertical",description:"Vertical line pattern."},{value:"diagonal",description:"Diagonal line pattern (/)."},{value:"backDiagonal",description:"Back-diagonal line pattern (\\)."},{value:"dots",description:"Dots pattern."},{value:"diamonds",description:"Filled diamonds pattern."}]},fillStyleWord:{componentType:"text",description:"Human-readable name of the fill style."},textColor:{componentType:"text",description:"Text color (light mode)."},textColorWord:{componentType:"text",description:"Human-readable name of the text color (light mode)."},textColorDarkMode:{componentType:"text",description:"Text color (dark mode)."},textColorWordDarkMode:{componentType:"text",description:"Human-readable name of the text color (dark mode)."},highContrastColor:{componentType:"text",description:"High-contrast accent color (light mode)."},highContrastColorWord:{componentType:"text",description:"Human-readable name of the high-contrast accent color (light mode)."},highContrastColorDarkMode:{componentType:"text",description:"High-contrast accent color (dark mode)."},highContrastColorWordDarkMode:{componentType:"text",description:"Human-readable name of the high-contrast accent color (dark mode)."},backgroundColor:{componentType:"text",description:"Background color (light mode)."},backgroundColorWord:{componentType:"text",description:"Human-readable name of the background color (light mode)."},backgroundColorDarkMode:{componentType:"text",description:"Background color (dark mode)."},backgroundColorWordDarkMode:{componentType:"text",description:"Human-readable name of the background color (dark mode)."}};styleAttributes.markerStyle.validValues.filter(nA=>nA.value!=="cross"&&nA.value!=="plus");const MARKER_OVERRIDE_KEYS=["markerStyle","markerSize","markerFilled"],LINE_OVERRIDE_KEYS=["lineStyle","lineWidth"],FILL_OVERRIDE_KEYS=["fillOpacity","fillPatternOpacity","fillStyle"],markerOverrideAttributes=Object.fromEntries(MARKER_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]])),lineOverrideAttributes=Object.fromEntries(LINE_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]])),fillOverrideAttributes=Object.fromEntries(FILL_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]]));({...markerOverrideAttributes,...lineOverrideAttributes,...fillOverrideAttributes});const STYLE_OVERRIDE_CATEGORIES={marker:markerOverrideAttributes,line:lineOverrideAttributes,fill:fillOverrideAttributes};for(const[nA,eA]of Object.entries(STYLE_OVERRIDE_CATEGORIES))for(const[AA,tA]of Object.entries(eA)){if(AA.toLowerCase().includes("color"))throw new Error(`Style override category "${nA}" contains color-related key "${AA}"; colors stay <styleDefinition>-only so per-styleNumber WCAG contrast diagnostics remain authoritative. If this is intentional, also reconcile the lowercase asymmetry in returnSelectedStyleStateVariableDefinition.`);if(AA.endsWith("Opacity")&&AA!=="fillOpacity"&&AA!=="fillPatternOpacity")throw new Error(`Style override category "${nA}" contains contrast-feeding opacity key "${AA}"; lineOpacity and markerOpacity feed the WCAG contrast diagnostic as an opacityMultiplier on the foreground alpha, so they stay <styleDefinition>-only alongside colors. Only fillOpacity and fillPatternOpacity are contrast-irrelevant and overridable.`);if(tA.componentType==="text"&&!tA.toLowerCase)throw new Error(`Style override key "${AA}" in category "${nA}" is text-typed but missing toLowerCase: true. Add toLowerCase: true to its styleAttributes entry, or move it out of the override surface.`)}Object.entries(styleAttributes).filter(([,nA])=>nA.toLowerCase).map(([nA])=>nA);var base32$1={exports:{}},hasRequiredBase32;function requireBase32(){return hasRequiredBase32||(hasRequiredBase32=1,(function(nA){(function(){var eA=typeof window=="object"?window:{},AA=!eA.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;AA&&(eA=commonjsGlobal);var tA=!eA.HI_BASE32_NO_COMMON_JS&&!0&&nA.exports,iA="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),rA={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},aA=[0,0,0,0,0,0,0,0],oA=function(pA,mA){mA.length>10&&(mA="..."+mA.substr(-10));var QA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw QA.position=pA,QA},sA=function(pA){for(var mA="",QA=pA.length,BA=0,hA=0,DA,EA;BA<QA;){if(DA=pA[BA++],DA<=127){mA+=String.fromCharCode(DA);continue}else DA>191&&DA<=223?(EA=DA&31,hA=1):DA<=239?(EA=DA&15,hA=2):DA<=247?(EA=DA&7,hA=3):oA(BA,mA);for(var fA=0;fA<hA;++fA)DA=pA[BA++],(DA<128||DA>191)&&oA(BA,mA),EA<<=6,EA+=DA&63;EA>=55296&&EA<=57343&&oA(BA,mA),EA>1114111&&oA(BA,mA),EA<=65535?mA+=String.fromCharCode(EA):(EA-=65536,mA+=String.fromCharCode((EA>>10)+55296),mA+=String.fromCharCode((EA&1023)+56320))}return mA},lA=function(pA){if(pA==="")return[];if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");pA=pA.replace(/=/g,"");for(var mA,QA,BA,hA,DA,EA,fA,NA,yA=[],bA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255,yA[bA++]=(fA<<5|NA)&255;var kA=wA-vA;return kA===2?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255):kA===4?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255):kA===5?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255):kA===7&&(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255),yA},gA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA++),DA=pA.charCodeAt(NA++),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31];var bA=fA-yA;return bA===1?(mA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):bA===2?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):bA===4&&(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"="),EA},cA=function(pA){var mA,QA,BA,hA,DA,EA,fA=!1,NA="",yA=0,bA,wA=0,MA=pA.length;if(pA==="")return NA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],bA=wA;yA<MA&&bA<5;++yA)EA=pA.charCodeAt(yA),EA<128?aA[bA++]=EA:EA<2048?(aA[bA++]=192|EA>>6,aA[bA++]=128|EA&63):EA<55296||EA>=57344?(aA[bA++]=224|EA>>12,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63):(EA=65536+((EA&1023)<<10|pA.charCodeAt(++yA)&1023),aA[bA++]=240|EA>>18,aA[bA++]=128|EA>>12&63,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63);wA=bA-5,yA===MA&&++yA,yA>MA&&bA<6&&(fA=!0),mA=aA[0],bA>4?(QA=aA[1],BA=aA[2],hA=aA[3],DA=aA[4],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31]):bA===1?NA+=iA[mA>>>3]+iA[mA<<2&31]+"======":bA===2?(QA=aA[1],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(QA=aA[1],BA=aA[2],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):(QA=aA[1],BA=aA[2],hA=aA[3],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"=")}while(!fA);return NA},IA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA++],DA=pA[NA++],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31];var bA=fA-yA;return bA===1?(mA=pA[NA],EA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):bA===2?(mA=pA[NA++],QA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(mA=pA[NA++],QA=pA[NA++],BA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):bA===4&&(mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"="),EA},uA=function(pA,mA){var QA=typeof pA!="string";return QA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),QA?IA(pA):mA?gA(pA):cA(pA)},CA=function(pA,mA){if(!mA)return sA(lA(pA));if(pA==="")return"";if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");var QA,BA,hA,DA,EA,fA,NA,yA,bA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)+String.fromCharCode((NA<<5|yA)&255);var kA=wA-vA;return kA===2?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)):kA===4?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)):kA===5?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)):kA===7&&(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)),bA},dA={encode:uA,decode:CA};CA.asBytes=lA,tA?nA.exports=dA:eA.base32=dA})()})(base32$1)),base32$1.exports}requireBase32();function groupCompositeRanges({children:nA,ranges:eA,isAbsent:AA=()=>!1,isBlank:tA=()=>!1,skipRange:iA=()=>!1,trimEnd:rA=lA=>lA,startInd:aA=0,endInd:oA=nA.length-1,removedInd:sA=null}){const lA=(eA??[]).flatMap(CA=>{const dA=shiftForRemovedChild(CA,sA);return dA&&dA.firstInd>=aA&&dA.lastInd<=oA?[{range:CA,...dA}]:[]}).sort((CA,dA)=>CA.firstInd-dA.firstInd||dA.lastInd-CA.lastInd),gA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},cA=[gA];function IA(CA,dA){for(;CA.nextInd<dA;CA.nextInd++){const pA=nA[CA.nextInd];AA(pA)||(CA.items.push({kind:"child",value:pA,index:CA.nextInd}),CA.eligibility&&CA.eligible.push(CA.eligibility[CA.nextInd-CA.firstInd]??!1))}}function uA(){const CA=cA.pop();if(IA(CA,CA.lastInd+1),CA.items.length===0)return;const dA=cA[cA.length-1],pA=CA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=CA.eligible.every((BA,hA)=>BA||isBlankGroup(CA.items[hA],tA)),QA=!!CA.range.asList&&mA&&pA.length>1;dA.items.push({kind:"composite",range:CA.range,asList:QA,items:QA?prepareListItems(CA.items,tA,rA):CA.items}),dA.eligibility&&dA.eligible.push(mA)}for(const{range:CA,firstInd:dA,lastInd:pA}of lA){for(;cA.length>1&&pA>cA[cA.length-1].lastInd;)uA();const mA=cA[cA.length-1];dA<mA.nextInd||(IA(mA,dA),mA.nextInd=pA+1,!iA(CA)&&cA.push({range:CA,firstInd:dA,lastInd:pA,nextInd:dA,eligibility:CA.potentialListComponents??null,items:[],eligible:[]}))}for(;cA.length>1;)uA();return IA(gA,oA+1),gA.items}function shiftForRemovedChild(nA,eA){let{firstInd:AA,lastInd:tA}=nA;if(eA===null)return{firstInd:AA,lastInd:tA};if(!(AA===eA||tA===eA))return AA>eA&&(AA-=1),tA>eA&&(tA-=1),{firstInd:AA,lastInd:tA}}function isBlankGroup(nA,eA){return nA.kind==="child"?eA(nA.value):nA.items.every(AA=>isBlankGroup(AA,eA))}function prepareListItems(nA,eA,AA){const tA=nA.findIndex(aA=>!isBlankGroup(aA,eA));let iA=nA.length-1;for(;iA>tA&&isBlankGroup(nA[iA],eA);)iA--;const rA=[];for(const[aA,oA]of nA.entries())aA<tA||aA>=iA?rA.push(oA):isBlankGroup(oA,eA)?oA.kind==="composite"&&rA.push(withoutBlankChildren(oA)):rA.push(trimItemEnd(oA,eA,AA));return rA}function withoutBlankChildren(nA){return{...nA,items:nA.items.flatMap(eA=>eA.kind==="composite"?[withoutBlankChildren(eA)]:[])}}function trimItemEnd(nA,eA,AA){if(nA.kind==="child"){const rA=AA(nA.value);return rA===nA.value?nA:{...nA,value:rA}}let tA=nA.items.length;for(;isBlankGroup(nA.items[tA-1],eA);)tA--;const iA=nA.items.slice(tA).flatMap(rA=>rA.kind==="composite"?[withoutBlankChildren(rA)]:[]);return{...nA,items:[...nA.items.slice(0,tA-1),trimItemEnd(nA.items[tA-1],eA,AA),...iA]}}const{gcd,lcm}=context.math,{mod}=context.math,defaultCreativeCommonsVersion="4.0";function creativeCommonsLicense(nA,eA,AA,tA){return{code:nA,name:`Creative Commons ${eA}`,description:tA,kind:"creative-commons",url:(iA=defaultCreativeCommonsVersion)=>`https://creativecommons.org/licenses/${AA}/${iA}/`}}function fixedUrlLicense(nA,eA,AA,tA,iA){return{code:nA,name:eA,description:tA,kind:iA,url:()=>AA}}const mediaLicenses=[creativeCommonsLicense("CC-BY","Attribution","by","Creative Commons Attribution: reuse with credit, including commercially."),creativeCommonsLicense("CC-BY-SA","Attribution-ShareAlike","by-sa","Creative Commons Attribution-ShareAlike: reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-ND","Attribution-NoDerivatives","by-nd","Creative Commons Attribution-NoDerivatives: reuse unchanged, with credit."),creativeCommonsLicense("CC-BY-NC","Attribution-NonCommercial","by-nc","Creative Commons Attribution-NonCommercial: reuse with credit for noncommercial purposes."),creativeCommonsLicense("CC-BY-NC-SA","Attribution-NonCommercial-ShareAlike","by-nc-sa","Creative Commons Attribution-NonCommercial-ShareAlike: noncommercial reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-NC-ND","Attribution-NonCommercial-NoDerivatives","by-nc-nd","Creative Commons Attribution-NonCommercial-NoDerivatives: reuse unchanged for noncommercial purposes, with credit."),fixedUrlLicense("CC0","CC0 1.0 Public Domain Dedication","https://creativecommons.org/publicdomain/zero/1.0/","Creative Commons Zero: the creator has dedicated the work to the public domain.","public-domain"),fixedUrlLicense("PDM","Public Domain Mark 1.0","https://creativecommons.org/publicdomain/mark/1.0/","Public Domain Mark: the work is free of known copyright restrictions.","public-domain"),fixedUrlLicense("GFDL","GNU Free Documentation License","https://www.gnu.org/licenses/fdl-1.3.html","GNU Free Documentation License: copyleft license common on Wikimedia.","license"),fixedUrlLicense("FAL","Free Art License 1.3","https://artlibre.org/licence/lal/en/","Free Art License: copyleft license for artistic works.","license"),fixedUrlLicense("OGL","Open Government Licence v3.0 (UK)","https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/","UK Open Government Licence: reuse government material with attribution.","license"),fixedUrlLicense("MIT","MIT License","https://opensource.org/license/mit","MIT License: permissive license common for icon and illustration sets.","license"),fixedUrlLicense("APACHE-2.0","Apache License 2.0","https://www.apache.org/licenses/LICENSE-2.0","Apache License 2.0: permissive license common for icon and illustration sets.","license")];Object.fromEntries(mediaLicenses.map(nA=>[nA.code.toLowerCase(),nA]));var cssesc_1,hasRequiredCssesc;function requireCssesc(){if(hasRequiredCssesc)return cssesc_1;hasRequiredCssesc=1;var nA={},eA=nA.hasOwnProperty,AA=function(sA,lA){if(!sA)return lA;var gA={};for(var cA in lA)gA[cA]=eA.call(sA,cA)?sA[cA]:lA[cA];return gA},tA=/[ -,\.\/:-@\[-\^`\{-~]/,iA=/[ -,\.\/:-@\[\]\^`\{-~]/,rA=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,aA=function oA(sA,lA){lA=AA(lA,oA.options),lA.quotes!="single"&&lA.quotes!="double"&&(lA.quotes="single");for(var gA=lA.quotes=="double"?'"':"'",cA=lA.isIdentifier,IA=sA.charAt(0),uA="",CA=0,dA=sA.length;CA<dA;){var pA=sA.charAt(CA++),mA=pA.charCodeAt(),QA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&CA<dA){var BA=sA.charCodeAt(CA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:CA--}QA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?QA="\\"+pA:QA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?QA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!cA&&(pA=='"'&&gA==pA||pA=="'"&&gA==pA)||cA&&iA.test(pA)?QA="\\"+pA:QA=pA;uA+=QA}return cA&&(/^-[-\d]/.test(uA)?uA="\\-"+uA.slice(1):/\d/.test(IA)&&(uA="\\3"+IA+" "+uA.slice(1))),uA=uA.replace(rA,function(hA,DA,EA){return DA&&DA.length%2?hA:(DA||"")+EA}),!cA&&lA.wrap?gA+uA+gA:uA};return aA.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},aA.version="3.0.0",cssesc_1=aA,cssesc_1}requireCssesc();function isBlankChild(nA){return typeof nA=="string"&&nA.trim()===""}function makeWrapperElement(nA,eA,AA){return{type:"element",name:eA,attributes:{},children:AA,data:{id:nA}}}function materializeGroups(nA,eA,AA){const tA=[];for(const iA of nA){if(iA.kind==="child"){iA.value!==null&&tA.push(iA.value);continue}if(iA.asList){const aA=iA.items.map(gA=>isBlankGroup(gA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=iA.items.slice(oA,sA+1).filter((gA,cA)=>!aA[oA+cA]);eA||tA.push(...materializeGroups(iA.items.slice(0,oA),!1,AA)),AA.push(makeWrapperElement(iA.range.compositeIdx,"asList",materializeGroups(lA,!0,AA))),tA.push({id:iA.range.compositeIdx,annotation:"original"}),eA||tA.push(...materializeGroups(iA.items.slice(sA+1),!1,AA));continue}const rA=materializeGroups(iA.items,!1,AA);eA&&rA.length>1?(AA.push(makeWrapperElement(iA.range.compositeIdx,"_fragment",rA)),tA.push({id:iA.range.compositeIdx,annotation:"original"})):tA.push(...rA)}return tA}function applyCompositeListWrapping(nA,eA){const AA=groupCompositeRanges({children:nA,ranges:eA,isAbsent:rA=>rA===null,isBlank:isBlankChild,trimEnd:rA=>typeof rA=="string"?rA.trimEnd():rA}),tA=[];return{children:materializeGroups(AA,!1,tA),wrapperElements:tA}}function propRename(nA,eA){for(const[AA,tA]of Object.entries(eA))nA.hasOwnProperty(AA)&&(nA[tA]=nA[AA],delete nA[AA])}function elementRename(nA,eA){nA.name=eA}function booleanInputJsToRust(nA){nA.immediateValue=nA.value}function pointJsToRust(nA){const eA=nA.numericalXs;nA.x={math_object:eA[0].toString()},eA.length>=2&&(nA.y={math_object:eA[1].toString()}),eA.length>=3&&(nA.z={math_object:eA[2].toString()}),nA.coordsLatex=nA.latex}function refJsToRust(nA,eA){nA.referent=eA[nA.targetRendererId]}function sectionJsToRust(nA,eA){nA.divisionType=eA.name,nA.divisionDepth=nA.level;const AA=nA.titleChildName!=null?Number(nA.titleChildName):void 0,tA=AA!==void 0&&Number.isInteger(AA);if(nA.xrefLabel={label:(tA?nA.titlePrefix:nA.title)??"",global_ident:nA.sectionNumber??"",local_ident:nA.sectionNumber??"",preferred_form:"Global"},nA.codeNumber="",tA){nA.title=AA;const iA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);iA!==-1&&eA.children.splice(iA,1)}else nA.title=null}function tableJsToRust(nA,eA){nA.xrefLabel={label:nA.tableName??"",global_ident:nA.tableEnumeration??"",local_ident:nA.tableEnumeration??"",preferred_form:"Global"},nA.codeNumber=nA.tableEnumeration??"",nA.titlePrefix=nA.suppressTableNameInTitle?"":nA.tableNamePrefix??"",nA.divisionType="table",nA.divisionDepth=3;const AA=nA.titleChildName!=null?Number(nA.titleChildName):void 0;if(AA!==void 0&&Number.isInteger(AA)){nA.title=AA;const iA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);iA!==-1&&eA.children.splice(iA,1)}else nA.title=null;delete nA.tableEnumeration,delete nA.titleChildName,delete nA.tableName,delete nA.tableNamePrefix}function textJsToRust(nA){nA.value=nA.text}function childInstructionToContent(nA,eA){return typeof nA=="string"?nA:(eA[nA.id]=nA.componentIdx,{id:nA.componentIdx,annotation:"original"})}function applyElementJsToRustFixups(nA,eA){if(!(nA?.type!=="element"||!nA.data.props))switch(nA.name){case"angle":propRename(nA.data.props,{latexForRenderer:"latex"});break;case"cell":propRename(nA.data.props,{inHeader:"header"});break;case"booleanInput":booleanInputJsToRust(nA.data.props);break;case"text":textJsToRust(nA.data.props);break;case"aside":case"article":case"section":sectionJsToRust(nA.data.props,nA),nA.name==="section"&&elementRename(nA,"division");break;case"table":tableJsToRust(nA.data.props,nA);break;case"point":pointJsToRust(nA.data.props);break;case"ref":refJsToRust(nA.data.props,eA);break;case"coords":elementRename(nA,"math");break}}function flatDastFromJS(nA,eA){const AA=eA[0].rendererStatesToUpdate,tA=[],iA={[nA.id]:nA.componentIdx};tA[nA.componentIdx]={type:"element",name:nA.componentType,attributes:{},children:[],data:{id:nA.componentIdx,action_names:Object.keys(nA.actions)}};for(const aA of AA){let oA=tA[aA.componentIdx];if(oA||(oA=tA[aA.componentIdx]={type:"element",name:"",attributes:{},children:[],data:{id:aA.componentIdx}}),oA.type==="element"&&(oA.data.props=aA.stateValues,aA.childrenInstructions)){const sA=[];for(const cA of aA.childrenInstructions){if(cA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(cA,iA)),typeof cA=="string")continue;const IA=tA[cA.componentIdx];IA?IA.type==="element"&&(IA.name=cA.componentType,IA.data.id=cA.componentIdx,IA.data.action_names=Object.keys(cA.actions)):tA[cA.componentIdx]={type:"element",name:cA.componentType,attributes:{},children:[],data:{id:cA.componentIdx,action_names:Object.keys(cA.actions)}}}const{children:lA,wrapperElements:gA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const cA of gA)tA[cA.data.id]=cA}}for(const aA of tA)applyElementJsToRustFixups(aA,iA);return{type:"root",children:[{id:nA.componentIdx,annotation:"original"}],elements:tA,warnings:[]}}function collectInstructionMaps(nA,eA={},AA={}){for(const tA of nA)for(const iA of tA.rendererStatesToUpdate)for(const rA of iA.childrenInstructions??[])rA!=null&&typeof rA!="string"&&(eA[rA.componentIdx]=rA.componentType,AA[rA.id]=rA.componentIdx);return{componentIdxToName:eA,doenetIdToComponentIdx:AA}}function seedInstructionMaps(nA,eA){const AA={[nA.componentIdx]:nA.componentType},tA={[nA.id]:nA.componentIdx};return collectInstructionMaps(eA,AA,tA),{componentIdxToName:AA,doenetIdToComponentIdx:tA}}function flatDastUpdateFromJS(nA,eA,AA={}){const tA={};function iA(rA,aA){const oA=tA[rA];oA?(oA.changedState={...oA.changedState,...aA.changedState},aA.newChildren&&(oA.newChildren=aA.newChildren),aA.newFlatDastElement&&(oA.newFlatDastElement=aA.newFlatDastElement)):tA[rA]=aA}for(const rA of nA)for(const aA of rA.rendererStatesToUpdate){const{componentIdx:oA,stateValues:sA,childrenInstructions:lA}=aA,gA=[];if(lA)for(const dA of lA){if(dA==null){gA.push(null);continue}gA.push(childInstructionToContent(dA,AA))}const{children:cA,wrapperElements:IA}=applyCompositeListWrapping(gA,sA?._compositeReplacementActiveRange),uA={type:"element",name:eA[oA]??"",children:cA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(uA,AA);const CA={changedState:uA.data.props};lA&&(CA.newChildren=uA.children),iA(oA,CA);for(const dA of IA)iA(dA.data.id,{newFlatDastElement:dA})}return tA}async function resolvePathImmediatelyToNodeIdx(nA,eA,AA,tA=0){if(!AA.core)return-1;const iA=nA.match(/^([\w-]+)((\[\d+\])*)/);if(!iA)throw Error(`Invalid name to resolve: ${nA}`);const rA=[{type:"flatPathPart",name:iA[1],index:extractIndex(iA[2])}];let aA=nA.slice(iA[0].length);for(;aA.length>0;){const oA=aA.match(/^\.([\w-]+)((\[\d+\])*)/);if(!oA)throw Error(`Invalid name to resolve: ${nA}`);rA.push({type:"flatPathPart",name:oA[1],index:extractIndex(oA[2])}),aA=aA.slice(oA[0].length)}try{let oA=eA.resolve_path({path:rA},tA,!1);for(;oA.unresolvedPath!==null;){if(oA.unresolvedPath[0].name!=="")return-1;const sA=AA.core._components[oA.nodeIdx];if(!AA.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType,includeNonStandard:!0})||sA.isExpanded)return-1;const gA=oA.unresolvedPath[0].index;if(gA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof gA[0].value[0]!="string")throw Error("Not implemented: we have not implemented `resolvePathImmediatelyToNodeIdx` for paths that contain references to nodes.");await sA.stateValues.readyToExpandWhenResolved,await expandCompositeComponent({core:AA.core,component:sA}),oA=eA.resolve_path({path:rA},tA,!1)}return oA.nodeIdx}catch(oA){return console.error(oA),-1}}function extractIndex(nA){const eA=[];for(const AA of nA.matchAll(/\[(\d+)\]/g))eA.push({value:[AA[1]]});return eA}const JS_CORE_ACTION_NAME_OVERRIDES={point:{move:"movePoint"},graph:{changeBoundingBox:"changeAxisLimits"}};function translateJsCoreActionName(nA,eA){return nA==null?eA:JS_CORE_ACTION_NAME_OVERRIDES[nA]?.[eA]??eA}const WASM_FILE_NAME="lib_doenetml_worker_bg.wasm";function injectedGlobal(nA){const eA=globalThis[nA];return typeof eA=="string"?eA:void 0}function decodeWasmDataUrl(nA){try{const eA=nA.split(",")[1],AA=atob(eA),tA=new Uint8Array(AA.length);for(let iA=0;iA<AA.length;iA++)tA[iA]=AA.charCodeAt(iA);return tA.buffer}catch(eA){return console.warn("Error while decoding the WASM data URL:",eA),null}}function wasmUrlCandidates(){const nA=[];function eA(iA){nA.includes(iA)||nA.push(iA)}const AA=injectedGlobal("__doenetWorkerWasmUrl");AA!==void 0&&eA(AA);const tA=[injectedGlobal("__doenetWorkerScriptUrl"),typeof location<"u"?location.href:void 0];for(const iA of tA)if(iA!==void 0)try{eA(new URL(WASM_FILE_NAME,iA).href)}catch{}return eA(`https://cdn.jsdelivr.net/npm/@doenet/standalone@0.7.27-dev.712/doenetml-worker/${WASM_FILE_NAME}`),nA}async function resolveWasmInput(){const nA=injectedGlobal("__doenetWorkerWasmUrl");if(nA!==void 0&&/^data:.*;base64,/.test(nA)){const AA=decodeWasmDataUrl(nA);if(AA)return AA}let eA;for(const AA of wasmUrlCandidates())if(!AA.startsWith("data:"))try{const tA=await fetch(AA);if(!tA.ok)throw Error(`HTTP ${tA.status} fetching ${AA}`);const iA=tA.headers.get("Content-Type")??"";if(/^text\/html\b/i.test(iA))throw Error(`Fetching ${AA} returned ${iA}, an HTML page rather than WebAssembly`);return tA}catch(tA){eA=tA}throw eA??Error("No URL to load the core WASM from")}if(typeof globalThis<"u"&&!globalThis.document){const nA=new URL(typeof location<"u"?location.href:"http://localhost"),eA=nA.protocol+"//"+nA.host+nA.pathname;globalThis.document={URL:eA,baseURI:eA}}let wasmInitPromise=null;function ensureWasmInitialized(){return wasmInitPromise||(wasmInitPromise=(async()=>{const nA=await resolveWasmInput();return await __wbg_init({module_or_path:nA})})().catch(nA=>{throw wasmInitPromise=null,nA})),wasmInitPromise}const RELEASED_INITIALIZATION_DATA_MESSAGE="Cannot initialize from the document DAST: it was released when the previous initialization completed. Call setSource again before re-initializing.",DOCUMENT_BUILD_ERROR_NAME="DoenetDocumentBuildError";function readPanicMessage(){try{return take_last_panic_message()??void 0}catch(nA){console.error(nA);return}}function discardStalePanicMessage(){readPanicMessage()}function throwAsDocumentBuildError(nA,eA){const AA=nA instanceof Error?nA:new Error(String(nA??"unknown error"));throw AA.name=DOCUMENT_BUILD_ERROR_NAME,eA&&(AA.message=eA),AA}class CoreWorker{constructor(){this.wasm_initialized=!1,this.javascript_initialized=!1,this.source_set=!1,this._initializationDataReleased=!1,this.flags_set=!1,this.core_type="rust",this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!1,this._componentIdxToName={},this._doenetIdToComponentIdx={},this._javascriptInitialRenderDone=!1,this.isProcessingPromise=Promise.resolve(),this._hostedCores=new Map,this._nextHostedCoreId=1,this._isHostedCore=!1}async createCore(eA){const AA=new CoreWorker;AA._isHostedCore=!0,expose(AA,eA);const tA=this._nextHostedCoreId++;return this._hostedCores.set(tA,{core:AA,port:eA}),tA}async destroyCore(eA){const AA=this._hostedCores.get(eA);if(AA){this._hostedCores.delete(eA);try{await AA.core.terminate()}catch(tA){console.error("Error terminating hosted core",tA)}finally{AA.port.close()}}}setCoreType(eA){this.core_type=eA}async setSource(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setSource(eA.source)),this.doenetCore.set_source(eA.dast,eA.source),this.source_set=!0,this._initializationDataReleased=!1}catch(rA){throw console.error("Error when setting source",rA),rA}finally{iA()}}async setFlags(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setFlags(eA.flags)),this.doenetCore.set_flags(JSON.stringify(eA.flags)),this.flags_set=!0}finally{iA()}}async setLocaleData(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setLocaleData(eA.localeData))}finally{iA()}}async initializeJavascriptCore({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA}){const rA=this.isProcessingPromise;let{promise:aA,resolve:oA}=promiseWithResolver();this.isProcessingPromise=aA,await rA;let sA=!1;try{let lA=function(mA){return dA.update_root_names(mA)},gA=function(mA,QA,BA){return dA.resolve_path(mA,QA,BA)},cA=function(mA,QA){dA.add_nodes_to_resolver(mA,QA)},IA=function(mA,QA){dA.replace_index_resolutions_in_resolver(mA,QA)},uA=function(mA){dA.delete_nodes_from_resolver(mA)};if(!this.source_set||!this.flags_set||!this.javascriptCore||!this.doenetCore)throw Error("Cannot initialize javascript core before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);sA=!0,discardStalePanicMessage();let CA=this.doenetCore.return_normalized_dast_root();const dA=this.doenetCore,pA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:CA,addNodesToResolver:cA,replaceIndexResolutionsInResolver:IA,deleteNodesFromResolver:uA,resolvePath:gA,updateRootNames:lA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,pA}catch(lA){if(console.error(lA),!sA)throw lA;throwAsDocumentBuildError(lA,readPanicMessage())}finally{oA()}}async generateJavascriptDast(eA,AA,tA,iA,rA,aA,oA,sA){const lA=this.isProcessingPromise;let{promise:gA,resolve:cA}=promiseWithResolver();if(this.isProcessingPromise=gA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const IA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA);if(IA?.success===!1){const uA=readPanicMessage();uA!==void 0&&throwAsDocumentBuildError(new Error(IA.errMsg??""),uA)}return IA}catch(IA){console.error(IA),throwAsDocumentBuildError(IA,readPanicMessage())}finally{cA()}}async returnDast({variantIndex:eA=1}={}){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");try{return this.core_type==="javascript"?await this.returnFlatDastFromJS(eA):this.doenetCore.return_dast()}catch(rA){throw console.error(rA),rA}finally{iA()}}async returnNormalizedDastRoot(){if(!this.source_set||!this.doenetCore)throw Error("Cannot return normalized dast root before setting source");if(this.core_type==="javascript")return{nodes:[]};if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);return this.doenetCore.return_normalized_dast_root()}async returnFlatDastFromJS(eA){if(!this.javascriptCore||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);let AA=this.doenetCore.return_normalized_dast_root();const tA=this.doenetCore;function iA(fA){return tA.update_root_names(fA)}function rA(fA,NA,yA){return tA.resolve_path(fA,NA,yA)}function aA(fA,NA){tA.add_nodes_to_resolver(fA,NA)}function oA(fA,NA){tA.replace_index_resolutions_in_resolver(fA,NA)}function sA(fA){tA.delete_nodes_from_resolver(fA)}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:iA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const lA={coreId:"a",cid:null,initializeCounters:{}};let gA=null;this._javascriptUpdateBuffer=[];const cA=fA=>{fA.init?gA=fA.updateInstructions:this._capturingJavascriptUpdates&&fA.updateInstructions&&this._javascriptUpdateBuffer.push(...fA.updateInstructions)},IA=fA=>{},uA=fA=>{},CA=fA=>{},dA=fA=>{},pA=fA=>{},mA=fA=>Promise.resolve({allowView:!0}),QA=await this.javascriptCore.createCoreGenerateDast(lA,cA,IA,uA,CA,dA,pA,mA);if(!QA.success)throw console.error(QA.errMsg),Error(QA.errMsg);if(gA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const BA=QA.coreInfo.documentToRender,{componentIdxToName:hA,doenetIdToComponentIdx:DA}=seedInstructionMaps(BA,gA);return this._componentIdxToName=hA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(BA,gA)}async dispatchActionJavascript(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");try{return await this.javascriptCore.requestAction(eA)}catch(rA){throw console.error(rA),rA}finally{iA()}}async dispatchActionJavascriptFlat(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{if(!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");if(!this._javascriptInitialRenderDone)throw Error("Cannot dispatch a flat action before the initial render (returnDast) has run");this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!0;const rA=eA.componentIdx!=null?this._componentIdxToName[eA.componentIdx]:void 0,aA=translateJsCoreActionName(rA,eA.actionName),oA=await this.javascriptCore.requestAction({...eA,actionName:aA});if(oA&&typeof oA=="object"&&"success"in oA&&oA.success===!1){const lA=aA===eA.actionName?`"${eA.actionName}"`:`"${eA.actionName}" (translated to "${aA}")`;throw Error(`Action ${lA} failed: ${oA.errMsg??"unknown error"}`)}this._capturingJavascriptUpdates=!1;const sA=this._javascriptUpdateBuffer;return this._javascriptUpdateBuffer=[],collectInstructionMaps(sA,this._componentIdxToName,this._doenetIdToComponentIdx),flatDastUpdateFromJS(sA,this._componentIdxToName,this._doenetIdToComponentIdx)}catch(rA){throw console.error(rA),rA}finally{this._capturingJavascriptUpdates=!1,iA()}}async resolvePath(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot resolve a path before setting source and flags");try{return this.doenetCore.resolve_path(eA.path,eA.origin,eA.skipParentSearch)}finally{iA()}}async dispatchAction(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot handle action before setting source and flags");try{return this.doenetCore.dispatch_action(eA)}catch(rA){throw console.error(rA),rA}finally{iA()}}async resolvePathJavascript(eA,AA=0){const tA=this.isProcessingPromise;let{promise:iA,resolve:rA}=promiseWithResolver();if(this.isProcessingPromise=iA,await tA,!this.source_set||!this.flags_set||!this.doenetCore||!this.javascriptCore)throw Error("Cannot resolve path before setting source and flags");try{return await resolvePathImmediatelyToNodeIdx(eA,this.doenetCore,this.javascriptCore,AA)}catch(aA){throw console.error(aA),aA}finally{rA()}}async terminate(){const eA=this.isProcessingPromise;let{promise:AA,resolve:tA}=promiseWithResolver();if(this.isProcessingPromise=AA,await eA,this.doenetCore?.free(),this.doenetCore=void 0,this.source_set=!1,this.flags_set=!1,this.javascriptCore)try{await this.javascriptCore.terminate()}catch(iA){throw console.error(iA),iA}finally{tA()}else tA();this._isHostedCore||close()}async returnAllStateVariables(eA=!1){return this.javascriptCore?this.javascriptCore.returnAllStateVariables(eA):{}}handleVisibilityChange(eA){this.javascriptCore&&this.javascriptCore.handleVisibilityChange(eA)}async submitAllAnswers(){this.javascriptCore&&await this.javascriptCore.submitAllAnswers()}async saveImmediately(){this.javascriptCore&&this.javascriptCore.saveImmediately()}async flushState(){return this.javascriptCore?await this.javascriptCore.flushState():!1}async _getTests(){return this.doenetCore?._get_tests()}async _runTest(eA){return this.doenetCore?._run_test(eA)}}function promiseWithResolver(){let nA,eA;return{promise:new Promise((tA,iA)=>{nA=tA,eA=iA}),resolve:nA,reject:eA}}expose(new CoreWorker);function _mergeNamespaces$1(nA,eA){for(var AA=0;AA<eA.length;AA++){const tA=eA[AA];if(typeof tA!="string"&&!Array.isArray(tA)){for(const iA in tA)if(iA!=="default"&&!(iA in nA)){const rA=Object.getOwnPropertyDescriptor(tA,iA);rA&&Object.defineProperty(nA,iA,rA.get?rA:{enumerable:!0,get:()=>tA[iA]})}}}return Object.freeze(Object.defineProperty(nA,Symbol.toStringTag,{value:"Module"}))}var sha256$3={exports:{}},convertHex$1={exports:{}},convertHex=convertHex$1.exports,hasRequiredConvertHex;function requireConvertHex(){return hasRequiredConvertHex||(hasRequiredConvertHex=1,(function(nA){(function(eA){var AA={bytesToHex:function(rA){return tA(rA)},hexToBytes:function(rA){if(rA.length%2===1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return rA.indexOf("0x")===0&&(rA=rA.slice(2)),rA.match(/../g).map(function(aA){return parseInt(aA,16)})}};function tA(rA){return rA.map(function(aA){return iA(aA.toString(16),2)}).join("")}function iA(rA,aA){return rA.length>aA?rA:Array(aA-rA.length+1).join("0")+rA}nA.exports?nA.exports=AA:eA.convertHex=AA})(convertHex)})(convertHex$1)),convertHex$1.exports}var convertString$1={exports:{}},convertString=convertString$1.exports,hasRequiredConvertString;function requireConvertString(){return hasRequiredConvertString||(hasRequiredConvertString=1,(function(nA){(function(eA){var AA={bytesToString:function(tA){return tA.map(function(iA){return String.fromCharCode(iA)}).join("")},stringToBytes:function(tA){return tA.split("").map(function(iA){return iA.charCodeAt(0)})}};AA.UTF8={bytesToString:function(tA){return decodeURIComponent(escape(AA.bytesToString(tA)))},stringToBytes:function(tA){return AA.stringToBytes(unescape(encodeURIComponent(tA)))}},nA.exports?nA.exports=AA:eA.convertString=AA})(convertString)})(convertString$1)),convertString$1.exports}var sha256$2=sha256$3.exports,hasRequiredSha256;function requireSha256(){return hasRequiredSha256||(hasRequiredSha256=1,(function(nA){(function(eA){var AA={};nA.exports?(AA.bytesToHex=requireConvertHex().bytesToHex,AA.convertString=requireConvertString(),nA.exports=sA):(AA.bytesToHex=eA.convertHex.bytesToHex,AA.convertString=eA.convertString,eA.sha256=sA);var tA=[];(function(){function lA(uA){for(var CA=Math.sqrt(uA),dA=2;dA<=CA;dA++)if(!(uA%dA))return!1;return!0}function gA(uA){return(uA-(uA|0))*4294967296|0}for(var cA=2,IA=0;IA<64;)lA(cA)&&(tA[IA]=gA(Math.pow(cA,.3333333333333333)),IA++),cA++})();var iA=function(lA){for(var gA=[],cA=0,IA=0;cA<lA.length;cA++,IA+=8)gA[IA>>>5]|=lA[cA]<<24-IA%32;return gA},rA=function(lA){for(var gA=[],cA=0;cA<lA.length*32;cA+=8)gA.push(lA[cA>>>5]>>>24-cA%32&255);return gA},aA=[],oA=function(lA,gA,cA){for(var IA=lA[0],uA=lA[1],CA=lA[2],dA=lA[3],pA=lA[4],mA=lA[5],QA=lA[6],BA=lA[7],hA=0;hA<64;hA++){if(hA<16)aA[hA]=gA[cA+hA]|0;else{var DA=aA[hA-15],EA=(DA<<25|DA>>>7)^(DA<<14|DA>>>18)^DA>>>3,fA=aA[hA-2],NA=(fA<<15|fA>>>17)^(fA<<13|fA>>>19)^fA>>>10;aA[hA]=EA+aA[hA-7]+NA+aA[hA-16]}var yA=pA&mA^~pA&QA,bA=IA&uA^IA&CA^uA&CA,wA=(IA<<30|IA>>>2)^(IA<<19|IA>>>13)^(IA<<10|IA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+yA+tA[hA]+aA[hA],kA=wA+bA;BA=QA,QA=mA,mA=pA,pA=dA+vA|0,dA=CA,CA=uA,uA=IA,IA=vA+kA|0}lA[0]=lA[0]+IA|0,lA[1]=lA[1]+uA|0,lA[2]=lA[2]+CA|0,lA[3]=lA[3]+dA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+QA|0,lA[7]=lA[7]+BA|0};function sA(lA,gA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var cA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],IA=iA(lA),uA=lA.length*8;IA[uA>>5]|=128<<24-uA%32,IA[(uA+64>>9<<4)+15]=uA;for(var CA=0;CA<IA.length;CA+=16)oA(cA,IA,CA);var dA=rA(cA);return gA&&gA.asBytes?dA:gA&&gA.asString?AA.convertString.bytesToString(dA):AA.bytesToHex(dA)}sA.x2=function(lA,gA){return sA(sA(lA,{asBytes:!0}),gA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0Fpjk4uJM=Object.freeze(Object.defineProperty({__proto__:null,s:sha256$1},Symbol.toStringTag,{value:"Module"}));return exports.CoreWorker=CoreWorker,exports.DOCUMENT_BUILD_ERROR_NAME=DOCUMENT_BUILD_ERROR_NAME,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports})({});
2799
+ `).map(IA=>IA.trim().split(",").map(uA=>uA.trim())),oA=aA[0]?.length,sA=!1;for(let IA of aA.slice(1))if(IA.length!==oA){sA=!0;break}if(sA){let IA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}let lA={},gA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(IA=>(['"',"'"].includes(IA[0])&&IA[IA.length-1]===IA[0]&&(IA=IA.substring(1,IA.length-1)),IA)),gA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(IA=>`col${IA+1}`),gA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let IA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}if(lA.columnNames.includes("")){let IA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[IA]}}let cA=gA.length;lA.shape=[cA,oA];for(let IA=0;IA<oA;IA++){let uA=AA.columnTypesPrelim[IA]?.toLowerCase();if(["number","string"].includes(uA)||(uA="auto"),uA==="auto"){let CA=!1;for(let dA=0;dA<cA;dA++){let pA=gA[dA][IA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){CA=!0;break}}}CA?uA="string":uA="number"}if(uA==="number")for(let CA=0;CA<cA;CA++)gA[CA][IA]===""?gA[CA][IA]=null:gA[CA][IA]=Number(gA[CA][IA]);else for(let CA=0;CA<cA;CA++){let dA=gA[CA][IA];['"',"'"].includes(dA[0])&&dA[dA.length-1]===dA[0]&&(dA=dA.substring(1,dA.length-1)),gA[CA][IA]=dA}iA.push(uA)}return lA.data=gA,lA.columnTypes=iA,{setValue:{dataFrame:lA,numRows:cA,numColumns:oA,columnTypes:iA,columnNames:lA.columnNames}}}},eA.means={description:"Mean of each numeric column in the data frame.",public:!0,shadowingInstructions:{createComponentOfType:"number"},isArray:!0,entryPrefixes:["mean"],returnArraySizeDependencies:()=>({numColumns:{dependencyType:"stateVariable",variableName:"numColumns"}}),returnArraySize({dependencyValues:AA}){return[AA.numColumns]},returnArrayDependenciesByKey(){return{globalDependencies:{dataFrame:{dependencyType:"stateVariable",variableName:"dataFrame"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"},numRows:{dependencyType:"stateVariable",variableName:"numRows"},columnTypes:{dependencyType:"stateVariable",variableName:"columnTypes"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arrayKeys:tA}){let iA={};for(let rA of tA){let aA=0,oA=0;if(AA.columnTypes[rA]==="number"){for(let sA=0;sA<AA.numRows;sA++){let lA=AA.dataFrame.data[sA][rA];lA!==null&&(aA+=lA,oA++)}aA/=oA}else aA=NaN;iA[rA]=aA}return{setValue:{means:iA}}}},eA}}const{mean,std,variance}=context.math,STATISTICS=[{value:"mean",description:"The arithmetic mean of the values.",compute:mean},{value:"stdev",description:"The sample standard deviation.",compute:std},{value:"variance",description:"The sample variance.",compute:variance},{value:"stderr",description:"The standard error of the mean."},{value:"count",description:"The number of non-missing values."},{value:"minimum",description:"The smallest value.",compute:smallest},{value:"quartile1",description:"The first quartile (25th percentile).",compute:quartile1},{value:"median",description:"The median value.",compute:median},{value:"quartile3",description:"The third quartile (75th percentile).",compute:quartile3},{value:"maximum",description:"The largest value.",compute:largest},{value:"range",description:"The maximum minus the minimum."},{value:"sum",description:"The sum of the values.",compute:nA=>nA.reduce((eA,AA)=>eA+AA)}],FIVE_NUMBER_SUMMARY=["minimum","quartile1","median","quartile3","maximum"],DEFAULT_STATISTICS=["mean","stdev","count","minimum","quartile1","median","quartile3","maximum"];function returnColumnStatisticDefinition({value:nA,description:eA,compute:AA}){return{description:eA,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){const iA=tA.dataColumn;return{setValue:{[nA]:iA.length?AA(iA):null}}}}}function displayedStatistic(nA,eA,AA){return eA===null?null:nA==="count"?eA:roundForDisplay({value:numberToMathExpression(eA),dependencyValues:AA}).toString(buildNumberDisplayParameters(AA))}class SummaryStatistics extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="summaryStatistics";static componentDocs={summary:"Summary statistics (mean, median, etc.) for a list of numbers."};static createAttributesObject(){let eA=super.createAttributesObject();return eA.statisticsToDisplay={createComponentOfType:"textList",createStateVariable:"statisticsToDisplayPrelim",defaultValue:["default"],toLowerCase:!0,highlighted:!0,validValues:[{value:"default",description:`The default selection: ${DEFAULT_STATISTICS.join(", ")}.`},{value:"all",description:"Every statistic listed here."},{value:"fiveNumberSummary",description:`The five-number summary: ${FIVE_NUMBER_SUMMARY.join(", ")}.`},...STATISTICS.map(({value:AA,description:tA})=>({value:AA,description:tA}))],description:'Which summary statistics to display (or "default" / "all" / "fiveNumberSummary").'},Object.assign(eA,returnNumberDisplayAttributes()),eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=super.returnSugarInstructions();return eA.push(returnBreakStringsIntoMathsBySpacesSugarInstruction()),eA}static returnChildGroups(){return[{group:"numbers",componentTypes:["number"]},{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.statisticsToDisplay={description:"Which summary statistics to display.",public:!0,shadowingInstructions:{createComponentOfType:"textList"},returnDependencies:()=>({statisticsToDisplayPrelim:{dependencyType:"stateVariable",variableName:"statisticsToDisplayPrelim"}}),definition:function({dependencyValues:tA}){const iA=STATISTICS.map(sA=>sA.value),rA=tA.statisticsToDisplayPrelim,aA=new Set;for(const sA of rA)if(sA==="default")for(const lA of DEFAULT_STATISTICS)aA.add(lA);else if(sA==="all")for(const lA of iA)aA.add(lA);else if(sA==="fivenumbersummary")for(const lA of FIVE_NUMBER_SUMMARY)aA.add(lA);else aA.add(sA);return{setValue:{statisticsToDisplay:iA.filter(sA=>aA.has(sA))}}}},eA.dataColumn={description:"The numeric values being summarized.",returnDependencies:()=>({valueChildren:{dependencyType:"child",childGroups:["numbers","maths"],variableNames:["value"]}}),definition({dependencyValues:tA}){const iA=[];for(let rA of tA.valueChildren){const aA=rA.stateValues.value,oA=typeof aA?.evaluate_to_constant=="function"?aA.evaluate_to_constant():aA;Number.isFinite(oA)&&iA.push(oA)}return{setValue:{dataColumn:iA}}}};const AA={};AA.count={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataColumn:{dependencyType:"stateVariable",variableName:"dataColumn"}}),definition({dependencyValues:tA}){return{setValue:{count:tA.dataColumn.length}}}},AA.stderr={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({stdev:{dependencyType:"stateVariable",variableName:"stdev"},count:{dependencyType:"stateVariable",variableName:"count"}}),definition({dependencyValues:tA}){let iA=null;return tA.stdev!==null&&(iA=tA.stdev/Math.sqrt(tA.count)),{setValue:{stderr:iA}}}},AA.range={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},returnDependencies:()=>({minimum:{dependencyType:"stateVariable",variableName:"minimum"},maximum:{dependencyType:"stateVariable",variableName:"maximum"}}),definition({dependencyValues:tA}){let iA=null;return tA.minimum!==null&&(iA=tA.maximum-tA.minimum),{setValue:{range:iA}}}};for(let tA of STATISTICS)eA[tA.value]={...tA.compute?returnColumnStatisticDefinition(tA):{description:tA.description,...AA[tA.value]},highlighted:!0};return eA.summaryStatistics={description:"The statistics being displayed, as the table should show them, keyed by statistic.",forRenderer:!0,stateVariablesDeterminingDependencies:["statisticsToDisplay"],returnDependencies({stateValues:tA}){let iA={};for(let rA of["displayDigits","displayDecimals","displaySmallAsZero","padZeros","avoidScientificNotation"])iA[rA]={dependencyType:"stateVariable",variableName:rA};for(let rA of tA.statisticsToDisplay)iA[rA]={dependencyType:"stateVariable",variableName:rA};return iA},definition({dependencyValues:tA}){let iA={};for(let{value:rA}of STATISTICS){const aA=tA[rA];aA!==void 0&&(iA[rA]=displayedStatistic(rA,aA,tA))}return{setValue:{summaryStatistics:iA}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Legend extends GraphicalComponent{static componentType="legend";static componentDocs={summary:"A legend describing the contents of a graph"};static createAttributesObject(){let eA=super.createAttributesObject();return eA.layer.defaultValue=1,eA.position={description:"Position of the legend on the graph.",createComponentOfType:"text",createStateVariable:"position",defaultValue:"upperRight",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"upperRight",description:"Place the legend in the upper-right corner."},{value:"upperLeft",description:"Place the legend in the upper-left corner."},{value:"lowerRight",description:"Place the legend in the lower-right corner."},{value:"lowerLeft",description:"Place the legend in the lower-left corner."}]},eA.boxed={description:"Whether to draw an opaque box behind the legend so that graph contents passing behind it stay hidden.",createComponentOfType:"boolean",createStateVariable:"boxed",defaultValue:!1,public:!0,forRenderer:!0},eA.displayClosedSwatches={description:"Whether to render closed/filled swatches in the legend.",createComponentOfType:"boolean",createStateVariable:"displayClosedSwatches",defaultValue:!1,public:!0},eA}static returnChildGroups(){return[{group:"labels",componentTypes:["label"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.graphicalElementNames={returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["graphicalDescendants"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphicalElementNames:AA.graphAncestor.stateValues.graphicalDescendants.map(tA=>tA.componentIdx)}}:{setValue:{graphicalElementNames:null}}}},eA.legendElements={forRenderer:!0,stateVariablesDeterminingDependencies:["graphicalElementNames"],returnDependencies:({stateValues:AA})=>{let tA={labelChildren:{dependencyType:"child",childGroups:["labels"],variableNames:["value","hasLatex","forObjectComponentIdx","forObjectListEntry"]},displayClosedSwatches:{dependencyType:"stateVariable",variableName:"displayClosedSwatches"}};if(AA.graphicalElementNames){tA.numGraphicalElements={dependencyType:"value",value:AA.graphicalElementNames.length};for(let[iA,rA]of AA.graphicalElementNames.entries())tA[`graphicalElement${iA}`]={dependencyType:"multipleStateVariables",componentIdx:rA,variableNames:["selectedStyle","styleNumber","filled","entrySelectedStyle","numEntries"],variablesOptional:!0},tA[`graphicalElement${iA}AdapterSource`]={dependencyType:"adapterSource",componentIdx:rA},tA[`graphicalElement${iA}ShadowSource`]={dependencyType:"shadowSource",componentIdx:rA}}return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){let iA=[];if(AA.numGraphicalElements>0){let rA=[],aA=[],oA=[],sA=[];for(let IA=0;IA<AA.numGraphicalElements;IA++){let uA=AA[`graphicalElement${IA}`];const CA=tA.allComponentClasses[uA?.componentType]?.listEntryComponentType;CA!==void 0&&(uA={...uA,componentType:CA});let dA=AA[`graphicalElement${IA}AdapterSource`];dA&&(uA={...uA},uA.componentIdx=dA.componentIdx);let pA=AA[`graphicalElement${IA}ShadowSource`];if(pA){const mA=JSON.parse(JSON.stringify(uA));mA.componentIdx=pA.componentIdx,sA.push(mA)}sA.push(uA),CA!==void 0&&sA.push(...listEntryElementsForLabels({list:uA,listIndices:[uA.componentIdx,pA?.componentIdx],labelChildren:AA.labelChildren}))}let lA=sA.map(IA=>IA.componentIdx),gA=[],cA={};for(let IA of AA.labelChildren){let uA={value:IA.stateValues.value,hasLatex:IA.stateValues.hasLatex};if(IA.stateValues.forObjectComponentIdx){cA[IA.stateValues.forObjectComponentIdx]=uA;let CA=lA.indexOf(IA.stateValues.forObjectComponentIdx);if(CA!==-1){let dA=sA[CA];tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})?rA.push(dA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath?aA.push(dA.stateValues.styleNumber):dA.componentType!=="legend"&&oA.push(dA.stateValues.styleNumber)}}gA.push({labelInfo:uA,forObject:IA.stateValues.forObjectComponentIdx})}for(let IA of gA){let uA;if(IA.forObject){let CA=lA.indexOf(IA.forObject);CA!==-1&&(uA=sA[CA],sA.splice(CA,1),lA.splice(CA,1))}else for(let CA=0;CA<sA.length;CA++){let dA=sA[CA];if(!(dA.componentIdx in cA)){if(tA.isInheritedComponentType({inheritedComponentType:dA.componentType,baseComponentType:"point"})){if(!rA.includes(dA.stateValues.styleNumber)){uA=dA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[dA.componentType].representsClosedPath){if(!aA.includes(dA.stateValues.styleNumber)){uA=dA;break}}else if(dA.componentType!=="legend"&&!oA.includes(dA.stateValues.styleNumber)){uA=dA;break}}}if(uA){let CA=uA.stateValues.selectedStyle,dA=uA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:uA.componentType,baseComponentType:"point"})?(rA.push(dA),iA.push({swatchType:"marker",markerStyle:CA.markerStyle,markerColor:CA.markerColor,markerColorDarkMode:CA.markerColorDarkMode,markerSize:CA.markerSize,lineOpacity:CA.lineOpacity,label:IA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[uA.componentType].representsClosedPath?(aA.push(dA),iA.push({swatchType:"rectangle",lineStyle:CA.lineStyle,lineColor:CA.lineColor,lineColorDarkMode:CA.lineColorDarkMode,lineWidth:CA.lineWidth,lineOpacity:CA.lineOpacity,fillColor:CA.fillColor,fillColorDarkMode:CA.fillColorDarkMode,filled:uA.stateValues.filled,fillOpacity:CA.fillOpacity,label:IA.labelInfo})):(oA.push(dA),iA.push({swatchType:"line",lineStyle:CA.lineStyle,lineColor:CA.lineColor,lineColorDarkMode:CA.lineColorDarkMode,lineWidth:CA.lineWidth,lineOpacity:CA.lineOpacity,label:IA.labelInfo}))}}}return{setValue:{legendElements:iA}}}},eA.graphLimits={forRenderer:!0,returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xMin","xMax","yMin","yMax"]}}),definition({dependencyValues:AA}){return AA.graphAncestor?{setValue:{graphLimits:AA.graphAncestor.stateValues}}:{setValue:{graphLimits:null}}}},eA}}function listEntryElementsForLabels({list:nA,listIndices:eA,labelChildren:AA}){const tA=[],iA=new Set;for(const rA of AA){const aA=rA.stateValues.forObjectListEntry,oA=rA.stateValues.forObjectComponentIdx;if(!aA||!eA.includes(aA.listIdx)||!(aA.entryIndex<nA.stateValues.numEntries)||iA.has(oA))continue;iA.add(oA);const sA=nA.stateValues.entrySelectedStyle?.[aA.entryIndex],lA=sA===void 0||JSON.stringify(sA)===JSON.stringify(nA.stateValues.selectedStyle);tA.push({componentType:nA.componentType,componentIdx:oA,stateValues:{selectedStyle:sA??nA.stateValues.selectedStyle,styleNumber:lA?nA.stateValues.styleNumber:void 0,filled:nA.stateValues.filled}})}return tA}function parameterKey(nA){if(isValidVariable({tree:nA}))return typeof nA=="string"?"s"+nA:"t"+JSON.stringify(nA)}function replacePlaceholders(nA,eA){let AA=eA(nA);return AA!==void 0?AA:Array.isArray(nA)?[nA[0],...nA.slice(1).map(tA=>replacePlaceholders(tA,eA))]:nA}class MatchesPattern extends BooleanComponent{static componentType="matchesPattern";static componentDocs={summary:"Boolean condition that tests whether input matches a math pattern"};static rendererType="boolean";static createAttributesObject(){let eA=super.createAttributesObject();return eA.pattern={createComponentOfType:"math",description:"Math expression pattern to match against.",highlighted:!0},eA.parameters={createComponentOfType:"_variableNameList",description:"Variables in the pattern that act as placeholders. Repeating one in the pattern requires the same subexpression at each occurrence. When specified, blanks in the pattern are matched literally.",highlighted:!0},eA.allowImplicitIdentities={description:"Whether to allow implicit identity transformations when matching.",createComponentOfType:"boolean",createStateVariable:"allowImplicitIdentities",defaultValue:!1,public:!0,highlighted:!0},eA.allowPermutations={description:"Whether to allow permutations of operands when matching.",createComponentOfType:"boolean",createStateVariable:"allowPermutations",defaultValue:!0,public:!0,highlighted:!0},eA.requireNumericMatches={description:"Whether numeric placeholders must match numbers.",createComponentOfType:"boolean",createStateVariable:"requireNumericMatches",defaultValue:!1,public:!0,highlighted:!0},eA.requireVariableMatches={description:"Whether variable placeholders must match variables.",createComponentOfType:"boolean",createStateVariable:"requireVariableMatches",defaultValue:!1,public:!0,highlighted:!0},eA.excludeMatches={description:"Patterns whose matches are excluded.",createComponentOfType:"mathList",createStateVariable:"excludeMatches",defaultValue:[],public:!0,highlighted:!0},eA.matchExpressionWithBlanks={description:"Whether to allow expressions with blanks to match.",createComponentOfType:"boolean",createStateVariable:"matchExpressionWithBlanks",defaultValue:!1,public:!0,highlighted:!0},eA}static additionalSchemaChildren=["string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,componentInfoObjects:iA,nComponents:rA,stateIdInfo:aA}){return tA.length===0||tA.length===1&&iA.componentIsSpecifiedType(tA[0],"math")?{success:!1}:{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.parsedExpression,delete eA.mathChildrenByCode,eA.pattern={additionalStateVariablesDefined:["patternVariables"],returnDependencies:()=>({patternAttr:{dependencyType:"attributeComponent",attributeName:"pattern",variableNames:["value"]},parametersAttr:{dependencyType:"attributeComponent",attributeName:"parameters",variableNames:["variables"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK$1,patternVariables:tA}};let iA=AA.patternAttr.stateValues.value,rA=iA.variables(),aA=703;function oA(){let dA=numberToLetters(aA);for(aA++;rA.includes(dA);)dA=numberToLetters(aA),aA++;return dA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(iA.tree,pA=>{if(pA!==BLANK$1)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],gA=new Map,cA=new Map;for(let dA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(dA.tree);if(pA===void 0||gA.has(pA))continue;let mA=oA();gA.set(pA,mA),cA.set(mA,dA.toString()),tA.push(mA)}let IA=new Set,uA=replacePlaceholders(iA.tree,dA=>{let pA=gA.get(parameterKey(dA));return pA!==void 0&&IA.add(pA),pA}),CA=[...cA].filter(([dA])=>!IA.has(dA)).map(([dA,pA])=>pA);return CA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0117",args:{parameters:CA},position:sA})),{setValue:{pattern:uA,patternVariables:tA},sendDiagnostics:lA}}},eA.value={description:"Whether the input matches the pattern.",additionalStateVariablesDefined:[{variableName:"allPatternMatches"}],public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({pattern:{dependencyType:"stateVariable",variableName:"pattern"},patternVariables:{dependencyType:"stateVariable",variableName:"patternVariables"},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},allowImplicitIdentities:{dependencyType:"stateVariable",variableName:"allowImplicitIdentities"},allowPermutations:{dependencyType:"stateVariable",variableName:"allowPermutations"},requireNumericMatches:{dependencyType:"stateVariable",variableName:"requireNumericMatches"},requireVariableMatches:{dependencyType:"stateVariable",variableName:"requireVariableMatches"},excludeMatches:{dependencyType:"stateVariable",variableName:"excludeMatches"},matchExpressionWithBlanks:{dependencyType:"stateVariable",variableName:"matchExpressionWithBlanks"}}),definition:function({dependencyValues:AA}){if(AA.mathChildren.length===0)return{setValue:{value:!1,allPatternMatches:[]}};let tA=AA.mathChildren[0].stateValues.value;if(treeContainsBlank(tA.tree)&&!AA.matchExpressionWithBlanks)return{setValue:{value:!1,allPatternMatches:[]}};let iA="any";AA.requireNumericMatches?iA="number":AA.requireVariableMatches&&(iA="variable");let rA={};AA.patternVariables.forEach(gA=>rA[gA]=iA);let aA={variables:rA,allow_permutations:AA.allowPermutations};AA.allowImplicitIdentities&&(aA.allow_implicit_identities=AA.patternVariables);let oA=tA.match(AA.pattern,aA),sA=!1,lA=[];return oA&&(Object.values(oA).map(gA=>context.fromAst(gA)).some(gA=>AA.excludeMatches.some(cA=>gA.variables().some(IA=>cA.equalsViaSyntax(context.fromAst(IA)))))||(sA=!0,lA=AA.patternVariables.map(gA=>context.fromAst(oA[gA]??BLANK$1)))),{setValue:{value:sA,allPatternMatches:lA}}}},eA.numMatches={description:"The number of matches found.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}),definition({dependencyValues:AA}){return{setValue:{numMatches:AA.allPatternMatches.length},checkForActualChange:{numMatches:!0}}}},eA.patternMatches={description:"The list of matched sub-expressions.",public:!0,highlighted:!0,shadowingInstructions:{createComponentOfType:"math"},isArray:!0,numDimensions:1,entryPrefixes:["patternMatch"],returnArraySizeDependencies:()=>({numMatches:{dependencyType:"stateVariable",variableName:"numMatches"}}),returnArraySize({dependencyValues:AA}){return[AA.numMatches]},returnArrayDependenciesByKey(){return{globalDependencies:{allPatternMatches:{dependencyType:"stateVariable",variableName:"allPatternMatches"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA={};for(let iA=0;iA<AA.__array_size[0];iA++)tA[iA]=AA.allPatternMatches[iA];return{setValue:{patternMatches:tA}}}},eA}}class Matrix extends MathComponent{static componentType="matrix";static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static additionalSchemaChildren=["row","column"];static returnChildGroups(){return[{group:"rows",componentTypes:["matrixRow"]},{group:"columns",componentTypes:["matrixColumn"]},{group:"maths",componentTypes:["math"],excludeFromSchema:!0}]}static createAttributesObject(){let eA=super.createAttributesObject();return eA.defaultEntry={createComponentOfType:"math",createStateVariable:"defaultEntry",defaultValue:context.fromAst(0),description:"Value used for entries that aren't explicitly specified."},eA.numRows={createComponentOfType:"integer",description:"Number of rows in the matrix."},eA.numColumns={createComponentOfType:"integer",description:"Number of columns in the matrix."},eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,componentInfoObjects:iA,nComponents:rA,stateIdInfo:aA}){if(tA.length===0)return{success:!1};let oA=[],sA=!1;for(let lA of tA)typeof lA!="string"&&(lA.doenetAttributes||(lA.doenetAttributes={}),lA.componentType==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.componentType="matrixColumn",sA=!0):lA.componentType==="row"?(lA.doenetAttributes.createNameFromComponentType="row",lA.componentType="matrixRow",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="column"?(lA.doenetAttributes.createNameFromComponentType="column",lA.attributes.createComponentOfType.primitive.value="matrixColumn",sA=!0):lA.attributes?.createComponentOfType?.primitive.value==="row"&&(lA.doenetAttributes.createNameFromComponentType="row",lA.attributes.createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(lA));return sA||(tA.length>1||!iA.componentIsSpecifiedType(tA[0],"math"))&&(oA=[{type:"serialized",componentType:"math",componentIdx:rA++,stateId:aA?`${aA.prefix}${aA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}]),{success:!0,newChildren:oA,nComponents:rA}};return eA.push({replacementFunction:AA}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.codePre,delete eA.mathChildrenFunctionSymbols,delete eA.expressionWithCodes,delete eA.mathChildrenWithCanBeModified,delete eA.codesAdjacentToStrings,delete eA.canBeModified,delete eA.mathChildrenByVectorComponent,Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.unordered={description:"Whether matrix entries should be treated as unordered.",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({}),definition(){return{setValue:{unordered:!1}}}},eA.matrixSizePre={returnDependencies:()=>({rowChildren:{dependencyType:"child",childGroups:["rows"],variableNames:["numComponents"]},colChildren:{dependencyType:"child",childGroups:["columns"],variableNames:["numComponents"]},mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["matrixSize"]},numRowsAttr:{dependencyType:"attributeComponent",attributeName:"numRows",variableNames:["value"]},numColumnsAttr:{dependencyType:"attributeComponent",attributeName:"numColumns",variableNames:["value"]}}),definition({dependencyValues:AA}){let tA=null,iA=null;return AA.numRowsAttr&&(tA=AA.numRowsAttr.stateValues.value,Number.isFinite(tA)&&tA>0||(tA=null)),AA.numColumnsAttr&&(iA=AA.numColumnsAttr.stateValues.value,Number.isFinite(iA)&&iA>0||(iA=null)),AA.rowChildren.length>0?(tA===null&&(tA=AA.rowChildren.length),iA===null&&(iA=Math.max(1,...AA.rowChildren.map(rA=>rA.stateValues.numComponents)))):AA.colChildren.length>0?(iA===null&&(iA=AA.colChildren.length),tA===null&&(tA=Math.max(1,...AA.colChildren.map(rA=>rA.stateValues.numComponents)))):AA.mathChildren.length===1?(tA===null&&(tA=AA.mathChildren[0].stateValues.matrixSize[0]),iA===null&&(iA=AA.mathChildren[0].stateValues.matrixSize[1])):tA===null?iA===null?(tA=0,iA=0):tA=1:iA===null&&(iA=1),{setValue:{matrixSizePre:[tA,iA]}}}},eA.matrixPre={isArray:!0,numDimensions:2,hasEssential:!0,returnArraySizeDependencies:()=>({matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),returnArraySize({dependencyValues:AA}){return AA.matrixSizePre},returnArrayDependenciesByKey:({arrayKeys:AA})=>{let tA={defaultEntry:{dependencyType:"stateVariable",variableName:"defaultEntry"},rowChildIdentities:{dependencyType:"child",childGroups:["rows"]},colChildIdentities:{dependencyType:"child",childGroups:["columns"]}},iA={};for(let rA of AA){let[aA,oA]=rA.split(",");iA[rA]={rowChild:{dependencyType:"child",childGroups:["rows"],childIndices:[aA],variableNames:["math"+(Number(oA)+1)]},colChild:{dependencyType:"child",childGroups:["columns"],childIndices:[oA],variableNames:["math"+(Number(aA)+1)]},mathChild:{dependencyType:"child",childGroups:["maths"],childIndices:[0],variableNames:["matrixEntry"+(Number(aA)+1)+"_"+(Number(oA)+1)]}}}return{globalDependencies:tA,dependenciesByKey:iA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA,arraySize:rA}){let aA={},oA={},sA=AA.rowChildIdentities.length>0,lA=AA.colChildIdentities.length>0;for(let gA of iA){let[cA,IA]=gA.split(","),uA;sA?uA=tA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]:lA?uA=tA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]:uA=tA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)],uA===void 0?oA[gA]={defaultValue:AA.defaultEntry}:aA[gA]=uA}return{setValue:{matrixPre:aA},useEssentialOrDefaultValue:{matrixPre:oA}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:iA,dependencyNamesByKey:rA}){let aA=[],oA={},sA=tA.rowChildIdentities.length>0,lA=tA.colChildIdentities.length>0;for(let gA in AA.matrixPre){let[cA,IA]=gA.split(",");sA?iA[gA].rowChild[0]?.stateValues["math"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].rowChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):lA?iA[gA].colChild[0]?.stateValues["math"+(Number(cA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].colChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0}):iA[gA].mathChild[0]?.stateValues["matrixEntry"+(Number(cA)+1)+"_"+(Number(IA)+1)]===void 0?oA[gA]=AA.matrixPre[gA]:aA.push({setDependency:rA[gA].mathChild,desiredValue:AA.matrixPre[gA],childIndex:0,variableIndex:0})}return Object.keys(oA).length>0&&aA.push({setEssentialValue:"matrixPre",value:oA}),{success:!0,instructions:aA}}},eA.unnormalizedValue={returnDependencies:()=>({matrixPre:{dependencyType:"stateVariable",variableName:"matrixPre"},matrixSizePre:{dependencyType:"stateVariable",variableName:"matrixSizePre"}}),hasEssential:!0,defaultValue:context.fromAst(["matrix",["tuple",0,0],["tuple"]]),definition({dependencyValues:AA}){let tA=["tuple"];for(let rA=0;rA<AA.matrixSizePre[0];rA++)tA.push(["tuple",...AA.matrixPre[rA].map(aA=>aA.tree)]);return{setValue:{unnormalizedValue:context.fromAst(["matrix",["tuple",...AA.matrixSizePre],tA])}}},inverseDefinition({dependencyValues:AA,desiredStateVariableValues:tA}){let iA=tA.unnormalizedValue.tree;if(!(Array.isArray(iA)&&iA[0]==="matrix"&&iA[1]?.[1]===AA.matrixSizePre[0]&&iA[1]?.[2]===AA.matrixSizePre[1]))return{success:!1};let rA={};for(let aA=0;aA<AA.matrixSizePre[0];aA++)for(let oA=0;oA<AA.matrixSizePre[1];oA++)rA[`${aA},${oA}`]=context.fromAst(iA[2][aA+1][oA+1]);return{success:!0,instructions:[{setDependency:"matrixPre",desiredValue:rA}]}}},eA.canBeModified={returnDependencies:()=>({modifyIndirectly:{dependencyType:"stateVariable",variableName:"modifyIndirectly"},fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:AA.modifyIndirectly&&!AA.fixed}}}},eA}}const{eigs,square,abs,divide}=context.math;class EigenDecomposition extends BaseComponent{static componentType="eigenDecomposition";static rendererType=void 0;static componentDocs={summary:"Computes the eigenvalues and eigenvectors of a square matrix"};static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.decomposition={description:"The eigendecomposition of the matrix as a list of eigenvalue/eigenvector pairs.",additionalStateVariablesDefined:[{variableName:"numEigenvectors",description:"The number of eigenvectors found in the decomposition.",public:!0,shadowingInstructions:{createComponentOfType:"integer"}}],returnDependencies:()=>({mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]}}),definition({dependencyValues:AA}){if(AA.mathChild.length===0)return{setValue:{decomposition:null,numEigenvectors:0}};let tA=AA.mathChild[0].stateValues.value.tree;if(!Array.isArray(tA)||tA[0]!=="matrix")return{setValue:{decomposition:null,numEigenvectors:0}};let iA=tA[1][1],rA=tA[1][2];if(!(Number.isInteger(iA)&&rA===iA))return{setValue:{decomposition:null,numEigenvectors:0}};let aA=[];for(let sA=0;sA<iA;sA++){let lA=[],gA=tA[2][sA+1]||[];for(let cA=0;cA<rA;cA++){let IA=gA[cA+1];if(IA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number")lA.push(IA);else try{IA=context.fromAst(IA).evaluate_to_constant(),typeof IA=="number"||typeof IA?.re=="number"&&typeof IA?.im=="number"?lA.push(IA):lA.push(NaN)}catch{lA.push(NaN)}}aA.push(lA)}let oA;try{oA=eigs(aA)}catch(sA){console.error("Could nt calculate eigenvalues of matrix",sA);let lA=codedDiagnostic({type:"warning",code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},sendDiagnostics:[lA]}}return{setValue:{decomposition:oA,numEigenvectors:oA.eigenvectors.length}}}},eA.eigenvalues={description:"The eigenvalues of the matrix.",isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing()},entryPrefixes:["eigenvalue"],returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA;return AA.decomposition?tA=AA.decomposition.values.length:tA=0,[tA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let iA=[];for(let rA=0;rA<tA[0];rA++)iA.push(AA.decomposition.values[rA]);return{setValue:{eigenvalues:iA}}}},eA.eigenvectors={description:"The eigenvectors of the matrix, as a 2D array (one column per eigenvalue).",isArray:!0,public:!0,numDimensions:2,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="eigenvectorX"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},getArrayKeysFromVarName({arrayEntryPrefix:AA,varEnding:tA,arraySize:iA}){if(AA==="eigenvectorX"){let rA=tA.split("_").map(aA=>Number(aA)-1);return rA.length===2&&rA.every((aA,oA)=>Number.isInteger(aA)&&aA>=0)?iA?rA.every((aA,oA)=>aA<iA[oA])?[String(rA)]:[]:[String(rA)]:[]}else{let rA=Number(tA)-1;return Number.isInteger(rA)&&rA>=0?iA?rA<iA[0]?Array.from(Array(iA[1]),(aA,oA)=>rA+","+oA):[]:[rA+",0"]:[]}},arrayVarNameFromPropIndex(AA,tA){if(tA==="eigenvectors")return AA.length===1?"eigenvector"+AA[0]:`eigenvectorX${AA[0]}_${AA[1]}`;if(tA.slice(0,11)==="eigenvector"){let iA=Number(tA.slice(11));if(Number.isInteger(iA)&&iA>0)return`eigenvectorX${iA}_${AA[0]}`}return null},indexAliases:[[],["x","y","z"]],entryPrefixes:["eigenvectorX","eigenvector"],returnEntryDimensions:AA=>AA==="eigenvector"?1:0,returnArraySizeDependencies:()=>({decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}),returnArraySize({dependencyValues:AA}){let tA,iA;return AA.decomposition?(tA=AA.decomposition.eigenvectors.length,iA=AA.decomposition.eigenvectors[0].vector.length):(tA=0,iA=0),[tA,iA]},returnArrayDependenciesByKey(){return{globalDependencies:{decomposition:{dependencyType:"stateVariable",variableName:"decomposition"}}}},arrayDefinitionByKey({globalDependencyValues:AA,arraySize:tA}){let iA={};for(let rA=0;rA<tA[0];rA++){let aA=[],oA=0;for(let sA=0;sA<tA[1];sA++){let lA=AA.decomposition.eigenvectors[rA].vector[sA];aA.push(lA),oA+=square(abs(lA))}oA=Math.sqrt(oA),aA=aA.map(sA=>divide(sA,oA));for(let sA=0;sA<tA[1];sA++)iA[`${rA},${sA}`]=aA[sA]}return{setValue:{eigenvectors:iA}}}},eA}}class Latex extends Text{static componentType="latex";static componentDocs={summary:"A snippet of LaTeX that can be rendered as math"};static rendererType="text";static createAttributesObject(){let eA=super.createAttributesObject();return eA.isLatex.defaultValue=!0,eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA[0].componentTypes.push("math","m","md"),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.value.returnDependencies=()=>({mathTextLikeChildren:{dependencyType:"child",childGroups:["textLike"],variableNames:["text","latex"],variablesOptional:!0}}),eA.value.definition=function({dependencyValues:AA}){if(AA.mathTextLikeChildren.length===0)return{useEssentialOrDefaultValue:{value:!0}};let tA=[];for(let rA of AA.mathTextLikeChildren)if(typeof rA=="string"){let aA=rA.trim();aA&&tA.push(aA)}else if(rA.stateValues.latex!==void 0){let aA=rA.stateValues.latex.trim();aA&&tA.push(aA)}else{let aA=rA.stateValues.text.trim();aA&&tA.push(aA)}return{setValue:{value:tA.join(" ")}}},eA.value.inverseDefinition=function({desiredStateVariableValues:AA,dependencyValues:tA}){let iA=tA.mathTextLikeChildren.length;return iA>1?{success:!1}:iA===1?{success:!0,instructions:[{setDependency:"textLikeChildren",desiredValue:AA.value,childIndex:0,variableIndex:tA.textLikeChildren[0].stateValues?.latex===void 0?0:1}]}:{success:!0,instructions:[{setEssentialValue:"value",value:AA.value===null?"":String(AA.value)}]}},eA.latex={isAlias:!0,targetVariableName:"value",description:"The LaTeX content as a string."},eA}}class BlockQuote extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="blockQuote";static rendererType="blockQuote";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static componentDocs={summary:"A block-level quotation"};static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}class Description extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="description";static componentDocs={summary:"Extra information about an enclosing component, shown to all users in a popup or disclosure"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static inSchemaOnlyInheritAs=[];static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnPassThroughListItemChildStateVariableDefinitions()),eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}const{mod:mod$1}=context.math;function findAttractedSegmentPointsSub({point1:nA,point2:eA,scales:AA,threshold2:tA,numericalNearestPointFunction:iA,numericalNearestPointAsLineFunction:rA,verifyNotOneSided:aA=!0}){let oA=1e-6,sA=oA**2,lA=rA(nA,AA);if(!lA)return{success:!1};let gA=lA.reduce((IA,uA,CA)=>IA+Math.pow(uA-nA[CA],2),0);if(gA>=tA)return{success:!1};let cA=rA(eA,AA);if(!cA)return{success:!1};if(gA=cA.reduce((IA,uA,CA)=>IA+Math.pow(uA-eA[CA],2),0),gA>=tA)return{success:!1};if(aA){let IA=iA(nA,AA),uA=IA&&IA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),CA=iA(eA,AA),dA=CA&&CA.every((pA,mA)=>Math.abs(pA-cA[mA])<oA);if(!(uA||dA)&&(gA=IA.reduce((pA,mA,QA)=>pA+Math.pow(mA-CA[QA],2),0),gA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:cA}}function findAttractedSegmentPoints({point1:nA,point2:eA,allowRotation:AA,scales:tA,threshold2:iA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA}){let oA=findAttractedSegmentPointsSub({point1:nA,point2:eA,scales:tA,threshold2:iA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!0});if(!oA.success)return{success:!1};let sA=1e-6,lA=sA**2,{nearestPoint1:gA,nearestPoint2:cA}=oA;if(!AA){let NA=[eA[0]-nA[0],eA[1]-nA[1]],yA=[cA[0]-gA[0],cA[1]-gA[1]],bA=Math.atan2(yA[1],yA[0])-Math.atan2(NA[1],NA[0]);if(bA=mod$1(bA+Math.PI,2*Math.PI)-Math.PI,Math.abs(bA)>sA)return{success:!1}}let IA=nA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0),uA=gA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0);if(Math.abs(IA-uA)<lA){let NA=gA.reduce((yA,bA,wA)=>yA+Math.pow(bA-nA[wA],2),0)+cA.reduce((yA,bA,wA)=>yA+Math.pow(bA-eA[wA],2),0);return NA<iA?{success:!0,distance2:NA,segment:[gA,cA]}:{success:!1}}if(uA>IA)return{success:!1};let CA=Math.sqrt(IA/uA),dA=Math.sqrt(nA.reduce((NA,yA,bA)=>NA+Math.pow(yA-gA[bA],2),0)),pA=Math.sqrt(eA.reduce((NA,yA,bA)=>NA+Math.pow(yA-cA[bA],2),0)),mA=dA/(dA+pA),QA=1-mA,BA=(CA-1)*mA+1,hA=(CA-1)*QA+1,DA=cA.map((NA,yA)=>NA+(gA[yA]-NA)*BA),EA=gA.map((NA,yA)=>NA+(cA[yA]-NA)*hA);if(oA=findAttractedSegmentPointsSub({point1:DA,point2:EA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let fA=DA.reduce((NA,yA,bA)=>NA+Math.pow(yA-nA[bA],2),0)+EA.reduce((NA,yA,bA)=>NA+Math.pow(yA-eA[bA],2),0);return fA<iA?{success:!0,distance2:fA,segment:[DA,EA]}:{success:!1}}function attractSegment({segment:nA,allowRotation:eA,scales:AA,threshold2:tA,numericalNearestPointFunctions:iA,numericalNearestPointAsLineFunctions:rA}){let aA=nA[0],oA=nA[1];if(aA.length!=oA.length)return{};let sA,lA=1/0,gA=eA?tA*1e3:tA;for(let[cA,IA]of iA.entries()){let uA=rA[cA],CA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:gA,numericalNearestPointFunction:IA,numericalNearestPointAsLineFunction:uA});CA.success&&CA.distance2<lA&&(lA=CA.distance2,sA=CA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<gA?{constrained:!1,distance2:lA,segment:sA}:{}}function nearestPointForSegment({point:nA,segment:eA,scales:AA}){let tA=eA[0][0],iA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(iA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===iA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-iA)/lA,IA=gA*gA+cA*cA,uA=((nA[0]-tA)/sA*gA+(nA[1]-iA)/lA*cA)/IA;return uA<=0?[tA,iA]:uA>=1?[rA,aA]:[tA+uA*gA*sA,iA+uA*cA*lA]}function nearestPointForSegmentAsLine({point:nA,segment:eA,scales:AA}){let tA=eA[0][0],iA=eA[0][1],rA=eA[1][0],aA=eA[1][1],oA=Number.isFinite(tA)&&Number.isFinite(iA)&&Number.isFinite(rA)&&Number.isFinite(aA);if(eA[0].length!==2||!oA||rA===tA&&aA===iA)return null;let sA=AA[0],lA=AA[1],gA=(rA-tA)/sA,cA=(aA-iA)/lA,IA=gA*gA+cA*cA,uA=((nA[0]-tA)/sA*gA+(nA[1]-iA)/lA*cA)/IA;return[tA+uA*gA*sA,iA+uA*cA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentDocs={summary:"Constrains group members to attract to each other when nearby"};static rendererType="containerInline";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.relativeToGraphScales={description:"Whether the snapping threshold is interpreted relative to graph scales.",createComponentOfType:"boolean",createStateVariable:"relativeToGraphScales",defaultValue:!1,public:!0},eA.threshold={createComponentOfType:"number",description:"Distance threshold within which group members snap together."},eA.angleThreshold={description:"Angular distance within which group members snap together.",createComponentOfType:"number",createStateVariable:"angleThreshold",defaultValue:Math.PI*.03,public:!0},eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"graphical",componentTypes:["_graphical"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnConstraintGraphInfoDefinitions();return Object.assign(eA,AA),eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.numObjects={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"]}}),definition({dependencyValues:tA}){return{setValue:{numObjects:tA.graphicalChildren.length}}}},eA.pointsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","numericalXs","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let iA=[];for(let rA of tA.graphicalChildren)rA.stateValues.numericalVertices?iA.push(rA.stateValues.numericalVertices):rA.stateValues.numericalXs?iA.push([rA.stateValues.numericalXs]):rA.stateValues.numericalEndpoints?iA.push(rA.stateValues.numericalEndpoints):iA.push([]);return{setValue:{pointsByObject:iA}}}},eA.getPointsForObject={returnDependencies:()=>({pointsByObject:{dependencyType:"stateVariable",variableName:"pointsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getPointsForObject:function(rA){return tA.pointsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.segmentsByObject={returnDependencies:()=>({graphicalChildren:{dependencyType:"child",childGroups:["graphical"],variableNames:["numericalVertices","closed","numericalEndpoints"],variablesOptional:!0}}),definition({dependencyValues:tA}){let iA=[];for(let rA of tA.graphicalChildren)if(rA.stateValues.numericalVertices){let aA=rA.stateValues.numericalVertices,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);rA.stateValues.closed&&sA.push([aA[oA-1],aA[0]]),iA.push(sA)}else if(rA.stateValues.numericalEndpoints){let aA=rA.stateValues.numericalEndpoints,oA=aA.length,sA=[];for(let lA=1;lA<oA;lA++)sA.push([aA[lA-1],aA[lA]]);iA.push(sA)}else iA.push([]);return{setValue:{segmentsByObject:iA}}}},eA.getSegmentsForObject={returnDependencies:()=>({segmentsByObject:{dependencyType:"stateVariable",variableName:"segmentsByObject"}}),definition({dependencyValues:tA}){return{setValue:{getSegmentsForObject:function(rA){return tA.segmentsByObject.filter((aA,oA)=>oA!==rA).reduce((aA,oA)=>(aA.push(...oA),aA),[])}}}}},eA.threshold={description:"Distance within which group members attract each other.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,returnDependencies:()=>({thresholdAttr:{dependencyType:"attributeComponent",attributeName:"threshold",variableNames:["value"]},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"}}),definition({dependencyValues:tA}){return tA.thresholdAttr?{setValue:{threshold:tA.thresholdAttr.stateValues.value}}:{useEssentialOrDefaultValue:{threshold:{get defaultValue(){return tA.relativeToGraphScales&&tA.graphXmin!==null?.02:.5}}}}},inverseDefinition({desiredStateVariableValues:tA,dependencyValues:iA}){return iA.thresholdAttr?{success:!0,instructions:[{setDependency:"thresholdAttr",desiredValue:tA.threshold}]}:{success:!0,instructions:[{setEssentialValue:"threshold",value:tA.threshold}]}}},eA.verticesConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},angleThreshold:{dependencyType:"stateVariable",variableName:"angleThreshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let iA;tA.relativeToGraphScales?iA=tA.scales||[1,1,1]:iA=[1,1,1];let rA=tA.angleThreshold,aA=function({numericalUnconstrainedEdges:cA,allowRotation:IA,enforceRigid:uA,shrinkThreshold:CA,rotationPoint:dA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),QA=[],BA=[],hA=!1,DA={distance2:1/0},EA=tA.threshold;CA&&(EA*=.2);let fA=EA*EA;for(let[NA,yA]of cA.entries()){let bA=[],wA=[];for(let vA of mA)bA.push((kA,TA)=>nearestPointForSegment({point:kA,segment:vA,scales:TA})),wA.push((kA,TA)=>nearestPointForSegmentAsLine({point:kA,segment:vA,scales:TA}));let MA=attractSegment({segment:yA,allowRotation:IA,scales:iA,threshold2:fA,numericalNearestPointFunctions:bA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(QA.push(MA.segment),BA.push(!0),hA=!0):(QA.push(yA),BA.push(!1),!hA&&MA.distance2<DA.distance2&&(DA=MA,DA.edgeInd=NA))}if(IA&&uA&&!hA&&DA.distance2<1/0){let NA=DA.edgeInd,yA=rotateIfClose({attractedEdgeInd:NA,attractingSegment:DA.segment,angleThreshold:rA,rotationPoint:dA,numericalUnconstrainedEdges:cA});yA&&(QA[NA]=yA,BA[NA]=!0,hA=!0)}if(IA&&uA&&!hA){let NA=[0,Math.PI/2],yA=rotateToAttractAngles({numericalUnconstrainedEdges:cA,anglesToAttract:NA,angleThreshold:rA,rotationPoint:dA});if(yA){let bA=yA.rotatedEdgeInd;QA[bA]=yA.rotatedEdge,BA[bA]=!0,hA=!0}}return{numericalConstrainedEdges:QA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:cA,closed:IA,shrinkThreshold:uA,onlyMoveVertexInd:CA=null},{objectInd:dA}){let pA=tA.getPointsForObject(dA),mA=tA.getSegmentsForObject(dA),QA=[],BA=[],hA=tA.threshold;uA&&(hA*=.2);let DA=hA*hA;for(let[yA,bA]of cA.entries()){if(CA!==null&&yA!==CA){QA.push(bA),BA.push(!1);continue}let wA=1/0,MA={};for(let TA of pA){if(bA.length!==TA.length)continue;let OA=bA.reduce((FA,RA,xA)=>FA+Math.pow((RA-TA[xA])/iA[xA],2),0);OA<wA&&(MA=TA,wA=OA)}let vA=!1,kA;if(wA<DA)vA=!0,kA=MA;else{wA=1/0,MA={};for(let TA of mA){let OA=nearestPointForSegment({point:bA,segment:TA,scales:iA});if(OA){let FA=bA.reduce((RA,xA,jA)=>RA+Math.pow((xA-OA[jA])/iA[jA],2),0);FA<wA&&(MA=OA,wA=FA)}}wA<DA?(vA=!0,kA=MA):kA=bA}QA.push(kA),BA.push(vA)}let EA=cA.length,fA=IA?EA:EA-1,NA=[];for(let yA=0;yA<fA;yA++){let bA=(yA+1)%EA;if(!(CA!==null&&!(CA===yA||CA===bA))&&!(BA[yA]||BA[bA])){let wA=cA[yA],MA=cA[bA],vA,kA=1/0;for(let TA of pA){let OA=nearestPointForSegment({point:TA,segment:[wA,MA],scales:iA});if(OA){let FA=OA.reduce((RA,xA,jA)=>RA+Math.pow(xA-TA[jA],2),0);if(FA<kA)if(CA===null){let RA=wA.map((jA,HA)=>jA+TA[HA]-OA[HA]),xA=MA.map((jA,HA)=>jA+TA[HA]-OA[HA]);vA=[RA,xA],kA=FA}else{let RA;CA===yA?RA=MA:RA=wA;let xA=[TA[0]-RA[0],TA[1]-RA[1]],jA=Math.sqrt(Math.pow(xA[0],2)+Math.pow(xA[1],2)),zA=Math.sqrt(Math.pow(wA[0]-MA[0],2)+Math.pow(wA[1]-MA[1],2))/jA;if(zA<1)continue;let GA=RA.map((JA,Or)=>JA+xA[Or]*zA),KA;CA===yA?(KA=[GA,MA],FA=Math.pow(wA[0]-GA[0],2)+Math.pow(wA[1]-GA[1],2)):(KA=[wA,GA],FA=Math.pow(MA[0]-GA[0],2)+Math.pow(MA[1]-GA[1],2)),FA<kA&&(kA=FA,vA=KA)}}}kA<DA&&NA.push({vertexInd1:yA,vertexInd2:bA,distance2:kA,movedSegment:vA})}}NA.sort((yA,bA)=>yA.distance2-bA.distance2);for(let{vertexInd1:yA,vertexInd2:bA,movedSegment:wA}of NA)BA[yA]||BA[bA]||(BA[yA]=!0,BA[bA]=!0,QA[yA]=wA[0],QA[bA]=wA[1]);return{numericalConstrainedVertices:QA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:cA,closed:IA,enforceRigid:uA,allowRotation:CA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}){let BA=sA({unconstrainedVertices:cA,closed:IA,enforceRigid:uA,allowRotation:CA,rotationPoint:dA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA});return BA=lA({unconstrainedVertices:BA,closed:IA,enforceRigid:uA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:QA}),BA}}}}},eA.pointConstraintFunction={returnDependencies:()=>({getPointsForObject:{dependencyType:"stateVariable",variableName:"getPointsForObject"},getSegmentsForObject:{dependencyType:"stateVariable",variableName:"getSegmentsForObject"},threshold:{dependencyType:"stateVariable",variableName:"threshold"},relativeToGraphScales:{dependencyType:"stateVariable",variableName:"relativeToGraphScales"},scales:{dependencyType:"stateVariable",variableName:"scales"}}),definition({dependencyValues:tA}){let iA;return tA.relativeToGraphScales?iA=tA.scales||[1,1,1]:iA=[1,1,1],{setValue:{pointConstraintFunction:function(aA,oA){let sA=aA.map(uA=>findFiniteNumericalValue(uA)),lA=tA.getPointsForObject(oA),gA=tA.getSegmentsForObject(oA),cA=1/0,IA={};for(let uA of lA){if(sA.length!==uA.length)continue;let CA=sA.reduce((dA,pA,mA)=>dA+Math.pow((pA-uA[mA])/iA[mA],2),0);CA<cA&&(IA=uA,cA=CA)}if(cA<tA.threshold*tA.threshold)return IA.map(uA=>context.fromAst(uA));cA=1/0,IA={};for(let uA of gA){let CA=nearestPointForSegment({point:sA,segment:uA,scales:iA});if(CA){let dA=sA.reduce((pA,mA,QA)=>pA+Math.pow((mA-CA[QA])/iA[QA],2),0);dA<cA&&(IA=CA,cA=dA)}}return cA<tA.threshold*tA.threshold?IA.map(uA=>context.fromAst(uA)):aA}}}}},eA}async addChildren(eA){return await addChildrenToDynamicChild(this,eA)}async deleteChildren(eA){return await deleteChildrenFromDynamicChild(this,eA)}}function rotateToAttractAngles({numericalUnconstrainedEdges:nA,anglesToAttract:eA,angleThreshold:AA,rotationPoint:tA}){let iA=1/0,rA;for(let[cA,IA]of nA.entries()){let uA=Math.atan((IA[1][1]-IA[0][1])/(IA[1][0]-IA[0][0]));for(let CA of eA){let dA=mod$6(CA-uA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(dA)<Math.abs(iA)&&(iA=dA,rA=cA)}}if(!(Math.abs(iA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(iA),lA=Math.sin(iA),gA=nA[rA].map(cA=>{let IA=cA[0]-aA,uA=cA[1]-oA;return[IA*sA-uA*lA+aA,IA*lA+uA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:gA}}function rotateIfClose({attractedEdgeInd:nA,attractingSegment:eA,angleThreshold:AA,rotationPoint:tA,numericalUnconstrainedEdges:iA}){let rA=Math.atan((eA[1][1]-eA[0][1])/(eA[1][0]-eA[0][0])),aA=iA[nA],oA=Math.atan((aA[1][1]-aA[0][1])/(aA[1][0]-aA[0][0])),sA=mod$6(rA-oA+Math.PI/2,Math.PI)-Math.PI/2;if(!(Math.abs(sA)<AA))return null;let[lA,gA]=tA,cA=Math.cos(sA),IA=Math.sin(sA);return iA[nA].map(CA=>{let dA=CA[0]-lA,pA=CA[1]-gA;return[dA*cA-pA*IA+lA,dA*IA+pA*cA+gA]})}class BlockScoredComponent extends BlockComponent{static componentType="_blockScoredComponent";static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnStandardAnswerAttributes()),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"disabled",newName:"disabledOriginal"}),Object.assign(eA,returnStandardAnswerStateVariableDefinition()),eA}}function parseIntegerResponse(nA){const eA=nA.trim();if(eA==="")return null;const AA=Number(eA);return Number.isInteger(AA)?AA:null}function isDistractorResponse(nA){return nA.trim().toLowerCase()==="x"}function calculateResponseOffset({numericResponse:nA,effectiveProblemNum:eA,numEffectiveProblems:AA}){return(nA-eA+AA)%AA}function calculatePretzelCredit({problemOrder:nA,currentResponses:eA,distractors:AA,mode:tA}){const iA=new Set(AA),rA=nA.length,aA=rA-iA.size;if(aA===0)return eA.every(isDistractorResponse)?1:0;const oA=Array(rA).fill(null);let sA=0;for(let uA=0;uA<rA;uA++)iA.has(uA)||(oA[uA]=sA,sA++);const lA=[],gA=tA==="circuit"?aA===1?0:1:null;for(let uA=0;uA<rA;uA++){const CA=nA[uA],dA=eA[uA]??"";if(iA.has(CA)){if(!isDistractorResponse(dA))return 0;continue}const pA=parseIntegerResponse(dA);if(pA===null)return 0;const mA=oA[CA],QA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(QA!==gA)return 0;continue}lA.push(QA)}if(tA==="circuit")return 1;const cA=lA[0];return lA.every(uA=>uA===cA)?1:0}class Pretzel extends BlockScoredComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this),submitAnswer:this.submitAnswer.bind(this)})}static componentType="pretzel";static componentDocs={summary:"A response-matching component where students enter a sequence to match statements and answers"};static renderChildren=!0;static additionalSchemaChildren=["problem"];static additionalSchemaChildrenDoNotInherit=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.maxNumColumns={description:"Maximum number of columns when arranging child problems.",createComponentOfType:"integer",createStateVariable:"maxNumColumns",defaultValue:2,public:!0,forRenderer:!0,clamp:[1,4]},eA.mode={description:"Arrangement mode for the child problems.",createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",public:!0,forRenderer:!0,toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static returnChildGroups(){return[{group:"problems",componentTypes:["statement"],excludeFromSchema:!0},{group:"textInputs",componentTypes:["textInput"],excludeFromSchema:!0},{group:"givenAnswers",componentTypes:["span"],excludeFromSchema:!0}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.textInputs={returnDependencies:()=>({textInputs:{dependencyType:"child",childGroups:["textInputs"]}}),definition:function({dependencyValues:AA}){return{setValue:{textInputs:AA.textInputs}}}},eA.problemOrder={stateVariablesDeterminingDependencies:["textInputs"],additionalStateVariablesDefined:["distractors"],returnDependencies({stateValues:AA}){return AA.textInputs.length>0?{problemOrder:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"problemOrder"},distractors:{dependencyType:"sourceCompositeStateVariable",replacementIdx:AA.textInputs[0].componentIdx,variableName:"distractors"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{problemOrder:AA.problemOrder??[],distractors:AA.distractors??[]}}}},eA.numProblems={description:"The number of child problems.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({problemChildren:{dependencyType:"child",childGroups:["problems"]}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.problemChildren.length}}}},eA.currentResponses={description:"The current responses across all child problems.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,entryPrefixes:["currentResponse"],returnArraySizeDependencies:()=>({numProblems:{dependencyType:"stateVariable",variableName:"numProblems"}}),returnArraySize({dependencyValues:AA}){return[AA.numProblems]},returnArrayDependenciesByKey({arrayKeys:AA}){const tA={};for(const iA of AA)tA[iA]={textInput:{dependencyType:"child",childGroups:["textInputs"],childIndices:[iA],variableNames:["value"]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA}){const tA={};for(const iA in AA)tA[iA]=AA[iA].textInput[0].stateValues.value;return{setValue:{currentResponses:tA}}}},eA.creditAchievedIfSubmit={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},currentResponses:{dependencyType:"stateVariable",variableName:"currentResponses"},distractors:{dependencyType:"stateVariable",variableName:"distractors"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=AA.problemOrder.map(iA=>iA-1);return{setValue:{creditAchievedIfSubmit:calculatePretzelCredit({problemOrder:tA,currentResponses:AA.currentResponses,distractors:AA.distractors,mode:AA.mode})}}}},eA.numSubmittedResponses={description:"The number of responses submitted.",public:!0,shadowingInstructions:{createComponentOfType:"number"},hasEssential:!0,defaultValue:0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{numSubmittedResponses:!0}}),inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"numSubmittedResponses",value:AA.numSubmittedResponses}]}}},eA.submittedResponses={description:"The most recently submitted responses.",public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,allowExtraArrayKeysInInverse:!0,entryPrefixes:["submittedResponse"],defaultValueByArrayKey:()=>"_",hasEssential:!0,inverseShadowToSetEntireArray:!0,doNotCombineInverseArrayInstructions:!0,returnArraySizeDependencies:()=>({numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}),returnArraySize({dependencyValues:AA}){return[AA.numSubmittedResponses]},returnArrayDependenciesByKey(){return{globalDependencies:{numSubmittedResponses:{dependencyType:"stateVariable",variableName:"numSubmittedResponses"}}}},arrayDefinitionByKey({globalDependencyValues:AA}){let tA=[];AA.submittedResponsesComponentType&&tA.push(...AA.submittedResponsesComponentType.slice(0,AA.numSubmittedResponses));let iA={};for(let rA=0;rA<AA.numSubmittedResponses;rA++)iA[rA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:iA}}},inverseArrayDefinitionByKey:function({desiredStateVariableValues:AA,initialChange:tA}){return tA?{success:!0,instructions:[{setDependency:"numSubmittedResponses",desiredValue:AA.submittedResponses.length},{setEssentialValue:"submittedResponses",value:[...AA.submittedResponses]}]}:{success:!1}}},eA.showCheckWork={forRenderer:!0,returnDependencies:()=>({suppressCheckWork:{dependencyType:"stateVariable",variableName:"suppressCheckWork"}}),definition({dependencyValues:AA}){return{setValue:{showCheckWork:!AA.suppressCheckWork}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}async submitAnswer({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(await this.stateValues.numAttemptsLeft<1||await this.stateValues.disabled)return;const aA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let oA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:aA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],sA=await this.stateValues.currentResponses;oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:sA}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies}),oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:await this.stateValues.numSubmissions+1}),aA<1&&oA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const lA=[];for(const gA of sA)if(gA.toString)try{lA.push(gA.toString())}catch{lA.push("_")}else lA.push(gA);return oA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:sA,responseText:lA,creditAchieved:aA}),await this.coreFunctions.performUpdate({updateInstructions:oA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:sA,responseText:lA,componentTypes:Array(sA.length).fill("text"),creditAchieved:aA}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function getCorrespondingAnswerIdx({problemIdx:nA,numProblems:eA,distractorSet:AA}){if(AA.has(nA))return nA;let tA=(nA-1+eA)%eA,iA=0;for(;AA.has(tA)&&iA<eA;)tA=(tA-1+eA)%eA,iA++;return tA}function normalizePretzelMode(nA){return nA?.toLowerCase()==="circuit"?"circuit":"pretzel"}function getProblemIndicesToPermute({numProblems:nA,mode:eA}){const AA=eA==="circuit"?2:1;return[...Array(Math.max(nA-AA+1,0)).keys()].map(tA=>tA+AA)}function buildProblemOrderFromPermutedIndices({permutedIndices:nA,numProblems:eA,mode:AA}){return AA==="circuit"?eA===0?[]:[1,...nA]:nA}function determineNumberOfPermutations({numProblems:nA,mode:eA}){const AA=getProblemIndicesToPermute({numProblems:nA,mode:eA}).length;let tA=1;for(let iA=2;iA<=AA;iA++)tA*=iA;return tA}function shuffleProblemOrder({numProblems:nA,variantRng:eA,mode:AA}){const tA=getProblemIndicesToPermute({numProblems:nA,mode:AA});for(let iA=tA.length-1;iA>0;iA--){const rA=eA(),aA=Math.floor(rA*(iA+1));[tA[iA],tA[aA]]=[tA[aA],tA[iA]]}return buildProblemOrderFromPermutedIndices({permutedIndices:tA,numProblems:nA,mode:AA})}class PretzelArranger extends CompositeComponent{static componentType="_pretzelArranger";static componentDocs={summary:"Internal arranger that lays out subset visualizations within <pretzel>."};static createsVariants=!0;static serializeReplacementsForChildren=!0;static replacementsAlreadyInResolver=!0;static useSerializedChildrenComponentIndices=!0;static createAttributesObject(){const eA=super.createAttributesObject();return eA.mode={createPrimitiveOfType:"string",createStateVariable:"mode",defaultValue:"pretzel",toLowerCase:!0,validValues:[{value:"pretzel",description:"Interleaved arrangement where each problem's answer feeds the next and one can start with any problem."},{value:"circuit",description:"A variant of the pretzel where one must start with the first problem."}]},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.serializedProblemChildren={returnDependencies:()=>({serializedChildren:{dependencyType:"serializedChildren",doNotProxy:!0}}),definition:function({dependencyValues:AA}){return{setValue:{serializedProblemChildren:AA.serializedChildren.filter(tA=>tA.componentType==="problem")}}}},eA.numProblems={description:"The number of problems arranged.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"}}),definition({dependencyValues:AA}){return{setValue:{numProblems:AA.serializedProblemChildren.length}}}},eA.problemOrder={forRenderer:!0,shadowVariable:!0,returnDependencies:({sharedParameters:AA})=>({mode:{dependencyType:"stateVariable",variableName:"mode"},numProblems:{dependencyType:"stateVariable",variableName:"numProblems"},variantSeed:{dependencyType:"value",value:AA.variantSeed},rngClass:{dependencyType:"value",value:AA.rngClass,doNotProxy:!0},variants:{dependencyType:"variants"}}),definition:function({dependencyValues:AA}){let tA=AA.numProblems,iA=[],rA;const aA=AA.mode;let oA=AA.variants?.desiredVariant?.indices;if(oA!==void 0)if(oA.length!==tA)iA.push(codedDiagnostic({type:"info",code:"doenet-i0005"}));else{if(oA=oA.map(Number),!oA.every(Number.isInteger))throw Error("All indices specified for pretzel must be integers");if(!oA.every(lA=>lA>=1&&lA<=tA))iA.push(codedDiagnostic({type:"info",code:"doenet-i0007",args:{component:"pretzel"}}));else if(new Set(oA).size!==tA)iA.push(codedDiagnostic({type:"info",code:"doenet-i0008"}));else if(aA==="circuit"&&tA>0&&oA[0]!==1)iA.push(codedDiagnostic({type:"info",code:"doenet-i0009"}));else return{setValue:{problemOrder:oA}}}let sA=AA.rngClass(AA.variantSeed+"co");return rA=shuffleProblemOrder({numProblems:tA,variantRng:sA,mode:aA}),{setValue:{problemOrder:rA},sendDiagnostics:iA}}},eA.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({componentInfoObjects:AA,sharedParameters:tA})=>({variantSeed:{dependencyType:"value",value:tA.variantSeed},problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(AA.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],useReplacementsForComposites:!0,recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:AA,componentIdx:tA}){let iA={seed:AA.variantSeed,meta:{createdBy:tA},indices:AA.problemOrder},rA=iA.subvariants=[];for(let aA of AA.variantDescendants)aA.stateValues.isVariantComponent?rA.push(aA.stateValues.generatedVariantInfo):aA.stateValues.generatedVariantInfo&&rA.push(...aA.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:iA,isVariantComponent:!0}}}},eA.statements={additionalStateVariablesDefined:["givenAnswers","validProblems","distractors"],returnDependencies:()=>({serializedProblemChildren:{dependencyType:"stateVariable",variableName:"serializedProblemChildren"},mode:{dependencyType:"stateVariable",variableName:"mode"}}),definition({dependencyValues:AA}){const tA=[],iA=[],rA=[];let aA=!0;const oA=[];for(const[sA,lA]of AA.serializedProblemChildren.entries()){let gA=null,cA=null;for(const IA of lA.children)if(IA.componentType==="statement")gA=IA;else if(IA.componentType==="givenAnswer"){const uA=IA.children.find(CA=>CA.componentType==="_postponeRenderContainer");uA&&(cA={...uA,componentType:"span",attributes:{...uA.attributes},children:(uA.children??[]).filter(CA=>CA.componentType!=="label"&&CA.componentType!=="shortDescription")},cA.componentIdx=IA.componentIdx,IA.attributes.name&&(cA.attributes.name=IA.attributes.name))}(gA===null||cA===null)&&(aA=!1),tA.push(gA),iA.push(cA),lA.attributes.isDistractor?.primitive.value&&rA.push(sA)}return aA||oA.push(codedDiagnostic({type:"warning",code:"doenet-w0076"})),AA.mode==="circuit"&&rA.includes(0)&&oA.push(codedDiagnostic({type:"error",code:"doenet-e0001"})),{setValue:{statements:tA,givenAnswers:iA,validProblems:aA,distractors:rA},sendDiagnostics:oA}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({problemOrder:{dependencyType:"stateVariable",variableName:"problemOrder"},statements:{dependencyType:"stateVariable",variableName:"statements"},givenAnswers:{dependencyType:"stateVariable",variableName:"givenAnswers"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){tA.replacementsCreated===void 0&&(tA.replacementsCreated=0);const iA={prefix:`${eA.stateId}|`,num:tA.replacementsCreated},rA=[];let aA=[];const oA=await eA.stateValues.numProblems,sA=await eA.stateValues.problemOrder,lA=await eA.stateValues.statements,gA=await eA.stateValues.givenAnswers,cA=await eA.stateValues.distractors,IA=await eA.stateValues.mode,uA=new Set(cA);for(let CA=0;CA<oA;CA++){const dA=sA[CA]-1,pA=lA[dA],mA=getCorrespondingAnswerIdx({problemIdx:dA,numProblems:oA,distractorSet:uA}),QA=gA[mA];QA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(QA),aA.push({type:"serialized",componentType:"textInput",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{width:{type:"component",name:"width",component:{type:"serialized",componentType:"componentSize",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{componentSize:{size:15,isAbsolute:!0}},children:[],attributes:{},doenetAttributes:{}}}},doenetAttributes:{},state:IA==="circuit"&&CA===0?{value:"1",disabledPreliminary:!0}:{},children:[{type:"serialized",componentType:"shortDescription",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{},children:[{type:"serialized",componentType:"text",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,state:{value:"Enter number in sequence for this answer or X if it is a distractor"},children:[],attributes:{},doenetAttributes:{}}],attributes:{},doenetAttributes:{}}]}),pA===null?aA.push({type:"serialized",componentType:"statement",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(pA)}return tA.replacementsCreated=iA.num,{replacements:aA,diagnostics:rA,nComponents:AA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}static determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA}){let iA=0;const rA=normalizePretzelMode(eA.attributes.mode?.primitive?.value);for(let lA of eA.children)if(lA.componentType==="problem")iA++;else if(AA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:"_composite"})&&lA.attributes.createComponentOfType?.primitive.value==="problem")if(lA.attributes.numProblems?.primitive!==void 0){let gA=Number(lA.attributes.numProblems?.primitive.value);if(Number.isInteger(gA)&&gA>=0)iA+=gA;else return{success:!1}}else iA++;else return{success:!1};let aA=determineNumberOfPermutations({numProblems:iA,mode:rA}),oA=super.determineNumberOfUniqueVariants({serializedComponent:eA,componentInfoObjects:AA,infoDiagnostics:tA});if(!oA.success)return{success:!1};let sA=oA.numVariants*aA;return eA.variants.numVariants=sA,eA.variants.uniqueVariantData={numVariantsByDescendant:eA.variants.uniqueVariantData.numVariantsByDescendant,numberOfPermutations:aA,numProblems:iA,mode:rA},{success:!0,numVariants:sA}}static getUniqueVariant({serializedComponent:eA,variantIndex:AA,componentInfoObjects:tA}){let iA=eA.variants?.numVariants;if(iA===void 0)return{success:!1};if(!Number.isInteger(AA)||AA<1||AA>iA)return{success:!1};let rA=eA.variants.uniqueVariantData.numVariantsByDescendant,aA=eA.variants.descendantVariantComponents,oA=eA.variants.uniqueVariantData.numberOfPermutations,sA=eA.variants.uniqueVariantData.numProblems;const lA=normalizePretzelMode(eA.variants.uniqueVariantData.mode);let gA=[...rA];gA.push(oA);let cA=enumerateCombinations({numberOfOptionsByIndex:gA,maxNumber:AA})[AA-1].map(BA=>BA+1),IA=cA.pop(),uA=cA;const CA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),dA=buildProblemOrderFromPermutedIndices({permutedIndices:enumeratePermutations({values:CA,maxNumber:IA})[IA-1],numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let hA=aA[BA],EA=tA.allComponentClasses[hA.componentType].getUniqueVariant({serializedComponent:hA,variantIndex:uA[BA],componentInfoObjects:tA});if(!EA.success)return{success:!1};mA.push(EA.desiredVariant),pA=!0}else mA.push({});let QA={indices:dA};return pA&&(QA.subvariants=mA),{success:!0,desiredVariant:QA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static componentDocs={summary:"Reveals its children one step at a time, each once the steps before it are complete"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!1;static createAttributesObject(){let eA=super.createAttributesObject();return eA.hideFutureSections={createComponentOfType:"boolean",createStateVariable:"hideFutureSections",defaultValue:!1,public:!0,description:"Whether to hide later cascade sections until previous ones are completed."},eA.revealAll={createComponentOfType:"boolean",createStateVariable:"revealAllPreliminary",defaultValue:!1,description:"Whether all cascade entries should be revealed regardless of progress."},eA.boxAll={createComponentOfType:"boolean",createStateVariable:"boxAll",defaultValue:!1,description:"Whether to draw boxes around all cascade entries regardless of progress."},Object.assign(eA,returnSectionTitleStateColorAttributes()),eA}static returnChildGroups(){return[{group:"titles",componentTypes:["title"]},{group:"setups",componentTypes:["setup"]},{group:"cascadeMessages",componentTypes:["cascadeMessage"]},{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();Object.assign(eA,returnCascadeStepStateVariableDefinitions()),Object.assign(eA,returnSectionTitleStateColorStateVariableDefinitions()),eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},titleChildren:{dependencyType:"child",childGroups:["titles"]},asList:{dependencyType:"stateVariable",variableName:"asList"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"}}),definition({dependencyValues:tA,componentInfoObjects:iA}){const rA=new Set(tA.titleChildren.map(sA=>sA.componentIdx)),aA=[];for(const[sA,lA]of tA.allChildren.entries()){if(typeof lA=="string"){!tA.hideChildren&&!tA.asList&&aA.push(sA);continue}rA.has(lA.componentIdx)||tA.asList&&!LIST_CONTAINER_TYPES.some(gA=>iA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:gA}))&&!["introduction","conclusion"].includes(lA.componentType)||aA.push(sA)}const oA=tA.titleChildren.map(sA=>codedDiagnostic({type:"warning",code:"doenet-w0167",position:sA.position||void 0}));return{setValue:{childIndicesToRender:aA},sendDiagnostics:oA}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this cascade's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:tA}){return{setValue:{asList:!!tA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA.childrenAggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{childrenAggregateScores:!0}})};const AA=returnScoredSectionStateVariableDefinition();return eA.aggregateScores={returnDependencies:()=>({}),definition:()=>({setValue:{aggregateScores:!0}})},eA.scoredDescendants=AA.scoredDescendants,eA.creditAchievedForProgress=AA.creditAchievedForProgress,eA.childCreditAchieved={returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["creditAchievedForProgress"],variablesOptional:!0}}),definition({dependencyValues:tA}){return{setValue:{childCreditAchieved:tA.children.map(rA=>rA.stateValues?.creditAchievedForProgress??null)}}}},eA.numCompleted={description:"The number of cascade sections currently completed.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({childCreditAchieved:{dependencyType:"stateVariable",variableName:"childCreditAchieved"}}),definition({dependencyValues:tA}){let iA=0;for(const rA of tA.childCreditAchieved)if(rA===1||rA===null)iA++;else break;return{setValue:{numCompleted:iA}}}},eA.revealAll={returnDependencies:()=>({cascadeAncestor:{dependencyType:"ancestor",componentType:"cascade",variableNames:["revealAll"]},revealAllPreliminary:{dependencyType:"stateVariable",variableName:"revealAllPreliminary"}}),definition({dependencyValues:tA,usedDefault:iA}){let rA=!1;return iA.revealAllPreliminary?tA.cascadeAncestor&&(rA=tA.cascadeAncestor.stateValues.revealAll):rA=tA.revealAllPreliminary,{setValue:{revealAll:rA}}}},eA.childrenToHide={additionalStateVariablesDefined:["childrenToHideChildren","sectionToShowCascadeMessage"],returnDependencies:()=>({hideFutureSections:{dependencyType:"stateVariable",variableName:"hideFutureSections"},numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"],variableNames:["hasCascadeMessageToShow"],variablesOptional:!0},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"},hideChildren:{dependencyType:"stateVariable",variableName:"hideChildren"},showCascadeMessage:{dependencyType:"stateVariable",variableName:"showCascadeMessage"}}),definition({dependencyValues:tA,componentInfoObjects:iA}){const rA=tA.childrenWithCascadeMessages.filter(cA=>cA.componentType==="cascadeMessage").map(cA=>cA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[cA,IA]of tA.children.entries())cA<=tA.numCompleted?tA.hideChildren&&aA.push(IA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(uA=>iA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:uA}))?oA.push(IA.componentIdx):aA.push(IA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,gA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(cA=>cA!==gA)),{setValue:{childrenToHide:aA,childrenToHideChildren:oA,sectionToShowCascadeMessage:lA}}}},eA.hasCascadeMessageToShow={returnDependencies:()=>({numCompleted:{dependencyType:"stateVariable",variableName:"numCompleted"},children:{dependencyType:"child",childGroups:["anything"]},childrenWithCascadeMessages:{dependencyType:"child",childGroups:["anything","cascadeMessages"]},revealAll:{dependencyType:"stateVariable",variableName:"revealAll"}}),definition({dependencyValues:tA}){return{setValue:{hasCascadeMessageToShow:nextOwnCascadeMessage(tA)!==null}}}},eA}recordVisibilityChange({isVisible:eA}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{isVisible:eA}})}}function nextOwnCascadeMessage(nA){if(nA.revealAll||nA.numCompleted>nA.children.length-2)return null;const eA=nA.children[nA.numCompleted].componentIdx,AA=nA.childrenWithCascadeMessages.findIndex(tA=>tA.componentIdx===eA);return nA.childrenWithCascadeMessages.slice(AA+1).find(tA=>tA.componentType==="cascadeMessage")?.componentIdx??null}class Page extends BlockComponent{static componentType="page";static componentDocs={summary:"The content of one printed page"};static rendererType="containerBlock";static renderChildren=!0;static canDisplayChildErrors=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.childIndicesToRender={returnDependencies:()=>({allChildren:{dependencyType:"child",includeAllChildren:!0},asList:{dependencyType:"stateVariable",variableName:"asList"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){const iA=[];for(const[rA,aA]of AA.allChildren.entries())(!AA.asList||typeof aA!="string"&&(LIST_CONTAINER_TYPES.some(oA=>tA.isInheritedComponentType({inheritedComponentType:aA.componentType,baseComponentType:oA}))||["introduction","conclusion"].includes(aA.componentType)))&&iA.push(rA);return{setValue:{childIndicesToRender:iA}}},markStale:()=>({updateRenderedChildren:!0})},eA.isListItem={returnDependencies:()=>({}),definition:()=>({setValue:{isListItem:!1}})},eA.asList={description:"Whether this page's children are rendered as a list, which is whatever its parent does.",public:!0,forRenderer:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({parentAsList:{dependencyType:"parentStateVariable",variableName:"asList"}}),definition({dependencyValues:AA}){return{setValue:{asList:!!AA.parentAsList}}}},Object.assign(eA,returnSequencePassThroughDefinitions(DIVISION_SEQUENCE),returnSequencePassThroughDefinitions(LIST_ITEM_SEQUENCE)),eA}}class DynamicChildren extends CompositeComponent{constructor(eA){super(eA),Object.assign(this.actions,{addChildren:this.addChildren.bind(this),deleteChildren:this.deleteChildren.bind(this)})}static componentType="_dynamicChildren";static componentDocs={summary:"Internal container for dynamically-generated children."};static treatAsComponentForRecursiveReplacements=!0;static stateVariableToEvaluateAfterReplacements="readyToExpandWhenResolved";static createAttributesObject(){let eA=super.createAttributesObject();return eA.deferUntilParentRendered={createComponentOfType:"boolean",createStateVariable:"deferUntilParentRendered",defaultValue:!1,description:"Whether to wait until the parent is rendered before creating dynamic children."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.dynamicChildren={hasEssential:!0,defaultValue:[],returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{dynamicChildren:!0}}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"dynamicChildren",value:AA.dynamicChildren}]}}},eA.createReplacements={stateVariablesDeterminingDependencies:["deferUntilParentRendered"],returnDependencies:({stateValues:AA})=>{const tA={deferUntilParentRendered:{dependencyType:"stateVariable",variableName:"deferUntilParentRendered"}};return AA.deferUntilParentRendered&&(tA.parentRendered={dependencyType:"parentStateVariable",variableName:"rendered"}),tA},definition({dependencyValues:AA}){return{setValue:{createReplacements:!AA.deferUntilParentRendered||AA.parentRendered!==!1}}},markStale(){return{updateReplacements:!0}}},eA.nGroups={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"}}),definition({dependencyValues:AA}){return{setValue:{nGroups:AA.dynamicChildren.length}}}},eA.readyToExpandWhenResolved={returnDependencies:()=>({dynamicChildren:{dependencyType:"stateVariable",variableName:"dynamicChildren"},createReplacements:{dependencyType:"stateVariable",variableName:"createReplacements"}}),definition:function(){return{setValue:{readyToExpandWhenResolved:!0}}},markStale(){return{updateReplacements:!0}}},eA}async addChildren({serializedComponents:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){if(eA&&eA.length>0){const rA=[...await this.stateValues.dynamicChildren];return rA.push({type:"serialized",componentType:"group",componentIdx:0,attributes:{},doenetAttributes:{},state:{},children:deepClone(eA)}),await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:rA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}else return}async deleteChildren({number:eA,actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}){const rA=await this.stateValues.nGroups;let aA=Math.min(eA,rA);if(aA>0){const oA=(await this.stateValues.dynamicChildren).slice(0,rA-aA);return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"dynamicChildren",value:oA}],actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}else return}static async createSerializedReplacements({component:eA,nComponents:AA,workspace:tA}){let iA=[];tA.replacementsCreated===void 0&&(tA.replacementsCreated=0),tA.replacementsCreatedThroughGroup=[];let rA=[];if(!await eA.stateValues.createReplacements)return tA.nGroups=0,{replacements:rA,diagnostics:iA,nComponents:AA};const aA=await eA.stateValues.nGroups;for(let oA=0;oA<aA;oA++){let sA=await this.replacementForGroup({component:eA,groupNum:oA,nComponents:AA,workspace:tA}),lA=sA.replacements;AA=sA.nComponents,rA.push(...lA)}return tA.nGroups=aA,{replacements:rA,diagnostics:iA,nComponents:AA}}static async replacementForGroup({component:eA,groupNum:AA,nComponents:tA,workspace:iA}){let rA=[deepClone((await eA.stateValues.dynamicChildren)[AA])];const aA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated},oA=createNewComponentIndices(rA,tA,aA);return rA=oA.components,tA=oA.nComponents,iA.replacementsCreated=aA.num,iA.replacementsCreatedThroughGroup=[...iA.replacementsCreatedThroughGroup,iA.replacementsCreated],{replacements:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,nComponents:AA,workspace:tA}){const rA=await eA.stateValues.createReplacements?await eA.stateValues.nGroups:0;if(rA===tA.nGroups)return{replacementChanges:[],nComponents:AA};if(rA<tA.nGroups){const sA=[{changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:rA,numberReplacementsToDelete:tA.nGroups-rA}];return tA.nGroups=rA,tA.replacementsCreated=tA.replacementsCreatedThroughGroup[rA-1]||0,tA.replacementsCreatedThroughGroup=tA.replacementsCreatedThroughGroup.slice(0,rA),{replacementChanges:sA,nComponents:AA}}let aA=[];for(let sA=tA.nGroups;sA<rA;sA++){let lA=await this.replacementForGroup({component:eA,groupNum:sA,nComponents:AA,workspace:tA}),gA=lA.replacements;AA=lA.nComponents,aA.push(...gA)}let oA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA.nGroups,numberReplacementsToReplace:0,serializedReplacements:aA,replacementsToWithhold:0};return tA.nGroups=rA,{replacementChanges:[oA],nComponents:AA}}}class ShortDescription extends TextOrInline{static componentType="shortDescription";static componentDocs={summary:"A short accessibility description (e.g. for a `<graph>`) read by screen readers"};static rendererType=void 0;static inSchemaOnlyInheritAs=[];static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.inlineChildren={returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text","hidden"],variablesOptional:!0}}),definition:({dependencyValues:AA})=>({setValue:{inlineChildren:AA.inlineChildren}})},eA.value={description:"The short description text.",public:!0,shadowingInstructions:{createComponentOfType:this.componentType},stateVariablesDeterminingDependencies:["inlineChildren"],returnDependencies:({stateValues:AA})=>{const tA={inlineChildren:{dependencyType:"stateVariable",variableName:"inlineChildren"}};for(const[iA,rA]of AA.inlineChildren.entries())typeof rA=="object"&&(tA[`adapterSource${iA}`]={dependencyType:"adapterSource",componentIdx:rA.componentIdx});return tA},definition({dependencyValues:AA,componentInfoObjects:tA}){const iA=textFromChildren(AA.inlineChildren);let rA;for(let oA=0;oA<AA.inlineChildren.length;oA++){const sA=AA.inlineChildren[oA];if(typeof sA!="object")continue;const lA=AA[`adapterSource${oA}`]?.componentType??sA.componentType;if(tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"math"})||tA.isInheritedComponentType({inheritedComponentType:lA,baseComponentType:"m"})){rA=lA;break}}const aA=[];return rA&&aA.push(codedDiagnostic({type:"accessibility",level:2,code:"doenet-a0005",args:{component:rA}})),{setValue:{value:iA},sendDiagnostics:aA}}},eA}}const unitConversions={"":1,px:1,pixel:1,pixels:1,"%":1,em:100,in:96,inch:96,inches:96,pt:1.333333333333,mm:3.7795296,millimeter:3.7795296,millimeters:3.7795296,cm:37.795296,centimeter:37.795296,centimeters:37.795296};class ComponentSize extends InlineComponent{static componentType="componentSize";static rendererType="text";static excludeFromSchema=!0;static primaryStateVariableForDefinition="componentSize";static stateVariableToBeShadowed="componentSize";static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=tA[tA.length-1];if(typeof aA=="string"){let oA=/([a-zA-z]+|%)$/,sA=aA.trim(),lA=sA.match(oA);if(lA){let gA=lA[1];if(gA in unitConversions){let cA=sA.slice(0,lA.index),IA=tA.slice(0,tA.length-1);return cA.length>0&&IA.push(cA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:IA,attributes:{},doenetAttributes:{},state:{}},gA],nComponents:iA}}}}return{success:!0,newChildren:[{componentType:"number",children:tA}]}};return eA.push({childrenRegex:/..+/,replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"strings",componentTypes:["string"]},{group:"numbers",componentTypes:["number"]},{group:"componentSizes",componentTypes:["componentSize"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions(),AA=returnSelectedStyleStateVariableDefinition();Object.assign(eA,AA);let tA=returnTextStyleDescriptionDefinitions();return Object.assign(eA,tA),eA.componentSize={description:"The size value with its associated unit (absolute pixels or relative percent).",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},hasEssential:!0,returnDependencies:()=>({componentSizeChild:{dependencyType:"child",childGroups:["componentSizes"],variableNames:["componentSize"]},numberChild:{dependencyType:"child",childGroups:["numbers"],variableNames:["value"]},stringChild:{dependencyType:"child",childGroups:["strings"],variableNames:["value"]},parentDefaultAbsoluteSize:{dependencyType:"parentStateVariable",variableName:"defaultAbsoluteSize"}}),definition({dependencyValues:iA}){let rA=iA.parentDefaultAbsoluteSize===void 0?!1:iA.parentDefaultAbsoluteSize;if(iA.stringChild.length===0)return iA.numberChild.length===0?iA.componentSizeChild.length===0?{useEssentialOrDefaultValue:{componentSize:{defaultValue:{size:100,isAbsolute:rA}}}}:{setValue:{componentSize:iA.componentSizeChild[0].stateValues.componentSize}}:{setValue:{componentSize:{size:iA.numberChild[0].stateValues.value,isAbsolute:!0}}};{let aA,oA;if(iA.numberChild.length>0)aA=iA.numberChild[0].stateValues.value,oA=iA.stringChild[0].trim();else{let cA=iA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(cA===null)return{setValue:{componentSize:null}};aA=cA[1],oA=cA[2].trim()}if(aA=Number(aA),!Number.isFinite(aA))return{setValue:{componentSize:null}};let sA=!(oA==="%"||oA==="em"),lA=unitConversions[oA];return lA===void 0&&(lA=1),{setValue:{componentSize:{size:lA*aA,isAbsolute:sA}}}}},inverseDefinition({desiredStateVariableValues:iA,dependencyValues:rA}){if(rA.stringChild.length===0)return rA.numberChild.length===0?rA.componentSizeChild.length===0?{success:!0,instructions:[{setEssentialValue:"componentSize",value:iA.componentSize}]}:{success:!0,instructions:[{setDependency:"componentSizeChild",desiredValue:iA.componentSize,childIndex:0,variableIndex:0}]}:iA.componentSize.isAbsolute?{success:!0,instructions:[{setDependency:"numberChild",desiredValue:iA.componentSize.size,childIndex:0,variableIndex:0}]}:{success:!1};if(rA.numberChild.length>0){let aA=rA.stringChild[0].trim(),oA=!(aA==="%"||aA==="em");if(iA.componentSize.isAbsolute!==oA)return{success:!1};let sA=unitConversions[aA];return sA===void 0&&(sA=1),{success:!0,instructions:[{setDependency:"numberChild",desiredValue:iA.componentSize.size/sA,childIndex:0,variableIndex:0}]}}else{let aA=iA.componentSize.size;return iA.componentSize.isAbsolute?aA+="px":aA+="%",{success:!0,instructions:[{setDependency:"stringChild",desiredValue:aA,childIndex:0,variableIndex:0}]}}}},eA.number={description:"The numeric portion of the size.",public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA=null;return iA.componentSize&&(rA=iA.componentSize.size),{setValue:{number:rA}}},inverseDefinition({desiredStateVariableValues:iA,dependencyValues:rA}){return rA.componentSize?{success:!0,instructions:[{setDependency:"componentSize",desiredValue:{size:iA.number,isAbsolute:rA.componentSize.isAbsolute}}]}:{success:!1}}},eA.math=mathStateVariableFromNumberStateVariable({numberVariableName:"number",mathVariableName:"math",isPublic:!0}),eA.math.description="The size as a math expression.",eA.isAbsolute={description:"Whether the size uses absolute units (pixels) rather than relative units (percent).",public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA=null;return iA.componentSize&&(rA=iA.componentSize.isAbsolute),{setValue:{isAbsolute:rA}}}},eA.text={forRenderer:!0,returnDependencies:()=>({componentSize:{dependencyType:"stateVariable",variableName:"componentSize"}}),definition({dependencyValues:iA}){let rA="";return iA.componentSize&&(rA=iA.componentSize.size,iA.componentSize.isAbsolute?rA+="px":rA+="%"),{setValue:{text:rA}}}},eA}static adapters=["number","math"]}class ComponentSizeList extends BaseComponent{static componentType="_componentSizeList";static rendererType="asList";static renderChildren=!0;static stateVariableToBeShadowed="componentSizes";static additionalSchemaChildren=["string","number"];static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=[],oA=[],sA=function(){oA.length>0&&(aA.push({type:"serialized",componentType:"componentSize",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}}),oA=[])};for(let lA of tA)if(typeof lA=="string"){let gA=lA.split(/\s+/);gA[0].length===0&&(sA(),gA=gA.slice(1));for(let[cA,IA]of gA.entries())IA.length>0?(oA.push(IA),cA<gA.length-1&&sA()):sA()}else oA.push(lA);return sA(),{success:!0,newChildren:aA,nComponents:iA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"componentSizes",componentTypes:["componentSize"]},{group:"componentSizeLists",componentTypes:["_componentSizeList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.overrideChildHide={returnDependencies:()=>({}),definition:()=>({setValue:{overrideChildHide:!0}})},eA.numComponents={description:"The number of size values in the list.",public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:["childIndexByArrayKey"],returnDependencies(){return{componentSizeListChildren:{dependencyType:"child",childGroups:["componentSizeLists"],variableNames:["numComponents"]},componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],skipComponentIndices:!0}}},definition:function({dependencyValues:AA,componentInfoObjects:tA}){let iA=0,rA=[],aA=0;for(let[oA,sA]of AA.componentSizeAndComponentSizeListChildren.entries())if(tA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.componentSizeListChildren[aA];aA++;for(let gA=0;gA<lA.stateValues.numComponents;gA++)rA[iA+gA]=[oA,gA];iA+=lA.stateValues.numComponents}else rA[iA]=[oA,0],iA+=1;return{setValue:{numComponents:iA,childIndexByArrayKey:rA},checkForActualChange:{numComponents:!0}}}},eA.componentSizes={description:"The list of component sizes.",public:!0,shadowingInstructions:{createComponentOfType:"componentSize"},isArray:!0,entryPrefixes:["componentSize"],stateVariablesDeterminingDependencies:["childIndexByArrayKey"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA,stateValues:tA}){let iA={},rA={childIndexByArrayKey:{dependencyType:"stateVariable",variableName:"childIndexByArrayKey"}};for(let aA of AA){let oA=[],sA="1";tA.childIndexByArrayKey[aA]&&(oA=[tA.childIndexByArrayKey[aA][0]],sA=tA.childIndexByArrayKey[aA][1]+1),iA[aA]={componentSizeAndComponentSizeListChildren:{dependencyType:"child",childGroups:["componentSizes","componentSizeLists"],variableNames:["componentSize","componentSize"+sA],variablesOptional:!0,childIndices:oA}}}return{globalDependencies:rA,dependenciesByKey:iA}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA,componentInfoObjects:rA}){let aA={};for(let oA of iA){let sA=tA[oA].componentSizeAndComponentSizeListChildren[0];if(sA)if(rA.isInheritedComponentType({inheritedComponentType:sA.componentType,baseComponentType:"_componentSizeList"})){let lA=AA.childIndexByArrayKey[oA][1]+1;aA[oA]=sA.stateValues["componentSize"+lA]}else aA[oA]=sA.stateValues.componentSize}return{setValue:{componentSizes:aA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,dependencyValuesByKey:iA,dependencyNamesByKey:rA,arraySize:aA,componentInfoObjects:oA}){let sA=[];for(let lA in AA.componentSizes){if(!iA[lA])continue;let gA=iA[lA].componentSizeAndComponentSizeListChildren[0];gA&&(oA.isInheritedComponentType({inheritedComponentType:gA.componentType,baseComponentType:"_componentSizeList"})?sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:1}):sA.push({setDependency:rA[lA].componentSizeAndComponentSizeListChildren,desiredValue:AA.componentSizes[lA],childIndex:0,variableIndex:0}))}return{success:!0,instructions:sA}}},eA.numValues={isAlias:!0,targetVariableName:"numComponents",description:"The number of component sizes in the list."},eA.values={isAlias:!0,targetVariableName:"componentSizes",description:"The list's component sizes."},eA}}const ComponentSize$1=Object.freeze(Object.defineProperty({__proto__:null,ComponentSize,ComponentSizeList},Symbol.toStringTag,{value:"Module"}));class Copy extends CompositeComponent{static componentType="_copy";static excludeFromSchema=!0;static acceptAnyAttribute=!0;static includeBlankStringChildren=!0;static stateVariableToEvaluateAfterReplacements="needsReplacementsUpdatedWhenStale";static createAttributesObject(){let eA=super.createAttributesObject();return delete eA.disabled,delete eA.modifyIndirectly,delete eA.fixed,delete eA.fixLocation,delete eA.styleNumber,delete eA.isResponse,delete eA.isPotentialResponse,delete eA.hide,eA.createComponentOfType={createPrimitiveOfType:"string"},eA.createComponentIdx={createPrimitiveOfType:"integer"},eA.createComponentName={createPrimitiveOfType:"string"},eA.numComponents={createPrimitiveOfType:"number"},eA.copyInChildren={createPrimitiveOfType:"boolean"},eA.uri={createPrimitiveOfType:"string",createStateVariable:"uri",defaultValue:null,public:!0},eA.link={createPrimitiveOfType:"boolean",createStateVariable:"link",defaultValue:!0},eA.removeEmptyArrayEntries={createPrimitiveOfType:"boolean",createStateVariable:"removeEmptyArrayEntries",defaultValue:!1},eA.asList={createPrimitiveOfType:"boolean",createStateVariable:"asListPreliminary",defaultValue:!0,description:"Whether to render the items separated by commas (true) or with no separator (false)."},eA}static keepChildrenSerialized({serializedComponent:eA}){return eA.children===void 0?[]:Object.keys(eA.children)}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.refResolutionIndexDependencies={returnDependencies:()=>({refResolutionIndexDependencies:{dependencyType:"refResolutionIndexDependencies"}}),definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencies:AA.refResolutionIndexDependencies}})},eA.refResolutionIndexDependencyValues={stateVariablesDeterminingDependencies:["refResolutionIndexDependencies"],returnDependencies:({stateValues:AA})=>{const tA={};for(const iA of AA.refResolutionIndexDependencies)tA[iA]={dependencyType:"stateVariable",componentIdx:iA,variableName:"value"};return tA},definition:({dependencyValues:AA})=>({setValue:{refResolutionIndexDependencyValues:AA}})},eA.extendIdx={additionalStateVariablesDefined:["unresolvedPath","originalPath"],stateVariablesDeterminingDependencies:["refResolutionIndexDependencyValues"],returnDependencies:({stateValues:AA})=>({refResolution:{dependencyType:"refResolution",indexDependencyValues:AA.refResolutionIndexDependencyValues}}),definition:({dependencyValues:AA})=>({setValue:{extendIdx:AA.refResolution.extendIdx,unresolvedPath:AA.refResolution.unresolvedPath,originalPath:AA.refResolution.originalPath}})},eA.extendedComponent={shadowVariable:!0,stateVariablesDeterminingDependencies:["extendIdx"],returnDependencies({stateValues:AA}){return AA.extendIdx!==-1?{extendedComponent:{dependencyType:"componentIdentity",componentIdx:AA.extendIdx}}:{}},definition:function({dependencyValues:AA}){let tA=null;return AA.extendedComponent&&(tA=AA.extendedComponent),{setValue:{extendedComponent:tA}}}},eA.targetInactive={stateVariablesDeterminingDependencies:["extendedComponent"],returnDependencies({stateValues:AA}){return AA.extendedComponent?{targetIsInactiveCompositeReplacement:{dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"isInactiveCompositeReplacement"}}:{}},definition:function({dependencyValues:AA}){return{setValue:{targetInactive:!!AA.targetIsInactiveCompositeReplacement}}}},eA.cid={additionalStateVariablesDefined:["doenetId"],returnDependencies:()=>({uri:{dependencyType:"stateVariable",variableName:"uri"}}),definition:function({dependencyValues:AA}){if(!AA.uri||AA.uri.substring(0,7).toLowerCase()!=="doenet:")return{setValue:{cid:null,doenetId:null}};let tA=null,iA=null,rA=AA.uri.match(/[:&]cid=([^&]+)/i);return rA&&(tA=rA[1]),rA=AA.uri.match(/[:&]doenetid=([^&]+)/i),rA&&(iA=rA[1]),{setValue:{cid:tA,doenetId:iA}}}},eA.createComponentOfType={returnDependencies:()=>({typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA}){let tA=null;return AA.typeAttr&&(tA=AA.typeAttr),{setValue:{createComponentOfType:tA}}}},eA.replacementSourceIdentities={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","createComponentOfType"],additionalStateVariablesDefined:["usedReplacements"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let iA={numComponentsSpecified:{dependencyType:"stateVariable",variableName:"numComponentsSpecified"}},rA=!1;if(AA.extendedComponent!==null){if(AA.extendedComponent.componentType==="_copy"||tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!0})&&AA.extendedComponent.componentType!==AA.createComponentOfType){rA=!0;let aA=AA.unresolvedPath?.[0]?.name;aA===""&&(aA=null),iA.targets={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:AA.unresolvedPath!=null,stopAtListComposites:AA.unresolvedPath==null,includeWithheldReplacements:!0,stopIfHaveProp:aA}}rA||(iA.targets={dependencyType:"stateVariable",variableName:"extendedComponent"}),iA.usedReplacements={dependencyType:"value",value:rA}}return iA},definition({dependencyValues:AA}){let tA=null;if(AA.targets&&(tA=AA.targets,Array.isArray(tA)||(tA=[tA]),AA.numComponentsSpecified===1&&tA.length>1)){const iA=tA.findIndex(aA=>typeof aA!="string"||aA.trim()!==""),rA=tA.findLastIndex(aA=>typeof aA!="string"||aA.trim()!=="");iA!==-1&&rA!==-1&&(tA=tA.slice(iA,rA+1))}return{setValue:{replacementSourceIdentities:tA,usedReplacements:!!AA.usedReplacements}}}},eA.asList={stateVariablesDeterminingDependencies:["usedReplacements","extendedComponent"],returnDependencies({stateValues:AA}){const tA={asListPreliminary:{dependencyType:"stateVariable",variableName:"asListPreliminary"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.usedReplacements&&(tA.extendedComponentAsList={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"asList",variablesOptional:!0}),tA},definition({dependencyValues:AA,usedDefault:tA}){return tA.asListPreliminary&&AA.usedReplacements&&typeof AA.extendedComponentAsList=="boolean"?{setValue:{asList:AA.extendedComponentAsList}}:{setValue:{asList:AA.asListPreliminary}}}},eA.implicitProp={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath"],returnDependencies({stateValues:AA}){let tA={unresolvedPath:{dependencyType:"stateVariable",variableName:"unresolvedPath"},usedReplacements:{dependencyType:"stateVariable",variableName:"usedReplacements"}};return AA.unresolvedPath||(tA.replacementSourceIdentities={dependencyType:"stateVariable",variableName:"replacementSourceIdentities"},tA.typeAttr={dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}),tA},definition({dependencyValues:AA,componentInfoObjects:tA}){if(AA.unresolvedPath||AA.usedReplacements||!(AA.replacementSourceIdentities?.length>0))return{setValue:{implicitProp:null}};let iA=AA.replacementSourceIdentities[0],rA=tA.allComponentClasses[iA.componentType]?.variableForImplicitProp;if(!rA)return{setValue:{implicitProp:null}};if(AA.typeAttr){let aA=tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()];if(aA===iA.componentType)return{setValue:{implicitProp:null}};let oA=tA.publicStateVariableInfo[iA.componentType].stateVariableDescriptions[rA];if(oA.createComponentOfType!==void 0&&oA.createComponentOfType!==aA)return{setValue:{implicitProp:null}}}return{setValue:{implicitProp:rA}}}},eA.replacementSources={stateVariablesDeterminingDependencies:["replacementSourceIdentities","unresolvedPath","implicitProp","usedReplacements","extendedComponent"],additionalStateVariablesDefined:["effectivePropNameBySource"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){let iA={replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};const rA=AA.usedReplacements&&AA.extendedComponent?.componentType!=="_copy"&&!AA.implicitProp&&AA.unresolvedPath?.[0]?.name==="";if(AA.replacementSourceIdentities!==null)for(let[aA,oA]of AA.replacementSourceIdentities.entries()){let sA=AA.unresolvedPath;AA.implicitProp&&(sA=[{name:AA.implicitProp,index:[]}]);let lA;if(sA){if(sA=[...sA],iA["unresolvedPath"+aA]={dependencyType:"value",value:sA},typeof oA=="string"||rA&&tA.allComponentClasses[oA.componentType]?.listEntryComponentType!==void 0)continue;lA={dependencyType:"stateVariableFromUnresolvedPath",componentIdx:oA.componentIdx,unresolvedPath:sA,returnAsComponentObject:!0,variablesOptional:!0,caseInsensitiveVariableMatch:!0,publicStateVariablesOnly:!0,useMappedVariableNames:!0}}else{if(typeof oA=="string")continue;lA={dependencyType:"componentIdentity",componentIdx:oA.componentIdx}}iA["target"+aA]=lA}return iA},definition({dependencyValues:AA}){let tA=null,iA=null;if(AA.replacementSourceIdentities!==null){tA=[],iA=[];for(let rA in AA.replacementSourceIdentities){let aA=AA["target"+rA];if(aA){tA.push(aA);let oA;aA.stateValues&&(oA=Object.keys(aA.stateValues)[0]),!oA&&AA["unresolvedPath"+rA]&&(oA="__prop_name_not_found"),iA.push(oA)}else{const oA=AA.replacementSourceIdentities[rA];typeof oA=="string"?AA["unresolvedPath"+rA]?iA.push("__prop_name_not_found"):(tA.push(oA),iA.push(void 0)):(tA.push(void 0),iA.push("__no_target_found"))}}}return{setValue:{replacementSources:tA,effectivePropNameBySource:iA}}}},eA.numComponentsSpecified={returnDependencies:()=>({numComponentsAttr:{dependencyType:"attributePrimitive",attributeName:"numComponents"},typeAttr:{dependencyType:"attributePrimitive",attributeName:"createComponentOfType"}}),definition({dependencyValues:AA,componentInfoObjects:tA}){let iA;if(AA.typeAttr){if(!(tA.componentTypeLowerCaseMapping[AA.typeAttr.toLowerCase()]in tA.allComponentClasses))return{setValue:{numComponentsSpecified:null},sendDiagnostics:[codedDiagnostic({type:"warning",code:"doenet-w0065",args:{type:AA.typeAttr}})]};AA.numComponentsAttr!==null?iA=AA.numComponentsAttr:iA=1}else{if(AA.numComponentsAttr!==null)throw Error("You must specify createComponentOfType when specifying numComponents for a copy.");iA=null}return{setValue:{numComponentsSpecified:iA}}}},eA.unlinkedDescendants={stateVariablesDeterminingDependencies:["extendIdx","link"],returnDependencies({stateValues:AA}){let tA={};return AA.link?tA.targetItself={dependencyType:"componentIdentity",componentIdx:AA.extendIdx}:tA.targetDescendants={dependencyType:"descendant",ancestorIdx:AA.extendIdx,componentTypes:["_composite"]},tA},definition(){return{setValue:{unlinkedDescendants:!0}}}},eA.unlinkedTargetsExpanded={stateVariablesDeterminingDependencies:["extendedComponent","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let iA={};return!AA.link&&AA.extendedComponent&&tA.isInheritedComponentType({inheritedComponentType:AA.extendedComponent.componentType,baseComponentType:"_composite"})&&(iA.targetReplacements={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,recurseNonStandardComposites:!0}),iA},definition(){return{setValue:{unlinkedTargetsExpanded:!0}}}},eA.readyToExpandWhenResolved={stateVariablesDeterminingDependencies:["extendedComponent","unresolvedPath","link"],returnDependencies({stateValues:AA,componentInfoObjects:tA}){let iA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},needsReplacementsUpdatedWhenStale:{dependencyType:"stateVariable",variableName:"needsReplacementsUpdatedWhenStale"},link:{dependencyType:"stateVariable",variableName:"link"},unlinkedTargetsExpanded:{dependencyType:"stateVariable",variableName:"unlinkedTargetsExpanded"},unlinkedDescendants:{dependencyType:"stateVariable",variableName:"unlinkedDescendants"}};return AA.extendedComponent&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(iA.targetReadyToExpandWhenResolved={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"readyToExpandWhenResolved"}),AA.extendedComponent&&AA.unresolvedPath===null&&(iA.extendedVariantInfo={dependencyType:"stateVariable",componentIdx:AA.extendedComponent.componentIdx,variableName:"generatedVariantInfo",variablesOptional:!0}),AA.link||(iA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),iA},definition(){return{setValue:{readyToExpandWhenResolved:!0}}}},eA.needsReplacementsUpdatedWhenStale={stateVariablesDeterminingDependencies:["extendedComponent","replacementSourceIdentities","effectivePropNameBySource","unresolvedPath","link","removeEmptyArrayEntries"],returnDependencies:function({stateValues:AA,componentInfoObjects:tA}){if(!AA.link)return{};let iA={extendedComponent:{dependencyType:"stateVariable",variableName:"extendedComponent"},targetInactive:{dependencyType:"stateVariable",variableName:"targetInactive"},replacementSourceIdentities:{dependencyType:"stateVariable",variableName:"replacementSourceIdentities"}};if(AA.effectivePropNameBySource!==null){for(let[rA,aA]of AA.effectivePropNameBySource.entries())if(aA){let oA=AA.replacementSourceIdentities[rA];iA["sourceArraySize"+rA]={dependencyType:"stateVariableArraySize",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0},iA["sourceComponentType"+rA]={dependencyType:"stateVariableComponentType",componentIdx:oA.componentIdx,variableName:aA,variablesOptional:!0,caseInsensitiveVariableMatch:!0}}}return AA.extendedComponent!==null&&tA.isCompositeComponent({componentType:AA.extendedComponent.componentType,includeNonStandard:!1})&&(iA.allReplacementIdentities={dependencyType:"replacement",compositeIdx:AA.extendedComponent.componentIdx,recursive:!0,variableNames:["isInactiveCompositeReplacement"]}),AA.removeEmptyArrayEntries&&(iA.replacementSources={dependencyType:"stateVariable",variableName:"replacementSources"}),iA},markStale(){return{updateReplacements:!0}},definition:()=>({setValue:{needsReplacementsUpdatedWhenStale:!0}})},eA}static async createSerializedReplacements(eA){const AA=await this.createReplacementsFromSources(eA),{component:tA}=eA;if(await tA.stateValues.link===!1){const iA=tA.coreFunctions.savedCopySnapshot?.(tA.stateId);iA&&applyCopySnapshot(AA.replacements,iA),tA.unlinkedSnapshot=copySnapshotOf(AA.replacements),tA.freshUnlinkedSnapshot=async()=>copySnapshotOf((await this.createReplacementsFromSources({...eA,workspace:{}})).replacements)}return AA}static async createReplacementsFromSources({component:eA,components:AA,nComponents:tA,workspace:iA,allDoenetMLs:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){iA.replacementsCreated===void 0&&(iA.replacementsCreated=0);let lA=[];await eA.stateValues.numComponentsSpecified,iA.numReplacementsBySource=[],iA.numNonStringReplacementsBySource=[],iA.propVariablesCopiedBySource=[],iA.sourceIndices=[];let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let DA=[];const EA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};if(eA.attributes.copyInChildren?.primitive.value){let NA=aA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],yA=aA.allComponentClasses[NA];const bA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:NA,componentInfoObjects:aA,compositeAttributesObj:gA,nComponents:tA,stateIdInfo:EA}),wA=bA.attributes;tA=bA.nComponents;let MA=deepClone(eA.serializedChildren);yA.includeBlankStringChildren||(MA=MA.filter(kA=>typeof kA!="string"||kA.trim()!==""));let vA=wA;DA=[{type:"serialized",componentType:NA,componentIdx:tA++,stateId:`${EA.prefix}${EA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:MA}],iA.numReplacementsBySource.push(DA.length),iA.numNonStringReplacementsBySource.push(DA.filter(kA=>typeof kA!="string").length)}let fA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:DA,workspace:iA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:EA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...fA.diagnostics),tA=fA.nComponents,addAttributesToSingleReplacement(fA.replacements,eA),iA.replacementsCreated=EA.num,{replacements:fA.replacements,diagnostics:lA,nComponents:tA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let uA=await eA.stateValues.effectivePropNameBySource;for(let DA in cA)if(uA[DA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+DA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${DA} of replacementSources of ${eA.componentIdx}`);let CA=[];const dA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};let pA=[],mA=[],QA=0,BA=0;for(let DA in cA){let EA;if(eA.attributes.createComponentOfType?.primitive){let yA=await eA.stateValues.numComponentsSpecified,bA=cA.length;EA=Math.floor(yA/bA);let wA=yA%bA;DA<wA&&EA++}let fA=await this.createReplacementForSource({component:eA,sourceNum:DA,components:AA,nComponents:tA,stateIdInfo:dA,allDoenetMLs:rA,numReplacementsSoFar:QA,numNonStringReplacementsSoFar:BA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:EA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(DA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...fA.diagnostics),tA=fA.nComponents,iA.propVariablesCopiedBySource[DA]=fA.propVariablesCopiedByReplacement;let NA=fA.serializedReplacements;pA[DA]=NA.length,mA[DA]=NA.filter(yA=>typeof yA!="string").length,QA+=pA[DA],BA+=mA[DA],CA.push(...NA)}iA.numReplacementsBySource=pA,iA.numNonStringReplacementsBySource=mA,iA.sourceIndices=cA.map(DA=>DA.componentIdx);let hA=await verifyReplacementsMatchSpecifiedType({component:eA,replacements:CA,workspace:iA,componentInfoObjects:aA,compositeAttributesObj:gA,components:AA,nComponents:tA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...hA.diagnostics),tA=hA.nComponents,CA=hA.replacements,addAttributesToSingleReplacement(CA,eA),iA.replacementsCreated=dA.num,{replacements:CA,diagnostics:lA,nComponents:tA}}static async createReplacementForSource({component:eA,sourceNum:AA,components:tA,nComponents:iA,stateIdInfo:rA,allDoenetMLs:aA,numReplacementsSoFar:oA,numNonStringReplacementsSoFar:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:uA}){let CA=[],dA=(await eA.stateValues.replacementSourceIdentities)[AA];if(typeof dA!="object")return eA.stateValues.effectivePropNameBySource[AA]?{serializedReplacements:[],diagnostics:CA,nComponents:iA}:{serializedReplacements:[dA],diagnostics:CA,nComponents:iA};const pA=tA[dA.componentIdx];if(await pA.stateValues.isInactiveCompositeReplacement)return{serializedReplacements:[],diagnostics:CA,nComponents:iA};let mA=(await eA.stateValues.effectivePropNameBySource)[AA],QA=await eA.stateValues.link;if(!QA||mA&&await eA.stateValues.removeEmptyArrayEntries){const hA=(await eA.stateValues.replacementSources)[AA];hA&&(dA=hA)}if(mA){let hA=await replacementFromProp({component:eA,components:tA,nComponents:iA,stateIdInfo:rA,replacementSource:dA,propName:mA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});CA.push(...hA.diagnostics),iA=hA.nComponents;let DA=hA.serializedReplacements,EA=hA.propVariablesCopiedByReplacement;if(uA&&eA.serializedChildren.length>0)if(DA.length===0){let fA=gA.componentTypeLowerCaseMapping[eA.attributes.createComponentOfType.primitive.value.toLowerCase()],NA=gA.allComponentClasses[fA];const yA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:fA,componentInfoObjects:gA,compositeAttributesObj:lA,nComponents:iA,stateIdInfo:rA}),bA=yA.attributes;iA=yA.nComponents;let wA=deepClone(eA.serializedChildren);NA.includeBlankStringChildren||(wA=wA.filter(vA=>typeof vA!="string"||vA.trim()!==""));let MA=bA;DA=[{type:"serialized",componentType:fA,componentIdx:iA++,stateId:`${rA.prefix}${rA.num++}`,attributes:MA,doenetAttributes:{},state:{},children:wA}],EA=[[]]}else DA.length===1&&addChildrenFromComposite({replacements:DA,children:eA.serializedChildren,componentInfoObjects:gA});return{serializedReplacements:DA,propVariablesCopiedByReplacement:EA,diagnostics:CA,nComponents:iA}}let BA;try{BA=[await pA.serialize({valueReferenceAsComponent:!0,components:QA?void 0:tA,copyAll:!QA,componentSourceAttributesToIgnore:["labelIsName"],copyVariants:!QA,copyPrimaryEssentialIfShadow:!QA,copyEssentialStateIfShadow:!QA,errorIfEncounterComponent:[eA.componentIdx]})];let hA=createNewComponentIndices(BA,iA,rA);BA=hA.components,iA=hA.nComponents}catch(hA){if(hA.message?.startsWith(SERIALIZE_ENCOUNTERED_COMPONENT_PREFIX)){const EA=getSelfReferentialFallbackPropName({componentAncestors:eA.ancestors,componentInfoObjects:gA,replacementSourceComponentType:pA.componentType});if(EA)try{let fA=await replacementFromProp({component:eA,components:tA,nComponents:iA,stateIdInfo:rA,replacementSource:pA,propName:EA,allDoenetMLs:aA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA});return CA.push(...fA.diagnostics),iA=fA.nComponents,{serializedReplacements:fA.serializedReplacements,propVariablesCopiedByReplacement:fA.propVariablesCopiedByReplacement,diagnostics:CA,nComponents:iA}}catch{}}console.error("we're calling this circular",hA);const DA=codedDiagnostic({type:"error",code:"doenet-e0005",args:{componentType:eA.attributes.createComponentOfType?.primitive?.value??"none"}});return BA=[{type:"serialized",componentType:"_error",componentIdx:iA++,stateId:`${rA.prefix}${rA.num++}`,state:errorComponentState(DA.message,DA),attributes:{},doenetAttributes:{},children:[]}],CA.push(DA),{serializedReplacements:BA,diagnostics:CA,nComponents:iA}}if(!QA&&typeof BA[0]=="object")for(const hA of CONTEXT_ATTRIBUTES)delete BA[0].state?.[hA],delete BA[0].state?.[`${hA}Preliminary`];BA=postProcessCopy({serializedComponents:BA,componentIdx:eA.componentIdx,addShadowDependencies:QA,unlinkExternalCopies:!1});for(let hA of BA){if(typeof hA!="object")continue;hA.attributes||(hA.attributes={});const DA=convertUnresolvedAttributesForComponentType({attributes:eA.attributes,componentType:hA.componentType,componentInfoObjects:gA,compositeAttributesObj:lA,dontSkipAttributes:["asList"],nComponents:iA,stateIdInfo:rA}),EA=DA.attributes;if(iA=DA.nComponents,deleteReplacedAttributes({attributes:hA.attributes,attributesFromComposite:EA,componentType:hA.componentType,componentInfoObjects:gA}),QA&&uA){const fA=extendIgnoresAttributesAndChildren({replacementType:hA.componentType,attributeNames:Object.keys(EA),copyAttributeNames:Object.keys(lA),children:eA.serializedChildren,componentInfoObjects:gA});CA.push(...fA.diagnostics);for(const NA of fA.attributeNames)delete EA[NA]}Object.assign(hA.attributes,EA)}return uA&&BA.length===1&&eA.serializedChildren.length>0&&addChildrenFromComposite({replacements:BA,children:eA.serializedChildren,componentInfoObjects:gA}),{serializedReplacements:BA,diagnostics:CA,nComponents:iA}}static async calculateReplacementChanges({component:eA,nComponents:AA,componentChanges:tA,components:iA,workspace:rA,componentInfoObjects:aA,resolveItem:oA,publicCaseInsensitiveAliasSubstitutions:sA}){let lA=[];if(await eA.stateValues.link===!1)return{replacementChanges:[],diagnostics:lA,nComponents:AA};let gA=this.createAttributesObject(),cA=await eA.stateValues.replacementSourceIdentities;if(!await eA.stateValues.extendedComponent||!cA){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacements.length>0){let vA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToDelete:eA.replacements.length};yA.push(vA)}let wA=rA.sourceIndices.length===0;rA.sourceIndices=[],rA.numReplacementsBySource=[],rA.numNonStringReplacementsBySource=[],rA.propVariablesCopiedBySource=[];let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...MA.diagnostics),AA=MA.nComponents,wA?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,MA.replacementChanges),rA.replacementsCreated=bA.num,{replacementChanges:MA.replacementChanges,diagnostics:lA,nComponents:AA})}if(await eA.stateValues.targetInactive){let yA=[];const bA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};let wA=eA.replacements.length;if(wA>0){if(eA.replacementsToWithhold!==wA){let vA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:wA};yA.push(vA)}let MA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:yA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...MA.diagnostics),AA=MA.nComponents,yA=MA.replacementChanges}return addAttributesToSingleReplacementChange(eA,yA),rA.replacementsCreated=bA.num,{replacementChanges:yA,diagnostics:lA,nComponents:AA}}let IA=await oA({componentIdx:eA.componentIdx,type:"determineDependencies",stateVariable:"replacementSources",dependency:"__determine_dependencies",expandComposites:!1});if(!IA.success)throw Error(`Couldn't resolve determineDependencies of replacementSources of ${eA.componentIdx}`);let uA=await eA.stateValues.effectivePropNameBySource;for(let yA in cA)if(uA[yA]&&(IA=await oA({componentIdx:eA.componentIdx,type:"recalculateDownstreamComponents",stateVariable:"replacementSources",dependency:"target"+yA,expandComposites:!1}),!IA.success))throw Error(`Couldn't resolve recalculateDownstreamComponents for target${yA} of replacementSources of ${eA.componentIdx}`);let CA=[];const dA={prefix:`${eA.stateId}|`,num:rA.replacementsCreated};if(eA.replacementsToWithhold>0){let yA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:0};CA.push(yA)}let pA=0,mA=0,QA=[],BA=[],hA=[],DA=Math.max(cA.length,rA.numReplacementsBySource.length),EA=!1;for(let yA=0;yA<DA;yA++){let bA;if(eA.attributes.createComponentOfType?.primitive){let zA=await eA.stateValues.numComponentsSpecified,GA=cA.length;bA=Math.floor(zA/GA);let KA=zA%GA;yA<KA&&bA++}let wA=cA[yA];if(!EA&&await iA[wA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){let zA=!0;for(let GA=yA+1;GA<DA;GA++){const KA=cA[GA];if(!await iA[KA?.componentIdx]?.stateValues.isInactiveCompositeReplacement){zA=!1;break}}if(zA){let GA=rA.numReplacementsBySource.slice(yA).reduce((KA,JA)=>KA+JA,0);if(GA>0){let KA={changeType:"changeReplacementsToWithhold",replacementsToWithhold:GA};CA.push(KA)}for(let KA=yA;KA<DA;KA++)QA[KA]=rA.numReplacementsBySource[KA],BA[KA]=rA.numNonStringReplacementsBySource[KA],hA[KA]=rA.propVariablesCopiedBySource[KA];break}else wA=void 0}if(wA===void 0){if(rA.numReplacementsBySource[yA]>0&&!EA){let zA=rA.numReplacementsBySource.slice(yA).reduce((GA,KA)=>GA+KA,0);if(zA>0){let GA={changeType:"delete",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToDelete:zA};CA.push(GA)}EA=!0,rA.numReplacementsBySource.slice(yA).forEach((GA,KA)=>rA.numReplacementsBySource[KA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((GA,KA)=>rA.numNonStringReplacementsBySource[KA]=0)}QA[yA]=0,BA[yA]=0,hA.push([]);continue}let MA=rA.sourceIndices[yA],vA=MA===void 0||wA.componentIdx!==MA||EA;if(!vA)for(let zA=0;zA<rA.numReplacementsBySource[yA];zA++){let GA=eA.replacements[pA+zA];if(GA){if(!uA[yA]&&GA.shadows?.componentIdx!==cA[yA].componentIdx){vA=!0;break}}else{vA=!0;break}}if(vA){let zA=0;yA in rA.numReplacementsBySource&&(zA=rA.numReplacementsBySource[yA]);let GA=zA;EA&&(GA=0);let KA=await this.recreateReplacements({component:eA,sourceNum:yA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,numReplacementsToDelete:GA,components:iA,nComponents:AA,stateIdInfo:dA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA});lA.push(...KA.diagnostics),AA=KA.nComponents,pA+=KA.numReplacements,mA+=KA.numNonStringReplacements,QA[yA]=KA.numReplacements,BA[yA]=KA.numNonStringReplacements,hA[yA]=KA.propVariablesCopiedByReplacement;let JA=KA.replacementInstruction;if(!EA&&KA.numReplacements!==zA){let Or=rA.numReplacementsBySource.slice(yA).reduce((As,WA)=>As+WA,0);JA.numberReplacementsToReplace=Or,EA=!0,rA.numReplacementsBySource.slice(yA).forEach((As,WA)=>rA.numReplacementsBySource[WA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((As,WA)=>rA.numNonStringReplacementsBySource[WA]=0)}JA&&CA.push(JA);continue}if(!uA[yA]&&rA.numReplacementsBySource[yA]>0){pA+=rA.numReplacementsBySource[yA],mA+=rA.numNonStringReplacementsBySource[yA],QA[yA]=rA.numReplacementsBySource[yA],BA[yA]=rA.numNonStringReplacementsBySource[yA];continue}const kA={prefix:`${eA.stateId}|`,num:dA.num};let TA=await this.createReplacementForSource({component:eA,sourceNum:yA,components:iA,nComponents:AA,stateIdInfo:kA,numReplacementsSoFar:pA,numNonStringReplacementsSoFar:mA,compositeAttributesObj:gA,componentInfoObjects:aA,numComponentsForSource:bA,publicCaseInsensitiveAliasSubstitutions:sA,copyInChildren:Number(yA)===0&&eA.attributes.copyInChildren?.primitive.value});lA.push(...TA.diagnostics);const OA=TA.nComponents;let FA=TA.propVariablesCopiedByReplacement,RA=TA.serializedReplacements,xA=RA.length,jA=rA.numReplacementsBySource[yA];if(xA!==jA){let zA=rA.numReplacementsBySource.slice(yA).reduce((KA,JA)=>KA+JA,0),GA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA,numberReplacementsToReplace:zA,serializedReplacements:RA};CA.push(GA),EA=!0,AA=OA,dA.num=kA.num,rA.numReplacementsBySource.slice(yA).forEach((KA,JA)=>rA.numReplacementsBySource[JA]=0),rA.numNonStringReplacementsBySource.slice(yA).forEach((KA,JA)=>rA.numNonStringReplacementsBySource[JA]=0)}else for(let zA=0;zA<xA;zA++){let GA=FA[zA].length!==rA.propVariablesCopiedBySource[yA][zA].length,KA=!GA;if(!GA)if(rA.propVariablesCopiedBySource[yA][zA].some((JA,Or)=>JA!==FA[zA][Or]))KA=!1,GA=!0;else{let JA=eA.replacements[pA+zA];(JA.componentType!==RA[zA].componentType||valueReferenceDiffers(JA,RA[zA]))&&(GA=!0)}if(zA==0&&GA&&KA&&await eA.stateValues.numComponentsSpecified===1&&xA===1&&!(eA.replacementsToWithhold>0)&&rA.sourceIndices.length===1&&(GA=!1),GA){AA=OA,dA.num=kA.num;let JA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:pA+zA,numberReplacementsToReplace:1,serializedReplacements:[RA[zA]]};CA.push(JA)}RA[zA]}let HA=RA.filter(zA=>typeof zA!="string").length;pA+=xA,mA+=HA,QA[yA]=xA,BA[yA]=HA,hA[yA]=FA}let fA=rA.sourceIndices.length===0;rA.numReplacementsBySource=QA,rA.numNonStringReplacementsBySource=BA,rA.sourceIndices=cA.map(yA=>yA.componentIdx),rA.propVariablesCopiedBySource=hA;let NA=await verifyReplacementsMatchSpecifiedType({component:eA,replacementChanges:CA,workspace:rA,componentInfoObjects:aA,compositeAttributesObj:gA,components:iA,nComponents:AA,stateIdInfo:dA,publicCaseInsensitiveAliasSubstitutions:sA});return lA.push(...NA.diagnostics),AA=NA.nComponents,CA=NA.replacementChanges,fA&&rA.sourceIndices.length===0?{replacementChanges:[],diagnostics:lA,nComponents:AA}:(addAttributesToSingleReplacementChange(eA,CA),rA.replacementsCreated=dA.num,{replacementChanges:CA,diagnostics:lA,nComponents:AA})}static async recreateReplacements({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:iA,numReplacementsToDelete:rA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA}){let uA=[],CA=await this.createReplacementForSource({component:eA,sourceNum:AA,numReplacementsSoFar:tA,numNonStringReplacementsSoFar:iA,components:aA,nComponents:oA,stateIdInfo:sA,compositeAttributesObj:lA,componentInfoObjects:gA,numComponentsForSource:cA,publicCaseInsensitiveAliasSubstitutions:IA,copyInChildren:Number(AA)===0&&eA.attributes.copyInChildren?.primitive.value});uA.push(...CA.diagnostics),oA=CA.nComponents;let dA=CA.propVariablesCopiedByReplacement,pA=CA.serializedReplacements;if(pA.length>0||rA>0){let mA={changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:tA,numberReplacementsToReplace:rA,serializedReplacements:pA};return{numReplacements:pA.length,numNonStringReplacements:pA.filter(QA=>typeof QA!="string").length,propVariablesCopiedByReplacement:dA,replacementInstruction:mA,diagnostics:uA,nComponents:oA}}else return{numReplacements:0,numNonStringReplacements:0,propVariablesCopiedByReplacement:dA,replacementInstruction:null,diagnostics:uA,nComponents:oA}}}async function replacementFromProp({component:nA,components:eA,nComponents:AA,stateIdInfo:tA,replacementSource:iA,propName:rA,allDoenetMLs:aA,compositeAttributesObj:oA,componentInfoObjects:sA,numComponentsForSource:lA,publicCaseInsensitiveAliasSubstitutions:gA}){let cA=[],IA=[],uA=[],CA=-1,dA,pA;if(iA&&(dA=eA[iA.componentIdx],pA=isListEntryArrayVariable(dA,rA)?rA:gA({stateVariables:[rA],componentClass:dA.constructor})[0]),pA===void 0||pA.slice(0,12)==="__not_public"){if(rA==="__no_target_found"){const fA=await nA.stateValues.unresolvedPath,NA=fA[0].position?.start.offset,yA=fA[fA.length-1].position?.end.offset;let bA="";if(NA!=null&&yA!=null){const wA=fA[0].sourceDoc??0;bA=aA?.[wA]?.substring(NA,yA)}cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:bA,component:iA.componentType}}))}else rA!=="__prop_name_not_found"&&cA.push(codedDiagnostic({type:"info",code:"doenet-i0018",args:{property:rA,component:iA.componentType}}));return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA}}let mA=dA.state[pA],QA=await mA.value,BA=await nA.stateValues.link;const hA=await nA.stateValues.implicitProp,DA=nA.ancestors[0]?.componentClass,EA=BA&&!nA.attributes.createComponentOfType?.primitive;if(mA.isArray||mA.isArrayEntry){let fA,NA,yA,bA;if(mA.isArray?(fA=mA,yA=await mA.arraySize,NA=mA.getAllArrayKeys(yA,!1)):(fA=dA.state[mA.arrayStateVariable],NA=await mA.unflattenedArrayKeys,bA=await mA.arrayKeys),fA.shadowingInstructions?.hasVariableComponentType&&(await nA.stateValues.replacementSources,!fA.shadowingInstructions.createComponentOfType))return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};let wA=mA.wrappingComponents,MA=wA.length,vA=lA;if(mA.isArray)yA.some(TA=>TA===0)?vA=0:vA=yA.slice(0,yA.length-MA).reduce((TA,OA)=>TA*OA,1);else if(bA.length===0)vA=0;else if(MA===0)vA=bA.length;else if(MA>=mA.numDimensions)vA=1;else if(MA===mA.numDimensions-1)vA=NA.length;else{let TA=mA.numDimensions-MA-1;vA=flattenLevels(NA,TA).length}const kA=mA.isArray?await arrayListReplacement({component:nA,components:eA,target:dA,varName:pA,arrayStateVarObj:fA,numWrappingComponents:MA,link:BA,mayBeValueReference:EA,parentClass:DA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}):void 0;if(kA)return{serializedReplacements:[kA.serializedComponent],propVariablesCopiedByReplacement:[[pA]],diagnostics:cA,nComponents:kA.nComponents};if(MA===0){let TA=flattenDeep(NA);for(let OA=0;OA<vA;OA++){let FA=TA[OA];if(await nA.stateValues.removeEmptyArrayEntries){if(!FA)continue;let jA=fA.keyToIndex(FA);Array.isArray(jA)||(jA=[jA]);let HA=await fA.value;for(let zA of jA)HA=HA[zA];if(HA==null)continue}CA++;let RA=uA[CA]=[],xA=fA.shadowingInstructions.createComponentOfType;if(Array.isArray(xA)&&(xA[fA.keyToIndex(FA)]?xA=xA[fA.keyToIndex(FA)]:xA=xA[0]),FA){let jA=fA.arrayVarNameFromArrayKey(FA);RA.push(jA);const HA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:xA,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),zA=HA.attributes;AA=HA.nComponents;let GA;if(fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){GA={};for(let WA in fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let YA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[WA].stateVariableToShadow,ZA=dA.state[YA];ZA.isArray&&(YA=ZA.arrayVarNameFromArrayKey(FA)),GA[WA]={stateVariableToShadow:YA}}}let KA;if(fA.shadowingInstructions.addStateVariablesShadowingStateVariables){KA={};for(let WA in fA.shadowingInstructions.addStateVariablesShadowingStateVariables){let YA=fA.shadowingInstructions.addStateVariablesShadowingStateVariables[WA].stateVariableToShadow,ZA=dA.state[YA];ZA.isArray&&(YA=ZA.arrayVarNameFromArrayKey(FA)),KA[WA]={stateVariableToShadow:YA}}}const{responseMarks:JA,otherAttributes:Or}=separateResponseMarks(zA),As=EA?planValueReference({parentClass:DA,targetComponentType:dA.componentType,valueComponentType:xA,fromImplicitProp:!1,hasAttributes:Object.keys(Or).length>0,allowDrawn:!0,componentInfoObjects:sA}):void 0;if(As)IA.push(serializeValueReference({...As,referencedVariable:jA,valueComponentType:xA,target:dA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,responseMarks:JA}));else if(BA){let WA={};const YA=listEntrySourceDoenetAttributes({arrayStateVarObj:fA,arrayKey:FA,target:dA}),ZA=YA.listEntrySource?.variables??{};if(GA){let XA=sA.allComponentClasses[xA].createAttributesObject();for(let Br in GA){if(Br in ZA)continue;let Hr=GA[Br].stateVariableToShadow,rs=XA[Br]?.createComponentOfType;if(attributeShadowIsReference(rs))WA[Br]=shadowAttributeReference({attrName:Br,attributeComponentType:rs,target:dA,stateVariableToShadow:Hr});else if(rs){let os={type:"serialized",componentType:rs,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:Hr}]}};WA[Br]={component:os}}}}deleteReplacedAttributes({attributes:WA,attributesFromComposite:zA,componentType:xA,componentInfoObjects:sA}),Object.assign(WA,zA),IA.push({type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:WA,doenetAttributes:YA,children:[],state:{},downstreamDependencies:{[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:jA,additionalStateVariableShadowing:KA}]}})}else{let WA={};if(GA){let Cs=sA.allComponentClasses[xA].createAttributesObject(),cs={};for(let VA in GA)if(Cs[VA]?.createComponentOfType){let LA=GA[VA].stateVariableToShadow,_A=dA.state[LA],Li,ns;if(_A)Li=await _A.value,ns=_A.usedDefault;else{const ts=dA.state[fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[VA].stateVariableToShadow];Li=(await ts.value)[fA.keyToIndex(FA)],ns=!!ts.usedDefaultByArrayKey?.[FA]}ns||(cs[VA]=Li)}const UA=convertAttributeValuesForComponentType({attributeValues:cs,componentType:xA,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),qA=UA.attributes;if(AA=UA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let VA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[VA]?.component){const LA=await dA.attributes[VA].component.serialize({copyAll:!0,copyVariants:!0});let _A=createNewComponentIndices([LA],AA,tA);AA=_A.nComponents,qA[VA]={type:"component",name:VA,component:_A.components[0]}}else dA.attributes[VA]?.type==="literal"?qA[VA]=copyOfLiteralAttribute(dA.attributes[VA],dA):dA.attributes[VA]?.primitive!==void 0&&(qA[VA]={type:"primitive",name:VA,primitive:JSON.parse(JSON.stringify(dA.attributes[VA].primitive))});Object.assign(WA,qA)}const YA=sA.allComponentClasses[xA].createAttributesObject(),ZA=fA.keyToIndex(FA);for(const as of CONTEXT_ATTRIBUTES){if(!YA[as]||!Number.isInteger(ZA)||!isListEntryArrayVariable(dA,pA))continue;const Cs=await writtenEntryAttributeComponent({list:dA,index:ZA,attributeName:as,components:eA});if(!Cs)continue;if(Cs.literal){WA[as]=Cs.literal;continue}const cs=createNewComponentIndices([await Cs.serialize({copyAll:!0,copyVariants:!0,components:eA})],AA,tA);AA=cs.nComponents,WA[as]={type:"component",name:as,component:cs.components[0]}}deleteReplacedAttributes({attributes:WA,attributesFromComposite:zA,componentType:xA,componentInfoObjects:sA}),Object.assign(WA,zA);const PA=primaryEssentialStateVariableOf({componentType:xA,componentInfoObjects:sA});let XA=fA.keyToIndex(FA);Array.isArray(XA)||(XA=[XA]);let Br=await fA.value;for(let as of XA)Br=Br[as];const Hr=AA++,rs=`${tA.prefix}${tA.num++}`,os=await listEntrySourceSnapshot({arrayStateVarObj:fA,arrayKey:FA,target:dA,nComponents:AA,stateIdInfo:tA});AA=os.nComponents;let Is={type:"serialized",componentType:xA,componentIdx:Hr,stateId:rs,attributes:WA,doenetAttributes:{},state:{...os.state,[PA]:Br},children:os.children};IA.push(Is)}}else IA.push({type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},children:[],state:{}})}}else{let TA=async function(RA,xA,jA=!1){let HA=[],zA=[];if(xA>1)for(let KA of RA){let JA=await TA(KA,xA-1);HA.push(...JA.pieces),zA.push(...JA.propVariablesCopiedByPiece)}else for(let KA of RA){let JA=fA.arrayVarNameFromArrayKey(KA),Or=[JA],As=fA.shadowingInstructions.createComponentOfType;Array.isArray(As)&&(As=As[fA.keyToIndex(KA)]);let WA;if(fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){WA={};let ZA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let PA in ZA)if(!ZA[PA].addToOuterIfWrappedArray){let XA=ZA[PA].stateVariableToShadow,Br=dA.state[XA];Br.isArray&&(XA=Br.arrayVarNameFromArrayKey(KA)),WA[PA]={stateVariableToShadow:XA}}}let YA;if(fA.shadowingInstructions.addStateVariablesShadowingStateVariables){YA={};for(let ZA in fA.shadowingInstructions.addStateVariablesShadowingStateVariables){let PA=fA.shadowingInstructions.addStateVariablesShadowingStateVariables[ZA].stateVariableToShadow,XA=dA.state[PA];XA.isArray&&(PA=XA.arrayVarNameFromArrayKey(KA)),YA[ZA]={stateVariableToShadow:PA}}}if(BA){let ZA={};if(WA){let XA=sA.allComponentClasses[As].createAttributesObject();for(let Br in WA){let Hr=WA[Br].stateVariableToShadow,rs=XA[Br]?.createComponentOfType;if(attributeShadowIsReference(rs))ZA[Br]=shadowAttributeReference({attrName:Br,attributeComponentType:rs,target:dA,stateVariableToShadow:Hr});else if(rs){let os={type:"serialized",componentType:rs,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:Hr}]}};ZA[Br]={component:os}}}}HA.push({type:"serialized",componentType:As,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:ZA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:JA,additionalStateVariableShadowing:YA}]}})}else{let ZA={};if(WA){let os=sA.allComponentClasses[As].createAttributesObject(),Is={};for(let cs in WA)if(os[cs]?.createComponentOfType){let UA=WA[cs].stateVariableToShadow,qA=dA.state[UA],VA=await qA.value;qA.isArray&&(VA=VA[qA.keyToIndex[KA]]),dA.state[UA].usedDefault||(Is[cs]=VA)}const as=convertAttributeValuesForComponentType({attributeValues:Is,componentType:As,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),Cs=as.attributes;if(AA=as.nComponents,mA.shadowingInstructions.attributesToShadow)for(let cs of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[cs]?.component){let UA=await dA.attributes[cs].component.serialize({copyAll:!0,copyVariants:!0}),qA=createNewComponentIndices([UA],AA,tA);AA=qA.nComponents,Cs[cs]={type:"component",name:cs,component:qA.components[0]}}else dA.attributes[cs]?.type==="literal"?Cs[cs]=copyOfLiteralAttribute(dA.attributes[cs],dA):dA.attributes[cs]?.primitive!==void 0&&(Cs[cs]={type:"primitive",name:cs,primitive:JSON.parse(JSON.stringify(dA.attributes[cs].primitive))});Object.assign(ZA,Cs)}const PA=primaryEssentialStateVariableOf({componentType:As,componentInfoObjects:sA});let XA=fA.keyToIndex(KA);Array.isArray(XA)||(XA=[XA]);let Br=await fA.value;for(let rs of XA)Br=Br[rs];let Hr={type:"serialized",componentType:As,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:ZA,doenetAttributes:{},children:[],state:{[PA]:Br}};HA.push(Hr)}zA.push(Or)}let GA=wA[xA-1];if(HA.length>0&&GA&&GA.length>0){for(let KA=GA.length-1;KA>=0;KA--){let JA=typeof GA[KA]=="object"?GA[KA].componentType:GA[KA],Or=[],As={};for(let WA of HA)if(WA.isAttributeNamed){let YA=WA.isAttributeNamed;delete WA.isAttributeNamed,As[YA]={component:WA}}else Or.push(WA);HA=[{type:"serialized",componentType:JA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,children:Or,attributes:As,doenetAttributes:{},state:{},skipSugar:!0}],typeof GA[KA]=="object"&&GA[KA].isAttributeNamed&&(HA[0].isAttributeNamed=GA[KA].isAttributeNamed)}zA=[flattenDeep(zA)]}if(jA&&fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let KA={},JA=fA.shadowingInstructions.addAttributeComponentsShadowingStateVariables;for(let Or in JA)if(JA[Or].addToOuterIfWrappedArray){let As=JA[Or].stateVariableToShadow;KA[Or]={stateVariableToShadow:As}}if(Object.keys(KA).length>0)for(let Or of HA){let As=Or.attributes;As||(As=Or.attributes={});let YA=sA.allComponentClasses[Or.componentType].createAttributesObject();if(BA)for(let ZA in KA){let PA=KA[ZA].stateVariableToShadow,XA=YA[ZA]?.createComponentOfType;if(attributeShadowIsReference(XA))As[ZA]=shadowAttributeReference({attrName:ZA,attributeComponentType:XA,target:dA,stateVariableToShadow:PA});else if(XA){let Br={type:"serialized",componentType:XA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:PA}]}};As[ZA]={component:Br}}}else{let ZA={};for(let PA in KA)if(YA[PA]?.createComponentOfType){let XA=KA[PA].stateVariableToShadow,Hr=await dA.state[XA].value;dA.state[XA].usedDefault||(ZA[PA]=Hr)}if(Object.keys(ZA).length>0){const PA=convertAttributeValuesForComponentType({attributeValues:ZA,componentType:Or.componentType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA});ZA=PA.attributes,AA=PA.nComponents,Object.assign(As,ZA)}}}}return{pieces:HA,propVariablesCopiedByPiece:zA}},OA=await TA(NA,mA.numDimensions,!0),FA=OA.pieces;uA=OA.propVariablesCopiedByPiece;for(let RA of FA){if(typeof RA!="object")continue;RA.attributes||(RA.attributes={});const xA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:RA.componentType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),jA=xA.attributes;AA=xA.nComponents,deleteReplacedAttributes({attributes:RA.attributes,attributesFromComposite:jA,componentType:RA.componentType,componentInfoObjects:sA}),Object.assign(RA.attributes,jA),BA&&(RA.downstreamDependencies={[iA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:pA,ignorePrimaryStateVariable:!0}]})}if(CA+=FA.length,IA.push(...FA),FA.length<vA)for(let RA=FA.length;RA<vA;RA++){CA++,uA[CA]=[];let xA,jA=wA[0],HA;jA&&jA.length>0?typeof jA[0]=="object"?(xA=jA[0].componentType,HA=Object.assign({},jA[0].doenetAttributes)):xA=jA[0]:(xA=fA.shadowingInstructions.createComponentOfType,Array.isArray(xA)&&(mA.isArrayEntry?xA=xA[fA.keyToIndex(bA[RA])]:xA=xA[RA]));let zA={type:"serialized",componentType:xA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]};HA&&(zA.doenetAttributes=HA),IA.push(zA)}else if(FA>vA)throw Error(`Something went wrong when creating replacements for ${nA.componentIdx} as we ended up with too many replacements`)}}else{if(mA.shadowingInstructions?.hasVariableComponentType&&await mA.value,!mA.shadowingInstructions?.createComponentOfType)return{serializedReplacements:[],propVariablesCopiedByReplacement:[],diagnostics:cA,nComponents:AA};if(CA++,(uA[CA]=[]).push(pA),mA.shadowingInstructions.createComponentOfType==="string")IA.push(await mA.value);else{const NA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,compositeAttributesObj:oA,nComponents:AA,stateIdInfo:tA}),yA=NA.attributes;AA=NA.nComponents;const{responseMarks:bA,otherAttributes:wA}=separateResponseMarks(yA),MA=EA?planValueReference({parentClass:DA,targetComponentType:dA.componentType,valueComponentType:mA.shadowingInstructions.createComponentOfType,fromImplicitProp:!!hA,hasAttributes:Object.keys(wA).length>0,allowDrawn:!0,componentInfoObjects:sA}):void 0;if(MA)IA.push(serializeValueReference({...MA,referencedVariable:pA,valueComponentType:mA.shadowingInstructions.createComponentOfType,target:dA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,responseMarks:bA,copiesReferent:copiesReferent({fromImplicitProp:!!hA,targetClass:dA.constructor,plan:MA})}));else if(BA){let vA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let TA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject();for(let OA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let FA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[OA].stateVariableToShadow,RA=TA[OA]?.createComponentOfType;if(attributeShadowIsReference(RA))vA[OA]=shadowAttributeReference({attrName:OA,attributeComponentType:RA,target:dA,stateVariableToShadow:FA});else if(RA){let xA={type:"serialized",componentType:RA,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:FA}]}};vA[OA]={component:xA}}}}deleteReplacedAttributes({attributes:vA,attributesFromComposite:yA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA}),Object.assign(vA,yA),IA.push({type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:vA,doenetAttributes:{},state:{},children:[],downstreamDependencies:{[dA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:pA,additionalStateVariableShadowing:mA.shadowingInstructions.addStateVariablesShadowingStateVariables}]}})}else{let vA={};if(mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables){let FA=sA.allComponentClasses[mA.shadowingInstructions.createComponentOfType].createAttributesObject(),RA={};for(let HA in mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables)if(FA[HA]?.createComponentOfType&&!CONTEXT_ATTRIBUTES.includes(HA)){let zA=mA.shadowingInstructions.addAttributeComponentsShadowingStateVariables[HA].stateVariableToShadow,GA=await dA.state[zA].value;dA.state[zA].usedDefault||(RA[HA]={type:"unresolved",name:HA,children:[GA.toString()]})}const xA=convertUnresolvedAttributesForComponentType({attributes:RA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA,nComponents:AA,stateIdInfo:tA}),jA=xA.attributes;if(AA=xA.nComponents,mA.shadowingInstructions.attributesToShadow)for(let HA of mA.shadowingInstructions.attributesToShadow)if(dA.attributes[HA]?.component){let zA=await dA.attributes[HA].component.serialize({copyAll:!0,copyVariants:!0}),GA=createNewComponentIndices([zA],AA,tA);AA=GA.nComponents,jA[HA]={type:"component",name:HA,component:GA.components[0]}}else dA.attributes[HA]?.type==="literal"?jA[HA]=copyOfLiteralAttribute(dA.attributes[HA],dA):dA.attributes[HA]?.primitive!==void 0&&(jA[HA]={type:"primitive",name:HA,primitive:JSON.parse(JSON.stringify(dA.attributes[HA].primitive))});Object.assign(vA,jA)}deleteReplacedAttributes({attributes:vA,attributesFromComposite:yA,componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA}),Object.assign(vA,yA);const kA=primaryEssentialStateVariableOf({componentType:mA.shadowingInstructions.createComponentOfType,componentInfoObjects:sA});let TA={type:"serialized",componentType:mA.shadowingInstructions.createComponentOfType,componentIdx:AA++,stateId:`${tA.prefix}${tA.num++}`,attributes:vA,doenetAttributes:{},children:[],state:{[kA]:QA}};IA.push(TA)}}}if(hA)for(let fA of IA)fA.componentType!=="_ref"&&(fA.doenetAttributes||(fA.doenetAttributes={}),fA.doenetAttributes.fromImplicitProp=!0,fA.downstreamDependencies?.[dA.componentIdx]?.[0]&&(fA.downstreamDependencies[dA.componentIdx][0].fromImplicitProp=!0));return{serializedReplacements:IA,propVariablesCopiedByReplacement:uA,diagnostics:cA,nComponents:AA}}function extendIgnoresAttributesAndChildren({replacementType:nA,attributeNames:eA,copyAttributeNames:AA,children:tA,componentInfoObjects:iA}){const rA=iA.allComponentClasses[nA];if(!rA)return{attributeNames:[],diagnostics:[]};const aA=iA.isCompositeComponent({componentType:nA}),oA=rA.prototype instanceof ValueListComponent;if(!aA&&!oA)return{attributeNames:[],diagnostics:[]};const sA=rA.createAttributesObject(),lA=new Set([...Object.keys((aA?CompositeComponent:ValueListComponent).createAttributesObject()),...Object.keys(returnNumberDisplayAttributes()).filter(IA=>nA==="collect"||IA in sA),...rA===Group||rA.prototype instanceof Group?Object.keys(Group.createAttributesObject()):[],...AA]),gA=[],cA=eA.filter(IA=>!lA.has(IA));for(const IA of cA)gA.push(codedDiagnostic({type:"warning",code:"doenet-w0168",args:{attribute:IA,componentType:nA}}));return aA&&!rA.addExtraSerializedChildrenWhenShadowing&&tA.some(IA=>typeof IA!="string"||IA.trim()!=="")&&gA.push(codedDiagnostic({type:"warning",code:"doenet-w0169",args:{componentType:nA}})),{attributeNames:cA,diagnostics:gA}}function addChildrenFromComposite({replacements:nA,children:eA,componentInfoObjects:AA}){let tA=nA[0];tA.children||(tA.children=[]);let iA=deepClone(eA);AA.allComponentClasses[tA.componentType].includeBlankStringChildren||(iA=iA.filter(aA=>typeof aA!="string"||aA.trim()!=="")),tA.children.push(...iA)}const LIST_TYPE_OF_VALUE_TYPE={math:"mathList",number:"numberList",text:"textList",boolean:"booleanList"};async function arrayListReplacement({component:nA,components:eA,target:AA,varName:tA,arrayStateVarObj:iA,numWrappingComponents:rA,link:aA,mayBeValueReference:oA,parentClass:sA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:cA,stateIdInfo:IA}){const uA=iA.shadowingInstructions?.createComponentOfType,CA=typeof uA=="string"?LIST_TYPE_OF_VALUE_TYPE[uA]:void 0;if(CA===void 0||(iA.numDimensions??1)!==1||rA>0||!aA||!oA||await nA.stateValues.removeEmptyArrayEntries||eA[nA.parentIdx]?.sharedParameters?.compositesMustHaveAReplacement||Object.values(iA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{}).some(({stateVariableToShadow:DA})=>AA.state[DA]?.companionOfEachEntry))return;const dA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:CA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:0,stateIdInfo:{prefix:"",num:0}}),{otherAttributes:pA}=separateResponseMarks(dA.attributes);if(Object.keys(pA).length>0||planValueReference({parentClass:sA,targetComponentType:AA.componentType,valueComponentType:uA,fromImplicitProp:!1,hasAttributes:!1,componentInfoObjects:lA}))return;const mA=convertUnresolvedAttributesForComponentType({attributes:nA.attributes,componentType:CA,componentInfoObjects:lA,compositeAttributesObj:gA,nComponents:cA,stateIdInfo:IA});cA=mA.nComponents;const QA={},BA=lA.allComponentClasses[CA].createAttributesObject(),hA=iA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{};for(const DA in hA){const EA=hA[DA].stateVariableToShadow,fA=BA[DA]?.createComponentOfType;if(!(!fA||AA.state[EA]?.isArray)){if(attributeShadowIsReference(fA)){QA[DA]=shadowAttributeReference({attrName:DA,attributeComponentType:fA,target:AA,stateVariableToShadow:EA});continue}QA[DA]={component:{type:"serialized",componentType:fA,componentIdx:cA++,stateId:`${IA.prefix}${IA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[],downstreamDependencies:{[AA.componentIdx]:[{compositeIdx:nA.componentIdx,dependencyType:"referenceShadow",propVariable:EA}]}}}}}return Object.assign(QA,mA.attributes),{serializedComponent:{type:"serialized",componentType:CA,componentIdx:cA++,stateId:`${IA.prefix}${IA.num++}`,attributes:QA,doenetAttributes:{},children:[],state:{},downstreamDependencies:{[AA.componentIdx]:[{dependencyType:"referenceShadow",compositeIdx:nA.componentIdx,propVariable:tA}]}},nComponents:cA}}function listEntrySourceDoenetAttributes({arrayStateVarObj:nA,arrayKey:eA,target:AA}){const tA=nA.shadowingInstructions.listEntrySourceVariables,iA=nA.keyToIndex(eA);return!tA||!Number.isInteger(iA)?{}:{listEntrySource:{componentIdx:AA.componentIdx,index:iA,variables:tA}}}async function listEntrySourceSnapshot({arrayStateVarObj:nA,arrayKey:eA,target:AA,nComponents:tA,stateIdInfo:iA}){const rA=[],aA={},oA=nA.shadowingInstructions.listEntrySourceVariables,sA=nA.keyToIndex(eA);if(!oA||!Number.isInteger(sA))return{children:rA,state:aA,nComponents:tA};const lA=nA.shadowingInstructions.addAttributeComponentsShadowingStateVariables??{};for(const[gA,cA]of Object.entries(oA)){if(gA==="labelHasLatex"||gA in lA||CONTEXT_ATTRIBUTES.includes(gA))continue;const IA=(await AA.state[cA].value)[sA];gA==="label"?typeof IA=="string"&&IA!==""&&rA.push({type:"serialized",componentType:"label",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{valueShadow:IA},children:[]}):IA!=null&&(aA[gA]=IA)}return{children:rA,state:aA,nComponents:tA}}function deleteReplacedAttributes({attributes:nA,attributesFromComposite:eA,componentType:AA,componentInfoObjects:tA}){const iA=tA.allComponentClasses[AA]?.createAttributesObject()??{};for(const rA in eA)for(const aA of iA[rA]?.replacesOnReference??[])delete nA[aA]}class ValueRef extends BaseComponent{static componentType="_ref";static rendererType=void 0;static excludeFromSchema=!0;static primaryStateVariableForDefinition="value";constructor(eA){if(super(eA),this.state.value.shadowingInstructions={createComponentOfType:this.presentedComponentType},this.doenetAttributes.copiesReferent&&this.isDrawn)for(const AA of this._referentActionNames())this.actions[AA]=(tA={})=>this._performOnReferent(AA,tA);if((this.doenetAttributes.fixedReferent||!this.isDrawn)&&(this.state.hidden.stateVariablesDeterminingDependencies=void 0),this.doenetAttributes.fixedReferent)for(const AA of["referentInfo","value","canBeModified","unordered","isNumber"])this.state[AA].stateVariablesDeterminingDependencies=void 0;else if(!pathHasIndexComponents(this.refResolution))for(const AA of["extendIdx","unresolvedPath","originalPath"])this.state[AA].stateVariablesDeterminingDependencies=void 0}get fixedReferent(){return this.doenetAttributes.fixedReferent}static createAttributesObject(){return{}}static returnChildGroups(){return[]}get presentedComponentType(){return this.doenetAttributes.presentedComponentType}get isDrawn(){if(this.doenetAttributes.isAttributeChildFor!==void 0)return!1;const eA=this.ancestors?.[0]?.componentClass;return this._drawnInParentClass!==eA&&(this._drawnInParentClass=eA,this._isDrawn=parentDrawsValueReferences(eA,this.componentInfoObjects)),this._isDrawn}get rendererType(){if(this.isDrawn)return this.componentInfoObjects.allComponentClasses[this.presentedComponentType]?.rendererType}get rendererVariables(){if(!this.isDrawn)return NO_RENDERER_VARIABLES;if(this._rendererVariables===void 0){this._rendererVariables={};for(const eA of this._presentedRendererVariableNames())(DRAWN_REFERENCE_VARIABLES.has(eA)||this.doenetAttributes.copiesReferent&&COPIED_REFERENT_VARIABLES.has(eA))&&(this._rendererVariables[eA]=!0)}return this._rendererVariables}get rendererConstants(){const eA={};for(const AA of this._presentedRendererVariableNames())AA in DRAWN_REFERENCE_CONSTANTS&&!(AA in this.rendererVariables)&&(eA[AA]=DRAWN_REFERENCE_CONSTANTS[AA]);return eA}async _performOnReferent(eA,{actionId:AA,sourceInformation:tA={},skipRendererUpdate:iA=!1}={}){const rA=this.fixedReferent??await this.stateValues.referentInfo;!rA||await this.stateValues.fixed||await this.coreFunctions.triggerChainedActions({triggeringAction:eA.endsWith("Clicked")?"click":"focus",componentIdx:rA.componentIdx,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA})}_referentActionNames(){for(const eA in REFERENT_ACTIONS)if(this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:this.presentedComponentType,baseComponentType:eA}))return REFERENT_ACTIONS[eA];return[]}_presentedRendererVariableNames(){if(this._presentedRendererNames===void 0){const eA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType];this._presentedRendererNames=Object.keys(eA?.returnStateVariableInfo({onlyForRenderer:!0}).stateVariableDescriptions??{})}return this._presentedRendererNames}get presentsAsAdapter(){return this.doenetAttributes.adapterVariable!==void 0}static returnStateVariableDefinitions(){const eA=super.returnStateVariableDefinitions(),AA={},tA=referenceSlotDefinitions({fixedReferentOf:iA=>iA.fixedReferent,readPlanOf:iA=>iA.doenetAttributes,emptyValueOf:(iA,rA)=>emptyValueOfType(iA.presentedComponentType,rA)});return Object.assign(AA,tA),AA.hidden={stateVariablesDeterminingDependencies:["referentInfo"],returnDependencies({stateValues:iA={}}){const rA={parentHidden:{dependencyType:"parentStateVariable",variableName:"hidden"},sourceCompositeHidden:{dependencyType:"sourceCompositeStateVariable",variableName:"hidden"}},aA=this.svComponent;if(!aA.isDrawn)return rA;aA.fixedReferent||(rA.valueMissing={dependencyType:"stateVariable",variableName:"valueMissing"});const oA=aA.fixedReferent??iA.referentInfo;return aA.doenetAttributes.copiesReferent&&oA&&(rA.referentHide={dependencyType:"stateVariable",componentIdx:oA.componentIdx,variableName:"hide",variablesOptional:!0}),Object.assign(rA,listEntryHideDependencies(oA)),rA},definition:({dependencyValues:iA})=>{const rA=listEntryHide(iA);return{setValue:{hidden:!!(iA.parentHidden||iA.sourceCompositeHidden||iA.valueMissing||iA.referentHide||rA)}}},markStale:()=>({updateParentRenderedChildren:!0})},AA.isInactiveCompositeReplacement=eA.isInactiveCompositeReplacement,AA.unordered=unorderedDefinition(),AA.isNumber=referentOrFallback({stateVariable:"isNumber",fallbackDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),fallback:({value:iA})=>Number.isFinite(typeof iA=="number"?iA:iA?.tree)}),AA}async serialize(eA={}){const AA=await super.serialize(eA);if(!eA.valueReferenceAsComponent||eA.serializingDescendant)return AA;AA.componentType=this.presentedComponentType,delete AA.extending;for(const aA of VALUE_REFERENCE_DOENET_ATTRIBUTES)delete AA.doenetAttributes[aA],delete AA.originalDoenetAttributes[aA];const tA=this.fixedReferent??await this.stateValues.referentInfo,iA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType]?.createAttributesObject()??{},rA=eA.copyAll?eA.components?.[tA?.componentIdx]:void 0;for(const aA in tA?.companions??{}){const oA=iA[aA]?.createComponentOfType;if(!oA||aA in AA.attributes)continue;if(!eA.copyAll&&attributeShadowIsReference(oA)){AA.attributes[aA]=shadowAttributeReference({attrName:aA,attributeComponentType:oA,target:{componentIdx:tA.componentIdx},stateVariableToShadow:tA.companions[aA]});continue}const sA={type:"serialized",componentType:oA,componentIdx:-1,attributes:{},doenetAttributes:{},state:{},children:[]};if(eA.copyAll){if(!rA)continue;sA.state.value=await currentReferentValue(rA,tA.companions[aA]),sA.dontShadowOriginalIndex=!0}else sA.shadowsVariableOf={componentIdx:tA.componentIdx,variableName:tA.companions[aA]};AA.attributes[aA]={type:"component",name:aA,component:sA}}if(tA&&(this.fixedReferent||!pathHasIndexComponents(this.refResolution))&&(AA.shadowsVariableOf={componentIdx:tA.componentIdx,variableName:tA.variableName},this.doenetAttributes.copiesReferent&&(AA.shadowsVariableOf.fromImplicitProp=!0,AA.doenetAttributes.fromImplicitProp=!0)),eA.copyAll){if(this.doenetAttributes.copiesReferent&&rA)for(const aA in rA.state){if(!rA.state[aA].hasEssential||aA==="literalAttributeWrites")continue;const sA=await rA.stateValues[aA];rA.state[aA].usedDefault||(AA.state[aA]=sA)}AA.state.value=await this.stateValues.value}return AA}returnMatchedChildIndices(){return[]}createOnDemandStateVariableDefinitions({stateVariable:eA,classDefinitions:AA}){if(eA==="valueMissing")return this.fixedReferent?[]:[[eA,valueMissingDefinition()]];if(eA==="pastEndOfList")return this.fixedReferent?[]:[[eA,pastEndOfListDefinition()]];if(eA==="valueAsResponse")return[[eA,valueAsResponseDefinition(this.doenetAttributes.referencedComponentType,this.fixedReferent)]];if(eA==="componentTypeAsResponse")return[[eA,componentTypeAsResponseDefinition(this.doenetAttributes.referencedComponentType,this.fixedReferent)]];if(CONTEXT_ATTRIBUTES.includes(eA))return[[eA,contextAttributeDefinition({attributeName:eA,base:{hasEssential:!0,defaultValue:!1},ownAttribute:!1,sourceDependency:referentContextDependency(eA),stateVariablesDeterminingDependencies:this.fixedReferent?void 0:["referentInfo"]})]];if(this.doenetAttributes.copiesReferent&&this.isDrawn&&COPIED_REFERENT_VARIABLES.has(eA))return[[eA,readsReferentVariable(eA,eA,this.fixedReferent)]];const tA=variableOfCopiedReferentVariable(eA);if(tA!==void 0)return[[eA,this.doenetAttributes.copiesReferent?readsReferentVariable(eA,tA,this.fixedReferent):{returnDependencies:()=>({}),definition:()=>({setValue:{[eA]:null}})}]];const iA=variableOfReferentVariable(eA);if(iA!==void 0)return[[eA,readsReferentVariable(eA,iA,this.fixedReferent)]];const rA=this.componentInfoObjects.allComponentClasses[this.presentedComponentType];if(!rA)return[];const aA=AA(rA);let oA=eA;if(!aA[oA]){const gA=this.componentInfoObjects.stateVariableInfo[this.presentedComponentType].arrayEntryPrefixes,cA=Object.keys(gA).filter(IA=>oA.startsWith(IA)).sort((IA,uA)=>uA.length-IA.length)[0];if(cA!==void 0&&(oA=gA[cA].arrayVariableName,oA in this.state))return[]}const sA=aA[oA];if(!sA||sA.isAlias)return[];const lA=[oA,...sA.additionalStateVariablesDefined??[]];return lA.length===1&&!sA.isArray?[[oA,companionOrBorrowed(oA,sA,this.fixedReferent)]]:lA.map(gA=>[gA,Object.create(aA[gA])])}}const VALUE_REFERENCE_DOENET_ATTRIBUTES=["presentedComponentType","referencedComponentType","adapterVariable","fixedReferent","copiesReferent","listEntryAdapterProperty","readsReferentAdapter"],NO_RENDERER_VARIABLES=Object.freeze({}),DRAWN_REFERENCE_VARIABLES=new Set(["hidden","text","latex","value","selectedStyle"]),DRAWN_REFERENCE_CONSTANTS=Object.freeze({renderAsMath:!1,renderMode:"inline",clickTarget:!1}),COPIED_REFERENT_VARIABLES=new Set(["selectedStyle","fixed",...Object.keys(DRAWN_REFERENCE_CONSTANTS)]);function referentContextDependency(nA){return(eA,AA)=>{const tA=eA.fixedReferent??AA.referentInfo;return!tA||tA.variableName===nA?null:{dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:nA==="fixed"&&tA.listEntryPosition!==void 0?"entriesFixed":nA,variablesOptional:!0}}}const REFERENT_ACTIONS={number:["numberClicked","numberFocused"],math:["mathClicked","mathFocused"],text:["textClicked","textFocused"]};function pastEndOfListDefinition(){return{stateVariablesDeterminingDependencies:["referentInfo"],returnDependencies({stateValues:nA,componentInfoObjects:eA}){const AA=nA.referentInfo,tA=AA?.listEntryPosition===void 0?void 0:eA.allComponentClasses[AA.componentType]?.listEntryCountVariable;return tA===void 0?{}:{referentInfo:{dependencyType:"stateVariable",variableName:"referentInfo"},numEntries:{dependencyType:"stateVariable",componentIdx:AA.componentIdx,variableName:tA}}},definition({dependencyValues:nA}){return{setValue:{pastEndOfList:nA.numEntries!==void 0&&nA.referentInfo.listEntryPosition>nA.numEntries}}}}}function valueAsResponseDefinition(nA,eA){const AA={returnDependencies({stateValues:tA={}}){const iA=eA??tA.referentInfo,rA=eA?{}:{valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA&&(rA.referenced={dependencyType:"stateVariable",componentIdx:iA.componentIdx,variableName:iA.referencedVariable,variablesOptional:!0}),rA},definition({dependencyValues:tA,componentInfoObjects:iA}){let rA=tA.referenced;return tA.valueMissing?rA=context.fromAst("_"):rA==null&&(rA=emptyValueOfType(nA,iA)),{setValue:{valueAsResponse:rA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function componentTypeAsResponseDefinition(nA,eA){return{returnDependencies:()=>eA?{}:{valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}},definition({dependencyValues:AA}){return{setValue:{componentTypeAsResponse:AA.valueMissing?"math":nA}}}}}function companionOrBorrowed(nA,eA,AA){const tA=Object.create(eA);return AA||(tA.stateVariablesDeterminingDependencies=[...eA.stateVariablesDeterminingDependencies??[],"referentInfo"]),tA.returnDependencies=function(iA){const rA=AA??iA.stateValues?.referentInfo,aA=rA?.companions?.[nA];return aA?{fromReferent:{dependencyType:"stateVariable",componentIdx:rA.componentIdx,variableName:aA,variablesOptional:!0}}:eA.returnDependencies.call(this,iA)},tA.definition=function(iA){if(!("fromReferent"in iA.dependencyValues))return eA.definition.call(this,iA);const rA=iA.dependencyValues.fromReferent;return iA.usedDefault.fromReferent&&this.hasEssential&&this.defaultValue!==void 0?{useEssentialOrDefaultValue:{[nA]:{defaultValue:rA}}}:{setValue:{[nA]:rA}}},tA.inverseDefinition=async function(iA){return(await iA.stateValues.referentInfo)?.companions?.[nA]?{success:!0,instructions:[{setDependency:"fromReferent",desiredValue:iA.desiredStateVariableValues[nA],shadowedVariable:!0}]}:eA.inverseDefinition?eA.inverseDefinition.call(this,iA):{success:!1}},tA}function listEntryHideDependencies(nA){return nA?.listEntryPosition===void 0?{}:{entryPosition:{dependencyType:"value",value:nA.listEntryPosition},referentVariable:{dependencyType:"value",value:nA.variableName},referentEntryPrefix:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"listEntryVariablePrefix",variablesOptional:!0},referentEntryHides:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"entryHides",variablesOptional:!0}}}function listEntryHide(nA){const eA=nA.entryPosition;if(!(!nA.referentEntryHides||nA.referentVariable!==`${nA.referentEntryPrefix}${eA}`&&nA.referentVariable!==`${LIST_ENTRY_PREFIX}value_${eA}`))return!!nA.referentEntryHides[eA-1]}function readsReferentVariable(nA,eA,AA){const tA={hasEssential:!0,defaultValue:null,returnDependencies({stateValues:iA={}}){const rA=AA??iA.referentInfo;return rA?{fromReferent:{dependencyType:"stateVariable",componentIdx:rA.componentIdx,variableName:eA,variablesOptional:!0}}:{}},definition({dependencyValues:iA,usedDefault:rA}){const aA=iA.fromReferent;return aA==null?{setValue:{[nA]:null}}:rA.fromReferent?{useEssentialOrDefaultValue:{[nA]:{defaultValue:aA}}}:{setValue:{[nA]:aA}}},async inverseDefinition({desiredStateVariableValues:iA,stateValues:rA}){return await rA.referentInfo?{success:!0,instructions:[{setDependency:"fromReferent",desiredValue:iA[nA]}]}:{success:!1}}};return AA||(tA.stateVariablesDeterminingDependencies=["referentInfo"]),tA}class SegmentConstraintComponent extends BaseComponent{static componentType="_segmentConstraint";static rendererType=void 0;static inSchemaOnlyInheritAs=["_segmentConstraint"]}class VariableNameList extends MathList{static componentType="_variableNameList";static stateVariableToBeShadowed="variables";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.variables={description:"The list of variable names.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},isArray:!0,entryPrefixes:["var"],additionalStateVariablesDefined:["validVariables"],returnArraySizeDependencies:()=>({numComponents:{dependencyType:"stateVariable",variableName:"numComponents"}}),returnArraySize({dependencyValues:AA}){return[AA.numComponents]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let iA of AA)tA[iA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(iA)+1)}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let iA={},rA={},aA=[];for(let oA of tA){let sA=AA[oA].math,lA=isValidVariable(sA);lA||(aA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:sA.toString()}})),lA=!1),iA[oA]=sA,rA[oA]=lA}return{setValue:{variables:iA,validVariables:rA},sendDiagnostics:aA}}},eA}}class Variable extends MathComponent{static componentType="_variableName";static rendererType="math";static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return renameStateVariable({stateVariableDefinitions:eA,oldName:"value",newName:"valuePreValidate"}),eA.valuePreValidate.essentialVarName="value",eA.value={description:"The variable as a math expression.",public:!0,shadowingInstructions:{createComponentOfType:"_variableName"},additionalStateVariablesDefined:["validVariable"],returnDependencies:()=>({valuePreValidate:{dependencyType:"stateVariable",variableName:"valuePreValidate"}}),definition({dependencyValues:AA}){let tA=[],iA=isValidVariable(AA.valuePreValidate);return iA||tA.push(codedDiagnostic({type:"warning",code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:iA},sendDiagnostics:tA}},inverseDefinition({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setDependency:"valuePreValidate",desiredValue:AA.value}]}}},eA}}class ListOfNumberLists extends InlineComponent{static componentType="_listOfNumberLists";static includeBlankStringChildren=!0;static removeBlankStringChildrenPostSugar=!0;static additionalSchemaChildren=["math","string"];static returnSugarInstructions(){let eA=[],AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){let aA=breakEmbeddedStringsIntoParensPieces({componentList:tA,removeParens:!0});return aA.success!==!0?{success:!1}:{success:!0,newChildren:aA.pieces.map(oA=>({type:"serialized",componentType:"numberList",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:oA,attributes:{},doenetAttributes:{},state:{}})),nComponents:iA}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){return[{group:"lists",componentTypes:["numberList"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return delete eA.value,eA.numLists={returnDependencies:()=>({listChildren:{dependencyType:"child",childGroups:["lists"]}}),definition({dependencyValues:AA}){return{setValue:{numLists:AA.listChildren.length}}}},eA.lists={isArray:!0,entryPrefixes:["list"],returnArraySizeDependencies:()=>({numLists:{dependencyType:"stateVariable",variableName:"numLists"}}),returnArraySize({dependencyValues:AA}){return[AA.numLists]},returnArrayDependenciesByKey({arrayKeys:AA}){let tA={};for(let iA of AA)tA[iA]={listChildren:{dependencyType:"child",childGroups:["lists"],variableNames:["values"],childIndices:[iA]}};return{dependenciesByKey:tA}},arrayDefinitionByKey({dependencyValuesByKey:AA,arrayKeys:tA}){let iA={};for(let rA of tA)if(AA[rA].listChildren&&AA[rA].listChildren.length===1){let aA=AA[rA].listChildren[0];iA[rA]=aA.stateValues.values}return{setValue:{lists:iA}}}},eA}}class DirectionComponent extends BaseComponent{static componentType="_directionComponent";static rendererType=void 0;static primaryStateVariableForDefinition="directionShadow";static additionalSchemaChildren=["math","string"];static createAttributesObject(){let eA=super.createAttributesObject();return Object.assign(eA,returnNumberDisplayAttributes()),eA}static returnSugarInstructions(){let eA=super.returnSugarInstructions(),AA=function({matchedChildren:tA,nComponents:iA,stateIdInfo:rA}){return tA.length===0?{success:!1}:tA.length>1||typeof tA[0]=="string"?{success:!0,newChildren:[{type:"serialized",componentType:"math",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:tA,attributes:{},doenetAttributes:{},state:{}}],nComponents:iA}:{success:!1}};return eA.push({replacementFunction:AA}),eA}static returnChildGroups(){let eA=super.returnChildGroups();return eA.push({group:"directions",componentTypes:["_directionComponent"]}),eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnNumberDisplayStateVariableDefinitions()),eA.directionShadow={defaultValue:context.fromAst(["vector",1,0]),hasEssential:!0,essentialVarName:"direction",set:convertValueToMathExpression,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{directionShadow:!0}}),inverseDefinition:function({desiredStateVariableValues:AA}){return{success:!0,instructions:[{setEssentialValue:"directionShadow",value:convertValueToMathExpression(AA.directionShadow)}]}}},eA.unnormalizedDirection={returnDependencies:()=>({directionChild:{dependencyType:"child",childGroups:["directions"],variableNames:["unnormalizedDirection"]},directionShadow:{dependencyType:"stateVariable",variableName:"directionShadow"}}),definition({dependencyValues:AA}){let tA;return AA.directionChild.length>0?tA=AA.directionChild[0].stateValues.unnormalizedDirection:tA=AA.directionShadow,tA=tA.tuples_to_vectors().expand().simplify(),{setValue:{unnormalizedDirection:tA}}},inverseDefinition({desiredStateVariableValues:AA,dependencyValues:tA}){let iA;return tA.directionChild.length>0?iA=[{setDependency:"directionChild",desiredValue:AA.unnormalizedDirection,childIndex:0,variableIndex:0}]:iA=[{setDependency:"directionShadow",desiredValue:AA.unnormalizedDirection}],{success:!0,instructions:iA}}},eA.numDimensions={returnDependencies:()=>({unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}),definition({dependencyValues:AA}){let tA=AA.unnormalizedDirection.tree,iA;return Array.isArray(tA)&&vectorOperators.includes(tA[0])?iA=tA.length-1:iA=1,{setValue:{numDimensions:iA}}}},eA.direction={description:"The normalized direction as a unit vector.",public:!0,shadowingInstructions:{createComponentOfType:"math",addAttributeComponentsShadowingStateVariables:returnNumberDisplayAttributeComponentShadowing(),returnWrappingComponents(AA){return AA==="x"?[]:[["vector",{componentType:"mathList",isAttributeNamed:"xs"}]]}},isArray:!0,entryPrefixes:["x"],hasEssential:!0,essentialVarName:"direction2",set:convertValueToMathExpression,returnArraySizeDependencies:()=>({numDimensions:{dependencyType:"stateVariable",variableName:"numDimensions"}}),returnArraySize({dependencyValues:AA}){return[AA.numDimensions]},returnArrayDependenciesByKey(){return{globalDependencies:{unnormalizedDirection:{dependencyType:"stateVariable",variableName:"unnormalizedDirection"}}}},arrayDefinitionByKey:function({globalDependencyValues:AA,arraySize:tA}){let iA={},rA=AA.unnormalizedDirection.tree;if(Array.isArray(rA)&&vectorOperators.includes(rA[0])){let aA=[],oA=tA[0],sA=0,lA=!0;for(let gA=0;gA<oA;gA++){let cA=AA.unnormalizedDirection.get_component(gA).evaluate_to_constant();if(Number.isFinite(cA))aA.push(cA),sA+=cA*cA;else{lA=!1;break}}if(lA){let gA=Math.sqrt(sA);for(let cA=0;cA<oA;cA++)iA[cA.toString()]=context.fromAst(aA[cA]/gA)}else for(let gA=0;gA<oA;gA++)iA[gA.toString()]=context.fromAst("_")}else iA[0]=context.fromAst(1);return{setValue:{direction:iA}}},inverseArrayDefinitionByKey({desiredStateVariableValues:AA,globalDependencyValues:tA,arraySize:iA}){let rA=[];if(iA[0]>1){let aA=0;for(let sA=0;sA<iA[0];sA++){let lA=evaluateToNumber(tA.unnormalizedDirection.get_component(sA));aA+=lA*lA}Number.isFinite(aA)?aA=Math.sqrt(aA):aA=1;let oA=["vector"];for(let sA in AA.direction)oA[Number(sA)+1]=AA.direction[sA].tree*aA;oA.length=iA[0]+1,rA.push({setDependency:"unnormalizedDirection",desiredValue:context.fromAst(markUnspecifiedComponents(oA))})}return{success:!0,instructions:rA}}},eA}}class ErrorComponent extends BlockComponent{static componentType="_error";static renderChildren=!0;static createAttributesObject(){let eA=super.createAttributesObject();return eA.message={createComponentOfType:"text",createStateVariable:"message",defaultValue:"",public:!0,forRenderer:!0,description:"The error message describing what went wrong."},eA}static returnChildGroups(){return[{group:"errors",componentTypes:["_error"]},{group:"any",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.hidden={returnDependencies:()=>({}),definition:()=>({setValue:{hidden:!1}})},eA.code={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{code:!0}})},eA.args={forRenderer:!0,hasEssential:!0,defaultValue:null,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{args:!0}})},eA.rangeMessage={description:"A message describing where in the source document the error was found.",forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"text"},additionalStateVariablesDefined:[{variableName:"rangeArgs",forRenderer:!0}],returnDependencies:()=>({position:{dependencyType:"position"}}),definition({dependencyValues:AA}){let tA=AA.position;return tA?.start.line===void 0?{setValue:{rangeMessage:"",rangeArgs:null}}:{setValue:{rangeMessage:"Found on "+printDoenetMLrange(tA)+".",rangeArgs:{span:tA.start.line===tA.end.line?"line":"lines",startLine:String(tA.start.line),endLine:String(tA.end.line)}}}}},eA.showMessage={forRenderer:!0,returnDependencies:()=>({childErrors:{dependencyType:"child",childGroups:["errors"],variableNames:["message"]},message:{dependencyType:"stateVariable",variableName:"message"}}),definition({dependencyValues:AA}){return{setValue:{showMessage:!AA.childErrors.some(iA=>iA.stateValues.message===AA.message)}}}},eA}}class Comment extends BaseComponent{static componentType="_comment";static rendererType=void 0;static returnChildGroups(){return[{group:"any",componentTypes:["_base"]}]}}const componentTypeArray=[...Object.values(Aliases),...Object.values(MMeMen),...Object.values(MdMdnMrow),...Object.values(BooleanOperators),...Object.values(BooleanOperatorsOfMath),...Object.values(MathOperators),...Object.values(MathListOperators),...Object.values(ListIndexOperators),...Object.values(CountOperators),Chart,Series,...Object.values(FunctionOperators),...Object.values(TextOperatorsOfMath),...Object.values(Extrema$1),...Object.values(ParagraphMarkup),...Object.values(SingleCharacterComponents),...Object.values(Sectioning),...Object.values(Lists),...Object.values(DynamicalSystems),...Object.values(Chemistry),...Object.values(FeedbackDefinitions$1),...Object.values(StyleDefinitions$1),...Object.values(StylePalette$1),...Object.values(SideBySide$1),...Object.values(ComponentWithSelectableType$1),...Object.values(Indexing),...Object.values(Divisions),...Object.values(Verbatim),...Object.values(Paginator$1),...Object.values(MatrixInput$1),...Object.values(FractionInput$1),...Object.values(Solution$1),Document,Text,TextList$1,TextList2,P$2,BooleanComponent,BooleanList,MathComponent,MathList,TupleList,NumberList,Copy,ValueRef,Collect,RegisteredCollectList,Ref,Point,Coords,Line,LineSegment,Ray,Polyline,Polygon,Triangle,Rectangle,RegularPolygon,Circle,Parabola,Curve,BezierControls,ControlVectors,Vector,Angle,Answer,Award,When,MathInput,Textinput,BooleanInput,Choiceinput,Choice,NumberComponent,Integer,Graph$1,Annotations,Annotation,Function$1,PiecewiseFunction,Interval,Option$1,Sequence,Slider,Spreadsheet,DiscreteSimulationResultList,DiscreteSimulationResultPolyline,Cell,Row,Column,Col,CellBlock,Tabular,Table,Figure,Markers,Panel,Repeat,RepeatForSequence,RepeatValues,RepeatValueList,RepeatPointList,RepeatIndices,Pegboard,Constraints,ConstrainToGrid,ConstrainToGraph,AttractToGrid,ConstrainTo,AttractTo,ConstraintUnion,AttractToConstraint,ConstrainToInterior,Intersection,ConstrainToAngles,AttractToAngles,ConditionalContent,AsList,VariantControl,TextListFromString,SelectFromSequence,Select,Group,AnimateFromSequence,Evaluate,SelectRandomNumbers,SampleRandomNumbers,SampleMultivariateRandomNumber,SelectPrimeNumbers,SamplePrimeNumbers,Substitute,PeriodicSet,Image,Video,Embed,Hint,IntComma,Pluralize,Feedback,CollaborateGroups,CollaborateGroupSetup,ConsiderAsResponses,Case,Lorem,UpdateValue,CallAction,triggerSet,FunctionIterates,Module,ModuleAttributes,Setup,Footnote,Caption,Endpoint,Sort,SortList,SortIndices,Shuffle,ShuffleList,SolveEquations,PostponeRenderContainer,SubsetOfRealsInput,SubsetOfReals,Split,BestFitLine,RegionBetweenCurveXAxis,RegionBetweenCurves,SlopeField,VectorField,RegionHalfPlane,CodeEditor,HasSameFactoring,DataFrame,SummaryStatistics,Legend,Label,MatchesPattern,Matrix,EigenDecomposition,Latex,BlockQuote,Description,StickyGroup,Pretzel,PretzelArranger,Cascade,Page,DynamicChildren,ShortDescription,BaseComponent,InlineComponent,BlockComponent,BlockScoredComponent,GraphicalComponent,ConstraintComponent,SegmentConstraintComponent,Input,CompositeComponent,PointList,IntervalList,LineListComponent,VectorList,AngleListComponent,BooleanOperator,BooleanBaseOperatorOfMath,MathOperator,MathOperatorOneInput,FunctionOperator,...Object.values(ComponentSize$1),...Object.values(SectioningComponent$1),InlineRenderInlineChildren,TextOrInline,SingleCharacter,VariableNameList,Variable,ListOfNumberLists,DirectionComponent,ErrorComponent,Comment];function allComponentClasses(){const nA={},eA=new Set;for(let AA of componentTypeArray){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let iA=tA.toLowerCase();if(eA.has(iA))throw Error("component type "+tA+" defined in two classes");nA[tA]=AA,eA.add(iA)}return nA}function componentTypesCreatingVariants(){const nA={},eA=new Set;for(let AA of componentTypeArray)if(AA.createsVariants){let tA=AA.componentType;if(tA===void 0)throw Error("Cannot create component as componentType is undefined for class "+AA);let iA=tA.toLowerCase();if(eA.has(iA))throw Error("component type "+tA+" defined in two classes");nA[tA]=AA,eA.add(iA)}return nA}function createComponentInfoObjects(){const nA=allComponentClasses(),eA=componentTypesCreatingVariants(),AA={};for(const lA in nA)AA[lA.toLowerCase()]=lA;const tA={};for(const lA in nA)Object.defineProperty(tA,lA,{get:(function(){const gA=nA[lA].returnStateVariableInfo();return delete tA[lA],tA[lA]=gA}).bind(this),configurable:!0});const iA={};for(const lA in nA)Object.defineProperty(iA,lA,{get:(function(){const gA=nA[lA].returnStateVariableInfo({onlyPublic:!0});return delete iA[lA],iA[lA]=gA}).bind(this),configurable:!0});function rA({inheritedComponentType:lA,baseComponentType:gA}){if(lA===gA)return!0;if(lA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let cA=nA[gA];return cA?cA.isPrototypeOf(nA[lA]):!1}function aA({componentType:lA,includeNonStandard:gA=!0}){const cA=nA[lA];return cA?rA({inheritedComponentType:lA,baseComponentType:"_composite"})&&(gA||!cA.treatAsComponentForRecursiveReplacements):!1}const oA=(lA,gA)=>rA({inheritedComponentType:lA,baseComponentType:gA});return{allComponentClasses:nA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,isInheritedComponentType:rA,isCompositeComponent:aA,stateVariableInfo:tA,publicStateVariableInfo:iA,componentIsSpecifiedType:(lA,gA)=>oA(lA.componentType,gA)||lA.attributes?.createComponentOfType?.primitive!==void 0&&oA(lA.attributes?.createComponentOfType?.primitive.value,gA)}}async function returnAllPossibleVariants(nA,eA,AA){let iA=getNumVariants({serializedComponent:nA,componentInfoObjects:eA,infoDiagnostics:AA}).numVariants,rA;return nA.variants?.allPossibleVariants?rA=nA.variants.allPossibleVariants:rA=[...Array(iA).keys()].map(aA=>indexToLowercaseLetters(aA+1)),rA}function indexToLowercaseLetters(nA){return numberToLetters(nA,!0)}class PublicDoenetMLCore{constructor(){this.core=null,this.initialized=!1,this.doenetML="",this.flags={},this.localeData=DEFAULT_LOCALE_DATA}setSource(eA){this.doenetML=eA}setFlags(eA){this.flags=eA}setLocaleData(eA){this.localeData=eA}async initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:rA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:lA,updateRootNames:gA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=gA;let cA=createComponentInfoObjects();const{document:IA,nComponents:uA,diagnostics:CA,sources:dA}=await normalizedDastToSerializedComponents(rA,cA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,serializedDocument:IA,nComponentsInit:uA,allDoenetMLs:dA,preliminaryDiagnostics:CA,componentInfoObjects:cA},this.initialized=!0;let pA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,CA);const mA=this.coreBaseArgs.serializedDocument.children.reduce((QA,BA)=>(typeof BA=="object"&&(QA[BA.componentType]=(QA[BA.componentType]??0)+1),QA),{});return{allPossibleVariants:pA,baseComponentCounts:mA}}async createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA){if(this.initialized&&!this.coreBaseArgs?.serializedDocument)return{success:!1,errMsg:"Cannot create the core a second time from the same worker; the serialized document was released after the first core was created."};let lA={...this.coreBaseArgs,...eA,addNodesToResolver:this.addNodesToResolver,replaceIndexResolutionsInResolver:this.replaceIndexResolutionsInResolver,deleteNodesFromResolver:this.deleteNodesFromResolver,resolvePath:this.resolvePath,updateRootNames:this.updateRootNames,updateRenderersCallback:AA,reportScoreAndStateCallback:tA,requestAnimationFrame:iA,cancelAnimationFrame:rA,copyToClipboard:aA,sendEvent:oA,requestSolutionView:sA};if(this.initialized){this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{return{success:!0,...await this.core.generateDast()}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async requestAction(eA){if(!this.core)return{success:!1,errMsg:"Cannot request action before core is created"};try{return await this.core.requestAction(eA)}catch(AA){return console.error(AA),{success:!1,errMsg:typeof AA=="string"?AA:typeof AA=="object"&&AA&&"message"in AA&&typeof AA.message=="string"?AA.message:"",actionId:eA.args?.actionId}}}async returnAllStateVariables(eA=!1,AA=!1){if(!this.core?.components)return{};const tA=this.core.processQueue.stoppedByError;if(tA!==null)throw Error(tA);const iA={},rA=this.core.components;eA&&console.log(rA);for(let aA in rA){const oA=Number(aA);let sA=rA[oA];if(!sA)continue;iA[oA]={componentIdx:oA,componentType:sA.componentType,stateValues:{},activeChildren:[],sharedParameters:null};let lA=iA[oA];for(let gA in sA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(gA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType})&&!sA.isExpanded)continue;const cA=await sA.state[gA].value;lA.stateValues[gA]=AA?cA:removeFunctionsMathExpressionClass(cA)}lA.activeChildren=sA.activeChildren.map(gA=>gA.componentIdx?{componentIdx:gA.componentIdx,componentType:gA.componentType}:gA),sA.replacements&&(lA.replacements=sA.replacements.map(gA=>gA.componentIdx?{componentIdx:gA.componentIdx,componentType:gA.componentType}:gA),sA.replacementsToWithhold!==void 0&&(lA.replacementsToWithhold=sA.replacementsToWithhold)),sA.replacementOf&&(lA.replacementOf=sA.replacementOf.componentIdx),lA.sharedParameters=AA?sA.sharedParameters:removeFunctionsMathExpressionClass(sA.sharedParameters)}return iA}async terminate(){this.core&&(await this.core.terminate(),this.core=null)}handleVisibilityChange(eA){this.core?.handleVisibilityChange(eA)}navigatingToComponent(eA,AA){this.core&&handleNavigatingToComponent({core:this.core,componentIdx:eA,hash:AA}).catch(reportTimerError(TimerLabels.navigateToComponent))}async submitAllAnswers(){await this.core?.requestAction({componentIdx:this.core.documentIdx,actionName:"submitAllAnswers",args:{}}),await this.core?.saveImmediately()}async saveImmediately(){await this.core?.saveImmediately()}async flushState(){return await this.core?.flushState()??!1}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(nA){return nA&&nA.__esModule&&Object.prototype.hasOwnProperty.call(nA,"default")?nA.default:nA}var colorName$1,hasRequiredColorName;function requireColorName(){return hasRequiredColorName||(hasRequiredColorName=1,colorName$1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),colorName$1}var colorNameExports=requireColorName();const colorName=getDefaultExportFromCjs(colorNameExports);var r$2={grad:.9,turn:360,rad:360/(2*Math.PI)},t$3=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},n$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},e$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},u$2=function(nA){return(nA=isFinite(nA)?nA%360:0)>0?nA:nA+360},a$2=function(nA){return{r:e$2(nA.r,0,255),g:e$2(nA.g,0,255),b:e$2(nA.b,0,255),a:e$2(nA.a)}},o$3=function(nA){return{r:n$2(nA.r),g:n$2(nA.g),b:n$2(nA.b),a:n$2(nA.a,3)}},i$2=/^#([0-9a-f]{3,8})$/i,s$1=function(nA){var eA=nA.toString(16);return eA.length<2?"0"+eA:eA},h$2=function(nA){var eA=nA.r,AA=nA.g,tA=nA.b,iA=nA.a,rA=Math.max(eA,AA,tA),aA=rA-Math.min(eA,AA,tA),oA=aA?rA===eA?(AA-tA)/aA:rA===AA?2+(tA-eA)/aA:4+(eA-AA)/aA:0;return{h:60*(oA<0?oA+6:oA),s:rA?aA/rA*100:0,v:rA/255*100,a:iA}},b$2=function(nA){var eA=nA.h,AA=nA.s,tA=nA.v,iA=nA.a;eA=eA/360*6,AA/=100,tA/=100;var rA=Math.floor(eA),aA=tA*(1-AA),oA=tA*(1-(eA-rA)*AA),sA=tA*(1-(1-eA+rA)*AA),lA=rA%6;return{r:255*[tA,oA,aA,aA,sA,tA][lA],g:255*[sA,tA,tA,oA,aA,aA][lA],b:255*[aA,aA,sA,tA,tA,oA][lA],a:iA}},g=function(nA){return{h:u$2(nA.h),s:e$2(nA.s,0,100),l:e$2(nA.l,0,100),a:e$2(nA.a)}},d$1=function(nA){return{h:n$2(nA.h),s:n$2(nA.s),l:n$2(nA.l),a:n$2(nA.a,3)}},f$1=function(nA){return b$2((AA=(eA=nA).s,{h:eA.h,s:(AA*=((tA=eA.l)<50?tA:100-tA)/100)>0?2*AA/(tA+AA)*100:0,v:tA+AA,a:eA.a}));var eA,AA,tA},c$1=function(nA){return{h:(eA=h$2(nA)).h,s:(iA=(200-(AA=eA.s))*(tA=eA.v)/100)>0&&iA<200?AA*tA/100/(iA<=100?iA:200-iA)*100:0,l:iA/2,a:eA.a};var eA,AA,tA,iA},l$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p$2=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v$1=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y$1={string:[[function(nA){var eA=i$2.exec(nA);return eA?(nA=eA[1]).length<=4?{r:parseInt(nA[0]+nA[0],16),g:parseInt(nA[1]+nA[1],16),b:parseInt(nA[2]+nA[2],16),a:nA.length===4?n$2(parseInt(nA[3]+nA[3],16)/255,2):1}:nA.length===6||nA.length===8?{r:parseInt(nA.substr(0,2),16),g:parseInt(nA.substr(2,2),16),b:parseInt(nA.substr(4,2),16),a:nA.length===8?n$2(parseInt(nA.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(nA){var eA=v$1.exec(nA)||m.exec(nA);return eA?eA[2]!==eA[4]||eA[4]!==eA[6]?null:a$2({r:Number(eA[1])/(eA[2]?100/255:1),g:Number(eA[3])/(eA[4]?100/255:1),b:Number(eA[5])/(eA[6]?100/255:1),a:eA[7]===void 0?1:Number(eA[7])/(eA[8]?100:1)}):null},"rgb"],[function(nA){var eA=l$2.exec(nA)||p$2.exec(nA);if(!eA)return null;var AA,tA,iA=g({h:(AA=eA[1],tA=eA[2],tA===void 0&&(tA="deg"),Number(AA)*(r$2[tA]||1)),s:Number(eA[3]),l:Number(eA[4]),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return f$1(iA)},"hsl"]],object:[[function(nA){var eA=nA.r,AA=nA.g,tA=nA.b,iA=nA.a,rA=iA===void 0?1:iA;return t$3(eA)&&t$3(AA)&&t$3(tA)?a$2({r:Number(eA),g:Number(AA),b:Number(tA),a:Number(rA)}):null},"rgb"],[function(nA){var eA=nA.h,AA=nA.s,tA=nA.l,iA=nA.a,rA=iA===void 0?1:iA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=g({h:Number(eA),s:Number(AA),l:Number(tA),a:Number(rA)});return f$1(aA)},"hsl"],[function(nA){var eA=nA.h,AA=nA.s,tA=nA.v,iA=nA.a,rA=iA===void 0?1:iA;if(!t$3(eA)||!t$3(AA)||!t$3(tA))return null;var aA=(function(oA){return{h:u$2(oA.h),s:e$2(oA.s,0,100),v:e$2(oA.v,0,100),a:e$2(oA.a)}})({h:Number(eA),s:Number(AA),v:Number(tA),a:Number(rA)});return b$2(aA)},"hsv"]]},N=function(nA,eA){for(var AA=0;AA<eA.length;AA++){var tA=eA[AA][0](nA);if(tA)return[tA,eA[AA][1]]}return[null,void 0]},x$1=function(nA){return typeof nA=="string"?N(nA.trim(),y$1.string):typeof nA=="object"&&nA!==null?N(nA,y$1.object):[null,void 0]},M$2=function(nA,eA){var AA=c$1(nA);return{h:AA.h,s:e$2(AA.s+100*eA,0,100),l:AA.l,a:AA.a}},H=function(nA){return(299*nA.r+587*nA.g+114*nA.b)/1e3/255},$=function(nA,eA){var AA=c$1(nA);return{h:AA.h,s:AA.s,l:e$2(AA.l+100*eA,0,100),a:AA.a}},j=(function(){function nA(eA){this.parsed=x$1(eA)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return nA.prototype.isValid=function(){return this.parsed!==null},nA.prototype.brightness=function(){return n$2(H(this.rgba),2)},nA.prototype.isDark=function(){return H(this.rgba)<.5},nA.prototype.isLight=function(){return H(this.rgba)>=.5},nA.prototype.toHex=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,iA=eA.b,aA=(rA=eA.a)<1?s$1(n$2(255*rA)):"","#"+s$1(AA)+s$1(tA)+s$1(iA)+aA;var eA,AA,tA,iA,rA,aA},nA.prototype.toRgb=function(){return o$3(this.rgba)},nA.prototype.toRgbString=function(){return eA=o$3(this.rgba),AA=eA.r,tA=eA.g,iA=eA.b,(rA=eA.a)<1?"rgba("+AA+", "+tA+", "+iA+", "+rA+")":"rgb("+AA+", "+tA+", "+iA+")";var eA,AA,tA,iA,rA},nA.prototype.toHsl=function(){return d$1(c$1(this.rgba))},nA.prototype.toHslString=function(){return eA=d$1(c$1(this.rgba)),AA=eA.h,tA=eA.s,iA=eA.l,(rA=eA.a)<1?"hsla("+AA+", "+tA+"%, "+iA+"%, "+rA+")":"hsl("+AA+", "+tA+"%, "+iA+"%)";var eA,AA,tA,iA,rA},nA.prototype.toHsv=function(){return eA=h$2(this.rgba),{h:n$2(eA.h),s:n$2(eA.s),v:n$2(eA.v),a:n$2(eA.a,3)};var eA},nA.prototype.invert=function(){return w$1({r:255-(eA=this.rgba).r,g:255-eA.g,b:255-eA.b,a:eA.a});var eA},nA.prototype.saturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,eA))},nA.prototype.desaturate=function(eA){return eA===void 0&&(eA=.1),w$1(M$2(this.rgba,-eA))},nA.prototype.grayscale=function(){return w$1(M$2(this.rgba,-1))},nA.prototype.lighten=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,eA))},nA.prototype.darken=function(eA){return eA===void 0&&(eA=.1),w$1($(this.rgba,-eA))},nA.prototype.rotate=function(eA){return eA===void 0&&(eA=15),this.hue(this.hue()+eA)},nA.prototype.alpha=function(eA){return typeof eA=="number"?w$1({r:(AA=this.rgba).r,g:AA.g,b:AA.b,a:eA}):n$2(this.rgba.a,3);var AA},nA.prototype.hue=function(eA){var AA=c$1(this.rgba);return typeof eA=="number"?w$1({h:eA,s:AA.s,l:AA.l,a:AA.a}):n$2(AA.h)},nA.prototype.isEqual=function(eA){return this.toHex()===w$1(eA).toHex()},nA})(),w$1=function(nA){return nA instanceof j?nA:new j(nA)},S=[],k=function(nA){nA.forEach(function(eA){S.indexOf(eA)<0&&(eA(j,y$1),S.push(eA))})},a$1=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},t$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},o$2=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},r$1=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h$1=function(nA){return 255*(nA>.0031308?1.055*Math.pow(nA,1/2.4)-.055:12.92*nA)},n$1=96.422,p$1=100,M$1=82.521,u$1=function(nA){var eA,AA,tA={x:.9555766*(eA=nA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h$1(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h$1(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h$1(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:nA.a},{r:o$2(AA.r,0,255),g:o$2(AA.g,0,255),b:o$2(AA.b,0,255),a:o$2(AA.a)}},e$1=function(nA){var eA=r$1(nA.r),AA=r$1(nA.g),tA=r$1(nA.b);return(function(iA){return{x:o$2(iA.x,0,n$1),y:o$2(iA.y,0,p$1),z:o$2(iA.z,0,M$1),a:o$2(iA.a)}})((function(iA){return{x:1.0478112*iA.x+.0228866*iA.y+-.050127*iA.z,y:.0295424*iA.x+.9904844*iA.y+-.0170491*iA.z,z:-.0092345*iA.x+.0150436*iA.y+.7521316*iA.z,a:iA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:nA.a}))},w=216/24389,b$1=24389/27,i$1=function(nA){var eA=nA.l,AA=nA.a,tA=nA.b,iA=nA.alpha,rA=iA===void 0?1:iA;if(!a$1(eA)||!a$1(AA)||!a$1(tA))return null;var aA=(function(oA){return{l:o$2(oA.l,0,400),a:oA.a,b:oA.b,alpha:o$2(oA.alpha)}})({l:Number(eA),a:Number(AA),b:Number(tA),alpha:Number(rA)});return l$1(aA)},l$1=function(nA){var eA=(nA.l+16)/116,AA=nA.a/500+eA,tA=eA-nA.b/200;return u$1({x:(Math.pow(AA,3)>w?Math.pow(AA,3):(116*AA-16)/b$1)*n$1,y:(nA.l>8?Math.pow((nA.l+16)/116,3):nA.l/b$1)*p$1,z:(Math.pow(tA,3)>w?Math.pow(tA,3):(116*tA-16)/b$1)*M$1,a:nA.alpha})};function labPlugin(nA,eA){nA.prototype.toLab=function(){return tA=e$1(this.rgba),rA=tA.y/p$1,aA=tA.z/M$1,iA=(iA=tA.x/n$1)>w?Math.cbrt(iA):(b$1*iA+16)/116,AA={l:116*(rA=rA>w?Math.cbrt(rA):(b$1*rA+16)/116)-16,a:500*(iA-rA),b:200*(rA-(aA=aA>w?Math.cbrt(aA):(b$1*aA+16)/116)),alpha:tA.a},{l:t$2(AA.l,2),a:t$2(AA.a,2),b:t$2(AA.b,2),alpha:t$2(AA.alpha,3)};var AA,tA,iA,rA,aA},nA.prototype.delta=function(AA){AA===void 0&&(AA="#FFF");var tA=AA instanceof nA?AA:new nA(AA),iA=(function(rA,aA){var oA=rA.l,sA=rA.a,lA=rA.b,gA=aA.l,cA=aA.a,IA=aA.b,uA=180/Math.PI,CA=Math.PI/180,dA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(cA,2)+Math.pow(IA,2),.5),mA=(oA+gA)/2,QA=Math.pow((dA+pA)/2,7),BA=.5*(1-Math.pow(QA/(QA+Math.pow(25,7)),.5)),hA=sA*(1+BA),DA=cA*(1+BA),EA=Math.pow(Math.pow(hA,2)+Math.pow(lA,2),.5),fA=Math.pow(Math.pow(DA,2)+Math.pow(IA,2),.5),NA=(EA+fA)/2,yA=hA===0&&lA===0?0:Math.atan2(lA,hA)*uA,bA=DA===0&&IA===0?0:Math.atan2(IA,DA)*uA;yA<0&&(yA+=360),bA<0&&(bA+=360);var wA=bA-yA,MA=Math.abs(bA-yA);MA>180&&bA<=yA?wA+=360:MA>180&&bA>yA&&(wA-=360);var vA=yA+bA;MA<=180?vA/=2:vA=(yA+bA<360?vA+360:vA-360)/2;var kA=1-.17*Math.cos(CA*(vA-30))+.24*Math.cos(2*CA*vA)+.32*Math.cos(CA*(3*vA+6))-.2*Math.cos(CA*(4*vA-63)),TA=gA-oA,OA=fA-EA,FA=2*Math.sin(CA*wA/2)*Math.pow(EA*fA,.5),RA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),xA=1+.045*NA,jA=1+.015*NA*kA,HA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),zA=-2*Math.pow(QA/(QA+Math.pow(25,7)),.5)*Math.sin(2*CA*HA);return Math.pow(Math.pow(TA/1/RA,2)+Math.pow(OA/1/xA,2)+Math.pow(FA/1/jA,2)+zA*OA*FA/(1*xA*1*jA),.5)})(this.toLab(),tA.toLab())/100;return o$2(t$2(iA,3))},eA.object.push([i$1,"lab"])}var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t$1=function(nA){return typeof nA=="string"?nA.length>0:typeof nA=="number"},a=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=Math.pow(10,eA)),Math.round(AA*nA)/AA+0},n=function(nA,eA,AA){return eA===void 0&&(eA=0),AA===void 0&&(AA=1),nA>AA?AA:nA>eA?nA:eA},u=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},h=function(nA){return 255*(nA>.0031308?1.055*Math.pow(nA,1/2.4)-.055:12.92*nA)},o$1=96.422,e=100,c=82.521,i=function(nA){var eA,AA,tA={x:.9555766*(eA=nA).x+-.0230393*eA.y+.0631636*eA.z,y:-.0282895*eA.x+1.0099416*eA.y+.0210077*eA.z,z:.0122982*eA.x+-.020483*eA.y+1.3299098*eA.z};return AA={r:h(.032404542*tA.x-.015371385*tA.y-.004985314*tA.z),g:h(-.00969266*tA.x+.018760108*tA.y+41556e-8*tA.z),b:h(556434e-9*tA.x-.002040259*tA.y+.010572252*tA.z),a:nA.a},{r:n(AA.r,0,255),g:n(AA.g,0,255),b:n(AA.b,0,255),a:n(AA.a)}},l=function(nA){var eA=u(nA.r),AA=u(nA.g),tA=u(nA.b);return(function(iA){return{x:n(iA.x,0,o$1),y:n(iA.y,0,e),z:n(iA.z,0,c),a:n(iA.a)}})((function(iA){return{x:1.0478112*iA.x+.0228866*iA.y+-.050127*iA.z,y:.0295424*iA.x+.9904844*iA.y+-.0170491*iA.z,z:-.0092345*iA.x+.0150436*iA.y+.7521316*iA.z,a:iA.a}})({x:100*(.4124564*eA+.3575761*AA+.1804375*tA),y:100*(.2126729*eA+.7151522*AA+.072175*tA),z:100*(.0193339*eA+.119192*AA+.9503041*tA),a:nA.a}))},f=216/24389,b=24389/27,d=function(nA){return{l:n(nA.l,0,100),c:nA.c,h:(eA=nA.h,(eA=isFinite(eA)?eA%360:0)>0?eA:eA+360),a:nA.a};var eA},p=function(nA){return{l:a(nA.l,2),c:a(nA.c,2),h:a(nA.h,2),a:a(nA.a,3)}},v=function(nA){var eA=nA.l,AA=nA.c,tA=nA.h,iA=nA.a,rA=iA===void 0?1:iA;if(!t$1(eA)||!t$1(AA)||!t$1(tA))return null;var aA=d({l:Number(eA),c:Number(AA),h:Number(tA),a:Number(rA)});return M(aA)},y=function(nA){var eA=(function(rA){var aA=l(rA),oA=aA.x/o$1,sA=aA.y/e,lA=aA.z/c;return oA=oA>f?Math.cbrt(oA):(b*oA+16)/116,{l:116*(sA=sA>f?Math.cbrt(sA):(b*sA+16)/116)-16,a:500*(oA-sA),b:200*(sA-(lA=lA>f?Math.cbrt(lA):(b*lA+16)/116)),alpha:aA.a}})(nA),AA=a(eA.a,3),tA=a(eA.b,3),iA=Math.atan2(tA,AA)/Math.PI*180;return{l:eA.l,c:Math.sqrt(AA*AA+tA*tA),h:iA<0?iA+360:iA,a:eA.alpha}},M=function(nA){return eA={l:nA.l,a:nA.c*Math.cos(nA.h*Math.PI/180),b:nA.c*Math.sin(nA.h*Math.PI/180),alpha:nA.a},tA=eA.a/500+(AA=(eA.l+16)/116),iA=AA-eA.b/200,i({x:(Math.pow(tA,3)>f?Math.pow(tA,3):(116*tA-16)/b)*o$1,y:(eA.l>8?Math.pow((eA.l+16)/116,3):eA.l/b)*e,z:(Math.pow(iA,3)>f?Math.pow(iA,3):(116*iA-16)/b)*c,a:eA.alpha});var eA,AA,tA,iA},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(nA){var eA=x.exec(nA);if(!eA)return null;var AA,tA,iA=d({l:Number(eA[1]),c:Number(eA[2]),h:(AA=eA[3],tA=eA[4],tA===void 0&&(tA="deg"),Number(AA)*(r[tA]||1)),a:eA[5]===void 0?1:Number(eA[5])/(eA[6]?100:1)});return M(iA)};function lchPlugin(nA,eA){nA.prototype.toLch=function(){return p(y(this.rgba))},nA.prototype.toLchString=function(){return AA=p(y(this.rgba)),tA=AA.l,iA=AA.c,rA=AA.h,(aA=AA.a)<1?"lch("+tA+"% "+iA+" "+rA+" / "+aA+")":"lch("+tA+"% "+iA+" "+rA+")";var AA,tA,iA,rA,aA},eA.string.push([s,"lch"]),eA.object.push([v,"lch"])}k([labPlugin,lchPlugin]);const canonicalColorHexByKey={black:"#000000",white:"#ffffff",gray:"#808080",red:"#ff0000",orange:"#ffa500",yellow:"#ffff00",green:"#008000",cyan:"#00ffff",blue:"#0000ff",purple:"#800080",pink:"#ffc0cb",brown:"#a52a2a"},canonicalAnchorDefinitions=Object.fromEntries(Object.entries(canonicalColorHexByKey).map(([nA,eA])=>[nA,{hex:eA,canonical:nA}])),extraAnchorDefinitions={silver:{hex:"#c0c0c0",canonical:"gray"},grayDark:{hex:"#4d4d4d",canonical:"gray"},grayCustom:{hex:"#757575",canonical:"gray"},grayLight:{hex:"#c8c8c8",canonical:"gray"},grayLighter:{hex:"#dcdcdc",canonical:"gray"},maroon:{hex:"#800000",canonical:"red"},redLight:{hex:"#f08080",canonical:"red"},redCustom:{hex:"#D4042D",canonical:"red"},redDark:{hex:"#8b0000",canonical:"red"},crimson:{hex:"#dc143c",canonical:"red"},wine:{hex:"#993355",canonical:"red"},orangeLight:{hex:"#ffa07a",canonical:"orange"},orangeCustom:{hex:"#F19143",canonical:"orange"},orangePresetAccessible:{hex:"#a6510c",canonical:"orange"},orangeDark:{hex:"#ff8c00",canonical:"orange"},yellowLight:{hex:"#ffffe0",canonical:"yellow"},yellowDark:{hex:"#bdb76b",canonical:"yellow"},yellowgreen:{hex:"#9acd32",canonical:"green"},olive:{hex:"#808000",canonical:"green"},lime:{hex:"#00ff00",canonical:"green"},greenLight:{hex:"#90ee90",canonical:"green"},greenCustom:{hex:"#2ca02c",canonical:"green"},greenDark:{hex:"#006400",canonical:"green"},teal:{hex:"#008080",canonical:"green"},aqua:{hex:"#00ffff",canonical:"cyan"},cyanLight:{hex:"#e0ffff",canonical:"cyan"},cyanMid:{hex:"#25b0c0",canonical:"cyan"},cyanDark:{hex:"#008b8b",canonical:"cyan"},navy:{hex:"#000080",canonical:"blue"},blueMid:{hex:"#4477aa",canonical:"blue"},blueSky:{hex:"#56b4e9",canonical:"blue"},blueCustom:{hex:"#648FFF",canonical:"blue"},bluePresetAccessible:{hex:"#1f5dff",canonical:"blue"},blueLight:{hex:"#add8e6",canonical:"blue"},blueDark:{hex:"#00008b",canonical:"blue"},fuchsia:{hex:"#ff00ff",canonical:"purple"},purpleCustom:{hex:"#644CD6",canonical:"purple"},purpleMuted:{hex:"#9c5686",canonical:"purple"},purpleLight:{hex:"#dda0dd",canonical:"purple"},purpleDark:{hex:"#8b008b",canonical:"purple"},hotpink:{hex:"#ff69b4",canonical:"pink"},pinkDark:{hex:"#ff1493",canonical:"pink"},brownLight:{hex:"#deb887",canonical:"brown"},brownDark:{hex:"#8b4513",canonical:"brown"}},anchorDefinitions={...canonicalAnchorDefinitions,...extraAnchorDefinitions};Object.values(anchorDefinitions).map(nA=>({color:w$1(nA.hex),canonical:nA.canonical})),[...Object.keys(colorName)];const DEFAULT_STYLE_VALUES={lineOpacity:.7,lineWidth:4,lineWidthWord:"thick",lineStyle:"solid",lineStyleWord:"",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,markerFilled:!0,fillOpacity:.3,fillPatternOpacity:1,fillStyle:"solid",fillStyleWord:"",lineColor:"#1f5dff",lineColorDarkMode:"#648FFF",markerColor:"#1f5dff",markerColorDarkMode:"#648FFF",fillColor:"#1f5dff",fillColorDarkMode:"#648FFF",textColor:"black",textColorDarkMode:"white",highContrastColor:"#2963FF",highContrastColorDarkMode:"#92B4FF"},defaultPalette={name:"default",description:"The standard Doenet styles: blue, red, orange, purple, black, and gray.",styles:{1:{...DEFAULT_STYLE_VALUES},2:{lineColor:"#D4042D",lineColorDarkMode:"#F1466A",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#D4042D",markerColorDarkMode:"#F1466A",markerOpacity:.7,markerStyle:"square",markerStyleWord:"square",markerSize:5,fillColor:"#D4042D",fillColorDarkMode:"#F1466A",fillOpacity:.3,textColor:"#D4042D",textColorDarkMode:"#FF7A7A",highContrastColor:"#D4042D",highContrastColorDarkMode:"#FF7A7A"},3:{lineColor:"#a6510c",lineColorDarkMode:"#F19143",lineOpacity:.7,lineWidth:3,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#a6510c",markerColorDarkMode:"#F19143",markerOpacity:.7,markerStyle:"triangle",markerStyleWord:"triangle",markerSize:5,fillColor:"#a6510c",fillColorDarkMode:"#F19143",fillOpacity:.3,textColor:"#BE5A0E",textColorDarkMode:"#FFA94D",highContrastColor:"#BE5A0E",highContrastColorDarkMode:"#FFA94D"},4:{lineColor:"#644CD6",lineColorDarkMode:"#9F8FE8",lineColorWordDarkMode:"purple",lineOpacity:.7,lineWidth:2,lineWidthWord:"",lineStyle:"solid",lineStyleWord:"",markerColor:"#644CD6",markerColorDarkMode:"#9F8FE8",markerColorWordDarkMode:"purple",markerOpacity:.7,markerStyle:"diamond",markerStyleWord:"diamond",markerSize:5,fillColor:"#644CD6",fillColorDarkMode:"#9F8FE8",fillColorWordDarkMode:"purple",fillOpacity:.3,textColor:"#644CD6",textColorDarkMode:"#B0A4EE",highContrastColor:"#644CD6",highContrastColorDarkMode:"#B0A4EE"},5:{lineColor:"black",lineColorDarkMode:"white",lineOpacity:1,lineWidth:1,lineWidthWord:"thin",lineStyle:"solid",lineStyleWord:"",markerColor:"black",markerColorDarkMode:"white",markerOpacity:1,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"black",fillColorDarkMode:"white",fillOpacity:.7,textColor:"black",textColorDarkMode:"white",highContrastColor:"black",highContrastColorDarkMode:"white"},6:{lineColor:"#636363",lineColorDarkMode:"#CCCCCC",lineOpacity:.7,lineWidth:1,lineWidthWord:"thin",lineStyle:"dotted",lineStyleWord:"dotted",markerColor:"#636363",markerColorDarkMode:"#CCCCCC",markerOpacity:.7,markerStyle:"circle",markerStyleWord:"point",markerSize:5,fillColor:"#636363",fillColorDarkMode:"#CCCCCC",fillOpacity:.3,textColor:"#757575",textColorDarkMode:"#B0B0B0",highContrastColor:"#757575",highContrastColorDarkMode:"#B0B0B0"}}},okabeItoPalette={name:"okabeIto",description:"Colorblind-friendly blues, oranges, greens, and purples adapted from the Okabe-Ito palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#0072b2",markerColor:"#0072b2",fillColor:"#0072b2",highContrastColor:"#0072b2",lineColorDarkMode:"#0072b2",markerColorDarkMode:"#0072b2",fillColorDarkMode:"#0072b2",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#c15400",markerColor:"#c15400",fillColor:"#c15400",textColor:"#c15400",highContrastColor:"#c15400",lineColorDarkMode:"#d55e00",markerColorDarkMode:"#d55e00",fillColorDarkMode:"#d55e00",textColorDarkMode:"#d55e00",lineWidth:2,markerStyle:"square"},3:{lineColor:"#009e73",markerColor:"#009e73",fillColor:"#009e73",textColor:"#008561",highContrastColor:"#008561",lineColorDarkMode:"#009e73",markerColorDarkMode:"#009e73",fillColorDarkMode:"#009e73",textColorDarkMode:"#009e73",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#cc79a7",markerColor:"#cc79a7",fillColor:"#cc79a7",textColor:"#a35f85",highContrastColor:"#a35f85",lineColorWord:"purple",markerColorWord:"purple",fillColorWord:"purple",lineColorDarkMode:"#cc79a7",markerColorDarkMode:"#cc79a7",fillColorDarkMode:"#cc79a7",textColorDarkMode:"#cc79a7",lineColorWordDarkMode:"purple",markerColorWordDarkMode:"purple",fillColorWordDarkMode:"purple",textColorWordDarkMode:"purple",highContrastColorWordDarkMode:"purple",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#5a5513",markerColor:"#5a5513",fillColor:"#5a5513",textColor:"#5a5513",highContrastColor:"#5a5513",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#f0e442",markerColorDarkMode:"#f0e442",fillColorDarkMode:"#f0e442",textColorDarkMode:"#f0e442",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#499bca",markerColor:"#499bca",fillColor:"#499bca",textColor:"#397ba1",highContrastColor:"#397ba1",lineColorWord:"skyblue",markerColorWord:"skyblue",fillColorWord:"skyblue",textColorWord:"skyblue",highContrastColorWord:"skyblue",lineColorDarkMode:"#56b4e9",markerColorDarkMode:"#56b4e9",fillColorDarkMode:"#56b4e9",textColorDarkMode:"#56b4e9",lineColorWordDarkMode:"skyblue",markerColorWordDarkMode:"skyblue",fillColorWordDarkMode:"skyblue",textColorWordDarkMode:"skyblue",highContrastColorWordDarkMode:"skyblue",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#c58700",markerColor:"#c58700",fillColor:"#c58700",textColor:"#9d6b00",highContrastColor:"#9d6b00",lineColorWord:"goldenrod",markerColorWord:"goldenrod",fillColorWord:"goldenrod",textColorWord:"goldenrod",highContrastColorWord:"goldenrod",lineColorDarkMode:"#e69f00",markerColorDarkMode:"#e69f00",fillColorDarkMode:"#e69f00",textColorDarkMode:"#e69f00",lineColorWordDarkMode:"goldenrod",markerColorWordDarkMode:"goldenrod",fillColorWordDarkMode:"goldenrod",textColorWordDarkMode:"goldenrod",highContrastColorWordDarkMode:"goldenrod",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"}}},tolBrightPalette={name:"tolBright",description:"Colorblind-friendly bright blues, reds, greens, and purples from Paul Tol's bright palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#4477aa",markerColor:"#4477aa",fillColor:"#4477aa",highContrastColor:"#4477aa",lineColorDarkMode:"#4477aa",markerColorDarkMode:"#4477aa",fillColorDarkMode:"#4477aa",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#ee6677",markerColor:"#ee6677",fillColor:"#ee6677",textColor:"#bf515e",highContrastColor:"#bf515e",lineColorDarkMode:"#ee6677",markerColorDarkMode:"#ee6677",fillColorDarkMode:"#ee6677",textColorDarkMode:"#ee6677",lineWidth:2,markerStyle:"square"},3:{lineColor:"#228833",markerColor:"#228833",fillColor:"#228833",textColor:"#228833",highContrastColor:"#228833",lineColorDarkMode:"#228833",markerColorDarkMode:"#228833",fillColorDarkMode:"#228833",textColorDarkMode:"#3d8e47",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#a29534",markerColor:"#a29534",fillColor:"#a29534",textColor:"#817628",highContrastColor:"#817628",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#ccbb44",markerColorDarkMode:"#ccbb44",fillColorDarkMode:"#ccbb44",textColorDarkMode:"#ccbb44",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#4d9db8",markerColor:"#4d9db8",fillColor:"#4d9db8",textColor:"#3c7d94",highContrastColor:"#3c7d94",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#66ccee",markerColorDarkMode:"#66ccee",fillColorDarkMode:"#66ccee",textColorDarkMode:"#66ccee",lineColorWordDarkMode:"cyan",markerColorWordDarkMode:"cyan",fillColorWordDarkMode:"cyan",textColorWordDarkMode:"cyan",highContrastColorWordDarkMode:"cyan",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#aa3377",markerColor:"#aa3377",fillColor:"#aa3377",textColor:"#aa3377",highContrastColor:"#aa3377",lineColorDarkMode:"#aa3377",markerColorDarkMode:"#aa3377",fillColorDarkMode:"#aa3377",textColorDarkMode:"#b5648c",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#bbbbbb",markerColorDarkMode:"#bbbbbb",fillColorDarkMode:"#bbbbbb",textColorDarkMode:"#bbbbbb",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"}}},tolMutedPalette={name:"tolMuted",description:"Nine colorblind-friendly muted styles from Paul Tol's muted palette, with varied marker shapes and line styles.",styles:{1:{lineColor:"#332288",markerColor:"#332288",fillColor:"#332288",highContrastColor:"#332288",lineColorWord:"indigo",markerColorWord:"indigo",fillColorWord:"indigo",highContrastColorWord:"indigo",lineColorDarkMode:"#8a86e8",markerColorDarkMode:"#8a86e8",fillColorDarkMode:"#8a86e8",lineColorWordDarkMode:"indigo",markerColorWordDarkMode:"indigo",fillColorWordDarkMode:"indigo",highContrastColorWordDarkMode:"indigo",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#669ab5",markerColor:"#669ab5",fillColor:"#669ab5",textColor:"#507a90",highContrastColor:"#507a90",lineColorDarkMode:"#88ccee",markerColorDarkMode:"#88ccee",fillColorDarkMode:"#88ccee",textColorDarkMode:"#88ccee",lineWidth:2,markerStyle:"square"},3:{lineColor:"#41a393",markerColor:"#41a393",fillColor:"#41a393",textColor:"#328175",highContrastColor:"#328175",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#44aa99",markerColorDarkMode:"#44aa99",fillColorDarkMode:"#44aa99",textColorDarkMode:"#44aa99",lineColorWordDarkMode:"teal",markerColorWordDarkMode:"teal",fillColorWordDarkMode:"teal",textColorWordDarkMode:"teal",highContrastColorWordDarkMode:"teal",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#117733",markerColor:"#117733",fillColor:"#117733",textColor:"#117733",highContrastColor:"#117733",lineColorDarkMode:"#117733",markerColorDarkMode:"#117733",fillColorDarkMode:"#117733",textColorDarkMode:"#548a5f",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#989833",markerColor:"#989833",fillColor:"#989833",textColor:"#787827",highContrastColor:"#787827",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#999933",markerColorDarkMode:"#999933",fillColorDarkMode:"#999933",textColorDarkMode:"#999933",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#867c46",markerColor:"#867c46",fillColor:"#867c46",textColor:"#7f7542",highContrastColor:"#7f7542",lineColorWord:"tan",markerColorWord:"tan",fillColorWord:"tan",textColorWord:"tan",highContrastColorWord:"tan",lineColorDarkMode:"#ddcc77",markerColorDarkMode:"#ddcc77",fillColorDarkMode:"#ddcc77",textColorDarkMode:"#ddcc77",lineColorWordDarkMode:"tan",markerColorWordDarkMode:"tan",fillColorWordDarkMode:"tan",textColorWordDarkMode:"tan",highContrastColorWordDarkMode:"tan",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#cc6677",markerColor:"#cc6677",fillColor:"#cc6677",textColor:"#b35968",highContrastColor:"#b35968",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#cc6677",markerColorDarkMode:"#cc6677",fillColorDarkMode:"#cc6677",textColorDarkMode:"#cc6677",lineColorWordDarkMode:"pink",markerColorWordDarkMode:"pink",fillColorWordDarkMode:"pink",textColorWordDarkMode:"pink",highContrastColorWordDarkMode:"pink",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#882255",markerColor:"#882255",fillColor:"#882255",textColor:"#882255",highContrastColor:"#882255",lineColorWord:"maroon",markerColorWord:"maroon",fillColorWord:"maroon",textColorWord:"maroon",highContrastColorWord:"maroon",lineColorDarkMode:"#924b69",markerColorDarkMode:"#924b69",fillColorDarkMode:"#924b69",textColorDarkMode:"#a17083",lineColorWordDarkMode:"maroon",markerColorWordDarkMode:"maroon",fillColorWordDarkMode:"maroon",textColorWordDarkMode:"maroon",highContrastColorWordDarkMode:"maroon",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#aa4499",markerColor:"#aa4499",fillColor:"#aa4499",textColor:"#aa4499",highContrastColor:"#aa4499",lineColorDarkMode:"#aa4499",markerColorDarkMode:"#aa4499",fillColorDarkMode:"#aa4499",textColorDarkMode:"#b262a3",lineWidth:2,lineStyle:"dashed",markerStyle:"square"}}},tolHighContrastPalette={name:"tolHighContrast",description:"Four maximum-distinction styles from Paul Tol's high-contrast palette, distinguishable even in grayscale.",styles:{1:{lineColor:"#004488",markerColor:"#004488",fillColor:"#004488",highContrastColor:"#004488",lineColorDarkMode:"#496194",markerColorDarkMode:"#496194",fillColorDarkMode:"#496194",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#b88d29",markerColor:"#b88d29",fillColor:"#b88d29",textColor:"#92701f",highContrastColor:"#92701f",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ddaa33",markerColorDarkMode:"#ddaa33",fillColorDarkMode:"#ddaa33",textColorDarkMode:"#ddaa33",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"square"},3:{lineColor:"#bb5566",markerColor:"#bb5566",fillColor:"#bb5566",textColor:"#bb5566",highContrastColor:"#bb5566",lineColorDarkMode:"#c06976",markerColorDarkMode:"#c06976",fillColorDarkMode:"#c06976",textColorDarkMode:"#c06976",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",textColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",textColorDarkMode:"#ffffff",lineWidth:2,markerStyle:"diamond"}}},ibmPalette={name:"ibm",description:"Five colorblind-friendly styles from the IBM Design Library accessible palette, with varied marker shapes.",styles:{1:{lineColor:"#648fff",markerColor:"#648fff",fillColor:"#648fff",highContrastColor:"#4f71cb",lineColorDarkMode:"#648fff",markerColorDarkMode:"#648fff",fillColorDarkMode:"#648fff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#6a53d5",markerColor:"#6a53d5",fillColor:"#6a53d5",textColor:"#6a53d5",highContrastColor:"#6a53d5",lineColorDarkMode:"#785ef0",markerColorDarkMode:"#785ef0",fillColorDarkMode:"#785ef0",textColorDarkMode:"#7f69f0",lineWidth:2,markerStyle:"square"},3:{lineColor:"#dc267f",markerColor:"#dc267f",fillColor:"#dc267f",textColor:"#dc267f",highContrastColor:"#dc267f",lineColorWord:"magenta",markerColorWord:"magenta",fillColorWord:"magenta",textColorWord:"magenta",highContrastColorWord:"magenta",lineColorDarkMode:"#dc267f",markerColorDarkMode:"#dc267f",fillColorDarkMode:"#dc267f",textColorDarkMode:"#dd4186",lineColorWordDarkMode:"magenta",markerColorWordDarkMode:"magenta",fillColorWordDarkMode:"magenta",textColorWordDarkMode:"magenta",highContrastColorWordDarkMode:"magenta",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#fe6100",markerColor:"#fe6100",fillColor:"#fe6100",textColor:"#cb4b00",highContrastColor:"#cb4b00",lineColorDarkMode:"#fe6100",markerColorDarkMode:"#fe6100",fillColorDarkMode:"#fe6100",textColorDarkMode:"#fe6100",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#865a00",markerColor:"#865a00",fillColor:"#865a00",textColor:"#865a00",highContrastColor:"#865a00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffb000",markerColorDarkMode:"#ffb000",fillColorDarkMode:"#ffb000",textColorDarkMode:"#ffb000",lineColorWordDarkMode:"gold",markerColorWordDarkMode:"gold",fillColorWordDarkMode:"gold",textColorWordDarkMode:"gold",highContrastColorWordDarkMode:"gold",lineWidth:2,markerStyle:"triangleDown"}}},grayscalePalette={name:"grayscale",description:"Four grays with maximum luminance separation, for readers who distinguish styles by lightness alone.",styles:{1:{lineColor:"#000000",markerColor:"#000000",fillColor:"#000000",highContrastColor:"#000000",lineColorDarkMode:"#ffffff",markerColorDarkMode:"#ffffff",fillColorDarkMode:"#ffffff",highContrastColorDarkMode:"#ffffff",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#323232",markerColor:"#323232",fillColor:"#323232",textColor:"#323232",highContrastColor:"#323232",lineColorWord:"dark gray",markerColorWord:"dark gray",fillColorWord:"dark gray",textColorWord:"dark gray",highContrastColorWord:"dark gray",lineColorDarkMode:"#c7c7c7",markerColorDarkMode:"#c7c7c7",fillColorDarkMode:"#c7c7c7",textColorDarkMode:"#c7c7c7",highContrastColorDarkMode:"#c7c7c7",lineColorWordDarkMode:"light gray",markerColorWordDarkMode:"light gray",fillColorWordDarkMode:"light gray",textColorWordDarkMode:"light gray",highContrastColorWordDarkMode:"light gray",lineWidth:2,markerStyle:"square"},3:{lineColor:"#616161",markerColor:"#616161",fillColor:"#616161",textColor:"#616161",highContrastColor:"#616161",lineColorDarkMode:"#929292",markerColorDarkMode:"#929292",fillColorDarkMode:"#929292",textColorDarkMode:"#929292",highContrastColorDarkMode:"#929292",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#939393",markerColor:"#939393",fillColor:"#939393",textColor:"#767676",highContrastColor:"#767676",lineColorWord:"light gray",markerColorWord:"light gray",fillColorWord:"light gray",textColorWord:"light gray",highContrastColorWord:"light gray",lineColorDarkMode:"#626262",markerColorDarkMode:"#626262",fillColorDarkMode:"#626262",textColorDarkMode:"#7d7d7d",highContrastColorDarkMode:"#7d7d7d",lineColorWordDarkMode:"dark gray",markerColorWordDarkMode:"dark gray",fillColorWordDarkMode:"dark gray",textColorWordDarkMode:"dark gray",highContrastColorWordDarkMode:"dark gray",lineWidth:2,markerStyle:"diamond"}}},categoricalPalette={name:"categorical",description:"Ten maximally varied hues adapted from the Category10 sequence, for documents needing many obviously distinct styles.",styles:{1:{lineColor:"#1f77b4",markerColor:"#1f77b4",fillColor:"#1f77b4",highContrastColor:"#1f77b4",lineColorDarkMode:"#5ba3dd",markerColorDarkMode:"#5ba3dd",fillColorDarkMode:"#5ba3dd",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#e7730c",markerColor:"#e7730c",fillColor:"#e7730c",textColor:"#b95b07",highContrastColor:"#b95b07",lineColorDarkMode:"#ff9d3c",markerColorDarkMode:"#ff9d3c",fillColorDarkMode:"#ff9d3c",textColorDarkMode:"#ff9d3c",lineWidth:2,markerStyle:"square"},3:{lineColor:"#217a21",markerColor:"#217a21",fillColor:"#217a21",textColor:"#217a21",highContrastColor:"#217a21",lineColorDarkMode:"#2ca02c",markerColorDarkMode:"#2ca02c",fillColorDarkMode:"#2ca02c",textColorDarkMode:"#2ca02c",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#d62728",markerColor:"#d62728",fillColor:"#d62728",textColor:"#d62728",highContrastColor:"#d62728",lineColorDarkMode:"#e2494a",markerColorDarkMode:"#e2494a",fillColorDarkMode:"#e2494a",textColorDarkMode:"#e2494a",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#9467bd",markerColor:"#9467bd",fillColor:"#9467bd",textColor:"#8e62b5",highContrastColor:"#8e62b5",lineColorDarkMode:"#b48fd6",markerColorDarkMode:"#b48fd6",fillColorDarkMode:"#b48fd6",textColorDarkMode:"#b48fd6",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#7a4a41",markerColor:"#7a4a41",fillColor:"#7a4a41",textColor:"#7a4a41",highContrastColor:"#7a4a41",lineColorDarkMode:"#a9705f",markerColorDarkMode:"#a9705f",fillColorDarkMode:"#a9705f",textColorDarkMode:"#a9705f",lineColorWordDarkMode:"brown",markerColorWordDarkMode:"brown",fillColorWordDarkMode:"brown",textColorWordDarkMode:"brown",highContrastColorWordDarkMode:"brown",lineWidth:2,markerStyle:"triangleLeft"},7:{lineColor:"#d670b7",markerColor:"#d670b7",fillColor:"#d670b7",textColor:"#ab5892",highContrastColor:"#ab5892",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#e377c2",markerColorDarkMode:"#e377c2",fillColorDarkMode:"#e377c2",textColorDarkMode:"#e377c2",lineWidth:3,lineStyle:"dashed",markerStyle:"triangleRight"},8:{lineColor:"#7f7f7f",markerColor:"#7f7f7f",fillColor:"#7f7f7f",textColor:"#757575",highContrastColor:"#757575",lineColorDarkMode:"#a8a8a8",markerColorDarkMode:"#a8a8a8",fillColorDarkMode:"#a8a8a8",textColorDarkMode:"#a8a8a8",lineWidth:1,lineStyle:"dotted",markerStyle:"circle"},9:{lineColor:"#6e6e12",markerColor:"#6e6e12",fillColor:"#6e6e12",textColor:"#6e6e12",highContrastColor:"#6e6e12",lineColorWord:"olive",markerColorWord:"olive",fillColorWord:"olive",textColorWord:"olive",highContrastColorWord:"olive",lineColorDarkMode:"#bcbd22",markerColorDarkMode:"#bcbd22",fillColorDarkMode:"#bcbd22",textColorDarkMode:"#bcbd22",lineColorWordDarkMode:"olive",markerColorWordDarkMode:"olive",fillColorWordDarkMode:"olive",textColorWordDarkMode:"olive",highContrastColorWordDarkMode:"olive",lineWidth:2,lineStyle:"dashed",markerStyle:"square"},10:{lineColor:"#12a2b1",markerColor:"#12a2b1",fillColor:"#12a2b1",textColor:"#0c818e",highContrastColor:"#0c818e",textColorWord:"cyan",highContrastColorWord:"cyan",lineColorDarkMode:"#17becf",markerColorDarkMode:"#17becf",fillColorDarkMode:"#17becf",textColorDarkMode:"#17becf",lineWidth:2,lineStyle:"dotted",markerStyle:"diamond"}}},grumpyNarwhalPalette={name:"grumpyNarwhal",description:"Six saturated hues — burnt orange, forest green, deep pink, arctic teal, gold, and purple — going neon in dark mode.",styles:{1:{lineColor:"#b34700",markerColor:"#b34700",fillColor:"#b34700",highContrastColor:"#b34700",lineColorDarkMode:"#ff5f00",markerColorDarkMode:"#ff5f00",fillColorDarkMode:"#ff5f00",lineColorWordDarkMode:"orange",markerColorWordDarkMode:"orange",fillColorWordDarkMode:"orange",lineWidth:4,markerStyle:"circle"},2:{lineColor:"#1b7a1b",markerColor:"#1b7a1b",fillColor:"#1b7a1b",textColor:"#1b7a1b",highContrastColor:"#1b7a1b",lineColorDarkMode:"#39ff14",markerColorDarkMode:"#39ff14",fillColorDarkMode:"#39ff14",textColorDarkMode:"#39ff14",lineWidth:2,markerStyle:"square"},3:{lineColor:"#c20e67",markerColor:"#c20e67",fillColor:"#c20e67",textColor:"#c20e67",highContrastColor:"#c20e67",lineColorWord:"pink",markerColorWord:"pink",fillColorWord:"pink",textColorWord:"pink",highContrastColorWord:"pink",lineColorDarkMode:"#ff1493",markerColorDarkMode:"#ff1493",fillColorDarkMode:"#ff1493",textColorDarkMode:"#ff1493",lineWidth:3,markerStyle:"triangle"},4:{lineColor:"#007a8c",markerColor:"#007a8c",fillColor:"#007a8c",textColor:"#007a8c",highContrastColor:"#007a8c",lineColorWord:"teal",markerColorWord:"teal",fillColorWord:"teal",textColorWord:"teal",highContrastColorWord:"teal",lineColorDarkMode:"#00e5ff",markerColorDarkMode:"#00e5ff",fillColorDarkMode:"#00e5ff",textColorDarkMode:"#00e5ff",lineWidth:2,markerStyle:"diamond"},5:{lineColor:"#8a6d00",markerColor:"#8a6d00",fillColor:"#8a6d00",textColor:"#8a6d00",highContrastColor:"#8a6d00",lineColorWord:"gold",markerColorWord:"gold",fillColorWord:"gold",textColorWord:"gold",highContrastColorWord:"gold",lineColorDarkMode:"#ffea00",markerColorDarkMode:"#ffea00",fillColorDarkMode:"#ffea00",textColorDarkMode:"#ffea00",lineWidth:2,markerStyle:"triangleDown"},6:{lineColor:"#b026ff",markerColor:"#b026ff",fillColor:"#b026ff",textColor:"#b026ff",highContrastColor:"#b026ff",lineColorDarkMode:"#b026ff",markerColorDarkMode:"#b026ff",fillColorDarkMode:"#b026ff",textColorDarkMode:"#b445ff",highContrastColorDarkMode:"#b445ff",lineWidth:2,markerStyle:"triangleLeft"}}};function deepFreezePalette(nA){for(const eA of Object.values(nA.styles)){for(const AA of Object.values(eA))typeof AA=="object"&&AA!==null&&Object.freeze(AA);Object.freeze(eA)}return Object.freeze(nA.styles),Object.freeze(nA)}function registerByKey(nA){return[nA.name.toLowerCase(),deepFreezePalette(nA)]}const STYLE_PALETTES=Object.assign(Object.create(null),Object.fromEntries([defaultPalette,okabeItoPalette,tolBrightPalette,tolMutedPalette,tolHighContrastPalette,ibmPalette,grayscalePalette,categoricalPalette,grumpyNarwhalPalette].map(registerByKey)));Object.freeze(STYLE_PALETTES),defaultPalette.name.toLowerCase(),Object.freeze(Object.keys(STYLE_PALETTES));var o=function(nA){var eA=nA/255;return eA<.04045?eA/12.92:Math.pow((eA+.055)/1.055,2.4)},t=function(nA){return .2126*o(nA.r)+.7152*o(nA.g)+.0722*o(nA.b)};function a11yPlugin(nA){nA.prototype.luminance=function(){return eA=t(this.rgba),(AA=2)===void 0&&(AA=0),tA===void 0&&(tA=Math.pow(10,AA)),Math.round(tA*eA)/tA+0;var eA,AA,tA},nA.prototype.contrast=function(eA){eA===void 0&&(eA="#FFF");var AA,tA,iA,rA,aA,oA,sA,lA=eA instanceof nA?eA:new nA(eA);return rA=this.rgba,aA=lA.toRgb(),oA=t(rA),sA=t(aA),AA=oA>sA?(oA+.05)/(sA+.05):(sA+.05)/(oA+.05),(tA=2)===void 0&&(tA=0),iA===void 0&&(iA=Math.pow(10,tA)),Math.floor(iA*AA)/iA+0},nA.prototype.isReadable=function(eA,AA){return eA===void 0&&(eA="#FFF"),AA===void 0&&(AA={}),this.contrast(eA)>=(oA=(aA=(tA=AA).size)===void 0?"normal":aA,(rA=(iA=tA.level)===void 0?"AA":iA)==="AAA"&&oA==="normal"?7:rA==="AA"&&oA==="large"?3:4.5);var tA,iA,rA,aA,oA}}function namesPlugin(nA,eA){var AA={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},tA={};for(var iA in AA)tA[AA[iA]]=iA;var rA={};nA.prototype.toName=function(aA){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var oA,sA,lA=tA[this.toHex()];if(lA)return lA;if(aA?.closest){var gA=this.toRgb(),cA=1/0,IA="black";if(!rA.length)for(var uA in AA)rA[uA]=new nA(AA[uA]).toRgb();for(var CA in AA){var dA=(oA=gA,sA=rA[CA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));dA<cA&&(cA=dA,IA=CA)}return IA}},eA.string.push([function(aA){var oA=aA.toLowerCase(),sA=oA==="transparent"?"#0000":AA[oA];return sA?new nA(sA).toRgb():null},"name"])}k([a11yPlugin,namesPlugin]);let styleAttributes={lineColor:{componentType:"text",description:"Color used for line strokes (light mode)."},lineColorWord:{componentType:"text",description:"Human-readable name of the line color (light mode)."},lineColorDarkMode:{componentType:"text",description:"Color used for line strokes (dark mode)."},lineColorWordDarkMode:{componentType:"text",description:"Human-readable name of the line color (dark mode)."},lineOpacity:{componentType:"number",description:"Opacity of line strokes, 0 to 1."},lineWidth:{componentType:"number",description:"Stroke width for lines, in pixels."},lineWidthWord:{componentType:"text",description:"Human-readable name of the line width."},lineStyle:{componentType:"text",description:"Stroke style for lines.",toLowerCase:!0,validValues:[{value:"solid",description:"Continuous, unbroken stroke."},{value:"dashed",description:"Stroke composed of evenly-spaced dashes."},{value:"dotted",description:"Stroke composed of evenly-spaced dots."}]},lineStyleWord:{componentType:"text",description:"Human-readable name of the line style."},markerColor:{componentType:"text",description:"Color used for markers/points (light mode)."},markerColorWord:{componentType:"text",description:"Human-readable name of the marker color (light mode)."},markerColorDarkMode:{componentType:"text",description:"Color used for markers/points (dark mode)."},markerColorWordDarkMode:{componentType:"text",description:"Human-readable name of the marker color (dark mode)."},markerOpacity:{componentType:"number",description:"Opacity of markers/points, 0 to 1."},markerStyle:{componentType:"text",description:"Marker shape.",toLowerCase:!0,validValues:[{value:"circle",description:"Circular marker."},{value:"square",description:"Square marker."},{value:"triangle",description:'Triangular marker pointing up (alias for "triangleUp").'},{value:"triangleUp",description:"Triangular marker pointing up."},{value:"triangleDown",description:"Triangular marker pointing down."},{value:"triangleLeft",description:"Triangular marker pointing left."},{value:"triangleRight",description:"Triangular marker pointing right."},{value:"diamond",description:"Diamond-shaped marker."},{value:"cross",description:"Cross-shaped marker (×)."},{value:"plus",description:"Plus-shaped marker (+)."}]},markerStyleWord:{componentType:"text",description:"Human-readable name of the marker style."},markerSize:{componentType:"number",description:"Marker size in pixels."},markerFilled:{componentType:"boolean",description:"Whether the marker is rendered filled (true) or open (false). Has no effect when markerStyle is cross or plus, which have no interior."},fillColor:{componentType:"text",description:"Fill color used inside closed shapes (light mode)."},fillColorWord:{componentType:"text",description:"Human-readable name of the fill color (light mode)."},fillColorDarkMode:{componentType:"text",description:"Fill color used inside closed shapes (dark mode)."},fillColorWordDarkMode:{componentType:"text",description:"Human-readable name of the fill color (dark mode)."},fillOpacity:{componentType:"number",description:"Opacity of solid fills, 0 to 1."},fillPatternOpacity:{componentType:"number",description:"Opacity of pattern fills (non-solid fillStyle), 0 to 1."},fillStyle:{componentType:"text",description:"Fill pattern used inside closed shapes.",toLowerCase:!0,validValues:[{value:"solid",description:"Solid fill."},{value:"horizontal",description:"Horizontal line pattern."},{value:"vertical",description:"Vertical line pattern."},{value:"diagonal",description:"Diagonal line pattern (/)."},{value:"backDiagonal",description:"Back-diagonal line pattern (\\)."},{value:"dots",description:"Dots pattern."},{value:"diamonds",description:"Filled diamonds pattern."}]},fillStyleWord:{componentType:"text",description:"Human-readable name of the fill style."},textColor:{componentType:"text",description:"Text color (light mode)."},textColorWord:{componentType:"text",description:"Human-readable name of the text color (light mode)."},textColorDarkMode:{componentType:"text",description:"Text color (dark mode)."},textColorWordDarkMode:{componentType:"text",description:"Human-readable name of the text color (dark mode)."},highContrastColor:{componentType:"text",description:"High-contrast accent color (light mode)."},highContrastColorWord:{componentType:"text",description:"Human-readable name of the high-contrast accent color (light mode)."},highContrastColorDarkMode:{componentType:"text",description:"High-contrast accent color (dark mode)."},highContrastColorWordDarkMode:{componentType:"text",description:"Human-readable name of the high-contrast accent color (dark mode)."},backgroundColor:{componentType:"text",description:"Background color (light mode)."},backgroundColorWord:{componentType:"text",description:"Human-readable name of the background color (light mode)."},backgroundColorDarkMode:{componentType:"text",description:"Background color (dark mode)."},backgroundColorWordDarkMode:{componentType:"text",description:"Human-readable name of the background color (dark mode)."}};styleAttributes.markerStyle.validValues.filter(nA=>nA.value!=="cross"&&nA.value!=="plus");const MARKER_OVERRIDE_KEYS=["markerStyle","markerSize","markerFilled"],LINE_OVERRIDE_KEYS=["lineStyle","lineWidth"],FILL_OVERRIDE_KEYS=["fillOpacity","fillPatternOpacity","fillStyle"],markerOverrideAttributes=Object.fromEntries(MARKER_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]])),lineOverrideAttributes=Object.fromEntries(LINE_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]])),fillOverrideAttributes=Object.fromEntries(FILL_OVERRIDE_KEYS.map(nA=>[nA,styleAttributes[nA]]));({...markerOverrideAttributes,...lineOverrideAttributes,...fillOverrideAttributes});const STYLE_OVERRIDE_CATEGORIES={marker:markerOverrideAttributes,line:lineOverrideAttributes,fill:fillOverrideAttributes};for(const[nA,eA]of Object.entries(STYLE_OVERRIDE_CATEGORIES))for(const[AA,tA]of Object.entries(eA)){if(AA.toLowerCase().includes("color"))throw new Error(`Style override category "${nA}" contains color-related key "${AA}"; colors stay <styleDefinition>-only so per-styleNumber WCAG contrast diagnostics remain authoritative. If this is intentional, also reconcile the lowercase asymmetry in returnSelectedStyleStateVariableDefinition.`);if(AA.endsWith("Opacity")&&AA!=="fillOpacity"&&AA!=="fillPatternOpacity")throw new Error(`Style override category "${nA}" contains contrast-feeding opacity key "${AA}"; lineOpacity and markerOpacity feed the WCAG contrast diagnostic as an opacityMultiplier on the foreground alpha, so they stay <styleDefinition>-only alongside colors. Only fillOpacity and fillPatternOpacity are contrast-irrelevant and overridable.`);if(tA.componentType==="text"&&!tA.toLowerCase)throw new Error(`Style override key "${AA}" in category "${nA}" is text-typed but missing toLowerCase: true. Add toLowerCase: true to its styleAttributes entry, or move it out of the override surface.`)}Object.entries(styleAttributes).filter(([,nA])=>nA.toLowerCase).map(([nA])=>nA);var base32$1={exports:{}},hasRequiredBase32;function requireBase32(){return hasRequiredBase32||(hasRequiredBase32=1,(function(nA){(function(){var eA=typeof window=="object"?window:{},AA=!eA.HI_BASE32_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;AA&&(eA=commonjsGlobal);var tA=!eA.HI_BASE32_NO_COMMON_JS&&!0&&nA.exports,iA="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),rA={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},aA=[0,0,0,0,0,0,0,0],oA=function(pA,mA){mA.length>10&&(mA="..."+mA.substr(-10));var QA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw QA.position=pA,QA},sA=function(pA){for(var mA="",QA=pA.length,BA=0,hA=0,DA,EA;BA<QA;){if(DA=pA[BA++],DA<=127){mA+=String.fromCharCode(DA);continue}else DA>191&&DA<=223?(EA=DA&31,hA=1):DA<=239?(EA=DA&15,hA=2):DA<=247?(EA=DA&7,hA=3):oA(BA,mA);for(var fA=0;fA<hA;++fA)DA=pA[BA++],(DA<128||DA>191)&&oA(BA,mA),EA<<=6,EA+=DA&63;EA>=55296&&EA<=57343&&oA(BA,mA),EA>1114111&&oA(BA,mA),EA<=65535?mA+=String.fromCharCode(EA):(EA-=65536,mA+=String.fromCharCode((EA>>10)+55296),mA+=String.fromCharCode((EA&1023)+56320))}return mA},lA=function(pA){if(pA==="")return[];if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");pA=pA.replace(/=/g,"");for(var mA,QA,BA,hA,DA,EA,fA,NA,yA=[],bA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255,yA[bA++]=(fA<<5|NA)&255;var kA=wA-vA;return kA===2?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255):kA===4?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255):kA===5?(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255):kA===7&&(mA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA[bA++]=(mA<<3|QA>>>2)&255,yA[bA++]=(QA<<6|BA<<1|hA>>>4)&255,yA[bA++]=(hA<<4|DA>>>1)&255,yA[bA++]=(DA<<7|EA<<2|fA>>>3)&255),yA},gA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA++),DA=pA.charCodeAt(NA++),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31];var bA=fA-yA;return bA===1?(mA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):bA===2?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):bA===4&&(mA=pA.charCodeAt(NA++),QA=pA.charCodeAt(NA++),BA=pA.charCodeAt(NA++),hA=pA.charCodeAt(NA),EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"="),EA},cA=function(pA){var mA,QA,BA,hA,DA,EA,fA=!1,NA="",yA=0,bA,wA=0,MA=pA.length;if(pA==="")return NA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],bA=wA;yA<MA&&bA<5;++yA)EA=pA.charCodeAt(yA),EA<128?aA[bA++]=EA:EA<2048?(aA[bA++]=192|EA>>6,aA[bA++]=128|EA&63):EA<55296||EA>=57344?(aA[bA++]=224|EA>>12,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63):(EA=65536+((EA&1023)<<10|pA.charCodeAt(++yA)&1023),aA[bA++]=240|EA>>18,aA[bA++]=128|EA>>12&63,aA[bA++]=128|EA>>6&63,aA[bA++]=128|EA&63);wA=bA-5,yA===MA&&++yA,yA>MA&&bA<6&&(fA=!0),mA=aA[0],bA>4?(QA=aA[1],BA=aA[2],hA=aA[3],DA=aA[4],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31]):bA===1?NA+=iA[mA>>>3]+iA[mA<<2&31]+"======":bA===2?(QA=aA[1],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(QA=aA[1],BA=aA[2],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):(QA=aA[1],BA=aA[2],hA=aA[3],NA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"=")}while(!fA);return NA},IA=function(pA){for(var mA,QA,BA,hA,DA,EA="",fA=pA.length,NA=0,yA=parseInt(fA/5)*5;NA<yA;)mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA++],DA=pA[NA++],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[(hA<<3|DA>>>5)&31]+iA[DA&31];var bA=fA-yA;return bA===1?(mA=pA[NA],EA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):bA===2?(mA=pA[NA++],QA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[QA<<4&31]+"===="):bA===3?(mA=pA[NA++],QA=pA[NA++],BA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):bA===4&&(mA=pA[NA++],QA=pA[NA++],BA=pA[NA++],hA=pA[NA],EA+=iA[mA>>>3]+iA[(mA<<2|QA>>>6)&31]+iA[QA>>>1&31]+iA[(QA<<4|BA>>>4)&31]+iA[(BA<<1|hA>>>7)&31]+iA[hA>>>2&31]+iA[hA<<3&31]+"="),EA},uA=function(pA,mA){var QA=typeof pA!="string";return QA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),QA?IA(pA):mA?gA(pA):cA(pA)},CA=function(pA,mA){if(!mA)return sA(lA(pA));if(pA==="")return"";if(!/^[A-Z2-7=]+$/.test(pA))throw new Error("Invalid base32 characters");var QA,BA,hA,DA,EA,fA,NA,yA,bA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)+String.fromCharCode((NA<<5|yA)&255);var kA=wA-vA;return kA===2?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)):kA===4?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)):kA===5?(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)):kA===7&&(QA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA=rA[pA.charAt(MA++)],bA+=String.fromCharCode((QA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|hA<<1|DA>>>4)&255)+String.fromCharCode((DA<<4|EA>>>1)&255)+String.fromCharCode((EA<<7|fA<<2|NA>>>3)&255)),bA},dA={encode:uA,decode:CA};CA.asBytes=lA,tA?nA.exports=dA:eA.base32=dA})()})(base32$1)),base32$1.exports}requireBase32();function groupCompositeRanges({children:nA,ranges:eA,isAbsent:AA=()=>!1,isBlank:tA=()=>!1,skipRange:iA=()=>!1,trimEnd:rA=lA=>lA,startInd:aA=0,endInd:oA=nA.length-1,removedInd:sA=null}){const lA=(eA??[]).flatMap(CA=>{const dA=shiftForRemovedChild(CA,sA);return dA&&dA.firstInd>=aA&&dA.lastInd<=oA?[{range:CA,...dA}]:[]}).sort((CA,dA)=>CA.firstInd-dA.firstInd||dA.lastInd-CA.lastInd),gA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},cA=[gA];function IA(CA,dA){for(;CA.nextInd<dA;CA.nextInd++){const pA=nA[CA.nextInd];AA(pA)||(CA.items.push({kind:"child",value:pA,index:CA.nextInd}),CA.eligibility&&CA.eligible.push(CA.eligibility[CA.nextInd-CA.firstInd]??!1))}}function uA(){const CA=cA.pop();if(IA(CA,CA.lastInd+1),CA.items.length===0)return;const dA=cA[cA.length-1],pA=CA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=CA.eligible.every((BA,hA)=>BA||isBlankGroup(CA.items[hA],tA)),QA=!!CA.range.asList&&mA&&pA.length>1;dA.items.push({kind:"composite",range:CA.range,asList:QA,items:QA?prepareListItems(CA.items,tA,rA):CA.items}),dA.eligibility&&dA.eligible.push(mA)}for(const{range:CA,firstInd:dA,lastInd:pA}of lA){for(;cA.length>1&&pA>cA[cA.length-1].lastInd;)uA();const mA=cA[cA.length-1];dA<mA.nextInd||(IA(mA,dA),mA.nextInd=pA+1,!iA(CA)&&cA.push({range:CA,firstInd:dA,lastInd:pA,nextInd:dA,eligibility:CA.potentialListComponents??null,items:[],eligible:[]}))}for(;cA.length>1;)uA();return IA(gA,oA+1),gA.items}function shiftForRemovedChild(nA,eA){let{firstInd:AA,lastInd:tA}=nA;if(eA===null)return{firstInd:AA,lastInd:tA};if(!(AA===eA||tA===eA))return AA>eA&&(AA-=1),tA>eA&&(tA-=1),{firstInd:AA,lastInd:tA}}function isBlankGroup(nA,eA){return nA.kind==="child"?eA(nA.value):nA.items.every(AA=>isBlankGroup(AA,eA))}function prepareListItems(nA,eA,AA){const tA=nA.findIndex(aA=>!isBlankGroup(aA,eA));let iA=nA.length-1;for(;iA>tA&&isBlankGroup(nA[iA],eA);)iA--;const rA=[];for(const[aA,oA]of nA.entries())aA<tA||aA>=iA?rA.push(oA):isBlankGroup(oA,eA)?oA.kind==="composite"&&rA.push(withoutBlankChildren(oA)):rA.push(trimItemEnd(oA,eA,AA));return rA}function withoutBlankChildren(nA){return{...nA,items:nA.items.flatMap(eA=>eA.kind==="composite"?[withoutBlankChildren(eA)]:[])}}function trimItemEnd(nA,eA,AA){if(nA.kind==="child"){const rA=AA(nA.value);return rA===nA.value?nA:{...nA,value:rA}}let tA=nA.items.length;for(;isBlankGroup(nA.items[tA-1],eA);)tA--;const iA=nA.items.slice(tA).flatMap(rA=>rA.kind==="composite"?[withoutBlankChildren(rA)]:[]);return{...nA,items:[...nA.items.slice(0,tA-1),trimItemEnd(nA.items[tA-1],eA,AA),...iA]}}const{gcd,lcm}=context.math,{mod}=context.math,defaultCreativeCommonsVersion="4.0";function creativeCommonsLicense(nA,eA,AA,tA){return{code:nA,name:`Creative Commons ${eA}`,description:tA,kind:"creative-commons",url:(iA=defaultCreativeCommonsVersion)=>`https://creativecommons.org/licenses/${AA}/${iA}/`}}function fixedUrlLicense(nA,eA,AA,tA,iA){return{code:nA,name:eA,description:tA,kind:iA,url:()=>AA}}const mediaLicenses=[creativeCommonsLicense("CC-BY","Attribution","by","Creative Commons Attribution: reuse with credit, including commercially."),creativeCommonsLicense("CC-BY-SA","Attribution-ShareAlike","by-sa","Creative Commons Attribution-ShareAlike: reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-ND","Attribution-NoDerivatives","by-nd","Creative Commons Attribution-NoDerivatives: reuse unchanged, with credit."),creativeCommonsLicense("CC-BY-NC","Attribution-NonCommercial","by-nc","Creative Commons Attribution-NonCommercial: reuse with credit for noncommercial purposes."),creativeCommonsLicense("CC-BY-NC-SA","Attribution-NonCommercial-ShareAlike","by-nc-sa","Creative Commons Attribution-NonCommercial-ShareAlike: noncommercial reuse with credit; adaptations keep the same license."),creativeCommonsLicense("CC-BY-NC-ND","Attribution-NonCommercial-NoDerivatives","by-nc-nd","Creative Commons Attribution-NonCommercial-NoDerivatives: reuse unchanged for noncommercial purposes, with credit."),fixedUrlLicense("CC0","CC0 1.0 Public Domain Dedication","https://creativecommons.org/publicdomain/zero/1.0/","Creative Commons Zero: the creator has dedicated the work to the public domain.","public-domain"),fixedUrlLicense("PDM","Public Domain Mark 1.0","https://creativecommons.org/publicdomain/mark/1.0/","Public Domain Mark: the work is free of known copyright restrictions.","public-domain"),fixedUrlLicense("GFDL","GNU Free Documentation License","https://www.gnu.org/licenses/fdl-1.3.html","GNU Free Documentation License: copyleft license common on Wikimedia.","license"),fixedUrlLicense("FAL","Free Art License 1.3","https://artlibre.org/licence/lal/en/","Free Art License: copyleft license for artistic works.","license"),fixedUrlLicense("OGL","Open Government Licence v3.0 (UK)","https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/","UK Open Government Licence: reuse government material with attribution.","license"),fixedUrlLicense("MIT","MIT License","https://opensource.org/license/mit","MIT License: permissive license common for icon and illustration sets.","license"),fixedUrlLicense("APACHE-2.0","Apache License 2.0","https://www.apache.org/licenses/LICENSE-2.0","Apache License 2.0: permissive license common for icon and illustration sets.","license")];Object.fromEntries(mediaLicenses.map(nA=>[nA.code.toLowerCase(),nA]));var cssesc_1,hasRequiredCssesc;function requireCssesc(){if(hasRequiredCssesc)return cssesc_1;hasRequiredCssesc=1;var nA={},eA=nA.hasOwnProperty,AA=function(sA,lA){if(!sA)return lA;var gA={};for(var cA in lA)gA[cA]=eA.call(sA,cA)?sA[cA]:lA[cA];return gA},tA=/[ -,\.\/:-@\[-\^`\{-~]/,iA=/[ -,\.\/:-@\[\]\^`\{-~]/,rA=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,aA=function oA(sA,lA){lA=AA(lA,oA.options),lA.quotes!="single"&&lA.quotes!="double"&&(lA.quotes="single");for(var gA=lA.quotes=="double"?'"':"'",cA=lA.isIdentifier,IA=sA.charAt(0),uA="",CA=0,dA=sA.length;CA<dA;){var pA=sA.charAt(CA++),mA=pA.charCodeAt(),QA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&CA<dA){var BA=sA.charCodeAt(CA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:CA--}QA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?QA="\\"+pA:QA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?QA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!cA&&(pA=='"'&&gA==pA||pA=="'"&&gA==pA)||cA&&iA.test(pA)?QA="\\"+pA:QA=pA;uA+=QA}return cA&&(/^-[-\d]/.test(uA)?uA="\\-"+uA.slice(1):/\d/.test(IA)&&(uA="\\3"+IA+" "+uA.slice(1))),uA=uA.replace(rA,function(hA,DA,EA){return DA&&DA.length%2?hA:(DA||"")+EA}),!cA&&lA.wrap?gA+uA+gA:uA};return aA.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},aA.version="3.0.0",cssesc_1=aA,cssesc_1}requireCssesc();function isBlankChild(nA){return typeof nA=="string"&&nA.trim()===""}function makeWrapperElement(nA,eA,AA){return{type:"element",name:eA,attributes:{},children:AA,data:{id:nA}}}function materializeGroups(nA,eA,AA){const tA=[];for(const iA of nA){if(iA.kind==="child"){iA.value!==null&&tA.push(iA.value);continue}if(iA.asList){const aA=iA.items.map(gA=>isBlankGroup(gA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=iA.items.slice(oA,sA+1).filter((gA,cA)=>!aA[oA+cA]);eA||tA.push(...materializeGroups(iA.items.slice(0,oA),!1,AA)),AA.push(makeWrapperElement(iA.range.compositeIdx,"asList",materializeGroups(lA,!0,AA))),tA.push({id:iA.range.compositeIdx,annotation:"original"}),eA||tA.push(...materializeGroups(iA.items.slice(sA+1),!1,AA));continue}const rA=materializeGroups(iA.items,!1,AA);eA&&rA.length>1?(AA.push(makeWrapperElement(iA.range.compositeIdx,"_fragment",rA)),tA.push({id:iA.range.compositeIdx,annotation:"original"})):tA.push(...rA)}return tA}function applyCompositeListWrapping(nA,eA){const AA=groupCompositeRanges({children:nA,ranges:eA,isAbsent:rA=>rA===null,isBlank:isBlankChild,trimEnd:rA=>typeof rA=="string"?rA.trimEnd():rA}),tA=[];return{children:materializeGroups(AA,!1,tA),wrapperElements:tA}}function propRename(nA,eA){for(const[AA,tA]of Object.entries(eA))nA.hasOwnProperty(AA)&&(nA[tA]=nA[AA],delete nA[AA])}function elementRename(nA,eA){nA.name=eA}function booleanInputJsToRust(nA){nA.immediateValue=nA.value}function pointJsToRust(nA){const eA=nA.numericalXs;nA.x={math_object:eA[0].toString()},eA.length>=2&&(nA.y={math_object:eA[1].toString()}),eA.length>=3&&(nA.z={math_object:eA[2].toString()}),nA.coordsLatex=nA.latex}function refJsToRust(nA,eA){nA.referent=eA[nA.targetRendererId]}function sectionJsToRust(nA,eA){nA.divisionType=eA.name,nA.divisionDepth=nA.level;const AA=nA.titleChildName!=null?Number(nA.titleChildName):void 0,tA=AA!==void 0&&Number.isInteger(AA);if(nA.xrefLabel={label:(tA?nA.titlePrefix:nA.title)??"",global_ident:nA.sectionNumber??"",local_ident:nA.sectionNumber??"",preferred_form:"Global"},nA.codeNumber="",tA){nA.title=AA;const iA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);iA!==-1&&eA.children.splice(iA,1)}else nA.title=null}function tableJsToRust(nA,eA){nA.xrefLabel={label:nA.tableName??"",global_ident:nA.tableEnumeration??"",local_ident:nA.tableEnumeration??"",preferred_form:"Global"},nA.codeNumber=nA.tableEnumeration??"",nA.titlePrefix=nA.suppressTableNameInTitle?"":nA.tableNamePrefix??"",nA.divisionType="table",nA.divisionDepth=3;const AA=nA.titleChildName!=null?Number(nA.titleChildName):void 0;if(AA!==void 0&&Number.isInteger(AA)){nA.title=AA;const iA=eA.children.findIndex(rA=>typeof rA!="string"&&rA.id===AA);iA!==-1&&eA.children.splice(iA,1)}else nA.title=null;delete nA.tableEnumeration,delete nA.titleChildName,delete nA.tableName,delete nA.tableNamePrefix}function textJsToRust(nA){nA.value=nA.text}function childInstructionToContent(nA,eA){return typeof nA=="string"?nA:(eA[nA.id]=nA.componentIdx,{id:nA.componentIdx,annotation:"original"})}function applyElementJsToRustFixups(nA,eA){if(!(nA?.type!=="element"||!nA.data.props))switch(nA.name){case"angle":propRename(nA.data.props,{latexForRenderer:"latex"});break;case"cell":propRename(nA.data.props,{inHeader:"header"});break;case"booleanInput":booleanInputJsToRust(nA.data.props);break;case"text":textJsToRust(nA.data.props);break;case"aside":case"article":case"section":sectionJsToRust(nA.data.props,nA),nA.name==="section"&&elementRename(nA,"division");break;case"table":tableJsToRust(nA.data.props,nA);break;case"point":pointJsToRust(nA.data.props);break;case"ref":refJsToRust(nA.data.props,eA);break;case"coords":elementRename(nA,"math");break}}function flatDastFromJS(nA,eA){const AA=eA[0].rendererStatesToUpdate,tA=[],iA={[nA.id]:nA.componentIdx};tA[nA.componentIdx]={type:"element",name:nA.componentType,attributes:{},children:[],data:{id:nA.componentIdx,action_names:Object.keys(nA.actions)}};for(const aA of AA){let oA=tA[aA.componentIdx];if(oA||(oA=tA[aA.componentIdx]={type:"element",name:"",attributes:{},children:[],data:{id:aA.componentIdx}}),oA.type==="element"&&(oA.data.props=aA.stateValues,aA.childrenInstructions)){const sA=[];for(const cA of aA.childrenInstructions){if(cA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(cA,iA)),typeof cA=="string")continue;const IA=tA[cA.componentIdx];IA?IA.type==="element"&&(IA.name=cA.componentType,IA.data.id=cA.componentIdx,IA.data.action_names=Object.keys(cA.actions)):tA[cA.componentIdx]={type:"element",name:cA.componentType,attributes:{},children:[],data:{id:cA.componentIdx,action_names:Object.keys(cA.actions)}}}const{children:lA,wrapperElements:gA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const cA of gA)tA[cA.data.id]=cA}}for(const aA of tA)applyElementJsToRustFixups(aA,iA);return{type:"root",children:[{id:nA.componentIdx,annotation:"original"}],elements:tA,warnings:[]}}function collectInstructionMaps(nA,eA={},AA={}){for(const tA of nA)for(const iA of tA.rendererStatesToUpdate)for(const rA of iA.childrenInstructions??[])rA!=null&&typeof rA!="string"&&(eA[rA.componentIdx]=rA.componentType,AA[rA.id]=rA.componentIdx);return{componentIdxToName:eA,doenetIdToComponentIdx:AA}}function seedInstructionMaps(nA,eA){const AA={[nA.componentIdx]:nA.componentType},tA={[nA.id]:nA.componentIdx};return collectInstructionMaps(eA,AA,tA),{componentIdxToName:AA,doenetIdToComponentIdx:tA}}function flatDastUpdateFromJS(nA,eA,AA={}){const tA={};function iA(rA,aA){const oA=tA[rA];oA?(oA.changedState={...oA.changedState,...aA.changedState},aA.newChildren&&(oA.newChildren=aA.newChildren),aA.newFlatDastElement&&(oA.newFlatDastElement=aA.newFlatDastElement)):tA[rA]=aA}for(const rA of nA)for(const aA of rA.rendererStatesToUpdate){const{componentIdx:oA,stateValues:sA,childrenInstructions:lA}=aA,gA=[];if(lA)for(const dA of lA){if(dA==null){gA.push(null);continue}gA.push(childInstructionToContent(dA,AA))}const{children:cA,wrapperElements:IA}=applyCompositeListWrapping(gA,sA?._compositeReplacementActiveRange),uA={type:"element",name:eA[oA]??"",children:cA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(uA,AA);const CA={changedState:uA.data.props};lA&&(CA.newChildren=uA.children),iA(oA,CA);for(const dA of IA)iA(dA.data.id,{newFlatDastElement:dA})}return tA}async function resolvePathImmediatelyToNodeIdx(nA,eA,AA,tA=0){if(!AA.core)return-1;const iA=nA.match(/^([\w-]+)((\[\d+\])*)/);if(!iA)throw Error(`Invalid name to resolve: ${nA}`);const rA=[{type:"flatPathPart",name:iA[1],index:extractIndex(iA[2])}];let aA=nA.slice(iA[0].length);for(;aA.length>0;){const oA=aA.match(/^\.([\w-]+)((\[\d+\])*)/);if(!oA)throw Error(`Invalid name to resolve: ${nA}`);rA.push({type:"flatPathPart",name:oA[1],index:extractIndex(oA[2])}),aA=aA.slice(oA[0].length)}try{let oA=eA.resolve_path({path:rA},tA,!1);for(;oA.unresolvedPath!==null;){if(oA.unresolvedPath[0].name!=="")return-1;const sA=AA.core._components[oA.nodeIdx];if(!AA.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType,includeNonStandard:!0})||sA.isExpanded)return-1;const gA=oA.unresolvedPath[0].index;if(gA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof gA[0].value[0]!="string")throw Error("Not implemented: we have not implemented `resolvePathImmediatelyToNodeIdx` for paths that contain references to nodes.");await sA.stateValues.readyToExpandWhenResolved,await expandCompositeComponent({core:AA.core,component:sA}),oA=eA.resolve_path({path:rA},tA,!1)}return oA.nodeIdx}catch(oA){return console.error(oA),-1}}function extractIndex(nA){const eA=[];for(const AA of nA.matchAll(/\[(\d+)\]/g))eA.push({value:[AA[1]]});return eA}const JS_CORE_ACTION_NAME_OVERRIDES={point:{move:"movePoint"},graph:{changeBoundingBox:"changeAxisLimits"}};function translateJsCoreActionName(nA,eA){return nA==null?eA:JS_CORE_ACTION_NAME_OVERRIDES[nA]?.[eA]??eA}const WASM_FILE_NAME="lib_doenetml_worker_bg.wasm";function injectedGlobal(nA){const eA=globalThis[nA];return typeof eA=="string"?eA:void 0}function decodeWasmDataUrl(nA){try{const eA=nA.split(",")[1],AA=atob(eA),tA=new Uint8Array(AA.length);for(let iA=0;iA<AA.length;iA++)tA[iA]=AA.charCodeAt(iA);return tA.buffer}catch(eA){return console.warn("Error while decoding the WASM data URL:",eA),null}}function wasmUrlCandidates(){const nA=[];function eA(iA){nA.includes(iA)||nA.push(iA)}const AA=injectedGlobal("__doenetWorkerWasmUrl");AA!==void 0&&eA(AA);const tA=[injectedGlobal("__doenetWorkerScriptUrl"),typeof location<"u"?location.href:void 0];for(const iA of tA)if(iA!==void 0)try{eA(new URL(WASM_FILE_NAME,iA).href)}catch{}return eA(`https://cdn.jsdelivr.net/npm/@doenet/standalone@0.7.27-dev.713/doenetml-worker/${WASM_FILE_NAME}`),nA}async function resolveWasmInput(){const nA=injectedGlobal("__doenetWorkerWasmUrl");if(nA!==void 0&&/^data:.*;base64,/.test(nA)){const AA=decodeWasmDataUrl(nA);if(AA)return AA}let eA;for(const AA of wasmUrlCandidates())if(!AA.startsWith("data:"))try{const tA=await fetch(AA);if(!tA.ok)throw Error(`HTTP ${tA.status} fetching ${AA}`);const iA=tA.headers.get("Content-Type")??"";if(/^text\/html\b/i.test(iA))throw Error(`Fetching ${AA} returned ${iA}, an HTML page rather than WebAssembly`);return tA}catch(tA){eA=tA}throw eA??Error("No URL to load the core WASM from")}if(typeof globalThis<"u"&&!globalThis.document){const nA=new URL(typeof location<"u"?location.href:"http://localhost"),eA=nA.protocol+"//"+nA.host+nA.pathname;globalThis.document={URL:eA,baseURI:eA}}let wasmInitPromise=null;function ensureWasmInitialized(){return wasmInitPromise||(wasmInitPromise=(async()=>{const nA=await resolveWasmInput();return await __wbg_init({module_or_path:nA})})().catch(nA=>{throw wasmInitPromise=null,nA})),wasmInitPromise}const RELEASED_INITIALIZATION_DATA_MESSAGE="Cannot initialize from the document DAST: it was released when the previous initialization completed. Call setSource again before re-initializing.",DOCUMENT_BUILD_ERROR_NAME="DoenetDocumentBuildError";function readPanicMessage(){try{return take_last_panic_message()??void 0}catch(nA){console.error(nA);return}}function discardStalePanicMessage(){readPanicMessage()}function throwAsDocumentBuildError(nA,eA){const AA=nA instanceof Error?nA:new Error(String(nA??"unknown error"));throw AA.name=DOCUMENT_BUILD_ERROR_NAME,eA&&(AA.message=eA),AA}class CoreWorker{constructor(){this.wasm_initialized=!1,this.javascript_initialized=!1,this.source_set=!1,this._initializationDataReleased=!1,this.flags_set=!1,this.core_type="rust",this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!1,this._componentIdxToName={},this._doenetIdToComponentIdx={},this._javascriptInitialRenderDone=!1,this.isProcessingPromise=Promise.resolve(),this._hostedCores=new Map,this._nextHostedCoreId=1,this._isHostedCore=!1}async createCore(eA){const AA=new CoreWorker;AA._isHostedCore=!0,expose(AA,eA);const tA=this._nextHostedCoreId++;return this._hostedCores.set(tA,{core:AA,port:eA}),tA}async destroyCore(eA){const AA=this._hostedCores.get(eA);if(AA){this._hostedCores.delete(eA);try{await AA.core.terminate()}catch(tA){console.error("Error terminating hosted core",tA)}finally{AA.port.close()}}}setCoreType(eA){this.core_type=eA}async setSource(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setSource(eA.source)),this.doenetCore.set_source(eA.dast,eA.source),this.source_set=!0,this._initializationDataReleased=!1}catch(rA){throw console.error("Error when setting source",rA),rA}finally{iA()}}async setFlags(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.wasm_initialized||(await ensureWasmInitialized(),this.wasm_initialized=!0),this.doenetCore||(this.doenetCore=PublicDoenetMLCore$1.new()),this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setFlags(eA.flags)),this.doenetCore.set_flags(JSON.stringify(eA.flags)),this.flags_set=!0}finally{iA()}}async setLocaleData(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{this.core_type==="javascript"&&(this.javascriptCore||(this.javascriptCore=new PublicDoenetMLCore),this.javascriptCore.setLocaleData(eA.localeData))}finally{iA()}}async initializeJavascriptCore({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA}){const rA=this.isProcessingPromise;let{promise:aA,resolve:oA}=promiseWithResolver();this.isProcessingPromise=aA,await rA;let sA=!1;try{let lA=function(mA){return dA.update_root_names(mA)},gA=function(mA,QA,BA){return dA.resolve_path(mA,QA,BA)},cA=function(mA,QA){dA.add_nodes_to_resolver(mA,QA)},IA=function(mA,QA){dA.replace_index_resolutions_in_resolver(mA,QA)},uA=function(mA){dA.delete_nodes_from_resolver(mA)};if(!this.source_set||!this.flags_set||!this.javascriptCore||!this.doenetCore)throw Error("Cannot initialize javascript core before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);sA=!0,discardStalePanicMessage();let CA=this.doenetCore.return_normalized_dast_root();const dA=this.doenetCore,pA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:CA,addNodesToResolver:cA,replaceIndexResolutionsInResolver:IA,deleteNodesFromResolver:uA,resolvePath:gA,updateRootNames:lA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,pA}catch(lA){if(console.error(lA),!sA)throw lA;throwAsDocumentBuildError(lA,readPanicMessage())}finally{oA()}}async generateJavascriptDast(eA,AA,tA,iA,rA,aA,oA,sA){const lA=this.isProcessingPromise;let{promise:gA,resolve:cA}=promiseWithResolver();if(this.isProcessingPromise=gA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const IA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA);if(IA?.success===!1){const uA=readPanicMessage();uA!==void 0&&throwAsDocumentBuildError(new Error(IA.errMsg??""),uA)}return IA}catch(IA){console.error(IA),throwAsDocumentBuildError(IA,readPanicMessage())}finally{cA()}}async returnDast({variantIndex:eA=1}={}){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");try{return this.core_type==="javascript"?await this.returnFlatDastFromJS(eA):this.doenetCore.return_dast()}catch(rA){throw console.error(rA),rA}finally{iA()}}async returnNormalizedDastRoot(){if(!this.source_set||!this.doenetCore)throw Error("Cannot return normalized dast root before setting source");if(this.core_type==="javascript")return{nodes:[]};if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);return this.doenetCore.return_normalized_dast_root()}async returnFlatDastFromJS(eA){if(!this.javascriptCore||!this.doenetCore)throw Error("Cannot return dast before setting source and flags");if(this._initializationDataReleased)throw Error(RELEASED_INITIALIZATION_DATA_MESSAGE);let AA=this.doenetCore.return_normalized_dast_root();const tA=this.doenetCore;function iA(fA){return tA.update_root_names(fA)}function rA(fA,NA,yA){return tA.resolve_path(fA,NA,yA)}function aA(fA,NA){tA.add_nodes_to_resolver(fA,NA)}function oA(fA,NA){tA.replace_index_resolutions_in_resolver(fA,NA)}function sA(fA){tA.delete_nodes_from_resolver(fA)}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:iA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const lA={coreId:"a",cid:null,initializeCounters:{}};let gA=null;this._javascriptUpdateBuffer=[];const cA=fA=>{fA.init?gA=fA.updateInstructions:this._capturingJavascriptUpdates&&fA.updateInstructions&&this._javascriptUpdateBuffer.push(...fA.updateInstructions)},IA=fA=>{},uA=fA=>{},CA=fA=>{},dA=fA=>{},pA=fA=>{},mA=fA=>Promise.resolve({allowView:!0}),QA=await this.javascriptCore.createCoreGenerateDast(lA,cA,IA,uA,CA,dA,pA,mA);if(!QA.success)throw console.error(QA.errMsg),Error(QA.errMsg);if(gA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const BA=QA.coreInfo.documentToRender,{componentIdxToName:hA,doenetIdToComponentIdx:DA}=seedInstructionMaps(BA,gA);return this._componentIdxToName=hA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(BA,gA)}async dispatchActionJavascript(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");try{return await this.javascriptCore.requestAction(eA)}catch(rA){throw console.error(rA),rA}finally{iA()}}async dispatchActionJavascriptFlat(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();this.isProcessingPromise=tA,await AA;try{if(!this.source_set||!this.flags_set||!this.javascriptCore)throw Error("Cannot handle action before setting source and flags");if(!this._javascriptInitialRenderDone)throw Error("Cannot dispatch a flat action before the initial render (returnDast) has run");this._javascriptUpdateBuffer=[],this._capturingJavascriptUpdates=!0;const rA=eA.componentIdx!=null?this._componentIdxToName[eA.componentIdx]:void 0,aA=translateJsCoreActionName(rA,eA.actionName),oA=await this.javascriptCore.requestAction({...eA,actionName:aA});if(oA&&typeof oA=="object"&&"success"in oA&&oA.success===!1){const lA=aA===eA.actionName?`"${eA.actionName}"`:`"${eA.actionName}" (translated to "${aA}")`;throw Error(`Action ${lA} failed: ${oA.errMsg??"unknown error"}`)}this._capturingJavascriptUpdates=!1;const sA=this._javascriptUpdateBuffer;return this._javascriptUpdateBuffer=[],collectInstructionMaps(sA,this._componentIdxToName,this._doenetIdToComponentIdx),flatDastUpdateFromJS(sA,this._componentIdxToName,this._doenetIdToComponentIdx)}catch(rA){throw console.error(rA),rA}finally{this._capturingJavascriptUpdates=!1,iA()}}async resolvePath(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot resolve a path before setting source and flags");try{return this.doenetCore.resolve_path(eA.path,eA.origin,eA.skipParentSearch)}finally{iA()}}async dispatchAction(eA){const AA=this.isProcessingPromise;let{promise:tA,resolve:iA}=promiseWithResolver();if(this.isProcessingPromise=tA,await AA,!this.source_set||!this.flags_set||!this.doenetCore)throw Error("Cannot handle action before setting source and flags");try{return this.doenetCore.dispatch_action(eA)}catch(rA){throw console.error(rA),rA}finally{iA()}}async resolvePathJavascript(eA,AA=0){const tA=this.isProcessingPromise;let{promise:iA,resolve:rA}=promiseWithResolver();if(this.isProcessingPromise=iA,await tA,!this.source_set||!this.flags_set||!this.doenetCore||!this.javascriptCore)throw Error("Cannot resolve path before setting source and flags");try{return await resolvePathImmediatelyToNodeIdx(eA,this.doenetCore,this.javascriptCore,AA)}catch(aA){throw console.error(aA),aA}finally{rA()}}async terminate(){const eA=this.isProcessingPromise;let{promise:AA,resolve:tA}=promiseWithResolver();if(this.isProcessingPromise=AA,await eA,this.doenetCore?.free(),this.doenetCore=void 0,this.source_set=!1,this.flags_set=!1,this.javascriptCore)try{await this.javascriptCore.terminate()}catch(iA){throw console.error(iA),iA}finally{tA()}else tA();this._isHostedCore||close()}async returnAllStateVariables(eA=!1){return this.javascriptCore?this.javascriptCore.returnAllStateVariables(eA):{}}handleVisibilityChange(eA){this.javascriptCore&&this.javascriptCore.handleVisibilityChange(eA)}async submitAllAnswers(){this.javascriptCore&&await this.javascriptCore.submitAllAnswers()}async saveImmediately(){this.javascriptCore&&this.javascriptCore.saveImmediately()}async flushState(){return this.javascriptCore?await this.javascriptCore.flushState():!1}async _getTests(){return this.doenetCore?._get_tests()}async _runTest(eA){return this.doenetCore?._run_test(eA)}}function promiseWithResolver(){let nA,eA;return{promise:new Promise((tA,iA)=>{nA=tA,eA=iA}),resolve:nA,reject:eA}}expose(new CoreWorker);function _mergeNamespaces$1(nA,eA){for(var AA=0;AA<eA.length;AA++){const tA=eA[AA];if(typeof tA!="string"&&!Array.isArray(tA)){for(const iA in tA)if(iA!=="default"&&!(iA in nA)){const rA=Object.getOwnPropertyDescriptor(tA,iA);rA&&Object.defineProperty(nA,iA,rA.get?rA:{enumerable:!0,get:()=>tA[iA]})}}}return Object.freeze(Object.defineProperty(nA,Symbol.toStringTag,{value:"Module"}))}var sha256$3={exports:{}},convertHex$1={exports:{}},convertHex=convertHex$1.exports,hasRequiredConvertHex;function requireConvertHex(){return hasRequiredConvertHex||(hasRequiredConvertHex=1,(function(nA){(function(eA){var AA={bytesToHex:function(rA){return tA(rA)},hexToBytes:function(rA){if(rA.length%2===1)throw new Error("hexToBytes can't have a string with an odd number of characters.");return rA.indexOf("0x")===0&&(rA=rA.slice(2)),rA.match(/../g).map(function(aA){return parseInt(aA,16)})}};function tA(rA){return rA.map(function(aA){return iA(aA.toString(16),2)}).join("")}function iA(rA,aA){return rA.length>aA?rA:Array(aA-rA.length+1).join("0")+rA}nA.exports?nA.exports=AA:eA.convertHex=AA})(convertHex)})(convertHex$1)),convertHex$1.exports}var convertString$1={exports:{}},convertString=convertString$1.exports,hasRequiredConvertString;function requireConvertString(){return hasRequiredConvertString||(hasRequiredConvertString=1,(function(nA){(function(eA){var AA={bytesToString:function(tA){return tA.map(function(iA){return String.fromCharCode(iA)}).join("")},stringToBytes:function(tA){return tA.split("").map(function(iA){return iA.charCodeAt(0)})}};AA.UTF8={bytesToString:function(tA){return decodeURIComponent(escape(AA.bytesToString(tA)))},stringToBytes:function(tA){return AA.stringToBytes(unescape(encodeURIComponent(tA)))}},nA.exports?nA.exports=AA:eA.convertString=AA})(convertString)})(convertString$1)),convertString$1.exports}var sha256$2=sha256$3.exports,hasRequiredSha256;function requireSha256(){return hasRequiredSha256||(hasRequiredSha256=1,(function(nA){(function(eA){var AA={};nA.exports?(AA.bytesToHex=requireConvertHex().bytesToHex,AA.convertString=requireConvertString(),nA.exports=sA):(AA.bytesToHex=eA.convertHex.bytesToHex,AA.convertString=eA.convertString,eA.sha256=sA);var tA=[];(function(){function lA(uA){for(var CA=Math.sqrt(uA),dA=2;dA<=CA;dA++)if(!(uA%dA))return!1;return!0}function gA(uA){return(uA-(uA|0))*4294967296|0}for(var cA=2,IA=0;IA<64;)lA(cA)&&(tA[IA]=gA(Math.pow(cA,.3333333333333333)),IA++),cA++})();var iA=function(lA){for(var gA=[],cA=0,IA=0;cA<lA.length;cA++,IA+=8)gA[IA>>>5]|=lA[cA]<<24-IA%32;return gA},rA=function(lA){for(var gA=[],cA=0;cA<lA.length*32;cA+=8)gA.push(lA[cA>>>5]>>>24-cA%32&255);return gA},aA=[],oA=function(lA,gA,cA){for(var IA=lA[0],uA=lA[1],CA=lA[2],dA=lA[3],pA=lA[4],mA=lA[5],QA=lA[6],BA=lA[7],hA=0;hA<64;hA++){if(hA<16)aA[hA]=gA[cA+hA]|0;else{var DA=aA[hA-15],EA=(DA<<25|DA>>>7)^(DA<<14|DA>>>18)^DA>>>3,fA=aA[hA-2],NA=(fA<<15|fA>>>17)^(fA<<13|fA>>>19)^fA>>>10;aA[hA]=EA+aA[hA-7]+NA+aA[hA-16]}var yA=pA&mA^~pA&QA,bA=IA&uA^IA&CA^uA&CA,wA=(IA<<30|IA>>>2)^(IA<<19|IA>>>13)^(IA<<10|IA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+yA+tA[hA]+aA[hA],kA=wA+bA;BA=QA,QA=mA,mA=pA,pA=dA+vA|0,dA=CA,CA=uA,uA=IA,IA=vA+kA|0}lA[0]=lA[0]+IA|0,lA[1]=lA[1]+uA|0,lA[2]=lA[2]+CA|0,lA[3]=lA[3]+dA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+QA|0,lA[7]=lA[7]+BA|0};function sA(lA,gA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var cA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],IA=iA(lA),uA=lA.length*8;IA[uA>>5]|=128<<24-uA%32,IA[(uA+64>>9<<4)+15]=uA;for(var CA=0;CA<IA.length;CA+=16)oA(cA,IA,CA);var dA=rA(cA);return gA&&gA.asBytes?dA:gA&&gA.asString?AA.convertString.bytesToString(dA):AA.bytesToHex(dA)}sA.x2=function(lA,gA){return sA(sA(lA,{asBytes:!0}),gA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0Fpjk4uJM=Object.freeze(Object.defineProperty({__proto__:null,s:sha256$1},Symbol.toStringTag,{value:"Module"}));return exports.CoreWorker=CoreWorker,exports.DOCUMENT_BUILD_ERROR_NAME=DOCUMENT_BUILD_ERROR_NAME,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports})({});
2800
2800
  //# sourceMappingURL=index.js.map