\":u.Greater([p,f]);break;case\"<=\":u.LessEqual([p,f]);break;case\">=\":u.GreaterEqual([p,f]);break;case\"=\":u.Equal([p,f]);break}if(u.fuseBroadcast(),u.isConstant())return new pn(u);let g=u.getInstruction(p).type!==2||Nc(t,i.args[1]).indexOf(u.argNames[p])!==-1;if(!rs.plotImplicits&&g)throw IP();return Rr[c].direction===-1?u.Subtract([f,p]):u.Subtract([p,f]),u.fuseBroadcast(),tA({policy:e,ctx:a,isInequality:l,allowSolvingIn3D:!1,maybeBaseCase:r},u)}function tA({policy:e,ctx:t,isInequality:n,allowSolvingIn3D:r,maybeBaseCase:i},s){let o=s.getLiveArgNames();if(o.length===0)throw J(`Unexpected: non-constant node with dependencies: ${o}`);if(o.length===1&&!n&&!rs.plotSingleVariableImplicitEquations)return TP();let a=g=>g===\"x\"||g===\"y\"||g===\"z\";if(e.is3dPolicy()?!o.every(a):o.length>2)return tn(e.sliderVariables(o)).setDependencies(o);if(n&&!e.validInequalityVariables(o))return xP().setDependencies(o);let{localFrames:u,effectiveOrder:c,variableOfInterest:l}=_k(t,n);if(e.complicatedPolarImplicit(l,c))return EP().setDependencies(o);if(!e.validImplicitVariables(o)){let g=rc();return i&&(g.silent=!0),g}if(e.is3dPolicy()&&r&&c!==1)return Bo();if(c>2||e.is3dPolicy()&&!r)return new pn(s);let p=[],f=[],m=1;for(let g=0;g1&&!r.validSolvedVariable(u);o[a]={localFrames:[],effectiveOrder:0,variableOfInterest:u};let l=!t;if(c){o[a].effectiveOrder=1/0;continue}let p=s?n.getConstantListLength():1;if(p==null)throw new Error(\"Programming error: cannot solve a variable-length list expression\");for(let f=0;f2){o[a].effectiveOrder=1/0;continue e}let d=m.getPolynomialCoefficients(u);o[a].localFrames.push(d),o[a].effectiveOrder=Math.max(o[a].effectiveOrder,d.coefficients.length-1)}}if(i.length===1)return o[0];if(i.length===2&&!i.includes(\"z\"))return i[0]===\"y\"&&(o=[o[1],o[0]]),o[0].effectiveOrder===0?o[1]:o[1].effectiveOrder===0?o[0]:o[o[0].effectiveOrderc.effectiveOrder===1);if(a.length>0)return a[0];let u=o.filter(c=>c.effectiveOrder===2);return u.length>0?u[0]:o[0]}}function Lk(e,t){return t?Fk(e):wk(e)}function wk({chunk:e,coefficients:t}){let[n,r,i]=t,s=e.Constant(De(0,1)),o=e.Constant(NaN);if(i===void 0){r===void 0&&(r=s);let a=e.Negative([e.Divide([n,r])]),u=e.Equal([r,s]);return[e.Piecewise([u,o,a])]}else{let a=e.Constant(De(2,1)),u=e.Multiply([a,i]),c=e.Negative([r]),l=e.Subtract([e.Multiply([r,r]),e.Multiply([a,e.Multiply([u,n])])]),p=e.Equal([i,s]),f=e.getInstruction(l);if(f.type===1&&q(f.value)===0)return[e.Piecewise([p,o,e.Divide([c,u])])];{let m=e.SyntheticNativeFunction(\"sqrt\",[l]),g=e.Less([r,s]),d=e.Greater([r,s]),y=e.Divide([e.Add([c,m]),u]),h=e.Divide([e.Subtract([c,m]),u]),b=e.Negative([e.Divide([n,r])]);return[e.Piecewise([p,e.Piecewise([g,b,o]),h]),e.Piecewise([p,e.Piecewise([d,b,o]),y])]}}}function Fk({chunk:e,coefficients:t}){let[n,r,i]=t,s=e.Constant(De(0,1));i===void 0&&(i=s),r===void 0&&(r=s),n===void 0&&(n=s);let o=e.Constant(De(2,1)),a=e.Constant(NaN),u=e.Constant(De(1e305,1)),c=e.Negative([u]),l=e.Multiply([o,i]),p=e.Negative([r]),f=e.Subtract([e.Multiply([r,r]),e.Multiply([o,e.Multiply([l,n])])]),m=e.SyntheticNativeFunction(\"sqrt\",[f]),g=e.Divide([e.Add([p,m]),l]),d=e.Divide([e.Subtract([p,m]),l]),y=e.Negative([e.Divide([n,r])]),h=e.Equal([i,s]),b=e.Greater([i,s]),x=e.Equal([r,s]),P=e.Greater([r,s]),M=e.Less([r,s]),I=e.Greater([n,s]),E=e.Less([f,s]);return[e.Piecewise([h,e.Piecewise([M,y,a]),e.Piecewise([b,d,a])]),e.Piecewise([h,e.Piecewise([x,e.Piecewise([I,c,a]),a]),e.Piecewise([b,e.Piecewise([E,c,a]),g])]),e.Piecewise([h,e.Piecewise([x,e.Piecewise([I,u,a]),a]),e.Piecewise([b,e.Piecewise([E,u,a]),d])]),e.Piecewise([h,e.Piecewise([P,y,a]),e.Piecewise([b,g,a])])]}var{abs:Au,min:X0,max:Z0}=Math;function W0(e,t){let{xmin:n,xmax:r,ymin:i,ymax:s,zmin:o,zmax:a}=t,u=[[n,i,a],[n,s,a],[r,s,a],[r,i,a],[n,i,o],[n,s,o],[r,s,o],[r,i,o]],c=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],l=[];for(let[v,O]of c){let A=u[v],N=u[O],L=e(...A),z=e(...N),G=L/(L-z);0<=G&&G<=1&&l.push(gs(A,N,G))}if(l.length<3)return;let p=X0(...l.map(v=>v[0])),f=Z0(...l.map(v=>v[0])),m=X0(...l.map(v=>v[1])),g=Z0(...l.map(v=>v[1])),d=X0(...l.map(v=>v[2])),y=Z0(...l.map(v=>v[2])),h=e(n,i,o),b=(e(r,i,o)-h)/(r-n),x=(e(n,s,o)-h)/(s-i),P=(e(n,i,a)-h)/(a-o),M,I,E;return Au(P)>=Au(b)&&Au(P)>=Au(x)?(M=(v,O)=>[v,O,o-(h+b*(v-n)+x*(O-i))/P],I=new ee(p,f),E=new ee(m,g)):Au(x)>=Au(P)&&Au(x)>=Au(b)?(M=(v,O)=>[v,i-(h+b*(v-n)+P*(O-o))/x,O],I=new ee(p,f),E=new ee(d,y)):(M=(v,O)=>[n-(h+x*(v-i)+P*(O-o))/b,v,O],I=new ee(m,g),E=new ee(d,y)),{explicitPlane:M,u:I,v:E}}function yh(e,t){let n=[],r=[],i=[],s=[],o=W0(e,t);if(o){let{explicitPlane:a,u,v:c}=o;n.push(...a(u.min,c.min),...a(u.max,c.min),...a(u.min,c.max),...a(u.max,c.max));let l=new Qe(n[0],n[1],n[2]),p=new Qe(n[3],n[4],n[5]),f=new Qe(n[6],n[7],n[8]),m=new Qe().subVectors(f,l),g=new Qe().subVectors(l,p),d=m.cross(g).normalize();r.push(d.x,d.y,d.z,d.x,d.y,d.z,d.x,d.y,d.z,d.x,d.y,d.z),i.push(0,0,0,1,1,0,1,1),s.push(0,1,2,3,2,1)}return{positions:n,normals:r,faces:s,uvs:i,resolved:!0,extraAttrs:[]}}var Bk=!1,Nu=256,bh=D.List;function dr(){return{}}function Uc(e,t,n){let r=1/0;for(let s of t){let o=e[s];Array.isArray(o)&&o.length{let b=Uc(this.metaData,Object.keys(y).map(P=>l[P]),s),x=[];return bh.wrap(t).eachElement((P,M)=>{if(M>=b)return;let I=this.getGraphInfo(e,P);I.graphMode=r.graphMode;let E=_u(this,M,s);I.listIndex=E.listIndex,I.style=E.style,\"lineWidth\"in y&&(I.lineWidth=E.lineWidth),\"lineOpacity\"in y&&(I.lineOpacity=E.lineOpacity),\"fillOpacity\"in y&&(I.fillOpacity=E.fillOpacity),\"color\"in y&&(I.color=a(this.userData,E.color)),\"resolution\"in y&&(I.resolution=E.resolution),x.push(...h(P,I))}),x},f=r.graphMode;switch(f){case 4:{let{points:b,droppedIndices:x}=yd([t.asValue()]),P=this.userData.shouldGraph&&c.points,M=this.userData.showLabel&&!P;return P?[{segments:[b],graphMode:f,droppedIndices:x,color:sa(this.userData,this.metaData),style:this.userData.pointStyle,showLabel:!!this.userData.showLabel,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,pointOpacity:this.metaData.computedPointOpacity,pointSize:this.metaData.computedMovablePointSize,suppressTextOutline:this.userData.suppressTextOutline,editableLabel:o(this.userData),labels:this.computedLabels||[],poi:Us(b),movablePointInfo:[]}]:M?[{segments:[b],graphMode:3,color:sa(this.userData,this.metaData),style:this.userData.pointStyle,showLabel:!!this.userData.showLabel,nakedLabel:!0,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,pointOpacity:this.metaData.computedPointOpacity,suppressTextOutline:this.userData.suppressTextOutline,editableLabel:o(this.userData),labels:this.computedLabels||[],poi:Us(b),showPoint:!1}]:[]}case 3:{let b=[],x=this.userData.shouldGraph&&c.points,P=this.userData.shouldGraph&&c.lines,M=[\"colorLatexValue\"];x&&M.push(\"computedPointOpacity\",\"computedPointSize\"),(this.userData.showLabel||x)&&M.push(\"computedLabelSize\",\"computedLabelAngle\");let I=Uc(this.metaData,M,s),E=bh.wrap(t).asValue();Xr(E),E.length>I&&(E.length=I);let v=this.userData.showLabel&&!x&&!P,O=yd(E);if(this.userData.showLabel||x){let A={segments:[O.points],graphMode:f,droppedIndices:O.droppedIndices,color:this.metaData.colorLatexValue||this.userData.color,style:this.userData.pointStyle,showLabel:!!this.userData.showLabel,showPoint:x,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,pointSize:this.metaData.computedPointSize,pointOpacity:this.metaData.computedPointOpacity,suppressTextOutline:this.userData.suppressTextOutline,interactiveLabel:!!this.userData.interactiveLabel,editableLabel:o(this.userData),nakedLabel:v,labels:this.computedLabels||[],poi:Us(E)};e.is3dPolicy()?b.push(...Xk(A)):b.push(A)}if(P){let A=this.metaData.computedLineWidth,N={segments:aA(E),graphMode:5,color:sa(this.userData,this.metaData),style:this.userData.lineStyle,lineWidth:A,lineOpacity:this.metaData.computedLineOpacity,poi:dr()};b.push(rA(e,N,n,A))}return b}case 114:case 115:case 116:{let b=[],x=this.userData.shouldGraph&&c.points,P=this.userData.shouldGraph&&c.lines,M=[\"colorLatexValue\"];x&&M.push(\"computedPointOpacity\",\"computedPointSize\");let I=bh.wrap(t).asValue();Xr(I);let{degreeMode:E}=n,v=I.map(N=>SN(f,N,E)),O=Uc(this.metaData,M,s),A=Math.min(v.length,O);if(x)for(let N=0;N{if(L.set(Y,de,re),z.set(ie,Z,Re),G.set(Ne,Te,Me),!L.isFinite()||!z.isFinite()||!G.isFinite())return;let ve=P.length/3;P.push(L.x,L.y,L.z,z.x,z.y,z.z,G.x,G.y,G.z),O.subVectors(L,G),A.subVectors(z,L),N.crossVectors(O,A),M.push(N.x,N.y,N.z,N.x,N.y,N.z,N.x,N.y,N.z),I.push(ve,ve+1,ve+2),E.push(0,0,0,1,1,0)},w=()=>{let Y={guid:fi(),resolved:!0,positions:new Float32Array(P),normals:new Float32Array(M),faces:new Uint32Array(I),uvs:new Float32Array(E),extraAttrs:new Float32Array([])};return v.length&&(Y.colors=new Float32Array(v)),Y};if(t.valueType===tr&&!Array.isArray(x)){let Y=this.metaData.computedFillOpacity,de=\"\";if(b){let re=(m=this.metaData.colorLatexValue)!=null?m:this.userData.color;de=a(this.userData,re)}return p({color:!0},(re,ie)=>{if(re.valueType===In){let[[Z,Re,Ne],[Te,Me,ve],[Q,U,xe]]=re.asValue();if($(Z,Re,Ne,Te,Me,ve,Q,U,xe),!b){let[le,K,_e]=G0(ie.color);v.push(le,K,_e,le,K,_e,le,K,_e)}}return[]}),[{meshData:w(),color:de,fillOpacity:Y!=null?Y:1,graphMode:117}]}return p({color:!0,fillOpacity:!0},(Y,de)=>{var U;let[[re,ie,Z],[Re,Ne,Te],[Me,ve,Q]]=Y.asValue();return P=[],M=[],I=[],E=[],$(re,ie,Z,Re,Ne,Te,Me,ve,Q),[{meshData:w(),color:a(this.userData,de.color),fillOpacity:(U=de.fillOpacity)!=null?U:1,graphMode:117}]})}case 119:{let b=this.metaData.colorLatexValue?!Array.isArray(this.metaData.colorLatexValue):!0;if(t.valueType===er&&b&&!Array.isArray(this.metaData.computedLineWidth)){let x=(g=this.metaData.colorLatexValue)!=null?g:this.userData.color,P=this.metaData.computedLineWidth,M=[];return p({color:!0},I=>{if(I.valueType===Nt){let[[E,v,O],[A,N,L]]=I.asValue();M.push(E,v,O,A,N,L,NaN,NaN,NaN)}return[]}),[{graphMode:119,guid:fi(),points:M,color:x,thickness:P!=null?P:1}]}return p({color:!0,lineWidth:!0},(x,P)=>{let{lineWidth:M,color:I}=P,E=x.asValue(),[[v,O,A],[N,L,z]]=E;return uA(v,O,A,N,L,z)?[]:[{graphMode:119,guid:fi(),points:[v,O,A,N,L,z],color:I,thickness:M}]})}case 129:let y=this.metaData.colorLatexValue?!Array.isArray(this.metaData.colorLatexValue):!0;if(t.valueType===nr&&y&&!Array.isArray(this.metaData.computedLineWidth)){let b=(d=this.metaData.colorLatexValue)!=null?d:this.userData.color,x=this.metaData.computedLineWidth,P=[];return p({color:!0},M=>{if(M.valueType===Se){let[[I,E,v],[O,A,N]]=M.asValue();P.push(O,A,N,I+O,E+A,v+N)}return[]}),[{graphMode:129,guid:fi(),points:P,color:b,thickness:x!=null?x:1}]}return p({color:!0,lineWidth:!0},(b,x)=>{let{lineWidth:P,color:M}=x,I=b.asValue(),[[E,v,O],[A,N,L]]=I;return uA(E,v,O,A,N,L)?[]:[{graphMode:129,guid:fi(),points:[A,N,L,E+A,v+N,O+L],color:M,thickness:P}]});case 118:return p({color:!0,resolution:!0,fillOpacity:!0},(b,x)=>{let{color:P,fillOpacity:M}=x,I=b.asValue(),[[E,v,O],A]=I,N=Math.abs(A);return isNaN(E)||isNaN(v)||isNaN(O)||isNaN(A)?[]:[{graphMode:118,position:[E,v,O],radius:[N,N,N],guid:fi(),color:P,fillOpacity:M!=null?M:1}]});case 5:case 100:case 101:case 102:{let b=this.userData,x=this.metaData,P=[],M=p({color:!0,lineOpacity:!0,lineWidth:!0,resolution:!0},(E,v)=>{var A;let O=E.getDependencies();if(O.length===0&&!ca(E.valueType)){let{points:N,droppedIndices:L}=yd([E.asValue()]);return[{segments:[N],graphMode:3,droppedIndices:L,color:sa(b,x),style:b.lineStyle,showPoint:!1,poi:Us(N)}]}else{let N=E.getCompiledFunction(O);v.domain=(A=N.domain)!=null?A:{type:\"1d\",min:this.metaData.evaluatedDomainMin,max:this.metaData.evaluatedDomainMax};let L=_a({viewState:n,graphInfo:v,compiled:N});return[rA(e,L,n,v.lineWidth)]}}),I=[];for(let E of M)E&&I.push(E);if(c.fill)if(I.forEach((E,v)=>{let{color:O,fillOpacity:A,listIndex:N}=_u(this,v,s);P.push({segments:E.segments,color:O,fillOpacity:A,listIndex:N,graphMode:7,poi:dr()})}),c.lines)I=I.concat(P);else return P;return I}case 20:return p({lineOpacity:!0,lineWidth:!0,color:!0},(b,x)=>{let[[P,M],I]=b.asValue();return isNaN(P)||isNaN(M)||isNaN(I)?[]:[{segments:[[P,M,I]],resolved:!0,graphMode:x.graphMode,color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:x.operator,poi:dr()}]});case 21:return p({color:!0,lineWidth:!0,lineOpacity:!0},(b,x)=>{let P=By(b.asValue());if(!P)return[];let M=[];return P.type===\"arc\"?M.push({graphMode:f,segments:[[P.center[0],P.center[1],P.radius,P.startAngle,P.endAngle]],color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()}):P.type===\"rays\"?M.push({graphMode:19,segments:[[P.start1[0],P.start1[1],P.end1[0],P.end1[1]]],color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()},{graphMode:19,segments:[[P.start2[0],P.start2[1],P.end2[0],P.end2[1]]],color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()}):M.push({graphMode:17,segments:[[P.start[0],P.start[1],P.end[0],P.end[1]]],color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()}),[...M,...sA(M,i)]});case 17:case 18:case 19:return p({color:!0,lineWidth:!0,lineOpacity:!0},(b,x)=>{let[[P,M],[I,E]]=b.asValue();if(isNaN(P)||isNaN(M)||isNaN(I)||isNaN(E))return[];let v=[],O={segments:[[P,M,I,E]],resolved:!0,graphMode:x.graphMode,color:x.color,style:x.lineStyle,arrowMode:x.arrowMode,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()};if(v.push(iA(e,O,n)),v.push(...sA([O],i)),this.userData.showLabel&&r.graphMode===17){let A=x.listIndex,N=this.computedLabels&&this.computedLabels[A||0];v.push({graphMode:22,objectType:17,segments:[[P,M,I,E]],color:x.color,listIndex:A,showLabel:!0,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,labels:N?[N]:[Gk(as(I-P,E-M),n)]})}return v});case 24:return p({lineOpacity:!0,lineWidth:!0,color:!0},(b,x)=>{let[P,M]=b.asValue(),[[I,E],[v,O]]=[M,[M[0]+P[0],M[1]+P[1]]];if(isNaN(v)||isNaN(O)||isNaN(I)||isNaN(E))return[];let A={segments:[[I,E,v,O]],resolved:!0,graphMode:x.graphMode,color:x.color,style:x.lineStyle,arrowMode:x.arrowMode,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:x.listIndex,operator:r.operator,poi:dr()};return[iA(e,A,n)]});case 23:return p({lineOpacity:!0,lineWidth:!0,color:!0},(b,x)=>{let{value:P,valueType:M}=b.asTypedValue(),[[I,E],v,O]=P;if(isNaN(I)||isNaN(E)||isNaN(v)||isNaN(O))return[];let A=x.listIndex,N=M===Ae,L=N?O:Math.abs(O),z=[];if(z.push({graphMode:23,segments:[[I,E,v,O,N?1:0]],color:x.color,style:x.lineStyle,lineWidth:x.lineWidth,lineOpacity:x.lineOpacity,listIndex:A,operator:r.operator,poi:dr()}),this.userData.showAngleLabel){let G=this.computedLabels&&this.computedLabels[A||0];z.push({graphMode:22,objectType:23,segments:[[I,E,v,O]],color:x.color,listIndex:A,showLabel:!0,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,labels:G?[G]:[zk(L,n)]})}return z});case 1:case 2:case 8:case 112:case 126:case 113:case 127:case 6:case 130:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 120:case 121:case 122:case 123:case 124:{let b=t.valueType===T;return p({lineOpacity:!0,lineWidth:!0,resolution:!0,fillOpacity:!0,color:!0},(x,P)=>{var w,Y,de,re,ie,Z,Re,Ne,Te,Me,ve;(r.graphMode===6||r.graphMode===110||r.graphMode===124)&&(P.domain={type:\"1d\",min:this.metaData.evaluatedDomainMin,max:this.metaData.evaluatedDomainMax,isExplicit:this.metaData.isExplicitDomain});let M=(w=ss[r.graphMode])!=null?w:[],I=x.getCompiledFunction(M);(r.graphMode==130||r.graphMode==103||r.graphMode==104||r.graphMode==105||r.graphMode==111||r.graphMode==109)&&(P.domain=(Y=I.domain)!=null?Y:{type:\"2d\",uMin:this.metaData.evaluatedDomain3DMin1,uMax:this.metaData.evaluatedDomain3DMax1,vMin:this.metaData.evaluatedDomain3DMin2,vMax:this.metaData.evaluatedDomain3DMax2});let E=[],v;try{v=x.getCompiledDerivative()}catch(Q){}let O=$k(this,x,I,n,P,v,b);if(O)return O;let A=YE(P.graphMode),N=(de=this.userData.extendTo3D)!=null?de:!1,L=A&&!N,z=!e.is3dPolicy()||L,G=(re=this.userData.lines)!=null?re:z,$=(ie=this.userData.lines)!=null?ie:!L;if(P.graphMode===127&&!N&&((Z=this.userData.lines)==null||Z)){let Q=(Re=ss[P.graphMode])!=null?Re:[],U=x._chunk.copy();U.GreaterEqual([U.getReturnIndex(),U.Constant(0)]);let xe=x.getCompiledFunction(Q),le=0,K=n.viewport,{xmin:_e,xmax:Ze,ymin:me,ymax:te}=K,pt=new ee(_e,Ze),Ro=new ee(me,te),ku=yh((Cd,Ah,_h)=>_h-le,K);return[{meshData:qi(ku),color:P.color,fillOpacity:(Ne=P.fillOpacity)!=null?Ne:1,uvRange:[pt,Ro],uvArgs:(Te=ss[P.graphMode])!=null?Te:[],extraMeshArgs:(Me=Vc[P.graphMode])!=null?Me:[],graphMode:106,compiled:xe,restrictionShader:Wo(U,Nu)}]}if(A&&(this.userData.lines===!0?(G=L,$=!L):this.userData.lines===!1&&(G=!1,$=!1)),$&&ea(P.graphMode)){let Q=mh(P.graphMode);if(P.graphMode===113||P.graphMode===127){let{positions:U,normals:xe,faces:le,uvs:K}=QN(),_e={guid:fi(),isDomainCube:!0,resolved:!0,positions:U,normals:xe,faces:le,uvs:K,extraAttrs:new Float32Array([])},Ze=x.toImplicitBool();E.push({meshData:_e,graphMode:113,color:P.color,fillOpacity:1,uvRange:[new ee(0,1),new ee(0,1)],uvArgs:[],extraMeshArgs:[],compiled:I,restrictionShader:Wo(Ze._chunk,Nu)});let me=cR(Ze._chunk,x._chunk,Q);for(let te of me){let pt=nA(P,{concrete:new pn(te.value),restriction:te.restriction&&Wo(te.restriction,Nu)},n);E.push(pt)}}else{let U=x.getRestrictedFunctionForGLSL(Q,Nu),xe=nA(P,U,n);E.push(xe)}}if(G&&Uk(this,P),!ea(P.graphMode)){let Q=_a({viewState:n,graphInfo:P,compiled:I,derivative:v}),U=dA(Aa(this),x);if(U&&(Q.boundingBox=U),e.is3dPolicy()&&G&&Q0(Q.graphMode)){let xe=(ve=P.lineWidth)!=null?ve:1;E.push(oh(Q,n,xe))}else if(Q.fillSegments){let{fillSegments:xe,...le}=Q;G||(le.lineWidth=0),E.push(le)}else G||(Q.lineWidth=0),(G||!ea(r.graphMode))&&E.push(Q);P.graphMode===8&&P.operator!==\"=\"&&E.push({graphMode:7,segments:Q.fillSegments,poi:dr(),listIndex:P.listIndex,color:P.color,fillOpacity:P.fillOpacity})}return E})}case 200:case 201:case 202:case 206:case 205:case 211:case 203:case 204:case 213:case 207:case 208:case 212:case 214:case 215:case 209:return p({color:!0,lineWidth:!0,lineOpacity:!0,resolution:!0},(b,x)=>{var w;switch(f){case 206:case 211:x.domain={type:\"1d\",min:this.metaData.evaluatedDomainMin,max:this.metaData.evaluatedDomainMax,isExplicit:this.metaData.isExplicitDomain};break;case 203:case 204:case 213:case 207:case 208:case 212:case 214:case 215:x.domain={type:\"2d\",uMin:this.metaData.evaluatedDomain3DMin1,uMax:this.metaData.evaluatedDomain3DMax1,vMin:this.metaData.evaluatedDomain3DMin2,vMax:this.metaData.evaluatedDomain3DMax2};break}let P=(w=ss[f])!=null?w:[],M={allowSlices:!0},I=Ra(b._chunk,P,M),{valueChunk:E,slices:v}=I.getValueAndRestrictionChunk(),O=E.getCompiledFunction(P),A=v[0],N=A.type===\"implicit\",L=N?NaN:A.value,z=N?\"_implicit\":A.variable,G,$=Y=>_a({viewState:n,graphInfo:{...x,slice_coordinate:z,slice_value:L,slice_function:Y},compiled:O});if(N){let Y=[\"x\",\"y\",\"z\"],de=[\"x\",\"y\",\"z\",\"r\",\"theta\"],re=[\"x\",\"y\",\"z\",\"rho\",\"theta\",\"phi\"],ie=[\"x\",\"y\",\"z\",\"u\",\"v\"],Z=A.sliceChunk;switch(f){case 200:case 201:case 202:G=Z.getCompiledFunction(Y);break;case 211:case 213:G=Z.getCompiledFunction(de);break;case 212:G=Z.getCompiledFunction(re);break;case 215:case 214:G=Z.getCompiledFunction(ie);break;case 209:{let Re=(Me,ve)=>{let Q=ve.getCompiledFunction(Y),U=Me._symbol,xe=Me._expression.args,le=[];for(let K of xe){if(!(K instanceof pn))throw J(\"Programming Error: bad type\");if(U===\"x\")O=K._chunk.getCompiledFunction([\"y\",\"z\"]),x.graphMode=201;else if(U===\"y\")O=K._chunk.getCompiledFunction([\"x\",\"z\"]),x.graphMode=202;else if(U===\"z\")O=K._chunk.getCompiledFunction([\"x\",\"y\"]),x.graphMode=200;else throw J(\"Programming Error: bad lhs\");le.push($(Q))}return le},Ne=(Me,ve)=>{let Q=n.viewport,U=ve.getCompiledFunction(Y),xe=Me.getCompiledFunction(Y).fn,le=W0(xe,Q);if(le){let{explicitPlane:K,u:_e,v:Ze}=le;return x.graphMode=214,O={args:[\"u\",\"v\"],source:\"\",constants:[],fn:K,executionMetadata:{}},x.domain={type:\"2d\",uMin:_e.min,uMax:_e.max,vMin:Ze.min,vMax:Ze.max},[$(U)]}else return[]};if(Z.isImplicitPlane())return Ne(Z,E);if(E.isImplicitPlane())return Ne(E,Z);let Te=Y0(e,E);return Te instanceof D.SolvedEquation&&!Te.isError?Re(Te,Z):(Te=Y0(e,Z),Te instanceof D.SolvedEquation&&!Te.isError?Re(Te,E):[$(Z.getCompiledFunction(Y))])}}}return[$(G)]});case 210:return p({color:!0,fillOpacity:!0,resolution:!0},(b,x)=>{var Me,ve,Q,U,xe,le,K,_e;let P=(Me=ss[f])!=null?Me:[],M={allowSlices:!0},I=Ra(b._chunk,P,M),{restrictionChunk:E,slices:v}=I.getSlicesAndRestrictionChunk(),O=E.getCompiledFunction(P);if(v[0].type===\"implicit\"){let Ze=v[0].sliceChunk,me;try{me=Ze.copy().gradient([\"x\",\"y\",\"z\"]).getCompiledFunction([\"x\",\"y\",\"z\"]).fn}catch(_h){}let te=(ve=x.resolution)!=null?ve:NaN;isNaN(te)&&(te=dd),te=rr(te,0,100);let pt=_0(Ze.getCompiledFunction(P),void 0,me,n.viewport,te,{isInequality:!1}),{xmin:Ro,xmax:Ba,ymin:ku,ymax:$c}=n.viewport,Od=new ee(Ro,Ba),Cd=new ee(ku,$c);return[{meshData:pt,color:x.color,fillOpacity:(Q=x.fillOpacity)!=null?Q:1,uvRange:[Od,Cd],uvArgs:(U=ss[x.graphMode])!=null?U:[],extraMeshArgs:(xe=Vc[x.graphMode])!=null?xe:[],graphMode:f,compiled:O,restrictionShader:Wo(E,Nu)}]}let A=v[0].value,N=v[0].variable,L=n.viewport,{xmin:z,xmax:G,ymin:$,ymax:w,zmin:Y,zmax:de}=L,re,ie,Z;switch(N){case\"x\":re=new ee($,w),ie=new ee(Y,de),Z=(Ze,me,te)=>Ze-A;break;case\"y\":re=new ee(z,G),ie=new ee(Y,de),Z=(Ze,me,te)=>me-A;break;case\"z\":re=new ee(z,G),ie=new ee($,w),Z=(Ze,me,te)=>te-A;break;default:return[]}let Re=yh(Z,L);return[{meshData:qi(Re),color:x.color,fillOpacity:(le=x.fillOpacity)!=null?le:1,uvRange:[re,ie],uvArgs:(K=ss[x.graphMode])!=null?K:[],extraMeshArgs:(_e=Vc[x.graphMode])!=null?_e:[],graphMode:f,compiled:O,restrictionShader:Wo(E,Nu)}]});case 16:{let b=[],x=this.userData.lines===void 0?!0:this.userData.lines,P=this.userData.fill===void 0?!0:this.userData.fill;if(!P&&!x)return b;let M=Uc(this.metaData,[\"computedLineOpacity\",\"computedLineWidth\",\"colorLatexValue\",\"fillOpacity\"],s),I=t.asValue();W(t.valueType)||(I=[I]);for(let E=0;EM-1)continue;let v=I[E];if(!v.length)continue;let O=this.getGraphInfo(e,t),{listIndex:A,lineWidth:N,lineOpacity:L,fillOpacity:z,color:G}=_u(this,E,s);this.userData.shouldOmitLastPolygonSegment||(v=[...v,v[0]]),Xr(v);let $=aA(v);if($.length&&(P&&b.push({segments:$,graphMode:7,poi:dr(),color:G,fillOpacity:z,style:O.style,listIndex:A}),x&&b.push({segments:$,graphMode:5,poi:dr(),color:G,style:this.userData.lineStyle,lineWidth:N,lineOpacity:L,listIndex:A}),Bk&&this.userData.showLabel)){let w=this.computedLabels&&this.computedLabels[A||0];b.push({graphMode:22,objectType:16,segments:$,color:G,listIndex:A,showLabel:!0,labelSize:this.metaData.computedLabelSize,labelAngle:this.metaData.computedLabelAngle,labelOrientation:this.userData.labelOrientation,labels:w?[w]:[kk(mI(v),n)]})}}return b}case 7:case 11:case 10:case 15:case 22:case 128:return!1;default:let h=f;throw new Error(`Unexpected graphMode: ${h}`)}}function nA(e,t,n){var c,l,p;let r=(c=ss[e.graphMode])!=null?c:[],i=t.concrete.getCompiledFunction(r),s,o,a=!1;if(e.graphMode===112||e.graphMode===126||e.graphMode===113){e.operator!==\"=\"&&(a=!0);try{s=t.concrete.gradient([\"x\",\"y\",\"z\"])._chunk,o=s.getCompiledFunction([\"x\",\"y\",\"z\"]).fn}catch(f){}}if(e.graphMode===112&&o&&s){let f=qk(i.fn,o,s,n.viewport);if(f)return{graphMode:118,position:f.center,radius:f.radii,guid:fi(),color:e.color,restrictionShader:t.restriction,fillOpacity:(l=e.fillOpacity)!=null?l:1}}let u=e.graphMode;if((u===112||u===113||u===127||u===106||u===107||u===108)&&t.concrete._chunk.isLinearIn([\"x\",\"y\",\"z\"])){let f=n.viewport,m,g,d;switch(u){case 106:m=(b,x,P)=>P-i.fn(b,x),g=new ee(f.xmin,f.xmax),d=new ee(f.ymin,f.ymax);break;case 107:m=(b,x,P)=>b-i.fn(x,P),g=new ee(f.ymin,f.ymax),d=new ee(f.zmin,f.zmax);break;case 108:m=(b,x,P)=>x-i.fn(b,P),g=new ee(f.xmin,f.xmax),d=new ee(f.zmin,f.zmax);break;case 112:case 113:case 127:m=i.fn,g=new ee(f.xmin,f.xmax),d=new ee(f.ymin,f.ymax);break}let y=qi(yh(m,f)),h=u===113||u===127;return u===127&&(u=113),{meshData:y,color:e.color,fillOpacity:h?1:(p=e.fillOpacity)!=null?p:1,uvRange:[g,d],uvArgs:[],extraMeshArgs:[],graphMode:u,compiled:i,restrictionShader:t.restriction}}return _a({viewState:n,graphInfo:e,compiled:i,restrictionShader3d:t.restriction,isImplicit3dInequality:a,gradient:o,dependencies:t.concrete._dependencies})}function Uk(e,t){var r,i,s;if(YE(t.graphMode))switch(t.graphMode){case 121:case 123:{t.graphMode=2,t.willConvertTo3D=!0,(r=t.lineWidth)!=null||(t.lineWidth=1);break}case 120:case 122:{t.graphMode=1,t.willConvertTo3D=!0,(i=t.lineWidth)!=null||(t.lineWidth=1);break}case 124:let{min:o,max:a}=((s=t.domain)==null?void 0:s.type)===\"1d\"?t.domain:{min:0,max:2*Math.PI};t.graphMode=6,t.domain={type:\"1d\",min:o,max:a,isExplicit:e.metaData.isExplicitDomain};break;case 126:t.graphMode=8;break}}function qk(e,t,n,r){if(r.zmin===void 0||r.zmax===void 0)return;let i=n.argNames.indexOf(\"x\"),s=n.argNames.indexOf(\"y\"),o=n.argNames.indexOf(\"z\");if(i===-1||s===-1||o===-1)return;let a=n.getInstruction(n.getReturnIndex());if(a.type!==38||a.args.length!==3)return;let[u,c,l]=a.args,p=Lr(n,i,{allowRestriction:!1,allowClosedBlockReferences:!1}),f=Lr(n,s,{allowRestriction:!1,allowClosedBlockReferences:!1}),m=Lr(n,o,{allowRestriction:!1,allowClosedBlockReferences:!1});if(en(p,u)!==1||en(f,c)!==1||en(m,l)!==1||en(f,u)!==0||en(m,u)!==0||en(p,c)!==0||en(m,c)!==0||en(p,l)!==0||en(f,l)!==0)return;let{xmin:g,ymin:d,zmin:y,xmax:h,ymax:b,zmax:x}=r,P=t(g,d,y),M=t(h,b,x),I=.5*(M[0]-P[0])/(h-g),E=.5*(M[1]-P[1])/(b-d),v=.5*(M[2]-P[2])/(x-y),O=(g*M[0]-h*P[0])/(M[0]-P[0]),A=(d*M[1]-b*P[1])/(M[1]-P[1]),N=(y*M[2]-x*P[2])/(M[2]-P[2]),L=-e(O,A,N),z=Math.sqrt(L/I),G=Math.sqrt(L/E),$=Math.sqrt(L/v);if(!(!isFinite(O)||!isFinite(A)||!isFinite(N)||!isFinite(z)||!isFinite(G)||!isFinite($)||z===0||G===0||$===0))return{center:[O,A,N],radii:[z,G,$]}}function $k(e,t,n,r,i,s,o){let a=e.metaData.evaluatedCDFMin,u=e.metaData.evaluatedCDFMax,c=Aa(e),l=dA(c,t),p=c&&c.discrete;if(a!==void 0&&u!==void 0&&!isNaN(a)&&!isNaN(u)&&o){let f=[];if(p){let m={viewState:r,graphInfo:i,compiled:n,bounds:[a,u],maxOverride:oA(c,t),showPoint:e.userData.shouldGraph},g=NN(m),d=g.cdfTopBranch,y=g.topBranches;if(y.forEach(function(h){!h||!l||(h.boundingBox=l)}),y.every(h=>h!==void 0)&&(f=y,d&&d.segments[0].length)){let h=[];d.segments[0].forEach(function(b){!isNaN(b[0])&&!isNaN(b[1])&&h.push([b[0],0,b[0],b[1]])}),f.push({graphMode:5,segments:h,boundingBox:l,poi:dr(),color:i.color})}}else{let g=AN({viewState:r,graphInfo:i,compiled:n,derivative:s,bounds:[a,u]}),d=g.cdfTopBranch,y=g.topBranches;if(y.forEach(function(h){!h||!l||(h.boundingBox=l)}),f=y,d&&d.segments.length){let h,b;for(let x=0;x=4){h=P[0];break}}for(let x=d.segments.length-1;x>=0;x--){let P=d.segments[x];if(P.length>=4){b=P[P.length-2];break}}if(h!==void 0&&b!==void 0&&isFinite(h)&&isFinite(b)){let x=ih(d.segments,[[h,0,b,0]],d.graphMode);f.push({graphMode:7,segments:x,poi:dr(),color:i.color})}}}return f}else if(p){let f=rh({viewState:r,graphInfo:i,compiled:n,showPoint:e.userData.shouldGraph,maxOverride:oA(c,t)});return l&&(f.boundingBox=l),[f]}else return}function cA(e){return Yk(e)||Q0(e)||lA(e)}function Yk(e){return e===3}function j0(e,t){let n=t!=null?t:{};if(!Array.isArray(e))return()=>e;let r=Object.keys(n).length===0?e:e.filter((i,s)=>!n[s]);return i=>r[i]}function Xk(e){var s,o;let t=e.droppedIndices,n=j0((s=e.pointSize)!=null?s:1,t),r=j0(e.color,t),i=j0((o=e.pointOpacity)!=null?o:1,t);return e.segments[0].map(([a,u],c)=>({graphMode:114,position:[a,u,0],radius:.02*n(c),guid:fi(),color:r(c),fillOpacity:i(c)}))}function rA(e,t,n,r){return e.is3dPolicy()&&Q0(t.graphMode)?oh(t,n,r!=null?r:1):t}function Q0(e){switch(e){case 1:case 2:case 6:case 8:case 5:return!0;default:return!1}}function oh(e,t,n,r=0){var o;let i=pA(e,t,r),s=ah(i,t.viewport,n);return{graphMode:128,guid:fi(),points:s,resolved:e.resolved,color:e.color,thickness:(o=e.lineWidth)!=null?o:1}}function iA(e,t,n){return e.is3dPolicy()&&lA(t.graphMode)?Zk(t,n):t}function lA(e){switch(e){case 17:case 24:return!0;default:return!1}}function Zk(e,t){var r;let n=pA(e,t);return{graphMode:e.graphMode===17?119:e.graphMode===24?129:128,guid:fi(),points:Wk(n),color:e.color,thickness:(r=e.lineWidth)!=null?r:1}}function Wk(e){let t=[];for(let[n,r,i]of e)t.push(n,r,i);return t}function pA(e,t,n=0){function r(s,o){if(e.graphMode===1)return[o,s];if(e.graphMode===6){let a=t.degreeMode?s*Math.PI/180:s;return[o*Math.cos(a),o*Math.sin(a)]}else return[s,o]}let i=[];for(let s=0;sf&&Z>f){let Ne=.5*(f/ie),Te=.5*(f/Z),Me=Ks(v,x,1-Ne),ve=Ks(O,P,1-Ne),Q=Ks(A,M,1-Ne),U=Ks(x,N,Te),xe=Ks(P,L,Te),le=Ks(M,z,Te);d.push(Me,ve,Q),d.push(Ks(Me,x,.5),Ks(ve,P,.5),Ks(Q,M,.5)),d.push(x,P,M),d.push(Ks(x,U,.5),Ks(P,xe,.5),Ks(M,le,.5)),d.push(U,xe,le)}else d.push(x,P,M)}else d.push(x,P,M)}return d}function Ks(e,t,n){return(1-n)*e+n*t}function jk(e){return e.startsWith(\"shader:\")}function hh(e,t,n){return{resolved:!0,graphMode:t,segments:n,operator:e.operator,poi:dr(),color:e.color,style:\"DASHED\",lineWidth:1,lineOpacity:.5,isIntersectionExtension:!0}}function sA(e,t){var r,i;if(!t)return[];let n=[];for(let s of e)if(s.graphMode===17){let o=t[(r=s.listIndex)!=null?r:0];if(!o)continue;let a=0,u,c=1,l,[p,f,m,g]=s.segments[0];for(let d=0;dc&&(c=b,l=d)}u!==void 0&&n.push(hh(s,17,[[p,f,o[u][0],o[u][1]]])),l!==void 0&&n.push(hh(s,17,[[m,g,o[l][0],o[l][1]]]))}else if(s.graphMode===21){let o=t[(i=s.listIndex)!=null?i:0];if(!o)continue;let[a,u,c,l,p]=s.segments[0],f=p-l+(pg)&&(g=x,d=b)}let y=m[d],h=m[d+1];y>0&&n.push(hh(s,21,[[a,u,c,l,l+y*f]])),h<1&&n.push(hh(s,21,[[a,u,c,p,p-(1-h)*f]]))}}return n}function Jk(){throw new Error(\"Programming error: this function is not expected to be called\")}function fA(e,t,n,r){let i=[];for(let s=0;s0?i:!1}D.Base.prototype.tryGraph=function(e,t,n,r){var i,s;try{let o=this.graph(e,t,n,r);if(Array.isArray(o))for(let a of o)\"compiled\"in a&&((i=a.compiled)!=null&&i.executionMetadata.recursionTerminationStatus)&&(a.recursionTerminationStatus=(s=a.compiled)==null?void 0:s.executionMetadata.recursionTerminationStatus);return o}catch(o){let a=o instanceof D.Error?o.getError():J(o).getError();return[IN(a)]}};D.Base.prototype.graph=function(e,t,n,r){let i=this.getGraphInfo(e,t);return this._graph(e,t,n,i,r)};D.BaseComparator.prototype.graph=function(e,t,n){let r=this.getGraphInfo(e,t),i=r.graphMode,s=\"baseComparator\",o=this.userData.lines===void 0?!0:this.userData.lines;if(i===8||i===112||i===113||i===127||i===210)return this._graph(e,t,n,r);if(i===10||!(t instanceof D.SolvedEquation))return!1;let a=this.getOperator(),u=[],c=[],l=!0;t._expression.eachElement(function(y){u.push(y.getCompiledFunction());try{c.push(y.getCompiledDerivative())}catch(h){l=!1}}),l||(c=void 0);let p=[],f=[-1,0,0,1],m=Uc(this.metaData,[\"computedLineWidth\",\"computedLineOpacity\",\"computedFillOpacity\",\"colorLatexValue\"],s),g=Math.min(u.length,m);for(let y=0;y{let d=g;if(d>=p)return;m[0].userData=m[1].userData=a,m[0].metaData=m[1].metaData=u;let y=void 0,{color:h,lineWidth:b,lineOpacity:x,fillOpacity:P}=_u(this,d,y),M=this._graph(e,m[0],n,r)[0];M.listIndex=d,M.operator=s,M.color=h,M.lineWidth=b,M.lineOpacity=x,i.push(M);let I=this._graph(e,m[1],n,r)[0];I.listIndex=d,I.operator=o,I.color=h,I.lineWidth=b,I.lineOpacity=x,i.push(I);let E=M.segments,v=I.segments;Xr(E),Xr(v);let O=ih(E,v,M.graphMode);c||(M.lineWidth=0,I.lineWidth=0),i.push({graphMode:7,listIndex:M.listIndex,segments:O,lineOpacity:x,fillOpacity:P,poi:dr(),color:h})}),i};D.Regression.prototype.graph=function(e,t,n){let r=this.getGraphInfo(e,t);return this._graph(e,t.model,n,r)};function K0(e,t){let n=1/0,r=-1/0,i=1/0,s=-1/0;for(let a of t)for(var o=0;or&&(r=u),cs&&(s=c)}if(isFinite(n)&&isFinite(i))return{type:e,xmin:n,ymin:i,xmax:r,ymax:s}}function dA(e,t){if(!e||!(t instanceof pn))return;let n=t._chunk,r=n.getInstruction(n.getReturnIndex());if(r.type!==37)return;let i=e.discrete?\"discreteDistribution\":\"continuousDistribution\";if(e.symbol===\"binomialdist\"&&r.symbol===\"binompdf\"){let s=ln(n,r.args[1]),o=ln(n,r.args[2]),a=wy(o*s,s,o);return{type:i,xmin:0,xmax:s,ymin:0,ymax:a}}if(e.symbol===\"poissondist\"&&r.symbol===\"poissonpdf\"){let s=ln(n,r.args[1]),o=Math.max(Yl(Math.floor(s),s),Yl(Math.ceil(s),s));return{type:i,xmin:0,xmax:2.5*s,ymin:0,ymax:o}}if(e.symbol===\"normaldist\"&&r.symbol===\"normalpdf\"){let s=ln(n,r.args[1]),o=ln(n,r.args[2]),a=iI(s,s,o);return{type:i,xmin:s-2*Math.abs(o),xmax:s+2*Math.abs(o),ymin:0,ymax:a}}if(e.symbol===\"uniformdist\"&&r.symbol===\"uniformpdf\"){let s=ln(n,r.args[1]),o=ln(n,r.args[2]),a=(s+o)/2,u=o-s,c=aI(a,s,o);return{type:i,xmin:s-u/3,xmax:o+u/3,ymin:0,ymax:c}}if(e.symbol===\"tdist\"&&r.symbol===\"tpdf\"){let s=ln(n,r.args[1]),o=Ly(0,s);return{type:i,xmin:-3,xmax:3,ymin:0,ymax:o}}}function oA(e,t){if(e===void 0||e.symbol!==\"binomialdist\"||!(t instanceof pn))return;let n=t._chunk,r=n.getInstruction(n.getReturnIndex());if(r.type===37&&r.symbol===\"binompdf\")return ln(n,r.args[1])}function mA(e,t,n){let r={};n-=.5*t;for(var i=e.length-1;i>=0;i--){let s=e[i],o=Math.floor((s-n)/t);r[o]?r[o].data.push(s):r[o]={id:o,data:[s],min:o*t+n,max:o*t+n+t,center:o*t+n+t/2}}return r}D.Histogram.prototype.graph=function(e,t,n){let r=this.getGraphInfo(e,t),i=t.args[0].asValue(),s=t.args[1].asValue(),o=this.userData.vizProps&&this.userData.vizProps.binAlignment===\"left\"?s/2:0;Xr(i);let a=mA(i,s,o),u=1;this.userData.vizProps&&this.userData.vizProps.histogramMode===\"density\"?u=1/(i.length*s):this.userData.vizProps&&this.userData.vizProps.histogramMode===\"relative\"&&(u=1/i.length);let c=[],l=[];for(let f in a){let m=a[f],g=m.data.length;l.push([m.min,0*u,m.min,g*u,m.max,g*u,m.max,0*u]);let d=0;a[m.id+1]&&(d=a[m.id+1].data.length);let y=[m.min,0*u,m.min,g*u,m.max,g*u];d=0;p--)b.center!==b.data[p]&&(u=!0)}if(this.userData.vizProps&&this.userData.vizProps.dotplotXMode===\"exact\")for(let h in a){c=a[h].data,c.reverse();for(let x=0;xI)&&y.push([E,f])})}let h=[[c,m,p,m,p,g,c,g,c,m],[l,m,l,g],[c,f,a,f],[p,f,u,f],[a,f-d,a,f+d],[u,f-d,u,f+d]];if(this.userData.vizProps&&this.userData.vizProps.alignedAxis===\"y\"){for(let P of h)for(var b=0;b1&&P.push(M),M=[]);continue}let $=z.asValue(),w=G.asValue();if(g){if(L>=l)continue;let Y=f&&this.isValueDraggable(t,0,L),de=m&&this.isValueDraggable(t,o,L);Y||de?(b.push([$,w]),x.push({index:L,dragX:Y,dragY:de})):h.push([$,w])}d&&M.push([$,w]),$E&&(E=$),wO&&(O=w)}let N={type:\"table\",xmin:I,xmax:E,ymin:v,ymax:O};b.length&&y.push({graphMode:4,segments:[b],color:c.colorLatexValue||u.color,tableId:u.tableId,poi:Us(b),movablePointInfo:x,boundingBox:N,pointOpacity:c.computedPointOpacity,pointSize:c.computedMovablePointSize}),h.length&&y.push({segments:[h],droppedIndices:A,graphMode:3,showPoint:!0,poi:Us(h),color:c.colorLatexValue||u.color,pointSize:c.computedPointSize,pointOpacity:c.computedPointOpacity,style:u.pointStyle,tableId:u.tableId,boundingBox:N}),(P.length||M.length)&&(P.push(M),y.push({segments:P.map(Qk),graphMode:5,poi:dr(),color:sa(u,c),style:u.lineStyle,lineWidth:Array.isArray(c.computedLineWidth)?c.computedLineWidth[0]:c.computedLineWidth,lineOpacity:Array.isArray(c.computedLineOpacity)?c.computedLineOpacity[0]:c.computedLineOpacity,tableId:u.tableId,boundingBox:N})),y.length&&(r[u.id]=y)}return r};function Kk(e,t,n){return e?t===0&&n===0?e[2].type!==\"none\"||e[3].type!==\"none\":t!==0&&n!==0?e[0].type!==\"none\"&&e[1].type!==\"none\":t!==0?e[0].type!==\"none\":n!==0?e[1].type!==\"none\":!1:!1}D.Image.prototype.graph=function(e,t,n){let r=[];if(t.center.valueType!==R||t.center.getDependencies().length!==0||!t.radianAngle.isConstant||!t.width.isConstant||!t.height.isConstant||!t.opacity.isConstant)return r;let i=[],s=[],o=t.width.asValue()/2,a=t.height.asValue()/2,u=t.radianAngle.asValue();for(var c=-1;c<=1;c++)for(var l=-1;l<=1;l++){let[p,f]=t.center.asValue(),m=[p+c*o*Math.cos(u)+l*a*Math.sin(u),f-c*o*Math.sin(u)+l*a*Math.cos(u)];Kk(t.moveStrategy,c,l)&&(i.push(m),s.push([c,l]))}return r.push({segments:[i],scaleFactors:[s],graphMode:4,color:sa(this.userData,this.metaData),style:this.userData.style,poi:Us(i),movablePointInfo:[],pointOpacity:1}),r};function aA(e){let t=[],n=[];for(let[r,i]of e)!isNaN(r)&&!isNaN(i)?t.push(r,i):(t.length>=4&&n.push(t),t=[]);return t.length>=4&&n.push(t),n}function uA(...e){return e.some(t=>isNaN(t))}function ez(e){return e.isError?e.getError():e.asValue()===void 0?\"\":+e.asValue()}function tz(e,t,n){let r=[];for(var i=0;i0)return r.variables=t.getSliderVariables(e,n),r;r.dimensions.x=[],r.dimensions.y=[],r.dimensions.radianAngle=[],r.dimensions.width=[],r.dimensions.height=[],r.dimensions.opacity=[];let i=[n.center,n.radianAngle,n.width,n.height,n.opacity];return i.some(o=>o&&o.valueType&&W(o.valueType))&&(r.is_concrete_list=!0),D.List.eachArgs(i,function(o){let a=o[0].asValue(),u=+o[1].asValue(),c=Math.atan2(Math.sin(u),Math.cos(u));r.dimensions.x.push(+a[0]),r.dimensions.y.push(+a[1]),r.dimensions.radianAngle.push(c),r.dimensions.width.push(+o[2].asValue()),r.dimensions.height.push(+o[3].asValue()),r.dimensions.opacity.push(Math.max(0,Math.min(1,+o[4].asValue())))}),(e.graphingEnabled()?t.getGraphMode(e,n):10)!==10&&(r.is_graphable=!0),n.moveStrategy&&(r.move_strategy=n.moveStrategy),t.center&&(t.center.type===\"Identifier\"?(r.center_reference_id=t.center.referencedStatementId,r.center_reference_symbol=t.center._symbol):t.center.type===\"ParenSeq\"&&n.center.valueType===R&&(r.center_is_point_literal=!0)),r}function rz(e,t,n){let r=n.handler,i=n.minStep,s={},o={};for(let p of r.getDependencies())e.validActionVariable(p)||(s[p]=!0);for(let p of i.getDependencies())o[p]=!0;let a;if(xo(i))a={status:\"error\",error:i.getError()};else{let p=i.asValue();typeof p==\"number\"&&!isNaN(p)&&p>=0?a={status:\"valid\",value:p}:a={status:\"error\",error:eP().getError()}}let u=Object.keys(s);u.length>0&&(r=tn(u).setDependencies(r.getDependencies()));let c;r.isError&&!nM(e,r)?c={status:\"error\",error:r.getError()}:r.isEmptyAction?c={status:\"empty\"}:c={status:\"maybe-valid\"};let l={handler:c,minStep:a,variables:[]};return Fu(l,e,{...s,...o}),l}function iz(){return{operator:\"=\",variables:[]}}function yA(e,t,n,r){var c;if(Gs(n))return tz(e,n,r);if(rd(n))return nz(e,n,r);let i=iz();if(n instanceof D.Ticker)return e.graphingEnabled()?rz(e,n,r):(i.error=J(\"Ticker without graphing\").getError(),i);if(e.is3dProduct()){let l=e,p=n.getGraphMode(l,r);if((p===100||p===101||p===102||p===5)&&r.getDependencies().length===1){let f=r.getDependencies()[0];(f===\"u\"||f===\"v\"||f===\"t\")&&(i.internal_domain_dependency=f)}}if((c=n.parseOptions)!=null&&c.selection){let l=r.getCursorContext();if(l)i.cursor_context={...l,selection:n.parseOptions.selection};else if(xo(r)){let p=oz(e,t,n);p&&(i.cursor_context={...p,selection:n.parseOptions.selection})}}if(n instanceof cr&&r instanceof pn?i.recursion=r.getRecursiveFunctionMetadata():n instanceof cr&&r instanceof C&&r.recursionMetadata&&(i.recursion=r.recursionMetadata),n instanceof wi&&(i.recursion_base_case={symbol:n._symbol,argValue:n.specifiedArg.valid?n.specifiedArg.argValue:void 0}),r.isError&&!(n instanceof D.FunctionDefinition&&!r.blocksExport)&&!r.silent){i.error=r.getError(),i.variables=n.getSliderVariables(e,r),i.is_single_identifier=n instanceof D.Identifier,r.actionValue&&(i.action_value=WE(r.actionValue));let l=eM(e,t,n,r);return Object.keys(l).length>0&&(i.geometry=eM(e,t,n,r)),i}if(r.valueType===Ut&&r.getDependencies().length===0){let l=r.asValue();i.rgb_value=xc(l[0],l[1],l[2]).formatHex()}r.valueType===rt&&r.getDependencies().length===0&&(i.action_value=WE(r.asValue())),r.moveStrategy&&(i.move_strategy=r.moveStrategy,i.default_drag_mode=r.defaultDragMode),n.isInequality()&&(i.is_inequality=!0),i.operator=n.getOperator(),r instanceof D.SolvedEquation?r._expression.asValue()!==!0&&r._expression.asValue()!==!1&&(i.assignment=r._symbol):n instanceof D.Assignment&&(n._symbol.startsWith(\"_\")||(i.assignment=n._symbol)),n instanceof D.FunctionDefinition&&(i.function_definition=n._symbol);let s=e.graphingEnabled()?n.getGraphMode(e,r):10;if(e.graphingEnabled()&&e.is3dPolicy()&&!ea(s)&&!cA(s)&&(s=10),s!==10&&(i.is_graphable=!0,i.expression_type=n.getExpressionType(s,r.valueType),e.is3dPolicy()&&(i.expression_type===\"SINGLE_POINT\"?i.expression_type=\"POINT3D\":i.expression_type===\"POINT_LIST\"&&(i.expression_type=\"POINT3D_LIST\")),r.valueType&&ca(r.valueType)&&(i.map_type=r.valueType),r.isShadeBetween()&&(i.is_shade_between=!0),i.expression_type!==\"POINT3D\"&&i.expression_type!==\"POINT3D_LIST\")){let l=n.tableInfo(e,r);l&&(i.is_tableable=!0,i.table_info=l)}if(r.valueType!==void 0&&W(r.valueType)&&(i.is_concrete_list=!0,r.valueType===Zn&&r.getDependencies().length===0)){let l=r.asValue();l&&(i.rgb_value=l.map(p=>xc(p[0],p[1],p[2]).formatHex()))}if(i.variables=i.is_graphable?[]:n.getSliderVariables(e,r),i.is_single_identifier=n instanceof D.Identifier,r.isTypedConstant){let l=r.asTypedValue();i.typed_constant_value=l,(l.valueType===T||l.valueType===ge)&&(i.constant_value=l.value),sz(l.valueType)&&(i.geometry=eM(e,t,n,r))}let o=r.getEvaluationInfo();if(o&&i.operator===\"=\"&&!n.isConstant&&!n.isFunction&&!(n instanceof D.RecursiveFunctionBaseCase)&&r.valueType!==ge&&r.valueType!==Ln&&!(n instanceof D.Equation)&&!(n instanceof D.ComparatorChain)&&(i.is_evaluable=!0,i.zero_values=o),r instanceof D.OptimizedRegression){let l=r,p={};for(var a in l.parameters)l.parameters.hasOwnProperty(a)&&(p[ur(a)]=+l.parameters[a].asValue());i.is_regression=!0,i.regression={parameters:p,residualVariable:ur(l.residualVariable),residualSuggestionId:l.residualSuggestionId,shouldSuggestLogMode:l.shouldSuggestLogMode,isLinear:l.isLinear,statistics:l.statistics,parameterWarning:l.parameterWarning}}let u=Aa(n);return u&&u.discrete&&(i.is_discrete_distribution=!0),i}function sz(e){switch(e){case R:case Pt:case fe:case Bn:case Ie:case Tn:case Le:case Gn:case he:case kn:case pe:case Fn:case ce:case Vn:case Be:case Rn:case Ge:case gn:case Ae:case hn:case Ue:case mr:return!0;default:return!1}}function eM(e,t,n,r){let i={};r.valueType!==void 0&&(i.valueType=r.valueType),i.valueType&&oe(i.valueType,R)&&e.graphingEnabled()&&n.getGraphMode(e,r)===4&&(i.isMovablePoint=!0);let{identifier:s,listAccess:o,assignmentRhsReference:a,tree:u}=Wy(n);if(s&&(i.identifier=s),o&&(i.listAccess=o),a&&(i.assignmentRhsReference=a),u&&(i.call=u,r.valueType&&oe(r.valueType,Ue)&&n instanceof cr)){let l=n._expression;i.transformation_preview_info={type:u.symbol,args:l.args.slice(1).map(p=>p.tryGetConcreteTree(e,t).asTypedValue())}}let c=r.moveStrategy&&r.moveStrategy[0];return c&&\"initialValue\"in c&&c.initialValue!==void 0&&(i.gliderParameter=c.initialValue),i}function oz(e,t,n){let r=n.parseOptions;if(!(r!=null&&r.selection))return;let{start:i,end:s,input:o}=r.selection;if(o.trim()===\"\")return{type:\"empty\",allowedTypes:[Ht]};let a=\"\\\\cursor\",u=o.slice(0,i)+a+\" \"+o.slice(s),c={input:u,start:i,end:i+a.length},l=Vs(u,{...n.parseOptions,selection:c});return l.isError?l.getCursorContext():mp({policy:e,frame:t,selection:c},l).getCursorContext()}function Fu(e,t,n){let r=e.variables;if(r&&r.length){let i={};for(let s of r)i[s]=!0;for(let s in n)i[s]=!0;n=i}e.variables=t.sliderVariables(Object.keys(n))}function nM(e,t){if(t.blocksExport)return!1;let n=t.getDependencies();if(n.length===0)return!1;for(let r of n)if(!e.validActionVariable(r))return!1;return!0}var k=class{constructor(t,n,r,i){this.policy=t,this.rawTree=r,this.concreteTree=i,this.evaluationState=yA(t,n,r,i)}exportTo(t,n){this.rawTree.exportTo(t,this.concreteTree,n)}graph(t,n){return this.rawTree.tryGraph(this.policy,this.concreteTree,t,n)}getGraphMode(){return this.policy.graphingEnabled()?this.rawTree.getGraphMode(this.policy,this.concreteTree):10}getGraphInfo(){return this.rawTree.getGraphInfo(this.policy,this.concreteTree)}shouldIntersect(){if(!this.evaluationState.is_graphable||!this.rawTree.userData.shouldGraph||!rs.pointsOfInterest)return!1;var t=this.getGraphMode();return t===1||t===2}};var F=function(){};F.version=\"1.2.6\";F._myIndexOf=function(t){var n=this.length,r;for(r=0;r=0;i--) ret[i] = arguments.callee(`+t.join(\",\")+`,_s,_k+1);\n return ret;\n}\n`+r+`\nfor(i=_n-1;i!==-1;--i) {\n `+n+`\n}\nreturn ret;`,F.compile.apply(null,i)};F.pointwise2=function(t,n,r){typeof r==\"undefined\"&&(r=\"\");var i=[],s,o=/\\[i\\]$/,a,u=\"\",c=!1;for(s=0;s=0;o--)e(typeof t==\"object\"?t[o]:t,typeof n==\"object\"?n[o]:n,r,i+1,s)};F._biforeach2=function e(t,n,r,i,s){if(i===r.length-1)return s(t,n);var o,a=r[i],u=Array(a);for(o=a-1;o>=0;--o)u[o]=e(typeof t==\"object\"?t[o]:t,typeof n==\"object\"?n[o]:n,r,i+1,s);return u};F._foreach=function e(t,n,r,i){if(r===n.length-1){i(t);return}var s,o=n[r];for(s=o-1;s>=0;s--)e(t[s],n,r+1,i)};F._foreach2=function e(t,n,r,i){if(r===n.length-1)return i(t);var s,o=n[r],a=Array(o);for(s=o-1;s>=0;s--)a[s]=e(t[s],n,r+1,i);return a};F.ops2={add:\"+\",sub:\"-\",mul:\"*\",div:\"/\",mod:\"%\",and:\"&&\",or:\"||\",eq:\"===\",neq:\"!==\",lt:\"<\",gt:\">\",leq:\"<=\",geq:\">=\",band:\"&\",bor:\"|\",bxor:\"^\",lshift:\"<<\",rshift:\">>\",rrshift:\">>>\"};F.opseq={addeq:\"+=\",subeq:\"-=\",muleq:\"*=\",diveq:\"/=\",modeq:\"%=\",lshifteq:\"<<=\",rshifteq:\">>=\",rrshifteq:\">>>=\",bandeq:\"&=\",boreq:\"|=\",bxoreq:\"^=\"};F.mathfuns=[\"abs\",\"acos\",\"asin\",\"atan\",\"ceil\",\"cos\",\"exp\",\"floor\",\"log\",\"round\",\"sin\",\"sqrt\",\"tan\",\"isNaN\",\"isFinite\"];F.mathfuns2=[\"atan2\",\"pow\",\"max\",\"min\"];F.ops1={neg:\"-\",not:\"!\",bnot:\"~\",clone:\"\"};F.mapreducers={any:[\"if(xi) return true;\",\"var accum = false;\"],all:[\"if(!xi) return false;\",\"var accum = true;\"],sum:[\"accum += xi;\",\"var accum = 0;\"],prod:[\"accum *= xi;\",\"var accum = 1;\"],norm2Squared:[\"accum += xi*xi;\",\"var accum = 0;\"],norminf:[\"accum = max(accum,abs(xi));\",\"var accum = 0, max = Math.max, abs = Math.abs;\"],norm1:[\"accum += abs(xi);\",\"var accum = 0, abs = Math.abs;\"],sup:[\"accum = max(accum,xi);\",\"var accum = -Infinity, max = Math.max;\"],inf:[\"accum = min(accum,xi);\",\"var accum = Infinity, min = Math.min;\"]};(function(){var e,t;for(e=0;eh&&(y=f,h=g);for(u=o[y],o[y]=o[m],o[m]=u,p=c[y],c[y]=c[m],c[m]=p,d=u[m],g=m;g!==s;++g)u[g]/=d;for(g=s-1;g!==-1;--g)p[g]/=d;for(f=i-1;f!==-1;--f)if(f!==m){for(a=o[f],l=c[f],d=a[m],g=m+1;g!==s;++g)a[g]-=u[g]*d;for(g=s-1;g>0;--g)l[g]-=p[g]*d,--g,l[g]-=p[g]*d;g===0&&(l[0]-=p[0]*d)}}return c};F.det=function(t){var n=F.dim(t);if(n.length!==2||n[0]!==n[1])throw new Error(\"numeric: det() only works on square matrices\");var r=n[0],i=1,s,o,a,u=F.clone(t),c,l,p,f,m,g,d;for(o=0;oMath.abs(u[a][o])&&(a=s);for(a!==o&&(f=u[a],u[a]=u[o],u[o]=f,i*=-1),c=u[o],s=o+1;s=1;n-=2){for(u=t[n],a=t[n-1],r=s-1;r>=1;--r)c=o[r],c[n]=u[r],c[n-1]=a[r],--r,c=o[r],c[n]=u[r],c[n-1]=a[r];r===0&&(c=o[0],c[n]=u[0],c[n-1]=a[0])}if(n===0){for(a=t[0],r=s-1;r>=1;--r)o[r][0]=a[r],--r,o[r][0]=a[r];r===0&&(o[0][0]=a[0])}return o};F.negtranspose=function(t){var n,r,i=t.length,s=t[0].length,o=Array(s),a,u,c;for(r=0;r=1;n-=2){for(u=t[n],a=t[n-1],r=s-1;r>=1;--r)c=o[r],c[n]=-u[r],c[n-1]=-a[r],--r,c=o[r],c[n]=-u[r],c[n-1]=-a[r];r===0&&(c=o[0],c[n]=-u[0],c[n-1]=-a[0])}if(n===0){for(a=t[0],r=s-1;r>=1;--r)o[r][0]=-a[r],--r,o[r][0]=-a[r];r===0&&(o[0][0]=-a[0])}return o};F.norm2=function(t){return Math.sqrt(F.norm2Squared(t))};F.linspace=function(t,n,r){if(typeof r==\"undefined\"&&(r=Math.max(Math.round(n-t)+1,1)),r<2)return r===1?[t]:[];var i,s=Array(r);for(r--,i=r;i>=0;i--)s[i]=(i*n+(r-i)*t)/r;return s};F.getBlock=function(t,n,r){var i=F.dim(t);function s(o,a){var u,c=n[a],l=r[a]-c,p=Array(l);if(a===i.length-1){for(u=l;u>=0;u--)p[u]=o[u+c];return p}for(u=l;u>=0;u--)p[u]=s(o[u+c],a+1);return p}return s(t,0)};F.setBlock=function(t,n,r,i){var s=F.dim(t);function o(a,u,c){var l,p=n[c],f=r[c]-p;if(c===s.length-1)for(l=f;l>=0;l--)a[l+p]=u[l];for(l=f;l>=0;l--)o(a[l+p],u[l],c+1)}return o(t,i,0),t};F.getRange=function(t,n,r){var i=n.length,s=r.length,o,a,u=Array(i),c,l;for(o=i-1;o!==-1;--o)for(u[o]=Array(s),c=u[o],l=t[n[o]],a=s-1;a!==-1;--a)c[a]=l[r[a]];return u};F.blockMatrix=function(t){var n=F.dim(t);if(n.length<4)return F.blockMatrix([t]);var r=n[0],i=n[1],s,o,a,u,c;for(s=0,o=0,a=0;a=0;c--){for(u=Array(o),p=t[c],l=o-1;l>=3;--l)u[l]=p*n[l],--l,u[l]=p*n[l],--l,u[l]=p*n[l],--l,u[l]=p*n[l];for(;l>=0;)u[l]=p*n[l],--l;a[c]=u}return a};F.epsilon=2220446049250313e-31;F.LU=function(e,t){t=t||!1;var n=Math.abs,r,i,s,o,a,u,c,l,p,f=e.length,m=f-1,g=new Array(f);for(t||(e=F.clone(e)),s=0;s=0;--r){for(l=s[r],i=r+1;io&&(o=l,a=c)}if(r[s]=a,a!==s)for(let c=0;c=0;c--){let l=i[c];if(Math.abs(l[c])<=u)o[c]=0;else{for(let p=c+1;p=0;c--)if(s[c]!==c){let l=o[c];o[c]=o[s[c]],o[s[c]]=l}return o}function pz(e,t,n){let r=Array(e.r[0].length);for(let s=0;s0?e[0].length:0;return{numRows:t,numCols:n}}function yz(){throw new Error(\"Matrix dimension mismatch\")}function rM(e,t){let n=Ph(e),r=Ph(t);n.numCols!==r.numRows&&yz();let i=[];for(let s=0;st&&(t=i)}return t}function bA(e){for(let t=0;tc)&&(c=f,u=p)}if(!isFinite(c))return bA(e),{determinant:NaN,rank:0};if(c===0){s=De(0,1),a+=1;continue}if(!En(e[u][a])&&cMath.abs(u)<1e-6?0:u),r=t.solution.map(()=>0),i=Bu(e,n),s=Vu(e,n),o=Vu(e,r),a=0;for(let u=0;u1){Fa(e,f,g,y);break}let b=g&&g.length>0?g[0]:lM(e),[x,P]=h.args,M=b.isLazy?x:b.valueMap[x],I=b.isLazy?P:b.valueMap[P],E=b.chunk.getInstruction(M),v=b.chunk.getInstruction(I),O,A,N;if(E.type===37)O=x,N=E,A=P;else if(v.type===37)O=P,N=v,A=x;else{Fa(e,f,g,y);break}let L=pM(m,O);if(L===void 0||SA(m,A)){Fa(e,f,g,y);break}let{listAccessIndex:z,listStatistics:G}=L;if(N.symbol===\"exp\"){let $=Dz(b,y,A,O,z,G);if($){g=$;break}}else if(OA(N)){let $=Mz(b,y,A,O,z);if($){g=[$];break}}Fa(e,f,g,y);break;default:{Fa(e,f,g,y);break}}}if(g===void 0||g.length===0)return;let d=[];for(let y of g)d.push({chunk:y.chunk,forwardParameterMap:y.forwardParameterMap,reverseParameterMap:y.reverseParameterMap});return d}function Fa(e,t,n,r){if(n===void 0)return;let i=e.getInstruction(r);if(be(i))for(let s of n)s.valueMap[r]=r;else for(let s of n){let{chunk:o,valueMap:a}=s,u=[],c=0;for(let l of i.args){if(a[l]!==l){if(c+=1,c>1){n.length=0;return}}else{let p=t[l];for(let f=0;f0?Mn(o,i,u):r}}function pM(e,t){let{listAccessDependencyTable:n,listAccesses:r,listStatisticsTable:i}=e,s,o=n[t];for(let a=0;a0){let b=vh(e),{chunk:x,valueMap:P}=b,M=x.Multiply([x.SyntheticNativeFunction(\"ln\",[P[o]]),P[a]]);return P[a]=M,P[t]=x.SyntheticNativeFunction(\"exp\",[M]),Td(b,t,a,n,r)||b}let c=fM(i,o);if(c===void 0)return;let l=dM(e,o,c);if(l===void 0)return;let{chunk:p,valueMap:f}=l,m=p.Multiply([f[o],f[a]]);f[a]=m,f[t]=p.SyntheticNativeFunction(\"exp\",[m]);function g(b){let x=l.forwardParameterMap(b),P=x[c],M=Math.log(P);return x[c]=M,x}function d(b){let x=b.slice(),P=x[c],M=Math.exp(P);return x[c]=M,l.reverseParameterMap(x)}let y=l.replacementMask.slice();y[c]=!0;let h={chunk:p,forwardParameterMap:g,reverseParameterMap:d,isLazy:!1,valueMap:f,replacementMask:y};return Td(h,t,a,n,r)||h}function Dz(e,t,n,r,i,s){if(!e.isLazy&&e.didShiftScale)return;let o=e.isLazy?e:DA(e),a=e.chunk,u=fM(a,n);if(u===void 0)return;let c=dM(e,n,u);if(c===void 0)return;let{chunk:l,valueMap:p}=c,f=l.getInstruction(p[r]).args[0],m=l.Add([f,p[n]]);p[n]=m,p[t]=l.SyntheticNativeFunction(\"exp\",[m]);function g(I){let E=c.forwardParameterMap(I),v=E[u],O=Math.log(v);return E[u]=O,E}function d(I){let E=I.slice(),v=E[u],O=Math.exp(v);return E[u]=O,c.reverseParameterMap(E)}function y(I){let E=c.forwardParameterMap(I),v=E[u],O=Math.log(-v);return E[u]=O,E}function h(I){let E=I.slice(),v=E[u],O=-Math.exp(v);return E[u]=O,c.reverseParameterMap(E)}let b=c.replacementMask.slice();b[u]=!0;let x=vh(o);x.valueMap[t]=x.chunk.Multiply([x.valueMap[n],x.valueMap[r]]);let P={chunk:l,forwardParameterMap:g,reverseParameterMap:d,isLazy:!1,valueMap:p,replacementMask:b},M=DA(P);return M.forwardParameterMap=y,M.reverseParameterMap=h,P=Td(P,t,n,i,s)||P,M=Td(M,t,n,i,s)||M,M.valueMap[t]=M.chunk.Negative([M.valueMap[t]]),[x,P,M]}function Td(e,t,n,r,i){let s=Sz(e,n,r,i);if(s!==void 0)return s.valueMap[t]=s.chunk.SyntheticNativeFunction(\"exp\",[s.valueMap[n]]),s}function Sz(e,t,n,r){let i=RA(e,t,n);if(i===void 0)return;let{chunk:s,valueMap:o}=i,a=s.getInstruction(o[t]);if(a.type!==8)return;let u=a.args[1],c=s.getInstruction(a.args[0]);if(c.type!==10)return;let[l,p]=c.args,{min:f,max:m}=r,g=m-f,d=.5*(m+f),y=s.Divide([s.Subtract([p,s.Constant(d)]),s.Constant(g)]),h=s.Add([s.Multiply([l,y]),u]);o[t]=h;function b(P){let M=i.forwardParameterMap(P),I=M[l],E=M[u],v=I*g,O=E+d*I;return M[l]=v,M[u]=O,M}function x(P){let M=P.slice(),I=P[l],E=P[u],v=I/g,O=E-v*d;return M[l]=v,M[u]=O,i.reverseParameterMap(M)}return{chunk:s,forwardParameterMap:b,reverseParameterMap:x,isLazy:!1,valueMap:o,replacementMask:i.replacementMask,didShiftScale:!0}}function dM(e,t,n){let r=e.chunk,i=Lr(r,n,{allowRestriction:!1,allowClosedBlockReferences:!1});if(en(i,t)!==1)return;let s=ws(i,t),[o,a]=Hn(s,t);if(a===void 0)return;let u=s.newChunk.getInstruction(o);if(u.type!==1||u.valueType!==T)return;let c=s.newChunk.getInstruction(a);if(c.type!==1||c.valueType!==T)return;let l=vh(e),{chunk:p,valueMap:f}=l,m=q(u.value),g=q(c.value);f[t]=n;function d(b){let x=l.forwardParameterMap(b),P=x[n],M=m+g*P;return x[n]=M,x}function y(b){let x=b.slice(),M=(x[n]-m)/g;return x[n]=M,l.reverseParameterMap(x)}let h=l.replacementMask.slice();return h[n]=!0,{chunk:p,forwardParameterMap:d,reverseParameterMap:y,isLazy:!1,valueMap:f,replacementMask:h}}function RA(e,t,n){let r=e.chunk,i=e.isLazy?t:e.valueMap[t],s=Lr(r,n,{allowRestriction:!1,allowClosedBlockReferences:!0});if(en(s,i)!==1)return;e.isLazy&&(s=Lr(r.copy().reopenFinalBlock(),n,{allowRestriction:!1,allowClosedBlockReferences:!1}));let o=ws(s,i),[a,u]=Hn(o,i);if(u===void 0)return;let c=o.newChunk,l=Math.max(u,a),p=[];for(let Z=0;Z<=l;Z++)if(c.getInstruction(Z).type===2){let Ne=vp(c.argNames.length);Ne[Z]=!0,p.push(Ne)}else p.push(Mh(c,p,c.argNames.length,Z));let f,m;for(let Z=0;Zs[0]!==\"_\"),r;for(let s of n){let o=s.match(/_(.*)/);if(o&&(r=\"e_\"+o[1],!t[r]))return r}let i=1;for(;;){if(r=\"e_\"+i,!t[r])return r;i++}}function NA({policy:e,frame:t},n,r){let i=n._rhs.getDependencies(),s,o;for(let p of i){if(r.hasOwnProperty(p))continue;let f=t[p];if(!f||(f.type===\"Assignment\"&&(f=f._expression),!f.buildIRExpression))continue;let m=f.buildIRExpression(e,t,{coerceToNumber:!0});if(!m.isError&&m.valueType===se){if(s!==void 0){s=void 0,o=void 0;break}m.getDependencies().length===0&&(s=p,o=m)}}let a=Object.create(t);s!==void 0&&(a[s]=void 0);let u=n._rhs.buildIRExpression(e,a,{coerceToNumber:!0}),c=Object.create(a);for(let p in r)c[p]=r[p];let l=n._rhs.buildIRExpression(e,c,{coerceToNumber:!0});return o?{node:u,substituted:l,listNode:o,isValid:!0}:{node:u,substituted:l,listNode:o,isValid:!1}}function Nz(e,t,n){let r=[];t||(t={}),n||(n={});for(let i of e){let s=ur(i);n[i]&&isFinite(n[i].asValue())?r.push(+n[i].asValue()):t.hasOwnProperty(s)&&isFinite(+t[s])?r.push(+t[s]):r.push(1)}return r}function AA(e,t){let n=t.getDependencies(),r=t.getCompiledFunction(n).fn;if(n.length){let i=t.findLinearSubset(n),s=i.every(a=>a),o=[];for(let a of n)o.push(t.takeDerivative(a).getCompiledFunction(n).fn);if(s){let a=n.map(()=>De(0,1)),u=t.interpretWithParameters(a),c=[];for(let m of n)c.push(t.takeDerivative(m).interpretWithParameters(a));let l=uM(u,c);if(l){let m=t.interpretWithParameters(l);return{solution:l,residuals:m,MSE:yM(m),isLinear:s}}let{solution:p,MSE:f}=aM(r,cM(r,o));return{solution:p,residuals:r.apply(void 0,p),MSE:f,isLinear:s}}else{let a=[];for(let p of n)a.push(t.boundDomain(p));let u={linearSubset:i,bounds:a,preferredInitialGuess:e},{solution:c,MSE:l}=aM(r,MA(r,o,u));return{solution:c,residuals:r.apply(void 0,c),MSE:l,isLinear:s}}}else return{solution:[],residuals:t.interpretWithParameters([]),MSE:Bu(r,[]),isLinear:!0}}function _A(e,t){let n={},r=t.getDependencies();for(let i=0;i0)return{RMSE:Math.sqrt(o)};let a=W(t.valueType)?wf(t.asValue()):0;if(t.getDependencies().length||!isFinite(a)||a<=0||!e.isLhsSimple)return{RMSE:Math.sqrt(o)};{let u=1-o/a;if(n.isValid){let c=[],l=[],p=i&&(s===di.LINLOG||s===di.LOGLOG);D.List.eachArgs([n.listNode,t],function(m){let g=m[0].isConstant?m[0].asCompilerValue():NaN,d=m[1].isConstant?m[1].asCompilerValue():NaN;c.push(p?Math.log(q(g)):g),l.push(d)});let f=Vy(c.map(m=>q(m)),l.map(m=>q(m)));if(Li(Az(c,l).MSE,o,8))return{r:f,rsquared:f*f}}return{Rsquared:u}}}function Az(e,t){let n=t,r=[e.map(a=>hi(a)),e.map(()=>De(-1,1))],i=uM(n,r);if(i){let[a,u]=i,c=[];for(let l=0;l+f.asValue());if(a.length<3)return di.NONE;a.sort(function(f,m){return f-m});let u=a.map(s),c=u.map(Math.log),l=a.map(Math.log),p=!0;return D.List.wrap(t).eachElement(f=>{isFinite(Math.log(+f.asValue()))||(p=!1)}),mM(a,c)&&p?di.LOGLIN:mM(l,c)&&p?di.LOGLOG:mM(l,u)?di.LINLOG:di.NONE}function wA({policy:e,frame:t},n,r){let i=Object.create(t);for(let a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);let s=mp({policy:e,frame:i,wrapInList:!0},n),o=s.getError();if(o)throw o;return s.asCompilerValue()}function yM(e){let t=0;for(let n of e){let r=q(n);t+=r*r}return t/e.length}function FA(e,t){let n,r,i=t._chunk;if(i&&(r=CA(i)),!r||r.length===0)return t=t.deriveRegressionRestrictions(),n=AA(e,t),{parameters:_A(n.solution,t),residuals:n.residuals,isLinear:n.isLinear,parameterWarning:!1};let s=t.getDependencies(),o=t.getCompiledFunction(s).fn,a=1/0,u={},c,l=!1;for(let p of r){let f=new pn(p.chunk);if(f=f.deriveRegressionRestrictions(),n=AA(p.forwardParameterMap(e),f),n.MSEq(d))),g=Bu(o,m);if(u&&(!isFinite(g)||g>=a)){isFinite(g)||(l=!0);continue}a=n.MSE,u=_A(m,t),c=o.apply(void 0,m)}}return{parameters:u,residuals:c,isLinear:!1,parameterWarning:l}}D.Base.prototype.analyze=function(e,t){return Gr(this)?kr(e,t,this):new k(e,t,this,this.tryGetConcreteTree(e,t))};function Dh(e,t,n,r){if(r.isError)return new k(e,t,n,r);if(!e.areAllScalesLinear()&&!Zc(r.valueType)){let u=cl(ne(r.valueType));return u.setCursorContext(r.getCursorContext()),new k(e,t,n,u)}var i=Cs(e,r),s=r.getDependencies();let o;switch(r.valueType){case St:case wn:case We:{o=r;break}case Ut:case Zn:case Ie:case Tn:case pe:case Fn:case ce:case Vn:case fe:case Bn:case Le:case Gn:case he:case kn:case Ge:case gn:case Ae:case hn:case Ue:case mr:case rt:case Be:case Rn:case Nt:case er:case Se:case nr:case In:case tr:case Nn:case yr:case mn:case Ur:i.length?o=tn(n.getSliderVariables(e,r)).setDependencies(i):o=r;break;case R:case V:case Pt:case Kn:if(i.length)if(e.validParametricVariables(i))o=r;else{var a=n.getSliderVariables(e,r);o=tn(a).setDependencies(a)}else o=r;break;case Wn:case sr:case jn:case or:case Dr:case Or:case Sr:case Cr:{i.length===0?o=r:o=tn(n.getSliderVariables(e,r)).setDependencies(i);break}case T:case se:i.length===0?o=r:i.length<=(e.is3dPolicy()?2:1)?e.is3dPolicy()&&s.length>i.length&&!e.validImplicitVariables(s)?o=tn(n.getSliderVariables(e,r)).setDependencies(s):e.validExpressionVariables(i)?o=r:o=Rm(e.implicitDependency(i)).setDependencies(i):e.validImplicitVariables(i)?o=Rm().setDependencies(i):o=tn(n.getSliderVariables(e,r)).setDependencies(s);break;default:o=J(`Programming error: unexpected value type ${r.valueType}`)}return xo(o)&&o.setCursorContext(r.getCursorContext()),o=Hc(e,n,o),new k(e,t,n,o)}function BA(e){return new D.FunctionCall(\"pdf\",[e,new D.Identifier(\"x\")])}D.Identifier.prototype.analyze=function(e,t){let n=this.tryGetConcreteTree(e,t,{coerceToNumber:!0}),r=Dh(e,t,this,n);return Gr(this)&&!hM(r)?kr(e,t,this):r};D.FunctionCall.prototype.analyze=function(e,t,n){var r;Lg[this._symbol]&&Nc(t,this).length===0&&!e.is3dPolicy()?r=BA(this).tryGetConcreteTree(e,t):r=this.tryGetConcreteTree(e,t);var i=Dh(e,t,this,r);if(Gr(this)&&!hM(i))return kr(e,t,this);var s=this.getMoveStrategy(e,t,r,n);if(s){var o=this.getDefaultDragMode(s),a=r.asCompilerValue(),u=[new D.Constant(a[0]),new D.Constant(a[1])];return new k(e,t,this,new D.MovablePoint(u,s,o))}return i};D.Expression.prototype.analyze=function(e,t){var n=Dh(e,t,this,this.tryGetConcreteTree(e,t));return Gr(this)&&!hM(n)?kr(e,t,this):n};D.FunctionDefinition.prototype.analyze=function(e,t){if(Gr(this))return kr(e,t,this);if(Ke[this._symbol])return this.asEquation().analyze(e,t);var n=this._symbol.split(\"_\")[0];if(Ke[n]&&Ke[n].isFunction)return new k(e,t,this,fl(this._symbol,n));let r=this.tryGetConcreteTree(e,t);if(r instanceof D.Error&&!r.blocksExport&&this._argSymbols.length===1){let u=Object.create(t);u[this._argSymbols[0]]=new ze(\"identityTransformation\");let c=this._expression.tryGetConcreteTree(e,u);if(!(c instanceof D.Error))return new k(e,t,this,c)}if(r.isError)return new k(e,t,this,r);var i=this._argSymbols,s=r.getDependencies();if(s.indexOf(this._symbol)!==-1)return new k(e,t,this,$a([this._symbol]));var o=s.filter(function(u){return i.indexOf(u)===-1});if(e.unplottablePolarFunction(this._symbol,s))return new k(e,t,this,bP());if(e.is3dPolicy()&&e.assignmentForbidden(this._symbol))return new k(e,t,this,Vm(this._symbol));if(o.some(function(u){return e.assignmentForbidden(u)}))return new k(e,t,this,rf(o,this._symbol,i).setDependencies(s));if(o.length){var a=this.getSliderVariables(e,r);return new k(e,t,this,tn(a).setDependencies(a))}return!e.areAllScalesLinear()&&!Zc(r.valueType)?new k(e,t,this,cl(ne(r.valueType))):(r=Hc(e,this,r),new k(e,t,this,r))};D.Assignment.prototype.analyze=function(e,t,n){if(Gr(this))return kr(e,t,this);var r=this._symbol;if(!e.validLHS(r))return new k(e,t,this,hP(r));if(Ke[r])return this.asEquation().analyze(e,t);var i;if(this._expression instanceof D.FunctionCall&&Lg[this._expression._symbol]&&Nc(t,this).length===0&&!e.is3dPolicy())i=BA(this._expression).tryGetConcreteTree(e,t);else{var s=Object.create(t);s[r]=e.validSolvedVariable(r)?void 0:rc(),i=this.tryGetConcreteTree(e,s)}if(i.isError)return new k(e,t,this,i);if(!e.areAllScalesLinear()&&!Zc(i.valueType))return new k(e,t,this,cl(ne(i.valueType)));if(this.isEquation(e,i))return this.asEquation().analyze(e,t);let o=i.valueType===Ut||i.valueType===Zn;if(e.assignmentForbidden(r)&&o){let g=yP(r).allowExport().setDependencies([r]);return new k(e,t,this,g)}let a=i.getDependencies(),u=Cs(e,i),c=u.includes(\"x\")||u.includes(\"y\"),l=u.includes(\"r\")||u.includes(\"theta\");if(r===\"r\"&&a.includes(\"phi\")){let g=u.includes(\"z\")?vm():fP();return new k(e,t,this,g)}if(r===\"rho\"&&u.includes(\"z\")){let g=a.includes(\"phi\")?vm():dP();return new k(e,t,this,g)}let p=this.getSliderVariables(e,i,a);if(e.tooManySliderVariables(a,p,o)||c&&l){let g=tn(p).allowExport().setDependencies(p);return new k(e,t,this,g)}var f=this.getMoveStrategy(e,t,i,n);if(f){var m=this.getDefaultDragMode(f);return i=new D.MovablePoint([i.elementAt(0),i.elementAt(1)],f,m),new k(e,t,this,i)}return i=Hc(e,this,i),new k(e,t,this,i)};D.RecursiveFunctionBaseCase.prototype.analyze=function(e,t){if(Gr(this))return kr(e,t,this);if(!this.specifiedArg.valid)return new k(e,t,this,this.specifiedArg.error);let n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=this._argSymbols,i=n.getDependencies();if(e.is3dPolicy()&&e.assignmentForbidden(this._symbol))return new k(e,t,this,Vm(this._symbol));var s=i.filter(function(a){return r.indexOf(a)===-1});if(s.includes(this.specifiedArg.argSymbol))return new k(e,t,this,pb(this.specifiedArg.argSymbol));for(let a of s)if(e.assignmentForbidden(a))return new k(e,t,this,lb(a));if(s.length){var o=this.getSliderVariables(e,n);return new k(e,t,this,tn(o).setDependencies(o))}return!e.areAllScalesLinear()&&!Zc(n.valueType)?new k(e,t,this,cl(ne(n.valueType))):new k(e,t,this,n)};D.CoordinateEquation.prototype.analyze=function(e,t){if(!e.validCoordinateEquationSymbol(this._concatenatedSymbol))return this.asEquation().analyze(e,t);if(Gr(this))return kr(e,t,this);let n=this.tryGetConcreteTree(e,t);return n=Hc(e,this,n),new k(e,t,this,n)};D.Regression.prototype.analyze=function(e,t,n,r,i){if(Gr(this))return kr(e,t,this);var s={policy:e,frame:t,exportFrame:n,lastExportFrame:r,priorAnalysis:i};return new k(e,t,this,VA(s,this))};function gM(e,t){var n=this.tryGetConcreteTree(e,t),r=n.getDependencies();return r.length?new k(e,t,this,tn(this.getSliderVariables(e,n)).setDependencies(r)):new k(e,t,this,this.tryGetConcreteTree(e,t))}D.Histogram.prototype.analyze=function(e,t){return Gr(this)?kr(e,t,this):e.areAllScalesLinear()?gM.call(this,e,t):new k(e,t,this,nx())};D.DotPlot.prototype.analyze=function(e,t){return Gr(this)?kr(e,t,this):e.areAllScalesLinear()?gM.call(this,e,t):new k(e,t,this,rx())};D.BoxPlot.prototype.analyze=function(e,t){return Gr(this)?kr(e,t,this):e.areAllScalesLinear()?gM.call(this,e,t):new k(e,t,this,ix())};function GA(e){return function(t,n){if(Gr(this))return kr(t,n,this);var r=this.tryGetConcreteTree(t,n),i=r.getDependencies();if(i.length)return new k(t,n,this,tn(this.getSliderVariables(t,r)).setDependencies(i));var s=new k(t,n,this,this.tryGetConcreteTree(t,n));if(!r.isError){s.evaluationState.expression_type=\"TTEST\";var o=r.args.map(function(a){return a.asValue()});s.evaluationState.ttest_results=e.apply(null,o)}return s}}D.TTest.prototype.analyze=GA(cI);D.IndependentTTest.prototype.analyze=GA(lI);D.Stats.prototype.analyze=function(e,t){if(Gr(this))return kr(e,t,this);var n=this.tryGetConcreteTree(e,t),r=n.getDependencies();if(r.length)return new k(e,t,this,tn(this.getSliderVariables(e,n)).setDependencies(r));var i=new k(e,t,this,this.tryGetConcreteTree(e,t));if(!n.isError){i.evaluationState.expression_type=\"STATS\";var s=n.args.map(function(o){return o.asValue()});i.evaluationState.stats_results=pI.apply(null,s)}return i};D.Equation.prototype.analyze=D.CallAssignment.prototype.analyze=D.BaseComparator.prototype.analyze=wz;function wz(e,t){if(Gr(this))return kr(e,t,this);var n=this.getOperator()!==\"=\";if(n&&!rs.plotInequalities)return new k(e,t,this,Dm());var r=eA({policy:e,frame:t},this);if(r.isError)return new k(e,t,this,r);let i=Cs(e,r);if(r instanceof D.SolvedEquation&&i.length){var s=i.concat(r._symbol);if(!e.validImplicitVariables(s))return new k(e,t,this,rc().setDependencies(s))}return this.getGraphMode(e,r)===8&&!e.validImplicitVariables(i)?new k(e,t,this,rc().setDependencies(i)):(r=Hc(e,this,r),new k(e,t,this,r))}D.DoubleInequality.prototype.analyze=function(e,t){if(Gr(this))return kr(e,t,this);if(!rs.plotInequalities)return new k(e,t,this,Dm());var n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=n.getDependencies();return Rr[this._operators[0]].direction!==Rr[this._operators[1]].direction?new k(e,t,this,Om()):e.validDoubleInequalitySymbol(n._symbol)?e.validDoubleInequalityVariables(r)?r.length>2?new k(e,t,this,tn(this.getSliderVariables(e,n)).setDependencies(r)):n._expressions[0].getDependencies().indexOf(n._symbol)!==-1||n._expressions[1].getDependencies().indexOf(n._symbol)!==-1?new k(e,t,this,Cm().setDependencies(r)):new k(e,t,this,n):new k(e,t,this,Sm().setDependencies(r)):new k(e,t,this,Sm().setDependencies(r))};D.ComparatorChain.prototype.analyze=function(e,t){if(Gr(this))return kr(e,t,this);var n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=n.getDependencies();if(r.length)if(e.is3dPolicy()){if(!e.validImplicitVariables(r))return new k(e,t,this,(this.symbols.includes(\"=\")?PP():MP()).setDependencies(r));if(!(this.symbols.every(s=>s===\"<\"||s===\"<=\")||this.symbols.every(s=>s===\">\"||s===\">=\")||this.symbols.every(s=>s===\"=\")))return new k(e,t,this,Om().setDependencies(r));if(this.symbols.includes(\"=\")&&!r.includes(\"z\"))return new k(e,t,this,vP().setDependencies(r));let i=this._difference.tryGetConcreteTree(e,t);return i=Hc(e,this,i),new k(e,t,this,i)}else return this.symbols.includes(\"=\")?new k(e,t,this,DP()):this.symbols.length>2?new k(e,t,this,Mb()):e.validDoubleInequalityVariables(r)?new k(e,t,this,Cm()):new k(e,t,this,tn(this.getSliderVariables(e,n)).setDependencies(r));return new k(e,t,this,n)};D.ParenSeq.prototype.analyze=function(e,t,n){if(Gr(this))return kr(e,t,this);var r=this.tryGetConcreteTree(e,t);if(r.isError)return new k(e,t,this,r);var i=this.getMoveStrategy(e,t,r,n);if(i){var s=this.getDefaultDragMode(i),o=r.asCompilerValue(),a=[new D.Constant(o[0]),new D.Constant(o[1])];return new k(e,t,this,new D.MovablePoint(a,i,s))}return Dh(e,t,this,r)};function Fz(e,t){return e.filter(function(n){return!t[n]})}function Vz(e){for(var t={},n=0;n1;u&&u.isError&&(u.isTableCycleWithoutGlobalDefinition||u.isMultiplyDefinedByTables&&!c)&&(n[a]=void 0)}var l=o.analyze(e,n);if(s===0&&l.concreteTree.isIndependent){var p=l.concreteTree.getDependencies()[0];e.validFirstColumnVariable(p)||(l=new k(e,t,o,OP()))}if(l.concreteTree.isIndependent)l.rawTree.exportToLocal(e,l.concreteTree,n);else if(!l.concreteTree.isError){var f=l.concreteTree.header.getDependencies(),m=Fz(f,n);m.length&&(l=new k(e,t,o,tn(m).setDependencies(m)))}r.push(l.concreteTree)}var g=1;for(s=0;s0){var i=r[0],s,o=Ke[i];return o?s=o.isFunction?ms(i):ic(i):s=cf(i),new k(e,t,this,s)}return new k(e,t,this,n)};D.Assignment.prototype.analyzeFourFunction=function(e,t){return new k(e,t,this,lf())};D.FunctionDefinition.prototype.analyzeFourFunction=function(e,t){return new k(e,t,this,pf())};function kA(e,t){return new k(e,t,this,ma())}D.Equation.prototype.analyzeFourFunction=kA;D.CallAssignment.prototype.analyzeFourFunction=kA;function bM(e,t){return new k(e,t,this,sc())}D.DoubleInequality.prototype.analyzeFourFunction=bM;D.ComparatorChain.prototype.analyzeFourFunction=bM;D.BaseComparator.prototype.analyzeFourFunction=bM;D.Regression.prototype.analyzeFourFunction=function(e,t){return new k(e,t,this,oc())};D.ParenSeq.prototype.analyzeFourFunction=function(e,t){return new k(e,t,this,ac())};D.Base.prototype.analyzeScientific=function(e,t){var n=this.tryGetConcreteTree(e,t);return n.isError?new k(e,t,this,n):new k(e,t,this,J(`Unexpected node type ${this.type}`))};D.Expression.prototype.analyzeScientific=function(e,t){var n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=n.getDependencies();return r.length>0?new k(e,t,this,tn(r)):new k(e,t,this,n)};D.Assignment.prototype.analyzeScientific=function(e,t){var n=this._symbol;if(Ke[n])return new k(e,t,this,fl(n));var r=Object.create(t);r[n]=ma();var i=this.tryGetConcreteTree(e,r);if(i.isError)return new k(e,t,this,i);var s=i.getDependencies();return this.isEquation(e,i)?new k(e,t,this,ma()):s.length>0?new k(e,t,this,tn(s)):new k(e,t,this,i)};D.FunctionDefinition.prototype.analyzeScientific=function(e,t){if(Ke[this._symbol])return new k(e,t,this,fl(this._symbol));var n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=this._argSymbols,i=n.getDependencies();if(i.indexOf(this._symbol)!==-1)return new k(e,t,this,$a([this._symbol]));var s=i.filter(function(o){return r.indexOf(o)===-1});return s.length?new k(e,t,this,rf(s,this._symbol,r)):new k(e,t,this,n)};function zA(e,t){return new k(e,t,this,ma())}D.Equation.prototype.analyzeScientific=zA;D.CallAssignment.prototype.analyzeScientific=zA;function xM(e,t){return new k(e,t,this,sc())}D.DoubleInequality.prototype.analyzeScientific=xM;D.ComparatorChain.prototype.analyzeScientific=xM;D.BaseComparator.prototype.analyzeScientific=xM;D.Regression.prototype.analyzeScientific=function(e,t){return new k(e,t,this,oc())};D.ParenSeq.prototype.analyzeScientific=function(e,t){return new k(e,t,this,ac())};D.Base.prototype.analyzeSingleExpressionScientific=function(e,t){var n=this.tryGetConcreteTree(e,t);return n.isError?new k(e,t,this,n):new k(e,t,this,J(`Unexpected node type ${this.type}`))};D.Expression.prototype.analyzeSingleExpressionScientific=function(e,t){var n=this.tryGetConcreteTree(e,t);if(n.isError)return new k(e,t,this,n);var r=n.getDependencies();if(r.length>0){var i=r[0],s,o=Ke[i];return o?s=o.isFunction?ms(i):ic(i):s=cf(i),new k(e,t,this,s)}return new k(e,t,this,n)};D.Assignment.prototype.analyzeSingleExpressionScientific=function(e,t){return new k(e,t,this,lf())};D.FunctionDefinition.prototype.analyzeSingleExpressionScientific=function(e,t){return new k(e,t,this,pf())};function HA(e,t){return new k(e,t,this,ma())}D.Equation.prototype.analyzeSingleExpressionScientific=HA;D.CallAssignment.prototype.analyzeSingleExpressionScientific=HA;function PM(e,t){return new k(e,t,this,sc())}D.DoubleInequality.prototype.analyzeSingleExpressionScientific=PM;D.ComparatorChain.prototype.analyzeSingleExpressionScientific=PM;D.BaseComparator.prototype.analyzeSingleExpressionScientific=PM;D.Regression.prototype.analyzeSingleExpressionScientific=function(e,t){return new k(e,t,this,oc())};D.ParenSeq.prototype.analyzeSingleExpressionScientific=function(e,t){return new k(e,t,this,ac())};D.Base.prototype.getGraphInfo=function(e,t){var n=t.getDependencies(),r,i;switch(n.length){case 0:r=UA(t),i=t.boundDomain(\"x\");break;case 1:i=t.boundDomain(n[0]),Yi(i)&&!gi(i)&&(r=UA(t));break;default:i=Xn();break}return{graphMode:this.getGraphMode(e,t),color:sa(this.userData,this.metaData),pointStyle:this.userData.pointStyle,lineStyle:this.userData.lineStyle,arrowMode:this.userData.arrowMode,operator:this.getOperator(),isLinear:!!r,linearCoefficients:r,domainBound:i}};function UA(e){switch(e.valueType){case T:return TM(e);case R:{var t=TM(e.elementAt(0)),n=TM(e.elementAt(1));return!t||!n?void 0:[t,n]}default:return}}function TM(e){var t=e.getDependencies();switch(t.length){case 0:return[+e.asValue(),0];case 1:if(e.polynomialOrder(t[0])>1)return;var n=e.getPolynomialCoefficients(t[0]);return[n[0]?+n[0].asValue():0,n[1]?+n[1].asValue():0];default:return}}var qA=new D.Constant(De(0,1));D.Base.prototype.getMoveStrategy=function(){};D.Assignment.prototype.getMoveStrategy=function(e,t,n,r){return this._expression.getMoveStrategy(e,t,n,r)};function Bz(e){return{type:\"updateSliderNonlinear\",id:e.id,initialValue:e.initialValue,min:e.min,max:e.max,compiled:e.compiled,movesOn:e.movesOn,hasLinearComponent:e.hasLinearComponent}}function Gz(e){return{type:\"updateGliderParameter\",span:e.span,movesOn:e.movesOn}}function kz(e){return{type:\"updateSliderForGlider\",id:e.sliderId,movesOn:e.movesOn,min:e.min,max:e.max}}function $A(e,t,n,r,i,s){var o=t.getDependencies();for(let y of o)if(i[y])return;for(var a=o.length-1;a>=0;a--){var u=o[a];if(!s[u]){var c=r[u];if(c!==void 0){var l=n[u];if(l.order===1){var p=l.tree,f=p.getPolynomialCoefficients(u),m=f[1]||qA,g=f[0]||qA;if(!(!g.isConstant||!m.isConstant)&&!(!isFinite(g.asValue())||!isFinite(m.asValue()))&&m.asValue()!==0){var d=[-g.asValue()/m.asValue(),1/m.asValue()];return{symbol:u,id:c,coefficients:d}}}}}}}function zz(e,t){for(var n in t){var r=t[n].evaluationState,i=r.assignment;if(i===e)return n}}function Hz(e){for(var t={},n=0;n1)return!1;let r;if(n.length===0){if(!e.tableableAsConstant(this._symbol))return!1;r=e.implicitIndependent(this._symbol)}else r=n[0];if(!e.validFirstColumnVariable(r))return!1;let i=e.assignmentForbidden(this._symbol)?wo(this.getInputString().replace(/[^=]*=/,\"\")):wo(this.getInputString().split(\"=\")[0]);return{independent_variable:r,dependent_column:i,by_reference:!e.assignmentForbidden(this._symbol)}};D.FunctionDefinition.prototype.tableInfo=function(e,t){if(this._argSymbols.length!==1||!this.getInputString().length)return!1;var n=t.getDependencies();if(n.length>1)return!1;var r=this._argSymbols[0];if(!e.validFirstColumnVariable(r))return!1;var i=e.assignmentForbidden(this._symbol),s=i?wo(this.getInputString().replace(/[^=]*=/,\"\")):wo(this.getInputString().split(\"=\")[0]);return{independent_variable:r,dependent_column:s,by_reference:!i}};D.BaseComparator.prototype.tableInfo=function(e,t){return!1};D.ComparatorChain.prototype.tableInfo=function(e,t){return!1};D.DoubleInequality.prototype.tableInfo=function(e,t){return!1};D.Equation.prototype.tableInfo=function(e,t){return!1};D.Base.prototype.tableError=function(){return this.isInequality()?S(\"shared-calculator-error-table-inequality-supplement\"):!(this instanceof D.Expression)&&!(this instanceof D.IRExpression)?S(\"shared-calculator-error-table-generic-supplement\"):!1};D.List.prototype.tableError=function(){return S(\"shared-calculator-error-table-list-supplement\")};D.Equation.prototype.tableError=D.Assignment.prototype.tableError=function(){return S(\"shared-calculator-error-table-equation-supplement\")};D.ComparatorChain.prototype.tableError=function(){return this.symbols.includes(\"=\")?S(\"shared-calculator-error-table-equation-supplement\"):S(\"shared-calculator-error-table-inequality-supplement\")};D.FunctionDefinition.prototype.tableError=function(){return S(\"shared-calculator-error-table-function-definition-supplement\")};D.Regression.prototype.tableError=function(){return S(\"shared-calculator-error-table-regression-supplement\")};D.List.prototype.elementAt=function(e){return e=Math.floor(e),e>=0&ðis.args.length-1?new D.Constant(NaN):this.args[e]};function qz(){return ur(this._symbol)+\" \"}D.Identifier.prototype.printLatex=qz;D.Constant.prototype.printLatex=function(){return ta(this.asValue())};D.Ticker.prototype.printLatex=function(){return\"\\\\ticker\\\\left(\"+this.args.map(mi).join(\", \")+\"\\\\right)\"};D.Negative.prototype.printLatex=function(){return\"-\\\\left(\"+this.args[0].printLatex()+\"\\\\right)\"};D.Add.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)+\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.PercentOf.prototype.printLatex=function(){return this.args[0].printLatex()+\" \\\\% \\\\operatorname{of} \"+this.args[1].printLatex()};D.Subtract.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)-\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.Multiply.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)*\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.DotMultiply.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)\\\\cdot\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.CrossMultiply.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)\\\\times\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.Divide.prototype.printLatex=function(){return\"\\\\frac{\"+this.args[0].printLatex()+\"}{\"+this.args[1].printLatex()+\"}\"};D.Exponent.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)^{\"+this.args[1].printLatex()+\"}\"};D.Assignment.prototype.printLatex=function(){return ur(this._symbol)+\"=\"+this._expression.printLatex()};D.CoordinateEquation.prototype.printLatex=function(){return\"\\\\left(\"+this._symbols.map(e=>ur(e)).join(\",\")+\"\\\\right)=\"+this._expression.printLatex()};D.Equation.prototype.printLatex=D.CallAssignment.prototype.printLatex=function(){return this._lhs.printLatex()+\"=\"+this._rhs.printLatex()};function Sh(e){switch(e){case\">\":return\">\";case\"<\":return\"<\";case\">=\":return\"\\\\ge \";case\"<=\":return\"\\\\le \";case\"=\":return\"=\"}return\"\"}D.BaseComparator.prototype.printLatex=function(){return\"\\\\left(\"+this.args[0].printLatex()+\"\\\\right)\"+Sh(this.operator)+\"\\\\left(\"+this.args[1].printLatex()+\"\\\\right)\"};D.ComparatorChain.prototype.printLatex=function(){let e=\"\";for(let t=0;t