@cortex-js/compute-engine 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/compute-engine.esm.js +22846 -16608
- package/dist/compute-engine.js +23518 -17282
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +4337 -10529
- package/dist/math-json.js +4354 -10532
- package/dist/math-json.min.esm.js +2 -7
- package/dist/math-json.min.js +2 -7
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +90 -0
- package/dist/types/compute-engine/assume.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +93 -0
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +52 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
- package/dist/types/compute-engine/compute-engine.d.ts +252 -0
- package/dist/types/compute-engine/cost-function.d.ts +3 -0
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
- package/dist/types/compute-engine/dictionary/collections.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +26 -0
- package/dist/types/compute-engine/dictionary/logic.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/sets.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/domain-utils.d.ts +30 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
- package/dist/types/compute-engine/latex-syntax/public.d.ts +550 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +2 -3
- package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +43 -0
- package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
- package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
- package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +1076 -434
- package/dist/types/compute-engine/rules.d.ts +18 -0
- package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
- package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
- package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
- package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
- package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
- package/dist/types/compute-engine.d.ts +3 -0
- package/dist/types/math-json/math-json-format.d.ts +101 -0
- package/dist/types/math-json/utils.d.ts +97 -0
- package/dist/types/math-json.d.ts +5 -3
- package/package.json +39 -36
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
- package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
- package/dist/types/compute-engine/numeric.d.ts +0 -21
- package/dist/types/compute-engine/patterns.d.ts +0 -22
- package/dist/types/compute-engine/predicates.d.ts +0 -42
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
- package/dist/types/latex-syntax/definitions.d.ts +0 -40
- package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
- package/dist/types/latex-syntax/parse.d.ts +0 -138
- package/dist/types/latex-syntax/public.d.ts +0 -455
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/public.d.ts +0 -163
package/dist/math-json.min.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
!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,E=1e7,q=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/V(4,t=Math.ceil(n/3))).toString():(t=16,r="2.3283064365386962890625e-10"),e.precision+=t,i=W(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/V(4,e=Math.ceil(n/3))).toString():(e=16,i="2.3283064365386962890625e-10"),s=W(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=W(s,2,n,n,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,n=W(s,2,n=n.times(1/V(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]=E-1;--u[n],u[r]+=E}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=P(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)/E|0,u[n]%=E;for(i&&(u.unshift(i),++r),a=u.length;0==u[--a];)u.pop();return e.d=u,e.e=P(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 W(e,2,i,i);t=(t=1.4*Math.sqrt(r))>16?16:0|t,i=W(e,2,i=i.times(1/V(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%E|0,i=o/E|0;s[n]=(s[n]+i)%E|0}for(;!s[--a];)s.pop();return i?++t:s.shift(),e.d=s,e.e=P(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=D(r,!0):(z(e,0,o),void 0===i?i=n.rounding:z(i,0,8),t=D(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=D(n):(z(e,0,o),void 0===i?i=s.rounding:z(i,0,8),t=D(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=D(r,r.e<=n.toExpNeg||r.e>=n.toExpPos):(z(e,1,o),void 0===i?i=n.rounding:z(i,0,8),t=D(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=D(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=D(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,q,M,S,A,z,k,I,O,D=n.constructor,P=n.s==s.s?1:-1,F=n.d,T=s.d;if(!(F&&F[0]&&T&&T[0]))return new D(n.s&&s.s&&(F?!T||F[0]!=T[0]:T)?F&&0==F[0]||!T?0*P:P/0:NaN);for(u?(f=1,h=n.e-s.e):(u=E,f=7,h=v(n.e/f)-v(s.e/f)),I=T.length,z=F.length,b=(y=new D(P)).d=[],g=0;T[g]==(F[g]||0);g++);if(T[g]>(F[g]||0)&&h--,null==a?(M=a=D.precision,o=D.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?(q=w[0],I!=N&&(q=q*u+(w[1]||0)),(p=q/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]==E&&(h[0]=1));break}if(h[p]+=o,h[p]!=E)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 D(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 P(e,i){var t=e[0];for(i*=7;t>=10;t/=10)i++;return i}function F(e,i,t){if(i>q)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,E)).length-1;0===c[a];--a)c.pop();return a<0?new n(0*e.s):(e.e=P(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 W(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 V(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=D(e)).indexOf("."))>=0&&(p=p.replace(".",""),(m=new d(1)).e=p.length-u,m.d=I(D(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 Ee(e,i){return new this(e).mod(i)}function qe(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 De(e){return new this(e).tan()}function Pe(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=Ee,s.mul=qe,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=De,s.tanh=Pe,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:{}};
|
|
2
|
-
/**
|
|
3
|
-
* @license Complex.js v2.0.13 12/05/2020
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2020, Robert Eisele (robert@xarg.org)
|
|
6
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
7
|
-
**/!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),[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7].map((e=>new h.exports.Decimal(e))),new h.exports.Decimal(607).div(128),[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22].map((e=>new h.exports.Decimal(e)));const p="Parentheses",f="LatexTokens",m="List",d="Missing",v="Nothing",x="Sequence",y="Sequence2",b="Add",w="Derivative",N="Divide",E="InverseFunction",q="Multiply",M="Negate",S="Power",A="Prime",z="Root",k="Sqrt",I="Subtract",O="ComplexInfinity",L="ImaginaryUnit";function D(e){return null!==e&&"object"==typeof e&&"num"in e}function P(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(D(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(H(e,2))?T(H(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;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(H(e,2));1===r?(u=null!==(i=T(H(e,1)))&&void 0!==i?i:null,c=1):-1===r&&(u=1,c=null!==(t=T(H(e,1)))&&void 0!==t?t:null)}return l===N&&(u=null!==(r=T(H(e,1)))&&void 0!==r?r:null,c=null!==(n=T(H(e,2)))&&void 0!==n?n:null),l===q&&B(H(e,2))===S&&-1===T(H(H(e,2),2))&&(u=null!==(s=T(H(e,1)))&&void 0!==s?s:null,c=null!==(a=T(H(H(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:P(e)?e.sym:null}function j(e){return Array.isArray(e)?e.slice(1):F(e)?e.fn.slice(1):[]}function U(e,i){let t=null;if(Array.isArray(e)&&(t=e),F(e)&&(t=e.fn),null===t)return[];let r=1;const n=[];for(;r<t.length;)n.push(i(t[r])),r+=1;return n}function H(e,i){var t,r;return null===e?null:Array.isArray(e)?null!==(t=e[i])&&void 0!==t?t:null:F(e)&&null!==(r=e.fn[i])&&void 0!==r?r:null}function G(e){return Array.isArray(e)?Math.max(0,e.length-1):F(e)?Math.max(0,e.fn.length-1):0}function W(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=H(i,1),n=H(i,2),s=H(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 Q(e,i){return i>2?"solidus":"radical"}function Y(e){return"<space>"===e||"\\qquad"===e||"\\quad"===e||"\\enskip"===e||"\\;"===e||"\\,"===e||"\\ "===e||"~"===e}function J(e,i,t){return(r,n,s)=>{if(s>=i)return[r,null];n.skipSpace(),n.match(t),"Missing"===r&&(r=v);const a=[e,null!=r?r:v];let o=!1;for(;!o;){for(o=!0,n.skipSpace();n.match(t);)a.push(v),n.skipSpace();if(n.atEnd)a.push(v);else{const e=n.matchExpression(i);a.push(null!=e?e:v),o=null===e}o||(n.skipSpace(),o=!n.match(t))}return[null,a]}}function K(e){return(i,t)=>j(t).map((e=>i.serialize(e))).join(e)}const X=[{name:f,serialize:function(e,i){return j(i).map((i=>{const t=C(i);return null===t?e.serialize(i):"<{>"===t?"{":"<}>"===t?"}":"<$>"===t?"$":"<$$>"===t?"$$":"<space>'"===t?" ":t})).join("")}},{name:p,trigger:{matchfix:"("},parse:(e,i,t)=>{var r;const n=i.index;if(!i.match("("))return[e,null];let s=!1,a=!0,o=!1,l=0,u="";for(;!s&&a;){const e=i.next();i.atEnd||")"===e?s=!0:"\\mathtt"===e?(i.match("<{>"),o=!0):Y(e)||(/^[0-9a-zA-Z]$/.test(e)?(l=Math.max(l,parseInt(e,36)),u+=e):a=!1),o&&i.match("<}>")}if(i.skipSpace(),a&&i.match("_")){const t=null!==(r=T(i.matchRequiredLatexArgument()))&&void 0!==r?r:NaN;return!isFinite(t)||t<2||t>36||l>=t?(i.onError({code:"base-out-of-range"}),[e,v]):[e,["BaseForm",parseInt(u,t),t]]}i.index=n;const c=i.matchBalancedExpression("(",")",i.onError);return c?B(c)===x?[e,[p,...j(c)]]:[e,[p,c]]:[e,[p]]},serialize:(e,i)=>e.wrapString(K(",")(e,i),(e.level,"paren")),separator:",",closeFence:")",precedence:20},{name:m,trigger:{matchfix:"\\lbrack"},separator:",",closeFence:"\\rbrack",precedence:20,parse:(e,i,t)=>{if(null===e){const t=i.matchBalancedExpression("\\lbrack","\\rbrack",i.onError);return t?B(t)===x?[e,[m,...j(t)]]:[e,[m,t]]:[null,[m]]}return[e,null]}},{name:"BaseForm",serialize:(e,i)=>{var t,r;const n=null!==(t=T(H(i,2)))&&void 0!==t?t:NaN;if(isFinite(n)&&n>=2&&n<=36){const e=null!==(r=T(H(i,1)))&&void 0!==r?r:NaN;if(isFinite(e)){let i=Number(e).toString(n),t=0;if(2===n||10===n?t=4:16===n?t=2:n>16&&(t=4),t>0){const e=i;i="";for(let r=0;r<e.length;r++)r>0&&r%t==0&&(i="\\, "+i),i=e[e.length-r-1]+i}return`(\\mathtt{${i}})_{${n}}`}}return"\\operatorname{BaseForm}("+e.serialize(H(i,1))+", "+e.serialize(H(i,2))+")"}},{name:"Set",trigger:{matchfix:"\\lbrace"},separator:",",closeFence:"\\rbrace",precedence:20},{name:x,trigger:{infix:","},parse:J(x,20,","),serialize:K(", "),precedence:20},{name:y,trigger:{infix:";"},parse:J(y,19,";"),serialize:K("; "),precedence:19},{name:d,trigger:"\\placeholder",serialize:"\\placeholder",requiredLatexArg:1},{name:"Subscript",trigger:{infix:"_"},precedence:720,serialize:(e,i)=>2===G(i)?e.serialize(H(i,1))+"_{"+e.serialize(H(i,2))+"}":"_{"+e.serialize(H(i,1))+"}",parse:(e,i,t)=>{var r;if(!i.match("_"))return[e,null];const n=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:d;return e?[null,["Subscript",e,n]]:[null,["Subscript",n]]}},{name:"Superplus",trigger:{superfix:"+"}},{name:"Subplus",trigger:{subfix:"+"}},{name:"Superminus",trigger:{superfix:"-"}},{name:"Subminus",trigger:{subfix:"-"}},{name:"Superstar",trigger:{superfix:"*"}},{name:"Superstar",trigger:{superfix:"\\star"}},{name:"Substar",trigger:{subfix:"*"}},{name:"Substar",trigger:{subfix:"\\star"}},{name:"Superdagger",trigger:{superfix:"\\dagger"}},{name:"Superdagger",trigger:{superfix:"\\dag"}},{name:A,trigger:{superfix:"\\prime"},arguments:"group"},{trigger:{superfix:"\\doubleprime"},parse:(e,i)=>[null,[A,null!=e?e:v,2]],arguments:"group"},{name:E,serialize:(e,i)=>e.serialize(H(i,1))+"^{-1}"},{name:w,trigger:"D",parse:(e,i)=>[e,[w,1]],serialize:(e,i)=>{var t;const r=null!==(t=T(H(i,1)))&&void 0!==t?t:NaN;if(!isFinite(r))return"";const n=e.serialize(H(i,2));return 1===r?n+"^{\\prime}":2===r?n+"^{\\doubleprime}":n+"^{("+Number(r).toString()+")}"}},{name:"Piecewise",trigger:{environment:"cases"},parse:(e,i)=>{var t;return[e,["Piecewise",null!==(t=i.matchTabular())&&void 0!==t?t:v]]},serialize:(e,i)=>{if(B(H(i,1))!==m)return"";const t=j(H(i,1));let r="",n="";for(const i of t){r+=n;const t=H(i,1);if(null!==t){r+=e.serialize(t);const n=H(i,2);null!==n&&(r+="&"+e.serialize(n))}n="\\\\"}return"\\begin{cases}"+r+"\\end{cases}"}}];function ee(e){var i,t,r,n;if("number"==typeof(e=ie(e)))return-e;if(e&&D(e))return"-"===e.num[0]?{num:e.num.slice(1)}:"+"===e.num[0]?{num:"-"+e.num.slice(1)}:{num:"-"+e.num};if(e instanceof h.exports.Decimal)return e.mul(-1);if(e instanceof g.exports.Complex)return e.mul(-1);const s=B(e),a=G(e);if(s===M&&1===a)return null!==(i=H(e,1))&&void 0!==i?i:d;if(s===q){const i=ee(null!==(t=H(e,1))&&void 0!==t?t:d);return[q,i,...j(e).slice(1)]}return s===b?[b,...U(e,ee)]:s===I?[I,null!==(r=H(e,2))&&void 0!==r?r:d,null!==(n=H(e,1))&&void 0!==n?n:d]:s===p&&1===a?ee(H(H(e,1),1)):[M,null!=e?e:d]}function ie(e){return null===e?v:Z(e)?e:$(e)===p&&1===G(e)?ie(H(e,1)):function(e,i){const t=$(e);if(null!==t)return[i(t),...j(e).map(i)];const r=W(e);if(null!==r){const e=Object.keys(r),t={};for(const n of e)t[n]=i(r[n]);return{dict:t}}return i(e)}(e,ie)}function te(e,i,t,r){return null===t?"\\sqrt{}":(r=null!=r?r:2,"solidus"===i?e.wrapShort(t)+"^{1\\/"+e.serialize(r)+"}":"quotient"===i?e.wrapShort(t)+"^{\\frac{1}{"+e.serialize(r)+"}}":2===T(r)?"\\sqrt{"+e.serialize(t)+"}":"\\sqrt["+e.serialize(r)+"]{"+e.serialize(t)+"}")}function re(e,i,t){if(!i.match("\\sqrt"))return[e,null];const r=i.matchOptionalLatexArgument(),n=i.matchRequiredLatexArgument();return null===n?null!==r?[e,[z,v,r]]:[e,[k]]:null!==r?[e,[z,n,r]]:[e,[k,n]]}function ne(e,i,t){if(276<t)return[e,null];const r=i.index;if(!i.match("-"))return[e,null];const n=i.matchExpression(null===e?400:277);return null===n?(i.index=r,[e,null]):null===e?[null,[M,n]]:[null,[I,e,n]]}function se(e,i){var t;if(null===i)return"";e.level-=1;let r="";const[n,s]=function(e){var i,t,r,n,s,a;if(B(e)!==q)return[[],[]];const o=[],l=[],u=j(e);for(const e of u)if(B(e)===S)if(B(H(e,2))===M){const r=null!==(i=H(e,1))&&void 0!==i?i:v,n=null!==(t=H(H(e,2),1))&&void 0!==t?t:v;l.push([S,r,n])}else{const i=null!==(r=T(H(e,2)))&&void 0!==r?r:NaN;-1===i?l.push(null!==(n=H(e,1))&&void 0!==n?n:v):i<0?l.push([S,null!==(s=H(e,1))&&void 0!==s?s:v,null!==(a=ee(H(e,2)))&&void 0!==a?a:v]):o.push(e)}else o.push(e);return[o,l]}(i);if(s.length>0&&(r=1===s.length&&1===s[0]?0===n.length?"1":1===n.length?e.serialize(n[0]):se(e,[q,...n]):e.serialize([N,1===n.length?n[0]:[q,...n],1===s.length?s[0]:[q,...s]])),r)return e.level+=1,r;let a=!1,o=null;const u=G(i)+1;let c=!1;for(let n=1;n<u;n++)if(o=H(i,n),null!==o){let i;"number"==typeof o||D(o)?(i=e.serialize(o),"-1"!==i||r?("-"===i[0]&&(i=i.slice(1),a=!a),r=r?l([r,e.options.multiply,i]):i):r="-",c=!0):B(o)!==S||isNaN(null!==(t=T(H(o,1)))&&void 0!==t?t:NaN)?(B(o)===M&&(o=H(o,1),a=!a),i=e.wrap(o,390),r=r?c&&B(o)===N?l([r,"\\times",i]):e.options.invisibleMultiply?l([r,e.options.invisibleMultiply,i]):l([r,i]):i,c=!1):(r=r?l([r,e.options.multiply,e.serialize(o)]):e.serialize(o),c=!0)}return e.level+=1,a?"-"+r:r}function ae(e,i){if(null===i)return"";if(1===G(i))return e.serialize(H(i,1));const t=e.level>3?"inline-solidus":"quotient";if("inline-solidus"===t||"nice-solidus"===t){const r=e.wrapShort(H(i,1)),n=e.wrapShort(H(i,2));return"nice-solidus"===t?`^{${r}}\\!\\!/\\!_{${n}}`:`${r}\\/${n}`}return"reciprocal"===t?e.wrap(H(i,1))+e.wrap(H(i,2))+"^{-1}":"factor"===t?"\\frac{1}{"+e.serialize(H(i,2))+"}"+e.wrap(H(i,1)):"\\frac{"+e.serialize(H(i,1))+"}{"+e.serialize(H(i,2))+"}"}function oe(e,i){var t;const r=H(i,1),n=H(i,2);if(null===n)return e.serialize(r);if(null===r)return"";const s=B(i);if(s===k||s===z)return te(e,Q(0,e.level),H(i,1),H(i,2));const a=null!==(t=T(n))&&void 0!==t?t:1;if(-1===a)return e.serialize([N,"1",r]);if(a<0)return e.serialize([N,"1",[S,r,-a]]);if(B(n)===N){if(1===T(H(n,1)))return te(e,Q(0,e.level),r,H(n,2))}else if(B(n)===S&&-1===T(H(n,2)))return te(e,Q(0,e.level),r,H(n,1));return e.wrapShort(r)+"^{"+e.serialize(n)+"}"}function le(e,i,t){var r;const n=i.next();let s=!1,a=0;if(i.skipSpace(),i.match("^")){if(i.skipSpace(),i.match("<{>")){i.skipSpace(),i.match("-")&&i.match("1")&&(s=!0);do{i.match("\\doubleprime")&&(a+=2),i.match("\\prime")&&(a+=1),i.match("'")&&(a+=1)}while(!i.match("<}>")&&!i.atEnd)}let e=!1;for(;!e;)i.skipSpace(),i.match("\\doubleprime")?a+=2:i.match("\\prime")||i.match("'")?a+=1:e=!0}let o=null!==(r={"\\arcsin":"Arcsin","\\arccos":"Arccos","\\arctan":"Arctan","\\arctg":"Arctan","\\arcctg":"Arctan","\\arcsec":"Arcsec","\\arccsc":" Arccsc","\\arsinh":"Arsinh","\\arcosh":"Arcosh","\\artanh":"Artanh","\\arcsech":"Arcsech","\\arccsch":"Arcsch","\\ch":"Cosh","\\cos":"Cos","\\cosec":"Csc","\\cosh":"Csch","\\cot":"Cot","\\cotg":"Cot","\\coth":"Coth","\\csc":"Csc","\\ctg":"Cot","\\cth":"Coth","\\sec":"Sec","\\sin":"Sin","\\sinh":"Sinh","\\sh":"Sinh","\\tan":"Tan","\\tanh":"Tanh","\\tg":"Tan","\\th":"Tanh"}[n])&&void 0!==r?r:n;s&&(o=[E,o]),a>=1&&(o=[w,a,o]);const l=i.matchArguments("implicit");return null===l?[null,o]:[null,[o,...l]]}function ue(e){return u(e)}Number.EPSILON.toString();const ce={algebra:[{name:"To",trigger:{infix:"\\to"},precedence:270}],arithmetic:[{name:"ThreeQuarter",serialize:"\\frac{3}{4}"},{name:"TwoThird",serialize:"\\frac{2}{3}"},{name:"Half",serialize:"\\frac{1}{2}"},{name:"Third",serialize:"\\frac{1}{3}"},{name:"Quarter",serialize:"\\frac{1}{4}"},{name:"CatalanConstant",serialize:"G"},{name:"GoldenRatio",serialize:"\\varphi"},{name:"EulerGamma",serialize:"\\gamma"},{name:"Degrees",serialize:"\\frac{\\pi}{180}"},{name:"MinusDoublePi",serialize:"-2\\pi"},{name:"MinusPi",serialize:"-\\pi"},{name:"MinusHalfPi",serialize:"-\\frac{\\pi}{2}"},{name:"QuarterPi",serialize:"\\frac{\\pi}{4}"},{name:"ThirdPi",serialize:"\\frac{\\pi}{3}"},{name:"HalfPi",serialize:"\\frac{\\pi}{2}"},{name:"TwoThirdPi",serialize:"\\frac{2\\pi}{3}"},{name:"ThreeQuarterPi",serialize:"\\frac{3\\pi}{4}"},{name:"DoublePi",serialize:"2\\pi"},{name:"Complex",precedence:275,serialize:(e,i)=>{const t=T(H(i,1)),r=T(H(i,2));if(0===r)return e.serialize(H(i,1));const n=1===r?"\\imaginaryI":-1===r?"-\\imaginaryI":l([e.serialize(H(i,2)),"\\imaginaryI"]);return 0===t?n:l([e.serialize(H(i,1)),"+",n])}},{name:"Exp",serialize:(e,i)=>{var t;return l(["\\exponentialE^{",e.serialize(null!==(t=H(i,1))&&void 0!==t?t:v),"}"])}},{name:"Square",serialize:(e,i)=>e.wrapShort(H(i,1))+"^2"},{trigger:{symbol:"\\infty"},parse:{num:"+Infinity"}},{name:O,trigger:{symbol:["\\tilde","\\infty"]},serialize:"\\tilde\\infty"},{name:O,trigger:{symbol:["\\tilde","<{>","\\infty","<}>"]},serialize:"\\tilde\\infty"},{name:"Pi",trigger:{symbol:"\\pi"}},{name:"Pi",trigger:{symbol:"π"},serialize:"\\pi"},{name:"ExponentialE",trigger:{symbol:"e"},serialize:"e"},{name:L,trigger:{symbol:"i"},serialize:"\\imaginaryI"},{name:L,trigger:{symbol:"\\imaginaryI"}},{name:b,trigger:{prefix:"+",infix:"+"},parse:function(e,i,t){if(275<t)return[e,null];const r=i.index;if(!i.match("+"))return[e,null];const n=i.matchExpression(null===e?400:275);return null===n?(i.index=r,[e,null]):null===e?[null,n]:i.applyOperator(b,e,n)},serialize:function(e,i){var t,r;e.level-=1;const n=B(i);let s="",a=H(i,1),o=!Number.isNaN(null!==(t=T(a))&&void 0!==t?t:NaN);if(n===M)s="-"+e.wrap(a,276);else if(n===b){s=e.serialize(a);const t=G(i)+1;for(let n=2;n<t;n++){a=H(i,n);const t=null!==(r=T(a))&&void 0!==r?r:NaN,l=!Number.isNaN(t);let u=!1;if(null!==a&&o){const[i,t]=R(a);null!==i&&null!==t&&isFinite(i)&&isFinite(t)&&1!==t&&(s+=e.options.invisiblePlus+e.serialize(a),u=!0)}if(!u)if(t<0)s+=e.serialize(a);else if(B(a)===M)s+=e.wrap(a,275);else{const i=e.wrap(a,275);"-"===i[0]||"+"===i[0]?s+=i:s=s+"+"+i}o=l}}else if(n===I){const t=H(i,2);s=null!==t?e.wrap(a,275)+"-"+e.wrap(t,275):e.wrap(a,275)}return e.level+=1,s},associativity:"both",precedence:275},{name:M,trigger:{prefix:"-"},parse:ne,associativity:"left",precedence:275},{name:I,trigger:{infix:"-"},parse:ne,associativity:"both",precedence:275},{name:"PlusMinus",trigger:{infix:"\\pm"},associativity:"both",precedence:270},{name:"MinusPlus",trigger:{infix:"\\mp"},associativity:"both",precedence:270},{name:q,trigger:{infix:"\\times"},serialize:se,associativity:"both",precedence:390},{name:q,trigger:{infix:"\\cdot"},serialize:se,associativity:"both",precedence:390},{name:q,trigger:{infix:"*"},serialize:se,associativity:"both",precedence:390},{name:N,trigger:"\\frac",parse:function(e,i,t){var r,n,s,a;if(!i.match("\\frac"))return[e,null];const o=null!==(r=i.matchRequiredLatexArgument())&&void 0!==r?r:d,l=null!==(n=i.matchRequiredLatexArgument())&&void 0!==n?n:d;if("PartialDerivative"===B(o)&&("PartialDerivative"===B(l)||B(l)===q&&"PartialDerivative"===B(H(l,1)))){const t=null!==(s=H(o,3))&&void 0!==s?s:v;let r=H(o,1);null!==r&&r!==v||(r=null!==(a=i.matchExpression())&&void 0!==a?a:v);let n=[];if(B(l)===q){for(const e of j(l))if("PartialDerivative"===$(e)){const i=H(e,2);i&&n.push(i)}}else{const e=H(l,2);e&&n.push(e)}return n.length>1&&(n=[m,...n]),[e,["PartialDerivative",r,n,t===v?1:t]]}return[e,[N,o,l]]},serialize:ae,requiredLatexArg:2},{name:N,trigger:{infix:"\\/"},serialize:ae,associativity:"non",precedence:660},{name:N,trigger:{infix:"/"},serialize:ae,associativity:"non",precedence:660},{name:N,trigger:{infix:"\\div"},serialize:ae,associativity:"non",precedence:660},{name:S,trigger:{infix:"^"},associativity:"non",precedence:720,serialize:oe},{name:S,trigger:{infix:["*","*"]},associativity:"non",precedence:720,serialize:oe},{name:k,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:re,serialize:oe},{name:z,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:re},{name:"Norm",trigger:{matchfix:"\\lVert"},closeFence:"\\rVert"},{name:"Norm",trigger:{matchfix:"\\|"},closeFence:"\\|"},{name:"Norm",trigger:{matchfix:["|","|"]},closeFence:["|","|"]},{name:"Abs",trigger:{matchfix:"|"},closeFence:"|"},{name:"Abs",trigger:{matchfix:"\\lvert"},closeFence:"\\rvert"},{name:"Factorial",trigger:{postfix:"!"},precedence:810},{name:"Factorial2",trigger:{postfix:["!","!"]},precedence:810},{name:"Lcm",trigger:{symbol:["\\operatorname","<{>","l","c","m","<}>"]}},{name:"Gcd",trigger:{symbol:["\\operatorname","<{>","g","c","d","<}>"]}},{name:"Ceil",trigger:{symbol:["\\operatorname","<{>","c","e","i","l","<}>"]}},{name:"Floor",trigger:{symbol:["\\operatorname","<{>","f","l","o","o","r","<}>"]}},{name:"Round",trigger:{symbol:["\\operatorname","<{>","r","o","u","n","d","<}>"]}},{name:"Sign",trigger:{symbol:["\\operatorname","<{>","s","g","n","<}>"]}}],calculus:[{trigger:{symbol:"\\int"},parse:function(e,i,t){if(!i.match("\\int"))return[e,null];let r=v,n=v,s=!1;for(;!s;)i.skipSpace(),i.match("_")?n=i.matchRequiredLatexArgument():i.match("^")?r=i.matchRequiredLatexArgument():s=!0;const a=i.matchBalancedExpression("<{>","<}>");return[e,["Integral",null!=a?a:"",null!=r?r:v,null!=n?n:v]]},serialize:function(e,i){return""}}],core:X,inequalities:[{name:"NotLess",trigger:{infix:["!","<"]},associativity:"right",precedence:246},{name:"NotLess",trigger:{infix:"\\nless"},associativity:"right",precedence:246},{name:"Less",trigger:{infix:"<"},associativity:"right",precedence:245},{name:"Less",trigger:{infix:"\\lt"},associativity:"right",precedence:245},{name:"LessEqual",trigger:{infix:["<","="]},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\le"},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\leq"},associativity:"right",precedence:241},{name:"LessEqual",trigger:{infix:"\\leqslant"},associativity:"right",precedence:265},{name:"LessNotEqual",trigger:{infix:"\\lneqq"},associativity:"right",precedence:260},{name:"NotLessNotEqual",trigger:{infix:"\\nleqq"},associativity:"right",precedence:260},{name:"LessOverEqual",trigger:{infix:"\\leqq"},associativity:"right",precedence:265},{name:"GreaterOverEqual",trigger:{infix:"\\geqq"},associativity:"right",precedence:265},{name:"Equal",trigger:{infix:"="},associativity:"right",precedence:260},{name:"StarEqual",trigger:{infix:["*","="]},associativity:"right",precedence:260},{name:"StarEqual",trigger:{infix:["\\star","="]},associativity:"right",precedence:260},{name:"PlusEqual",trigger:{infix:["+","="]},associativity:"right",precedence:260},{name:"MinusEqual",trigger:{infix:["-","="]},associativity:"right",precedence:260},{name:"SlashEqual",trigger:{infix:["/","="]},associativity:"right",precedence:260},{name:"EqualEqual",trigger:{infix:["=","="]},associativity:"right",precedence:260},{name:"EqualEqualEqual",trigger:{infix:["=","=","="]},associativity:"right",precedence:265},{name:"TildeFullEqual",trigger:{infix:"\\cong"},associativity:"right",precedence:260},{name:"NotTildeFullEqual",trigger:{infix:"\\ncong"},associativity:"right",precedence:260},{name:"Assign",trigger:{infix:[":","="]},associativity:"right",precedence:260},{name:"Assign",trigger:{infix:"\\coloneq"},associativity:"right",precedence:260},{name:"Approx",trigger:{infix:"\\approx"},associativity:"right",precedence:247},{name:"NotApprox",trigger:{infix:"\\approx"},associativity:"right",precedence:247},{name:"ApproxEqual",trigger:{infix:"\\approxeq"},associativity:"right",precedence:260},{name:"NotApproxEqual",trigger:{infix:["!","\\approxeq"]},associativity:"right",precedence:250},{name:"NotEqual",trigger:{infix:"\\ne"},associativity:"right",precedence:255},{name:"Unequal",trigger:{infix:["!","="]},associativity:"right",precedence:260},{name:"GreaterEqual",trigger:{infix:"\\ge"},associativity:"right",precedence:242},{name:"GreaterEqual",trigger:{infix:"\\geq"},associativity:"right",precedence:242},{name:"GreaterEqual",trigger:{infix:[">","="]},associativity:"right",precedence:243},{name:"GreaterEqual",trigger:{infix:"\\geqslant"},associativity:"right",precedence:265},{name:"GreaterNotEqual",trigger:{infix:"\\gneqq"},associativity:"right",precedence:260},{name:"NotGreaterNotEqual",trigger:{infix:"\\ngeqq"},associativity:"right",precedence:260},{name:"Greater",trigger:{infix:">"},associativity:"right",precedence:245},{name:"Greater",trigger:{infix:"\\gt"},associativity:"right",precedence:245},{name:"NotGreater",trigger:{infix:"\\ngtr"},associativity:"right",precedence:244},{name:"NotGreater",trigger:{infix:["!",">"]},associativity:"right",precedence:244},{name:"RingEqual",trigger:{infix:"\\circeq"},associativity:"right",precedence:260},{name:"TriangleEqual",trigger:{infix:"\\triangleq"},associativity:"right",precedence:260},{name:"DotEqual",trigger:{infix:"\\doteq"},associativity:"right",precedence:265},{name:"DotEqualDot",trigger:{infix:"\\doteqdot"},associativity:"right",precedence:265},{name:"FallingDotEqual",trigger:{infix:"\\fallingdotseq"},associativity:"right",precedence:265},{name:"RisingDotEqual",trigger:{infix:"\\fallingdotseq"},associativity:"right",precedence:265},{name:"QuestionEqual",trigger:{infix:"\\questeq"},associativity:"right",precedence:260},{name:"Equivalent",trigger:{infix:"\\equiv"},associativity:"right",precedence:260},{name:"MuchLess",trigger:{infix:"\\ll"},associativity:"right",precedence:260},{name:"MuchGreater",trigger:{infix:"\\gg"},associativity:"right",precedence:260},{name:"Precedes",trigger:{infix:"\\prec"},associativity:"right",precedence:260},{name:"Succeeds",trigger:{infix:"\\succ"},associativity:"right",precedence:260},{name:"PrecedesEqual",trigger:{infix:"\\preccurlyeq"},associativity:"right",precedence:260},{name:"SucceedsEqual",trigger:{infix:"\\curlyeqprec"},associativity:"right",precedence:260},{name:"NotPrecedes",trigger:{infix:"\\nprec"},associativity:"right",precedence:260},{name:"NotSucceeds",trigger:{infix:"\\nsucc"},associativity:"right",precedence:260},{name:"Between",trigger:{infix:"\\between"},associativity:"right",precedence:265}],other:V,physics:[{name:"mu-0",trigger:{symbol:["\\mu","_","0"]}}],sets:[{trigger:{symbol:"\\N"},parse:"NaturalNumber"},{trigger:{symbol:"\\Z"},parse:"Integer"},{trigger:{symbol:"\\Q"},parse:"RationalNumber"},{trigger:{symbol:["\\mathbb","<{>","A","<}>"]},parse:"AlgebraicNumber"},{trigger:{symbol:"\\R"},parse:"RealNumber"},{trigger:{symbol:"\\C"},parse:"ComplexNumber"},{trigger:{symbol:"\\varnothing"},parse:"EmptySet"},{trigger:{symbol:"\\emptyset"},parse:"EmptySet"},{name:"Complement",trigger:{infix:"\\complement"},precedence:240},{name:"Element",trigger:{infix:"\\in"},precedence:240},{name:"Intersection",trigger:{infix:"\\Cap"},precedence:350},{name:"NotElement",trigger:{infix:"\\notin"},precedence:240},{name:"SetMinus",trigger:{infix:"\\setminus"},precedence:650},{name:"SubsetEqual",trigger:{infix:"\\subseteq"},precedence:240},{name:"SymmetricDifference",trigger:{infix:"\\triangle"},precedence:260},{name:"Union",trigger:{infix:"\\cup"},precedence:350},{name:"Contains",trigger:{infix:"\\ni"},associativity:"right",precedence:160},{name:"Subset",trigger:{infix:"\\subset"},associativity:"right",precedence:240},{name:"SquareSubset",trigger:{infix:"\\sqsubset"},associativity:"right",precedence:265},{name:"SquareSubsetEqual",trigger:{infix:"\\sqsubseteq"},associativity:"right",precedence:265},{name:"Superset",trigger:{infix:"\\supset"},associativity:"right",precedence:240},{name:"SquareSuperset",trigger:{infix:"\\sqsupset"},associativity:"right",precedence:265},{name:"SquareSupersetEqual",trigger:{infix:"\\sqsupseteq"},associativity:"right",precedence:265},{name:"NotSubset",trigger:{infix:"\\nsubset"},associativity:"right",precedence:240},{name:"NotSuperset",trigger:{infix:"\\nsupset"},associativity:"right",precedence:240},{name:"SupersetEqual",trigger:{infix:"\\supseteq"},associativity:"right",precedence:240},{name:"NotSubsetNotEqual",trigger:{infix:"\\nsubseteq"},associativity:"right",precedence:240},{name:"NotSupersetNotEqual",trigger:{infix:"\\nsupseteq"},associativity:"right",precedence:240},{name:"SubsetNotEqual",trigger:{infix:"\\subsetneq"},associativity:"right",precedence:240},{name:"SubsetNotEqual",trigger:{infix:"\\varsupsetneqq"},associativity:"right",precedence:240},{name:"SupersetNotEqual",trigger:{infix:"\\supsetneq"},associativity:"right",precedence:240},{name:"SupersetNotEqual",trigger:{infix:"\\varsupsetneq"},associativity:"right",precedence:240}],symbols:[{trigger:{symbol:"\\alpha"},parse:"α"},{trigger:{symbol:"\\beta"},parse:"β"},{trigger:{symbol:"\\gamma"},parse:"γ"},{trigger:{symbol:"\\delta"},parse:"δ"},{trigger:{symbol:"\\epsilon"},parse:"ϵ"},{trigger:{symbol:"\\varepsilon"},parse:"ε"},{trigger:{symbol:"\\zeta"},parse:"ζ"},{trigger:{symbol:"\\eta"},parse:"η"},{trigger:{symbol:"\\theta"},parse:"θ"},{trigger:{symbol:"\\vartheta"},parse:"ϑ"},{trigger:{symbol:"\\iota"},parse:"ι"},{trigger:{symbol:"\\kappa"},parse:"κ"},{trigger:{symbol:"\\varkappa"},parse:"ϰ"},{trigger:{symbol:"\\lambda"},parse:"λ"},{trigger:{symbol:"\\mu"},parse:"μ"},{trigger:{symbol:"\\nu"},parse:"ν"},{trigger:{symbol:"\\xi"},parse:"ξ"},{trigger:{symbol:"\\omicron"},parse:"ο"},{trigger:{symbol:"\\varpi"},parse:"ϖ"},{trigger:{symbol:"\\rho"},parse:"ρ"},{trigger:{symbol:"\\varrho"},parse:"ϱ"},{trigger:{symbol:"\\sigma"},parse:"σ"},{trigger:{symbol:"\\varsigma"},parse:"ς"},{trigger:{symbol:"\\tau"},parse:"τ"},{trigger:{symbol:"\\phi"},parse:"ϕ"},{trigger:{symbol:"\\varphi"},parse:"φ"},{trigger:{symbol:"\\upsilon"},parse:"υ"},{trigger:{symbol:"\\chi"},parse:"χ"},{trigger:{symbol:"\\psi"},parse:"ψ"},{trigger:{symbol:"\\omega"},parse:"ω"},{trigger:{symbol:"\\Gamma"},parse:"Γ"},{trigger:{symbol:"\\Delta"},parse:"Δ"},{trigger:{symbol:"\\Theta"},parse:"Θ"},{trigger:{symbol:"\\Lambda"},parse:"Λ"},{trigger:{symbol:"\\Xi"},parse:"Ξ"},{trigger:{symbol:"\\Pi"},parse:"Π"},{trigger:{symbol:"\\Sigma"},parse:"Σ"},{trigger:{symbol:"\\Upsilon"},parse:"Υ"},{trigger:{symbol:"\\Phi"},parse:"Φ"},{trigger:{symbol:"\\Psi"},parse:"Ψ"},{trigger:{symbol:"\\Omega"},parse:"Ω"},{trigger:{symbol:"\\digamma"},parse:"ϝ"},{trigger:{symbol:"\\aleph"},parse:"ℵ"},{trigger:{symbol:"\\beth"},parse:"ℶ"},{trigger:{symbol:"\\daleth"},parse:"ℸ"},{trigger:{symbol:"\\gimel"},parse:"ℷ"},{trigger:{symbol:"\\Finv"},parse:"Ⅎ"},{trigger:{symbol:"\\Game"},parse:"⅁"},{trigger:{symbol:"\\wp"},parse:"℘"},{trigger:{symbol:"\\eth"},parse:"ð"},{trigger:{symbol:"\\mho"},parse:"℧"},{trigger:{symbol:"\\clubsuit"},parse:"♣"},{trigger:{symbol:"\\heartsuit"},parse:"♡"},{trigger:{symbol:"\\spadesuit"},parse:"♠"},{trigger:{symbol:"\\diamondsuit"},parse:"♢"},{trigger:{symbol:"\\sharp"},parse:"♯"},{trigger:{symbol:"\\flat"},parse:"♭"},{trigger:{symbol:"\\natural"},parse:"♮"}],trigonometry:[{name:"Arcsin",trigger:"\\arcsin",arguments:"implicit",parse:le},{name:"Arccos",trigger:"\\arccos",arguments:"implicit",parse:le},{name:"Arctan",trigger:"\\arctan",arguments:"implicit",parse:le},{name:"Arctan",trigger:"\\arctg",arguments:"implicit",parse:le},{name:"Arccot",trigger:"\\arcctg",arguments:"implicit",parse:le},{name:"Arcsec",trigger:"\\arcsec",arguments:"implicit",parse:le},{name:"Arccsc",trigger:"\\arccsc",arguments:"implicit",parse:le},{name:"Arsinh",trigger:"\\arsinh",arguments:"implicit",parse:le},{name:"Arcosh",trigger:"\\arcosh",arguments:"implicit",parse:le},{name:"Artanh",trigger:"\\artanh",arguments:"implicit",parse:le},{name:"Arsech",trigger:"\\arsech",arguments:"implicit",parse:le},{name:"Arcsch",trigger:"\\arcsch",arguments:"implicit",parse:le},{name:"Cosh",trigger:"\\ch",arguments:"implicit",parse:le},{name:"Cosec",trigger:"\\cosec",arguments:"implicit",parse:le},{name:"Cosh",trigger:"\\cosh",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\cot",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\cotg",arguments:"implicit",parse:le},{name:"Coth",trigger:"\\coth",arguments:"implicit",parse:le},{name:"Csc",trigger:"\\csc",arguments:"implicit",parse:le},{name:"Cot",trigger:"\\ctg",arguments:"implicit",parse:le},{name:"Coth",trigger:"\\cth",arguments:"implicit",parse:le},{name:"Sec",trigger:"\\sec",arguments:"implicit",parse:le},{name:"Sinh",trigger:"\\sinh",arguments:"implicit",parse:le},{name:"Sinh",trigger:"\\sh",arguments:"implicit",parse:le},{name:"Tan",trigger:"\\tan",arguments:"implicit",parse:le},{name:"Tan",trigger:"\\tg",arguments:"implicit",parse:le},{name:"Tanh",trigger:"\\tanh",arguments:"implicit",parse:le},{name:"Tanh",trigger:"\\th",arguments:"implicit",parse:le},{name:"Cos",trigger:"\\cos",arguments:"implicit",parse:le},{name:"Sin",trigger:"\\sin",arguments:"implicit",parse:le}]},he={precision:15,positiveInfinity:"\\infty",negativeInfinity:"-\\infty",notANumber:"\\operatorname{NaN}",decimalMarker:".",groupSeparator:",",exponentProduct:"\\cdot",beginExponentMarker:"10^{",endExponentMarker:"}",notation:"auto",truncationMarker:"\\ldots",beginRepeatingDigits:"\\overline{",endRepeatingDigits:"}",imaginaryNumber:"\\imaginaryI"},ge={invisibleOperator:q,skipSpace:!0,parseArgumentsOfUnknownLatexCommands:!0,parseNumbers:!0,promoteUnknownSymbols:/^[a-zA-Z]$/,promoteUnknownFunctions:/^[fg]$/,ignoreCommands:["\\displaystyle","\\!","\\:","\\enskip","\\quad","\\,","\\;","\\enspace","\\qquad","\\selectfont","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"],idempotentCommands:["\\left","\\right","\\mleft","\\mright","\\middle","\\bigl","\\bigm","\\bigr","\\Bigl","\\Bigm","\\Bigr","\\biggl","\\biggm","\\biggr","\\Biggl","\\Biggm","\\Biggr"],invisiblePlusOperator:b,preserveLatex:!1},pe={invisibleMultiply:"",invisiblePlus:"",multiply:"\\times"};function fe(e,i){var t;let r=e;for(let e=0;e<i.length;e++){let n=null!==(t=i[e])&&void 0!==t?t:"";if(/[a-zA-Z*]/.test(n[0])){const i=r.match(new RegExp("(.*)#"+Number(e+1).toString()));i&&/\\[a-zA-Z*]+/.test(i[1])&&(n=" "+n)}r=r.replace("#"+Number(e+1).toString(),n)}return r}class me{constructor(e,i,t,r){let n;this.index=0,this.options={...he,...ge,...i},this.tokens=e,this.onError=e=>r({...e,before:this.latexBefore(),after:this.latexAfter()}),this.dictionary=t,this.invisibleOperatorPrecedence=0,this.options.invisibleOperator&&(n=this.dictionary.name.get(this.options.invisibleOperator),void 0===n?r({code:"unknown-operator",arg:"invisible operator "+this.options.invisibleOperator}):void 0===n.precedence?r({code:"expected-operator",arg:"invisible operator "+this.options.invisibleOperator}):this.invisibleOperatorPrecedence=n.precedence)}clone(e,i){return new me(this.tokens.slice(e,i),this.options,this.dictionary,this.onError)}balancedClone(e,i,t=!0){if(!this.matchAll(e))return t||this.onError({code:"syntax-error",arg:"Expected "+u(e)}),null;const r=this.index;let n=r,s=1;for(;!this.atEnd&&0!==s;)this.skipSpace(),n=this.index,this.matchAll(i)?s-=1:this.matchAll(e)?s+=1:this.next();return 0!==s?(t||this.onError({code:"unbalanced-symbols",arg:u(e)+u(i)}),this.index=r,null):this.clone(r,n)}get atEnd(){return this.index>=this.tokens.length}get peek(){return this.tokens[this.index]}latex(e,i){return u(this.tokens.slice(e,i))}latexAhead(e){return u(this.tokens.slice(this.index,this.index+e))}latexBefore(){return this.latex(0,this.index)}latexAfter(){return this.latex(this.index)}lookAhead(){let e=Math.min(this.dictionary.lookahead,this.tokens.length-this.index);const i=[];for(;e>0;)i[e]=this.latexAhead(e--);return i}peekDefinition(e){let i;i="operator"===e?this.lookAhead().map(((e,i)=>{var t,r,n,s,a;return null!==(s=null!==(r=null===(t=this.dictionary.infix[i])||void 0===t?void 0:t.get(e))&&void 0!==r?r:null===(n=this.dictionary.postfix[i])||void 0===n?void 0:n.get(e))&&void 0!==s?s:null===(a=this.dictionary.prefix[i])||void 0===a?void 0:a.get(e)})):this.lookAhead().map(((i,t)=>{var r;return null===(r=this.dictionary[e][t])||void 0===r?void 0:r.get(i)}));for(let e=i.length;e>0;e--)if(void 0!==i[e])return[i[e],e];return[null,0]}next(){return this.tokens[this.index++]}skipSpace(){if(!this.atEnd&&"<{>"===this.peek&&"<}>"===this.tokens[this.index+1])return this.index+=2,this.skipSpace(),!0;let e=!1;for(;!this.atEnd&&(this.options.ignoreCommands.includes(this.peek)||this.options.idempotentCommands.includes(this.peek));)this.index+=1,this.skipSpace(),e=!0;if(!this.options.skipSpace)return!1;for(;this.match("<space>");)e=!0;return e&&this.skipSpace(),e}match(e){return this.tokens[this.index]===e&&(this.index++,!0)}matchAll(e){let i=!0;"string"==typeof e&&(e=[e]);let t=0;do{i=this.tokens[this.index+t]===e[t++]}while(i&&t<e.length);return i&&(this.index+=t),i}matchAny(e){return e.includes(this.tokens[this.index])?this.tokens[this.index++]:""}matchWhile(e){const i=[];for(;e.includes(this.tokens[this.index]);)i.push(this.tokens[this.index++]);return i}matchSign(){let e=!1,i=!1;for(;!i;)this.skipSpace()?i=!1:this.match("-")?(e=!e,i=!1):i=!this.match("+");return e?"-":"+"}matchDecimalDigits(){let e="",i=!1;for(;!i;)if(e+=this.matchWhile(["0","1","2","3","4","5","6","7","8","9"]).join(""),i=!0,this.options.groupSeparator){const e=this.index;this.match(this.options.groupSeparator)&&(/[0-9]/.test(this.peek)?i=!1:this.index=e)}return e}matchSignedInteger(){const e=this.index,i=this.matchSign(),t=this.matchDecimalDigits();return t?("-"===i?"-":"")+t:(this.index=e,"")}matchExponent(){const e=this.index;let i="";if(this.matchAny(["e","E","d","D"])){const e=this.matchSignedInteger();e&&(i="e"+e)}if(i)return i;if(this.match("\\times")&&(this.skipSpace(),this.match("1")&&this.match("0")&&this.match("^"))){if(/[0-9]/.test(this.peek))return"e"+this.next();if(this.match("<{>")){this.skipSpace();const e=this.matchSignedInteger();if(this.skipSpace(),this.match("<}>")&&e)return"e"+e}}return this.index=e,""}matchNumber(){var e,i;if(!this.options.parseNumbers)return"";const t=this.index,r=this.matchSign();let n=this.matchDecimalDigits();if(!n)return this.index=t,"";n=("-"===r?"-":"")+n;let s=!1,a=!1;this.match(null!==(e=this.options.decimalMarker)&&void 0!==e?e:"")&&(s=!0,n+="."+(null!==(i=this.matchDecimalDigits())&&void 0!==i?i:"0"));const o=this.matchExponent();return o&&(a=!0),n?n.length+o.length>12?s||a?n+o+"d":n+"n":n+o:(this.index=t,"")}matchOperator(e,i=null,t=0){const[r,n]=this.peekDefinition(e);if(null===r)return null;if("function"==typeof r.parse){let e=null;return[i,e]=r.parse(i,this,t),null===e?null:this.applyInvisibleOperator(i,e)}let s=r.precedence;if(void 0===s||s<t)return null;s+="left"===r.associativity?1:0,this.index+=n;const a=this.matchExpression(s);return this.applyInvisibleOperator(...this.applyOperator(r.parse,i,a))}matchArguments(e){if(!e)return null;const i=this.index;let t=null;const r=this.matchMatchfixOperator();if("group"===e&&B(r)===p)t=j(r);else if("implicit"===e)if(B(r)===p)t=j(r);else if(null!==r)t=[r];else{const e=this.matchPrimary();null!==e&&(t=[e])}else this.index=i;return t}matchMatchfixOperator(){const[e]=this.peekDefinition("matchfix");if(null===e)return null;if("function"==typeof e.parse)return this.applyInvisibleOperator(...e.parse(null,this,0));const i="object"==typeof e.trigger?e.trigger.matchfix:e.trigger;if(!i||!e.closeFence||!e.parse)return null;const t=this.matchBalancedExpression(i,e.closeFence,this.onError);return t?[e.parse,t]:[e.parse]}matchDefinition(e){const[i,t]=this.peekDefinition(e);if("function"==typeof(null==i?void 0:i.parse)){const[,e]=i.parse(null,this,0);return[i,e]}return this.index+=t,[i,null]}matchSymbol(){var e,i,t,r;const[n,s]=this.matchDefinition("symbol");if(null!==s)return s;if(null===n){if(null===(e=this.options.promoteUnknownFunctions)||void 0===e?void 0:e.test(this.peek)){const e=this.next(),i=this.matchMatchfixOperator();return null===i?e:B(i)!==p?null:[e,...j(i)]}return(null===(i=this.options.promoteUnknownSymbols)||void 0===i?void 0:i.test(this.peek))?this.next():this.matchUnknownLatexCommand()}const a=[],o=[];let l,u=null!==(t=n.optionalLatexArg)&&void 0!==t?t:0;for(;u>0;)l=this.matchOptionalLatexArgument(),null!==l&&o.push(l),u--;for(u=null!==(r=n.requiredLatexArg)&&void 0!==r?r:0;u>0;)l=this.matchRequiredLatexArgument(),null===l&&this.onError({code:"expected-argument"}),null!==l&&a.push(l),u--;const c=this.matchArguments(n.arguments);return null===c?0===a.length&&0===o.length?n.parse:[n.parse,...a,...o]:[n.parse,...a,...c,...o]}matchOptionalLatexArgument(){return this.skipSpace(),this.matchBalancedExpression("[","]")}matchRequiredLatexArgument(){return this.skipSpace(),this.matchBalancedExpression("<{>","<}>")||(/^[0-9]$/.test(this.peek)?parseFloat(this.next()):/^[^\\#]$/.test(this.peek)?this.next():this.matchSymbol())}matchSupsub(e){if(null===e)return null;let i=null;return this.skipSpace(),[["^","superfix"],["_","subfix"]].forEach((t=>{var r,n,s;if(null!==i)return;const[a,o]=t,l=this.index;if(!this.match(a))return;const u=this.index;let c,h=0;if(this.match("<{>")?([c,h]=this.peekDefinition(o),c?"function"==typeof c.parse?i=c.parse(e,this,0)[1]:(this.index+=h,this.match("<}>")?i=[null!==(r=c.parse)&&void 0!==r?r:c.name,e]:this.index=u):this.index=u):([c,h]=this.peekDefinition(o),c?"function"==typeof c.parse?i=c.parse(e,this,0)[1]:(this.index+=h,i=[null!==(n=c.parse)&&void 0!==n?n:c.name,e]):this.index=u),null===i&&(c=null===(s=this.dictionary.infix[1])||void 0===s?void 0:s.get(a),"function"==typeof(null==c?void 0:c.parse)?(this.index=l,i=c.parse(e,this,0)[1]):"string"==typeof(null==c?void 0:c.parse)?([e,i]=this.applyOperator(c.parse,e,this.matchRequiredLatexArgument()),i=this.applyInvisibleOperator(e,i)):i=this.applyInvisibleOperator(e,a)),null!==i){const e=this.matchArguments(null==c?void 0:c.arguments);null!==e&&(i=[i,...e])}})),i}matchPostfix(e){if(null===e)return null;const[i,t]=this.peekDefinition("postfix");return null==i?null:"function"==typeof i.parse?([,e]=i.parse(e,this,0),null===e?null:e):(this.index+=t,[i.parse,e])}matchString(){let e="",i=this.atEnd;for(;!i;){if(this.match("<space>"))e+=" ";else{const t=this.peek;"]"===t?i=!0:/^<({|}|\$|\$\$|space)>$/.test(t)?"\\"===t[0]?(this.onError({code:"unexpected-command"}),e+=this.next()):i=!0:e+=this.next()}i=i||this.atEnd}return e}matchEnvironmentName(e,i){if(this.match(e)){const e=this.index;if(this.match("<{>")){const e=this.matchString();if(this.match("<}>")&&e===i)return!0}this.index=e}return!1}matchTabular(){const e=["list"];let i=["list"],t=null,r=!1;for(;!this.atEnd&&!r;)if(this.match("&"))i.push(null!=t?t:v),t=null;else if(this.match("\\\\")||this.match("\\cr"))this.skipSpace(),this.matchOptionalLatexArgument(),null!==t&&i.push(t),e.push(i),i=["list"],t=null;else{const e=this.matchExpression();null===e&&(r=!0),t=null!==t?this.applyInvisibleOperator(t,e):e}return i.length>1&&e.push(i),e}matchEnvironment(){var e;if(this.match("\\begin")&&this.match("<{>")){const i=this.matchString();if(this.match("<}>")){const t=this.index;let r=this.index,n=1;for(;!this.atEnd&&0!==n;)r=this.index,this.matchEnvironmentName("\\begin",i)?n+=1:this.matchEnvironmentName("\\end",i)?n-=1:this.next();const s=this.dictionary.environment.get(i);return"function"==typeof(null==s?void 0:s.parse)?s.parse(null,this.clone(t,r),0)[1]:null!==(e=null==s?void 0:s.parse)&&void 0!==e?e:null}}return null}applyOperator(e,i,t){var r,n,s,a;const o=this.dictionary.name.get(e);if(void 0===o)return this.onError({code:"unknown-operator"}),[i,t];if(void 0!==(null===(r=o.trigger)||void 0===r?void 0:r.prefix)&&null===i&&null!==t)return[null,[o.name,t]];if(void 0!==(null===(n=o.trigger)||void 0===n?void 0:n.postfix)&&null!==i)return[null,[o.name,i]];if(void 0!==(null===(s=o.trigger)||void 0===s?void 0:s.matchfix)||void 0!==(null===(a=o.trigger)||void 0===a?void 0:a.infix)){if("non"===o.associativity)return[null,[e,null!=i?i:"Missing",null!=t?t:"Missing"]];if(B(i)===e){if("both"===o.associativity){if(B(t)===e){if(Array.isArray(i))return[null,i.concat(j(t))];if(F(i))return[null,i.fn.concat(j(t))]}else t&&(Array.isArray(i)&&i.push(t),F(i)&&i.fn.push(t));return[null,i]}return"left"===o.associativity?[null,[e,null!=i?i:d,null!=t?t:d]]:Array.isArray(i)?[null,[e,i[1],[e,i[2],null!=t?t:d]]]:(F(i)&&(i.fn[2]=[e,i.fn[2],null!=t?t:d]),[null,i])}return B(t)===e?"both"===o.associativity?(Array.isArray(t)&&i&&t.splice(1,0,i),F(t)&&i&&t.fn.splice(1,0,i),[null,t]):"right"===o.associativity?[null,[e,null!=i?i:d,null!=t?t:d]]:Array.isArray(t)?[null,[e,t[1],[e,t[2],null!=i?i:d]]]:(F(t)&&(t.fn[2]=[e,t.fn[2],null!=i?i:d]),[null,t]):[null,[e,null!=i?i:"Missing",null!=t?t:"Missing"]]}return[i,null]}applyInvisibleOperator(e,i){if(null===e)return i;if(null===i)return e;if(this.options.invisiblePlusOperator&&("number"==typeof e||D(e))&&function(e){var i,t;const r=_(e);if(null!==r&&["ThreeQuarter","TwoThird","Half","Third","Quarter"].includes(r))return!0;if(B(e)!==N)return!1;const n=null!==(i=T(H(e,1)))&&void 0!==i?i:NaN,s=null!==(t=T(H(e,2)))&&void 0!==t?t:NaN;return Number.isInteger(n)&&Number.isInteger(s)}(i))return[e,i]=this.applyOperator(this.options.invisiblePlusOperator,e,i),null===e?i:null;if(this.options.invisibleOperator)return[e,i]=this.applyOperator(this.options.invisibleOperator,e,i),null===e?i:null;let t=[f];return B(e)===f?t=t.concat(j(e)):t.push(e),null!==i&&(B(i)===f?t=t.concat(j(i)):t.push(i)),this.options.invisibleOperator&&this.onError({code:"unexpected-sequence"}),t}matchUnknownLatexCommand(){var e;const i=this.peek;if(!i||"\\"!==i[0])return null;if(this.next(),"\\operatorname"===i){if(this.skipSpace(),"<{>"===this.peek){let e="";for(this.next();!this.atEnd&&"<}>"!==this.tokens[this.index];)e+=this.next();return e}return null!==(e=this.next())&&void 0!==e?e:d}const t=[],r=[];let n=!1;do{n=!0;let e=this.matchOptionalLatexArgument();null!==e&&(t.push(e),n=!1),this.skipSpace(),"<{>"===this.peek&&(e=this.matchRequiredLatexArgument(),null!==e&&(r.push(e),n=!1))}while(!n);return t.length>0||r.length>0?[i,...r,...t]:i}matchPrimary(e){let i=null;const t=this.index,r=this.matchNumber();r&&(i={num:r}),null===i&&(i=this.matchMatchfixOperator()),null===i&&(i=this.matchEnvironment()),null===i&&(i=this.matchSymbol());let n=null;do{n=this.matchSupsub(i),i=null!=n?n:i}while(null!==n);let s=null;do{s=this.matchPostfix(i),i=null!=s?s:i}while(null!==s);return this.decorate(i,t)}matchBalancedExpression(e,i,t){const r=this.balancedClone(e,i);if(!r)return null==t||t({code:"unbalanced-symbols",arg:u(e)+u(i)}),null;const n=r.matchExpression();return r.atEnd||null==t||t({code:"unbalanced-symbols",arg:u(e)+u(i)}),n}matchExpression(e=0){let i=null;const t=this.index;this.skipSpace(),i=this.matchPrimary(e),null===i&&(i=this.matchOperator("prefix"));let r=!1;for(;!this.atEnd&&!r;){this.skipSpace();let t=this.matchOperator("infix",i,e);if(null===t&&null!==i){const[e]=this.peekDefinition("operator");if(null===e){const e=this.matchExpression(this.invisibleOperatorPrecedence);null!==e&&(t=this.applyInvisibleOperator(i,e))}}null!==t?i=t:r=!0}return this.decorate(i,t)}decorate(e,i){if(null===e)return null;if(this.options.preserveLatex){const t=this.latex(i,this.index);Array.isArray(e)?e={latex:t,fn:e}:"number"==typeof e?e={latex:t,num:Number(e).toString()}:"string"==typeof e?e={latex:t,sym:e}:"object"==typeof e&&null!==e&&(e.latex=t)}return e}}function de(e,i){const t=e.length,r=e;e=e.slice(0,-1);for(let t=0;t<e.length-16;t++){const r=e.substr(0,t);for(let n=0;n<17;n++){const s=e.substr(t,n+1),a=Math.floor((e.length-r.length)/s.length);if(a>1&&(r+s.repeat(a+1)).startsWith(e))return"0"===s?r.replace(/(\d{3})/g,"$1"+i.groupSeparator):r.replace(/(\d{3})/g,"$1"+i.groupSeparator)+i.beginRepeatingDigits+s+i.endRepeatingDigits}}const n=t>i.precision-1;return e=r,n&&(e=e.substr(0,i.precision-1)),i.groupSeparator&&(e=e.replace(/(\d{3})/g,"$1"+i.groupSeparator)).endsWith(i.groupSeparator)&&(e=e.slice(0,-i.groupSeparator.length)),n?e+i.truncationMarker:e}function ve(e,i){var t;return e?i.beginExponentMarker?i.beginExponentMarker+e+(null!==(t=i.endExponentMarker)&&void 0!==t?t:""):"10^{"+e+"}":""}class xe{constructor(e,i,t){this.level=-1,this.options=e,e.invisibleMultiply&&(/#1/.test(e.invisibleMultiply)&&/#2/.test(e.invisibleMultiply)||t({code:"expected-argument",arg:"invisibleMultiply"})),this.onError=t,this.dictionary=i}wrap(e,i){if(null===e)return"";if(void 0===i)return"("+this.serialize(e)+")";if("number"==typeof e||D(e)||"string"==typeof e||P(e))return this.serialize(e);const t=B(e);if(t&&t!==p){const r=this.dictionary.name.get(t);if(r&&void 0!==r.precedence&&r.precedence<i)return this.wrapString(this.serialize(e),(this.level,"paren"))}return this.serialize(e)}wrapShort(e){if(null===e)return"";const i=this.serialize(e);return B(e)===p||"number"==typeof e||D(e)||/(^(.|\\[a-zA-Z*]+))$/.test(i)?i:this.wrapString(i,(this.level,"paren"))}wrapString(e,i){return"none"===i?e:"("+e+")"}serializeSymbol(e,i){const t=$(e);if(!t){if("string"==typeof(null==i?void 0:i.serialize))return i.serialize;const t=_(e);if(null===t)return"";switch(function(e,i){const t=_(e);return null===t?"asis":t.length>1?"upright":"asis"}(e,this.level)){case"upright":return"\\operatorname{"+t+"}";default:return t}}const r=j(e);if(!i){if("string"==typeof t&&t.length>0&&"\\"===t[0]){let e=t;for(const i of r)e+="{"+this.serialize(i)+"}";return e}return`${this.serialize(t)}(${r.map((e=>this.serialize(e))).join(", ")})`}if(i.requiredLatexArg>0){let e="",t="",n=0;for(;n<i.requiredLatexArg;)t+="{"+this.serialize(r[n++])+"}";for(;n<Math.min(r.length,i.optionalLatexArg+i.requiredLatexArg);){const i=this.serialize(r[1+n++]);i&&(e+="["+i+"]")}return i.serialize+(e+t)}return this.level,i.serialize+this.serialize([p,...r])}serializeDictionary(e){return`\\left[\\begin{array}{lll}${Object.keys(e).map((i=>`\\textbf{${i}} & \\rightarrow & ${this.serialize(e[i])}`)).join("\\\\")}\\end{array}\\right]`}serialize(e){if(null===e)return"";this.level+=1;const i=(()=>{var i,t,r,n;const s=function(e,i){var t,r;let n;if("number"==typeof e)n=e;else{if(!D(e))return"";n=e.num}if(n===1/0||"Infinity"===n||"+Infinity"===n)return i.positiveInfinity;if(n===-1/0||"-Infinity"===n)return i.negativeInfinity;if("NaN"===n||"number"==typeof n&&Number.isNaN(n))return i.notANumber;if("number"==typeof n)return"engineering"===i.notation?function(e,i){if(0===e)return"0";const t=Math.abs(e);let r=Math.round(Math.log10(t));r-=r%3,t<1e3&&(r=0);const n=t/Math.pow(10,r);let s="";const a=n.toString().match(/^(.*)\.(.*)$/);(null==a?void 0:a[1])&&a[2]&&(s=a[1]+i.decimalMarker+a[2]),i.groupSeparator&&(s=de(n.toExponential(),i));let o="";return 0!==r&&(o=ve(r.toString(),i)),(e<0?"-":"")+s+o}(n,i):function(e,i){let t,r=e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i);(null==r?void 0:r[1])&&r[2]&&(t=ve(r[2],i),t&&(t=i.exponentProduct+t));let n=e,s="";return r=(t?r[1]:e).match(/^(.*)\.(.*)$/),(null==r?void 0:r[1])&&r[2]&&(n=r[1],s=r[2]),i.groupSeparator&&(n=n.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator),s=de(s,i)),s&&(s=i.decimalMarker+s),n+s+(null!=t?t:"")}(n.toString(),i);/[a-zA-Z]$/.test(n)&&(n=n.slice(0,-1));let s="";for("-"===n[0]?(s="-",n=n.substr(1)):"+"===n[0]&&(n=n.substr(1));"0"===n[0];)n=n.substr(1);if(0===n.length)return s+"0";"."===n[0]&&(n="0"+n);let a="";if(n.indexOf(".")>=0){const e=n.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);if(!e)return"";const r=e[1],o=e[2];if(a=null!==(t=e[4])&&void 0!==t?t:"","0"===r){let e=0;for(;"0"===o[e]&&e<o.length;)e+=1;let t="";if(e<=4)t="0"+i.decimalMarker,t+=o.substr(0,e),t+=de(n.substr(t.length),i);else if(e+1>=i.precision)t="0",s="";else{t=n[e];const r=de(n.substr(e+1),i);r&&(t+=i.decimalMarker+r)}"0"!==t&&(!(n.length-1>i.precision)||i.endRepeatingDigits&&t.endsWith(i.endRepeatingDigits)||!i.truncationMarker||t.endsWith(i.truncationMarker)||(t+=i.truncationMarker),e>4&&(t+=i.exponentProduct+ve((1-e).toString(),i))),n=t}else{n=r.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator);const e=de(o,i);e&&(n+=i.decimalMarker+e)}}else if(n.length>i.precision){const e=n.length;let t=n[0];const r=de(n.substr(1),i);r&&(t+=i.decimalMarker+r,i.truncationMarker&&!t.endsWith(i.truncationMarker)&&i.endRepeatingDigits&&!t.endsWith(i.endRepeatingDigits)&&(t+=i.truncationMarker)),"1"!==t?t+=i.exponentProduct:t="",n=t+ve((e-1).toString(),i)}else{const e=n.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);e&&(n=e[1],e[2]&&(n+=i.decimalMarker+e[2]),a=null!==(r=e[4])&&void 0!==r?r:""),n=n.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator)}const o=ve(a,i);return s+n+(o?i.exponentProduct+o:"")}(e,this.options);if(s)return s;const a=C(e);if(null!==a)return`\\text{${a}}`;const o=_(e);if(null!==o)return this.serializeSymbol(e,this.dictionary.name.get(o));const c=W(e);if(null!==c)return this.serializeDictionary(c);const h=B(e);if(h){if("\\"===h[0]){const i=j(e);return 0===i.length?h:h+"{"+i.map((e=>this.serialize(e))).filter((e=>Boolean(e))).join("}{")+"}"}const s=this.dictionary.name.get(h);if(s){let a="";return"function"==typeof s.serialize&&(a=s.serialize(this,e)),a||void 0===s.precedence&&!(null===(i=s.trigger)||void 0===i?void 0:i.superfix)&&!(null===(t=s.trigger)||void 0===t?void 0:t.subfix)||(a=function(e,i,t){var r,n,s,a,o;let l="";const u=G(i),c=B(i);if((null===(r=t.trigger)||void 0===r?void 0:r.superfix)||(null===(n=t.trigger)||void 0===n?void 0:n.subfix))return 1!==u&&e.onError({code:"operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.serialize(H(i,1))]);if(null===(s=t.trigger)||void 0===s?void 0:s.postfix)return 1!==u&&e.onError({code:"postfix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.wrap(H(i,1),t.precedence)]);if(null===(a=t.trigger)||void 0===a?void 0:a.prefix)return 1!==u&&e.onError({code:"prefix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),fe(t.serialize,[e.wrap(H(i,1),t.precedence+1)]);if(null===(o=t.trigger)||void 0===o?void 0:o.infix){l=e.wrap(H(i,1),t.precedence);for(let r=2;r<u+1;r++){const n=H(i,r);null!==n&&(l=fe(t.serialize,[l,e.wrap(n,t.precedence)]))}}return l}(this,e,s)),!a&&(null===(r=s.trigger)||void 0===r?void 0:r.matchfix)&&(a=function(e,i,t){var r,n;let s=[];if("string"==typeof(null===(r=t.trigger)||void 0===r?void 0:r.matchfix)?s.push(null===(n=t.trigger)||void 0===n?void 0:n.matchfix):t.trigger&&Array.isArray(t.trigger.matchfix)&&(s=[...t.trigger.matchfix]),G(i)>=1){let r="";for(const n of j(i))n&&(s.push(r),s.push(e.serialize(n)),r=t.separator)}return s.push(u(t.closeFence)),l(s)}(this,e,s)),!a&&(null===(n=s.trigger)||void 0===n?void 0:n.symbol)&&(a=this.serializeSymbol(e,s)),a}}if(Array.isArray(e)||F(e))return this.serializeSymbol(e);this.onError({code:"syntax-error",arg:JSON.stringify(e)})})();return this.level-=1,null!=i?i:""}}class ye{constructor(e){var i,t;this.onError=null!==(i=null==e?void 0:e.onError)&&void 0!==i?i:e=>{"undefined"!=typeof window&&(!e.before||e.after)};const r={...null!=e?e:{}};delete r.dictionary,delete r.onError,this.options={...he,...pe,...ge,...r},this.dictionary=function(e,i){var t,r,n,s,a,o,l,u,c,h,g,p,f,m,d;const v={lookahead:1,name:new Map,prefix:[],infix:[],postfix:[],matchfix:[],superfix:[],subfix:[],symbol:[],environment:new Map};for(const x of e)void 0===x.parse&&(x.parse=x.name),"string"==typeof x.trigger&&(x.trigger={symbol:x.trigger}),"string"==typeof x.serialize&&void 0!==(null===(t=x.trigger)||void 0===t?void 0:t.symbol)&&/#[0-9]/.test(x.serialize)&&i({code:"unexpected-argument",arg:x.name}),void 0===x.serialize&&(void 0!==(null===(r=x.trigger)||void 0===r?void 0:r.postfix)?x.serialize="#1"+ue(x.trigger.postfix):void 0!==(null===(n=x.trigger)||void 0===n?void 0:n.prefix)?x.serialize=ue(x.trigger.prefix)+"#1":void 0!==(null===(s=x.trigger)||void 0===s?void 0:s.infix)?x.serialize="#1"+ue(x.trigger.infix)+"#2":void 0!==(null===(a=x.trigger)||void 0===a?void 0:a.symbol)?x.serialize=ue(x.trigger.symbol):void 0!==(null===(o=x.trigger)||void 0===o?void 0:o.superfix)?x.serialize="#1^{"+ue(null===(l=x.trigger)||void 0===l?void 0:l.superfix)+"}":void 0!==(null===(u=x.trigger)||void 0===u?void 0:u.subfix)?x.serialize="#1_{"+ue(null===(c=x.trigger)||void 0===c?void 0:c.subfix)+"}":x.serialize=""),void 0!==(null===(h=x.trigger)||void 0===h?void 0:h.infix)&&(void 0===x.precedence&&i({code:"syntax-error",arg:"Infix operators require a precedence"}),x.associativity||(x.associativity="non")),void 0!==(null===(g=x.trigger)||void 0===g?void 0:g.symbol)&&(x.arguments=null!==(p=x.arguments)&&void 0!==p?p:"",x.optionalLatexArg=null!==(f=x.optionalLatexArg)&&void 0!==f?f:0,x.requiredLatexArg=null!==(m=x.requiredLatexArg)&&void 0!==m?m:0),void 0!==(null===(d=x.trigger)||void 0===d?void 0:d.matchfix)&&("function"===x.parse||x.closeFence||i({code:"syntax-error",arg:"Matchfix operators require a close fence or a custom parse function"})),void 0!==x.trigger&&(["infix","prefix","postfix","symbol","matchfix","superfix","subfix"].forEach((e=>{if(x.trigger[e]){const t=(i=x.trigger[e],Array.isArray(i)?i.length:1);v.lookahead=Math.max(v.lookahead,t),void 0===v[e][t]&&(v[e][t]=new Map),v[e][t].set(ue(x.trigger[e]),x)}var i})),void 0!==x.trigger.environment&&v.environment.set(x.trigger.environment,x)),void 0!==x.name?v.name.set(ue(x.name),x):"string"==typeof x.parse&&v.name.set(x.parse,x),void 0!==x.trigger||x.name||i({code:"syntax-error",arg:"Need at least a trigger or a name"});return v}(null!==(t=null==e?void 0:e.dictionary)&&void 0!==t?t:ye.getDictionary(),this.onError)}static getDictionary(e="all"){if("all"===e){let e=[];for(const i of Object.keys(ce))e=[...e,...ce[i]];return e}return ce[e]?[...ce[e]]:[]}parse(e){var i;const t=new me(o(e,[]),this.options,this.dictionary,this.onError),r=t.matchExpression();return t.atEnd||null===(i=this.onError)||void 0===i||i.call(this,{code:"syntax-error"}),null!=r?r:""}serialize(e){return new xe(this.options,this.dictionary,this.onError).serialize(e)}}e.LatexSyntax=ye,e.parse=function(e,i){return new ye(i).parse(e)},e.serialize=function(e,i){return new ye(i).serialize(e)},e.version="0.4.0",Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
/** MathJSON 0.4.3 */
|
|
2
|
+
var global,factory;global=this,factory=function(e){const i=8205;function t(e){return e===i||65038===e||65039===e||e>=127995&&e<=128e3||e>=129456&&e<=129460||e>=917536&&e<=917632}function r(e){return e>=127462&&e<=127487}class n{constructor(e){this.obeyspaces=!1,this.s=function(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const n=[],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;n.push(String.fromCodePoint(...s.slice(e,2*a-e+1)))}else if(t(o)){const e=a-1;for(;t(s[a]);)a+=s[a]===i?2:1;n.push(String.fromCodePoint(...s.slice(e,2*a-e-1)))}else r(e)?(a+=1,n.push(String.fromCodePoint(...s.slice(a-2,2)))):n.push(String.fromCodePoint(e))}return n}(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("")),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 s(e,i){let t=[],r=e.next();if(r)if("\\relax"===r);else if("\\noexpand"===r)r=e.next(),r&&t.push(r);else if("\\obeyspaces"===r)e.obeyspaces=!0;else if("\\space"===r||"~"===r)t.push("<space>");else if("\\bgroup"===r)t.push("<{>");else if("\\egroup"===r)t.push("<}>");else if("\\string"===r)r=e.next(),r&&("\\"===r[0]?Array.from(r).forEach((e=>t.push("\\"===e?"\\backslash":e))):"<{>"===r?t.push("\\{"):"<space>"===r?t.push("~"):"<}>"===r&&t.push("\\}"));else if("\\csname"===r){for(;"<space>"===e.peek();)e.next();let n="",s=!1,o=[];do{0===o.length&&(/^#[0-9?]$/.test(e.peek())?(o=a(i?.[e.get().slice(1)]??i?.["?"]??"\\placeholder{}",i),r=o[0]):(r=e.next(),o=r?[r]:[])),s=0===o.length,s||"\\endcsname"!==r||(s=!0,o.shift()),s||(s="<$>"===r||"<$$>"===r||"<{>"===r||"<}>"===r||!!r&&r.length>1&&"\\"===r[0]),s||(n+=o.shift())}while(!s);n&&t.push("\\"+n),t=t.concat(o)}else if("\\endcsname"===r);else if(r.length>1&&"#"===r[0]){const e=r.slice(1);t=t.concat(a(i?.[e]??i?.["?"]??"\\placeholder{}",i))}else t.push(r);return t}function a(e,i){const t=e.toString().split(/\r?\n/);let r="",a="";for(const e of t){r+=a,a=" ";const i=e.match(/((?:\\%)|[^%])*/);null!==i&&(r+=i[0])}const o=new n(r);let l=[];do{l=l.concat(s(o,i))}while(!o.end());return l}function o(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 l(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 o(i.map((e=>({"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[e]??e))))}function c(e){return!("kind"in e)||"symbol"===e.kind}function g(e){return"kind"in e&&"matchfix"===e.kind}function u(e){return"kind"in e&&"infix"===e.kind}function p(e){return"kind"in e&&"prefix"===e.kind}function h(e){return"kind"in e&&"postfix"===e.kind}const m="List",f="Divide",d="Multiply",x="Negate",y="Power",k="Prime",v="Root",b="Sqrt",S="Subtract",N="ComplexInfinity",A="ExponentialE",z="ImaginaryUnit";function q(e){return null!==e&&"object"==typeof e&&"num"in e}function E(e){return null!==e&&"object"==typeof e&&"sym"in e}function P(e){return null!==e&&"object"==typeof e&&"fn"in e}function D(e){return null===e||!Array.isArray(e)&&("object"!=typeof e||!("fn"in e||"dic"in e))}function _(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 L(e){return null===e?null:Array.isArray(e)?e[0]:P(e)?e.fn[0]:null}function w(e){const i=L(e);return"string"==typeof i?i:""}function C(e,i){return null===e?null:Array.isArray(e)?e[i]??null:P(e)?e.fn[i]??null:null}function $(e){return Array.isArray(e)?Math.max(0,e.length-1):P(e)?Math.max(0,e.fn.length-1):0}function M(e){return null===e?null:"string"==typeof e?e.length>=2&&"'"===e[0]&&"'"===e[e.length-1]?null:e:E(e)?e.sym:null}function I(e){if(null===e)return null;if("number"==typeof e)return e;if(q(e))return parseFloat(e.num);const i=M(e);return"NaN"===i?NaN:"+Infinity"===i?1/0:"-Infinity"===i?-1/0:null}function R(e){if(D(e))return[null,null];const i=L(e);if(!i)return[null,null];let t=null,r=null;if("Negate"===i&&([t,r]=R(C(e,1)??"Missing"),null!==t&&null!==r))return[-t,r];if("Rational"===i)return[I(C(e,1)??NaN)??NaN,I(C(e,2)??NaN)??NaN];if("Power"===i){const i=I(C(e,2));1===i?(t=I(C(e,1))??null,r=1):-1===i&&(t=1,r=I(C(e,1))??null)}return"Divide"===i&&(t=I(C(e,1))??null,r=I(C(e,2))??null),"Multiply"===i&&L(C(e,2))===y&&-1===I(C(C(e,2),2))&&(t=I(C(e,1))??null,r=I(C(C(e,2),1))??null),null===t||null===r?[null,null]:Number.isInteger(t)&&Number.isInteger(r)?[t,r]:[null,null]}function O(e){return Array.isArray(e)?e.slice(1):P(e)?e.fn.slice(1):[]}function T(e,i){let t=null;if(Array.isArray(e)&&(t=e),P(e)&&(t=e.fn),null===t)return[];let r=1;const n=[];for(;r<t.length;)n.push(i(t[r])),r+=1;return n}function F(e){return"object"==typeof e&&"dict"in e?e.dict:null}function j(e,i,t,r="both"){if("non"===r)return[e,i,t];const n=L(i),s=L(t);return"left"===r?n===e?[e,...O(i)??[],t]:[e,i,t]:"right"===r?s===e?[e,i,...O(t)??[]]:[e,i,t]:n===e&&s===e?[e,...O(i)??[],...O(t)??[]]:n===e?[e,...O(i)??[],t]:s===e?[e,i,...O(t)??[]]:[e,i,t]}function Z(e){const i=L(e);return null===e?null:("Delimiter"===i&&(e=C(e,1)??null),null===e?null:"Sequence"===i?O(e)??[]:null)}function B(e,i){return i>2?"solidus":"radical"}function G(e,i){return i>3?"inline-solidus":"quotient"}function U(e,i,t,r){return null===t?"\\sqrt{}":(r=r??2,"solidus"===i?e.wrapShort(t)+"^{1\\/"+e.serialize(r)+"}":"quotient"===i?e.wrapShort(t)+"^{\\frac{1}{"+e.serialize(r)+"}}":2===I(r)?"\\sqrt{"+e.serialize(t)+"}":"\\sqrt["+e.serialize(r)+"]{"+e.serialize(t)+"}")}function W(e,i){if(null===i)return"";const t=C(i,1)??"Missing",r=C(i,2)??"Missing";if(1===$(i))return e.serialize(t);const n=G(0,e.level);if("inline-solidus"===n||"nice-solidus"===n){const i=e.wrapShort(t),s=e.wrapShort(r);return"inline-solidus"===n?`${i}\\/${s}`:`^{${i}}\\!\\!/\\!_{${s}}`}return"reciprocal"===n?e.wrap(t)+e.wrap(r)+"^{-1}":"factor"===n?"\\frac{1}{"+e.serialize(r)+"}"+e.wrap(t):`\\frac{${e.serialize(t)}}{${e.serialize(r)}}`}function V(e,i){const t=L(i),r=C(i,1)??"Missing",n=C(i,2)??"Missing";if("Sqrt"===t)return U(e,B(0,e.level),r,2);if("Root"===t)return U(e,B(0,e.level),r,n);const s=I(n)??1;if(-1===s)return e.serialize([f,"1",r]);if(s<0)return e.serialize([f,"1",[y,r,-s]]);if("Divide"===L(n)||"Rational"===L(n)){if(1===I(C(n,1)))return U(e,B(0,e.level),r,C(n,2))}else if(L(n)===y&&-1===I(C(n,2)))return U(e,B(0,e.level),r,C(n,1));return e.wrapShort(r)+"^{"+e.serialize(n)+"}"}const H=[{name:"CatalanConstant",serialize:"G"},{name:"GoldenRatio",serialize:"\\varphi"},{name:"EulerGamma",serialize:"\\gamma"},{name:"Degrees",serialize:"\\frac{\\pi}{180}"},{trigger:["\\infty"],parse:{num:"+Infinity"}},{name:N,trigger:["\\tilde","\\infty"],serialize:"\\tilde\\infty"},{trigger:["\\tilde","<{>","\\infty","<}>"],parse:N},{name:"Pi",trigger:["\\pi"]},{trigger:["\u03c0"],parse:"Pi"},{name:A,trigger:["e"],serialize:"e"},{trigger:["\\mathrm","<{>","e","<}>"],parse:A},{trigger:["\\exponentialE"],parse:A},{name:z,trigger:["\\imaginaryI"]},{trigger:["i"],parse:z},{trigger:["\\mathrm","<{>","i","<}>"],parse:z},{name:"Add",trigger:["+"],kind:"infix",associativity:"both",precedence:275,parse:(e,i,t)=>{if(275<i.minPrec)return null;const r=e.matchExpression({...i,minPrec:275});return null===r?null:j("Add",t,r)},serialize:function(e,i){e.level-=1;const t=L(i);let r="",n=C(i,1),s=!Number.isNaN(I(n)??NaN);if(t===x)r="-"+e.wrap(n,276);else if("Add"===t){r=e.serialize(n);const t=$(i)+1;for(let a=2;a<t;a++){n=C(i,a);const t=I(n)??NaN,o=!Number.isNaN(t);let l=!1;if(null!==n&&s){const[i,t]=R(n);null!==i&&null!==t&&isFinite(i)&&isFinite(t)&&1!==t&&(r+=e.options.invisiblePlus+e.serialize(n),l=!0)}if(!l)if(t<0)r+=e.serialize(n);else if("Negate"===L(n))r+=e.wrap(n,275);else{const i=e.wrap(n,275);"-"===i[0]||"+"===i[0]?r+=i:r=r+"+"+i}s=o}}else if(t===S){const t=C(i,2);r=null!==t?e.wrap(n,275)+"-"+e.wrap(t,275):e.wrap(n,275)}return e.level+=1,r}},{kind:"prefix",trigger:["+"],precedence:275,parse:(e,i)=>275<i.minPrec?null:e.matchExpression({...i,minPrec:400})},{name:"Complex",precedence:274,serialize:(e,i)=>{const t=I(C(i,1)),r=I(C(i,2));if(0===r)return e.serialize(C(i,1));const n=1===r?"\\imaginaryI":-1===r?"-\\imaginaryI":o([e.serialize(C(i,2)),"\\imaginaryI"]);return 0===t?n:o(null!==r&&r<0?[e.serialize(C(i,1)),n]:[e.serialize(C(i,1)),"+",n])}},{name:"Divide",trigger:["\\frac"],requiredLatexArg:2,precedence:660,parse:function(e){const i=e.matchRequiredLatexArgument()??"Missing",t=e.matchRequiredLatexArgument()??"Missing";if("PartialDerivative"===L(i)&&("PartialDerivative"===L(t)||"Multiply"===L(t)&&"PartialDerivative"===L(C(t,1)))){const r=C(i,3)??"Nothing";let n=C(i,1);null!==n&&"Missing"!==n||(n=e.matchExpression()??"Nothing");let s=[];if("Multiply"===L(t)){for(const e of O(t))if("PartialDerivative"===L(e)){const i=C(e,2);i&&s.push(i)}}else{const e=C(t,2);e&&s.push(e)}return s.length>1&&(s=[m,...s]),["PartialDerivative",n,...s,"Missing"===r?1:r]}return[f,i,t]},serialize:W},{trigger:["\\/"],kind:"infix",associativity:"non",precedence:660,parse:"Divide"},{trigger:["/"],kind:"infix",associativity:"non",precedence:660,parse:"Divide"},{trigger:["\\div"],kind:"infix",associativity:"non",precedence:660,parse:"Divide"},{name:"Exp",serialize:(e,i)=>o(["\\exponentialE^{",e.serialize(C(i,1)??"Nothing"),"}"])},{name:"Factorial",trigger:["!"],kind:"postfix",precedence:810},{name:"Factorial2",trigger:["!","!"],kind:"postfix",precedence:810},{trigger:"\\operatorname{floor}",parse:e=>{const i=e.matchArguments("group");return null===i?null:["Floor",...i]}},{name:"Gcd",trigger:"\\operatorname{gcd}",parse:e=>{const i=e.matchArguments("group");return null===i?null:["Gcd",...i]},serialize:(e,i)=>o(["\\operatorname{gcd}","\\left(",e.serialize(i),"\\right)"])},{name:"Half",serialize:"\\frac12"},{name:"Lcm",trigger:"\\operatorname{lcm}"},{name:"MinusPlus",trigger:["\\mp"],kind:"infix",associativity:"both",precedence:270},{name:d,trigger:["\\times"],kind:"infix",associativity:"both",precedence:390,serialize:function e(i,t){if(null===t)return"";i.level-=1;let r="";const[n,s]=function(e){if("Multiply"!==L(e))return[[],[]];const i=[],t=[],r=O(e);for(const e of r)if("Power"===L(e))if("Negate"===L(C(e,2))){const i=C(e,1)??"Nothing",r=C(C(e,2),1)??"Nothing";t.push([y,i,r])}else{const r=I(C(e,2))??NaN;-1===r?t.push(C(e,1)??"Nothing"):r<0?t.push([y,C(e,1)??"Nothing",-r]):i.push(e)}else i.push(e);return[i,t]}(t);if(s.length>0&&(r=1===s.length&&1===s[0]?0===n.length?"1":1===n.length?i.serialize(n[0]):e(i,[d,...n]):i.serialize([f,1===n.length?n[0]:[d,...n],1===s.length?s[0]:[d,...s]])),r)return i.level+=1,r;let a=!1,l=null;const c=$(t)+1;let g=!1;for(let e=1;e<c;e++){if(l=C(t,e),null===l)continue;let n;if("number"==typeof l||q(l))n=i.serialize(l),"-1"!==n||r?("-"===n[0]&&(n=n.slice(1),a=!a),r=r?o([r,i.options.multiply,n]):n):r="-",g=!0;else{if("Power"===L(l)){const[e,t]=R(C(l,2)??NaN);if(1===e&&null!==t){r+=U(i,B(0,i.level),C(l,1),t),g=!1;continue}}if("Power"!==L(l)||isNaN(I(C(l,1))??NaN)){if("Negate"===L(l)&&(l=C(l,1),a=!a),n=i.wrap(l,390),r){const e=L(l);r=!g||"Divide"!==e&&"Rational"!==e?i.options.invisibleMultiply?o([r,i.options.invisibleMultiply,n]):o([r,n]):o([r,i.options.multiply,n])}else r=n;g=!1}else n=i.serialize(l),r=r?o([r,i.options.multiply,n]):n,g=!0}}return i.level+=1,a?"-"+r:r}},{trigger:["\\cdot"],kind:"infix",associativity:"both",precedence:390,parse:(e,i,t)=>{if(391<i.minPrec)return null;const r=e.matchExpression({...i,minPrec:392});return null===r?null:j("Multiply",t,r)}},{trigger:["*"],kind:"infix",associativity:"both",precedence:390,parse:(e,i,t)=>{if(391<i.minPrec)return null;const r=e.matchExpression({...i,minPrec:392});return null===r?null:["Multiply",t,r]}},{name:x,trigger:["-"],kind:"prefix",parse:(e,i)=>{if(276<i.minPrec)return null;const t=e.matchExpression({...i,minPrec:400});return null===t?null:[x,t]},precedence:275},{name:"PlusMinus",trigger:["\\pm"],kind:"infix",associativity:"both",precedence:270},{name:y,trigger:["^"],kind:"infix",serialize:V},{name:"Rational",precedence:660,serialize:W},{name:v,serialize:V},{name:"Round",trigger:"\\operatorname{round}"},{name:"Square",precedence:720,serialize:(e,i)=>e.wrapShort(C(i,1))+"^2"},{name:"Sign",trigger:"\\operatorname{sgn}"},{name:b,trigger:["\\sqrt"],optionalLatexArg:1,requiredLatexArg:1,parse:function(e){const i=e.matchOptionalLatexArgument(),t=e.matchRequiredLatexArgument();return null===t?null!==i?[v,"Nothing",i]:[b,"Nothing"]:null!==i?[v,t,i]:[b,t]},serialize:V},{name:S,trigger:["-"],kind:"infix",associativity:"both",precedence:275,parse:(e,i,t)=>{if(276<i.minPrec)return null;const r=e.matchExpression({...i,minPrec:277});return null===r?null:[S,t,r]}}];function J(e=""){return(i,t)=>O(t).map((e=>i.serialize(e))).join(e)}function K(e,i){if(null===i)return"";const t=L(i);if("LatexString"===t)return ie(e,i);if("LatexTokens"===t)return ee(e,i);const r=_(i);if(null!==r)return`\\text{${r}}`;const n=I(i);return null!==n?n.toString():`\\text{${JSON.stringify(i)}}`}const Q=[{name:"Missing",trigger:["\\placeholder"],requiredLatexArg:1,serialize:e=>e.options.missingSymbol??"\\placeholder{}"},{name:"BaseForm",serialize:(e,i)=>{const t=I(C(i,2))??NaN;if(isFinite(t)&&t>=2&&t<=36){const e=I(C(i,1))??NaN;if(isFinite(e)){let i=Number(e).toString(t),r=0;if(2===t||10===t?r=4:16===t?r=2:t>16&&(r=4),r>0){const e=i;i="";for(let t=0;t<e.length;t++)t>0&&t%r==0&&(i="\\, "+i),i=e[e.length-t-1]+i}return`(\\text{${i}}_{${t}}`}}return"\\operatorname{BaseForm}("+e.serialize(C(i,1))+", "+e.serialize(C(i,2))+")"}},{name:"Delimiter",serialize:(e,i)=>{const t=$(i);if(0===t)return"";if(1===t)return`\\left( ${e.serialize(C(i,1))} \\right)`;let r="",n="\\left(",s="\\left)";2===t?r=K(e,C(i,2))??"":3===t?(n=K(e,C(i,2))??"",s=K(e,C(i,3))??""):(n=K(e,C(i,2))??"",r=K(e,C(i,3))??"",s=K(e,C(i,4))??"");const a=C(i,1);return r&&"Sequence"===L(a)?`${n} ${J(r)(e,a)} ${s}`:`${n} ${e.serialize(a)} ${s}`}},{name:"Error",serialize:(e,i)=>{const t=C(i,1),r="Nothing"===M(t)?"":e.serialize(t);if($(i)>=3){const e=C(i,3);if(e&&"LatexForm"===L(e)){const i=te(_(C(e,1)));if(i)return`${r??""}\\texttt{\\textcolor{red}{${i}}}`}}return r??""}},{name:"FromLatex",serialize:(e,i)=>`\\texttt{${te(_(C(i,1)))}}`},{name:"LatexForm",serialize:ie},{name:"LatexTokens",serialize:ee},{kind:"matchfix",openDelimiter:"(",closeDelimiter:")",parse:(e,i)=>null===i?null:"Sequence"===L(i)?0===$(i)?["Delimiter","Nothing"]:["Delimiter",...O(i)]:["Delimiter",i]},{name:"Sequence",trigger:[","],kind:"infix",precedence:20,parse:(X=20,(e,i,t)=>{if(i.minPrec>=X)return null;"Missing"===t&&(t="Nothing");const r=["Sequence",t];let n=!1;for(;!n;){for(n=!0,e.skipSpace();e.match(",");)r.push("Nothing"),e.skipSpace();if(e.atTerminator(i))r.push("Nothing");else{const t=e.matchExpression({...i,minPrec:X});r.push(t??"Nothing"),n=null===t}n||(e.skipSpace(),n=!e.match(","))}return r}),serialize:J()},{trigger:[";"],kind:"infix",precedence:19,parse:function(e){return(i,t,r)=>{if(t.minPrec>=e)return null;"Missing"===r&&(r="Nothing");const n=["Sequence",...Z(r)??["Sequence",r]];for(;;){for(i.skipSpace();i.match(",");)n.push("Nothing"),i.skipSpace();if(i.atEnd){n.push("Nothing");break}const r=i.matchExpression({...t,minPrec:e});if(null===r){n.push("Nothing");break}if(n.push(...Z(r)??["Sequence",r]),i.skipSpace(),!i.match(","))break}return n}}(19)},{name:"String",trigger:["\\text"],parse:e=>Y(e),serialize:(e,i)=>{const t=O(i);return null===t||0===t.length?"\\text{}":"\\text{"+t.map((i=>e.serialize(i))).join("")+"}"}},{name:"Subscript",trigger:["_"],kind:"infix",serialize:(e,i)=>2===$(i)?e.serialize(C(i,1))+"_{"+e.serialize(C(i,2))+"}":"_{"+e.serialize(C(i,1))+"}"},{name:"Superplus",trigger:["^","+"],kind:"postfix"},{name:"Subplus",trigger:["_","+"],kind:"postfix"},{name:"Superminus",trigger:["^","-"],kind:"postfix"},{name:"Subminus",trigger:["_","-"],kind:"postfix"},{trigger:["^","*"],kind:"postfix",parse:(e,i)=>["Superstar",i]},{name:"Superstar",trigger:["^","\\star"],kind:"postfix"},{trigger:["_","*"],kind:"postfix",parse:(e,i)=>["Substar",i]},{name:"Substar",trigger:["_","\\star"],kind:"postfix"},{name:"Superdagger",trigger:["^","\\dagger"],kind:"postfix"},{trigger:["^","\\dag"],kind:"postfix",parse:(e,i)=>["Superdagger",i]},{name:k,trigger:["^","\\prime"],kind:"postfix"},{trigger:["^","\\doubleprime"],kind:"postfix",parse:(e,i)=>[k,i??"Nothing",2]},{name:"Derivative",serialize:(e,i)=>{const t=I(C(i,1))??NaN;if(!isFinite(t))return"";const r=e.serialize(C(i,2));return 1===t?r+"^{\\prime}":2===t?r+"^{\\doubleprime}":r+"^{("+Number(t).toString()+")}"}},{name:"Piecewise",trigger:"cases",kind:"environment",parse:e=>["Piecewise",e.matchTabular("cases")??"Nothing"],serialize:(e,i)=>{if(L(C(i,1))!==m)return"";const t=O(C(i,1));let r="",n="";for(const i of t){r+=n;const t=C(i,1);if(null!==t){r+=e.serialize(t);const n=C(i,2);null!==n&&(r+="&"+e.serialize(n))}n="\\\\"}return"\\begin{cases}"+r+"\\end{cases}"}}];var X;function Y(e,i){if(!e.match("<{>"))return"Nothing";const t=[];let r="",n=null;for(;!e.atEnd&&!e.match("<}>");)if("<{>"===e.peek)t.push(Y(e));else if(e.match("\\textbf")&&e.match("<{>"))t.push(Y(e,{"font-weight":"bold"}));else if(e.match("\\color")&&e.match("<{>")){const i=e.matchColor();i&&e.match("<}>")&&(null!==n&&r?t.push(["Style",r,{dict:n}]):r&&t.push(["String",r]),r="",n={color:i})}else if(e.match("<space>"))r+=" ";else if(e.match("<$>")){const i=e.index,n=e.matchExpression()??"Nothing";e.skipSpace(),e.match("<$>")?t.push(n):(r+="$",e.index=i)}else if(e.match("<$$>")){const i=e.index,n=e.matchExpression()??"Nothing";e.skipSpace(),e.match("<$$>")?t.push(n):(r+="$$",e.index=i)}else r+=e.matchChar()??"";return null!==n&&r?t.push(["Style",r,{dict:n}]):r&&t.push(["String",r]),i?["Style",["String",...t],{dict:i}]:["String",...t]}function ee(e,i){return null===i?"":o(T(i,(i=>{const t=_(i);return null===t?e.serialize(i):"<{>"===t?"{":"<}>"===t?"}":"<$>"===t?"$":"<$$>"===t?"$$":"<space>"===t?" ":t})))}function ie(e,i){return null===i?"":o(T(i,(i=>_(i)??e.serialize(i))))}function te(e){return null===e?"":e.replace(/[{}\[\]\\:\-\$%]/g,(e=>({"{":"\\lbrace ","}":"\\rbrace ","[":"\\lbrack ","]":"\\rbrack ",":":"\\colon ","\\":"\\backslash "}[e]??"\\"+e)))}const re=[{name:"Overscript",trigger:["\\overset"],kind:"infix",precedence:700},{name:"Underscript",trigger:["\\underset"],kind:"infix",precedence:700},{name:"Increment",trigger:["+","+"],kind:"postfix",precedence:880},{name:"Decrement",trigger:["-","-"],kind:"postfix",precedence:880},{name:"PreIncrement",trigger:["+","+"],kind:"prefix",precedence:880},{name:"PreDecrement",trigger:["-","-"],kind:"prefix",precedence:880},{name:"Ring",trigger:["\\circ"],kind:"infix",precedence:265},{name:"Transpose",trigger:["^","T"],kind:"infix"},{name:"ConjugateTranspose",trigger:["^","H"],kind:"infix"},{name:"StringJoin",trigger:["\\lt","\\gt"],kind:"infix",precedence:780},{name:"Starstar",trigger:["\\star","\\star"],kind:"infix",precedence:780},{name:"PartialDerivative",trigger:["\\partial"],kind:"prefix",parse:e=>{let i=!1,t="Nothing",r="Nothing";for(;!i;)e.skipSpace(),e.match("_")?r=e.matchRequiredLatexArgument():e.match("^")?t=e.matchRequiredLatexArgument():i=!0;const n=Z(r);if(n&&(r=[m,...n]),!r||!t)return null;let s=e.matchRequiredLatexArgument()??"Nothing";return"Nothing"!==s&&(s=[s,...e.matchArguments("group")??"Nothing"]),["PartialDerivative",s,r,t]},serialize:(e,i)=>{let t="\\partial";const r=C(i,1),n=C(i,2),s=C(i,3);return null!==n&&"Nothing"!==n&&(L(n)===m?t+="_{"+e.serialize(["Sequence",...O(n)])+"}":t+="_{"+e.serialize(n)+"}"),null!==s&&"Nothing"!==s&&(t+="^{"+e.serialize(s)+"}"),null!==r&&"Nothing"!==r&&(t+=e.serialize(r)),t},precedence:740},{name:"OverBar",trigger:["\\overline"],requiredLatexArg:1},{name:"UnderBar",trigger:["\\underline"],requiredLatexArg:1},{name:"OverVector",trigger:["\\vec"],requiredLatexArg:1},{name:"OverTilde",trigger:["\\tilde"],requiredLatexArg:1},{name:"OverHat",trigger:["\\hat"],requiredLatexArg:1},{name:"OverRightArrow",trigger:["\\overrightarrow"],requiredLatexArg:1},{name:"OverLeftArrow",trigger:["\\overleftarrow"],requiredLatexArg:1},{name:"OverRightDoubleArrow",trigger:["\\Overrightarrow"],requiredLatexArg:1},{name:"OverLeftHarpoon",trigger:["\\overleftharpoon"],requiredLatexArg:1},{name:"OverRightHarpoon",trigger:["\\overrightharpoon"],requiredLatexArg:1},{name:"OverLeftRightArrow",trigger:["\\overleftrightarrow"],requiredLatexArg:1},{name:"OverBrace",trigger:["\\overbrace"],requiredLatexArg:1},{name:"OverLineSegment",trigger:["\\overlinesegment"],requiredLatexArg:1},{name:"OverGroup",trigger:["\\overgroup"],requiredLatexArg:1}];function ne(e){return i=>{let t=!1,r=0;if(i.skipSpace(),i.match("^")){if(i.skipSpace(),i.match("<{>")){i.skipSpace(),i.match("-")&&i.match("1")&&(t=!0);do{i.match("\\doubleprime")&&(r+=2),i.match("\\prime")&&(r+=1),i.match("'")&&(r+=1)}while(!i.match("<}>")&&!i.atEnd)}let e=!1;for(;!e;)i.skipSpace(),i.match("\\doubleprime")?r+=2:i.match("\\prime")||i.match("'")?r+=1:e=!0}let n={"\\arcsin":"Arcsin","\\arccos":"Arccos","\\arctan":"Arctan","\\arctg":"Arctan","\\arcctg":"Arctan","\\arcsec":"Arcsec","\\arccsc":" Arccsc","\\arsinh":"Arsinh","\\arcosh":"Arcosh","\\artanh":"Artanh","\\arcsech":"Arcsech","\\arccsch":"Arcsch","\\ch":"Cosh","\\cos":"Cos","\\cosec":"Csc","\\cosh":"Csch","\\cot":"Cot","\\cotg":"Cot","\\coth":"Coth","\\csc":"Csc","\\ctg":"Cot","\\cth":"Coth","\\sec":"Sec","\\sin":"Sin","\\sinh":"Sinh","\\sh":"Sinh","\\tan":"Tan","\\tanh":"Tanh","\\tg":"Tan","\\th":"Tanh"}[e??""]??e??"";t&&(n=["InverseFunction",n]),r>=1&&(n=["Derivative",r,n]);const s=i.matchArguments("implicit");return null===s?[n,"Nothing"]:[n,...s]}}const se=[{name:"Arcsin",trigger:["\\arcsin"],arguments:"implicit",parse:ne("Arcsin")},{name:"Arccos",trigger:["\\arccos"],arguments:"implicit",parse:ne("Arccos")},{name:"Arctan",trigger:["\\arctan"],arguments:"implicit",parse:ne("Arctan")},{trigger:["\\arctg"],arguments:"implicit",parse:ne("Arctan")},{name:"Arccot",trigger:["\\arcctg"],arguments:"implicit",parse:ne("Arccot")},{name:"Arcsec",trigger:["\\arcsec"],arguments:"implicit",parse:ne("Arcsec")},{name:"Arccsc",trigger:["\\arccsc"],arguments:"implicit",parse:ne("Arccsc")},{name:"Arsinh",trigger:["\\arsinh"],arguments:"implicit",parse:ne("Arsinh")},{name:"Arcosh",trigger:["\\arcosh"],arguments:"implicit",parse:ne("Arcosh")},{name:"Artanh",trigger:["\\artanh"],arguments:"implicit",parse:ne("Artanh")},{name:"Arsech",trigger:["\\arsech"],arguments:"implicit",parse:ne("Arsech")},{name:"Arcsch",trigger:["\\arcsch"],arguments:"implicit",parse:ne("Arcsch")},{trigger:["\\ch"],arguments:"implicit",parse:ne("Cosh")},{name:"Cosec",trigger:["\\cosec"],arguments:"implicit",parse:ne("Cosec")},{name:"Cosh",trigger:["\\cosh"],arguments:"implicit",parse:ne("Cosh")},{name:"Cot",trigger:["\\cot"],arguments:"implicit",parse:ne("Cot")},{trigger:["\\cotg"],arguments:"implicit",parse:ne("Cot")},{name:"Coth",trigger:["\\coth"],arguments:"implicit",parse:ne("Coth")},{name:"Csc",trigger:["\\csc"],arguments:"implicit",parse:ne("Csc")},{trigger:["\\ctg"],arguments:"implicit",parse:ne("Cot")},{trigger:["\\cth"],arguments:"implicit",parse:ne("Cotanh")},{name:"Sec",trigger:["\\sec"],arguments:"implicit",parse:ne("Sec")},{name:"Sinh",trigger:["\\sinh"],arguments:"implicit",parse:ne("Sinh")},{trigger:["\\sh"],arguments:"implicit",parse:ne("Sinh")},{name:"Tan",trigger:["\\tan"],arguments:"implicit",parse:ne("Tan")},{trigger:["\\tg"],arguments:"implicit",parse:ne("Tan")},{name:"Tanh",trigger:["\\tanh"],arguments:"implicit",parse:ne("Tanh")},{trigger:["\\th"],arguments:"implicit",parse:ne("Tanh")},{name:"Cos",trigger:["\\cos"],arguments:"implicit",parse:ne("Cos")},{name:"Sin",trigger:["\\sin"],arguments:"implicit",parse:ne("Sin")}],ae=[{name:"AlgebraicNumber",trigger:"\\bar\\Q"},{name:"ComplexNumber",trigger:["\\C"]},{trigger:"\\mathbb{C}",parse:"ComplexNumber"},{name:"ImaginaryNumber",trigger:["\\imaginaryI\\R"]},{name:"ExtendedComplexNumber",trigger:["\\bar\\C"]},{name:"EmptySet",trigger:["\\emptyset"]},{trigger:["\\varnothing"],parse:"EmptySet"},{name:"Integer",trigger:["\\Z"]},{trigger:"\\mathbb{Z}",parse:"Integer"},{name:"RationalNumber",trigger:["\\Q"]},{name:"RealNumber",trigger:["\\R"]},{name:"ExtendedRealNumber",trigger:["\\bar\\R"]},{name:"TranscendentalNumber",trigger:"\\R-\\bar\\Q"},{trigger:"\\R\\backslash\\bar\\Q",parse:"TranscendentalNumber"},{name:"NegativeNumber",trigger:"\\R^-"},{trigger:"\\R^{-}",parse:"NegativeNumber"},{trigger:"\\R_-",parse:"NegativeNumber"},{trigger:"\\R_{-}",parse:"NegativeNumber"},{trigger:"\\R^{\\lt}",parse:"NegativeNumber"},{name:"PositiveNumber",trigger:"\\R^+"},{trigger:"\\R^{+}",parse:"PositiveNumber"},{trigger:"\\R_+",parse:"PositiveNumber"},{trigger:"\\R_{+}",parse:"PositiveNumber"},{trigger:"\\R^{\\gt}",parse:"PositiveNumber"},{name:"NonPositiveNumber",trigger:"\\R^{0-}"},{trigger:"\\R^{-0}",parse:"NonPositiveNumber"},{trigger:"\\R^{\\leq}",parse:"NonPositiveNumber"},{name:"NegativeInteger",trigger:"\\Z^-"},{trigger:"\\Z^-",parse:"NegativeInteger"},{trigger:"\\Z^{-}",parse:"NegativeInteger"},{trigger:"\\Z_-",parse:"NegativeInteger"},{trigger:"\\Z_{-}",parse:"NegativeInteger"},{trigger:"\\Z^{\\lt}",parse:"NegativeInteger"},{name:"PositiveInteger",trigger:"\\Z^+"},{trigger:"\\Z^{+}",parse:"PositiveInteger"},{trigger:"\\Z_+",parse:"PositiveInteger"},{trigger:"\\Z_{+}",parse:"PositiveInteger"},{trigger:"\\Z^{\\gt}",parse:"PositiveInteger"},{trigger:"\\Z^{\\gt0}",parse:"PositiveInteger"},{trigger:"\\N^+",parse:"PositiveInteger"},{trigger:"\\N^{+}",parse:"PositiveInteger"},{trigger:"\\N^*",parse:"PositiveInteger"},{trigger:"\\N^{*}",parse:"PositiveInteger"},{trigger:"\\N^\\star",parse:"PositiveInteger"},{trigger:"\\N^{\\star}",parse:"PositiveInteger"},{trigger:"\\N_1",parse:"PositiveInteger"},{trigger:"\\N_{1}",parse:"PositiveInteger"},{name:"NonNegativeInteger",trigger:["\\N"]},{trigger:"\\Z^{+0}",parse:"NonNegativeInteger"},{trigger:"\\Z^{\\geq}",parse:"NonNegativeInteger"},{trigger:"\\Z^{\\geq0}",parse:"NonNegativeInteger"},{trigger:"\\Z^{0+}",parse:"NonNegativeInteger"},{trigger:"\\mathbb{N}",parse:"NonNegativeInteger"},{trigger:"\\N_0",parse:"NonNegativeInteger"},{trigger:"\\N_{0}",parse:"NonNegativeInteger"},{name:"CartesianProduct",trigger:["\\times"],kind:"infix",associativity:"right",precedence:390,parse:(e,i,t)=>{if(390<i.minPrec)return null;const r=e.computeEngine;if(!r||!r.box(t).domain.isSubsetOf("Set"))return null;const n=e.index,s=e.matchExpression({...i,minPrec:390});return null===s||!0!==r.box(t).domain.isSubsetOf("Set")?(e.index=n,null):["CartesianProduct",t,s]}},{name:"Complement",trigger:["^","\\complement"],kind:"infix"},{name:"Intersection",trigger:["\\cap"],kind:"infix",precedence:350},{name:"Interval",serialize:oe},{name:"Multiple",serialize:oe},{name:"Union",trigger:["\\cup"],kind:"infix",precedence:350},{name:"Range",serialize:oe},{name:"SetMinus",trigger:["\\setminus"],kind:"infix",precedence:650},{name:"SymmetricDifference",trigger:["\\triangle"],kind:"infix",precedence:260},{trigger:["\\ni"],kind:"infix",associativity:"right",precedence:160,parse:(e,i,t)=>{const r=e.matchExpression(i);return null===r?null:["Element",r,t]}},{name:"Element",trigger:["\\in"],kind:"infix",precedence:240},{name:"NotElement",trigger:["\\notin"],kind:"infix",precedence:240},{name:"NotSubset",trigger:["\\nsubset"],kind:"infix",associativity:"right",precedence:240},{name:"NotSuperset",trigger:["\\nsupset"],kind:"infix",associativity:"right",precedence:240},{name:"NotSubsetNotEqual",trigger:["\\nsubseteq"],kind:"infix",associativity:"right",precedence:240},{name:"NotSupersetNotEqual",trigger:["\\nsupseteq"],kind:"infix",associativity:"right",precedence:240},{name:"SquareSubset",trigger:["\\sqsubset"],kind:"infix",associativity:"right",precedence:265},{name:"SquareSubsetEqual",trigger:["\\sqsubseteq"],kind:"infix",associativity:"right",precedence:265},{name:"SquareSuperset",trigger:["\\sqsupset"],kind:"infix",associativity:"right",precedence:265},{name:"SquareSupersetEqual",trigger:["\\sqsupseteq"],kind:"infix",associativity:"right",precedence:265},{name:"Subset",trigger:["\\subset"],kind:"infix",associativity:"right",precedence:240},{trigger:["\\subsetneq"],kind:"infix",associativity:"right",precedence:240,parse:"Subset"},{trigger:["\\varsubsetneqq"],kind:"infix",associativity:"right",precedence:240,parse:"Subset"},{name:"SubsetEqual",trigger:["\\subseteq"],kind:"infix",precedence:240},{name:"Superset",trigger:["\\supset"],kind:"infix",associativity:"right",precedence:240},{trigger:["\\supsetneq"],kind:"infix",associativity:"right",precedence:240,parse:"Superset"},{trigger:["\\varsupsetneq"],kind:"infix",associativity:"right",precedence:240,parse:"Superset"},{name:"SupersetEqual",trigger:["\\supseteq"],kind:"infix",associativity:"right",precedence:240}];function oe(e,i){if(null===i)return"";const t=L(i);return null===t?"":"Set"===t?0===$(i)?"\\emptyset":2===$(i)&&"Condition"===L(C(i,2))?o(["\\left\\lbrace",e.serialize(C(i,1)),"\\middle\\mid",e.serialize(C(i,2)),"\\right\\rbrace"]):o(["\\left\\lbrace",...O(i).map((i=>e.serialize(i)+" ,")),"\\right\\rbrace"]):(e.numericSetStyle(i,e.level),"")}const le=[{name:"Integral",trigger:["\\int"],parse:function(e){let i="Nothing",t="Nothing",r=!1;for(;!r;)e.skipSpace(),e.match("_")?t=e.matchRequiredLatexArgument():e.match("^")?i=e.matchRequiredLatexArgument():r=!0;return["Integral",e.matchExpression({tokens:["d"]})??"",i??"Nothing",t??"Nothing"]},serialize:function(e,i){return""}}],ce=[["Alpha","\\alpha",945],["Beta","\\beta",946],["Delta","\\delta",948],["Epsilon","\\epsilon",949],["EpsilonSymbol","\\varepsilon",1013],["Zeta","\\zeta",950],["Eta","\\eta",951],["Theta","\\theta",952],["ThetaSymbol","\\vartheta",977],["Iota","\\iota",953],["Kappa","\\kappa",954],["KappaSymbol","\\varkappa",1008],["Lambda","\\lambda",955],["Mu","\\mu",956],["Nu","\\nu",957],["Xi","\\xi",958],["Omicron","\\omicron",959],["PiSymbol","\\varpi",982],["Rho","\\rho",961],["RhoSymbol","\\varrho",1009],["Sigma","\\sigma",963],["FinalSigma","\\varsigma",962],["Tau","\\tau",964],["Phi","\\phi",981],["PhiLetter","\\varphi",966],["Upsilon","\\upsilon",965],["Chi","\\chi",967],["Psi","\\psi",968],["Omega","\\omega",969],["CapitalAlpha","\\Alpha",913],["CapitalBeta","\\Beta",914],["CapitalGamma","\\Gamma",915],["CapitalDelta","\\Delta",916],["CapitalEpsilon","\\Epsilon",917],["CapitalZeta","\\Zeta",918],["CapitalEta","\\Eta",919],["CapitalTheta","\\Theta",920],["CapitaIota","\\Iota",921],["CapitalKappa","\\Kappa",922],["CapitalLambda","\\Lambda",923],["CapitalMu","\\Mu",924],["CapitalNu","\\Nu",925],["CapitalXi","\\Xi",926],["CapitalOmicron","\\Omicron",927],["CapitalPi","\\Pi",928],["CapitalRho","\\Rho",929],["CapitalSigma","\\Sigma",931],["CapitalTau","\\Tau",932],["CapitalPhi","\\Phi",934],["CapitalUpsilon","\\Upsilon",933],["CapitalChi","\\Chi",935],["CapitalPsi","\\Psi",936],["CapitalOmega","\\Omega",937],["Digamma","\\digamma",989],["Alef","\\aleph",8501],["Bet","\\beth",8502],["Gimel","\\gimel",8503],["Dalet","\\daleth",8504],["TurnedCapitalF","\\Finv",8498],["TurnedCapitalG","\\Game",8513],["Weierstrass","\\wp",8472],["Eth","\\eth",240],["InvertedOhm","\\mho",8487],["BlackClubSuit","\\clubsuit",9827],["WhiteHeartSuit","\\heartsuit",9825],["BlackSpadeSuit","\\spadesuit",9824],["WhiteDiamondSuit","\\diamondsuit",9826],["Sharp","\\sharp",9839],["Flat","\\flat",9837],["Natural","\\natural",9838]],ge=[...ce.map((([e,i,t])=>({name:e,trigger:[i],parse:e}))),...ce.map((([e,i,t])=>({trigger:[String.fromCodePoint(t)],parse:e})))],ue={"(":"(",")":")","[":"\\lbrack","]":"\\rbrack","{":"\\lbrace","}":"\\rbrace","<":"\\langle",">":"\\rangle","|":"\\vert","||":"\\Vert","\\lceil":"\\lceil","\\lfloor":"\\lfloor","\\rceil":"\\rceil","\\rfloor":"\\rfloor"};function pe(e){return Array.isArray(e)?e.length:1}function he(e,i){if(!function(e,i){const t=e.name??e.trigger??e.openDelimiter;if(void 0!==e.serialize&&!e.name)return i({severity:"warning",message:["invalid-dictionary-entry",t,"Unexpected serialize property without a name property"]}),!1;if(g(e)){if(e.trigger)return i({severity:"warning",message:["invalid-dictionary-entry",t,`Unexpected 'trigger' "${e.trigger}". 'matchfix' operators use a 'openDelimiter' and 'closeDelimiter' instead of a trigger. `]}),!1;if(!e.openDelimiter||!e.closeDelimiter)return i({severity:"warning",message:["invalid-dictionary-entry",t,"Expected `openDelimiter` and a `closeDelimiter` for matchfix operator"]}),!1;if(typeof e.openDelimiter!=typeof e.closeDelimiter)return i({severity:"warning",message:["invalid-dictionary-entry",t,"Expected `openDelimiter` and `closeDelimiter` to both be strings or array of LatexToken"]}),!1}if(u(e)||h(e)||p(e)){if(Array.isArray(e.trigger)&&("_"===e.trigger[0]||"^"===e.trigger[0])||"string"==typeof e.trigger&&(e.trigger.startsWith("^")||e.trigger.startsWith("_"))){if(void 0!==e.precedence||void 0!==e.associativity)return i({severity:"warning",message:["invalid-dictionary-entry",t,'Unexpected "precedence" or "associativity" for superscript/subscript operator']}),!1}else if(void 0===e.precedence)return i({severity:"warning",message:["invalid-dictionary-entry",t,`Expected a "precedence" for ${e.kind} operator`]}),!1}else if(void 0!==e.associativity)return i({severity:"warning",message:["invalid-dictionary-entry",t,'Unexpected "associativity" operator']}),!1;return c(e)||void 0===e.optionalLatexArg&&void 0===e.requiredLatexArg?g(e)||e.trigger||e.name?void 0!==e.parse||void 0!==e.name||(i({severity:"warning",message:["invalid-dictionary-entry",t,"Expected a 'parse' or 'name'"]}),!1):(i({severity:"warning",message:["invalid-dictionary-entry",t,"Expected at least a 'trigger' or a 'name'"]}),!1):(i({severity:"warning",message:["invalid-dictionary-entry",t,'Unexpected "optionalLatexArg" or "requiredLatexArg" for non-symbol']}),!1)}(e,i))return[null,null];const t={name:e.name,kind:"kind"in e?e.kind:"symbol"};if("matchfix"===t.kind&&g(e)){if(t.openDelimiter=e.openDelimiter,t.closeDelimiter=e.closeDelimiter,"function"==typeof e.serialize)t.serialize=e.serialize;else{const e="string"==typeof t.openDelimiter?ue[t.openDelimiter]:l(t.openDelimiter),i="string"==typeof t.closeDelimiter?ue[t.closeDelimiter]:l(t.closeDelimiter);t.serialize=(t,r)=>o([e,t.serialize(r),i])}if("function"==typeof e.parse)t.parse=e.parse;else{const i=e.parse??e.name;t.parse=(e,t)=>[i,t]}return[null,t]}if("environment"===t.kind&&function(e){return"kind"in e&&"environment"===e.kind}(e)){const i=e.trigger;return t.serialize=(e,t)=>`\\begin{${i}${e.serialize(C(t,1))}\\end{${i}`,t.parse=e.parse??(()=>null),[i,t]}const r="string"==typeof e.trigger?a(e.trigger,[]):e.trigger,n=r?l(r):"";if(e.trigger,"symbol"===t.kind&&c(e)&&(t.arguments=e.arguments??"",t.precedence=e.precedence??0,t.optionalLatexArg=e.optionalLatexArg??0,t.requiredLatexArg=e.requiredLatexArg??0),"infix"!==t.kind&&"prefix"!==t.kind&&"postfix"!==t.kind||!(u(e)||p(e)||h(e))||(!r||"^"!==r[0]&&"_"!==r[0]?t.precedence=e.precedence??0:t.precedence=720),"infix"===t.kind&&u(e))if(t.associativity=e.associativity??"non","function"==typeof e.parse)t.parse=e.parse;else if(!r||"^"!==r[0]&&"_"!==r[0]){const i=e.parse??e.name,r=t.precedence,n=t.associativity;t.parse=(e,t,s)=>{if(r<t.minPrec)return null;const a=e.matchExpression({...t,minPrec:r});return"string"!=typeof i?[i,s,a??"Missing"]:j(i,s,a??"Missing",n)}}else{const i=e.parse??e.name;t.parse=(e,t,r)=>[i,C(r,1)??"Missing",C(r,2)??"Missing"]}else if("function"==typeof e.parse)t.parse=e.parse;else if(void 0!==e.parse)t.parse=()=>e.parse;else if(void 0===e.parse&&void 0!==e.name)if("postfix"===t.kind)t.parse=(i,t)=>t?[e.name,t]:null;else if("prefix"===t.kind){const i=t.precedence,r=e.name;t.parse=(e,t)=>{if(i<t.minPrec)return null;const n=e.matchExpression({...t,minPrec:i});return null===n?null:[r,n]}}else t.parse=()=>e.name;return"function"==typeof e.serialize||"string"==typeof e.serialize?t.serialize=e.serialize:r&&("postfix"===t.kind?t.serialize="#1"+n:"prefix"===t.kind?t.serialize=n+"#1":"infix"===t.kind?t.serialize="#1"+n+"#2":"symbol"===t.kind?t.serialize=n:t.serialize=""),[r??null,t]}const me={algebra:[{name:"To",trigger:["\\to"],kind:"infix",precedence:270}],arithmetic:H,calculus:le,core:Q,logic:[{name:"True",trigger:["\\mathrm","<{>","T","r","u","e","<}>"],serialize:"\\mathrm{True}"},{name:"False",trigger:["\\mathrm","<{>","F","a","l","s","e","<}>"],serialize:"\\mathrm{False}"},{name:"Maybe",trigger:["\\mathrm","<{>","M","a","y","b","e","<}>"],serialize:"\\mathrm{Maybe}"}],relop:[{trigger:["!","<"],kind:"infix",associativity:"right",precedence:246,parse:"NotLess"},{name:"NotLess",trigger:["\\nless"],kind:"infix",associativity:"right",precedence:246},{trigger:["<"],kind:"infix",associativity:"right",precedence:245,parse:"Less"},{name:"Less",trigger:["\\lt"],kind:"infix",associativity:"right",precedence:245},{trigger:["<","="],kind:"infix",associativity:"right",precedence:241,parse:"LessEqual"},{name:"LessEqual",trigger:["\\le"],kind:"infix",associativity:"right",precedence:241},{trigger:["\\leq"],kind:"infix",associativity:"right",precedence:241,parse:"Equal"},{trigger:["\\leqslant"],kind:"infix",associativity:"right",precedence:265,parse:"LessEqual"},{name:"LessNotEqual",trigger:["\\lneqq"],kind:"infix",associativity:"right",precedence:260},{name:"NotLessNotEqual",trigger:["\\nleqq"],kind:"infix",associativity:"right",precedence:260},{name:"LessOverEqual",trigger:["\\leqq"],kind:"infix",associativity:"right",precedence:265},{name:"GreaterOverEqual",trigger:["\\geqq"],kind:"infix",associativity:"right",precedence:265,parse:"GreaterEqual"},{name:"Equal",trigger:["="],kind:"infix",associativity:"right",precedence:260},{trigger:["*","="],kind:"infix",associativity:"right",precedence:260,parse:"StarEqual"},{name:"StarEqual",trigger:["\\star","="],kind:"infix",associativity:"right",precedence:260},{name:"PlusEqual",trigger:["+","="],kind:"infix",associativity:"right",precedence:260},{name:"MinusEqual",trigger:["-","="],kind:"infix",associativity:"right",precedence:260},{name:"SlashEqual",trigger:["/","="],kind:"infix",associativity:"right",precedence:260},{name:"EqualEqual",trigger:["=","="],kind:"infix",associativity:"right",precedence:260},{name:"EqualEqualEqual",trigger:["=","=","="],kind:"infix",associativity:"right",precedence:265},{name:"TildeFullEqual",trigger:["\\cong"],kind:"infix",associativity:"right",precedence:260},{name:"NotTildeFullEqual",trigger:["\\ncong"],kind:"infix",associativity:"right",precedence:260},{trigger:[":","="],kind:"infix",associativity:"right",precedence:260,parse:"Assign"},{name:"Assign",trigger:["\\coloneq"],kind:"infix",associativity:"right",precedence:260},{name:"Approx",trigger:["\\approx"],kind:"infix",associativity:"right",precedence:247},{name:"NotApprox",trigger:["\\approx"],kind:"infix",associativity:"right",precedence:247},{name:"ApproxEqual",trigger:["\\approxeq"],kind:"infix",associativity:"right",precedence:260},{name:"NotApproxEqual",trigger:["!","\\approxeq"],kind:"infix",associativity:"right",precedence:250},{name:"NotEqual",trigger:["\\ne"],kind:"infix",associativity:"right",precedence:255},{name:"Unequal",trigger:["!","="],kind:"infix",associativity:"right",precedence:260},{name:"GreaterEqual",trigger:["\\ge"],kind:"infix",associativity:"right",precedence:242},{trigger:["\\geq"],kind:"infix",associativity:"right",precedence:242,parse:"GreaterEqual"},{trigger:[">","="],kind:"infix",associativity:"right",precedence:243,parse:"GreaterEqual"},{trigger:["\\geqslant"],kind:"infix",associativity:"right",precedence:265,parse:"GreaterEqual"},{name:"GreaterNotEqual",trigger:["\\gneqq"],kind:"infix",associativity:"right",precedence:260},{name:"NotGreaterNotEqual",trigger:["\\ngeqq"],kind:"infix",associativity:"right",precedence:260},{trigger:[">"],kind:"infix",associativity:"right",precedence:245,parse:"Greater"},{name:"Greater",trigger:["\\gt"],kind:"infix",associativity:"right",precedence:245},{name:"NotGreater",trigger:["\\ngtr"],kind:"infix",associativity:"right",precedence:244},{trigger:["!",">"],kind:"infix",associativity:"right",precedence:244,parse:"NotGreater"},{name:"RingEqual",trigger:["\\circeq"],kind:"infix",associativity:"right",precedence:260},{name:"TriangleEqual",trigger:["\\triangleq"],kind:"infix",associativity:"right",precedence:260},{name:"DotEqual",trigger:["\\doteq"],kind:"infix",associativity:"right",precedence:265},{name:"DotEqualDot",trigger:["\\doteqdot"],kind:"infix",associativity:"right",precedence:265},{name:"FallingDotEqual",trigger:["\\fallingdotseq"],kind:"infix",associativity:"right",precedence:265},{name:"RisingDotEqual",trigger:["\\fallingdotseq"],kind:"infix",associativity:"right",precedence:265},{name:"QuestionEqual",trigger:["\\questeq"],kind:"infix",associativity:"right",precedence:260},{name:"Equivalent",trigger:["\\equiv"],kind:"infix",associativity:"right",precedence:260},{name:"MuchLess",trigger:["\\ll"],kind:"infix",associativity:"right",precedence:260},{name:"MuchGreater",trigger:["\\gg"],kind:"infix",associativity:"right",precedence:260},{name:"Precedes",trigger:["\\prec"],kind:"infix",associativity:"right",precedence:260},{name:"Succeeds",trigger:["\\succ"],kind:"infix",associativity:"right",precedence:260},{name:"PrecedesEqual",trigger:["\\preccurlyeq"],kind:"infix",associativity:"right",precedence:260},{name:"SucceedsEqual",trigger:["\\curlyeqprec"],kind:"infix",associativity:"right",precedence:260},{name:"NotPrecedes",trigger:["\\nprec"],kind:"infix",associativity:"right",precedence:260},{name:"NotSucceeds",trigger:["\\nsucc"],kind:"infix",associativity:"right",precedence:260},{name:"Between",trigger:["\\between"],kind:"infix",associativity:"right",precedence:265}],other:re,physics:[{name:"mu-0",trigger:"\\mu_0"}],sets:ae,symbols:ge,trigonometry:se},fe={"(":["\\lparen","("],")":["\\rparen",")"],"[":["\\lbrack"],"]":["\\rbrack"],"<":["<","\\langle"],">":[">","\\rangle"],"{":["\\{","\\lbrace"],"}":["\\}","\\rbrace"],":":[":","\\colon"],"|":["|","\\|","\\lvert","\\rvert"],"||":["||","\\Vert","\\lVert","\\rVert"],"\\lfloor":["\\lfloor"],"\\rfloor":["\\rfloor"],"\\lceil":["\\lceil"],"\\rceil":["\\rceil"],"\\ulcorner":["\\ulcorner"],"\\urcorner":["\\urcorner"],"\\llcorner":["\\llcorner"],"\\lrcorner":["\\lrcorner"],"\\lgroup":["\\lgroup"],"\\rgroup":["\\rgroup"],"\\lmoustache":["\\lmoustache"],"\\rmoustache":["\\rmoustache"]},de={":":[":","\\colon"],"|":["|","\\|","\\mid","\\mvert"]},xe={"\\left":"\\right","\\bigl":"\\bigr","\\Bigl":"\\Bigr","\\biggl":"\\biggr","\\Biggl":"\\Biggr","\\big":"\\big","\\Big":"\\Big","\\bigg":"\\bigg","\\Bigg":"\\Bigg"},ye=["\\middle","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],ke={"(":")","[":"]","\\{":"\\}","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache"},ve={precision:6,positiveInfinity:"\\infty",negativeInfinity:"-\\infty",notANumber:"\\operatorname{NaN}",decimalMarker:".",groupSeparator:"\\,",exponentProduct:"\\cdot",beginExponentMarker:"10^{",endExponentMarker:"}",notation:"auto",truncationMarker:"\\ldots",beginRepeatingDigits:"\\overline{",endRepeatingDigits:"}",imaginaryNumber:"\\imaginaryI",avoidExponentsInRange:[-7,20]},be={applyInvisibleOperator:"auto",skipSpace:!0,parseArgumentsOfUnknownLatexCommands:!0,parseNumbers:!0,parseUnknownToken:e=>["\\displaystyle","\\!","\\:","\\enskip","\\quad","\\,","\\;","\\enspace","\\qquad","\\selectfont","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"].includes(e)?"skip":/^[fg]$/.test(e)?"function":/^[a-zA-Z]$/.test(e)?"symbol":"error",preserveLatex:!0};class Se{constructor(e,i,t,r,n){this.index=0,this._lastPeek="",this._peekCounter=0,this.options={...ve,...be,...i},this.engine=r,this._tokens=e,this.onError=n,this._dictionary=t}updateOptions(e){for(const[i,t]of Object.entries(e))this.options[i]=t}clone(e,i){return new Se(this._tokens.slice(e,i),this.options,this._dictionary,this.engine,this.onError)}get atEnd(){return this.index>=this._tokens.length}get peek(){if(this._tokens[this.index]===this._lastPeek?this._peekCounter+=1:this._peekCounter=0,this._peekCounter>=1024)throw Error("Infinite loop");return this._lastPeek=this._tokens[this.index],this._tokens[this.index]}atTerminator(e){const i=this.index;return!!this.atEnd||!!e&&(!(!e.condition||!e.condition(this))||!!(e.tokens&&e.tokens.length>0&&this.matchAll(e.tokens))&&(this.index=i,!0))}latex(e,i){return l(this._tokens.slice(e,i))}latexAhead(e){return l(this._tokens.slice(this.index,this.index+e))}latexBefore(){return this.latex(0,this.index)}latexAfter(){return this.latex(this.index)}lookAhead(){let e=Math.min(this._dictionary.lookahead,this._tokens.length-this.index);const i=[];for(;e>0;)i[e]=this.latexAhead(e--);return i}peekDefinitions(e){let i;i="operator"===e?this.lookAhead().map(((e,i)=>this._dictionary.infix[i]?.get(e)??this._dictionary.postfix[i]?.get(e)??this._dictionary.prefix[i]?.get(e))):this.lookAhead().map(((i,t)=>this._dictionary[e][t]?.get(i)));const t=[];for(let e=i.length;e>0;e--)if(void 0!==i[e])for(const r of i[e])t.push([r,e]);return 0===t.length?null:t}next(){return this._tokens[this.index++]}skipSpace(){if(!this.atEnd&&"<{>"===this.peek&&"<}>"===this._tokens[this.index+1])return this.index+=2,this.skipSpace(),!0;let e=!1;for(;!this.atEnd&&"skip"===this.options.parseUnknownToken?.(this.peek,this);)this.index+=1,this.skipSpace(),e=!0;if(!this.options.skipSpace)return!1;for(;this.match("<space>");)e=!0;return e&&this.skipSpace(),e}matchChar(){const e=this.index;let i=0;for(;this.match("^");)i+=1;if(i>=2){let e="",t=0;for(;t!=i;){const i=this.matchAny(["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]);if(!i)break;e+=i,t+=1}if(e.length===i)return String.fromCodePoint(Number.parseInt(e,16))}else{if(this.match("\\char")){let e=Math.floor(this.matchLatexNumber()??NaN);return(!Number.isFinite(e)||e<0||e>1114111)&&(e=10067),String.fromCodePoint(e)}if(this.match("\\unicode"))if("<{>"===this.peek){const e=this.matchLatexNumber();if(this.match("<}>")&&null!==e&&e>=0&&e<=1114111)return String.fromCodePoint(e)}else{const e=this.matchLatexNumber();if(null!==e&&e>=0&&e<=1114111)return String.fromCodePoint(e)}}return this.index=e,this.next()}matchColor(e=!1){let i="";for(;!this.atEnd&&"}"!==this.peek;)i+=this.next();return i}matchLatexDimension(){return null}match(e){return this._tokens[this.index]===e&&(this.index++,!0)}matchAll(e){"string"==typeof e&&(e=[e]);let i=!0,t=0;do{i=this._tokens[this.index+t]===e[t++]}while(i&&t<e.length);return i&&(this.index+=t),i}matchAny(e){return e.includes(this._tokens[this.index])?this._tokens[this.index++]:""}matchWhile(e){const i=[];for(;e.includes(this._tokens[this.index]);)i.push(this._tokens[this.index++]);return i}matchSign(){let e=!1,i=!1;for(;!i;)this.skipSpace()?i=!1:this.matchAny(["-","\u2212"])?(e=!e,i=!1):i=!this.matchAny(["+","\ufe62"]);return e?"-":"+"}matchDecimalDigits(){let e="",i=!1;for(;!i;)if(e+=this.matchWhile(["0","1","2","3","4","5","6","7","8","9"]).join(""),i=!0,this.options.groupSeparator){const e=this.index;this.skipSpace(),this.match(this.options.groupSeparator)&&(this.skipSpace(),/[0-9]/.test(this.peek)?i=!1:this.index=e)}return e}matchSignedInteger(){const e=this.index,i=this.matchSign(),t=this.matchDecimalDigits();return t?("-"===i?"-":"")+t:(this.index=e,"")}matchExponent(){const e=this.index;let i="";if(this.matchAny(["e","E"])){const e=this.matchSignedInteger();e&&(i="e"+e)}if(i)return i;if(this.match("\\times")&&(this.skipSpace(),this.match("1")&&this.match("0")&&this.match("^"))){if(/[0-9]/.test(this.peek))return"e"+this.next();if(this.match("<{>")){this.skipSpace();const e=this.matchSignedInteger();if(this.skipSpace(),this.match("<}>")&&e)return"e"+e}}return this.index=e,""}matchNumber(){if(!this.options.parseNumbers)return"";const e=this.index;this.skipSpace(),this.match("+");let i=!1;if(this.match(this.options.decimalMarker)){const t=this.index;if(!this.matchAny(["0","1","2","3","4","5","6","7","8","9"]))return this.index=e,"";this.index=t,i=!0}let t=this.matchDecimalDigits();return t?(!i&&this.match(this.options.decimalMarker??"")&&(t+="."+(this.matchDecimalDigits()??"0")),(i?"0.":"")+t+this.matchExponent()):(this.index=e,"")}matchLatexNumber(e=!0){let i=!1,t=this.peek;for(;"<space>"===t||"+"===t||"-"===t;)"-"===t&&(i=!i),this.next(),t=this.peek;let r=10,n=["0","1","2","3","4","5","6","7","8","9"];if(this.match("'"))r=8,n=["0","1","2","3","4","5","6","7"],e=!0;else if(this.match('"')||this.match("x"))r=16,n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],e=!0;else if(this.match("`"))return t=this.next(),t?t.startsWith("\\")&&2===t.length?(i?-1:1)*(t.codePointAt(1)??0):(i?-1:1)*(t.codePointAt(0)??0):null;let s="";for(;n.includes(this.peek);)s+=this.next();if(!e&&this.match("."))for(s+=".";n.includes(this.peek);)s+=this.next();const a=e?Number.parseInt(s,r):Number.parseFloat(s);return Number.isNaN(a)?null:i?-a:a}matchPrefixOperator(e){e||(e={minPrec:0}),e.minPrec||(e={...e,minPrec:0});const i=this.peekDefinitions("prefix");if(null===i)return null;const t=this.index;for(const[r,n]of i){this.index=t+n;const i=r.parse(this,e);if(i)return i}return this.index=t,null}matchInfixOperator(e,i){i||(i={minPrec:0}),i.minPrec||(i={...i,minPrec:0});const t=this.peekDefinitions("infix");if(null===t)return null;const r=this.index;for(const[n,s]of t)if(n.precedence>=i.minPrec){this.index=r+s;const t=n.parse(this,i,e);if(t)return t}return this.index=r,null}matchArguments(e){if(!e)return null;const i=this.index;let t=null;const r=this.matchEnclosure();if("group"===e&&"Delimiter"===L(r))t=O(r);else if("implicit"===e)if("Delimiter"===L(r))t=O(r);else if(null!==r)t=[r];else{const e=this.matchPrimary();null!==e&&(t=[e])}else this.index=i;return t}matchOpenDelimiter(e,i){const t=this.index,r=xe[this.peek];r&&this.next();const n=fe[e]??[e],s=r?[r]:[];return n.includes("||")&&this.matchAll(["|","|"])?(s.push("|"),s.push("|"),s):n.includes(this.peek)?(ke[e]===i?s.push(ke[this.peek]):s.push(i),this.next(),s):(this.index=t,null)}matchMiddleDelimiter(e){const i=de[e]??[e];if(ye.includes(this.peek)){const e=this.index;return this.next(),i.includes(this.peek)?(this.next(),!0):(this.index=e,!1)}return!!i.include(this.peek)&&(this.next(),!0)}matchEnclosure(){const e=this._dictionary.matchfix;if(0===e.length)return null;const i=this.index;for(const t of e){if(this.index=i,Array.isArray(t.openDelimiter)){if(!this.matchAll(t.openDelimiter))continue;const e=this.matchExpression({tokens:t.closeDelimiter,minPrec:0});if(this.skipSpace(),!this.matchAll(t.closeDelimiter))continue;if("function"==typeof t.parse){const i=t.parse(this,e??"Nothing");if(null===i)continue;return i}return[t.name,e??"Nothing"]}const e=this.matchOpenDelimiter(t.openDelimiter,t.closeDelimiter);if(null===e)continue;const r=this.matchExpression({minPrec:0,tokens:e});if(r&&this.matchAll(e)){if("function"==typeof t.parse){const e=t.parse(this,r??"Nothing");if(null===e)continue;return e}return[t.name,r]}}return this.index=i,null}matchSymbol(){const e=this.index,i=this.peekDefinitions("symbol");if(i)for(const[t,r]of i){let i=null;if(this.index=e+r,"function"!=typeof t.parse)return t.name;if(i=t.parse(this),i)return i}this.index=e;const t=this.options.parseUnknownToken?.(this.peek,this);if("function"===t){const e=this.next(),i=this.matchEnclosure();return null===i?e:"Delimiter"!==L(i)?null:[e,...O(i)]}return"symbol"===t?this.next():this.matchUnknownLatexCommand()}matchOptionalLatexArgument(){const e=this.index;if(this.skipSpace(),this.match("[")){const e=this.matchExpression();if(this.skipSpace(),this.match("]"))return e}return this.index=e,null}matchRequiredLatexArgument(){const e=this.index;if(this.skipSpace(),this.match("<{>")){const i=this.matchExpression({tokens:["<}>"]});return this.skipSpace(),this.match("<}>")?i:(this.index=e,null)}if(/^[0-9]$/.test(this.peek))return parseInt(this.next());if(/^[^\\#]$/.test(this.peek))return this.next();const i=this.matchSymbol();return i||(this.index=e,null)}matchSupsub(e){if(null===e)return null;const i=this.index;this.skipSpace();const t=[],r=[];for(;"_"===this.peek||"^"===this.peek;){if(this.match("_")){let e=this.matchRequiredLatexArgument();!e&&this.match("<{>")&&(e=this.matchString({tokens:["<}>"]}),e&&this.match("<}>")),r.push(e??"Nothing")}else this.match("^")&&t.push(this.matchRequiredLatexArgument()??"Nothing");this.skipSpace()}if(0===t.length&&0===r.length)return this.index=i,e;let n=e;if(r.length>0){const e=this._dictionary.infix[1]?.get("_");if(e){const i=["Subscript",n,1===r.length?r[0]:["Sequence",...r]];for(const t of e)if(n="function"==typeof t.parse?t.parse(this,{minPrec:0},i):i,n)break}}if(t.length>0){const e=this._dictionary.infix[1]?.get("^");if(e){const i=["Superscript",n,1===t.length?t[0]:["Sequence",...t]];for(const t of e)if(n="function"==typeof t.parse?t.parse(this,{minPrec:0},i):i,n)break}}return null===n&&(this.index=i),n}matchPostfix(e){if(null===e)return null;const i=this.peekDefinitions("postfix");if(null===i)return null;const t=this.index;for(const[r,n]of i){this.index=t+n;const i=r.parse(this,e);if(null!==i)return i}return this.index=t,null}matchString(e){e.minPrec||(e={...e,minPrec:0});let i="",t=this.atEnd;for(;!t;){const r=this.peek;"<space>"===r?i+=" ":"\\"===r[0]?(this.onError([{severity:"warning",message:"unexpected-command"}]),i+=this.next()):/^<(\$|\$\$)>$/.test(r)?t=!0:i+=this.next(),t=t||this.atTerminator(e)}return i}matchEnvironmentName(e,i){if(!this.match(e))return!1;const t=this.index;if(this.match("<{>")){const e=this.matchString({tokens:["<}>"]});if(this.match("<}>")&&e===i)return!0}return this.index=t,!1}matchTabular(e){const i=["List"],t={minPrec:0,tokens:["\\end","<{>",...e.split(""),"<}>"]};let r=["List"],n=null;for(;!this.atTerminator(t);)this.match("&")?(r.push(n??"Nothing"),n=null):(this.match("\\\\")||this.match("\\cr"))&&(this.skipSpace(),this.matchOptionalLatexArgument(),null!==n&&r.push(n),i.push(r),r=["List"],n=null);return r.length>1&&i.push(r),i}matchEnvironment(){if(!this.match("\\begin"))return null;const e=this.index;if(this.match("<{>")){const e=this.matchString({tokens:["<}>"]});if(this.match("<}>")){const i=this._dictionary.environment.get(e);if(i)return i.parse(this,[],[]);const t=this.matchTabular(e);if(null!==t)return t}}return this.index=e,null}applyInvisibleOperator(e,i){if(null===i||this.atTerminator(e))return null;if(null===this.options.applyInvisibleOperator)return null;const t=this.index,r=this.matchExpression({...e,minPrec:390});if(null===r)return this.index=t,null;if("function"==typeof this.options.applyInvisibleOperator)return this.options.applyInvisibleOperator(this,i,r);const n=this.engine.box(r),s=M(i);if(s&&this.engine.getFunctionDefinition(s)){let e=[];return e="Delimiter"===n.head?"Sequence"===n.op1.head?[...n.op1.ops]:[n.op1]:[n],[s,...e.map((e=>e.json))]}const a=this.engine.box(i);if(a.isLiteral&&a.isInteger&&n.isLiteral){const[e,t]=n.rationalValue;if(null!==e&&null!==t)return["Add",i,r]}return a.isNumber&&n.isNumber?j("Multiply",i,r):(this.index=t,null)}matchUnknownLatexCommand(){const e=this.peek;if(!e||"\\"!==e[0])return null;this.next();const i=[];if("\\operatorname"===e){if(this.match("<{>")){for(;!this.atEnd&&"<}>"!==this.peek;)i.push(this.next());this.match("<}>")}else i.push(this.next());return 0===i.length?["Error","Nothing",{str:"syntax-error"},["LatexForm",{str:e}]]:["Error","Nothing",{str:"unknown-command"},["LatexForm",{str:`${e}{${l(i)}}`}]]}for(;this.match("[");){i.push("[");let e=0;for(;!this.atEnd&&0===e&&"]"!==this.peek;)"["===this.peek&&(e+=1),"]"===this.peek&&(e-=1),i.push(this.next());this.match("]")&&i.push("]")}for(;this.match("<{>");){i.push("<{>");let e=0;for(;!this.atEnd&&0===e&&"<}>"!==this.peek;)"<{>"===this.peek&&(e+=1),"<}>"===this.peek&&(e-=1),i.push(this.next());this.match("<}>")&&i.push("<}>")}return["Error","Nothing",{str:"unknown-command"},["LatexForm",{str:`${e}${l(i)}`}]]}matchPrimary(){let e=null;const i=this.index,t=this.matchNumber();if(t&&(e={num:t}),null===e&&(e=this.matchEnclosure()),null===e&&(e=this.matchEnvironment()),null===e&&(e=this.matchSymbol()),null!==e){e=this.decorate(e,i);let t=null,r=this.index;do{if(t=this.matchPostfix(e),e=t??e,this.index===r&&null!==t)break;r=this.index}while(null!==t)}return null!==e&&(e=this.matchSupsub(e)),this.decorate(e,i)}matchExpression(e){const i=this.index;e||(e={minPrec:0}),e.minPrec||(e={...e,minPrec:0}),this.skipSpace();let t=this.matchPrefixOperator({...e,minPrec:0});if(null===t&&(t=this.matchPrimary()),t){let i=!1;for(;!this.atTerminator(e)&&!i;){this.skipSpace();let r=this.matchInfixOperator(t,e);null===r&&null===this.peekDefinitions("operator")&&(r=this.applyInvisibleOperator(e,t)),null!==r?t=r:i=!0}}return this.decorate(t,i)}decorate(e,i){if(null===e)return null;if(!this.options.preserveLatex)return e;const t=this.latex(i,this.index);return Array.isArray(e)?e={latex:t,fn:e}:"number"==typeof e?e={latex:t,num:Number(e).toString()}:"string"==typeof e?e={latex:t,sym:e}:"object"==typeof e&&null!==e&&(e.latex=t),e}}function Ne(e,i){const t=e.length,r=e;e=e.slice(0,-1);for(let t=0;t<e.length-16;t++){const r=e.substring(0,t);for(let n=0;n<17;n++){const s=e.substring(t,t+n+1),a=Math.floor((e.length-r.length)/s.length);if(a>1&&(r+s.repeat(a+1)).startsWith(e))return"0"===s?r.replace(/(\d{3})/g,"$1"+i.groupSeparator):r.replace(/(\d{3})/g,"$1"+i.groupSeparator)+i.beginRepeatingDigits+s+i.endRepeatingDigits}}const n=t>i.precision-1;return e=r,n&&(e=e.substring(0,i.precision-1)),i.groupSeparator&&(e=e.replace(/(\d{3})/g,"$1"+i.groupSeparator)).endsWith(i.groupSeparator)&&(e=e.slice(0,-i.groupSeparator.length)),n?e+i.truncationMarker:e}function Ae(e,i){return e?i.beginExponentMarker?i.beginExponentMarker+e+(i.endExponentMarker??""):"10^{"+e+"}":""}function ze(e,i){if(null===e)return"";let t;if("number"==typeof e)t=e;else{if("object"!=typeof e||!("num"in e))return"";t=e.num}if(t===1/0||"Infinity"===t||"+Infinity"===t)return i.positiveInfinity;if(t===-1/0||"-Infinity"===t)return i.negativeInfinity;if("NaN"===t||"number"==typeof t&&Number.isNaN(t))return i.notANumber;if("number"==typeof t)return"engineering"===i.notation?function(e,i){if(0===e)return"0";const t=Math.abs(e);let r=Math.round(Math.log10(t));r-=r%3,t>Math.pow(10,i.avoidExponentsInRange[0])&&t<Math.pow(10,i.avoidExponentsInRange[1])&&(r=0);const n=t/Math.pow(10,r);let s="";const a=n.toString().match(/^(.*)\.(.*)$/);a?.[1]&&a[2]&&(s=a[1]+i.decimalMarker+a[2]),i.groupSeparator&&(s=Ne(n.toExponential(),i));let o="";return 0!==r&&(o=Ae(r.toString(),i)),(e<0?"-":"")+s+o}(t,i):function(e,i){let t,r=e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i);r?.[1]&&r[2]&&(t=Ae(r[2],i));let n=r?.[1]??e,s="";return r=(t?r[1]:e).match(/^(.*)\.(.*)$/),r?.[1]&&r[2]&&(n=r[1],s=r[2]),i.groupSeparator&&(n=n.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator),s=Ne(s,i)),s&&(s=i.decimalMarker+s),t?"1"!==n||s?n+s+i.exponentProduct+t:t:n+s}(t.toString(),i);/[0-9][nd]$/.test(t)&&(t=t.slice(0,-1));let r="";for("-"===t[0]?(r="-",t=t.substring(1)):"+"===t[0]&&(t=t.substring(1));"0"===t[0];)t=t.substring(1);if(0===t.length)return r+"0";"."===t[0]&&(t="0"+t);let n="";if(t.indexOf(".")>=0){const e=t.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);if(!e)return"";const s=e[1],a=e[2];if(n=e[4]??"","0"===s){let e=0;for(;"0"===a[e]&&e<a.length;)e+=1;let n="";if(e<=4)n="0"+i.decimalMarker,n+=a.substring(0,e),n+=Ne(t.substring(n.length),i);else if(e+1>=i.precision)n="0",r="";else{n=t[e];const r=Ne(t.substring(e+1),i);r&&(n+=i.decimalMarker+r)}"0"!==n&&(!(t.length-1>i.precision)||i.endRepeatingDigits&&n.endsWith(i.endRepeatingDigits)||!i.truncationMarker||n.endsWith(i.truncationMarker)||(n+=i.truncationMarker),e>4&&(n+=i.exponentProduct+Ae(""+(1-e),i))),t=n}else{t=s.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator);const e=Ne(a,i);e&&(t+=i.decimalMarker+e)}}else if(t.length>i.precision){const e=t.length;if(e>i.avoidExponentsInRange[1]){let r=t[0];const n=Ne(t.substring(1),i);n&&(r+=i.decimalMarker+n,i.truncationMarker&&!r.endsWith(i.truncationMarker)&&i.endRepeatingDigits&&!r.endsWith(i.endRepeatingDigits)&&(r+=i.truncationMarker)),"1"!==r?r+=i.exponentProduct:r="",t=r+Ae(""+(e-1),i)}}else{const e=t.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);e&&(t=e[1],e[2]&&(t+=i.decimalMarker+e[2]),n=e[4]??""),t=t.replace(/\B(?=(\d{3})+(?!\d))/g,i.groupSeparator)}const s=Ae(n,i);return"1"===t&&s?r+s:(s&&(t=t+i.exponentProduct+s),r+t)}class qe{constructor(e,i,t,r){this.level=-1,this.options=e,this.computeEngine=t,e.invisibleMultiply&&(/#1/.test(e.invisibleMultiply)&&/#2/.test(e.invisibleMultiply)||r([{severity:"warning",message:["expected-argument","invisibleMultiply"]}])),this.onError=r,this.dictionary=i}updateOptions(e){for(const i of Object.keys(this.options))i in e&&(this.options[i]=e[i])}wrap(e,i){if(null===e)return"";if(void 0===i)return"("+this.serialize(e)+")";if("number"==typeof e||q(e)||"string"==typeof e||E(e))return this.serialize(e);const t=L(e);if("string"==typeof t&&"Delimiter"!==t){const r=this.dictionary.name.get(t);if(r&&("symbol"===r.kind||"prefix"===r.kind||"infix"===r.kind||"postfix"===r.kind)&&r.precedence<i)return this.wrapString(this.serialize(e),this.options.applyFunctionStyle(e,this.level))}return this.serialize(e)}wrapShort(e){if(null===e)return"";const i=this.serialize(e);return"Delimiter"===L(e)||"number"==typeof e||q(e)||/(^(.|\\[a-zA-Z*]+))$/.test(i)?i:this.wrapString(i,this.options.groupStyle(e,this.level+1))}wrapString(e,i){return"none"===i?e:"("+e+")"}serializeSymbol(e,i){const t=L(e);if(!t)return"string"==typeof i?.serialize?i.serialize:"function"==typeof i?.serialize?i.serialize(this,e):De(M(e),"upright.")??"";const r=O(e);if(!i){if("string"==typeof t&&t.length>0&&"\\"===t[0]){let e=t;for(const i of r)e+="{"+this.serialize(i)+"}";return e}return"string"==typeof t?`${De(t,"upright.")}(${r.map((e=>this.serialize(e))).join(", ")})`:`\\operatorname{Apply}(${this.serialize(t)}, ${this.serialize(["List",...r])})`}if(i.requiredLatexArg>0){let e="",t="",n=0;for(;n<i.requiredLatexArg;)t+="{"+this.serialize(r[n++])+"}";for(;n<Math.min(r.length,i.optionalLatexArg+i.requiredLatexArg);){const i=this.serialize(r[1+n++]);i&&(e+="["+i+"]")}return i.serialize+(e+t)}return"function"==typeof i.serialize?i.serialize(this,e):"none"===this.options.applyFunctionStyle(e,this.level)?i.serialize+o(r.map((e=>this.serialize(e)))):i.serialize+this.serialize(["Delimiter",...r])}serializeDictionary(e){return`\\left[\\begin{array}{lll}${Object.keys(e).map((i=>`\\textbf{${i}} & \\rightarrow & ${this.serialize(e[i])}`)).join("\\\\")}\\end{array}\\right]`}serialize(e){if(null===e)return"";this.level+=1;const i=(()=>{const i=ze(e,this.options);if(i)return i;const t=_(e);if(null!==t)return`\\text{${t}}`;const r=M(e);if(null!==r){const i=this.dictionary.name.get(r);if("symbol"===i?.kind)return this.serializeSymbol(e,i)}const n=F(e);if(null!==n)return this.serializeDictionary(n);const s=w(e);if(s){if("\\"===s[0]){const i=O(e);return 0===i.length?s:s+"{"+i.map((e=>this.serialize(e))).filter((e=>!!e)).join("}{")+"}"}const i=this.dictionary.name.get(s);if(i){let t="";return"function"==typeof i.serialize&&(t=i.serialize(this,e)),t||"infix"!==i.kind&&"postfix"!==i.kind&&"prefix"!==i.kind||(t=function(e,i,t){let r="";const n=$(i),s=w(i);if("postfix"===t.kind)return 1!==n&&e.onError([{severity:"warning",message:["postfix-operator-requires-one-operand",e.serializeSymbol(s)]}]),Ee(t.serialize,[e.wrap(C(i,1),t.precedence)]);if("prefix"===t.kind)return 1!==n&&e.onError([{severity:"warning",message:["prefix-operator-requires-one-operand",e.serializeSymbol(s)]}]),Ee(t.serialize,[e.wrap(C(i,1),t.precedence+1)]);if("infix"===t.kind){r=e.wrap(C(i,1),t.precedence);for(let s=2;s<n+1;s++){const n=C(i,s);null!==n&&(r=Ee(t.serialize,[r,e.wrap(n,t.precedence)]))}}return r}(this,e,i)),t||"matchfix"!==i.kind||(t=function(e,i,t){return Ee(t.serialize,[e.serialize(C(i,1)??"Nothing")])}(this,e,i)),t||"symbol"!==i.kind||(t=this.serializeSymbol(e,i)),t}}if(Array.isArray(e)||P(e)||null!==M(e))return this.serializeSymbol(e);this.onError([{severity:"warning",message:["syntax-error",JSON.stringify(e)]}])})();return this.level-=1,i??""}applyFunctionStyle(e,i){return this.options.applyFunctionStyle(e,i)}groupStyle(e,i){return this.options.groupStyle(e,i)}rootStyle(e,i){return this.options.rootStyle(e,i)}fractionStyle(e,i){return this.options.fractionStyle(e,i)}logicStyle(e,i){return this.options.logicStyle(e,i)}powerStyle(e,i){return this.options.powerStyle(e,i)}numericSetStyle(e,i){return this.options.numericSetStyle(e,i)}}function Ee(e,i){let t=e;for(let e=0;e<i.length;e++){let r=i[e]??"";if(/[a-zA-Z*]/.test(r[0])){const i=t.match(RegExp("(.*)#"+Number(e+1).toString()));i&&/\\[a-zA-Z*]+/.test(i[1])&&(r=" "+r)}t=t.replace("#"+Number(e+1).toString(),r)}return t}const Pe=["alpha","beta","gamma","Gamma","delta","Delta","epsilon","zeta","eta","theta","Theta","iota","kappa","lambda","Lambda","mu","nu","xi","Xi","pi","Pi","rho","sigma","Sigma","tau","upsilon","phi","Phi","varphi","chi","psi","Psi","omega","Omega","aleph","ast","blacksquare","bot","bullet","circ","diamond","times","top","square","star"];function De(e,i="italic."){if(null===e)return null;const t=e.match(/^(_+)(.*)/);if(t)return`\\text{${"\\_".repeat(t[1].length)+_e(t[2])}}`;let r;[r,e]=function(e){const i=e.match(/^([a-zA-Z-]+\.)(.*)/);return i?[i[1],i[2]]:["",e]}(e);const n=_e(e);return 1!==n.length||r?(r||(r=i),({"upright.":"\\mathrm{_}","italic.":"\\mathit{_}","bold-italic.":"\\mathbf{\\mathit{_}}","script.":"\\mathscr{_}","calligraphic.":"\\mathcal{_}","bold-script.":"\\mathbf{\\mathscr{_}}","bold-calligraphic.":"\\mathbf{\\mathcal{_}}","fraktur.":"\\mathfrak{_}","gothic.":"\\mathfrak{_}","bold-gothic.":"\\mathbf{\\mathfrak{_}}","bold-fraktur.":"\\mathbf{\\mathfrak{_}}","sans-serif.":"\\mathsf{_}","bold-sans-serif.":"\\mathbf{\\mathsf{_}}","italic-sans-serif.":"\\mathit{\\mathsf{_}}","monospace.":"\\mathtt{_}","blackboard.":"\\mathbb{_}","double-struck.":"\\mathbb{_}"}[r]??"\\mathit{_}").replace("_",n)):n}function _e(e){const i=e.indexOf("_");if(i>0){const t=e.substring(0,i),r=e.substring(i+1);return r?r.startsWith('"')&&r.endsWith('"')?`${_e(t)}_\\mathrm{${_e(r.substring(1,-1))}}`:`${_e(t)}_{${_e(r)}}`:De(t)+"\\_"}const t=e.match(/([^0-9]+?)([0-9]+)$/);return t?0===t[1].length?e:`${_e(t[1])}_{${t[2]}}`:Pe.includes(e)?"\\"+e:e=e.replace(/[{}\[\]\\:\-\$%]/g,(e=>({"{":"\\lbrace ","}":"\\rbrace ","[":"\\lbrack ","]":"\\rbrack ",":":"\\colon ","\\":"\\backslash ","-":'\\unicode{"2013}'}[e]??"\\"+e)))}const Le={invisibleMultiply:"",invisiblePlus:"",multiply:"\\times",missingSymbol:"\\placeholder{}",applyFunctionStyle:function(e,i){return"paren"},groupStyle:function(e,i){return"paren"},rootStyle:B,fractionStyle:G,logicStyle:function(e,i){return"boolean"},powerStyle:function(e,i){return"solidus"},numericSetStyle:function(e,i){return"compact"}};class we{constructor(e){this.onError=e.onError??(e=>{if("undefined"!=typeof window)for(const i of e);}),this.computeEngine=e.computeEngine;const i={...e};delete i.dictionary,delete i.onError,this.options={...ve,...Le,...be,...i},this.dictionary=function(e,i){const t={lookahead:1,name:new Map,symbol:[],infix:[],prefix:[],postfix:[],environment:new Map,matchfix:[]};for(const r of e){const[e,n]=he(r,i);if(null!==n)if(void 0!==n.name&&(t.name.has(n.name)&&i({severity:"warning",message:["invalid-dictionary-entry",n.name,"Duplicate definition"]}),t.name.set(n.name,n)),"matchfix"===n.kind)t.matchfix.push(n);else if("environment"===n.kind){const e=l(r.trigger??"");t.environment.has(e)&&i({severity:"warning",message:["invalid-dictionary-entry",e,"Duplicate environment definition"]}),t.environment.set(e,n)}else if(e){const i=l(r.trigger??""),s=pe(e);if(t.lookahead=Math.max(t.lookahead,s),"symbol"===n.kind){void 0===t.symbol[s]&&(t.symbol[s]=new Map);const e=t.symbol[s];e.has(i)?e.get(i).push(n):e.set(i,[n])}else if("prefix"===n.kind){void 0===t.prefix[s]&&(t.prefix[s]=new Map);const e=t.prefix[s];e.has(i)?e.get(i).push(n):e.set(i,[n])}else if("infix"===n.kind){void 0===t.infix[s]&&(t.infix[s]=new Map);const e=t.infix[s];e.has(i)?e.get(i).push(n):e.set(i,[n])}else if("postfix"===n.kind){void 0===t.postfix[s]&&(t.postfix[s]=new Map);const e=t.postfix[s];e.has(i)?e.get(i).push(n):e.set(i,[n])}}}return t}(e.dictionary??we.getDictionary(),(e=>this.onError([e])))}updateOptions(e){for(const i of Object.keys(this.options))i in e&&(this.options[i]=e[i]);this.serializer.updateOptions(e)}static getDictionary(e="all"){if("all"===e){let e=[];for(const i of Object.keys(me))me[i]&&(e=[...e,...me[i]]);return e}return me[e]?[...me[e]]:[]}parse(e){const i=new Se(a(e,[]),this.options,this.dictionary,this.computeEngine,this.onError);let t=i.matchExpression();if(!i.atEnd){const e=[];for(;!i.atEnd;)e.push(i.next());t=["Error",t??"Nothing",{str:"syntax-error"},["LatexForm",{str:l(e)}]]}return t??"Nothing"}serialize(e){return this.serializer.serialize(e)}get serializer(){return this._serializer||(this._serializer=new qe(this.options,this.dictionary,this.computeEngine,this.onError)),this._serializer}}e.LatexSyntax=we,e.applyRecursively=function(e,i){const t=L(e);if(null!==t)return[i(t),...O(e).map(i)];const r=F(e);if(null!==r){const e=Object.keys(r),t={};for(const n of e)t[n]=i(r[n]);return{dict:t}}return i(e)},e.asValidJSONNumber=function(e){if("string"==typeof e){const i=Number(e);if("+"===e[0]&&(e=e.slice(1)),i.toString()===e)return isNaN(i)||!isFinite(i)?i.toString():i}return e},e.getDictionary=F,e.getStringValue=_,e.head=L,e.headName=w,e.isAtomic=D,e.isDictionaryObject=function(e){return null!==e&&"object"==typeof e&&"dict"in e},e.isFunctionObject=P,e.isStringObject=function(e){return null!==e&&"object"==typeof e&&"str"in e},e.isSymbolObject=E,e.mapArgs=T,e.nops=$,e.op=C,e.symbol=M,e.tail=O,e.version="0.4.3",Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).MathJson={});
|