@cortex-js/math-json
Version:
A JSON schema to represent math formulas
7 lines • 101 kB
JavaScript
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).MathJson={})}(this,(function(e){const i=8205,t=[127462,127487];function r(e){return e===i||65038===e||65039===e||e>=127995&&e<=128e3||e>=129456&&e<=129460||e>=917536&&e<=917632}function n(e){return e>=t[0]&&e<=t[1]}class s{constructor(e){this.obeyspaces=!1,this.s=function(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const t=[],s=function(e){const i=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){const i=e.charCodeAt(t+1);i>=56320&&i<=57343&&(r=65536+1024*(r-55296)+(i-56320),t++)}i.push(r)}return i}(e);let a=0;for(;a<s.length;){const e=s[a++],o=s[a];if(o===i){const e=a-1;for(a+=2;s[a]===i;)a+=2;t.push(String.fromCodePoint(...s.slice(e,2*a-e+1)))}else if(r(o)){const e=a-1;for(;r(s[a]);)a+=s[a]===i?2:1;t.push(String.fromCodePoint(...s.slice(e,2*a-e-1)))}else n(e)?(a+=1,t.push(String.fromCodePoint(...s.slice(a-2,2)))):t.push(String.fromCodePoint(e))}return t}(e),this.pos=0}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(e){let i;return i="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join("")),(null==i?void 0:i[0])?(this.pos+=i[0].length,i[0]):null}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]+/))return"<space>";if(this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]/))return"<space>";const e=this.get();if("\\"===e){if(!this.end()){let e=this.match(/^[a-zA-Z*]+/);if(e)this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]*/);else if(e=this.get()," "===e)return"<space>";return"\\"+e}}else{if("{"===e)return"<{>";if("}"===e)return"<}>";if("^"===e){if("^"===this.peek()){this.get();const e=this.match(/^(\^(\^(\^(\^[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f][0-9a-f]/);if(e)return String.fromCodePoint(parseInt(e.slice(e.lastIndexOf("^")+1),16))}return e}if("#"===e){if(!this.end()){let e=!1;if(/[0-9?]/.test(this.peek())&&(e=!0,this.pos+1<this.s.length)){const i=this.s[this.pos+1];e=/[^0-9A-Za-z]/.test(i)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}}function a(e,i){var t,r,n,s;let a=[],l=e.next();if(l)if("\\relax"===l);else if("\\noexpand"===l)l=e.next(),l&&a.push(l);else if("\\obeyspaces"===l)e.obeyspaces=!0;else if("\\space"===l||"~"===l)a.push("<space>");else if("\\bgroup"===l)a.push("<{>");else if("\\egroup"===l)a.push("<}>");else if("\\string"===l)l=e.next(),l&&("\\"===l[0]?Array.from(l).forEach((e=>a.push("\\"===e?"\\backslash":e))):"<{>"===l?a.push("\\{"):"<space>"===l?a.push("~"):"<}>"===l&&a.push("\\}"));else if("\\csname"===l){for(;"<space>"===e.peek();)e.next();let n="",s=!1,u=[];do{if(0===u.length)if(/^#[0-9?]$/.test(e.peek())){const n=e.get().slice(1);u=o(null!==(r=null!==(t=null==i?void 0:i[n])&&void 0!==t?t:null==i?void 0:i["?"])&&void 0!==r?r:"\\placeholder{}",i),l=u[0]}else l=e.next(),u=l?[l]:[];s=0===u.length,s||"\\endcsname"!==l||(s=!0,u.shift()),s||(s="<$>"===l||"<$$>"===l||"<{>"===l||"<}>"===l||!!l&&l.length>1&&"\\"===l[0]),s||(n+=u.shift())}while(!s);n&&a.push("\\"+n),a=a.concat(u)}else if("\\endcsname"===l);else if(l.length>1&&"#"===l[0]){const e=l.slice(1);a=a.concat(o(null!==(s=null!==(n=null==i?void 0:i[e])&&void 0!==n?n:null==i?void 0:i["?"])&&void 0!==s?s:"\\placeholder{}",i))}else a.push(l);return a}function o(e,i){const t=e.toString().split(/\r?\n/);let r="",n="";for(const e of t){r+=n,n=" ";const i=e.match(/((?:\\%)|[^%])*/);null!==i&&(r+=i[0])}const o=new s(r);let l=[];do{l=l.concat(a(o,i))}while(!o.end());return l}function l(e){let i="",t="";for(const r of e)r&&(/[a-zA-Z*]/.test(r[0])&&(t+=i),i=/\\[a-zA-Z]+\*?$/.test(r)?" ":"",t+=r);return t}function u(e){let i=[];if(Array.isArray(e))for(const t of e)Array.isArray(t)?i=[...i,...t]:i.push(t);else i=[e];return l(i.map((e=>{var i;return null!==(i={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[e])&&void 0!==i?i:e})))}var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},h={exports:{}};!function(e){!function(i){var t,r,n,s,a=9e15,o=1e9,l="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",c="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",h={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-a,maxE:a,crypto:!1},g=!0,p="[DecimalError] ",f=p+"Invalid argument: ",m=p+"Precision limit exceeded",d=p+"crypto unavailable",v=Math.floor,x=Math.pow,y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,b=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,w=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,q=1e7,E=u.length-1,M=c.length-1,S={name:"[object Decimal]"};function A(e){var i,t,r,n=e.length-1,s="",a=e[0];if(n>0){for(s+=a,i=1;i<n;i++)(t=7-(r=e[i]+"").length)&&(s+=R(t)),s+=r;(t=7-(r=(a=e[i])+"").length)&&(s+=R(t))}else if(0===a)return"0";for(;a%10==0;)a/=10;return s+a}function z(e,i,t){if(e!==~~e||e<i||e>t)throw Error(f+e)}function k(e,i,t,r){var n,s,a,o;for(s=e[0];s>=10;s/=10)--i;return--i<0?(i+=7,n=0):(n=Math.ceil((i+1)/7),i%=7),s=x(10,7-i),o=e[n]%s|0,null==r?i<3?(0==i?o=o/100|0:1==i&&(o=o/10|0),a=t<4&&99999==o||t>3&&49999==o||5e4==o||0==o):a=(t<4&&o+1==s||t>3&&o+1==s/2)&&(e[n+1]/s/100|0)==x(10,i-2)-1||(o==s/2||0==o)&&0==(e[n+1]/s/100|0):i<4?(0==i?o=o/1e3|0:1==i?o=o/100|0:2==i&&(o=o/10|0),a=(r||t<4)&&9999==o||!r&&t>3&&4999==o):a=((r||t<4)&&o+1==s||!r&&t>3&&o+1==s/2)&&(e[n+1]/s/1e3|0)==x(10,i-3)-1,a}function I(e,i,t){for(var r,n,s=[0],a=0,o=e.length;a<o;){for(n=s.length;n--;)s[n]*=i;for(s[0]+=l.indexOf(e.charAt(a++)),r=0;r<s.length;r++)s[r]>t-1&&(void 0===s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/t|0,s[r]%=t)}return s.reverse()}S.absoluteValue=S.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),L(e)},S.ceil=function(){return L(new this.constructor(this),this.e+1,2)},S.comparedTo=S.cmp=function(e){var i,t,r,n,s=this,a=s.d,o=(e=new s.constructor(e)).d,l=s.s,u=e.s;if(!a||!o)return l&&u?l!==u?l:a===o?0:!a^l<0?1:-1:NaN;if(!a[0]||!o[0])return a[0]?l:o[0]?-u:0;if(l!==u)return l;if(s.e!==e.e)return s.e>e.e^l<0?1:-1;for(i=0,t=(r=a.length)<(n=o.length)?r:n;i<t;++i)if(a[i]!==o[i])return a[i]>o[i]^l<0?1:-1;return r===n?0:r>n^l<0?1:-1},S.cosine=S.cos=function(){var e,i,t=this,r=t.constructor;return t.d?t.d[0]?(e=r.precision,i=r.rounding,r.precision=e+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,i){var t,r,n=i.d.length;n<32?r=(1/W(4,t=Math.ceil(n/3))).toString():(t=16,r="2.3283064365386962890625e-10"),e.precision+=t,i=V(e,1,i.times(r),new e(1));for(var s=t;s--;){var a=i.times(i);i=a.times(a).minus(a).times(8).plus(1)}return e.precision-=t,i}(r,Q(r,t)),r.precision=e,r.rounding=i,L(2==s||3==s?t.neg():t,e,i,!0)):new r(1):new r(NaN)},S.cubeRoot=S.cbrt=function(){var e,i,t,r,n,s,a,o,l,u,c=this,h=c.constructor;if(!c.isFinite()||c.isZero())return new h(c);for(g=!1,(s=c.s*x(c.s*c,1/3))&&Math.abs(s)!=1/0?r=new h(s.toString()):(t=A(c.d),(s=((e=c.e)-t.length+1)%3)&&(t+=1==s||-2==s?"0":"00"),s=x(t,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(r=new h(t=s==1/0?"5e"+e:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+e)).s=c.s),a=(e=h.precision)+3;;)if(u=(l=(o=r).times(o).times(o)).plus(c),r=O(u.plus(c).times(o),u.plus(l),a+2,1),A(o.d).slice(0,a)===(t=A(r.d)).slice(0,a)){if("9999"!=(t=t.slice(a-3,a+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(L(r,e+1,1),i=!r.times(r).times(r).eq(c));break}if(!n&&(L(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}a+=4,n=1}return g=!0,L(r,e,h.rounding,i)},S.decimalPlaces=S.dp=function(){var e,i=this.d,t=NaN;if(i){if(t=7*((e=i.length-1)-v(this.e/7)),e=i[e])for(;e%10==0;e/=10)t--;t<0&&(t=0)}return t},S.dividedBy=S.div=function(e){return O(this,new this.constructor(e))},S.dividedToIntegerBy=S.divToInt=function(e){var i=this.constructor;return L(O(this,new i(e),0,1,1),i.precision,i.rounding)},S.equals=S.eq=function(e){return 0===this.cmp(e)},S.floor=function(){return L(new this.constructor(this),this.e+1,3)},S.greaterThan=S.gt=function(e){return this.cmp(e)>0},S.greaterThanOrEqualTo=S.gte=function(e){var i=this.cmp(e);return 1==i||0===i},S.hyperbolicCosine=S.cosh=function(){var e,i,t,r,n,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;t=a.precision,r=a.rounding,a.precision=t+Math.max(s.e,s.sd())+4,a.rounding=1,(n=s.d.length)<32?i=(1/W(4,e=Math.ceil(n/3))).toString():(e=16,i="2.3283064365386962890625e-10"),s=V(a,1,s.times(i),new a(1),!0);for(var l,u=e,c=new a(8);u--;)l=s.times(s),s=o.minus(l.times(c.minus(l.times(c))));return L(s,a.precision=t,a.rounding=r,!0)},S.hyperbolicSine=S.sinh=function(){var e,i,t,r,n=this,s=n.constructor;if(!n.isFinite()||n.isZero())return new s(n);if(i=s.precision,t=s.rounding,s.precision=i+Math.max(n.e,n.sd())+4,s.rounding=1,(r=n.d.length)<3)n=V(s,2,n,n,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,n=V(s,2,n=n.times(1/W(5,e)),n,!0);for(var a,o=new s(5),l=new s(16),u=new s(20);e--;)a=n.times(n),n=n.times(o.plus(a.times(l.times(a).plus(u))))}return s.precision=i,s.rounding=t,L(n,i,t,!0)},S.hyperbolicTangent=S.tanh=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+7,r.rounding=1,O(t.sinh(),t.cosh(),r.precision=e,r.rounding=i)):new r(t.s)},S.inverseCosine=S.acos=function(){var e,i=this,t=i.constructor,r=i.abs().cmp(1),n=t.precision,s=t.rounding;return-1!==r?0===r?i.isNeg()?T(t,n,s):new t(0):new t(NaN):i.isZero()?T(t,n+4,s).times(.5):(t.precision=n+6,t.rounding=1,i=i.asin(),e=T(t,n+4,s).times(.5),t.precision=n,t.rounding=s,e.minus(i))},S.inverseHyperbolicCosine=S.acosh=function(){var e,i,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(e=r.precision,i=r.rounding,r.precision=e+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,g=!1,t=t.times(t).minus(1).sqrt().plus(t),g=!0,r.precision=e,r.rounding=i,t.ln()):new r(t)},S.inverseHyperbolicSine=S.asinh=function(){var e,i,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,g=!1,t=t.times(t).plus(1).sqrt().plus(t),g=!0,r.precision=e,r.rounding=i,t.ln())},S.inverseHyperbolicTangent=S.atanh=function(){var e,i,t,r,n=this,s=n.constructor;return n.isFinite()?n.e>=0?new s(n.abs().eq(1)?n.s/0:n.isZero()?n:NaN):(e=s.precision,i=s.rounding,r=n.sd(),Math.max(r,e)<2*-n.e-1?L(new s(n),e,i,!0):(s.precision=t=r-n.e,n=O(n.plus(1),new s(1).minus(n),t+e,1),s.precision=e+4,s.rounding=1,n=n.ln(),s.precision=e,s.rounding=i,n.times(.5))):new s(NaN)},S.inverseSine=S.asin=function(){var e,i,t,r,n=this,s=n.constructor;return n.isZero()?new s(n):(i=n.abs().cmp(1),t=s.precision,r=s.rounding,-1!==i?0===i?((e=T(s,t+4,r).times(.5)).s=n.s,e):new s(NaN):(s.precision=t+6,s.rounding=1,n=n.div(new s(1).minus(n.times(n)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=r,n.times(2)))},S.inverseTangent=S.atan=function(){var e,i,t,r,n,s,a,o,l,u=this,c=u.constructor,h=c.precision,p=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&h+4<=M)return(a=T(c,h+4,p).times(.25)).s=u.s,a}else{if(!u.s)return new c(NaN);if(h+4<=M)return(a=T(c,h+4,p).times(.5)).s=u.s,a}for(c.precision=o=h+10,c.rounding=1,e=t=Math.min(28,o/7+2|0);e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(g=!1,i=Math.ceil(o/7),r=1,l=u.times(u),a=new c(u),n=u;-1!==e;)if(n=n.times(l),s=a.minus(n.div(r+=2)),n=n.times(l),void 0!==(a=s.plus(n.div(r+=2))).d[i])for(e=i;a.d[e]===s.d[e]&&e--;);return t&&(a=a.times(2<<t-1)),g=!0,L(a,c.precision=h,c.rounding=p,!0)},S.isFinite=function(){return!!this.d},S.isInteger=S.isInt=function(){return!!this.d&&v(this.e/7)>this.d.length-2},S.isNaN=function(){return!this.s},S.isNegative=S.isNeg=function(){return this.s<0},S.isPositive=S.isPos=function(){return this.s>0},S.isZero=function(){return!!this.d&&0===this.d[0]},S.lessThan=S.lt=function(e){return this.cmp(e)<0},S.lessThanOrEqualTo=S.lte=function(e){return this.cmp(e)<1},S.logarithm=S.log=function(e){var i,t,r,n,s,a,o,l,u=this,c=u.constructor,h=c.precision,p=c.rounding;if(null==e)e=new c(10),i=!0;else{if(t=(e=new c(e)).d,e.s<0||!t||!t[0]||e.eq(1))return new c(NaN);i=e.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:1!=u.s?NaN:t?0:1/0);if(i)if(t.length>1)s=!0;else{for(n=t[0];n%10==0;)n/=10;s=1!==n}if(g=!1,a=j(u,o=h+5),r=i?F(c,o+10):j(e,o),k((l=O(a,r,o,1)).d,n=h,p))do{if(a=j(u,o+=10),r=i?F(c,o+10):j(e,o),l=O(a,r,o,1),!s){+A(l.d).slice(n+1,n+15)+1==1e14&&(l=L(l,h+1,0));break}}while(k(l.d,n+=10,p));return g=!0,L(l,h,p)},S.minus=S.sub=function(e){var i,t,r,n,s,a,o,l,u,c,h,p,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return f.s&&e.s?f.d?e.s=-e.s:e=new m(e.d||f.s!==e.s?f:NaN):e=new m(NaN),e;if(f.s!=e.s)return e.s=-e.s,f.plus(e);if(u=f.d,p=e.d,o=m.precision,l=m.rounding,!u[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!u[0])return new m(3===l?-0:0);e=new m(f)}return g?L(e,o,l):e}if(t=v(e.e/7),c=v(f.e/7),u=u.slice(),s=c-t){for((h=s<0)?(i=u,s=-s,a=p.length):(i=p,t=c,a=u.length),s>(r=Math.max(Math.ceil(o/7),a)+2)&&(s=r,i.length=1),i.reverse(),r=s;r--;)i.push(0);i.reverse()}else{for((h=(r=u.length)<(a=p.length))&&(a=r),r=0;r<a;r++)if(u[r]!=p[r]){h=u[r]<p[r];break}s=0}for(h&&(i=u,u=p,p=i,e.s=-e.s),a=u.length,r=p.length-a;r>0;--r)u[a++]=0;for(r=p.length;r>s;){if(u[--r]<p[r]){for(n=r;n&&0===u[--n];)u[n]=q-1;--u[n],u[r]+=q}u[r]-=p[r]}for(;0===u[--a];)u.pop();for(;0===u[0];u.shift())--t;return u[0]?(e.d=u,e.e=D(u,t),g?L(e,o,l):e):new m(3===l?-0:0)},S.modulo=S.mod=function(e){var i,t=this,r=t.constructor;return e=new r(e),!t.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||t.d&&!t.d[0]?L(new r(t),r.precision,r.rounding):(g=!1,9==r.modulo?(i=O(t,e.abs(),0,3,1)).s*=e.s:i=O(t,e,0,r.modulo,1),i=i.times(e),g=!0,t.minus(i))},S.naturalExponential=S.exp=function(){return _(this)},S.naturalLogarithm=S.ln=function(){return j(this)},S.negated=S.neg=function(){var e=new this.constructor(this);return e.s=-e.s,L(e)},S.plus=S.add=function(e){var i,t,r,n,s,a,o,l,u,c,h=this,p=h.constructor;if(e=new p(e),!h.d||!e.d)return h.s&&e.s?h.d||(e=new p(e.d||h.s===e.s?h:NaN)):e=new p(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.minus(e);if(u=h.d,c=e.d,o=p.precision,l=p.rounding,!u[0]||!c[0])return c[0]||(e=new p(h)),g?L(e,o,l):e;if(s=v(h.e/7),r=v(e.e/7),u=u.slice(),n=s-r){for(n<0?(t=u,n=-n,a=c.length):(t=c,r=s,a=u.length),n>(a=(s=Math.ceil(o/7))>a?s+1:a+1)&&(n=a,t.length=1),t.reverse();n--;)t.push(0);t.reverse()}for((a=u.length)-(n=c.length)<0&&(n=a,t=c,c=u,u=t),i=0;n;)i=(u[--n]=u[n]+c[n]+i)/q|0,u[n]%=q;for(i&&(u.unshift(i),++r),a=u.length;0==u[--a];)u.pop();return e.d=u,e.e=D(u,r),g?L(e,o,l):e},S.precision=S.sd=function(e){var i,t=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(f+e);return t.d?(i=C(t.d),e&&t.e+1>i&&(i=t.e+1)):i=NaN,i},S.round=function(){var e=this,i=e.constructor;return L(new i(e),e.e+1,i.rounding)},S.sine=S.sin=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(e,i){var t,r=i.d.length;if(r<3)return V(e,2,i,i);t=(t=1.4*Math.sqrt(r))>16?16:0|t,i=V(e,2,i=i.times(1/W(5,t)),i);for(var n,s=new e(5),a=new e(16),o=new e(20);t--;)n=i.times(i),i=i.times(s.plus(n.times(a.times(n).minus(o))));return i}(r,Q(r,t)),r.precision=e,r.rounding=i,L(s>2?t.neg():t,e,i,!0)):new r(NaN)},S.squareRoot=S.sqrt=function(){var e,i,t,r,n,s,a=this,o=a.d,l=a.e,u=a.s,c=a.constructor;if(1!==u||!o||!o[0])return new c(!u||u<0&&(!o||o[0])?NaN:o?a:1/0);for(g=!1,0==(u=Math.sqrt(+a))||u==1/0?(((i=A(o)).length+l)%2==0&&(i+="0"),u=Math.sqrt(i),l=v((l+1)/2)-(l<0||l%2),r=new c(i=u==1/0?"5e"+l:(i=u.toExponential()).slice(0,i.indexOf("e")+1)+l)):r=new c(u.toString()),t=(l=c.precision)+3;;)if(r=(s=r).plus(O(a,s,t+2,1)).times(.5),A(s.d).slice(0,t)===(i=A(r.d)).slice(0,t)){if("9999"!=(i=i.slice(t-3,t+1))&&(n||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(L(r,l+1,1),e=!r.times(r).eq(a));break}if(!n&&(L(s,l+1,0),s.times(s).eq(a))){r=s;break}t+=4,n=1}return g=!0,L(r,l,c.rounding,e)},S.tangent=S.tan=function(){var e,i,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(e=r.precision,i=r.rounding,r.precision=e+10,r.rounding=1,(t=t.sin()).s=1,t=O(t,new r(1).minus(t.times(t)).sqrt(),e+10,0),r.precision=e,r.rounding=i,L(2==s||4==s?t.neg():t,e,i,!0)):new r(NaN)},S.times=S.mul=function(e){var i,t,r,n,s,a,o,l,u,c=this,h=c.constructor,p=c.d,f=(e=new h(e)).d;if(e.s*=c.s,!(p&&p[0]&&f&&f[0]))return new h(!e.s||p&&!p[0]&&!f||f&&!f[0]&&!p?NaN:p&&f?0*e.s:e.s/0);for(t=v(c.e/7)+v(e.e/7),(l=p.length)<(u=f.length)&&(s=p,p=f,f=s,a=l,l=u,u=a),s=[],r=a=l+u;r--;)s.push(0);for(r=u;--r>=0;){for(i=0,n=l+r;n>r;)o=s[n]+f[r]*p[n-r-1]+i,s[n--]=o%q|0,i=o/q|0;s[n]=(s[n]+i)%q|0}for(;!s[--a];)s.pop();return i?++t:s.shift(),e.d=s,e.e=D(s,t),g?L(e,h.precision,h.rounding):e},S.toBinary=function(e,i){return Y(this,2,e,i)},S.toDecimalPlaces=S.toDP=function(e,i){var t=this,r=t.constructor;return t=new r(t),void 0===e?t:(z(e,0,o),void 0===i?i=r.rounding:z(i,0,8),L(t,e+t.e+1,i))},S.toExponential=function(e,i){var t,r=this,n=r.constructor;return void 0===e?t=P(r,!0):(z(e,0,o),void 0===i?i=n.rounding:z(i,0,8),t=P(r=L(new n(r),e+1,i),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+t:t},S.toFixed=function(e,i){var t,r,n=this,s=n.constructor;return void 0===e?t=P(n):(z(e,0,o),void 0===i?i=s.rounding:z(i,0,8),t=P(r=L(new s(n),e+n.e+1,i),!1,e+r.e+1)),n.isNeg()&&!n.isZero()?"-"+t:t},S.toFraction=function(e){var i,t,r,n,s,a,o,l,u,c,h,p,m=this,d=m.d,v=m.constructor;if(!d)return new v(m);if(u=t=new v(1),r=l=new v(0),a=(s=(i=new v(r)).e=C(d)-m.e-1)%7,i.d[0]=x(10,a<0?7+a:a),null==e)e=s>0?i:u;else{if(!(o=new v(e)).isInt()||o.lt(u))throw Error(f+o);e=o.gt(i)?s>0?i:u:o}for(g=!1,o=new v(A(d)),c=v.precision,v.precision=s=7*d.length*2;h=O(o,i,0,1,1),1!=(n=t.plus(h.times(r))).cmp(e);)t=r,r=n,n=u,u=l.plus(h.times(n)),l=n,n=i,i=o.minus(h.times(n)),o=n;return n=O(e.minus(t),r,0,1,1),l=l.plus(n.times(u)),t=t.plus(n.times(r)),l.s=u.s=m.s,p=O(u,r,s,1).minus(m).abs().cmp(O(l,t,s,1).minus(m).abs())<1?[u,r]:[l,t],v.precision=c,g=!0,p},S.toHexadecimal=S.toHex=function(e,i){return Y(this,16,e,i)},S.toNearest=function(e,i){var t=this,r=t.constructor;if(t=new r(t),null==e){if(!t.d)return t;e=new r(1),i=r.rounding}else{if(e=new r(e),void 0===i?i=r.rounding:z(i,0,8),!t.d)return e.s?t:e;if(!e.d)return e.s&&(e.s=t.s),e}return e.d[0]?(g=!1,t=O(t,e,0,i,1).times(e),g=!0,L(t)):(e.s=t.s,t=e),t},S.toNumber=function(){return+this},S.toOctal=function(e,i){return Y(this,8,e,i)},S.toPower=S.pow=function(e){var i,t,r,n,s,a,o=this,l=o.constructor,u=+(e=new l(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new l(x(+o,u));if((o=new l(o)).eq(1))return o;if(r=l.precision,s=l.rounding,e.eq(1))return L(o,r,s);if((i=v(e.e/7))>=e.d.length-1&&(t=u<0?-u:u)<=9007199254740991)return n=$(l,o,t,r),e.s<0?new l(1).div(n):L(n,r,s);if((a=o.s)<0){if(i<e.d.length-1)return new l(NaN);if(0==(1&e.d[i])&&(a=1),0==o.e&&1==o.d[0]&&1==o.d.length)return o.s=a,o}return(i=0!=(t=x(+o,u))&&isFinite(t)?new l(t+"").e:v(u*(Math.log("0."+A(o.d))/Math.LN10+o.e+1)))>l.maxE+1||i<l.minE-1?new l(i>0?a/0:0):(g=!1,l.rounding=o.s=1,t=Math.min(12,(i+"").length),(n=_(e.times(j(o,r+t)),r)).d&&k((n=L(n,r+5,1)).d,r,s)&&(i=r+10,+A((n=L(_(e.times(j(o,i+t)),i),i+5,1)).d).slice(r+1,r+15)+1==1e14&&(n=L(n,r+1,0))),n.s=a,g=!0,l.rounding=s,L(n,r,s))},S.toPrecision=function(e,i){var t,r=this,n=r.constructor;return void 0===e?t=P(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(z(e,1,o),void 0===i?i=n.rounding:z(i,0,8),t=P(r=L(new n(r),e,i),e<=r.e||r.e<=n.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+t:t},S.toSignificantDigits=S.toSD=function(e,i){var t=this.constructor;return void 0===e?(e=t.precision,i=t.rounding):(z(e,1,o),void 0===i?i=t.rounding:z(i,0,8)),L(new t(this),e,i)},S.toString=function(){var e=this,i=e.constructor,t=P(e,e.e<=i.toExpNeg||e.e>=i.toExpPos);return e.isNeg()&&!e.isZero()?"-"+t:t},S.truncated=S.trunc=function(){return L(new this.constructor(this),this.e+1,1)},S.valueOf=S.toJSON=function(){var e=this,i=e.constructor,t=P(e,e.e<=i.toExpNeg||e.e>=i.toExpPos);return e.isNeg()?"-"+t:t};var O=function(){function e(e,i,t){var r,n=0,s=e.length;for(e=e.slice();s--;)r=e[s]*i+n,e[s]=r%t|0,n=r/t|0;return n&&e.unshift(n),e}function i(e,i,t,r){var n,s;if(t!=r)s=t>r?1:-1;else for(n=s=0;n<t;n++)if(e[n]!=i[n]){s=e[n]>i[n]?1:-1;break}return s}function t(e,i,t,r){for(var n=0;t--;)e[t]-=n,n=e[t]<i[t]?1:0,e[t]=n*r+e[t]-i[t];for(;!e[0]&&e.length>1;)e.shift()}return function(n,s,a,o,l,u){var c,h,g,p,f,m,d,x,y,b,w,N,E,M,S,A,z,k,I,O,P=n.constructor,D=n.s==s.s?1:-1,F=n.d,T=s.d;if(!(F&&F[0]&&T&&T[0]))return new P(n.s&&s.s&&(F?!T||F[0]!=T[0]:T)?F&&0==F[0]||!T?0*D:D/0:NaN);for(u?(f=1,h=n.e-s.e):(u=q,f=7,h=v(n.e/f)-v(s.e/f)),I=T.length,z=F.length,b=(y=new P(D)).d=[],g=0;T[g]==(F[g]||0);g++);if(T[g]>(F[g]||0)&&h--,null==a?(M=a=P.precision,o=P.rounding):M=l?a+(n.e-s.e)+1:a,M<0)b.push(1),m=!0;else{if(M=M/f+2|0,g=0,1==I){for(p=0,T=T[0],M++;(g<z||p)&&M--;g++)S=p*u+(F[g]||0),b[g]=S/T|0,p=S%T|0;m=p||g<z}else{for((p=u/(T[0]+1)|0)>1&&(T=e(T,p,u),F=e(F,p,u),I=T.length,z=F.length),A=I,N=(w=F.slice(0,I)).length;N<I;)w[N++]=0;(O=T.slice()).unshift(0),k=T[0],T[1]>=u/2&&++k;do{p=0,(c=i(T,w,I,N))<0?(E=w[0],I!=N&&(E=E*u+(w[1]||0)),(p=E/k|0)>1?(p>=u&&(p=u-1),1==(c=i(d=e(T,p,u),w,x=d.length,N=w.length))&&(p--,t(d,I<x?O:T,x,u))):(0==p&&(c=p=1),d=T.slice()),(x=d.length)<N&&d.unshift(0),t(w,d,N,u),-1==c&&(c=i(T,w,I,N=w.length))<1&&(p++,t(w,I<N?O:T,N,u)),N=w.length):0===c&&(p++,w=[0]),b[g++]=p,c&&w[0]?w[N++]=F[A]||0:(w=[F[A]],N=1)}while((A++<z||void 0!==w[0])&&M--);m=void 0!==w[0]}b[0]||b.shift()}if(1==f)y.e=h,r=m;else{for(g=1,p=b[0];p>=10;p/=10)g++;y.e=g+h*f-1,L(y,l?a+y.e+1:a,o,m)}return y}}();function L(e,i,t,r){var n,s,a,o,l,u,c,h,p,f=e.constructor;e:if(null!=i){if(!(h=e.d))return e;for(n=1,o=h[0];o>=10;o/=10)n++;if((s=i-n)<0)s+=7,a=i,l=(c=h[p=0])/x(10,n-a-1)%10|0;else if((p=Math.ceil((s+1)/7))>=(o=h.length)){if(!r)break e;for(;o++<=p;)h.push(0);c=l=0,n=1,a=(s%=7)-7+1}else{for(c=o=h[p],n=1;o>=10;o/=10)n++;l=(a=(s%=7)-7+n)<0?0:c/x(10,n-a-1)%10|0}if(r=r||i<0||void 0!==h[p+1]||(a<0?c:c%x(10,n-a-1)),u=t<4?(l||r)&&(0==t||t==(e.s<0?3:2)):l>5||5==l&&(4==t||r||6==t&&(s>0?a>0?c/x(10,n-a):0:h[p-1])%10&1||t==(e.s<0?8:7)),i<1||!h[0])return h.length=0,u?(i-=e.e+1,h[0]=x(10,(7-i%7)%7),e.e=-i||0):h[0]=e.e=0,e;if(0==s?(h.length=p,o=1,p--):(h.length=p+1,o=x(10,7-s),h[p]=a>0?(c/x(10,n-a)%x(10,a)|0)*o:0),u)for(;;){if(0==p){for(s=1,a=h[0];a>=10;a/=10)s++;for(a=h[0]+=o,o=1;a>=10;a/=10)o++;s!=o&&(e.e++,h[0]==q&&(h[0]=1));break}if(h[p]+=o,h[p]!=q)break;h[p--]=0,o=1}for(s=h.length;0===h[--s];)h.pop()}return g&&(e.e>f.maxE?(e.d=null,e.e=NaN):e.e<f.minE&&(e.e=0,e.d=[0])),e}function P(e,i,t){if(!e.isFinite())return U(e);var r,n=e.e,s=A(e.d),a=s.length;return i?(t&&(r=t-a)>0?s=s.charAt(0)+"."+s.slice(1)+R(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):n<0?(s="0."+R(-n-1)+s,t&&(r=t-a)>0&&(s+=R(r))):n>=a?(s+=R(n+1-a),t&&(r=t-n-1)>0&&(s=s+"."+R(r))):((r=n+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),t&&(r=t-a)>0&&(n+1===a&&(s+="."),s+=R(r))),s}function D(e,i){var t=e[0];for(i*=7;t>=10;t/=10)i++;return i}function F(e,i,t){if(i>E)throw g=!0,t&&(e.precision=t),Error(m);return L(new e(u),i,1,!0)}function T(e,i,t){if(i>M)throw Error(m);return L(new e(c),i,t,!0)}function C(e){var i=e.length-1,t=7*i+1;if(i=e[i]){for(;i%10==0;i/=10)t--;for(i=e[0];i>=10;i/=10)t++}return t}function R(e){for(var i="";e--;)i+="0";return i}function $(e,i,t,r){var n,s=new e(1),a=Math.ceil(r/7+4);for(g=!1;;){if(t%2&&J((s=s.times(i)).d,a)&&(n=!0),0===(t=v(t/2))){t=s.d.length-1,n&&0===s.d[t]&&++s.d[t];break}J((i=i.times(i)).d,a)}return g=!0,s}function Z(e){return 1&e.d[e.d.length-1]}function B(e,i,t){for(var r,n=new e(i[0]),s=0;++s<i.length;){if(!(r=new e(i[s])).s){n=r;break}n[t](r)&&(n=r)}return n}function _(e,i){var t,r,n,s,a,o,l,u=0,c=0,h=0,p=e.constructor,f=p.rounding,m=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==i?(g=!1,l=m):l=i,o=new p(.03125);e.e>-2;)e=e.times(o),h+=5;for(l+=r=Math.log(x(2,h))/Math.LN10*2+5|0,t=s=a=new p(1),p.precision=l;;){if(s=L(s.times(e),l,1),t=t.times(++c),A((o=a.plus(O(s,t,l,1))).d).slice(0,l)===A(a.d).slice(0,l)){for(n=h;n--;)a=L(a.times(a),l,1);if(null!=i)return p.precision=m,a;if(!(u<3&&k(a.d,l-r,f,u)))return L(a,p.precision=m,f,g=!0);p.precision=l+=10,t=s=o=new p(1),c=0,u++}a=o}}function j(e,i){var t,r,n,s,a,o,l,u,c,h,p,f=1,m=e,d=m.d,v=m.constructor,x=v.rounding,y=v.precision;if(m.s<0||!d||!d[0]||!m.e&&1==d[0]&&1==d.length)return new v(d&&!d[0]?-1/0:1!=m.s?NaN:d?0:m);if(null==i?(g=!1,c=y):c=i,v.precision=c+=10,r=(t=A(d)).charAt(0),!(Math.abs(s=m.e)<15e14))return u=F(v,c+2,y).times(s+""),m=j(new v(r+"."+t.slice(1)),c-10).plus(u),v.precision=y,null==i?L(m,y,x,g=!0):m;for(;r<7&&1!=r||1==r&&t.charAt(1)>3;)r=(t=A((m=m.times(e)).d)).charAt(0),f++;for(s=m.e,r>1?(m=new v("0."+t),s++):m=new v(r+"."+t.slice(1)),h=m,l=a=m=O(m.minus(1),m.plus(1),c,1),p=L(m.times(m),c,1),n=3;;){if(a=L(a.times(p),c,1),A((u=l.plus(O(a,new v(n),c,1))).d).slice(0,c)===A(l.d).slice(0,c)){if(l=l.times(2),0!==s&&(l=l.plus(F(v,c+2,y).times(s+""))),l=O(l,new v(f),c,1),null!=i)return v.precision=y,l;if(!k(l.d,c-10,x,o))return L(l,v.precision=y,x,g=!0);v.precision=c+=10,u=a=m=O(h.minus(1),h.plus(1),c,1),p=L(m.times(m),c,1),n=o=1}l=u,n+=2}}function U(e){return String(e.s*e.s/0)}function H(e,i){var t,r,n;for((t=i.indexOf("."))>-1&&(i=i.replace(".","")),(r=i.search(/e/i))>0?(t<0&&(t=r),t+=+i.slice(r+1),i=i.substring(0,r)):t<0&&(t=i.length),r=0;48===i.charCodeAt(r);r++);for(n=i.length;48===i.charCodeAt(n-1);--n);if(i=i.slice(r,n)){if(n-=r,e.e=t=t-r-1,e.d=[],r=(t+1)%7,t<0&&(r+=7),r<n){for(r&&e.d.push(+i.slice(0,r)),n-=7;r<n;)e.d.push(+i.slice(r,r+=7));r=7-(i=i.slice(r)).length}else r-=n;for(;r--;)i+="0";e.d.push(+i),g&&(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 G(e,i){var r,n,s,a,o,l,u,c,h;if("Infinity"===i||"NaN"===i)return+i||(e.s=NaN),e.e=NaN,e.d=null,e;if(b.test(i))r=16,i=i.toLowerCase();else if(y.test(i))r=2;else{if(!w.test(i))throw Error(f+i);r=8}for((a=i.search(/p/i))>0?(u=+i.slice(a+1),i=i.substring(2,a)):i=i.slice(2),o=(a=i.indexOf("."))>=0,n=e.constructor,o&&(a=(l=(i=i.replace(".","")).length)-a,s=$(n,new n(r),a,2*a)),a=h=(c=I(i,r,q)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=D(c,h),e.d=c,g=!1,o&&(e=O(e,s,4*l)),u&&(e=e.times(Math.abs(u)<54?x(2,u):t.pow(2,u))),g=!0,e)}function V(e,i,t,r,n){var s,a,o,l,u=e.precision,c=Math.ceil(u/7);for(g=!1,l=t.times(t),o=new e(r);;){if(a=O(o.times(l),new e(i++*i++),u,1),o=n?r.plus(a):r.minus(a),r=O(a.times(l),new e(i++*i++),u,1),void 0!==(a=o.plus(r)).d[c]){for(s=c;a.d[s]===o.d[s]&&s--;);if(-1==s)break}s=o,o=r,r=a,a=s}return g=!0,a.d.length=c+1,a}function W(e,i){for(var t=e;--i;)t*=e;return t}function Q(e,i){var t,r=i.s<0,n=T(e,e.precision,1),a=n.times(.5);if((i=i.abs()).lte(a))return s=r?4:1,i;if((t=i.divToInt(n)).isZero())s=r?3:2;else{if((i=i.minus(t.times(n))).lte(a))return s=Z(t)?r?2:3:r?4:1,i;s=Z(t)?r?1:4:r?3:2}return i.minus(n).abs()}function Y(e,i,t,n){var s,a,u,c,h,g,p,f,m,d=e.constructor,v=void 0!==t;if(v?(z(t,1,o),void 0===n?n=d.rounding:z(n,0,8)):(t=d.precision,n=d.rounding),e.isFinite()){for(v?(s=2,16==i?t=4*t-3:8==i&&(t=3*t-2)):s=i,(u=(p=P(e)).indexOf("."))>=0&&(p=p.replace(".",""),(m=new d(1)).e=p.length-u,m.d=I(P(m),10,s),m.e=m.d.length),a=h=(f=I(p,10,s)).length;0==f[--h];)f.pop();if(f[0]){if(u<0?a--:((e=new d(e)).d=f,e.e=a,f=(e=O(e,m,t,n,0,s)).d,a=e.e,g=r),u=f[t],c=s/2,g=g||void 0!==f[t+1],g=n<4?(void 0!==u||g)&&(0===n||n===(e.s<0?3:2)):u>c||u===c&&(4===n||g||6===n&&1&f[t-1]||n===(e.s<0?8:7)),f.length=t,g)for(;++f[--t]>s-1;)f[t]=0,t||(++a,f.unshift(1));for(h=f.length;!f[h-1];--h);for(u=0,p="";u<h;u++)p+=l.charAt(f[u]);if(v){if(h>1)if(16==i||8==i){for(u=16==i?4:3,--h;h%u;h++)p+="0";for(h=(f=I(p,s,i)).length;!f[h-1];--h);for(u=1,p="1.";u<h;u++)p+=l.charAt(f[u])}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>h)for(a-=h;a--;)p+="0";else a<h&&(p=p.slice(0,a)+"."+p.slice(a))}else p=v?"0p+0":"0";p=(16==i?"0x":2==i?"0b":8==i?"0o":"")+p}else p=U(e);return e.s<0?"-"+p:p}function J(e,i){if(e.length>i)return e.length=i,!0}function K(e){return new this(e).abs()}function X(e){return new this(e).acos()}function ee(e){return new this(e).acosh()}function ie(e,i){return new this(e).plus(i)}function te(e){return new this(e).asin()}function re(e){return new this(e).asinh()}function ne(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function ae(e,i){e=new this(e),i=new this(i);var t,r=this.precision,n=this.rounding,s=r+4;return e.s&&i.s?e.d||i.d?!i.d||e.isZero()?(t=i.s<0?T(this,r,n):new this(0)).s=e.s:!e.d||i.isZero()?(t=T(this,s,1).times(.5)).s=e.s:i.s<0?(this.precision=s,this.rounding=1,t=this.atan(O(e,i,s,1)),i=T(this,s,1),this.precision=r,this.rounding=n,t=e.s<0?t.minus(i):t.plus(i)):t=this.atan(O(e,i,s,1)):(t=T(this,s,1).times(i.s>0?.25:.75)).s=e.s:t=new this(NaN),t}function oe(e){return new this(e).cbrt()}function le(e){return L(e=new this(e),e.e+1,2)}function ue(e){if(!e||"object"!=typeof e)throw Error(p+"Object expected");var i,t,r,n=!0===e.defaults,s=["precision",1,o,"rounding",0,8,"toExpNeg",-a,0,"toExpPos",0,a,"maxE",0,a,"minE",-a,0,"modulo",0,9];for(i=0;i<s.length;i+=3)if(t=s[i],n&&(this[t]=h[t]),void 0!==(r=e[t])){if(!(v(r)===r&&r>=s[i+1]&&r<=s[i+2]))throw Error(f+t+": "+r);this[t]=r}if(t="crypto",n&&(this[t]=h[t]),void 0!==(r=e[t])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(f+t+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[t]=!0}else this[t]=!1}return this}function ce(e){return new this(e).cos()}function he(e){return new this(e).cosh()}function ge(e,i){return new this(e).div(i)}function pe(e){return new this(e).exp()}function fe(e){return L(e=new this(e),e.e+1,3)}function me(){var e,i,t=new this(0);for(g=!1,e=0;e<arguments.length;)if((i=new this(arguments[e++])).d)t.d&&(t=t.plus(i.times(i)));else{if(i.s)return g=!0,new this(1/0);t=i}return g=!0,t.sqrt()}function de(e){return e instanceof t||e&&"[object Decimal]"===e.name||!1}function ve(e){return new this(e).ln()}function xe(e,i){return new this(e).log(i)}function ye(e){return new this(e).log(2)}function be(e){return new this(e).log(10)}function we(){return B(this,arguments,"lt")}function Ne(){return B(this,arguments,"gt")}function qe(e,i){return new this(e).mod(i)}function Ee(e,i){return new this(e).mul(i)}function Me(e,i){return new this(e).pow(i)}function Se(e){var i,t,r,n,s=0,a=new this(1),l=[];if(void 0===e?e=this.precision:z(e,1,o),r=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(i=crypto.getRandomValues(new Uint32Array(r));s<r;)(n=i[s])>=429e7?i[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=n%1e7;else{if(!crypto.randomBytes)throw Error(d);for(i=crypto.randomBytes(r*=4);s<r;)(n=i[s]+(i[s+1]<<8)+(i[s+2]<<16)+((127&i[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(i,s):(l.push(n%1e7),s+=4);s=r/4}else for(;s<r;)l[s++]=1e7*Math.random()|0;for(e%=7,(r=l[--s])&&e&&(n=x(10,7-e),l[s]=(r/n|0)*n);0===l[s];s--)l.pop();if(s<0)t=0,l=[0];else{for(t=-1;0===l[0];t-=7)l.shift();for(r=1,n=l[0];n>=10;n/=10)r++;r<7&&(t-=7-r)}return a.e=t,a.d=l,a}function Ae(e){return L(e=new this(e),e.e+1,this.rounding)}function ze(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function ke(e){return new this(e).sin()}function Ie(e){return new this(e).sinh()}function Oe(e){return new this(e).sqrt()}function Le(e,i){return new this(e).sub(i)}function Pe(e){return new this(e).tan()}function De(e){return new this(e).tanh()}function Fe(e){return L(e=new this(e),e.e+1,1)}(t=function e(i){var t,r,n;function s(e){var i,t,r,n=this;if(!(n instanceof s))return new s(e);if(n.constructor=s,e instanceof s)return n.s=e.s,void(g?!e.d||e.e>s.maxE?(n.e=NaN,n.d=null):e.e<s.minE?(n.e=0,n.d=[0]):(n.e=e.e,n.d=e.d.slice()):(n.e=e.e,n.d=e.d?e.d.slice():e.d));if("number"==(r=typeof e)){if(0===e)return n.s=1/e<0?-1:1,n.e=0,void(n.d=[0]);if(e<0?(e=-e,n.s=-1):n.s=1,e===~~e&&e<1e7){for(i=0,t=e;t>=10;t/=10)i++;return void(g?i>s.maxE?(n.e=NaN,n.d=null):i<s.minE?(n.e=0,n.d=[0]):(n.e=i,n.d=[e]):(n.e=i,n.d=[e]))}return 0*e!=0?(e||(n.s=NaN),n.e=NaN,void(n.d=null)):H(n,e.toString())}if("string"!==r)throw Error(f+e);return 45===(t=e.charCodeAt(0))?(e=e.slice(1),n.s=-1):(43===t&&(e=e.slice(1)),n.s=1),N.test(e)?H(n,e):G(n,e)}if(s.prototype=S,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=ue,s.clone=e,s.isDecimal=de,s.abs=K,s.acos=X,s.acosh=ee,s.add=ie,s.asin=te,s.asinh=re,s.atan=ne,s.atanh=se,s.atan2=ae,s.cbrt=oe,s.ceil=le,s.cos=ce,s.cosh=he,s.div=ge,s.exp=pe,s.floor=fe,s.hypot=me,s.ln=ve,s.log=xe,s.log10=be,s.log2=ye,s.max=we,s.min=Ne,s.mod=qe,s.mul=Ee,s.pow=Me,s.random=Se,s.round=Ae,s.sign=ze,s.sin=ke,s.sinh=Ie,s.sqrt=Oe,s.sub=Le,s.tan=Pe,s.tanh=De,s.trunc=Fe,void 0===i&&(i={}),i&&!0!==i.defaults)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)i.hasOwnProperty(r=n[t++])||(i[r]=this[r]);return s.config(i),s}(h)).default=t.Decimal=t,u=new t(u),c=new t(c),e.exports?("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(S[Symbol.for("nodejs.util.inspect.custom")]=S.toString,S[Symbol.toStringTag]="Decimal"),e.exports=t):(i||(i="undefined"!=typeof self&&self&&self.self==self?self:window),n=i.Decimal,t.noConflict=function(){return i.Decimal=n,t},i.Decimal=t)}(c)}(h);var g={exports:{}};
/**
* @license Complex.js v2.0.13 12/05/2020
*
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/!function(e,i){!function(i){var t=function(e){return.5*(Math.exp(e)+Math.exp(-e))},r=function(e){return.5*(Math.exp(e)-Math.exp(-e))},n=function(){throw SyntaxError("Invalid Param")};function s(e,i){var t=Math.abs(e),r=Math.abs(i);return 0===e?Math.log(r):0===i?Math.log(t):t<3e3&&r<3e3?.5*Math.log(e*e+i*i):Math.log(e/Math.cos(Math.atan2(i,e)))}function a(e,i){if(!(this instanceof a))return new a(e,i);var t=function(e,i){var t={re:0,im:0};if(null==e)t.re=t.im=0;else if(void 0!==i)t.re=e,t.im=i;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return a.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return a.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else 2===e.length?(t.re=e[0],t.im=e[1]):n();break;case"string":t.im=t.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),s=1,o=0;null===r&&n();for(var l=0;l<r.length;l++){var u=r[l];" "===u||"\t"===u||"\n"===u||("+"===u?s++:"-"===u?o++:"i"===u||"I"===u?(s+o===0&&n()," "===r[l+1]||isNaN(r[l+1])?t.im+=parseFloat((o%2?"-":"")+"1"):(t.im+=parseFloat((o%2?"-":"")+r[l+1]),l++),s=o=0):((s+o===0||isNaN(u))&&n(),"i"===r[l+1]||"I"===r[l+1]?(t.im+=parseFloat((o%2?"-":"")+u),l++):t.re+=parseFloat((o%2?"-":"")+u),s=o=0))}s+o>0&&n();break;case"number":t.im=0,t.re=e;break;default:n()}return isNaN(t.re)||isNaN(t.im),t}(e,i);this.re=t.re,this.im=t.im}a.prototype={re:0,im:0,sign:function(){var e=this.abs();return new a(this.re/e,this.im/e)},add:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:new a(this.re+t.re,this.im+t.im)},sub:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:new a(this.re-t.re,this.im-t.im)},mul:function(e,i){var t=new a(e,i);return this.isInfinite()&&t.isZero()||this.isZero()&&t.isInfinite()?a.NAN:this.isInfinite()||t.isInfinite()?a.INFINITY:0===t.im&&0===this.im?new a(this.re*t.re,0):new a(this.re*t.re-this.im*t.im,this.re*t.im+this.im*t.re)},div:function(e,i){var t=new a(e,i);if(this.isZero()&&t.isZero()||this.isInfinite()&&t.isInfinite())return a.NAN;if(this.isInfinite()||t.isZero())return a.INFINITY;if(this.isZero()||t.isInfinite())return a.ZERO;e=this.re,i=this.im;var r,n,s=t.re,o=t.im;return 0===o?new a(e/s,i/s):Math.abs(s)<Math.abs(o)?new a((e*(n=s/o)+i)/(r=s*n+o),(i*n-e)/r):new a((e+i*(n=o/s))/(r=o*n+s),(i-e*n)/r)},pow:function(e,i){var t=new a(e,i);if(e=this.re,i=this.im,t.isZero())return a.ONE;if(0===t.im){if(0===i&&e>0)return new a(Math.pow(e,t.re),0);if(0===e)switch((t.re%4+4)%4){case 0:return new a(Math.pow(i,t.re),0);case 1:return new a(0,Math.pow(i,t.re));case 2:return new a(-Math.pow(i,t.re),0);case 3:return new a(0,-Math.pow(i,t.re))}}if(0===e&&0===i&&t.re>0&&t.im>=0)return a.ZERO;var r=Math.atan2(i,e),n=s(e,i);return e=Math.exp(t.re*n-t.im*r),i=t.im*n+t.re*r,new a(e*Math.cos(i),e*Math.sin(i))},sqrt:function(){var e,i,t=this.re,r=this.im,n=this.abs();if(t>=0){if(0===r)return new a(Math.sqrt(t),0);e=.5*Math.sqrt(2*(n+t))}else e=Math.abs(r)/Math.sqrt(2*(n-t));return i=t<=0?.5*Math.sqrt(2*(n-t)):Math.abs(r)/Math.sqrt(2*(n+t)),new a(e,r<0?-i:i)},exp:function(){var e=Math.exp(this.re);return this.im,new a(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,i=this.im;return new a(Math.expm1(e)*Math.cos(i)+function(e){var i=Math.PI/4;if(e<-i||e>i)return Math.cos(e)-1;var t=e*e;return t*(t*(1/24+t*(-1/720+t*(1/40320+t*(-1/3628800+t*(1/4790014600+t*(-1/87178291200+t*(1/20922789888e3)))))))-.5)}(i),Math.exp(e)*Math.sin(i))},log:function(){var e=this.re,i=this.im;return new a(s(e,i),Math.atan2(i,e))},abs:function(){return e=this.re,i=this.im,t=Math.abs(e),r=Math.abs(i),t<3e3&&r<3e3?Math.sqrt(t*t+r*r):(t<r?(t=r,r=e/i):r=i/e,t*Math.sqrt(1+r*r));var e,i,t,r},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,i=this.im;return new a(Math.sin(e)*t(i),Math.cos(e)*r(i))},cos:function(){var e=this.re,i=this.im;return new a(Math.cos(e)*t(i),-Math.sin(e)*r(i))},tan:function(){var e=2*this.re,i=2*this.im,n=Math.cos(e)+t(i);return new a(Math.sin(e)/n,r(i)/n)},cot:function(){var e=2*this.re,i=2*this.im,n=Math.cos(e)-t(i);return new a(-Math.sin(e)/n,r(i)/n)},sec:function(){var e=this.re,i=this.im,n=.5*t(2*i)+.5*Math.cos(2*e);return new a(Math.cos(e)*t(i)/n,Math.sin(e)*r(i)/n)},csc:function(){var e=this.re,i=this.im,n=.5*t(2*i)-.5*Math.cos(2*e);return new a(Math.sin(e)*t(i)/n,-Math.cos(e)*r(i)/n)},asin:function(){var e=this.re,i=this.im,t=new a(i*i-e*e+1,-2*e*i).sqrt(),r=new a(t.re-i,t.im+e).log();return new a(r.im,-r.re)},acos:function(){var e=this.re,i=this.im,t=new a(i*i-e*e+1,-2*e*i).sqrt(),r=new a(t.re-i,t.im+e).log();return new a(Math.PI/2-r.im,r.re)},atan:function(){var e=this.re,i=this.im;if(0===e){if(1===i)return new a(0,1/0);if(-1===i)return new a(0,-1/0)}var t=e*e+(1-i)*(1-i),r=new a((1-i*i-e*e)/t,-2*e/t).log();return new a(-.5*r.im,.5*r.re)},acot:function(){var e=this.re,i=this.im;if(0===i)return new a(Math.atan2(1,e),0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).atan():new a(0!==e?e/0:0,0!==i?-i/0:0).atan()},asec:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(0,1/0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).acos():new a(0!==e?e/0:0,0!==i?-i/0:0).acos()},acsc:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(Math.PI/2,1/0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).asin():new a(0!==e?e/0:0,0!==i?-i/0:0).asin()},sinh:function(){var e=this.re,i=this.im;return new a(r(e)*Math.cos(i),t(e)*Math.sin(i))},cosh:function(){var e=this.re,i=this.im;return new a(t(e)*Math.cos(i),r(e)*Math.sin(i))},tanh:function(){var e=2*this.re,i=2*this.im,n=t(e)+Math.cos(i);return new a(r(e)/n,Math.sin(i)/n)},coth:function(){var e=2*this.re,i=2*this.im,n=t(e)-Math.cos(i);return new a(r(e)/n,-Math.sin(i)/n)},csch:function(){var e=this.re,i=this.im,n=Math.cos(2*i)-t(2*e);return new a(-2*r(e)*Math.cos(i)/n,2*t(e)*Math.sin(i)/n)},sech:function(){var e=this.re,i=this.im,n=Math.cos(2*i)+t(2*e);return new a(2*t(e)*Math.cos(i)/n,-2*r(e)*Math.sin(i)/n)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;var i=this.asin();return this.re=-this.im,this.im=e,e=i.re,i.re=-i.im,i.im=e,i},acosh:function(){var e=this.acos();if(e.im<=0){var i=e.re;e.re=-e.im,e.im=i}else i=e.im,e.im=-e.re,e.re=i;return e},atanh:function(){var e=this.re,i=this.im,t=e>1&&0===i,r=1-e,n=1+e,o=r*r+i*i,l=0!==o?new a((n*r-i*i)/o,(i*r+n*i)/o):new a(-1!==e?e/0:0,0!==i?i/0:0),u=l.re;return l.re=s(l.re,l.im)/2,l.im=Math.atan2(l.im,u)/2,t&&(l.im=-l.im),l},acoth:function(){var e=this.re,i=this.im;if(0===e&&0===i)return new a(0,Math.PI/2);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).atanh():new a(0!==e?e/0:0,0!==i?-i/0:0).atanh()},acsch:function(){var e=this.re,i=this.im;if(0===i)return new a(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).asinh():new a(0!==e?e/0:0,0!==i?-i/0:0).asinh()},asech:function(){var e=this.re,i=this.im;if(this.isZero())return a.INFINITY;var t=e*e+i*i;return 0!==t?new a(e/t,-i/t).acosh():new a(0!==e?e/0:0,0!==i?-i/0:0).acosh()},inverse:function(){if(this.isZero())return a.INFINITY;if(this.isInfinite())return a.ZERO;var e=this.re,i=this.im,t=e*e+i*i;return new a(e/t,-i/t)},conjugate:function(){return new a(this.re,-this.im)},neg:function(){return new a(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new a(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new a(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new a(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,i){var t=new a(e,i);return Math.abs(t.re-this.re)<=a.EPSILON&&Math.abs(t.im-this.im)<=a.EPSILON},clone:function(){return new a(this.re,this.im)},toString:function(){var e=this.re,i=this.im,t="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<a.EPSILON&&(e=0),Math.abs(i)<a.EPSILON&&(i=0),0===i?t+e:(0!==e?(t+=e,t+=" ",i<0?(i=-i,t+="-"):t+="+",t+=" "):i<0&&(i=-i,t+="-"),1!==i&&(t+=i),t+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},a.ZERO=new a(0,0),a.ONE=new a(1,0),a.I=new a(0,1),a.PI=new a(Math.PI,0),a.E=new a(Math.E,0),a.INFINITY=new a(1/0,1/0),a.NAN=new a(NaN,NaN),a.EPSILON=1e-15,Object.defineProperty(a,"__esModule",{value:!0}),a.default=a,a.Complex=a,e.exports=a}()}(g),new h.exports.Decimal(0),new h.exports.Decimal(1),new h.exports.Decimal(-1),new h.exports.Decimal(NaN),new h.exports.Decimal(1/0),new h.exports.Decimal(-1/0),h.exports.Decimal.acos(-1),h.exports.Decimal.exp(1),Math.pow(10,-10);const p="Parentheses",f="LatexTokens",m="List",d="Missing",v="Nothing",x="Sequence",y="Sequence2",b="Add",w="Derivative",N="Divide",q="InverseFunction",E="Multiply",M="Negate",S="Power",A="Prime",z="Root",k="Sqrt",I="Subtract",O="ComplexInfinity",L="ImaginaryUnit";function P(e){return null!==e&&"object"==typeof e&&"num"in e}function D(e){return null!==e&&"object"==typeof e&&"sym"in e}function F(e){return null!==e&&"object"==typeof e&&"fn"in e}function T(e){if("number"==typeof e)return e;if(null===e)return null;if(P(e))return e.num.endsWith("d")||e.num.endsWith("n")?null:parseFloat(e.num);const i=_(e);return null===i?null:"NaN"===i?NaN:"+Infinity"===i?1/0:"-Infinity"===i?-1/0:"Complex"===B(e)&&0===T(U(e,2))?T(U(e,1)):null}function C(e){return null===e?null:"object"==typeof e&&"str"in e?e.str:"string"!=typeof e||e.length<2||"'"!==e[0]||"'"!==e[e.length-1]?null:e.substring(1,e.length-1)}function R(e){var i,t,r,n,s,a;if("number"==typeof e&&Number.isInteger(e))return[e,1];if(P(e)){const i=T(e);if(null!==i&&Number.isInteger(i))return[i,1]}const o=_(e);if("ThreeQuarter"===o)return[3,4];if("TwoThird"===o)return[2,3];if("Half"===o)return[1,2];if("Third"===o)return[1,3];if("Quarter"===o)return[1,4];if(Z(e))return[null,null];const l=B(e);if(!l)return[null,null];let u=null,c=null;if(l===S){const r=T(U(e,2));1===r?(u=null!==(i=T(U(e,1)))&&void 0!==i?i:null,c=1):-1===r&&(u=1,c=null!==(t=T(U(e,1)))&&void 0!==t?t:null)}return l===N&&(u=null!==(r=T(U(e,1)))&&void 0!==r?r:null,c=null!==(n=T(U(e,2)))&&void 0!==n?n:null),l===E&&B(U(e,2))===S&&-1===T(U(U(e,2),2))&&(u=null!==(s=T(U(e,1)))&&void 0!==s?s:null,c=null!==(a=T(U(U(e,2),1)))&&void 0!==a?a:null),null===u||null===c?[null,null]:Number.isInteger(u)&&Number.isInteger(c)?[u,c]:[null,null]}function $(e){return null===e?null:Array.isArray(e)?e[0]:F(e)?e.fn[0]:null}function Z(e){return null===e||!Array.isArray(e)&&("object"!=typeof e||!("fn"in e||"dic"in e))}function B(e){if(null===e)return"";const i=$(e);return"string"==typeof i?i:""}function _(e){return null===e?null:"string"==typeof e?e.length>=2&&"'"===e[0]&&"'"===e[e.length-1]?null:e:D(e)?e.sym:null}function j(e){return Array.isArray(e)?e.slice(1):F(e)?e.fn.slice(1):[]}function U(e,i){return null===e?null:Array.isArray(e)?e[i]:F(e)?e.fn[i]:null}function H(e){return Array.isArray(e)?Math.max(0,e.length-1):F(e)?Math.max(0,e.fn.length-1):0}function G(e){return"object"==typeof e&&"dict"in e?e.dict:null}const V=[{name:"Overscript",trigger:{infix:"\\overset"},precedence:700},{name:"Underscript",trigger:{infix:"\\underset"},precedence:700},{name:"Increment",trigger:{postfix:["+","+"]},precedence:880},{name:"Decrement",trigger:{postfix:["-","-"]},precedence:880},{name:"PreIncrement",trigger:{prefix:["+","+"]},precedence:880},{name:"PreDecrement",trigger:{prefix:["-","-"]},precedence:880},{name:"Ring",trigger:{infix:"\\circ"},precedence:265},{name:"Transpose",trigger:{superfix:"T"}},{name:"ConjugateTranspose",trigger:{superfix:"H"}},{name:"StringJoin",trigger:{infix:["\\lt","\\gt"]},precedence:780},{name:"Starstar",trigger:{infix:["\\star","\\star"]},precedence:780},{name:"PartialDerivative",trigger:{prefix:"\\partial"},parse:(e,i,t)=>{var r,n;let s=!1,a=v,o=v;for(;!s;)i.skipSpace(),i.match("_")?o=i.matchRequiredLatexArgument():i.match("^")?a=i.matchRequiredLatexArgument():s=!0;if(B(o)===x&&(o=[m,...j(o)]),!o||!a)return[e,null];let l=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:v;return l!==v&&(l=[l,...null!==(n=i.matchArguments("group"))&&void 0!==n?n:v]),[null,["PartialDerivative",l,o,a]]},serialize:(e,i)=>{let t="\\partial";const r=U(i,1),n=U(i,2),s=U(i,3);return null!==n&&n!==v&&($(n)===m?t+="_{"+e.serialize([x,...j(n)])+"}":t+="_{"+e.serialize(n)+"}"),null!==s&&s!==v&&(t+="^{"+e.serialize(s)+"}"),null!==r&&r!==v&&(t+=e.serialize(r)),t},precedence:740},{name:"OverBar",trigger:{symbol:"\\overline"},requiredLatexArg:1},{name:"UnderBar",trigger:{symbol:"\\underline"},requiredLatexArg:1},{name:"OverVector",trigger:{symbol:"\\vec"},requiredLatexArg:1},{name:"OverTile",trigger:{symbol:"\\tilde"},requiredLatexArg:1},{name:"OverHat",trigger:{symbol:"\\hat"},requiredLatexArg:1},{name:"OverHat",trigger:{symbol:"\\hat"},requiredLatexArg:1},{name:"OverRightArrow",trigger:{symbol:"\\overrightarrow"},requiredLatexArg:1},{name:"OverLeftArrow",trigger:{symbol:"\\overleftarrow"},requiredLatexArg:1},{name:"OverRightDoubleArrow",trigger:{symbol:"\\Overrightarrow"},requiredLatexArg:1},{name:"OverLeftHarpoon",trigger:{symbol:"\\overleftharpoon"},requiredLatexArg:1},{name:"OverRightHarpoon",trigger:{symbol:"\\overrightharpoon"},requiredLatexArg:1},{name:"OverLeftRightArrow",trigger:{symbol:"\\overleftrightarrow"},requiredLatexArg:1},{name:"OverBrace",trigger:{symbol:"\\overbrace"},requiredLatexArg:1},{name:"OverLineSegment",trigger:{symbol:"\\overlinesegment"},requiredLatexArg:1},{name:"OverGroup",trigger:{symbol:"\\overgroup"},requiredLatexArg:1}];function W(e,i){return i>2?"solidus":"radical"}function Q(e){return"<space>"===e||"\\qquad"===e||"\\quad"===e||"\\enskip"===e||"\\;"===e||"\\,"===e||"\\ "===e||"~"===e}function Y(e,i,t){return(r,n,s)=>{if(s>=i)r