@doenet/doenetml 0.7.27-dev.882 → 0.7.27-dev.883
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{AnswerResponseButton-CSrOes8c.js → AnswerResponseButton-O6QkA8hS.js} +2 -2
- package/{ClickTarget-DCkQqIJu.js → ClickTarget-CyifAnlZ.js} +1 -1
- package/{Description-CUFepz4p.js → Description-CP7x6g7P.js} +1 -1
- package/{EditorViewer-BY0oEC_N.js → EditorViewer-BwVvyNCc.js} +5 -5
- package/{GraphFrame-rZ9hxnSh.js → GraphFrame-CTK8MOnv.js} +2 -2
- package/{JSXGraphRenderer-BHxmaRwT.js → JSXGraphRenderer-B1dkKVU_.js} +1 -1
- package/{NonInlineMediaWrapper-CsUDzy0m.js → NonInlineMediaWrapper-DN7m_Pym.js} +1 -1
- package/Viewer/renderers/mathquill/mathquill.d.ts.map +1 -1
- package/{_blank-BEq5eK05.js → _blank-N5qo4xcd.js} +3 -3
- package/{_error-Dw5fgWas.js → _error-sm37t60j.js} +2 -2
- package/{alert-DF5fKswP.js → alert-DRdK2rN6.js} +3 -3
- package/{angle-CsGJwcPq.js → angle-BaW05dnu.js} +6 -6
- package/{answer-DunUXDgl.js → answer-DW9itV3c.js} +6 -6
- package/{asList-Cj9lz09u.js → asList-CUotDX-D.js} +2 -2
- package/{blockQuote-NZW4uhQe.js → blockQuote-LjC4jLEv.js} +3 -3
- package/{boolean-B7_HOzC2.js → boolean-B2C2UqKW.js} +2 -2
- package/{booleanInput-CkAWKqN6.js → booleanInput-DhnD8pFM.js} +7 -7
- package/{br-XdQhthkT.js → br-DPGYGh3l.js} +2 -2
- package/{button-iRVR_hAn.js → button-B-inuTTX.js} +5 -5
- package/{c-m_gDHvHZ.js → c-C3v3l2KU.js} +3 -3
- package/{cell-CbgtE5u7.js → cell-ByN7BkFZ.js} +3 -3
- package/{chart-DUvYv57Y.js → chart-D50ArZJQ.js} +4 -4
- package/{choiceInput-DnjfNIQI.js → choiceInput-pWAlrsXS.js} +7 -7
- package/{circle-BKVihmqT.js → circle-C4WqUS89.js} +6 -6
- package/{cobwebPolyline-DBaJ8zZt.js → cobwebPolyline-BsbIjzs0.js} +4 -4
- package/{codeEditor-DjNaQgjs.js → codeEditor-CvdzeQ5L.js} +2 -2
- package/{composites-rzKsL5Oe.js → composites-CF401ujF.js} +1 -1
- package/{containerBlock-B2Q9Odgw.js → containerBlock-Cb4MnPQh.js} +4 -4
- package/{containerInline-CTyesPea.js → containerInline-ZKdsYDel.js} +4 -4
- package/{curve-CreuQ54N.js → curve-91XQm81C.js} +4 -4
- package/{delete-aiJtPaSd.js → delete-Cj74AKUb.js} +3 -3
- package/{doenetml-dcX2EsRT.js → doenetml-5SWFSbLT.js} +3 -3
- package/doenetml-external-worker.js +2 -2
- package/doenetml-inline-worker.js +3 -3
- package/doenetml-worker/index.esm.js +1 -1
- package/doenetml-worker/index.js +1 -1
- package/{ellipsis-qQioG5hQ.js → ellipsis-BQcGURZz.js} +2 -2
- package/{em-Bl3PISvT.js → em-BYm_5QM_.js} +3 -3
- package/{embed-DymS7-xt.js → embed-BShFfDQB.js} +2 -2
- package/{feedback-eH8cPpJ6.js → feedback-CT3v8J6U.js} +4 -4
- package/{figure-DCg6aUO3.js → figure-Dmm6_1Ua.js} +3 -3
- package/{fillPatterns-BnCw-UEj.js → fillPatterns-DfG-I7Kd.js} +1 -1
- package/{footnote-B8blD_EC.js → footnote-B7aJbSX3.js} +3 -3
- package/{fractionInput-Bn-VADvU.js → fractionInput-sLpxmi2_.js} +5 -5
- package/{graph-CTYA9nl2.js → graph-CFF-RIRY.js} +5 -5
- package/{hint-maGiswRr.js → hint-nn2UvaM9.js} +5 -5
- package/{hovercard-store-CW-JxGh2.js → hovercard-store-Bq7ZOM76.js} +1 -1
- package/{hr-Cjj8KOwy.js → hr-R0pTOMoa.js} +2 -2
- package/{image-DWy40pb_.js → image-iYcFt8Zi.js} +8 -8
- package/{index-AmO8vXL7.js → index-BK4FfzPc.js} +1 -1
- package/{index.es-D1y0G_O4.js → index.es-_Bg2ps2T.js} +1 -1
- package/index.js +1 -1
- package/{inputLabel-9X9Co3yM.js → inputLabel-Bzs9wldn.js} +3 -3
- package/{insert-Brklr5hD.js → insert--XUj8aNW.js} +3 -3
- package/{label-DVe6qA4E.js → label-iVmtfbz-.js} +9 -9
- package/{legend-YYYg9UUb.js → legend-DqozyejQ.js} +4 -4
- package/{line-DP1d62vS.js → line-Bsc_ZKR2.js} +6 -6
- package/{lineFamilyDragHandlers-DJGgl3fD.js → lineFamilyDragHandlers-BOqvQb54.js} +1 -1
- package/{lineSegment-CDBPyCpi.js → lineSegment-BbHrWlQX.js} +5 -5
- package/{list-DXC2jZ8h.js → list-BsrJRiSg.js} +4 -4
- package/{lq-Bg_WG94x.js → lq-DBMOX7Xc.js} +2 -2
- package/{lsq-odQakbnr.js → lsq-evozJ6a9.js} +2 -2
- package/{markupRenderer-D2htl91P.js → markupRenderer-llAWVTDc.js} +1 -1
- package/{math-DHYYfr3n.js → math-BEe2AZ23.js} +8 -8
- package/{mathInput-cBXllLl6.js → mathInput-DLXm5R6S.js} +138 -12
- package/{mathInputSlots-Cs980pxZ.js → mathInputSlots-Cp4ez1jM.js} +1 -1
- package/{matrixInput-OBO9a5k1.js → matrixInput-BFhYLlkY.js} +5 -5
- package/{mdash-DwLnF5b6.js → mdash-BIOsklRL.js} +2 -2
- package/{nbsp-CebMpsNE.js → nbsp-DjpJNoO-.js} +2 -2
- package/{ndash-C4wyEhUg.js → ndash-C-DFXzvn.js} +2 -2
- package/{number-zJVr1ADn.js → number-DXNWzNSn.js} +8 -8
- package/{orbitalDiagram-D7F_2hM7.js → orbitalDiagram-Ag1b5y3T.js} +2 -2
- package/{orbitalDiagramInput-DSbHgsAd.js → orbitalDiagramInput-BDZXC83e.js} +2 -2
- package/{p-is2amDt8.js → p-C11wdFJA.js} +4 -4
- package/package.json +1 -1
- package/{paginatorControls-B12TU0eF.js → paginatorControls-5EtKuUvf.js} +2 -2
- package/{pegboard-d6gfzhII.js → pegboard-CbZ0TJJN.js} +3 -3
- package/{point-NaocP8hR.js → point-xxecXDtA.js} +6 -6
- package/{polygon-Ci2MNniN.js → polygon-D1o6eEes.js} +6 -6
- package/{polyline-Dsx9clzJ.js → polyline-B2q1zxSA.js} +5 -5
- package/{pre-C4q3PfSi.js → pre-Ci3-KFiU.js} +3 -3
- package/{prefigure-Co4wYbe3.js → prefigure-BvIXFPCu.js} +1 -1
- package/{pretzel-8T1Qa4sD.js → pretzel-BQcvDOum.js} +4 -4
- package/{q-DAeoN3Hh.js → q-DpzXTwvY.js} +3 -3
- package/{ray-BA7bVRTg.js → ray-CGcL3wXW.js} +5 -5
- package/{ref-DXK89EPb.js → ref-C96F6YWW.js} +3 -3
- package/{regionBetweenCurveXAxis-ciridAq3.js → regionBetweenCurveXAxis-VFxjeTx1.js} +5 -5
- package/{regionBetweenCurves-jzFNBpU3.js → regionBetweenCurves-BqIStf5B.js} +5 -5
- package/{row-CieQBldo.js → row-D-sQ-tbS.js} +2 -2
- package/{rq-DoipvlTk.js → rq-DPz7fmBH.js} +2 -2
- package/{rsq-BqX6jBV4.js → rsq-DUnLj9zb.js} +2 -2
- package/{section-DlZ_bsn7.js → section-DqguZIEe.js} +6 -6
- package/{sha256-8sXzDnE0-Ds_1NFMh.js → sha256-8sXzDnE0-c-d4EZQ-.js} +1 -1
- package/{sideBySide-t2LKjfhM.js → sideBySide-O85NZWW4.js} +2 -2
- package/{slider-Fbl4YNaT.js → slider-DMY0nH26.js} +4 -4
- package/{slopeField-BYmpkJ_t.js → slopeField-CZSF8kw5.js} +2 -2
- package/{solution-CElVw-M8.js → solution-CwwpioJG.js} +4 -4
- package/{spreadsheet-CawKIRV0.js → spreadsheet-BhzueZ9T.js} +2 -2
- package/{sq-B1GsfLba.js → sq-D370rS0g.js} +3 -3
- package/{subsetOfRealsInput-BeT-gW1O.js → subsetOfRealsInput-D931zOam.js} +2 -2
- package/{summaryStatistics-v5hIio9E.js → summaryStatistics-CzT4vo-g.js} +2 -2
- package/{table-cPB_Nl8D.js → table-Bj82VLpZ.js} +2 -2
- package/{tabular-qKgWcWgx.js → tabular-Ct_U-QKd.js} +2 -2
- package/{tag-CqqViuxK.js → tag-Bb7BuMsj.js} +2 -2
- package/{text-Bskxwp9m.js → text-BHimaHF8.js} +8 -8
- package/{textInput-BkXQgmVV.js → textInput-DNREClYL.js} +8 -8
- package/{tooltip-provider-CBWITpaP.js → tooltip-provider-BzXzxVWo.js} +2 -2
- package/{useAnchoredGraphDragHandler-DYcXcNLG.js → useAnchoredGraphDragHandler-ZFAqNk0y.js} +1 -1
- package/useDoenetRenderer-B06Vg5B2.js +114 -0
- package/{useFieldCurve-BSgWkgfT.js → useFieldCurve-6dukzc5C.js} +2 -2
- package/{useSubmitActionWithDelay-Cgy1BRYg.js → useSubmitActionWithDelay-LcMrTBQf.js} +2 -2
- package/{vector-DOESRPU2.js → vector-DnTGOv52.js} +6 -6
- package/{vectorField-DADmthJy.js → vectorField-BWA8Wdj8.js} +2 -2
- package/{video-E0r7pewz.js → video-qBXQXLSx.js} +4 -4
- package/useDoenetRenderer-CR_peeui.js +0 -114
package/doenetml-worker/index.js
CHANGED
|
@@ -1420,5 +1420,5 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
1420
1420
|
`};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,cA){if(!(lA instanceof cA))throw new TypeError("Cannot call a class as a function")}function iA(lA,cA){for(var gA=0;gA<cA.length;gA++){var uA=cA[gA];uA.enumerable=uA.enumerable||!1,uA.configurable=!0,"value"in uA&&(uA.writable=!0),Object.defineProperty(lA,uA.key,uA)}}function rA(lA,cA,gA){return cA&&iA(lA.prototype,cA),Object.defineProperty(lA,"prototype",{writable:!1}),lA}function aA(lA,cA,gA){return cA in lA?Object.defineProperty(lA,cA,{value:gA,enumerable:!0,configurable:!0,writable:!0}):lA[cA]=gA,lA}var oA=(function(){function lA(){var cA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},gA=cA.sentencesPerParagraph,uA=gA===void 0?{max:7,min:3}:gA,IA=cA.wordsPerSentence,dA=IA===void 0?{max:15,min:5}:IA,CA=cA.random;cA.seed;var pA=cA.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),uA.min>uA.max)throw new Error("Minimum number of sentences per paragraph (".concat(uA.min,") cannot exceed maximum (").concat(uA.max,")."));if(dA.min>dA.max)throw new Error("Minimum number of words per sentence (".concat(dA.min,") cannot exceed maximum (").concat(dA.max,")."));this.sentencesPerParagraph=uA,this.words=mA,this.wordsPerSentence=dA,this.random=CA||Math.random}return rA(lA,[{key:"generateRandomInteger",value:function(gA,uA){return Math.floor(this.random()*(uA-gA+1)+gA)}},{key:"generateRandomWords",value:function(gA){var uA=this,IA=this.wordsPerSentence,dA=IA.min,CA=IA.max,pA=gA||this.generateRandomInteger(dA,CA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,hA){return"".concat(uA.pluckRandomWord()," ").concat(mA)},"").trim()}},{key:"generateRandomSentence",value:function(gA){return"".concat((0,AA.capitalize)(this.generateRandomWords(gA)),".")}},{key:"generateRandomParagraph",value:function(gA){var uA=this,IA=this.sentencesPerParagraph,dA=IA.min,CA=IA.max,pA=gA||this.generateRandomInteger(dA,CA);return(0,AA.makeArrayOfLength)(pA).reduce(function(mA,hA){return"".concat(uA.generateRandomSentence()," ").concat(mA)},"").trim()}},{key:"pluckRandomWord",value:function(){var gA=0,uA=this.words.length-1,IA=this.generateRandomInteger(gA,uA);return this.words[IA]}}]),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(uA){return uA&&uA.__esModule?uA:{default:uA}}function aA(uA,IA){if(!(uA instanceof IA))throw new TypeError("Cannot call a class as a function")}function oA(uA,IA){for(var dA=0;dA<IA.length;dA++){var CA=IA[dA];CA.enumerable=CA.enumerable||!1,CA.configurable=!0,"value"in CA&&(CA.writable=!0),Object.defineProperty(uA,CA.key,CA)}}function sA(uA,IA,dA){return IA&&oA(uA.prototype,IA),Object.defineProperty(uA,"prototype",{writable:!1}),uA}function lA(uA,IA,dA){return IA in uA?Object.defineProperty(uA,IA,{value:dA,enumerable:!0,configurable:!0,writable:!0}):uA[IA]=dA,uA}var cA=(function(){function uA(){var IA=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},dA=arguments.length>1&&arguments[1]!==void 0?arguments[1]:eA.FORMAT_PLAIN,CA=arguments.length>2?arguments[2]:void 0;if(aA(this,uA),this.format=dA,this.suffix=CA,lA(this,"generator",void 0),eA.FORMATS.indexOf(dA.toLowerCase())===-1)throw new Error("".concat(dA," is an invalid format. Please use ").concat(eA.FORMATS.join(" or "),"."));this.generator=new tA.default(IA)}return sA(uA,[{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(dA){return this.format===eA.FORMAT_HTML?"<p>".concat(dA,"</p>"):dA}},{key:"formatStrings",value:function(dA){var CA=this;return dA.map(function(pA){return CA.formatString(pA)})}},{key:"generateWords",value:function(dA){return this.formatString(this.generator.generateRandomWords(dA))}},{key:"generateSentences",value:function(dA){return this.formatString(this.generator.generateRandomParagraph(dA))}},{key:"generateParagraphs",value:function(dA){var CA=this.generator.generateRandomParagraph.bind(this.generator);return this.formatStrings((0,iA.makeArrayOfStrings)(dA,CA)).join(this.getLineEnding())}}]),uA})(),gA=cA;nA.default=gA})(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,cA=lA===void 0?1:lA,gA=sA.format,uA=gA===void 0?eA.FORMAT_PLAIN:gA,IA=sA.paragraphLowerBound,dA=IA===void 0?3:IA,CA=sA.paragraphUpperBound,pA=CA===void 0?7:CA,mA=sA.random,hA=sA.sentenceLowerBound,BA=hA===void 0?5:hA,QA=sA.sentenceUpperBound,EA=QA===void 0?15:QA,fA=sA.units,yA=fA===void 0?AA.UNIT_SENTENCES:fA,DA=sA.words,bA=DA===void 0?tA.WORDS:DA,NA=sA.suffix,wA=NA===void 0?"":NA,MA={random:mA,sentencesPerParagraph:{max:pA,min:dA},words:bA,wordsPerSentence:{max:EA,min:BA}},vA=new iA.default(MA,uA,wA);switch(yA){case AA.UNIT_PARAGRAPHS:case AA.UNIT_PARAGRAPH:return vA.generateParagraphs(cA);case AA.UNIT_SENTENCES:case AA.UNIT_SENTENCE:return vA.generateSentences(cA);case AA.UNIT_WORDS:case AA.UNIT_WORD:return vA.generateWords(cA);default:return""}};nA.loremIpsum=aA})(dist)),dist}var distExports=requireDist();async function loremParameters(nA){return[await nA.stateValues.minSentencesPerParagraph,await nA.stateValues.maxSentencesPerParagraph,await nA.stateValues.minWordsPerSentence,await nA.stateValues.maxWordsPerSentence,await nA.stateValues.generateWords,await nA.stateValues.generateSentences,await nA.stateValues.generateParagraphs]}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=[];AA.parametersUsed=await loremParameters(eA);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(`
|
|
1421
1421
|
`).map(cA=>({type:"serialized",componentType:"p",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[cA]})))}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 cA of lA.slice(0,lA.length-1))oA.push({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[cA+"."]}),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(cA=>({type:"serialized",componentType:"text",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[cA]}));oA.push(lA[0]);for(let cA of lA.slice(1))oA.push(" "),oA.push(cA)}}return AA.replacementsCreated=iA.num,{replacements:oA,diagnostics:rA,nComponents:tA}}static async calculateReplacementChanges({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA}){const rA=await loremParameters(eA);if(iA.parametersUsed&&rA.every((lA,cA)=>Object.is(lA,iA.parametersUsed[cA])))return{replacementChanges:[],diagnostics:[],nComponents:tA};let aA=[],oA=await this.createSerializedReplacements({component:eA,componentInfoObjects:AA,nComponents:tA,workspace:iA});return aA.push(...oA.diagnostics),tA=oA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:oA.replacements}],diagnostics:aA,nComponents:tA}}static setUpVariant({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA}){setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:tA})}}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,disabledCheckedByTriggerSet:iA=!1}){if(!iA&&!this.flags.readOnly&&await this.stateValues.disabled)return;let rA=await this.stateValues.targetComponentIdx,aA=await this.stateValues.actionName;if(rA!=null&&aA!=null&&(await targetsNotWithheld({component:this,targetIndices:[rA]})).length>0){let oA={sourceInformation:AA,skipRendererUpdate:!0};this.serializedChildren.length>0&&(oA.serializedComponents=deepClone(this.serializedChildren)),this.attributes.number&&(oA.number=this.attributes.number.type==="literal"?literalAttributeValue(this.attributes.number,this.componentInfoObjects):await this.attributes.number.component.stateValues.value),this.attributes.numbers&&(oA.numbers=await this.attributes.numbers.component.stateValues.numbers),eA&&(oA.actionId=eA),(await this.coreFunctions.performAction({componentIdx:rA,actionName:aA,args:oA,event:{verb:"selected",object:{componentIdx:this.componentIdx,componentType:this.componentType}},caseInsensitiveMatch:!0}))?.actionUnavailable&&await this.warnActionUnavailable(aA),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"],variableNames:["disabled"]}}),definition({dependencyValues:rA}){return{setValue:{updateValueAndActionsToTrigger:rA.updateValueAndCallActionChildren}}}},eA}async triggerActions({actionId:eA,sourceInformation:AA={},skipRendererUpdate:tA=!1}){if(!this.flags.readOnly&&await this.stateValues.disabled)return;const iA=(await this.stateValues.updateValueAndActionsToTrigger).filter(rA=>this.flags.readOnly||!rA.stateValues.disabled);for(let rA of iA)this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:rA.componentType,baseComponentType:"updateValue"})?await this.coreFunctions.performAction({componentIdx:rA.componentIdx,actionName:"updateValue",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,disabledCheckedByTriggerSet:!0}}):this.componentInfoObjects.isInheritedComponentType({inheritedComponentType:rA.componentType,baseComponentType:"callAction"})&&await this.coreFunctions.performAction({componentIdx:rA.componentIdx,actionName:"callAction",args:{actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,disabledCheckedByTriggerSet:!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 ValueListComponent{static componentType="functionIterates";static componentDocs={summary:"List of values produced by iterating a function"};static listEntryComponentType="math";static listEntryValuesVariable="allIterates";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."},eA}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return eA.numDimensions={description:"Number of dimensions of each iterate.",public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numInputs","numOutputs"]},functionDecidedByDoenetML:{dependencyType:"decidedByDoenetML",attributeNames:["function"]}}),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:levelFromSource(AA.functionDecidedByDoenetML),code:"doenet-w0056",args:{inputs:tA,outputs:iA},position:AA.functionAttr.position||void 0});return{setValue:{numDimensions:0},conditionDiagnostics:[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 cA=0;cA<oA;cA++)lA=sA(lA),tA.push(lA)}else{let sA=iA.stateValues.symbolicfs,lA=rA.tree.slice(1).map(cA=>context.fromAst(cA));for(let cA=0;cA<oA;cA++){let gA=[];for(let uA=0;uA<AA.numDimensions;uA++)gA.push(sA[uA](...lA).tree);tA.push(context.fromAst(["vector",...gA])),lA=gA.map(uA=>context.fromAst(uA))}}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 cA=0;cA<oA;cA++)lA=sA(lA),tA.push(context.fromAst(lA))}else{let sA=iA.stateValues.numericalfs,lA=rA.tree.slice(1).map(cA=>evaluateToNumber(context.fromAst(cA)));for(let cA=0;cA<oA;cA++){let gA=[];for(let uA=0;uA<AA.numDimensions;uA++)gA.push(sA[uA](...lA));tA.push(context.fromAst(["vector",...gA])),lA=gA}}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 mapShadowedReplacementIndicesThroughSerializedChildren=!0;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],cA=Object.keys(lA.constructor.createAttributesObject()).map(pA=>pA.toLowerCase());cA.push("name");const gA=[],uA=deepClone(await eA.state.serializedChildren.value),{writtenFor:IA,corrections:dA}=moduleAttributesWritten({written:Object.keys(lA.attributes),declared:uA.map(pA=>pA.attributes.name?.primitive?.value).filter(Boolean)});for(const{written:pA,corrected:mA}of dA){const hA=lA.attributes[pA];hA.type!=="unresolved"||cA.includes(mA.toLowerCase())||oA.push(codedDiagnostic({type:"warning",code:"doenet-w0197",args:{attribute:pA,suggestion:mA,componentType:"module"},position:hA.position??lA.position,sourceDoc:hA.sourceDoc??lA.sourceDoc}))}for(const pA of uA){const mA=pA.attributes.name?.primitive?.value;if(!mA){gA.push(pA),oA.push(codedDiagnostic({type:"warning",code:"doenet-w0074",args:{component:pA.componentType},position:pA.position}));continue}const hA=IA.get(mA);let BA=hA===void 0?void 0:lA.attributes[hA];if(BA===void 0){gA.push(pA);continue}if(cA.includes(mA.toLowerCase())){oA.push(codedDiagnostic({type:"warning",code:"doenet-w0075",args:{component:pA.componentType,name:mA},position:pA.position})),gA.push(pA);continue}if(BA.type!=="unresolved")throw Error("A module attribute that isn't an existing attribute must be unresolved!");if(referencesComponent(BA.children,pA.componentIdx)){oA.push(codedDiagnostic({type:"error",code:"doenet-e0055",args:{name:mA},position:BA.position})),gA.push(pA);continue}const QA=deepClone(BA.children);setUnflattenedReferenceOrigins(QA,eA.componentIdx);const EA=expandUnflattenedToSerializedComponents({serializedComponents:QA,componentInfoObjects:tA,nComponents:iA,stateIdInfo:aA});oA.push(...EA.diagnostics),iA=EA.nComponents,pA.children=EA.components;const fA=applySugar({serializedComponents:[pA],componentInfoObjects:tA,nComponents:iA,stateIdInfo:aA});oA.push(...fA.diagnostics),iA=fA.nComponents,gA.push(fA.components[0])}const CA={type:"serialized",componentType:"setup",componentIdx:iA++,stateId:`${aA.prefix}${aA.num++}`,children:gA,attributes:{},doenetAttributes:{},state:{}};return rA.replacementsCreated=aA.num,{replacements:[CA],diagnostics:oA,nComponents:iA}}}function referencesComponent(nA,eA){for(const AA of nA)if(!(typeof AA!="object"||AA===null)){if(AA.extending&&unwrapSource(AA.extending).nodeIdx===eA||referencesComponent(AA.children??[],eA))return!0;for(const tA in AA.attributes)if(referencesComponent(AA.attributes[tA].children??[],eA))return!0}return!1}class Footnote extends InlineComponent{static componentType="footnote";static isContent=!0;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","valueMissing"],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 isContent=!0;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","valueMissing"],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 get collectionCompositeClass(){return Sort}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"},childOrderMissing:{dependencyType:"stateVariable",variableName:"childOrderMissing"},...AA==="vector"&&aA.sortVectorsBy==="tail"?{childOrderTails:{dependencyType:"stateVariable",variableName:"childOrderTails"}}:{}}),definition({dependencyValues:aA}){const sA=(aA.childOrderTails??aA.childOrderValues).map((gA,uA)=>aA.childOrderMissing[uA]?{numericalValue:NaN,textValue:"",numeric:!0,missing:!0}:AA==="point"||AA==="vector"?comparableCoordinate(gA,aA.sortByComponent):comparableEntryValue(gA,tA)),lA=sA.every(gA=>gA.numeric);return{setValue:{entryOrder:[...sA.keys()].sort((gA,uA)=>compareForSorting(sA[gA],sA[uA],lA))},checkForActualChange:{entryOrder:!0}}}}};return rA.childOrderMissing={returnDependencies:()=>({entryStructure:{dependencyType:"stateVariable",variableName:"childOrderEntryStructure"},children:{dependencyType:"child",childGroups:iA,variableNames:["valueMissing","contentMissing"],variablesOptional:!0}}),definition:({dependencyValues:aA})=>({setValue:{childOrderMissing:aA.entryStructure.map(oA=>{if(oA.missing)return!0;if(oA.componentInd===void 0)return!1;const sA=aA.children[oA.componentInd];return!!(sA?.componentType==="_missing"||sA?.stateValues?.valueMissing||sA?.stateValues?.contentMissing)})}})},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]}function wrapperUnits(nA=[]){const eA=nA.filter(iA=>iA.wrapperOfSeveral&&iA.lastInd>=iA.firstInd).sort((iA,rA)=>iA.firstInd-rA.firstInd||rA.lastInd-rA.firstInd-(iA.lastInd-iA.firstInd)),AA=new Map;let tA=-1;for(const iA of eA)iA.firstInd<=tA||(AA.set(iA.firstInd,iA),tA=iA.lastInd);return AA}class Shuffle extends CompositeComponent{static componentType="shuffle";static attributesAreProperties=!1;static componentDocs={summary:"Randomly shuffles its children"};static takesIndex=!0;static allowInSchemaAnywhere=!0;static createsVariants=!0;static choiceChildTypes=["_base"];static choiceTextChildren=!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, beside components of one type written as tags, they are read as that type where they read as it (only text with coordinates as a point or vector, only `true` or `false` as a boolean); otherwise 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,{allowComponents:!0})),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return makeCollectionSettingsOwn(eA),eA.originalComponentIndices={additionalStateVariablesDefined:["numComponents"],returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"],variableNames:["componentIndicesInList"],variablesOptional:!0,markWrappersOfSeveral:!0,reportCompositeChanges:!0}}),definition({dependencyValues:AA}){let tA=[];const iA=[],rA=AA.children,aA=wrapperUnits(rA.compositeReplacementRange);for(let oA=0;oA<rA.length;oA++){const sA=aA.get(oA);if(sA){tA.push(sA.compositeIdx),oA=sA.lastInd;continue}const lA=rA[oA];typeof lA=="string"&&iA.push(codedDiagnostic({type:"warning",code:"doenet-w0015",args:{value:lA,component:"shuffle"}})),lA.stateValues?.componentIndicesInList?tA.push(...lA.stateValues.componentIndicesInList):lA.listEntryIndex!==void 0?tA.push(`${lA.componentIdx}|${lA.listEntryIndex}`):tA.push(lA.componentIdx)}return{setValue:{originalComponentIndices:tA,numComponents:tA.length},sendDiagnostics:iA}}},eA.componentOrder={shadowVariable:!0,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(),cA=Math.floor(lA*(sA+1));[oA[sA],oA[cA]]=[oA[cA],oA[sA]]}return{setValue:{componentOrder:oA},sendDiagnostics:tA}}},eA.replacementSourceKeys={returnDependencies:()=>({originalComponentIndices:{dependencyType:"stateVariable",variableName:"originalComponentIndices"},componentOrder:{dependencyType:"stateVariable",variableName:"componentOrder"}}),definition:({dependencyValues:AA})=>({setValue:{replacementSourceKeys:AA.componentOrder.map(tA=>AA.originalComponentIndices[tA-1]).filter(tA=>tA!==void 0)}})},Object.assign(eA,returnReplacementsToHideDefinitions("replacementSourceKeys")),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:variantDescendantComponentTypes(AA),variableNames:["isVariantComponent","generatedVariantInfo"],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.numItems=numItemsDefinition({variableName:"originalComponentIndices",count:AA=>Array.isArray(AA)?AA.filter(tA=>tA!==void 0).length: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}){const aA=reorderErrorReplacements({component:eA,nComponents:rA});if(aA)return iA.componentsCopied=[],aA;let oA=[],sA=[],lA=[];iA.replacementsCreated===void 0&&(iA.replacementsCreated=0);const cA={prefix:`${eA.stateId}|`,num:iA.replacementsCreated};let gA=await eA.stateValues.originalComponentIndices;const uA=[];for(let IA of await eA.stateValues.componentOrder){const dA=gA[IA-1];let CA=shuffledSource(dA,AA);CA&&(lA.push(dA),uA.push(CA))}return{replacements:sA,nComponents:rA}=await this.copyReplacementSources({component:eA,replacementSources:uA,nComponents:rA,stateIdInfo:cA}),iA.componentsCopied=lA,iA.replacementsCreated=cA.num,{replacements:sA,diagnostics:oA,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);if(tA=sA.nComponents,aA.componentType==="_copy"&&isWrapperOfSeveral(aA)){rA.push({type:"serialized",componentType:"group",componentIdx:tA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{shuffledUnitOf:aA.componentIdx},state:{},children:sA.components});continue}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,cA]of tA.componentsCopied.entries()){const gA=eA.replacements[sA];if(typeof cA=="string"?gA!==void 0:gA?.shadows?.componentIdx===cA||gA?.doenetAttributes?.shuffledUnitOf===cA){sA++;continue}const uA=shuffledSource(cA,AA);if(!uA)continue;const IA=await this.copyReplacementSources({component:eA,replacementSources:[uA],nComponents:iA,stateIdInfo:oA});iA=IA.nComponents,aA.push({changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:lA,numberReplacementsToReplace:0,numberDeletedReplacementsToReplace:1,serializedReplacements:IA.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=[];if(eA.doenetAttributes?.reorderErrorAtLoad)return{replacementChanges:[],diagnostics:aA,nComponents:rA};let oA=[],sA=await eA.stateValues.originalComponentIndices;for(let uA of await eA.stateValues.componentOrder){const IA=sA[uA-1];shuffledSource(IA,AA)&&oA.push(IA)}if(oA.length==iA.componentsCopied.length&&iA.componentsCopied.every((uA,IA)=>uA===oA[IA]))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}),cA=lA.replacements;return aA.push(...lA.diagnostics),rA=lA.nComponents,{replacementChanges:[{changeType:"add",changeTopLevelReplacements:!0,firstReplacementInd:0,numberReplacementsToReplace:eA.replacements.length,serializedReplacements:cA}],diagnostics:aA,nComponents:rA}}static numberOfShuffledChildren({serializedComponent:eA,componentInfoObjects:AA}){let tA=0;for(let iA of eA.children){if(typeof iA=="object"&&iA.componentType==="group"&&!iA.extending){if(iA.children.filter(aA=>typeof aA!="string"||aA.trim()!=="").length>1){tA++;continue}return}if(AA.allComponentClasses[iA.componentType]?.listEntryComponentType!==void 0)return;if(AA.isInheritedComponentType({inheritedComponentType:iA.componentType,baseComponentType:"_composite"}))if(iA.attributes._createComponentOfType?.primitive)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 cA=combinationAtIndex({numberOfOptionsByIndex:lA,index:AA-1}).map(hA=>hA+1),gA=cA.pop(),uA=cA,IA=[...Array(sA).keys()].map(hA=>hA+1),dA=permutationAtIndex({values:IA,index:gA-1}),CA=!1,pA=[];for(let hA=0;hA<rA.length;hA++)if(rA[hA]>1){let BA=aA[hA],EA=tA.allComponentClasses[BA.componentType].getUniqueVariant({serializedComponent:BA,variantIndex:uA[hA],componentInfoObjects:tA});if(!EA.success)return{success:!1};pA.push(EA.desiredVariant),CA=!0}else pA.push({});let mA={indices:dA};return CA&&(mA.subvariants=pA),{success:!0,desiredVariant:mA}}}function shuffleListClass(nA){return class extends reorderedValueListClass(nA){static componentType="_shuffleList";static createsVariants=!0;static get collectionCompositeClass(){return Shuffle}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=[],aA=listSplittingFromAttribute(AA.attributes?._listSplitting?.primitive?.value);for(const sA of AA.children)typeof sA=="string"?iA+=this.splitTextIntoPieces(sA,aA)?.length??0:rA.push(sA);const oA=Shuffle.numberOfShuffledChildren({serializedComponent:{...AA,children:rA},componentInfoObjects:tA});return oA===void 0?void 0:oA+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,{allowComponents:!0})),eA}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let eA=super.returnStateVariableDefinitions();return Object.assign(eA,returnListValueStateVariableDefinitions({componentName:this.componentType,supportProps:!0,keepMissing:!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 indexThroughProperty="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"},equationDecidedByDoenetML:{dependencyType:"decidedByDoenetML",attributeNames:["variables"],childGroups:["maths","strings"]}}),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(),cA;try{cA=lA.f()}catch{let DA=[codedDiagnostic({type:levelFromSource(tA.equationDecidedByDoenetML),code:"doenet-w0057",args:{equation:iA.toString()}})];return{setValue:{allSolutions:[]},conditionDiagnostics:DA}}let gA=yA=>cA({[sA]:yA}),uA=yA=>normalizeMathExpression({value:lA.substitute({[sA]:yA}).strings_to_subscripts(),simplify:!0,expand:!0}).evaluate_to_constant(),IA=function(yA){try{return gA(yA)}catch{return NaN}},dA=function(yA){try{return gA(yA)}catch{return toNumberOrNaN(uA(yA))}};if(Number.isFinite(rA)||(rA=-10),Number.isFinite(aA)||(aA=10),rA>aA)return{setValue:{allSolutions:[]}};let CA=[rA,aA],pA=[rA];for(let yA=0;yA<CA.length-1;yA++){let DA=CA[yA],bA=CA[yA+1],NA=tA.numDiscretizationPoints,wA=(bA-DA)/NA;for(let MA=1;MA<NA;MA++)pA.push(DA+MA*wA);pA.push(bA)}let mA=2*pA[0]-pA[1],hA=2*pA[pA.length-1]-pA[pA.length-2];pA=[mA,...pA,hA];let BA=pA.map(dA),QA=pA[0],EA=BA[0];for(let yA=0;yA<pA.length;yA++){let DA=pA[yA],bA=BA[yA];if(!Number.isFinite(bA)||!Number.isFinite(EA)){let NA,wA;if(Number.isFinite(bA)?(NA=DA,wA=QA):Number.isFinite(EA)&&(NA=QA,wA=DA),NA!==void 0){for(;;){let MA=(NA+wA)/2;if(MA===NA||MA===wA)break;Number.isFinite(IA(MA))?NA=MA:wA=MA}[DA,QA].includes(NA)||(pA.splice(yA,0,NA),BA.splice(yA,0,IA(NA)))}}QA=DA,EA=bA}oA=[],QA=pA[0],EA=BA[0],EA===0&&oA.push(QA);for(let yA=1;yA<pA.length;yA++){let DA=pA[yA],bA=BA[yA];if(bA===0){let NA=!1;if(yA<pA.length-1){let wA=pA[yA+1],MA=BA[yA+1],vA=QA,TA=EA;if(EA*MA>0){for(let kA=0;kA<10;kA++)if(QA=.1*QA+.9*DA,wA=.1*wA+.9*DA,EA=IA(QA),MA=IA(wA),EA*MA<0){EA*TA<0?(oA.push(eA.fzero(IA,[vA,QA])),oA.push(DA)):(oA.includes(DA)||oA.push(DA),DA=wA,bA=MA),NA=!0;break}}}!NA&&!oA.includes(DA)&&oA.push(DA)}else if(bA*EA<0)oA.push(eA.fzero(IA,[QA,DA]));else if(EA!==0&&yA<pA.length-1){let NA=pA[yA+1],wA=BA[yA+1];if((EA-bA)*(wA-bA)>0&&(bA>0&&EA>bA||bA<0&&EA<bA)){let MA;EA>bA?MA=IA:MA=TA=>-IA(TA);let vA=eA.fminbr(MA,[QA,NA],void 0,1e-10);if(vA.success){let TA=vA.x,kA=IA(TA);kA*EA<0?(oA.push(eA.fzero(IA,[QA,TA])),DA=TA,bA=kA):kA===0&&oA.push(TA)}}}QA=DA,EA=bA}return oA=oA.filter(yA=>yA>=rA&&yA<=aA),{setValue:{allSolutions:oA.map(yA=>context.fromAst(yA))}}}},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 isValue=!1;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(cA=>cA.value);for(let cA of aA.points){let gA=lA.indexOf(cA.value);gA===-1?oA.push(cA):oA[gA].inSubset||=cA.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 isValue=!0;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:{size:800,isAbsolute:!0},public:!0,forRenderer:!0,excludeFromSchema:!0},eA.height={description:"Display height of the input.",createComponentOfType:"componentSize",createStateVariable:"height",defaultValue:{size:300,isAbsolute:!0},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((dA,CA)=>dA-CA),oA=[],sA=[],lA=0,cA=1/0,gA=0;aA.length>0&&(cA=aA[0]);let uA=rA[0],IA=-1/0;iA.push({value:1/0,inSubset:!1});for(let dA of iA){let CA=!1;for(uA&&uA[0]<dA.value&&(CA=!0);cA<dA.value;)cA!==IA&&(oA.push({value:cA,inSubset:CA,isAdditional:!0,additionalPointInd:gA}),sA.push({left:IA,right:cA,inSubset:CA}),IA=cA),gA++,cA=aA[gA],cA===void 0&&(cA=1/0);oA.push(dA),sA.push({left:IA,right:dA.value,inSubset:CA}),IA=dA.value,CA&&(lA++,uA=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(gA=>gA.value).includes(aA)){let gA=!1;for(let uA of sA)if(uA[0]<aA&&uA[1]>aA){gA=!0;break}if(gA)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 uA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:!1,additionalPoints:lA});return await this.coreFunctions.performUpdate({updateInstructions:uA,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,cA=oA.map(dA=>dA.value).indexOf(rA.value),gA=sA.map(dA=>dA[1]).indexOf(rA.value),uA=sA.map(dA=>dA[0]).indexOf(rA.value);if(gA!==-1)if(uA!==-1)sA[gA]=[sA[gA][0],sA[uA][1]],sA.splice(uA,1),oA.splice(cA,1);else{let dA=(await this.stateValues.pointsDisplayed)[eA-1];dA&&dA.isAdditional?(sA[gA]=[sA[gA][0],dA.value],aA.splice(dA.additionalPointInd,1),lA=!0,oA.splice(cA,1,dA)):(sA.splice(gA,1),oA.splice(cA,1),dA&&!dA.inSubset&&sA.map(pA=>pA[1]).indexOf(dA.value)===-1&&(aA.push(dA.value),lA=!0))}else if(uA!==-1){let dA=(await this.stateValues.pointsDisplayed)[eA+1];dA&&dA.isAdditional?(sA[uA]=[dA.value,sA[uA][1]],aA.splice(dA.additionalPointInd,1),lA=!0,oA.splice(cA,1,dA)):(sA.splice(uA,1),oA.splice(cA,1),dA&&!dA.inSubset&&sA.map(pA=>pA[0]).indexOf(dA.value)===-1&&(aA.push(dA.value),lA=!0))}else oA.splice(cA,1);let IA=await this.createUpdateInstructions({intervalsFromSubset:sA,pointsFromSubset:oA,modifiedAdditionalPoints:lA,additionalPoints:aA});return await this.coreFunctions.performUpdate({updateInstructions:IA,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=cA=>Math.round(cA/rA)*rA,oA=[];for(let cA of eA)oA.push(subsetOfReals.OpenInterval(aA(cA[0]),aA(cA[1])));for(let cA of AA)cA.inSubset&&oA.push(subsetOfReals.Singleton(aA(cA.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,cA=lA[eA],gA=lA[eA-1];gA&&(sA=Math.max(sA,gA.value+oA));let uA=lA[eA+1];uA&&(sA=Math.min(sA,uA.value-oA));let IA=[...await this.stateValues.additionalPoints],dA=[...await this.stateValues.pointsFromSubset],CA=[...await this.stateValues.intervalsFromSubset];if(cA.isAdditional)return IA[cA.additionalPointInd]=sA,tA?await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:IA}],transient:!0,actionId:iA,sourceInformation:rA,skipRendererUpdate:aA}):await this.coreFunctions.performUpdate({updateInstructions:[{componentIdx:this.componentIdx,updateType:"updateValue",stateVariable:"additionalPoints",value:IA}],actionId:iA,sourceInformation:rA,skipRendererUpdate:aA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{movedPoint:sA,intervalsFromSubset:CA,pointsFromSubset:dA,additionalPoints:IA}}});{let pA=dA.map(QA=>QA.value).indexOf(cA.value),mA=CA.map(QA=>QA[1]).indexOf(cA.value),hA=CA.map(QA=>QA[0]).indexOf(cA.value);dA[pA]={value:sA,inSubset:dA[pA].inSubset},mA!==-1&&(CA[mA]=[CA[mA][0],sA]),hA!==-1&&(CA[hA]=[sA,CA[hA][1]]);let BA=await this.createUpdateInstructions({intervalsFromSubset:CA,pointsFromSubset:dA,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:CA,pointsFromSubset:dA,additionalPoints:IA}}})}}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[gA,uA]of oA.entries())if(uA[0]<rA.value&&uA[1]>rA.value){let IA=[[uA[0],rA.value],[rA.value,uA[1]]];oA.splice(gA,1,...IA);break}}else aA.push({value:rA.value,inSubset:!0});else{let gA=aA.map(dA=>dA.value).indexOf(rA.value),uA=oA.map(dA=>dA[1]).indexOf(rA.value),IA=oA.map(dA=>dA[0]).indexOf(rA.value);uA!==-1?IA!==-1?(oA[uA]=[oA[uA][0],oA[IA][1]],oA.splice(IA,1),aA.splice(gA,1),sA.push(rA.value),lA=!0):aA[gA]={value:rA.value,inSubset:!rA.inSubset}:IA!==-1?aA[gA]={value:rA.value,inSubset:!rA.inSubset}:(aA.splice(gA,1),sA.push(rA.value),lA=!0)}let cA=await this.createUpdateInstructions({intervalsFromSubset:oA,pointsFromSubset:aA,modifiedAdditionalPoints:lA,additionalPoints:sA});return await this.coreFunctions.performUpdate({updateInstructions:cA,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],cA=[...await this.stateValues.intervalsFromSubset],gA=[...await this.stateValues.additionalPoints],uA=!1;if(rA.inSubset){let dA,CA;for(let[pA,mA]of cA.entries())if(mA[0]<=rA.left&&mA[1]>=rA.right){CA=mA,dA=pA;break}if(rA.left===CA[0])if(rA.right===CA[1]){if(cA.splice(dA,1),oA&&!oA.inSubset&&cA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(hA=>hA.value).indexOf(oA.value);lA.splice(mA,1),gA.push(oA.value),uA=!0}if(sA&&!sA.inSubset&&cA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(hA=>hA.value).indexOf(sA.value);lA.splice(mA,1),gA.push(sA.value),uA=!0}}else{if(cA[dA]=[rA.right,CA[1]],oA&&!oA.inSubset&&cA.map(mA=>mA[1]).indexOf(oA.value)===-1){let mA=lA.map(hA=>hA.value).indexOf(oA.value);lA.splice(mA,1),gA.push(oA.value),uA=!0}lA.push({value:sA.value,inSubset:!0}),gA.splice(sA.additionalPointInd,1),uA=!0}else if(rA.right===CA[1]){if(cA[dA]=[CA[0],rA.left],sA&&!sA.inSubset&&cA.map(mA=>mA[0]).indexOf(sA.value)===-1){let mA=lA.map(hA=>hA.value).indexOf(sA.value);lA.splice(mA,1),gA.push(sA.value),uA=!0}lA.push({value:oA.value,inSubset:!0}),gA.splice(oA.additionalPointInd,1),uA=!0}else{let pA=[[CA[0],rA.left],[rA.right,CA[1]]];cA.splice(dA,1,...pA),lA.push({value:oA.value,inSubset:!0}),lA.push({value:sA.value,inSubset:!0}),gA.splice(sA.additionalPointInd,1),gA.splice(oA.additionalPointInd,1),uA=!0}}else{let dA=cA.map(pA=>pA[1]).indexOf(rA.left),CA=cA.map(pA=>pA[0]).indexOf(rA.right);if(dA===-1)CA===-1?(cA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(gA.splice(sA.additionalPointInd,1),uA=!0),oA&&oA.isAdditional&&(gA.splice(oA.additionalPointInd,1),uA=!0)):(sA.inSubset?(cA[CA]=[rA.left,cA[CA][1]],gA.push(sA.value),uA=!0):cA.push([rA.left,rA.right]),oA&&oA.isAdditional&&(gA.splice(oA.additionalPointInd,1),uA=!0));else if(CA===-1)oA.inSubset?(cA[dA]=[cA[dA][0],rA.right],gA.push(oA.value),uA=!0):cA.push([rA.left,rA.right]),sA&&sA.isAdditional&&(gA.splice(sA.additionalPointInd,1),uA=!0);else if(oA.inSubset)if(sA.inSubset){let pA=[cA[dA][0],cA[CA][1]];cA.splice(dA,2,pA),gA.push(oA.value),gA.push(sA.value),uA=!0}else cA[dA]=[cA[dA][0],rA.right],gA.push(oA.value),uA=!0;else sA.inSubset?(cA[CA]=[rA.left,cA[CA][1]],gA.push(sA.value),uA=!0):cA.push([rA.left,rA.right])}let IA=await this.createUpdateInstructions({intervalsFromSubset:cA,pointsFromSubset:lA,modifiedAdditionalPoints:uA,additionalPoints:gA});return await this.coreFunctions.performUpdate({updateInstructions:IA,actionId:AA,sourceInformation:tA,skipRendererUpdate:iA,event:{verb:"interacted",object:{componentIdx:this.componentIdx,componentType:this.componentType},result:{toggledInterval:[rA.left,rA.right],intervalsFromSubset:cA,pointsFromSubset:lA,additionalPoints:gA}}})}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((cA,gA)=>cA===aA[gA]))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 missingWhenEntriesMissing=["data"];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 CA=context.fromAst("_");return{setValue:{equation:CA,coeff0:CA,coeffVar1:CA,coeffVar2:CA}}}let tA=[],iA=[];for(let CA of AA.data.stateValues.points){let pA=CA.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 CA=context.fromAst("_");return{setValue:{equation:CA,coeff0:CA,coeffVar1:CA,coeffVar2:CA}}}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))),cA=context.fromAst(subset(sA,index(1,0))),gA=context.fromAst(-1),uA=AA.variables,IA=context.fromAst(["+",["*","a","x"],"c"]).substitute({a:cA,c:lA,x:uA[0]}).simplify();return{setValue:{equation:context.fromAst(["=",uA[1].tree,"r"]).substitute({r:IA}),coeff0:lA,coeffVar1:cA,coeffVar2:gA}}},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 aA)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[cA,gA]=[0,rA(sA)].sort((uA,IA)=>uA-IA);return lA=Math.max(cA,Math.min(gA,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(),cA=sA.x2?.evaluate_to_constant();if(!(Number.isFinite(lA)&&Number.isFinite(cA)))return{};AA.flipFunctions&&([lA,cA]=[cA,lA]),lA=Math.max(tA,Math.min(iA,lA));let[gA,uA]=[rA(lA),aA(lA)].sort((IA,dA)=>IA-dA);return cA=Math.max(gA,Math.min(uA,cA)),AA.flipFunctions&&([lA,cA]=[cA,lA]),{x1:lA,x2:cA}}}}}},eA}}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:SLOPE_FIELD_DEFAULT_MARK_LENGTH,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 holdsUnenteredEdit=!0;static isValue=!0;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+=`
|
|
1422
1422
|
`),{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}){if(typeof AA.value!="string")return{success:!1};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 missingWhenComputedFromMissing=!1;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 dA=findMonomialFromFactors(tA.tree.slice(1)),CA=findMonomialFromFactors(iA.tree.slice(1));if(!dA.equals(CA)){let pA=context.fromAst(["-",CA.tree]);if(!dA.equals(pA))return{setValue:{value:!1}}}}if(AA.allowOnlySignDifferences){let dA=normalizeFactorSigns(tA),CA=normalizeFactorSigns(iA);return{setValue:{value:dA.equalsViaSyntax(CA,{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(dA=>context.fromAst(dA).variables().length>0),oA=iA.tree.slice(1).filter(dA=>context.fromAst(dA).variables().length>0);if(aA.length!==oA.length)return{setValue:{value:!1}};let sA=0,lA=0,cA=0,gA=0,uA=AA.variable.subscripts_to_strings().tree;for(let dA of aA){let CA=context.fromAst(dA).subscripts_to_strings().derivative(uA).derivative(uA).simplify();if(CA.tree===0)lA++;else if(CA.variables().length===0)sA++;else return{setValue:{value:!1}}}for(let dA of oA){let CA=context.fromAst(dA).subscripts_to_strings().derivative(uA).derivative(uA).simplify();if(CA.tree===0)gA++;else if(CA.variables().length===0)cA++;else return{setValue:{value:!1}}}return{setValue:{value:lA===gA&&sA===cA}}}},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(`
|
|
1423
|
-
`).map(uA=>uA.trim().split(",").map(IA=>IA.trim())),oA=aA[0]?.length,sA=!1;for(let uA of aA.slice(1))if(uA.length!==oA){sA=!0;break}if(sA){let uA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}let lA={},cA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(uA=>(['"',"'"].includes(uA[0])&&uA[uA.length-1]===uA[0]&&(uA=uA.substring(1,uA.length-1)),uA)),cA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(uA=>`col${uA+1}`),cA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let uA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}if(lA.columnNames.includes("")){let uA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}let gA=cA.length;lA.shape=[gA,oA];for(let uA=0;uA<oA;uA++){let IA=AA.columnTypesPrelim[uA]?.toLowerCase();if(["number","string"].includes(IA)||(IA="auto"),IA==="auto"){let dA=!1;for(let CA=0;CA<gA;CA++){let pA=cA[CA][uA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){dA=!0;break}}}dA?IA="string":IA="number"}if(IA==="number")for(let dA=0;dA<gA;dA++)cA[dA][uA]===""?cA[dA][uA]=null:cA[dA][uA]=Number(cA[dA][uA]);else for(let dA=0;dA<gA;dA++){let CA=cA[dA][uA];['"',"'"].includes(CA[0])&&CA[CA.length-1]===CA[0]&&(CA=CA.substring(1,CA.length-1)),cA[dA][uA]=CA}iA.push(IA)}return lA.data=cA,lA.columnTypes=iA,{setValue:{dataFrame:lA,numRows:gA,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(this.componentType)),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 uA=0;uA<AA.numGraphicalElements;uA++){let IA=AA[`graphicalElement${uA}`];const dA=tA.allComponentClasses[IA?.componentType]?.listEntryComponentType;dA!==void 0&&(IA={...IA,componentType:dA});let CA=AA[`graphicalElement${uA}AdapterSource`];CA&&(IA={...IA},IA.componentIdx=CA.componentIdx);let pA=AA[`graphicalElement${uA}ShadowSource`];if(pA){const mA=JSON.parse(JSON.stringify(IA));mA.componentIdx=pA.componentIdx,sA.push(mA)}sA.push(IA),dA!==void 0&&sA.push(...listEntryElementsForLabels({list:IA,listIndices:[IA.componentIdx,pA?.componentIdx],labelChildren:AA.labelChildren}))}let lA=sA.map(uA=>uA.componentIdx),cA=[],gA={};for(let uA of AA.labelChildren){let IA={value:uA.stateValues.value,hasLatex:uA.stateValues.hasLatex};if(uA.stateValues.forObjectComponentIdx){gA[uA.stateValues.forObjectComponentIdx]=IA;let dA=lA.indexOf(uA.stateValues.forObjectComponentIdx);if(dA!==-1){let CA=sA[dA];tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})?rA.push(CA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath?aA.push(CA.stateValues.styleNumber):CA.componentType!=="legend"&&oA.push(CA.stateValues.styleNumber)}}cA.push({labelInfo:IA,forObject:uA.stateValues.forObjectComponentIdx})}for(let uA of cA){let IA;if(uA.forObject){let dA=lA.indexOf(uA.forObject);dA!==-1&&(IA=sA[dA],sA.splice(dA,1),lA.splice(dA,1))}else for(let dA=0;dA<sA.length;dA++){let CA=sA[dA];if(!(CA.componentIdx in gA)){if(tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})){if(!rA.includes(CA.stateValues.styleNumber)){IA=CA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath){if(!aA.includes(CA.stateValues.styleNumber)){IA=CA;break}}else if(CA.componentType!=="legend"&&!oA.includes(CA.stateValues.styleNumber)){IA=CA;break}}}if(IA){let dA=IA.stateValues.selectedStyle,CA=IA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:"point"})?(rA.push(CA),iA.push({swatchType:"marker",markerStyle:dA.markerStyle,markerColor:dA.markerColor,markerColorDarkMode:dA.markerColorDarkMode,markerSize:dA.markerSize,lineOpacity:dA.lineOpacity,label:uA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[IA.componentType].representsClosedPath?(aA.push(CA),iA.push({swatchType:"rectangle",lineStyle:dA.lineStyle,lineColor:dA.lineColor,lineColorDarkMode:dA.lineColorDarkMode,lineWidth:dA.lineWidth,lineOpacity:dA.lineOpacity,fillColor:dA.fillColor,fillColorDarkMode:dA.fillColorDarkMode,filled:IA.stateValues.filled,fillOpacity:dA.fillOpacity,label:uA.labelInfo})):(oA.push(CA),iA.push({swatchType:"line",lineStyle:dA.lineStyle,lineColor:dA.lineColor,lineColorDarkMode:dA.lineColorDarkMode,lineWidth:dA.lineWidth,lineOpacity:dA.lineOpacity,label:uA.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 missingWhenComputedFromMissing=!1;static childGroupsReadOnce=["maths"];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"]},patternDecidedByDoenetML:{dependencyType:"decidedByDoenetML",attributeNames:["pattern","parameters"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK$2,patternVariables:tA}};let iA=AA.patternAttr.stateValues.value,rA=iA.variables(),aA=703;function oA(){let CA=numberToLetters(aA);for(aA++;rA.includes(CA);)CA=numberToLetters(aA),aA++;return CA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(iA.tree,pA=>{if(pA!==BLANK$2)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],cA=new Map,gA=new Map;for(let CA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(CA.tree);if(pA===void 0||cA.has(pA))continue;let mA=oA();cA.set(pA,mA),gA.set(mA,CA.toString()),tA.push(mA)}let uA=new Set,IA=replacePlaceholders(iA.tree,CA=>{let pA=cA.get(parameterKey(CA));return pA!==void 0&&uA.add(pA),pA}),dA=[...gA].filter(([CA])=>!uA.has(CA)).map(([CA,pA])=>pA);return dA.length>0&&lA.push(codedDiagnostic({type:levelFromSource(AA.patternDecidedByDoenetML),code:"doenet-w0117",args:{parameters:dA},position:sA})),{setValue:{pattern:IA,patternVariables:tA},conditionDiagnostics: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(cA=>rA[cA]=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(cA=>context.fromAst(cA)).some(cA=>AA.excludeMatches.some(gA=>cA.variables().some(uA=>gA.equalsViaSyntax(context.fromAst(uA)))))||(sA=!0,lA=AA.patternVariables.map(cA=>context.fromAst(oA[cA]??BLANK$2)))),{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 isValue=!1;static childGroupsReadOnce=["maths"];static childrenIgnoredBeside({fromSource:eA,added:AA,groupOf:tA}){const iA=[...eA,...AA].some(rA=>["rows","columns"].includes(tA(rA)));return AA.filter(rA=>tA(rA)==="maths"&&iA)}static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static variableForIndexAsProp="matrix";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 IA of tA)typeof IA!="string"&&(IA.doenetAttributes||(IA.doenetAttributes={}),IA.componentType==="column"?(IA.doenetAttributes.createNameFromComponentType="column",IA.componentType="matrixColumn",sA=!0):IA.componentType==="row"?(IA.doenetAttributes.createNameFromComponentType="row",IA.componentType="matrixRow",sA=!0):IA.attributes?._createComponentOfType?.primitive.value==="column"?(IA.doenetAttributes.createNameFromComponentType="column",IA.attributes._createComponentOfType.primitive.value="matrixColumn",sA=!0):IA.attributes?._createComponentOfType?.primitive.value==="row"&&(IA.doenetAttributes.createNameFromComponentType="row",IA.attributes._createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(IA));const lA=[],cA=IA=>typeof IA=="object"&&iA.componentIsSpecifiedType(IA,"math"),gA=tA.filter(IA=>typeof IA!="string"||IA.trim()!==""),uA=gA.filter(cA);return sA?uA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0194",args:{reason:"rows"}})):gA.length>1&&gA.every(cA)?(lA.push(codedDiagnostic({type:"warning",code:"doenet-w0194",args:{reason:"several"}})),oA=uA):(tA.length>1||!cA(tA[0]))&&(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,diagnostics:lA}};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"],childIndices:[-1],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,set:convertValueToMathExpression,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:[-1],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 cA of iA){let[gA,uA]=cA.split(","),IA;sA?IA=tA[cA].rowChild[0]?.stateValues["math"+(Number(uA)+1)]:lA?IA=tA[cA].colChild[0]?.stateValues["math"+(Number(gA)+1)]:IA=tA[cA].mathChild[0]?.stateValues["matrixEntry"+(Number(gA)+1)+"_"+(Number(uA)+1)],IA===void 0?oA[cA]={defaultValue:AA.defaultEntry}:aA[cA]=IA}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 cA in AA.matrixPre){let[gA,uA]=cA.split(",");sA?iA[cA].rowChild[0]?.stateValues["math"+(Number(uA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].rowChild,desiredValue:AA.matrixPre[cA],childIndex:0,variableIndex:0}):lA?iA[cA].colChild[0]?.stateValues["math"+(Number(gA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].colChild,desiredValue:AA.matrixPre[cA],childIndex:0,variableIndex:0}):iA[cA].mathChild[0]?.stateValues["matrixEntry"+(Number(gA)+1)+"_"+(Number(uA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].mathChild,desiredValue:AA.matrixPre[cA],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,set:convertValueToMathExpression,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:()=>({fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:!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"]},matrixDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths"]}}),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=[],cA=tA[2][sA+1]||[];for(let gA=0;gA<rA;gA++){let uA=cA[gA+1];if(uA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof uA=="number"||typeof uA?.re=="number"&&typeof uA?.im=="number")lA.push(uA);else try{uA=context.fromAst(uA).evaluate_to_constant(),typeof uA=="number"||typeof uA?.re=="number"&&typeof uA?.im=="number"?lA.push(uA):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:levelFromSource(AA.matrixDecidedByDoenetML),code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},conditionDiagnostics:[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 isContent=!0;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 isContent=!0;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 cA=lA.reduce((uA,IA,dA)=>uA+Math.pow(IA-nA[dA],2),0);if(cA>=tA)return{success:!1};let gA=rA(eA,AA);if(!gA)return{success:!1};if(cA=gA.reduce((uA,IA,dA)=>uA+Math.pow(IA-eA[dA],2),0),cA>=tA)return{success:!1};if(aA){let uA=iA(nA,AA),IA=uA&&uA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),dA=iA(eA,AA),CA=dA&&dA.every((pA,mA)=>Math.abs(pA-gA[mA])<oA);if(!(IA||CA)&&(cA=uA.reduce((pA,mA,hA)=>pA+Math.pow(mA-dA[hA],2),0),cA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:gA}}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:cA,nearestPoint2:gA}=oA;if(!AA){let DA=[eA[0]-nA[0],eA[1]-nA[1]],bA=[gA[0]-cA[0],gA[1]-cA[1]],NA=Math.atan2(bA[1],bA[0])-Math.atan2(DA[1],DA[0]);if(NA=mod$1(NA+Math.PI,2*Math.PI)-Math.PI,Math.abs(NA)>sA)return{success:!1}}let uA=nA.reduce((DA,bA,NA)=>DA+Math.pow(bA-eA[NA],2),0),IA=cA.reduce((DA,bA,NA)=>DA+Math.pow(bA-gA[NA],2),0);if(Math.abs(uA-IA)<lA){let DA=cA.reduce((bA,NA,wA)=>bA+Math.pow(NA-nA[wA],2),0)+gA.reduce((bA,NA,wA)=>bA+Math.pow(NA-eA[wA],2),0);return DA<iA?{success:!0,distance2:DA,segment:[cA,gA]}:{success:!1}}if(IA>uA)return{success:!1};let dA=Math.sqrt(uA/IA),CA=Math.sqrt(nA.reduce((DA,bA,NA)=>DA+Math.pow(bA-cA[NA],2),0)),pA=Math.sqrt(eA.reduce((DA,bA,NA)=>DA+Math.pow(bA-gA[NA],2),0)),mA=CA/(CA+pA),hA=1-mA,BA=(dA-1)*mA+1,QA=(dA-1)*hA+1,EA=gA.map((DA,bA)=>DA+(cA[bA]-DA)*BA),fA=cA.map((DA,bA)=>DA+(gA[bA]-DA)*QA);if(oA=findAttractedSegmentPointsSub({point1:EA,point2:fA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let yA=EA.reduce((DA,bA,NA)=>DA+Math.pow(bA-nA[NA],2),0)+fA.reduce((DA,bA,NA)=>DA+Math.pow(bA-eA[NA],2),0);return yA<iA?{success:!0,distance2:yA,segment:[EA,fA]}:{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,cA=eA?tA*1e3:tA;for(let[gA,uA]of iA.entries()){let IA=rA[gA],dA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:cA,numericalNearestPointFunction:uA,numericalNearestPointAsLineFunction:IA});dA.success&&dA.distance2<lA&&(lA=dA.distance2,sA=dA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<cA?{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],cA=(rA-tA)/sA,gA=(aA-iA)/lA,uA=cA*cA+gA*gA,IA=((nA[0]-tA)/sA*cA+(nA[1]-iA)/lA*gA)/uA;return IA<=0?[tA,iA]:IA>=1?[rA,aA]:[tA+IA*cA*sA,iA+IA*gA*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],cA=(rA-tA)/sA,gA=(aA-iA)/lA,uA=cA*cA+gA*gA,IA=((nA[0]-tA)/sA*cA+(nA[1]-iA)/lA*gA)/uA;return[tA+IA*cA*sA,iA+IA*gA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";static isContent=!0;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:gA,allowRotation:uA,enforceRigid:IA,shrinkThreshold:dA,rotationPoint:CA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),hA=[],BA=[],QA=!1,EA={distance2:1/0},fA=tA.threshold;dA&&(fA*=.2);let yA=fA*fA;for(let[DA,bA]of gA.entries()){let NA=[],wA=[];for(let vA of mA)NA.push((TA,kA)=>nearestPointForSegment({point:TA,segment:vA,scales:kA})),wA.push((TA,kA)=>nearestPointForSegmentAsLine({point:TA,segment:vA,scales:kA}));let MA=attractSegment({segment:bA,allowRotation:uA,scales:iA,threshold2:yA,numericalNearestPointFunctions:NA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(hA.push(MA.segment),BA.push(!0),QA=!0):(hA.push(bA),BA.push(!1),!QA&&MA.distance2<EA.distance2&&(EA=MA,EA.edgeInd=DA))}if(uA&&IA&&!QA&&EA.distance2<1/0){let DA=EA.edgeInd,bA=rotateIfClose({attractedEdgeInd:DA,attractingSegment:EA.segment,angleThreshold:rA,rotationPoint:CA,numericalUnconstrainedEdges:gA});bA&&(hA[DA]=bA,BA[DA]=!0,QA=!0)}if(uA&&IA&&!QA){let DA=[0,Math.PI/2],bA=rotateToAttractAngles({numericalUnconstrainedEdges:gA,anglesToAttract:DA,angleThreshold:rA,rotationPoint:CA});if(bA){let NA=bA.rotatedEdgeInd;hA[NA]=bA.rotatedEdge,BA[NA]=!0,QA=!0}}return{numericalConstrainedEdges:hA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:gA,closed:uA,shrinkThreshold:IA,onlyMoveVertexInd:dA=null},{objectInd:CA}){let pA=tA.getPointsForObject(CA),mA=tA.getSegmentsForObject(CA),hA=[],BA=[],QA=tA.threshold;IA&&(QA*=.2);let EA=QA*QA;for(let[bA,NA]of gA.entries()){if(dA!==null&&bA!==dA){hA.push(NA),BA.push(!1);continue}let wA=1/0,MA={};for(let kA of pA){if(NA.length!==kA.length)continue;let OA=NA.reduce((FA,GA,RA)=>FA+Math.pow((GA-kA[RA])/iA[RA],2),0);OA<wA&&(MA=kA,wA=OA)}let vA=!1,TA;if(wA<EA)vA=!0,TA=MA;else{wA=1/0,MA={};for(let kA of mA){let OA=nearestPointForSegment({point:NA,segment:kA,scales:iA});if(OA){let FA=NA.reduce((GA,RA,jA)=>GA+Math.pow((RA-OA[jA])/iA[jA],2),0);FA<wA&&(MA=OA,wA=FA)}}wA<EA?(vA=!0,TA=MA):TA=NA}hA.push(TA),BA.push(vA)}let fA=gA.length,yA=uA?fA:fA-1,DA=[];for(let bA=0;bA<yA;bA++){let NA=(bA+1)%fA;if(!(dA!==null&&!(dA===bA||dA===NA))&&!(BA[bA]||BA[NA])){let wA=gA[bA],MA=gA[NA],vA,TA=1/0;for(let kA of pA){let OA=nearestPointForSegment({point:kA,segment:[wA,MA],scales:iA});if(OA){let FA=OA.reduce((GA,RA,jA)=>GA+Math.pow(RA-kA[jA],2),0);if(FA<TA)if(dA===null){let GA=wA.map((jA,WA)=>jA+kA[WA]-OA[WA]),RA=MA.map((jA,WA)=>jA+kA[WA]-OA[WA]);vA=[GA,RA],TA=FA}else{let GA;dA===bA?GA=MA:GA=wA;let RA=[kA[0]-GA[0],kA[1]-GA[1]],jA=Math.sqrt(Math.pow(RA[0],2)+Math.pow(RA[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 xA=GA.map((HA,KA)=>HA+RA[KA]*zA),$A;dA===bA?($A=[xA,MA],FA=Math.pow(wA[0]-xA[0],2)+Math.pow(wA[1]-xA[1],2)):($A=[wA,xA],FA=Math.pow(MA[0]-xA[0],2)+Math.pow(MA[1]-xA[1],2)),FA<TA&&(TA=FA,vA=$A)}}}TA<EA&&DA.push({vertexInd1:bA,vertexInd2:NA,distance2:TA,movedSegment:vA})}}DA.sort((bA,NA)=>bA.distance2-NA.distance2);for(let{vertexInd1:bA,vertexInd2:NA,movedSegment:wA}of DA)BA[bA]||BA[NA]||(BA[bA]=!0,BA[NA]=!0,hA[bA]=wA[0],hA[NA]=wA[1]);return{numericalConstrainedVertices:hA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:gA,closed:uA,enforceRigid:IA,allowRotation:dA,rotationPoint:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA}){let BA=sA({unconstrainedVertices:gA,closed:uA,enforceRigid:IA,allowRotation:dA,rotationPoint:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA});return BA=lA({unconstrainedVertices:BA,closed:uA,enforceRigid:IA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA}),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(IA=>findFiniteNumericalValue(IA)),lA=tA.getPointsForObject(oA),cA=tA.getSegmentsForObject(oA),gA=1/0,uA={};for(let IA of lA){if(sA.length!==IA.length)continue;let dA=sA.reduce((CA,pA,mA)=>CA+Math.pow((pA-IA[mA])/iA[mA],2),0);dA<gA&&(uA=IA,gA=dA)}if(gA<tA.threshold*tA.threshold)return uA.map(IA=>context.fromAst(IA));gA=1/0,uA={};for(let IA of cA){let dA=nearestPointForSegment({point:sA,segment:IA,scales:iA});if(dA){let CA=sA.reduce((pA,mA,hA)=>pA+Math.pow((mA-dA[hA])/iA[hA],2),0);CA<gA&&(uA=dA,gA=CA)}}return gA<tA.threshold*tA.threshold?uA.map(IA=>context.fromAst(IA)):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[gA,uA]of nA.entries()){let IA=Math.atan((uA[1][1]-uA[0][1])/(uA[1][0]-uA[0][0]));for(let dA of eA){let CA=mod$6(dA-IA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(CA)<Math.abs(iA)&&(iA=CA,rA=gA)}}if(!(Math.abs(iA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(iA),lA=Math.sin(iA),cA=nA[rA].map(gA=>{let uA=gA[0]-aA,IA=gA[1]-oA;return[uA*sA-IA*lA+aA,uA*lA+IA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:cA}}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,cA]=tA,gA=Math.cos(sA),uA=Math.sin(sA);return iA[nA].map(dA=>{let CA=dA[0]-lA,pA=dA[1]-cA;return[CA*gA-pA*uA+lA,CA*uA+pA*gA+cA]})}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 IA=0;IA<rA;IA++)iA.has(IA)||(oA[IA]=sA,sA++);const lA=[],cA=tA==="circuit"?aA===1?0:1:null;for(let IA=0;IA<rA;IA++){const dA=nA[IA],CA=eA[IA]??"";if(iA.has(dA)){if(!isDistractorResponse(CA))return 0;continue}const pA=parseIntegerResponse(CA);if(pA===null)return 0;const mA=oA[dA],hA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(hA!==cA)return 0;continue}lA.push(hA)}if(tA==="circuit")return 1;const gA=lA[0];return lA.every(IA=>IA===gA)?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 isContent=!0;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 attributesDeterminingChoices=["mode"];static choiceChildTypes=["problem"];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 preprocessSerializedChildren({serializedChildren:eA,attributes:AA}){const tA=[...eA.keys()].filter(uA=>eA[uA]?.componentType==="_pretzelArranger");if(tA.length<2)return;const iA=eA[tA[0]],rA=tA.slice(1).map(uA=>eA[uA]);for(const uA of tA.slice(1).reverse())eA.splice(uA,1);const aA=rA.flatMap(uA=>uA.children??[]),oA=aA.some(uA=>uA?.componentType==="problem"),sA=rA.findLast(uA=>uA.attributes?.mode)?.attributes.mode;if(!!iA.downstreamDependencies){iA.attributes.mode?AA.mode=iA.attributes.mode:delete AA.mode;return}if(iA.children=[...iA.children??[],...aA],sA&&(iA.attributes.mode=sA),!iA.variants?.desiredVariant)return;iA.variants={...iA.variants,mergedArrangers:rA.map(uA=>({componentIdx:uA.componentIdx,childIdxs:(uA.children??[]).filter(IA=>typeof IA=="object").map(IA=>IA.componentIdx)}))};const cA={...iA.variants.desiredVariant};iA.variants={...iA.variants,desiredVariant:cA};const gA=cA.indices;if(gA&&(oA||sA?.primitive.value.toLowerCase()==="circuit"&&Number(gA[0])!==1)&&delete cA.indices,oA){delete cA.seed;const uA=rA.find(dA=>dA.variants?.desiredVariant?.seed!==void 0)?.variants.desiredVariant;uA&&(cA.seed=uA.seed,uA.indices&&(cA.indices=uA.indices));const IA=rA.flatMap(dA=>dA.variants?.desiredVariant?.subvariants??[]);cA.subvariants&&IA.length>0&&(cA.subvariants=[...cA.subvariants,...IA])}}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={};for(let iA=0;iA<AA.numSubmittedResponses;iA++)tA[iA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:tA}}},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.insideSectionWideCheckWork={returnDependencies:()=>({ancestorSuppressingAnswerSubmitButtons:{dependencyType:"ancestor",variableNames:["suppressAnswerSubmitButtons","numAttemptsLeft"]}}),definition({dependencyValues:AA}){return{setValue:{insideSectionWideCheckWork:!!AA.ancestorSuppressingAnswerSubmitButtons?.stateValues.suppressAnswerSubmitButtons}}}},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,usesContainerAttempt:iA=!1}){const rA=await this.stateValues.numAttemptsLeft;if(rA<1||await this.stateValues.disabled)return;const oA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let sA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:oA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],lA=await this.stateValues.currentResponses;sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:lA}),sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies});const cA=await this.stateValues.numSubmissions+1;sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:cA}),oA<1&&sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const gA=[];for(const uA of lA)if(uA.toString)try{gA.push(uA.toString())}catch{gA.push("_")}else gA.push(uA);return sA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:lA,responseText:gA,creditAchieved:oA}),await this.coreFunctions.performUpdate({updateInstructions:sA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:lA,responseText:gA,componentTypes:Array(lA.length).fill("text"),creditAchieved:oA,...attemptCountsForEvent({numSubmissions:cA,maxNumAttempts:await this.stateValues.maxNumAttempts,numAttemptsLeftBefore:rA,usesAttempt:!await this.stateValues.insideSectionWideCheckWork||iA})}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function isProblemCopy({child:nA,componentInfoObjects:eA}){return typeof nA=="object"&&eA.isInheritedComponentType({inheritedComponentType:nA.componentType,baseComponentType:"_composite"})&&nA.attributes._createComponentOfType?.primitive.value==="problem"}function problemChildren(nA){return nA.filter(eA=>eA.componentType==="problem")}function arrangedParts(nA){let eA=null,AA=null;for(const tA of nA.children)if(tA.componentType==="statement")eA=tA;else if(tA.componentType==="givenAnswer"){const iA=tA.children.find(rA=>rA.componentType==="_postponeRenderContainer");iA&&(AA={...iA,componentType:"span",attributes:{...iA.attributes},children:(iA.children??[]).filter(rA=>rA.componentType!=="label"&&rA.componentType!=="shortDescription")},AA.componentIdx=tA.componentIdx,tA.attributes.name&&(AA.attributes.name=tA.attributes.name))}return{statement:eA,givenAnswer:AA}}function arrangedContent(nA){const eA=[];for(const AA of problemChildren(nA)){const{statement:tA,givenAnswer:iA}=arrangedParts(AA);tA&&eA.push(tA),iA&&eA.push(iA)}return eA}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 replacementsAlreadyInResolver=!0;static mapShadowedReplacementIndicesThroughSerializedChildren=!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,componentInfoObjects:tA}){const iA=[];return AA.serializedChildren.some(rA=>isProblemCopy({child:rA,componentInfoObjects:tA}))&&iA.push(codedDiagnostic({type:"warning",code:"doenet-w0176"})),{setValue:{serializedProblemChildren:problemChildren(AA.serializedChildren)},sendDiagnostics:iA}}},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"},variants:{dependencyType:"variants"},variantDescendants:{dependencyType:"descendant",componentTypes:variantDescendantComponentTypes(AA),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=[];for(let sA of AA.variantDescendants)sA.stateValues.isVariantComponent?rA.push(sA.stateValues.generatedVariantInfo):sA.stateValues.generatedVariantInfo&&rA.push(...sA.stateValues.generatedVariantInfo.subvariants);const aA=AA.variants?.arrangedVariantComponentIdxs,oA=new Map(rA.map(sA=>[sA.meta?.createdBy,sA]));return aA?.length===rA.length&&aA.every(sA=>oA.has(sA))&&(rA=aA.map(sA=>oA.get(sA))),iA.subvariants=rA,{setValue:{generatedVariantInfo:iA,isVariantComponent:!0}}}},eA.variantsOfMergedComponents={returnDependencies:()=>({generatedVariantInfo:{dependencyType:"stateVariable",variableName:"generatedVariantInfo"},variants:{dependencyType:"variants"}}),definition({dependencyValues:AA}){const{seed:tA,indices:iA,subvariants:rA}=AA.generatedVariantInfo,aA=new Map(rA.map(sA=>[sA.meta?.createdBy,sA])),oA={};for(const sA of AA.variants?.mergedArrangers??[])oA[sA.componentIdx]={seed:tA,indices:iA,subvariants:(sA.variantComponentIdxs??[]).map(lA=>aA.get(lA)??{})};return{setValue:{variantsOfMergedComponents:oA}}}},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()){const{statement:cA,givenAnswer:gA}=arrangedParts(lA);(cA===null||gA===null)&&(aA=!1),tA.push(cA),iA.push(gA),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,cA=await eA.stateValues.givenAnswers,gA=await eA.stateValues.distractors,uA=await eA.stateValues.mode,IA=new Set(gA);for(let dA=0;dA<oA;dA++){const CA=sA[dA]-1,pA=lA[CA],mA=getCorrespondingAnswerIdx({problemIdx:CA,numProblems:oA,distractorSet:IA}),hA=cA[mA];hA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(hA),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:uA==="circuit"&&dA===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,core:tA}){const iA=gatherVariantComponents({serializedComponents:arrangedContent(eA.children),componentInfoObjects:tA.componentInfoObjects});setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:iA}),eA.variants??={},eA.variants.arrangedVariantComponentIdxs=iA.map(aA=>aA.componentIdx);const rA=eA.variants.mergedArrangers;if(rA){const aA=eA.children??[];eA.variants.mergedArrangers=rA.map(oA=>({...oA,variantComponentIdxs:gatherVariantComponents({serializedComponents:arrangedContent(aA.filter(sA=>oA.childIdxs.includes(sA?.componentIdx))),componentInfoObjects:tA.componentInfoObjects}).map(sA=>sA.componentIdx)}))}}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(isProblemCopy({child:lA,componentInfoObjects:AA}))continue;return{success:!1}}let aA=determineNumberOfPermutations({numProblems:iA,mode:rA});eA.variants??={};let oA=super.determineNumberOfUniqueVariants({serializedComponent:{...eA,children:arrangedContent(eA.children)},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 cA=[...rA];cA.push(oA);let gA=combinationAtIndex({numberOfOptionsByIndex:cA,index:AA-1}).map(BA=>BA+1),uA=gA.pop(),IA=gA;const dA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),CA=buildProblemOrderFromPermutedIndices({permutedIndices:permutationAtIndex({values:dA,index:uA-1}),numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let QA=aA[BA],fA=tA.allComponentClasses[QA.componentType].getUniqueVariant({serializedComponent:QA,variantIndex:IA[BA],componentInfoObjects:tA});if(!fA.success)return{success:!1};mA.push(fA.desiredVariant),pA=!0}else mA.push({});let hA={indices:CA};return pA&&(hA.subvariants=mA),{success:!0,desiredVariant:hA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static isContent=!0;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(cA=>iA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:cA}))&&!["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(gA=>gA.componentType==="cascadeMessage").map(gA=>gA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[gA,uA]of tA.children.entries())gA<=tA.numCompleted?tA.hideChildren&&aA.push(uA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(IA=>iA.isInheritedComponentType({inheritedComponentType:uA.componentType,baseComponentType:IA}))?oA.push(uA.componentIdx):aA.push(uA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,cA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(gA=>gA!==cA)),{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 isContent=!0;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}),cA=lA.replacements;AA=lA.nComponents,aA.push(...cA)}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","valueMissing"],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 cA=lA[1];if(cA in unitConversions){let gA=sA.slice(0,lA.index),uA=tA.slice(0,tA.length-1);return gA.length>0&&uA.push(gA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:uA,attributes:{},doenetAttributes:{},state:{}},cA],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 gA=iA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(gA===null)return{setValue:{componentSize:null}};aA=gA[1],oA=gA[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();const AA=returnGroupIntoListEntriesOfComponentType({componentType:"componentSize",forceComponentType:!0,includeNonMacros:!0});let tA=function({matchedChildren:iA,componentInfoObjects:rA,nComponents:aA,stateIdInfo:oA,parentComponentType:sA}){return AA({matchedChildren:iA,componentInfoObjects:rA,nComponents:aA,stateIdInfo:oA,parentComponentType:sA})};return eA.push({replacementFunction:tA}),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 cA=0;cA<lA.stateValues.numComponents;cA++)rA[iA+cA]=[oA,cA];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 cA=iA[lA].componentSizeAndComponentSizeListChildren[0];cA&&(oA.isInheritedComponentType({inheritedComponentType:cA.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 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.drawnMissing?BLANK_RENDERER_TYPE: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,gestureId:tA,sourceInformation:iA={},skipRendererUpdate:rA=!1}={}){const aA=this.fixedReferent??await this.stateValues.referentInfo;!aA||await this.stateValues.fixed||await this.coreFunctions.triggerChainedActions({triggeringAction:eA.endsWith("Clicked")?"click":"focus",componentIdx:aA.componentIdx,actionId:AA,gestureId:tA,sourceInformation:iA,skipRendererUpdate:rA})}_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;rA.valueMissing={dependencyType:"stateVariable",variableName:"valueMissing"};const oA=aA.fixedReferent??iA.referentInfo;return(aA.doenetAttributes.copiesReferent||aA.doenetAttributes.hiddenWithReferent)&&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.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,AA.holdsValue=!0,eA.withoutReaderState||(AA.initialEssentialState={...AA.initialEssentialState??{},...deepClone(AA.state)})}return AA}returnMatchedChildIndices(){return[]}createOnDemandStateVariableDefinitions({stateVariable:eA,classDefinitions:AA}){if(eA==="valueMissing")return[[eA,this.fixedReferent?fixedReferentMissingDefinition(this.fixedReferent):valueMissingDefinition()]];if(eA==="namesNothing")return[[eA,namesNothingDefinition(this.fixedReferent,this.componentInfoObjects)]];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),listEntrySourceOf:referentListEntrySource,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 cA=this.componentInfoObjects.stateVariableInfo[this.presentedComponentType].arrayEntryPrefixes,gA=Object.keys(cA).filter(uA=>oA.startsWith(uA)).sort((uA,IA)=>IA.length-uA.length)[0];if(gA!==void 0&&(oA=cA[gA].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(cA=>[cA,Object.create(aA[cA])])}}const VALUE_REFERENCE_DOENET_ATTRIBUTES=["presentedComponentType","referencedComponentType","adapterVariable","fixedReferent","copiesReferent","hiddenWithReferent","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}}}function referentListEntrySource(nA,eA){const AA=nA.fixedReferent??eA.referentInfo;if(AA?.listEntryPosition===void 0)return;const tA=nA.componentInfoObjects.allComponentClasses[AA.componentType]?.listEntryContextArrays;if(tA)return{componentIdx:AA.componentIdx,index:AA.listEntryPosition-1,variables:tA}}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={valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA?.referencedWholeComponent?rA.wholeReferent=wholeReferentResponseDependency(iA):iA&&(rA.referenced={dependencyType:"stateVariable",componentIdx:iA.componentIdx,variableName:iA.referencedVariable,variablesOptional:!0}),rA},definition({dependencyValues:tA,componentInfoObjects:iA}){if(tA.valueMissing)return{setValue:{valueAsResponse:missingResponseValue(missingResponseType(tA,nA),iA)}};if(tA.wholeReferent)return{setValue:{valueAsResponse:wholeReferentResponse(tA.wholeReferent).value}};let rA=tA.referenced;return rA==null&&(rA=emptyValueOfType(nA,iA)),{setValue:{valueAsResponse:rA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function componentTypeAsResponseDefinition(nA,eA){const AA={returnDependencies({stateValues:tA={}}){const iA=eA??tA.referentInfo,rA={valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA?.referencedWholeComponent&&(rA.wholeReferent=wholeReferentResponseDependency(iA)),rA},definition({dependencyValues:tA}){let iA=nA;return tA.valueMissing?iA=missingResponseType(tA,nA):tA.wholeReferent&&(iA=wholeReferentResponse(tA.wholeReferent).componentType),{setValue:{componentTypeAsResponse:iA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function missingResponseType(nA,eA){return nA.wholeReferent?nA.wholeReferent.stateValues?.componentType??nA.wholeReferent.componentType??"math":eA===void 0||eA==="_missing"?"math":eA}function wholeReferentResponseDependency(nA){return{dependencyType:"multipleStateVariables",componentIdx:nA.componentIdx,variableNames:["value","formula","componentType"],variablesOptional:!0}}function wholeReferentResponse(nA){const eA=nA.stateValues??{};return eA.value!==void 0?{value:eA.value,componentType:eA.componentType??nA.componentType}:eA.formula instanceof context.class?{value:eA.formula,componentType:"math"}:{value:"",componentType:"text"}}function fixedReferentMissingDefinition(nA){return{returnDependencies:()=>({targetMissing:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"valueMissing",variablesOptional:!0},...nA.listEntryPosition===void 0?{}:{entryMissing:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:`entryMissing${nA.listEntryPosition}`,variablesOptional:!0}}}),definition({dependencyValues:eA}){return{setValue:{valueMissing:!!eA.targetMissing||!!eA.entryMissing}}}}}function namesNothingDefinition(nA,eA){return{...nA?{}:{stateVariablesDeterminingDependencies:["referentInfo"]},returnDependencies({stateValues:AA={}}){const tA=nA??AA.referentInfo;if(!tA)return{};const iA={hasReferent:{dependencyType:"value",value:!0}};if(tA.listEntryPosition!==void 0)iA.entry={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:tA.variableName,variablesOptional:!0},iA.entryMissing={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:`entryMissing${tA.listEntryPosition}`,variablesOptional:!0};else{const rA=eA.allComponentClasses[tA.componentType],aA=["namesNothing"];rA?.missingWhenContentMissing&&aA.push("contentMissing"),rA?.missingWhenContentNamesNothing&&(tA.referencedWholeComponent||tA.referencedPrimaryValue)&&aA.push("contentNamesNothing");for(const oA of aA)iA[oA]={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:oA,variablesOptional:!0}}return iA},definition({dependencyValues:AA}){return{setValue:{namesNothing:!AA.hasReferent||"entry"in AA&&AA.entry==null||!!AA.entryMissing||!!AA.namesNothing||!!AA.contentMissing||!!AA.contentNamesNothing}}}}}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 rA of AA)tA[rA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(rA)+1)}};return{dependenciesByKey:tA,globalDependencies:{variablesDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths","strings"]}}}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA}){let rA={},aA={},oA={};for(let sA of iA){let lA=tA[sA].math,cA=isValidVariable(lA);oA[sA]=[],cA||(oA[sA].push(codedDiagnostic({type:levelFromSource(AA.variablesDecidedByDoenetML),code:"doenet-w0017",args:{value:lA.toString()}})),cA=!1),rA[sA]=lA,aA[sA]=cA}return{setValue:{variables:rA,validVariables:aA},conditionDiagnosticsByKey:oA}}},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"},valueDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths","strings"]}}),definition({dependencyValues:AA}){let tA=[],iA=isValidVariable(AA.valuePreValidate);return iA||tA.push(codedDiagnostic({type:levelFromSource(AA.valueDecidedByDoenetML),code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:iA},conditionDiagnostics: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,isAttributeComponent:aA,parentComponentType:oA}){let sA=breakIntoBracketedListEntries({componentList:tA,removeBrackets:!0});return sA.success!==!0?{success:!1,diagnostics:sA.unmatchedBrackets?[listBracketsUnmatchedDiagnostic(aA?oA:"_listOfNumberLists",!1)]:[]}:{success:!0,newChildren:sA.pieces.map(lA=>({type:"serialized",componentType:"numberList",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:lA,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 cA=0;cA<oA;cA++){let gA=AA.unnormalizedDirection.get_component(cA).evaluate_to_constant();if(Number.isFinite(gA))aA.push(gA),sA+=gA*gA;else{lA=!1;break}}if(lA){let cA=Math.sqrt(sA);for(let gA=0;gA<oA;gA++)iA[gA.toString()]=context.fromAst(aA[gA]/cA)}else for(let cA=0;cA<oA;cA++)iA[cA.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 Missing extends InlineComponent{static componentType="_missing";static rendererType=BLANK_RENDERER_TYPE;static excludeFromSchema=!0;static returnStateVariableDefinitions(){const eA=super.returnStateVariableDefinitions();return eA.valueMissing={returnDependencies:()=>({}),definition:()=>({setValue:{valueMissing:!0}})},eA.namesNothing={returnDependencies:()=>({}),definition:()=>({setValue:{namesNothing:!0}})},eA.text={returnDependencies:()=>({}),definition:()=>({setValue:{text:MISSING_TEXT}})},eA.value={returnDependencies:()=>({}),definition:()=>({setValue:{value:context.fromAst(MISSING_TEXT)}})},eA.canBeModified={returnDependencies:()=>({}),definition:()=>({setValue:{canBeModified:!1}})},eA.unordered={returnDependencies:()=>({}),definition:()=>({setValue:{unordered:!1}})},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(SelectionParameter$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,Missing,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 cA in nA)AA[cA.toLowerCase()]=cA;function tA(cA){return Object.hasOwn(nA,cA)?cA:void 0}const iA={};for(const cA in nA)Object.defineProperty(iA,cA,{get:(function(){const gA=nA[cA].returnStateVariableInfo();return delete iA[cA],iA[cA]=gA}).bind(this),configurable:!0});const rA={};for(const cA in nA)Object.defineProperty(rA,cA,{get:(function(){const gA=nA[cA].returnStateVariableInfo({onlyPublic:!0});return delete rA[cA],rA[cA]=gA}).bind(this),configurable:!0});function aA({inheritedComponentType:cA,baseComponentType:gA}){if(cA===gA)return!0;if(cA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let uA=nA[gA];return uA?uA.isPrototypeOf(nA[cA]):!1}function oA({componentType:cA,includeNonStandard:gA=!0}){const uA=nA[cA];return uA?aA({inheritedComponentType:cA,baseComponentType:"_composite"})&&(gA||!uA.treatAsComponentForRecursiveReplacements):!1}const sA=(cA,gA)=>aA({inheritedComponentType:cA,baseComponentType:gA});return{allComponentClasses:nA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,componentTypeAsWritten:tA,isInheritedComponentType:aA,isCompositeComponent:oA,stateVariableInfo:iA,publicStateVariableInfo:rA,componentIsSpecifiedType:(cA,gA)=>sA(cA.componentType,gA)||cA.attributes?._createComponentOfType?.primitive!==void 0&&sA(cA.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)}function referenceOf(nA){const eA=nA.extending;if(eA)return eA.Ref??eA.ExtendAttribute??eA.CopyAttribute??eA.CopyWithStateAttribute}function authoredComponents(nA){const eA=new Map,AA=new Map;function tA(iA){if(typeof iA!="object"||iA===null||eA.has(iA.componentIdx))return;eA.set(iA.componentIdx,iA),AA.set(iA.componentIdx,AA.size);for(const aA of Object.values(iA.attributes??{})){aA?.component&&tA(aA.component);for(const oA of aA?.references??[])tA(oA);for(const oA of aA?.children??[])tA(oA)}const rA=referenceOf(iA);for(const aA of rA?.unresolvedPath??[])for(const oA of aA?.index??[])for(const sA of oA?.value??[])tA(sA);for(const aA of iA.children??[])tA(aA)}return tA(nA),{byIdx:eA,order:AA}}function authoredNodesOf(nA,eA,AA){const tA=new Set,iA=new Set,rA=[nA];for(;rA.length>0;){const aA=rA.pop();if(iA.has(aA))continue;if(iA.add(aA),eA.has(aA)){tA.add(aA);continue}const oA=AA[aA];if(!oA)continue;oA.madeFromIdx!==void 0&&rA.push(oA.madeFromIdx);const sA=oA.replacementOf?.componentIdx??oA.shadows?.componentIdx??oA.parentIdx;sA!==void 0&&rA.push(sA)}return tA}function isOfAttributeWritten(nA,eA){return Object.keys(nA.attributes??{}).some(AA=>{const tA=AA.toLowerCase();return eA===tA||eA.startsWith(`__${tA}_`)})}function authoredOwnerOf(nA,eA,AA,tA){const iA=new Set,rA=[];let aA=nA;for(;aA!==void 0&&!iA.has(aA);){if(AA.has(aA))return{owner:aA,passed:rA};iA.add(aA);const oA=tA[aA];let sA=oA?.replacementOf?.componentIdx;const lA=new Set;for(;sA!==void 0&&!AA.has(sA)&&!lA.has(sA);)lA.add(sA),sA=tA[sA]?.madeFromIdx;const cA=sA===void 0?void 0:AA.get(sA);if(cA?.componentType==="_copy"&&oA?.madeFromIdx!==void 0&&isOfAttributeWritten(cA,eA)){const gA=authoredOwnerOf(oA.madeFromIdx,eA,AA,tA);return gA.owner!==void 0&&rA.push(gA.owner),rA.push(...gA.passed),{owner:cA.componentIdx,passed:rA}}cA?.componentType==="_copy"&&oA?.madeFromIdx!==void 0&&rA.push(cA.componentIdx),aA=oA?.madeFromIdx}return{owner:void 0,passed:rA}}function blameLoadCycle({componentIndices:nA,stateVariables:eA=[],components:AA,document:tA,componentInfoObjects:iA}){const{byIdx:rA,order:aA}=authoredComponents(tA),oA=new Set;for(const mA of nA)for(const hA of authoredNodesOf(mA,rA,AA))hA!==tA.componentIdx&&oA.add(hA);const sA=new Map;function lA(mA){let hA=sA.get(mA);return hA||(hA=new Set,sA.set(mA,hA)),hA}for(const[mA,hA]of eA){if(typeof hA!="string")continue;const BA=hA.toLowerCase(),{owner:QA,passed:EA}=authoredOwnerOf(mA,BA,rA,AA);if(QA!==void 0){lA(QA).add(BA);for(const fA of EA)lA(fA)}}const cA=[...oA].sort((mA,hA)=>aA.get(mA)-aA.get(hA));function gA(mA,hA){return iA.isInheritedComponentType({inheritedComponentType:mA,baseComponentType:hA})}function uA(mA){return mA.componentType==="_copy"||mA.componentType==="_ref"}function IA(mA){if(!uA(mA))return!1;const hA=referenceOf(mA),BA=hA?.unresolvedPath?.[0]?.name;if(typeof BA!="string"||!NUMBER_PROPERTIES.has(BA.toLowerCase()))return!1;const QA=rA.get(hA.nodeIdx);return QA!==void 0&&oA.has(QA.componentIdx)&&gA(QA.componentType,"_sectioningComponent")}const dA=cA.find(mA=>IA(rA.get(mA)));if(dA!==void 0)return{blamed:dA,onCycle:oA,variablesOnCycle:sA};const CA=cA.filter(mA=>uA(rA.get(mA))||iA.isCompositeComponent({componentType:rA.get(mA).componentType,includeNonStandard:!0})),pA=CA.find(mA=>sA.get(mA)?.size!==0)??CA[0];if(pA!==void 0)return{blamed:pA,onCycle:oA,variablesOnCycle:sA};if(cA.length!==0)return{blamed:cA[0],onCycle:oA,variablesOnCycle:sA}}const MAX_LOAD_CYCLE_REBUILDS=5;function madeAnError(nA,eA){const AA=[nA];for(;AA.length>0;){const tA=AA.pop();if(typeof tA!="object"||tA===null)continue;if(tA.componentIdx===eA)return tA.componentType==="_error";for(const aA of Object.values(tA.attributes??{}))AA.push(aA?.component,...aA?.references??[],...aA?.children??[]);const iA=tA.extending,rA=iA?.Ref??iA?.ExtendAttribute??iA?.CopyAttribute??iA?.CopyWithStateAttribute;for(const aA of[rA?.unresolvedPath,rA?.originalPath])for(const oA of aA??[])for(const sA of oA?.index??[])AA.push(...sA?.value??[]);AA.push(...tA.children??[])}return!1}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:cA,saveResolver:gA,restoreResolver:uA,releaseSavedResolver:IA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=cA,this.saveResolver=gA,this.restoreResolver=uA,this.releaseSavedResolver=IA,this._normalizedRootForRebuild=void 0;let dA=createComponentInfoObjects();gA&&uA&&(gA(),this._normalizedRootForRebuild=structuredClone(rA));const{document:CA,nComponents:pA,diagnostics:mA,sources:hA}=await normalizedDastToSerializedComponents(rA,dA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,serializedDocument:CA,nComponentsInit:pA,allDoenetMLs:hA,preliminaryDiagnostics:mA,componentInfoObjects:dA},this.initialized=!0;let BA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,mA);const QA=this.coreBaseArgs.serializedDocument.children.reduce((EA,fA)=>(typeof fA=="object"&&(EA[fA.componentType]=(EA[fA.componentType]??0)+1),EA),{});return{allPossibleVariants:BA,baseComponentCounts:QA}}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){const cA=lA.serializedDocument;this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{let gA;try{gA=await this.core.generateDast()}catch(uA){if(!(uA instanceof CircularDependencyError))throw uA;gA=await this.rebuildAroundLoadCycle(uA,cA,lA)}return{success:!0,...gA}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}finally{this._releaseRebuildData()}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async rebuildAroundLoadCycle(eA,AA,tA){const iA=this._normalizedRootForRebuild;if(!iA||!this.restoreResolver||!AA)throw eA;this._normalizedRootForRebuild=void 0;const rA=[];let aA=AA;for(let oA=1;oA<=MAX_LOAD_CYCLE_REBUILDS;oA++){const sA=this.core,lA=blameLoadCycle({componentIndices:eA.componentIndices,stateVariables:eA.stateVariables,components:sA._components,document:aA,componentInfoObjects:tA.componentInfoObjects});if(lA===void 0||(rA.push(lA),sA.abandonLoad(),this.core=null,!this.restoreResolver()))throw eA;const{document:cA,nComponents:gA,diagnostics:uA}=await normalizedDastToSerializedComponents(oA<MAX_LOAD_CYCLE_REBUILDS?structuredClone(iA):iA,tA.componentInfoObjects,this.addNodesToResolver,{loadCycles:rA});if(rA.some(IA=>IA.made===void 0||!madeAnError(cA,IA.made))||new Set(rA.map(IA=>IA.made)).size<rA.length)throw eA;await returnAllPossibleVariants(cA,tA.componentInfoObjects,uA),this.core=new Core({...tA,serializedDocument:cA,nComponentsInit:gA,preliminaryDiagnostics:uA});try{return await this.core.generateDast()}catch(IA){if(!(IA instanceof CircularDependencyError))throw IA;eA=IA,aA=cA}}throw eA}_releaseRebuildData(){this._normalizedRootForRebuild=void 0,this.releaseSavedResolver?.()}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 cA in sA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(cA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType})&&!sA.isExpanded)continue;const gA=await sA.state[cA].value;lA.stateValues[cA]=AA?gA:removeFunctionsMathExpressionClass(gA)}lA.activeChildren=sA.activeChildren.map(cA=>cA.componentIdx?{componentIdx:cA.componentIdx,componentType:cA.componentType}:cA),sA.replacements&&(lA.replacements=sA.replacements.map(cA=>cA.componentIdx?{componentIdx:cA.componentIdx,componentType:cA.componentType}:cA),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,cA=aA.l,gA=aA.a,uA=aA.b,IA=180/Math.PI,dA=Math.PI/180,CA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(gA,2)+Math.pow(uA,2),.5),mA=(oA+cA)/2,hA=Math.pow((CA+pA)/2,7),BA=.5*(1-Math.pow(hA/(hA+Math.pow(25,7)),.5)),QA=sA*(1+BA),EA=gA*(1+BA),fA=Math.pow(Math.pow(QA,2)+Math.pow(lA,2),.5),yA=Math.pow(Math.pow(EA,2)+Math.pow(uA,2),.5),DA=(fA+yA)/2,bA=QA===0&&lA===0?0:Math.atan2(lA,QA)*IA,NA=EA===0&&uA===0?0:Math.atan2(uA,EA)*IA;bA<0&&(bA+=360),NA<0&&(NA+=360);var wA=NA-bA,MA=Math.abs(NA-bA);MA>180&&NA<=bA?wA+=360:MA>180&&NA>bA&&(wA-=360);var vA=bA+NA;MA<=180?vA/=2:vA=(bA+NA<360?vA+360:vA-360)/2;var TA=1-.17*Math.cos(dA*(vA-30))+.24*Math.cos(2*dA*vA)+.32*Math.cos(dA*(3*vA+6))-.2*Math.cos(dA*(4*vA-63)),kA=cA-oA,OA=yA-fA,FA=2*Math.sin(dA*wA/2)*Math.pow(fA*yA,.5),GA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),RA=1+.045*DA,jA=1+.015*DA*TA,WA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),zA=-2*Math.pow(hA/(hA+Math.pow(25,7)),.5)*Math.sin(2*dA*WA);return Math.pow(Math.pow(kA/1/GA,2)+Math.pow(OA/1/RA,2)+Math.pow(FA/1/jA,2)+zA*OA*FA/(1*RA*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 cA=this.toRgb(),gA=1/0,uA="black";if(!rA.length)for(var IA in AA)rA[IA]=new nA(AA[IA]).toRgb();for(var dA in AA){var CA=(oA=cA,sA=rA[dA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));CA<gA&&(gA=CA,uA=dA)}return uA}},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 hA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw hA.position=pA,hA},sA=function(pA){for(var mA="",hA=pA.length,BA=0,QA=0,EA,fA;BA<hA;){if(EA=pA[BA++],EA<=127){mA+=String.fromCharCode(EA);continue}else EA>191&&EA<=223?(fA=EA&31,QA=1):EA<=239?(fA=EA&15,QA=2):EA<=247?(fA=EA&7,QA=3):oA(BA,mA);for(var yA=0;yA<QA;++yA)EA=pA[BA++],(EA<128||EA>191)&&oA(BA,mA),fA<<=6,fA+=EA&63;fA>=55296&&fA<=57343&&oA(BA,mA),fA>1114111&&oA(BA,mA),fA<=65535?mA+=String.fromCharCode(fA):(fA-=65536,mA+=String.fromCharCode((fA>>10)+55296),mA+=String.fromCharCode((fA&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,hA,BA,QA,EA,fA,yA,DA,bA=[],NA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255,bA[NA++]=(EA<<7|fA<<2|yA>>>3)&255,bA[NA++]=(yA<<5|DA)&255;var TA=wA-vA;return TA===2?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255):TA===4?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255):TA===5?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255):TA===7&&(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255,bA[NA++]=(EA<<7|fA<<2|yA>>>3)&255),bA},cA=function(pA){for(var mA,hA,BA,QA,EA,fA="",yA=pA.length,DA=0,bA=parseInt(yA/5)*5;DA<bA;)mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA++),QA=pA.charCodeAt(DA++),EA=pA.charCodeAt(DA++),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31];var NA=yA-bA;return NA===1?(mA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):NA===2?(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):NA===4&&(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA++),QA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"="),fA},gA=function(pA){var mA,hA,BA,QA,EA,fA,yA=!1,DA="",bA=0,NA,wA=0,MA=pA.length;if(pA==="")return DA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],NA=wA;bA<MA&&NA<5;++bA)fA=pA.charCodeAt(bA),fA<128?aA[NA++]=fA:fA<2048?(aA[NA++]=192|fA>>6,aA[NA++]=128|fA&63):fA<55296||fA>=57344?(aA[NA++]=224|fA>>12,aA[NA++]=128|fA>>6&63,aA[NA++]=128|fA&63):(fA=65536+((fA&1023)<<10|pA.charCodeAt(++bA)&1023),aA[NA++]=240|fA>>18,aA[NA++]=128|fA>>12&63,aA[NA++]=128|fA>>6&63,aA[NA++]=128|fA&63);wA=NA-5,bA===MA&&++bA,bA>MA&&NA<6&&(yA=!0),mA=aA[0],NA>4?(hA=aA[1],BA=aA[2],QA=aA[3],EA=aA[4],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31]):NA===1?DA+=iA[mA>>>3]+iA[mA<<2&31]+"======":NA===2?(hA=aA[1],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(hA=aA[1],BA=aA[2],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):(hA=aA[1],BA=aA[2],QA=aA[3],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"=")}while(!yA);return DA},uA=function(pA){for(var mA,hA,BA,QA,EA,fA="",yA=pA.length,DA=0,bA=parseInt(yA/5)*5;DA<bA;)mA=pA[DA++],hA=pA[DA++],BA=pA[DA++],QA=pA[DA++],EA=pA[DA++],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31];var NA=yA-bA;return NA===1?(mA=pA[DA],fA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):NA===2?(mA=pA[DA++],hA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(mA=pA[DA++],hA=pA[DA++],BA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):NA===4&&(mA=pA[DA++],hA=pA[DA++],BA=pA[DA++],QA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"="),fA},IA=function(pA,mA){var hA=typeof pA!="string";return hA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),hA?uA(pA):mA?cA(pA):gA(pA)},dA=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 hA,BA,QA,EA,fA,yA,DA,bA,NA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)+String.fromCharCode((fA<<7|yA<<2|DA>>>3)&255)+String.fromCharCode((DA<<5|bA)&255);var TA=wA-vA;return TA===2?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)):TA===4?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)):TA===5?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)):TA===7&&(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)+String.fromCharCode((fA<<7|yA<<2|DA>>>3)&255)),NA},CA={encode:IA,decode:dA};dA.asBytes=lA,tA?nA.exports=CA:eA.base32=CA})()})(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(dA=>{const CA=shiftForRemovedChild(dA,sA);return CA&&CA.firstInd>=aA&&CA.lastInd<=oA?[{range:dA,...CA}]:[]}).sort((dA,CA)=>dA.firstInd-CA.firstInd||CA.lastInd-dA.lastInd),cA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},gA=[cA];function uA(dA,CA){for(;dA.nextInd<CA;dA.nextInd++){const pA=nA[dA.nextInd];AA(pA)||(dA.items.push({kind:"child",value:pA,index:dA.nextInd}),dA.eligibility&&dA.eligible.push(dA.eligibility[dA.nextInd-dA.firstInd]??!1))}}function IA(){const dA=gA.pop();if(uA(dA,dA.lastInd+1),dA.items.length===0)return;const CA=gA[gA.length-1],pA=dA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=dA.eligible.every((BA,QA)=>BA||isBlankGroup(dA.items[QA],tA)),hA=!!dA.range.asList&&mA&&pA.length>1;CA.items.push({kind:"composite",range:dA.range,asList:hA,items:hA?prepareListItems(dA.items,tA,rA):dA.items}),CA.eligibility&&CA.eligible.push(mA)}for(const{range:dA,firstInd:CA,lastInd:pA}of lA){for(;gA.length>1&&pA>gA[gA.length-1].lastInd;)IA();const mA=gA[gA.length-1];CA<mA.nextInd||(uA(mA,CA),mA.nextInd=pA+1,!iA(dA)&&gA.push({range:dA,firstInd:CA,lastInd:pA,nextInd:CA,eligibility:dA.potentialListComponents??null,items:[],eligible:[]}))}for(;gA.length>1;)IA();return uA(cA,oA+1),cA.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 cA={};for(var gA in lA)cA[gA]=eA.call(sA,gA)?sA[gA]:lA[gA];return cA},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 cA=lA.quotes=="double"?'"':"'",gA=lA.isIdentifier,uA=sA.charAt(0),IA="",dA=0,CA=sA.length;dA<CA;){var pA=sA.charAt(dA++),mA=pA.charCodeAt(),hA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&dA<CA){var BA=sA.charCodeAt(dA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:dA--}hA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?hA="\\"+pA:hA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?hA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!gA&&(pA=='"'&&cA==pA||pA=="'"&&cA==pA)||gA&&iA.test(pA)?hA="\\"+pA:hA=pA;IA+=hA}return gA&&(/^-[-\d]/.test(IA)?IA="\\-"+IA.slice(1):/\d/.test(uA)&&(IA="\\3"+uA+" "+IA.slice(1))),IA=IA.replace(rA,function(QA,EA,fA){return EA&&EA.length%2?QA:(EA||"")+fA}),!gA&&lA.wrap?cA+IA+cA:IA};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(cA=>isBlankGroup(cA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=iA.items.slice(oA,sA+1).filter((cA,gA)=>!aA[oA+gA]);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 gA of aA.childrenInstructions){if(gA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(gA,iA)),typeof gA=="string")continue;const uA=tA[gA.componentIdx];uA?uA.type==="element"&&(uA.name=gA.componentType,uA.data.id=gA.componentIdx,uA.data.action_names=Object.keys(gA.actions)):tA[gA.componentIdx]={type:"element",name:gA.componentType,attributes:{},children:[],data:{id:gA.componentIdx,action_names:Object.keys(gA.actions)}}}const{children:lA,wrapperElements:cA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const gA of cA)tA[gA.data.id]=gA}}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,cA=[];if(lA)for(const CA of lA){if(CA==null){cA.push(null);continue}cA.push(childInstructionToContent(CA,AA))}const{children:gA,wrapperElements:uA}=applyCompositeListWrapping(cA,sA?._compositeReplacementActiveRange),IA={type:"element",name:eA[oA]??"",children:gA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(IA,AA);const dA={changedState:IA.data.props};lA&&(dA.newChildren=IA.children),iA(oA,dA);for(const CA of uA)iA(CA.data.id,{newFlatDastElement:CA})}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.childIndex||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 cA=oA.unresolvedPath[0].index;if(cA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof cA[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.882/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(QA){return hA.update_root_names(QA)},cA=function(QA,EA,fA){return hA.resolve_path(QA,EA,fA)},gA=function(QA,EA){hA.add_nodes_to_resolver(QA,EA)},uA=function(QA,EA){hA.replace_index_resolutions_in_resolver(QA,EA)},IA=function(QA){hA.delete_nodes_from_resolver(QA)},dA=function(){hA.save_resolver()},CA=function(){return hA.restore_resolver()},pA=function(){hA.release_saved_resolver()};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 mA=this.doenetCore.return_normalized_dast_root();const hA=this.doenetCore,BA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:mA,addNodesToResolver:gA,replaceIndexResolutionsInResolver:uA,deleteNodesFromResolver:IA,resolvePath:cA,updateRootNames:lA,saveResolver:dA,restoreResolver:CA,releaseSavedResolver:pA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,BA}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:cA,resolve:gA}=promiseWithResolver();if(this.isProcessingPromise=cA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const uA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA);if(uA?.success===!1){const IA=readPanicMessage();IA!==void 0&&throwAsDocumentBuildError(new Error(uA.errMsg??""),IA)}return uA}catch(uA){console.error(uA),throwAsDocumentBuildError(uA,readPanicMessage())}finally{gA()}}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(NA){return tA.update_root_names(NA)}function rA(NA,wA,MA){return tA.resolve_path(NA,wA,MA)}function aA(NA,wA){tA.add_nodes_to_resolver(NA,wA)}function oA(NA,wA){tA.replace_index_resolutions_in_resolver(NA,wA)}function sA(NA){tA.delete_nodes_from_resolver(NA)}function lA(){tA.save_resolver()}function cA(){return tA.restore_resolver()}function gA(){tA.release_saved_resolver()}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:iA,saveResolver:lA,restoreResolver:cA,releaseSavedResolver:gA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const uA={coreId:"a",cid:null,initializeCounters:{}};let IA=null;this._javascriptUpdateBuffer=[];const dA=NA=>{NA.init?IA=NA.updateInstructions:this._capturingJavascriptUpdates&&NA.updateInstructions&&this._javascriptUpdateBuffer.push(...NA.updateInstructions)},CA=NA=>{},pA=NA=>{},mA=NA=>{},hA=NA=>{},BA=NA=>{},QA=NA=>Promise.resolve({allowView:!0}),EA=await this.javascriptCore.createCoreGenerateDast(uA,dA,CA,pA,mA,hA,BA,QA);if(!EA.success)throw console.error(EA.errMsg),Error(EA.errMsg);if(IA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const fA=EA.coreInfo.documentToRender,{componentIdxToName:yA,doenetIdToComponentIdx:DA}=seedInstructionMaps(fA,IA);return this._componentIdxToName=yA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(fA,IA)}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(IA){for(var dA=Math.sqrt(IA),CA=2;CA<=dA;CA++)if(!(IA%CA))return!1;return!0}function cA(IA){return(IA-(IA|0))*4294967296|0}for(var gA=2,uA=0;uA<64;)lA(gA)&&(tA[uA]=cA(Math.pow(gA,.3333333333333333)),uA++),gA++})();var iA=function(lA){for(var cA=[],gA=0,uA=0;gA<lA.length;gA++,uA+=8)cA[uA>>>5]|=lA[gA]<<24-uA%32;return cA},rA=function(lA){for(var cA=[],gA=0;gA<lA.length*32;gA+=8)cA.push(lA[gA>>>5]>>>24-gA%32&255);return cA},aA=[],oA=function(lA,cA,gA){for(var uA=lA[0],IA=lA[1],dA=lA[2],CA=lA[3],pA=lA[4],mA=lA[5],hA=lA[6],BA=lA[7],QA=0;QA<64;QA++){if(QA<16)aA[QA]=cA[gA+QA]|0;else{var EA=aA[QA-15],fA=(EA<<25|EA>>>7)^(EA<<14|EA>>>18)^EA>>>3,yA=aA[QA-2],DA=(yA<<15|yA>>>17)^(yA<<13|yA>>>19)^yA>>>10;aA[QA]=fA+aA[QA-7]+DA+aA[QA-16]}var bA=pA&mA^~pA&hA,NA=uA&IA^uA&dA^IA&dA,wA=(uA<<30|uA>>>2)^(uA<<19|uA>>>13)^(uA<<10|uA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+bA+tA[QA]+aA[QA],TA=wA+NA;BA=hA,hA=mA,mA=pA,pA=CA+vA|0,CA=dA,dA=IA,IA=uA,uA=vA+TA|0}lA[0]=lA[0]+uA|0,lA[1]=lA[1]+IA|0,lA[2]=lA[2]+dA|0,lA[3]=lA[3]+CA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+hA|0,lA[7]=lA[7]+BA|0};function sA(lA,cA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var gA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],uA=iA(lA),IA=lA.length*8;uA[IA>>5]|=128<<24-IA%32,uA[(IA+64>>9<<4)+15]=IA;for(var dA=0;dA<uA.length;dA+=16)oA(gA,uA,dA);var CA=rA(gA);return cA&&cA.asBytes?CA:cA&&cA.asString?AA.convertString.bytesToString(CA):AA.bytesToHex(CA)}sA.x2=function(lA,cA){return sA(sA(lA,{asBytes:!0}),cA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0DJ8rfLd0=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})({});
|
|
1423
|
+
`).map(uA=>uA.trim().split(",").map(IA=>IA.trim())),oA=aA[0]?.length,sA=!1;for(let uA of aA.slice(1))if(uA.length!==oA){sA=!0;break}if(sA){let uA=codedDiagnostic({type:"warning",code:"doenet-w0066",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}let lA={},cA=[];if(AA.hasHeader?(lA.columnNames=aA[0].map(uA=>(['"',"'"].includes(uA[0])&&uA[uA.length-1]===uA[0]&&(uA=uA.substring(1,uA.length-1)),uA)),cA=aA.slice(1)):(lA.columnNames=[...Array(oA).keys()].map(uA=>`col${uA+1}`),cA=aA),[...new Set(lA.columnNames)].length<lA.columnNames){let uA=codedDiagnostic({type:"warning",code:"doenet-w0067",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}if(lA.columnNames.includes("")){let uA=codedDiagnostic({type:"warning",code:"doenet-w0068",args:{componentIdx:String(tA)}});return{setValue:{dataFrame:null,numRows:gA,numColumns:oA,columnTypes:iA,columnNames:rA},sendDiagnostics:[uA]}}let gA=cA.length;lA.shape=[gA,oA];for(let uA=0;uA<oA;uA++){let IA=AA.columnTypesPrelim[uA]?.toLowerCase();if(["number","string"].includes(IA)||(IA="auto"),IA==="auto"){let dA=!1;for(let CA=0;CA<gA;CA++){let pA=cA[CA][uA];if(pA!==""){let mA=Number(pA);if(!Number.isFinite(mA)){dA=!0;break}}}dA?IA="string":IA="number"}if(IA==="number")for(let dA=0;dA<gA;dA++)cA[dA][uA]===""?cA[dA][uA]=null:cA[dA][uA]=Number(cA[dA][uA]);else for(let dA=0;dA<gA;dA++){let CA=cA[dA][uA];['"',"'"].includes(CA[0])&&CA[CA.length-1]===CA[0]&&(CA=CA.substring(1,CA.length-1)),cA[dA][uA]=CA}iA.push(IA)}return lA.data=cA,lA.columnTypes=iA,{setValue:{dataFrame:lA,numRows:gA,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(this.componentType)),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 uA=0;uA<AA.numGraphicalElements;uA++){let IA=AA[`graphicalElement${uA}`];const dA=tA.allComponentClasses[IA?.componentType]?.listEntryComponentType;dA!==void 0&&(IA={...IA,componentType:dA});let CA=AA[`graphicalElement${uA}AdapterSource`];CA&&(IA={...IA},IA.componentIdx=CA.componentIdx);let pA=AA[`graphicalElement${uA}ShadowSource`];if(pA){const mA=JSON.parse(JSON.stringify(IA));mA.componentIdx=pA.componentIdx,sA.push(mA)}sA.push(IA),dA!==void 0&&sA.push(...listEntryElementsForLabels({list:IA,listIndices:[IA.componentIdx,pA?.componentIdx],labelChildren:AA.labelChildren}))}let lA=sA.map(uA=>uA.componentIdx),cA=[],gA={};for(let uA of AA.labelChildren){let IA={value:uA.stateValues.value,hasLatex:uA.stateValues.hasLatex};if(uA.stateValues.forObjectComponentIdx){gA[uA.stateValues.forObjectComponentIdx]=IA;let dA=lA.indexOf(uA.stateValues.forObjectComponentIdx);if(dA!==-1){let CA=sA[dA];tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})?rA.push(CA.stateValues.styleNumber):AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath?aA.push(CA.stateValues.styleNumber):CA.componentType!=="legend"&&oA.push(CA.stateValues.styleNumber)}}cA.push({labelInfo:IA,forObject:uA.stateValues.forObjectComponentIdx})}for(let uA of cA){let IA;if(uA.forObject){let dA=lA.indexOf(uA.forObject);dA!==-1&&(IA=sA[dA],sA.splice(dA,1),lA.splice(dA,1))}else for(let dA=0;dA<sA.length;dA++){let CA=sA[dA];if(!(CA.componentIdx in gA)){if(tA.isInheritedComponentType({inheritedComponentType:CA.componentType,baseComponentType:"point"})){if(!rA.includes(CA.stateValues.styleNumber)){IA=CA;break}}else if(AA.displayClosedSwatches&&tA.allComponentClasses[CA.componentType].representsClosedPath){if(!aA.includes(CA.stateValues.styleNumber)){IA=CA;break}}else if(CA.componentType!=="legend"&&!oA.includes(CA.stateValues.styleNumber)){IA=CA;break}}}if(IA){let dA=IA.stateValues.selectedStyle,CA=IA.stateValues.styleNumber;tA.isInheritedComponentType({inheritedComponentType:IA.componentType,baseComponentType:"point"})?(rA.push(CA),iA.push({swatchType:"marker",markerStyle:dA.markerStyle,markerColor:dA.markerColor,markerColorDarkMode:dA.markerColorDarkMode,markerSize:dA.markerSize,lineOpacity:dA.lineOpacity,label:uA.labelInfo})):AA.displayClosedSwatches&&tA.allComponentClasses[IA.componentType].representsClosedPath?(aA.push(CA),iA.push({swatchType:"rectangle",lineStyle:dA.lineStyle,lineColor:dA.lineColor,lineColorDarkMode:dA.lineColorDarkMode,lineWidth:dA.lineWidth,lineOpacity:dA.lineOpacity,fillColor:dA.fillColor,fillColorDarkMode:dA.fillColorDarkMode,filled:IA.stateValues.filled,fillOpacity:dA.fillOpacity,label:uA.labelInfo})):(oA.push(CA),iA.push({swatchType:"line",lineStyle:dA.lineStyle,lineColor:dA.lineColor,lineColorDarkMode:dA.lineColorDarkMode,lineWidth:dA.lineWidth,lineOpacity:dA.lineOpacity,label:uA.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 missingWhenComputedFromMissing=!1;static childGroupsReadOnce=["maths"];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"]},patternDecidedByDoenetML:{dependencyType:"decidedByDoenetML",attributeNames:["pattern","parameters"]}}),definition({dependencyValues:AA}){let tA=[];if(!AA.patternAttr)return{setValue:{pattern:BLANK$2,patternVariables:tA}};let iA=AA.patternAttr.stateValues.value,rA=iA.variables(),aA=703;function oA(){let CA=numberToLetters(aA);for(aA++;rA.includes(CA);)CA=numberToLetters(aA),aA++;return CA}if(!AA.parametersAttr)return{setValue:{pattern:replacePlaceholders(iA.tree,pA=>{if(pA!==BLANK$2)return;let mA=oA();return tA.push(mA),mA}),patternVariables:tA}};let sA=AA.parametersAttr.position||void 0,lA=[],cA=new Map,gA=new Map;for(let CA of AA.parametersAttr.stateValues.variables){let pA=parameterKey(CA.tree);if(pA===void 0||cA.has(pA))continue;let mA=oA();cA.set(pA,mA),gA.set(mA,CA.toString()),tA.push(mA)}let uA=new Set,IA=replacePlaceholders(iA.tree,CA=>{let pA=cA.get(parameterKey(CA));return pA!==void 0&&uA.add(pA),pA}),dA=[...gA].filter(([CA])=>!uA.has(CA)).map(([CA,pA])=>pA);return dA.length>0&&lA.push(codedDiagnostic({type:levelFromSource(AA.patternDecidedByDoenetML),code:"doenet-w0117",args:{parameters:dA},position:sA})),{setValue:{pattern:IA,patternVariables:tA},conditionDiagnostics: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(cA=>rA[cA]=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(cA=>context.fromAst(cA)).some(cA=>AA.excludeMatches.some(gA=>cA.variables().some(uA=>gA.equalsViaSyntax(context.fromAst(uA)))))||(sA=!0,lA=AA.patternVariables.map(cA=>context.fromAst(oA[cA]??BLANK$2)))),{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 isValue=!1;static childGroupsReadOnce=["maths"];static childrenIgnoredBeside({fromSource:eA,added:AA,groupOf:tA}){const iA=[...eA,...AA].some(rA=>["rows","columns"].includes(tA(rA)));return AA.filter(rA=>tA(rA)==="maths"&&iA)}static componentDocs={summary:"A matrix of math values",childAliases:{row:"matrixRow",column:"matrixColumn"}};static rendererType="math";static variableForIndexAsProp="matrix";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 IA of tA)typeof IA!="string"&&(IA.doenetAttributes||(IA.doenetAttributes={}),IA.componentType==="column"?(IA.doenetAttributes.createNameFromComponentType="column",IA.componentType="matrixColumn",sA=!0):IA.componentType==="row"?(IA.doenetAttributes.createNameFromComponentType="row",IA.componentType="matrixRow",sA=!0):IA.attributes?._createComponentOfType?.primitive.value==="column"?(IA.doenetAttributes.createNameFromComponentType="column",IA.attributes._createComponentOfType.primitive.value="matrixColumn",sA=!0):IA.attributes?._createComponentOfType?.primitive.value==="row"&&(IA.doenetAttributes.createNameFromComponentType="row",IA.attributes._createComponentOfType.primitive.value="matrixRow",sA=!0),oA.push(IA));const lA=[],cA=IA=>typeof IA=="object"&&iA.componentIsSpecifiedType(IA,"math"),gA=tA.filter(IA=>typeof IA!="string"||IA.trim()!==""),uA=gA.filter(cA);return sA?uA.length>0&&lA.push(codedDiagnostic({type:"warning",code:"doenet-w0194",args:{reason:"rows"}})):gA.length>1&&gA.every(cA)?(lA.push(codedDiagnostic({type:"warning",code:"doenet-w0194",args:{reason:"several"}})),oA=uA):(tA.length>1||!cA(tA[0]))&&(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,diagnostics:lA}};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"],childIndices:[-1],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,set:convertValueToMathExpression,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:[-1],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 cA of iA){let[gA,uA]=cA.split(","),IA;sA?IA=tA[cA].rowChild[0]?.stateValues["math"+(Number(uA)+1)]:lA?IA=tA[cA].colChild[0]?.stateValues["math"+(Number(gA)+1)]:IA=tA[cA].mathChild[0]?.stateValues["matrixEntry"+(Number(gA)+1)+"_"+(Number(uA)+1)],IA===void 0?oA[cA]={defaultValue:AA.defaultEntry}:aA[cA]=IA}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 cA in AA.matrixPre){let[gA,uA]=cA.split(",");sA?iA[cA].rowChild[0]?.stateValues["math"+(Number(uA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].rowChild,desiredValue:AA.matrixPre[cA],childIndex:0,variableIndex:0}):lA?iA[cA].colChild[0]?.stateValues["math"+(Number(gA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].colChild,desiredValue:AA.matrixPre[cA],childIndex:0,variableIndex:0}):iA[cA].mathChild[0]?.stateValues["matrixEntry"+(Number(gA)+1)+"_"+(Number(uA)+1)]===void 0?oA[cA]=AA.matrixPre[cA]:aA.push({setDependency:rA[cA].mathChild,desiredValue:AA.matrixPre[cA],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,set:convertValueToMathExpression,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:()=>({fixed:{dependencyType:"stateVariable",variableName:"fixed"}}),definition({dependencyValues:AA}){return{setValue:{canBeModified:!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"]},matrixDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths"]}}),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=[],cA=tA[2][sA+1]||[];for(let gA=0;gA<rA;gA++){let uA=cA[gA+1];if(uA==null)return{setValue:{decomposition:null,numEigenvectors:0}};if(typeof uA=="number"||typeof uA?.re=="number"&&typeof uA?.im=="number")lA.push(uA);else try{uA=context.fromAst(uA).evaluate_to_constant(),typeof uA=="number"||typeof uA?.re=="number"&&typeof uA?.im=="number"?lA.push(uA):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:levelFromSource(AA.matrixDecidedByDoenetML),code:"doenet-w0059"});return{setValue:{decomposition:null,numEigenvectors:0},conditionDiagnostics:[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 isContent=!0;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 isContent=!0;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 cA=lA.reduce((uA,IA,dA)=>uA+Math.pow(IA-nA[dA],2),0);if(cA>=tA)return{success:!1};let gA=rA(eA,AA);if(!gA)return{success:!1};if(cA=gA.reduce((uA,IA,dA)=>uA+Math.pow(IA-eA[dA],2),0),cA>=tA)return{success:!1};if(aA){let uA=iA(nA,AA),IA=uA&&uA.every((pA,mA)=>Math.abs(pA-lA[mA])<oA),dA=iA(eA,AA),CA=dA&&dA.every((pA,mA)=>Math.abs(pA-gA[mA])<oA);if(!(IA||CA)&&(cA=uA.reduce((pA,mA,hA)=>pA+Math.pow(mA-dA[hA],2),0),cA<sA))return{success:!1}}return{success:!0,nearestPoint1:lA,nearestPoint2:gA}}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:cA,nearestPoint2:gA}=oA;if(!AA){let DA=[eA[0]-nA[0],eA[1]-nA[1]],bA=[gA[0]-cA[0],gA[1]-cA[1]],NA=Math.atan2(bA[1],bA[0])-Math.atan2(DA[1],DA[0]);if(NA=mod$1(NA+Math.PI,2*Math.PI)-Math.PI,Math.abs(NA)>sA)return{success:!1}}let uA=nA.reduce((DA,bA,NA)=>DA+Math.pow(bA-eA[NA],2),0),IA=cA.reduce((DA,bA,NA)=>DA+Math.pow(bA-gA[NA],2),0);if(Math.abs(uA-IA)<lA){let DA=cA.reduce((bA,NA,wA)=>bA+Math.pow(NA-nA[wA],2),0)+gA.reduce((bA,NA,wA)=>bA+Math.pow(NA-eA[wA],2),0);return DA<iA?{success:!0,distance2:DA,segment:[cA,gA]}:{success:!1}}if(IA>uA)return{success:!1};let dA=Math.sqrt(uA/IA),CA=Math.sqrt(nA.reduce((DA,bA,NA)=>DA+Math.pow(bA-cA[NA],2),0)),pA=Math.sqrt(eA.reduce((DA,bA,NA)=>DA+Math.pow(bA-gA[NA],2),0)),mA=CA/(CA+pA),hA=1-mA,BA=(dA-1)*mA+1,QA=(dA-1)*hA+1,EA=gA.map((DA,bA)=>DA+(cA[bA]-DA)*BA),fA=cA.map((DA,bA)=>DA+(gA[bA]-DA)*QA);if(oA=findAttractedSegmentPointsSub({point1:EA,point2:fA,scales:tA,threshold2:lA,numericalNearestPointFunction:rA,numericalNearestPointAsLineFunction:aA,verifyNotOneSided:!1}),!oA.success)return{success:!1};let yA=EA.reduce((DA,bA,NA)=>DA+Math.pow(bA-nA[NA],2),0)+fA.reduce((DA,bA,NA)=>DA+Math.pow(bA-eA[NA],2),0);return yA<iA?{success:!0,distance2:yA,segment:[EA,fA]}:{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,cA=eA?tA*1e3:tA;for(let[gA,uA]of iA.entries()){let IA=rA[gA],dA=findAttractedSegmentPoints({point1:aA,point2:oA,allowRotation:eA,scales:AA,threshold2:cA,numericalNearestPointFunction:uA,numericalNearestPointAsLineFunction:IA});dA.success&&dA.distance2<lA&&(lA=dA.distance2,sA=dA.segment)}return lA<tA?{constrained:!0,segment:sA}:lA<cA?{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],cA=(rA-tA)/sA,gA=(aA-iA)/lA,uA=cA*cA+gA*gA,IA=((nA[0]-tA)/sA*cA+(nA[1]-iA)/lA*gA)/uA;return IA<=0?[tA,iA]:IA>=1?[rA,aA]:[tA+IA*cA*sA,iA+IA*gA*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],cA=(rA-tA)/sA,gA=(aA-iA)/lA,uA=cA*cA+gA*gA,IA=((nA[0]-tA)/sA*cA+(nA[1]-iA)/lA*gA)/uA;return[tA+IA*cA*sA,iA+IA*gA*lA]}const{mod:mod$6}=context.math;class StickyGroup extends GraphicalComponent{static componentType="stickyGroup";static isContent=!0;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:gA,allowRotation:uA,enforceRigid:IA,shrinkThreshold:dA,rotationPoint:CA},{objectInd:pA}){let mA=tA.getSegmentsForObject(pA),hA=[],BA=[],QA=!1,EA={distance2:1/0},fA=tA.threshold;dA&&(fA*=.2);let yA=fA*fA;for(let[DA,bA]of gA.entries()){let NA=[],wA=[];for(let vA of mA)NA.push((TA,kA)=>nearestPointForSegment({point:TA,segment:vA,scales:kA})),wA.push((TA,kA)=>nearestPointForSegmentAsLine({point:TA,segment:vA,scales:kA}));let MA=attractSegment({segment:bA,allowRotation:uA,scales:iA,threshold2:yA,numericalNearestPointFunctions:NA,numericalNearestPointAsLineFunctions:wA});MA.constrained?(hA.push(MA.segment),BA.push(!0),QA=!0):(hA.push(bA),BA.push(!1),!QA&&MA.distance2<EA.distance2&&(EA=MA,EA.edgeInd=DA))}if(uA&&IA&&!QA&&EA.distance2<1/0){let DA=EA.edgeInd,bA=rotateIfClose({attractedEdgeInd:DA,attractingSegment:EA.segment,angleThreshold:rA,rotationPoint:CA,numericalUnconstrainedEdges:gA});bA&&(hA[DA]=bA,BA[DA]=!0,QA=!0)}if(uA&&IA&&!QA){let DA=[0,Math.PI/2],bA=rotateToAttractAngles({numericalUnconstrainedEdges:gA,anglesToAttract:DA,angleThreshold:rA,rotationPoint:CA});if(bA){let NA=bA.rotatedEdgeInd;hA[NA]=bA.rotatedEdge,BA[NA]=!0,QA=!0}}return{numericalConstrainedEdges:hA,constraintUsedForEdge:BA}},oA=function({numericalUnconstrainedVertices:gA,closed:uA,shrinkThreshold:IA,onlyMoveVertexInd:dA=null},{objectInd:CA}){let pA=tA.getPointsForObject(CA),mA=tA.getSegmentsForObject(CA),hA=[],BA=[],QA=tA.threshold;IA&&(QA*=.2);let EA=QA*QA;for(let[bA,NA]of gA.entries()){if(dA!==null&&bA!==dA){hA.push(NA),BA.push(!1);continue}let wA=1/0,MA={};for(let kA of pA){if(NA.length!==kA.length)continue;let OA=NA.reduce((FA,GA,RA)=>FA+Math.pow((GA-kA[RA])/iA[RA],2),0);OA<wA&&(MA=kA,wA=OA)}let vA=!1,TA;if(wA<EA)vA=!0,TA=MA;else{wA=1/0,MA={};for(let kA of mA){let OA=nearestPointForSegment({point:NA,segment:kA,scales:iA});if(OA){let FA=NA.reduce((GA,RA,jA)=>GA+Math.pow((RA-OA[jA])/iA[jA],2),0);FA<wA&&(MA=OA,wA=FA)}}wA<EA?(vA=!0,TA=MA):TA=NA}hA.push(TA),BA.push(vA)}let fA=gA.length,yA=uA?fA:fA-1,DA=[];for(let bA=0;bA<yA;bA++){let NA=(bA+1)%fA;if(!(dA!==null&&!(dA===bA||dA===NA))&&!(BA[bA]||BA[NA])){let wA=gA[bA],MA=gA[NA],vA,TA=1/0;for(let kA of pA){let OA=nearestPointForSegment({point:kA,segment:[wA,MA],scales:iA});if(OA){let FA=OA.reduce((GA,RA,jA)=>GA+Math.pow(RA-kA[jA],2),0);if(FA<TA)if(dA===null){let GA=wA.map((jA,WA)=>jA+kA[WA]-OA[WA]),RA=MA.map((jA,WA)=>jA+kA[WA]-OA[WA]);vA=[GA,RA],TA=FA}else{let GA;dA===bA?GA=MA:GA=wA;let RA=[kA[0]-GA[0],kA[1]-GA[1]],jA=Math.sqrt(Math.pow(RA[0],2)+Math.pow(RA[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 xA=GA.map((HA,KA)=>HA+RA[KA]*zA),$A;dA===bA?($A=[xA,MA],FA=Math.pow(wA[0]-xA[0],2)+Math.pow(wA[1]-xA[1],2)):($A=[wA,xA],FA=Math.pow(MA[0]-xA[0],2)+Math.pow(MA[1]-xA[1],2)),FA<TA&&(TA=FA,vA=$A)}}}TA<EA&&DA.push({vertexInd1:bA,vertexInd2:NA,distance2:TA,movedSegment:vA})}}DA.sort((bA,NA)=>bA.distance2-NA.distance2);for(let{vertexInd1:bA,vertexInd2:NA,movedSegment:wA}of DA)BA[bA]||BA[NA]||(BA[bA]=!0,BA[NA]=!0,hA[bA]=wA[0],hA[NA]=wA[1]);return{numericalConstrainedVertices:hA,constraintUsedForVertex:BA}},sA=returnVertexConstraintFunctionFromEdges(aA),lA=returnVertexConstraintFunction(oA);return{setValue:{verticesConstraintFunction:function({unconstrainedVertices:gA,closed:uA,enforceRigid:IA,allowRotation:dA,rotationPoint:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA}){let BA=sA({unconstrainedVertices:gA,closed:uA,enforceRigid:IA,allowRotation:dA,rotationPoint:CA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA});return BA=lA({unconstrainedVertices:BA,closed:uA,enforceRigid:IA,shrinkThreshold:pA,vertexIndMoved:mA},{objectInd:hA}),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(IA=>findFiniteNumericalValue(IA)),lA=tA.getPointsForObject(oA),cA=tA.getSegmentsForObject(oA),gA=1/0,uA={};for(let IA of lA){if(sA.length!==IA.length)continue;let dA=sA.reduce((CA,pA,mA)=>CA+Math.pow((pA-IA[mA])/iA[mA],2),0);dA<gA&&(uA=IA,gA=dA)}if(gA<tA.threshold*tA.threshold)return uA.map(IA=>context.fromAst(IA));gA=1/0,uA={};for(let IA of cA){let dA=nearestPointForSegment({point:sA,segment:IA,scales:iA});if(dA){let CA=sA.reduce((pA,mA,hA)=>pA+Math.pow((mA-dA[hA])/iA[hA],2),0);CA<gA&&(uA=dA,gA=CA)}}return gA<tA.threshold*tA.threshold?uA.map(IA=>context.fromAst(IA)):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[gA,uA]of nA.entries()){let IA=Math.atan((uA[1][1]-uA[0][1])/(uA[1][0]-uA[0][0]));for(let dA of eA){let CA=mod$6(dA-IA+Math.PI/2,Math.PI)-Math.PI/2;Math.abs(CA)<Math.abs(iA)&&(iA=CA,rA=gA)}}if(!(Math.abs(iA)<AA))return null;let[aA,oA]=tA,sA=Math.cos(iA),lA=Math.sin(iA),cA=nA[rA].map(gA=>{let uA=gA[0]-aA,IA=gA[1]-oA;return[uA*sA-IA*lA+aA,uA*lA+IA*sA+oA]});return{rotatedEdgeInd:rA,rotatedEdge:cA}}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,cA]=tA,gA=Math.cos(sA),uA=Math.sin(sA);return iA[nA].map(dA=>{let CA=dA[0]-lA,pA=dA[1]-cA;return[CA*gA-pA*uA+lA,CA*uA+pA*gA+cA]})}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 IA=0;IA<rA;IA++)iA.has(IA)||(oA[IA]=sA,sA++);const lA=[],cA=tA==="circuit"?aA===1?0:1:null;for(let IA=0;IA<rA;IA++){const dA=nA[IA],CA=eA[IA]??"";if(iA.has(dA)){if(!isDistractorResponse(CA))return 0;continue}const pA=parseIntegerResponse(CA);if(pA===null)return 0;const mA=oA[dA],hA=calculateResponseOffset({numericResponse:pA,effectiveProblemNum:mA,numEffectiveProblems:aA});if(tA==="circuit"){if(hA!==cA)return 0;continue}lA.push(hA)}if(tA==="circuit")return 1;const gA=lA[0];return lA.every(IA=>IA===gA)?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 isContent=!0;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 attributesDeterminingChoices=["mode"];static choiceChildTypes=["problem"];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 preprocessSerializedChildren({serializedChildren:eA,attributes:AA}){const tA=[...eA.keys()].filter(uA=>eA[uA]?.componentType==="_pretzelArranger");if(tA.length<2)return;const iA=eA[tA[0]],rA=tA.slice(1).map(uA=>eA[uA]);for(const uA of tA.slice(1).reverse())eA.splice(uA,1);const aA=rA.flatMap(uA=>uA.children??[]),oA=aA.some(uA=>uA?.componentType==="problem"),sA=rA.findLast(uA=>uA.attributes?.mode)?.attributes.mode;if(!!iA.downstreamDependencies){iA.attributes.mode?AA.mode=iA.attributes.mode:delete AA.mode;return}if(iA.children=[...iA.children??[],...aA],sA&&(iA.attributes.mode=sA),!iA.variants?.desiredVariant)return;iA.variants={...iA.variants,mergedArrangers:rA.map(uA=>({componentIdx:uA.componentIdx,childIdxs:(uA.children??[]).filter(IA=>typeof IA=="object").map(IA=>IA.componentIdx)}))};const cA={...iA.variants.desiredVariant};iA.variants={...iA.variants,desiredVariant:cA};const gA=cA.indices;if(gA&&(oA||sA?.primitive.value.toLowerCase()==="circuit"&&Number(gA[0])!==1)&&delete cA.indices,oA){delete cA.seed;const uA=rA.find(dA=>dA.variants?.desiredVariant?.seed!==void 0)?.variants.desiredVariant;uA&&(cA.seed=uA.seed,uA.indices&&(cA.indices=uA.indices));const IA=rA.flatMap(dA=>dA.variants?.desiredVariant?.subvariants??[]);cA.subvariants&&IA.length>0&&(cA.subvariants=[...cA.subvariants,...IA])}}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={};for(let iA=0;iA<AA.numSubmittedResponses;iA++)tA[iA]=!0;return{useEssentialOrDefaultValue:{submittedResponses:tA}}},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.insideSectionWideCheckWork={returnDependencies:()=>({ancestorSuppressingAnswerSubmitButtons:{dependencyType:"ancestor",variableNames:["suppressAnswerSubmitButtons","numAttemptsLeft"]}}),definition({dependencyValues:AA}){return{setValue:{insideSectionWideCheckWork:!!AA.ancestorSuppressingAnswerSubmitButtons?.stateValues.suppressAnswerSubmitButtons}}}},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,usesContainerAttempt:iA=!1}){const rA=await this.stateValues.numAttemptsLeft;if(rA<1||await this.stateValues.disabled)return;const oA=await this.stateValues.handGraded?0:await this.stateValues.creditAchievedIfSubmit;let sA=[{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchieved",value:oA},{updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"responseHasBeenSubmitted",value:!0}],lA=await this.stateValues.currentResponses;sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"submittedResponses",value:lA}),sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"justSubmitted",value:!0}),sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"creditAchievedDependenciesAtSubmit",value:await this.stateValues.creditAchievedDependencies});const cA=await this.stateValues.numSubmissions+1;sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numSubmissions",value:cA}),oA<1&&sA.push({updateType:"updateValue",componentIdx:this.componentIdx,stateVariable:"numIncorrectSubmissions",value:await this.stateValues.numIncorrectSubmissions+1});const gA=[];for(const uA of lA)if(uA.toString)try{gA.push(uA.toString())}catch{gA.push("_")}else gA.push(uA);return sA.push({updateType:"recordItemSubmission",componentNumber:await this.stateValues.inComponentNumber,submittedComponent:this.componentIdx,response:lA,responseText:gA,creditAchieved:oA}),await this.coreFunctions.performUpdate({updateInstructions:sA,actionId:eA,sourceInformation:AA,skipRendererUpdate:!0,event:{verb:"submitted",object:{componentIdx:this.componentIdx,componentType:this.componentType,answerNumber:this.answerNumber,rootName:this.rootName},result:{response:lA,responseText:gA,componentTypes:Array(lA.length).fill("text"),creditAchieved:oA,...attemptCountsForEvent({numSubmissions:cA,maxNumAttempts:await this.stateValues.maxNumAttempts,numAttemptsLeftBefore:rA,usesAttempt:!await this.stateValues.insideSectionWideCheckWork||iA})}}}),await this.coreFunctions.triggerChainedActions({componentIdx:this.componentIdx,actionId:eA,sourceInformation:AA,skipRendererUpdate:tA})}}function isProblemCopy({child:nA,componentInfoObjects:eA}){return typeof nA=="object"&&eA.isInheritedComponentType({inheritedComponentType:nA.componentType,baseComponentType:"_composite"})&&nA.attributes._createComponentOfType?.primitive.value==="problem"}function problemChildren(nA){return nA.filter(eA=>eA.componentType==="problem")}function arrangedParts(nA){let eA=null,AA=null;for(const tA of nA.children)if(tA.componentType==="statement")eA=tA;else if(tA.componentType==="givenAnswer"){const iA=tA.children.find(rA=>rA.componentType==="_postponeRenderContainer");iA&&(AA={...iA,componentType:"span",attributes:{...iA.attributes},children:(iA.children??[]).filter(rA=>rA.componentType!=="label"&&rA.componentType!=="shortDescription")},AA.componentIdx=tA.componentIdx,tA.attributes.name&&(AA.attributes.name=tA.attributes.name))}return{statement:eA,givenAnswer:AA}}function arrangedContent(nA){const eA=[];for(const AA of problemChildren(nA)){const{statement:tA,givenAnswer:iA}=arrangedParts(AA);tA&&eA.push(tA),iA&&eA.push(iA)}return eA}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 replacementsAlreadyInResolver=!0;static mapShadowedReplacementIndicesThroughSerializedChildren=!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,componentInfoObjects:tA}){const iA=[];return AA.serializedChildren.some(rA=>isProblemCopy({child:rA,componentInfoObjects:tA}))&&iA.push(codedDiagnostic({type:"warning",code:"doenet-w0176"})),{setValue:{serializedProblemChildren:problemChildren(AA.serializedChildren)},sendDiagnostics:iA}}},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"},variants:{dependencyType:"variants"},variantDescendants:{dependencyType:"descendant",componentTypes:variantDescendantComponentTypes(AA),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=[];for(let sA of AA.variantDescendants)sA.stateValues.isVariantComponent?rA.push(sA.stateValues.generatedVariantInfo):sA.stateValues.generatedVariantInfo&&rA.push(...sA.stateValues.generatedVariantInfo.subvariants);const aA=AA.variants?.arrangedVariantComponentIdxs,oA=new Map(rA.map(sA=>[sA.meta?.createdBy,sA]));return aA?.length===rA.length&&aA.every(sA=>oA.has(sA))&&(rA=aA.map(sA=>oA.get(sA))),iA.subvariants=rA,{setValue:{generatedVariantInfo:iA,isVariantComponent:!0}}}},eA.variantsOfMergedComponents={returnDependencies:()=>({generatedVariantInfo:{dependencyType:"stateVariable",variableName:"generatedVariantInfo"},variants:{dependencyType:"variants"}}),definition({dependencyValues:AA}){const{seed:tA,indices:iA,subvariants:rA}=AA.generatedVariantInfo,aA=new Map(rA.map(sA=>[sA.meta?.createdBy,sA])),oA={};for(const sA of AA.variants?.mergedArrangers??[])oA[sA.componentIdx]={seed:tA,indices:iA,subvariants:(sA.variantComponentIdxs??[]).map(lA=>aA.get(lA)??{})};return{setValue:{variantsOfMergedComponents:oA}}}},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()){const{statement:cA,givenAnswer:gA}=arrangedParts(lA);(cA===null||gA===null)&&(aA=!1),tA.push(cA),iA.push(gA),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,cA=await eA.stateValues.givenAnswers,gA=await eA.stateValues.distractors,uA=await eA.stateValues.mode,IA=new Set(gA);for(let dA=0;dA<oA;dA++){const CA=sA[dA]-1,pA=lA[CA],mA=getCorrespondingAnswerIdx({problemIdx:CA,numProblems:oA,distractorSet:IA}),hA=cA[mA];hA===null?aA.push({type:"serialized",componentType:"span",componentIdx:AA++,stateId:`${iA.prefix}${iA.num++}`,attributes:{},doenetAttributes:{},state:{},children:[]}):aA.push(hA),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:uA==="circuit"&&dA===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,core:tA}){const iA=gatherVariantComponents({serializedComponents:arrangedContent(eA.children),componentInfoObjects:tA.componentInfoObjects});setUpVariantSeedAndRng({serializedComponent:eA,sharedParameters:AA,descendantVariantComponents:iA}),eA.variants??={},eA.variants.arrangedVariantComponentIdxs=iA.map(aA=>aA.componentIdx);const rA=eA.variants.mergedArrangers;if(rA){const aA=eA.children??[];eA.variants.mergedArrangers=rA.map(oA=>({...oA,variantComponentIdxs:gatherVariantComponents({serializedComponents:arrangedContent(aA.filter(sA=>oA.childIdxs.includes(sA?.componentIdx))),componentInfoObjects:tA.componentInfoObjects}).map(sA=>sA.componentIdx)}))}}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(isProblemCopy({child:lA,componentInfoObjects:AA}))continue;return{success:!1}}let aA=determineNumberOfPermutations({numProblems:iA,mode:rA});eA.variants??={};let oA=super.determineNumberOfUniqueVariants({serializedComponent:{...eA,children:arrangedContent(eA.children)},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 cA=[...rA];cA.push(oA);let gA=combinationAtIndex({numberOfOptionsByIndex:cA,index:AA-1}).map(BA=>BA+1),uA=gA.pop(),IA=gA;const dA=getProblemIndicesToPermute({numProblems:sA,mode:lA}),CA=buildProblemOrderFromPermutedIndices({permutedIndices:permutationAtIndex({values:dA,index:uA-1}),numProblems:sA,mode:lA});let pA=!1,mA=[];for(let BA=0;BA<rA.length;BA++)if(rA[BA]>1){let QA=aA[BA],fA=tA.allComponentClasses[QA.componentType].getUniqueVariant({serializedComponent:QA,variantIndex:IA[BA],componentInfoObjects:tA});if(!fA.success)return{success:!1};mA.push(fA.desiredVariant),pA=!0}else mA.push({});let hA={indices:CA};return pA&&(hA.subvariants=mA),{success:!0,desiredVariant:hA}}}class Cascade extends BlockComponent{constructor(eA){super(eA),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="cascade";static isContent=!0;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(cA=>iA.isInheritedComponentType({inheritedComponentType:lA.componentType,baseComponentType:cA}))&&!["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(gA=>gA.componentType==="cascadeMessage").map(gA=>gA.componentIdx);if(tA.revealAll)return{setValue:{childrenToHide:rA,childrenToHideChildren:[],sectionToShowCascadeMessage:null}};const aA=[],oA=[];for(const[gA,uA]of tA.children.entries())gA<=tA.numCompleted?tA.hideChildren&&aA.push(uA.componentIdx):!tA.hideChildren&&!tA.hideFutureSections&&["_sectioningComponent","cascade"].some(IA=>iA.isInheritedComponentType({inheritedComponentType:uA.componentType,baseComponentType:IA}))?oA.push(uA.componentIdx):aA.push(uA.componentIdx);const sA=tA.children[tA.numCompleted+1],lA=sA&&oA.includes(sA.componentIdx)&&sA.stateValues?.hasCascadeMessageToShow?sA.componentIdx:null,cA=lA===null&&(!tA.hideChildren||tA.showCascadeMessage)?nextOwnCascadeMessage(tA):null;return aA.push(...rA.filter(gA=>gA!==cA)),{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 isContent=!0;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}),cA=lA.replacements;AA=lA.nComponents,aA.push(...cA)}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","valueMissing"],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 cA=lA[1];if(cA in unitConversions){let gA=sA.slice(0,lA.index),uA=tA.slice(0,tA.length-1);return gA.length>0&&uA.push(gA),{success:!0,newChildren:[{type:"serialized",componentType:"number",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:uA,attributes:{},doenetAttributes:{},state:{}},cA],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 gA=iA.stringChild[0].trim().match(/^(-?[\d.]+)\s*(.*)$/);if(gA===null)return{setValue:{componentSize:null}};aA=gA[1],oA=gA[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();const AA=returnGroupIntoListEntriesOfComponentType({componentType:"componentSize",forceComponentType:!0,includeNonMacros:!0});let tA=function({matchedChildren:iA,componentInfoObjects:rA,nComponents:aA,stateIdInfo:oA,parentComponentType:sA}){return AA({matchedChildren:iA,componentInfoObjects:rA,nComponents:aA,stateIdInfo:oA,parentComponentType:sA})};return eA.push({replacementFunction:tA}),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 cA=0;cA<lA.stateValues.numComponents;cA++)rA[iA+cA]=[oA,cA];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 cA=iA[lA].componentSizeAndComponentSizeListChildren[0];cA&&(oA.isInheritedComponentType({inheritedComponentType:cA.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 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.drawnMissing?BLANK_RENDERER_TYPE: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,gestureId:tA,sourceInformation:iA={},skipRendererUpdate:rA=!1}={}){const aA=this.fixedReferent??await this.stateValues.referentInfo;!aA||await this.stateValues.fixed||await this.coreFunctions.triggerChainedActions({triggeringAction:eA.endsWith("Clicked")?"click":"focus",componentIdx:aA.componentIdx,actionId:AA,gestureId:tA,sourceInformation:iA,skipRendererUpdate:rA})}_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;rA.valueMissing={dependencyType:"stateVariable",variableName:"valueMissing"};const oA=aA.fixedReferent??iA.referentInfo;return(aA.doenetAttributes.copiesReferent||aA.doenetAttributes.hiddenWithReferent)&&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.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,AA.holdsValue=!0,eA.withoutReaderState||(AA.initialEssentialState={...AA.initialEssentialState??{},...deepClone(AA.state)})}return AA}returnMatchedChildIndices(){return[]}createOnDemandStateVariableDefinitions({stateVariable:eA,classDefinitions:AA}){if(eA==="valueMissing")return[[eA,this.fixedReferent?fixedReferentMissingDefinition(this.fixedReferent):valueMissingDefinition()]];if(eA==="namesNothing")return[[eA,namesNothingDefinition(this.fixedReferent,this.componentInfoObjects)]];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),listEntrySourceOf:referentListEntrySource,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 cA=this.componentInfoObjects.stateVariableInfo[this.presentedComponentType].arrayEntryPrefixes,gA=Object.keys(cA).filter(uA=>oA.startsWith(uA)).sort((uA,IA)=>IA.length-uA.length)[0];if(gA!==void 0&&(oA=cA[gA].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(cA=>[cA,Object.create(aA[cA])])}}const VALUE_REFERENCE_DOENET_ATTRIBUTES=["presentedComponentType","referencedComponentType","adapterVariable","fixedReferent","copiesReferent","hiddenWithReferent","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}}}function referentListEntrySource(nA,eA){const AA=nA.fixedReferent??eA.referentInfo;if(AA?.listEntryPosition===void 0)return;const tA=nA.componentInfoObjects.allComponentClasses[AA.componentType]?.listEntryContextArrays;if(tA)return{componentIdx:AA.componentIdx,index:AA.listEntryPosition-1,variables:tA}}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={valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA?.referencedWholeComponent?rA.wholeReferent=wholeReferentResponseDependency(iA):iA&&(rA.referenced={dependencyType:"stateVariable",componentIdx:iA.componentIdx,variableName:iA.referencedVariable,variablesOptional:!0}),rA},definition({dependencyValues:tA,componentInfoObjects:iA}){if(tA.valueMissing)return{setValue:{valueAsResponse:missingResponseValue(missingResponseType(tA,nA),iA)}};if(tA.wholeReferent)return{setValue:{valueAsResponse:wholeReferentResponse(tA.wholeReferent).value}};let rA=tA.referenced;return rA==null&&(rA=emptyValueOfType(nA,iA)),{setValue:{valueAsResponse:rA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function componentTypeAsResponseDefinition(nA,eA){const AA={returnDependencies({stateValues:tA={}}){const iA=eA??tA.referentInfo,rA={valueMissing:{dependencyType:"stateVariable",variableName:"valueMissing"}};return iA?.referencedWholeComponent&&(rA.wholeReferent=wholeReferentResponseDependency(iA)),rA},definition({dependencyValues:tA}){let iA=nA;return tA.valueMissing?iA=missingResponseType(tA,nA):tA.wholeReferent&&(iA=wholeReferentResponse(tA.wholeReferent).componentType),{setValue:{componentTypeAsResponse:iA}}}};return eA||(AA.stateVariablesDeterminingDependencies=["referentInfo"]),AA}function missingResponseType(nA,eA){return nA.wholeReferent?nA.wholeReferent.stateValues?.componentType??nA.wholeReferent.componentType??"math":eA===void 0||eA==="_missing"?"math":eA}function wholeReferentResponseDependency(nA){return{dependencyType:"multipleStateVariables",componentIdx:nA.componentIdx,variableNames:["value","formula","componentType"],variablesOptional:!0}}function wholeReferentResponse(nA){const eA=nA.stateValues??{};return eA.value!==void 0?{value:eA.value,componentType:eA.componentType??nA.componentType}:eA.formula instanceof context.class?{value:eA.formula,componentType:"math"}:{value:"",componentType:"text"}}function fixedReferentMissingDefinition(nA){return{returnDependencies:()=>({targetMissing:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:"valueMissing",variablesOptional:!0},...nA.listEntryPosition===void 0?{}:{entryMissing:{dependencyType:"stateVariable",componentIdx:nA.componentIdx,variableName:`entryMissing${nA.listEntryPosition}`,variablesOptional:!0}}}),definition({dependencyValues:eA}){return{setValue:{valueMissing:!!eA.targetMissing||!!eA.entryMissing}}}}}function namesNothingDefinition(nA,eA){return{...nA?{}:{stateVariablesDeterminingDependencies:["referentInfo"]},returnDependencies({stateValues:AA={}}){const tA=nA??AA.referentInfo;if(!tA)return{};const iA={hasReferent:{dependencyType:"value",value:!0}};if(tA.listEntryPosition!==void 0)iA.entry={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:tA.variableName,variablesOptional:!0},iA.entryMissing={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:`entryMissing${tA.listEntryPosition}`,variablesOptional:!0};else{const rA=eA.allComponentClasses[tA.componentType],aA=["namesNothing"];rA?.missingWhenContentMissing&&aA.push("contentMissing"),rA?.missingWhenContentNamesNothing&&(tA.referencedWholeComponent||tA.referencedPrimaryValue)&&aA.push("contentNamesNothing");for(const oA of aA)iA[oA]={dependencyType:"stateVariable",componentIdx:tA.componentIdx,variableName:oA,variablesOptional:!0}}return iA},definition({dependencyValues:AA}){return{setValue:{namesNothing:!AA.hasReferent||"entry"in AA&&AA.entry==null||!!AA.entryMissing||!!AA.namesNothing||!!AA.contentMissing||!!AA.contentNamesNothing}}}}}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 rA of AA)tA[rA]={math:{dependencyType:"stateVariable",variableName:"math"+(Number(rA)+1)}};return{dependenciesByKey:tA,globalDependencies:{variablesDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths","strings"]}}}},arrayDefinitionByKey({globalDependencyValues:AA,dependencyValuesByKey:tA,arrayKeys:iA}){let rA={},aA={},oA={};for(let sA of iA){let lA=tA[sA].math,cA=isValidVariable(lA);oA[sA]=[],cA||(oA[sA].push(codedDiagnostic({type:levelFromSource(AA.variablesDecidedByDoenetML),code:"doenet-w0017",args:{value:lA.toString()}})),cA=!1),rA[sA]=lA,aA[sA]=cA}return{setValue:{variables:rA,validVariables:aA},conditionDiagnosticsByKey:oA}}},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"},valueDecidedByDoenetML:{dependencyType:"decidedByDoenetML",childGroups:["maths","strings"]}}),definition({dependencyValues:AA}){let tA=[],iA=isValidVariable(AA.valuePreValidate);return iA||tA.push(codedDiagnostic({type:levelFromSource(AA.valueDecidedByDoenetML),code:"doenet-w0017",args:{value:AA.valuePreValidate.toString()}})),{setValue:{value:AA.valuePreValidate,validVariable:iA},conditionDiagnostics: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,isAttributeComponent:aA,parentComponentType:oA}){let sA=breakIntoBracketedListEntries({componentList:tA,removeBrackets:!0});return sA.success!==!0?{success:!1,diagnostics:sA.unmatchedBrackets?[listBracketsUnmatchedDiagnostic(aA?oA:"_listOfNumberLists",!1)]:[]}:{success:!0,newChildren:sA.pieces.map(lA=>({type:"serialized",componentType:"numberList",componentIdx:iA++,stateId:rA?`${rA.prefix}${rA.num++}`:void 0,children:lA,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 cA=0;cA<oA;cA++){let gA=AA.unnormalizedDirection.get_component(cA).evaluate_to_constant();if(Number.isFinite(gA))aA.push(gA),sA+=gA*gA;else{lA=!1;break}}if(lA){let cA=Math.sqrt(sA);for(let gA=0;gA<oA;gA++)iA[gA.toString()]=context.fromAst(aA[gA]/cA)}else for(let cA=0;cA<oA;cA++)iA[cA.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 Missing extends InlineComponent{static componentType="_missing";static rendererType=BLANK_RENDERER_TYPE;static excludeFromSchema=!0;static returnStateVariableDefinitions(){const eA=super.returnStateVariableDefinitions();return eA.valueMissing={returnDependencies:()=>({}),definition:()=>({setValue:{valueMissing:!0}})},eA.namesNothing={returnDependencies:()=>({}),definition:()=>({setValue:{namesNothing:!0}})},eA.text={returnDependencies:()=>({}),definition:()=>({setValue:{text:MISSING_TEXT}})},eA.value={returnDependencies:()=>({}),definition:()=>({setValue:{value:context.fromAst(MISSING_TEXT)}})},eA.canBeModified={returnDependencies:()=>({}),definition:()=>({setValue:{canBeModified:!1}})},eA.unordered={returnDependencies:()=>({}),definition:()=>({setValue:{unordered:!1}})},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(SelectionParameter$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,Missing,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 cA in nA)AA[cA.toLowerCase()]=cA;function tA(cA){return Object.hasOwn(nA,cA)?cA:void 0}const iA={};for(const cA in nA)Object.defineProperty(iA,cA,{get:(function(){const gA=nA[cA].returnStateVariableInfo();return delete iA[cA],iA[cA]=gA}).bind(this),configurable:!0});const rA={};for(const cA in nA)Object.defineProperty(rA,cA,{get:(function(){const gA=nA[cA].returnStateVariableInfo({onlyPublic:!0});return delete rA[cA],rA[cA]=gA}).bind(this),configurable:!0});function aA({inheritedComponentType:cA,baseComponentType:gA}){if(cA===gA)return!0;if(cA==="string")return gA==="_base"||gA==="_inline";if(gA==="string")return!1;let uA=nA[gA];return uA?uA.isPrototypeOf(nA[cA]):!1}function oA({componentType:cA,includeNonStandard:gA=!0}){const uA=nA[cA];return uA?aA({inheritedComponentType:cA,baseComponentType:"_composite"})&&(gA||!uA.treatAsComponentForRecursiveReplacements):!1}const sA=(cA,gA)=>aA({inheritedComponentType:cA,baseComponentType:gA});return{allComponentClasses:nA,componentTypesCreatingVariants:eA,componentTypeLowerCaseMapping:AA,componentTypeAsWritten:tA,isInheritedComponentType:aA,isCompositeComponent:oA,stateVariableInfo:iA,publicStateVariableInfo:rA,componentIsSpecifiedType:(cA,gA)=>sA(cA.componentType,gA)||cA.attributes?._createComponentOfType?.primitive!==void 0&&sA(cA.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)}function referenceOf(nA){const eA=nA.extending;if(eA)return eA.Ref??eA.ExtendAttribute??eA.CopyAttribute??eA.CopyWithStateAttribute}function authoredComponents(nA){const eA=new Map,AA=new Map;function tA(iA){if(typeof iA!="object"||iA===null||eA.has(iA.componentIdx))return;eA.set(iA.componentIdx,iA),AA.set(iA.componentIdx,AA.size);for(const aA of Object.values(iA.attributes??{})){aA?.component&&tA(aA.component);for(const oA of aA?.references??[])tA(oA);for(const oA of aA?.children??[])tA(oA)}const rA=referenceOf(iA);for(const aA of rA?.unresolvedPath??[])for(const oA of aA?.index??[])for(const sA of oA?.value??[])tA(sA);for(const aA of iA.children??[])tA(aA)}return tA(nA),{byIdx:eA,order:AA}}function authoredNodesOf(nA,eA,AA){const tA=new Set,iA=new Set,rA=[nA];for(;rA.length>0;){const aA=rA.pop();if(iA.has(aA))continue;if(iA.add(aA),eA.has(aA)){tA.add(aA);continue}const oA=AA[aA];if(!oA)continue;oA.madeFromIdx!==void 0&&rA.push(oA.madeFromIdx);const sA=oA.replacementOf?.componentIdx??oA.shadows?.componentIdx??oA.parentIdx;sA!==void 0&&rA.push(sA)}return tA}function isOfAttributeWritten(nA,eA){return Object.keys(nA.attributes??{}).some(AA=>{const tA=AA.toLowerCase();return eA===tA||eA.startsWith(`__${tA}_`)})}function authoredOwnerOf(nA,eA,AA,tA){const iA=new Set,rA=[];let aA=nA;for(;aA!==void 0&&!iA.has(aA);){if(AA.has(aA))return{owner:aA,passed:rA};iA.add(aA);const oA=tA[aA];let sA=oA?.replacementOf?.componentIdx;const lA=new Set;for(;sA!==void 0&&!AA.has(sA)&&!lA.has(sA);)lA.add(sA),sA=tA[sA]?.madeFromIdx;const cA=sA===void 0?void 0:AA.get(sA);if(cA?.componentType==="_copy"&&oA?.madeFromIdx!==void 0&&isOfAttributeWritten(cA,eA)){const gA=authoredOwnerOf(oA.madeFromIdx,eA,AA,tA);return gA.owner!==void 0&&rA.push(gA.owner),rA.push(...gA.passed),{owner:cA.componentIdx,passed:rA}}cA?.componentType==="_copy"&&oA?.madeFromIdx!==void 0&&rA.push(cA.componentIdx),aA=oA?.madeFromIdx}return{owner:void 0,passed:rA}}function blameLoadCycle({componentIndices:nA,stateVariables:eA=[],components:AA,document:tA,componentInfoObjects:iA}){const{byIdx:rA,order:aA}=authoredComponents(tA),oA=new Set;for(const mA of nA)for(const hA of authoredNodesOf(mA,rA,AA))hA!==tA.componentIdx&&oA.add(hA);const sA=new Map;function lA(mA){let hA=sA.get(mA);return hA||(hA=new Set,sA.set(mA,hA)),hA}for(const[mA,hA]of eA){if(typeof hA!="string")continue;const BA=hA.toLowerCase(),{owner:QA,passed:EA}=authoredOwnerOf(mA,BA,rA,AA);if(QA!==void 0){lA(QA).add(BA);for(const fA of EA)lA(fA)}}const cA=[...oA].sort((mA,hA)=>aA.get(mA)-aA.get(hA));function gA(mA,hA){return iA.isInheritedComponentType({inheritedComponentType:mA,baseComponentType:hA})}function uA(mA){return mA.componentType==="_copy"||mA.componentType==="_ref"}function IA(mA){if(!uA(mA))return!1;const hA=referenceOf(mA),BA=hA?.unresolvedPath?.[0]?.name;if(typeof BA!="string"||!NUMBER_PROPERTIES.has(BA.toLowerCase()))return!1;const QA=rA.get(hA.nodeIdx);return QA!==void 0&&oA.has(QA.componentIdx)&&gA(QA.componentType,"_sectioningComponent")}const dA=cA.find(mA=>IA(rA.get(mA)));if(dA!==void 0)return{blamed:dA,onCycle:oA,variablesOnCycle:sA};const CA=cA.filter(mA=>uA(rA.get(mA))||iA.isCompositeComponent({componentType:rA.get(mA).componentType,includeNonStandard:!0})),pA=CA.find(mA=>sA.get(mA)?.size!==0)??CA[0];if(pA!==void 0)return{blamed:pA,onCycle:oA,variablesOnCycle:sA};if(cA.length!==0)return{blamed:cA[0],onCycle:oA,variablesOnCycle:sA}}const MAX_LOAD_CYCLE_REBUILDS=5;function madeAnError(nA,eA){const AA=[nA];for(;AA.length>0;){const tA=AA.pop();if(typeof tA!="object"||tA===null)continue;if(tA.componentIdx===eA)return tA.componentType==="_error";for(const aA of Object.values(tA.attributes??{}))AA.push(aA?.component,...aA?.references??[],...aA?.children??[]);const iA=tA.extending,rA=iA?.Ref??iA?.ExtendAttribute??iA?.CopyAttribute??iA?.CopyWithStateAttribute;for(const aA of[rA?.unresolvedPath,rA?.originalPath])for(const oA of aA??[])for(const sA of oA?.index??[])AA.push(...sA?.value??[]);AA.push(...tA.children??[])}return!1}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:cA,saveResolver:gA,restoreResolver:uA,releaseSavedResolver:IA}){this.addNodesToResolver=aA,this.replaceIndexResolutionsInResolver=oA,this.deleteNodesFromResolver=sA,this.resolvePath=lA,this.updateRootNames=cA,this.saveResolver=gA,this.restoreResolver=uA,this.releaseSavedResolver=IA,this._normalizedRootForRebuild=void 0;let dA=createComponentInfoObjects();gA&&uA&&(gA(),this._normalizedRootForRebuild=structuredClone(rA));const{document:CA,nComponents:pA,diagnostics:mA,sources:hA}=await normalizedDastToSerializedComponents(rA,dA,aA);this.coreBaseArgs={doenetML:this.doenetML,flags:this.flags,localeData:this.localeData,activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,serializedDocument:CA,nComponentsInit:pA,allDoenetMLs:hA,preliminaryDiagnostics:mA,componentInfoObjects:dA},this.initialized=!0;let BA=await returnAllPossibleVariants(this.coreBaseArgs.serializedDocument,this.coreBaseArgs.componentInfoObjects,mA);const QA=this.coreBaseArgs.serializedDocument.children.reduce((EA,fA)=>(typeof fA=="object"&&(EA[fA.componentType]=(EA[fA.componentType]??0)+1),EA),{});return{allPossibleVariants:BA,baseComponentCounts:QA}}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){const cA=lA.serializedDocument;this.core=new Core(lA),this.coreBaseArgs.serializedDocument=void 0;try{let gA;try{gA=await this.core.generateDast()}catch(uA){if(!(uA instanceof CircularDependencyError))throw uA;gA=await this.rebuildAroundLoadCycle(uA,cA,lA)}return{success:!0,...gA}}catch(gA){return console.error(gA),{success:!1,errMsg:typeof gA=="object"&&gA&&"message"in gA&&typeof gA.message=="string"?gA.message:""}}finally{this._releaseRebuildData()}}else return{success:!1,coreId:lA.coreId,errMsg:"Internal error. Cannot create document. Core not initialized."}}async rebuildAroundLoadCycle(eA,AA,tA){const iA=this._normalizedRootForRebuild;if(!iA||!this.restoreResolver||!AA)throw eA;this._normalizedRootForRebuild=void 0;const rA=[];let aA=AA;for(let oA=1;oA<=MAX_LOAD_CYCLE_REBUILDS;oA++){const sA=this.core,lA=blameLoadCycle({componentIndices:eA.componentIndices,stateVariables:eA.stateVariables,components:sA._components,document:aA,componentInfoObjects:tA.componentInfoObjects});if(lA===void 0||(rA.push(lA),sA.abandonLoad(),this.core=null,!this.restoreResolver()))throw eA;const{document:cA,nComponents:gA,diagnostics:uA}=await normalizedDastToSerializedComponents(oA<MAX_LOAD_CYCLE_REBUILDS?structuredClone(iA):iA,tA.componentInfoObjects,this.addNodesToResolver,{loadCycles:rA});if(rA.some(IA=>IA.made===void 0||!madeAnError(cA,IA.made))||new Set(rA.map(IA=>IA.made)).size<rA.length)throw eA;await returnAllPossibleVariants(cA,tA.componentInfoObjects,uA),this.core=new Core({...tA,serializedDocument:cA,nComponentsInit:gA,preliminaryDiagnostics:uA});try{return await this.core.generateDast()}catch(IA){if(!(IA instanceof CircularDependencyError))throw IA;eA=IA,aA=cA}}throw eA}_releaseRebuildData(){this._normalizedRootForRebuild=void 0,this.releaseSavedResolver?.()}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 cA in sA.state){if(["replacements","recursiveReplacements","fullRecursiveReplacements"].includes(cA)&&this.core.componentInfoObjects.isCompositeComponent({componentType:sA.componentType})&&!sA.isExpanded)continue;const gA=await sA.state[cA].value;lA.stateValues[cA]=AA?gA:removeFunctionsMathExpressionClass(gA)}lA.activeChildren=sA.activeChildren.map(cA=>cA.componentIdx?{componentIdx:cA.componentIdx,componentType:cA.componentType}:cA),sA.replacements&&(lA.replacements=sA.replacements.map(cA=>cA.componentIdx?{componentIdx:cA.componentIdx,componentType:cA.componentType}:cA),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,cA=aA.l,gA=aA.a,uA=aA.b,IA=180/Math.PI,dA=Math.PI/180,CA=Math.pow(Math.pow(sA,2)+Math.pow(lA,2),.5),pA=Math.pow(Math.pow(gA,2)+Math.pow(uA,2),.5),mA=(oA+cA)/2,hA=Math.pow((CA+pA)/2,7),BA=.5*(1-Math.pow(hA/(hA+Math.pow(25,7)),.5)),QA=sA*(1+BA),EA=gA*(1+BA),fA=Math.pow(Math.pow(QA,2)+Math.pow(lA,2),.5),yA=Math.pow(Math.pow(EA,2)+Math.pow(uA,2),.5),DA=(fA+yA)/2,bA=QA===0&&lA===0?0:Math.atan2(lA,QA)*IA,NA=EA===0&&uA===0?0:Math.atan2(uA,EA)*IA;bA<0&&(bA+=360),NA<0&&(NA+=360);var wA=NA-bA,MA=Math.abs(NA-bA);MA>180&&NA<=bA?wA+=360:MA>180&&NA>bA&&(wA-=360);var vA=bA+NA;MA<=180?vA/=2:vA=(bA+NA<360?vA+360:vA-360)/2;var TA=1-.17*Math.cos(dA*(vA-30))+.24*Math.cos(2*dA*vA)+.32*Math.cos(dA*(3*vA+6))-.2*Math.cos(dA*(4*vA-63)),kA=cA-oA,OA=yA-fA,FA=2*Math.sin(dA*wA/2)*Math.pow(fA*yA,.5),GA=1+.015*Math.pow(mA-50,2)/Math.pow(20+Math.pow(mA-50,2),.5),RA=1+.045*DA,jA=1+.015*DA*TA,WA=30*Math.exp(-1*Math.pow((vA-275)/25,2)),zA=-2*Math.pow(hA/(hA+Math.pow(25,7)),.5)*Math.sin(2*dA*WA);return Math.pow(Math.pow(kA/1/GA,2)+Math.pow(OA/1/RA,2)+Math.pow(FA/1/jA,2)+zA*OA*FA/(1*RA*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 cA=this.toRgb(),gA=1/0,uA="black";if(!rA.length)for(var IA in AA)rA[IA]=new nA(AA[IA]).toRgb();for(var dA in AA){var CA=(oA=cA,sA=rA[dA],Math.pow(oA.r-sA.r,2)+Math.pow(oA.g-sA.g,2)+Math.pow(oA.b-sA.b,2));CA<gA&&(gA=CA,uA=dA)}return uA}},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 hA=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+pA+" bytes: "+mA+" <-");throw hA.position=pA,hA},sA=function(pA){for(var mA="",hA=pA.length,BA=0,QA=0,EA,fA;BA<hA;){if(EA=pA[BA++],EA<=127){mA+=String.fromCharCode(EA);continue}else EA>191&&EA<=223?(fA=EA&31,QA=1):EA<=239?(fA=EA&15,QA=2):EA<=247?(fA=EA&7,QA=3):oA(BA,mA);for(var yA=0;yA<QA;++yA)EA=pA[BA++],(EA<128||EA>191)&&oA(BA,mA),fA<<=6,fA+=EA&63;fA>=55296&&fA<=57343&&oA(BA,mA),fA>1114111&&oA(BA,mA),fA<=65535?mA+=String.fromCharCode(fA):(fA-=65536,mA+=String.fromCharCode((fA>>10)+55296),mA+=String.fromCharCode((fA&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,hA,BA,QA,EA,fA,yA,DA,bA=[],NA=0,wA=pA.length,MA=0,vA=wA>>3<<3;MA<vA;)mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255,bA[NA++]=(EA<<7|fA<<2|yA>>>3)&255,bA[NA++]=(yA<<5|DA)&255;var TA=wA-vA;return TA===2?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255):TA===4?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255):TA===5?(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255):TA===7&&(mA=rA[pA.charAt(MA++)],hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],bA[NA++]=(mA<<3|hA>>>2)&255,bA[NA++]=(hA<<6|BA<<1|QA>>>4)&255,bA[NA++]=(QA<<4|EA>>>1)&255,bA[NA++]=(EA<<7|fA<<2|yA>>>3)&255),bA},cA=function(pA){for(var mA,hA,BA,QA,EA,fA="",yA=pA.length,DA=0,bA=parseInt(yA/5)*5;DA<bA;)mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA++),QA=pA.charCodeAt(DA++),EA=pA.charCodeAt(DA++),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31];var NA=yA-bA;return NA===1?(mA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):NA===2?(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):NA===4&&(mA=pA.charCodeAt(DA++),hA=pA.charCodeAt(DA++),BA=pA.charCodeAt(DA++),QA=pA.charCodeAt(DA),fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"="),fA},gA=function(pA){var mA,hA,BA,QA,EA,fA,yA=!1,DA="",bA=0,NA,wA=0,MA=pA.length;if(pA==="")return DA;do{for(aA[0]=aA[5],aA[1]=aA[6],aA[2]=aA[7],NA=wA;bA<MA&&NA<5;++bA)fA=pA.charCodeAt(bA),fA<128?aA[NA++]=fA:fA<2048?(aA[NA++]=192|fA>>6,aA[NA++]=128|fA&63):fA<55296||fA>=57344?(aA[NA++]=224|fA>>12,aA[NA++]=128|fA>>6&63,aA[NA++]=128|fA&63):(fA=65536+((fA&1023)<<10|pA.charCodeAt(++bA)&1023),aA[NA++]=240|fA>>18,aA[NA++]=128|fA>>12&63,aA[NA++]=128|fA>>6&63,aA[NA++]=128|fA&63);wA=NA-5,bA===MA&&++bA,bA>MA&&NA<6&&(yA=!0),mA=aA[0],NA>4?(hA=aA[1],BA=aA[2],QA=aA[3],EA=aA[4],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31]):NA===1?DA+=iA[mA>>>3]+iA[mA<<2&31]+"======":NA===2?(hA=aA[1],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(hA=aA[1],BA=aA[2],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):(hA=aA[1],BA=aA[2],QA=aA[3],DA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"=")}while(!yA);return DA},uA=function(pA){for(var mA,hA,BA,QA,EA,fA="",yA=pA.length,DA=0,bA=parseInt(yA/5)*5;DA<bA;)mA=pA[DA++],hA=pA[DA++],BA=pA[DA++],QA=pA[DA++],EA=pA[DA++],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[(QA<<3|EA>>>5)&31]+iA[EA&31];var NA=yA-bA;return NA===1?(mA=pA[DA],fA+=iA[mA>>>3]+iA[mA<<2&31]+"======"):NA===2?(mA=pA[DA++],hA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[hA<<4&31]+"===="):NA===3?(mA=pA[DA++],hA=pA[DA++],BA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[BA<<1&31]+"==="):NA===4&&(mA=pA[DA++],hA=pA[DA++],BA=pA[DA++],QA=pA[DA],fA+=iA[mA>>>3]+iA[(mA<<2|hA>>>6)&31]+iA[hA>>>1&31]+iA[(hA<<4|BA>>>4)&31]+iA[(BA<<1|QA>>>7)&31]+iA[QA>>>2&31]+iA[QA<<3&31]+"="),fA},IA=function(pA,mA){var hA=typeof pA!="string";return hA&&pA.constructor===ArrayBuffer&&(pA=new Uint8Array(pA)),hA?uA(pA):mA?cA(pA):gA(pA)},dA=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 hA,BA,QA,EA,fA,yA,DA,bA,NA="",wA=pA.indexOf("=");wA===-1&&(wA=pA.length);for(var MA=0,vA=wA>>3<<3;MA<vA;)hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],bA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)+String.fromCharCode((fA<<7|yA<<2|DA>>>3)&255)+String.fromCharCode((DA<<5|bA)&255);var TA=wA-vA;return TA===2?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)):TA===4?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)):TA===5?(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)):TA===7&&(hA=rA[pA.charAt(MA++)],BA=rA[pA.charAt(MA++)],QA=rA[pA.charAt(MA++)],EA=rA[pA.charAt(MA++)],fA=rA[pA.charAt(MA++)],yA=rA[pA.charAt(MA++)],DA=rA[pA.charAt(MA++)],NA+=String.fromCharCode((hA<<3|BA>>>2)&255)+String.fromCharCode((BA<<6|QA<<1|EA>>>4)&255)+String.fromCharCode((EA<<4|fA>>>1)&255)+String.fromCharCode((fA<<7|yA<<2|DA>>>3)&255)),NA},CA={encode:IA,decode:dA};dA.asBytes=lA,tA?nA.exports=CA:eA.base32=CA})()})(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(dA=>{const CA=shiftForRemovedChild(dA,sA);return CA&&CA.firstInd>=aA&&CA.lastInd<=oA?[{range:dA,...CA}]:[]}).sort((dA,CA)=>dA.firstInd-CA.firstInd||CA.lastInd-dA.lastInd),cA={range:null,firstInd:aA,lastInd:oA,nextInd:aA,eligibility:null,items:[],eligible:[]},gA=[cA];function uA(dA,CA){for(;dA.nextInd<CA;dA.nextInd++){const pA=nA[dA.nextInd];AA(pA)||(dA.items.push({kind:"child",value:pA,index:dA.nextInd}),dA.eligibility&&dA.eligible.push(dA.eligibility[dA.nextInd-dA.firstInd]??!1))}}function IA(){const dA=gA.pop();if(uA(dA,dA.lastInd+1),dA.items.length===0)return;const CA=gA[gA.length-1],pA=dA.items.filter(BA=>!isBlankGroup(BA,tA)),mA=dA.eligible.every((BA,QA)=>BA||isBlankGroup(dA.items[QA],tA)),hA=!!dA.range.asList&&mA&&pA.length>1;CA.items.push({kind:"composite",range:dA.range,asList:hA,items:hA?prepareListItems(dA.items,tA,rA):dA.items}),CA.eligibility&&CA.eligible.push(mA)}for(const{range:dA,firstInd:CA,lastInd:pA}of lA){for(;gA.length>1&&pA>gA[gA.length-1].lastInd;)IA();const mA=gA[gA.length-1];CA<mA.nextInd||(uA(mA,CA),mA.nextInd=pA+1,!iA(dA)&&gA.push({range:dA,firstInd:CA,lastInd:pA,nextInd:CA,eligibility:dA.potentialListComponents??null,items:[],eligible:[]}))}for(;gA.length>1;)IA();return uA(cA,oA+1),cA.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 cA={};for(var gA in lA)cA[gA]=eA.call(sA,gA)?sA[gA]:lA[gA];return cA},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 cA=lA.quotes=="double"?'"':"'",gA=lA.isIdentifier,uA=sA.charAt(0),IA="",dA=0,CA=sA.length;dA<CA;){var pA=sA.charAt(dA++),mA=pA.charCodeAt(),hA=void 0;if(mA<32||mA>126){if(mA>=55296&&mA<=56319&&dA<CA){var BA=sA.charCodeAt(dA++);(BA&64512)==56320?mA=((mA&1023)<<10)+(BA&1023)+65536:dA--}hA="\\"+mA.toString(16).toUpperCase()+" "}else lA.escapeEverything?tA.test(pA)?hA="\\"+pA:hA="\\"+mA.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(pA)?hA="\\"+mA.toString(16).toUpperCase()+" ":pA=="\\"||!gA&&(pA=='"'&&cA==pA||pA=="'"&&cA==pA)||gA&&iA.test(pA)?hA="\\"+pA:hA=pA;IA+=hA}return gA&&(/^-[-\d]/.test(IA)?IA="\\-"+IA.slice(1):/\d/.test(uA)&&(IA="\\3"+uA+" "+IA.slice(1))),IA=IA.replace(rA,function(QA,EA,fA){return EA&&EA.length%2?QA:(EA||"")+fA}),!gA&&lA.wrap?cA+IA+cA:IA};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(cA=>isBlankGroup(cA,isBlankChild)),oA=aA.indexOf(!1),sA=aA.lastIndexOf(!1),lA=iA.items.slice(oA,sA+1).filter((cA,gA)=>!aA[oA+gA]);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 gA of aA.childrenInstructions){if(gA==null){sA.push(null);continue}if(sA.push(childInstructionToContent(gA,iA)),typeof gA=="string")continue;const uA=tA[gA.componentIdx];uA?uA.type==="element"&&(uA.name=gA.componentType,uA.data.id=gA.componentIdx,uA.data.action_names=Object.keys(gA.actions)):tA[gA.componentIdx]={type:"element",name:gA.componentType,attributes:{},children:[],data:{id:gA.componentIdx,action_names:Object.keys(gA.actions)}}}const{children:lA,wrapperElements:cA}=applyCompositeListWrapping(sA,aA.stateValues?._compositeReplacementActiveRange);oA.children=lA;for(const gA of cA)tA[gA.data.id]=gA}}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,cA=[];if(lA)for(const CA of lA){if(CA==null){cA.push(null);continue}cA.push(childInstructionToContent(CA,AA))}const{children:gA,wrapperElements:uA}=applyCompositeListWrapping(cA,sA?._compositeReplacementActiveRange),IA={type:"element",name:eA[oA]??"",children:gA,data:{id:oA,props:{...sA}}};applyElementJsToRustFixups(IA,AA);const dA={changedState:IA.data.props};lA&&(dA.newChildren=IA.children),iA(oA,dA);for(const CA of uA)iA(CA.data.id,{newFlatDastElement:CA})}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.childIndex||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 cA=oA.unresolvedPath[0].index;if(cA.length===0)throw Error("Something went wrong as we have a ref resolution without a name or an index");if(typeof cA[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.883/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(QA){return hA.update_root_names(QA)},cA=function(QA,EA,fA){return hA.resolve_path(QA,EA,fA)},gA=function(QA,EA){hA.add_nodes_to_resolver(QA,EA)},uA=function(QA,EA){hA.replace_index_resolutions_in_resolver(QA,EA)},IA=function(QA){hA.delete_nodes_from_resolver(QA)},dA=function(){hA.save_resolver()},CA=function(){return hA.restore_resolver()},pA=function(){hA.release_saved_resolver()};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 mA=this.doenetCore.return_normalized_dast_root();const hA=this.doenetCore,BA=await this.javascriptCore.initializeWorker({activityId:eA,docId:AA,requestedVariantIndex:tA,attemptNumber:iA,normalizedRoot:mA,addNodesToResolver:gA,replaceIndexResolutionsInResolver:uA,deleteNodesFromResolver:IA,resolvePath:cA,updateRootNames:lA,saveResolver:dA,restoreResolver:CA,releaseSavedResolver:pA});return this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0,BA}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:cA,resolve:gA}=promiseWithResolver();if(this.isProcessingPromise=cA,await lA,!this.javascript_initialized||!this.javascriptCore)throw Error("Cannot return javascript dast before initializing javascript core");try{discardStalePanicMessage();const uA=await this.javascriptCore?.createCoreGenerateDast(eA,AA,tA,iA,rA,aA,oA,sA);if(uA?.success===!1){const IA=readPanicMessage();IA!==void 0&&throwAsDocumentBuildError(new Error(uA.errMsg??""),IA)}return uA}catch(uA){console.error(uA),throwAsDocumentBuildError(uA,readPanicMessage())}finally{gA()}}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(NA){return tA.update_root_names(NA)}function rA(NA,wA,MA){return tA.resolve_path(NA,wA,MA)}function aA(NA,wA){tA.add_nodes_to_resolver(NA,wA)}function oA(NA,wA){tA.replace_index_resolutions_in_resolver(NA,wA)}function sA(NA){tA.delete_nodes_from_resolver(NA)}function lA(){tA.save_resolver()}function cA(){return tA.restore_resolver()}function gA(){tA.release_saved_resolver()}await this.javascriptCore.initializeWorker({activityId:"a",docId:"a",requestedVariantIndex:eA,attemptNumber:1,normalizedRoot:AA,addNodesToResolver:aA,replaceIndexResolutionsInResolver:oA,deleteNodesFromResolver:sA,resolvePath:rA,updateRootNames:iA,saveResolver:lA,restoreResolver:cA,releaseSavedResolver:gA}),this.javascript_initialized=!0,this.doenetCore.release_initialization_data(),this._initializationDataReleased=!0;const uA={coreId:"a",cid:null,initializeCounters:{}};let IA=null;this._javascriptUpdateBuffer=[];const dA=NA=>{NA.init?IA=NA.updateInstructions:this._capturingJavascriptUpdates&&NA.updateInstructions&&this._javascriptUpdateBuffer.push(...NA.updateInstructions)},CA=NA=>{},pA=NA=>{},mA=NA=>{},hA=NA=>{},BA=NA=>{},QA=NA=>Promise.resolve({allowView:!0}),EA=await this.javascriptCore.createCoreGenerateDast(uA,dA,CA,pA,mA,hA,BA,QA);if(!EA.success)throw console.error(EA.errMsg),Error(EA.errMsg);if(IA===null)throw Error("Need to address case where do not get updateRenderersCallback before dast");const fA=EA.coreInfo.documentToRender,{componentIdxToName:yA,doenetIdToComponentIdx:DA}=seedInstructionMaps(fA,IA);return this._componentIdxToName=yA,this._doenetIdToComponentIdx=DA,this._javascriptInitialRenderDone=!0,flatDastFromJS(fA,IA)}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(IA){for(var dA=Math.sqrt(IA),CA=2;CA<=dA;CA++)if(!(IA%CA))return!1;return!0}function cA(IA){return(IA-(IA|0))*4294967296|0}for(var gA=2,uA=0;uA<64;)lA(gA)&&(tA[uA]=cA(Math.pow(gA,.3333333333333333)),uA++),gA++})();var iA=function(lA){for(var cA=[],gA=0,uA=0;gA<lA.length;gA++,uA+=8)cA[uA>>>5]|=lA[gA]<<24-uA%32;return cA},rA=function(lA){for(var cA=[],gA=0;gA<lA.length*32;gA+=8)cA.push(lA[gA>>>5]>>>24-gA%32&255);return cA},aA=[],oA=function(lA,cA,gA){for(var uA=lA[0],IA=lA[1],dA=lA[2],CA=lA[3],pA=lA[4],mA=lA[5],hA=lA[6],BA=lA[7],QA=0;QA<64;QA++){if(QA<16)aA[QA]=cA[gA+QA]|0;else{var EA=aA[QA-15],fA=(EA<<25|EA>>>7)^(EA<<14|EA>>>18)^EA>>>3,yA=aA[QA-2],DA=(yA<<15|yA>>>17)^(yA<<13|yA>>>19)^yA>>>10;aA[QA]=fA+aA[QA-7]+DA+aA[QA-16]}var bA=pA&mA^~pA&hA,NA=uA&IA^uA&dA^IA&dA,wA=(uA<<30|uA>>>2)^(uA<<19|uA>>>13)^(uA<<10|uA>>>22),MA=(pA<<26|pA>>>6)^(pA<<21|pA>>>11)^(pA<<7|pA>>>25),vA=BA+MA+bA+tA[QA]+aA[QA],TA=wA+NA;BA=hA,hA=mA,mA=pA,pA=CA+vA|0,CA=dA,dA=IA,IA=uA,uA=vA+TA|0}lA[0]=lA[0]+uA|0,lA[1]=lA[1]+IA|0,lA[2]=lA[2]+dA|0,lA[3]=lA[3]+CA|0,lA[4]=lA[4]+pA|0,lA[5]=lA[5]+mA|0,lA[6]=lA[6]+hA|0,lA[7]=lA[7]+BA|0};function sA(lA,cA){lA.constructor===String&&(lA=AA.convertString.UTF8.stringToBytes(lA));var gA=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],uA=iA(lA),IA=lA.length*8;uA[IA>>5]|=128<<24-IA%32,uA[(IA+64>>9<<4)+15]=IA;for(var dA=0;dA<uA.length;dA+=16)oA(gA,uA,dA);var CA=rA(gA);return cA&&cA.asBytes?CA:cA&&cA.asString?AA.convertString.bytesToString(CA):AA.bytesToHex(CA)}sA.x2=function(lA,cA){return sA(sA(lA,{asBytes:!0}),cA)}})(sha256$2)})(sha256$3)),sha256$3.exports}var sha256Exports=requireSha256();const sha256=getDefaultExportFromCjs$1(sha256Exports),sha256$1=_mergeNamespaces$1({__proto__:null,default:sha256},[sha256Exports]),sha2568sXzDnE0DJ8rfLd0=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})({});
|
|
1424
1424
|
//# sourceMappingURL=index.js.map
|