@cortex-js/compute-engine 0.4.2 → 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.
Files changed (132) hide show
  1. package/README.md +2 -2
  2. package/dist/compute-engine.esm.js +22446 -16214
  3. package/dist/compute-engine.js +22449 -16222
  4. package/dist/compute-engine.min.esm.js +2 -7
  5. package/dist/compute-engine.min.js +2 -7
  6. package/dist/math-json.esm.js +4336 -10528
  7. package/dist/math-json.js +4353 -10531
  8. package/dist/math-json.min.esm.js +2 -7
  9. package/dist/math-json.min.js +2 -7
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +90 -0
  12. package/dist/types/compute-engine/assume.d.ts +21 -6
  13. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
  14. package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
  15. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
  16. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
  17. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
  18. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +93 -0
  19. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
  20. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
  21. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
  22. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
  24. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
  25. package/dist/types/compute-engine/boxed-expression/order.d.ts +52 -0
  26. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
  27. package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
  28. package/dist/types/compute-engine/compute-engine.d.ts +233 -97
  29. package/dist/types/compute-engine/cost-function.d.ts +3 -0
  30. package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
  31. package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
  32. package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
  33. package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
  34. package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
  35. package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
  36. package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
  37. package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
  38. package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
  39. package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
  40. package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
  41. package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
  42. package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
  43. package/dist/types/compute-engine/domain-utils.d.ts +30 -0
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
  52. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
  53. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
  54. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
  55. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
  56. package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
  57. package/dist/types/compute-engine/latex-syntax/public.d.ts +550 -0
  58. package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +2 -3
  59. package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
  60. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +43 -0
  61. package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
  62. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
  63. package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
  64. package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
  65. package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
  66. package/dist/types/compute-engine/public.d.ts +1076 -434
  67. package/dist/types/compute-engine/rules.d.ts +16 -6
  68. package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
  69. package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
  70. package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
  71. package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
  72. package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
  73. package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
  74. package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
  75. package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
  76. package/dist/types/compute-engine.d.ts +3 -5
  77. package/dist/types/math-json/math-json-format.d.ts +101 -0
  78. package/dist/types/math-json/utils.d.ts +97 -0
  79. package/dist/types/math-json.d.ts +5 -3
  80. package/package.json +27 -26
  81. package/dist/cortex.esm.js +0 -20989
  82. package/dist/cortex.js +0 -21011
  83. package/dist/cortex.min.esm.js +0 -7
  84. package/dist/cortex.min.js +0 -7
  85. package/dist/types/common/debug.d.ts +0 -28
  86. package/dist/types/common/utils.d.ts +0 -153
  87. package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
  88. package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
  89. package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
  90. package/dist/types/compute-engine/domains.d.ts +0 -4
  91. package/dist/types/compute-engine/evaluate.d.ts +0 -13
  92. package/dist/types/compute-engine/expression-map.d.ts +0 -11
  93. package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
  94. package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
  95. package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
  96. package/dist/types/compute-engine/numeric.d.ts +0 -21
  97. package/dist/types/compute-engine/numerical-eval.d.ts +0 -5
  98. package/dist/types/compute-engine/order.d.ts +0 -18
  99. package/dist/types/compute-engine/patterns.d.ts +0 -22
  100. package/dist/types/compute-engine/predicates.d.ts +0 -42
  101. package/dist/types/compute-engine/simplify.d.ts +0 -6
  102. package/dist/types/compute-engine/utils.d.ts +0 -15
  103. package/dist/types/cortex/formatter.d.ts +0 -165
  104. package/dist/types/cortex/parse-cortex.d.ts +0 -5
  105. package/dist/types/cortex/reserved-words.d.ts +0 -1
  106. package/dist/types/cortex/serialize-cortex.d.ts +0 -14
  107. package/dist/types/cortex.d.ts +0 -8
  108. package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
  109. package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
  110. package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
  111. package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
  112. package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
  113. package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
  114. package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
  115. package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
  116. package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
  117. package/dist/types/latex-syntax/definitions.d.ts +0 -40
  118. package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
  119. package/dist/types/latex-syntax/parse.d.ts +0 -138
  120. package/dist/types/latex-syntax/public.d.ts +0 -456
  121. package/dist/types/latex-syntax/serializer.d.ts +0 -26
  122. package/dist/types/latex-syntax/utils.d.ts +0 -10
  123. package/dist/types/point-free-parser/characters.d.ts +0 -25
  124. package/dist/types/point-free-parser/combinators.d.ts +0 -46
  125. package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
  126. package/dist/types/point-free-parser/grammar.d.ts +0 -12
  127. package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
  128. package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
  129. package/dist/types/point-free-parser/parsers.d.ts +0 -130
  130. package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
  131. package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
  132. package/dist/types/public.d.ts +0 -163
@@ -1,7 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).cortex={})}(this,(function(e){const t=8205,i=[127462,127487];function n(e){return e===t||65038===e||65039===e||e>=127995&&e<=128e3||e>=129456&&e<=129460||e>=917536&&e<=917632}function r(e){return e>=i[0]&&e<=i[1]}function s(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;const i=[],s=function(e){const t=[];for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n>=55296&&n<=56319){const t=e.charCodeAt(i+1);t>=56320&&t<=57343&&(n=65536+1024*(n-55296)+(t-56320),i++)}t.push(n)}return t}(e);let o=0;for(;o<s.length;){const e=s[o++],a=s[o];if(a===t){const e=o-1;for(o+=2;s[o]===t;)o+=2;i.push(String.fromCodePoint(...s.slice(e,2*o-e+1)))}else if(n(a)){const e=o-1;for(;n(s[o]);)o+=s[o]===t?2:1;i.push(String.fromCodePoint(...s.slice(e,2*o-e-1)))}else r(e)?(o+=1,i.push(String.fromCodePoint(...s.slice(o-2,2)))):i.push(String.fromCodePoint(e))}return i}class o{constructor(e){this.obeyspaces=!1,this.s=s(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 t;return t="string"==typeof this.s?e.exec(this.s.slice(this.pos)):e.exec(this.s.slice(this.pos).join("")),(null==t?void 0:t[0])?(this.pos+=t[0].length,t[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 t=this.s[this.pos+1];e=/[^0-9A-Za-z]/.test(t)}return e?"#"+this.get():"#"}}else if("$"===e)return"$"===this.peek()?(this.get(),"<$$>"):"<$>"}return e}}function a(e,t){var i,n,r,s;let o=[],a=e.next();if(a)if("\\relax"===a);else if("\\noexpand"===a)a=e.next(),a&&o.push(a);else if("\\obeyspaces"===a)e.obeyspaces=!0;else if("\\space"===a||"~"===a)o.push("<space>");else if("\\bgroup"===a)o.push("<{>");else if("\\egroup"===a)o.push("<}>");else if("\\string"===a)a=e.next(),a&&("\\"===a[0]?Array.from(a).forEach((e=>o.push("\\"===e?"\\backslash":e))):"<{>"===a?o.push("\\{"):"<space>"===a?o.push("~"):"<}>"===a&&o.push("\\}"));else if("\\csname"===a){for(;"<space>"===e.peek();)e.next();let r="",s=!1,u=[];do{if(0===u.length)if(/^#[0-9?]$/.test(e.peek())){const r=e.get().slice(1);u=l(null!==(n=null!==(i=null==t?void 0:t[r])&&void 0!==i?i:null==t?void 0:t["?"])&&void 0!==n?n:"\\placeholder{}",t),a=u[0]}else a=e.next(),u=a?[a]:[];s=0===u.length,s||"\\endcsname"!==a||(s=!0,u.shift()),s||(s="<$>"===a||"<$$>"===a||"<{>"===a||"<}>"===a||!!a&&a.length>1&&"\\"===a[0]),s||(r+=u.shift())}while(!s);r&&o.push("\\"+r),o=o.concat(u)}else if("\\endcsname"===a);else if(a.length>1&&"#"===a[0]){const e=a.slice(1);o=o.concat(l(null!==(s=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:null==t?void 0:t["?"])&&void 0!==s?s:"\\placeholder{}",t))}else o.push(a);return o}function l(e,t){const i=e.toString().split(/\r?\n/);let n="",r="";for(const e of i){n+=r,r=" ";const t=e.match(/((?:\\%)|[^%])*/);null!==t&&(n+=t[0])}const s=new o(n);let l=[];do{l=l.concat(a(s,t))}while(!s.end());return l}function u(e){let t="",i="";for(const n of e)n&&(/[a-zA-Z*]/.test(n[0])&&(i+=t),t=/\\[a-zA-Z]+\*?$/.test(n)?" ":"",i+=n);return i}function c(e){let t=[];if(Array.isArray(e))for(const i of e)Array.isArray(i)?t=[...t,...i]:t.push(i);else t=[e];return u(t.map((e=>{var t;return null!==(t={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"}[e])&&void 0!==t?t:e})))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},h={exports:{}};!function(e){!function(t){var i,n,r,s,o=9e15,a=1e9,l="0123456789abcdef",u="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",c="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",f={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-o,maxE:o,crypto:!1},h=!0,m="[DecimalError] ",p=m+"Invalid argument: ",g=m+"Precision limit exceeded",d=m+"crypto unavailable",v=Math.floor,x=Math.pow,b=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,y=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,w=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,S=1e7,M=u.length-1,E=c.length-1,A={name:"[object Decimal]"};function D(e){var t,i,n,r=e.length-1,s="",o=e[0];if(r>0){for(s+=o,t=1;t<r;t++)(i=7-(n=e[t]+"").length)&&(s+=z(i)),s+=n;(i=7-(n=(o=e[t])+"").length)&&(s+=z(i))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function C(e,t,i){if(e!==~~e||e<t||e>i)throw Error(p+e)}function _(e,t,i,n){var r,s,o,a;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=7,r=0):(r=Math.ceil((t+1)/7),t%=7),s=x(10,7-t),a=e[r]%s|0,null==n?t<3?(0==t?a=a/100|0:1==t&&(a=a/10|0),o=i<4&&99999==a||i>3&&49999==a||5e4==a||0==a):o=(i<4&&a+1==s||i>3&&a+1==s/2)&&(e[r+1]/s/100|0)==x(10,t-2)-1||(a==s/2||0==a)&&0==(e[r+1]/s/100|0):t<4?(0==t?a=a/1e3|0:1==t?a=a/100|0:2==t&&(a=a/10|0),o=(n||i<4)&&9999==a||!n&&i>3&&4999==a):o=((n||i<4)&&a+1==s||!n&&i>3&&a+1==s/2)&&(e[r+1]/s/1e3|0)==x(10,t-3)-1,o}function k(e,t,i){for(var n,r,s=[0],o=0,a=e.length;o<a;){for(r=s.length;r--;)s[r]*=t;for(s[0]+=l.indexOf(e.charAt(o++)),n=0;n<s.length;n++)s[n]>i-1&&(void 0===s[n+1]&&(s[n+1]=0),s[n+1]+=s[n]/i|0,s[n]%=i)}return s.reverse()}A.absoluteValue=A.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),q(e)},A.ceil=function(){return q(new this.constructor(this),this.e+1,2)},A.comparedTo=A.cmp=function(e){var t,i,n,r,s=this,o=s.d,a=(e=new s.constructor(e)).d,l=s.s,u=e.s;if(!o||!a)return l&&u?l!==u?l:o===a?0:!o^l<0?1:-1:NaN;if(!o[0]||!a[0])return o[0]?l:a[0]?-u:0;if(l!==u)return l;if(s.e!==e.e)return s.e>e.e^l<0?1:-1;for(t=0,i=(n=o.length)<(r=a.length)?n:r;t<i;++t)if(o[t]!==a[t])return o[t]>a[t]^l<0?1:-1;return n===r?0:n>r^l<0?1:-1},A.cosine=A.cos=function(){var e,t,i=this,n=i.constructor;return i.d?i.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(i.e,i.sd())+7,n.rounding=1,i=function(e,t){var i,n,r=t.d.length;r<32?n=(1/W(4,i=Math.ceil(r/3))).toString():(i=16,n="2.3283064365386962890625e-10"),e.precision+=i,t=G(e,1,t.times(n),new e(1));for(var s=i;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=i,t}(n,V(n,i)),n.precision=e,n.rounding=t,q(2==s||3==s?i.neg():i,e,t,!0)):new n(1):new n(NaN)},A.cubeRoot=A.cbrt=function(){var e,t,i,n,r,s,o,a,l,u,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(h=!1,(s=c.s*x(c.s*c,1/3))&&Math.abs(s)!=1/0?n=new f(s.toString()):(i=D(c.d),(s=((e=c.e)-i.length+1)%3)&&(i+=1==s||-2==s?"0":"00"),s=x(i,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(n=new f(i=s==1/0?"5e"+e:(i=s.toExponential()).slice(0,i.indexOf("e")+1)+e)).s=c.s),o=(e=f.precision)+3;;)if(u=(l=(a=n).times(a).times(a)).plus(c),n=F(u.plus(c).times(a),u.plus(l),o+2,1),D(a.d).slice(0,o)===(i=D(n.d)).slice(0,o)){if("9999"!=(i=i.slice(o-3,o+1))&&(r||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(q(n,e+1,1),t=!n.times(n).times(n).eq(c));break}if(!r&&(q(a,e+1,0),a.times(a).times(a).eq(c))){n=a;break}o+=4,r=1}return h=!0,q(n,e,f.rounding,t)},A.decimalPlaces=A.dp=function(){var e,t=this.d,i=NaN;if(t){if(i=7*((e=t.length-1)-v(this.e/7)),e=t[e])for(;e%10==0;e/=10)i--;i<0&&(i=0)}return i},A.dividedBy=A.div=function(e){return F(this,new this.constructor(e))},A.dividedToIntegerBy=A.divToInt=function(e){var t=this.constructor;return q(F(this,new t(e),0,1,1),t.precision,t.rounding)},A.equals=A.eq=function(e){return 0===this.cmp(e)},A.floor=function(){return q(new this.constructor(this),this.e+1,3)},A.greaterThan=A.gt=function(e){return this.cmp(e)>0},A.greaterThanOrEqualTo=A.gte=function(e){var t=this.cmp(e);return 1==t||0===t},A.hyperbolicCosine=A.cosh=function(){var e,t,i,n,r,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;i=o.precision,n=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?t=(1/W(4,e=Math.ceil(r/3))).toString():(e=16,t="2.3283064365386962890625e-10"),s=G(o,1,s.times(t),new o(1),!0);for(var l,u=e,c=new o(8);u--;)l=s.times(s),s=a.minus(l.times(c.minus(l.times(c))));return q(s,o.precision=i,o.rounding=n,!0)},A.hyperbolicSine=A.sinh=function(){var e,t,i,n,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(t=s.precision,i=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,(n=r.d.length)<3)r=G(s,2,r,r,!0);else{e=(e=1.4*Math.sqrt(n))>16?16:0|e,r=G(s,2,r=r.times(1/W(5,e)),r,!0);for(var o,a=new s(5),l=new s(16),u=new s(20);e--;)o=r.times(r),r=r.times(a.plus(o.times(l.times(o).plus(u))))}return s.precision=t,s.rounding=i,q(r,t,i,!0)},A.hyperbolicTangent=A.tanh=function(){var e,t,i=this,n=i.constructor;return i.isFinite()?i.isZero()?new n(i):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,F(i.sinh(),i.cosh(),n.precision=e,n.rounding=t)):new n(i.s)},A.inverseCosine=A.acos=function(){var e,t=this,i=t.constructor,n=t.abs().cmp(1),r=i.precision,s=i.rounding;return-1!==n?0===n?t.isNeg()?O(i,r,s):new i(0):new i(NaN):t.isZero()?O(i,r+4,s).times(.5):(i.precision=r+6,i.rounding=1,t=t.asin(),e=O(i,r+4,s).times(.5),i.precision=r,i.rounding=s,e.minus(t))},A.inverseHyperbolicCosine=A.acosh=function(){var e,t,i=this,n=i.constructor;return i.lte(1)?new n(i.eq(1)?0:NaN):i.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(i.e),i.sd())+4,n.rounding=1,h=!1,i=i.times(i).minus(1).sqrt().plus(i),h=!0,n.precision=e,n.rounding=t,i.ln()):new n(i)},A.inverseHyperbolicSine=A.asinh=function(){var e,t,i=this,n=i.constructor;return!i.isFinite()||i.isZero()?new n(i):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(i.e),i.sd())+6,n.rounding=1,h=!1,i=i.times(i).plus(1).sqrt().plus(i),h=!0,n.precision=e,n.rounding=t,i.ln())},A.inverseHyperbolicTangent=A.atanh=function(){var e,t,i,n,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=s.precision,t=s.rounding,n=r.sd(),Math.max(n,e)<2*-r.e-1?q(new s(r),e,t,!0):(s.precision=i=n-r.e,r=F(r.plus(1),new s(1).minus(r),i+e,1),s.precision=e+4,s.rounding=1,r=r.ln(),s.precision=e,s.rounding=t,r.times(.5))):new s(NaN)},A.inverseSine=A.asin=function(){var e,t,i,n,r=this,s=r.constructor;return r.isZero()?new s(r):(t=r.abs().cmp(1),i=s.precision,n=s.rounding,-1!==t?0===t?((e=O(s,i+4,n).times(.5)).s=r.s,e):new s(NaN):(s.precision=i+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=n,r.times(2)))},A.inverseTangent=A.atan=function(){var e,t,i,n,r,s,o,a,l,u=this,c=u.constructor,f=c.precision,m=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&f+4<=E)return(o=O(c,f+4,m).times(.25)).s=u.s,o}else{if(!u.s)return new c(NaN);if(f+4<=E)return(o=O(c,f+4,m).times(.5)).s=u.s,o}for(c.precision=a=f+10,c.rounding=1,e=i=Math.min(28,a/7+2|0);e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(a/7),n=1,l=u.times(u),o=new c(u),r=u;-1!==e;)if(r=r.times(l),s=o.minus(r.div(n+=2)),r=r.times(l),void 0!==(o=s.plus(r.div(n+=2))).d[t])for(e=t;o.d[e]===s.d[e]&&e--;);return i&&(o=o.times(2<<i-1)),h=!0,q(o,c.precision=f,c.rounding=m,!0)},A.isFinite=function(){return!!this.d},A.isInteger=A.isInt=function(){return!!this.d&&v(this.e/7)>this.d.length-2},A.isNaN=function(){return!this.s},A.isNegative=A.isNeg=function(){return this.s<0},A.isPositive=A.isPos=function(){return this.s>0},A.isZero=function(){return!!this.d&&0===this.d[0]},A.lessThan=A.lt=function(e){return this.cmp(e)<0},A.lessThanOrEqualTo=A.lte=function(e){return this.cmp(e)<1},A.logarithm=A.log=function(e){var t,i,n,r,s,o,a,l,u=this,c=u.constructor,f=c.precision,m=c.rounding;if(null==e)e=new c(10),t=!0;else{if(i=(e=new c(e)).d,e.s<0||!i||!i[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(i=u.d,u.s<0||!i||!i[0]||u.eq(1))return new c(i&&!i[0]?-1/0:1!=u.s?NaN:i?0:1/0);if(t)if(i.length>1)s=!0;else{for(r=i[0];r%10==0;)r/=10;s=1!==r}if(h=!1,o=B(u,a=f+5),n=t?T(c,a+10):B(e,a),_((l=F(o,n,a,1)).d,r=f,m))do{if(o=B(u,a+=10),n=t?T(c,a+10):B(e,a),l=F(o,n,a,1),!s){+D(l.d).slice(r+1,r+15)+1==1e14&&(l=q(l,f+1,0));break}}while(_(l.d,r+=10,m));return h=!0,q(l,f,m)},A.minus=A.sub=function(e){var t,i,n,r,s,o,a,l,u,c,f,m,p=this,g=p.constructor;if(e=new g(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new g(e.d||p.s!==e.s?p:NaN):e=new g(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(u=p.d,m=e.d,a=g.precision,l=g.rounding,!u[0]||!m[0]){if(m[0])e.s=-e.s;else{if(!u[0])return new g(3===l?-0:0);e=new g(p)}return h?q(e,a,l):e}if(i=v(e.e/7),c=v(p.e/7),u=u.slice(),s=c-i){for((f=s<0)?(t=u,s=-s,o=m.length):(t=m,i=c,o=u.length),s>(n=Math.max(Math.ceil(a/7),o)+2)&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for((f=(n=u.length)<(o=m.length))&&(o=n),n=0;n<o;n++)if(u[n]!=m[n]){f=u[n]<m[n];break}s=0}for(f&&(t=u,u=m,m=t,e.s=-e.s),o=u.length,n=m.length-o;n>0;--n)u[o++]=0;for(n=m.length;n>s;){if(u[--n]<m[n]){for(r=n;r&&0===u[--r];)u[r]=S-1;--u[r],u[n]+=S}u[n]-=m[n]}for(;0===u[--o];)u.pop();for(;0===u[0];u.shift())--i;return u[0]?(e.d=u,e.e=P(u,i),h?q(e,a,l):e):new g(3===l?-0:0)},A.modulo=A.mod=function(e){var t,i=this,n=i.constructor;return e=new n(e),!i.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||i.d&&!i.d[0]?q(new n(i),n.precision,n.rounding):(h=!1,9==n.modulo?(t=F(i,e.abs(),0,3,1)).s*=e.s:t=F(i,e,0,n.modulo,1),t=t.times(e),h=!0,i.minus(t))},A.naturalExponential=A.exp=function(){return j(this)},A.naturalLogarithm=A.ln=function(){return B(this)},A.negated=A.neg=function(){var e=new this.constructor(this);return e.s=-e.s,q(e)},A.plus=A.add=function(e){var t,i,n,r,s,o,a,l,u,c,f=this,m=f.constructor;if(e=new m(e),!f.d||!e.d)return f.s&&e.s?f.d||(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.minus(e);if(u=f.d,c=e.d,a=m.precision,l=m.rounding,!u[0]||!c[0])return c[0]||(e=new m(f)),h?q(e,a,l):e;if(s=v(f.e/7),n=v(e.e/7),u=u.slice(),r=s-n){for(r<0?(i=u,r=-r,o=c.length):(i=c,n=s,o=u.length),r>(o=(s=Math.ceil(a/7))>o?s+1:o+1)&&(r=o,i.length=1),i.reverse();r--;)i.push(0);i.reverse()}for((o=u.length)-(r=c.length)<0&&(r=o,i=c,c=u,u=i),t=0;r;)t=(u[--r]=u[r]+c[r]+t)/S|0,u[r]%=S;for(t&&(u.unshift(t),++n),o=u.length;0==u[--o];)u.pop();return e.d=u,e.e=P(u,n),h?q(e,a,l):e},A.precision=A.sd=function(e){var t,i=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(p+e);return i.d?(t=L(i.d),e&&i.e+1>t&&(t=i.e+1)):t=NaN,t},A.round=function(){var e=this,t=e.constructor;return q(new t(e),e.e+1,t.rounding)},A.sine=A.sin=function(){var e,t,i=this,n=i.constructor;return i.isFinite()?i.isZero()?new n(i):(e=n.precision,t=n.rounding,n.precision=e+Math.max(i.e,i.sd())+7,n.rounding=1,i=function(e,t){var i,n=t.d.length;if(n<3)return G(e,2,t,t);i=(i=1.4*Math.sqrt(n))>16?16:0|i,t=G(e,2,t=t.times(1/W(5,i)),t);for(var r,s=new e(5),o=new e(16),a=new e(20);i--;)r=t.times(t),t=t.times(s.plus(r.times(o.times(r).minus(a))));return t}(n,V(n,i)),n.precision=e,n.rounding=t,q(s>2?i.neg():i,e,t,!0)):new n(NaN)},A.squareRoot=A.sqrt=function(){var e,t,i,n,r,s,o=this,a=o.d,l=o.e,u=o.s,c=o.constructor;if(1!==u||!a||!a[0])return new c(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(h=!1,0==(u=Math.sqrt(+o))||u==1/0?(((t=D(a)).length+l)%2==0&&(t+="0"),u=Math.sqrt(t),l=v((l+1)/2)-(l<0||l%2),n=new c(t=u==1/0?"5e"+l:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+l)):n=new c(u.toString()),i=(l=c.precision)+3;;)if(n=(s=n).plus(F(o,s,i+2,1)).times(.5),D(s.d).slice(0,i)===(t=D(n.d)).slice(0,i)){if("9999"!=(t=t.slice(i-3,i+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(q(n,l+1,1),e=!n.times(n).eq(o));break}if(!r&&(q(s,l+1,0),s.times(s).eq(o))){n=s;break}i+=4,r=1}return h=!0,q(n,l,c.rounding,e)},A.tangent=A.tan=function(){var e,t,i=this,n=i.constructor;return i.isFinite()?i.isZero()?new n(i):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,(i=i.sin()).s=1,i=F(i,new n(1).minus(i.times(i)).sqrt(),e+10,0),n.precision=e,n.rounding=t,q(2==s||4==s?i.neg():i,e,t,!0)):new n(NaN)},A.times=A.mul=function(e){var t,i,n,r,s,o,a,l,u,c=this,f=c.constructor,m=c.d,p=(e=new f(e)).d;if(e.s*=c.s,!(m&&m[0]&&p&&p[0]))return new f(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:m&&p?0*e.s:e.s/0);for(i=v(c.e/7)+v(e.e/7),(l=m.length)<(u=p.length)&&(s=m,m=p,p=s,o=l,l=u,u=o),s=[],n=o=l+u;n--;)s.push(0);for(n=u;--n>=0;){for(t=0,r=l+n;r>n;)a=s[r]+p[n]*m[r-n-1]+t,s[r--]=a%S|0,t=a/S|0;s[r]=(s[r]+t)%S|0}for(;!s[--o];)s.pop();return t?++i:s.shift(),e.d=s,e.e=P(s,i),h?q(e,f.precision,f.rounding):e},A.toBinary=function(e,t){return Y(this,2,e,t)},A.toDecimalPlaces=A.toDP=function(e,t){var i=this,n=i.constructor;return i=new n(i),void 0===e?i:(C(e,0,a),void 0===t?t=n.rounding:C(t,0,8),q(i,e+i.e+1,t))},A.toExponential=function(e,t){var i,n=this,r=n.constructor;return void 0===e?i=I(n,!0):(C(e,0,a),void 0===t?t=r.rounding:C(t,0,8),i=I(n=q(new r(n),e+1,t),!0,e+1)),n.isNeg()&&!n.isZero()?"-"+i:i},A.toFixed=function(e,t){var i,n,r=this,s=r.constructor;return void 0===e?i=I(r):(C(e,0,a),void 0===t?t=s.rounding:C(t,0,8),i=I(n=q(new s(r),e+r.e+1,t),!1,e+n.e+1)),r.isNeg()&&!r.isZero()?"-"+i:i},A.toFraction=function(e){var t,i,n,r,s,o,a,l,u,c,f,m,g=this,d=g.d,v=g.constructor;if(!d)return new v(g);if(u=i=new v(1),n=l=new v(0),o=(s=(t=new v(n)).e=L(d)-g.e-1)%7,t.d[0]=x(10,o<0?7+o:o),null==e)e=s>0?t:u;else{if(!(a=new v(e)).isInt()||a.lt(u))throw Error(p+a);e=a.gt(t)?s>0?t:u:a}for(h=!1,a=new v(D(d)),c=v.precision,v.precision=s=7*d.length*2;f=F(a,t,0,1,1),1!=(r=i.plus(f.times(n))).cmp(e);)i=n,n=r,r=u,u=l.plus(f.times(r)),l=r,r=t,t=a.minus(f.times(r)),a=r;return r=F(e.minus(i),n,0,1,1),l=l.plus(r.times(u)),i=i.plus(r.times(n)),l.s=u.s=g.s,m=F(u,n,s,1).minus(g).abs().cmp(F(l,i,s,1).minus(g).abs())<1?[u,n]:[l,i],v.precision=c,h=!0,m},A.toHexadecimal=A.toHex=function(e,t){return Y(this,16,e,t)},A.toNearest=function(e,t){var i=this,n=i.constructor;if(i=new n(i),null==e){if(!i.d)return i;e=new n(1),t=n.rounding}else{if(e=new n(e),void 0===t?t=n.rounding:C(t,0,8),!i.d)return e.s?i:e;if(!e.d)return e.s&&(e.s=i.s),e}return e.d[0]?(h=!1,i=F(i,e,0,t,1).times(e),h=!0,q(i)):(e.s=i.s,i=e),i},A.toNumber=function(){return+this},A.toOctal=function(e,t){return Y(this,8,e,t)},A.toPower=A.pow=function(e){var t,i,n,r,s,o,a=this,l=a.constructor,u=+(e=new l(e));if(!(a.d&&e.d&&a.d[0]&&e.d[0]))return new l(x(+a,u));if((a=new l(a)).eq(1))return a;if(n=l.precision,s=l.rounding,e.eq(1))return q(a,n,s);if((t=v(e.e/7))>=e.d.length-1&&(i=u<0?-u:u)<=9007199254740991)return r=U(l,a,i,n),e.s<0?new l(1).div(r):q(r,n,s);if((o=a.s)<0){if(t<e.d.length-1)return new l(NaN);if(0==(1&e.d[t])&&(o=1),0==a.e&&1==a.d[0]&&1==a.d.length)return a.s=o,a}return(t=0!=(i=x(+a,u))&&isFinite(i)?new l(i+"").e:v(u*(Math.log("0."+D(a.d))/Math.LN10+a.e+1)))>l.maxE+1||t<l.minE-1?new l(t>0?o/0:0):(h=!1,l.rounding=a.s=1,i=Math.min(12,(t+"").length),(r=j(e.times(B(a,n+i)),n)).d&&_((r=q(r,n+5,1)).d,n,s)&&(t=n+10,+D((r=q(j(e.times(B(a,t+i)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(r=q(r,n+1,0))),r.s=o,h=!0,l.rounding=s,q(r,n,s))},A.toPrecision=function(e,t){var i,n=this,r=n.constructor;return void 0===e?i=I(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(C(e,1,a),void 0===t?t=r.rounding:C(t,0,8),i=I(n=q(new r(n),e,t),e<=n.e||n.e<=r.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+i:i},A.toSignificantDigits=A.toSD=function(e,t){var i=this.constructor;return void 0===e?(e=i.precision,t=i.rounding):(C(e,1,a),void 0===t?t=i.rounding:C(t,0,8)),q(new i(this),e,t)},A.toString=function(){var e=this,t=e.constructor,i=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+i:i},A.truncated=A.trunc=function(){return q(new this.constructor(this),this.e+1,1)},A.valueOf=A.toJSON=function(){var e=this,t=e.constructor,i=I(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+i:i};var F=function(){function e(e,t,i){var n,r=0,s=e.length;for(e=e.slice();s--;)n=e[s]*t+r,e[s]=n%i|0,r=n/i|0;return r&&e.unshift(r),e}function t(e,t,i,n){var r,s;if(i!=n)s=i>n?1:-1;else for(r=s=0;r<i;r++)if(e[r]!=t[r]){s=e[r]>t[r]?1:-1;break}return s}function i(e,t,i,n){for(var r=0;i--;)e[i]-=r,r=e[i]<t[i]?1:0,e[i]=r*n+e[i]-t[i];for(;!e[0]&&e.length>1;)e.shift()}return function(r,s,o,a,l,u){var c,f,h,m,p,g,d,x,b,y,N,w,M,E,A,D,C,_,k,F,I=r.constructor,P=r.s==s.s?1:-1,T=r.d,O=s.d;if(!(T&&T[0]&&O&&O[0]))return new I(r.s&&s.s&&(T?!O||T[0]!=O[0]:O)?T&&0==T[0]||!O?0*P:P/0:NaN);for(u?(p=1,f=r.e-s.e):(u=S,p=7,f=v(r.e/p)-v(s.e/p)),k=O.length,C=T.length,y=(b=new I(P)).d=[],h=0;O[h]==(T[h]||0);h++);if(O[h]>(T[h]||0)&&f--,null==o?(E=o=I.precision,a=I.rounding):E=l?o+(r.e-s.e)+1:o,E<0)y.push(1),g=!0;else{if(E=E/p+2|0,h=0,1==k){for(m=0,O=O[0],E++;(h<C||m)&&E--;h++)A=m*u+(T[h]||0),y[h]=A/O|0,m=A%O|0;g=m||h<C}else{for((m=u/(O[0]+1)|0)>1&&(O=e(O,m,u),T=e(T,m,u),k=O.length,C=T.length),D=k,w=(N=T.slice(0,k)).length;w<k;)N[w++]=0;(F=O.slice()).unshift(0),_=O[0],O[1]>=u/2&&++_;do{m=0,(c=t(O,N,k,w))<0?(M=N[0],k!=w&&(M=M*u+(N[1]||0)),(m=M/_|0)>1?(m>=u&&(m=u-1),1==(c=t(d=e(O,m,u),N,x=d.length,w=N.length))&&(m--,i(d,k<x?F:O,x,u))):(0==m&&(c=m=1),d=O.slice()),(x=d.length)<w&&d.unshift(0),i(N,d,w,u),-1==c&&(c=t(O,N,k,w=N.length))<1&&(m++,i(N,k<w?F:O,w,u)),w=N.length):0===c&&(m++,N=[0]),y[h++]=m,c&&N[0]?N[w++]=T[D]||0:(N=[T[D]],w=1)}while((D++<C||void 0!==N[0])&&E--);g=void 0!==N[0]}y[0]||y.shift()}if(1==p)b.e=f,n=g;else{for(h=1,m=y[0];m>=10;m/=10)h++;b.e=h+f*p-1,q(b,l?o+b.e+1:o,a,g)}return b}}();function q(e,t,i,n){var r,s,o,a,l,u,c,f,m,p=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(r=1,a=f[0];a>=10;a/=10)r++;if((s=t-r)<0)s+=7,o=t,l=(c=f[m=0])/x(10,r-o-1)%10|0;else if((m=Math.ceil((s+1)/7))>=(a=f.length)){if(!n)break e;for(;a++<=m;)f.push(0);c=l=0,r=1,o=(s%=7)-7+1}else{for(c=a=f[m],r=1;a>=10;a/=10)r++;l=(o=(s%=7)-7+r)<0?0:c/x(10,r-o-1)%10|0}if(n=n||t<0||void 0!==f[m+1]||(o<0?c:c%x(10,r-o-1)),u=i<4?(l||n)&&(0==i||i==(e.s<0?3:2)):l>5||5==l&&(4==i||n||6==i&&(s>0?o>0?c/x(10,r-o):0:f[m-1])%10&1||i==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=x(10,(7-t%7)%7),e.e=-t||0):f[0]=e.e=0,e;if(0==s?(f.length=m,a=1,m--):(f.length=m+1,a=x(10,7-s),f[m]=o>0?(c/x(10,r-o)%x(10,o)|0)*a:0),u)for(;;){if(0==m){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(e.e++,f[0]==S&&(f[0]=1));break}if(f[m]+=a,f[m]!=S)break;f[m--]=0,a=1}for(s=f.length;0===f[--s];)f.pop()}return h&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function I(e,t,i){if(!e.isFinite())return Z(e);var n,r=e.e,s=D(e.d),o=s.length;return t?(i&&(n=i-o)>0?s=s.charAt(0)+"."+s.slice(1)+z(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):r<0?(s="0."+z(-r-1)+s,i&&(n=i-o)>0&&(s+=z(n))):r>=o?(s+=z(r+1-o),i&&(n=i-r-1)>0&&(s=s+"."+z(n))):((n=r+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),i&&(n=i-o)>0&&(r+1===o&&(s+="."),s+=z(n))),s}function P(e,t){var i=e[0];for(t*=7;i>=10;i/=10)t++;return t}function T(e,t,i){if(t>M)throw h=!0,i&&(e.precision=i),Error(g);return q(new e(u),t,1,!0)}function O(e,t,i){if(t>E)throw Error(g);return q(new e(c),t,i,!0)}function L(e){var t=e.length-1,i=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)i--;for(t=e[0];t>=10;t/=10)i++}return i}function z(e){for(var t="";e--;)t+="0";return t}function U(e,t,i,n){var r,s=new e(1),o=Math.ceil(n/7+4);for(h=!1;;){if(i%2&&J((s=s.times(t)).d,o)&&(r=!0),0===(i=v(i/2))){i=s.d.length-1,r&&0===s.d[i]&&++s.d[i];break}J((t=t.times(t)).d,o)}return h=!0,s}function R(e){return 1&e.d[e.d.length-1]}function $(e,t,i){for(var n,r=new e(t[0]),s=0;++s<t.length;){if(!(n=new e(t[s])).s){r=n;break}r[i](n)&&(r=n)}return r}function j(e,t){var i,n,r,s,o,a,l,u=0,c=0,f=0,m=e.constructor,p=m.rounding,g=m.precision;if(!e.d||!e.d[0]||e.e>17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(h=!1,l=g):l=t,a=new m(.03125);e.e>-2;)e=e.times(a),f+=5;for(l+=n=Math.log(x(2,f))/Math.LN10*2+5|0,i=s=o=new m(1),m.precision=l;;){if(s=q(s.times(e),l,1),i=i.times(++c),D((a=o.plus(F(s,i,l,1))).d).slice(0,l)===D(o.d).slice(0,l)){for(r=f;r--;)o=q(o.times(o),l,1);if(null!=t)return m.precision=g,o;if(!(u<3&&_(o.d,l-n,p,u)))return q(o,m.precision=g,p,h=!0);m.precision=l+=10,i=s=a=new m(1),c=0,u++}o=a}}function B(e,t){var i,n,r,s,o,a,l,u,c,f,m,p=1,g=e,d=g.d,v=g.constructor,x=v.rounding,b=v.precision;if(g.s<0||!d||!d[0]||!g.e&&1==d[0]&&1==d.length)return new v(d&&!d[0]?-1/0:1!=g.s?NaN:d?0:g);if(null==t?(h=!1,c=b):c=t,v.precision=c+=10,n=(i=D(d)).charAt(0),!(Math.abs(s=g.e)<15e14))return u=T(v,c+2,b).times(s+""),g=B(new v(n+"."+i.slice(1)),c-10).plus(u),v.precision=b,null==t?q(g,b,x,h=!0):g;for(;n<7&&1!=n||1==n&&i.charAt(1)>3;)n=(i=D((g=g.times(e)).d)).charAt(0),p++;for(s=g.e,n>1?(g=new v("0."+i),s++):g=new v(n+"."+i.slice(1)),f=g,l=o=g=F(g.minus(1),g.plus(1),c,1),m=q(g.times(g),c,1),r=3;;){if(o=q(o.times(m),c,1),D((u=l.plus(F(o,new v(r),c,1))).d).slice(0,c)===D(l.d).slice(0,c)){if(l=l.times(2),0!==s&&(l=l.plus(T(v,c+2,b).times(s+""))),l=F(l,new v(p),c,1),null!=t)return v.precision=b,l;if(!_(l.d,c-10,x,a))return q(l,v.precision=b,x,h=!0);v.precision=c+=10,u=o=g=F(f.minus(1),f.plus(1),c,1),m=q(g.times(g),c,1),r=a=1}l=u,r+=2}}function Z(e){return String(e.s*e.s/0)}function Q(e,t){var i,n,r;for((i=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(i<0&&(i=n),i+=+t.slice(n+1),t=t.substring(0,n)):i<0&&(i=t.length),n=0;48===t.charCodeAt(n);n++);for(r=t.length;48===t.charCodeAt(r-1);--r);if(t=t.slice(n,r)){if(r-=n,e.e=i=i-n-1,e.d=[],n=(i+1)%7,i<0&&(n+=7),n<r){for(n&&e.d.push(+t.slice(0,n)),r-=7;n<r;)e.d.push(+t.slice(n,n+=7));n=7-(t=t.slice(n)).length}else n-=r;for(;n--;)t+="0";e.d.push(+t),h&&(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 H(e,t){var n,r,s,o,a,l,u,c,f;if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(y.test(t))n=16,t=t.toLowerCase();else if(b.test(t))n=2;else{if(!N.test(t))throw Error(p+t);n=8}for((o=t.search(/p/i))>0?(u=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),a=(o=t.indexOf("."))>=0,r=e.constructor,a&&(o=(l=(t=t.replace(".","")).length)-o,s=U(r,new r(n),o,2*o)),o=f=(c=k(t,n,S)).length-1;0===c[o];--o)c.pop();return o<0?new r(0*e.s):(e.e=P(c,f),e.d=c,h=!1,a&&(e=F(e,s,4*l)),u&&(e=e.times(Math.abs(u)<54?x(2,u):i.pow(2,u))),h=!0,e)}function G(e,t,i,n,r){var s,o,a,l,u=e.precision,c=Math.ceil(u/7);for(h=!1,l=i.times(i),a=new e(n);;){if(o=F(a.times(l),new e(t++*t++),u,1),a=r?n.plus(o):n.minus(o),n=F(o.times(l),new e(t++*t++),u,1),void 0!==(o=a.plus(n)).d[c]){for(s=c;o.d[s]===a.d[s]&&s--;);if(-1==s)break}s=a,a=n,n=o,o=s}return h=!0,o.d.length=c+1,o}function W(e,t){for(var i=e;--t;)i*=e;return i}function V(e,t){var i,n=t.s<0,r=O(e,e.precision,1),o=r.times(.5);if((t=t.abs()).lte(o))return s=n?4:1,t;if((i=t.divToInt(r)).isZero())s=n?3:2;else{if((t=t.minus(i.times(r))).lte(o))return s=R(i)?n?2:3:n?4:1,t;s=R(i)?n?1:4:n?3:2}return t.minus(r).abs()}function Y(e,t,i,r){var s,o,u,c,f,h,m,p,g,d=e.constructor,v=void 0!==i;if(v?(C(i,1,a),void 0===r?r=d.rounding:C(r,0,8)):(i=d.precision,r=d.rounding),e.isFinite()){for(v?(s=2,16==t?i=4*i-3:8==t&&(i=3*i-2)):s=t,(u=(m=I(e)).indexOf("."))>=0&&(m=m.replace(".",""),(g=new d(1)).e=m.length-u,g.d=k(I(g),10,s),g.e=g.d.length),o=f=(p=k(m,10,s)).length;0==p[--f];)p.pop();if(p[0]){if(u<0?o--:((e=new d(e)).d=p,e.e=o,p=(e=F(e,g,i,r,0,s)).d,o=e.e,h=n),u=p[i],c=s/2,h=h||void 0!==p[i+1],h=r<4?(void 0!==u||h)&&(0===r||r===(e.s<0?3:2)):u>c||u===c&&(4===r||h||6===r&&1&p[i-1]||r===(e.s<0?8:7)),p.length=i,h)for(;++p[--i]>s-1;)p[i]=0,i||(++o,p.unshift(1));for(f=p.length;!p[f-1];--f);for(u=0,m="";u<f;u++)m+=l.charAt(p[u]);if(v){if(f>1)if(16==t||8==t){for(u=16==t?4:3,--f;f%u;f++)m+="0";for(f=(p=k(m,s,t)).length;!p[f-1];--f);for(u=1,m="1.";u<f;u++)m+=l.charAt(p[u])}else m=m.charAt(0)+"."+m.slice(1);m=m+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)m="0"+m;m="0."+m}else if(++o>f)for(o-=f;o--;)m+="0";else o<f&&(m=m.slice(0,o)+"."+m.slice(o))}else m=v?"0p+0":"0";m=(16==t?"0x":2==t?"0b":8==t?"0o":"")+m}else m=Z(e);return e.s<0?"-"+m:m}function J(e,t){if(e.length>t)return e.length=t,!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 te(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function ne(e){return new this(e).asinh()}function re(e){return new this(e).atan()}function se(e){return new this(e).atanh()}function oe(e,t){e=new this(e),t=new this(t);var i,n=this.precision,r=this.rounding,s=n+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(i=t.s<0?O(this,n,r):new this(0)).s=e.s:!e.d||t.isZero()?(i=O(this,s,1).times(.5)).s=e.s:t.s<0?(this.precision=s,this.rounding=1,i=this.atan(F(e,t,s,1)),t=O(this,s,1),this.precision=n,this.rounding=r,i=e.s<0?i.minus(t):i.plus(t)):i=this.atan(F(e,t,s,1)):(i=O(this,s,1).times(t.s>0?.25:.75)).s=e.s:i=new this(NaN),i}function ae(e){return new this(e).cbrt()}function le(e){return q(e=new this(e),e.e+1,2)}function ue(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,i,n,r=!0===e.defaults,s=["precision",1,a,"rounding",0,8,"toExpNeg",-o,0,"toExpPos",0,o,"maxE",0,o,"minE",-o,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(i=s[t],r&&(this[i]=f[i]),void 0!==(n=e[i])){if(!(v(n)===n&&n>=s[t+1]&&n<=s[t+2]))throw Error(p+i+": "+n);this[i]=n}if(i="crypto",r&&(this[i]=f[i]),void 0!==(n=e[i])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(p+i+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[i]=!0}else this[i]=!1}return this}function ce(e){return new this(e).cos()}function fe(e){return new this(e).cosh()}function he(e,t){return new this(e).div(t)}function me(e){return new this(e).exp()}function pe(e){return q(e=new this(e),e.e+1,3)}function ge(){var e,t,i=new this(0);for(h=!1,e=0;e<arguments.length;)if((t=new this(arguments[e++])).d)i.d&&(i=i.plus(t.times(t)));else{if(t.s)return h=!0,new this(1/0);i=t}return h=!0,i.sqrt()}function de(e){return e instanceof i||e&&"[object Decimal]"===e.name||!1}function ve(e){return new this(e).ln()}function xe(e,t){return new this(e).log(t)}function be(e){return new this(e).log(2)}function ye(e){return new this(e).log(10)}function Ne(){return $(this,arguments,"lt")}function we(){return $(this,arguments,"gt")}function Se(e,t){return new this(e).mod(t)}function Me(e,t){return new this(e).mul(t)}function Ee(e,t){return new this(e).pow(t)}function Ae(e){var t,i,n,r,s=0,o=new this(1),l=[];if(void 0===e?e=this.precision:C(e,1,a),n=Math.ceil(e/7),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)(r=t[s])>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:l[s++]=r%1e7;else{if(!crypto.randomBytes)throw Error(d);for(t=crypto.randomBytes(n*=4);s<n;)(r=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((127&t[s+3])<<24))>=214e7?crypto.randomBytes(4).copy(t,s):(l.push(r%1e7),s+=4);s=n/4}else for(;s<n;)l[s++]=1e7*Math.random()|0;for(e%=7,(n=l[--s])&&e&&(r=x(10,7-e),l[s]=(n/r|0)*r);0===l[s];s--)l.pop();if(s<0)i=0,l=[0];else{for(i=-1;0===l[0];i-=7)l.shift();for(n=1,r=l[0];r>=10;r/=10)n++;n<7&&(i-=7-n)}return o.e=i,o.d=l,o}function De(e){return q(e=new this(e),e.e+1,this.rounding)}function Ce(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function _e(e){return new this(e).sin()}function ke(e){return new this(e).sinh()}function Fe(e){return new this(e).sqrt()}function qe(e,t){return new this(e).sub(t)}function Ie(e){return new this(e).tan()}function Pe(e){return new this(e).tanh()}function Te(e){return q(e=new this(e),e.e+1,1)}(i=function e(t){var i,n,r;function s(e){var t,i,n,r=this;if(!(r instanceof s))return new s(e);if(r.constructor=s,e instanceof s)return r.s=e.s,void(h?!e.d||e.e>s.maxE?(r.e=NaN,r.d=null):e.e<s.minE?(r.e=0,r.d=[0]):(r.e=e.e,r.d=e.d.slice()):(r.e=e.e,r.d=e.d?e.d.slice():e.d));if("number"==(n=typeof e)){if(0===e)return r.s=1/e<0?-1:1,r.e=0,void(r.d=[0]);if(e<0?(e=-e,r.s=-1):r.s=1,e===~~e&&e<1e7){for(t=0,i=e;i>=10;i/=10)t++;return void(h?t>s.maxE?(r.e=NaN,r.d=null):t<s.minE?(r.e=0,r.d=[0]):(r.e=t,r.d=[e]):(r.e=t,r.d=[e]))}return 0*e!=0?(e||(r.s=NaN),r.e=NaN,void(r.d=null)):Q(r,e.toString())}if("string"!==n)throw Error(p+e);return 45===(i=e.charCodeAt(0))?(e=e.slice(1),r.s=-1):(43===i&&(e=e.slice(1)),r.s=1),w.test(e)?Q(r,e):H(r,e)}if(s.prototype=A,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=te,s.asin=ie,s.asinh=ne,s.atan=re,s.atanh=se,s.atan2=oe,s.cbrt=ae,s.ceil=le,s.cos=ce,s.cosh=fe,s.div=he,s.exp=me,s.floor=pe,s.hypot=ge,s.ln=ve,s.log=xe,s.log10=ye,s.log2=be,s.max=Ne,s.min=we,s.mod=Se,s.mul=Me,s.pow=Ee,s.random=Ae,s.round=De,s.sign=Ce,s.sin=_e,s.sinh=ke,s.sqrt=Fe,s.sub=qe,s.tan=Ie,s.tanh=Pe,s.trunc=Te,void 0===t&&(t={}),t&&!0!==t.defaults)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],i=0;i<r.length;)t.hasOwnProperty(n=r[i++])||(t[n]=this[n]);return s.config(t),s}(f)).default=i.Decimal=i,u=new i(u),c=new i(c),e.exports?("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(A[Symbol.for("nodejs.util.inspect.custom")]=A.toString,A[Symbol.toStringTag]="Decimal"),e.exports=i):(t||(t="undefined"!=typeof self&&self&&self.self==self?self:window),r=t.Decimal,i.noConflict=function(){return t.Decimal=r,i},t.Decimal=i)}(f)}(h);var m={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,t){!function(t){var i=function(e){return.5*(Math.exp(e)+Math.exp(-e))},n=function(e){return.5*(Math.exp(e)-Math.exp(-e))},r=function(){throw SyntaxError("Invalid Param")};function s(e,t){var i=Math.abs(e),n=Math.abs(t);return 0===e?Math.log(n):0===t?Math.log(i):i<3e3&&n<3e3?.5*Math.log(e*e+t*t):Math.log(e/Math.cos(Math.atan2(t,e)))}function o(e,t){if(!(this instanceof o))return new o(e,t);var i=function(e,t){var i={re:0,im:0};if(null==e)i.re=i.im=0;else if(void 0!==t)i.re=e,i.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)i.re=e.re,i.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return o.INFINITY;i.re=e.abs*Math.cos(e.arg),i.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 o.INFINITY;i.re=e.r*Math.cos(e.phi),i.im=e.r*Math.sin(e.phi)}else 2===e.length?(i.re=e[0],i.im=e[1]):r();break;case"string":i.im=i.re=0;var n=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),s=1,a=0;null===n&&r();for(var l=0;l<n.length;l++){var u=n[l];" "===u||"\t"===u||"\n"===u||("+"===u?s++:"-"===u?a++:"i"===u||"I"===u?(s+a===0&&r()," "===n[l+1]||isNaN(n[l+1])?i.im+=parseFloat((a%2?"-":"")+"1"):(i.im+=parseFloat((a%2?"-":"")+n[l+1]),l++),s=a=0):((s+a===0||isNaN(u))&&r(),"i"===n[l+1]||"I"===n[l+1]?(i.im+=parseFloat((a%2?"-":"")+u),l++):i.re+=parseFloat((a%2?"-":"")+u),s=a=0))}s+a>0&&r();break;case"number":i.im=0,i.re=e;break;default:r()}return isNaN(i.re)||isNaN(i.im),i}(e,t);this.re=i.re,this.im=i.im}o.prototype={re:0,im:0,sign:function(){var e=this.abs();return new o(this.re/e,this.im/e)},add:function(e,t){var i=new o(e,t);return this.isInfinite()&&i.isInfinite()?o.NAN:this.isInfinite()||i.isInfinite()?o.INFINITY:new o(this.re+i.re,this.im+i.im)},sub:function(e,t){var i=new o(e,t);return this.isInfinite()&&i.isInfinite()?o.NAN:this.isInfinite()||i.isInfinite()?o.INFINITY:new o(this.re-i.re,this.im-i.im)},mul:function(e,t){var i=new o(e,t);return this.isInfinite()&&i.isZero()||this.isZero()&&i.isInfinite()?o.NAN:this.isInfinite()||i.isInfinite()?o.INFINITY:0===i.im&&0===this.im?new o(this.re*i.re,0):new o(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)},div:function(e,t){var i=new o(e,t);if(this.isZero()&&i.isZero()||this.isInfinite()&&i.isInfinite())return o.NAN;if(this.isInfinite()||i.isZero())return o.INFINITY;if(this.isZero()||i.isInfinite())return o.ZERO;e=this.re,t=this.im;var n,r,s=i.re,a=i.im;return 0===a?new o(e/s,t/s):Math.abs(s)<Math.abs(a)?new o((e*(r=s/a)+t)/(n=s*r+a),(t*r-e)/n):new o((e+t*(r=a/s))/(n=a*r+s),(t-e*r)/n)},pow:function(e,t){var i=new o(e,t);if(e=this.re,t=this.im,i.isZero())return o.ONE;if(0===i.im){if(0===t&&e>0)return new o(Math.pow(e,i.re),0);if(0===e)switch((i.re%4+4)%4){case 0:return new o(Math.pow(t,i.re),0);case 1:return new o(0,Math.pow(t,i.re));case 2:return new o(-Math.pow(t,i.re),0);case 3:return new o(0,-Math.pow(t,i.re))}}if(0===e&&0===t&&i.re>0&&i.im>=0)return o.ZERO;var n=Math.atan2(t,e),r=s(e,t);return e=Math.exp(i.re*r-i.im*n),t=i.im*r+i.re*n,new o(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,i=this.re,n=this.im,r=this.abs();if(i>=0){if(0===n)return new o(Math.sqrt(i),0);e=.5*Math.sqrt(2*(r+i))}else e=Math.abs(n)/Math.sqrt(2*(r-i));return t=i<=0?.5*Math.sqrt(2*(r-i)):Math.abs(n)/Math.sqrt(2*(r+i)),new o(e,n<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new o(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new o(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(e<-t||e>t)return Math.cos(e)-1;var i=e*e;return i*(i*(1/24+i*(-1/720+i*(1/40320+i*(-1/3628800+i*(1/4790014600+i*(-1/87178291200+i*(1/20922789888e3)))))))-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new o(s(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,i=Math.abs(e),n=Math.abs(t),i<3e3&&n<3e3?Math.sqrt(i*i+n*n):(i<n?(i=n,n=e/t):n=t/e,i*Math.sqrt(1+n*n));var e,t,i,n},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var e=this.re,t=this.im;return new o(Math.sin(e)*i(t),Math.cos(e)*n(t))},cos:function(){var e=this.re,t=this.im;return new o(Math.cos(e)*i(t),-Math.sin(e)*n(t))},tan:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)+i(t);return new o(Math.sin(e)/r,n(t)/r)},cot:function(){var e=2*this.re,t=2*this.im,r=Math.cos(e)-i(t);return new o(-Math.sin(e)/r,n(t)/r)},sec:function(){var e=this.re,t=this.im,r=.5*i(2*t)+.5*Math.cos(2*e);return new o(Math.cos(e)*i(t)/r,Math.sin(e)*n(t)/r)},csc:function(){var e=this.re,t=this.im,r=.5*i(2*t)-.5*Math.cos(2*e);return new o(Math.sin(e)*i(t)/r,-Math.cos(e)*n(t)/r)},asin:function(){var e=this.re,t=this.im,i=new o(t*t-e*e+1,-2*e*t).sqrt(),n=new o(i.re-t,i.im+e).log();return new o(n.im,-n.re)},acos:function(){var e=this.re,t=this.im,i=new o(t*t-e*e+1,-2*e*t).sqrt(),n=new o(i.re-t,i.im+e).log();return new o(Math.PI/2-n.im,n.re)},atan:function(){var e=this.re,t=this.im;if(0===e){if(1===t)return new o(0,1/0);if(-1===t)return new o(0,-1/0)}var i=e*e+(1-t)*(1-t),n=new o((1-t*t-e*e)/i,-2*e/i).log();return new o(-.5*n.im,.5*n.re)},acot:function(){var e=this.re,t=this.im;if(0===t)return new o(Math.atan2(1,e),0);var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).atan():new o(0!==e?e/0:0,0!==t?-t/0:0).atan()},asec:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new o(0,1/0);var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).acos():new o(0!==e?e/0:0,0!==t?-t/0:0).acos()},acsc:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new o(Math.PI/2,1/0);var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).asin():new o(0!==e?e/0:0,0!==t?-t/0:0).asin()},sinh:function(){var e=this.re,t=this.im;return new o(n(e)*Math.cos(t),i(e)*Math.sin(t))},cosh:function(){var e=this.re,t=this.im;return new o(i(e)*Math.cos(t),n(e)*Math.sin(t))},tanh:function(){var e=2*this.re,t=2*this.im,r=i(e)+Math.cos(t);return new o(n(e)/r,Math.sin(t)/r)},coth:function(){var e=2*this.re,t=2*this.im,r=i(e)-Math.cos(t);return new o(n(e)/r,-Math.sin(t)/r)},csch:function(){var e=this.re,t=this.im,r=Math.cos(2*t)-i(2*e);return new o(-2*n(e)*Math.cos(t)/r,2*i(e)*Math.sin(t)/r)},sech:function(){var e=this.re,t=this.im,r=Math.cos(2*t)+i(2*e);return new o(2*i(e)*Math.cos(t)/r,-2*n(e)*Math.sin(t)/r)},asinh:function(){var e=this.im;this.im=-this.re,this.re=e;var t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t},acosh:function(){var e=this.acos();if(e.im<=0){var t=e.re;e.re=-e.im,e.im=t}else t=e.im,e.im=-e.re,e.re=t;return e},atanh:function(){var e=this.re,t=this.im,i=e>1&&0===t,n=1-e,r=1+e,a=n*n+t*t,l=0!==a?new o((r*n-t*t)/a,(t*n+r*t)/a):new o(-1!==e?e/0:0,0!==t?t/0:0),u=l.re;return l.re=s(l.re,l.im)/2,l.im=Math.atan2(l.im,u)/2,i&&(l.im=-l.im),l},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new o(0,Math.PI/2);var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).atanh():new o(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new o(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).asinh():new o(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return o.INFINITY;var i=e*e+t*t;return 0!==i?new o(e/i,-t/i).acosh():new o(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return o.INFINITY;if(this.isInfinite())return o.ZERO;var e=this.re,t=this.im,i=e*e+t*t;return new o(e/i,-t/i)},conjugate:function(){return new o(this.re,-this.im)},neg:function(){return new o(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new o(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new o(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new o(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var i=new o(e,t);return Math.abs(i.re-this.re)<=o.EPSILON&&Math.abs(i.im-this.im)<=o.EPSILON},clone:function(){return new o(this.re,this.im)},toString:function(){var e=this.re,t=this.im,i="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<o.EPSILON&&(e=0),Math.abs(t)<o.EPSILON&&(t=0),0===t?i+e:(0!==e?(i+=e,i+=" ",t<0?(t=-t,i+="-"):i+="+",i+=" "):t<0&&(t=-t,i+="-"),1!==t&&(i+=t),i+"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())}},o.ZERO=new o(0,0),o.ONE=new o(1,0),o.I=new o(0,1),o.PI=new o(Math.PI,0),o.E=new o(Math.E,0),o.INFINITY=new o(1/0,1/0),o.NAN=new o(NaN,NaN),o.EPSILON=1e-15,Object.defineProperty(o,"__esModule",{value:!0}),o.default=o,o.Complex=o,e.exports=o}()}(m);const p=new h.exports.Decimal(0),g=new h.exports.Decimal(1),d=new h.exports.Decimal(-1),v=new h.exports.Decimal(NaN),x=new h.exports.Decimal(1/0),b=new h.exports.Decimal(-1/0);function y(e){if("number"==typeof e&&(e=new h.exports.Decimal(e)),!e.isInteger()||e.isNegative())return v;if(e.lessThan(10))return new h.exports.Decimal([1,1,2,6,24,120,720,5040,40320,362880,3628800][e.toNumber()]);if(e.gt(Number.MAX_SAFE_INTEGER)){let t=g,i=new h.exports.Decimal(2);for(;i.lessThan(e);)t=t.mul(i),i=i.add(1);return t}if(e.modulo(2).eq(1))return e.times(y(e.minus(1)));let t=e.toNumber(),i=e.toNumber(),n=e;for(;t>2;)t-=2,i+=t,n=n.mul(i);return n}const N=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7].map((e=>new h.exports.Decimal(e))),w=new h.exports.Decimal(607).div(128),S=[.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)));function M(e){if("number"==typeof e&&(e=new h.exports.Decimal(e)),e.isNegative())return v;let t=S[0];for(let i=S.length-1;i>0;--i)t=t.add(S[i].div(e.add(i)));const i=e.add(w).add(.5);return h.exports.Decimal.acos(-1).mul(2).log().mul(.5).add(i.log().mul(e.add(.5)).minus(i).add(t.log()).minus(e.log()))}function E(e){if("number"==typeof e&&(e=new h.exports.Decimal(e)),e.lessThan(.5)){const t=h.exports.Decimal.acos(-1);return t.div(t.mul(e).sin().mul(E(h.exports.Decimal.sub(1,e))))}if(e.greaterThan(100))return M(e).exp();{e=e.sub(1);let t=N[0];for(let i=1;i<9;i++)t=t.add(N[i].div(e.add(i)));const i=e.add(7).add(.5);return h.exports.Decimal.acos(-1).times(2).sqrt().mul(t.mul(i.neg().exp()).mul(h.exports.Decimal.pow(i,e.add(.5))))}}const A=Math.log10(Math.pow(2,53)),D=Math.pow(10,-10),C=new Set([2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919]);function _(e,t){if(!Number.isInteger(e)||!Number.isInteger(t))return NaN;for(;0!==t;)[e,t]=[t,e%t];return e<0?-e:e}const k=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],F=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function q(e){if(e<0)return NaN;let t=F[0];for(let i=F.length-1;i>0;--i)t+=F[i]/(e+i);const i=e+4.7421875+.5;return.5*Math.log(2*Math.PI)+(e+.5)*Math.log(i)-i+Math.log(t)-Math.log(e)}function I(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*I(1-e));if(e>100)return Math.exp(q(e));{e-=1;let t=k[0];for(let i=1;i<9;i++)t+=k[i]/(e+i);const i=e+7+.5;return Math.sqrt(2*Math.PI)*Math.pow(i,e+.5)*Math.exp(-i)*t}}const P="Parentheses",T="Identity",O="LatexTokens",L="List",z="Missing",U="Nothing",R="Sequence",$="Sequence2",j="Add",B="Derivative",Z="Divide",Q="InverseFunction",H="Multiply",G="Negate",W="Power",V="Prime",Y="Root",J="Sqrt",K="Subtract",X="ComplexInfinity",ee="ExponentialE",te="ImaginaryUnit";function ie(e){return null!==e&&"object"==typeof e&&"num"in e}function ne(e){return null!==e&&"object"==typeof e&&"sym"in e}function re(e){return null!==e&&"object"==typeof e&&"str"in e}function se(e){return null!==e&&"object"==typeof e&&"fn"in e}function oe(e){return null!==e&&"object"==typeof e&&"dict"in e}function ae(e){if("number"==typeof e)return e;if(null===e)return null;if(ie(e))return e.num.endsWith("d")||e.num.endsWith("n")?null:parseFloat(e.num);const t=xe(e);return null===t?null:"NaN"===t?NaN:"+Infinity"===t?1/0:"-Infinity"===t?-1/0:"Complex"===ve(e)&&0===ae(we(e,2))?ae(we(e,1)):null}function le(e){if(null===e)return null;if(e instanceof m.exports.Complex)return e;const t=xe(e);if(null!==t){if("ComplexInfinity"===t)return m.exports.Complex.INFINITY;if(t===te)return m.exports.Complex.I}const i=ve(e);if("Complex"===i){const t=ae(we(e,1)),i=ae(we(e,2));return null===t||null===i?null:new m.exports.Complex(t,i)}let n=ue(e);if(null!==n)return new m.exports.Complex(0,n);if("Add"===i&&2===Se(e)){let t=ae(we(e,1));if(null!==t?n=ue(we(e,2)):(n=ue(we(e,1)),null!==n&&(t=ae(we(e,2)))),null!==t&&null!==n)return new m.exports.Complex(t,n)}if("Subtract"===i){const t=ae(we(e,1)),i=we(e,2);if(null!==t){if(xe(i)===te)return new m.exports.Complex(t,-1);if("Multiply"===ve(i)&&we(i,2)===te){const e=ae(we(i,1));if(null!==e)return new m.exports.Complex(t,-e)}}}if("Multiply"===i&&2===Se(e)){let t=null;if(xe(we(e,2))===te?t=ae(we(e,2)):xe(we(e,1))===te&&(t=ae(we(e,1))),null!==t&&Number.isInteger(t))return 0===t?m.exports.Complex.ZERO:1===t?m.exports.Complex.ONE:-1===t?m.exports.Complex.ONE.neg():new m.exports.Complex(0,t)}if("Negate"===i){const t=le(we(e,1));if(null!==t)return t.neg()}return null}function ue(e){if("ImaginaryUnit"===xe(e))return 1;let t=null;const i=ve(e);return"Multiply"===i&&2===Se(e)?"ImaginaryUnit"===xe(we(e,1))?t=ae(we(e,2)):"ImaginaryUnit"===xe(we(e,2))&&(t=ae(we(e,1))):"Negate"===i&&1===Se(e)&&"ImaginaryUnit"===xe(we(e,1))&&(t=-1),0===t?null:t}function ce(e){var t,i;if(e instanceof h.exports.Decimal)return e;const n=xe(e);if(null!==n){if("NaN"===n)return v;if("+Infinity"===n)return x;if("-Infinity"===n)return b}if(ie(e))return e.num.endsWith("d")||e.num.endsWith("n")?new h.exports.Decimal(e.num.slice(0,-1)):new h.exports.Decimal(null!==(t=ae(e))&&void 0!==t?t:NaN);if(null!==e&&e instanceof m.exports.Complex){const t=e;return 0===t.im?new h.exports.Decimal(t.re):null}return"Complex"===ve(e)&&0===ae(we(e,2))?new h.exports.Decimal(null!==(i=ae(we(e,1)))&&void 0!==i?i:NaN):null}function fe(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 he(e){var t,i,n,r,s,o;const a=xe(e);if("ThreeQuarter"===a)return[3,4];if("TwoThird"===a)return[2,3];if("Half"===a)return[1,2];if("Third"===a)return[1,3];if("Quarter"===a)return[1,4];if(de(e))return[null,null];const l=ve(e);if(!l)return[null,null];let u=null,c=null;if(l===W){const n=ae(we(e,2));1===n?(u=null!==(t=ae(we(e,1)))&&void 0!==t?t:null,c=1):-1===n&&(u=1,c=null!==(i=ae(we(e,1)))&&void 0!==i?i:null)}return l===Z&&(u=null!==(n=ae(we(e,1)))&&void 0!==n?n:null,c=null!==(r=ae(we(e,2)))&&void 0!==r?r:null),l===H&&ve(we(e,2))===W&&-1===ae(we(we(e,2),2))&&(u=null!==(s=ae(we(e,1)))&&void 0!==s?s:null,c=null!==(o=ae(we(we(e,2),1)))&&void 0!==o?o:null),null===u||null===c?[null,null]:Number.isInteger(u)&&Number.isInteger(c)?[u,c]:[null,null]}function me(e,t){var i,n,r,s;if(xe(e)===t)return[1,1];const o=ve(e);if(o===H){if(xe(null!==(i=we(e,2))&&void 0!==i?i:z)!==t)return[null,null];const n=we(e,1),r=ae(n);return null!==r?[r,1]:he(null!=n?n:z)}if(o===Z){const i=ae(null!==(n=we(e,2))&&void 0!==n?n:z);if(null===i||isNaN(i))return[null,null];const s=null!==(r=we(e,1))&&void 0!==r?r:z,o=xe(s);if(o===t)return[1,i];let a=null;if("MinusDoublePi"===o)a=-2;else if("MinusPi"===o)a=-1;else if("DoublePi"===o)a=2;else{if(ve(s)!==H)return[null,null];if(xe(we(s,2))!==t)return[null,null];a=ae(we(s,1))}return null===a?[null,null]:[a,i]}if(o===G){const[i,n]=me(null!==(s=we(e,1))&&void 0!==s?s:z,t);return null===i||isNaN(i)?[null,null]:[-i,n]}return[null,null]}function pe(e){return Array.isArray(e)?e[0]:se(e)?e.fn[0]:"number"==typeof e||ie(e)?"Number":"string"==typeof e?"String":ne(e)?"Symbol":oe(e)?"Dictionary":null}function ge(e){return null===e?null:Array.isArray(e)?e[0]:se(e)?e.fn[0]:null}function de(e){return null===e||!Array.isArray(e)&&("object"!=typeof e||!("fn"in e||"dic"in e))}function ve(e){if(null===e)return"";const t=ge(e);return"string"==typeof t?t:""}function xe(e){return null===e?null:"string"==typeof e?e.length>=2&&"'"===e[0]&&"'"===e[e.length-1]?null:e:ne(e)?e.sym:null}function be(e){return Array.isArray(e)?e.slice(1):se(e)?e.fn.slice(1):[]}function ye(e,t){const i=ge(e);if(null!==i)return[t(i),...be(e).map(t)];const n=Me(e);if(null!==n){const e=Object.keys(n),i={};for(const r of e)i[r]=t(n[r]);return{dict:i}}return t(e)}function Ne(e,t){let i=null;if(Array.isArray(e)&&(i=e),se(e)&&(i=e.fn),null===i)return[];let n=1;const r=[];for(;n<i.length;)r.push(t(i[n])),n+=1;return r}function we(e,t){var i,n;return null===e?null:Array.isArray(e)?null!==(i=e[t])&&void 0!==i?i:null:se(e)&&null!==(n=e.fn[t])&&void 0!==n?n:null}function Se(e){return Array.isArray(e)?Math.max(0,e.length-1):se(e)?Math.max(0,e.fn.length-1):0}function Me(e){return"object"==typeof e&&"dict"in e?e.dict:null}function Ee(e,t){if(typeof e!=typeof t)return!1;if(null===e)return null===t;if(void 0===e)return void 0===t;if("number"==typeof e)return e===t;if("string"==typeof e)return e===t;if(Array.isArray(e)&&Array.isArray(t)){if(!Ee(pe(e),pe(t)))return!1;const i=Se(e);if(Se(t)!==i)return!1;for(let n=0;n<i;n++)if(!Ee(we(e,n),we(t,n)))return!1;return!0}if("object"==typeof e){if(ie(e)&&ie(t))return ae(e)===ae(t);if(ne(e)&&ne(t))return xe(e)===xe(t);if(se(e)&&se(t)){if(!Ee(pe(e),pe(t)))return!1;const i=Se(e);if(Se(t)!==i)return!1;for(let n=0;n<i;n++)if(!Ee(we(e,n),we(t,n)))return!1;return!0}if(re(e)&&re(t))return fe(e)===fe(t);if(oe(e)&&oe(t)){const i=Me(e),n=Me(t);if(null===i&&null!==n)return!1;if(null===i&&null===n)return!0;const r=Object.keys(i);if(null===n||r.length!==Object.keys(n).length)return!1;for(const e of r)if(!Ee(i[e],n[e]))return!1;return!0}}return!1}const Ae=[{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,t,i)=>{var n,r;let s=!1,o=U,a=U;for(;!s;)t.skipSpace(),t.match("_")?a=t.matchRequiredLatexArgument():t.match("^")?o=t.matchRequiredLatexArgument():s=!0;if(ve(a)===R&&(a=[L,...be(a)]),!a||!o)return[e,null];let l=null!==(n=t.matchRequiredLatexArgument())&&void 0!==n?n:U;return l!==U&&(l=[l,...null!==(r=t.matchArguments("group"))&&void 0!==r?r:U]),[null,["PartialDerivative",l,a,o]]},serialize:(e,t)=>{let i="\\partial";const n=we(t,1),r=we(t,2),s=we(t,3);return null!==r&&r!==U&&(ge(r)===L?i+="_{"+e.serialize([R,...be(r)])+"}":i+="_{"+e.serialize(r)+"}"),null!==s&&s!==U&&(i+="^{"+e.serialize(s)+"}"),null!==n&&n!==U&&(i+=e.serialize(n)),i},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 De(e,t){return t>2?"solidus":"radical"}function Ce(e){return"<space>"===e||"\\qquad"===e||"\\quad"===e||"\\enskip"===e||"\\;"===e||"\\,"===e||"\\ "===e||"~"===e}function _e(e,t,i){return(n,r,s)=>{if(s>=t)return[n,null];r.skipSpace(),r.match(i),"Missing"===n&&(n=U);const o=[e,null!=n?n:U];let a=!1;for(;!a;){for(a=!0,r.skipSpace();r.match(i);)o.push(U),r.skipSpace();if(r.atEnd)o.push(U);else{const e=r.matchExpression(t);o.push(null!=e?e:U),a=null===e}a||(r.skipSpace(),a=!r.match(i))}return[null,o]}}function ke(e){return(t,i)=>be(i).map((e=>t.serialize(e))).join(e)}const Fe=[{name:O,serialize:function(e,t){return be(t).map((t=>{const i=fe(t);return null===i?e.serialize(t):"<{>"===i?"{":"<}>"===i?"}":"<$>"===i?"$":"<$$>"===i?"$$":"<space>'"===i?" ":i})).join("")}},{name:P,trigger:{matchfix:"("},parse:(e,t,i)=>{var n;const r=t.index;if(!t.match("("))return[e,null];let s=!1,o=!0,a=!1,l=0,u="";for(;!s&&o;){const e=t.next();t.atEnd||")"===e?s=!0:"\\mathtt"===e?(t.match("<{>"),a=!0):Ce(e)||(/^[0-9a-zA-Z]$/.test(e)?(l=Math.max(l,parseInt(e,36)),u+=e):o=!1),a&&t.match("<}>")}if(t.skipSpace(),o&&t.match("_")){const i=null!==(n=ae(t.matchRequiredLatexArgument()))&&void 0!==n?n:NaN;return!isFinite(i)||i<2||i>36||l>=i?(t.onError({code:"base-out-of-range"}),[e,U]):[e,["BaseForm",parseInt(u,i),i]]}t.index=r;const c=t.matchBalancedExpression("(",")",t.onError);return c?ve(c)===R?[e,[P,...be(c)]]:[e,[P,c]]:[e,[P]]},serialize:(e,t)=>e.wrapString(ke(",")(e,t),(e.level,"paren")),separator:",",closeFence:")",precedence:20},{name:L,trigger:{matchfix:"\\lbrack"},separator:",",closeFence:"\\rbrack",precedence:20,parse:(e,t,i)=>{if(null===e){const i=t.matchBalancedExpression("\\lbrack","\\rbrack",t.onError);return i?ve(i)===R?[e,[L,...be(i)]]:[e,[L,i]]:[null,[L]]}return[e,null]}},{name:"BaseForm",serialize:(e,t)=>{var i,n;const r=null!==(i=ae(we(t,2)))&&void 0!==i?i:NaN;if(isFinite(r)&&r>=2&&r<=36){const e=null!==(n=ae(we(t,1)))&&void 0!==n?n:NaN;if(isFinite(e)){let t=Number(e).toString(r),i=0;if(2===r||10===r?i=4:16===r?i=2:r>16&&(i=4),i>0){const e=t;t="";for(let n=0;n<e.length;n++)n>0&&n%i==0&&(t="\\, "+t),t=e[e.length-n-1]+t}return`(\\mathtt{${t}})_{${r}}`}}return"\\operatorname{BaseForm}("+e.serialize(we(t,1))+", "+e.serialize(we(t,2))+")"}},{name:"Set",trigger:{matchfix:"\\lbrace"},separator:",",closeFence:"\\rbrace",precedence:20},{name:R,trigger:{infix:","},parse:_e(R,20,","),serialize:ke(", "),precedence:20},{name:$,trigger:{infix:";"},parse:_e($,19,";"),serialize:ke("; "),precedence:19},{name:z,trigger:"\\placeholder",serialize:"\\placeholder",requiredLatexArg:1},{name:"Subscript",trigger:{infix:"_"},precedence:720,serialize:(e,t)=>2===Se(t)?e.serialize(we(t,1))+"_{"+e.serialize(we(t,2))+"}":"_{"+e.serialize(we(t,1))+"}",parse:(e,t,i)=>{var n;if(!t.match("_"))return[e,null];const r=null!==(n=t.matchRequiredLatexArgument())&&void 0!==n?n:z;return e?[null,["Subscript",e,r]]:[null,["Subscript",r]]}},{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:V,trigger:{superfix:"\\prime"},arguments:"group"},{trigger:{superfix:"\\doubleprime"},parse:(e,t)=>[null,[V,null!=e?e:U,2]],arguments:"group"},{name:Q,serialize:(e,t)=>e.serialize(we(t,1))+"^{-1}"},{name:B,trigger:"D",parse:(e,t)=>[e,[B,1]],serialize:(e,t)=>{var i;const n=null!==(i=ae(we(t,1)))&&void 0!==i?i:NaN;if(!isFinite(n))return"";const r=e.serialize(we(t,2));return 1===n?r+"^{\\prime}":2===n?r+"^{\\doubleprime}":r+"^{("+Number(n).toString()+")}"}},{name:"Piecewise",trigger:{environment:"cases"},parse:(e,t)=>{var i;return[e,["Piecewise",null!==(i=t.matchTabular())&&void 0!==i?i:U]]},serialize:(e,t)=>{if(ve(we(t,1))!==L)return"";const i=be(we(t,1));let n="",r="";for(const t of i){n+=r;const i=we(t,1);if(null!==i){n+=e.serialize(i);const r=we(t,2);null!==r&&(n+="&"+e.serialize(r))}r="\\\\"}return"\\begin{cases}"+n+"\\end{cases}"}}];function qe(e,t){const i=ae(t);return null!==i?0===i:!!e.is(["Equal",t,0])||!0!==e.is(["NotEqual",t,0])&&!0!==e.is(["Greater",t,0])&&!0!==e.is(["Less",t,0])&&null===i&&void 0}function Ie(e,t){const i=qe(e,t);return void 0===i?void 0:!i}function Pe(e,t){if(null===t)return;const i=ae(t);if(null!==i&&!Number.isFinite(i))return!0;if(null!==i&&isNaN(i))return;const n=xe(t);if(n===X)return!0;if(n===z||n===U)return!1;if(e.is(t,"ComplexNumber"))return!1;const r=ve(t);if("Negate"===r){if(Pe(e,we(t,1)))return!0}else if("Multiply"===r){const i=be(t);if(i.some((t=>!0===Pe(e,t)))&&i.every((t=>!0===Ie(e,t))))return!0}return null===i&&void 0}function Te(e,t){if(null===t)return;const i=ae(t);if(null!==i)return i>0;const n=xe(t);if(n&&["Quarter","Third","Half","TwoThird","ThreeQuarter","MinusDoublePi","MinusPi","QuarterPi","ThirdPi","HalfPi","TwoThirdPi","ThreeQuarterPi","Pi","DoublePi","MachineEpsilon","CatalanConstant","GoldenRatio","EulerGamma","ExponentialE"].includes(n))return!0;if(e.is(["Greater",t,0]))return!0;if(e.is(["LessEqual",t,0]))return!1;if(e.is(["Less",t,0]))return!1;const r=ve(t);if(r){if(("Cosh"===r||"Exp"===r)&&Le(0,we(t,1)))return!0;if("Sqrt"===r&&Te(e,we(t,1)))return!0;if(r===H||r===j)return be(t).every((t=>!0===Te(e,t)));if(r===Z&&Te(e,we(t,1))&&Te(e,we(t,2)))return!0;if(r===W&&Te(e,we(t,1)))return!0}}function Oe(e,t){const i=Te(e,t);return!0!==i&&(void 0!==i?!1===qe(e,t):void 0)}function Le(e,t){return null!==t&&null!==ae(t)}function ze(e,t,i){var n,r,s;if(!t||!i)return!1;if("string"==typeof t&&t===i)return!0;if("Anything"===i)return!0;if("Nothing"===i)return!1;const o=ve(t);if("Union"===o)return be(t).some((t=>ze(e,t,i)));if("Intersection"===o)return be(t).every((t=>ze(e,t,i)));if("SetMinus"===o)return ze(e,we(t,1),i)&&!ze(e,we(t,2),i);const a=ve(i);if("Union"===a)return be(i).some((i=>ze(e,t,i)));if("Intersection"===a)return be(i).every((i=>ze(e,t,i)));if("SetMinus"===a)return ze(e,t,we(i,1))&&!ze(e,t,we(i,2));const l=null!==(n=xe(i))&&void 0!==n?n:a;if(!l){const e=null!==(r=ae(i))&&void 0!==r?r:NaN;if(Number.isNaN(e))return!1;i=0===i?"NumberZero":["Set",i]}const u=e.getSetDefinition(l);if(!u)return!1;if("function"==typeof u.isSubsetOf)return u.isSubsetOf(this,t,i);const c=null!==(s=xe(t))&&void 0!==s?s:o;if(!c)return!1;const f=e.getSetDefinition(c);if(!f)return!1;for(const t of f.supersets)if(ze(e,t,i))return!0;return!1}const Ue={MachineEpsilon:{domain:"RealNumber",constant:!0,value:{num:Number.EPSILON.toString()}},ImaginaryUnit:{domain:"ImaginaryNumber",constant:!0,wikidata:"Q193796"},ExponentialE:{domain:"TranscendentalNumber",wikidata:"Q82435",constant:!0,value:e=>"decimal"===e.numericFormat?h.exports.Decimal.exp(1):"complex"===e.numericFormat?m.exports.Complex.E:2.718281828459045},GoldenRatio:{domain:"IrrationalNumber",wikidata:"Q41690",constant:!0,hold:!1,value:["Divide",["Add",1,["Sqrt",5]],2]},CatalanConstant:{domain:"RealNumber",wikidata:"Q855282",constant:!0,value:{num:"0.91596559417721901505"}},EulerGamma:{domain:"RealNumber",wikidata:"Q273023",constant:!0,value:{num:"0.577215664901532860606"}},Quarter:{domain:"RationalNumber",wikidata:"Q2310416",constant:!0,hold:!1,value:[Z,3,4]},Third:{domain:"RationalNumber",wikidata:"Q20021125",constant:!0,hold:!1,value:[Z,1,3]},Half:{domain:"RationalNumber",wikidata:"Q2114394",constant:!0,hold:!1,value:[Z,1,2]},TwoThird:{domain:"RationalNumber",constant:!0,hold:!1,value:[Z,2,3]},ThreeQuarter:{domain:"RationalNumber",constant:!0,hold:!1,value:[Z,3,4]},Abs:{domain:"Function",wikidata:"Q3317982",threadable:!0,idempotent:!0,numeric:!0,range:["Interval",0,1/0],evalNumber:(e,t)=>Math.abs(t),evalComplex:(e,t)=>m.exports.Complex.abs(t),evalDecimal:(e,t)=>h.exports.Decimal.abs(t)},Add:{domain:"Function",wikidata:"Q32043",associative:!0,commutative:!0,threadable:!0,idempotent:!0,range:"Number",numeric:!0,simplify:function(e,...t){var i,n;if(0===t.length)return 0;if(1===t.length)return t[0];let r=0,s=1,o=p,a=m.exports.Complex.ZERO,l=!1,u=!1;const c=[];for(const i of t){const t=xe(i);if(t===z||t===U)return NaN;if(t===X)return X;Pe(e,i)&&(Te(e,i)?l=!0:u=!0);const[n,f]=he(i);if(null!==n&&null!==f){if(isNaN(n)||isNaN(f))return NaN;r=r*f+n*s,s*=f}else{const t=le(i);if(null!==t)Number.isInteger(t.re)&&Number.isInteger(t.im)?a=a.add(t):c.push(i);else{const t=ce(i);if(null!==t&&t.isInteger())o=o.add(t);else{const t=ae(i);null!==t&&Number.isInteger(t)?r+=t:!1!==Ie(e,i)&&c.push(i)}}}}if(l&&u)return NaN;if(l)return 1/0;if(u)return-1/0;if(o.isZero()||c.push(o),a.isZero()||c.push(a),0===c.length)return 0===r?0:1===s?r:["Divide",r,s];if(0!==r){const e=_(r,s);r/=e,s/=e,1===s?c.push(r):c.push(["Divide",r,s])}return 1===c.length?c[0]:2===c.length&&ve(c[1])===G?["Subtract",c[0],null!==(i=we(c[1],1))&&void 0!==i?i:z]:2===c.length&&ve(c[0])===G?["Subtract",c[1],null!==(n=we(c[0],1))&&void 0!==n?n:z]:["Add",...c]},evalNumber:(e,...t)=>{if(0===t.length)return 0;let i=0;for(const e of t)i+=e;return i},evalComplex:(e,...t)=>{if(0===t.length)return m.exports.Complex.ZERO;let i=m.exports.Complex.ZERO;for(const e of t)i=i.add(e);return i},evalDecimal:(e,...t)=>{if(0===t.length)return p;let i=p;for(const e of t)i=i.add(e);return i},evaluate:(e,...t)=>{if(0===t.length)return 0;let i=["Add"];const n=t.filter((e=>e instanceof h.exports.Decimal));n.length>0&&(1===n.length?i.push(n[0]):i.push(e.N(["Add",...n])));const r=t.filter((e=>e instanceof m.exports.Complex));r.length>0&&(1===r.length?i.push(r[0]):i.push(e.N(["Add",...r])));const s=t.filter((e=>"number"==typeof e));s.length>0&&(1===s.length?i.push(s[0]):i.push(e.N(["Add",...s])));const o=t.filter((e=>!("number"==typeof e||e instanceof h.exports.Decimal||e instanceof m.exports.Complex)));return i=[...i,...o],0===i.length?0:1===i.length?i[1]:i}},Chop:{domain:"Function",associative:!0,threadable:!0,idempotent:!0,numeric:!0,range:"Number",evalNumber:(e,t)=>e.chop(t),evalComplex:(e,t)=>e.chop(t),evalDecimal:(e,t)=>e.chop(t)},Ceil:{domain:"Function",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.ceil(t),evalComplex:(e,t)=>m.exports.Complex.ceil(t),evalDecimal:(e,t)=>h.exports.Decimal.ceil(t)},Divide:{domain:"Function",range:"Number",numeric:!0,evalNumber:(e,t,i)=>t/i,evalComplex:(e,t,i)=>"number"==typeof t?new m.exports.Complex(t).div(i):t.div(i),evalDecimal:(e,t,i)=>h.exports.Decimal.div(t,i)},Exp:{domain:["ContinuousFunction","MonotonicFunction"],wikidata:"Q168698",threadable:!0,range:"Number",numeric:!0,evalNumber:(e,t)=>Math.exp(t),evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t).exp():t.exp(),evalDecimal:(e,t)=>h.exports.Decimal.exp(t)},Erf:{domain:["ContinuousFunction","MonotonicFunction"],range:"Number",numeric:!0},Erfc:{domain:["ContinuousFunction","MonotonicFunction"],range:"Number",numeric:!0},Factorial:{wikidata:"Q120976",domain:"MonotonicFunction",range:"Integer",numeric:!0,evalNumber:(e,t)=>function(e){if(!Number.isInteger(e)||e<0)return NaN;let t=1;for(let i=2;i<=e;i++)t*=i;return t}(t),evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t+1):t.add(1),evalDecimal:(e,t)=>y(t)},Floor:{domain:"Function",wikidata:"Q56860783",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.floor(t),evalDecimal:(e,t)=>h.exports.Decimal.floor(t)},Gamma:{domain:"Function",wikidata:"Q190573",range:"Number",numeric:!0,evalNumber:(e,t)=>I(t),evalDecimal:(e,t)=>E(t)},LogGamma:{domain:"Function",range:"Number",numeric:!0,evalNumber:(e,t)=>q(t),evalDecimal:(e,t)=>M(t)},Ln:{domain:"Function",wikidata:"Q11197",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.log(t),evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t).log():t.log(),evalDecimal:(e,t)=>h.exports.Decimal.log(t)},Log:{domain:"Function",range:"Number",numeric:!0,evalNumber:(e,t,i)=>Math.log(i)/Math.log(t),evalComplex:(e,t,i)=>{const n="number"==typeof t?new m.exports.Complex(t):t;return("number"==typeof i?new m.exports.Complex(i):i).log().div(n.log())},evalDecimal:(e,t,i)=>h.exports.Decimal.log(i).div(h.exports.Decimal.log(t))},Lb:{domain:"Function",wikidata:"Q581168",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.log2(t),evalComplex:(e,t,i)=>("number"==typeof i?new m.exports.Complex(i):i).log().div(m.exports.Complex.log(2)),evalDecimal:(e,t)=>h.exports.Decimal.log(t).div(h.exports.Decimal.log(2))},Lg:{domain:"Function",wikidata:"Q966582",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.log10(t),evalComplex:(e,t,i)=>("number"==typeof i?new m.exports.Complex(i):i).log().div(m.exports.Complex.log(10)),evalDecimal:(e,t)=>h.exports.Decimal.log(t).div(h.exports.Decimal.log(10))},Multiply:{domain:"Function",wikidata:"Q40276",associative:!0,commutative:!0,idempotent:!0,range:"Number",simplify:function(e,...t){if(0===t.length)return 1;if(1===t.length)return t[0];const i=[];let n=1,r=1,s=m.exports.Complex.ONE;for(const o of t){const t=ae(o);if(0===t)return 0;if(null===t||Number.isFinite(t)&&!Number.isInteger(t)){const[t,a]=[null,null];if(null!==t&&null!==a)n*=t,r*=a;else{const t=le(o);if(null!==t)Number.isInteger(t.re)&&Number.isInteger(t.im)?s=s.mul(t):i.push(o);else{if(qe(e,o))return 0;i.push(o)}}}else n*=t}return 0!==s.im?(s=s.mul(n),n=1):(n*=s.re,s=m.exports.Complex.ONE),0!==n&&isFinite(n)?(s.equals(m.exports.Complex.ONE)||i.push(["Complex",s.re,s.im]),0===i.length?1===r?n:["Divide",n,r]:(1!==r&&(i.unshift(["Divide",n,r]),n=1,r=1),1===i.length&&1===n?i[0]:1===i.length&&-1===n?["Negate",i[0]]:1===n?["Multiply",...i]:-1===n?["Negate",["Multiply",...i]]:["Multiply",n,...i])):n/r},numeric:!0,evalNumber:function(e,...t){if(0===t.length)return 1;if(1===t.length)return t[0];let i=1;for(const e of t)i*=e;return i},evalComplex:(e,...t)=>{if(0===t.length)return m.exports.Complex.ONE;let i=m.exports.Complex.ONE;for(const e of t)i=i.mul(e);return i},evalDecimal:(e,...t)=>{if(0===t.length)return g;let i=g;for(const e of t)i=i.mul(e);return i},evaluate:(e,...t)=>{if(0===t.length)return 0;let i=["Multiply"];const n=t.filter((e=>e instanceof h.exports.Decimal));n.length>0&&(1===n.length?i.push(n[0]):i.push(e.N(["Multiply",...n])));const r=t.filter((e=>e instanceof m.exports.Complex));r.length>0&&(1===r.length?i.push(r[0]):i.push(e.N(["Multiply",...r])));const s=t.filter((e=>"number"==typeof e));s.length>0&&(1===s.length?i.push(s[0]):i.push(e.N(["Multiply",...s])));const o=t.filter((e=>!("number"==typeof e||e instanceof h.exports.Decimal||e instanceof m.exports.Complex)));return i=[...i,...o],0===i.length?1:1===i.length?i[1]:i}},Negate:{domain:"Function",wikidata:"Q715358",range:"Number",simplify:(e,t)=>{var i;return null!==(i=Re(t))&&void 0!==i?i:["Negate",t]},numeric:!0,evalNumber:(e,t)=>-t,evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(-t):t.neg(),evalDecimal:(e,t)=>"number"==typeof t?new h.exports.Decimal(-t):t.neg()},Power:{domain:"Function",wikidata:"Q33456",commutative:!1,numeric:!0,range:"Number",simplify:(e,...t)=>je(e,["Power",...t]),evalNumber:(e,t,i)=>Math.pow(t,i),evalComplex:(e,t,i)=>{const n="number"==typeof t?new m.exports.Complex(t):t,r="number"==typeof i?new m.exports.Complex(i):i;return m.exports.Complex.pow(n,r)},evalDecimal:(e,t,i)=>h.exports.Decimal.pow(t,i)},Round:{domain:"Function",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.round(t),evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t).round():t.round(),evalDecimal:(e,t)=>h.exports.Decimal.round(t)},Sign:{domain:"Function",range:["Range",-1,1],numeric:!0,simplify:(e,t)=>qe(e,t)?0:Oe(e,t)?-1:1,evalNumber:(e,t)=>0===t?0:t<0?-1:1,evalComplex:(e,t)=>{const i="number"==typeof t?new m.exports.Complex(t):t;return i.div(i.abs())},evalDecimal:(e,t)=>"number"==typeof t?0===t?p:t<0?d:g:t.isZero()?p:t.isNeg()?d:g},SignGamma:{domain:"Function",range:"Number",numeric:!0},Sqrt:{domain:"Function",wikidata:"Q134237",range:"Number",numeric:!0,evalNumber:(e,t)=>Math.sqrt(t),evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t).sqrt():t.sqrt(),evalDecimal:(e,t)=>h.exports.Decimal.sqrt(t)},Square:{domain:"Function",wikidata:"Q3075175",range:"Number",numeric:!0,evalNumber:(e,t)=>t*t,evalComplex:(e,t)=>"number"==typeof t?new m.exports.Complex(t).multiply(t):t.mul(t),evalDecimal:(e,t)=>h.exports.Decimal.mul(t,t)},Root:{domain:"Function",commutative:!1,range:"Number",numeric:!0,evalNumber:(e,t,i)=>Math.pow(t,1/i),evalComplex:(e,t,i)=>{const n="number"==typeof t?new m.exports.Complex(t):t,r="number"==typeof i?new m.exports.Complex(1/i):new m.exports.Complex(m.exports.Complex.ONE.div(i));return m.exports.Complex.pow(n,r)},evalDecimal:(e,t,i)=>h.exports.Decimal.pow(t,g.div(i))},Subtract:{domain:"Function",wikidata:"Q32043",range:"Number",numeric:!0,evalNumber:(e,t,i)=>t-i,evalComplex:(e,t,i)=>"number"==typeof t?new m.exports.Complex(t).sub(i):t.sub(i),evalDecimal:(e,t,i)=>h.exports.Decimal.sub(t,i)}};function Re(e){var t,i,n,r;if("number"==typeof(e=$e(e)))return-e;if(e&&ie(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 m.exports.Complex)return e.mul(-1);const s=ve(e),o=Se(e);if(s===G&&1===o)return null!==(t=we(e,1))&&void 0!==t?t:z;if(s===H){const t=Re(null!==(i=we(e,1))&&void 0!==i?i:z);return[H,t,...be(e).slice(1)]}return s===j?[j,...Ne(e,Re)]:s===K?[K,null!==(n=we(e,2))&&void 0!==n?n:z,null!==(r=we(e,1))&&void 0!==r?r:z]:s===P&&1===o?Re(we(we(e,1),1)):[G,null!=e?e:z]}function $e(e){return null===e?U:de(e)?e:ge(e)===P&&1===Se(e)?$e(we(e,1)):ye(e,$e)}function je(e,t){var i,n;if(2!==Se(t=$e(t)))return t;const r=we(t,1),s=null!==(i=ae(r))&&void 0!==i?i:NaN,o=we(t,2);if("ComplexInfinity"===xe(o))return NaN;const a=null!==(n=ae(o))&&void 0!==n?n:NaN;if(qe(e,o))return 1;if(1===a)return r;if(2===a)return["Square",r];if(-1===a)return-1===s||1===s?-1:Number.isFinite(s)?["Divide",1,r]:0;if(!Number.isFinite(a)){if(0===s&&a<0)return"ComplexInfinity";if(1===s||-1===s)return NaN;if(s===1/0){if(a>0)return 1/0;if(a<0)return 0}if(s===-1/0&&!Number.isFinite(a))return NaN}return t}function Be(e){if(de(e))return e;let[t,i]=he(e);return 3===t&&4===i?"ThreeQuarter":2===t&&3===i?"TwoThird":1===t&&2===i?"Half":1===t&&4===i?"Quarter":([t,i]=me(e,"Pi"),null===t||null===i?ye(e,(e=>Be(e))):-2===t&&1===i?"MinusDoublePi":-1===t&&2===i?"MinusHalfPi":1===t&&4===i?"QuarterPi":1===t&&3===i?"ThirdPi":1===t&&2===i?"HalfPi":2===t&&3===i?"TwoThirdPi":3===t&&4===i?"ThreeQuarterPi":2===t&&1===i?"DoublePi":1===t&&1===i?"Pi":1===t?["Divide","Pi",i]:1===i?["Multiply",t,"Pi"]:["Multiply",["Divide",t,i],"Pi"])}function Ze(e,t,i,n){return null===i?"\\sqrt{}":(n=null!=n?n:2,"solidus"===t?e.wrapShort(i)+"^{1\\/"+e.serialize(n)+"}":"quotient"===t?e.wrapShort(i)+"^{\\frac{1}{"+e.serialize(n)+"}}":2===ae(n)?"\\sqrt{"+e.serialize(i)+"}":"\\sqrt["+e.serialize(n)+"]{"+e.serialize(i)+"}")}function Qe(e,t,i){if(!t.match("\\sqrt"))return[e,null];const n=t.matchOptionalLatexArgument(),r=t.matchRequiredLatexArgument();return null===r?null!==n?[e,[Y,U,n]]:[e,[J]]:null!==n?[e,[Y,r,n]]:[e,[J,r]]}function He(e,t,i){if(276<i)return[e,null];const n=t.index;if(!t.match("-"))return[e,null];const r=t.matchExpression(null===e?400:277);return null===r?(t.index=n,[e,null]):null===e?[null,[G,r]]:[null,[K,e,r]]}function Ge(e,t){var i;if(null===t)return"";e.level-=1;let n="";const[r,s]=function(e){var t,i,n,r,s,o;if(ve(e)!==H)return[[],[]];const a=[],l=[],u=be(e);for(const e of u)if(ve(e)===W)if(ve(we(e,2))===G){const n=null!==(t=we(e,1))&&void 0!==t?t:U,r=null!==(i=we(we(e,2),1))&&void 0!==i?i:U;l.push([W,n,r])}else{const t=null!==(n=ae(we(e,2)))&&void 0!==n?n:NaN;-1===t?l.push(null!==(r=we(e,1))&&void 0!==r?r:U):t<0?l.push([W,null!==(s=we(e,1))&&void 0!==s?s:U,null!==(o=Re(we(e,2)))&&void 0!==o?o:U]):a.push(e)}else a.push(e);return[a,l]}(t);if(s.length>0&&(n=1===s.length&&1===s[0]?0===r.length?"1":1===r.length?e.serialize(r[0]):Ge(e,[H,...r]):e.serialize([Z,1===r.length?r[0]:[H,...r],1===s.length?s[0]:[H,...s]])),n)return e.level+=1,n;let o=!1,a=null;const l=Se(t)+1;let c=!1;for(let r=1;r<l;r++)if(a=we(t,r),null!==a){let t;"number"==typeof a||ie(a)?(t=e.serialize(a),"-1"!==t||n?("-"===t[0]&&(t=t.slice(1),o=!o),n=n?u([n,e.options.multiply,t]):t):n="-",c=!0):ve(a)!==W||isNaN(null!==(i=ae(we(a,1)))&&void 0!==i?i:NaN)?(ve(a)===G&&(a=we(a,1),o=!o),t=e.wrap(a,390),n=n?c&&ve(a)===Z?u([n,"\\times",t]):e.options.invisibleMultiply?u([n,e.options.invisibleMultiply,t]):u([n,t]):t,c=!1):(n=n?u([n,e.options.multiply,e.serialize(a)]):e.serialize(a),c=!0)}return e.level+=1,o?"-"+n:n}function We(e,t){if(null===t)return"";if(1===Se(t))return e.serialize(we(t,1));const i=e.level>3?"inline-solidus":"quotient";if("inline-solidus"===i||"nice-solidus"===i){const n=e.wrapShort(we(t,1)),r=e.wrapShort(we(t,2));return"nice-solidus"===i?`^{${n}}\\!\\!/\\!_{${r}}`:`${n}\\/${r}`}return"reciprocal"===i?e.wrap(we(t,1))+e.wrap(we(t,2))+"^{-1}":"factor"===i?"\\frac{1}{"+e.serialize(we(t,2))+"}"+e.wrap(we(t,1)):"\\frac{"+e.serialize(we(t,1))+"}{"+e.serialize(we(t,2))+"}"}function Ve(e,t){var i;const n=we(t,1),r=we(t,2);if(null===r)return e.serialize(n);if(null===n)return"";const s=ve(t);if(s===J||s===Y)return Ze(e,De(0,e.level),we(t,1),we(t,2));const o=null!==(i=ae(r))&&void 0!==i?i:1;if(-1===o)return e.serialize([Z,"1",n]);if(o<0)return e.serialize([Z,"1",[W,n,-o]]);if(ve(r)===Z){if(1===ae(we(r,1)))return Ze(e,De(0,e.level),n,we(r,2))}else if(ve(r)===W&&-1===ae(we(r,2)))return Ze(e,De(0,e.level),n,we(r,1));return e.wrapShort(n)+"^{"+e.serialize(r)+"}"}function Ye(e,t,i){var n;const r=t.next();let s=!1,o=0;if(t.skipSpace(),t.match("^")){if(t.skipSpace(),t.match("<{>")){t.skipSpace(),t.match("-")&&t.match("1")&&(s=!0);do{t.match("\\doubleprime")&&(o+=2),t.match("\\prime")&&(o+=1),t.match("'")&&(o+=1)}while(!t.match("<}>")&&!t.atEnd)}let e=!1;for(;!e;)t.skipSpace(),t.match("\\doubleprime")?o+=2:t.match("\\prime")||t.match("'")?o+=1:e=!0}let a=null!==(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"}[r])&&void 0!==n?n:r;s&&(a=[Q,a]),o>=1&&(a=[B,o,a]);const l=t.matchArguments("implicit");return null===l?[null,a]:[null,[a,...l]]}function Je(e){return c(e)}const Ke={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,t)=>{const i=ae(we(t,1)),n=ae(we(t,2));if(0===n)return e.serialize(we(t,1));const r=1===n?"\\imaginaryI":-1===n?"-\\imaginaryI":u([e.serialize(we(t,2)),"\\imaginaryI"]);return 0===i?r:u([e.serialize(we(t,1)),"+",r])}},{name:"Exp",serialize:(e,t)=>{var i;return u(["\\exponentialE^{",e.serialize(null!==(i=we(t,1))&&void 0!==i?i:U),"}"])}},{name:"Square",serialize:(e,t)=>e.wrapShort(we(t,1))+"^2"},{trigger:{symbol:"\\infty"},parse:{num:"+Infinity"}},{name:X,trigger:{symbol:["\\tilde","\\infty"]},serialize:"\\tilde\\infty"},{name:X,trigger:{symbol:["\\tilde","<{>","\\infty","<}>"]},serialize:"\\tilde\\infty"},{name:"Pi",trigger:{symbol:"\\pi"}},{name:"Pi",trigger:{symbol:"π"},serialize:"\\pi"},{name:ee,trigger:{symbol:"e"},serialize:"e"},{name:te,trigger:{symbol:"i"},serialize:"\\imaginaryI"},{name:te,trigger:{symbol:"\\imaginaryI"}},{name:j,trigger:{prefix:"+",infix:"+"},parse:function(e,t,i){if(275<i)return[e,null];const n=t.index;if(!t.match("+"))return[e,null];const r=t.matchExpression(null===e?400:275);return null===r?(t.index=n,[e,null]):null===e?[null,r]:t.applyOperator(j,e,r)},serialize:function(e,t){var i,n;e.level-=1;const r=ve(t);let s="",o=we(t,1),a=!Number.isNaN(null!==(i=ae(o))&&void 0!==i?i:NaN);if(r===G)s="-"+e.wrap(o,276);else if(r===j){s=e.serialize(o);const i=Se(t)+1;for(let r=2;r<i;r++){o=we(t,r);const i=null!==(n=ae(o))&&void 0!==n?n:NaN,l=!Number.isNaN(i);let u=!1;if(null!==o&&a){const[t,i]=he(o);null!==t&&null!==i&&isFinite(t)&&isFinite(i)&&1!==i&&(s+=e.options.invisiblePlus+e.serialize(o),u=!0)}if(!u)if(i<0)s+=e.serialize(o);else if(ve(o)===G)s+=e.wrap(o,275);else{const t=e.wrap(o,275);"-"===t[0]||"+"===t[0]?s+=t:s=s+"+"+t}a=l}}else if(r===K){const i=we(t,2);s=null!==i?e.wrap(o,275)+"-"+e.wrap(i,275):e.wrap(o,275)}return e.level+=1,s},associativity:"both",precedence:275},{name:G,trigger:{prefix:"-"},parse:He,associativity:"left",precedence:275},{name:K,trigger:{infix:"-"},parse:He,associativity:"both",precedence:275},{name:"PlusMinus",trigger:{infix:"\\pm"},associativity:"both",precedence:270},{name:"MinusPlus",trigger:{infix:"\\mp"},associativity:"both",precedence:270},{name:H,trigger:{infix:"\\times"},serialize:Ge,associativity:"both",precedence:390},{name:H,trigger:{infix:"\\cdot"},serialize:Ge,associativity:"both",precedence:390},{name:H,trigger:{infix:"*"},serialize:Ge,associativity:"both",precedence:390},{name:Z,trigger:"\\frac",parse:function(e,t,i){var n,r,s,o;if(!t.match("\\frac"))return[e,null];const a=null!==(n=t.matchRequiredLatexArgument())&&void 0!==n?n:z,l=null!==(r=t.matchRequiredLatexArgument())&&void 0!==r?r:z;if("PartialDerivative"===ve(a)&&("PartialDerivative"===ve(l)||ve(l)===H&&"PartialDerivative"===ve(we(l,1)))){const i=null!==(s=we(a,3))&&void 0!==s?s:U;let n=we(a,1);null!==n&&n!==U||(n=null!==(o=t.matchExpression())&&void 0!==o?o:U);let r=[];if(ve(l)===H){for(const e of be(l))if("PartialDerivative"===ge(e)){const t=we(e,2);t&&r.push(t)}}else{const e=we(l,2);e&&r.push(e)}return r.length>1&&(r=[L,...r]),[e,["PartialDerivative",n,r,i===U?1:i]]}return[e,[Z,a,l]]},serialize:We,requiredLatexArg:2},{name:Z,trigger:{infix:"\\/"},serialize:We,associativity:"non",precedence:660},{name:Z,trigger:{infix:"/"},serialize:We,associativity:"non",precedence:660},{name:Z,trigger:{infix:"\\div"},serialize:We,associativity:"non",precedence:660},{name:W,trigger:{infix:"^"},associativity:"non",precedence:720,serialize:Ve},{name:W,trigger:{infix:["*","*"]},associativity:"non",precedence:720,serialize:Ve},{name:J,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:Qe,serialize:Ve},{name:Y,trigger:"\\sqrt",optionalLatexArg:1,requiredLatexArg:1,parse:Qe},{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,t,i){if(!t.match("\\int"))return[e,null];let n=U,r=U,s=!1;for(;!s;)t.skipSpace(),t.match("_")?r=t.matchRequiredLatexArgument():t.match("^")?n=t.matchRequiredLatexArgument():s=!0;const o=t.matchBalancedExpression("<{>","<}>");return[e,["Integral",null!=o?o:"",null!=n?n:U,null!=r?r:U]]},serialize:function(e,t){return""}}],core:Fe,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:Ae,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:Ye},{name:"Arccos",trigger:"\\arccos",arguments:"implicit",parse:Ye},{name:"Arctan",trigger:"\\arctan",arguments:"implicit",parse:Ye},{name:"Arctan",trigger:"\\arctg",arguments:"implicit",parse:Ye},{name:"Arccot",trigger:"\\arcctg",arguments:"implicit",parse:Ye},{name:"Arcsec",trigger:"\\arcsec",arguments:"implicit",parse:Ye},{name:"Arccsc",trigger:"\\arccsc",arguments:"implicit",parse:Ye},{name:"Arsinh",trigger:"\\arsinh",arguments:"implicit",parse:Ye},{name:"Arcosh",trigger:"\\arcosh",arguments:"implicit",parse:Ye},{name:"Artanh",trigger:"\\artanh",arguments:"implicit",parse:Ye},{name:"Arsech",trigger:"\\arsech",arguments:"implicit",parse:Ye},{name:"Arcsch",trigger:"\\arcsch",arguments:"implicit",parse:Ye},{name:"Cosh",trigger:"\\ch",arguments:"implicit",parse:Ye},{name:"Cosec",trigger:"\\cosec",arguments:"implicit",parse:Ye},{name:"Cosh",trigger:"\\cosh",arguments:"implicit",parse:Ye},{name:"Cot",trigger:"\\cot",arguments:"implicit",parse:Ye},{name:"Cot",trigger:"\\cotg",arguments:"implicit",parse:Ye},{name:"Coth",trigger:"\\coth",arguments:"implicit",parse:Ye},{name:"Csc",trigger:"\\csc",arguments:"implicit",parse:Ye},{name:"Cot",trigger:"\\ctg",arguments:"implicit",parse:Ye},{name:"Coth",trigger:"\\cth",arguments:"implicit",parse:Ye},{name:"Sec",trigger:"\\sec",arguments:"implicit",parse:Ye},{name:"Sinh",trigger:"\\sinh",arguments:"implicit",parse:Ye},{name:"Sinh",trigger:"\\sh",arguments:"implicit",parse:Ye},{name:"Tan",trigger:"\\tan",arguments:"implicit",parse:Ye},{name:"Tan",trigger:"\\tg",arguments:"implicit",parse:Ye},{name:"Tanh",trigger:"\\tanh",arguments:"implicit",parse:Ye},{name:"Tanh",trigger:"\\th",arguments:"implicit",parse:Ye},{name:"Cos",trigger:"\\cos",arguments:"implicit",parse:Ye},{name:"Sin",trigger:"\\sin",arguments:"implicit",parse:Ye}]},Xe={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"},et={invisibleOperator:H,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:j,preserveLatex:!1},tt={invisibleMultiply:"",invisiblePlus:"",multiply:"\\times"};function it(e,t){var i;let n=e;for(let e=0;e<t.length;e++){let r=null!==(i=t[e])&&void 0!==i?i:"";if(/[a-zA-Z*]/.test(r[0])){const t=n.match(new RegExp("(.*)#"+Number(e+1).toString()));t&&/\\[a-zA-Z*]+/.test(t[1])&&(r=" "+r)}n=n.replace("#"+Number(e+1).toString(),r)}return n}class nt{constructor(e,t,i,n){let r;this.index=0,this.options={...Xe,...et,...t},this.tokens=e,this.onError=e=>n({...e,before:this.latexBefore(),after:this.latexAfter()}),this.dictionary=i,this.invisibleOperatorPrecedence=0,this.options.invisibleOperator&&(r=this.dictionary.name.get(this.options.invisibleOperator),void 0===r?n({code:"unknown-operator",arg:"invisible operator "+this.options.invisibleOperator}):void 0===r.precedence?n({code:"expected-operator",arg:"invisible operator "+this.options.invisibleOperator}):this.invisibleOperatorPrecedence=r.precedence)}clone(e,t){return new nt(this.tokens.slice(e,t),this.options,this.dictionary,this.onError)}balancedClone(e,t,i=!0){if(!this.matchAll(e))return i||this.onError({code:"syntax-error",arg:"Expected "+c(e)}),null;const n=this.index;let r=n,s=1;for(;!this.atEnd&&0!==s;)this.skipSpace(),r=this.index,this.matchAll(t)?s-=1:this.matchAll(e)?s+=1:this.next();return 0!==s?(i||this.onError({code:"unbalanced-symbols",arg:c(e)+c(t)}),this.index=n,null):this.clone(n,r)}get atEnd(){return this.index>=this.tokens.length}get peek(){return this.tokens[this.index]}latex(e,t){return c(this.tokens.slice(e,t))}latexAhead(e){return c(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 t=[];for(;e>0;)t[e]=this.latexAhead(e--);return t}peekDefinition(e){let t;t="operator"===e?this.lookAhead().map(((e,t)=>{var i,n,r,s,o;return null!==(s=null!==(n=null===(i=this.dictionary.infix[t])||void 0===i?void 0:i.get(e))&&void 0!==n?n:null===(r=this.dictionary.postfix[t])||void 0===r?void 0:r.get(e))&&void 0!==s?s:null===(o=this.dictionary.prefix[t])||void 0===o?void 0:o.get(e)})):this.lookAhead().map(((t,i)=>{var n;return null===(n=this.dictionary[e][i])||void 0===n?void 0:n.get(t)}));for(let e=t.length;e>0;e--)if(void 0!==t[e])return[t[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 t=!0;"string"==typeof e&&(e=[e]);let i=0;do{t=this.tokens[this.index+i]===e[i++]}while(t&&i<e.length);return t&&(this.index+=i),t}matchAny(e){return e.includes(this.tokens[this.index])?this.tokens[this.index++]:""}matchWhile(e){const t=[];for(;e.includes(this.tokens[this.index]);)t.push(this.tokens[this.index++]);return t}matchSign(){let e=!1,t=!1;for(;!t;)this.skipSpace()?t=!1:this.match("-")?(e=!e,t=!1):t=!this.match("+");return e?"-":"+"}matchDecimalDigits(){let e="",t=!1;for(;!t;)if(e+=this.matchWhile(["0","1","2","3","4","5","6","7","8","9"]).join(""),t=!0,this.options.groupSeparator){const e=this.index;this.match(this.options.groupSeparator)&&(/[0-9]/.test(this.peek)?t=!1:this.index=e)}return e}matchSignedInteger(){const e=this.index,t=this.matchSign(),i=this.matchDecimalDigits();return i?("-"===t?"-":"")+i:(this.index=e,"")}matchExponent(){const e=this.index;let t="";if(this.matchAny(["e","E","d","D"])){const e=this.matchSignedInteger();e&&(t="e"+e)}if(t)return t;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,t;if(!this.options.parseNumbers)return"";const i=this.index,n=this.matchSign();let r=this.matchDecimalDigits();if(!r)return this.index=i,"";r=("-"===n?"-":"")+r;let s=!1,o=!1;this.match(null!==(e=this.options.decimalMarker)&&void 0!==e?e:"")&&(s=!0,r+="."+(null!==(t=this.matchDecimalDigits())&&void 0!==t?t:"0"));const a=this.matchExponent();return a&&(o=!0),r?r.length+a.length>12?s||o?r+a+"d":r+"n":r+a:(this.index=i,"")}matchOperator(e,t=null,i=0){const[n,r]=this.peekDefinition(e);if(null===n)return null;if("function"==typeof n.parse){let e=null;return[t,e]=n.parse(t,this,i),null===e?null:this.applyInvisibleOperator(t,e)}let s=n.precedence;if(void 0===s||s<i)return null;s+="left"===n.associativity?1:0,this.index+=r;const o=this.matchExpression(s);return this.applyInvisibleOperator(...this.applyOperator(n.parse,t,o))}matchArguments(e){if(!e)return null;const t=this.index;let i=null;const n=this.matchMatchfixOperator();if("group"===e&&ve(n)===P)i=be(n);else if("implicit"===e)if(ve(n)===P)i=be(n);else if(null!==n)i=[n];else{const e=this.matchPrimary();null!==e&&(i=[e])}else this.index=t;return i}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 t="object"==typeof e.trigger?e.trigger.matchfix:e.trigger;if(!t||!e.closeFence||!e.parse)return null;const i=this.matchBalancedExpression(t,e.closeFence,this.onError);return i?[e.parse,i]:[e.parse]}matchDefinition(e){const[t,i]=this.peekDefinition(e);if("function"==typeof(null==t?void 0:t.parse)){const[,e]=t.parse(null,this,0);return[t,e]}return this.index+=i,[t,null]}matchSymbol(){var e,t,i,n;const[r,s]=this.matchDefinition("symbol");if(null!==s)return s;if(null===r){if(null===(e=this.options.promoteUnknownFunctions)||void 0===e?void 0:e.test(this.peek)){const e=this.next(),t=this.matchMatchfixOperator();return null===t?e:ve(t)!==P?null:[e,...be(t)]}return(null===(t=this.options.promoteUnknownSymbols)||void 0===t?void 0:t.test(this.peek))?this.next():this.matchUnknownLatexCommand()}const o=[],a=[];let l,u=null!==(i=r.optionalLatexArg)&&void 0!==i?i:0;for(;u>0;)l=this.matchOptionalLatexArgument(),null!==l&&a.push(l),u--;for(u=null!==(n=r.requiredLatexArg)&&void 0!==n?n:0;u>0;)l=this.matchRequiredLatexArgument(),null===l&&this.onError({code:"expected-argument"}),null!==l&&o.push(l),u--;const c=this.matchArguments(r.arguments);return null===c?0===o.length&&0===a.length?r.parse:[r.parse,...o,...a]:[r.parse,...o,...c,...a]}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 t=null;return this.skipSpace(),[["^","superfix"],["_","subfix"]].forEach((i=>{var n,r,s;if(null!==t)return;const[o,a]=i,l=this.index;if(!this.match(o))return;const u=this.index;let c,f=0;if(this.match("<{>")?([c,f]=this.peekDefinition(a),c?"function"==typeof c.parse?t=c.parse(e,this,0)[1]:(this.index+=f,this.match("<}>")?t=[null!==(n=c.parse)&&void 0!==n?n:c.name,e]:this.index=u):this.index=u):([c,f]=this.peekDefinition(a),c?"function"==typeof c.parse?t=c.parse(e,this,0)[1]:(this.index+=f,t=[null!==(r=c.parse)&&void 0!==r?r:c.name,e]):this.index=u),null===t&&(c=null===(s=this.dictionary.infix[1])||void 0===s?void 0:s.get(o),"function"==typeof(null==c?void 0:c.parse)?(this.index=l,t=c.parse(e,this,0)[1]):"string"==typeof(null==c?void 0:c.parse)?([e,t]=this.applyOperator(c.parse,e,this.matchRequiredLatexArgument()),t=this.applyInvisibleOperator(e,t)):t=this.applyInvisibleOperator(e,o)),null!==t){const e=this.matchArguments(null==c?void 0:c.arguments);null!==e&&(t=[t,...e])}})),t}matchPostfix(e){if(null===e)return null;const[t,i]=this.peekDefinition("postfix");return null==t?null:"function"==typeof t.parse?([,e]=t.parse(e,this,0),null===e?null:e):(this.index+=i,[t.parse,e])}matchString(){let e="",t=this.atEnd;for(;!t;){if(this.match("<space>"))e+=" ";else{const i=this.peek;"]"===i?t=!0:/^<({|}|\$|\$\$|space)>$/.test(i)?"\\"===i[0]?(this.onError({code:"unexpected-command"}),e+=this.next()):t=!0:e+=this.next()}t=t||this.atEnd}return e}matchEnvironmentName(e,t){if(this.match(e)){const e=this.index;if(this.match("<{>")){const e=this.matchString();if(this.match("<}>")&&e===t)return!0}this.index=e}return!1}matchTabular(){const e=["list"];let t=["list"],i=null,n=!1;for(;!this.atEnd&&!n;)if(this.match("&"))t.push(null!=i?i:U),i=null;else if(this.match("\\\\")||this.match("\\cr"))this.skipSpace(),this.matchOptionalLatexArgument(),null!==i&&t.push(i),e.push(t),t=["list"],i=null;else{const e=this.matchExpression();null===e&&(n=!0),i=null!==i?this.applyInvisibleOperator(i,e):e}return t.length>1&&e.push(t),e}matchEnvironment(){var e;if(this.match("\\begin")&&this.match("<{>")){const t=this.matchString();if(this.match("<}>")){const i=this.index;let n=this.index,r=1;for(;!this.atEnd&&0!==r;)n=this.index,this.matchEnvironmentName("\\begin",t)?r+=1:this.matchEnvironmentName("\\end",t)?r-=1:this.next();const s=this.dictionary.environment.get(t);return"function"==typeof(null==s?void 0:s.parse)?s.parse(null,this.clone(i,n),0)[1]:null!==(e=null==s?void 0:s.parse)&&void 0!==e?e:null}}return null}applyOperator(e,t,i){var n,r,s,o;const a=this.dictionary.name.get(e);if(void 0===a)return this.onError({code:"unknown-operator"}),[t,i];if(void 0!==(null===(n=a.trigger)||void 0===n?void 0:n.prefix)&&null===t&&null!==i)return[null,[a.name,i]];if(void 0!==(null===(r=a.trigger)||void 0===r?void 0:r.postfix)&&null!==t)return[null,[a.name,t]];if(void 0!==(null===(s=a.trigger)||void 0===s?void 0:s.matchfix)||void 0!==(null===(o=a.trigger)||void 0===o?void 0:o.infix)){if("non"===a.associativity)return[null,[e,null!=t?t:"Missing",null!=i?i:"Missing"]];if(ve(t)===e){if("both"===a.associativity){if(ve(i)===e){if(Array.isArray(t))return[null,t.concat(be(i))];if(se(t))return[null,t.fn.concat(be(i))]}else i&&(Array.isArray(t)&&t.push(i),se(t)&&t.fn.push(i));return[null,t]}return"left"===a.associativity?[null,[e,null!=t?t:z,null!=i?i:z]]:Array.isArray(t)?[null,[e,t[1],[e,t[2],null!=i?i:z]]]:(se(t)&&(t.fn[2]=[e,t.fn[2],null!=i?i:z]),[null,t])}return ve(i)===e?"both"===a.associativity?(Array.isArray(i)&&t&&i.splice(1,0,t),se(i)&&t&&i.fn.splice(1,0,t),[null,i]):"right"===a.associativity?[null,[e,null!=t?t:z,null!=i?i:z]]:Array.isArray(i)?[null,[e,i[1],[e,i[2],null!=t?t:z]]]:(se(i)&&(i.fn[2]=[e,i.fn[2],null!=t?t:z]),[null,i]):[null,[e,null!=t?t:"Missing",null!=i?i:"Missing"]]}return[t,null]}applyInvisibleOperator(e,t){if(null===e)return t;if(null===t)return e;if(this.options.invisiblePlusOperator&&("number"==typeof e||ie(e))&&function(e){var t,i;const n=xe(e);if(null!==n&&["ThreeQuarter","TwoThird","Half","Third","Quarter"].includes(n))return!0;if(ve(e)!==Z)return!1;const r=null!==(t=ae(we(e,1)))&&void 0!==t?t:NaN,s=null!==(i=ae(we(e,2)))&&void 0!==i?i:NaN;return Number.isInteger(r)&&Number.isInteger(s)}(t))return[e,t]=this.applyOperator(this.options.invisiblePlusOperator,e,t),null===e?t:null;if(this.options.invisibleOperator)return[e,t]=this.applyOperator(this.options.invisibleOperator,e,t),null===e?t:null;let i=[O];return ve(e)===O?i=i.concat(be(e)):i.push(e),null!==t&&(ve(t)===O?i=i.concat(be(t)):i.push(t)),this.options.invisibleOperator&&this.onError({code:"unexpected-sequence"}),i}matchUnknownLatexCommand(){var e;const t=this.peek;if(!t||"\\"!==t[0])return null;if(this.next(),"\\operatorname"===t){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:z}const i=[],n=[];let r=!1;do{r=!0;let e=this.matchOptionalLatexArgument();null!==e&&(i.push(e),r=!1),this.skipSpace(),"<{>"===this.peek&&(e=this.matchRequiredLatexArgument(),null!==e&&(n.push(e),r=!1))}while(!r);return i.length>0||n.length>0?[t,...n,...i]:t}matchPrimary(e){let t=null;const i=this.index,n=this.matchNumber();n&&(t={num:n}),null===t&&(t=this.matchMatchfixOperator()),null===t&&(t=this.matchEnvironment()),null===t&&(t=this.matchSymbol());let r=null;do{r=this.matchSupsub(t),t=null!=r?r:t}while(null!==r);let s=null;do{s=this.matchPostfix(t),t=null!=s?s:t}while(null!==s);return this.decorate(t,i)}matchBalancedExpression(e,t,i){const n=this.balancedClone(e,t);if(!n)return null==i||i({code:"unbalanced-symbols",arg:c(e)+c(t)}),null;const r=n.matchExpression();return n.atEnd||null==i||i({code:"unbalanced-symbols",arg:c(e)+c(t)}),r}matchExpression(e=0){let t=null;const i=this.index;this.skipSpace(),t=this.matchPrimary(e),null===t&&(t=this.matchOperator("prefix"));let n=!1;for(;!this.atEnd&&!n;){this.skipSpace();let i=this.matchOperator("infix",t,e);if(null===i&&null!==t){const[e]=this.peekDefinition("operator");if(null===e){const e=this.matchExpression(this.invisibleOperatorPrecedence);null!==e&&(i=this.applyInvisibleOperator(t,e))}}null!==i?t=i:n=!0}return this.decorate(t,i)}decorate(e,t){if(null===e)return null;if(this.options.preserveLatex){const i=this.latex(t,this.index);Array.isArray(e)?e={latex:i,fn:e}:"number"==typeof e?e={latex:i,num:Number(e).toString()}:"string"==typeof e?e={latex:i,sym:e}:"object"==typeof e&&null!==e&&(e.latex=i)}return e}}function rt(e,t){const i=e.length,n=e;e=e.slice(0,-1);for(let i=0;i<e.length-16;i++){const n=e.substr(0,i);for(let r=0;r<17;r++){const s=e.substr(i,r+1),o=Math.floor((e.length-n.length)/s.length);if(o>1&&(n+s.repeat(o+1)).startsWith(e))return"0"===s?n.replace(/(\d{3})/g,"$1"+t.groupSeparator):n.replace(/(\d{3})/g,"$1"+t.groupSeparator)+t.beginRepeatingDigits+s+t.endRepeatingDigits}}const r=i>t.precision-1;return e=n,r&&(e=e.substr(0,t.precision-1)),t.groupSeparator&&(e=e.replace(/(\d{3})/g,"$1"+t.groupSeparator)).endsWith(t.groupSeparator)&&(e=e.slice(0,-t.groupSeparator.length)),r?e+t.truncationMarker:e}function st(e,t){var i;return e?t.beginExponentMarker?t.beginExponentMarker+e+(null!==(i=t.endExponentMarker)&&void 0!==i?i:""):"10^{"+e+"}":""}function ot(e,t){var i,n;let r;if("number"==typeof e)r=e;else{if(!ie(e))return"";r=e.num}if(r===1/0||"Infinity"===r||"+Infinity"===r)return t.positiveInfinity;if(r===-1/0||"-Infinity"===r)return t.negativeInfinity;if("NaN"===r||"number"==typeof r&&Number.isNaN(r))return t.notANumber;if("number"==typeof r)return"engineering"===t.notation?function(e,t){if(0===e)return"0";const i=Math.abs(e);let n=Math.round(Math.log10(i));n-=n%3,i<1e3&&(n=0);const r=i/Math.pow(10,n);let s="";const o=r.toString().match(/^(.*)\.(.*)$/);(null==o?void 0:o[1])&&o[2]&&(s=o[1]+t.decimalMarker+o[2]),t.groupSeparator&&(s=rt(r.toExponential(),t));let a="";return 0!==n&&(a=st(n.toString(),t)),(e<0?"-":"")+s+a}(r,t):function(e,t){let i,n=e.match(/^(.*)[e|E]([-+]?[0-9]+)$/i);(null==n?void 0:n[1])&&n[2]&&(i=st(n[2],t),i&&(i=t.exponentProduct+i));let r=e,s="";return n=(i?n[1]:e).match(/^(.*)\.(.*)$/),(null==n?void 0:n[1])&&n[2]&&(r=n[1],s=n[2]),t.groupSeparator&&(r=r.replace(/\B(?=(\d{3})+(?!\d))/g,t.groupSeparator),s=rt(s,t)),s&&(s=t.decimalMarker+s),r+s+(null!=i?i:"")}(r.toString(),t);/[a-zA-Z]$/.test(r)&&(r=r.slice(0,-1));let s="";for("-"===r[0]?(s="-",r=r.substr(1)):"+"===r[0]&&(r=r.substr(1));"0"===r[0];)r=r.substr(1);if(0===r.length)return s+"0";"."===r[0]&&(r="0"+r);let o="";if(r.indexOf(".")>=0){const e=r.match(/(\d*)\.(\d*)([e|E]([-+]?[0-9]*))?/);if(!e)return"";const n=e[1],a=e[2];if(o=null!==(i=e[4])&&void 0!==i?i:"","0"===n){let e=0;for(;"0"===a[e]&&e<a.length;)e+=1;let i="";if(e<=4)i="0"+t.decimalMarker,i+=a.substr(0,e),i+=rt(r.substr(i.length),t);else if(e+1>=t.precision)i="0",s="";else{i=r[e];const n=rt(r.substr(e+1),t);n&&(i+=t.decimalMarker+n)}"0"!==i&&(!(r.length-1>t.precision)||t.endRepeatingDigits&&i.endsWith(t.endRepeatingDigits)||!t.truncationMarker||i.endsWith(t.truncationMarker)||(i+=t.truncationMarker),e>4&&(i+=t.exponentProduct+st((1-e).toString(),t))),r=i}else{r=n.replace(/\B(?=(\d{3})+(?!\d))/g,t.groupSeparator);const e=rt(a,t);e&&(r+=t.decimalMarker+e)}}else if(r.length>t.precision){const e=r.length;let i=r[0];const n=rt(r.substr(1),t);n&&(i+=t.decimalMarker+n,t.truncationMarker&&!i.endsWith(t.truncationMarker)&&t.endRepeatingDigits&&!i.endsWith(t.endRepeatingDigits)&&(i+=t.truncationMarker)),"1"!==i?i+=t.exponentProduct:i="",r=i+st((e-1).toString(),t)}else{const e=r.match(/([0-9]*)\.?([0-9]*)([e|E]([-+]?[0-9]+))?/);e&&(r=e[1],e[2]&&(r+=t.decimalMarker+e[2]),o=null!==(n=e[4])&&void 0!==n?n:""),r=r.replace(/\B(?=(\d{3})+(?!\d))/g,t.groupSeparator)}const a=st(o,t);return s+r+(a?t.exponentProduct+a:"")}class at{constructor(e,t,i){this.level=-1,this.options=e,e.invisibleMultiply&&(/#1/.test(e.invisibleMultiply)&&/#2/.test(e.invisibleMultiply)||i({code:"expected-argument",arg:"invisibleMultiply"})),this.onError=i,this.dictionary=t}wrap(e,t){if(null===e)return"";if(void 0===t)return"("+this.serialize(e)+")";if("number"==typeof e||ie(e)||"string"==typeof e||ne(e))return this.serialize(e);const i=ve(e);if(i&&i!==P){const n=this.dictionary.name.get(i);if(n&&void 0!==n.precedence&&n.precedence<t)return this.wrapString(this.serialize(e),(this.level,"paren"))}return this.serialize(e)}wrapShort(e){if(null===e)return"";const t=this.serialize(e);return ve(e)===P||"number"==typeof e||ie(e)||/(^(.|\\[a-zA-Z*]+))$/.test(t)?t:this.wrapString(t,(this.level,"paren"))}wrapString(e,t){return"none"===t?e:"("+e+")"}serializeSymbol(e,t){const i=ge(e);if(!i){if("string"==typeof(null==t?void 0:t.serialize))return t.serialize;const i=xe(e);if(null===i)return"";switch(function(e,t){const i=xe(e);return null===i?"asis":i.length>1?"upright":"asis"}(e,this.level)){case"upright":return"\\operatorname{"+i+"}";default:return i}}const n=be(e);if(!t){if("string"==typeof i&&i.length>0&&"\\"===i[0]){let e=i;for(const t of n)e+="{"+this.serialize(t)+"}";return e}return`${this.serialize(i)}(${n.map((e=>this.serialize(e))).join(", ")})`}if(t.requiredLatexArg>0){let e="",i="",r=0;for(;r<t.requiredLatexArg;)i+="{"+this.serialize(n[r++])+"}";for(;r<Math.min(n.length,t.optionalLatexArg+t.requiredLatexArg);){const t=this.serialize(n[1+r++]);t&&(e+="["+t+"]")}return t.serialize+(e+i)}return this.level,t.serialize+this.serialize([P,...n])}serializeDictionary(e){return`\\left[\\begin{array}{lll}${Object.keys(e).map((t=>`\\textbf{${t}} & \\rightarrow & ${this.serialize(e[t])}`)).join("\\\\")}\\end{array}\\right]`}serialize(e){if(null===e)return"";this.level+=1;const t=(()=>{var t,i,n,r;const s=ot(e,this.options);if(s)return s;const o=fe(e);if(null!==o)return`\\text{${o}}`;const a=xe(e);if(null!==a)return this.serializeSymbol(e,this.dictionary.name.get(a));const l=Me(e);if(null!==l)return this.serializeDictionary(l);const f=ve(e);if(f){if("\\"===f[0]){const t=be(e);return 0===t.length?f:f+"{"+t.map((e=>this.serialize(e))).filter((e=>Boolean(e))).join("}{")+"}"}const s=this.dictionary.name.get(f);if(s){let o="";return"function"==typeof s.serialize&&(o=s.serialize(this,e)),o||void 0===s.precedence&&!(null===(t=s.trigger)||void 0===t?void 0:t.superfix)&&!(null===(i=s.trigger)||void 0===i?void 0:i.subfix)||(o=function(e,t,i){var n,r,s,o,a;let l="";const u=Se(t),c=ve(t);if((null===(n=i.trigger)||void 0===n?void 0:n.superfix)||(null===(r=i.trigger)||void 0===r?void 0:r.subfix))return 1!==u&&e.onError({code:"operator-requires-one-operand",arg:e.serializeSymbol(c)}),it(i.serialize,[e.serialize(we(t,1))]);if(null===(s=i.trigger)||void 0===s?void 0:s.postfix)return 1!==u&&e.onError({code:"postfix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),it(i.serialize,[e.wrap(we(t,1),i.precedence)]);if(null===(o=i.trigger)||void 0===o?void 0:o.prefix)return 1!==u&&e.onError({code:"prefix-operator-requires-one-operand",arg:e.serializeSymbol(c)}),it(i.serialize,[e.wrap(we(t,1),i.precedence+1)]);if(null===(a=i.trigger)||void 0===a?void 0:a.infix){l=e.wrap(we(t,1),i.precedence);for(let n=2;n<u+1;n++){const r=we(t,n);null!==r&&(l=it(i.serialize,[l,e.wrap(r,i.precedence)]))}}return l}(this,e,s)),!o&&(null===(n=s.trigger)||void 0===n?void 0:n.matchfix)&&(o=function(e,t,i){var n,r;let s=[];if("string"==typeof(null===(n=i.trigger)||void 0===n?void 0:n.matchfix)?s.push(null===(r=i.trigger)||void 0===r?void 0:r.matchfix):i.trigger&&Array.isArray(i.trigger.matchfix)&&(s=[...i.trigger.matchfix]),Se(t)>=1){let n="";for(const r of be(t))r&&(s.push(n),s.push(e.serialize(r)),n=i.separator)}return s.push(c(i.closeFence)),u(s)}(this,e,s)),!o&&(null===(r=s.trigger)||void 0===r?void 0:r.symbol)&&(o=this.serializeSymbol(e,s)),o}}if(Array.isArray(e)||se(e))return this.serializeSymbol(e);this.onError({code:"syntax-error",arg:JSON.stringify(e)})})();return this.level-=1,null!=t?t:""}}class lt{constructor(e){var t,i;this.onError=null!==(t=null==e?void 0:e.onError)&&void 0!==t?t:e=>{"undefined"!=typeof window&&(!e.before||e.after)};const n={...null!=e?e:{}};delete n.dictionary,delete n.onError,this.options={...Xe,...tt,...et,...n},this.dictionary=function(e,t){var i,n,r,s,o,a,l,u,c,f,h,m,p,g,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===(i=x.trigger)||void 0===i?void 0:i.symbol)&&/#[0-9]/.test(x.serialize)&&t({code:"unexpected-argument",arg:x.name}),void 0===x.serialize&&(void 0!==(null===(n=x.trigger)||void 0===n?void 0:n.postfix)?x.serialize="#1"+Je(x.trigger.postfix):void 0!==(null===(r=x.trigger)||void 0===r?void 0:r.prefix)?x.serialize=Je(x.trigger.prefix)+"#1":void 0!==(null===(s=x.trigger)||void 0===s?void 0:s.infix)?x.serialize="#1"+Je(x.trigger.infix)+"#2":void 0!==(null===(o=x.trigger)||void 0===o?void 0:o.symbol)?x.serialize=Je(x.trigger.symbol):void 0!==(null===(a=x.trigger)||void 0===a?void 0:a.superfix)?x.serialize="#1^{"+Je(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_{"+Je(null===(c=x.trigger)||void 0===c?void 0:c.subfix)+"}":x.serialize=""),void 0!==(null===(f=x.trigger)||void 0===f?void 0:f.infix)&&(void 0===x.precedence&&t({code:"syntax-error",arg:"Infix operators require a precedence"}),x.associativity||(x.associativity="non")),void 0!==(null===(h=x.trigger)||void 0===h?void 0:h.symbol)&&(x.arguments=null!==(m=x.arguments)&&void 0!==m?m:"",x.optionalLatexArg=null!==(p=x.optionalLatexArg)&&void 0!==p?p:0,x.requiredLatexArg=null!==(g=x.requiredLatexArg)&&void 0!==g?g:0),void 0!==(null===(d=x.trigger)||void 0===d?void 0:d.matchfix)&&("function"===x.parse||x.closeFence||t({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 i=(t=x.trigger[e],Array.isArray(t)?t.length:1);v.lookahead=Math.max(v.lookahead,i),void 0===v[e][i]&&(v[e][i]=new Map),v[e][i].set(Je(x.trigger[e]),x)}var t})),void 0!==x.trigger.environment&&v.environment.set(x.trigger.environment,x)),void 0!==x.name?v.name.set(Je(x.name),x):"string"==typeof x.parse&&v.name.set(x.parse,x),void 0!==x.trigger||x.name||t({code:"syntax-error",arg:"Need at least a trigger or a name"});return v}(null!==(i=null==e?void 0:e.dictionary)&&void 0!==i?i:lt.getDictionary(),this.onError)}static getDictionary(e="all"){if("all"===e){let e=[];for(const t of Object.keys(Ke))e=[...e,...Ke[t]];return e}return Ke[e]?[...Ke[e]]:[]}parse(e){var t;const i=new nt(l(e,[]),this.options,this.dictionary,this.onError),n=i.matchExpression();return i.atEnd||null===(t=this.onError)||void 0===t||t.call(this,{code:"syntax-error"}),null!=n?n:""}serialize(e){return new at(this.options,this.dictionary,this.onError).serialize(e)}}class ut{constructor(e){this.signal={severity:"error",...e}}toString(){let e="";if(this.signal.head&&(e+=this.signal.head+": "),"string"==typeof this.signal.message)e+=this.signal.message;else{e+=" ";for(const t of this.signal.message)e+=t.toString()+" "}return e}}function ct(e,t,i){const n=be(t);if(n.length>0)n.forEach((t=>ct(e,t,i)));else{const n=xe(t);if(n&&!i.has(n)){const t=e.getSymbolDefinition(n);t&&!1!==t.constant||i.add(n)}}}function ft(e,t){const i=new Set;return ct(e,t,i),i}function ht(e,t,i){if(null===t)return null;const n=dt(e);return""===n?i:i[n]?null===pt(t,i[n])?null:i:(i[n]=t,i)}function mt(e,t,i,n){var r;const s=ae(t);if(null!==s)return Math.abs(s-(null!==(r=ae(e))&&void 0!==r?r:NaN))<=n.numericalTolerance?i:null;const o=fe(t);if(null!==o)return fe(e)===o?i:null;const a=Me(t);if(null!==a){const t=Object.keys(a),r=Me(e);if(null===r)return null;if(Object.keys(r).length!==t.length)return null;for(const e of t){const t=mt(r[e],a[e],i,n);if(null===t)return null;i=t}return i}const l=xe(t);if(null!==l)return l.startsWith("_")?ht(l,e,i):l===xe(e)?"object"==typeof t&&"object"==typeof e&&"wikidata"in t&&"wikidata"in e&&t.wikidata!==e.wikidata?null:i:"object"==typeof t&&"object"==typeof e&&"wikidata"in t&&"wikidata"in e&&t.wikidata===e.wikidata?i:null;const u=ge(t);if(null===u)return null;if("string"==typeof u&&u.startsWith("_"))return ht(u,ge(e),i);{const t=ge(e);if(null===t)return null;if(null===pt(u,t,n))return null}const c=be(t),f=be(e),h=c.length;if(h!==f.length)return null;let m={...i},p=0;for(;p<h;){const e=c[p],t=xe(e);if(null!==t)if(t.startsWith("__")){let e=0;if(void 0===c[p+1])e=f.length+1;else{let t=!1;for(;!t&&e<f.length;)t=null!==pt(c[p+1],f[e],n),e+=1;if(!t)return null}if(!t.startsWith("___")&&e<=1)return null;m=ht(t,["Sequence",...f.splice(0,e-1)],m)}else if(t.startsWith("_"))m=ht(t,f.shift(),m);else{const t=pt(e,f.shift(),n);if(null===t)return null;m={...m,...t}}else{const t=pt(e,f.shift(),n);if(null===t)return null;m={...m,...t}}if(null===m)return null;p+=1}return m}function pt(e,t,i){return mt(t,e,{},null!=i?i:{numericalTolerance:D})}function gt(e,t){var i;const n=xe(e);if(null!==n)return n.startsWith("_")&&null!==(i=t[dt(n)])&&void 0!==i?i:e;const r=Me(e);if(null!==r){const e={};for(const i of Object.keys(r))e[i]=gt(r[i],t);return{dict:e}}const s=ge(e);if(null!==s){let i=[gt(s,t)];for(const n of be(e)){const e=xe(n);if(null!==e&&e.startsWith("__")){const n=t[dt(e)];void 0===n||"Sequence"!==ve(n)?i.push(e):i=i.concat(be(n))}else i.push(gt(n,t))}return i}return e}function dt(e){const t=e.match(/^__?_?([a-zA-Z0-9]+)/);return null===t?"":t[1]}class vt{constructor(e){this._items=e?new Map(e instanceof vt?e._items:e):new Map}has(e){for(const t of this._items.keys())if(pt(e,t))return!0;return!1}get(e){for(const[t,i]of this._items)if(pt(e,t))return i}set(e,t){for(const i of this._items.keys())if(pt(e,i))return void this._items.set(i,t);this._items.set(e,t)}delete(e){this._items.delete(e)}[Symbol.iterator](){return this._items.entries()}entries(){return this._items.entries()}}function xt(e){var t,i,n;let r=!0;const s=ve(e);return"Not"===s?([e,r]=xt(null!==(t=we(e,1))&&void 0!==t?t:z),r=!r):"NotEqual"===s?(r=!1,e=["Equal",null!==(i=we(e,1))&&void 0!==i?i:z]):"NotElement"===s&&(r=!1,e=["Element",null!==(n=we(e,1))&&void 0!==n?n:z]),[e,r]}function bt(e,t){const i=ve(t=e.canonical(t));if(!i)throw new ut({message:"expected-predicate"});let n=!0;if("And"===i)for(const i of be(t)){const t=bt(e,i);if("ok"!==t)return t}else[t,n]=xt(t);const r=e.is(t);if(void 0!==r){if(r===n)return"tautology";if(r!==n)return"contradiction"}return e.assumptions.set(t,n),"ok"}const yt={Anything:[],Expression:"Anything",Domain:["Set","Symbol"],ParametricDomain:["Domain","Function"],MaybeBoolean:"Expression",Boolean:"MaybeBoolean",Collection:"Expression",Dictionary:"Collection",List:"Collection",Sequence:"Collection",Tuple:"Collection",Set:"Collection",FiniteSet:"Set",InfiniteSet:"Set",EmptySet:"FiniteSet",String:"Expression",Symbol:"String",Function:"Expression",Predicate:"Function",LogicalFunction:"Predicate",TranscendentalFunction:"Function",AlgebraicFunction:"Function",PeriodicFunction:"Function",TrigonometricFunction:["PeriodicFunction","TranscendentalFunction"],HyperbolicFunction:"TranscendentalFunction",MonotonicFunction:"Function",StrictMonotonicFunction:"MonotonicFunction",ContinuousFunction:"Function",DifferentiableFunction:"ContinuousFunction",InfinitelyDifferentiableFunction:"DifferentiableFunction",RationalFunction:["AlgebraicFunction","ContinuousFunction"],PolynomialFunction:["AlgebraicFunction","InfinitelyDifferentiableFunction"],QuadraticFunction:"PolynomialFunction",LinearFunction:["QuadraticFunction","MonotonicFunction"],ConstantFunction:"LinearFunction",Number:"Set",ImaginaryNumber:["ComplexNumber","InfiniteSet"],ComplexNumber:"ExtendedComplexNumber",ExtendedComplexNumber:"Number",ComplexInfinity:"ExtendedComplexNumber",NumberZero:["CompositeNumber","ImaginaryNumber","FiniteSet"],NaturalNumber:"Integer",CompositeNumber:"NaturalNumber",PrimeNumber:"NaturalNumber",Integer:["RationalNumber","ExtendedInteger"],ExtendedInteger:"ExtendedRationalNumber",RationalNumber:["AlgebraicNumber","ExtendedRationalNumber"],IrrationalNumber:"RealNumber",TranscendentalNumber:["IrrationalNumber","ImaginaryNumber"],AlgebraicNumber:"IrrationalNumber",RealNumber:["ComplexNumber","ExtendedRealNumber"],ExtendedRealNumber:"ExtendedComplexNumber",ExtendedNaturalNumber:"ExtendedInteger",ExtendedRationalNumber:"ExtendedRealNumber",SignedInfinity:"ExtendedNaturalNumber",Tensor:"Expression",Scalar:"Tensor",Vector:"Matrix",Row:"Vector",Column:"Vector",Matrix:"Tensor",ComplexTensor:"Tensor",RealTensor:"ComplexTensor",IntegerTensor:"RealTensor",LogicalTensor:"IntegerTensor",SquareMatrix:"Matrix",MonomialMatrix:"SquareMatrix",TriangularMatrix:"SquareMatrix",UpperTriangularMatrix:"TriangularMatrix",LowerTriangularMatrix:"TriangularMatrix",PermutationMatrix:["MonomialMatrix","LogicalTensor","OrthogonalMatrix"],OrthogonalMatrix:["SquareMatrix","RealTensor"],DiagonalMatrix:["UpperTriangularMatrix","LowerTriangularMatrix"],IdentityMatrix:["DiagonalMatrix","SymmetricMatrix","PermutationMatrix"],ZeroMatrix:["DiagonalMatrix","SymmetricMatrix","PermutationMatrix"],SymmetricMatrix:["HermitianMatrix","SquareMatrix","RealTensor"],HermitianMatrix:"ComplexTensor",Quaternion:["SquareMatrix","ComplexTensor"]},Nt={Function:"Q11348",ComplexNumber:"Q26851286",Integer:"Q47007735",ImaginaryNumber:"Q47310259",NaturalNumber:"Q28920052"},wt={MaybeBoolean:["Union","Boolean",["Set","Maybe"]],NaturalNumber:["Union","CompositeNumber","PrimeNumber"],Scalar:["Intersection","Row","Column"],TriangularMatrix:["Union","UpperTriangularMatrix","LowerTriangularMatrix"],Vector:["Union","Row","Column"]},St={Boolean:2,MaybeBoolean:3,EmptySet:0,IdentityMatrix:1,ZeroMatrix:1,NumberZero:1},Mt={Range:{range:"ParametricDomain",evaluate:(e,t,i)=>(t=Math.round(t),i=Math.round(i),Number.isNaN(t)||Number.isNaN(i)||t>i?"EmptySet":t===-1/0&&i===1/0?"Integer":0===t&&i===1/0?"NaturalNumber":0===t&&0===i?"NumberZero":["Range",t,i])},Interval:{range:"ParametricDomain",evaluate:(e,t,i)=>Number.isNaN(t)||Number.isNaN(i)||t>i?"EmptySet":t===-1/0&&i===1/0?"RealNumber":0===t&&0===i?"NumberZero":["Interval",t,i]}},Et=["Sqrt",2],At=["Sqrt",3],Dt=["Sqrt",5],Ct=["Sqrt",6],_t=new vt([[["Divide","Pi",12],{Sin:["Divide",["Subtract",Ct,Et],4],Cos:["Divide",["Add",Ct,Et],4],Tan:["Subtract",[2,At]],Cot:["Add",[2,At]],Sec:["Subtract",[Ct,Et]],Csc:["Add",[Ct,Et]]}],[["Divide","Pi",10],{Sin:["Divide",["Subtract",Dt,1],4],Cos:["Divide",["Sqrt",["Add",10,["Multiply",2,Dt]]],4],Tan:["Divide",["Sqrt",["Subtract",25,["Multiply",10,Dt]]],4],Cot:["Sqrt",["Add",5,["Multiply",2,Dt]]],Sec:["Divide",["Sqrt",["Subtract",50,["Multiply",10,Dt]]],5],Csc:["Add",1,Dt]}],[["Divide","Pi",4],{Sin:["Divide",Et,2],Cos:["Divide",Et,2],Tan:1,Cot:1,Sec:Et,Csc:Et}],[["Divide","Pi",3],{Sin:["Divide",At,2],Cos:"Half",Tan:At,Cot:["Divide",At,3],Sec:2,Csc:["Divide",["Multiply",2,At],3]}],[["Divide","Pi",2],{Sin:1,Cos:0,Tan:1/0,Cot:0,Sec:1/0,Csc:1}]]),kt={Degrees:{domain:"Real",constant:!0,value:.017453292519943295},MinusDoublePi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[H,-2,"Pi"]},MinusPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[G,"Pi"]},MinusHalfPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[Z,[G,"Pi"],2]},QuarterPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[Z,"Pi",4]},ThirdPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[Z,"Pi",3]},HalfPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[Z,"Pi",2]},TwoThirdPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[H,2,[Z,"Pi",3]]},ThreeQuarterPi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[H,3,[Z,"Pi",4]]},Pi:{domain:"TranscendentalNumber",constant:!0,wikidata:"Q167",value:e=>"decimal"===e.numericFormat?h.exports.Decimal.acos(-1):"complex"===e.numericFormat?m.exports.Complex.PI:Math.PI},DoublePi:{domain:"TranscendentalNumber",constant:!0,hold:!1,value:[H,2,"Pi"]},Arccos:{domain:"TrigonometricFunction",range:["Interval",0,"Pi"],numeric:!0,value:["Subtract","HalfPi",["Arcsin","_"]],simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Arccos)&&void 0!==n?n:["Subtract","HalfPi",["Arcsin",t]]},evalNumber:(e,t)=>Math.acos(t),evalDecimal:(e,t)=>h.exports.Decimal.acos(t),evalComplex:(e,t)=>m.exports.Complex.acos(t)},Arcosh:{domain:"HyperbolicFunction",range:["Interval",0,1/0],numeric:!0,value:["Ln",["Add","_",["Sqrt",["Subtract",["Square","_"],1]]]],simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Arccosh)&&void 0!==n?n:["Ln",["Add",t,["Sqrt",["Subtract",["Square",t],1]]]]},evalNumber:(e,t)=>Math.acosh(t),evalDecimal:(e,t)=>h.exports.Decimal.acosh(t),evalComplex:(e,t)=>m.exports.Complex.acosh(t)},Arcsin:{domain:"TrigonometricFunction",range:["Interval","MinusHalfPi","HalfPi"],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Arcsin)&&void 0!==n?n:["Multiply",2,["Arctan2",t,["Add",1,["Sqrt",["Subtract",1,["Square",t]]]]]]},value:["Multiply",2,["Arctan2","_",["Add",1,["Sqrt",["Subtract",1,["Square","_"]]]]]],evalNumber:(e,t)=>Math.asin(t),evalDecimal:(e,t)=>h.exports.Decimal.asin(t),evalComplex:(e,t)=>m.exports.Complex.asin(t)},Arsinh:{domain:"HyperbolicFunction",range:["Interval",-1/0,1/0],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Arsinh)&&void 0!==n?n:["Ln",["Add",t,["Sqrt",["Add",["Square",t],1]]]]},value:["Ln",["Add","_",["Sqrt",["Add",["Square","_"],1]]]],evalNumber:(e,t)=>Math.asinh(t),evalDecimal:(e,t)=>h.exports.Decimal.asinh(t),evalComplex:(e,t)=>m.exports.Complex.asinh(t)},Arctan:{wikidata:"Q2257242",domain:"TrigonometricFunction",range:["Interval","MinusHalfPi","HalfPi"],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Arctan)&&void 0!==n?n:t},evalNumber:(e,t)=>Math.atan(t),evalDecimal:(e,t)=>h.exports.Decimal.atan(t),evalComplex:(e,t)=>m.exports.Complex.atan(t)},Arctan2:{wikidata:"Q776598",range:["Interval","MinusPi","Pi"],domain:"TrigonometricFunction",numeric:!0,evalNumber:(e,t,i)=>Math.atan2(t,i),evalDecimal:(e,t,i)=>h.exports.Decimal.atan2(t,i),evalComplex:(e,t,i)=>m.exports.Complex.atan2(t,i)},Artanh:{domain:"HyperbolicFunction",range:["Interval",-1/0,1/0],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Artanh)&&void 0!==n?n:["Multiply","Half",["Ln",["Divide",["Add",1,t],["Subtract",1,t]]]]},value:["Multiply","Half",["Ln",["Divide",["Add",1,"_"],["Subtract",1,"_"]]]],evalNumber:(e,t)=>Math.atanh(t),evalDecimal:(e,t)=>h.exports.Decimal.atanh(t),evalComplex:(e,t)=>m.exports.Complex.atanh(t)},Cosh:{domain:"HyperbolicFunction",range:["Interval",1,1/0],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Cosh)&&void 0!==n?n:t},value:["Multiply","Half",["Add",["Exp","_"],["Exp",["Negate","_"]]]],evalNumber:(e,t)=>Math.cosh(t),evalDecimal:(e,t)=>h.exports.Decimal.cosh(t),evalComplex:(e,t)=>m.exports.Complex.cosh(t)},Cos:{domain:"TrigonometricFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Cos)&&void 0!==n?n:["Sin",["Add",t,"HalfPi"]]},value:["Sin",["Add","_","HalfPi"]],evalNumber:(e,t)=>Math.cos(t),evalDecimal:(e,t)=>h.exports.Decimal.cos(t),evalComplex:(e,t)=>m.exports.Complex.cos(t)},Cot:{domain:"TrigonometricFunction",range:"ComplexNumber",numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Cot)&&void 0!==n?n:["Divide",["Cos",t],["Sin",t]]},value:["Divide",["Cos","_"],["Sin","_"]],evalNumber:(e,t)=>1/Math.tan(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.tan(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.tan(t))},Coth:{domain:"HyperbolicFunction",range:"ComplexNumber",numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Coth)&&void 0!==n?n:["Divide",1,["Tanh",t]]},value:["Divide",1,["Tanh","_"]],evalNumber:(e,t)=>1/Math.tanh(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.tanh(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.tanh(t))},Csc:{domain:"TrigonometricFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Csc)&&void 0!==n?n:["Divide",1,["Sin",t]]},value:["Divide",1,["Sin","_"]],evalNumber:(e,t)=>1/Math.tanh(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.tanh(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.tanh(t))},Csch:{domain:"HyperbolicFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Csch)&&void 0!==n?n:["Divide",1,["Sinh",t]]},value:["Divide",1,["Sinh","_"]],evalNumber:(e,t)=>1/Math.sinh(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.sinh(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.sinh(t))},FromPolarCoordinates:{domain:"Function",range:["TupleOf","RealNumber","RealNumber"]},Haversine:{wikidata:"Q2528380",domain:"TrigonometricFunction",range:["Interval",0,1],value:["Divide",["Subtract",1,["Cos","_"]],2],numeric:!0},Hypot:{domain:"Function",range:["Interval",0,1/0],value:["Sqrt",["Square","_"],["Square","_2"]],evalNumber:(e,t,i)=>Math.sqrt(t*t*+i*i),evalDecimal:(e,t,i)=>h.exports.Decimal.sqrt(t.mul(t).add(i.mul(i))),evalComplex:(e,t,i)=>m.exports.Complex.sqrt(t.mul(t).add(i.mul(i)))},InverseFunction:{domain:"Function",range:"Function",simplify:(e,t)=>{var i,n;const r=null!==(i=we(t,1))&&void 0!==i?i:z;return"string"!=typeof r?t:null!==(n={Sin:"Arcsin",Cos:"Arccos",Tan:"Arctan",Sec:"Arcsec",Csc:" Arccsc",Sinh:"Arsinh",Cosh:"Arcosh",Tanh:"Artanh",Sech:"Arcsech",Csch:"Arcsch",Arcosh:"Cosh",Arcos:"Cos",Arccsc:"Csc",Arcsch:"Csch",Arcsec:"Sec",Arcsin:"Sin",Arsinh:"Sinh",Arctan:"Tan",Artanh:"Tanh"}[r])&&void 0!==n?n:t}},InverseHaversine:{domain:"TrigonometricFunction",range:["Interval",["MinusPi"],"Pi"],numeric:!0,value:["Multiply",2,["Arcsin",["Sqrt","_"]]]},Sec:{domain:"TrigonometricFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Sec)&&void 0!==n?n:["Divide",1,["Cos",t]]},value:["Divide",1,["Cos","_"]],evalNumber:(e,t)=>1/Math.cos(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.cos(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.cos(t))},Sech:{domain:"HyperbolicFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Sech)&&void 0!==n?n:["Divide",1,["Cosh",t]]},value:["Divide",1,["Cosh","_"]],evalNumber:(e,t)=>1/Math.cosh(t),evalDecimal:(e,t)=>g.div(h.exports.Decimal.cosh(t)),evalComplex:(e,t)=>m.exports.Complex.ONE.div(m.exports.Complex.cosh(t))},Sinh:{domain:"HyperbolicFunction",range:["Interval",-1/0,1/0],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Sinh)&&void 0!==n?n:["Multiply","Half",["Subtract",["Exp",t],["Exp",["Negate",t]]]]},value:["Multiply","Half",["Subtract",["Exp","_"],["Exp",["Negate","_"]]]]},Sin:{domain:"TrigonometricFunction",range:["Interval",-1,1],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Sin)&&void 0!==n?n:t},value:["Divide",["Subtract",["Exp",["Multiply","ImaginaryUnit","_"]],["Exp",["Multiply","ImaginaryUnit",["Negate","_"]]]],["Multiply",2,"ImaginaryUnit"]],evalNumber:(e,t)=>Math.sin(t),evalDecimal:(e,t)=>t.sin(),evalComplex:(e,t)=>t.sin()},Tanh:{domain:"HyperbolicFunction",range:["Interval",-1/0,1/0],numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Tanh)&&void 0!==n?n:["Divide",["Sinh",t],["Cosh",t]]},value:["Divide",["Sinh","_"],["Cosh","_"]],evalNumber:(e,t)=>Math.tanh(t),evalDecimal:(e,t)=>t.tanh(),evalComplex:(e,t)=>t.tanh()},Tan:{domain:"TrigonometricFunction",range:"RealNumber",numeric:!0,simplify:(e,t)=>{var i,n;return null!==(n=null===(i=_t.get(t))||void 0===i?void 0:i.Tan)&&void 0!==n?n:["Divide",["Sin",t],["Cos",t]]},value:["Divide",["Sin","_"],["Cos","_"]],evalNumber:(e,t)=>Math.tan(t),evalDecimal:(e,t)=>t.tan(),evalComplex:(e,t)=>t.tan()},ToPolarCoordinates:{domain:"Function",range:["TupleOf","RealNumber","RealNumber"]}};function Ft(e){return null!==e&&"object"==typeof e&&"supersets"in e}function qt(e){return null!==e&&"object"==typeof e&&"constant"in e}function It(e){return null!==e&&"object"==typeof e&&"range"in e}function Pt(e){return null!==e&&"object"==typeof e&&"countable"in e}function Tt(e,t){var i;const n=Ot(t);if(null!==n)return n;const r=xe(t);if(null!==r){const n=e.ask(["Element",t,"_domain"]);if(n.length>0)return 1===n.length?n[0].domain:"Anything";const s=e.getDefinition(r);return s&&"function"==typeof s.domain?null!==(i=s.domain(t))&&void 0!==i?i:"Anything":s&&s.domain?s.domain:s&&"value"in s&&s.value?"function"==typeof s.value?Tt(e,s.value(e)):Tt(e,s.value):"Anything"}const s=ge(t);if("string"==typeof s){const i=e.getFunctionDefinition(s);if(i){if("function"==typeof i.range)return i.range(e,...be(t));if(void 0!==i.range)return i.range;if(void 0!==i.value)return Tt(e,i.value)}}return re(t)?"String":oe(t)?"Dictionary":null}function Ot(e){var t,i;if(void 0===e)return null;const n=ae(e);if(null!==n&&!isNaN(n))return 0===n?"NumberZero":isFinite(n)?Number.isInteger(n)?C.has(n)?"PrimeNumber":n>=1&&n<7919?"CompositeNumber":n>0?"NaturalNumber":"Integer":n>0?["Interval",["Open",0],1/0]:"RealNumber":"SignedInfinity";if(e instanceof h.exports.Decimal)return e.isNaN()?"Number":e.isZero()?"NumberZero":e.isFinite()?e.isInteger()?e.abs().lessThan(Number.MAX_SAFE_INTEGER)?Ot(e.toNumber()):e.isPositive()?"NaturalNumber":"Integer":e.isPositive()?["Interval",["Open",0],1/0]:"RealNumber":"SignedInfinity";if(e instanceof m.exports.Complex){const t=e;return 0===t.im?Ot(t.re):0===t.re&&0!==t.im?"ImaginaryNumber":"ComplexNumber"}if("Complex"===ve(e)){const n=null!==(t=ae(we(e,1)))&&void 0!==t?t:NaN,r=null!==(i=ae(we(e,2)))&&void 0!==i?i:NaN;return 0===r?Ot(n):0===n&&0!==r?"ImaginaryNumber":"ComplexNumber"}let[r,s]=he(e);if(null!==r&&null!==s){const e=_(r,s);if(r/=e,s/=e,!Number.isNaN(r)&&!Number.isNaN(s))return 0===r?"NumberZero":1!==s&&-1!==s?"RationalNumber":Ot(r)}const o=xe(e);if(null!==o){if("NaN"===o)return"Number";if("+Infinity"===o||"-Infinity"===o)return"SignedInfinity";if(o===X)return"ComplexInfinity";if(o===te)return"ImaginaryNumber";if(["Quarter","Third","Half","TwoThird","ThreeQuarter"].includes(o))return"RationalNumber";if(["MinusDoublePi","MinusPi","QuarterPi","ThirdPi","HalfPi","TwoThirdPi","ThreeQuarterPi","Pi","DoublePi","ExponentialE"].includes(o))return"TranscendentalNumber";if(["MachineEpsilon","CatalanConstant","GoldenRatio","EulerGamma"].includes(o))return"RealNumber"}if(ve(e)===W&&ve(we(e,2))===Z&&1===we(we(e,2),1)&&2===we(we(e,2),2)){const t=ae(we(e,1));if(null!==t&&C.has(t))return"IrrationalNumber"}return"RealNumber"}function Lt(e="all"){if("all"===e)return Lt(["domains","core","collections","algebra","arithmetic","calculus","complex","combinatorics","dimensions","inequalities","intervals","linear-algebra","logic","numeric","other","physics","polynomials","relations","statistics","transcendentals","trigonometry","rounding","units"]);const t=[];for(const i of e)zt[i]&&t.push(zt[i]);return t}const zt={arithmetic:Ue,algebra:{},calculus:{},combinatorics:{},complex:{},core:{Apply:{domain:"Function",range:"Anything"},About:{domain:"Function",range:"Dictionary"},BaseForm:{domain:"Function",range:"Integer"},Block:{domain:"Function",range:"Anything"},Domain:{domain:"ParametricDomain",range:"Domain"},Evaluate:{domain:"Function",range:"Anything"},Parentheses:{domain:"Function",threadable:!0,pure:!1,range:"Anything"},Head:{domain:"Function",range:"Anything"},Lambda:{domain:"Function",wikidata:"Q567612",hold:"all",range:"Anything"},Latex:{domain:"Function",range:"String"},String:{domain:"Function",threadable:!0,range:"String"},Symbol:{domain:"Function",threadable:!0,range:"Symbol"},Tail:{domain:"Function",range:"List"}},collections:{EmptySet:{domain:"EmptySet",constant:!0,wikidata:"Q226183"},CartesianProduct:{domain:"Function",wikidata:"Q173740",range:"Set",evaluate:function(e,t,i){return"EmptySet"}},Intersection:{domain:"Function",wikidata:"Q185837",threadable:!0,associative:!0,commutative:!0,idempotent:!0,involution:!0,range:"Set",evaluate:function(e,...t){return"EmptySet"}},Complement:{domain:"Function",wikidata:"Q242767",range:"Set"},Union:{domain:"Function",wikidata:"Q185359",threadable:!0,associative:!0,commutative:!0,idempotent:!0,involution:!0,range:"Set",evaluate:function(e,...t){return"EmptySet"}},SymmetricDifference:{domain:"Function",wikidata:"Q1147242",range:"Set"},Subset:{domain:"Predicate",range:"MaybeBoolean",evaluate:function(e,t,i){return"False"}},SubsetEqual:{domain:"Predicate",range:"MaybeBoolean",evaluate:function(e,t,i){return"False"}},SetMinus:{domain:"Function",wikidata:"Q18192442",range:"MaybeBoolean",evaluate:function(e,t,i){return"EmptySet"}}},domains:function(){var e;const t={Nothing:{countable:!0,supersets:[],domain:"Domain"}};for(const i of Object.keys(yt)){const n=Array.isArray(yt[i])?yt[i]:[yt[i]];t[i]=null!==(e=Mt[i])&&void 0!==e?e:{},t[i]={domain:Mt[i]?"ParametricDomain":"Domain",wikidata:Nt[i],supersets:n,value:wt,countable:void 0!==St[i],size:()=>St[i],...t[i]};for(const e of n)if("Anything"!==e&&!yt[e])throw new Error(`Unknown parent of domain "${i}": "${e}"`)}const i=new Set;for(const e of Object.keys(t))i.add(e);for(const e of Object.keys(t))for(const n of t[e].supersets)i.delete(n);i.delete("Nothing"),t.Nothing.supersets=[...i.values()];for(const e of Object.keys(t)){let i=!1,n=0,r=[e];for(;n<512&&!i;){const e=r.pop();i="Anything"===e,i||(r=[...e,...t[e].supersets]),n++}if(!i)throw new Error(`The "${e}" domain cannot reach "Anything"`)}return t}(),dimensions:{},logic:{True:{domain:"Boolean",constant:!0},False:{domain:"Boolean",constant:!0},Maybe:{domain:"MaybeBoolean",constant:!0},And:{domain:"LogicalFunction",threadable:!0,associative:!0,commutative:!0,idempotent:!0,range:"MaybeBoolean"},Or:{domain:"LogicalFunction",threadable:!0,associative:!0,commutative:!0,idempotent:!0,range:"MaybeBoolean"},Not:{domain:"LogicalFunction",involution:!0,range:"MaybeBoolean"},Equivalent:{domain:"LogicalFunction",range:"MaybeBoolean"},Implies:{domain:"LogicalFunction",range:"MaybeBoolean"},Exists:{domain:"LogicalFunction",range:"MaybeBoolean"},Equal:{domain:"LogicalFunction",range:"MaybeBoolean"},NotEqual:{domain:"Function",wikidata:"Q28113351",commutative:!0,range:"MaybeBoolean"}},inequalities:{},intervals:{},"linear-algebra":{},numeric:{},other:{},polynomials:{},physics:{"Mu-0":{constant:!0,wikidata:"Q1515261",domain:"RealNumber",value:125663706212e-17,unit:[H,"H",[W,"m",-1]]}},relations:{},rounding:{},statistics:{},transcendentals:{},trigonometry:kt,units:{}};function Ut(e,t){const i=new Map;for(const n of Object.keys(e)){const[r,s]=Rt(e[n],t);s&&t.signal({severity:r?"warning":"error",message:["invalid-dictionary-entry",s],head:n}),r&&i.set(n,r)}return t.context={parentScope:t.context,dictionary:i,assumptions:new vt},function(e,t){const i=new Set;for(const[n,r]of t){if(/[A-Za-z][A-Za-z0-9-]*/.test(n)||1===n.length||e.signal({severity:"error",message:"invalid-name",head:n}),r.wikidata&&(i.has(r.wikidata)&&e.signal({severity:"warning",message:["duplicate-wikidata",r.wikidata],head:n}),i.add(r.wikidata)),qt(r)&&("function"==typeof r.domain||e.isSubsetOf(r.domain,"Anything")||e.signal({severity:"warning",message:["unknown-domain",r.domain],head:n}),!1!==r.hold||r.value||e.signal({severity:"warning",message:["invalid-dictionary-entry","symbol has hold = false, but no value"],head:n})),It(r)){const t=r.range;"function"==typeof t||e.isSubsetOf(t,"Anything")||e.signal({severity:"warning",message:["unknown-domain",t],head:n})}if(Ft(r)){0===r.supersets.length&&"Anything"!==n&&e.signal({severity:"warning",message:"expected-supersets",head:n});for(const i of r.supersets)e.isSubsetOf(i,"Anything")||e.signal({severity:"warning",message:["expected-supersets",i],head:n}),e.isSubsetOf(i,n)&&(e.signal({severity:"warning",message:["cyclic-definition",$t(e,n)],head:n}),t.delete(n))}}}(t,i),t.context=t.context.parentScope,i}function Rt(e,t){if("number"==typeof e)return[{domain:Ot(e),constant:!1,value:e}];let i=e.domain;if(qt(e)){let t;return i||(t="no domain provided.",i="Anything"),!1!==(e={domain:i,constant:!1,...e}).hold||e.value||(e.hold=!0),[e,t]}if(Pt(e)||"function"!=typeof i&&t.isSubsetOf(i,"Collection"))return[{domain:"Collection",iterable:void 0!==e.iterator,indexable:void 0!==e.at,countable:void 0!==e.size,...e},void 0];if(It(e)||"function"!=typeof i&&t.isSubsetOf(i,"Function")){let t,n={...e};return n={wikidata:"",scope:null,threadable:!1,associative:!1,commutative:!1,additive:!1,multiplicative:!1,outtative:!1,idempotent:!1,involution:!1,numeric:!1,pure:!0,hold:"none",sequenceHold:!1,signatures:[],...e},n.range?"LogicalFunction"===i||"Predicate"===i?"Boolean"!==n.range&&"MaybeBoolean"!==n.range&&(t='A "LogicalFunction" or a "Predicate" should have a range of "Boolean" or "MaybeBoolean"'):"Boolean"!==n.range&&"MaybeBoolean"!==n.range||(t='looks like a "LogicalFunction" or a "Predicate"?'):t="no function range provided.",[n,t]}if(Ft(e)||"function"!=typeof i&&t.isSubsetOf(i,"Function"))return[e];if(e){const n=e;if(i&&"function"!=typeof i&&t.isSubsetOf(i,"Number")){if(void 0===n.value)return[null,'expected "value" property in definition'];const r=Ot("function"==typeof n.value?n.value(t):n.value);return[{domain:r,constant:!1,...e},r!==i?'inferred domain "${inferredDomain}"':""]}if(i&&"function"!=typeof i&&t.isSubsetOf(i,"Function"))return[{range:"Anything",...e},'a "Function" should have a "range" property in its definition'];if(i&&"function"!=typeof i&&t.isSubsetOf(i,"Set"))return[e,'a "Set" should have a "supersets" property in its definition']}return[e,"could not be validate"]}function $t(e,t,i){var n;const r=[`${t}`],s="string"==typeof t?t:ve(t);if(i){if(i.includes(s))return`${s} ↩︎ `;i.push(s)}else i=[s];const o=e.getSetDefinition(s);if(!o)return`${s}?!`;if(!o.supersets.length||0===o.supersets.length)return"";for(const t of null==o?void 0:o.supersets)"string"==typeof t&&r.push($t(e,t,[...i]));return r.length<=1?null!==(n=r[0])&&void 0!==n?n:"":"["+r.join(" ➔ ")+"]"}const jt={"simplify-arithmetic":[["x - x",0],[["Subtract","_x",0],"x"],[["Subtract",0,"_x"],"-x"],[["Add","_x",["Negate","_x"]],0],["x \\times x ","x^2"],[["Divide","_x",1],{sym:"_x"}],[["Divide","_x","_x"],1,(e,t)=>{var i;return null!==(i=Ie(e,t.x))&&void 0!==i&&i}],[["Divide","_x",0],1/0,(e,t)=>{var i;return null!==(i=Te(e,t.x))&&void 0!==i&&i}],[["Divide","_x",0],-1/0,(e,t)=>{var i;return null!==(i=Oe(e,t.x))&&void 0!==i&&i}],[["Divide",0,0],NaN],[["Power","_x","Half"],["\\sqrt{x}"]],[["Power","_x",["Divide",1,2]],["\\sqrt{x}"]],[["Power","_x",2],["Square","_x"]],[["Divide",["Complex","_re","_im"],"_x"],["Add",["Divide",["Complex",0,"_im"],"_x"],["Divide","_re","_x"]],(e,t)=>{var i,n,r;return null!==(i=e.isNotZero(t.re))&&void 0!==i&&i&&null!==(n=e.isInteger(t.re))&&void 0!==n&&n&&null!==(r=e.isInteger(t.im))&&void 0!==r&&r}],[["Abs","_x"],{sym:"_x"},(e,t)=>{var i,n;return null!==(i=qe(e,t.x))&&void 0!==i&&i||null!==(n=Te(e,t.x))&&void 0!==n&&n}],[["Abs","_x"],["Negate","_x"],(e,t)=>{var i;return null!==(i=Oe(e,t.x))&&void 0!==i&&i}]]};function Bt(e,t,i){var n,r,s,o,a;if(null===t)return null;if(1===(i=null!=i?i:["simplify-all"]).length&&"simplify-all"===i[0]&&(i=["simplify-arithmetic"]),t=e.replace(e.getRules(i),t),t=null!==(n=function(e,t){var i;const n=e.getSymbolDefinition(null!==(i=xe(t))&&void 0!==i?i:"");if(n&&!1===n.hold&&n.value)return"function"==typeof n.value?Bt(e,n.value(e)):Bt(e,n.value);const[r,s]=function([e,t]){if(null===e||null===t)return[null,null];const i=_(e,t);return t<0?[-e/i,-t/i]:[e/i,t/i]}(he(t));if(null!==r&&null!==s)return 1===s?r:0===r&&isFinite(s)?0:Object.is(s,-0)&&isFinite(r)?-1/0:0===s&&isFinite(r)?1/0:["Divide",r,s];const o=le(t);if(null!==o)return 0===o.im?o.re:["Complex",o.re,o.im];if("Complex"===ve(t)){const e=we(t,1),i=we(t,2),n=ae(i);if(0===n)return e;const r=ae(e);return 0===r?["Multiply",i,"ImaginaryUnit"]:["Add",null!=r?r:e,["Multiply",null!=n?n:i,"ImaginaryUnit"]]}return t}(e,t))&&void 0!==n?n:t,!0===e.is(t))return"True";if(de(t))return t;if(null!==Me(t))return ye(t,(t=>{var n;return null!==(n=e.simplify(t,{simplifications:i}))&&void 0!==n?n:t}));const l=Bt(e,null!==(r=ge(t))&&void 0!==r?r:z,i);if("string"==typeof l){const n=e.getFunctionDefinition(l);if(n){const r=[],u=be(t);for(let t=0;t<u.length;t++){const l=ve(u[t]);"Evaluate"===l?r.push(null!==(s=e.simplify(u[t],{simplifications:i}))&&void 0!==s?s:u[t]):"Hold"===l?r.push(null!==(o=we(u[t],1))&&void 0!==o?o:z):0===t&&"first"===n.hold||t>0&&"rest"===n.hold||"all"===n.hold?r.push(u[t]):r.push(null!==(a=e.simplify(u[t],{simplifications:i}))&&void 0!==a?a:u[t])}return"function"==typeof n.simplify?n.simplify(e,...r):[l,...r]}}return null!==l?[l,...be(t)]:t}function Zt(e,t){var i,n;const r=Gt(e),s=Gt(t);if(r<s)return-1;if(r>s)return 1;let o=Vt(e);isNaN(o)&&(o=Number(1/0));let a=Vt(t);if(isNaN(a)&&(a=Number(1/0)),o<a)return-1;if(o>a)return 1;const l=Wt(e),u=Wt(t);if(l===u&&l>0)for(let r=1;r<=l;r++){const s=Zt(null!==(i=we(e,r))&&void 0!==i?i:z,null!==(n=we(t,r))&&void 0!==n?n:z);if(0!==s)return s}return u-l}function Qt(e,t){var i,n;if(0===e)return-1/0;const r=ve(e);if(r===W){const t=null!==(i=ae(we(e,2)))&&void 0!==i?i:NaN;return isFinite(t)?t:0}if(r===H){let i=0;return be(e).forEach((e=>{i+=Qt(e,t)})),i}return t.includes(null!==(n=xe(e))&&void 0!==n?n:z)?1:0}function Ht(e,t){var i,n;const r=ve(e);if(r===W){if(xe(null!==(i=we(e,1))&&void 0!==i?i:z)===t){const t=null!==(n=ae(we(e,2)))&&void 0!==n?n:NaN;if(isFinite(t))return t}return 0}if(r===H){let i=0;for(const n of be(e))i+=Ht(n,t);return i}return xe(e)===t?1:0}function Gt(e){return"string"==typeof e?e:ne(e)?e.sym:ge(e)?be(e).map(Gt).join(" "):""}function Wt(e){if(ge(e)){const t=be(e);return t.map(Wt).reduce(((e,t)=>e+t),t.length)}return 0}function Vt(e){var t;return ge(e)?NaN:"number"==typeof e?e:ie(e)?null!==(t=ae(e))&&void 0!==t?t:NaN:0}function Yt(e,t,i){var n,r;let s=be(i);if(0===s.length)return i;s=s.map((i=>Yt(e,t,i)));const o=ve(i);if(o===j)s.sort(((e,i)=>function(e,t,i){const n=Qt(e,i),r=Qt(t,i);if(n<r)return 1;if(n>r)return-1;for(const n of i){const i=Ht(e,n),r=Ht(t,n);if(i!==r)return r-i}const s=Gt(e),o=Gt(t);return s>o?-1:s<o?1:Zt(e,t)}(e,i,t)));else{const t=e.getFunctionDefinition(o);null!==(n=null==t?void 0:t.commutative)&&void 0!==n&&n&&s.sort(Zt)}return[null!==(r=ge(i))&&void 0!==r?r:z,...s]}function Jt(e){if(de(e=$e(e)))return[Z,1,e];const t=ge(e);return t===W&&2===Se(e)?[W,we(e,1),Re(we(e,2))]:t===Z&&2===Se(e)?[Z,we(e,2),we(e,1)]:[Z,1,e]}function Kt(e,t){if(de(e))return e;if(ve(e)!==t)return ye(e,(e=>Kt(e,t)));const i=be(e);let n=[t];for(let e=0;e<i.length;e++)ve(i[e])===t?n=n.concat(be(Kt(i[e],t))):n.push(Kt(i[e],t));return n}function Xt(e,t){if(de(e))return e;const i=ve(e),n=t.getFunctionDefinition(i);if(null==n?void 0:n.involution){const t=be(e);if(1===t.length&&ve(t[0])===i)return Kt(t[0],i)}return ye(e,(e=>Xt(e,t)))}function ei(e,t){if(de(e))return e;const i=ve(e),n=t.getFunctionDefinition(i);return(null==n?void 0:n.idempotent)?Kt(e,i):ye(e,(e=>ei(e,t)))}function ti(e,t){if(de(e))return e;const i=ve(e),n=t.getFunctionDefinition(i);return(null==n?void 0:n.associative)?Kt(e,i):ye(e,(e=>ti(e,t)))}function ii(e,t){if(de(e))return e;if(ge(e)!==j)return ye(e,(e=>ii(e)));let i=be(e=Kt($e(e),j));i=i.map((e=>ii(e))).filter((e=>0!==ae(e)));const n=i.length;return 0===n?0:1===n?i[0]:[j,...i]}function ni(e,t){if(de(e))return e;if(ge(e)!==Z)return ye(e,(e=>ni(e)));if(2!==Se(e))return e;const i=ni(we(e,1)),n=ni(we(e,2));return 1===ae(n)?i:1===ae(i)?Jt(n):-1===ae(i)?[G,Jt(n)]:[Z,i,n]}function ri(e,t){return de(e)?e:ve(e)===W&&xe(we(e,1))===ee?["Exp",ri(we(e,2))]:ye(e,(e=>ri(e)))}function si(e,t){var i;if(de(e))return e;const n=ve(e);if(n!==L&&n!==R&&n!==$)return ye(e,(e=>si(e,t)));const r=be(e);let s=[ge(e)];if(n===L){for(let e of r)if(e=si(e,t),ve(e)===T){const t=we(e,1);null!==t&&s.push(t)}else s.push(e);return s}const o=t.getFunctionDefinition(n),a=null!==(i=null==o?void 0:o.sequenceHold)&&void 0!==i&&i;for(let e of r){e=si(e,t);const i=ve(e);if(i===T){const t=we(e,1);null!==t&&s.push(t)}else if(i!==n||a)s.push(e);else for(let i of be(e))i=si(i,t),ve(i)===n?s=s.concat(be(i)):s.push(i)}return s}function oi(e){var t,i;const n=ve(e);if(n===J)return 2;if(n===Y)return null!==(t=ae(we(e,2)))&&void 0!==t?t:2;if(n!==W)return 1;const r=we(e,2);if(null===r)return 1;if(ve(r)===W&&-1===ae(we(r,2))){const e=null!==(i=ae(we(r,1)))&&void 0!==i?i:NaN;if(isFinite(e))return e}return 1}function ai(e,t){var i;if(de(e))return e;if(ge(e)!==H)return ye(e,(e=>ai(e)));e=Kt($e(e),H);const[n,r]=function(e){var t;const i=be(e),n=[],r=[];for(const e of i)2===oi(e)?n.push(null!==(t=we(e,1))&&void 0!==t?t:z):r.push(e);return[n,r]}(e);let s;s=0===n.length?r:1===n.length?[...r,[J,n[0]]]:[...r,[J,[H,...n]]];let o=!1,a=!1;if(s=s.map((e=>{var t,i;if(ve(e)===G)return a=!0,o=!o,null!==(t=we(e,1))&&void 0!==t?t:z;const n=null!==(i=ae(e))&&void 0!==i?i:NaN;return n<0?(a=!0,o=!o,-n):e})),o){const e=null!==(i=ae(s[0]))&&void 0!==i?i:NaN;s=isFinite(e)?be(Kt([H,-e,...s.slice(1)],H)):be(Kt([H,-1,...s],H))}else s=be(Kt([H,...s],H));return s=s.filter((e=>1!==ae(e))),0===s.length?1:1===s.length?s[0]:[H,...s]}function li(e,t){return de(e)?e:ve(e=ye(e,(e=>li(e,t))))===W?je(t,e):e}function ui(e,t){var i;return de(e)?e:ge(e)!==G?ye(e,(e=>ui(e))):Re(null!==(i=we($e(e),1))&&void 0!==i?i:z)}function ci(e,t){return e}function fi(e,t){return Be(e)}function hi(e,t){if(!de(e))return ye(e,(e=>fi(e)));const[i,n]=he(e);return null===i||null===n?e:1===n?i:-1===n?-i:n<0?["Divide",Re(i),Re(n)]:["Divide",i,n]}function mi(e,t){if("number"==typeof e){if(isNaN(e))return{num:"NaN"};if(!isFinite(e)&&e>0)return{num:"+Infinity"};if(!isFinite(e)&&e<0)return{num:"-Infinity"}}else{if(e instanceof h.exports.Decimal)return{num:e.toString()+"d"};if(ie(e))return/([+-]Infinity|NaN)/.test(e.num)||/[+-]?\d*\.?\d*([eE][+-]?\d+)?[dn]?/.test(e.num)?e:{num:"NaN"}}if("ImaginaryUnit"===e)return e;const i=le(e);if(null!==i){if(0===t.chop(i.im)&&0===t.chop(i.re))return 0;if(0===t.chop(i.im))return i.re;let e=null;return e=0===t.chop(i.im+1)?["Negate","ImaginaryUnit"]:0===t.chop(i.im-1)?"ImaginaryUnit":["Multiply",i.im,"ImaginaryUnit"],0===t.chop(i.re)?e:["Add",i.re,e]}return de(e)?e:ye(e,(e=>mi(e,t)))}function pi(e,t){if(de(e))return e;if(ge(e)!==K)return ye(e,(e=>pi(e)));if(2!==Se(e))return e;const i=pi(we(e,1)),n=ae(i),r=pi(we(e,2)),s=ae(r);return 0===n?0===s?0:Re(r):[j,i,Re(r)]}function gi(e,t){if(de(e))return e;const i=ge(e);if(Se(e)<2&&i!==Y&&i!==W)return ye(e,(e=>gi(e)));const n=gi(we(e,2)),r=gi(we(e,1));if(i===Y)return 2===ae(n)?[J,r]:[Y,r,n];if(i===W){const[e,t]=he(n);if(-1===e)return 2===t?[J,r]:[Y,r,t];if(1===t)return[W,r,e];if(null!==e&&null!==t)return[W,r,[Z,e,t]]}return e}function di(e){if("string"==typeof e){const t=Number(e);if("+"===e[0]&&(e=e.slice(1)),t.toString()===e)return isNaN(t)||!isFinite(t)?t.toString():t}return e}function vi(e,t){if(null===e)return null;if(Array.isArray(e))return e.map(((e,t)=>{var i;return 0===t?e:null!==(i=vi(e))&&void 0!==i?i:U}));if("object"==typeof e)if(1===Object.keys(e).length){if(ie(e)){const t=di(e.num);return"number"==typeof t?t:{num:t}}if(se(e))return e.fn.map((e=>{var t;return null!==(t=vi(e))&&void 0!==t?t:U}));if(ne(e))return e.sym}else se(e)&&(e.fn=e.fn.map((e=>{var t;return null!==(t=vi(e))&&void 0!==t?t:U})));return e}function xi(e,t){if(null===e)return null;if("number"==typeof e||"string"==typeof e)return e;if(Array.isArray(e))return e.map((e=>{var t;return null!==(t=xi(e))&&void 0!==t?t:U}));if("object"==typeof e){if("num"in e){const t=di(e.num);return"number"==typeof t?t:{num:t}}if("fn"in e)return e.fn.map((e=>{var t;return null!==(t=xi(e))&&void 0!==t?t:U}));if("dict"in e)return{dict:Object.fromEntries(Object.entries(e.dict).map((e=>{var t;return[e[0],null!==(t=xi(e[1]))&&void 0!==t?t:U]})))}}return null}function bi(e,t){return"number"==typeof e?{num:e.toString()}:"string"==typeof e?{sym:e}:Array.isArray(e)&&e.length>0?{fn:e.map((e=>bi(e)))}:"object"==typeof e&&"fn"in e?{...e,fn:e.fn.map((e=>bi(e)))}:e}function yi(e,t){const i=t.getVars(e);return Yt(t,Array.from(i).sort(),e)}function Ni(e,t){return t.format(e,["canonical-boolean","canonical-number","canonical-exp","canonical-root","canonical-subtract","canonical-divide","canonical-power","canonical-multiply","canonical-negate","canonical-add","flatten","canonical-list","canonical-domain","canonical-rational","canonical-constants","sorted","json"])}function wi(e,t){return ti(ei(Xt(e,t),t),t)}function Si(e,t){return function(e,t){return t}(0,e)}function Mi(e,t){var i,n;const r=null!==(n=null!==(i=le(t))&&void 0!==i?i:ce(t))&&void 0!==n?n:ae(t);if(null!==r)return r;const s=xe(t);if(null!==s){const i=e.getSymbolDefinition(s);return i&&i.value?"function"==typeof i.value?Mi(e,i.value(e)):Mi(e,i.value):t}return null!==Me(t)?ye(t,(t=>{var i;return null!==(i=Mi(e,t))&&void 0!==i?i:t})):null!==ge(t)?function(e,t){var i,n,r,s,o;const a=ge(t);if("string"==typeof a){const l=e.getFunctionDefinition(a);if(l&&l.numeric){const n=[];let r=0,s=0,o=0;for(let a of be(t))if("Evaluate"===ve(a)&&(a=null!==(i=we(a,1))&&void 0!==i?i:z),"Hold"===ve(a))n.push(a);else{const t=Mi(e,a);t instanceof h.exports.Decimal?(s+=1,n.push(t)):t instanceof m.exports.Complex?(o+=1,n.push(t)):"number"==typeof t?(r+=1,n.push(t)):n.push(null!=t?t:a)}let u=e.numericFormat;"auto"===u&&(u=o>0?"complex":s>0?"decimal":"machine"),("decimal"===u&&"function"!=typeof l.evalDecimal||"complex"===u&&"function"!=typeof l.evalComplex)&&(u="machine");const c=r+s+o;if(c===n.length){if("decimal"==u&&0===o)return l.evalDecimal(e,...n);if("complex"==u&&0===s)return l.evalComplex(e,...n);if("function"==typeof l.evalNumber&&r===c)return l.evalNumber(e,...n)}return"function"==typeof l.evaluate?l.evaluate(e,...n):[a,...n]}if(l){const i=[],u=be(t);for(let t=0;t<u.length;t++){const a=ve(u[t]);if("Hold"===a)i.push(null!==(n=we(u[t],1))&&void 0!==n?n:z);else if("Evaluate"===a){const n=null!==(r=we(u[t],1))&&void 0!==r?r:z;i.push(null!==(s=Mi(e,n))&&void 0!==s?s:n)}else 0===t&&"first"===l.hold||t>0&&"rest"===l.hold||"all"===l.hold?i.push(u[t]):i.push(null!==(o=Mi(e,u[t]))&&void 0!==o?o:u[t])}return"function"==typeof l.evaluate?l.evaluate(e,...i):[a,...i]}}const l={__:["Sequence",be(t)]};let u=1;for(const e of be(t))1===u&&(l._=e),l[`_${u}`]=e,u+=1;return Mi(e,gt(a,l))}(e,t):t}function Ei(e,t){var i,n,r,s,o,a;if(null===t)return null;const l=null!==(n=null!==(i=ce(t))&&void 0!==i?i:ae(t))&&void 0!==n?n:le(t);if(null!==l)return l;const u=xe(t);if(null!==u){const i=e.getSymbolDefinition(u);return i&&i.value?"function"==typeof i.value?i.value(e):i.value:t}if(null!==Me(t))return ye(t,(t=>{var i;return null!==(i=Ei(e,t))&&void 0!==i?i:t}));const c=ge(t);if(null!==c){if("string"==typeof c){const i=e.getFunctionDefinition(c);if(null===i)return t;const n=[],l=be(t);for(let t=0;t<l.length;t++){const u=ve(l[t]);if("Hold"===u)n.push(null!==(r=we(l[t],1))&&void 0!==r?r:z);else if("Evaluate"===u){const i=null!==(s=we(l[t],1))&&void 0!==s?s:z;n.push(null!==(o=Mi(e,i))&&void 0!==o?o:i)}else 0===t&&"first"===i.hold||t>0&&"rest"===i.hold||"all"===i.hold?n.push(l[t]):n.push(null!==(a=Ei(e,l[t]))&&void 0!==a?a:l[t])}return"function"==typeof i.evaluate?i.evaluate(e,...n):[c,...n]}const i={__:["Sequence",be(t)]};let n=1;for(const e of be(t))1===n&&(i._=e),i[`_${n}`]=e,n+=1;return Ei(e,gt(c,i))}return t}const Ai={x:"_x",y:"_y",z:"_z",a:"_a",b:"_b",c:"_c",m:"_m",n:"_n",i:"_i",j:"_j"};function Di(e,t){const i=new Set;for(const[n,r,s]of t){const t="string"==typeof n?e.canonical(Ci(e.parse(n),Ai)):Ci(n,Ai),o="string"==typeof r?e.canonical(Ci(e.parse(r),Ai)):Ci(r,Ai);if("function"==typeof s||void 0===s)i.add([t,o,s]);else if("string"==typeof s){const n=e.parse(s);i.add([t,o,(e,t)=>{var i;return null!==(i=e.is(gt(n,t)))&&void 0!==i&&i}])}}return i}function Ci(e,t){for(const[i,n]of Object.entries(t))e=_i(e,i,n);return e}function _i(e,t,i){return xe(e)===t?i:ve(e)===t?[i,be(e)]:de(e)?e:ye(e,(e=>_i(e,t,i)))}function ki(e,[t,i,n],r){const s=pt(t,r);return null===s?null:"function"!=typeof n||n(e,s)?gt(i,s):null}class Fi{constructor(e){var t;const i=null!==(t=null==e?void 0:e.dictionaries)&&void 0!==t?t:Fi.getDictionaries();this.numericFormat="auto",this.tolerance=D;for(const e of i)this.context?this.pushScope(e):this.pushScope(e,{warn:e=>{for(const t of e)t.message},timeLimit:2,memoryLimit:1,recursionLimit:1024});this.pushScope({})}static getDictionaries(e="all"){return Lt(e)}get precision(){return this._precision}set precision(e){"machine"===e&&(e=Math.min(A,Math.floor(A))),e<=A&&(this._numericFormat="machine"),h.exports.Decimal.set({precision:e}),this._precision=e}get numericFormat(){return this._numericFormat}set numericFormat(e){"machine"===e||"complex"===e||"auto"===e?this._precision=Math.floor(A):"decimal"===e&&(this._precision=h.exports.Decimal.precision),this._numericFormat=e}get tolerance(){return this._tolerance}set tolerance(e){this._tolerance=Math.max(e,0)}*getRules(e){if(!this._rules){this._rules={};for(const e of Object.keys(jt))this._rules[e]=Di(this,jt[e])}"string"==typeof e&&(e=[e]);for(const t of e)if(this._rules[t])for(const e of this._rules[t])yield e}get latexSyntax(){return this._latexSyntax||(this._latexSyntax=new lt),this._latexSyntax}pushScope(e,t){this.context={...t,parentScope:this.context,dictionary:Ut(e,this),assumptions:this.context?new vt(this.context.assumptions):new vt}}popScope(){var e;const t=null===(e=this.context)||void 0===e?void 0:e.parentScope;if(this.context.warnings){const e=[...this.context.warnings];this.context.warnings=[],this.context.warn&&this.context.warn(e)}t&&this.context.warnings&&this.context.warnings.length>0&&(t.warnings?t.warnings=[...t.warnings,...this.context.warnings]:t.warnings=[...this.context.warnings]),this.context=t}get assumptions(){return this.context.assumptions||(this.context.assumptions=new vt),this.context.assumptions}signal(e){}get timeLimit(){let e=this.context;for(;e;){if(void 0!==e.timeLimit)return e.timeLimit;e=e.parentScope}}get recursionLimit(){let e=this.context;for(;e;){if(void 0!==e.recursionLimit)return e.recursionLimit;e=e.parentScope}}get iterationLimit(){let e=this.context;for(;e;){if(void 0!==e.iterationLimit)return e.iterationLimit;e=e.parentScope}}shouldContinueExecution(){return void 0===this.deadline||this.deadline>=Date.now()}checkContinueExecution(){if(!this.shouldContinueExecution())throw new ut({message:"timeout"})}getFunctionDefinition(e){var t,i;let n,r=this.context;for(;r&&!n;)n=null===(t=r.dictionary)||void 0===t?void 0:t.get(e),void 0===n||It(n)||(n=void 0),void 0===n&&(r=r.parentScope);return n&&(n.scope=r),null!==(i=n)&&void 0!==i?i:null}getSymbolDefinition(e){var t;let i,n=this.context;for(;n&&!i;)i=null===(t=n.dictionary)||void 0===t?void 0:t.get(e),void 0===i||qt(i)||(i=void 0),void 0===i&&(n=n.parentScope);return i?(i.scope=n,i):null}getSetDefinition(e){var t;let i,n=this.context;for(;n&&!i;)i=null===(t=n.dictionary)||void 0===t?void 0:t.get(e),void 0===i||Ft(i)||(i=void 0),void 0===i&&(n=n.parentScope);return i?(i.scope=n,i):null}getCollectionDefinition(e){var t;let i,n=this.context;for(;n&&!i;)i=null===(t=n.dictionary)||void 0===t?void 0:t.get(e),void 0===i||Pt(i)||(i=void 0),void 0===i&&(n=n.parentScope);return i?(i.scope=n,i):null}getDefinition(e){var t;let i,n=this.context;for(;n&&!i;)i=null===(t=n.dictionary)||void 0===t?void 0:t.get(e),void 0===i&&(n=n.parentScope);return i?(i.scope=n,i):null}canonical(e){return this.format(e)}format(e,t){return function(e,t,i){let n=t;for(const t of i){const i={canonical:Ni,"canonical-add":ii,"canonical-boolean":ci,"canonical-constants":fi,"canonical-divide":ni,"canonical-domain":Si,"canonical-exp":ri,"canonical-list":si,"canonical-multiply":ai,"canonical-power":li,"canonical-negate":ui,"canonical-number":mi,"canonical-rational":hi,"canonical-root":gi,"canonical-subtract":pi,json:vi,flatten:wi,sorted:yi,"stripped-metadata":xi,"object-literal":bi}[t];if(!i)return null;n=i(n,e)}return n}(this,e,Array.isArray(t)?t:[null!=t?t:"canonical"])}evaluate(e,t){return async function(e,t,i){var n,r,s,o;const a=null!==(r=null!==(n=null==i?void 0:i.timeLimit)&&void 0!==n?n:e.timeLimit)&&void 0!==r?r:2;a&&isFinite(a)&&(e.deadline=Date.now()+1e3*a);const l=null!==(o=null!==(s=null==i?void 0:i.iterationLimit)&&void 0!==s?s:e.iterationLimit)&&void 0!==o?o:1024;let u=0,c=t,f=JSON.stringify(c);for(;u<l&&e.shouldContinueExecution();){if(c=Ei(e,c),null===c)return null;const t=JSON.stringify(c);if(f===t)return c;f=t,u+=1}return e.canonical(c)}(this,e,t)}simplify(e,t){return Bt(this,e,null==t?void 0:t.simplifications)}N(e,t){const i=this.precision,n=this.numericFormat;(null==t?void 0:t.precision)&&(this.precision=t.precision);let r=this.canonical(Bt(this,e));return null!==r&&(r=Mi(this,r)),null!==r&&(r=this.canonical(r)),this.precision=i,this.numericFormat=n,null!=r?r:e}is(e,t){let i=e;return t&&(i=["Element",e,t]),function(e,t){let i=!0;[t,i]=xt(t);const n=e.assumptions.get(t);if(void 0!==n)return n===i}(this,i)}ask(e){const t=[];for(const i in this.assumptions){const n=pt(e,i,{numericalTolerance:this._tolerance});null!==n&&t.push(n)}return t}assume(e,t){let i=e;return t&&(i=["Element",e,t]),bt(this,i)}replace(e,t){return function(e,t,i){let n=!1;for(;!n;){n=!0;for(const r of t){const t=ki(e,r,i);null!==t&&(n=!1,i=t)}}return i}(this,e,t)}domain(e){return Tt(this,e)}getVars(e){return ft(this,e)}chop(e){return"number"==typeof e?Math.abs(e)<=this._tolerance?0:e:e instanceof m.exports.Complex?Math.abs(e.re)<=this._tolerance&&Math.abs(e.im)<=this._tolerance?0:e:e instanceof h.exports.Decimal&&e.abs().lte(this._tolerance)?p:e}parse(e){return this.latexSyntax.parse(e)}serialize(e){return this.latexSyntax.serialize(e)}isZero(e){return qe(this,e)}isNotZero(e){return Ie(this,e)}isNumeric(e){return!1}isInfinity(e){return Pe(this,e)}isFinite(e){}isNonNegative(e){return function(e,t){const i=e.isZero(t);if(void 0!==i)return!0===i||e.isPositive(t)}(this,e)}isPositive(e){return Te(this,e)}isNegative(e){return Oe(this,e)}isNonPositive(e){return function(e,t){const i=Te(e,t);if(void 0!==i)return!i}(this,e)}isInteger(e){return function(e,t){const i=ae(t);return null!==i&&Number.isInteger(i)}(0,e)}isRational(e){}isAlgebraic(e){}isReal(e){return Le(0,e)}isExtendedReal(e){}isComplex(e){}isOne(e){}isNegativeOne(e){}isElement(e,t){}isSubsetOf(e,t){return ze(this,e,t)}isEqual(e,t){}isLess(e,t){}isLessEqual(e,t){}isGreater(e,t){}isGreaterEqual(e,t){}}class qi{constructor(e){this.internal=new Fi(e)}static getDictionaries(e="all"){return Fi.getDictionaries(e)}get precision(){return this.internal.precision}set precision(e){this.internal.precision=e}get numericFormat(){return this.internal.numericFormat}set numericFormat(e){this.internal.numericFormat=e}get tolerance(){return this.internal.tolerance}set tolerance(e){this.internal.tolerance=e}get context(){return this.internal.context}pushScope(e,t){this.internal.pushScope(e,t)}popScope(){this.internal.popScope()}get assumptions(){return this.internal.assumptions}shouldContinueExecution(){return this.internal.shouldContinueExecution()}checkContinueExecution(){this.internal.checkContinueExecution()}signal(e){this.internal.signal(e)}getFunctionDefinition(e){return this.internal.getFunctionDefinition(e)}getSymbolDefinition(e){return this.internal.getSymbolDefinition(e)}getSetDefinition(e){return this.internal.getSetDefinition(e)}getCollectionDefinition(e){return this.internal.getCollectionDefinition(e)}getDefinition(e){return this.internal.getDefinition(e)}getRules(e){return this.internal.getRules(e)}format(e,t){return this.internal.format(e,t)}canonical(e){return this.internal.format(e,["canonical"])}N(e){return this.internal.N(e)}simplify(e,t){var i,n,r,s;const o=null!==(n=null!==(i=null==t?void 0:t.timeLimit)&&void 0!==i?i:this.internal.timeLimit)&&void 0!==n?n:2;o&&isFinite(o)&&(this.internal.deadline=Date.now()+1e3*o);const a=null!==(s=null!==(r=null==t?void 0:t.iterationLimit)&&void 0!==r?r:this.internal.iterationLimit)&&void 0!==s?s:1024;let l=0,u=this.canonical(e),c=u;for(;l<a&&this.shouldContinueExecution();){if(u=this.internal.simplify(u,{simplifications:null==t?void 0:t.simplifications}),null===u)return c;if(Ee(c,u))return this.canonical(u);c=u,l+=1}return null===u?null:this.canonical(u)}async evaluate(e,t){const i=this.internal.evaluate(e,t);return null===i?null:this.canonical(await i)}parse(e){return this.internal.parse(e)}serialize(e){return this.serialize(e)}domain(e){return this.internal.domain(e)}is(e,t){return this.internal.is(e,t)}ask(e){return this.internal.ask(e)}assume(e,t){return this.internal.assume(e,t)}replace(e,t){return this.internal.replace(e,t)}getVars(e){return this.internal.getVars(e)}chop(e){return this.internal.chop(e)}isZero(e){return this.internal.isZero(e)}isNotZero(e){return this.internal.isNotZero(e)}isNumeric(e){return this.internal.isNumeric(e)}isInfinity(e){return this.internal.isInfinity(e)}isFinite(e){return this.internal.isFinite(e)}isNonNegative(e){return this.internal.isNonNegative(e)}isPositive(e){return this.internal.isPositive(e)}isNegative(e){return this.internal.isNegative(e)}isNonPositive(e){return this.internal.isNonPositive(e)}isInteger(e){return this.internal.isInteger(e)}isRational(e){return this.internal.isRational(e)}isAlgebraic(e){return this.internal.isAlgebraic(e)}isReal(e){return this.internal.isReal(e)}isExtendedReal(e){return this.internal.isExtendedReal(e)}isComplex(e){return this.internal.isComplex(e)}isOne(e){return this.internal.isOne(e)}isNegativeOne(e){return this.internal.isNegativeOne(e)}isElement(e,t){return this.internal.isElement(e,t)}isSubsetOf(e,t){return this.internal.isSubsetOf(e,t)}isEqual(e,t){return this.internal.isEqual(e,t)}isLess(e,t){return this.internal.isLess(e,t)}isLessEqual(e,t){return this.internal.isLessEqual(e,t)}isGreater(e,t){return this.internal.isGreater(e,t)}isGreaterEqual(e,t){return this.internal.isGreaterEqual(e,t)}}let Ii=null;const Pi=/\r\n|[\n\r\u2028\u2029]/,Ti=e=>`<div>${e.join("</div><div>")}</div>`,Oi=e=>`<span style="color:#F33">${e}</span>`;class Li{constructor(e,t){this.source=e,this.url=null!=t?t:""}get lines(){return this._lines||(this._lines=this.source.split(Pi)),this._lines}get lineOffsets(){if(null==this._lineOffsets){const e=[],t=this.source;let i=!0,n=0;for(;n<t.length;){i&&(e.push(n),i=!1);const r=t.charCodeAt(n);i=13===r||10===r||8232===r||8233===r,13===r&&n+1<t.length&&10===t.charCodeAt(n+1)&&n++,n++}i&&t.length>0&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets}getLinecol(e){e=Math.max(Math.min(e,this.source.length),0);const t=this.lineOffsets;let i=0,n=t.length;if(0===n)return[1,e+1];for(;i<n;){const r=Math.floor((i+n)/2);t[r]>e?n=r:i=r+1}return[i,e-t[i-1]+1]}signalOrigin(e){const[t,i]=this.getLinecol(e);return{url:this.url,source:this.source,offset:e,line:t,column:i,around:this.sourceAround(t,i)}}chalkGutter(e){return(e=>`<span style="opacity:.5">${e}</span>`)(e)}chalkMarker(e){return Oi(e)}chalkMessage(e){return Oi(e)}sourceAround(e,t,i){const n=Math.max(e-1-3,0),r=Math.min(this.lines.length,e+3)-1,s="number"==typeof t,o=String(r).length,a=[];for(let l=n;l<=r;l++){const n=` ${` ${l+1}`.slice(-o)} ┆ `;let r="";if(l===e-1){if(s){const e=this.lines[l].slice(0,Math.max(t-1,0)).replace(/[^\t]/g," ");r=Ti(["",[" ",this.chalkGutter(n.replace(/\d/g," ")),e,this.chalkMarker("^")].join("")]),i&&(r+=" "+this.chalkMessage(i))}else i&&(r=Ti(["",this.chalkGutter(n.replace(/\d/g," "))+i]));a.push(`<span style="background:rgba(255, 100, 100, .1);display:block;border-radius: 4px">${[this.chalkMarker(">"),this.chalkGutter(n),this.lines[l],r].join("")}</span>`)}else a.push(` ${this.chalkGutter(n)}${this.lines[l]}`)}return Ti(a)}}const zi=[10,13,8232,8233],Ui=Wi([[33,47],[58,64],[91,94],96,[123,126],[161,167],169,[171,172],174,[176,177],182,187,191,215,247,[8208,8254],[8257,8275],[8592,8730],[8731,10101],[10132,11903],[12289,12291],[12296,12320],12336,[64830,64831],[65093,65094]]),Ri=Wi([[0,32],[127,159],92,96,[65534,65535]]),$i=[...Ri,33,34,35,36,37,38,39,40,41,46,58,60,63,64,91,93,94,123,125,126],ji=[9,10,11,12,13,32,133,8206,8207,8232,8233,0,160,5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288],Bi=Wi([...ji,2042,65101,65102,65103,8208,8209,8210,8211,65112,8259,727,65374,65306,1417,1795,1796,65072,8282,1475,760,42889,8758,42237,894,65281,451,660,2429,8228,1748,1793,1794,1632,1776,12539,65381,903,65793,8231,65282,8220,8221,[0,31],[127,159],173,1564,6158,8203,8204,8205,8206,8207,8288,8289,8290,8291,8292,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,10240,[64976,65007],65279,65534,65535]),Zi=new Map([[0,"\\0"],[8,"\\b"],[9,"\\t"],[10,"\\n"],[12,"\\f"],[13,"\\r"],[32," "],[92,"\\\\"],[39,"\\'"],[34,'\\"']]),Qi=new Map([[48,0],[92,92],[39,39],[34,34],[98,8],[102,12],[110,10],[114,13],[115,32],[116,9]]),Hi=new Map([[48,0],[49,1],[50,2],[51,3],[52,4],[53,5],[54,6],[55,7],[56,8],[57,9],[97,10],[65,10],[98,11],[66,11],[99,12],[67,12],[100,13],[68,13],[101,14],[69,14],[102,15],[70,15],[65296,0],[65297,1],[65298,2],[65299,3],[65300,4],[65301,5],[65302,6],[65303,7],[65304,8],[65305,9],[65313,10],[65314,11],[65315,12],[65316,13],[65317,14],[65318,15],[65345,10],[65346,11],[65347,12],[65348,13],[65349,14],[65350,15]]),Gi=new Map([[48,0],[49,1],[50,2],[51,3],[52,4],[53,5],[54,6],[55,7],[56,8],[57,9],[65296,0],[65297,1],[65298,2],[65299,3],[65300,4],[65301,5],[65302,6],[65303,7],[65304,8],[65305,9]]);function Wi(e){const t=[];for(const i of e)if("number"==typeof i)t.push(i);else for(let e=i[0];e<=i[1];e++)t.push(e);return t}function Vi(e){return zi.includes(e)}function Yi(e){return 9===e||32===e}function Ji(e){return ji.includes(e)}function Ki(e){return ji.includes(e)||Ui.includes(e)}function Xi(e){return Ri.includes(e)}function en(e){return $i.includes(e)}function tn(e){return Bi.includes(e)}function nn(e){return e>65535?2:1}!function(e){const t=new Map;for(const[i,n]of Object.entries(e))if(t.has(n)){const e=t.get(n);e.push(parseInt(i)),t.set(n,e)}else t.set(n,[parseInt(i)])}(new Map([[172,"!"],[177,"+-"],[8723,"-+"],[215,"*"],[247,"/"],[8725,"/"],[8228,"."],[8229,".."],[8230,"..."],[8231,"."],[8242,"'"],[8243,"''"],[8244,"'''"],[8258,"***"],[8260,"/"],[8263,"??"],[8264,"?!"],[8265,"!?"],[8270,"*"],[8273,"**"],[8278,"..."],[8281,"....."],[8282,":"],[8283,".:."],[8290,"*"],[8292,"+"],[960,"Pi"],[8252,"!!"],[8520,"ImaginaryUnit"],[8519,"ExponentialE"],[8450,"ComplexNumber"],[8477,"RealNumber"],[8469,"NaturalNumber"],[8484,"Integer"],[8474,"RationalNumber"],[8592,"<-"],[8594,"->"],[8596,"<->"],[8614,"|->"],[8656,"=>"],[8660,"<=>"],[8709,"EmptySet"],[8734,"Infinity"],[10717,"ComplexInfinity"],[8722,"-"],[8728,"."],[8896,"&&"],[8897,"||"],[8743,"&&"],[8744,"||"],[8759,"::"],[8800,"!="],[8801,"=="],[8802,"!=="],[8803,"==="],[10877,"<="],[10878,">="],[8804,"<="],[8805,">="],[8806,"<="],[8807,">="],[8810,"<<"],[8811,">>"],[9655,"|>"],[9665,"<|"],[10704,"||>"],[10703,"<||"],[8669,"~>"],[8668,"<~"],[8712,"in"],[8713,"!in"],[10869,"=="],[10870,"==="],[9216,"\\0"],[9224,"\\b"],[9225,"\\t"],[9226,"\\n"],[9252,"\\n"],[9229,"\\r"]]));class rn extends Error{constructor(e){super(),this.message=e}}class sn{constructor(e,t,i){this._offset=0,this.length=0,this.rules=e,this.source=t,this.url=i,this.length=t.length,this._trace=[]}get(e){return this.source.codePointAt(e)}atEnd(){return this.offset>=this.source.length}atLinebreak(){return Vi(this.source.codePointAt(this.offset))}atString(e){let t=0,i=!0;const n=this.offset;for(;i&&t<e.length&&t<this.source.length;)i=this.get(n+t)===e.codePointAt(t),t+=1;return i}slice(e,t){return this.source.slice(e,t)}get offset(){return this._offset}trace(e){return[...this._trace,"string"==typeof e?e:"function"==typeof e?"???":e[0]]}skipTo(e){return this._offset=e,this}fatalError(e){throw new rn(e)}hasRule(e){return this.rules.has(e)}parse(e,t){let i;return this._trace.push("string"==typeof e?e:"function"==typeof e?"???":e[0]),void 0!==t&&this.skipTo(t),i="string"==typeof e?this.rules.parse(e,this):"function"==typeof e?e(this):e[1](this),this._trace.pop(),i}parseWhitespace(){return this.hasRule("whitespace")?this.parse("whitespace"):this.ignore()}ignore(){return new on(this).ignore()}failure(){return new on(this).failure()}}class on{constructor(e){this._parser=e,this._range=[e.offset,e.offset]}copyDiagnostics(e){e.isError&&(void 0===this._diagnostics&&(this._diagnostics=[]),e._diagnostics&&(this._diagnostics=[...this._diagnostics,...e._diagnostics]))}get parser(){return this._parser}get diagnostics(){var e;return null!==(e=this._diagnostics)&&void 0!==e?e:[]}get isFailure(){return void 0===this._diagnostics&&void 0===this._value}get isEmpty(){return void 0===this._diagnostics&&null===this._value}get isSuccess(){return void 0===this._diagnostics&&void 0!==this._value&&null!==this._value}get isError(){return void 0!==this._diagnostics}get start(){return this._range[0]}get end(){return this._range[1]}set end(e){this._range[1]=e}set range(e){this._range=e}get value(){return this._value}set value(e){this._value=e}success(e){return this._value=e,this._range[1]=this._parser.offset-1,this}failure(){return this._parser.skipTo(this._range[0]),this}ignore(){return this._value=null,this}ignoreUntil(e){return this._parser.skipTo(e),this._range[1]=this._parser.offset,this._value=null,this}error(e,t,i){return this._value=e,this._range[1]=this._parser.offset-1,this._diagnostics||(this._diagnostics=[]),this._diagnostics.push({severity:"error",range:[this._range[0],this._range[1]],message:"function"==typeof t?t(this):t,fixits:i}),this}errorAt(e,t,i,n){return this._value=e,this._range[1]=this._parser.offset-1,this._diagnostics||(this._diagnostics=[]),this._diagnostics.push({severity:"error",range:[this._range[0],this._range[1],i],message:"function"==typeof t?t(this):t,fixits:n}),this}errorFrom(e,t){return this._value=t,this._range[1]=this._parser.offset-1,this._diagnostics||(this._diagnostics=[]),e._diagnostics&&(this._diagnostics=[...this._diagnostics,...e._diagnostics]),this}warning(e,t){return this._range[1]=this._parser.offset-1,this._diagnostics||(this._diagnostics=[]),this._diagnostics.push({severity:"warning",range:[this._range[0],this._range[1]],message:e,fixits:t}),this}}function an(e,t){let i=e.offset;const n=[...t].map((e=>e.codePointAt(0)));for(;i<t.length-n.length;){let t=e.get(i);if(t===n[0]){let r=!0,s=1;for(;r&&s<n.length;)t=e.get(i),r=t===n[s],r&&(s+=1,i+=nn(t));if(r)return i}i+=nn(t)}return-1}function ln(e){return"string"==typeof e?e:e[0]}function un(e,t,i,n,r){const s=new on(e);let o=0,a=1/0;for(const e of i)s.copyDiagnostics(e),(e.isSuccess||e.isError)&&(o=Math.max(o,e.end),a=Math.min(a,e.end));if(s.range=[a,o],s.value=i.length>0?t(...i):null,r&&s.error(s.value,r),n)for(const e of n)s.copyDiagnostics(e);return s}function cn(e,t){const i=new on(e);let n=0,r=!0;const s=e.offset;for(;n<t.length&&r&&n<e.length;)r=e.get(s+n)===t.codePointAt(n),n++;return r&&n===t.length&&(e.skipTo(e.offset+n),i.success(t)),i}function fn(e){return 1===e.length?function(e){return[`U+${("0000"+e.toString(16)).slice(-4)} (${String.fromCodePoint(e)})`,t=>function(e,t){const i=new on(e),n=e.offset;return e.get(n)!==t&&i.failure(),e.skipTo(n+nn(t)),i.success(String.fromCodePoint(t))}(t,e)]}(e.codePointAt(0)):[`**\`${e}\`**`,t=>cn(t,e)]}function hn(e,t){return[e.map((e=>ln(e))).join(" "),i=>{const n=[],r=[];let s=!0;r.push(i.parseWhitespace());for(const o of e){const e=i.offset,a=i.parse(o);if(n.push(a),a.isFailure&&s)return a;if(a.isFailure)return un(i,t,n,r,["unexpected-symbol",String.fromCodePoint(i.get(e)),i.trace(o)]);s=!1,r.push(i.parseWhitespace())}return un(i,t,n,r)}]}function mn(e,t){return[e.map((e=>ln(e))).join(" | "),i=>{const n=i.offset;let r;for(const s of e){i.skipTo(n);const e=i.parse(s);if(t&&(e.isSuccess||e.isError)&&(e.value=t(e)),e.isSuccess)return e;!r&&e.isError&&(r=e)}return r?(i.skipTo(r.end+1),r):(i.skipTo(n),i.failure())}]}function pn(e,t){return[`(${ln(e)})!`,i=>{const n=i.parse(e);if(n.isSuccess||n.isEmpty||n.isError)return n;let r=5;const s=i.offset;let o=t;for(o||(o=i.atEnd()?["expression-expected"]:["unexpected-symbol",String.fromCodePoint(i.get(s)),i.trace(e)]);r>0&&!i.atEnd();){i.skipTo(i.offset+1);const t=i.parse(e);if(t.isSuccess||t.isEmpty)return n.errorAt(t.value,o,s),n.copyDiagnostics(t),n;r-=1}return n.errorAt(n.value,o,s)}]}function gn(e,t){const i=new on(e);let n=e.offset;if(n>=e.length)return i.failure();if("p"===t){if(112!==e.get(n)&&80!==e.get(n))return i.failure()}else if(101!==e.get(n)&&69!==e.get(n))return i.failure();n+=1;let r=1;if(45===e.get(n)?(n++,r=-1):43===e.get(n)&&n++,e.offset!==n&&!Gi.has(e.get(n)))return e.skipTo(n),i.error(0,"exponent-expected");let s=0;for(;Gi.has(e.get(n));)s=10*s+Gi.get(e.get(n++));return e.skipTo(n),i.success(r*s)}function dn(e,t,i){const n=new on(e);let r=gn(e,"e");return r.isSuccess?i=Number.parseFloat(i.toString()+"e"+r.value.toString()):r.isFailure&&(r=gn(e,"p"),r.isSuccess&&(i*=Math.pow(2,r.value))),r.isSuccess||r.isFailure?n.success(i):n.error(i,"exponent-expected")}function vn(e){let t=!1,i=e.offset;for(;!t&&i<e.length;){const n=e.get(i++);13!==n&&8232!==n&&8233!==n||(t=!0),10===n&&(13===e.get(i)&&(i+=1),t=!0)}e.skipTo(i)}function xn(e){const t=e.get(e.offset);13!==t&&8232!==t&&8233!==t?10===t&&(13===e.get(e.offset+1)?e.skipTo(e.offset+2):e.skipTo(e.offset+1)):e.skipTo(e.offset+1)}function bn(e){const t=new on(e);return 47===e.get(e.offset)&&47===e.get(e.offset+1)&&vn(e),t.ignore()}function yn(e){const t=new on(e);let i=e.offset;if(47!==e.get(i)||42!==e.get(i+1))return t.failure();i+=2;let n=1;for(;n>0&&i<e.length;){const t=e.get(i);47===t&&42===e.get(i+1)?(n+=1,i+=2):42===t&&47===e.get(i+1)?(n-=1,i+=2):i+=nn(t)}return n>0?(e.skipTo(e.offset+i),t.errorAt(null,"end-of-comment-expected",t.start)):t.ignoreUntil(i)}function Nn(e){const t=new on(e);return 0!==e.offset||35!==e.get(0)||33!==e.get(1)?t.failure():(vn(e),t.success(!0))}function wn(e){const t=new on(e);if(92!==e.get(e.offset))return t.failure();const i=e.offset,n=Qi.get(e.get(i+1));if(void 0!==n)return e.skipTo(i+2),t.success(String.fromCodePoint(n));let r=i+1;const s=e.get(r++);if(117!==s)return e.skipTo(r),t.errorAt(String.fromCodePoint(s),["invalid-escape-sequence","\\"+String.fromCodePoint(s)],i);let o=0,a=!1,l=!1,u="";if(123===e.get(r)){for(r+=1;!l&&r<i+11;){const t=e.get(r++);u+=String.fromCodePoint(t),a=a||!Hi.has(t),a||(o=16*o+Hi.get(t)),l=125===e.get(r)}l&&(r+=1)}else{for(;!a&&r<=e.offset+5;){const t=e.get(r++);u+=String.fromCodePoint(t),a=!Hi.has(t),a||(o=16*o+Hi.get(t))}l=r<=e.length}return e.skipTo(r),a||!l?t.errorAt("�",["invalid-unicode-codepoint-string",u],i):o>1114111?t.errorAt("�",["invalid-unicode-codepoint-value","U+"+("00000"+o.toString(16)).slice(-8).toUpperCase()],i):o>=55296&&o<=57343?t.errorAt("�",["invalid-unicode-codepoint-value","U+"+("0000"+o.toString(16)).slice(-4).toUpperCase()],i):t.success(String.fromCodePoint(o))}function Sn(e,t){const i=new on(e);if(void 0===t||92!==e.get(e.offset)||40!==e.get(e.offset+1))return i.failure();const n=e.offset+2,r=e.parse(t,n);return i.copyDiagnostics(r),41!==e.get(e.offset)?i.error(r.value,["closing-bracket-expected",")"]):(e.skipTo(e.offset+1),i.value=r.value,i)}const Mn=new class{constructor(){this.rules={},this.ruleDescription={},this.rule("quoted-text-item","U+0000-U+0009 U+000B-U+000C U+000E-U+0021 U+0023-U+2027 U+202A-U+D7FF | U+E000-U+10FFFF"),this.rule("linebreak","(U+000A \\[U+000D\\]) | U+000D | U+2028 | U+2029"),this.rule("unicode-char","_quoted-text-item_ | _linebreak_ | U+0022"),this.rule("pattern-syntax","U+0021-U+002F | U+003A-U+0040 | U+005b-U+005E | U+0060 | U+007b-U+007e | U+00A1-U+00A7 | U+00A9 | U+00AB-U+00AC | U+00AE | U+00B0-U+00B1 | U+00B6 | U+00BB | U+00BF | U+00D7 | U+00F7 | U+2010-U+203E | U+2041-U+2053 | U+2190-U+2775 | U+2794-U+27EF | U+3001-U+3003 | U+3008-U+3020 | U+3030 | U+FD3E | U+FD3F | U+FE45 | U+FE46"),this.rule("inline-space","U+0009 | U+0020"),this.rule("pattern-whitespace","_inline-space_ | U+000A | U+000B | U+000C | U+000D | U+0085 | U+200E | U+200F | U+2028 | U+2029"),this.rule("whitespace","_pattern-whitespace_ | U+0000 | U+00A0 | U+1680 | U+180E | U+2000-U+200A | U+202f | U+205f | U+3000"),this.rule("line-comment","**`//`** (_unicode-char_)* _linebreak_)"),this.rule("block-comment","**`/*`** (((_unicode-char_)\\* _linebreak_)) | _block-comment_) **`*/`**"),this.rule("digit","U+0030-U+0039 | U+FF10-U+FF19"),this.rule("hex-digit","_digit_ | U+0041-U+0046 | U+0061-U+0066 | U+FF21-FF26 | U+FF41-U+FF46"),this.rule("binary-digit","U+0030 | U+0031 | U+FF10 | U+FF11"),this.rule("numerical-constant","**`NaN`** | **`Infinity`** | **`+Infinity`** | **`-Infinity`**"),this.rule("base-10-exponent","(**`e`** | **`E`**) \\[_sign_\\](_digit_)+"),this.rule("base-2-exponent","(**`p`** | **`P`**) \\[_sign_\\](_digit_)+"),this.rule("binary-number","**`0b`** (_binary-digit_)+ \\[**`.`** (_binary-digit_)+ \\]\\[_exponent_\\]"),this.rule("hexadecimal-number","**`0x`** (_hex-digit_)+ \\[**`.`** (_hex-digit_)+ \\]\\[_exponent_\\]"),this.rule("decimal-number","(_digit_)+ \\[**`.`** (_digit_)+ \\]\\[_exponent_\\]"),this.rule("sign","**`+`** | **`-`**"),this.rule("symbol","_verbatim-symbol_ | _inline-symbol_"),this.rule("verbatim-symbol","**``` ` ```** (_escape-sequence_ | _symbol_start_) (_escape-sequence_ | _symbol_continue_)* **``` ` ```**"),this.rule("inline-symbol","_symbol-start_ (_symbol_continue_)*"),this.rule("escape-expression","**`\\(`** _expression_ **`)`**"),this.rule("single-line-string",'**`"`** (_escape-sequence_ | _escape-expression_ | _quoted-text-item_)* **`"`**'),this.rule("multiline-string",'**`"""`** _multiline-string-line_ **`"""`**'),this.rule("extended-string","..."),this.rule("shebang","**`#!`** (unicode-char)* (_linebreak | _eof_)"),this.rule("shebang",Nn)}rule(e,t){"string"==typeof t?this.ruleDescription[e]=t:"function"==typeof t?(this.ruleDescription[e]||(this.ruleDescription[e]=`_${e}_`),this.rules[e]=t):(this.ruleDescription[e]=t[0],this.rules[e]=t[1])}toString(){return Object.keys(this.ruleDescription).map((e=>`_${e}_ → ${this.ruleDescription[e]}`)).join("\n\n")}parse(e,t,i){if("string"==typeof t&&(t=new sn(this,t,null!=i?i:"")),!this.has(e))throw new Error("Unexpected rule "+e);return this.rules[e](t)}has(e){return"function"==typeof this.rules[e]}get(e){return this.rules[e]}};function En(e){if(null==e)return"";const t=fe(e);if(null!==t)return t;const i=ae(e);return null!==i?Number(i).toString():e.toString()}const An={0:"\\u0000",1:"\\u0001",2:"\\u0002",3:"\\u0003",4:"\\u0004",5:"\\u0005",6:"\\u0006",7:"\\u0007",8:"\\b",9:"\\t",10:"\\n",11:"\\u000b",12:"\\f",13:"\\r",14:"\\u000e",15:"\\u000f",16:"\\u0010",17:"\\u0011",18:"\\u0012",19:"\\u0013",20:"\\u0014",21:"\\u0015",22:"\\u0016",23:"\\u0017",24:"\\u0018",25:"\\u0019",26:"\\u001a",27:"\\u001b",28:"\\u001c",29:"\\u001d",30:"\\u001e",31:"\\u001f",34:'\\"',47:"\\/",92:"\\\\"};function Dn(e){var t;let i="";for(const n of e)i+=null!==(t=An[n.codePointAt(0)])&&void 0!==t?t:n;return i}function Cn(e,t){return Array.isArray(t)||(t=t.range),Array.isArray(e)?{fn:e,sourceOffsets:t}:"object"==typeof e?{...e,sourceOffsets:t}:"number"==typeof e?{num:e.toString(),sourceOffsets:t}:"string"==typeof e&&"'"===e[0]&&"'"===e[e.length-1]?{str:e.slice(1,-1),sourceOffsets:t}:{sym:e,sourceOffsets:t}}var _n,kn;Mn.rule("whitespace",(e=>function(e){let t=!1;const i=new on(e);let n=e.offset;for(;!t&&n<e.length;){const r=e.offset;for(;!t;){const i=e.get(n);t=!Ji(i),t||(n+=nn(i))}if(i.copyDiagnostics(bn(e.skipTo(n))),i.copyDiagnostics(yn(e)),i.isError)return i;t=r===e.offset,n=e.offset}return e.skipTo(n),i.ignore()}(e))),Mn.rule("pragma",mn(["pragma-symbol","pragma-function"])),Mn.rule("pragma-symbol",mn([fn("#line"),fn("#column"),fn("#filename"),fn("#url"),fn("#date"),fn("#time")],(e=>{var t;if("#date"===e.value){const e=new Date;return e.getFullYear()+"-"+("00"+(1+e.getMonth())).slice(-2)+"-"+("00"+(1+e.getDay())).slice(-2)}if("#time"===e.value){const e=new Date;return("00"+e.getHours().toString()).slice(-2)+":"+("00"+e.getMinutes().toString()).slice(-2)+":"+("00"+e.getSeconds().toString()).slice(-2)}return"#url"===e.value?null!==(t=e.parser.url)&&void 0!==t?t:"Nothing":"#filename"===e.value?e.parser.url?e.parser.url.substring(e.parser.url.lastIndexOf("/")+1):"Nothing":"#line"===e.value?new Li(e.parser.source,e.parser.url).getLinecol(e.parser.offset)[0]:"#column"===e.value?new Li(e.parser.source,e.parser.url).getLinecol(e.parser.offset)[1]:"Nothing"}))),Mn.rule("pragma-function",hn([mn([fn("#warning"),fn("#error"),fn("#env"),fn("#navigator")]),"function-call-argument-clause"],((e,t)=>{var i;if("#warning"===e.value)return{str:Ne(t.value,(e=>En(e))).join(" ")};if("#error"===e.value){const e=Ne(t.value,(e=>En(e))).join(" ");throw new rn(e)}if("#env"===e.value){if("process"in globalThis&&process.env)return{str:null!==(i=process.env[En(we(t.value,1))])&&void 0!==i?i:""}}else if("#navigator"===e.value&&"navigator"in globalThis)return{str:navigator[En(we(t.value,1))]};return"Nothing"}))),Mn.rule("function-call-argument-clause",(_n=e=>["List",...e.map((e=>e.value))],[`**\`(\`** (${ln("expression")}+#**\`,\`** **\`)\`**`,e=>{const t=new on(e);if(!e.parse(fn("(")).isSuccess)return t.failure();const i=[];let n=!1;for(;!n&&!e.atEnd();){const r=e.parse("expression");t.copyDiagnostics(r),n=!r.isSuccess,n||(i.push(r),n=!e.parse(fn(",")).isSuccess)}return 0===i.length?t.error(_n([]),"expression-expected"):e.parse(fn(")")).isSuccess?t.success(_n(i)):t.error(_n(i),["closing-bracket-expected",")"])}])),Mn.rule("signed-number","_numerical-constant_ | (\\[_sign_\\] (_binary-number_ | _hexadecimal-number_ | _decimal-number_)"),Mn.rule("signed-number",(e=>{const t=new on(e);let i=cn(e,"NaN");if(i.isFailure&&(i=cn(e,"+Infinity")),i.isFailure&&(i=cn(e,"-Infinity")),i.isSuccess)return t.success(Cn({num:i.value},i));if(i=cn(e,"Infinity"),i.isSuccess)return t.success(Cn({num:"+Infinity"},i));const n=function(e){const t=new on(e);let i=e.offset,n=1;45===e.get(i)?(i++,n=-1):43===e.get(i)&&i++,e.skipTo(i);const r=function(e){let t=function(e){const t=new on(e);let i=e.offset;if(48!==e.get(i++)||98!==e.get(i++))return t.failure();let n=0,r=!1;for(;!r&&i<e.length;){const t=Hi.get(e.get(i++));0===t?n<<=1:1===t?n=1+(n<<1):95===e.get(i-1)||(r=!0,i-=1)}if(46===e.get(i)){i+=1;let t=.5,s=0;for(r=!1;!r&&i<e.length;){const n=Hi.get(e.get(i++));0===n?t/=2:1===n?(s+=t,t/=2):95===e.get(i-1)||(r=!0,i-=1)}n+=s}return e.skipTo(i),dn(e,0,n)}(e);return t.isFailure&&(t=function(e){const t=new on(e);let i=e.offset;if(48!==e.get(i++)||120!==e.get(i++))return t.failure();let n=0,r=!1;for(;!r&&i<e.length;){const t=e.get(i++);Hi.has(t)?n=16*n+Hi.get(t):95!==t&&(r=!0,i-=1)}if(46===e.get(i++)){let s=.0625;r=!1;let o=0;for(;!r&&i<e.length;){const a=e.get(i++);if(Hi.has(a))o+=s*Hi.get(a),s/=16;else{if(95===a)return e.skipTo(i),t.error(n+o,"hexadecimal-number-expected");r=!0,i-=1}}n+=o}return e.skipTo(i),dn(e,0,n)}(e)),t.isFailure&&(t=function(e){const t=new on(e),i=e.offset;if(!Gi.has(e.get(i)))return t.failure();let n=i,r=0,s=!1;for(;!s&&n<e.length;){const t=e.get(n++);Gi.has(t)?r=10*r+Gi.get(t):95!==t&&(s=!0,n-=1)}if(46===e.get(n)){n+=1;let i=.1;s=!1;let o=0;for(;!s&&n<e.length;){const a=e.get(n++);if(Gi.has(a))o+=i*Gi.get(a),i/=10;else{if(95===a)return e.skipTo(n),t.error(r+o,"decimal-number-expected");s=!0,n-=1}}r+=o}return e.skipTo(n),dn(e,0,r)}(e)),t}(e);return r.isSuccess?t.success(n*r.value):r.isError?t.errorFrom(r,n*r.value):t.failure()}(e);return n.isSuccess?t.success(Cn(n.value,n)):n})),Mn.rule("symbol","_verbatim-symbol_ | _inline-symbol_"),Mn.rule("symbol",(e=>{const t=new on(e),i=function(e){const t=function(e){const t=new on(e);if(96!==e.get(e.offset))return t.failure();let i=!1,n=!1,r=e.offset+1,s="",o=!1;for(;!i&&!o&&r<e.length;){const t=e.get(r);if(o=Vi(t),i=96===t,!i)if(92===t){e.skipTo(r);const t=wn(e);t.isSuccess&&(s+=t.value),r=e.offset}else{n=n||Xi(t);const e=String.fromCodePoint(t);s+=e,r+=e.length}}return i?(e.skipTo(r+1),0===s.length?t.errorAt("Missing","empty-verbatim-symbol",t.start):n||en(s.charCodeAt(0))?t.errorAt("Missing",["invalid-symbol-name",s],t.start):t.success(s)):(e.skipTo(r),t.errorAt("Missing",["unbalanced-verbatim-symbol",s],t.start))}(e);if(!t.isFailure)return t;const i=e.offset;let n=e.get(i);if(en(n)||Ki(n))return t.failure();let r=!1,s=i,o="";for(;!r&&s<e.length;)if(n=e.get(s),r=Ki(n)||Xi(n),!r){const e=String.fromCodePoint(n);o+=e,s+=e.length}return 0===o.length?t.failure():(e.skipTo(s),t.success(o))}(e);return t.copyDiagnostics(i),t.end=i.end,(i.isSuccess||i.isError)&&t.success(Cn(i.value,i)),t})),Mn.rule("string","_single-line-string_ | _multiline-string_ | _extended-string_"),Mn.rule("string",(e=>{let t=function(e,t){const i=new on(e),n=e.offset;if(34!==e.get(n))return i.failure();if(34===e.get(n+1)&&34!==e.get(n+2))return e.skipTo(e.offset+2),i.success([""]);if(34===e.get(n+1)&&34===e.get(n+2))return i.failure();let r=!1,s=!1;e.skipTo(n+1);const o=[];let a="";for(;!r&&!s&&!e.atEnd();){const t=e.get(e.offset);if(s=34===t,r=Vi(t),92===t){const t=Sn(e,"expression");if(t.isFailure){const t=wn(e);i.copyDiagnostics(t),t.isSuccess?a+=t.value:t.isError&&(a+="\\"+t.value)}else o.push(a),a="",i.copyDiagnostics(t),o.push(t.value)}else r||s||(a+=String.fromCodePoint(t)),e.skipTo(e.offset+1)}return a&&(o.push(a),a=""),s?(i.success(o),i):0===o.length&&(e.atEnd()||e.atLinebreak())?i.error([""],["string-literal-opening-delimiter-expected",'"']):i.error(o,["string-literal-closing-delimiter-expected",'"'])}(e);if(t.isFailure&&(t=function(e,t){const i=new on(e),n=e.offset;if(34!==e.get(n)||34!==e.get(n+1)||34!==e.get(n+2))return i.failure();if(function(e){let t,i=e.offset;do{t=e.get(i++)}while(32===t||9===t);e.skipTo(i-1)}(e.skipTo(n+3)),!e.atLinebreak())return i.error([""],"multiline-string-expected");xn(e);let r=!1,s=e.offset;const o=[];let a=[],l="";for(;!r&&s<e.length;){const t=e.get(s);if(Vi(t))l&&a.push(l),l="",o.push(a),a=[],xn(e.skipTo(s)),s=e.offset;else if(r=34===t&&34===e.get(s+1)&&34===e.get(s+2),92===t)if(Vi(e.get(s+1)))l+="\\\n",s+=2;else{e.skipTo(s);const n=Sn(e,"expression");if(n.isFailure){const n=wn(e);s=e.offset,n.isSuccess?l+=n.value:n.isError&&(l+=String.fromCodePoint(t),i.copyDiagnostics(n))}else s=e.offset,a.push(l),l="",i.copyDiagnostics(n),a.push(n.value)}else r||(l+=String.fromCodePoint(t)),s+=1}e.skipTo(s+2);const u=l;let c=!0;if(u.length>0){for(const e of u)Yi(e.codePointAt(0))||(c=!1);if(c)for(const e of o)"string"==typeof e[0]&&e[0].startsWith(u)&&(e[0]=e[0].slice(u.length))}let f=[];for(let e=0;e<=o.length-1;e++){const t=o[e],i=t[t.length-1];"string"==typeof i&&"\\"===i[i.length-1]?(t[t.length-1]=i.slice(-1),f=[...f,...t]):f=e===o.length-1?[...f,...t]:[...f,...t,"\n"]}return c?(i.value=f,i):i.error(f,"multiline-whitespace-expected")}(e)),t.isFailure&&(t=function(e){const t=e.offset,i=new on(e);if(35!==e.get(t))return i.failure();let n=0,r=t;for(;35===e.get(r++);)n+=1;if(r-=1,34!==e.get(r++))return i.failure();let s="",o=!1,a=!1;do{const t=e.get(r++);if(o=r>=e.length||Vi(t),34===t){let t=n;for(;t>0&&35===e.get(r+t-1);)t-=1;a=0===t,a&&(r+=n)}o||a||(s+=String.fromCodePoint(t))}while(!o&&!a);return e.skipTo(r),a?i.success(s):i.error(s,["string-literal-closing-delimiter-expected","#".repeat(n)+'"'])}(e),t.isSuccess))return t.success(Cn({str:t.value},t));if(t.isFailure||t.isEmpty)return t;const i=[];let n,r;for(const e of t.value)"string"==typeof e?n=(null!=n?n:"")+e:re(e)?n=(null!=n?n:"")+e.str:("string"==typeof n&&(i.push(n),n=void 0),i.push(e));return"string"==typeof n&&i.push(n),r=1===i.length&&"string"==typeof i[0]?Cn({str:Dn(i[0])},t):Cn(["String",...i.map((e=>"string"==typeof e?{str:e}:e))],t),t.value=r,t})),Mn.rule("primary",mn(["pragma","signed-number","symbol","string","parenthesized-expression"])),Mn.rule("expression",function(e,t,i){const n=ln("primary");return[[["NotElement","!in",160],["Element","in",240],["LessEqual","<=",241],["GreaterEqual",">=",242],["Less","<",245],["Greater",">",245],["NotEqual","!=",255],["Assign","=",258],["Equal","==",260],["Same","===",260],["KeyValue","->",265],["Add","+",275],["Subtract","-",275],["Multiply","*",390],["Divide","/",660],["Negate","-",665,"prefix"],["Power","^",720,"left"],["Pipe","|>",790],["BackPipe","~>",790],["Or","||",800],["And","&&",810],["Not","!",820,"prefix"]].map((e=>{var t;const[i,r,s]=e,o=null!==(t=e[3])&&void 0!==t?t:"right";return"prefix"===o?`**\`${r}\`**<sub>${s}</sub> ${n}`:"suffix"===o?`${n} **\`${r}\`**<sub>${s}</sub>`:"left"===o?`_···_ **\`${r}\`**<sub>${s}L</sub> ${n}`:`${n} **\`${r}\`**<sub>${s}R</sub> _···_`})).join(" | "),e=>function(e,t,i,n){return e.parse("primary")}(e)]}()),Mn.rule("parenthesized-expression",(kn=")",[`**\`(\`** (${ln("expression")})* **\`)\`**`,e=>{const t=new on(e);if(!e.atString("("))return t.failure();const i=e.offset;e.skipTo(i+"(".length);const n=e.parse("expression");return n.isError?(t.copyDiagnostics(n),t.range=[t.start,an(e,kn)],t):e.atString(kn)?(e.skipTo(e.offset+kn.length),t.value=n.value,t):t.error(n.value,["closing-bracket-expected",kn])}])),Mn.rule("cortex",pn(hn([function(e){return[`\\[${ln(e)}\\]`,t=>{const i=t.offset,n=t.parse(e);return n.isSuccess||n.isEmpty?n:n.isFailure?(t.skipTo(i),t.ignore()):n}]}("shebang"),function(e,t){return[`(${ln(e)})*`,i=>{const n=[i.parseWhitespace()];let r=i.parse(e);const s=[r];for(;!i.atEnd()&&(r.isSuccess||r.isEmpty);)n.push(i.parseWhitespace()),r=i.parse(e),s.push(r);return un(i,t,s,n)}]}("expression",((...e)=>{var t;const i=e.filter((e=>!e.isEmpty&&!e.isFailure));return 0===i.length?Cn("Nothing",e[0]):1===i.length?Cn(null!==(t=i[0].value)&&void 0!==t?t:"Nothing",i[0]):Cn(["Do",...i.map((e=>e.value))],[i[0].start,i[i.length-1].end])})),pn(["_eof_",e=>{const t=new on(e);return e.atEnd()?t.success(!0):t.failure()}])],((e,t,i)=>{var n;return Cn(null!==(n=t.value)&&void 0!==n?n:"Nothing",t)}))));class Fn{constructor(e){this.fmt=e}}class qn extends Fn{constructor(e){super(e)}debug(){return"EmptyBlock"}serialize(e){return""}nextCol(e){return e}cost(e){return 0}}class In extends Fn{constructor(e,t){super(e),this.s=t}debug(){return" "===this.s?'" "':'"'+this.s+'"'}serialize(e){return this.s}nextCol(e){return e+this.s.length}cost(e){const t=this.nextCol(e);return t>=this.fmt.margin?(t-this.fmt.margin)*this.fmt.cost.margin+(this.fmt.margin-this.fmt.softMargin)*this.fmt.cost.softMargin:t>=this.fmt.softMargin?(t-this.fmt.softMargin)*this.fmt.cost.softMargin:0}}class Pn extends Fn{constructor(e,...t){super(e),this.blocks=t}debug(){return"Line("+this.blocks.map((e=>e.debug())).join(", ")+")"}serialize(e){const t=[];for(const i of this.blocks)t.push(i.serialize(e)),e=i.nextCol(e);return t.join("")}nextCol(e){return this.blocks.reduce(((e,t)=>t.nextCol(e)),e)}cost(e){let t=0;for(const i of this.blocks)t+=i.cost(e),e=i.nextCol(e);return t}}class Tn extends Fn{constructor(e,...t){super(e),this.blocks=t}debug(){return"Stack("+this.blocks.map((e=>e.debug())).join(", ")+")"}serialize(e){let t="",i="";for(const n of this.blocks)t+=i+n.serialize(e),i||(i=this.fmt.linebreak()+this.fmt.indentChars(e));return t}nextCol(e){return e}cost(e){return this.blocks.reduce(((t,i)=>this.fmt.cost.linebreak+t+i.cost(e)),0)}}class On extends Fn{constructor(e,...t){super(e),this.blocks=t}debug(){return"Wrap("+this.blocks.map((e=>e.debug())).join(", ")+")"}solution(e){const t=[];let i=[];for(const n of this.blocks)0===i.length||new Pn(this.fmt,...i,n).nextCol(e)<=this.fmt.margin?i.push(n):(t.push(i),i=[n]);return 0!==i.length&&t.push(i),new Tn(this.fmt,...t.map((e=>new Pn(this.fmt,...e))))}serialize(e){return this.solution(e).serialize(e)}nextCol(e){return this.solution(e).nextCol(e)}cost(e){return this.solution(e).cost(e)}}class Ln extends Fn{constructor(e,...t){super(e),this.blocks=t}debug(){return"Choice(\n "+this.blocks.map((e=>e.debug())).join("\n ")+"\n)"}choice(e){let t,i=1/0;return this.blocks.forEach((n=>{const r=n.cost(e);r<i&&(i=r,t=n)})),t}serialize(e){return this.choice(e).serialize(e)}nextCol(e){return this.choice(e).nextCol(e)}cost(e){return Math.min(...this.blocks.map((t=>t.cost(e))))}}class zn{constructor(e){var t;"space"===(null==e?void 0:e.indentChar)?e.indentChar=" ":"tab"===(null==e?void 0:e.indentChar)&&(e.indentChar="\t"),this.options={cost:{softMargin:.05,margin:100,linebreak:2,commentLinebreak:.5,flowLinebreak:.3,callLinebreak:.5,argLinebreak:5,...null!==(t=null==e?void 0:e.cost)&&void 0!==t?t:{}},indentChar:" ",indentCharWidth:1,indentWidth:2,margin:80,softMargin:50,aroundInfixOperator:" ",aroundRelationalOperator:" ",afterSeparator:" ",...null!=e?e:{}}}get cost(){return this.options.cost}get margin(){return this.options.margin}get softMargin(){return this.options.softMargin}indentChars(e=1){return("tab"===this.options.indentChar?"\t":" ").repeat(e*this.options.indentWidth)}indentLength(e=1){return e*this.options.indentWidth*this.options.indentCharWidth}linebreak(e,t){return e||t?t?e+"\n"+t:e+"\n":"\n"}countLinebreaks(e){return e.split(/\r\n|\r|\n/).length}normalizedBlocks(e){return e.map((e=>"string"==typeof e?new In(this,e):e)).filter((e=>!(e instanceof qn)))}infixOperator(e){return new In(this,this.options.aroundInfixOperator+e+this.options.aroundInfixOperator)}relationalOperator(e){return new In(this,this.options.aroundRelationalOperator+e+this.options.aroundRelationalOperator)}separator(e){return new In(this,e+this.options.afterSeparator)}fence(e){return new In(this,e)}text(e){return e&&0!==e.length?new In(this,e):new qn(this)}line(...e){const t=this.normalizedBlocks(e),i=[];let n="";for(const e of t)e instanceof In?n?(i.pop(),n+=e.s,i.push(new In(this,n))):(i.push(e),n=e.s):(n="",i.push(e));return 1===i.length?i[0]:new Pn(this,...i)}stack(...e){const t=this.normalizedBlocks(e);return 1===t.length?t[0]:new Tn(this,...t)}wrap(...e){const t=this.normalizedBlocks(e);return 1===t.length?t[0]:new On(this,...t)}indent(e,t=1){return new Pn(this,new In(this,this.indentChars(t)),e)}choice(...e){const t=this.normalizedBlocks(e);return 1===t.length?t[0]:new Ln(this,...t)}fencedBlock(e,t,i){return t?this.fencedList(e,"",i,[t]):this.line(this.fence(e),this.fence(i))}fencedList(e,t,i,n){const r=this.fence(e),s=this.fence(i);if(0===n.length)return this.line(r,s);if(1===n.length)return this.line(r,n[0],s);const o=n.map((e=>this.line(e,t))),a=[...o];return a.pop(),a.push(n[n.length-1]),e||i?this.choice(this.line(r,...a,s),this.stack(r,this.indent(this.stack(...o)),s)):this.choice(this.line(...a),this.wrap(...o))}list(e,t){return this.fencedList("",e,"",t)}}const Un=new Set(["abstract","at","and","as","assert","await","begin","break","case","catch","class","const","continue","debugger","default","delete","dynamic","do","each","else","end","export","extern","finally","for","from","function","get","global","goto","if","in","inline","interface","internal","import","label","lazy","local","loop","match","module","namespace","native","new","not","of","on","optional","or","package","private","protected","protocol","public","repeat","return","self","set","static","super","switch","this","throw","to","try","until","using","var","warn","when","where","while","with","xor","yield"]),Rn={precision:15,decimalMarker:".",groupSeparator:"_",exponentProduct:"",beginExponentMarker:"e",endExponentMarker:"",notation:"auto",imaginaryNumber:"i",truncationMarker:"",beginRepeatingDigits:"",endRepeatingDigits:"",positiveInfinity:"+Infinity",negativeInfinity:"-Infinity",notANumber:"NaN"};function $n(e){return Zi.has(e)?Zi.get(e):tn(e)?e<65536?`\\u${("0000"+e.toString(16)).slice(-4)}`:`\\u{${("000000000"+e.toString(16)).slice(-8)}}`:String.fromCodePoint(e)}function jn(e){let t="";const i=s(e);if("string"==typeof i)for(const e of i)t+=$n(e.codePointAt(0));else for(const e of i)1===e.length?t+=$n(e.codePointAt(0)):t+=e;return t}function Bn(e){if(Un.has(e))return`\`${e}\``;if(/^[a-zA-Z][a-zA-Z\d_]*$/.test(e))return e;const t=e.codePointAt(0);if(Gi.has(t))return`\`${jn(e)}\``;let i=!1;const n=s(e);let r=0;for(;!i&&r<n.length;){const e=n[r].codePointAt(0);i=Zi.has(e)||tn(e)||Ki(e),r+=1}return i?`\`${jn(e)}\``:e}e.ComputeEngine=qi,e.ExpressionMap=vt,e.LatexSyntax=lt,e.count=function(e,t,i){let n=0;for(const r of e)null!==pt(r,t,i)&&(n+=1);return n},e.evaluate=function(e){return null===Ii&&(Ii=new qi),Ii.evaluate(e)},e.format=function(e,t){return null===Ii&&(Ii=new qi),Ii.format(e,t)},e.match=pt,e.parse=function(e,t){return new lt(t).parse(e)},e.parseCortex=function(e,t){const i=Mn.parse("cortex",e,t);if(i.isSuccess)return[i.value,[]];const n=new Li(e);return i.isError?[i.value,(r=i.diagnostics,[...r]).map((e=>{var t;return{...e,origin:n.signalOrigin(null!==(t=e.range[2])&&void 0!==t?t:e.range[1])}}))]:(i.isEmpty||i.isFailure,["Nothing",[]]);var r},e.serialize=function(e,t){return new lt(t).serialize(e)},e.serializeCortex=function(e,t){const i=new zn({...(null==t?void 0:t.fancySymbols)?{aroundInfixOperator:" ",aroundRelationalOperator:" ",afterSeparator:" "}:{},...t});function n(e){var a,l;if(null===e)return new qn(this);const u=fe(e);if(null!==u)return c=u,i.text(`"${jn(c)}"`);var c;const f=function(e){return"object"!=typeof e?i.text():"comment"in e&&e.comment&&e.comment.length>0?i.text(`/* ${e.comment} */`):i.text()}(e);let h;if(null!==ge(e)&&(h=null!==(l=null!==(a=function(e){var t,i;return null!==(i=null===(t=s[ve(e)])||void 0===t?void 0:t.call(s,e))&&void 0!==i?i:null}(e))&&void 0!==a?a:function(e){var s;const o=ve(e);if(!o)return null;const a=r[o];if(!a)return null;const l=(null==t?void 0:t.fancySymbols)&&null!==(s=a.fancySymbol)&&void 0!==s?s:a.symbol;if(a.unary){if(1!==Se(e))return null;const t=we(e,1),s=ve(t),o=r[s];return o&&o.precedence<a.precedence?i.line(l,"(",n(t),")"):i.line(l,n(t))}const u=Ne(e,(e=>{const t=ve(e),s=r[t];return s&&s.precedence<a.precedence?i.line("(",n(e),")"):n(e)}));return u?i.list(a.relational?i.relationalOperator(l):i.infixOperator(l),u):null}(e))&&void 0!==l?l:o(e)),!h){const t=xe(e);null!==t&&(h=i.text(Bn(t)))}if(h||("number"==typeof e||ie(e))&&(h=i.text(ot(e,Rn))),!h){const t=Me(e);if(null!==t){const e=Object.keys(t).map((e=>i.line(jn(e),i.relationalOperator("->"),n(t[e]))));if(0===e.length)return i.line(i.fence("{"),i.relationalOperator("->"),i.fence("}"));h=i.fencedList("{",i.separator(","),"}",e)}}return h?f instanceof qn?h:i.choice(i.line(f,h),i.stack(f,h)):i.text()}const r={NotElementOf:{symbol:"!in",fancySymbol:"∉",relational:!0,precedence:160},ElementOf:{symbol:"in",fancySymbol:"∈",relational:!0,precedence:240},LessEqual:{symbol:"<=",relational:!0,fancySymbol:"⩽",precedence:241},GreaterEqual:{symbol:">=",fancySymbol:"⩾",relational:!0,precedence:242},Less:{symbol:"<",relational:!0,precedence:245},Greater:{symbol:">",relational:!0,precedence:245},NotEqual:{symbol:"!=",fancySymbol:"≠",relational:!0,precedence:255},Assign:{symbol:"=",relational:!0,precedence:258},Equal:{symbol:"==",relational:!0,precedence:260},Same:{symbol:"===",fancySymbol:"≣",relational:!0,precedence:260},KeyValue:{symbol:"->",fancySymbol:"→",precedence:265},Add:{symbol:"+",precedence:275},Subtract:{symbol:"-",fancySymbol:"−",precedence:275},Multiply:{symbol:"*",fancySymbol:"×",precedence:390},Divide:{symbol:"/",fancySymbol:"÷",precedence:660},Negate:{symbol:"-",unary:!0,fancySymbol:"−",precedence:665},Power:{symbol:"^",precedence:720},Or:{symbol:"||",fancySymbol:"⋁",precedence:800},And:{symbol:"&&",fancySymbol:"⋀",precedence:810},Not:{symbol:"!",unary:!0,fancySymbol:"¬",precedence:820}},s={BaseForm:e=>{var t;const n=null!==(t=ae(we(e,2)))&&void 0!==t?t:16,r=we(e,1),s=ae(r);return null===s||Number.isNaN(s)||!Number.isFinite(s)||2!==n&&10!==n&&16!==n?o(e):2===n?i.text("0b"+Number(s).toString(2)):10===n?i.text(ot(r,Rn)):16===n?Number.isFinite(s)?Number.isInteger(s)?i.text("0x"+Number(s).toString(16)):i.text(function(e){const t="0123456789abcdef",i=e<0?"-":"";e=Math.abs(e);let n="",r=0,s=Math.trunc(e),o=e-s;if(0!==s)for(;s%2==0&&s>0;)s/=2,o/=2,r+=1;else{let e=o;for(;2*e<2;)e*=2,r-=1;s=Math.trunc(e),o=e-s}for(;0!==s;)n=t[s%16]+n,s=Math.trunc(s/16);if(n?n+=".":n="0.",0===o)n+="0";else for(;o>0;){const e=Math.trunc(16*o);n+=t[e],o=16*o-e}return i+"0x"+n+"p"+(r<0?"-":"")+Number(Math.abs(r)).toString()}(s)):i.text(ot(r,Rn)):o(e)},String:e=>i.wrap('"',...Ne(e,(e=>{const t=fe(e);return null!==t?i.text(jn(t)):i.fencedBlock("\\(",n(e),")")})),'"'),List:e=>i.fencedList("{",i.separator(","),"}",Ne(e,n)),Set:e=>0===Se(e)?i.text("EmptySet"):i.fencedList("[",i.separator(","),"]",Ne(e,n))};function o(e){const t=ge(e);return"string"==typeof t?i.line(Bn(t),i.fencedList("(",i.separator(","),")",Ne(e,n))):i.line("Apply(",n(t),i.separator(","),i.fencedList("[",i.separator(","),"]",Ne(e,n)),")")}return n(e).serialize(0)},e.substitute=gt,e.version="0.4.2",Object.defineProperty(e,"__esModule",{value:!0})}));