mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
2 lines • 395 kB
JavaScript
/*! For license information please see mathjslab.node.cjs2015.js.LICENSE.txt */
(()=>{var __webpack_modules__={109:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nodeElse=t.nodeElseIf=t.nodeIfAppendElseIf=t.nodeIfAppendElse=t.nodeIfBegin=t.nodeAppendDeclaration=t.nodeDeclarationFirst=t.nodeArguments=t.nodeArgumentValidation=t.nodeFunction=t.nodeFunctionHandle=t.nodeReturnList=t.nodeIndirectRef=t.nodeAppendRow=t.nodeFirstRow=t.nodeList=t.appendNodeList=t.nodeListFirst=t.nodeOp=t.nodeRange=t.nodeIndexExpr=t.nodeCmdWList=t.nodeIdentifier=t.nodeLiteral=t.emptyArray=t.appendRow=t.firstRow=t.nodeNumber=t.nodeString=void 0;const n=r(956),i=r(826),s=r(271),a=r(679),o=n.CharString.create;t.nodeString=o;const l=i.ComplexDecimal.parse;t.nodeNumber=l;const c=a.MultiArray.firstRow;t.firstRow=c;const h=a.MultiArray.appendRow;t.appendRow=h;const u=a.MultiArray.emptyArray;t.emptyArray=u,t.nodeLiteral=e=>({type:e}),t.nodeIdentifier=e=>({type:"IDENT",id:e.replace(/(\r\n|[\n\r])|[\ ]/gm,"")}),t.nodeCmdWList=(e,t)=>({type:"CMDWLIST",id:e.id,args:t?t.list:[],omitAns:!0}),t.nodeIndexExpr=(e,t=null,r="()")=>({type:"IDX",expr:e,args:t?t.list:[],delim:r}),t.nodeRange=(e,t,r)=>({type:"RANGE",start_:e,stop_:t,stride_:null!=r?r:null}),t.nodeOp=(e,t,r)=>{switch(e){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":return{type:e,left:t,right:r};case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":return{type:e,left:t,right:r,omitAns:!0};case"()":case"!":case"~":case"+_":case"-_":return{type:e,right:t};case"++_":case"--_":return{type:e,right:t,omitAns:!0};case".'":case"'":return{type:e,left:t};case"_++":case"_--":return{type:e,left:t,omitAns:!0};default:return{type:`INVALID:${e}`}}},t.nodeListFirst=e=>{if(e){const t={type:"LIST",list:[e]};return e.parent=t,t}return{type:"LIST",list:[]}},t.appendNodeList=(e,t)=>(t.parent=e,e.list.push(t),e),t.nodeList=e=>({type:"LIST",list:e}),t.nodeFirstRow=(e=null,t)=>e?c(e.list,t):u(t),t.nodeAppendRow=(e,t=null)=>t?h(e,t.list):e,t.nodeIndirectRef=(e,t)=>"."===e.type?(e.field.push(t),e):{type:".",obj:e,field:[t]},t.nodeReturnList=e=>({type:"RETLIST",selector:e}),t.nodeFunctionHandle=(e=null,t=null,r=null)=>new s.FunctionHandle(e?e.id:null,!0,t?t.list:[],r),t.nodeFunction=(e,t,r,n,i)=>({type:"FCN",id:e.id,return:t.list,parameter:r.list,arguments:n.list,statements:i.list}),t.nodeArgumentValidation=(e,t,r=null,n,i=null)=>({name:e,size:t.list,class:r,functions:n.list,default:i}),t.nodeArguments=(e,t)=>({attribute:e,validation:t.list}),t.nodeDeclarationFirst=e=>({type:e,list:[]}),t.nodeAppendDeclaration=(e,t)=>(e.list.push(t),e),t.nodeIfBegin=(e,t)=>({type:"IF",expression:[e],then:[t],else:null,omitAns:!0}),t.nodeIfAppendElse=(e,t)=>(e.else=t.else,e),t.nodeIfAppendElseIf=(e,t)=>(e.expression.push(t.expression),e.then.push(t.then),e),t.nodeElseIf=(e,t)=>({expression:e,then:t}),t.nodeElse=e=>({else:e})},110:function(e,t,r){var n;!function(){"use strict";var i,s,a,o=9e15,l=1e9,c="0123456789abcdef",h="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",u="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",d={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},p=!0,m="[DecimalError] ",f=m+"Invalid argument: ",_=m+"Precision limit exceeded",g=m+"crypto unavailable",x="[object Decimal]",E=Math.floor,L=Math.pow,T=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,y=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,A=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,C=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,N=1e7,S=h.length-1,M=u.length-1,R={toStringTag:x};function I(e){var t,r,n,i=e.length-1,s="",a=e[0];if(i>0){for(s+=a,t=1;t<i;t++)(r=7-(n=e[t]+"").length)&&(s+=B(r)),s+=n;(r=7-(n=(a=e[t])+"").length)&&(s+=B(r))}else if(0===a)return"0";for(;a%10==0;)a/=10;return s+a}function b(e,t,r){if(e!==~~e||e<t||e>r)throw Error(f+e)}function w(e,t,r,n){var i,s,a,o;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=7,i=0):(i=Math.ceil((t+1)/7),t%=7),s=L(10,7-t),o=e[i]%s|0,null==n?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),a=r<4&&99999==o||r>3&&49999==o||5e4==o||0==o):a=(r<4&&o+1==s||r>3&&o+1==s/2)&&(e[i+1]/s/100|0)==L(10,t-2)-1||(o==s/2||0==o)&&!(e[i+1]/s/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),a=(n||r<4)&&9999==o||!n&&r>3&&4999==o):a=((n||r<4)&&o+1==s||!n&&r>3&&o+1==s/2)&&(e[i+1]/s/1e3|0)==L(10,t-3)-1,a}function D(e,t,r){for(var n,i,s=[0],a=0,o=e.length;a<o;){for(i=s.length;i--;)s[i]*=t;for(s[0]+=c.indexOf(e.charAt(a++)),n=0;n<s.length;n++)s[n]>r-1&&(void 0===s[n+1]&&(s[n+1]=0),s[n+1]+=s[n]/r|0,s[n]%=r)}return s.reverse()}R.absoluteValue=R.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),v(e)},R.ceil=function(){return v(new this.constructor(this),this.e+1,2)},R.clampedTo=R.clamp=function(e,t){var r=this,n=r.constructor;if(e=new n(e),t=new n(t),!e.s||!t.s)return new n(NaN);if(e.gt(t))throw Error(f+t);return r.cmp(e)<0?e:r.cmp(t)>0?t:new n(r)},R.comparedTo=R.cmp=function(e){var t,r,n,i,s=this,a=s.d,o=(e=new s.constructor(e)).d,l=s.s,c=e.s;if(!a||!o)return l&&c?l!==c?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-c:0;if(l!==c)return l;if(s.e!==e.e)return s.e>e.e^l<0?1:-1;for(t=0,r=(n=a.length)<(i=o.length)?n:i;t<r;++t)if(a[t]!==o[t])return a[t]>o[t]^l<0?1:-1;return n===i?0:n>i^l<0?1:-1},R.cosine=R.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n,i;if(t.isZero())return t;(n=t.d.length)<32?i=(1/$(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=X(e,1,t.times(i),new e(1));for(var s=r;s--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return e.precision-=r,t}(n,K(n,r)),n.precision=e,n.rounding=t,v(2==a||3==a?r.neg():r,e,t,!0)):new n(1):new n(NaN)},R.cubeRoot=R.cbrt=function(){var e,t,r,n,i,s,a,o,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(p=!1,(s=h.s*L(h.s*h,1/3))&&Math.abs(s)!=1/0?n=new u(s.toString()):(r=I(h.d),(s=((e=h.e)-r.length+1)%3)&&(r+=1==s||-2==s?"0":"00"),s=L(r,1/3),e=E((e+1)/3)-(e%3==(e<0?-1:2)),(n=new u(r=s==1/0?"5e"+e:(r=s.toExponential()).slice(0,r.indexOf("e")+1)+e)).s=h.s),a=(e=u.precision)+3;;)if(c=(l=(o=n).times(o).times(o)).plus(h),n=O(c.plus(h).times(o),c.plus(l),a+2,1),I(o.d).slice(0,a)===(r=I(n.d)).slice(0,a)){if("9999"!=(r=r.slice(a-3,a+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(v(n,e+1,1),t=!n.times(n).times(n).eq(h));break}if(!i&&(v(o,e+1,0),o.times(o).times(o).eq(h))){n=o;break}a+=4,i=1}return p=!0,v(n,e,u.rounding,t)},R.decimalPlaces=R.dp=function(){var e,t=this.d,r=NaN;if(t){if(r=7*((e=t.length-1)-E(this.e/7)),e=t[e])for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},R.dividedBy=R.div=function(e){return O(this,new this.constructor(e))},R.dividedToIntegerBy=R.divToInt=function(e){var t=this.constructor;return v(O(this,new t(e),0,1,1),t.precision,t.rounding)},R.equals=R.eq=function(e){return 0===this.cmp(e)},R.floor=function(){return v(new this.constructor(this),this.e+1,3)},R.greaterThan=R.gt=function(e){return this.cmp(e)>0},R.greaterThanOrEqualTo=R.gte=function(e){var t=this.cmp(e);return 1==t||0===t},R.hyperbolicCosine=R.cosh=function(){var e,t,r,n,i,s=this,a=s.constructor,o=new a(1);if(!s.isFinite())return new a(s.s?1/0:NaN);if(s.isZero())return o;r=a.precision,n=a.rounding,a.precision=r+Math.max(s.e,s.sd())+4,a.rounding=1,(i=s.d.length)<32?t=(1/$(4,e=Math.ceil(i/3))).toString():(e=16,t="2.3283064365386962890625e-10"),s=X(a,1,s.times(t),new a(1),!0);for(var l,c=e,h=new a(8);c--;)l=s.times(s),s=o.minus(l.times(h.minus(l.times(h))));return v(s,a.precision=r,a.rounding=n,!0)},R.hyperbolicSine=R.sinh=function(){var e,t,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,(n=i.d.length)<3)i=X(s,2,i,i,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,i=X(s,2,i=i.times(1/$(5,e)),i,!0);for(var a,o=new s(5),l=new s(16),c=new s(20);e--;)a=i.times(i),i=i.times(o.plus(a.times(l.times(a).plus(c))))}return s.precision=t,s.rounding=r,v(i,t,r,!0)},R.hyperbolicTangent=R.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,O(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},R.inverseCosine=R.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return-1!==r?0===r?e.isNeg()?F(t,n,i):new t(0):new t(NaN):e.isZero()?F(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))},R.inverseHyperbolicCosine=R.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,p=!1,r=r.times(r).minus(1).sqrt().plus(r),p=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},R.inverseHyperbolicSine=R.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,p=!1,r=r.times(r).plus(1).sqrt().plus(r),p=!0,n.precision=e,n.rounding=t,r.ln())},R.inverseHyperbolicTangent=R.atanh=function(){var e,t,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?v(new s(i),e,t,!0):(s.precision=r=n-i.e,i=O(i.plus(1),new s(1).minus(i),r+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)},R.inverseSine=R.asin=function(){var e,t,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),r=s.precision,n=s.rounding,-1!==t?0===t?((e=F(s,r+4,n).times(.5)).s=i.s,e):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))},R.inverseTangent=R.atan=function(){var e,t,r,n,i,s,a,o,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=M)return(a=F(h,u+4,d).times(.25)).s=c.s,a}else{if(!c.s)return new h(NaN);if(u+4<=M)return(a=F(h,u+4,d).times(.5)).s=c.s,a}for(h.precision=o=u+10,h.rounding=1,e=r=Math.min(28,o/7+2|0);e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(p=!1,t=Math.ceil(o/7),n=1,l=c.times(c),a=new h(c),i=c;-1!==e;)if(i=i.times(l),s=a.minus(i.div(n+=2)),i=i.times(l),void 0!==(a=s.plus(i.div(n+=2))).d[t])for(e=t;a.d[e]===s.d[e]&&e--;);return r&&(a=a.times(2<<r-1)),p=!0,v(a,h.precision=u,h.rounding=d,!0)},R.isFinite=function(){return!!this.d},R.isInteger=R.isInt=function(){return!!this.d&&E(this.e/7)>this.d.length-2},R.isNaN=function(){return!this.s},R.isNegative=R.isNeg=function(){return this.s<0},R.isPositive=R.isPos=function(){return this.s>0},R.isZero=function(){return!!this.d&&0===this.d[0]},R.lessThan=R.lt=function(e){return this.cmp(e)<0},R.lessThanOrEqualTo=R.lte=function(e){return this.cmp(e)<1},R.logarithm=R.log=function(e){var t,r,n,i,s,a,o,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(null==e)e=new h(10),t=!0;else{if(r=(e=new h(e)).d,e.s<0||!r||!r[0]||e.eq(1))return new h(NaN);t=e.eq(10)}if(r=c.d,c.s<0||!r||!r[0]||c.eq(1))return new h(r&&!r[0]?-1/0:1!=c.s?NaN:r?0:1/0);if(t)if(r.length>1)s=!0;else{for(i=r[0];i%10==0;)i/=10;s=1!==i}if(p=!1,a=q(c,o=u+5),n=t?U(h,o+10):q(e,o),w((l=O(a,n,o,1)).d,i=u,d))do{if(a=q(c,o+=10),n=t?U(h,o+10):q(e,o),l=O(a,n,o,1),!s){+I(l.d).slice(i+1,i+15)+1==1e14&&(l=v(l,u+1,0));break}}while(w(l.d,i+=10,d));return p=!0,v(l,u,d)},R.minus=R.sub=function(e){var t,r,n,i,s,a,o,l,c,h,u,d,m=this,f=m.constructor;if(e=new f(e),!m.d||!e.d)return m.s&&e.s?m.d?e.s=-e.s:e=new f(e.d||m.s!==e.s?m:NaN):e=new f(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(c=m.d,d=e.d,o=f.precision,l=f.rounding,!c[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!c[0])return new f(3===l?-0:0);e=new f(m)}return p?v(e,o,l):e}if(r=E(e.e/7),h=E(m.e/7),c=c.slice(),s=h-r){for((u=s<0)?(t=c,s=-s,a=d.length):(t=d,r=h,a=c.length),s>(n=Math.max(Math.ceil(o/7),a)+2)&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for((u=(n=c.length)<(a=d.length))&&(a=n),n=0;n<a;n++)if(c[n]!=d[n]){u=c[n]<d[n];break}s=0}for(u&&(t=c,c=d,d=t,e.s=-e.s),a=c.length,n=d.length-a;n>0;--n)c[a++]=0;for(n=d.length;n>s;){if(c[--n]<d[n]){for(i=n;i&&0===c[--i];)c[i]=N-1;--c[i],c[n]+=N}c[n]-=d[n]}for(;0===c[--a];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(e.d=c,e.e=k(c,r),p?v(e,o,l):e):new f(3===l?-0:0)},R.modulo=R.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?v(new n(r),n.precision,n.rounding):(p=!1,9==n.modulo?(t=O(r,e.abs(),0,3,1)).s*=e.s:t=O(r,e,0,n.modulo,1),t=t.times(e),p=!0,r.minus(t))},R.naturalExponential=R.exp=function(){return G(this)},R.naturalLogarithm=R.ln=function(){return q(this)},R.negated=R.neg=function(){var e=new this.constructor(this);return e.s=-e.s,v(e)},R.plus=R.add=function(e){var t,r,n,i,s,a,o,l,c,h,u=this,d=u.constructor;if(e=new d(e),!u.d||!e.d)return u.s&&e.s?u.d||(e=new d(e.d||u.s===e.s?u:NaN)):e=new d(NaN),e;if(u.s!=e.s)return e.s=-e.s,u.minus(e);if(c=u.d,h=e.d,o=d.precision,l=d.rounding,!c[0]||!h[0])return h[0]||(e=new d(u)),p?v(e,o,l):e;if(s=E(u.e/7),n=E(e.e/7),c=c.slice(),i=s-n){for(i<0?(r=c,i=-i,a=h.length):(r=h,n=s,a=c.length),i>(a=(s=Math.ceil(o/7))>a?s+1:a+1)&&(i=a,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((a=c.length)-(i=h.length)<0&&(i=a,r=h,h=c,c=r),t=0;i;)t=(c[--i]=c[i]+h[i]+t)/N|0,c[i]%=N;for(t&&(c.unshift(t),++n),a=c.length;0==c[--a];)c.pop();return e.d=c,e.e=k(c,n),p?v(e,o,l):e},R.precision=R.sd=function(e){var t,r=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(f+e);return r.d?(t=H(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},R.round=function(){var e=this,t=e.constructor;return v(new t(e),e.e+1,t.rounding)},R.sine=R.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:X(e,2,t,t);r=(r=1.4*Math.sqrt(n))>16?16:0|r,t=X(e,2,t=t.times(1/$(5,r)),t);for(var i,s=new e(5),a=new e(16),o=new e(20);r--;)i=t.times(t),t=t.times(s.plus(i.times(a.times(i).minus(o))));return t}(n,K(n,r)),n.precision=e,n.rounding=t,v(a>2?r.neg():r,e,t,!0)):new n(NaN)},R.squareRoot=R.sqrt=function(){var e,t,r,n,i,s,a=this,o=a.d,l=a.e,c=a.s,h=a.constructor;if(1!==c||!o||!o[0])return new h(!c||c<0&&(!o||o[0])?NaN:o?a:1/0);for(p=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=I(o)).length+l)%2==0&&(t+="0"),c=Math.sqrt(t),l=E((l+1)/2)-(l<0||l%2),n=new h(t=c==1/0?"5e"+l:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+l)):n=new h(c.toString()),r=(l=h.precision)+3;;)if(n=(s=n).plus(O(a,s,r+2,1)).times(.5),I(s.d).slice(0,r)===(t=I(n.d)).slice(0,r)){if("9999"!=(t=t.slice(r-3,r+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(v(n,l+1,1),e=!n.times(n).eq(a));break}if(!i&&(v(s,l+1,0),s.times(s).eq(a))){n=s;break}r+=4,i=1}return p=!0,v(n,l,h.rounding,e)},R.tangent=R.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(r=r.sin()).s=1,r=O(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,v(2==a||4==a?r.neg():r,e,t,!0)):new n(NaN)},R.times=R.mul=function(e){var t,r,n,i,s,a,o,l,c,h=this,u=h.constructor,d=h.d,m=(e=new u(e)).d;if(e.s*=h.s,!(d&&d[0]&&m&&m[0]))return new u(!e.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:d&&m?0*e.s:e.s/0);for(r=E(h.e/7)+E(e.e/7),(l=d.length)<(c=m.length)&&(s=d,d=m,m=s,a=l,l=c,c=a),s=[],n=a=l+c;n--;)s.push(0);for(n=c;--n>=0;){for(t=0,i=l+n;i>n;)o=s[i]+m[n]*d[i-n-1]+t,s[i--]=o%N|0,t=o/N|0;s[i]=(s[i]+t)%N|0}for(;!s[--a];)s.pop();return t?++r:s.shift(),e.d=s,e.e=k(s,r),p?v(e,u.precision,u.rounding):e},R.toBinary=function(e,t){return Y(this,2,e,t)},R.toDecimalPlaces=R.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(b(e,0,l),void 0===t?t=n.rounding:b(t,0,8),v(r,e+r.e+1,t))},R.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=P(n,!0):(b(e,0,l),void 0===t?t=i.rounding:b(t,0,8),r=P(n=v(new i(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},R.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return void 0===e?r=P(i):(b(e,0,l),void 0===t?t=s.rounding:b(t,0,8),r=P(n=v(new s(i),e+i.e+1,t),!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},R.toFraction=function(e){var t,r,n,i,s,a,o,l,c,h,u,d,m=this,_=m.d,g=m.constructor;if(!_)return new g(m);if(c=r=new g(1),n=l=new g(0),a=(s=(t=new g(n)).e=H(_)-m.e-1)%7,t.d[0]=L(10,a<0?7+a:a),null==e)e=s>0?t:c;else{if(!(o=new g(e)).isInt()||o.lt(c))throw Error(f+o);e=o.gt(t)?s>0?t:c:o}for(p=!1,o=new g(I(_)),h=g.precision,g.precision=s=7*_.length*2;u=O(o,t,0,1,1),1!=(i=r.plus(u.times(n))).cmp(e);)r=n,n=i,i=c,c=l.plus(u.times(i)),l=i,i=t,t=o.minus(u.times(i)),o=i;return i=O(e.minus(r),n,0,1,1),l=l.plus(i.times(c)),r=r.plus(i.times(n)),l.s=c.s=m.s,d=O(c,n,s,1).minus(m).abs().cmp(O(l,r,s,1).minus(m).abs())<1?[c,n]:[l,r],g.precision=h,p=!0,d},R.toHexadecimal=R.toHex=function(e,t){return Y(this,16,e,t)},R.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),null==e){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:b(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(p=!1,r=O(r,e,0,t,1).times(e),p=!0,v(r)):(e.s=r.s,r=e),r},R.toNumber=function(){return+this},R.toOctal=function(e,t){return Y(this,8,e,t)},R.toPower=R.pow=function(e){var t,r,n,i,s,a,o=this,l=o.constructor,c=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(L(+o,c));if((o=new l(o)).eq(1))return o;if(n=l.precision,s=l.rounding,e.eq(1))return v(o,n,s);if((t=E(e.e/7))>=e.d.length-1&&(r=c<0?-c:c)<=9007199254740991)return i=J(l,o,r,n),e.s<0?new l(1).div(i):v(i,n,s);if((a=o.s)<0){if(t<e.d.length-1)return new l(NaN);if(1&e.d[t]||(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(t=0!=(r=L(+o,c))&&isFinite(r)?new l(r+"").e:E(c*(Math.log("0."+I(o.d))/Math.LN10+o.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?a/0:0):(p=!1,l.rounding=o.s=1,r=Math.min(12,(t+"").length),(i=G(e.times(q(o,n+r)),n)).d&&w((i=v(i,n+5,1)).d,n,s)&&(t=n+10,+I((i=v(G(e.times(q(o,t+r)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=v(i,n+1,0))),i.s=a,p=!0,l.rounding=s,v(i,n,s))},R.toPrecision=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=P(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(b(e,1,l),void 0===t?t=i.rounding:b(t,0,8),r=P(n=v(new i(n),e,t),e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},R.toSignificantDigits=R.toSD=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(b(e,1,l),void 0===t?t=r.rounding:b(t,0,8)),v(new r(this),e,t)},R.toString=function(){var e=this,t=e.constructor,r=P(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},R.truncated=R.trunc=function(){return v(new this.constructor(this),this.e+1,1)},R.valueOf=R.toJSON=function(){var e=this,t=e.constructor,r=P(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};var O=function(){function e(e,t,r){var n,i=0,s=e.length;for(e=e.slice();s--;)n=e[s]*t+i,e[s]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(e[i]!=t[i]){s=e[i]>t[i]?1:-1;break}return s}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,a,o,l,c){var h,u,d,p,m,f,_,g,x,L,T,y,A,C,S,M,R,I,b,w,D=n.constructor,O=n.s==i.s?1:-1,P=n.d,k=i.d;if(!(P&&P[0]&&k&&k[0]))return new D(n.s&&i.s&&(P?!k||P[0]!=k[0]:k)?P&&0==P[0]||!k?0*O:O/0:NaN);for(c?(m=1,u=n.e-i.e):(c=N,m=7,u=E(n.e/m)-E(i.e/m)),b=k.length,R=P.length,L=(x=new D(O)).d=[],d=0;k[d]==(P[d]||0);d++);if(k[d]>(P[d]||0)&&u--,null==a?(C=a=D.precision,o=D.rounding):C=l?a+(n.e-i.e)+1:a,C<0)L.push(1),f=!0;else{if(C=C/m+2|0,d=0,1==b){for(p=0,k=k[0],C++;(d<R||p)&&C--;d++)S=p*c+(P[d]||0),L[d]=S/k|0,p=S%k|0;f=p||d<R}else{for((p=c/(k[0]+1)|0)>1&&(k=e(k,p,c),P=e(P,p,c),b=k.length,R=P.length),M=b,y=(T=P.slice(0,b)).length;y<b;)T[y++]=0;(w=k.slice()).unshift(0),I=k[0],k[1]>=c/2&&++I;do{p=0,(h=t(k,T,b,y))<0?(A=T[0],b!=y&&(A=A*c+(T[1]||0)),(p=A/I|0)>1?(p>=c&&(p=c-1),1==(h=t(_=e(k,p,c),T,g=_.length,y=T.length))&&(p--,r(_,b<g?w:k,g,c))):(0==p&&(h=p=1),_=k.slice()),(g=_.length)<y&&_.unshift(0),r(T,_,y,c),-1==h&&(h=t(k,T,b,y=T.length))<1&&(p++,r(T,b<y?w:k,y,c)),y=T.length):0===h&&(p++,T=[0]),L[d++]=p,h&&T[0]?T[y++]=P[M]||0:(T=[P[M]],y=1)}while((M++<R||void 0!==T[0])&&C--);f=void 0!==T[0]}L[0]||L.shift()}if(1==m)x.e=u,s=f;else{for(d=1,p=L[0];p>=10;p/=10)d++;x.e=d+u*m-1,v(x,l?a+x.e+1:a,o,f)}return x}}();function v(e,t,r,n){var i,s,a,o,l,c,h,u,d,m=e.constructor;e:if(null!=t){if(!(u=e.d))return e;for(i=1,o=u[0];o>=10;o/=10)i++;if((s=t-i)<0)s+=7,a=t,l=(h=u[d=0])/L(10,i-a-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(o=u.length)){if(!n)break e;for(;o++<=d;)u.push(0);h=l=0,i=1,a=(s%=7)-7+1}else{for(h=o=u[d],i=1;o>=10;o/=10)i++;l=(a=(s%=7)-7+i)<0?0:h/L(10,i-a-1)%10|0}if(n=n||t<0||void 0!==u[d+1]||(a<0?h:h%L(10,i-a-1)),c=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(s>0?a>0?h/L(10,i-a):0:u[d-1])%10&1||r==(e.s<0?8:7)),t<1||!u[0])return u.length=0,c?(t-=e.e+1,u[0]=L(10,(7-t%7)%7),e.e=-t||0):u[0]=e.e=0,e;if(0==s?(u.length=d,o=1,d--):(u.length=d+1,o=L(10,7-s),u[d]=a>0?(h/L(10,i-a)%L(10,a)|0)*o:0),c)for(;;){if(0==d){for(s=1,a=u[0];a>=10;a/=10)s++;for(a=u[0]+=o,o=1;a>=10;a/=10)o++;s!=o&&(e.e++,u[0]==N&&(u[0]=1));break}if(u[d]+=o,u[d]!=N)break;u[d--]=0,o=1}for(s=u.length;0===u[--s];)u.pop()}return p&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function P(e,t,r){if(!e.isFinite())return W(e);var n,i=e.e,s=I(e.d),a=s.length;return t?(r&&(n=r-a)>0?s=s.charAt(0)+"."+s.slice(1)+B(n):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+B(-i-1)+s,r&&(n=r-a)>0&&(s+=B(n))):i>=a?(s+=B(i+1-a),r&&(n=r-i-1)>0&&(s=s+"."+B(n))):((n=i+1)<a&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-a)>0&&(i+1===a&&(s+="."),s+=B(n))),s}function k(e,t){var r=e[0];for(t*=7;r>=10;r/=10)t++;return t}function U(e,t,r){if(t>S)throw p=!0,r&&(e.precision=r),Error(_);return v(new e(h),t,1,!0)}function F(e,t,r){if(t>M)throw Error(_);return v(new e(u),t,r,!0)}function H(e){var t=e.length-1,r=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function B(e){for(var t="";e--;)t+="0";return t}function J(e,t,r,n){var i,s=new e(1),a=Math.ceil(n/7+4);for(p=!1;;){if(r%2&&Z((s=s.times(t)).d,a)&&(i=!0),0===(r=E(r/2))){r=s.d.length-1,i&&0===s.d[r]&&++s.d[r];break}Z((t=t.times(t)).d,a)}return p=!0,s}function Q(e){return 1&e.d[e.d.length-1]}function V(e,t,r){for(var n,i,s=new e(t[0]),a=0;++a<t.length;){if(!(i=new e(t[a])).s){s=i;break}((n=s.cmp(i))===r||0===n&&s.s===r)&&(s=i)}return s}function G(e,t){var r,n,i,s,a,o,l,c=0,h=0,u=0,d=e.constructor,m=d.rounding,f=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(p=!1,l=f):l=t,o=new d(.03125);e.e>-2;)e=e.times(o),u+=5;for(l+=n=Math.log(L(2,u))/Math.LN10*2+5|0,r=s=a=new d(1),d.precision=l;;){if(s=v(s.times(e),l,1),r=r.times(++h),I((o=a.plus(O(s,r,l,1))).d).slice(0,l)===I(a.d).slice(0,l)){for(i=u;i--;)a=v(a.times(a),l,1);if(null!=t)return d.precision=f,a;if(!(c<3&&w(a.d,l-n,m,c)))return v(a,d.precision=f,m,p=!0);d.precision=l+=10,r=s=o=new d(1),h=0,c++}a=o}}function q(e,t){var r,n,i,s,a,o,l,c,h,u,d,m=1,f=e,_=f.d,g=f.constructor,x=g.rounding,E=g.precision;if(f.s<0||!_||!_[0]||!f.e&&1==_[0]&&1==_.length)return new g(_&&!_[0]?-1/0:1!=f.s?NaN:_?0:f);if(null==t?(p=!1,h=E):h=t,g.precision=h+=10,n=(r=I(_)).charAt(0),!(Math.abs(s=f.e)<15e14))return c=U(g,h+2,E).times(s+""),f=q(new g(n+"."+r.slice(1)),h-10).plus(c),g.precision=E,null==t?v(f,E,x,p=!0):f;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=I((f=f.times(e)).d)).charAt(0),m++;for(s=f.e,n>1?(f=new g("0."+r),s++):f=new g(n+"."+r.slice(1)),u=f,l=a=f=O(f.minus(1),f.plus(1),h,1),d=v(f.times(f),h,1),i=3;;){if(a=v(a.times(d),h,1),I((c=l.plus(O(a,new g(i),h,1))).d).slice(0,h)===I(l.d).slice(0,h)){if(l=l.times(2),0!==s&&(l=l.plus(U(g,h+2,E).times(s+""))),l=O(l,new g(m),h,1),null!=t)return g.precision=E,l;if(!w(l.d,h-10,x,o))return v(l,g.precision=E,x,p=!0);g.precision=h+=10,c=a=f=O(u.minus(1),u.plus(1),h,1),d=v(f.times(f),h,1),i=o=1}l=c,i+=2}}function W(e){return String(e.s*e.s/0)}function j(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%7,r<0&&(n+=7),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=7;n<i;)e.d.push(+t.slice(n,n+=7));n=7-(t=t.slice(n)).length}else n-=i;for(;n--;)t+="0";e.d.push(+t),p&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function z(e,t){var r,n,s,a,o,l,c,h,u;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),C.test(t))return j(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(y.test(t))r=16,t=t.toLowerCase();else if(T.test(t))r=2;else{if(!A.test(t))throw Error(f+t);r=8}for((a=t.search(/p/i))>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),o=(a=t.indexOf("."))>=0,n=e.constructor,o&&(a=(l=(t=t.replace(".","")).length)-a,s=J(n,new n(r),a,2*a)),a=u=(h=D(t,r,N)).length-1;0===h[a];--a)h.pop();return a<0?new n(0*e.s):(e.e=k(h,u),e.d=h,p=!1,o&&(e=O(e,s,4*l)),c&&(e=e.times(Math.abs(c)<54?L(2,c):i.pow(2,c))),p=!0,e)}function X(e,t,r,n,i){var s,a,o,l,c=e.precision,h=Math.ceil(c/7);for(p=!1,l=r.times(r),o=new e(n);;){if(a=O(o.times(l),new e(t++*t++),c,1),o=i?n.plus(a):n.minus(a),n=O(a.times(l),new e(t++*t++),c,1),void 0!==(a=o.plus(n)).d[h]){for(s=h;a.d[s]===o.d[s]&&s--;);if(-1==s)break}s=o,o=n,n=a,a=s}return p=!0,a.d.length=h+1,a}function $(e,t){for(var r=e;--t;)r*=e;return r}function K(e,t){var r,n=t.s<0,i=F(e,e.precision,1),s=i.times(.5);if((t=t.abs()).lte(s))return a=n?4:1,t;if((r=t.divToInt(i)).isZero())a=n?3:2;else{if((t=t.minus(r.times(i))).lte(s))return a=Q(r)?n?2:3:n?4:1,t;a=Q(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Y(e,t,r,n){var i,a,o,h,u,d,p,m,f,_=e.constructor,g=void 0!==r;if(g?(b(r,1,l),void 0===n?n=_.rounding:b(n,0,8)):(r=_.precision,n=_.rounding),e.isFinite()){for(g?(i=2,16==t?r=4*r-3:8==t&&(r=3*r-2)):i=t,(o=(p=P(e)).indexOf("."))>=0&&(p=p.replace(".",""),(f=new _(1)).e=p.length-o,f.d=D(P(f),10,i),f.e=f.d.length),a=u=(m=D(p,10,i)).length;0==m[--u];)m.pop();if(m[0]){if(o<0?a--:((e=new _(e)).d=m,e.e=a,m=(e=O(e,f,r,n,0,i)).d,a=e.e,d=s),o=m[r],h=i/2,d=d||void 0!==m[r+1],d=n<4?(void 0!==o||d)&&(0===n||n===(e.s<0?3:2)):o>h||o===h&&(4===n||d||6===n&&1&m[r-1]||n===(e.s<0?8:7)),m.length=r,d)for(;++m[--r]>i-1;)m[r]=0,r||(++a,m.unshift(1));for(u=m.length;!m[u-1];--u);for(o=0,p="";o<u;o++)p+=c.charAt(m[o]);if(g){if(u>1)if(16==t||8==t){for(o=16==t?4:3,--u;u%o;u++)p+="0";for(u=(m=D(p,i,t)).length;!m[u-1];--u);for(o=1,p="1.";o<u;o++)p+=c.charAt(m[o])}else p=p.charAt(0)+"."+p.slice(1);p=p+(a<0?"p":"p+")+a}else if(a<0){for(;++a;)p="0"+p;p="0."+p}else if(++a>u)for(a-=u;a--;)p+="0";else a<u&&(p=p.slice(0,a)+"."+p.slice(a))}else p=g?"0p+0":"0";p=(16==t?"0x":2==t?"0b":8==t?"0o":"")+p}else p=W(e);return e.s<0?"-"+p:p}function Z(e,t){if(e.length>t)return e.length=t,!0}function ee(e){return new this(e).abs()}function te(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ne(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function ae(e){return new this(e).atan()}function oe(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,s=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(r=t.s<0?F(this,n,i):new this(0)).s=e.s:!e.d||t.isZero()?(r=F(this,s,1).times(.5)).s=e.s:t.s<0?(this.precision=s,this.rounding=1,r=this.atan(O(e,t,s,1)),t=F(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(O(e,t,s,1)):(r=F(this,s,1).times(t.s>0?.25:.75)).s=e.s:r=new this(NaN),r}function ce(e){return new this(e).cbrt()}function he(e){return v(e=new this(e),e.e+1,2)}function ue(e,t,r){return new this(e).clamp(t,r)}function de(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,r,n,i=!0===e.defaults,s=["precision",1,l,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=d[r]),void 0!==(n=e[r])){if(!(E(n)===n&&n>=s[t+1]&&n<=s[t+2]))throw Error(f+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=d[r]),void 0!==(n=e[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(f+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(g);this[r]=!0}else this[r]=!1}return this}function pe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function fe(e,t){return new this(e).div(t)}function _e(e){return new this(e).exp()}function ge(e){return v(e=new this(e),e.e+1,3)}function xe(){var e,t,r=new this(0);for(p=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return p=!0,new this(1/0);r=t}return p=!0,r.sqrt()}function Ee(e){return e instanceof i||e&&e.toStringTag===x||!1}function Le(e){return new this(e).ln()}function Te(e,t){return new this(e).log(t)}function ye(e){return new this(e).log(2)}function Ae(e){return new this(e).log(10)}function Ce(){return V(this,arguments,-1)}function Ne(){return V(this,arguments,1)}function Se(e,t){return new this(e).mod(t)}function Me(e,t){return new this(e).mul(t)}function Re(e,t){return new this(e).pow(t)}function Ie(e){var t,r,n,i,s=0,a=new this(1),o=[];if(void 0===e?e=this.precision:b(e,1,l),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)(i=t[s])>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:o[s++]=i%1e7;else{if(!crypto.randomBytes)throw Error(g);for(t=crypto.randomBytes(n*=4);s<n;)(i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((127&t[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,s):(o.push(i%1e7),s+=4);s=n/4}else for(;s<n;)o[s++]=1e7*Math.random()|0;for(e%=7,(n=o[--s])&&e&&(i=L(10,7-e),o[s]=(n/i|0)*i);0===o[s];s--)o.pop();if(s<0)r=0,o=[0];else{for(r=-1;0===o[0];r-=7)o.shift();for(n=1,i=o[0];i>=10;i/=10)n++;n<7&&(r-=7-n)}return a.e=r,a.d=o,a}function be(e){return v(e=new this(e),e.e+1,this.rounding)}function we(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function De(e){return new this(e).sin()}function Oe(e){return new this(e).sinh()}function ve(e){return new this(e).sqrt()}function Pe(e,t){return new this(e).sub(t)}function ke(){var e=0,t=arguments,r=new this(t[e]);for(p=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return p=!0,v(r,this.precision,this.rounding)}function Ue(e){return new this(e).tan()}function Fe(e){return new this(e).tanh()}function He(e){return v(e=new this(e),e.e+1,1)}(i=function e(t){var r,n,i;function s(e){var t,r,n,i=this;if(!(i instanceof s))return new s(e);if(i.constructor=s,Ee(e))return i.s=e.s,void(p?!e.d||e.e>s.maxE?(i.e=NaN,i.d=null):e.e<s.minE?(i.e=0,i.d=[0]):(i.e=e.e,i.d=e.d.slice()):(i.e=e.e,i.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return i.s=1/e<0?-1:1,i.e=0,void(i.d=[0]);if(e<0?(e=-e,i.s=-1):i.s=1,e===~~e&&e<1e7){for(t=0,r=e;r>=10;r/=10)t++;return void(p?t>s.maxE?(i.e=NaN,i.d=null):t<s.minE?(i.e=0,i.d=[0]):(i.e=t,i.d=[e]):(i.e=t,i.d=[e]))}return 0*e!=0?(e||(i.s=NaN),i.e=NaN,void(i.d=null)):j(i,e.toString())}if("string"===n)return 45===(r=e.charCodeAt(0))?(e=e.slice(1),i.s=-1):(43===r&&(e=e.slice(1)),i.s=1),C.test(e)?j(i,e):z(i,e);if("bigint"===n)return e<0?(e=-e,i.s=-1):i.s=1,j(i,e.toString());throw Error(f+e)}if(s.prototype=R,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=de,s.clone=e,s.isDecimal=Ee,s.abs=ee,s.acos=te,s.acosh=re,s.add=ne,s.asin=ie,s.asinh=se,s.atan=ae,s.atanh=oe,s.atan2=le,s.cbrt=ce,s.ceil=he,s.clamp=ue,s.cos=pe,s.cosh=me,s.div=fe,s.exp=_e,s.floor=ge,s.hypot=xe,s.ln=Le,s.log=Te,s.log10=Ae,s.log2=ye,s.max=Ce,s.min=Ne,s.mod=Se,s.mul=Me,s.pow=Re,s.random=Ie,s.round=be,s.sign=we,s.sin=De,s.sinh=Oe,s.sqrt=ve,s.sub=Pe,s.sum=ke,s.tan=Ue,s.tanh=Fe,s.trunc=He,void 0===t&&(t={}),t&&!0!==t.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)t.hasOwnProperty(n=i[r++])||(t[n]=this[n]);return s.config(t),s}(d)).prototype.constructor=i,i.default=i.Decimal=i,h=new i(h),u=new i(u),void 0===(n=function(){return i}.call(t,r,t,e))||(e.exports=n)}()},152:function(e,t,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),a=0;a<r.length;a++)"default"!==r[a]&&i(t,e,r[a]);return s(t,e),t}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Evaluator=void 0;const l=r(222),c=o(r(207)),h=o(r(770)),u=r(645),d=r(430),p=a(r(109)),m=r(424),f=r(956),_=r(826),g=r(679),x=r(717),E=r(610),L=r(554),T=r(947),y=r(212),A=r(271),C=r(686);class N{get builtInFunctionList(){return Object.keys(this.builtInFunctionTable)}incDecOp(e,t){return e?e=>{if("IDENT"===e.type){if(this.nameTable[e.id])return this.nameTable[e.id]=L.MathOperation[t](this.nameTable[e.id],_.ComplexDecimal.one()),this.nameTable[e.id];throw new EvalError("in x++ or ++x, x must be defined first.")}throw new SyntaxError(`invalid ${"plus"===t?"increment":"decrement"} variable.`)}:e=>{if("IDENT"===e.type){if(this.nameTable[e.id]){const r=L.MathOperation.copy(this.nameTable[e.id]);return this.nameTable[e.id]=L.MathOperation[t](this.nameTable[e.id],_.ComplexDecimal.one()),r}throw new EvalError("in x++ or ++x, x must be defined first.")}throw new SyntaxError(`invalid ${"plus"===t?"increment":"decrement"} variable.`)}}nodePrecedence(e){if("number"==typeof e.type)return e instanceof _.ComplexDecimal?_.ComplexDecimal.precedence(e,this):this.precedenceTable.max;if("IDX"===e.type){const t=this.aliasName(e.expr.id);return"IDENT"===e.expr.type&&t in this.builtInFunctionTable&&(this.builtInFunctionTable[t].unparserMathML||t in C.MathML.format)?this.precedenceTable.max:this.precedenceTable.preMax}return"RANGE"===e.type?e.start_&&e.stop_?this.precedenceTable.min:this.precedenceTable.max:this.precedenceTable[e.type]||0}constructor(e){this.response={EXTERNAL:-2,WARNING:-1,OK:0,LEX_ERROR:1,PARSER_ERROR:2,EVAL_ERROR:3},this.debug=!1,this.nativeNameTable={false:_.ComplexDecimal.false(),true:_.ComplexDecimal.true(),i:_.ComplexDecimal.onei(),I:_.ComplexDecimal.onei(),j:_.ComplexDecimal.onei(),J:_.ComplexDecimal.onei(),e:_.ComplexDecimal.e(),pi:_.ComplexDecimal.pi(),inf:_.ComplexDecimal.inf_0(),Inf:_.ComplexDecimal.inf_0(),nan:_.ComplexDecimal.NaN_0(),NaN:_.ComplexDecimal.NaN_0()},this.nativeNameTableList=Object.keys(this.nativeNameTable),this.nameTable={},this.builtInFunctionTable={},this.localTable={},this.commandWordListTable={clear:{func:(...e)=>this.Clear(...e)},__operators__:{func:(...e)=>{const t=Object.keys(this.opTable).sort(),r=new g.MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new f.CharString(e)]),r}},__keywords__:{func:(...e)=>{const t=c.default.keywordNames.slice(1).sort(),r=new g.MultiArray([t.length,1],null,!0);return r.array=t.map(e=>[new f.CharString(e)]),r}},__builtins__:{func:(...e)=>{const t=new g.MultiArray([this.builtInFunctionList.length,1],null,!0);return t.array=this.builtInFunctionList.sort().map(e=>[new f.CharString(e)]),t}},__list_functions__:{func:(...e)=>g.MultiArray.emptyArray(!0)},localfunctions:{func:(...e)=>g.MultiArray.emptyArray(!0)},__dump_symtab_info__:{func:(...e)=>g.MultiArray.emptyArray(!0)}},this.opTable={"+":L.MathOperation.plus,"-":L.MathOperation.minus,".*":L.MathOperation.times,"*":L.MathOperation.mtimes,"./":L.MathOperation.rdivide,"/":L.MathOperation.mrdivide,".\\":L.MathOperation.ldivide,"\\":L.MathOperation.mldivide,".^":L.MathOperation.power,"^":L.MathOperation.mpower,"+_":L.MathOperation.uplus,"-_":L.MathOperation.uminus,".'":L.MathOperation.transpose,"'":L.MathOperation.ctranspose,"<":L.MathOperation.lt,"<=":L.MathOperation.le,"==":L.MathOperation.eq,">=":L.MathOperation.ge,">":L.MathOperation.gt,"!=":L.MathOperation.ne,"&":L.MathOperation.and,"|":L.MathOperation.or,"!":L.MathOperation.not,"&&":L.MathOperation.mand,"||":L.MathOperation.mor,"++_":this.incDecOp(!0,"plus"),"--_":this.incDecOp(!0,"minus"),"_++":this.incDecOp(!1,"plus"),"_--":this.incDecOp(!1,"minus")},this.functions={unparse:e=>new f.CharString(this.Unparse(e))},this.unparseString=f.CharString.unparse,this.unparseStringMathML=f.CharString.unparseMathML,this.newNumber=_.ComplexDecimal.newThis,this.unparseNumber=_.ComplexDecimal.unparse,this.unparseNumberMathML=_.ComplexDecimal.unparseMathML,this.isRowVector=g.MultiArray.isRowVector,this.unparseArray=g.MultiArray.unparse,this.unparseStructure=y.Structure.unparse,this.unparseStructureMathML=y.Structure.unparseMathML,this.newFunctionHandle=A.FunctionHandle.newThis,this.unparseFunctionHandle=A.FunctionHandle.unparse,this.unparseFunctionHandleMathML=A.FunctionHandle.unparseMathML,this.unparseArrayMathML=g.MultiArray.unparseMathML,this.evaluateArray=g.MultiArray.evaluate,this.mapArray=g.MultiArray.rawMap,this.getElements=g.MultiArray.getElements,this.getElementsLogical=g.MultiArray.getElementsLogical,this.setElements=g.MultiArray.setElements,this.setElementsLogical=g.MultiArray.setElementsLogical,this.expandRange=g.MultiArray.expandRange,this.expandColon=g.MultiArray.expandColon,this.array0x0=g.MultiArray.emptyArray,this.linearize=g.MultiArray.linearize,this.scalarToArray=g.MultiArray.scalarToMultiArray,this.scalarOrCellToArray=g.MultiArray.scalarOrCellToMultiArray,this.arrayToScalar=g.MultiArray.MultiArrayToScalar,this.linearLength=g.MultiArray.linearLength,this.getDimension=g.MultiArray.getDimension,this.toLogical=g.MultiArray.toLogical,this.getFields=y.Structure.getFields,this.setNewField=y.Structure.setNewField,this.unparseMathMLFunctions={logb:e=>{let t=this.unparserMathML(e.args[1]);return this.nodePrecedence(e.args[1])<this.precedenceTable.max&&(t=C.MathML.format["()"]("(",t,")")),C.MathML.format.logb(this.unparserMathML(e.args[0]),t)},log2:e=>{let t=this.unparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this.precedenceTable.max&&(t=C.MathML.format["()"]("(",t,")")),C.MathML.format.log2(t)},log10:e=>{let t=this.unparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this.precedenceTable.max&&(t=C.MathML.format["()"]("(",t,")")),C.MathML.format.log10(t)},factorial:e=>{let t=this.unparserMathML(e.args[0]);return this.nodePrecedence(e.args[0])<this.precedenceTable.max&&(t=C.MathML.format["()"]("(",t,")")),C.MathML.format.factorial(t)}},this.aliasName=e=>e,this.exitStatus=this.response.OK,this.precedenceTable={},N.precedence.forEach((e,t)=>{e.forEach(e=>{this.precedenceTable[e]=t+1})}),this.opTable["**"]=this.opTable["^"],this.precedenceTable["**"]=this.precedenceTable["^"],this.opTable[".**"]=this.opTable[".^"],this.precedenceTable[".**"]=this.precedenceTable[".^"],this.precedenceTable["_**"]=this.precedenceTable["_^"],this.precedenceTable["_.**"]=this.precedenceTable["_.^"],this.opTable["~="]=this.opTable["!="],this.precedenceTable["~="]=this.precedenceTable["!="],this.opTable["~"]=this.opTable["!"],this.precedenceTable["~"]=this.precedenceTable["!"],this.loadNativeTable();for(const e in this.functions)this.defineFunction(e,this.functions[e]);for(const e in L.MathOperation.leftAssociativeMultipleOperations)this.defineLeftAssociativeMultipleOperationFunction(e,L.MathOperation.leftAssociativeMultipleOperations[e]);for(const e in L.MathOperation.binaryOperations)this.defineBinaryOperatorFunction(e,L.MathOperation.binaryOperations[e]);for(const e in L.MathOperation.unaryOperations)this.defineUnaryOperatorFunction(e,L.MathOperation.unaryOperations[e]);for(const e in _.ComplexDecimal.mapFunction)this.defineFunction(e,_.ComplexDecimal.mapFunction[e],!0);for(const e in _.ComplexDecimal.twoArgFunction)this.defineFunction(e,_.ComplexDecimal.twoArgFunction[e]);for(const e in T.Configuration.functions)this.defineFunction(e,T.Configuration.functions[e]);for(const e in x.CoreFunctions.functions)this.defineFunction(e,x.CoreFunctions.functions[e]);for(const e in E.LinearAlgebra.functions)this.defineFunction(e,E.LinearAlgebra.functions[e]);for(const e in this.unparseMathMLFunctions)this.builtInFunctionTable[e].unparserMathML=this.unparseMathMLFunctions[e];e?(e.aliasNameTable?(this.aliasNameTable=e.aliasNameTable,this.aliasName=e=>{let t=!1,r="";for(const n in this.aliasNameTable)if(this.aliasNameTable[n].test(e)){t=!0,r=n;break}return t?r:e}):this.aliasName=e=>e,e.externalFunctionTable&&Object.assign(this.builtInFunctionTable,e.externalFunctionTable),e.externalCmdWListTable&&Object.assign(this.commandWordListTable,e.externalCmdWListTable)):this.aliasName=e=>e}Parse(e){const t=l.CharStreams.fromString(e),r=new c.default(t);r.commandNames=Object.keys(this.commandWordListTable);const n=new l.CommonTokenStream(r),i=new h.default(n);return i.buildParseTrees=!0,r.removeErrorListeners(),r.addErrorListener(new u.LexerErrorListener),i.removeErrorListeners(),i.addErrorListener(new d.ParserErrorListener),this.debug,i.input().node}loadNativeTable(){for(const e in this.nativeNameTable)this.nameTable[e]=this.nativeNameTable[e]}Restart(){this.nameTable={},this.localTable={},this.loadNativeTable()}Clear(...e){0===e.length?this.Restart():e.forEach(e=>{delete this.nameTable[e],delete this.builtInFunctionTable[e],this.nativeNameTableList.includes(e)&&(this.nameTable[e]=this.nativeNameTable[e])})}static throwErrorIfGreaterThanReturnList(e,t){if(t>e)throw new EvalError(`element number ${e+1} undefined in return list`)}reduceIfReturnList(e){if("RETLIST"===e.type){const t=e.selector(1,0);return t.parent=e.parent,t}return e}validateAssignment(e,t,r,n){const i="invalid left hand side of assignment";if("IDENT"===e.type)return[{id:e.id,index:[],field:[]}];if("IDX"===e.type&&"IDENT"===e.expr.type)return[{id:e.expr.id,index:e.args,field:[]}];if("."===e.type){const t=e.field.map(e=>{if("string"==typeof e)return e;{const t=this.reduceIfReturnList(this.Evaluator(e,r,n));if(t instanceof f.CharString)return t.str;throw new EvalError(`${i}: dynamic structure field names must be strings.`)}});if("IDENT"===e.obj.type)return[{id:e.obj.id,index:[],field:t}];if("IDX"===e.obj.type&&"IDENT"===e.obj.expr.type)return[{id:e.obj.expr.id,index:e.obj.args,field:t}];throw new EvalError(`${i}.`)}if("<~>"===e.type)return[{id:"~",index:[],field:[]}];if(t&&this.isRowVector(e))return e.array[0].map(e=>this.validateAssignment(e,!1,r,n)[0]);throw new EvalError(`${i}.`)}defineFunction(e,t,r=!1,n=[]){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:r,ev:n,func:t}}defineUnaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(...r)=>{if(1===r.length)return t(r[0]);throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}defineBinaryOperatorFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(r,...n)=>{if(1===n.length)return t(r,n[0]);throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}defineLeftAssociativeMultipleOperationFunction(e,t){this.builtInFunctionTable[e]={type:"BUILTIN",mapper:!1,ev:[],func:(r,...n)=>{if(1===n.length)return t(r,n[0]);if(n.length>1){let e=t(r,n[0]);for(let r=1;r<n.length;r++)e=t(e,n[r]);return e}throw new EvalError(`Invalid call to ${e}. Type 'help ${e}' to see correct usage.`)}}}toBoolean(e){const t=e instanceof g.MultiArray?this.toLogical(e):e;return t instanceof _.ComplexDecimal?Boolean(t.re.toNumber()||t.im.toNumber()):!!t.str}Evaluator(e,t=!1,r=""){if(this.debug&&console.log(`Evaluator(\ntree:${JSON.stringify(e,(e,t)=>"parent"!==e?t:null!==t||"root",2)},\nlocal:${t},\nfname:${r});`),!e)return null;if(e instanceof _.ComplexDecimal||e instanceof A.FunctionHandle||e instanceof f.CharString||e instanceof y.Structure)return e;if(e instanceof g.MultiArray)return this.evaluateArray(e,this,t,r);switch(e.type){case"+":case"-":case".*":case"*":case"./":case"/":case".\\":case"\\":case".^":case"^":case".**":case"**":case"<":case"<=":case"==":case">=":case">":case"!=":case"~=":case"&":case"|":case"&&":case"||":return e.left.parent=e,e.right.parent=e,this.opTable[e.type](this.reduceIfReturnList(this.Evaluator(e.left,t,r)),this.reduceIfReturnList(this.Evaluator(e.right,t,r)));case"()":return e.right.parent=e,this.reduceIfReturnList(this.Evaluator(e.right,t,r));case"!":case"~":case"+_":case"-_":return e.right.parent=e,this.opTable[e.type](this.reduceIfReturnList(this.Evaluator(e.right,t,r)));case"++_":case"--_":return e.right.parent=e,this.opTable[e.type](e.right);case".'":case"'":return e.left.parent=e,this.opTable[e.type](this.reduceIfReturnList(this.Evaluator(e.left,t,r)));case"_++":case"_--":return e.left.parent=e,this.opTable[e.type](e.left);case"=":case"+=":case"-=":case"*=":case"/=":case"\\=":case"^=":case"**=":case".*=":case"./=":case".\\=":case".^=":case".**=":case"&=":case"|=":{e.left.parent=e,e.right.parent=e;const n=this.validateAssignment(e.left,!0,t,r),i=e.type.substring(0,e.type.length-1);if(n.length>1&&i.length>0)throw new EvalError("computed multiple assignment not allowed.");let s;try{s=this.Evaluator(e.right,!1,r)}catch(t){s=e.right}"RETLIST"!==s.type&&(s=p.nodeReturnList((t,r)=>{if(0===r)return e.right;throw new EvalError(`element number ${r+1} undefined in return list`)}));const a=p.nodeListFirst();for(let o=0;o<n.length;o++){const{id:l,index:c,field:h}=n[o];if("~"!==l)if(0===c.length){"RETLIST"!==s.type&&(s=this.Evaluator(s,!1,r));const t=s.selector(n.length,o);t.parent=e.right;const c=i.length?p.nodeOp(i,p.nodeIdentifier(l),t):t;try{if(h.length>0){if(void 0===this.nameTable[l]&&(this.nameTable[l]=new y.Structure({})),!(this.nameTable[l]instanceof y.Structure))throw new EvalError("in indexed assignment.");this.setNewField(this.nameTable[l],h,this.reduceIfReturnList(this.Evaluator(c))),p.appendNodeList(a,p.nodeOp("=",p.nodeIdentifier(l),this.nameTable[l]))}else this.nameTable[l]=this.reduceIfReturnList(this.Evaluator(c)),p.appendNodeList(a,p.nodeOp("=",p.nodeIdentifier(l),this.nameTable[l]));continue}catch(e){throw this.nameTable[l]=c,e}}else{if(i){if(void 0!==this.nameTable[l]){if(this.nameTable[l]instanceof A.FunctionHandle)throw new EvalError("can't perform indexed assignment for function handle type.");if(1===c.length){const e=this.reduceIfReturnList(this.Evaluator(c[0],t,r));e instanceof g.MultiArray&&e.type===_.ComplexDecimal.LOGICAL?this.setElementsLogical(this.nameTable,l,h,this.linearize(e),this.scalarToArray(this.reduceIfReturnList(this.Evaluator(p.nodeOp(i,this.getElementsLogical(this.nameTable[l],l,h,e),this.scalarToArray(this.reduceIfReturnList(this.Evaluator(s.selector(n.length,o))))),!1,r)))):this.setElements(this.nameTable,l,h,[e],this.scalarToArray(this.reduceIfReturnList(this.Evaluator(p.nodeOp(i,this.getElements(this.nameTable[l],l,h,[e]),this.scalarToArray(this.reduceIfReturnList(th