=o-p&&e+n[n.length-2]<=l+p&&(Math.abs(e)=a&&(u&&Math.abs(e+n[n.length-2]-o)0){let t=Math.sqrt(e),r=(-2*d[2]-t)/(6*d[3]);r+n[n.length-2]>=o-p&&r+n[n.length-2]<=l+p&&(r>=a||Math.abs(r)0)return{setValue:{allMaxima:t.functionChild[0].stateValues.allMaxima}};if(1!==t.nInputs||1!==t.nOutputs)return{setValue:{allMaxima:[]}};let n,r,a=t.variables[0].subscripts_to_strings().tree,i=t.formula.subscripts_to_strings().derivative(a),s=!0;try{n=i.subscripts_to_strings().f()}catch(e){s=!1,r=()=>NaN}s&&(r=function(e){try{return n({[a]:e})}catch(e){return NaN}});let o=e=>-t.numericalf(e,!0),l=-100*t.xscale,u=100*t.xscale,c=!1,p=!1;if(null!==t.domain){let e=t.domain[0];if(void 0!==e)try{l=me$3.fromAst(e.tree[1][1]).evaluate_to_constant(),Number.isFinite(l)?c=!e.tree[2][1]:l=-100*t.xscale,u=me$3.fromAst(e.tree[1][2]).evaluate_to_constant(),Number.isFinite(u)?p=!e.tree[2][2]:u=100*t.xscale}catch(e){}}let d=1e3,m=(u-l)/d,h=1e-10*Math.max(Math.abs(l),Math.abs(u)),f=[],y=!1,g=!1,b=o(l-m),v=r(l-m);for(let t=-1;t0&&r(t+i)<0&&(N=!0,y=!1,!(t>=l-h&&t<=u+h)||c&&Math.abs(t-l)({allMaxima:{dependencyType:"stateVariable",variableName:"allMaxima"}}),definition:({dependencyValues:e})=>({setValue:{numberMaxima:e.allMaxima.length},checkForActualChange:{numberMaxima:!0}})},t.maxima={stateVariablesDeterminingDependencies:["isInterpolatedFunction"],public:!0,shadowingInstructions:{createComponentOfType:"number",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"],returnWrappingComponents:e=>"maximum"===e||void 0===e?[["point",{componentType:"mathList",isAttribute:"xs"}]]:[]},isArray:!0,nDimensions:2,entryPrefixes:["maximum","maximumLocations","maximumLocation","maximumValues","maximumValue"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if(["maximum","maximumLocation","maximumValue"].includes(e)){let r=Number(t)-1;return Number.isInteger(r)&&r>=0&&(!n||rt+",0")):["0,0"]:"maximumValues"===e?""!==t?[]:n?Array.from(Array(n[0]),((e,t)=>t+",1")):["0,1"]:[]},arrayVarNameFromArrayKey(e){let[t,n]=e.split(",");return"0"===n?"maximumLocation"+(Number(t)+1):"maximumValue"+(Number(t)+1)},arrayVarNameFromPropIndex(e,t){if("maxima"===t){if(1===e.length)return"maximum"+e[0];{let t=Number(e[0]);if(Number.isInteger(t)&&t>0){if(1===e[1])return"maximumLocation"+t;if(2===e[1])return"maximumValue"+t}return null}}if("maximumLocations"===t)return"maximumLocation"+e[0];if("maximumValues"===t)return"maximumValue"+e[0];if("maximum"===t.slice(0,7)){let n=Number(t.slice(7));if(Number.isInteger(n)&&n>0){if(1===e[0])return"maximumLocation"+n;if(2===e[0])return"maximumValue"+n}}return null},returnArraySizeDependencies:()=>({numberMaxima:{dependencyType:"stateVariable",variableName:"numberMaxima"}}),returnArraySize:({dependencyValues:e})=>[e.numberMaxima,2],returnArrayDependenciesByKey:()=>({globalDependencies:{allMaxima:{dependencyType:"stateVariable",variableName:"allMaxima"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t={};for(let n=0;n({numberMinima:{dependencyType:"stateVariable",variableName:"numberMinima"},numberMaxima:{dependencyType:"stateVariable",variableName:"numberMaxima"}}),definition:function({dependencyValues:e}){return{setValue:{numberExtrema:e.numberMinima+e.numberMaxima},checkForActualChange:{numberExtrema:!0}}}},t.allExtrema={returnDependencies:()=>({allMinima:{dependencyType:"stateVariable",variableName:"allMinima"},allMaxima:{dependencyType:"stateVariable",variableName:"allMaxima"}}),definition({dependencyValues:e}){let t=[...e.allMinima,...e.allMaxima].sort(((e,t)=>e[0]-t[0]));return{setValue:{allExtrema:t}}}},t.extrema={public:!0,shadowingInstructions:{createComponentOfType:"number",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"],returnWrappingComponents:e=>"extremum"===e||void 0===e?[["point",{componentType:"mathList",isAttribute:"xs"}]]:[]},isArray:!0,nDimensions:2,entryPrefixes:["extremum","extremumLocations","extremumLocation","extremumValues","extremumValue"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if(["extremum","extremumLocation","extremumValue"].includes(e)){let r=Number(t)-1;return Number.isInteger(r)&&r>=0&&(!n||rt+",0")):["0,0"]:"extremumValues"===e?""!==t?[]:n?Array.from(Array(n[0]),((e,t)=>t+",1")):["0,1"]:[]},arrayVarNameFromArrayKey(e){let[t,n]=e.split(",");return"0"===n?"extremumLocation"+(Number(t)+1):"extremumValue"+(Number(t)+1)},arrayVarNameFromPropIndex(e,t){if("extrema"===t){if(1===e.length)return"extremum"+e[0];{let t=Number(e[0]);if(Number.isInteger(t)&&t>0){if(1===e[1])return"extremumLocation"+t;if(2===e[1])return"extremumValue"+t}return null}}if("extremumLocations"===t)return"extremumLocation"+e[0];if("extremumValues"===t)return"extremumValue"+e[0];if("extremum"===t.slice(0,8)){let n=Number(t.slice(8));if(Number.isInteger(n)&&n>0){if(1===e[0])return"extremumLocation"+n;if(2===e[0])return"extremumValue"+n}}return null},returnArraySizeDependencies:()=>({numberExtrema:{dependencyType:"stateVariable",variableName:"numberExtrema"}}),returnArraySize:({dependencyValues:e})=>[e.numberExtrema,2],returnArrayDependenciesByKey:()=>({globalDependencies:{allExtrema:{dependencyType:"stateVariable",variableName:"allExtrema"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t={};for(let n=0;ne.isInterpolatedFunction?{xs:{dependencyType:"stateVariable",variableName:"xs"},coeffs:{dependencyType:"stateVariable",variableName:"coeffs"},isInterpolatedFunction:{dependencyType:"stateVariable",variableName:"isInterpolatedFunction"},variables:{dependencyType:"stateVariable",variableName:"variables"}}:{functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["returnNumericalDerivatives","variables"]},isInterpolatedFunction:{dependencyType:"stateVariable",variableName:"isInterpolatedFunction"},variables:{dependencyType:"stateVariable",variableName:"variables"}},definition:function({dependencyValues:e}){if(e.isInterpolatedFunction)return{setValue:{returnNumericalDerivatives:returnReturnDerivativesOfInterpolatedFunction(e)}};if(e.functionChild.length>0&&e.functionChild[0].stateValues.returnNumericalDerivatives){let t=e.variables.map((e=>e.subscripts_to_strings().tree)),n=e.functionChild[0].stateValues.variables,r=n.map((e=>e.subscripts_to_strings().tree)),a={};for(let[e,i]of t.entries())r[e]&&r[e]!==i&&(a[i]=n[e]);if(0===Object.keys(a).length)return{setValue:{returnNumericalDerivatives:e.functionChild[0].stateValues.returnNumericalDerivatives}};return{setValue:{returnNumericalDerivatives:function(t){let n=[];for(let e of t){let t=a[e.subscripts_to_strings().tree];t?n.push(t):n.push(me$3.fromAst("_"))}return e.functionChild[0].stateValues.returnNumericalDerivatives(n)}}}}return{setValue:{returnNumericalDerivatives:null}}}},t.numericalDerivativesDefinition={stateVariablesDeterminingDependencies:["isInterpolatedFunction"],returnDependencies:({stateValues:e})=>e.isInterpolatedFunction?{xs:{dependencyType:"stateVariable",variableName:"xs"},coeffs:{dependencyType:"stateVariable",variableName:"coeffs"},isInterpolatedFunction:{dependencyType:"stateVariable",variableName:"isInterpolatedFunction"},variables:{dependencyType:"stateVariable",variableName:"variables"}}:{functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalDerivativesDefinition","variables"]},isInterpolatedFunction:{dependencyType:"stateVariable",variableName:"isInterpolatedFunction"},variables:{dependencyType:"stateVariable",variableName:"variables"}},definition:function({dependencyValues:e}){if(e.isInterpolatedFunction)return{setValue:{numericalDerivativesDefinition:{derivativeType:"interpolatedFunction",xs:e.xs,coeffs:e.coeffs,variables:e.variables}}};if(e.functionChild.length>0&&e.functionChild[0].stateValues.numericalDerivativesDefinition){let t=e.variables.map((e=>e.subscripts_to_strings().tree)),n=e.functionChild[0].stateValues.variables,r=n.map((e=>e.subscripts_to_strings().tree)),a={};for(let[e,i]of t.entries())r[e]&&r[e]!==i&&(a[i]=n[e]);if(0===Object.keys(a).length)return{setValue:{numericalDerivativesDefinition:e.functionChild[0].stateValues.numericalDerivativesDefinition}};{let t={...e.functionChild[0].stateValues.numericalDerivativesDefinition};return t.variableMappings?t.variableMappings=[a,...t.variableMappings]:t.variableMappings=[a],{setValue:{numericalDerivativesDefinition:t}}}}return{setValue:{numericalDerivativesDefinition:{}}}}},t}static adapters=[{stateVariable:"numericalf",componentType:"curve",stateVariablesToShadow:["label","labelHasLatex"]},{stateVariable:"formula",componentType:"math",stateVariablesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]}]}function calculateInterpolationPoints({dependencyValues:e,numerics:t}){let n=[],r=[],a={maximum:e.prescribedMaxima,minimum:e.prescribedMinima,extremum:e.prescribedExtrema,point:e.prescribedPoints};for(let e in a)for(let t of a[e]){let a=null,i=null,s=null;if(null===t.x||(a=t.x.evaluate_to_constant(),Number.isFinite(a)))if(null===t.y||(i=t.y.evaluate_to_constant(),Number.isFinite(i)))if(null!==t.slope&&void 0!==t.slope&&(s=t.slope.evaluate_to_constant(),Number.isFinite(s)||(console.warn("Ignoring non-numerical slope"),s=null)),null===a){if(null===i){console.warn(`Ignoring empty ${e}`);continue}r.push({type:e,y:i,slope:s})}else n.push({type:e,x:a,y:i,slope:s});else console.warn(`Ignoring non-numerical ${e}`);else console.warn(`Ignoring non-numerical ${e}`)}n.sort(((e,t)=>e.x-t.x)),r.sort(((e,t)=>e.y-t.y));let i=-1/0,s=t.eps;for(let e=0;e0;){let e,t;void 0===l?e=v({allowedTypes:["maximum","minimum","extremum"],comparison:"atLeast",value:-1/0}):"maximum"===l?e=v({allowedTypes:["minimum","extremum"],comparison:"atMost",value:o-c}):"minimum"===l?e=v({allowedTypes:["maximum","extremum"],comparison:"atLeast",value:o+c}):"point"===l&&(e=v({allowedTypes:["maximum","extremum"],comparison:"atLeast",value:o+c}),!0!==e.success&&(e=v({allowedTypes:["minimum","extremum"],comparison:"atMost",value:o-c}))),!0===e.success?(t=e.point,r.splice(e.ind,1),m?(t.x=0,m=!1):t.x=i+u):(t=r.pop(),m?(t.x=0,m=!1):t.x=i+2*u);let n=y({p:t,typePrev:l,xPrev:i,yPrev:o});l=n.type,i=n.x,o=n.y}if(0===p.length&&p.push({type:"point",x:0,y:0,slope:0}),m=p[0],"maximum"===m.type){let e={type:"point",x:m.x-u,y:m.y-c,slope:2*c/u};p.splice(0,0,e)}else if("minimum"===m.type){let e={type:"point",x:m.x-u,y:m.y+c,slope:-2*c/u};p.splice(0,0,e)}else if("point"===m.type)if(1===p.length)null===m.slope&&(m.slope=0);else{let e=p[1],t=(e.y-m.y)/(e.x-m.x);if("maximum"===e.type||"minimum"===e.type)null===m.slope&&(m.slope=2*t);else{2===p.length?null===m.slope&&(m.slope=t):(null===e.slope&&(e.slope=f({point:e,prevPoint:m,nextPoint:p[2]})),null===m.slope&&(m.slope=2*(m.y-e.y)/(m.x-e.x)-e.slope));let n={x:m.x-u,y:m.y-u*m.slope,slope:m.slope};p.splice(0,0,n)}}let h=p[p.length-1];if("maximum"===h.type){let e={type:"point",x:h.x+u,y:h.y-c,slope:-2*c/u};p.push(e)}else if("minimum"===h.type){let e={type:"point",x:h.x+u,y:h.y+c,slope:2*c/u};p.push(e)}else if("point"===h.type)if(1===p.length){let e={type:"point",x:h.x+u,y:h.y+m.slope*u,slope:m.slope};p.push(e)}else{let e=p[p.length-2],t=(e.y-h.y)/(e.x-h.x);if("maximum"===e.type||"minimum"===e.type)null===h.slope&&(h.slope=2*t);else{2===p.length?null===h.slope&&(h.slope=t):(null===e.slope&&(e.slope=f({point:e,prevPoint:p[p.length-3],nextPoint:h})),null===h.slope&&(h.slope=2*(e.y-h.y)/(e.x-h.x)-e.slope));let n={x:h.x+u,y:h.y+u*h.slope,slope:h.slope};p.push(n)}}for(let e=1;ei-c||void 0!==r&&null!==e.y&&e.y>t.y-c?g({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t}):b({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t});if("minimum"===n||"minimum"===r)return null!==e.y&&e.yt.y+c?b({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t}):g({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t});if("point"===n||"point"===r){let o="maximum";return(null===e.y&&void 0!==t&&t.type===maximum||null!==e.y&&e.y<=i-c||void 0!==r&&null!==e.y&&e.y>=t.y-c)&&(o="minimum"),"minimum"===o?b({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t}):g({x:e.x,y:e.y,typePrev:n,xPrev:a,yPrev:i,yNext:s,pNext:t})}return null!==e.y&&e.ys-c){let n,a,o=(e+i)/2,l=null,u=v({allowedTypes:["minimum","extremum"],comparison:"atMost",value:Math.min(s,t)-c});!0===u.success?(a="minimum",n=u.point.y,r.splice(u.ind,1),l=0):(a="point",n=s-c),p.push({type:a,x:o,y:n,slope:l})}}else if("minimum"===a&&ti-c){let n=[(2*a+e)/3,(a+2*e)/3],s=[i-c,t+c],o=["atMost","atLeast"],l=[["minimum","extremum"],["maximum","extremum"]];for(let e=0;e<2;e++){let t,a,i=n[e],u=null,c=v({allowedTypes:l[e],comparison:o[e],value:s[e]});!0===c.success?(a=l[e][0],t=c.point.y,r.splice(c.ind,1),u=0):(a="point",t=s[e],u=null),p.push({type:a,x:i,y:t,slope:u})}}}else if("minimum"===n){null===t&&(t=void 0===s?i:"minimum"===o.type?Math.min(i,s):Math.min(i,s-c));let n,l,u=Math.max(i,t)+c,d=(e+a)/2,m=null,h=v({allowedTypes:["maximum","extremum"],comparison:"atLeast",value:u});!0===h.success?(l="maximum",n=h.point.y,r.splice(h.ind,1),m=0):(l="point",n=u),p.push({type:l,x:d,y:n,slope:m})}else if("point"===n)if(null===t)t=void 0===s?i-c:"minimum"===o.type?Math.min(i-c,s):Math.min(i,s)-c;else if(t>i-c){let n,i,s=(e+a)/2,o=null,l=v({allowedTypes:["maximum","extremum"],comparison:"atLeast",value:t+c});!0===l.success?(i="maximum",n=l.point.y,r.splice(l.ind,1),o=0):(i="point",n=t+c),p.push({type:i,x:s,y:n,slope:o})}let l={type:"minimum",x:e,y:t,slope:0};return p.push(l),l}function v({allowedTypes:e,comparison:t,value:n}){let a=[];if("atMost"===t)a=Object.keys(r).reverse();else{if("atLeast"!==t)return{success:!1};a=Object.keys(r)}for(let i of e)for(let e of a){let a=r[e];if(a.type===i)if("atMost"===t){if(a.y<=n)return{success:!0,ind:e,point:a}}else if(a.y>=n)return{success:!0,ind:e,point:a}}return{success:!1}}}function computeSplineParamCoeffs({dependencyValues:e}){let t=e.interpolationPoints;if(null===t)return{setValue:{xs:null,coeffs:null}};let n,r=[],a=[],i=t[0];a.push(i.x);for(let e=1;et.componentIsSpecifiedType(e,"label");if(0===e.length||!e.every((e=>"string"==typeof e||e.doenetAttributes?.createdFromMacro||n(e))))return{success:!1};let r=e.map(n),a=[],i=[],s=[];if(0===r.filter((e=>e)).length)a=e;else{if(r[0]){let t=r.indexOf(!1);-1!==t&&(i=e.slice(0,t),e=e.slice(t),r=r.slice(t))}let t=r.indexOf(!0);-1===t?a=e:(a=e.slice(0,t),s=e.slice(t))}return 0===a.length||1===a.length&&"string"!=typeof a[0]?{success:!1}:{success:!0,newChildren:[...i,{componentType:"math",children:a},...s]}}}),e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e}),n=this.componentType;t.isInterpolatedFunction={returnDependencies:()=>({}),definition:()=>({setValue:{isInterpolatedFunction:!1}})},delete t.nPrescribedPoints,delete t.prescribedPoints,delete t.prescribedMinima,delete t.prescribedMaxima,delete t.prescribedExtrema,delete t.interpolationPoints,delete t.xs,t.operatorBasedOnFormulaIfAvailable={returnDependencies:()=>({}),definition:()=>({setValue:{operatorBasedOnFormulaIfAvailable:!1}})},t.formula.returnDependencies=()=>({}),t.formula.definition=()=>({setValue:{formula:me$3.fromAst("_")}}),t.operatorComposesWithOriginal={returnDependencies:()=>({}),definition:()=>({setValue:{operatorComposesWithOriginal:!0}})},t.symbolicFunctionOperator={returnDependencies:()=>({}),definition:()=>({setValue:{symbolicFunctionOperator:e=>me$3.fromAst("_")}})},t.numericalFunctionOperator={additionalStateVariablesDefined:["numericalFunctionOperatorArguments"],returnDependencies:()=>({}),definition:()=>({setValue:{numericalFunctionOperator:e=>NaN,numericalFunctionOperatorArguments:[]}})},t.numericalFunctionOperatorArguments={returnDependencies:()=>({}),definition:()=>({setValue:{numericalFunctionOperatorArguments:{}}})},t.formulaOperator={returnDependencies:()=>({}),definition:()=>({setValue:{formulaOperator:e=>me$3.fromAst("_")}})},t.returnNumericalDerivatives={returnDependencies:()=>({}),definition:()=>({setValue:{returnNumericalDerivatives:null}})},t.formula={public:!0,shadowingInstructions:{createComponentOfType:"math"},additionalStateVariablesDefined:["operatorBasedOnFormula"],returnDependencies:()=>({operatorBasedOnFormulaIfAvailable:{dependencyType:"stateVariable",variableName:"operatorBasedOnFormulaIfAvailable"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["formula"]},mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},formulaOperator:{dependencyType:"stateVariable",variableName:"formulaOperator"}}),definition:function({dependencyValues:e}){if(!e.operatorBasedOnFormulaIfAvailable||(0===e.functionChild.length||"_"===e.functionChild[0].stateValues.formula.tree)&&(0===e.mathChild.length||"_"===e.mathChild[0].stateValues.value.tree))return{setValue:{formula:me$3.fromAst("_"),operatorBasedOnFormula:!1}};let t;return t=0===e.functionChild.length?e.mathChild[0].stateValues.value:e.functionChild[0].stateValues.formula,{setValue:{formula:e.formulaOperator(t),operatorBasedOnFormula:!0}}}},t.symbolicfs={isArray:!0,entryPrefixes:["symbolicf"],returnArraySizeDependencies:()=>({nOutputs:{dependencyType:"stateVariable",variableName:"nOutputs"}}),returnArraySize:({dependencyValues:e})=>[e.nOutputs],returnArrayDependenciesByKey:()=>({globalDependencies:{operatorBasedOnFormula:{dependencyType:"stateVariable",variableName:"operatorBasedOnFormula"},formula:{dependencyType:"stateVariable",variableName:"formula"},variables:{dependencyType:"stateVariable",variableName:"variables"},nInputs:{dependencyType:"stateVariable",variableName:"nInputs"},simplify:{dependencyType:"stateVariable",variableName:"simplify"},expand:{dependencyType:"stateVariable",variableName:"expand"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["symbolicfs"]},mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},symbolicFunctionOperator:{dependencyType:"stateVariable",variableName:"symbolicFunctionOperator"},operatorComposesWithOriginal:{dependencyType:"stateVariable",variableName:"operatorComposesWithOriginal"},domain:{dependencyType:"stateVariable",variableName:"domain"}}}),arrayDefinitionByKey:function({globalDependencyValues:e,usedDefault:t,arrayKeys:n,arraySize:r}){if(!e.operatorBasedOnFormula){if(e.operatorComposesWithOriginal){if(0===e.functionChild.length){if(0===e.mathChild.length){let e={};for(let t of n)e[t]=e=>me$3.fromAst("_");return{setValue:{symbolicfs:e}}}{let t=Object.assign({},e);t.formula=e.mathChild[0].stateValues.value;let a=[];for(let e=0;ee.symbolicFunctionOperator(...a.map((e=>e(...t))));return{setValue:{symbolicfs:i}}}}{let t=[];for(let n=0;ne.symbolicFunctionOperator(...t.map((e=>e(...n))));return{setValue:{symbolicfs:a}}}}{let t={};for(let r of n)t[r]=(...t)=>e.symbolicFunctionOperator(...t);return{setValue:{symbolicfs:t}}}}{let t={};for(let r of n)return t[r]=returnSymbolicFunctionFromFormula(e,r),{setValue:{symbolicfs:t}}}}},t.numericalfs={isArray:!0,entryPrefixes:["numericalf"],returnArraySizeDependencies:()=>({nOutputs:{dependencyType:"stateVariable",variableName:"nOutputs"}}),returnArraySize:({dependencyValues:e})=>[e.nOutputs],returnArrayDependenciesByKey:()=>({globalDependencies:{operatorBasedOnFormula:{dependencyType:"stateVariable",variableName:"operatorBasedOnFormula"},formula:{dependencyType:"stateVariable",variableName:"formula"},variables:{dependencyType:"stateVariable",variableName:"variables"},nInputs:{dependencyType:"stateVariable",variableName:"nInputs"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalfs"]},mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},numericalFunctionOperator:{dependencyType:"stateVariable",variableName:"numericalFunctionOperator"},operatorComposesWithOriginal:{dependencyType:"stateVariable",variableName:"operatorComposesWithOriginal"},domain:{dependencyType:"stateVariable",variableName:"domain"}}}),arrayDefinitionByKey:function({globalDependencyValues:e,usedDefault:t,arrayKeys:n,arraySize:r}){if(!e.operatorBasedOnFormula){if(e.operatorComposesWithOriginal){if(0===e.functionChild.length){if(0===e.mathChild.length){let e={};for(let t of n)e[t]=e=>NaN;return{setValue:{numericalfs:e}}}{Object.assign({},e).formula=e.mathChild[0].stateValues.value;let t=[];for(let n=0;ne.numericalFunctionOperator(...t.map((e=>e(...n))));return{setValue:{numericalfs:a}}}}{let t=[];for(let n=0;ne.numericalFunctionOperator(...t.map((e=>e(...n))));return{setValue:{numericalfs:a}}}}{let t={};for(let r of n)t[r]=(...t)=>e.numericalFunctionOperator(...t);return{setValue:{numericalfs:t}}}}{let t={};for(let r of n)return t[r]=returnNumericalFunctionFromFormula({formula:e.formula,nInputs:e.nInputs,variables:e.variables,domain:e.domain,component:r}),{setValue:{numericalfs:t}}}}},t.fDefinitions={isArray:!0,entryPrefixes:["fDefinition"],returnArraySizeDependencies:()=>({nOutputs:{dependencyType:"stateVariable",variableName:"nOutputs"}}),returnArraySize:({dependencyValues:e})=>[e.nOutputs],returnArrayDependenciesByKey:()=>({globalDependencies:{operatorBasedOnFormula:{dependencyType:"stateVariable",variableName:"operatorBasedOnFormula"},formula:{dependencyType:"stateVariable",variableName:"formula"},variables:{dependencyType:"stateVariable",variableName:"variables"},nInputs:{dependencyType:"stateVariable",variableName:"nInputs"},nOutputs:{dependencyType:"stateVariable",variableName:"nOutputs"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["fDefinitions"]},mathChild:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]},numericalFunctionOperator:{dependencyType:"stateVariable",variableName:"numericalFunctionOperator"},numericalFunctionOperatorArguments:{dependencyType:"stateVariable",variableName:"numericalFunctionOperatorArguments"},operatorComposesWithOriginal:{dependencyType:"stateVariable",variableName:"operatorComposesWithOriginal"},domain:{dependencyType:"stateVariable",variableName:"domain"}}}),arrayDefinitionByKey:function({globalDependencyValues:e,usedDefault:t,arrayKeys:r,arraySize:a}){if(e.operatorBasedOnFormula){let t={};for(let n of r)t[n]={functionType:"formula",formula:e.formula.tree,variables:e.variables.map((e=>e.tree)),nInputs:e.nInputs,nOutputs:e.nOutputs,domain:e.domain,component:n};return{setValue:{fDefinitions:t}}}if(e.operatorComposesWithOriginal){if(0===e.functionChild.length){if(0===e.mathChild.length){let t={};for(let n of r)t[n]={functionType:"formula",formula:"_",variables:e.variables.map((e=>e.tree)),nInputs:e.nInputs,nOutputs:e.nOutputs,domain:e.domain};return{setValue:{fDefinitions:t}}}throw Error("function operator with math child not implemented yet")}{let t={};for(let a of r)t[a]={functionType:"functionOperator",componentType:n,nOutputs:e.nOutputs,functionOperatorArguments:e.numericalFunctionOperatorArguments,operatorComposesWithOriginal:!0,originalFDefinition:e.functionChild[0].stateValues.fDefinitions[a]};return{setValue:{fDefinitions:t}}}}if(0===e.functionChild.length){if(0===e.mathChild.length){let t={};for(let n of r)t[n]={functionType:"formula",formula:"_",variables:e.variables.map((e=>e.tree)),nInputs:e.nInputs,nOutputs:e.nOutputs,domain:e.domain};return{setValue:{fDefinitions:t}}}throw Error("function operator with math child not implemented yet")}{let t={};for(let a of r)t[a]={functionType:"functionOperator",componentType:n,nOutputs:e.nOutputs,functionOperatorArguments:e.numericalFunctionOperatorArguments,operatorComposesWithOriginal:!1,originalFDefinition:e.functionChild[0].stateValues.fDefinitions[a]};return{setValue:{fDefinitions:t}}}}};let r=t.allMinima.returnDependencies;t.allMinima.returnDependencies=function(e){let t=r(e);return delete t.functionChild,t};let a=t.allMaxima.returnDependencies;return t.allMaxima.returnDependencies=function(e){let t=a(e);return delete t.functionChild,t},t}}class ClampFunction extends FunctionOperator{static componentType="clampFunction";static createAttributesObject(){let e=super.createAttributesObject();return e.lowerValue={createComponentOfType:"number",createStateVariable:"lowerValue",defaultValue:0,public:!0},e.upperValue={createComponentOfType:"number",createStateVariable:"upperValue",defaultValue:1,public:!0},e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e});return t.numericalFunctionOperator={additionalStateVariablesDefined:["numericalFunctionOperatorArguments"],returnDependencies:()=>({lowerValue:{dependencyType:"stateVariable",variableName:"lowerValue"},upperValue:{dependencyType:"stateVariable",variableName:"upperValue"}}),definition:function({dependencyValues:e}){return{setValue:{numericalFunctionOperator:functionOperatorDefinitions.clampFunction(e.lowerValue,e.upperValue),numericalFunctionOperatorArguments:[e.lowerValue,e.upperValue]}}}},t.symbolicFunctionOperator={returnDependencies:()=>({numericalFunctionOperator:{dependencyType:"stateVariable",variableName:"numericalFunctionOperator"}}),definition:({dependencyValues:e})=>({setValue:{symbolicFunctionOperator:t=>me$3.fromAst(e.numericalFunctionOperator(t.evaluate_to_constant()))}})},t}}class WrapFunctionPeriodic extends FunctionOperator{static componentType="wrapFunctionPeriodic";static createAttributesObject(){let e=super.createAttributesObject();return e.lowerValue={createComponentOfType:"number",createStateVariable:"lowerValue",defaultValue:0,public:!0},e.upperValue={createComponentOfType:"number",createStateVariable:"upperValue",defaultValue:1,public:!0},e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e});return t.numericalFunctionOperator={additionalStateVariablesDefined:["numericalFunctionOperatorArguments"],returnDependencies:()=>({lowerValue:{dependencyType:"stateVariable",variableName:"lowerValue"},upperValue:{dependencyType:"stateVariable",variableName:"upperValue"}}),definition:function({dependencyValues:e}){return{setValue:{numericalFunctionOperator:functionOperatorDefinitions.wrapFunctionPeriodic(e.lowerValue,e.upperValue),numericalFunctionOperatorArguments:[e.lowerValue,e.upperValue]}}}},t.symbolicFunctionOperator={returnDependencies:()=>({numericalFunctionOperator:{dependencyType:"stateVariable",variableName:"numericalFunctionOperator"}}),definition:({dependencyValues:e})=>({setValue:{symbolicFunctionOperator:t=>me$3.fromAst(e.numericalFunctionOperator(t.evaluate_to_constant()))}})},t}}class Derivative extends FunctionOperator{static componentType="derivative";static createAttributesObject(){let e=super.createAttributesObject();return e.derivVariables={createComponentOfType:"variables"},e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e});return t.operatorBasedOnFormulaIfAvailable={returnDependencies:()=>({}),definition:()=>({setValue:{operatorBasedOnFormulaIfAvailable:!0}})},t.operatorComposesWithOriginal={returnDependencies:()=>({}),definition:()=>({setValue:{operatorComposesWithOriginal:!1}})},t.haveFunctionChild={returnDependencies:()=>({functionChild:{dependencyType:"child",childGroups:["functions"]}}),definition:({dependencyValues:e})=>({setValue:{haveFunctionChild:e.functionChild.length>0}})},t.nInputs={defaultValue:1,hasEssential:!0,public:!0,shadowingInstructions:{createComponentOfType:"integer"},stateVariablesDeterminingDependencies:["haveFunctionChild"],returnDependencies({stateValues:e}){let t={nInputsAttr:{dependencyType:"attributeComponent",attributeName:"nInputs",variableNames:["value"]},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["nInputs"]},variablesAttr:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["nComponents"]}};return e.haveFunctionChild||(t.derivVariablesAttr={dependencyType:"attributeComponent",attributeName:"derivVariables",variableNames:["variables"]}),t},definition({dependencyValues:e}){if(null!==e.nInputsAttr){let t=e.nInputsAttr.stateValues.value;return t>=0||(t=1),{setValue:{nInputs:t}}}if(null!==e.variablesAttr)return{setValue:{nInputs:Math.max(1,e.variablesAttr.stateValues.nComponents)}};if(e.functionChild.length>0)return{setValue:{nInputs:e.functionChild[0].stateValues.nInputs}};if(null!==e.derivVariablesAttr){let t=[...new Set(e.derivVariablesAttr.stateValues.variables.map((e=>e.subscripts_to_strings().tree)))].length;return{setValue:{nInputs:t}}}return{useEssentialOrDefaultValue:{nInputs:!0}}}},t.variables={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"variable"},entryPrefixes:["variable"],returnArraySizeDependencies:()=>({nInputs:{dependencyType:"stateVariable",variableName:"nInputs"}}),returnArraySize:({dependencyValues:e})=>[e.nInputs],stateVariablesDeterminingDependencies:["haveFunctionChild"],returnArrayDependenciesByKey({arrayKeys:e,stateValues:t}){let n={variablesAttr:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["variables"]},parentVariableForChild:{dependencyType:"parentStateVariable",variableName:"variableForChild"},isInterpolatedFunction:{dependencyType:"stateVariable",variableName:"isInterpolatedFunction"},haveFunctionChild:{dependencyType:"stateVariable",variableName:"haveFunctionChild"}},r={};if(t.haveFunctionChild)for(let t of e)r[t]={functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["variable"+(Number(t)+1)]}};else n.derivVariablesAttr={dependencyType:"attributeComponent",attributeName:"derivVariables",variableNames:["variables"]};return{globalDependencies:n,dependenciesByKey:r}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arraySize:n,arrayKeys:r,usedDefault:a}){if(null!==e.variablesAttr){let t=e.variablesAttr.stateValues.variables;return{setValue:{variables:returnNVariables(n[0],t)}}}if(e.haveFunctionChild){let e={};for(let n of r)e[n]=t[n].functionChild[0].stateValues["variable"+(Number(n)+1)];return{setValue:{variables:e}}}if(null!==e.derivVariablesAttr){let t=[],r=[];for(let n of e.derivVariablesAttr.stateValues.variables){let e=n.subscripts_to_strings().tree;r.includes(e)||(t.push(n),r.push(e))}return{setValue:{variables:returnNVariables(n[0],t)}}}return e.parentVariableForChild&&!a.parentVariableForChild?{setValue:{variables:Array(n[0]).fill(e.parentVariableForChild)}}:{setValue:{variables:returnNVariables(n[0],[])}}}},t.nDerivatives={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({derivVariablesAttr:{dependencyType:"attributeComponent",attributeName:"derivVariables",variableNames:["nComponents"]}}),definition:({dependencyValues:e})=>null!==e.derivVariablesAttr?{setValue:{nDerivatives:e.derivVariablesAttr.stateValues.nComponents}}:{setValue:{nDerivatives:1}}},t.derivVariables={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"variable"},entryPrefixes:["derivVariable"],returnArraySizeDependencies:()=>({nDerivatives:{dependencyType:"stateVariable",variableName:"nDerivatives"}}),returnArraySize:({dependencyValues:e})=>[e.nDerivatives],returnArrayDependenciesByKey:()=>({globalDependencies:{derivVariablesAttr:{dependencyType:"attributeComponent",attributeName:"derivVariables",variableNames:["variables"]},variable1:{dependencyType:"stateVariable",variableName:"variable1"}}}),arrayDefinitionByKey:({globalDependencyValues:e})=>null!==e.derivVariablesAttr?{setValue:{derivVariables:e.derivVariablesAttr.stateValues.variables}}:{setValue:{derivVariables:{0:e.variable1}}}},t.formulaOperator={returnDependencies:()=>({derivVariables:{dependencyType:"stateVariable",variableName:"derivVariables"}}),definition:({dependencyValues:e})=>({setValue:{formulaOperator:function(t){let n=t.subscripts_to_strings();for(let t of e.derivVariables)n=n.derivative(t.subscripts_to_strings().tree);return n.strings_to_subscripts()}}})},t.numericalFunctionOperator={returnDependencies:()=>({functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["returnNumericalDerivatives"],variablesOptional:!0},derivVariables:{dependencyType:"stateVariable",variableName:"derivVariables"}}),additionalStateVariablesDefined:["returnNumericalDerivatives"],definition:function({dependencyValues:e}){if(0===e.functionChild.length||!e.functionChild[0].stateValues.returnNumericalDerivatives)return{setValue:{numericalFunctionOperator:e=>NaN,returnNumericalDerivatives:null}};return{setValue:{numericalFunctionOperator:e.functionChild[0].stateValues.returnNumericalDerivatives(e.derivVariables),returnNumericalDerivatives:function(t){let n=[...e.derivVariables,...t];return e.functionChild[0].stateValues.returnNumericalDerivatives(n)}}}}},t.numericalFunctionOperatorArguments={returnDependencies:()=>({functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalDerivativesDefinition"],variablesOptional:!0},derivVariables:{dependencyType:"stateVariable",variableName:"derivVariables"}}),additionalStateVariablesDefined:["numericalDerivativesDefinition"],definition:function({dependencyValues:e}){if(0===e.functionChild.length||!e.functionChild[0].stateValues.numericalDerivativesDefinition)return{setValue:{numericalFunctionOperatorArguments:[],numericalDerivativesDefinition:{}}};let t=e.functionChild[0].stateValues.numericalDerivativesDefinition,n={...t};return n.additionalDerivVariables?n.additionalDerivVariables=[...e.derivVariables,...n.additionalDerivVariables]:n.additionalDerivVariables=[...e.derivVariables],{setValue:{numericalFunctionOperatorArguments:[t,e.derivVariables],numericalDerivativesDefinition:n}}}},t.symbolicFunctionOperator={returnDependencies:()=>({numericalFunctionOperator:{dependencyType:"stateVariable",variableName:"numericalFunctionOperator"}}),definition:({dependencyValues:e})=>({setValue:{symbolicFunctionOperator:t=>me$3.fromAst(e.numericalFunctionOperator(t.evaluate_to_constant()))}})},t}}var FunctionOperators=Object.freeze({__proto__:null,ClampFunction:ClampFunction,WrapFunctionPeriodic:WrapFunctionPeriodic,Derivative:Derivative});class TextBaseOperatorOfMath extends Text{static componentType="_textOperatorOfMath";static rendererType="text";static returnChildGroups(){return[{group:"maths",componentTypes:["math"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions(),t=this;return e.value={public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,returnDependencies:()=>({mathChildren:{dependencyType:"child",childGroups:["maths"],variableNames:["value"]}}),definition:function({dependencyValues:e}){return{setValue:{value:t.applyTextOperator(e.mathChildren.map((e=>e.stateValues.value)))}}}},e}}class ExtractMathOperator extends TextBaseOperatorOfMath{static componentType="extractMathOperator";static applyTextOperator(e){return 0===e.length?"":1!==e.length?(console.warn("MathOperator requires exactly one math child"),""):Array.isArray(e[0].tree)?e[0].tree[0]:""}}var TextOperatorsOfMath=Object.freeze({__proto__:null,ExtractMathOperator:ExtractMathOperator});class Extremum extends BaseComponent{static componentType="extremum";static rendererType=void 0;static createAttributesObject(){let e=super.createAttributesObject();return e.location={createComponentOfType:"math"},e.value={createComponentOfType:"math"},e}static returnSugarInstructions(){let e=super.returnSugarInstructions();return e.push({childrenRegex:/s+(.*s)?/,replacementFunction:function({matchedChildren:e}){let t=returnBreakStringsSugarFunction({childrenToComponentFunction:e=>({componentType:"math",children:e}),mustStripOffOuterParentheses:!0}),n=t({matchedChildren:e});if(!n.success&&1===e.length)return{success:!0,newAttributes:{value:{component:{componentType:"math",children:e}}}};if(n.success){if(1===n.newChildren.length)return{success:!0,newAttributes:{value:{component:n.newChildren[0]}}};if(2===n.newChildren.length){let e=n.newChildren[0],t=n.newChildren[1],r={location:{component:e},value:{component:t}};return(0===e.children.length||1===e.children.length&&"string"==typeof e.children[0]&&""===e.children[0].trim())&&delete r.location,(0===t.children.length||1===t.children.length&&"string"==typeof t.children[0]&&""===t.children[0].trim())&&delete r.value,{success:!0,newAttributes:r}}return{success:!1}}return n}}),e}static returnChildGroups(){return[{group:"points",componentTypes:["point"]}]}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e}),n=this;return t.value={public:!0,shadowingInstructions:{createComponentOfType:"math"},defaultValue:null,hasEssential:!0,additionalStateVariablesDefined:[{variableName:"location",public:!0,shadowingInstructions:{createComponentOfType:"math"},defaultValue:null,hasEssential:!0}],returnDependencies:()=>({extremumChild:{dependencyType:"child",childGroups:["points"],variableNames:["nDimensions","xs"]},location:{dependencyType:"attributeComponent",attributeName:"location",variableNames:["value"]},value:{dependencyType:"attributeComponent",attributeName:"value",variableNames:["value"]}}),definition:function({dependencyValues:e}){let t,r;if(e.extremumChild.length>0){let a=e.extremumChild[0];2!==a.stateValues.nDimensions?(console.log("Cannot determine "+n.componentType+" from a point that isn't 2D"),t=null,r=null):(t=a.stateValues.xs[0],r=a.stateValues.xs[1])}else null!==e.location&&(t=e.location.stateValues.value),null!==e.value&&(r=e.value.stateValues.value);let a={},i={},s=!1,o=!1;void 0===t?(i.location=!0,o=!0):(a.location=t,s=!0),void 0===r?(i.value=!0,o=!0):(a.value=r,s=!0);let l={};return s&&(l.setValue=a),o&&(l.useEssentialOrDefaultValue=i),l}},t}}class Extrema extends BaseComponent{static componentType="extrema";static rendererType=void 0;static componentTypeSingular="extremum";static get componentTypeCapitalized(){return this.componentType.charAt(0).toUpperCase()+this.componentType.slice(1)}static returnSugarInstructions(){let e=super.returnSugarInstructions(),t=this;return e.push({replacementFunction:function({matchedChildren:e}){let n=breakEmbeddedStringsIntoParensPieces({componentList:e});return!0!==n.success?{success:!1}:{success:!0,newChildren:n.pieces.map((function(e){return e.length>1||"string"==typeof e[0]?{componentType:t.componentTypeSingular,children:e}:e[0]}))}}}),e}static returnChildGroups(){return[{group:"extrema",componentTypes:[this.componentTypeSingular]},{group:"points",componentTypes:["point"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions(),t=this;return e["n"+t.componentTypeCapitalized]={additionalStateVariablesDefined:["childIdentities"],returnDependencies:()=>({children:{dependencyType:"child",childGroups:["extrema","points"]}}),definition:function({dependencyValues:e}){return{setValue:{["n"+t.componentTypeCapitalized]:e.children.length,childIdentities:e.children}}}},e[t.componentType]={isArray:!0,nDimensions:2,entryPrefixes:[t.componentTypeSingular,t.componentTypeSingular+"Locations",t.componentTypeSingular+"Location",t.componentTypeSingular+"Values",t.componentTypeSingular+"Value"],stateVariablesDeterminingDependencies:["childIdentities"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:n,arraySize:r}){if([t.componentTypeSingular,t.componentTypeSingular+"Location",t.componentTypeSingular+"Value"].includes(e)){let a=Number(n)-1;return Number.isInteger(a)&&a>=0&&(!r||at+",0")):["0,0"]:e===t.componentTypeSingular+"Values"?""!==n?[]:r?Array.from(Array(r[0]),((e,t)=>t+",1")):["0,1"]:[]},arrayVarNameFromArrayKey(e){let[n,r]=e.split(",");return"0"===r?t.componentTypeSingular+"Location"+(Number(n)+1):t.componentTypeSingular+"Value"+(Number(n)+1)},arrayVarNameFromPropIndex(e,n){if(n===t.componentType){if(1===e.length)return t.componentTypeSingular+e[0];{let n=Number(e[0]);if(Number.isInteger(n)&&n>0){if(1===e[1])return t.componentTypeSingular+"Location"+n;if(2===e[1])return t.componentTypeSingular+"Value"+n}return null}}if(n===t.componentTypeSingular+"Locations")return t.componentTypeSingular+"Location"+e[0];if(n===t.componentTypeSingular+"Values")return t.componentTypeSingular+"Value"+e[0];let r=t.componentTypeSingular.length;if(n.slice(0,r)===t.componentTypeSingular){let a=Number(n.slice(r));if(Number.isInteger(a)&&a>0){if(1===e[0])return t.componentTypeSingular+"Location"+a;if(2===e[0])return t.componentTypeSingular+"Value"+a}}return null},returnArraySizeDependencies:()=>({nChildren:{dependencyType:"stateVariable",variableName:"n"+t.componentTypeCapitalized}}),returnArraySize:({dependencyValues:e})=>[e.nChildren,2],returnArrayDependenciesByKey({arrayKeys:e,stateValues:n}){let r={};for(let a of e){let e,[i,s]=a.split(",");e=n.childIdentities[i].componentType===t.componentTypeSingular?0===Number(s)?"location":"value":"x"+(Number(s)+1),r[a]={child:{dependencyType:"child",childGroups:["extrema","points"],variableNames:[e],childIndices:[i]}}}return{dependenciesByKey:r}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:n}){let r={};for(let t of n){let n=e[t].child[0];if(n){let e=t.split(",")[1],a=0===Number(e)?"location":"value";a in n.stateValues?r[t]=n.stateValues[a]:r[t]=n.stateValues["x"+(Number(e)+1)]}}return{setValue:{[t.componentType]:r}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:n}){let r=[];for(let a in e[t.componentType])r.push({setDependency:n[a].extremumChild,desiredValue:e[t.componentType][a],childIndex:0,variableIndex:0});return{success:!0,instructions:r}}},e}}var Extrema$1=Object.freeze({__proto__:null,Extremum:Extremum,Extrema:Extrema});class InlineRenderInlineChildren extends InlineComponent{static componentType="_inlineRenderInlineChildren";static renderChildren=!0;static includeBlankStringChildren=!0;static beginTextDelimiter="";static endTextDelimiter="";static returnChildGroups(){return[{group:"inlines",componentTypes:["_inline"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions(),t=this;return e.text={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({inlineChildren:{dependencyType:"child",childGroups:["inlines"],variableNames:["text"],variablesOptional:!0}}),definition:function({dependencyValues:e}){let n="";for(let t of e.inlineChildren)"object"!=typeof t?n+=t.toString():"string"==typeof t.stateValues.text?n+=t.stateValues.text:n+=" ";return n=t.beginTextDelimiter+n+t.endTextDelimiter,{setValue:{text:n}}}},e}}class Em extends InlineRenderInlineChildren{static componentType="em"}class Alert extends InlineRenderInlineChildren{static componentType="alert"}class Q$2 extends InlineRenderInlineChildren{static componentType="q";static beginTextDelimiter='"';static endTextDelimiter='"'}class SQ extends InlineRenderInlineChildren{static componentType="sq";static beginTextDelimiter="'";static endTextDelimiter="'"}class Term extends InlineRenderInlineChildren{static componentType="term";static rendererType="alert"}class C$2 extends InlineRenderInlineChildren{static componentType="c"}class Tag extends InlineRenderInlineChildren{static componentType="tag";static rendererType="tag";static beginTextDelimiter="<";static endTextDelimiter=">"}class Tage extends InlineRenderInlineChildren{static componentType="tage";static rendererType="tag";static beginTextDelimiter="<";static endTextDelimiter="/>";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.selfClosed={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{selfClosed:!0}})},e}}class Attr extends InlineRenderInlineChildren{static componentType="attr";static rendererType="c"}var ParagraphMarkup=Object.freeze({__proto__:null,Em:Em,Alert:Alert,Q:Q$2,SQ:SQ,Term:Term,C:C$2,Tag:Tag,Tage:Tage,Attr:Attr});class SingleCharacter extends InlineComponent{static componentType="_singleCharacterInline";static unicodeCharacter="";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.text={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({}),definition:()=>({setValue:{text:this.unicodeCharacter}})},e}}class Ndash extends SingleCharacter{static componentType="ndash";static unicodeCharacter="–"}class Mdash extends SingleCharacter{static componentType="mdash";static unicodeCharacter="—"}class NBSP extends SingleCharacter{static componentType="nbsp";static unicodeCharacter=" "}class Ellipsis extends SingleCharacter{static componentType="ellipsis";static unicodeCharacter="…"}var SingleCharacterComponents=Object.freeze({__proto__:null,Ndash:Ndash,Mdash:Mdash,NBSP:NBSP,Ellipsis:Ellipsis});class BlockComponent extends BaseComponent{static componentType="_block"}function returnDefaultFeedbackDefinitions(){return{numericalerror:"Credit reduced because numbers in your answer weren't quite right. Did you round too much?",goodjob:"Good job!",onesignerror:"Credit reduced because it appears that you made a sign error.",twosignerrors:"Credit reduced because it appears that you made two sign errors."}}function returnFeedbackDefinitionStateVariables(){let e={setupChildren:{returnDependencies:()=>({setupChildren:{dependencyType:"child",childGroups:["setups"],proceedIfAllChildrenNotMatched:!0}}),definition:({dependencyValues:e})=>({setValue:{setupChildren:e.setupChildren}})}};return e.feedbackDefinitions={stateVariablesDeterminingDependencies:["setupChildren"],returnDependencies({stateValues:e}){let t={ancestorWithFeedback:{dependencyType:"ancestor",variableNames:["feedbackDefinitions"]},setupChildren:{dependencyType:"child",childGroups:["setups"],proceedIfAllChildrenNotMatched:!0}};for(let n of e.setupChildren)t[`feedbackDefinitionsOf${n.componentName}`]={dependencyType:"child",parentName:n.componentName,childGroups:["feedbackDefinitions"],variableNames:["value"]};return t},definition({dependencyValues:e}){let t,n={};e.ancestorWithFeedback&&(t=e.ancestorWithFeedback.stateValues.feedbackDefinitions),t||(t=returnDefaultFeedbackDefinitions()),Object.assign(n,t);let r=[];for(let t of e.setupChildren)r.push(...e[`feedbackDefinitionsOf${t.componentName}`]);for(let e of r)Object.assign(n,e.stateValues.value);return{setValue:{feedbackDefinitions:n}}}},e}class SectioningComponent extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{submitAllAnswers:this.submitAllAnswers.bind(this),revealSection:this.revealSection.bind(this),closeSection:this.closeSection.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="_sectioningComponent";static renderChildren=!0;static includeBlankStringChildren=!0;static createsVariants=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.aggregateScores={createComponentOfType:"boolean",createStateVariable:"aggregateScores",defaultValue:!1,public:!0},e.weight={createComponentOfType:"number",createStateVariable:"weight",defaultValue:1,public:!0},e.sectionWideCheckWork={createComponentOfType:"boolean",createStateVariable:"sectionWideCheckWork",defaultValue:!1,public:!0},e.submitLabel={createComponentOfType:"text",createStateVariable:"submitLabel",defaultValue:"Check Work",public:!0,forRenderer:!0},e.submitLabelNoCorrectness={createComponentOfType:"text",createStateVariable:"submitLabelNoCorrectness",defaultValue:"Submit Response",public:!0,forRenderer:!0},e.boxed={createComponentOfType:"boolean",createStateVariable:"boxed",defaultValue:!1,public:!0,forRenderer:!0},e.suppressAutoName={createComponentOfType:"boolean",createStateVariable:"suppressAutoName",defaultValue:!1,public:!0},e.suppressAutoNumber={createComponentOfType:"boolean",createStateVariable:"suppressAutoNumber",defaultValue:!1,public:!0},e.includeAutoName={createComponentOfType:"boolean",createStateVariable:"includeAutoName",defaultValue:!1,public:!0},e.includeAutoNumber={createComponentOfType:"boolean",createStateVariable:"includeAutoNumber",defaultValue:!1,public:!0},e.includeAutoNameNumberIfNoTitle={createComponentOfType:"boolean",createStateVariable:"includeAutoNameNumberIfNoTitle",defaultValue:!0,public:!0},e.includeParentNumber={createComponentOfType:"boolean",createStateVariable:"includeParentNumber",defaultValue:!1,public:!0},e.level={createComponentOfType:"integer"},e}static returnChildGroups(){return[{group:"variantControls",componentTypes:["variantControl"]},{group:"titles",componentTypes:["title"]},{group:"setups",componentTypes:["setup"]},{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions(),t=returnStyleDefinitionStateVariables();Object.assign(e,t);let n=returnFeedbackDefinitionStateVariables();return Object.assign(e,n),e.enumeration={additionalStateVariablesDefined:[{variableName:"sectionNumber",public:!0,shadowingInstructions:{createComponentOfType:"text"}}],returnDependencies:()=>({countAmongSiblings:{dependencyType:"countAmongSiblingsOfSameType"},sectionAncestor:{dependencyType:"ancestor",componentType:"_sectioningComponent",variableNames:["enumeration"]},includeParentNumber:{dependencyType:"stateVariable",variableName:"includeParentNumber"}}),definition({dependencyValues:e}){let t=[];return e.includeParentNumber&&e.sectionAncestor&&t.push(...e.sectionAncestor.stateValues.enumeration),t.push(e.countAmongSiblings),{setValue:{enumeration:t,sectionNumber:t.join(".")}}}},e.sectionName={returnDependencies:()=>({}),definition:()=>({setValue:{sectionName:"Section"}})},e.titleChildName={forRenderer:!0,returnDependencies:()=>({titleChild:{dependencyType:"child",childGroups:["titles"]}}),definition({dependencyValues:e}){let t=null;return e.titleChild.length>0&&(t=e.titleChild[e.titleChild.length-1].componentName),{setValue:{titleChildName:t}}}},e.childIndicesToRender={returnDependencies:()=>({titleChildren:{dependencyType:"child",childGroups:["titles"]},allChildren:{dependencyType:"child",childGroups:["anything","variantControls","titles","setups"]},titleChildName:{dependencyType:"stateVariable",variableName:"titleChildName"}}),definition({dependencyValues:e}){let t=[],n=e.titleChildren.map((e=>e.componentName));for(let[r,a]of e.allChildren.entries())"object"==typeof a&&n.includes(a.componentName)&&a.componentName!==e.titleChildName||t.push(r);return{setValue:{childIndicesToRender:t}}}},e.title={additionalStateVariablesDefined:[{variableName:"titlePrefix",forRenderer:!0,alwaysUpdateRenderer:!0}],public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,alwaysUpdateRenderer:!0,returnDependencies:({sharedParameters:e})=>({titleChild:{dependencyType:"child",childGroups:["titles"],variableNames:["text"]},sectionName:{dependencyType:"stateVariable",variableName:"sectionName"},sectionNumber:{dependencyType:"stateVariable",variableName:"sectionNumber"},includeAutoName:{dependencyType:"stateVariable",variableName:"includeAutoName"},includeAutoNumber:{dependencyType:"stateVariable",variableName:"includeAutoNumber"},prerender:{dependencyType:"value",value:e.prerender},includeAutoNameNumberIfNoTitle:{dependencyType:"stateVariable",variableName:"includeAutoNameNumberIfNoTitle"}}),definition({dependencyValues:e}){let t="",n="";const r=e.titleChild.length>0;let a=(e.includeAutoNumber||!r&&e.includeAutoNameNumberIfNoTitle)&&!e.prerender,i=e.includeAutoName||!r&&e.includeAutoNameNumberIfNoTitle;return a?(i&&(t=e.sectionName+" "),t+=e.sectionNumber):i&&(t=e.sectionName),r?(t&&(e.includeAutoName?t+=": ":t+=". "),n=e.titleChild[e.titleChild.length-1].stateValues.text):n=t,{setValue:{title:n,titlePrefix:t}}}},e.containerTag={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{containerTag:"section"}})},e.level={forRenderer:!0,returnDependencies:()=>({ancestorLevel:{dependencyType:"ancestor",componentType:"_sectioningComponent",variableNames:["level"]},levelAttr:{dependencyType:"attributeComponent",attributeName:"level",variableNames:["value"]}}),definition({dependencyValues:e}){let t=e.levelAttr?.stateValues.value;return t>0||(t=(e.ancestorLevel?.stateValues.level||0)+1),{setValue:{level:t}}}},e.viewedSolution={defaultValue:!1,hasEssential:!0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{viewedSolution:!0}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setEssentialValue:"viewedSolution",value:e.viewedSolution}]})},e.scoredDescendants={returnDependencies:()=>({scoredDescendants:{dependencyType:"descendant",componentTypes:["_sectioningComponent","answer","setup"],variableNames:["scoredDescendants","aggregateScores","weight"],recurseToMatchedChildren:!1,variablesOptional:!0}}),definition({dependencyValues:e}){let t=[];for(let n of e.scoredDescendants)"setup"!==n.componentType&&(n.stateValues.aggregateScores||void 0===n.stateValues.scoredDescendants?t.push(n):t.push(...n.stateValues.scoredDescendants));return{setValue:{scoredDescendants:t}}}},e.answerDescendants={returnDependencies:()=>({answerDescendants:{dependencyType:"descendant",componentTypes:["answer"],variableNames:["justSubmitted"],recurseToMatchedChildren:!1}}),definition:({dependencyValues:e})=>({setValue:{answerDescendants:e.answerDescendants}})},e.justSubmitted={forRenderer:!0,returnDependencies:()=>({answerDescendants:{dependencyType:"stateVariable",variableName:"answerDescendants"}}),definition:({dependencyValues:e})=>({setValue:{justSubmitted:e.answerDescendants.every((e=>e.stateValues.justSubmitted))}})},e.showCorrectness={forRenderer:!0,returnDependencies:()=>({showCorrectnessFlag:{dependencyType:"flag",flagName:"showCorrectness"}}),definition:({dependencyValues:e})=>({setValue:{showCorrectness:!1!==e.showCorrectnessFlag}})},e.displayDigitsForCreditAchieved={returnDependencies:()=>({}),definition:()=>({setValue:{displayDigitsForCreditAchieved:3}})},e.creditAchieved={public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:{displayDigits:{stateVariableToShadow:"displayDigitsForCreditAchieved"}}},forRenderer:!0,defaultValue:0,hasEssential:!0,additionalStateVariablesDefined:[{variableName:"percentCreditAchieved",public:!0,shadowingInstructions:{createComponentOfType:"number",addAttributeComponentsShadowingStateVariables:{displayDigits:{stateVariableToShadow:"displayDigitsForCreditAchieved"}}},defaultValue:0,hasEssential:!0}],stateVariablesDeterminingDependencies:["aggregateScores","scoredDescendants"],returnDependencies({stateValues:e}){let t={aggregateScores:{dependencyType:"stateVariable",variableName:"aggregateScores"}};if(e.aggregateScores){t.scoredDescendants={dependencyType:"stateVariable",variableName:"scoredDescendants"};for(let[n,r]of e.scoredDescendants.entries())t["creditAchieved"+n]={dependencyType:"stateVariable",componentName:r.componentName,variableName:"creditAchieved"}}return t},definition({dependencyValues:e}){if(!e.aggregateScores)return{setValue:{creditAchieved:0,percentCreditAchieved:0}};let t,n=0,r=0;for(let[t,a]of e.scoredDescendants.entries()){let i=a.stateValues.weight;n+=e["creditAchieved"+t]*i,r+=i}return t=r>0?n/r:1,{setValue:{creditAchieved:t,percentCreditAchieved:100*t}}}},e.creditAchievedIfSubmit={defaultValue:0,stateVariablesDeterminingDependencies:["aggregateScores","scoredDescendants"],returnDependencies({stateValues:e}){let t={aggregateScores:{dependencyType:"stateVariable",variableName:"aggregateScores"}};if(e.aggregateScores){t.scoredDescendants={dependencyType:"stateVariable",variableName:"scoredDescendants"};for(let[n,r]of e.scoredDescendants.entries())t["creditAchievedIfSubmit"+n]={dependencyType:"stateVariable",componentName:r.componentName,variableName:"creditAchievedIfSubmit"}}return t},definition({dependencyValues:e}){if(!e.aggregateScores)return{setValue:{creditAchievedIfSubmit:0}};let t=0,n=0;for(let[r,a]of e.scoredDescendants.entries()){let i=a.stateValues.weight;t+=e["creditAchievedIfSubmit"+r]*i,n+=i}return{setValue:{creditAchievedIfSubmit:t/n}}}},e.generatedVariantInfo={additionalStateVariablesDefined:["isVariantComponent"],returnDependencies:({sharedParameters:e,componentInfoObjects:t})=>({variantSeed:{dependencyType:"value",value:e.variantSeed},variantIndex:{dependencyType:"value",value:e.variantIndex},variantName:{dependencyType:"value",value:e.variantName},variantDescendants:{dependencyType:"descendant",componentTypes:Object.keys(t.componentTypesCreatingVariants),variableNames:["isVariantComponent","generatedVariantInfo"],recurseToMatchedChildren:!1,variablesOptional:!0,includeNonActiveChildren:!0,ignoreReplacementsOfEncounteredComposites:!0}}),definition({dependencyValues:e,componentName:t}){let n={};e.variantName?(n.index=e.variantIndex,n.name=e.variantName):n.seed=e.variantSeed,n.meta={createdBy:t};let r=n.subvariants=[];for(let t of e.variantDescendants)t.stateValues.isVariantComponent?r.push(t.stateValues.generatedVariantInfo):t.stateValues.generatedVariantInfo&&r.push(...t.stateValues.generatedVariantInfo.subvariants);return{setValue:{generatedVariantInfo:n,isVariantComponent:!0}}}},e.collapsible={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{collapsible:!1}})},e.open={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,defaultValue:!0,hasEssential:!0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{open:!0}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setEssentialValue:"open",value:e.open}]})},e.createSubmitAllButton={forRenderer:!0,additionalStateVariablesDefined:[{variableName:"suppressAnswerSubmitButtons",forRenderer:!0}],returnDependencies:()=>({sectionWideCheckWork:{dependencyType:"stateVariable",variableName:"sectionWideCheckWork"},aggregateScores:{dependencyType:"stateVariable",variableName:"aggregateScores"},sectionAncestor:{dependencyType:"ancestor",componentType:"_sectioningComponent",variableNames:["suppressAnswerSubmitButtons"]},documentAncestor:{dependencyType:"ancestor",componentType:"document",variableNames:["suppressAnswerSubmitButtons"]}}),definition({dependencyValues:e,componentName:t}){let n=!1,r=!1;return e.documentAncestor.stateValues.suppressAnswerSubmitButtons||e.sectionAncestor&&e.sectionAncestor.stateValues.suppressAnswerSubmitButtons?r=!0:e.sectionWideCheckWork&&(e.aggregateScores?(n=!0,r=!0):console.warn(`Cannot create submit all button for ${t} because it doesn't aggegrate scores`)),{setValue:{createSubmitAllButton:n,suppressAnswerSubmitButtons:r}}}},e.suppressCheckwork={forRenderer:!0,returnDependencies:()=>({autoSubmit:{dependencyType:"flag",flagName:"autoSubmit"}}),definition:({dependencyValues:e})=>({setValue:{suppressCheckwork:e.autoSubmit}})},e}async submitAllAnswers({actionId:e}){this.coreFunctions.requestRecordEvent({verb:"submitted",object:{componentName:this.componentName,componentType:this.componentType},result:{creditAchieved:await this.stateValues.creditAchievedIfSubmit}});for(let e of await this.stateValues.answerDescendants)await e.stateValues.justSubmitted||await this.coreFunctions.performAction({componentName:e.componentName,actionName:"submitAnswer"});this.coreFunctions.resolveAction({actionId:e})}async revealSection({actionId:e}){return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"open",value:!0}],overrideReadOnly:!0,actionId:e,event:{verb:"viewed",object:{componentName:this.componentName,componentType:this.componentType}}})}async closeSection({actionId:e}){return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"open",value:!1}],overrideReadOnly:!0,actionId:e,event:{verb:"closed",object:{componentName:this.componentName,componentType:this.componentType}}})}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}static setUpVariant({serializedComponent:e,sharedParameters:t,descendantVariantComponents:n}){if(!e.variants?.allPossibleVariants)return void setUpVariantSeedAndRng({serializedComponent:e,sharedParameters:t,descendantVariantComponents:n,useSubpartVariantRng:!0});let r,a=e.variants.numberOfVariants,i=e.variants.desiredVariant;if(void 0!==i&&void 0!==i.index){let e=Number(i.index);if(Number.isFinite(e)){Number.isInteger(e)||(console.warn("Variant index "+i.index+" must be an integer"),e=Math.round(e));let t=(e-1)%a;t<0&&(t+=a),r=t+1}else console.warn("Variant index "+i.index+" must be a number"),r=1}if(void 0===r){let e=t.variantRng();r=Math.floor(e*a)+1}if(t.allPossibleVariants=e.variants.allPossibleVariants,t.allVariantNames=e.variants.allVariantNames,t.variantSeed=e.variants.allPossibleVariantSeeds[r-1],t.variantIndex=r,t.variantName=e.variants.allPossibleVariants[r-1],t.uniqueIndex=e.variants.allPossibleVariantUniqueIndices[r-1],t.variantRng=new t.rngClass(t.variantSeed),t.subpartVariantRng=new t.rngClass(t.variantSeed+"s"),i?.subvariants&&n)for(let e in i.subvariants){let t=i.subvariants[e],r=n[e];if(void 0===r)break;r.variants.desiredVariant=t}}static determineNumberOfUniqueVariants({serializedComponent:e,componentInfoObjects:t}){return determineVariantsForSection({serializedComponent:e,componentInfoObjects:t})}static getUniqueVariant({serializedComponent:e,variantIndex:t,componentInfoObjects:n}){if(!e.variants.allPossibleVariants)return super.getUniqueVariant({serializedComponent:e,variantIndex:t,componentInfoObjects:n});let r=e.variants.allPossibleVariantUniqueIndices[t-1];if(void 0===r)return{success:!1};if(!e.variants.uniqueVariants)return{success:!0,desiredVariant:{index:t}};let a=getVariantsForDescendantsForUniqueVariants({variantIndex:r,serializedComponent:e,componentInfoObjects:n});return a.success?(e.variants.selectedUniqueVariant=!0,{success:!0,desiredVariant:{index:t,subvariants:a.desiredVariants}}):(console.log("Failed to get unique variant for section."),{success:!1})}}class Section extends SectioningComponent{static componentType="section";static rendererType="section";static createAttributesObject(){let e=super.createAttributesObject();return e.includeParentNumber.defaultValue=!0,e}}class Subsection extends Section{static componentType="subsection"}class Subsubsection extends Section{static componentType="subsubsection"}class Paragraphs extends SectioningComponent{static componentType="paragraphs";static rendererType="section";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.level.definition=()=>({setValue:{level:4}}),e.sectionName.definition=()=>({setValue:{sectionName:"Paragraphs"}}),e}}class Aside extends SectioningComponent{static componentType="aside";static rendererType="section";static createAttributesObject(){let e=super.createAttributesObject();return e.collapsible={createComponentOfType:"boolean",createStateVariable:"collapsible",defaultValue:!0,public:!0,forRenderer:!0},e.startOpen={createComponentOfType:"boolean",createStateVariable:"startOpen",defaultValue:!1},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return delete e.collapsible,e.open.returnDependencies=()=>({startOpen:{dependencyType:"stateVariable",variableName:"startOpen"}}),e.open.definition=({dependencyValues:e})=>({useEssentialOrDefaultValue:{open:{defaultValue:e.startOpen}}}),e.level.definition=()=>({setValue:{level:3}}),e.containerTag.definition=()=>({setValue:{containerTag:"aside"}}),e.sectionName.definition=()=>({setValue:{sectionName:"Aside"}}),e}}class Problem extends SectioningComponent{static componentType="problem";static rendererType="section";static createAttributesObject(){let e=super.createAttributesObject();return e.aggregateScores.defaultValue=!0,e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.sectionName.definition=()=>({setValue:{sectionName:"Problem"}}),e}}class Exercise extends Problem{static componentType="exercise";static rendererType="section";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.sectionName.definition=()=>({setValue:{sectionName:"Exercise"}}),e}}class Example extends SectioningComponent{static componentType="example";static rendererType="section";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.sectionName.definition=()=>({setValue:{sectionName:"Example"}}),e}}class StandinForFutureLayoutTag extends SectioningComponent{static componentType="standinForFutureLayoutTag";static rendererType="section";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.level.definition=()=>({setValue:{level:3}}),e.containerTag.definition=()=>({setValue:{containerTag:"aside"}}),e}}class externalContent extends SectioningComponent{static componentType="externalContent";static rendererType="section";static createAttributesObject(){let e=super.createAttributesObject();return e.includeAutoNameNumberIfNoTitle.defaultValue=!1,e}}var Sectioning=Object.freeze({__proto__:null,Section:Section,Subsection:Subsection,Subsubsection:Subsubsection,Paragraphs:Paragraphs,Aside:Aside,Problem:Problem,Exercise:Exercise,Example:Example,StandinForFutureLayoutTag:StandinForFutureLayoutTag,externalContent:externalContent});class Ol extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="ol";static rendererType="list";static renderChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.label={createComponentOfType:"text",createStateVariable:"label",defaultValue:null,public:!0,forRenderer:!0},e.level={createComponentOfType:"integer"},e}static returnChildGroups(){return[{group:"lis",componentTypes:["li"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.numbered={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{numbered:!0}})},e.level={forRenderer:!0,returnDependencies:()=>({ancestorLevel:{dependencyType:"ancestor",componentType:"ol",variableNames:["level"]},levelAttr:{dependencyType:"attributeComponent",attributeName:"level",variableNames:["value"]}}),definition({dependencyValues:e}){let t=e.levelAttr?.stateValues.value;return t>0||(t=(e.ancestorLevel?.stateValues.level||0)+1),{setValue:{level:t}}}},e}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}class Ul extends Ol{static componentType="ul";static rendererType="list";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.numbered={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{numbered:!1}})},e}}class Li$1 extends BaseComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="li";static rendererType="list";static renderChildren=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.item={forRenderer:!0,returnDependencies:()=>({}),definition:()=>({setValue:{item:!0}})},e}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}var Lists=Object.freeze({__proto__:null,Ol:Ol,Ul:Ul,Li:Li$1});class ODESystem extends InlineComponent{static componentType="odesystem";static rendererType="math";static createAttributesObject(){let e=super.createAttributesObject();return e.independentVariable={createComponentOfType:"variable",createStateVariable:"independentVariable",defaultValue:me$3.fromAst("t"),public:!0},e.initialIndependentVariableValue={createComponentOfType:"math",createStateVariable:"initialIndependentVariableValue",defaultValue:me$3.fromAst(0),public:!0},e.displayDigits={createComponentOfType:"integer",createStateVariable:"displayDigits",defaultValue:14,public:!0},e.displayDecimals={createComponentOfType:"integer",createStateVariable:"displayDecimals",defaultValue:null,public:!0},e.displaySmallAsZero={createComponentOfType:"number",createStateVariable:"displaySmallAsZero",valueForTrue:1e-14,valueForFalse:0,defaultValue:0,public:!0},e.padZeros={createComponentOfType:"boolean",createStateVariable:"padZeros",defaultValue:!1,public:!0},e.renderMode={createComponentOfType:"text",createStateVariable:"renderMode",defaultValue:"align",public:!0,forRenderer:!0},e.chunkSize={createComponentOfType:"number",createStateVariable:"chunkSize",defaultValue:10,public:!0},e.tolerance={createComponentOfType:"number",createStateVariable:"tolerance",defaultValue:1e-6,public:!0},e.maxIterations={createComponentOfType:"number",createStateVariable:"maxIterations",defaultValue:1e3,public:!0},e.hideInitialCondition={createComponentOfType:"boolean",createStateVariable:"hideInitialCondition",defaultValue:!1,public:!0},e.initialConditions={createComponentOfType:"mathList"},e.variables={createComponentOfType:"variables"},e.number={createComponentOfType:"boolean",createStateVariable:"number",defaultValue:!1,public:!0},e}static returnChildGroups(){return[{group:"rightHandSides",componentTypes:["rightHandSide"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.validIndependentVariable={returnDependencies:()=>({independentVarAttr:{dependencyType:"attributeComponent",attributeName:"independentVariable",variableNames:["validVariable"]}}),definition({dependencyValues:e}){let t=!0;return e.independentVarAttr&&(t=e.independentVarAttr.stateValues.validVariable),{setValue:{validIndependentVariable:t}}}},e.nDimensions={returnDependencies:()=>({rhsChildren:{dependencyType:"child",childGroups:["rightHandSides"],skipComponentNames:!0}}),definition:function({dependencyValues:e}){return{setValue:{nDimensions:e.rhsChildren.length},checkForActualChange:{nDimensions:!0}}}},e.variables={additionalStateVariablesDefined:[{variableName:"validVariables",isArray:!0,entryPrefixes:["validVar"]}],isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"variable"},entryPrefixes:["var"],returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey:()=>({globalDependencies:{nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},variables:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["variables","validVariables"]},independentVariable:{dependencyType:"stateVariable",variableName:"independentVariable"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t=[],n=[],r=e.nDimensions;null!==e.variables&&(t=e.variables.stateValues.variables,n=[...e.variables.stateValues.validVariables].slice(0,r));let a=returnNVariables(r,t);return a.some((t=>t.equals(e.independentVariable)))&&console.warn("Variables of odesystem must be different than independent variable."),n.length({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={rhsChild:{dependencyType:"child",childGroups:["rightHandSides"],variableNames:["value"],childIndices:[n]}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e[r].rhsChild[0].stateValues.value;return{setValue:{rhss:n}}}},e.rhs={isAlias:!0,targetVariableName:"rhs1"},e.righthandside={isAlias:!0,targetVariableName:"rhs1"},e.righthandsides={isAlias:!0,targetVariableName:"rhss"},e.initialConditions={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math"},entryPrefixes:["initialCondition"],defaultValueByArrayKey:()=>me$3.fromAst(0),returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={initialConditionAttr:{dependencyType:"attributeComponent",attributeName:"initialConditions",variableNames:[`math${Number(n)+1}`]}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={},r={};for(let a of t){let t=!1;if(e[a].initialConditionAttr){let r=e[a].initialConditionAttr.stateValues[`math${Number(a)+1}`];void 0!==r&&(t=!0,n[a]=r)}t||(r[a]=!0)}let a={};return Object.keys(n).length>0&&(a.setValue={initialConditions:n}),Object.keys(r).length>0&&(a.useEssentialOrDefaultValue={initialConditions:r}),a}},e.initialCondition={isAlias:!0,targetVariableName:"initialCondition1"},e.equationTag={public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,stateVariablesDeterminingDependencies:["number"],returnDependencies:({stateValues:e})=>e.number?{equationCounter:{dependencyType:"counter",counterName:"equation"}}:{},definition:({dependencyValues:e})=>void 0!==e.equationCounter?{setValue:{equationTag:String(e.equationCounter)}}:{setValue:{equationTag:null}}},e.latex={public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,returnDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},variables:{dependencyType:"stateVariable",variableName:"variables"},initialConditions:{dependencyType:"stateVariable",variableName:"initialConditions"},hideInitialCondition:{dependencyType:"stateVariable",variableName:"hideInitialCondition"},displayDigits:{dependencyType:"stateVariable",variableName:"displayDigits"},displayDecimals:{dependencyType:"stateVariable",variableName:"displayDecimals"},displaySmallAsZero:{dependencyType:"stateVariable",variableName:"displaySmallAsZero"},padZeros:{dependencyType:"stateVariable",variableName:"padZeros"},independentVariable:{dependencyType:"stateVariable",variableName:"independentVariable"},initialIndependentVariableValue:{dependencyType:"stateVariable",variableName:"initialIndependentVariableValue"},rhss:{dependencyType:"stateVariable",variableName:"rhss"},number:{dependencyType:"stateVariable",variableName:"number"},equationTag:{dependencyType:"stateVariable",variableName:"equationTag"}}),definition({dependencyValues:e,usedDefault:t}){let n={};e.padZeros&&(t.displayDigits&&!t.displayDecimals?Number.isFinite(e.displayDecimals)&&(n.padToDecimals=e.displayDecimals):e.displayDigits>=1&&(n.padToDigits=e.displayDigits));let r=[],a=e.independentVariable.toLatex();for(let i=0;i({latex:{dependencyType:"stateVariable",variableName:"latex"}}),definition:function({dependencyValues:e}){return{setValue:{latexWithInputChildren:[e.latex]}}}},e.numericalRHSf={additionalStateVariablesDefined:["numericalRHSfDefinitions"],returnDependencies:()=>({validIndependentVariable:{dependencyType:"stateVariable",variableName:"validIndependentVariable"},independentVariable:{dependencyType:"stateVariable",variableName:"independentVariable"},validVariables:{dependencyType:"stateVariable",variableName:"validVariables"},variables:{dependencyType:"stateVariable",variableName:"variables"},rhss:{dependencyType:"stateVariable",variableName:"rhss"}}),definition({dependencyValues:e}){let t=!0;e.validIndependentVariable||(console.warn("Can't define ODE RHS functions with invalid independent variable."),t=!1),e.validVariables.every((e=>e))||(console.warn("Can't define ODE RHS functions with an invalid variable."),t=!1);let n,r=e.independentVariable.subscripts_to_strings().tree,a=e.variables.map((e=>e.subscripts_to_strings().tree));a.includes(r)&&(console.warn("Can't define ODE RHS functions when independent variable is a dependent variable"),t=!1),[...new Set(a)].length!==a.length&&(console.warn("Can't define ODE RHS functions with duplicate dependent variable names"),t=!1);try{n=e.rhss.map((e=>e.subscripts_to_strings().f()))}catch(e){console.warn("Cannot define ODE RHS function. Error creating mathjs function"),t=!1}if(!t){let t=e.rhss.length;return{setValue:{numericalRHSf:()=>NaN,numericalRHSfDefinitions:Array(t).fill({})}}}return{setValue:{numericalRHSf:function(e,t){let i={[r]:e};Array.isArray(t)?t.forEach(((e,t)=>i[a[t]]=e)):i[a[0]]=t;try{return n.map((e=>e(i)))}catch(e){return NaN}},numericalRHSfDefinitions:e.rhss.map((e=>({functionType:"formula",formula:e,nInputs:a.length+1,variables:[r,...a]})))}}}},e.haveNumericalInitialConditions={additionalStateVariablesDefined:["t0","x0s"],returnDependencies:()=>({initialIndependentVariableValue:{dependencyType:"stateVariable",variableName:"initialIndependentVariableValue"},initialConditions:{dependencyType:"stateVariable",variableName:"initialConditions"}}),definition({dependencyValues:e}){let t=e.initialIndependentVariableValue.evaluate_to_constant(),n=e.initialConditions.map((e=>e.evaluate_to_constant())),r=Number.isFinite(t)&&n.every((e=>Number.isFinite(e)));return{setValue:{t0:t,x0s:n,haveNumericalInitialConditions:r}}}},e.numericalSolutions={isArray:!0,entryPrefixes:["numericalSolution"],public:!0,shadowingInstructions:{createComponentOfType:"function",addStateVariablesShadowingStateVariables:{fDefinitions:{stateVariableToShadow:"numericalSolutionFDefinitions"}}},createWorkspace:!0,returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey:()=>({globalDependencies:{nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},validIndependentVariable:{dependencyType:"stateVariable",variableName:"validIndependentVariable"},independentVariable:{dependencyType:"stateVariable",variableName:"independentVariable"},validVariables:{dependencyType:"stateVariable",variableName:"validVariables"},variables:{dependencyType:"stateVariable",variableName:"variables"},chunkSize:{dependencyType:"stateVariable",variableName:"chunkSize"},tolerance:{dependencyType:"stateVariable",variableName:"tolerance"},maxIterations:{dependencyType:"stateVariable",variableName:"maxIterations"},haveNumericalInitialConditions:{dependencyType:"stateVariable",variableName:"haveNumericalInitialConditions"},t0:{dependencyType:"stateVariable",variableName:"t0"},x0s:{dependencyType:"stateVariable",variableName:"x0s"},numericalRHSf:{dependencyType:"stateVariable",variableName:"numericalRHSf"}}}),arrayDefinitionByKey({globalDependencyValues:e,workspace:t,componentName:n}){let r={};if(t.calculatedNumericSolutions=[],t.endingNumericalValues=[],t.maxPossibleTime=void 0,!e.haveNumericalInitialConditions){for(let t=0;tNaN;return{setValue:{numericalSolutions:r}}}let a=e.t0,i=e.x0s,s=e.chunkSize,o=e.tolerance,l=e.numericalRHSf,u=e.maxIterations;for(let c=0;c=r)for(let e=r;e<=p;e++){let r=t.endingNumericalValues[e-1];void 0===r&&(r=i);let c=a+e*s,p=me$3.math.dopri(c,c+s,r,l,o,u);t.endingNumericalValues.push(p.y[p.y.length-1]),t.calculatedNumericSolutions.push(p.at.bind(p));let d=p.x[p.x.length-1];if(d<.999999*(c+s)){t.maxPossibleTime=d;let e="For chunksize "+s+" and tolerance "+o+", odesystem";void 0!==n&&(e+=" ("+n+")"),e+=" hit maxiterations ("+u+") at t = "+t.maxPossibleTime+". Will not calculate solution beyond that time. Decrease chunksize, increase maxiterations, or increase tolerance to calculate further.";break}}return e>t.maxPossibleTime?NaN:t.calculatedNumericSolutions[p](e)[c]};return{setValue:{numericalSolutions:r}}}},e.numericalSolution={isAlias:!0,targetVariableName:"numericalSolution1"},e.numericalSolutionFDefinitions={forRenderer:!0,isArray:!0,entryPrefixes:["numericalSolutionFDefinition"],returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey:()=>({globalDependencies:{nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},validIndependentVariable:{dependencyType:"stateVariable",variableName:"validIndependentVariable"},independentVariable:{dependencyType:"stateVariable",variableName:"independentVariable"},validVariables:{dependencyType:"stateVariable",variableName:"validVariables"},variables:{dependencyType:"stateVariable",variableName:"variables"},chunkSize:{dependencyType:"stateVariable",variableName:"chunkSize"},tolerance:{dependencyType:"stateVariable",variableName:"tolerance"},maxIterations:{dependencyType:"stateVariable",variableName:"maxIterations"},haveNumericalInitialConditions:{dependencyType:"stateVariable",variableName:"haveNumericalInitialConditions"},t0:{dependencyType:"stateVariable",variableName:"t0"},x0s:{dependencyType:"stateVariable",variableName:"x0s"},numericalRHSfDefinitions:{dependencyType:"stateVariable",variableName:"numericalRHSfDefinitions"}}}),arrayDefinitionByKey:({globalDependencyValues:e})=>e.haveNumericalInitialConditions?{setValue:{numericalSolutionFDefinitions:[...Array(e.nDimensions).keys()].map((t=>({functionType:"ODESolution",nDimensions:e.nDimensions,t0:e.t0,x0s:e.x0s,chunkSize:e.chunkSize,tolerance:e.tolerance,numericalRHSfDefinitions:e.numericalRHSfDefinitions,maxIterations:e.maxIterations,component:t})))}}:{setValue:{numericalSolutionFDefinitions:Array(e.nDimensions).fill({})}}},e}}class Polyline extends GraphicalComponent{constructor(e){super(e),Object.assign(this.actions,{movePolyline:this.movePolyline.bind(this),finalizePolylinePosition:this.finalizePolylinePosition.bind(this),polylineClicked:this.polylineClicked.bind(this),mouseDownOnPolyline:this.mouseDownOnPolyline.bind(this)})}static componentType="polyline";static createAttributesObject(){let e=super.createAttributesObject();return e.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},e.verticesDraggable={createComponentOfType:"boolean"},e.vertices={createComponentOfType:"_pointListComponent"},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.styleDescription={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({selectedStyle:{dependencyType:"stateVariable",variableName:"selectedStyle"}}),definition:function({dependencyValues:e}){let t=e.selectedStyle.lineWidthWord;return e.selectedStyle.lineStyleWord&&(t&&(t+=" "),t+=e.selectedStyle.lineStyleWord),t&&(t+=" "),t+=e.selectedStyle.lineColorWord,{setValue:{styleDescription:t}}}},e.styleDescriptionWithNoun={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({styleDescription:{dependencyType:"stateVariable",variableName:"styleDescription"}}),definition:function({dependencyValues:e}){return{setValue:{styleDescriptionWithNoun:e.styleDescription+" polyline"}}}},e.verticesDraggable={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},hasEssential:!0,forRenderer:!0,returnDependencies:()=>({verticesDraggableAttr:{dependencyType:"attributeComponent",attributeName:"verticesDraggable",variableNames:["value"]},draggable:{dependencyType:"stateVariable",variableName:"draggable"}}),definition:({dependencyValues:e})=>e.verticesDraggableAttr?{setValue:{verticesDraggable:e.verticesDraggableAttr.stateValues.value}}:{useEssentialOrDefaultValue:{verticesDraggable:{defaultValue:e.draggable}}}},e.nVertices={public:!0,shadowingInstructions:{createComponentOfType:"number"},forRenderer:!0,returnDependencies:()=>({vertices:{dependencyType:"attributeComponent",attributeName:"vertices",variableNames:["nPoints"]}}),definition:function({dependencyValues:e}){return null!==e.vertices?{setValue:{nVertices:e.vertices.stateValues.nPoints}}:{setValue:{nVertices:0}}}},e.nDimensions={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({vertices:{dependencyType:"attributeComponent",attributeName:"vertices",variableNames:["nDimensions"]}}),definition:function({dependencyValues:e}){if(null!==e.vertices){return{setValue:{nDimensions:e.vertices.stateValues.nDimensions},checkForActualChange:{nDimensions:!0}}}return{setValue:{nDimensions:2}}}},e.vertices={public:!0,shadowingInstructions:{createComponentOfType:"math",returnWrappingComponents:e=>"vertexX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["vertexX","vertex"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("vertexX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},getAllArrayKeys(e,t=!0,n){function r(e){if(1===e.length)return Array.from(Array(e[0]),((e,t)=>String(t)));{let n=e[0],a=r(e.slice(1)),i=[];for(let e=0;ee+","+t))):i.push(a.map((t=>e+","+t)));return i}}if(n){if(0!==n.length&&e){let t=[...e];return t[0]=n[0],r(t)}return[]}return e&&0!==e.length?r(e):[]},arrayVarNameFromPropIndex(e,t){if("vertices"===t)return 1===e.length?"vertex"+e[0]:`vertexX${e[0]}_${e[1]}`;if("vertex"===t.slice(0,6)){let n=Number(t.slice(6));if(Number.isInteger(n)&&n>0)return`vertexX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nVertices:{dependencyType:"stateVariable",variableName:"nVertices"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nVertices,e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let[e,r]=n.split(","),a=Number(e)+1+"_"+(Number(r)+1);t[n]={vertices:{dependencyType:"attributeComponent",attributeName:"vertices",variableNames:["pointX"+a]}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let[t,a]=r.split(","),i=Number(t)+1+"_"+(Number(a)+1),s=e[r].vertices;null!==s&&s.stateValues["pointX"+i]?n[r]=s.stateValues["pointX"+i]:n[r]=me$3.fromAst("_")}return{setValue:{vertices:n}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyValuesByKey:t,dependencyNamesByKey:n,initialChange:r,stateValues:a}){let i=[];for(let r in e.vertices){let[a,s]=r.split(","),o=Number(a)+1+"_"+(Number(s)+1);if(null===t[r].vertices||!t[r].vertices.stateValues["pointX"+o])return{success:!1};i.push({setDependency:n[r].vertices,desiredValue:e.vertices[r],variableIndex:0})}return{success:!0,instructions:i}}},e.numericalVertices={isArray:!0,entryPrefixes:["numericalVertex"],forRenderer:!0,returnArraySizeDependencies:()=>({nVertices:{dependencyType:"stateVariable",variableName:"nVertices"}}),returnArraySize:({dependencyValues:e})=>[e.nVertices],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={vertex:{dependencyType:"stateVariable",variableName:"vertex"+(Number(n)+1)}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].vertex.map((e=>e.evaluate_to_constant()));t.every((e=>Number.isFinite(e)))||(t=Array(t.length).fill(NaN)),n[r]=t}return{setValue:{numericalVertices:n}}}},e.nearestPoint={returnDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},numericalVertices:{dependencyType:"stateVariable",variableName:"numericalVertices"},nVertices:{dependencyType:"stateVariable",variableName:"nVertices"}}),definition({dependencyValues:e}){let t,n,r=e.nDimensions,a=e.nVertices,i=e.numericalVertices,s=[],o=i[0]?.[0],l=i[0]?.[1];for(let e=1;e=1?{x1:h,x2:f}:{x1:l+g*a*n,x2:u+g*y*o};let b=Math.pow((d-r.x1)/n,2)+Math.pow((m-r.x2)/o,2);b0&&(p.x3=0),p}}}}},e}async movePolyline({pointCoords:e,transient:t,sourceInformation:n,actionId:r}){if(1===Object.keys(e).length){if(!await this.stateValues.verticesDraggable)return await this.coreFunctions.resolveAction({actionId:r})}else if(!await this.stateValues.draggable)return await this.coreFunctions.resolveAction({actionId:r});let a={};for(let t in e)a[t+",0"]=me$3.fromAst(e[t][0]),a[t+",1"]=me$3.fromAst(e[t][1]);return t?await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"vertices",value:a,sourceInformation:n}],transient:t,actionId:r}):await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"vertices",value:a,sourceInformation:n}],actionId:r,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{pointCoordinates:e}}})}async finalizePolylinePosition(){return await this.actions.movePolyline({pointCoords:await this.stateValues.numericalVertices,transient:!1})}async polylineClicked({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"click",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}async mouseDownOnPolyline({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"down",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}}class CobwebPolyline extends Polyline{static componentType="cobwebPolyline";static rendererType="cobwebPolyline";static createAttributesObject(){let e=super.createAttributesObject();return e.attractThreshold={createComponentOfType:"number",createStateVariable:"attractThreshold",defaultValue:.5,public:!0},e.nPoints={createComponentOfType:"number",createStateVariable:"nPoints",defaultValue:1,public:!0,clamp:[0,1/0],forRenderer:!0},e.variable={createComponentOfType:"variable",createStateVariable:"variable",defaultValue:me$3.fromAst("x"),public:!0,forRenderer:!0},e.nIterationsRequired={createComponentOfType:"number",createStateVariable:"nIterationsRequired",defaultValue:0,public:!0},e.initialPoint={createComponentOfType:"point"},e.function={createComponentOfType:"function"},e.lockToSolution={createComponentOfType:"boolean",createStateVariable:"lockToSolution",defaultValue:!1},e.defaultPoint={createComponentOfType:"point"},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.nDimensions.returnDependencies=()=>({}),e.nDimensions.definition=()=>({setValue:{nDimensions:2}}),e.initialPoint={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math",returnWrappingComponents:e=>"initialPointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},entryPrefixes:["initialPointX"],defaultValueByArrayKey:()=>me$3.fromAst(0),hasEssential:!0,returnArraySizeDependencies:()=>({}),returnArraySize:()=>[2],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={initialPointAttr:{dependencyType:"attributeComponent",attributeName:"initialPoint",variableNames:["x"+e]}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={},r={};for(let a of t){let t=Number(a)+1;e[a].initialPointAttr?n[a]=e[a].initialPointAttr.stateValues["x"+t]:r[a]=!0}let a={};return Object.keys(n).length>0&&(a.setValue={initialPoint:n}),Object.keys(r).length>0&&(a.useEssentialOrDefaultValue={initialPoint:r}),a},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyValuesByKey:t,dependencyNamesByKey:n}){let r=[];for(let a in e.initialPoint)t[a].initialPointAttr&&t[a].initialPointAttr.stateValues["x"+(Number(a)+1)]?r.push({setDependency:n[a].initialPointAttr,desiredValue:e.initialPoint[a],variableIndex:0}):r.push({setEssentialValue:"initialPoint",value:{[a]:e.initialPoint[a]}});return{success:!0,instructions:r}}},e.f={additionalStateVariablesDefined:[{variableName:"fDefinition",forRenderer:!0}],returnDependencies:()=>({functionAttr:{dependencyType:"attributeComponent",attributeName:"function",variableNames:["numericalf","fDefinition"]}}),definition:({dependencyValues:e})=>e.functionAttr?{setValue:{f:e.functionAttr.stateValues.numericalf,fDefinition:e.functionAttr.stateValues.fDefinition}}:{setValue:{f:null,fDefinition:null}}},e.nVertices={isAlias:!0,targetVariableName:"nPoints"},e.nOriginalVertices={providePreviousValuesInDefinition:!0,returnDependencies:()=>({nVertices:{dependencyType:"stateVariable",variableName:"nVertices"}}),definition({dependencyValues:e,previousValues:t}){let n=e.nVertices;return t.nOriginalVertices>n&&(n=t.nOriginalVertices),{setValue:{nOriginalVertices:n}}}},e.originalVertices={isArray:!0,nDimensions:2,hasEssential:!0,entryPrefixes:["originalVertexX","originalVertex"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("originalVertexX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("originalVertices"===t)return 1===e.length?"originalVertex"+e[0]:`originalVertexX${e[0]}_${e[1]}`;if("originalVertex"===t.slice(0,14)){let n=Number(t.slice(14));if(Number.isInteger(n)&&n>0)return`originalVertexX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nOriginalVertices:{dependencyType:"stateVariable",variableName:"nOriginalVertices"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nOriginalVertices-1,e.nDimensions],returnArrayDependenciesByKey:()=>({globalDependencies:{graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xmin","xmax","ymin","ymax"]},defaultPoint:{dependencyType:"attributeComponent",attributeName:"defaultPoint",variableNames:["xs"]}}}),arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n={};for(let r of t){let t=r.split(",").map(Number);n[r]={get defaultValue(){if(e.defaultPoint){let n=e.defaultPoint.stateValues.xs;if(2===n.length&&t[1]<2)return n[t[1]]}if(e.graphAncestor){if(0===t[1]){let t=e.graphAncestor.stateValues.xmin,n=e.graphAncestor.stateValues.xmax;return me$3.fromAst((t+n)/2)}if(1===t[1]){let t=e.graphAncestor.stateValues.ymin,n=e.graphAncestor.stateValues.ymax;return me$3.fromAst((t+n)/2)}}return me$3.fromAst(0)}}}return{useEssentialOrDefaultValue:{originalVertices:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e}){let t=[];for(let n in e.originalVertices)t.push({setEssentialValue:"originalVertices",value:{[n]:e.originalVertices[n]}});return{success:!0,instructions:t}}},e.vertices.additionalStateVariablesDefined=[{variableName:"prelimCorrectVertices",entryPrefixes:["prelimCorrectVertexX","prelimCorrectVertex"],getArrayKeysFromVarName:function({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("prelimCorrectVertexX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}}}],e.vertices.basedOnArrayKeyStateVariables=!0,e.vertices.returnArrayDependenciesByKey=function({arrayKeys:e}){let t={};for(let n of e){let[e,r]=n.split(",");t[n]="0"===e?{initialPoint:{dependencyType:"stateVariable",variableName:"initialPointX"+(Number(r)+1)}}:{originalVertexX1:{dependencyType:"stateVariable",variableName:"originalVertexX"+e+"_1"},originalVertexX2:{dependencyType:"stateVariable",variableName:"originalVertexX"+e+"_2"},previousVertexX1:{dependencyType:"stateVariable",variableName:"vertexX"+e+"_1"},previousVertexX2:{dependencyType:"stateVariable",variableName:"vertexX"+e+"_2"}}}return{globalDependencies:{f:{dependencyType:"stateVariable",variableName:"f"},attractThreshold:{dependencyType:"stateVariable",variableName:"attractThreshold"},lockToSolution:{dependencyType:"stateVariable",variableName:"lockToSolution"}},dependenciesByKey:t}},e.vertices.arrayDefinitionByKey=function({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n}){let r={},a={};for(let i of n){let[n,s]=i.split(",");if("0"===n)r[i]=t[i].initialPoint,a[i]=null;else{let s,o,l;try{s=[t[i].originalVertexX1.evaluate_to_constant(),t[i].originalVertexX2.evaluate_to_constant()],o=[t[i].previousVertexX1.evaluate_to_constant(),t[i].previousVertexX2.evaluate_to_constant()]}catch(e){r[n+",0"]=me$3.fromAst(0),r[n+",1"]=me$3.fromAst(0),a[n+",0"]=!1;continue}if(Number(n)%2==1){let t=e.f(o[0]);l=[o[0],t]}else l=[o[1],o[1]];Math.pow(s[0]-l[0],2)+Math.pow(s[1]-l[1],2)({nVertices:{dependencyType:"stateVariable",variableName:"nVertices"}}),returnArraySize:({dependencyValues:e})=>[e.nVertices-1],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={prelimCorrectVertex:{dependencyType:"stateVariable",variableName:"prelimCorrectVertexX"+(Number(n)+2)+"_1"}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e[r].prelimCorrectVertex;return{setValue:{correctVertices:n}}}},e.fractionCorrectVertices={public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:[{variableName:"nGradedVertices",public:!0,shadowingInstructions:{createComponentOfType:"number"}},{variableName:"nCorrectVertices",public:!0,shadowingInstructions:{createComponentOfType:"number"}}],returnDependencies:()=>({correctVertices:{dependencyType:"stateVariable",variableName:"correctVertices"}}),definition({dependencyValues:e}){let t,n,r=e.correctVertices.length;return 0===r?(t=0,n=0):(n=e.correctVertices.reduce(((e,t)=>e+t),0),t=n/r),{setValue:{fractionCorrectVertices:t,nGradedVertices:r,nCorrectVertices:n}}}},e.fractionCorrectVerticesAdjusted={public:!0,shadowingInstructions:{createComponentOfType:"number"},additionalStateVariablesDefined:[{variableName:"nGradedVerticesAdjusted",public:!0,shadowingInstructions:{createComponentOfType:"number"}}],returnDependencies:()=>({nCorrectVertices:{dependencyType:"stateVariable",variableName:"nCorrectVertices"},nGradedVertices:{dependencyType:"stateVariable",variableName:"nGradedVertices"},nIterationsRequired:{dependencyType:"stateVariable",variableName:"nIterationsRequired"}}),definition({dependencyValues:e}){let t=0;e.nIterationsRequired>0&&(t=2*e.nIterationsRequired-1);let n,r=Math.max(e.nGradedVertices,t);return n=0===r?0:e.nCorrectVertices/r,{setValue:{fractionCorrectVerticesAdjusted:n,nGradedVerticesAdjusted:r}}}},e.nIterateValues={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({nVertices:{dependencyType:"stateVariable",variableName:"nVertices"}}),definition:({dependencyValues:e})=>({setValue:{nIterateValues:Math.ceil((e.nVertices+1)/2)}})},e.iterateValues={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math"},entryPrefixes:["iterateValue"],returnArraySizeDependencies:()=>({nIterateValues:{dependencyType:"stateVariable",variableName:"nIterateValues"}}),returnArraySize:({dependencyValues:e})=>[e.nIterateValues],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]="0"===n?{iterateValue:{dependencyType:"stateVariable",variableName:"vertexX1_1"}}:{iterateValue:{dependencyType:"stateVariable",variableName:"vertexX"+2*Number(n)+"_2"}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e[r].iterateValue;return{setValue:{iterateValues:n}}}},e}}class Point extends GraphicalComponent{constructor(e){super(e),Object.assign(this.actions,{movePoint:this.movePoint.bind(this),switchPoint:this.switchPoint.bind(this),pointClicked:this.pointClicked.bind(this),mouseDownOnPoint:this.mouseDownOnPoint.bind(this)})}static componentType="point";static primaryStateVariableForDefinition="coordsShadow";static stateVariableForAttributeValue="coords";static createAttributesObject(){let e=super.createAttributesObject();return e.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},e.x={createComponentOfType:"math"},e.y={createComponentOfType:"math"},e.z={createComponentOfType:"math"},e.xs={createComponentOfType:"mathList"},e.coords={createComponentOfType:"coords"},e.displayDigits={createComponentOfType:"integer"},e.displayDecimals={createComponentOfType:"integer",createStateVariable:"displayDecimals",defaultValue:null,public:!0},e.displaySmallAsZero={createComponentOfType:"number",createStateVariable:"displaySmallAsZero",valueForTrue:1e-14,valueForFalse:0,defaultValue:0,public:!0},e.padZeros={createComponentOfType:"boolean",createStateVariable:"padZeros",defaultValue:!1,public:!0},e.labelPosition={createComponentOfType:"text",createStateVariable:"labelPosition",defaultValue:"upperright",public:!0,forRenderer:!0,toLowerCase:!0,validValues:["upperright","upperleft","lowerright","lowerleft","top","bottom","left","right"]},e.showCoordsWhenDragging={createComponentOfType:"boolean",createStateVariable:"showCoordsWhenDragging",defaultValue:!0,public:!0,forRenderer:!0},e}static returnSugarInstructions(){let e=super.returnSugarInstructions();return e.push({replacementFunction:function({matchedChildren:e,componentInfoObjects:t}){let n=returnBreakStringsSugarFunction({childrenToComponentFunction:e=>({componentType:"math",children:e}),mustStripOffOuterParentheses:!0}),r=e.map((e=>typeof e)),a=r.indexOf("string"),i=r.lastIndexOf("string");if(-1===a){let n=t.componentIsSpecifiedType,r=e.filter((e=>!(n(e,"point")||n(e,"vector")||n(e,"constraints")||n(e,"label"))));if(1===r.length){let t=r[0],n=e.indexOf(t);return{success:!0,newAttributes:{coords:{component:{componentType:"math",children:r}}},newChildren:[...e.slice(0,n),...e.slice(n+1)]}}return{success:!1}}let s=[...e.slice(0,a),...e.slice(i+1)],o=n({matchedChildren:e=e.slice(a,i+1)});return o.success||1!==e.length?o.success?{success:!0,newAttributes:{xs:{component:{componentType:"mathList",children:o.newChildren,skipSugar:!0}}},newChildren:s}:{success:!1}:{success:!0,newAttributes:{xs:{component:{componentType:"mathList",children:[{componentType:"math",children:e}]}}},newChildren:s}}}),e}static returnChildGroups(){let e=super.returnChildGroups();return e.push({group:"points",componentTypes:["point"]},{group:"vectors",componentTypes:["vector"]},{group:"constraints",componentTypes:["constraints"]}),e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.styleDescription={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({selectedStyle:{dependencyType:"stateVariable",variableName:"selectedStyle"}}),definition:function({dependencyValues:e}){return{setValue:{styleDescription:e.selectedStyle.markerColorWord}}}},e.styleDescriptionWithNoun={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({selectedStyle:{dependencyType:"stateVariable",variableName:"selectedStyle"}}),definition:function({dependencyValues:e}){return{setValue:{styleDescriptionWithNoun:e.selectedStyle.markerColorWord+" "+e.selectedStyle.markerStyleWord}}}},e.displayDigits={public:!0,shadowingInstructions:{createComponentOfType:"integer"},hasEssential:!0,defaultValue:10,returnDependencies:()=>({displayDigitsAttr:{dependencyType:"attributeComponent",attributeName:"displayDigits",variableNames:["value"]},displayDecimalsAttr:{dependencyType:"attributeComponent",attributeName:"displayDecimals",variableNames:["value"]}}),definition({dependencyValues:e,usedDefault:t}){if(null!==e.displayDigitsAttr){let n=null===e.displayDigitsAttr||t.displayDigitsAttr,r=null===e.displayDecimalsAttr||t.displayDecimalsAttr;if(!n&&!r){let t=e.displayDigitsAttr.shadowDepth;e.displayDecimalsAttr.shadowDepth({}),definition:()=>({useEssentialOrDefaultValue:{coordsShadow:!0}}),inverseDefinition:async function({desiredStateVariableValues:e,stateValues:t,workspace:n}){return{success:!0,instructions:[{setEssentialValue:"coordsShadow",value:e.coordsShadow}]}}},e.nDimensions={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({coordsShadow:{dependencyType:"stateVariable",variableName:"coordsShadow"},coords:{dependencyType:"attributeComponent",attributeName:"coords",variableNames:["value"]},x:{dependencyType:"attributeComponent",attributeName:"x"},y:{dependencyType:"attributeComponent",attributeName:"y"},z:{dependencyType:"attributeComponent",attributeName:"z"},xs:{dependencyType:"attributeComponent",attributeName:"xs",variableNames:["nComponents"]},pointChild:{dependencyType:"child",childGroups:["points"],variableNames:["nDimensions"]},vectorChild:{dependencyType:"child",childGroups:["vectors"],variableNames:["nDimensions"]}}),definition:function({dependencyValues:e}){let t,n,r=!1;if(n=null!==e.z?3:null!==e.y?2:0,null!==e.coords?(r=!0,t=e.coords.stateValues.value):e.coordsShadow&&(r=!0,t=e.coordsShadow),r){let e=t.tree;return n=Array.isArray(e)&&vectorOperators.includes(e[0])?Math.max(e.length-1,n):Math.max(1,n),{setValue:{nDimensions:n},checkForActualChange:{nDimensions:!0}}}return null!==e.xs?{setValue:{nDimensions:Math.max(e.xs.stateValues.nComponents,n)}}:e.pointChild.length>0?{setValue:{nDimensions:Math.max(e.pointChild[0].stateValues.nDimensions,n)}}:e.vectorChild.length>0?{setValue:{nDimensions:Math.max(e.vectorChild[0].stateValues.nDimensions,n)}}:(0===n&&(n=2),{setValue:{nDimensions:n},checkForActualChange:{nDimensions:!0}})}},e.arrayVariableForConstraints={returnDependencies:()=>({}),definition:()=>({setValue:{arrayVariableForConstraints:"unconstrainedXs"}})},e.arrayEntryPrefixForConstraints={returnDependencies:()=>({}),definition:()=>({setValue:{arrayEntryPrefixForConstraints:"unconstrainedX"}})},e.nDimensionsForConstraints={isAlias:!0,targetVariableName:"nDimensions"},e.unconstrainedXs={isArray:!0,entryPrefixes:["unconstrainedX"],defaultValueByArrayKey:()=>me$3.fromAst(0),hasEssential:!0,returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={xs:{dependencyType:"attributeComponent",attributeName:"xs",variableNames:["math"+e]},pointChild:{dependencyType:"child",childGroups:["points"],variableNames:["x"+e]},vectorChild:{dependencyType:"child",childGroups:["vectors"],variableNames:["x"+e]}},"0"===n?t[n].component={dependencyType:"attributeComponent",attributeName:"x",variableNames:["value"]}:"1"===n?t[n].component={dependencyType:"attributeComponent",attributeName:"y",variableNames:["value"]}:"2"===n&&(t[n].component={dependencyType:"attributeComponent",attributeName:"z",variableNames:["value"]})}return{globalDependencies:{coordsShadow:{dependencyType:"stateVariable",variableName:"coordsShadow"},coords:{dependencyType:"attributeComponent",attributeName:"coords",variableNames:["value"]}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n}){let r,a={},i={},s=!1;if(null!==e.coords?(s=!0,r=e.coords.stateValues.value):e.coordsShadow&&(s=!0,r=e.coordsShadow),s){let e=r.tree;if(Array.isArray(e)&&vectorOperators.includes(e[0]))for(let t of n){let n=Number(t);(n>=0||n0)a[e]=r[0].stateValues["x"+n];else{let r=t[e].vectorChild;r.length>0&&(a[e]=r[0].stateValues["x"+n])}}}for(let e of n){let n=t[e].component;n?a[e]=n.stateValues.value.simplify():void 0===a[e]&&(i[e]=!0)}let o={};return Object.keys(a).length>0&&(o.setValue={unconstrainedXs:a}),Object.keys(i).length>0&&(o.useEssentialOrDefaultValue={unconstrainedXs:i}),o},inverseArrayDefinitionByKey({desiredStateVariableValues:e,globalDependencyValues:t,dependencyValuesByKey:n,dependencyNamesByKey:r,arraySize:a}){let i,s,o=[],l=!1,u=!1;null!==t.coords?(l=!0,i="coords",s=Array(a[0]+1)):null!==t.coordsShadow&&(l=!0,i="coordsShadow",s=Array(a[0]+1));for(let t of Object.keys(e.unconstrainedXs).reverse()){let a=convertValueToMathExpression(e.unconstrainedXs[t]);if(null!==n[t].component)o.push({setDependency:r[t].component,desiredValue:a,childIndex:0,variableIndex:0});else if(l)s[Number(t)+1]=a.tree,u=!0;else{if(null!==n[t].xs)o.push({setDependency:r[t].xs,desiredValue:a,childIndex:0,variableIndex:0});else{if(n[t].pointChild.length>0)o.push({setDependency:r[t].pointChild,desiredValue:a,childIndex:0,variableIndex:0});else{n[t].vectorChild.length>0?o.push({setDependency:r[t].vectorChild,desiredValue:a,childIndex:0,variableIndex:0}):o.push({setEssentialValue:"unconstrainedXs",value:{[t]:a}})}}}}if(u){let e;1===a[0]?e=me$3.fromAst(s[1]):(s[0]="vector",e=me$3.fromAst(s));let t={setDependency:i,desiredValue:e};"coords"===i&&(t.childIndex=0,t.variableIndex=0),o.push(t)}return{success:!0,instructions:o}}},e.xs={public:!0,shadowingInstructions:{createComponentOfType:"math",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]},isArray:!0,entryPrefixes:["x"],returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1,r={};r.unconstrainedX={dependencyType:"stateVariable",variableName:`unconstrainedX${e}`},r.constraintsChild={dependencyType:"child",childGroups:["constraints"],variableNames:[`constraintResult${e}`]},t[n]=r}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t)if(e[r].constraintsChild.length>0){let t=Number(r)+1;n[r]=convertValueToMathExpression(e[r].constraintsChild[0].stateValues["constraintResult"+t])}else n[r]=convertValueToMathExpression(e[r].unconstrainedX);return t.length>0?{setValue:{xs:n}}:{}},async inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyValuesByKey:t,dependencyNamesByKey:n,initialChange:r,stateValues:a}){if(r&&!await a.draggable)return{success:!1};let i=[];for(let r of Object.keys(e.xs).reverse())t[r]&&(t[r].constraintsChild.length>0?i.push({setDependency:n[r].constraintsChild,desiredValue:e.xs[r],childIndex:0,variableIndex:0}):i.push({setDependency:n[r].unconstrainedX,desiredValue:e.xs[r]}));return{success:!0,instructions:i}}},e.x={isAlias:!0,targetVariableName:"x1"},e.y={isAlias:!0,targetVariableName:"x2"},e.z={isAlias:!0,targetVariableName:"x3"},e.coords={public:!0,shadowingInstructions:{createComponentOfType:"coords",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]},returnDependencies:()=>({xs:{dependencyType:"stateVariable",variableName:"xs"}}),definition:function({dependencyValues:e}){let t=[];for(let n of e.xs)n?t.push(n.tree):t.push("_");return t=t.length>1?["vector",...t]:1===t.length?t[0]:"_",{setValue:{coords:me$3.fromAst(t)}}},inverseDefinition:async function({desiredStateVariableValues:e,stateValues:t,initialChange:n}){if(n&&!await t.draggable)return{success:!1};let r=[],a={},i=e.coords.tree;if(Array.isArray(i)&&vectorOperators.includes(i[0]))for(let t=0;t({coords:{dependencyType:"stateVariable",variableName:"coords"},displayDigits:{dependencyType:"stateVariable",variableName:"displayDigits"},displayDecimals:{dependencyType:"stateVariable",variableName:"displayDecimals"},displaySmallAsZero:{dependencyType:"stateVariable",variableName:"displaySmallAsZero"},padZeros:{dependencyType:"stateVariable",variableName:"padZeros"}}),definition:function({dependencyValues:e,usedDefault:t}){let n={};return e.padZeros&&(t.displayDigits&&!t.displayDecimals?Number.isFinite(e.displayDecimals)&&(n.padToDecimals=e.displayDecimals):e.displayDigits>=1&&(n.padToDigits=e.displayDigits)),{setValue:{latex:roundForDisplay({value:e.coords,dependencyValues:e,usedDefault:t}).toLatex(n)}}}},e.value={isAlias:!0,targetVariableName:"coords"},e.constraintUsed={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({constraintsChild:{dependencyType:"child",childGroups:["constraints"],variableNames:["constraintUsed"]}}),definition:function({dependencyValues:e}){return 0===e.constraintsChild.length?{setValue:{constraintUsed:!1}}:{setValue:{constraintUsed:e.constraintsChild[0].stateValues.constraintUsed}}}},e.numericalXs={isArray:!0,entryPrefixes:["numericalX"],forRenderer:!0,returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={x:{dependencyType:"stateVariable",variableName:`x${e}`}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].x;t?(t=e[r].x.evaluate_to_constant(),Number.isFinite(t)?n[r]=t:n[r]=NaN):n[r]=NaN}return{setValue:{numericalXs:n}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,initialChange:n,stateValues:r}){if(n&&!await r.draggable)return{success:!1};let a=[];for(let n in e.numericalXs)dependencyValuesByKey[n]&&a.push({setDependency:t[n].xs,desiredValue:e.numericalXs[n]});return{success:!0,instructions:a}}},e.nearestPoint={returnDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},numericalXs:{dependencyType:"stateVariable",variableName:"numericalXs"}}),definition:({dependencyValues:e})=>({setValue:{nearestPoint:function(){let t={};for(let n=1;n<=e.nDimensions;n++){let r=e.numericalXs[n-1];if(!Number.isFinite(r))return{};t["x"+n]=r}return t}}})},e}static adapters=[{stateVariable:"coords",stateVariablesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]}];async movePoint({x:e,y:t,z:n,transient:r,actionId:a}){let i={};return void 0!==e&&(i[0]=me$3.fromAst(e)),void 0!==t&&(i[1]=me$3.fromAst(t)),void 0!==n&&(i[2]=me$3.fromAst(n)),r?await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"xs",value:i}],transient:r,actionId:a}):await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"xs",value:i}],actionId:a,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{x:e,y:t,z:n}}})}switchPoint(){}async pointClicked({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"click",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}async mouseDownOnPoint({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"down",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}}class EquilibriumPoint extends Point{static componentType="equilibriumPoint";static rendererType="point";static createAttributesObject(){let e=super.createAttributesObject();return e.stable={createComponentOfType:"boolean",createStateVariable:"stable",defaultValue:!0,public:!0},e.switchable={createComponentOfType:"boolean",createStateVariable:"switchable",defaultValue:!1,public:!0,forRenderer:!0},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.open={forRenderer:!0,returnDependencies:()=>({stable:{dependencyType:"stateVariable",variableName:"stable"}}),definition:({dependencyValues:e})=>({setValue:{open:!e.stable}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setDependency:"stable",desiredValue:!e.open}]})},e}async switchPoint({actionId:e}){if(await this.stateValues.switchable)return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"stable",value:!this.stateValues.stable}],actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{stable:!this.stateValues.stable}}});this.coreFunctions.resolveAction({actionId:e})}}class Line extends GraphicalComponent{constructor(e){super(e),Object.assign(this.actions,{moveLine:this.moveLine.bind(this),switchLine:this.switchLine.bind(this),lineClicked:this.lineClicked.bind(this),mouseDownOnLine:this.mouseDownOnLine.bind(this)})}static componentType="line";static createAttributesObject(){let e=super.createAttributesObject();return e.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},e.equation={createComponentOfType:"math"},e.through={createComponentOfType:"_pointListComponent"},e.slope={createComponentOfType:"number"},e.variables={createComponentOfType:"variables"},e.displayDigits={createComponentOfType:"integer"},e.displayDecimals={createComponentOfType:"integer",createStateVariable:"displayDecimals",defaultValue:null,public:!0},e.displaySmallAsZero={createComponentOfType:"number",createStateVariable:"displaySmallAsZero",valueForTrue:1e-14,valueForFalse:0,defaultValue:0,public:!0},e.padZeros={createComponentOfType:"boolean",createStateVariable:"padZeros",defaultValue:!1,public:!0},e.labelPosition={createComponentOfType:"text",createStateVariable:"labelPosition",defaultValue:"upperright",public:!0,forRenderer:!0,toLowerCase:!0,validValues:["upperright","upperleft","lowerright","lowerleft"]},e}static returnSugarInstructions(){let e=super.returnSugarInstructions();return e.push({replacementFunction:function({matchedChildren:e,componentInfoObjects:t}){if(0===e.length)return{success:!1};let n=e.map((e=>t.componentIsSpecifiedType(e,"label"))),r=[],a=[];if(0===n.filter((e=>e)).length)r=e;else{if(n[0]){let t=n.indexOf(!1);-1!==t&&(a.push(...e.slice(0,t)),e=e.slice(t),n=n.slice(t))}let t=n.indexOf(!0);-1===t?r=e:(r=e.slice(0,t),a.push(...e.slice(t)))}return 0===r.length?{success:!1}:{success:!0,newAttributes:{equation:{component:{componentType:"math",children:r}}},newChildren:a}}}),e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.styleDescription={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({selectedStyle:{dependencyType:"stateVariable",variableName:"selectedStyle"}}),definition:function({dependencyValues:e}){let t=e.selectedStyle.lineWidthWord;return e.selectedStyle.lineStyleWord&&(t&&(t+=" "),t+=e.selectedStyle.lineStyleWord),t&&(t+=" "),t+=e.selectedStyle.lineColorWord,{setValue:{styleDescription:t}}}},e.styleDescriptionWithNoun={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({styleDescription:{dependencyType:"stateVariable",variableName:"styleDescription"}}),definition:function({dependencyValues:e}){return{setValue:{styleDescriptionWithNoun:e.styleDescription+" line"}}}},e.displayDigits={public:!0,shadowingInstructions:{createComponentOfType:"integer"},hasEssential:!0,defaultValue:10,returnDependencies:()=>({displayDigitsAttr:{dependencyType:"attributeComponent",attributeName:"displayDigits",variableNames:["value"]},displayDecimalsAttr:{dependencyType:"attributeComponent",attributeName:"displayDecimals",variableNames:["value"]}}),definition({dependencyValues:e,usedDefault:t}){let n=null===e.displayDigitsAttr||t.displayDigitsAttr,r=null===e.displayDecimalsAttr||t.displayDecimalsAttr;if(!n&&!r){let t=e.displayDigitsAttr.shadowDepth;e.displayDecimalsAttr.shadowDepth({throughAttr:{dependencyType:"attributeComponent",attributeName:"through",variableNames:["nPoints"]}}),definition:function({dependencyValues:e}){return null===e.throughAttr?{setValue:{nPointsPrescribed:0}}:{setValue:{nPointsPrescribed:e.throughAttr.stateValues.nPoints}}}},e.basedOnSlope={returnDependencies:()=>({slopeAttr:{dependencyType:"attributeComponent",attributeName:"slope"},nPointsPrescribed:{dependencyType:"stateVariable",variableName:"nPointsPrescribed"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),definition:({dependencyValues:e})=>({setValue:{basedOnSlope:e.nPointsPrescribed<2&&null!==e.slopeAttr&&2===e.nDimensions}})},e.dForSlope={defaultValue:1,hasEssential:!0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{dForSlope:!0}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setEssentialValue:"dForSlope",value:e.dForSlope}]})},e.variables={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"variable"},entryPrefixes:["var"],returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nDimensions],returnArrayDependenciesByKey:()=>({globalDependencies:{variables:{dependencyType:"attributeComponent",attributeName:"variables",variableNames:["variables"]}}}),arrayDefinitionByKey({globalDependencyValues:e,arraySize:t}){let n=[];return null!==e.variables&&(n=e.variables.stateValues.variables),{setValue:{variables:returnNVariables(t[0],n)}}}},e.equationIdentity={returnDependencies:()=>({equation:{dependencyType:"attributeComponent",attributeName:"equation"}}),definition:function({dependencyValues:e}){return null!==e.equation?{setValue:{equationIdentity:e.equation}}:{setValue:{equationIdentity:null}}}},e.essentialPoints={isArray:!0,nDimensions:"2",hasEssential:!0,entryPrefixes:["essentialPointX","essentialPoint"],set:convertValueToMathExpression,defaultValueByArrayKey:e=>me$3.fromAst("0,0"===e?1:0),getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("essentialPointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[2,e.nDimensions],returnArrayDependenciesByKey:()=>({}),arrayDefinitionByKey({arrayKeys:e}){let t={};for(let n of e)t[n]=!0;return{useEssentialOrDefaultValue:{essentialPoints:t}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e}){let t=[];for(let n in e.essentialPoints)t.push({setEssentialValue:"essentialPoints",value:{[n]:convertValueToMathExpression(e.essentialPoints[n])}});return{success:!0,instructions:t}}},e.points={public:!0,shadowingInstructions:{createComponentOfType:"math",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"],returnWrappingComponents:e=>"pointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["pointX","point"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("pointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("points"===t)return 1===e.length?"point"+e[0]:`pointX${e[0]}_${e[1]}`;if("point"===t.slice(0,5)){let n=Number(t.slice(5));if(Number.isInteger(n)&&n>0)return`pointX${n}_${e[0]}`}return null},stateVariablesDeterminingDependencies:["equationIdentity","nPointsPrescribed","basedOnSlope"],returnArraySizeDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[2,e.nDimensions],returnArrayDependenciesByKey({stateValues:e,arrayKeys:t}){if(null===e.equationIdentity){let n={};for(let r of t){let[t,a]=r.split(","),i=Number(t)+1+"_"+(Number(a)+1);n[r]={through:{dependencyType:"attributeComponent",attributeName:"through",variableNames:["pointX"+i]}},e.basedOnSlope?("1"===t&&(1===e.nPointsPrescribed&&n[r].through.variableNames.push("pointX1_"+(Number(a)+1)),n[r].dForSlope={dependencyType:"stateVariable",variableName:"dForSlope"},n[r].slopeAttr={dependencyType:"attributeComponent",attributeName:"slope",variableNames:["value"]}),0===e.nPointsPrescribed&&(n[r].essentialPoint={dependencyType:"stateVariable",variableName:"essentialPointX2_"+(Number(a)+1)})):n[r].essentialPoint={dependencyType:"stateVariable",variableName:"essentialPointX"+i}}return{dependenciesByKey:n,globalDependencies:{nPointsPrescribed:{dependencyType:"stateVariable",variableName:"nPointsPrescribed"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},basedOnSlope:{dependencyType:"stateVariable",variableName:"basedOnSlope"}}}}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"}}}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,arraySize:r,componentName:a}){if("coeff0"in e){let t=calculatePointsFromCoeffs(e);if(t.success)return{setValue:{points:t.points}};{let e={};for(let t=0;te.toString()))];for(let e=0;e({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>Number.isNaN(e.nDimensions)?[0]:[2],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={point:{dependencyType:"stateVariable",variableName:"point"+(Number(n)+1)}};return{globalDependencies:{nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,componentName:r}){if(Number.isNaN(e.nDimensions))return{};let a={};for(let r of n){let n=t[r].point;Array.isArray(n)||(n=[n]);let i=[];for(let t=0;t({coeff0:{dependencyType:"stateVariable",variableName:"coeff0"},coeffvar1:{dependencyType:"stateVariable",variableName:"coeffvar1"},coeffvar2:{dependencyType:"stateVariable",variableName:"coeffvar2"}}),definition:function({dependencyValues:e}){let t=e.coeff0.evaluate_to_constant();Number.isFinite(t)||(t=NaN);let n=e.coeffvar1.evaluate_to_constant();Number.isFinite(n)||(n=NaN);let r=e.coeffvar2.evaluate_to_constant();return Number.isFinite(r)||(r=NaN),{setValue:{numericalCoeff0:t,numericalCoeffvar1:n,numericalCoeffvar2:r}}}},e.slope={public:!0,shadowingInstructions:{createComponentOfType:"math",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]},returnDependencies:()=>({coeffvar1:{dependencyType:"stateVariable",variableName:"coeffvar1"},coeffvar2:{dependencyType:"stateVariable",variableName:"coeffvar2"}}),definition:function({dependencyValues:e}){return{setValue:{slope:me$3.fromAst(["-",["/","a","b"]]).substitute({a:e.coeffvar1,b:e.coeffvar2}).simplify()}}}},e.xintercept={public:!0,shadowingInstructions:{createComponentOfType:"math",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]},returnDependencies:()=>({coeff0:{dependencyType:"stateVariable",variableName:"coeff0"},coeffvar1:{dependencyType:"stateVariable",variableName:"coeffvar1"}}),definition:({dependencyValues:e})=>({setValue:{xintercept:me$3.fromAst(["-",["/","a","b"]]).substitute({a:e.coeff0,b:e.coeffvar1}).simplify()}})},e.yintercept={public:!0,shadowingInstructions:{createComponentOfType:"math",attributesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]},returnDependencies:()=>({coeff0:{dependencyType:"stateVariable",variableName:"coeff0"},coeffvar2:{dependencyType:"stateVariable",variableName:"coeffvar2"}}),definition:({dependencyValues:e})=>({setValue:{yintercept:me$3.fromAst(["-",["/","a","b"]]).substitute({a:e.coeff0,b:e.coeffvar2}).simplify()}})},e.lastPointsFromInverting={defaultValue:null,hasEssential:!0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{lastPointsFromInverting:!0}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setEssentialValue:"lastPointsFromInverting",value:e.lastPointsFromInverting}]})},e.latex={forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({equation:{dependencyType:"stateVariable",variableName:"equation"},displayDigits:{dependencyType:"stateVariable",variableName:"displayDigits"},displayDecimals:{dependencyType:"stateVariable",variableName:"displayDecimals"},displaySmallAsZero:{dependencyType:"stateVariable",variableName:"displaySmallAsZero"},padZeros:{dependencyType:"stateVariable",variableName:"padZeros"}}),definition:function({dependencyValues:e,usedDefault:t}){let n={};return e.padZeros&&(t.displayDigits&&!t.displayDecimals?Number.isFinite(e.displayDecimals)&&(n.padToDecimals=e.displayDecimals):e.displayDigits>=1&&(n.padToDigits=e.displayDigits)),{setValue:{latex:roundForDisplay({value:e.equation,dependencyValues:e,usedDefault:t}).toLatex(n)}}}},e.nearestPoint={returnDependencies:()=>({nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"},numericalCoeff0:{dependencyType:"stateVariable",variableName:"numericalCoeff0"},numericalCoeffvar1:{dependencyType:"stateVariable",variableName:"numericalCoeffvar1"},numericalCoeffvar2:{dependencyType:"stateVariable",variableName:"numericalCoeffvar2"}}),definition({dependencyValues:e}){let t=e.numericalCoeffvar1,n=e.numericalCoeffvar2,r=e.numericalCoeff0,a=Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r),i=2!==e.nDimensions||!a||0===t&&0===n;return{setValue:{nearestPoint:function({variables:e,scales:a=[1,1]}){if(i)return{};let s=a[0],o=a[1],l=t*s,u=n*o,c=l*l+u*u,p=e.x1?.evaluate_to_constant(),d=e.x2?.evaluate_to_constant();if(!Number.isFinite(p)||!Number.isFinite(d))return{};let m=p/s,h=d/o,f={};return f.x1=(u*(u*m-l*h)-l*r)*s/c,f.x2=(l*(-u*m+l*h)-u*r)*o/c,void 0!==e.x3&&(f.x3=0),f}}}}},e}static adapters=[{stateVariable:"equation",stateVariablesToShadow:["displayDigits","displayDecimals","displaySmallAsZero","padZeros"]}];async moveLine({point1coords:e,point2coords:t,transient:n,actionId:r}){let a={"0,0":me$3.fromAst(e[0]),"0,1":me$3.fromAst(e[1])};return await this.stateValues.basedOnSlope||(a["1,0"]=me$3.fromAst(t[0]),a["1,1"]=me$3.fromAst(t[1])),n?await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"points",value:a}],transient:!0,actionId:r}):await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"points",value:a}],actionId:r,event:{verb:"interacted",object:{componentId:this.componentName},result:{point1:e,point2:t}}})}switchLine(){}async lineClicked({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"click",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}async mouseDownOnLine({actionId:e}){await this.coreFunctions.triggerChainedActions({triggeringAction:"down",componentName:this.componentName}),this.coreFunctions.resolveAction({actionId:e})}}function calculateCoeffsFromEquation({equation:e,variables:t}){let n=t[0],r=t[1],a=n.toString(),i=r.toString();if(e=e.expand().simplify(),!Array.isArray(e.tree)||"="!==e.tree[0]||3!==e.tree.length)return{success:!1};let s=me$3.fromAst(["+",e.tree[2],["-",e.tree[1]]]).expand().simplify(),o=[];o=Array.isArray(s.tree)&&"+"===s.tree[0]?s.tree.slice(1):[s.tree];let l=me$3.fromAst(0),u=me$3.fromAst(0),c=me$3.fromAst(0);for(let e of o){let t=p(e);if(!t.success)return{success:!1};l=l.add(t.coeffvar1),u=u.add(t.coeffvar2),c=c.add(t.coeff0)}return l=l.simplify(),u=u.simplify(),c=c.simplify(),{success:!0,coeff0:c,coeffvar1:l,coeffvar2:u};function p(e){let t=0,s=0,o=0;if("string"==typeof e)e===a?t=1:e===i?s=1:o=e;else if("number"==typeof e)o=e;else{if(!Array.isArray(e))return console.warn("Invalid format for equation of line in variables "+n+" and "+r),{success:!1};{let a=e[0],i=e.slice(1);if("-"===a){let e=p(i[0]);if(!e.success)return{success:!1};t=["-",e.coeffvar1.tree],s=["-",e.coeffvar2.tree],o=["-",e.coeff0.tree]}else{if("+"===a)return console.warn("Invalid format for equation of line in variables "+n+" and "+r),{success:!1};if("*"===a){let a=-1,l=-1;for(let e=0;e({stable:{dependencyType:"stateVariable",variableName:"stable"}}),definition:({dependencyValues:e})=>({setValue:{dashed:!e.stable}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setDependency:"stable",desiredValue:!e.dashed}]})},e}async switchLine({actionId:e}){if(await this.stateValues.switchable)return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"stable",value:!this.stateValues.stable}],actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{stable:!this.stateValues.stable}}});this.coreFunctions.resolveAction({actionId:e})}}class Curve extends GraphicalComponent{constructor(e){super(e),Object.assign(this.actions,{moveControlVector:this.moveControlVector.bind(this),moveThroughPoint:this.moveThroughPoint.bind(this),changeVectorControlDirection:this.changeVectorControlDirection.bind(this),switchCurve:this.switchCurve.bind(this),curveClicked:this.curveClicked.bind(this),mouseDownOnCurve:this.mouseDownOnCurve.bind(this)})}static componentType="curve";static rendererType="curve";static primaryStateVariableForDefinition="fShadow";static createAttributesObject(){let e=super.createAttributesObject();return e.draggable={createComponentOfType:"boolean",createStateVariable:"draggable",defaultValue:!0,public:!0,forRenderer:!0},e.labelPosition={createComponentOfType:"text",createStateVariable:"labelPosition",defaultValue:"upperright",public:!0,forRenderer:!0,toLowerCase:!0,validValues:["upperright","upperleft","lowerright","lowerleft","top","bottom","left","right"]},e.flipFunction={createComponentOfType:"boolean",createStateVariable:"flipFunction",defaultValue:!1,public:!0,forRenderer:!0},e.nDiscretizationPoints={createComponentOfType:"number",createStateVariable:"nDiscretizationPoints",defaultValue:1e3,public:!0},e.periodic={createComponentOfType:"boolean",createStateVariable:"periodic",defaultValue:!1,public:!0},e.splineTension={createComponentOfType:"number",createStateVariable:"splineTension",defaultValue:.8,clamp:[0,1],public:!0},e.extrapolateBackward={createComponentOfType:"boolean",createStateVariable:"extrapolateBackward",defaultValue:!1,public:!0,forRenderer:!0},e.extrapolateForward={createComponentOfType:"boolean",createStateVariable:"extrapolateForward",defaultValue:!1,public:!0,forRenderer:!0},e.splineForm={createComponentOfType:"text",createStateVariable:"splineForm",defaultValue:"centripetal",public:!0,toLowerCase:!0,validValues:["centripetal","uniform"]},e.variable={createComponentOfType:"variable",createStateVariable:"variableForChild",defaultValue:me$3.fromAst("x")},e.through={createComponentOfType:"_pointListComponent"},e.parMin={createComponentOfType:"math"},e.parMax={createComponentOfType:"math"},e.nearestPointAsCurve={createComponentOfType:"boolean",createStateVariable:"nearestPointAsCurvePrelim",defaultValue:!1},e}static returnSugarInstructions(){let e=super.returnSugarInstructions();return e.push({replacementFunction:function({matchedChildren:e,componentInfoObjects:t}){let n=e=>t.componentIsSpecifiedType(e,"label");if(0===e.length||!e.every((e=>"string"==typeof e||e.doenetAttributes?.createdFromMacro||n(e))))return{success:!1};let r=e.map(n),a=[],i=[],s=[];if(0===r.filter((e=>e)).length)a=e;else{if(r[0]){let t=r.indexOf(!1);-1!==t&&(i=e.slice(0,t),e=e.slice(t),r=r.slice(t))}let t=r.indexOf(!0);-1===t?a=e:(a=e.slice(0,t),s=e.slice(t))}if(0===a.length)return{success:!1};let o=returnBreakStringsSugarFunction({childrenToComponentFunction:e=>({componentType:"function",children:e}),mustStripOffOuterParentheses:!0}),l=o({matchedChildren:a}),u=[];return u=l.success?l.newChildren:[{componentType:"function",children:a}],{success:!0,newChildren:[...i,...u,...s]}}}),e}static returnChildGroups(){let e=super.returnChildGroups();return e.push({group:"functions",componentTypes:["function"]},{group:"bezierControls",componentTypes:["bezierControls"]}),e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e});return t.styleDescription={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({selectedStyle:{dependencyType:"stateVariable",variableName:"selectedStyle"}}),definition:function({dependencyValues:e}){let t=e.selectedStyle.lineWidthWord;return e.selectedStyle.lineStyleWord&&(t&&(t+=" "),t+=e.selectedStyle.lineStyleWord),t&&(t+=" "),t+=e.selectedStyle.lineColorWord,{setValue:{styleDescription:t}}}},t.styleDescriptionWithNoun={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({styleDescription:{dependencyType:"stateVariable",variableName:"styleDescription"}}),definition:function({dependencyValues:e}){return{setValue:{styleDescriptionWithNoun:e.styleDescription+" curve"}}}},t.curveType={forRenderer:!0,returnDependencies:()=>({functionChildren:{dependencyType:"child",childGroups:["functions"]},through:{dependencyType:"attributeComponent",attributeName:"through"}}),definition({dependencyValues:e}){let t="function";return null!==e.through?t="bezier":e.functionChildren.length>1&&(t="parameterization"),{setValue:{curveType:t}}}},t.fShadow={defaultValue:null,hasEssential:!0,returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{fShadow:!0}})},t.graphXmin={forRenderer:!0,additionalStateVariablesDefined:[{variableName:"graphXmax",forRenderer:!0},{variableName:"graphYmin",forRenderer:!0},{variableName:"graphYmax",forRenderer:!0}],returnDependencies:()=>({graphAncestor:{dependencyType:"ancestor",componentType:"graph",variableNames:["xmin","xmax","ymin","ymax"]}}),definition:({dependencyValues:e})=>e.graphAncestor?{setValue:{graphXmin:e.graphAncestor.stateValues.xmin,graphXmax:e.graphAncestor.stateValues.xmax,graphYmin:e.graphAncestor.stateValues.ymin,graphYmax:e.graphAncestor.stateValues.ymax}}:{setValue:{graphXmin:null,graphXmax:null,graphYmin:null,graphYmax:null}}},t.parMax={public:!0,shadowingInstructions:{createComponentOfType:"number"},forRenderer:!0,returnDependencies:()=>({curveType:{dependencyType:"stateVariable",variableName:"curveType"},parMaxAttr:{dependencyType:"attributeComponent",attributeName:"parMax",variableNames:["value"]},nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},extrapolateForward:{dependencyType:"stateVariable",variableName:"extrapolateForward"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["domain"]},adapterSourceDomain:{dependencyType:"adapterSourceStateVariable",variableName:"domain"},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},graphXmax:{dependencyType:"stateVariable",variableName:"graphXmax"},graphYmin:{dependencyType:"stateVariable",variableName:"graphYmin"},graphYmax:{dependencyType:"stateVariable",variableName:"graphYmax"},flipFunction:{dependencyType:"stateVariable",variableName:"flipFunction"}}),definition:function({dependencyValues:e}){let t;if("bezier"===e.curveType)t=e.nThroughPoints-1,e.extrapolateForward&&(t*=2);else if(null!==e.parMaxAttr)t=e.parMaxAttr.stateValues.value.evaluate_to_constant(),Number.isFinite(t)||(t=NaN);else if("function"===e.curveType){let n,r,a=null;if(a=1===e.functionChild.length?e.functionChild[0].stateValues.domain:e.adapterSourceDomain,null!==a){a=a[0];try{t=me$3.fromAst(a.tree[1][2]).evaluate_to_constant(),Number.isFinite(t)||t===1/0||(t=NaN)}catch(e){}}e.flipFunction?(r=e.graphYmax,n=e.graphYmin):(r=e.graphXmax,n=e.graphXmin),null!==r&&null!==n&&(t=void 0===t?r+.1*(r-n):Math.min(t,r+.1*(r-n))),void 0===t&&(t=1/0)}else t=10;return{setValue:{parMax:t}}}},t.parMin={forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({curveType:{dependencyType:"stateVariable",variableName:"curveType"},parMinAttr:{dependencyType:"attributeComponent",attributeName:"parMin",variableNames:["value"]},nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},extrapolateBackward:{dependencyType:"stateVariable",variableName:"extrapolateBackward"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["domain"]},adapterSourceDomain:{dependencyType:"adapterSourceStateVariable",variableName:"domain"},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},graphXmax:{dependencyType:"stateVariable",variableName:"graphXmax"},graphYmin:{dependencyType:"stateVariable",variableName:"graphYmin"},graphYmax:{dependencyType:"stateVariable",variableName:"graphYmax"},flipFunction:{dependencyType:"stateVariable",variableName:"flipFunction"}}),definition:function({dependencyValues:e}){let t;if("bezier"===e.curveType)t=0,e.extrapolateBackward&&(t=-(e.nThroughPoints-1));else if(null!==e.parMinAttr)t=e.parMinAttr.stateValues.value.evaluate_to_constant(),Number.isFinite(t)||(t=NaN);else if("function"===e.curveType){let n,r,a=null;if(a=1===e.functionChild.length?e.functionChild[0].stateValues.domain:e.adapterSourceDomain,null!==a){a=a[0];try{t=me$3.fromAst(a.tree[1][1]).evaluate_to_constant(),Number.isFinite(t)||t===-1/0||(t=NaN)}catch(e){}}e.flipFunction?(r=e.graphYmax,n=e.graphYmin):(r=e.graphXmax,n=e.graphXmin),null!==r&&null!==n&&(t=void 0===t?n+.1*(n-r):Math.max(t,n+.1*(n-r))),void 0===t&&(t=-1/0)}else t=-10;return{setValue:{parMin:t}}}},t.domainForFunctions={returnDependencies:()=>({parMin:{dependencyType:"stateVariable",variableName:"parMin"},parMax:{dependencyType:"stateVariable",variableName:"parMax"}}),definition:({dependencyValues:e})=>({setValue:{domainForFunctions:[me$3.fromAst(["interval",["tuple",e.parMin,e.parMax],["tuple",!0,!0]])]}})},t.nThroughPoints={returnDependencies:()=>({through:{dependencyType:"attributeComponent",attributeName:"through",variableNames:["nPoints"]}}),definition({dependencyValues:e}){let t=0;return null!==e.through&&(t=e.through.stateValues.nPoints),{setValue:{nThroughPoints:t}}}},t.nDimensions={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({through:{dependencyType:"attributeComponent",attributeName:"through",variableNames:["nDimensions"]}}),definition:function({dependencyValues:e}){if(null!==e.through){return{setValue:{nDimensions:e.through.stateValues.nDimensions},checkForActualChange:{nDimensions:!0}}}return{setValue:{nDimensions:2}}}},t.throughPoints={public:!0,shadowingInstructions:{createComponentOfType:"math",returnWrappingComponents:e=>"throughPointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["throughPointX","throughPoint"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("throughPointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("throughPoints"===t)return 1===e.length?"throughPoint"+e[0]:`throughPointX${e[0]}_${e[1]}`;if("throughPoint"===t.slice(0,12)){let n=Number(t.slice(12));if(Number.isInteger(n)&&n>0)return`throughPointX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints,e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let[e,r]=n.split(","),a=Number(e)+1+"_"+(Number(r)+1);t[n]={through:{dependencyType:"attributeComponent",attributeName:"through",variableNames:["pointX"+a]}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let[t,a]=r.split(","),i=Number(t)+1+"_"+(Number(a)+1),s=e[r].through;null!==s&&s.stateValues["pointX"+i]?n[r]=s.stateValues["pointX"+i]:n[r]=me$3.fromAst(0)}return{setValue:{throughPoints:n}}},async inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyValuesByKey:t,dependencyNamesByKey:n,initialChange:r,stateValues:a}){if(r&&!await a.draggable)return{success:!1};let i=[];for(let r in e.throughPoints){let[a,s]=r.split(","),o=Number(a)+1+"_"+(Number(s)+1);if(null===t[r].through||!t[r].through.stateValues["pointX"+o])return{success:!1};i.push({setDependency:n[r].through,desiredValue:e.throughPoints[r],childIndex:0,variableIndex:0})}return{success:!0,instructions:i}}},t.numericalThroughPoints={isArray:!0,entryPrefixes:["numericalThroughPoint"],forRenderer:!0,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={throughPoint:{dependencyType:"stateVariable",variableName:"throughPoint"+(Number(n)+1)}};return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].throughPoint.map((e=>e.evaluate_to_constant()));t.every((e=>Number.isFinite(e)))||(t=Array(t.length).fill(NaN)),n[r]=t}return{setValue:{numericalThroughPoints:n}}}},t.haveBezierControls={forRenderer:!0,returnDependencies:()=>({controlChild:{dependencyType:"child",childGroups:["bezierControls"]}}),definition:({dependencyValues:e})=>({setValue:{haveBezierControls:e.controlChild.length>0}})},t.bezierControlsAlwaysVisible={forRenderer:!0,returnDependencies:()=>({controlChild:{dependencyType:"child",childGroups:["bezierControls"],variableNames:["alwaysVisible"]}}),definition:({dependencyValues:e})=>({setValue:{bezierControlsAlwaysVisible:e.controlChild.length>0&&e.controlChild[0].stateValues.alwaysVisible}})},t.vectorControlDirections={public:!0,shadowingInstructions:{createComponentOfType:"text"},isArray:!0,entryPrefixes:["vectorControlDirection"],forRenderer:!0,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={controlChild:{dependencyType:"child",childGroups:["bezierControls"],variableNames:["direction"+(Number(n)+1)]}};return{dependenciesByKey:t,globalDependencies:{haveBezierControls:{dependencyType:"stateVariable",variableName:"haveBezierControls"}}}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].controlChild;t&&t.length>0?n[r]=t[0].stateValues["direction"+(Number(r)+1)]:n[r]="none"}return{setValue:{vectorControlDirections:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,dependencyValuesByKey:n,globalDependencyValues:r}){if(!r.haveBezierControls)return{success:!1};let a=[];for(let r in e.vectorControlDirections){let i=n[r].controlChild;i&&i.length>0&&a.push({setDependency:t[r].controlChild,desiredValue:e.vectorControlDirections[r],childIndex:0,variableIndex:0})}return{success:!0,instructions:a}}},t.hiddenControls={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},isArray:!0,entryPrefixes:["hiddenControl"],forRenderer:!0,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={controlChild:{dependencyType:"child",childGroups:["bezierControls"],variableNames:["hiddenControl"+(Number(n)+1)]}};return{dependenciesByKey:t,globalDependencies:{haveBezierControls:{dependencyType:"stateVariable",variableName:"haveBezierControls"}}}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].controlChild;t&&t.length>0?n[r]=t[0].stateValues["hiddenControl"+(Number(r)+1)]:n[r]=!1}return{setValue:{hiddenControls:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,dependencyValuesByKey:n,globalDependencyValues:r}){if(!r.haveBezierControls)return{success:!1};let a=[];for(let r in e.hiddenControls){let i=n[r].controlChild;i&&i.length>0&&a.push({setDependency:t[r].controlChild,desiredValue:e.hiddenControls[r],childIndex:0,variableIndex:0})}return{success:!0,instructions:a}}},t.controlVectors={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math",returnWrappingComponents:e=>"controlVectorX"===e?[]:[["vector",{componentType:"mathList",isAttribute:"xs"}]]},entryPrefixes:["controlVectorX","controlVector"],nDimensions:3,stateVariablesDeterminingDependencies:["vectorControlDirections","nThroughPoints"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("controlVectorX"===e){let e=t.split("_").map((e=>Number(e)-1));return 3===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>eNumber(e)-1));return 2===e.length&&e.every((e=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>eString(e)+","+n)):[]:[String(e)+",0"]:[]}},returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints,2,e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e,stateValues:t}){let n={};for(let r of e){let e=r.split(",").map((e=>Number(e))),a=e.map((e=>e+1)),i=a.join("_");n[r]={direction:{dependencyType:"stateVariable",variableName:"vectorControlDirection"+a[0]},controlChild:{dependencyType:"child",childGroups:["bezierControls"],variableNames:["control"+i]}};let s=e[0],o=t.vectorControlDirections[s],l=[];"none"===o?l=[s-1,s,s+1]:"previous"===o?l=[s,s+1]:"next"===o&&(l=[s-1,s]);for(let e of l)e>=0&&eNumber(e))),s=r.map((e=>e+1)),o=s.join("_"),l=r[0],u=r[1],c=n[i].direction;if("none"===c){let r,s,o=n[i]["throughPoint"+(l+1)];l>0&&(r=n[i]["throughPoint"+l]),lNumber(e))),s=i.map((e=>e+1)),o=s.join("_"),l=n[r].controlChild;if(l.length>0){l[0].stateValues["control"+o]&&a.push({setDependency:t[r].controlChild,desiredValue:e.controlVectors[r],childIndex:0,variableIndex:0})}}return{success:!0,instructions:a}}},t.numericalControlVectors={isArray:!0,entryPrefixes:["numericalControlVector"],forRenderer:!0,nDimensions:2,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints,2],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=n.split(",").map((e=>Number(e))),r=e.map((e=>e+1)),a=r.join("_");t[n]={controlVector:{dependencyType:"stateVariable",variableName:"controlVector"+a}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].controlVector.map((e=>e.tree));n[r]=t}return{setValue:{numericalControlVectors:n}}}},t.controlPoints={isArray:!0,public:!0,shadowingInstructions:{createComponentOfType:"math",returnWrappingComponents:e=>"controlPointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},entryPrefixes:["controlPointX","controlPoint"],nDimensions:3,getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("controlPointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 3===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>eNumber(e)-1));return 2===e.length&&e.every((e=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>eString(e)+","+n)):[]:[String(e)+",0"]:[]}},returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints,2,e.nDimensions],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=n.split(",").map((e=>Number(e))),r=e.map((e=>e+1)),a=r.join("_");t[n]={throughPointX:{dependencyType:"stateVariable",variableName:"throughPointX"+r[0]+"_"+r[2]},controlVectorX:{dependencyType:"stateVariable",variableName:"controlVectorX"+a}}}return{globalDependencies:{haveBezierControls:{dependencyType:"stateVariable",variableName:"haveBezierControls"},nDimensions:{dependencyType:"stateVariable",variableName:"nDimensions"}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n}){let r={};for(let a of n)if(2!==e.nDimensions)r[a]=me$3.fromAst(NaN);else{let e=t[a].controlVectorX;if(e){let n=t[a].throughPointX.evaluate_to_constant();Number.isFinite(n)||(n=NaN),r[a]=me$3.fromAst(n+e.tree)}else r[a]=null}return{setValue:{controlPoints:r}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,dependencyValuesByKey:n,globalDependencyValues:r}){if(!r.haveBezierControls||2!==r.nDimensions)return{success:!1};let a=[];for(let r in e.controlPoints){if(n[r].controlVectorX){let i=n[r].throughPointX,s=e.controlPoints[r];s.tree&&(s=s.tree);let o=me$3.fromAst(["+",s,["-",i.tree]]);a.push({setDependency:t[r].controlVectorX,desiredValue:o})}}return{success:!0,instructions:a}}},t.numericalControlPoints={isArray:!0,entryPrefixes:["numericalControlPoint"],forRenderer:!0,nDimensions:2,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints,2],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=n.split(",").map((e=>Number(e))),r=e.map((e=>e+1)),a=r.join("_");t[n]={controlPoint:{dependencyType:"stateVariable",variableName:"controlPoint"+a}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].controlPoint.map((e=>e.tree));n[r]=t}return{setValue:{numericalControlPoints:n}}}},t.splineCoeffs={isArray:!0,returnArraySizeDependencies:()=>({nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nThroughPoints-1],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1,r=e+1;t[n]={previousPoint:{dependencyType:"stateVariable",variableName:"numericalThroughPoint"+e},nextPoint:{dependencyType:"stateVariable",variableName:"numericalThroughPoint"+r},previousVector:{dependencyType:"stateVariable",variableName:"numericalControlVector"+e+"_2"},nextVector:{dependencyType:"stateVariable",variableName:"numericalControlVector"+r+"_1"}}}return{dependenciesByKey:t}},arrayDefinitionByKey({dependencyValuesByKey:e,arrayKeys:t}){let n={};for(let r of t){let t=e[r].previousPoint,a=e[r].nextPoint,i=e[r].previousVector,s=e[r].nextVector,o=[];for(let e=0;e<2;e++)o.push(initCubicPoly(t[e],a[e],3*i[e],-3*s[e]));n[r]=o}return{setValue:{splineCoeffs:n}}}},t.extrapolateBackwardCoeffs={stateVariablesDeterminingDependencies:["extrapolateBackward"],additionalStateVariablesDefined:[{variableName:"extrapolateBackwardMode",public:!0,shadowingInstructions:{createComponentOfType:"text"}}],returnDependencies({stateValues:e}){let t={extrapolateBackward:{dependencyType:"stateVariable",variableName:"extrapolateBackward"},nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}};return e.extrapolateBackward&&(t.firstSplineCoeffs={dependencyType:"stateVariable",variableName:"splineCoeffs1"},t.graphXmin={dependencyType:"stateVariable",variableName:"graphXmin"},t.graphXmax={dependencyType:"stateVariable",variableName:"graphXmax"},t.graphYmin={dependencyType:"stateVariable",variableName:"graphYmin"},t.graphYmax={dependencyType:"stateVariable",variableName:"graphYmax"}),t},definition({dependencyValues:e}){if(!e.extrapolateBackward||!e.firstSplineCoeffs)return{setValue:{extrapolateBackwardCoeffs:null,extrapolateBackwardMode:""}};let t=e.firstSplineCoeffs[0],n=e.firstSplineCoeffs[1],r=t[0],a=t[1],i=2*t[2],s=n[0],o=n[1],l=a*a+o*o,u=(o*i-a*(2*n[2]))/(l*l);if(Math.abs(u)<1e-12||Math.abs(a)<1e-12||Math.abs(o)<1e-12){let t=a,n=o;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,a=e.graphYmax-e.graphYmin,i=e.nThroughPoints-1,s=r/i/Math.abs(t),o=a/i/Math.abs(n),l=Math.min(s,o);l>1&&(t*=l,n*=l)}return{setValue:{extrapolateBackwardCoeffs:[[r,t,0],[s,n,0]],extrapolateBackwardMode:"line"}}}let c=o*u,p=-a*u;if(c*a>0){let t=c/p,n=(1+t*t)**2,i=a;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,a=e.graphYmax-e.graphYmin,s=e.nThroughPoints-1,o=r/s,l=1/0;if(0!==p){let e=p*n/2*s*s,r=-t*s,i=Math.sqrt(r*r+4*Math.abs(e)*a);l=(Math.abs(r)+i)/(2*Math.abs(e))}let u=Math.min(o,l);u>Math.abs(i)&&(i*=u/Math.abs(i))}return{setValue:{extrapolateBackwardCoeffs:[[r,i,0],[s,-i*t,p*i*i*n/2]],extrapolateBackwardMode:"parabolaVertical"}}}{let t=p/c,n=(1+t*t)**2,a=o;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,i=e.graphYmax-e.graphYmin,s=e.nThroughPoints-1,o=i/s,l=1/0;if(0!==c){let e=c*n/2*s*s,a=-t*s,i=Math.sqrt(a*a+4*Math.abs(e)*r);l=(Math.abs(a)+i)/(2*Math.abs(e))}let u=Math.min(l,o);u>Math.abs(a)&&(a*=u/Math.abs(a))}return{setValue:{extrapolateBackwardCoeffs:[[r,-a*t,c*a*a*n/2],[s,a,0]],extrapolateBackwardMode:"parabolaHorizontal"}}}}},t.extrapolateForwardCoeffs={stateVariablesDeterminingDependencies:["nThroughPoints","extrapolateForward"],additionalStateVariablesDefined:[{variableName:"extrapolateForwardMode",public:!0,shadowingInstructions:{createComponentOfType:"text"}}],returnDependencies({stateValues:e}){let t={extrapolateForward:{dependencyType:"stateVariable",variableName:"extrapolateForward"},nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"}};return e.extrapolateForward&&e.nThroughPoints>=2&&(t.lastSplineCoeffs={dependencyType:"stateVariable",variableName:"splineCoeffs"+(e.nThroughPoints-1)},t.graphXmin={dependencyType:"stateVariable",variableName:"graphXmin"},t.graphXmax={dependencyType:"stateVariable",variableName:"graphXmax"},t.graphYmin={dependencyType:"stateVariable",variableName:"graphYmin"},t.graphYmax={dependencyType:"stateVariable",variableName:"graphYmax"}),t},definition({dependencyValues:e}){if(!e.extrapolateForward||!e.lastSplineCoeffs)return{setValue:{extrapolateForwardCoeffs:null,extrapolateForwardMode:""}};let t=e.lastSplineCoeffs[0],n=e.lastSplineCoeffs[1],r=t[0]+t[1]+t[2]+t[3],a=t[1]+2*t[2]+3*t[3],i=2*t[2]+6*t[3],s=n[0]+n[1]+n[2]+n[3],o=n[1]+2*n[2]+3*n[3],l=a*a+o*o,u=(o*i-a*(2*n[2]+6*n[3]))/(l*l);if(Math.abs(u)<1e-12||Math.abs(a)<1e-12||Math.abs(o)<1e-12){let t=a,n=o;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,a=e.graphYmax-e.graphYmin,i=e.nThroughPoints-1,s=r/i/Math.abs(t),o=a/i/Math.abs(n),l=Math.min(s,o);l>1&&(t*=l,n*=l)}return{setValue:{extrapolateForwardCoeffs:[[r,t,0],[s,n,0]],extrapolateForwardMode:"line"}}}let c=o*u,p=-a*u;if(c*a<0){let t=c/p,n=(1+t*t)**2,i=a;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,a=e.graphYmax-e.graphYmin,s=e.nThroughPoints-1,o=r/s,l=1/0;if(0!==p){let e=p*n/2*s*s,r=-t*s,i=Math.sqrt(r*r+4*Math.abs(e)*a);l=(Math.abs(r)+i)/(2*Math.abs(e))}let u=Math.min(o,l);u>Math.abs(i)&&(i*=u/Math.abs(i))}return{setValue:{extrapolateForwardCoeffs:[[r,i,0],[s,-i*t,p*i*i*n/2]],extrapolateForwardMode:"parabolaVertical"}}}{let t=p/c,n=(1+t*t)**2,a=o;if(null!==e.graphXmin&&null!==e.graphXmax&&null!==e.graphYmin&&null!==e.graphYmax){let r=e.graphXmax-e.graphXmin,i=e.graphYmax-e.graphYmin,s=e.nThroughPoints-1,o=i/s,l=1/0;if(0!==c){let e=c*n/2*s*s,a=-t*s,i=Math.sqrt(a*a+4*Math.abs(e)*r);l=(Math.abs(a)+i)/(2*Math.abs(e))}let u=Math.min(l,o);u>Math.abs(a)&&(a*=u/Math.abs(a))}return{setValue:{extrapolateForwardCoeffs:[[r,-a*t,c*a*a*n/2],[s,a,0]],extrapolateForwardMode:"parabolaHorizontal"}}}}},t.fs={isArray:!0,entryPrefixes:["f"],additionalStateVariablesDefined:[{variableName:"fDefinitions",isArray:!0,forRenderer:!0,entryPrefixes:["fDefinition"]}],public:!0,shadowingInstructions:{createComponentOfType:"function",addStateVariablesShadowingStateVariables:{fDefinitions:{stateVariableToShadow:"fDefinitions"},domain:{stateVariableToShadow:"domainForFunctions"}}},returnArraySizeDependencies:()=>({functionChildren:{dependencyType:"child",childGroups:["functions"]},curveType:{dependencyType:"stateVariable",variableName:"curveType"}}),returnArraySize:({dependencyValues:e})=>"bezier"===e.curveType?[2]:[Math.max(1,e.functionChildren.length)],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["numericalf","fDefinition"],childIndices:[n]}},0===Number(n)&&(t[n].fShadow={dependencyType:"stateVariable",variableName:"fShadow"},t[n].fDefinitionAdapted={dependencyType:"adapterSourceStateVariable",variableName:"fDefinition"});return{globalDependencies:{curveType:{dependencyType:"stateVariable",variableName:"curveType"},numericalThroughPoints:{dependencyType:"stateVariable",variableName:"numericalThroughPoints"},splineCoeffs:{dependencyType:"stateVariable",variableName:"splineCoeffs"},nThroughPoints:{dependencyType:"stateVariable",variableName:"nThroughPoints"},extrapolateBackward:{dependencyType:"stateVariable",variableName:"extrapolateBackward"},extrapolateBackwardCoeffs:{dependencyType:"stateVariable",variableName:"extrapolateBackwardCoeffs"},extrapolateForward:{dependencyType:"stateVariable",variableName:"extrapolateForward"},extrapolateForwardCoeffs:{dependencyType:"stateVariable",variableName:"extrapolateForwardCoeffs"}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n}){if("bezier"===e.curveType){let t={functionType:"bezier",nThroughPoints:e.nThroughPoints,numericalThroughPoints:e.numericalThroughPoints,splineCoeffs:e.splineCoeffs,extrapolateForward:e.extrapolateForward,extrapolateForwardCoeffs:e.extrapolateForwardCoeffs,extrapolateBackward:e.extrapolateBackward,extrapolateBackwardCoeffs:e.extrapolateBackwardCoeffs},n={},r={};return t.component=0,n[0]=returnBezierFunctions(t),r[0]=t,t={...t},t.component=1,n[1]=returnBezierFunctions(t),r[1]=t,{setValue:{fs:n,fDefinitions:r}}}let r={},a={};for(let e of n){let n=t[e].functionChild;1===n.length?(r[e]=n[0].stateValues.numericalf,a[e]=n[0].stateValues.fDefinition):0===Number(e)&&t[e].fShadow?(r[e]=t[e].fShadow,a[e]=t[e].fDefinitionAdapted):(r[e]=()=>0,a[e]={functionType:"zero"})}return{setValue:{fs:r,fDefinitions:a}}}},t.f={isAlias:!0,targetVariableName:"f1"},t.allXCriticalPoints={returnDependencies:()=>({splineCoeffs:{dependencyType:"stateVariable",variableName:"splineCoeffs"},fs:{dependencyType:"stateVariable",variableName:"fs"},curveType:{dependencyType:"stateVariable",variableName:"curveType"}}),definition({dependencyValues:e}){let t=[];if("bezier"!==e.curveType)return{setValue:{allXCriticalPoints:t}};let n=e.fs[0],r=e.fs[1],a=[],i=!1;for(let[t,n]of e.splineCoeffs.entries()){let e=n[0],r=3*e[3],s=2*e[2],o=e[1];if(Math.abs(r)<1e-14){i=addTimePointBezier({t:-o/s,ind:t,ts:a,ignoreLeft:i})}else{let e=s*s-4*r*o;if(0==e){i=addTimePointBezier({t:-s/(2*r),ind:t,ts:a,ignoreLeft:i})}else if(e>0){let n=Math.sqrt(e),o=[(-s-n)/(2*r),(-s+n)/(2*r)];r<0&&(o=[o[1],o[0]]);let l=!1;for(let e of o){addTimePointBezier({t:e,ind:t,ts:a,ignoreLeft:i})&&(l=!0)}i=l}else i=!1}}for(let e of a)t.push([n(e),r(e)]);return{setValue:{allXCriticalPoints:t}}}},t.nXCriticalPoints={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({allXCriticalPoints:{dependencyType:"stateVariable",variableName:"allXCriticalPoints"}}),definition:({dependencyValues:e})=>({setValue:{nXCriticalPoints:e.allXCriticalPoints.length}})},t.xCriticalPoints={public:!0,shadowingInstructions:{createComponentOfType:"number",returnWrappingComponents:e=>"xCriticalPointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["xCriticalPointX","xCriticalPoint"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("xCriticalPointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("xCriticalPoints"===t)return 1===e.length?"xCriticalPoint"+e[0]:`xCriticalPointX${e[0]}_${e[1]}`;if("xCriticalPoint"===t.slice(0,14)){let n=Number(t.slice(14));if(Number.isInteger(n)&&n>0)return`xCriticalPointX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nXCriticalPoints:{dependencyType:"stateVariable",variableName:"nXCriticalPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nXCriticalPoints,2],returnArrayDependenciesByKey:()=>({globalDependencies:{allXCriticalPoints:{dependencyType:"stateVariable",variableName:"allXCriticalPoints"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t={};for(let n=0;n({splineCoeffs:{dependencyType:"stateVariable",variableName:"splineCoeffs"},fs:{dependencyType:"stateVariable",variableName:"fs"},curveType:{dependencyType:"stateVariable",variableName:"curveType"}}),definition({dependencyValues:e}){let t=[];if("bezier"!==e.curveType)return{setValue:{allYCriticalPoints:t}};let n=e.fs[0],r=e.fs[1],a=[],i=!1;for(let[t,n]of e.splineCoeffs.entries()){let e=n[1],r=3*e[3],s=2*e[2],o=e[1];if(Math.abs(r)<1e-14){i=addTimePointBezier({t:-o/s,ind:t,ts:a,ignoreLeft:i})}else{let e=s*s-4*r*o;if(0==e){i=addTimePointBezier({t:-s/(2*r),ind:t,ts:a,ignoreLeft:i})}else if(e>0){let n=Math.sqrt(e),o=[(-s-n)/(2*r),(-s+n)/(2*r)];r<0&&(o=[o[1],o[0]]);let l=!1;for(let e of o){addTimePointBezier({t:e,ind:t,ts:a,ignoreLeft:i})&&(l=!0)}i=l}else i=!1}}for(let e of a)t.push([n(e),r(e)]);return{setValue:{allYCriticalPoints:t}}}},t.nYCriticalPoints={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({allYCriticalPoints:{dependencyType:"stateVariable",variableName:"allYCriticalPoints"}}),definition:({dependencyValues:e})=>({setValue:{nYCriticalPoints:e.allYCriticalPoints.length}})},t.yCriticalPoints={public:!0,shadowingInstructions:{createComponentOfType:"number",returnWrappingComponents:e=>"yCriticalPointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["yCriticalPointX","yCriticalPoint"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("yCriticalPointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("yCriticalPoints"===t)return 1===e.length?"yCriticalPoint"+e[0]:`yCriticalPointX${e[0]}_${e[1]}`;if("yCriticalPoint"===t.slice(0,14)){let n=Number(t.slice(14));if(Number.isInteger(n)&&n>0)return`yCriticalPointX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nYCriticalPoints:{dependencyType:"stateVariable",variableName:"nYCriticalPoints"}}),returnArraySize:({dependencyValues:e})=>[e.nYCriticalPoints,2],returnArrayDependenciesByKey:()=>({globalDependencies:{allYCriticalPoints:{dependencyType:"stateVariable",variableName:"allYCriticalPoints"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t={};for(let n=0;n({splineCoeffs:{dependencyType:"stateVariable",variableName:"splineCoeffs"},fs:{dependencyType:"stateVariable",variableName:"fs"},curveType:{dependencyType:"stateVariable",variableName:"curveType"}}),definition({dependencyValues:e}){let t=[];if("bezier"!==e.curveType)return{setValue:{allCurvatureChangePoints:t}};let n=e.fs[0],r=e.fs[1],a=[],i=!1;for(let[t,n]of e.splineCoeffs.entries()){let[e,r,s,o]=n[0],[l,u,c,p]=n[1],d=3*(s*p-c*o),m=3*(r*p-u*o),h=r*c-u*s;if(Math.abs(d)<1e-14){i=addTimePointBezier({t:-h/m,ind:t,ts:a,ignoreLeft:i})}else{let e=m*m-4*d*h;if(0==e){i=addTimePointBezier({t:-m/(2*d),ind:t,ts:a,ignoreLeft:i})}else if(e>0){let n=Math.sqrt(e),r=[(-m-n)/(2*d),(-m+n)/(2*d)];d<0&&(r=[r[1],r[0]]);let s=!1;for(let e of r){addTimePointBezier({t:e,ind:t,ts:a,ignoreLeft:i})&&(s=!0)}i=s}else i=!1}}for(let e of a)t.push([n(e),r(e)]);return{setValue:{allCurvatureChangePoints:t}}}},t.nCurvatureChangePoints={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({allCurvatureChangePoints:{dependencyType:"stateVariable",variableName:"allCurvatureChangePoints"}}),definition:({dependencyValues:e})=>({setValue:{nCurvatureChangePoints:e.allCurvatureChangePoints.length}})},t.curvatureChangePoints={public:!0,shadowingInstructions:{createComponentOfType:"number",returnWrappingComponents:e=>"curvatureChangePointX"===e?[]:[["point",{componentType:"mathList",isAttribute:"xs"}]]},isArray:!0,nDimensions:2,entryPrefixes:["curvatureChangePointX","curvatureChangePoint"],getArrayKeysFromVarName({arrayEntryPrefix:e,varEnding:t,arraySize:n}){if("curvatureChangePointX"===e){let e=t.split("_").map((e=>Number(e)-1));return 2===e.length&&e.every(((e,t)=>Number.isInteger(e)&&e>=0))?n?e.every(((e,t)=>e=0?n?ee+","+n)):[]:[e+",0"]:[]}},arrayVarNameFromPropIndex(e,t){if("curvatureChangePoints"===t)return 1===e.length?"curvatureChangePoint"+e[0]:`curvatureChangePointX${e[0]}_${e[1]}`;if("curvatureChangePoint"===t.slice(0,20)){let n=Number(t.slice(20));if(Number.isInteger(n)&&n>0)return`curvatureChangePointX${n}_${e[0]}`}return null},returnArraySizeDependencies:()=>({nCurvatureChangePoints:{dependencyType:"stateVariable",variableName:"nCurvatureChangePoints"}}),returnArraySize:({dependencyValues:e})=>[e.nCurvatureChangePoints,2],returnArrayDependenciesByKey:()=>({globalDependencies:{allCurvatureChangePoints:{dependencyType:"stateVariable",variableName:"allCurvatureChangePoints"}}}),arrayDefinitionByKey({globalDependencyValues:e}){let t={};for(let n=0;n({nearestPointAsCurvePrelim:{dependencyType:"stateVariable",variableName:"nearestPointAsCurvePrelim"},functionChild:{dependencyType:"child",childGroups:["functions"],variableNames:["nearestPointAsCurve"]},adapterSourceValue:{dependencyType:"adapterSourceStateVariable",variableName:"nearestPointAsCurve"}}),definition({dependencyValues:e,usedDefault:t}){let n=e.nearestPointAsCurvePrelim;return t.nearestPointAsCurvePrelim&&(e.functionChild.length>0?n=e.functionChild[0].stateValues.nearestPointAsCurve:null!==e.adapterSourceValue&&(n=e.adapterSourceValue)),{setValue:{nearestPointAsCurve:n}}}},t.nearestPoint={returnDependencies:()=>({curveType:{dependencyType:"stateVariable",variableName:"curveType"},fs:{dependencyType:"stateVariable",variableName:"fs"},flipFunction:{dependencyType:"stateVariable",variableName:"flipFunction"},nDiscretizationPoints:{dependencyType:"stateVariable",variableName:"nDiscretizationPoints"},parMin:{dependencyType:"stateVariable",variableName:"parMin"},parMax:{dependencyType:"stateVariable",variableName:"parMax"},periodic:{dependencyType:"stateVariable",variableName:"periodic"},graphXmin:{dependencyType:"stateVariable",variableName:"graphXmin"},graphXmax:{dependencyType:"stateVariable",variableName:"graphXmax"},graphYmin:{dependencyType:"stateVariable",variableName:"graphYmin"},graphYmax:{dependencyType:"stateVariable",variableName:"graphYmax"},nearestPointAsCurve:{dependencyType:"stateVariable",variableName:"nearestPointAsCurve"}}),definition({dependencyValues:t}){let n=null;return"function"===t.curveType?n=getNearestPointFunctionCurve({dependencyValues:t,numerics:e}):["parameterization","bezier"].includes(t.curveType)&&(n=getNearestPointParametrizedCurve({dependencyValues:t,numerics:e})),{setValue:{nearestPoint:n}}}},t}async moveControlVector({controlVector:e,controlVectorInds:t,transient:n,actionId:r}){let a={[t+",0"]:me$3.fromAst(e[0]),[t+",1"]:me$3.fromAst(e[1])};return n?await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"controlVectors",value:a,sourceInformation:{controlVectorMoved:t}}],transient:n,actionId:r}):await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"controlVectors",value:a,sourceInformation:{controlVectorMoved:t}}],actionId:r,event:{verb:"interacted",object:{componentId:this.componentName},result:{["controlVector"+t.join("_")]:e}}})}async moveThroughPoint({throughPoint:e,throughPointInd:t,transient:n,actionId:r}){let a={[t+",0"]:me$3.fromAst(e[0]),[t+",1"]:me$3.fromAst(e[1])};return n?await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"throughPoints",value:a,sourceInformation:{throughPointMoved:t}}],transient:n,actionId:r}):await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"throughPoints",value:a,sourceInformation:{throughPointMoved:t}}],actionId:r,event:{verb:"interacted",object:{componentId:this.componentName},result:{["throughPoint"+t]:e}}})}async changeVectorControlDirection({direction:e,throughPointInd:t,actionId:n}){return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"vectorControlDirection",value:{[t]:e}}],actionId:n})}switchCurve(){}async curveClicked({actionId:e,name:t}){await this.coreFunctions.triggerChainedActions({triggeringAction:"click",componentName:t}),this.coreFunctions.resolveAction({actionId:e})}async mouseDownOnCurve({actionId:e,name:t}){await this.coreFunctions.triggerChainedActions({triggeringAction:"down",componentName:t}),this.coreFunctions.resolveAction({actionId:e})}}function getNearestPointFunctionCurve({dependencyValues:e,numerics:t}){let n=e.flipFunction,r=e.fs[0],a=e.nDiscretizationPoints,i=e.parMax,s=e.parMin;return function({variables:o,scales:l}){let u,c,p,d,m=o.x1?.evaluate_to_constant(),h=o.x2?.evaluate_to_constant(),f=l[0],y=l[1];if(s!==-1/0){if(u=s,c=r(s),!Number.isFinite(c)){let e=.99999*s+1e-5*i,t=r(e);Number.isFinite(t)&&(u=e,c=t)}if(n){let e=u;u=c,c=e}}if(i!==1/0){if(p=i,d=r(i),!Number.isFinite(d)){let e=1e-5*s+.99999*i,t=r(e);Number.isFinite(t)&&(p=e,d=t)}if(n){let e=p;p=d,d=e}}if(!e.nearestPointAsCurve||!Number.isFinite(m)||!Number.isFinite(h)){let e,t;if(n?(t=h,e=r(t)):(e=m,t=r(e)),!Number.isFinite(e)||!Number.isFinite(t)){let r,a;n?(r=Math.abs(s-h),a=Math.abs(i-h)):(r=Math.abs(s-m),a=Math.abs(i-m)),re.evaluate_to_constant())),a)l=a.map((e=>e.evaluate_to_constant())),s=n?n.map((e=>e.evaluate_to_constant())):[2*o[0]-l[0],2*o[1]-l[1]];else{if(!n)return{coordsNumeric:[me$3.fromAst(NaN),me$3.fromAst(NaN)],numericEntries:!1};s=n.map((e=>e.evaluate_to_constant())),l=[2*o[0]-s[0],2*o[1]-s[1]]}let c=[];if("centripetal"===i){let n=u(s,o),r=u(o,l);n=Math.sqrt(n),r=Math.sqrt(r),rme$3.fromAst(e)));return{coordsNumeric:p,numericEntries:Number.isFinite(c[0])&&Number.isFinite(c[1])}}function initCubicPoly(e,t,n,r){return[e,n,-3*e+3*t-2*n-r,2*e-2*t+n+r]}function addTimePointBezier({t:e,ind:t,ts:n,ignoreLeft:r=!1}){const a=1e-14;let i=!1;return e>=a?e<=.99999999999999?n.push(t+e):e<1.00000000000001&&(n.push(t+1),i=!0):e>-a&&!r&&n.push(t),i}class EquilibriumCurve extends Curve{static componentType="equilibriumCurve";static rendererType="curve";static createAttributesObject(){let e=super.createAttributesObject();return e.stable={createComponentOfType:"boolean",createStateVariable:"stable",defaultValue:!0,public:!0},e.switchable={createComponentOfType:"boolean",createStateVariable:"switchable",defaultValue:!1,public:!0,forRenderer:!0},e}static returnStateVariableDefinitions({numerics:e}){let t=super.returnStateVariableDefinitions({numerics:e});return t.dashed={forRenderer:!0,returnDependencies:()=>({stable:{dependencyType:"stateVariable",variableName:"stable"}}),definition:({dependencyValues:e})=>({setValue:{dashed:!e.stable}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setDependency:"stable",desiredValue:!e.dashed}]})},t}async switchCurve({actionId:e}){if(await this.stateValues.switchable)return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"stable",value:!this.stateValues.stable}],actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{stable:!this.stateValues.stable}}});this.coreFunctions.resolveAction({actionId:e})}}var DynamicalSystems=Object.freeze({__proto__:null,ODESystem:ODESystem,CobwebPolyline:CobwebPolyline,EquilibriumPoint:EquilibriumPoint,EquilibriumLine:EquilibriumLine,EquilibriumCurve:EquilibriumCurve});class Atom extends InlineComponent{static componentType="atom";static rendererType="math";static primaryStateVariableForDefinition="atomicNumberShadow";static createAttributesObject(){let e=super.createAttributesObject();return e.symbol={createComponentOfType:"text"},e.atomicNumber={createComponentOfType:"integer"},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.atomicNumberShadow={defaultValue:null,hasEssential:!0,essentialVarName:"atomicNumber",returnDependencies:()=>({}),definition:()=>({useEssentialOrDefaultValue:{atomicNumberShadow:!0}}),inverseDefinition:async function({desiredStateVariableValues:e}){return{success:!0,instructions:[{setEssentialValue:"atomicNumberShadow",value:e.atomicNumberShadow}]}}},e.dataForAtom={returnDependencies:()=>({fileContents:{dependencyType:"file",cid:"bafkreibilal4glrbpo7p7oodtwtnzkfhiylfoqa2td4ij6h6iqva57kzcy",fileType:"csv"},symbolAttr:{dependencyType:"attributeComponent",attributeName:"symbol",variableNames:["value"]},atomicNumberAttr:{dependencyType:"attributeComponent",attributeName:"atomicNumber",variableNames:["value"]},atomicNumberShadow:{dependencyType:"stateVariable",variableName:"atomicNumberShadow"}}),definition:function({dependencyValues:e}){let t=null,n=null;if(e.symbolAttr)t=e.symbolAttr.stateValues.value.toLowerCase();else if(e.atomicNumberAttr)n=e.atomicNumberAttr.stateValues.value;else{if(!e.atomicNumberShadow)return{setValue:{dataForAtom:null}};n=e.atomicNumberShadow}let r,a=e.fileContents.trim().split("\n");r=null!==n?n-1:["h","he","li","be","b","c","n","o","f","ne","na","mg","al","si","p","s","cl","ar","k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr","rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe","cs","ba","la","ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu","hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn","fr","ra","ac","th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr","rf","db","sg","bh","hs","mt","ds","rg","cn","nh","fl","mc","lv","ts","og"].indexOf(t?.toLowerCase());let i=a.slice(1)[r];if(!i)return{setValue:{dataForAtom:null}};i=i.trim().split(",").map((e=>e.trim()));let s=a[0].trim().split(",").map((e=>e.trim())).map((e=>(['"',"'"].includes(e[0])&&e[e.length-1]===e[0]&&(e=e.substring(1,e.length-1).trim()),e))),o=s.length,l=["number","string","string","number","number","string","number","string","string","number","number","number","number","number","number","number","string"],u={};for(let e=0;e({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Atomic Number"]:null,{setValue:{atomicNumber:t}}}},e.symbol={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Symbol:null,{setValue:{symbol:t}}}},e.name={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Name:null,{setValue:{name:t}}}},e.group={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Group:null,{setValue:{group:t}}}},e.atomicMass={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Atomic Mass"]:null,{setValue:{atomicMass:t}}}},e.phaseAtSTP={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Phase at STP"]:null,{setValue:{phaseAtSTP:t}}}},e.chargeOfCommonIon={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Charge of Common Ion"]:null,{setValue:{chargeOfCommonIon:t}}}},e.metalCategory={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Metal/Nonmetal/Metalloid"]:null,{setValue:{metalCategory:t}}}},e.groupName={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Group Name"]:null,{setValue:{groupName:t}}}},e.period={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Period:null,{setValue:{period:t}}}},e.ionizationEnergy={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Ionization Energy"]:null,{setValue:{ionizationEnergy:t}}}},e.meltingPoint={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Melting Point"]:null,{setValue:{meltingPoint:t}}}},e.boilingPoint={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Boiling Point"]:null,{setValue:{boilingPoint:t}}}},e.atomicRadius={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Atomic Radius"]:null,{setValue:{atomicRadius:t}}}},e.density={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Density:null,{setValue:{density:t}}}},e.electronegativity={public:!0,shadowingInstructions:{createComponentOfType:"number"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Electronegativity:null,{setValue:{electronegativity:t}}}},e.electronConfiguration={public:!0,shadowingInstructions:{createComponentOfType:"electronConfiguration"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Electron Configuration"]:null,{setValue:{electronConfiguration:t}}}},e.orbitalDiagram={public:!0,shadowingInstructions:{createComponentOfType:"orbitalDiagram"},returnDependencies:()=>({electronConfiguration:{dependencyType:"stateVariable",variableName:"electronConfiguration"}}),definition({dependencyValues:e}){let t;return t=e.electronConfiguration?electronConfigurationToOrbitalDiagram(e.electronConfiguration):null,{setValue:{orbitalDiagram:t}}}},e.math={public:!0,shadowingInstructions:{createComponentOfType:"math"},returnDependencies:()=>({symbol:{dependencyType:"stateVariable",variableName:"symbol"}}),definition({dependencyValues:e}){let t;return t=e.symbol?["^",e.symbol]:"_",{setValue:{math:me$3.fromAst(t)}}}},e.latex={additionalStateVariablesDefined:[{variableName:"latexWithInputChildren",forRenderer:!0}],returnDependencies:()=>({symbol:{dependencyType:"stateVariable",variableName:"symbol"}}),definition({dependencyValues:e}){let t;return t=e.symbol?`\\text{${e.symbol}}`:"[\\text{Invalid Chemical Symbol}]",{setValue:{latex:t,latexWithInputChildren:[t]}}}},e}static adapters=["math","name",{stateVariable:"atomicNumber",componentType:"ion"}]}function electronConfigurationToOrbitalDiagram(e){let t=e.tree;if(!Array.isArray(t)||"*"!==t[0])return null;t=t.slice(1);let n=t.length/2;if(!Number.isInteger(n))return null;let r=[];for(let e=0;e0))return null;let a=t[2*e+1];if(!Array.isArray(a)||"^"!==a[0])return null;let i=a[1],s=a[2];if(!(["s","p","d","f"].includes(i)&&Number.isInteger(s)&&s>0))return null;let o,l=`${n}${i}`;o="s"===i?1:"p"===i?3:"d"===i?5:7;let u=Array(o).fill("");for(let e=0;e({}),definition:()=>({useEssentialOrDefaultValue:{atomicNumberShadow:!0}}),inverseDefinition:async function({desiredStateVariableValues:e}){return{success:!0,instructions:[{setEssentialValue:"atomicNumberShadow",value:e.atomicNumberShadow}]}}},e.dataForAtom={returnDependencies:()=>({fileContents:{dependencyType:"file",cid:"bafkreibilal4glrbpo7p7oodtwtnzkfhiylfoqa2td4ij6h6iqva57kzcy",fileType:"csv"},symbolAttr:{dependencyType:"attributeComponent",attributeName:"symbol",variableNames:["value"]},atomicNumberAttr:{dependencyType:"attributeComponent",attributeName:"atomicNumber",variableNames:["value"]},atomChild:{dependencyType:"child",childGroups:["atoms"],variableNames:["atomicNumber"]},atomicNumberShadow:{dependencyType:"stateVariable",variableName:"atomicNumberShadow"}}),definition:function({dependencyValues:e}){let t=null,n=null;if(e.atomChild.length>0)n=e.atomChild[0].stateValues.atomicNumber;else if(e.symbolAttr)t=e.symbolAttr.stateValues.value.toLowerCase();else if(e.atomicNumberAttr)n=e.atomicNumberAttr.stateValues.value;else{if(!e.atomicNumberShadow)return{setValue:{dataForAtom:null}};n=e.atomicNumberShadow}let r,a=e.fileContents.trim().split("\n");r=null!==n?n-1:["h","he","li","be","b","c","n","o","f","ne","na","mg","al","si","p","s","cl","ar","k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr","rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe","cs","ba","la","ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu","hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn","fr","ra","ac","th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr","rf","db","sg","bh","hs","mt","ds","rg","cn","nh","fl","mc","lv","ts","og"].indexOf(t?.toLowerCase());let i=a.slice(1)[r];if(!i)return{setValue:{dataForAtom:null}};i=i.trim().split(",").map((e=>e.trim()));let s=a[0].trim().split(",").map((e=>e.trim())).map((e=>(['"',"'"].includes(e[0])&&e[e.length-1]===e[0]&&(e=e.substring(1,e.length-1).trim()),e))),o=s.length,l=["number","string","string","number","number","string","number","string","string","number","number","number","number","number","number","number","string"],u={};for(let e=0;e({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Atomic Number"]:null,{setValue:{atomicNumber:t}}}},e.symbol={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Symbol:null,{setValue:{symbol:t}}}},e.charge={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"},chargeAttr:{dependencyType:"attributeComponent",attributeName:"charge",variableNames:["value"]}}),definition({dependencyValues:e}){let t;return e.chargeAttr?(t=e.chargeAttr.stateValues.value,Number.isFinite(t)||(t=0)):t=e.dataForAtom&&e.dataForAtom["Charge of Common Ion"]||0,{setValue:{charge:t}}}},e.name={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"},charge:{dependencyType:"stateVariable",variableName:"charge"},group:{dependencyType:"stateVariable",variableName:"group"},atomicNumber:{dependencyType:"stateVariable",variableName:"atomicNumber"}}),definition({dependencyValues:e}){let t;if(e.dataForAtom){if(t=e.dataForAtom.Name,e.charge<0){let e={Hydrogen:"Hydride",Oxygen:"Oxide",Sulfur:"Sulfide",Nitrogen:"Nitride",Phosphorus:"Phosphide",Carbon:"Carbide"},n=t.length;"ine"===t.substring(n-3,n)?t=t.substring(0,n-3)+"ide":t in e&&(t=e[t])}else if(e.charge>0&&(e.group>=3&&e.group<=12||101===e.group||102===e.group||[13,31,49,50,81,82,83,84].includes(e.atomicNumber))){let n="";switch(e.charge){case 1:n=" (I)";break;case 2:n=" (II)";break;case 3:n=" (III)";break;case 4:n=" (IV)";break;case 5:n=" (V)";break;case 6:n=" (VI)";break;case 7:n=" (VII)";break;case 8:n=" (VIII)"}t+=n}}else t=null;return{setValue:{name:t}}}},e.group={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Group:null,{setValue:{group:t}}}},e.metalCategory={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Metal/Nonmetal/Metalloid"]:null,{setValue:{metalCategory:t}}}},e.groupName={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom["Group Name"]:null,{setValue:{groupName:t}}}},e.period={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({dataForAtom:{dependencyType:"stateVariable",variableName:"dataForAtom"}}),definition({dependencyValues:e}){let t;return t=e.dataForAtom?e.dataForAtom.Period:null,{setValue:{period:t}}}},e.math={public:!0,shadowingInstructions:{createComponentOfType:"math"},returnDependencies:()=>({symbol:{dependencyType:"stateVariable",variableName:"symbol"},charge:{dependencyType:"stateVariable",variableName:"charge"}}),definition({dependencyValues:e}){let t;return e.symbol?(t=["^",e.symbol],-1===e.charge?t.push("-"):1===e.charge?t.push("+"):e.charge<0?t.push(Math.abs(e.charge)+"-"):e.charge>0&&t.push(Math.abs(e.charge)+"+")):t="_",{setValue:{math:me$3.fromAst(t)}}}},e.latex={additionalStateVariablesDefined:[{variableName:"latexWithInputChildren",forRenderer:!0}],returnDependencies:()=>({symbol:{dependencyType:"stateVariable",variableName:"symbol"},charge:{dependencyType:"stateVariable",variableName:"charge"}}),definition({dependencyValues:e}){let t;return e.symbol?(t=`\\text{${e.symbol}}`,-1===e.charge?t+="^-":1===e.charge?t+="^+":e.charge<0?t+=`^{${Math.abs(e.charge)}-}`:e.charge>0&&(t+=`^{${Math.abs(e.charge)}+}`)):t="[\\text{Invalid Chemical Symbol}]",{setValue:{latex:t,latexWithInputChildren:[t]}}}},e}static adapters=["math","name"]}class IonicCompound extends InlineComponent{static componentType="ionicCompound";static rendererType="math";static createAttributesObject(){let e=super.createAttributesObject();return e.symbol={createComponentOfType:"text"},e.atomicNumber={createComponentOfType:"integer"},e.charge={createComponentOfType:"integer"},e}static returnChildGroups(){return[{group:"ions",componentTypes:["ion"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.ionicCompound={returnDependencies:()=>({ionChildren:{dependencyType:"child",childGroups:["ions"],variableNames:["symbol","charge","atomicNumber","name"]}}),definition({dependencyValues:e}){let t=e.ionChildren.map((e=>e.stateValues.charge));if(2!==t.length)return console.warn("have not implemented ionic compound for anything other than two ions"),{setValue:{ionicCompound:null}};if(!(t[0]*t[1]<0))return console.warn("ionic compound implemented only for one cation and one anion"),{setValue:{ionicCompound:null}};let n=Math.abs(t[1]),r=Math.abs(t[0]),a=me$3.math.gcd(n,r);return n/=a,r/=a,{setValue:{ionicCompound:[{symbol:e.ionChildren[0].stateValues.symbol,atomicNumber:e.ionChildren[0].stateValues.atomicNumber,name:e.ionChildren[0].stateValues.name,charge:t[0],count:n},{symbol:e.ionChildren[1].stateValues.symbol,atomicNumber:e.ionChildren[1].stateValues.atomicNumber,name:e.ionChildren[1].stateValues.name,charge:t[1],count:r}]}}}},e.math={public:!0,shadowingInstructions:{createComponentOfType:"math"},returnDependencies:()=>({ionicCompound:{dependencyType:"stateVariable",variableName:"ionicCompound"}}),definition({dependencyValues:e}){let t;if(e.ionicCompound){t=[];for(let n of e.ionicCompound){let e=n.symbol;n.count>1&&(e=["_",e,n.count]),t.push(e)}t=t.length>1?["*",...t]:1===t.length?t[0]:"_"}else t="_";return{setValue:{math:me$3.fromAst(t)}}}},e.latex={additionalStateVariablesDefined:[{variableName:"latexWithInputChildren",forRenderer:!0}],returnDependencies:()=>({ionicCompound:{dependencyType:"stateVariable",variableName:"ionicCompound"}}),definition({dependencyValues:e}){let t;if(e.ionicCompound){t="";for(let n of e.ionicCompound)t+=`\\text{${n.symbol}}`,n.count>1&&(t+=`_{${n.count}}`)}else t="[\\text{Invalid Ionic Compound}]";return{setValue:{latex:t,latexWithInputChildren:[t]}}}},e}static adapters=["math"]}class ElectronConfiguration extends MathComponent{static componentType="electronConfiguration";static rendererType="math";static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.latex={public:!0,shadowingInstructions:{createComponentOfType:"text"},returnDependencies:()=>({valueForDisplay:{dependencyType:"stateVariable",variableName:"valueForDisplay"}}),definition:function({dependencyValues:e,usedDefault:t}){let n;try{n=e.valueForDisplay.toLatex()}catch(e){n="_"}return n=n.replaceAll("\\,",""),n=n.replaceAll("\\cdot","~"),{setValue:{latex:n}}}},e}}class OrbitalDiagram extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="orbitalDiagram";static variableForPlainMacro="value";static createAttributesObject(){let e=super.createAttributesObject();return e.labels={createComponentOfType:"textList",createStateVariable:"labels",defaultValue:[]},e}static returnSugarInstructions(){return[{replacementFunction:function({matchedChildren:e}){return 1===e.length&&"string"!=typeof e[0]?{success:!1}:{success:!0,newChildren:[{componentType:"tupleList",children:e}]}}}]}static returnChildGroups(){return[{group:"tupleLists",componentTypes:["tupleList"]},{group:"orbitalDiagrams",componentTypes:["orbitalDiagram"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.value={defaultValue:[{orbitalText:"",boxes:[]}],public:!0,shadowingInstructions:{createComponentOfType:"orbitalDiagram"},forRenderer:!0,returnDependencies:()=>({orbitalDiagramChildren:{dependencyType:"child",childGroups:["orbitalDiagrams"],variableNames:["value"]},tupleListChildren:{dependencyType:"child",childGroups:["tupleLists"],variableNames:["maths"]},labels:{dependencyType:"stateVariable",variableName:"labels"}}),definition:function({dependencyValues:e}){return{setValue:{value:function(){function t(e){if("u"===e||"U"===e)return"U";if("d"===e||"D"===e)return"D";if("e"===e||"E"===e)return"";if(Array.isArray(e)&&"*"===e[0]){let t="";for(let n of e.slice(1))if("u"===n||"U"===n)t+="U";else{if("d"!==n&&"D"!==n)return"";t+="D"}return t}return""}if(1===e.orbitalDiagramChildren.length)return e.orbitalDiagramChildren[0].stateValues.value;let n=[];if(e.tupleListChildren[0]?.stateValues.maths.length>0){let r=e.tupleListChildren[0].stateValues.maths;for(let[a,i]of r.entries()){let r="";e.labels[a]&&(r=e.labels[a]);let s=[];if(Array.isArray(i.tree)&&"tuple"===i.tree[0])for(let e of i.tree.slice(1))s.push(t(e));else s.push(t(i.tree));n.push({orbitalText:r,boxes:s})}return n}return[{orbitalText:"",boxes:[]}]}()}}}},e}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}class OrbitalDiagramInput extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{addRow:this.addRow.bind(this),removeRow:this.removeRow.bind(this),addBox:this.addBox.bind(this),removeBox:this.removeBox.bind(this),addUpArrow:this.addUpArrow.bind(this),addDownArrow:this.addDownArrow.bind(this),removeArrow:this.removeArrow.bind(this),updateRowText:this.updateRowText.bind(this),selectRow:this.selectRow.bind(this),selectBox:this.selectBox.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="orbitalDiagramInput";static variableForPlainMacro="value";static variableForPlainCopy="value";static createAttributesObject(){let e=super.createAttributesObject();return e.prefill={createComponentOfType:"orbitalDiagram",createStateVariable:"prefill",defaultValue:[]},e.prefillLabel={createComponentOfType:"textList",createStateVariable:"prefillLabel",defaultValue:[]},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.value={defaultValue:[{orbitalText:"",boxes:[]}],hasEssential:!0,forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"orbitalDiagram"},returnDependencies:()=>({prefill:{dependencyType:"stateVariable",variableName:"prefill"},prefillLabel:{dependencyType:"stateVariable",variableName:"prefillLabel"}}),definition:function({dependencyValues:e}){return{useEssentialOrDefaultValue:{value:{get defaultValue(){return function(){if(e.prefill?.length>0){let t=JSON.parse(JSON.stringify(e.prefill));for(let[n,r]of t.entries())e.prefillLabel[n]&&(r.orbitalText=e.prefillLabel[n]);return t}return[{orbitalText:"",boxes:[]}]}()}}}}},inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setEssentialValue:"value",value:e.value}]})},e.rows={public:!0,shadowingInstructions:{createComponentOfType:"orbitalDiagram"},forRenderer:!0,returnDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),definition:({dependencyValues:e})=>({setValue:{rows:[...e.value].reverse()}}),inverseDefinition:({desiredStateVariableValues:e})=>({success:!0,instructions:[{setDependency:"value",desiredValue:[...e.rows].reverse()}]})},e.numRows={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({rows:{dependencyType:"stateVariable",variableName:"rows"}}),definition:function({dependencyValues:e}){return{setValue:{numRows:e.rows.length}}}},e.selectedRowIndex={defaultValue:0,hasEssential:!0,forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{selectedRowIndex:!0}}},async inverseDefinition({desiredStateVariableValues:e,stateValues:t}){let n=await t.numRows,r=e.selectedRowIndex;return r=Number.isFinite(r)?Math.min(n,Math.max(0,Math.round(r))):0,{success:!0,instructions:[{setEssentialValue:"selectedRowIndex",value:r}]}}},e.selectedBoxIndex={defaultValue:0,hasEssential:!0,forRenderer:!0,public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({}),definition:function(){return{useEssentialOrDefaultValue:{selectedBoxIndex:!0}}},async inverseDefinition({desiredStateVariableValues:e}){let t=e.selectedBoxIndex;return t=Number.isFinite(t)?Math.max(0,Math.round(t)):0,{success:!0,instructions:[{setEssentialValue:"selectedBoxIndex",value:t}]}}},e}async addRow({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t));t.length<20&&(n=[{orbitalText:"",boxes:[]},...t]);let r=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];return-1!==await this.stateValues.selectedRowIndex-1&&r.push({updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedRowIndex",value:0}),-1!==await this.stateValues.selectedBoxIndex-1&&r.push({updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedBoxIndex",value:0}),await this.coreFunctions.performUpdate({updateInstructions:r,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async removeRow({actionId:e}){let t=await this.stateValues.rows,n=await this.stateValues.selectedRowIndex-1,r=JSON.parse(JSON.stringify(t));if(t.length>1){let e=t.length-1-n;-1===n&&(e=0),r.splice(e,1)}return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:r},{updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedRowIndex",value:0},{updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedBoxIndex",value:0}],actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:r}}})}async addBox({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t)),r=await this.stateValues.selectedRowIndex-1,a=t.length-r-1;-1===r&&(a=0),n[a].boxes.length<17&&n[a].boxes.push("");let i=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];if(-1!==r){let e=0;i.push({updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedBoxIndex",value:e})}return await this.coreFunctions.performUpdate({updateInstructions:i,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async removeBox({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t)),r=await this.stateValues.selectedRowIndex-1,a=t.length-r-1;-1===r&&(a=0);let i=await this.stateValues.selectedBoxIndex-1,s=i;-1===i&&(s=n[a].boxes.length-1),n[a].boxes.splice(s,1);let o=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];return-1!==i&&o.push({updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedBoxIndex",value:0}),await this.coreFunctions.performUpdate({updateInstructions:o,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async addUpArrow({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t)),r=await this.stateValues.selectedRowIndex-1,a=t.length-r-1;-1===r&&(a=0);let i=await this.stateValues.selectedBoxIndex-1,s=i;-1===i&&(s=n[a].boxes.length-1),n[a].boxes.length>0&&n[a].boxes[s].length<3&&(n[a].boxes[s]=n[a].boxes[s]+"U");let o=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];return await this.coreFunctions.performUpdate({updateInstructions:o,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async addDownArrow({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t)),r=await this.stateValues.selectedRowIndex-1,a=t.length-r-1;-1===r&&(a=0);let i=await this.stateValues.selectedBoxIndex-1,s=i;-1===i&&(s=n[a].boxes.length-1),n[a].boxes.length>0&&n[a].boxes[s].length<3&&(n[a].boxes[s]=n[a].boxes[s]+"D");let o=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];return await this.coreFunctions.performUpdate({updateInstructions:o,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async removeArrow({actionId:e}){let t=await this.stateValues.rows,n=JSON.parse(JSON.stringify(t)),r=await this.stateValues.selectedRowIndex-1,a=t.length-r-1;-1===r&&(a=0);let i=await this.stateValues.selectedBoxIndex-1,s=i;-1===i&&(s=n[a].boxes.length-1),n[a].boxes.length>0&&n[a].boxes[s].length>0&&(n[a].boxes[s]=n[a].boxes[s].slice(0,-1));let o=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:n}];return await this.coreFunctions.performUpdate({updateInstructions:o,actionId:e,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:n}}})}async updateRowText({newValue:e,actionId:t}){let n=await this.stateValues.rows,r=JSON.parse(JSON.stringify(n)),a=await this.stateValues.selectedRowIndex-1,i=n.length-a-1;-1===a&&(i=0),r[i].orbitalText=e;let s=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"rows",value:r}];return await this.coreFunctions.performUpdate({updateInstructions:s,actionId:t,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{rows:r}}})}async selectRow({index:e,actionId:t}){return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedRowIndex",value:e}],actionId:t,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{selectedRowIndex:e}}})}async selectBox({index:e,actionId:t}){return await this.coreFunctions.performUpdate({updateInstructions:[{updateType:"updateValue",componentName:this.componentName,stateVariable:"selectedBoxIndex",value:e}],actionId:t,event:{verb:"interacted",object:{componentName:this.componentName,componentType:this.componentType},result:{selectedBoxIndex:e}}})}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}var Chemistry=Object.freeze({__proto__:null,Atom:Atom,Ion:Ion,IonicCompound:IonicCompound,ElectronConfiguration:ElectronConfiguration,OrbitalDiagram:OrbitalDiagram,OrbitalDiagramInput:OrbitalDiagramInput});class FeedbackDefinition extends BaseComponent{static componentType="feedbackDefinition";static createAttributesObject(){let e=super.createAttributesObject();return e.code={createComponentOfType:"text"},e.text={createComponentOfType:"text"},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.feedbackDefinition={returnDependencies:()=>({codeAttr:{dependencyType:"attributeComponent",attributeName:"code",variableNames:["value"]},textAttr:{dependencyType:"attributeComponent",attributeName:"text",variableNames:["value"]}}),definition({dependencyValues:e}){if(null!==e.codeAttr&&null!==e.textAttr){return{setValue:{feedbackDefinition:{[e.codeAttr.stateValues.value.toLowerCase()]:e.textAttr.stateValues.value}}}}return{setValue:{feedbackDefinition:null}}}},e}}class FeedbackDefinitions extends BaseComponent{static componentType="feedbackDefinitions";static rendererType=void 0;static returnChildGroups(){return[{group:"feedbackDefinition",componentTypes:["feedbackDefinition"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.value={returnDependencies:()=>({feedbackDefinitionChildren:{dependencyType:"child",childGroups:["feedbackDefinition"],variableNames:["feedbackDefinition"]}}),definition({dependencyValues:e}){let t={};for(let n of e.feedbackDefinitionChildren)n.stateValues.feedbackDefinition&&Object.assign(t,n.stateValues.feedbackDefinition);return{setValue:{value:t}}}},e}}var FeedbackDefinitions$1=Object.freeze({__proto__:null,FeedbackDefinition:FeedbackDefinition,FeedbackDefinitions:FeedbackDefinitions});class StyleDefinition extends BaseComponent{static componentType="styleDefinition";static rendererType=void 0;static createAttributesObject(){let e=super.createAttributesObject();e.styleNumber={createPrimitiveOfType:"number",createStateVariable:"styleNumber",defaultValue:1};for(let t in styleAttributes)e[t]={createComponentOfType:styleAttributes[t].componentType};return e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.styleDefinition={returnDependencies:function(){let e={};for(let t in styleAttributes)e[t]={dependencyType:"attributeComponent",attributeName:t,variableNames:["value"]};return e},definition:function({dependencyValues:e}){let t={};for(let n in styleAttributes)null!==e[n]&&(t[n]=e[n].stateValues.value,"string"==typeof t[n]&&(t[n]=t[n].toLowerCase()));return{setValue:{styleDefinition:t}}}},e}}class StyleDefinitions extends BaseComponent{static componentType="styleDefinitions";static rendererType=void 0;static returnChildGroups(){return[{group:"styleDefinition",componentTypes:["styleDefinition"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.value={returnDependencies:()=>({styleDefinitionChildren:{dependencyType:"child",childGroups:["styleDefinition"],variableNames:["styleNumber","styleDefinition"]}}),definition({dependencyValues:e}){let t={};for(let n of e.styleDefinitionChildren){let e=n.stateValues.styleNumber,r=t[e];r||(r=t[e]={}),Object.assign(r,n.stateValues.styleDefinition)}return{setValue:{value:t}}}},e}}var StyleDefinitions$1=Object.freeze({__proto__:null,StyleDefinition:StyleDefinition,StyleDefinitions:StyleDefinitions});class ComponentWithSelectableType extends BaseComponent{static componentType="_componentWithSelectableType";static rendererType=void 0;static includeBlankStringChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.type={createPrimitiveOfType:"string"},e}static returnSugarInstructions(){let e=[];return e.push({replacementFunction:function({matchedChildren:e,componentAttributes:t,parentAttributes:n}){let r=t.type;r||(r=n.type),r?["number","letters","math","text","boolean"].includes(r)||(console.warn(`Invalid type ${r}, setting type to number`),r="number"):r="number";let a="letters"===r?"text":r;return"text"!==a&&(e=e.filter((e=>"string"!=typeof e||""!==e.trim()))),{success:!0,newChildren:[{componentType:a,children:e}]}}}),e}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.type={shadowVariable:!0,returnDependencies:()=>({type:{dependencyType:"doenetAttribute",attributeName:"type"},parentType:{dependencyType:"parentStateVariable",variableName:"type"}}),definition:function({dependencyValues:e,componentName:t}){let n=e.type;return n||(n=e.parentType),n?["number","letters","math","text","boolean"].includes(n)||(console.warn(`Invalid type ${n}, setting type to number`),n="number"):n="number",{setValue:{type:n}}}},e.value={public:!0,shadowingInstructions:{hasVariableComponentType:!0},shadowVariable:!0,returnDependencies:()=>({type:{dependencyType:"stateVariable",variableName:"type"},atMostOneChild:{dependencyType:"child",childGroups:["anything"],variableNames:["value"]}}),definition({dependencyValues:e}){let t;return t=e.atMostOneChild.length>0?e.atMostOneChild[0].stateValues.value:"text"===e.type||"letters"===e.type?"":"boolean"!==e.type&&("number"===e.type?NaN:me$3.fromAst("_")),{setValue:{value:t},setCreateComponentOfType:{value:e.type}}},inverseDefinition:({desiredStateVariableValues:e,dependencyValues:t})=>t.atMostOneChild.length>0?{success:!0,instructions:[{setDependency:"atMostOneChild",desiredValue:e.value,childIndex:0,variableIndex:0}]}:{success:!1}},e}}class ComponentListWithSelectableType extends ComponentWithSelectableType{static componentType="_componentListWithSelectableType";static includeBlankStringChildren=!0;static removeBlankStringChildrenPostSugar=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.type={createPrimitiveOfType:"string"},e}static returnSugarInstructions(){let e=[];return e.push({replacementFunction:function({matchedChildren:e,componentAttributes:t,parentAttributes:n,isAttributeComponent:r=!1,createdFromMacro:a=!1,componentInfoObjects:i}){let s=t.type;s||(s=n.type),s?["number","letters","math","text","boolean"].includes(s)||(console.warn(`Invalid type ${s}, setting type to number`),s="number"):s="number";let o="letters"===s?"text":s;if(r&&!a){return returnGroupIntoComponentTypeSeparatedBySpaces({componentType:o})({matchedChildren:e})}return returnBreakStringsIntoComponentTypeBySpaces({componentType:o})({matchedChildren:e})}}),e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return delete e.value,e.nValues={additionalStateVariablesDefined:["childForValue"],returnDependencies:()=>({anythingForSelectedType:{dependencyType:"child",childGroups:["anything"],variableNames:["nValues"],variablesOptional:!0}}),definition({dependencyValues:e}){let t=0,n=[];for(let[r,a]of e.anythingForSelectedType.entries()){let e=Number.isInteger(a.stateValues.nValues)?a.stateValues.nValues:1;t+=e;for(let t=0;t({nValues:{dependencyType:"stateVariable",variableName:"nValues"}}),returnArraySize:({dependencyValues:e})=>[e.nValues],returnArrayDependenciesByKey({arrayKeys:e,stateValues:t}){let n={};for(let r of e){let e=t.childForValue[r];n[r]={anythingForSelectedType:{dependencyType:"child",childGroups:["anything"],variableNames:["value","values"],childIndices:[e.child],variablesOptional:!0},valueIndex:{dependencyType:"value",value:e.valueIndex}}}return{globalDependencies:{type:{dependencyType:"stateVariable",variableName:"type"}},dependenciesByKey:n}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,componentName:r}){let a={};for(let r of n)if(t[r].anythingForSelectedType&&1===t[r].anythingForSelectedType.length){let n,i=t[r].anythingForSelectedType[0];n=i.stateValues.values?i.stateValues.values[t[r].valueIndex]:i.stateValues.value,a[r]=convertValueToType(n,e.type)}return{setValue:{values:a},setCreateComponentOfType:{values:e.type}}}},e}}class ComponentListOfListsWithSelectableType extends ComponentWithSelectableType{static componentType="_componentListOfListsWithSelectableType";static createAttributesObject(){let e=super.createAttributesObject();return e.type={createPrimitiveOfType:"string"},e}static returnSugarInstructions(){let e=[];return e.push({replacementFunction:function({matchedChildren:e,componentAttributes:t,parentAttributes:n}){let r=breakEmbeddedStringsIntoParensPieces({componentList:e,removeParens:!0});if(!0!==r.success)return{success:!1};let a=t.type;return a||(a=n.type),a?["number","letters","math","text","boolean"].includes(a)||(console.warn(`Invalid type ${a}, setting type to number`),a="number"):a="number",{success:!0,newChildren:r.pieces.map((e=>({componentType:"_componentListWithSelectableType",attributes:{type:{primitive:a}},children:e})))}}}),e}static returnChildGroups(){return[{group:"lists",componentTypes:["_componentListWithSelectableType"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return delete e.value,e.nLists={returnDependencies:()=>({listChildren:{dependencyType:"child",childGroups:["lists"]}}),definition:({dependencyValues:e})=>({setValue:{nLists:e.listChildren.length}})},e.lists={isArray:!0,entryPrefixes:["list"],returnArraySizeDependencies:()=>({nLists:{dependencyType:"stateVariable",variableName:"nLists"}}),returnArraySize:({dependencyValues:e})=>[e.nLists],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e)t[n]={listChildren:{dependencyType:"child",childGroups:["lists"],variableNames:["values","type"],childIndices:[n]}};return{globalDependencies:{type:{dependencyType:"stateVariable",variableName:"type"}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n}){let r={};for(let a of n)if(t[a].listChildren&&1===t[a].listChildren.length){let n=t[a].listChildren[0];n.stateValues.type===e.type?r[a]=n.stateValues.values:r[a]=n.stateValues.values.map((t=>convertValueToType(t,e.type)))}return{setValue:{lists:r}}}},e}}function convertValueToType(e,t){if(Array.isArray(e)&&(e=e[0]),"number"===t){if(e instanceof me$3.class){let t=e.evaluate_to_constant();return Number.isFinite(t)||(t=NaN),t}return Number(e)}if("math"===t){if("string"==typeof e)try{return me$3.fromAst(textToAst$1.convert(e))}catch(e){}return convertValueToMathExpression(e)}return"boolean"===t?Boolean(e):String(e)}var ComponentWithSelectableType$1=Object.freeze({__proto__:null,ComponentWithSelectableType:ComponentWithSelectableType,ComponentListWithSelectableType:ComponentListWithSelectableType,ComponentListOfListsWithSelectableType:ComponentListOfListsWithSelectableType});class SideBySide extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="sideBySide";static renderChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.width={createComponentOfType:"_componentSize"},e.widths={createComponentOfType:"_componentSizeList"},e.margins={createComponentOfType:"_componentSizeList"},e.valign={createComponentOfType:"text"},e.valigns={createComponentOfType:"textList"},e}static returnChildGroups(){return[{group:"blocks",componentTypes:["_block"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.nPanels={forRenderer:!0,returnDependencies:()=>({blockChildren:{dependencyType:"child",childGroups:["blocks"],skipComponentNames:!0}}),definition:({dependencyValues:e})=>({setValue:{nPanels:e.blockChildren.length},checkForActualChange:{nPanels:!0}})},e.essentialWidths={isArray:!0,entryPrefixes:["essentialWidth"],defaultValueByArrayKey:()=>null,hasEssential:!0,returnArraySizeDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"}}),returnArraySize:({dependencyValues:e})=>[e.nPanels],returnArrayDependenciesByKey:()=>({}),arrayDefinitionByKey({arrayKeys:e}){let t={};for(let n of e)t[n]=!0;return{useEssentialOrDefaultValue:{essentialWidths:t}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e}){let t={};for(let n in e.essentialWidths)t[n]=e.essentialWidths[n];return{success:!0,instructions:[{setEssentialValue:"essentialWidths",value:t}]}}},e.allWidthsSpecified={additionalStateVariablesDefined:["widthsAbsolute"],returnDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"},widthAttr:{dependencyType:"attributeComponent",attributeName:"width",variableNames:["componentSize"]},widthsAttr:{dependencyType:"attributeComponent",attributeName:"widths",variableNames:["nComponents","componentSizes"]},parentWidths:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:"specifiedWidths"},parentWidthsAbsolute:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:"widthsAbsolute"},essentialWidth:{dependencyType:"stateVariable",variableName:"essentialWidths"}}),definition({dependencyValues:e}){let t,n=[],r=null,a=!1;null!==e.widthsAttr?t=e.widthsAttr.stateValues.nComponents:null!==e.widthAttr?(t=e.nPanels,a=!0):t=0;for(let i=0;iNumber.isFinite(e)?e:null)),{setValue:{allWidthsSpecified:n,widthsAbsolute:r}}}},e.essentialMargins={isArray:!0,entryPrefixes:["essentialMargin"],hasEssential:!0,defaultValueByArrayKey:()=>null,returnArraySizeDependencies:()=>({}),returnArraySize:()=>[2],returnArrayDependenciesByKey:()=>({}),arrayDefinitionByKey({arrayKeys:e}){let t={};for(let n of e)t[n]=!0;return{useEssentialOrDefaultValue:{essentialMargins:t}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e}){let t={};for(let n in e.essentialMargins)t[n]=e.essentialMargins[n];return{success:!0,instructions:[{setEssentialValue:"essentialMargins",value:t}]}}},e.allMarginsSpecified={additionalStateVariablesDefined:["marginsAbsolute"],returnDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"},marginsAttr:{dependencyType:"attributeComponent",attributeName:"margins",variableNames:["nComponents","componentSizes"]},parentMargins:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:"specifiedMargins"},parentMarginsAbsolute:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:"marginsAbsolute"},essentialMargins:{dependencyType:"stateVariable",variableName:"essentialMargins"}}),definition({dependencyValues:e}){let t=[],n=null;if(null===e.marginsAttr)if(e.parentMargins){n=e.parentMarginsAbsolute;for(let n=0;n<2;n++)null===e.essentialMargins[n]?t[n]=e.parentMargins[n]:t[n]=e.essentialMargins[n]}else for(let n=0;n<2;n++)t[n]=e.essentialMargins[n];else if(0===e.marginsAttr.stateValues.nComponents)for(let n=0;n<2;n++)t[n]=e.essentialMargins[n];else if(1===e.marginsAttr.stateValues.nComponents){let r=null;e.marginsAttr.stateValues.componentSizes[0]&&(r=e.marginsAttr.stateValues.componentSizes[0].size,Number.isFinite(r)||(r=null),n=Boolean(e.marginsAttr.stateValues.componentSizes[0].isAbsolute)),t=[r,r]}else{let r;if(n=!!e.marginsAttr.stateValues.componentSizes[0]&&Boolean(e.marginsAttr.stateValues.componentSizes[0].isAbsolute),r=!!e.marginsAttr.stateValues.componentSizes[1]&&Boolean(e.marginsAttr.stateValues.componentSizes[1].isAbsolute),r!==n)throw Error("SideBySide is not implemented for absolute measurements");t=e.marginsAttr.stateValues.componentSizes.slice(0,2).map((e=>e&&Number.isFinite(e.size)?e.size:null))}return{setValue:{allMarginsSpecified:t,marginsAbsolute:n}}}},e.absoluteMeasurements={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},forRenderer:!0,returnDependencies:()=>({widthsAbsolute:{dependencyType:"stateVariable",variableName:"widthsAbsolute"},marginsAbsolute:{dependencyType:"stateVariable",variableName:"marginsAbsolute"}}),definition({dependencyValues:e}){let t;if(null===e.widthsAbsolute)t=null!==e.marginsAbsolute&&e.marginsAbsolute;else if(null===e.marginsAbsolute)t=e.widthsAbsolute;else{if(e.widthsAbsolute!==e.marginsAbsolute)throw Error("SideBySide is not implemented for absolute measurements");t=e.widthsAbsolute}if(!0===t)throw Error("SideBySide is not implemented for absolute measurements");return{setValue:{absoluteMeasurements:t}}}},e.allWidths={additionalStateVariablesDefined:["allMargins",{variableName:"gapWidth",public:!0,shadowingInstructions:{createComponentOfType:"number"},forRenderer:!0}],returnDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"},allWidthsSpecified:{dependencyType:"stateVariable",variableName:"allWidthsSpecified"},allMarginsSpecified:{dependencyType:"stateVariable",variableName:"allMarginsSpecified"},absoluteMeasurements:{dependencyType:"stateVariable",variableName:"absoluteMeasurements"}}),definition({dependencyValues:e}){let t=0,n=[...e.allWidthsSpecified],r=[...e.allMarginsSpecified],a=0,i=0;for(let t=0;t=100){let t=100/(a+s);for(let r=0;r0){let t=(100-(a+s))/i;for(let r=0;r0){let t=(100-(a+s))/(o*e.nPanels);for(let e=0;e<2;e++)null===r[e]&&(r[e]=t)}else e.nPanels>1?t=(100-(a+s))/(e.nPanels-1):1===e.nPanels?r[1]=100-(r[0]+n[0]):console.warn("Invalid sideBySide, as it must have at least one block child");return{setValue:{allWidths:n,allMargins:r,gapWidth:t}}}},e.widths={public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"number"},entryPrefixes:["width"],forRenderer:!0,returnArraySizeDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"}}),returnArraySize:({dependencyValues:e})=>[e.nPanels],returnArrayDependenciesByKey({arrayKeys:e}){let t={allWidths:{dependencyType:"stateVariable",variableName:"allWidths"},widthsAttr:{dependencyType:"attributeComponent",attributeName:"widths",variableNames:["nComponents"]},widthAttr:{dependencyType:"attributeComponent",attributeName:"width",variableNames:["componentSize"]},absoluteMeasurements:{dependencyType:"stateVariable",variableName:"absoluteMeasurements"}},n={};for(let t of e){let e=Number(t)+1;n[t]={widthsAttr:{dependencyType:"attributeComponent",attributeName:"widths",variableNames:[`componentSize${e}`]},essentialWidth:{dependencyType:"stateVariable",variableName:`essentialWidth${e}`}}}return{globalDependencies:t,dependenciesByKey:n}},arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e.allWidths[r];return{setValue:{widths:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,dependencyValuesByKey:n,globalDependencyValues:r,arraySize:a}){let i,s=!1;null!==r.widthsAttr?i=r.widthsAttr.stateValues.nComponents:null!==r.widthAttr?(i=a[0],s=!0):i=0;let o=[];for(let n in e.widths){Number(n)({}),returnArraySize:()=>[2],returnArrayDependenciesByKey({arrayKeys:e}){let t={allMargins:{dependencyType:"stateVariable",variableName:"allMargins"},marginsAttr:{dependencyType:"attributeComponent",attributeName:"margins",variableNames:["componentSize1","componentSize2","nComponents"]},absoluteMeasurements:{dependencyType:"stateVariable",variableName:"absoluteMeasurements"}},n={};for(let t of e){let e=Number(t)+1;n[t]={essentialMargin:{dependencyType:"stateVariable",variableName:`essentialMargin${e}`}}}return{globalDependencies:t,dependenciesByKey:n}},arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e.allMargins[r];return{setValue:{margins:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,globalDependencyValues:t,dependencyNamesByKey:n}){let r=[];if(null===t.marginsAttr)for(let t in e.margins)r.push({setDependency:n[t].essentialMargin,desiredValue:e.margins[t]});else if(t.marginsAttr.stateValues.componentSize1&&Number.isFinite(t.marginsAttr.stateValues.componentSize1.size)){let n=1===t.marginsAttr.stateValues.nComponents;for(let a in e.margins)n?r.push({setDependency:"marginsAttr",desiredValue:{size:e.margins[a],isAbsolute:t.absoluteMeasurements},variableIndex:0}):r.push({setDependency:"marginsAttr",desiredValue:{size:e.margins[a],isAbsolute:t.absoluteMeasurements},variableIndex:a})}else"0"in e.margins?r.push({setDependency:"marginsAttr",desiredValue:{size:e.margins[0],isAbsolute:t.absoluteMeasurements},variableIndex:0}):r.push({setDependency:"marginsAttr",desiredValue:{size:e.margins[1],isAbsolute:t.absoluteMeasurements},variableIndex:0}),"1"in e.margins&&t.marginsAttr.stateValues.nComponents>1&&r.push({setDependency:"marginsAttr",desiredValue:{size:e.margins[1],isAbsolute:t.absoluteMeasurements},variableIndex:1});return{success:!0,instructions:r}}},e.essentialValigns={isArray:!0,entryPrefixes:["essentialValign"],defaultValueByArrayKey:()=>null,hasEssential:!0,returnArraySizeDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"}}),returnArraySize:({dependencyValues:e})=>[e.nPanels],returnArrayDependenciesByKey:()=>({}),arrayDefinitionByKey({arrayKeys:e}){let t={};for(let n of e)t[n]=!0;return{useEssentialOrDefaultValue:{essentialValigns:t}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e}){let t={};for(let n in e.essentialValigns)t[n]=e.essentialValigns[n];return{success:!0,instructions:[{setEssentialValue:"essentialValigns",value:t}]}}},e.valigns={public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"text"},entryPrefixes:["valign"],forRenderer:!0,returnArraySizeDependencies:()=>({nPanels:{dependencyType:"stateVariable",variableName:"nPanels"}}),returnArraySize:({dependencyValues:e})=>[e.nPanels],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={valignsAttr:{dependencyType:"attributeComponent",attributeName:"valigns",variableNames:[`text${e}`]},parentValign:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:`valign${e}`},parentValignAbsolute:{dependencyType:"parentStateVariable",parentComponentType:"sbsGroup",variableName:`valignAbsolute${e}`},essentialValign:{dependencyType:"stateVariable",variableName:`essentialValign${e}`}}}return{globalDependencies:{valignAttr:{dependencyType:"attributeComponent",attributeName:"valign",variableNames:["value"]},valignsAttr:{dependencyType:"attributeComponent",attributeName:"valigns",variableNames:["nComponents"]}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,arraySize:r}){let a,i={},s=!1;null!==e.valignsAttr?a=e.valignsAttr.stateValues.nComponents:null!==e.valignAttr?(a=r[0],s=!0):a=0;for(let r of n){let n=Number(r);if(n({sideBySideChildren:{dependencyType:"child",childGroups:["sideBySides"],variableNames:["nPanels"]}}),definition:({dependencyValues:e})=>({setValue:{maxNPanelsPerRow:me$3.math.max(e.sideBySideChildren.map((e=>e.stateValues.nPanels)))},checkForActualChange:{maxNPanelsPerRow:!0}})},e.specifiedWidths={additionalStateVariablesDefined:[{variableName:"widthsAbsoluteArray",isArray:!0}],isArray:!0,entryPrefixes:["specifiedWidth"],hasEssential:!0,defaultValueByArrayKey:()=>null,returnArraySizeDependencies:()=>({maxNPanelsPerRow:{dependencyType:"stateVariable",variableName:"maxNPanelsPerRow"}}),returnArraySize:({dependencyValues:e})=>[e.maxNPanelsPerRow],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={widthsAttr:{dependencyType:"attributeComponent",attributeName:"widths",variableNames:[`componentSize${e}`]}}}return{globalDependencies:{widthAttr:{dependencyType:"attributeComponent",attributeName:"width",variableNames:["componentSize"]},widthsAttr:{dependencyType:"attributeComponent",attributeName:"widths",variableNames:["nComponents"]}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,arraySize:r}){let a,i={},s={},o={},l=!1;null!==e.widthsAttr?a=e.widthsAttr.stateValues.nComponents:null!==e.widthAttr?(a=r[0],l=!0):a=0;for(let r of n){let n=Number(r);if(n0&&(u.useEssentialOrDefaultValue={specifiedWidths:s}),u},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,globalDependencyValues:n,stateValues:r,arraySize:a}){let i,s=!1;null!==n.widthsAttr?i=n.widthsAttr.stateValues.nComponents:null!==n.widthAttr?(i=a[0],s=!0):i=0;let o=[];for(let n in e.specifiedWidths){Number(n)({widthsAbsoluteArray:{dependencyType:"stateVariable",variableName:"widthsAbsoluteArray"}}),definition({dependencyValues:e}){let t=null;for(let n in e.widthsAbsoluteArray){let r=e.widthsAbsoluteArray[n];if(null!==r)if(r=Boolean(r),null===t)t=r;else if(t!==r)throw Error("SbsGroup is not implemented for absolute measurements")}return{setValue:{widthsAbsolute:t}}}},e.specifiedMargins={additionalStateVariablesDefined:[{variableName:"marginsAbsoluteArray",isArray:!0,entryPrefixes:["marginAbsolute"]}],isArray:!0,entryPrefixes:["specifiedMargin"],hasEssential:!0,defaultValueByArrayKey:()=>null,returnArraySizeDependencies:()=>({}),returnArraySize:()=>[2],returnArrayDependenciesByKey:({arrayKeys:e})=>({globalDependencies:{marginsAttr:{dependencyType:"attributeComponent",attributeName:"margins",variableNames:["componentSize1","componentSize2","nComponents"]}}}),arrayDefinitionByKey({dependencyValuesByKey:e,globalDependencyValues:t,arrayKeys:n}){let r={},a={},i={};if(null===t.marginsAttr||0===t.marginsAttr.stateValues.nComponents)for(let e of n)a[e]=!0,i[e]=null;else if(1===t.marginsAttr.stateValues.nComponents){let e=null,a=null;t.marginsAttr.stateValues.componentSize1&&(e=t.marginsAttr.stateValues.componentSize1.size,Number.isFinite(e)||(e=null),a=Boolean(t.marginsAttr.stateValues.componentSize1.isAbsolute));for(let t of n)r[t]=e,i[t]=a}else for(let e of n)if(t.marginsAttr.stateValues[`componentSize${Number(e)+1}`]){let n=t.marginsAttr.stateValues[`componentSize${Number(e)+1}`].size;Number.isFinite(n)||(n=null);let a=Boolean(t.marginsAttr.stateValues[`componentSize${Number(e)+1}`].isAbsolute);r[e]=n,i[e]=a}let s={setValue:{marginsAbsoluteArray:i,specifiedMargins:r}};return Object.keys(a).length>0&&(s.useEssentialOrDefaultValue={specifiedMargins:a}),s},async inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,globalDependencyValues:n,stateValues:r}){let a=[];if(null===n.marginsAttr)a.push({setEssentialValue:"specifiedMargins",value:e.specifiedMargins});else if(n.marginsAttr.stateValues.componentSize1&&Number.isFinite(n.marginsAttr.stateValues.componentSize1.size)){let t=1===n.marginsAttr.stateValues.nComponents;for(let n in e.specifiedMargins)t?a.push({setDependency:"marginsAttr",desiredValue:{size:e.specifiedMargins[n],isAbsolute:await r.marginsAbsolute},variableIndex:0}):a.push({setDependency:"marginsAttr",desiredValue:{size:e.specifiedMargins[n],isAbsolute:await r.marginsAbsolute},variableIndex:n})}else"0"in e.specifiedMargins?a.push({setDependency:"marginsAttr",desiredValue:{size:e.specifiedMargins[0],isAbsolute:await r.marginsAbsolute},variableIndex:0}):a.push({setDependency:"marginsAttr",desiredValue:{size:e.specifiedMargins[1],isAbsolute:await r.marginsAbsolute},variableIndex:0}),"1"in e.specifiedMargins&&n.marginsAttr.stateValues.nComponents>1&&a.push({setDependency:"marginsAttr",desiredValue:{size:e.specifiedMargins[1],isAbsolute:await r.marginsAbsolute},variableIndex:1});return{success:!0,instructions:a}}},e.marginsAbsolute={returnDependencies:()=>({marginsAbsoluteArray:{dependencyType:"stateVariable",variableName:"marginsAbsoluteArray"}}),definition({dependencyValues:e}){let t=null;for(let n in e.marginsAbsoluteArray){let r=e.marginsAbsoluteArray[n];if(null!==r)if(r=Boolean(r),null===t)t=r;else if(t!==r)throw Error("SbsGroup is not implemented for absolute measurements")}return{setValue:{marginsAbsolute:t}}}},e.absoluteMeasurements={public:!0,shadowingInstructions:{createComponentOfType:"boolean"},returnDependencies:()=>({widthsAbsolute:{dependencyType:"stateVariable",variableName:"widthsAbsolute"},marginsAbsolute:{dependencyType:"stateVariable",variableName:"marginsAbsolute"}}),definition({dependencyValues:e}){let t;if(null===e.widthsAbsolute)t=null!==e.marginsAbsolute&&e.marginsAbsolute;else if(null===e.marginsAbsolute)t=e.widthsAbsolute;else{if(e.widthsAbsolute!==e.marginsAbsolute)throw Error("SbsGroup is not implemented for absolute measurements");t=e.widthsAbsolute}if(!0===t)throw Error("SbsGroup is not implemented for absolute measurements");return{setValue:{absoluteMeasurements:t}}}},e.allWidths={additionalStateVariablesDefined:["allMargins",{variableName:"gapWidth",public:!0,shadowingInstructions:{createComponentOfType:"number"}}],returnDependencies:()=>({maxNPanelsPerRow:{dependencyType:"stateVariable",variableName:"maxNPanelsPerRow"},specifiedWidths:{dependencyType:"stateVariable",variableName:"specifiedWidths"},specifiedMargins:{dependencyType:"stateVariable",variableName:"specifiedMargins"},absoluteMeasurements:{dependencyType:"stateVariable",variableName:"absoluteMeasurements"}}),definition({dependencyValues:e}){let t=0,n=[...e.specifiedWidths],r=[...e.specifiedMargins],a=0,i=0;for(let t=0;t=100){let t=100/(a+s);for(let r=0;r0){let t=(100-(a+s))/i;for(let r=0;r0){let t=(100-(a+s))/(o*e.maxNPanelsPerRow);for(let e=0;e<2;e++)null===r[e]&&(r[e]=t)}else e.maxNPanelsPerRow>1?t=(100-(a+s))/(e.maxNPanelsPerRow-1):1===e.maxNPanelsPerRow?r[1]=100-(r[0]+n[0]):console.warn("Invalid sideBySide, as it must have at least one block child");return{setValue:{allWidths:n,allMargins:r,gapWidth:t}}}},e.widths={public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"number"},entryPrefixes:["width"],returnArraySizeDependencies:()=>({maxNPanelsPerRow:{dependencyType:"stateVariable",variableName:"maxNPanelsPerRow"}}),returnArraySize:({dependencyValues:e})=>[e.maxNPanelsPerRow],returnArrayDependenciesByKey({arrayKeys:e}){let t={allWidths:{dependencyType:"stateVariable",variableName:"allWidths"}},n={};for(let t of e){let e=Number(t)+1;n[t]={specifiedWidth:{dependencyType:"stateVariable",variableName:`specifiedWidth${e}`}}}return{globalDependencies:t,dependenciesByKey:n}},arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e.allWidths[r];return{setValue:{widths:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t}){let n=[];for(let r in e.widths)n.push({setDependency:t[r].specifiedWidth,desiredValue:e.widths[r],variableIndex:0});return{success:!0,instructions:n}}},e.margins={public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"number"},entryPrefixes:["margin"],returnArraySizeDependencies:()=>({}),returnArraySize:()=>[2],returnArrayDependenciesByKey({arrayKeys:e}){let t={allMargins:{dependencyType:"stateVariable",variableName:"allMargins"}},n={};for(let t of e){let e=Number(t)+1;n[t]={specifiedMargin:{dependencyType:"stateVariable",variableName:`specifiedMargin${e}`}}}return{globalDependencies:t,dependenciesByKey:n}},arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n={};for(let r of t)n[r]=e.allMargins[r];return{setValue:{margins:n}}},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t}){let n=[];for(let r in e.margins)n.push({setDependency:t[r].specifiedMargin,desiredValue:e.margins[r],variableIndex:0});return{success:!0,instructions:n}}},e.valigns={public:!0,isArray:!0,shadowingInstructions:{createComponentOfType:"text"},entryPrefixes:["valign"],hasEssential:!0,defaultValueByArrayKey:()=>"top",returnArraySizeDependencies:()=>({maxNPanelsPerRow:{dependencyType:"stateVariable",variableName:"maxNPanelsPerRow"}}),returnArraySize:({dependencyValues:e})=>[e.maxNPanelsPerRow],returnArrayDependenciesByKey({arrayKeys:e}){let t={};for(let n of e){let e=Number(n)+1;t[n]={valignsAttr:{dependencyType:"attributeComponent",attributeName:"valigns",variableNames:[`text${e}`]}}}return{globalDependencies:{valignAttr:{dependencyType:"attributeComponent",attributeName:"valign",variableNames:["value"]},valignsAttr:{dependencyType:"attributeComponent",attributeName:"valigns",variableNames:["nComponents"]}},dependenciesByKey:t}},arrayDefinitionByKey({globalDependencyValues:e,dependencyValuesByKey:t,arrayKeys:n,arraySize:r}){let a,i={},s={},o=!1;null!==e.valignsAttr?a=e.valignsAttr.stateValues.nComponents:null!==e.valignAttr?(a=r[0],o=!0):a=0;for(let r of n){let n=Number(r);if(n0&&(l.setValue={valigns:i}),Object.keys(s).length>0&&(l.useEssentialOrDefaultValue={valigns:s}),l},inverseArrayDefinitionByKey({desiredStateVariableValues:e,dependencyNamesByKey:t,globalDependencyValues:n,arraySize:r}){let a,i=!1;null!==n.valignsAttr?a=n.valignsAttr.stateValues.nComponents:null!==n.valignAttr?(a=r[0],i=!0):a=0;let s=[];for(let n in e.valigns){let r=e.valigns[n].toLowerCase();["top","middle","bottom"].includes(r)&&(Number(n)({stringTextChildren:{dependencyType:"child",childGroups:["stringsTexts"],variableNames:["value"]},hChildren:{dependencyType:"child",childGroups:["hs"],variableNames:["value"]}}),definition({dependencyValues:e}){let t;if(e.hChildren.length>0)t=e.hChildren.map((e=>e.stateValues.value));else{let n="";for(let t of e.stringTextChildren)n+="string"==typeof t?t:t.stateValues.value;t=[n]}return{setValue:{terms:t}}}},e}}var Indexing=Object.freeze({__proto__:null,H:H$2,Idx:Idx});class Div extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="div";static rendererType="containerBlock";static renderChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}class Span extends InlineComponent{static componentType="span";static rendererType="containerInline";static renderChildren=!0;static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}}var Divisions=Object.freeze({__proto__:null,Div:Div,Span:Span});class Pre extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="pre";static renderChildren=!0;static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"allChildren",componentTypes:["_base"]}]}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}class DisplayDoenetML extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="displayDoenetML";static rendererType="text";static includeBlankStringChildren=!0;static returnChildGroups(){return[{group:"allChildren",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.value={returnDependencies:()=>({childrenDoenetML:{dependencyType:"doenetML",displayOnlyChildren:!0}}),definition:({dependencyValues:e})=>({setValue:{value:e.childrenDoenetML}})},e.text={public:!0,shadowingInstructions:{createComponentOfType:"text"},forRenderer:!0,returnDependencies:()=>({value:{dependencyType:"stateVariable",variableName:"value"}}),definition:({dependencyValues:e})=>({setValue:{text:e.value}})},e}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}var Verbatim=Object.freeze({__proto__:null,Pre:Pre,DisplayDoenetML:DisplayDoenetML});class Paginator extends BlockComponent{constructor(e){super(e),Object.assign(this.actions,{setPage:this.setPage.bind(this),recordVisibilityChange:this.recordVisibilityChange.bind(this)})}static componentType="paginator";static rendererType="containerBlock";static renderChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.initialPage={createComponentOfType:"integer",createStateVariable:"initialPage",defaultValue:1},e}static returnChildGroups(){return[{group:"anything",componentTypes:["_base"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.nPages={public:!0,shadowingInstructions:{createComponentOfType:"integer"},returnDependencies:()=>({children:{dependencyType:"child",childGroups:["anything"]}}),definition:({dependencyValues:e})=>({setValue:{nPages:e.children.length}})},e.currentPage={public:!0,shadowingInstructions:{createComponentOfType:"integer"},hasEssential:!0,returnDependencies:()=>({initialPage:{dependencyType:"stateVariable",variableName:"initialPage"},nPages:{dependencyType:"stateVariable",variableName:"nPages"}}),definition:({dependencyValues:e})=>({useEssentialOrDefaultValue:{currentPage:{get defaultValue(){let t=e.initialPage;return Number.isInteger(t)?Math.max(1,Math.min(e.nPages,t)):1}}}}),async inverseDefinition({desiredStateVariableValues:e,stateValues:t,sourceInformation:n={}}){if(!n.fromSetPage)return{success:!1};let r=Number(e.currentPage);return Number.isInteger(r)?(r=Math.max(1,Math.min(await t.nPages,r)),{success:!0,instructions:[{setEssentialValue:"currentPage",value:r}]}):{success:!1}}},e.childIndicesToRender={returnDependencies:()=>({currentPage:{dependencyType:"stateVariable",variableName:"currentPage"}}),definition:({dependencyValues:e})=>({setValue:{childIndicesToRender:[e.currentPage-1]}}),markStale:()=>({updateRenderedChildren:!0})},e}async setPage({number:e,actionId:t}){if(!Number.isInteger(e))return void this.coreFunctions.resolveAction({actionId:t});let n=Math.max(1,Math.min(await this.stateValues.nPages,e)),r=[{updateType:"updateValue",componentName:this.componentName,stateVariable:"currentPage",value:n,sourceInformation:{fromSetPage:!0}}];await this.coreFunctions.performUpdate({updateInstructions:r,actionId:t,event:{verb:"selected",object:{componentName:this.componentName,componentType:this.componentType},result:{response:n,responseText:n.toString()}}})}recordVisibilityChange({isVisible:e,actionId:t}){this.coreFunctions.requestRecordEvent({verb:"visibilityChanged",object:{componentName:this.componentName,componentType:this.componentType},result:{isVisible:e}}),this.coreFunctions.resolveAction({actionId:t})}}class PaginatorControls extends BlockComponent{constructor(e){super(e),this.externalActions={},Object.defineProperty(this.externalActions,"setPage",{enumerable:!0,get:async function(){let e=await this.stateValues.paginatorComponentName;return e?{componentName:e,actionName:"setPage"}:void 0}.bind(this)})}static componentType="paginatorControls";static renderChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.previousLabel={createComponentOfType:"text",createStateVariable:"previousLabel",defaultValue:"Previous",forRenderer:!0,public:!0},e.nextLabel={createComponentOfType:"text",createStateVariable:"nextLabel",defaultValue:"Next",forRenderer:!0,public:!0},e.pageLabel={createComponentOfType:"text",createStateVariable:"pageLabel",defaultValue:"Page",forRenderer:!0,public:!0},e.paginator={createTargetComponentNames:!0},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.paginatorComponentName={returnDependencies:()=>({paginator:{dependencyType:"attributeTargetComponentNames",attributeName:"paginator"}}),definition({dependencyValues:e}){let t;return t=1===e.paginator?.length?e.paginator[0].absoluteName:null,{setValue:{paginatorComponentName:t}}}},e.currentPage={forRenderer:!0,stateVariablesDeterminingDependencies:["paginatorComponentName"],returnDependencies:({stateValues:e})=>e.paginatorComponentName?{paginatorPage:{dependencyType:"stateVariable",componentName:e.paginatorComponentName,variableName:"currentPage"}}:{},definition:({dependencyValues:e})=>"paginatorPage"in e?{setValue:{currentPage:e.paginatorPage}}:{setValue:{currentPage:1}}},e.nPages={forRenderer:!0,stateVariablesDeterminingDependencies:["paginatorComponentName"],returnDependencies:({stateValues:e})=>e.paginatorComponentName?{paginatorNPages:{dependencyType:"stateVariable",componentName:e.paginatorComponentName,variableName:"nPages"}}:{},definition:({dependencyValues:e})=>"paginatorNPages"in e?{setValue:{nPages:e.paginatorNPages}}:{setValue:{nPages:1}}},e}}var Paginator$1=Object.freeze({__proto__:null,Paginator:Paginator,PaginatorControls:PaginatorControls});class Input extends InlineComponent{static componentType="_input";static createAttributesObject(){let e=super.createAttributesObject();return e.collaborateGroups={createComponentOfType:"collaborateGroups",createStateVariable:"collaborateGroups",defaultValue:null,public:!0},e}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.nValues={returnDependencies:()=>({}),definition:()=>({setValue:{nValues:1}})},e.answerAncestor={returnDependencies:()=>({answerAncestor:{dependencyType:"ancestor",componentType:"answer",variableNames:["delegateCheckWorkToInput","justSubmitted","creditAchieved","showCorrectness","numberOfAttemptsLeft"]}}),definition:function({dependencyValues:e}){return{setValue:{answerAncestor:e.answerAncestor}}}},e.includeCheckWork={forRenderer:!0,returnDependencies:()=>({answerAncestor:{dependencyType:"stateVariable",variableName:"answerAncestor"}}),definition:function({dependencyValues:e}){let t=!1;return e.answerAncestor&&(t=e.answerAncestor.stateValues.delegateCheckWorkToInput),{setValue:{includeCheckWork:t}}}},e.suppressCheckwork={forRenderer:!0,returnDependencies:()=>({autoSubmit:{dependencyType:"flag",flagName:"autoSubmit"}}),definition:({dependencyValues:e})=>({setValue:{suppressCheckwork:e.autoSubmit}})},e.creditAchieved={defaultValue:0,public:!0,shadowingInstructions:{createComponentOfType:"number"},forRenderer:!0,returnDependencies:()=>({answerAncestor:{dependencyType:"stateVariable",variableName:"answerAncestor"}}),definition:function({dependencyValues:e}){let t=0;return e.answerAncestor&&(t=e.answerAncestor.stateValues.creditAchieved),{setValue:{creditAchieved:t}}}},e.valueHasBeenValidated={forRenderer:!0,returnDependencies:()=>({answerAncestor:{dependencyType:"stateVariable",variableName:"answerAncestor"}}),definition:function({dependencyValues:e}){let t=!1;return e.answerAncestor&&e.answerAncestor.stateValues.justSubmitted&&(t=!0),{setValue:{valueHasBeenValidated:t}}}},e.showCorrectness={forRenderer:!0,returnDependencies:()=>({showCorrectnessFlag:{dependencyType:"flag",flagName:"showCorrectness"},answerAncestor:{dependencyType:"stateVariable",variableName:"answerAncestor"}}),definition({dependencyValues:e}){let t;return t=e.answerAncestor?e.answerAncestor.stateValues.showCorrectness:!1!==e.showCorrectnessFlag,{setValue:{showCorrectness:t}}}},e.numberOfAttemptsLeft={forRenderer:!0,returnDependencies:()=>({answerAncestor:{dependencyType:"stateVariable",variableName:"answerAncestor"}}),definition({dependencyValues:e}){let t;return t=e.answerAncestor?e.answerAncestor.stateValues.numberOfAttemptsLeft:1/0,{setValue:{numberOfAttemptsLeft:t}}}},e}}class MatrixInput extends Input{constructor(e){super(e),Object.assign(this.actions,{updateNumRows:this.updateNumRows.bind(this),updateNumColumns:this.updateNumColumns.bind(this)}),this.externalActions={},Object.defineProperty(this.externalActions,"submitAnswer",{enumerable:!0,get:async function(){let e=await this.stateValues.answerAncestor;return null!==e?{componentName:e.componentName,actionName:"submitAnswer"}:void 0}.bind(this)})}static componentType="matrixInput";static variableForPlainMacro="value";static variableForPlainCopy="value";static processWhenJustUpdatedForNewComponent=!0;static renderChildren=!0;static createAttributesObject(){let e=super.createAttributesObject();return e.numRows={createComponentOfType:"integer",createStateVariable:"numRowsPreliminary",defaultValue:1,transformNonFiniteTo:0},e.numColumns={createComponentOfType:"integer",createStateVariable:"numColumnsPreliminary",defaultValue:1,transformNonFiniteTo:0},e.showSizeControls={createComponentOfType:"boolean",createStateVariable:"showSizeControls",defaultValue:!0,public:!0,forRenderer:!0},e.defaultEntry={createComponentOfType:"math",createStateVariable:"defaultEntry",defaultValue:me$3.fromAst("_")},e.prefill={createComponentOfType:"math",createStateVariable:"prefill",defaultValue:me$3.fromAst("_"),public:!0,copyComponentAttributesForCreatedComponent:["format","functionSymbols","splitSymbols","parseScientificNotation"]},e.format={createComponentOfType:"text",createStateVariable:"format",defaultValue:"text",public:!0},e.functionSymbols={createComponentOfType:"textList",createStateVariable:"functionSymbols",defaultValue:["f","g"],public:!0},e.splitSymbols={createComponentOfType:"boolean",createStateVariable:"splitSymbols",defaultValue:!0,public:!0},e.parseScientificNotation={createComponentOfType:"boolean",createStateVariable:"parseScientificNotation",defaultValue:!1,public:!0},e.displayDigits={createComponentOfType:"integer",createStateVariable:"displayDigits",defaultValue:10,public:!0},e.displayDecimals={createComponentOfType:"integer",createStateVariable:"displayDecimals",defaultValue:null,public:!0},e.displaySmallAsZero={createComponentOfType:"number",createStateVariable:"displaySmallAsZero",valueForTrue:1e-14,valueForFalse:0,defaultValue:0,public:!0},e.bindValueTo={createComponentOfType:"math"},e.unionFromU={createComponentOfType:"boolean",createStateVariable:"unionFromU",defaultValue:!1,public:!0},e}static returnSugarInstructions(){let e=super.returnSugarInstructions();return e.push({replacementFunction:function({matchedChildren:e,componentAttributes:t}){if(e.length>0)return{success:!1};return{success:!0,newChildren:[{componentType:"matrixInputGrid"}]}}}),e}static returnChildGroups(){return[{group:"matrixComponentInputs",componentTypes:["matrixComponentInput"]}]}static returnStateVariableDefinitions(){let e=super.returnStateVariableDefinitions();return e.valueOriginal={hasEssential:!0,shadowVariable:!0,returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo",variableNames:["value"]},prefill:{dependencyType:"stateVariable",variableName:"prefill"}}),set:convertValueToMathExpression,definition:function({dependencyValues:e}){return e.bindValueTo?{setValue:{valueOriginal:e.bindValueTo.stateValues.value}}:{useEssentialOrDefaultValue:{valueOriginal:{defaultValue:e.prefill}}}},inverseDefinition:function({desiredStateVariableValues:e,dependencyValues:t}){return t.bindValueTo?{success:!0,instructions:[{setDependency:"bindValueTo",desiredValue:e.valueOriginal,variableIndex:0}]}:{success:!0,instructions:[{setEssentialValue:"valueOriginal",value:e.valueOriginal}]}}},e.immediateValueOriginal={hasEssential:!0,shadowVariable:!0,returnDependencies:()=>({valueOriginal:{dependencyType:"stateVariable",variableName:"valueOriginal"}}),set:convertValueToMathExpression,definition:function({dependencyValues:e,changes:t,justUpdatedForNewComponent:n}){return t.valueOriginal&&!n?{setValue:{immediateValueOriginal:e.valueOriginal},setEssentialValue:{immediateValueOriginal:e.valueOriginal}}:{useEssentialOrDefaultValue:{immediateValueOriginal:{defaultValue:e.valueOriginal}}}},inverseDefinition:function({desiredStateVariableValues:e,initialChange:t,shadowedVariable:n}){let r=[{setEssentialValue:"immediateValueOriginal",value:e.immediateValueOriginal}];return t||n||r.push({setDependency:"valueOriginal",desiredValue:e.immediateValueOriginal}),{success:!0,instructions:r}}},e.haveBoundValue={returnDependencies:()=>({bindValueTo:{dependencyType:"attributeComponent",attributeName:"bindValueTo"}}),definition:({dependencyValues:e})=>({setValue:{haveBoundValue:null!==e.bindValueTo}})},e.numRows={public:!0,shadowingInstructions:{createComponentOfType:"integer"},forRenderer:!0,returnDependencies:()=>({numRowsPreliminary:{dependencyType:"stateVariable",variableName:"numRowsPreliminary"},valueOriginal:{dependencyType:"stateVariable",variableName:"valueOriginal"},haveBoundValue:{dependencyType:"stateVariable",variableName:"haveBoundValue"}}),definition({dependencyValues:e,usedDefault:t}){let n=e.numRowsPreliminary;if(t.numRowsPreliminary||e.haveBoundValue){let t=e.valueOriginal.tree;if(n=1,Array.isArray(t)){let e=t[0];"matrix"===e?n=t[1][1]:vectorOperators.includes(e)&&(n=t.length-1)}}return{setValue:{numRows:n}}},async inverseDefinition({desiredStateVariableValues:e,dependencyValues:t,stateValues:n}){let r=e.numRows;if(!Number.isInteger(r))return{success:!1};r=Math.max(0,r);let a=[{setDependency:"numRowsPreliminary",desiredValue:r}];if(t.haveBoundValue){let e=t.valueOriginal.tree,i=(await n.defaultEntry).tree;if(1===await n.numColumns&&Array.isArray(e)&&vectorOperators.includes(e[0])){let t=e.length-1;if(rt){let s=deepClone(e),o=await n.accumulatedComponents;for(let e=t;e({numColumnsPreliminary:{dependencyType:"stateVariable",variableName:"numColumnsPreliminary"},valueOriginal:{dependencyType:"stateVariable",variableName:"valueOriginal"},haveBoundValue:{dependencyType:"stateVariable",variableName:"haveBoundValue"}}),definition({dependencyValues:e,usedDefault:t}){let n=e.numColumnsPreliminary;if(t.numColumnsPreliminary||e.haveBoundValue){let t=e.valueOriginal.tree;if(n=1,Array.isArray(t)){let e=t[0];"matrix"===e?n=t[1][2]:Array.isArray(t[1])&&vectorOperators.includes(t[1][0])&&("^"===e&&"T"===t[2]||"prime"===e)&&(n=t[1].length-1)}}return{setValue:{numColumns:n}}},async inverseDefinition({desiredStateVariableValues:e,dependencyValues:t,stateValues:n}){let r=e.numColumns;if(!Number.isInteger(r))return{success:!1};r=Math.max(0,r);let a=[{setDependency:"numColumnsPreliminary",desiredValue:r}];if(t.haveBoundValue){let e=(await n.defaultEntry).tree,i=t.valueOriginal.tree,s=i[0];if(Array.isArray(i[1])&&vectorOperators.includes(i[1][0])&&("^"===s&&"T"===i[2]||"prime"===s)){let t=i[1].length-1;if(rt){let s=deepClone(i),o=(await n.accumulatedComponents)[0];o||(o=[]);for(let n=t;n({valueOriginal:{dependencyType:"stateVariable",variableName:"valueOriginal"}}),definition({dependencyValues:e,previousValues:t}){let n=[];t.accumulatedComponents&&(n=deepClone(t.accumulatedComponents));let r=e.valueOriginal.tree;if(Array.isArray(r)){let e=r[0];if("matrix"===e){let e=r[2];for(let[t,r]of e.slice(1).entries()){let e=n[t];e||(e=n[t]=[]);for(let[t,n]of r.slice(1).entries())e[t]=n}return{setValue:{accumulatedComponents:n}}}if(vectorOperators.includes(e)){for(let[e,t]of r.slice(1).entries()){let r=n[e];r||(r=n[e]=[]),r[0]=t}return{setValue:{accumulatedComponents:n}}}if(Array.isArray(r[1])&&vectorOperators.includes(r[1][0])&&("^"===e&&"T"===r[2]||"prime"===e)){let e=n[0];e||(e=n[0]=[]);for(let[t,n]of r[1].slice(1).entries())e[t]=n;return{setValue:{accumulatedComponents:n}}}}let a=n[0];return a||(a=n[0]=[]),a[0]=r,{setValue:{accumulatedComponents:n}}}},e.componentValues={isArray:!0,entryPrefixes:["componentValue"],nDimensions:2,returnArraySizeDependencies:()=>({numRows:{dependencyType:"stateVariable",variableName:"numRows"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"}}),returnArraySize:({dependencyValues:e})=>[e.numRows,e.numColumns],returnArrayDependenciesByKey:()=>({globalDependencies:{valueOriginal:{dependencyType:"stateVariable",variableName:"valueOriginal"},numRows:{dependencyType:"stateVariable",variableName:"numRows"},numColumns:{dependencyType:"stateVariable",variableName:"numColumns"},accumulatedComponents:{dependencyType:"stateVariable",variableName:"accumulatedComponents"},defaultEntry:{dependencyType:"stateVariable",variableName:"defaultEntry"}}}),arrayDefinitionByKey({globalDependencyValues:e,arrayKeys:t}){let n=e.valueOriginal.tree,r=e.accumulatedComponents,a=e.numRows,i=e.numColumns;if(Array.isArray(n)){let t=n[0];if("matrix"===t){if(n[1][1]===a&&n[1][2]===i){let e={},t=n[2];for(let n=0;ns)for(let t=0;tt)for(let n=t;n[...e]));else{let e=t.valueOriginal.tree;if(o){if(a=e.slice(1,1+i).map((e=>[e])),a.length