@cortex-js/compute-engine 0.63.0 → 0.64.0

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 (292) hide show
  1. package/dist/compile.esm.js +8 -3
  2. package/dist/compile.min.esm.js +7 -7
  3. package/dist/compile.min.umd.cjs +7 -7
  4. package/dist/compile.umd.cjs +8 -3
  5. package/dist/compute-engine.esm.js +1097 -106
  6. package/dist/compute-engine.min.esm.js +80 -80
  7. package/dist/compute-engine.min.umd.cjs +80 -80
  8. package/dist/compute-engine.umd.cjs +1097 -106
  9. package/dist/core.esm.js +1096 -105
  10. package/dist/core.min.esm.js +78 -78
  11. package/dist/core.min.umd.cjs +78 -78
  12. package/dist/core.umd.cjs +1096 -105
  13. package/dist/identities.esm.js +2 -7
  14. package/dist/identities.min.esm.js +2 -2
  15. package/dist/identities.min.umd.cjs +2 -2
  16. package/dist/identities.umd.cjs +2 -7
  17. package/dist/integration-rules.esm.js +3 -2
  18. package/dist/integration-rules.min.esm.js +4 -4
  19. package/dist/integration-rules.min.umd.cjs +4 -4
  20. package/dist/integration-rules.umd.cjs +3 -2
  21. package/dist/interval.esm.js +3 -2
  22. package/dist/interval.min.esm.js +4 -4
  23. package/dist/interval.min.umd.cjs +4 -4
  24. package/dist/interval.umd.cjs +3 -2
  25. package/dist/latex-syntax.esm.js +3 -2
  26. package/dist/latex-syntax.min.esm.js +6 -6
  27. package/dist/latex-syntax.min.umd.cjs +6 -6
  28. package/dist/latex-syntax.umd.cjs +3 -2
  29. package/dist/math-json.esm.js +2 -2
  30. package/dist/math-json.min.esm.js +2 -2
  31. package/dist/math-json.min.umd.cjs +2 -2
  32. package/dist/math-json.umd.cjs +2 -2
  33. package/dist/numerics.esm.js +53 -91
  34. package/dist/numerics.min.esm.js +4 -4
  35. package/dist/numerics.min.umd.cjs +4 -4
  36. package/dist/numerics.umd.cjs +53 -91
  37. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  38. package/dist/types/big-decimal/index.d.ts +1 -1
  39. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  40. package/dist/types/big-decimal/utils.d.ts +1 -1
  41. package/dist/types/common/ansi-codes.d.ts +1 -1
  42. package/dist/types/common/configuration-change.d.ts +1 -1
  43. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  44. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  45. package/dist/types/common/interruptible.d.ts +1 -1
  46. package/dist/types/common/one-of.d.ts +1 -1
  47. package/dist/types/common/signals.d.ts +1 -1
  48. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  49. package/dist/types/common/type/boxed-type.d.ts +1 -1
  50. package/dist/types/common/type/lexer.d.ts +1 -1
  51. package/dist/types/common/type/parse.d.ts +1 -1
  52. package/dist/types/common/type/parser.d.ts +1 -1
  53. package/dist/types/common/type/primitive.d.ts +1 -1
  54. package/dist/types/common/type/reduce.d.ts +1 -1
  55. package/dist/types/common/type/serialize.d.ts +1 -1
  56. package/dist/types/common/type/subtype.d.ts +1 -1
  57. package/dist/types/common/type/type-builder.d.ts +1 -1
  58. package/dist/types/common/type/types.d.ts +1 -1
  59. package/dist/types/common/type/utils.d.ts +1 -1
  60. package/dist/types/common/utils.d.ts +1 -1
  61. package/dist/types/compile.d.ts +1 -1
  62. package/dist/types/compute-engine/assume.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/exp-to-trig.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/multivariate-gcd.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/multivariate-poly.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +11 -5
  99. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  103. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  104. package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +1 -1
  105. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  106. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  107. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  108. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  109. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  110. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  111. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  112. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  113. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  114. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  115. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  116. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  117. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  118. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  119. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  120. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  121. package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
  122. package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
  123. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  124. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  125. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  126. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  127. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  128. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  131. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  132. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  133. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  134. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  135. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  136. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  137. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  138. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  139. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  140. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  141. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  142. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  143. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  144. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  145. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  146. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  147. package/dist/types/compute-engine/function-properties/index.d.ts +1 -1
  148. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  149. package/dist/types/compute-engine/fungrim/loader.d.ts +1 -1
  150. package/dist/types/compute-engine/fungrim/types.d.ts +1 -1
  151. package/dist/types/compute-engine/global-types.d.ts +1 -1
  152. package/dist/types/compute-engine/index.d.ts +1 -1
  153. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  154. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  155. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  156. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  157. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  158. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  159. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  163. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  170. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  171. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  172. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  173. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  174. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  175. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  176. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  177. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  178. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  179. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  180. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  181. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  182. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  183. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  184. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  185. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  186. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  187. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  188. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  189. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  190. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  191. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  192. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  193. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  194. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  195. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  196. package/dist/types/compute-engine/library/core.d.ts +1 -1
  197. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  198. package/dist/types/compute-engine/library/library.d.ts +1 -1
  199. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  200. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  201. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  202. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  203. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  204. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  205. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  206. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  207. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  208. package/dist/types/compute-engine/library/special-functions.d.ts +1 -1
  209. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  210. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  211. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  212. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  213. package/dist/types/compute-engine/library/units.d.ts +1 -1
  214. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  215. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  216. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  217. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  218. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  219. package/dist/types/compute-engine/numerics/bernoulli.d.ts +1 -1
  220. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  221. package/dist/types/compute-engine/numerics/complex-esm-augment.d.ts +1 -1
  222. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  223. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  224. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  225. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  226. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  227. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  228. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  229. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  230. package/dist/types/compute-engine/numerics/oscillatory-quadrature.d.ts +1 -1
  231. package/dist/types/compute-engine/numerics/polynomial-roots.d.ts +1 -1
  232. package/dist/types/compute-engine/numerics/primes.d.ts +5 -3
  233. package/dist/types/compute-engine/numerics/random.d.ts +1 -1
  234. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  235. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  236. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  237. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  238. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  239. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  240. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  241. package/dist/types/compute-engine/oeis.d.ts +1 -1
  242. package/dist/types/compute-engine/rubi/compile.d.ts +1 -1
  243. package/dist/types/compute-engine/rubi/driver.d.ts +1 -1
  244. package/dist/types/compute-engine/rubi/loader.d.ts +1 -1
  245. package/dist/types/compute-engine/rubi/match.d.ts +1 -1
  246. package/dist/types/compute-engine/rubi/normal-form.d.ts +1 -1
  247. package/dist/types/compute-engine/rubi/rubi-utils.d.ts +1 -1
  248. package/dist/types/compute-engine/rubi/types.d.ts +1 -1
  249. package/dist/types/compute-engine/sequence.d.ts +1 -1
  250. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  251. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  252. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  253. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  254. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  255. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  256. package/dist/types/compute-engine/symbolic/limit.d.ts +1 -1
  257. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  258. package/dist/types/compute-engine/symbolic/residue.d.ts +1 -1
  259. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  260. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  261. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  262. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  263. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  264. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  265. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  266. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  267. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  268. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  269. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  270. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  271. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  272. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  273. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  274. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  275. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  276. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  277. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  278. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  279. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  280. package/dist/types/compute-engine/types.d.ts +1 -1
  281. package/dist/types/compute-engine.d.ts +1 -1
  282. package/dist/types/core.d.ts +1 -1
  283. package/dist/types/identities.d.ts +1 -1
  284. package/dist/types/integration-rules.d.ts +1 -1
  285. package/dist/types/interval.d.ts +1 -1
  286. package/dist/types/latex-syntax.d.ts +2 -2
  287. package/dist/types/math-json/symbols.d.ts +1 -1
  288. package/dist/types/math-json/types.d.ts +1 -1
  289. package/dist/types/math-json/utils.d.ts +1 -1
  290. package/dist/types/math-json.d.ts +2 -2
  291. package/dist/types/numerics.d.ts +1 -1
  292. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
- /** Numerics 0.63.0 */
1
+ /** Numerics 0.64.0 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Numerics = {}));})(this, (function (exports) { 'use strict';
3
- "use strict";var Numerics=(()=>{var Ti=Object.defineProperty;var Un=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var jn=Object.prototype.hasOwnProperty;var $n=(i,e)=>{for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},Wn=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jn(e))!jn.call(i,r)&&r!==t&&Ti(i,r,{get:()=>e[r],enumerable:!(n=Un(e,r))||n.enumerable});return i};var Xn=i=>Wn(Ti({},"__esModule",{value:!0}),i);var Js={};$n(Js,{BigNumericValue:()=>ni,DEFAULT_PRECISION:()=>Tt,DEFAULT_TOLERANCE:()=>Ai,ExactNumericValue:()=>X,LARGEST_SMALL_PRIME:()=>Si,MACHINE_PRECISION:()=>vt,MACHINE_PRECISION_BITS:()=>Ri,MAX_BIGINT_DIGITS:()=>Et,MAX_ITERATION:()=>Mt,MAX_SYMBOLIC_TERMS:()=>Bt,MachineNumericValue:()=>ri,NumericValue:()=>R,SMALL_INTEGER:()=>P,add:()=>ne,airyAi:()=>Fn,airyBi:()=>Cn,areCompatibleUnits:()=>ms,asMachineRational:()=>xr,besselI:()=>oe,besselJ:()=>H,besselK:()=>An,besselY:()=>hi,beta:()=>Sn,bigBeta:()=>wn,bigDigamma:()=>Ki,bigGamma:()=>vn,bigGammaln:()=>Tn,bigInterquartileRange:()=>as,bigKurtosis:()=>ts,bigLambertW:()=>Pn,bigMean:()=>Hr,bigMedian:()=>oi,bigMode:()=>os,bigPolygamma:()=>Bn,bigPopulationStandardDeviation:()=>es,bigPopulationVariance:()=>ln,bigPrimeFactors:()=>Di,bigQuartiles:()=>fn,bigSkewness:()=>rs,bigStandardDeviation:()=>Qr,bigTrigamma:()=>Qi,bigVariance:()=>an,bigZeta:()=>kn,bigint:()=>V,bigintCanonicalInteger:()=>Me,bigintFactorial:()=>Fi,bigintGcd:()=>ie,bigintLcm:()=>Je,bigintValue:()=>Fr,bignumFactorial2:()=>nn,bignumGcd:()=>Wi,bignumLcm:()=>tn,canonicalInteger:()=>ee,cantorEnumerateComplexNumbers:()=>At,cantorEnumerateIntegers:()=>Ot,cantorEnumerateNaturalNumbers:()=>Ft,cantorEnumeratePositiveRationals:()=>Rt,cantorEnumerateRationals:()=>Dt,centeredDiff8thOrder:()=>St,chop:()=>Pt,complexGamma:()=>tt,complexGammaln:()=>nt,convertCompoundUnit:()=>ps,convertUnit:()=>Nn,determinant:()=>on,digamma:()=>pi,dimensionsEqual:()=>mi,div:()=>kr,erf:()=>Ni,erfInv:()=>In,erfc:()=>Xi,extrapolate:()=>Le,factorial:()=>kt,factorial2:()=>xt,findNamedUnit:()=>ds,fresnelC:()=>Gn,fresnelS:()=>Ln,fromDigits:()=>Zi,gamma:()=>G,gammaln:()=>he,gcd:()=>_,getExpressionDimension:()=>re,getExpressionScale:()=>se,getUnitDimension:()=>li,getUnitScale:()=>hn,interquartileRange:()=>us,interval:()=>Ur,intervalContains:()=>Jr,intervalSubset:()=>jr,inverse:()=>we,isBigRational:()=>je,isDimensionless:()=>cs,isInMachineRange:()=>xe,isInteger:()=>W,isMachineRational:()=>A,isNeg:()=>wr,isNegativeOne:()=>Xe,isOne:()=>We,isPositive:()=>$e,isPrime:()=>It,isPrimeBigint:()=>gr,isRational:()=>Er,isZero:()=>te,kurtosis:()=>is,lambertW:()=>Dn,lcm:()=>Ue,limit:()=>Ye,machineDenominator:()=>Br,machineNumerator:()=>Mr,mean:()=>Xr,median:()=>si,mode:()=>ss,monteCarloEstimate:()=>Wr,mul:()=>L,neg:()=>Vi,nextDown:()=>wt,nextUp:()=>Oi,numberToExpression:()=>O,numberToString:()=>x,parseUnitDSL:()=>Ns,polygamma:()=>zi,populationStandardDeviation:()=>zr,populationVariance:()=>cn,pow:()=>Pr,primeFactors:()=>Ge,quartiles:()=>mn,rationalAsFloat:()=>Ci,rationalGcd:()=>_i,rationalize:()=>Dr,reduceRationalSquareRoot:()=>Rr,reducedInteger:()=>Ct,reducedRational:()=>Be,sinc:()=>Yn,skewness:()=>ns,sqrt:()=>Sr,standardDeviation:()=>Kr,trigamma:()=>gi,variance:()=>un,version:()=>Us,zeta:()=>et});var R=class{get bignumRe(){}im;get bignumIm(){}isZeroWithTolerance(e){return this.isZero}valueOf(){return this.im===0?this.bignumRe?this.bignumRe.toNumber():this.re:this.toString()}[Symbol.toPrimitive](e){return e==="string"?this.toString():this.valueOf()}toJSON(){if(this.im===0){let e=this.re;if(Number.isFinite(e))return e}return this.N().toString()}print(){let e=console.log;e?.(this.toString())}};var rt=new Map,Hn=1e5;function E(i){if(i<=Hn){let e=rt.get(i);return e===void 0&&(e=10n**BigInt(i),rt.set(i,e)),e}return 10n**BigInt(i)}function J(i){if(i<0n&&(i=-i),i===0n)return 0;let e=0,t=1;for(;i>>BigInt(t)>0n;)t*=2;for(let n=t>>1;n>=1;n>>=1)i>>BigInt(n)>0n&&(e+=n,i>>=BigInt(n));return e+1}function ut(i,e,t){return i*e>>BigInt(t)}function at(i,e,t){return(i<<BigInt(t))/e}function Ie(i,e){if(i===0n)return 0n;if(i<0n)throw new RangeError("fpsqrt: negative input");let t=i<<BigInt(e),n;if(e<Kn){n=Mi(t);let a;do a=n,n=(n+t/n)/2n;while(F(n-a)>1n)}else n=Bi(t,J(t));let r=(n+t/n)/2n,s=F(n*n-t);return F(r*r-t)<s?r:n}function Mi(i){let e=J(i);if(e<=1023){let o=Math.sqrt(Number(i));if(Number.isFinite(o)&&o>=1)return BigInt(Math.floor(o))}let t=e-52,n=Number(i>>BigInt(t)),r=Math.sqrt(n);t&1&&(r*=Math.SQRT2);let s=BigInt(Math.round(r))<<BigInt(t>>1);return s>0n?s:1n}var ct=1024,Kn=640;function Bi(i,e){if(e<ct){let s=Mi(i),o;do o=s,s=(s+i/s)/2n;while(F(s-o)>1n);for(;s*s>i;)s-=1n;for(;(s+1n)*(s+1n)<=i;)s+=1n;return s}let t=e>>2<<1,n=Bi(i>>BigInt(t),e-t)<<BigInt(t>>1),r;do r=n,n=(n+i/n)/2n;while(F(n-r)>1n);for(;n*n>i;)n-=1n;for(;(n+1n)*(n+1n)<=i;)n+=1n;return n}function F(i){return i<0n?-i:i}function k(i){if(i===0n)return 1;if(i<0n&&(i=-i),i<0x20000000000000n)return Math.floor(Math.log10(Number(i)))+1;let e=0,t=i,n=1;for(;t>>BigInt(n)>0n;)n*=2;for(let s=n>>1;s>=1;s>>=1)t>>BigInt(s)>0n&&(e+=s,t>>=BigInt(s));e+=1;let r=Math.ceil(e*.30102999566398);return i<E(r-1)?r-1:i>=E(r)?r+1:r}function Re(i,e){let t=BigInt(e),n=1n<<t;if(i===0n)return n;let r=0,s=i,o=n>>1n;for(;F(s)>o;)s=s/2n,r++;let a=n,c=s;a+=c;for(let l=2;c=(c*s>>t)/BigInt(l),c!==0n;l++)a+=c;for(let l=0;l<r;l++)a=a*a>>t;return a}var Qn=2300;function wi(i,e){let t=1n<<BigInt(e);if(i<=0n)throw new RangeError("fpln: input must be positive");return i===t?0n:e>=Qn?ir(i,e):zn(i,e)}function zn(i,e){let t=BigInt(e),n=1n<<t,r=Number(i),s=Number(n),o,a=i,c=0,l=2;if(Number.isFinite(r)&&Number.isFinite(s)&&r>0&&s>0){let f=r/s;if(Number.isFinite(f)&&f>0){let d=Math.log(f);Number.isFinite(d)?(o=BigInt(Math.round(d*s)),l=48):o=vi(i,e)}else o=vi(i,e)}else{a=i;let f=n<<1n,d=n>>1n;for(;a>f||a<d;)a=Ie(a,e),c++;o=vi(a,e)}for(let f=Math.min(e,Math.max(8,2*l));f<e;){let d=BigInt(f),h=BigInt(e-f),N=o>>h,p=Re(N,f);if(p===0n){o=o/2n;continue}let g=a>>h;o=N+(g<<d)/p-(1n<<d)<<h,f=Math.min(e,2*f)}let m=0n;for(let f=0;f<100;f++){let d=Re(o,e);if(d===0n){o=o/2n;continue}let h=o+(a<<t)/d-n,N=F(h-o);if(N<=1n||N<100000n&&m>0n&&m<100000n&&N*4n>=m)break;m=N,o=h}for(let f=0;f<c;f++)o=2n*o;return o}var K=null;function er(i){if(K!==null){if(K.bits===i)return K.value;if(K.bits>i)return K.value>>BigInt(K.bits-i)}let e=Math.ceil(i*Fe)+12,t;if(e<=ot.length){let n=ot.slice(0,e);t=(BigInt(n)<<BigInt(i))/E(n.length)}else t=ur(i);return K={bits:i,value:t},t}function ir(i,e){let t=BigInt(e),n=J(i)-e,r=Math.max(2,Math.ceil(e/2+4-n)),s=i<<BigInt(r-2),o=1n<<t,a=s;for(;F(o-a)>1n;){let l=o+a>>1n;a=Te(o*a),o=l}return Oe(e)*s/(2n*o)-BigInt(r)*er(e)}var st=6243314768165359n;function vi(i,e){let t=BigInt(J(i)-e);return e>=53?t*st<<BigInt(e-53):t*st>>BigInt(53-e)}var ce="314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635",Fe=Math.log10(2),ot="693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095326366642654104239157814952043740430385500801944170641671518644712839968171784546957026271631064546150257207402481637773389638550695260668341137273873722928956493547025762652098859693201965058554764703306793654432547632744951250406069438147104689946506220167720424524529612687946546193165174681392672504103802546259656869144192871608293803172714367782654877566485085674077648451464439940461422603193096735402574446070308096085047486638523138181676751438667476647890881437141985494231519973548803751658612753529166100071053558249879414729509293113897155998205654392871700072180857610252368892132449713893203784393530887748259701715591070882368362758984258918535302436342143670611892367891923723146723217205340164925687274778234453534764811494186423867767744060695626573796008670762571991847340226514628379048830620330611446300737194890027436439650025809365194430411911506080948793067865158870900605203468429736193841289652556539686022194122924207574321757489097706752687115817051137009158942665478595964890653058460258668382940022833005382074005677053046787001841624044188332327983863490015631218895606505531512721993983320307514084260914790012651682434438935724727882054862715527418772430024897945401961872339808608316648114909306675193393128904316413706813977764981769748689038877899912965036192707108892641052309247839173735012298424204995689359922066022046549415106139187885744245577510206837030866619480896412186807790208181588580001688115973056186676199187395200766719214592236720602539595436541655311295175989940056000366513567569051245926825743946483168332624901803824240824231452306140963805700702551387702681785163069025513703234053802145019015374029509942262995779647427138157363801729873940704242179972266962979939312706935747240493386530879758721699645129446491883771156701678598804981838896784134938314014073166472765327635919233511233389338709513209059272185471328975470797891384445466676192702885533423429899321803769154973340267546758873236778342916191810430116091695265547859732891763545556742863877463987101912431754255888301206779210280341206879759143081283307230300883494705792496591005860012341561757413272465943",tr=13591409n,nr=545140134n,rr=10939058860032000n,sr=47.11;function Ae(i,e){if(e-i===1){let l,m;if(i===0)l=1n,m=1n;else{l=BigInt(6*i-5)*BigInt(2*i-1)*BigInt(6*i-1);let d=BigInt(i);m=d*d*d*rr}let f=l*(tr+nr*BigInt(i));return i&1&&(f=-f),[l,m,f]}let t=i+e>>1,[n,r,s]=Ae(i,t),[o,a,c]=Ae(t,e);return[n*o,r*a,a*s+n*c]}function lt(i){return Math.max(2,Math.floor(i/sr)+3)}function or(i){let[,e,t]=Ae(0,lt(i)),n=1n<<BigInt(i),r=Te(10005n*n*n);return e*426880n*r/t}function mt(i){let[,e,t]=Ae(0,lt(Math.ceil(i/Fe))),n=E(i),r=Te(10005n*n*n);return e*426880n*r/t}function Ei(i,e){if(e-i===1){let l=i===0?1n:BigInt(2*i-1),m=i===0?1n:9n*BigInt(2*i+1);return[l,m,l]}let t=i+e>>1,[n,r,s]=Ei(i,t),[o,a,c]=Ei(t,e);return[n*o,r*a,a*s+n*c]}function ur(i){let e=Math.max(2,Math.ceil(i/3.169925)+5),[,t,n]=Ei(0,e);return(n<<BigInt(i+1))/(3n*t)}function Te(i){if(i<0n)throw new RangeError("bigintSqrt: negative input");if(i===0n)return 0n;let e=J(i);if(e>=ct)return Bi(i,e);let t=Mi(i),n;do n=t,t=(t+i/t)/2n;while(F(t-n)>1n);for(;t*t>i;)t-=1n;for(;(t+1n)*(t+1n)<=i;)t+=1n;return t}var Q=null;function Oe(i){if(Q!==null){if(Q.bits===i)return Q.value;if(Q.bits>i)return Q.value>>BigInt(Q.bits-i)}let e=ar(i);return Q={bits:i,value:e},e}function ar(i){let e=Math.ceil(i*Fe)+12;if(e+1<=ce.length){let t=ce.slice(0,e+1);return(BigInt(t)<<BigInt(i))/E(t.length-1)}return or(i)}function Ce(i,e){let t=BigInt(e),n=1n<<t;if(i===0n)return[0n,n];let r=Oe(e),s=2n*r,o=r/2n,a,c=F(i);if(c>n<<30n){let B=J(c)-e+64,Y=e+B,S=i<<BigInt(B),be=2n*Oe(Y),Ii=S%be;Ii<0n&&(Ii+=be),a=Ii>>BigInt(B)}else a=i%s;a<0n&&(a+=s);let l=1n,m=1n;a>3n*o?(a=s-a,l=-1n):a>r?(a=a-r,l=-1n,m=-1n):a>o&&(a=r-a,m=-1n);let f=Math.round(e*Fe),d=Math.min(18,Math.max(2,Math.ceil(.87*Math.sqrt(f)))),h=0,N=n>>BigInt(d);for(;a>N;)a=a/2n,h++;let p=a,g=n,b=a,T=n,y=a*a,w=2n*t;for(let B=2;;B+=2){if(T=(T*y>>w)/(BigInt(B)*BigInt(B-1)),T===0n){b=(b*y>>w)/(BigInt(B+1)*BigInt(B)),b!==0n&&(B%4===2?(g-=T,p-=b):(g+=T,p+=b));break}if(b=(b*y>>w)/(BigInt(B+1)*BigInt(B)),B%4===2?(g-=T,p-=b):(g+=T,p+=b),b===0n)break}for(let B=0;B<h;B++){let Y=2n*p*g>>t,S=(2n*g*g>>t)-n;p=Y,g=S}return[l*p,m*g]}function ye(i,e){if(i===0n)return 0n;if(i<0n)return-ye(-i,e);let t=BigInt(e),n=1n<<t,s=Oe(e)/2n;if(i>n){let h=(n<<t)/i;return s-ye(h,e)}let o=4n*n/10n,a=0,c=i;for(;c>o;){let h=c*c,N=(n<<t)+h>>t,p=Ie(N,e);c=(c<<t)/(n+p),a++}let l=c,m=c,f=c*c,d=2n*t;for(let h=3;m=m*f>>d,m!==0n;h+=2)h%4===3?l-=m/BigInt(h):l+=m/BigInt(h);for(let h=0;h<a;h++)l=2n*l;return l}var ki=NaN,u=class i{static precision=50;static ZERO=Object.freeze(Object.assign(Object.create(i.prototype),{significand:0n,exponent:0}));static ONE=Object.freeze(Object.assign(Object.create(i.prototype),{significand:1n,exponent:0}));static TWO=Object.freeze(Object.assign(Object.create(i.prototype),{significand:2n,exponent:0}));static NEGATIVE_ONE=Object.freeze(Object.assign(Object.create(i.prototype),{significand:-1n,exponent:0}));static HALF=Object.freeze(Object.assign(Object.create(i.prototype),{significand:5n,exponent:-1}));static NAN=Object.freeze(Object.assign(Object.create(i.prototype),{significand:0n,exponent:NaN}));static POSITIVE_INFINITY=Object.freeze(Object.assign(Object.create(i.prototype),{significand:1n,exponent:1/0}));static NEGATIVE_INFINITY=Object.freeze(Object.assign(Object.create(i.prototype),{significand:-1n,exponent:1/0}));static _piFullPrecision=null;static _piCache=null;static _piCachePrecision=0;static _eulerGammaCache=null;static _eulerGammaCachePrecision=0;static get PI(){let e=i.precision;if(i._piCache!==null&&i._piCachePrecision===e)return i._piCache;let t=e+4,n;if(t+1<=ce.length)i._piFullPrecision===null&&(i._piFullPrecision=new i(ce[0]+"."+ce.slice(1))),n=i._piFullPrecision.toPrecision(t);else{let r=t+4;n=v(mt(r),-r).toPrecision(t)}return i._piCache=n,i._piCachePrecision=e,n}static get EULER_GAMMA(){let e=i.precision;if(i._eulerGammaCache!==null&&i._eulerGammaCachePrecision>=e)return i._eulerGammaCache.toPrecision(e);let t=mr(e);return i._eulerGammaCache=t,i._eulerGammaCachePrecision=e,t}significand;exponent;constructor(e){if(e instanceof i){this.significand=e.significand,this.exponent=e.exponent;return}if(typeof e=="bigint"){[this.significand,this.exponent]=Ve(e,0);return}if(typeof e=="number"){[this.significand,this.exponent]=fr(e);return}[this.significand,this.exponent]=Nt(e)}isNaN(){return Number.isNaN(this.exponent)}isZero(){return this.exponent===0&&this.significand===0n}isFinite(){return Number.isFinite(this.exponent)}isInteger(){return this.isFinite()&&this.exponent>=0}isPositive(){return this.significand>0n}isNegative(){return this.significand<0n}cmp(e){if(typeof e=="number"){if(Number.isNaN(e))return ki;let h=this.exponent;if(Number.isNaN(h))return ki;if(e===0)return this.significand===0n?0:this.significand>0n?1:-1;if(!Number.isFinite(h))return e===1/0?this.significand>0n?0:-1:e===-1/0?this.significand<0n?0:1:this.significand>0n?1:-1;if(this.significand===0n)return e>0?-1:1;if(e===1/0)return-1;if(e===-1/0)return 1;if(this.significand>0n!=e>0)return this.significand>0n?1:-1;if(Number.isInteger(e)&&h>=0&&h<=15){let N=this.significand*E(h),p=BigInt(e);return N<p?-1:N>p?1:0}e=new i(e)}let t=this.exponent,n=e.exponent,r=this.significand,s=e.significand;if(t!==t||n!==n)return ki;if(!Number.isFinite(t)||!Number.isFinite(n))return!Number.isFinite(t)&&!Number.isFinite(n)?r===s?0:r>s?1:-1:Number.isFinite(t)?s>0n?-1:1:r>0n?1:-1;if(r===0n)return s===0n?0:s>0n?-1:1;if(s===0n)return r>0n?1:-1;if(r>0n&&s<0n)return 1;if(r<0n&&s>0n)return-1;if(t===n)return r<s?-1:r>s?1:0;let o=k(r),a=k(s),c=o+t,l=a+n;if(c!==l){let h=r>0n?1:-1;return c>l?h:-h}let m=r,f=s,d=Math.abs(t-n);if(d>1e3){let h=o,N=a,p=Math.max(h,N)+1;h<p&&(m=m*E(p-h)),N<p&&(f=f*E(p-N))}else t<n?f=f*E(d):m=m*E(d);return m<f?-1:m>f?1:0}eq(e){return typeof e=="number"?e===0?this.significand===0n&&this.exponent===0:e===1?this.significand===1n&&this.exponent===0:e===-1?this.significand===-1n&&this.exponent===0:Number.isInteger(e)&&Number.isFinite(this.exponent)&&this.exponent>=0&&this.exponent<=15?this.significand*E(this.exponent)===BigInt(e):this.cmp(e)===0:this.significand===e.significand&&this.exponent===e.exponent}lt(e){return this.cmp(e)===-1}lte(e){let t=this.cmp(e);return t===-1||t===0}gt(e){return this.cmp(e)===1}gte(e){let t=this.cmp(e);return t===1||t===0}add(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(t===n)return v(this.significand+e.significand,t);let o=t-n;return o>0?v(this.significand*E(o)+e.significand,n):v(this.significand+e.significand*E(-o),t)}if(t!==t||n!==n)return i.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(n);return r&&s?this.significand!==e.significand?i.NAN:this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:r?this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:e.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}sub(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(t===n)return v(this.significand-e.significand,t);let o=t-n;return o>0?v(this.significand*E(o)-e.significand,n):v(this.significand-e.significand*E(-o),t)}if(t!==t||n!==n)return i.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(n);return r&&s?this.significand===e.significand?i.NAN:this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:r?this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:e.significand>0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY}mul(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n))return v(this.significand*e.significand,t+n);if(t!==t||n!==n||this.significand===0n||e.significand===0n)return i.NAN;let r=this.significand>0n?1n:-1n,s=e.significand>0n?1n:-1n;return r*s>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}neg(){let e=this.significand;return e===0n?this:Number.isFinite(this.exponent)?v(-e,this.exponent):e>0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY}abs(){return this.significand>=0n?this:Number.isFinite(this.exponent)?v(-this.significand,this.exponent):i.POSITIVE_INFINITY}floor(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.trunc();return this.significand<0n?t.sub(v(1n,0)):t}return this}ceil(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.trunc();return this.significand>0n?t.add(v(1n,0)):t}return this}round(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=v(5n,-1);return this.significand>0n?this.add(t).trunc():this.sub(t).trunc()}return this}trunc(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.significand/E(-e);return v(t===0n?0n:t,0)}return this}div(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent,r=this.significand,s=e.significand;if(Number.isFinite(t)&&Number.isFinite(n)){if(s===0n)return r===0n?i.NAN:r>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY;if(r===0n)return v(0n,0);let c=i.precision,l=10,m=r<0n?-r:r,f=s<0n?-s:s,d=k(m),h=k(f),N=c+l+Math.max(0,h-d),p=E(N),g=r*p/s,b=t-n-N;return v(g,b).toPrecision(c)}if(t!==t||n!==n)return i.NAN;let o=!Number.isFinite(t),a=!Number.isFinite(n);if(o&&a)return i.NAN;if(o){let c=r>0n?1n:-1n,l=s>0n?1n:s<0n?-1n:1n;return c*l>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}return v(0n,0)}inv(){return v(1n,0).div(this)}divToward(e,t){typeof e=="number"&&(e=new i(e));let n=this.exponent,r=e.exponent,s=this.significand,o=e.significand;if(!Number.isFinite(n)||!Number.isFinite(r)||o===0n||s===0n)return this.div(e);let a=s<0n!=o<0n,c=s<0n?-s:s,l=o<0n?-o:o,m=i.precision,d=m+10+Math.max(0,k(l)-k(c)),h=c*E(d),N=h/l,p=h%l!==0n,g=n-r-d,b=a?t==="floor":t==="ceiling",[T,y]=ft(N,p,g,m,b);return v(a?-T:T,y)}sqrtToward(e){if(this.significand===0n)return this.exponent!==this.exponent?this:i.ZERO;if(!Number.isFinite(this.exponent))return this.significand>0n?i.POSITIVE_INFINITY:i.NAN;if(this.significand<0n)return i.NAN;let t=i.precision,n=4,r=this.significand,s=this.exponent,o=s+k(r)-1,a=Math.floor(o/2),c=t+n-a;s+2*c<0&&(c=Math.ceil(-s/2)+1);let l=s+2*c,m=l>=0?r*E(l):r/E(-l),f=Te(m),d=f*f!==m,[h,N]=ft(f,d,-c,t,e==="ceiling");return v(h,N)}mod(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(e.significand===0n)return i.NAN;if(this.significand===0n)return v(0n,0);let r=t-n,s=r>=0?this.significand*E(r):this.significand,o=r>=0?e.significand:e.significand*E(-r),a=s/o;return this.sub(v(a,0).mul(e))}return t!==t||n!==n||!Number.isFinite(t)?i.NAN:new i(this)}pow(e){if(typeof e=="number"&&(e=new i(e)),this.isNaN()||e.isNaN()||!e.isFinite())return i.NAN;if(e.isInteger()){let l=e.toBigInt();if(l===0n)return v(1n,0);if(!this.isFinite())return l>0n?this.significand<0n&&l%2n!==0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY:v(0n,0);if(this.isZero())return l>0n?v(0n,0):i.POSITIVE_INFINITY;if(l<0n)return this.pow(e.neg()).inv();let m=this.significand<0n?-this.significand:this.significand,f=k(m),d=f>15?f-15:0,h=d>0?Number(m/10n**BigInt(d)):Number(m),N=Math.log10(h)+d+this.exponent,p=Number(l)*N;if(p>9e15)return this.significand<0n&&l%2n!==0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY;if(p<-9e15)return v(0n,0);let g=i.precision,b=v(1n,0),T=this,y=l;for(;y>0n;)y&1n&&(b=b.mul(T).toPrecision(g)),y>>=1n,y>0n&&(T=T.mul(T).toPrecision(g));return b}if(!this.isFinite())return this.significand<0n?i.NAN:e.significand>0n?i.POSITIVE_INFINITY:i.ZERO;if(this.isZero())return e.significand>0n?i.ZERO:i.POSITIVE_INFINITY;if(this.significand<0n)return i.NAN;let t=this.significand,n=this.exponent+k(t)-1,r=e.significand<0n?-e.significand:e.significand,o=e.exponent+k(r)-1+Math.log10(Math.abs(n)*2.303+3)+1,a=Math.min(20,Math.max(2,Math.ceil(o)+2)),c=i.precision;i.precision=c+a;try{let l=lr(this,c+a);return e.mul(l).exp().toPrecision(c)}finally{i.precision=c}}toNumber(){return Number.isFinite(this.exponent)?this.significand===0n?0:this.exponent===0?Number(this.significand):Number(this.toString()):this.exponent!==this.exponent?NaN:this.significand>0n?1/0:-1/0}toString(){if(!Number.isFinite(this.exponent))return this.exponent!==this.exponent?"NaN":this.significand>0n?"Infinity":"-Infinity";if(this.significand===0n)return"0";let e=this.significand<0n,t=(e?-this.significand:this.significand).toString(),n=t.length,r=n+this.exponent-1,s=e?"-":"";if(r>20||r<-6){let c=n===1?t:t[0]+"."+t.slice(1),l=r>=0?"+":"";return`${s}${c}e${l}${r}`}if(this.exponent>=0)return s+t+"0".repeat(this.exponent);let o=-this.exponent;if(o<n){let c=t.slice(0,n-o),l=t.slice(n-o);return`${s}${c}.${l}`}let a=o-n;return`${s}0.${"0".repeat(a)}${t}`}toFixed(e){let t=e??0;if(!Number.isFinite(this.exponent))return this.exponent!==this.exponent?"NaN":this.significand>0n?"Infinity":"-Infinity";let n=this.significand<0n,r=n?-this.significand:this.significand,s=this.exponent+t,o;if(s>=0)o=r*E(s);else{let f=E(-s),d=r/f,h=r%f,N=f/2n;h>N?o=d+1n:h<N||f%2n!==0n||d%2n===0n?o=d:o=d+1n}let a=n&&o!==0n?"-":"",c=o.toString();if(t===0)return`${a}${c}`;if(c.length<=t){let f=c.padStart(t,"0");return`${a}0.${f}`}let l=c.slice(0,c.length-t),m=c.slice(c.length-t);return`${a}${l}.${m}`}toPrecision(e){if(this.significand===0n||!Number.isFinite(this.exponent))return this;let t=this.significand<0n?-this.significand:this.significand,n=k(t);if(n<=e)return this;let r=n-e,s=E(r),o=t/s,a=t-o*s,c=s/2n;(a>c||a===c&&o%2n!==0n)&&(o+=1n);let l=this.significand<0n?-o:o;return v(l,this.exponent+r)}toBigInt(){if(!Number.isFinite(this.exponent))throw this.exponent!==this.exponent?new RangeError("Cannot convert NaN to BigInt"):new RangeError("Cannot convert Infinity to BigInt");if(this.exponent>=0)return this.significand*E(this.exponent);let e=E(-this.exponent);return this.significand/e}},cr=8,ve=[];function lr(i,e){let t=i.significand,n=i.exponent;for(let s=ve.length-1;s>=0;s--){let o=ve[s];if(o.prec===e&&o.exp===n&&o.sig===t)return o.ln}let r=i.ln();return ve.push({sig:t,exp:n,prec:e,ln:r}),ve.length>cr&&ve.shift(),r}function mr(i){let e=i+20+Math.ceil(Math.log10(i+10)),t=u.precision;u.precision=e;try{let n=Math.ceil(e*Math.LN10/4)+5,r=new u(n),s=r.mul(r),o=u.ONE,a=u.ONE,c=u.ZERO,l=u.ZERO,m=u.ONE.div(new u(10).pow(e)),f=6*n+100;for(let d=1;d<=f;d++){let h=new u(d).mul(d);if(o=o.mul(s).div(h).toPrecision(e),l=l.add(u.ONE.div(d)).toPrecision(e),a=a.add(o).toPrecision(e),c=c.add(o.mul(l)).toPrecision(e),d>n&&o.lt(a.mul(m)))break}return c.div(a).sub(r.ln()).toPrecision(i)}finally{u.precision=t}}function v(i,e){let[t,n]=Ve(i,e),r=Object.create(u.prototype);return r.significand=t,r.exponent=n,r}function ft(i,e,t,n,r){if(i===0n)return[r&&e?1n:0n,t];let s=k(i);if(s<=n)return[r&&e?i+1n:i,t];let o=s-n,a=E(o),c=i/a,l=e||i%a!==0n;return r&&l&&(c+=1n),[c,t+o]}var dt=1000000000n,ht=1000n;function Ve(i,e){if(i===0n)return[0n,0];for(;i%dt===0n;)i/=dt,e+=9;for(;i%ht===0n;)i/=ht,e+=3;for(;i%10n===0n;)i/=10n,e+=1;return[i,e]}function fr(i){return Number.isNaN(i)?[0n,NaN]:i===1/0?[1n,1/0]:i===-1/0?[-1n,1/0]:Number.isInteger(i)?Ve(BigInt(i),0):Nt(i.toString())}function Nt(i){if(i=i.trim(),i===""||i==="NaN")return[0n,NaN];if(i==="Infinity"||i==="+Infinity")return[1n,1/0];if(i==="-Infinity")return[-1n,1/0];let e,t=0,n=i.search(/[eE]/);if(n!==-1){if(e=i.slice(0,n),t=Number(i.slice(n+1)),!Number.isFinite(t))return[0n,NaN]}else e=i;let r=!1;e.startsWith("-")?(r=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let s=e.indexOf("."),o,a;s===-1?(o=e,a=""):(o=e.slice(0,s),a=e.slice(s+1)),o=o.replace(/^0+/,"")||"0";let c=o+a;if(c.length===0||!/^\d+$/.test(c))return[0n,NaN];let l=BigInt(c);r&&(l=-l);let m=-a.length;return Ve(l,m+t)}var dr=Math.log2(10),hr=Math.log10(2),Nr=16,xi=1e6;function j(i,e){let t=Math.ceil(e*dr)+Nr,n=BigInt(t);return i.exponent>=0?[i.significand*E(i.exponent)<<n,t]:[(i.significand<<n)/E(-i.exponent),t]}function $(i,e,t){if(i===0n)return u.ZERO;let n=i<0n,r=n?-i:i,s=BigInt(e),o=J(r)-e,a=Math.floor(o*hr),c=t+4-a,l,m;if(c>=0)l=r*E(c)+(1n<<s-1n)>>s,m=-c;else{let d=E(-c)<<s;l=(r+d/2n)/d,m=-c}if(l===0n)return u.ZERO;let f=k(l);if(f>t){let d=f-t,h=E(d),N=h/2n,p=l%h;l=l/h,p>=N&&(l+=1n),m+=d}return v(n?-l:l,m)}function C(i){let e=i.significand<0n?-i.significand:i.significand;return i.exponent+k(e)-1}var pt=BigInt(Number.MAX_SAFE_INTEGER),z=null;function bt(i){if(z!==null){if(z.bits===i)return z.value;if(z.bits>i)return z.value>>BigInt(z.bits-i)}let e=wi(10n<<BigInt(i),i);return z={bits:i,value:e},e}u.prototype.sqrt=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.significand<0n)return u.NAN;let i=u.precision,e=i+10,t=C(this),n=Math.floor(t/2),r=v(this.significand,this.exponent-2*n),[s,o]=j(r,e),a=Ie(s,o),c=$(a,o,i);return v(c.significand,c.exponent+n)};u.prototype.cbrt=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;if(this.significand<0n)return this.neg().cbrt().neg();let i=u.precision,e=i+10,t=C(this),n=Math.floor(t/3),r=v(this.significand,this.exponent-3*n),[s,o]=j(r,e),a=s<<BigInt(2*o),c,l=r.toNumber();if(o<=1e3&&Number.isFinite(l)&&l>0){let d=Number(1n<<BigInt(o)),h=Math.cbrt(l);Number.isFinite(h)&&h>0?(c=BigInt(Math.floor(h*d)),c===0n&&(c=1n)):c=gt(a)}else c=gt(a);let m;do{m=c;let d=c*c;if(d===0n){c=1n;break}c=(2n*c+a/d)/3n}while(F(c-m)>1n);{let d=(2n*c+a/(c*c))/3n,h=F(c*c*c-a);F(d*d*d-a)<h&&(c=d)}let f=$(c,o,i);return v(f.significand,f.exponent+n)};u.sqrt=function(i){return i.sqrt()};u.cbrt=function(i){return i.cbrt()};u.prototype.exp=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.ZERO;if(this.isZero())return u.ONE;if(C(this)>=17)return this.significand>0n?u.POSITIVE_INFINITY:u.ZERO;let i=u.precision,e=this.significand<0n?-this.significand:this.significand,t=Math.max(0,this.exponent+k(e)),n=i+20+t,[r,s]=j(this,n),o=bt(s),a=r/o,c=r-a*o;if(c<0n&&(a-=1n,c+=o),a>pt||a<-pt)return a>0n?u.POSITIVE_INFINITY:u.ZERO;let l=$(Re(c,s),s,i),m=l.exponent+Number(a);return Number.isSafeInteger(m)?v(l.significand,m):a>0n?u.POSITIVE_INFINITY:u.ZERO};u.prototype.ln=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.isZero())return u.NEGATIVE_INFINITY;if(this.significand<0n)return u.NAN;if(this.eq(1))return u.ZERO;let i=u.precision,e=this.significand,t=k(e),n=this.exponent+t-1,r=v(e,-(t-1)),s=Math.abs(n).toString().length,o=i+20+s,[a,c]=j(r,o),l=bt(c),m=wi(a,c)+BigInt(n)*l;return $(m,c,i)};u.prototype.log=function(i){let e=i instanceof u?i:new u(i);return this.ln().div(e.ln())};u.exp=function(i){return i.exp()};u.ln=function(i){return i.ln()};u.log10=function(i){return i.log(10)};u.log2=function(i){return i.log(2)};u.prototype.sin=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0);if(e+t+30>xi)return u.NAN;let[n,r]=j(this,t),[s]=Ce(n,r);return $(s,r,i)};u.prototype.cos=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ONE;let i=u.precision,e=i+15;if(C(this)+e+30>xi)return u.NAN;let[n,r]=j(this,e),[,s]=Ce(n,r);return $(s,r,i)};u.prototype.tan=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0);if(e+t+30>xi)return u.NAN;let[n,r]=j(this,t),[s,o]=Ce(n,r);if(o===0n)return s>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let a=(s<<BigInt(r))/o;return $(a,r,i)};u.prototype.atan=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite()){let o=u.PI.div(u.TWO);return this.significand>0n?o:o.neg()}let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0),[n,r]=j(this,t),s=ye(n,r);return $(s,r,i)};u.prototype.asin=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=this.abs(),e=u.ONE;if(i.gt(e))return u.NAN;if(i.eq(e)){let h=u.PI.div(u.TWO);return this.significand>0n?h:h.neg()}let t=u.precision,n=C(this);if(n<0&&-2*n>=t+4)return this.toPrecision(t);let r=t+20+(n<0?-n:0),[s,o]=j(this,r),a=1n<<BigInt(o),c=ut(s,s,o),l=a-c,m=Ie(l,o),f=at(s,m,o),d=ye(f,o);return $(d,o,t)};u.prototype.acos=function(){return this.isNaN()?u.NAN:this.isFinite()?this.abs().gt(u.ONE)?u.NAN:this.eq(1)?u.ZERO:this.eq(-1)?u.PI:u.PI.div(u.TWO).sub(this.asin()):u.NAN};u.sin=function(i){return i.sin()};u.cos=function(i){return i.cos()};u.tan=function(i){return i.tan()};u.asin=function(i){return i.asin()};u.acos=function(i){return i.acos()};u.atan=function(i){return i.atan()};u.atan2=function(i,e){let t=i instanceof u?i:new u(i);if(t.isNaN()||e.isNaN())return u.NAN;let n=u.PI,r=n.div(u.TWO);if(e.isZero())return t.isZero()?u.ZERO:t.significand>0n?r:r.neg();let s=t.div(e);return e.significand>0n?s.atan():t.significand>=0n?s.atan().add(n):s.atan().sub(n)};u.prototype.sinh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let i=u.precision,e=C(this);if(e<0){if(-2*e>=i+4)return this.toPrecision(i);let r=u.precision;u.precision=i-e+5;try{let s=this.exp();return s.sub(s.inv()).div(u.TWO).toPrecision(i)}finally{u.precision=r}}if(Math.abs(this.toNumber())>1.16*(i+3)){let r=this.abs().exp().div(u.TWO);return this.significand>0n?r:r.neg()}let t=this.exp(),n=t.inv();return t.sub(n).div(u.TWO)};u.prototype.cosh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ONE;if(!this.isFinite())return u.POSITIVE_INFINITY;let i=u.precision;if(Math.abs(this.toNumber())>1.16*(i+3))return this.abs().exp().div(u.TWO);let e=this.exp(),t=e.inv();return e.add(t).div(u.TWO)};u.prototype.tanh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.ONE:u.NEGATIVE_ONE;let i=u.precision,e=C(this);if(e<0){if(-2*e>=i+4)return this.toPrecision(i);let n=u.precision;u.precision=i-e+5;try{let r=this.mul(u.TWO).exp();return r.sub(u.ONE).div(r.add(u.ONE)).toPrecision(i)}finally{u.precision=n}}if(Math.abs(this.toNumber())>1.16*(i+3))return this.significand>0n?u.ONE:u.NEGATIVE_ONE;let t=this.mul(u.TWO).exp();return t.sub(u.ONE).div(t.add(u.ONE))};u.sinh=function(i){return i.sinh()};u.cosh=function(i){return i.cosh()};u.tanh=function(i){return i.tanh()};u.prototype.expm1=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_ONE;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-e>=i+2)return this.toPrecision(i);if(e<0){let t=u.precision;u.precision=i-e+5;try{return this.exp().sub(u.ONE).toPrecision(i)}finally{u.precision=t}}return this.exp().sub(u.ONE)};u.prototype.log1p=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.isZero())return u.ZERO;let i=u.ONE.add(this);if(i.isZero())return u.NEGATIVE_INFINITY;if(i.significand<0n)return u.NAN;let e=u.precision,t=C(this);if(t<0&&-t>=e+2)return this.toPrecision(e);if(t<0){let n=u.precision;u.precision=e-t+5;try{return u.ONE.add(this).ln().toPrecision(e)}finally{u.precision=n}}return u.ONE.add(this).ln()};u.prototype.asinh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let i=this.significand<0n,e=this.abs(),t=u.precision,n=C(this);if(n<0&&-2*n>=t+4)return this.toPrecision(t);let r=()=>e.add(e.mul(e).add(u.ONE).sqrt()).ln(),s;if(n<0){let o=u.precision;u.precision=t-n+5;try{s=r().toPrecision(t)}finally{u.precision=o}}else s=r();return i?s.neg():s};u.prototype.acosh=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.lt(u.ONE))return u.NAN;if(this.eq(1))return u.ZERO;let i=this.sub(u.ONE).div(u.TWO).sqrt();return u.TWO.mul(i.asinh())};u.prototype.atanh=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=this.abs();if(i.eq(1))return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;if(i.gt(u.ONE))return u.NAN;let e=u.precision,t=C(this);if(-2*t>=e+4)return this.toPrecision(e);let n=u.precision;u.precision=e-t+5;try{return u.ONE.add(this).div(u.ONE.sub(this)).ln().div(u.TWO).toPrecision(e)}finally{u.precision=n}};u.prototype.nthRoot=function(i){if(this.isNaN()||!Number.isInteger(i)||i===0)return u.NAN;if(i===1)return this;if(i===2)return this.sqrt();if(i===3)return this.cbrt();if(i<0)return this.nthRoot(-i).inv();if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:i%2===0?u.NAN:u.NEGATIVE_INFINITY;if(this.significand<0n)return i%2===0?u.NAN:this.neg().nthRoot(i).neg();let e=u.precision,t=u.precision;u.precision=e+8;try{return u.exp(this.ln().div(new u(i))).toPrecision(e)}finally{u.precision=t}};u.asinh=function(i){return i.asinh()};u.acosh=function(i){return i.acosh()};u.atanh=function(i){return i.atanh()};u.expm1=function(i){return i.expm1()};u.log1p=function(i){return i.log1p()};u.nthRoot=function(i,e){return i.nthRoot(e)};function gt(i){let e=J(i);if(e<=1023){let c=Math.cbrt(Number(i));if(Number.isFinite(c)&&c>=1)return BigInt(Math.floor(c))}let t=e-51,n=Number(i>>BigInt(t)),r=Math.cbrt(n),s=Math.floor(t/3),o=t%3;o===1&&(r*=1.2599210498948732),o===2&&(r*=1.5874010519681994);let a=BigInt(Math.round(r))<<BigInt(s);return a>0n?a:1n}var Ee=class extends Error{cause;value;constructor({message:e,value:t,cause:n}={}){super(e??"Operation canceled"),t&&(this.value=t),this.cause=n,this.name="CancellationError"}};function le(i){if(i!==void 0&&Date.now()>=i)throw new Ee({cause:"timeout",message:"Timeout exceeded"})}var _e;function qe(){return _e}function Ze(i,e){let t=_e;_e=i;try{return e()}finally{_e=t}}function Le(i,e,t={}){let{contract:n=.125,step:r=1,power:s=2,atol:o=1e-16,rtol:a=o>0?0:Math.sqrt(Number.EPSILON),maxeval:c=1e6,breaktol:l=2,deadline:m=qe()}=t;return isFinite(e)?Ze(m,()=>{let f=r,d=Math.pow(1/n,s),h=i(e+f),N=[h],p=1/0,g=1;for(;g<c;){le(m),g+=1,f*=n,N.push(i(e+f));let b=d,T=1/0;for(let y=N.length-2;y>=0;y--){let w=N[y];N[y]=N[y+1]+(N[y+1]-N[y])/(b-1);let B=Math.abs(N[y]-w);T=Math.min(T,B),B<p&&(h=N[y],p=B),b*=d}if(T>l*p||!isFinite(T)||p<=Math.max(a*Math.abs(h),o))break}return[h,p]}):Le(f=>i(1/f),1/e,{rtol:a,atol:o,maxeval:c,contract:Math.abs(n)>1?1/n:n,step:1/r,power:s,deadline:m})}function V(i){if(typeof i=="bigint")return i;if(typeof i=="number")return Number.isInteger(i)?BigInt(i):null;if(i instanceof u)return i.isInteger()?BigInt(i.toFixed(0)):null;let e=i.toLowerCase(),t=e.match(/^([+-]?[0-9]+)e([+-]?[0-9]+)$/);if(t){let r=parseInt(t[2]);if(r<0)return null;e=t[1]+"0".repeat(r)}if(e.indexOf(".")>=0||!/^[+-]?[0-9]+$/.test(e))return null;try{return BigInt(e)}catch(r){return console.error(r instanceof Error?r.message:String(r)),null}}var yt=0x3ffffffffffe5,Pi=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]),Si=7919;function Ge(i){if(Number.isInteger(i)&&i>=0&&i<Number.MAX_SAFE_INTEGER,i<=3)return{[i]:1};let e={},t=0;for(;i%2===0;)t+=1,i/=2;for(t>0&&(e[2]=t),t=0;i%3===0;)t+=1,i/=3;t>0&&(e[3]=t);let n=!1;for(;!n;){if(i===1)return e;let r=Math.sqrt(i);n=!0;for(let s=6;s<=r+6;s+=6){if(i%(s-1)===0){e[s-1]=(e[s-1]??0)+1,i/=s-1,n=!1;break}if(i%(s+1)===0){e[s+1]=(e[s+1]??0)+1,i/=s+1,n=!1;break}}}return e[i]!==void 0?e[i]+=1:e[i]=1,e}function It(i){if(!Number.isInteger(i)||!Number.isFinite(i)||Number.isNaN(i)||i<=1)return!1;if(i<=Si)return Pi.has(i);for(let e of Pi)if(i%e===0)return!1;return i<yt?i===pr(i)||void 0:yr(i,30)?void 0:!1}function pr(i){if(i===1)return 1;if(i%2===0)return 2;if(i%3===0)return 3;if(i%5===0)return 5;let e=Math.floor(Math.sqrt(i)),t=7;for(;t<=e;){if(i%t===0)return t;if(i%(t+4)===0)return t+4;if(i%(t+6)===0)return t+6;if(i%(t+10)===0)return t+10;if(i%(t+12)===0)return t+12;if(i%(t+16)===0)return t+16;if(i%(t+22)===0)return t+22;if(i%(t+24)===0)return t+24;t+=30}return i}function gr(i){if(i<=1)return!1;if(i<=Si)return It(Number(i));for(let e of Pi)if(i%BigInt(e)===BigInt(0))return!1;return i<yt&&(i=br(i)),Ir(i,30)?void 0:!1}function br(i){if(i===BigInt(1))return BigInt(1);if(i%BigInt(2)===BigInt(0))return BigInt(2);if(i%BigInt(3)===BigInt(0))return BigInt(3);if(i%BigInt(5)===BigInt(0))return BigInt(5);let e=BigInt(Math.floor(Math.sqrt(Number(i)))),t=BigInt(7);for(;t<=e;){if(i%t===BigInt(0))return t;if(i%(t+BigInt(4))===BigInt(0))return t+BigInt(4);if(i%(t+BigInt(6))===BigInt(0))return t+BigInt(6);if(i%(t+BigInt(10))===BigInt(0))return t+BigInt(10);if(i%(t+BigInt(12))===BigInt(0))return t+BigInt(12);if(i%(t+BigInt(16))===BigInt(0))return t+BigInt(16);if(i%(t+BigInt(22))===BigInt(0))return t+BigInt(22);if(i%(t+BigInt(24))===BigInt(0))return t+BigInt(24);t+=BigInt(30)}return i}function yr(i,e){let t=0,n=i-1;for(;n%2===0;)n/=2,++t;e:do{let r=Math.pow(2+Math.floor(Math.random()*(i-3)),n)%i;if(!(r===1||r===i-1)){for(let s=t-1;s--;){if(r=r*r%i,r===1)return!1;if(r===i-1)continue e}return!1}}while(--e);return!0}function Ir(i,e){let t=0,n=i-BigInt(1);for(;n%BigInt(2)===BigInt(0);)n=n/BigInt(2),++t;e:do{let r=BigInt(2+Math.floor(Math.random()*(Number(i)-3)))**n%i;if(!(r===BigInt(1)||r===i-BigInt(1))){for(let s=t-1;s--;){if(r=r*r%i,r===BigInt(1))return!1;if(r===i-BigInt(1))continue e}return!1}}while(--e);return!0}var Tr=[BigInt(4),BigInt(2),BigInt(4),BigInt(2),BigInt(4),BigInt(6),BigInt(2),BigInt(6)];function Di(i){if(i<Number.MAX_SAFE_INTEGER){let m=Ge(Number(i)),f=new Map;for(let d of Object.keys(m))f.set(V(d),m[Number(d)]);return f}let e=i,t=new Map,n=0,r=0,s=0,o=BigInt(10);for(;e%o===BigInt(0);)n+=1,s+=1,e=e/o;for(o=BigInt(5);e%o===BigInt(0);)s+=1,e=e/o;for(o=BigInt(3);e%o===BigInt(0);)r+=1,e=e/o;for(o=BigInt(2);e%o===BigInt(0);)n+=1,e=e/o;n>0&&t.set("2",n),r>0&&t.set("3",r),s>0&&t.set("5",s),o=BigInt(7);let a="",c=0;for(;o*o<e;)e%o===BigInt(0)?(a||(a=o.toString()),t.set(a,(t.get(a)??0)+1),e=e/o):(o=o+Tr[c],a="",c=c<7?c+1:0);e!==BigInt(1)&&t.set(e.toString(),(t.get(e.toString())??0)+1);let l=new Map;for(let[m,f]of t)l.set(V(m),f);return l}var Tt=21,Ri=53,vt=Math.floor(Math.log10(Math.pow(2,Ri))),Ai=1e-10,P=1e6,Et=1024,Mt=1e4,Bt=200;function Oi(i){if(i!==i)return i;if(i===-1/0)return-Number.MAX_VALUE;if(i===1/0||i===Number.MAX_VALUE)return 1/0;let e=i*(i<0?1-Number.EPSILON/2:1+Number.EPSILON);e===i&&(e=Number.MIN_VALUE*Number.EPSILON>0?i+Number.MIN_VALUE*Number.EPSILON:i+Number.MIN_VALUE),e===1/0&&(e=+Number.MAX_VALUE);let t=i+(e-i)/2;i<t&&t<e&&(e=t);let n=(e+i)/2;return i<n&&n<e&&(e=n),e===0?-0:e}function wt(i){return-Oi(-i)}function ee(i,e){if(i>=Number.MAX_SAFE_INTEGER)return[1,i];if(i===0)return[0,0];if(i===1)return[1,1];if(Number.isInteger(i)&&i>0&&i<Number.MAX_SAFE_INTEGER,e===2){let s=[[0,0],[1,1],[1,2],[1,3],[2,1],[1,5],[1,6],[1,7],[2,2],[3,1],[1,10],[1,11],[2,3],[1,13],[1,14],[1,15],[4,1],[1,17],[3,2],[1,19],[2,5]][i];if(s)return s}let t=Ge(i),n=BigInt(1),r=BigInt(1);for(let s of Object.keys(t)){let o=BigInt(parseInt(s)),a=BigInt(e);n=n*o**(BigInt(t[Number(s)])/a),r=r*o**(BigInt(t[Number(s)])%a)}return[Number(n),Number(r)]}function _(i,e){if(i===0)return e;if(e===0||i===e)return i;if(!Number.isInteger(i)||!Number.isInteger(e))return NaN;for(;e!==0;)[i,e]=[e,i%e];return i<0?-i:i}function Ue(i,e){if(i===0||e===0)return 0;let t=BigInt(i)*BigInt(e)/BigInt(_(i,e));return t<0n&&(t=-t),Number(t)}function kt(i){if(!Number.isInteger(i)||i<0)return NaN;if(i>=170)return 1/0;let e=1;for(let t=2;t<=i;t++)e=e*t;return e}function xt(i){if(!Number.isInteger(i)||i<0)return NaN;if(i<0)return NaN;if(i<=1)return 1;let e=i;for(;i>2;)i-=2,e*=i;return e}function Pt(i,e=Ai){return typeof i=="number"&&Math.abs(i)<=e?0:i}function St(i,e,t=.1){return(i(e-4*t)/280-4*i(e-3*t)/105+i(e-2*t)/5-4*i(e-t)/5+4*i(e+t)/5-i(e+2*t)/5+4*i(e+3*t)/105-i(e+4*t)/280)/t}function vr(i,e,t){let s=!Number.isFinite(e),o=h=>s?1/h:e+h,a=(h,N,p)=>{let g=.01*Math.max(1,Math.abs(p));for(let b=1;b<=5;b++){let T=i(o(h*Math.pow(N/h,b/6)));if(!Number.isFinite(T)||Math.abs(T-p)>g)return!1}return!0},c=s?1/t:t,l=0,m=!1,f=NaN,d=NaN;for(let h=1;h<=60;h++){let N=i(o(c));if(!Number.isFinite(N))return h-1;let p=Math.abs(N);if(h===1){l=p,f=p,d=c,c*=.125;continue}if(Math.abs(p-f)<=1e-10*Math.max(1,p))return a(d,c,N)?1/0:0;if(m&&l>1e-6&&p<1e-8*l)return h-1;p>l&&(m=!0,l=p),f=p,d=c,c*=.125}return 1/0}function Ye(i,e,t=1,n){if(t===0){let c=Ye(i,e,-1,n),l=Ye(i,e,1,n);return c===void 0||l===void 0?NaN:Math.abs(c-l)>1e-5?NaN:(c+l)/2}let r=t>0?1:-1,s=vr(i,e,r);if(s===0)return NaN;let[o,a]=Le(i,e,{step:r,deadline:n,...Number.isFinite(s)?{maxeval:s}:{}});return Number.isFinite(o)&&a>1e-6*Math.max(1,Math.abs(o))?NaN:o}function*Dt(){yield[0,1];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;t!==0&&_(e,t)===1&&(yield[e,t],yield[-e,t])}}function*Rt(){yield[0,1];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;t!==0&&_(e,t)===1&&(yield[e,t])}}function*At(){yield[0,0];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;if(t===0||_(e,t)!==1)continue;let n=e/t;for(let r=0;r<=i;r++){let s=i-r;if(s===0||_(r,s)!==1)continue;let o=r/s;yield[n,o],yield[-n,o],yield[n,-o],yield[-n,-o]}}}function*Ot(){yield 0;for(let i=1;;i++)yield i,yield-i}function*Ft(){for(let i=0;;i++)yield i}function ie(i,e){for(;e!==BigInt(0);)[i,e]=[e,i%e];return i<0?-i:i}function Je(i,e){return i*e/ie(i,e)}function Me(i,e){let t=Di(i),n=BigInt(1),r=BigInt(1),s=BigInt(e);for(let[o,a]of t){let c=V(a);n=n*o**(c/s),r=r*o**(c%s)}return[n,r]}function Ct(i){return i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}function*Fi(i){if(i<0)return BigInt(0);if(i<10)return BigInt([1,1,2,6,24,120,720,5040,40320,362880][Number(i)]);if(i%BigInt(2)===BigInt(1))return i*(yield*Fi(i-BigInt(1)));let e=i,t=i,n=i;for(;e>2;)e-=BigInt(2),t+=e,n*=t,yield n;return n}function Er(i){return i!==null&&Array.isArray(i)}function A(i){return i!==null&&Array.isArray(i)&&typeof i[0]=="number"}function je(i){return i!==null&&Array.isArray(i)&&typeof i[0]=="bigint"}function te(i){return i[0]==0}function $e(i){return i[0]>0}function We(i){return i[0]==i[1]}function Xe(i){return i[0]===-i[1]}function W(i){return i[1]==1}function Mr(i){return Number(i[0])}function Br(i){return Number(i[1])}function Ci(i){return Number(i[0])/Number(i[1])}function wr(i){return i[0]<0}function kr(i,e){return L(i,we(e))}function ne(i,e){if(typeof i[0]=="number"&&!Number.isFinite(i[0]))return i;let t=e;if(t===null)return i;if(je(t))return i=[BigInt(i[0]),BigInt(i[1])],[t[1]*i[0]+t[0]*i[1],t[1]*i[1]];if(!Number.isFinite(t[0]))return t;if(je(i)){let s=[BigInt(t[0]),BigInt(t[1])];return[s[1]*i[0]+s[0]*i[1],s[1]*i[1]]}let n=t[1]*i[0]+t[0]*i[1],r=t[1]*i[1];return n<=9007199254740991&&n>=-9007199254740991&&r<=9007199254740991?[n,r]:!Number.isFinite(n)||!Number.isFinite(r)?[NaN,1]:[BigInt(t[1])*BigInt(i[0])+BigInt(t[0])*BigInt(i[1]),BigInt(t[1])*BigInt(i[1])]}function L(i,e){if(A(i)&&(!Number.isFinite(i[0])||!Number.isFinite(i[1])))return[NaN,1];if(A(e)&&(!Number.isFinite(e[0])||!Number.isFinite(e[1])))return[NaN,1];if(A(i)&&A(e)){let t=i[0]*e[0],n=i[1]*e[1];return t<=9007199254740991&&t>=-9007199254740991&&n<=9007199254740991?[t,n]:!Number.isFinite(t)||!Number.isFinite(n)?[NaN,1]:[BigInt(i[0])*BigInt(e[0]),BigInt(i[1])*BigInt(e[1])]}return A(i)?[BigInt(i[0])*e[0],BigInt(i[1])*e[1]]:A(e)?[BigInt(e[0])*i[0],BigInt(e[1])*i[1]]:[i[0]*e[0],i[1]*e[1]]}function Vi(i){return[-i[0],i[1]]}function we(i){return i[0]<0?[-i[1],-i[0]]:[i[1],i[0]]}function xr(i){return[Number(i[0]),Number(i[1])]}function Pr(i,e){if(Number.isInteger(e),e===0)return[1,1];if(e<0&&(i=we(i),e=-e),e===1)return i;let t=BigInt(e);return[BigInt(i[0])**t,BigInt(i[1])**t]}function Sr(i){let e=Math.sqrt(Number(i[0])),t=Math.sqrt(Number(i[1]));if(Number.isInteger(e)&&Number.isInteger(t))return[e,t]}function _i(i,e){return A(i)&&A(e)?i[1]===1&&e[1]===1?[_(i[0],e[0]),1]:[_(i[0],e[0]),Ue(i[1],e[1])]:i[1]===1&&e[1]===1?[ie(BigInt(i[0]),BigInt(e[0])),BigInt(1)]:[ie(BigInt(i[0]),BigInt(e[0])),Je(BigInt(i[1]),BigInt(e[1]))]}function Be(i){if(A(i)){if(i[1]<0&&(i=[-i[0],-i[1]]),i[0]===1||i[1]===1)return i;if(!Number.isFinite(i[1]))return[0,1];let r=_(i[0],i[1]);return r<=1?i:[i[0]/r,i[1]/r]}i[1]<0&&(i=[-i[0],-i[1]]);let e=ie(i[0],i[1]),[t,n]=e<=1?i:[i[0]/e,i[1]/e];return t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?[Number(t),Number(n)]:[t,n]}function Dr(i){if(!Number.isFinite(i)||i%1===0)return i;let t=1e-15,n=Math.floor(i),r=1,s=0,o=n,a=1;for(;i-n>t*a*a;){i=1/(i-n),n=Math.floor(i);let c=r;r=o;let l=s;s=a,o=c+n*r,a=l+n*s}return[o,a]}function Rr(i){if(je(i)){let[a,c]=i,[l,m]=Me(a,2),[f,d]=Me(c,2);return[Be([l,f*d]),m*d]}let[e,t]=i,[n,r]=ee(e,2),[s,o]=ee(t,2);return[Be([n,s*o]),r*o]}function Vt(i){return!!(typeof i=="number"||qi(i)||typeof i=="string"&&Ar(i))}function qi(i){return i!==null&&typeof i=="object"&&"num"in i}function Ar(i){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(i)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(i)}function Or(i){if(i==="N")return[0,""];let e={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},t=0,n=0;i=i.toUpperCase();for(let r=i.length-1;r>=0;r--){let s=e[i[r]];if(s===void 0)return[t,i.slice(r)];s<n?t-=s:t+=s,n=s}return[t,""]}function Zi(i,e){if(i=i.trim(),i.length===0)return[NaN,""];if(i.startsWith("+"))return Zi(i.slice(1),e);if(i.startsWith("-")){let[r,s]=Zi(i.slice(1),e);return[-r,s]}let t=10;if(typeof e=="string"&&(e=e.toLowerCase()),i.startsWith("0x"))t=16,i=i.slice(2);else if(i.startsWith("0b"))t=2,i=i.slice(2);else{if(e==="roman")return Or(i);if(e==="base64"||e==="base-64")try{return[parseInt(btoa(i)),""]}catch{return[NaN,""]}else typeof e=="number"?t=e:typeof e=="string"&&(t=parseInt(e))}let n=0;for(let r=0;r<i.length;r++){let s={" ":-1,"\xA0":-1,"\u2000":-1,"\u2001":-1,"\u2002":-1,"\u2003":-1,"\u2004":-1,"\u2005":-1,"\u2006":-1,"\u2007":-1,"\u2008":-1,"\u2009":-1,"\u200A":-1,"\u200B":-1,"\u202F":-1,"\u205F":-1,_:-1,",":-1,0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,g:16,h:17,i:18,j:19,k:20,l:21,m:22,n:23,o:24,p:25,q:26,r:27,s:28,t:29,u:30,v:31,w:32,x:33,y:34,z:35}[i[r]];if(s!==-1){if(s===void 0)return[n,i.substring(r)];if(s>=t)return[n,i.substring(r)];n=n*t+s}}return[n,""]}function x(i,e){if(typeof e=="number"&&typeof i=="number")return i.toFixed(e);let t=i.toString();if(typeof i=="number"&&Number.isInteger(i)&&t.includes("e")){let n=BigInt(i).toString(),r=n.match(/0+$/);if((r?r[0].length:0)<=5)return n}else if(typeof i=="bigint"){let n=t.match(/0+$/),r=n?n[0].length:0;if(r>5)return`${t.slice(0,-r)}e+${r}`}return t}function Fr(i){if(typeof i=="number")return Number.isInteger(i)?BigInt(i):null;if(i==null||!Vt(i))return null;let e=qi(i)?i.num:i;if(typeof e=="number")return Number.isInteger(e)?BigInt(e):null;if(typeof e!="string")return null;let t=e.toLowerCase().replace(/[nd]$/,"").replace(/[\u0009-\u000d\u0020\u00a0]/g,"");return t==="nan"||/^(infinity|\+infinity|oo|\+oo|-infinity|-oo)$/.test(t)?null:V(t)}function O(i,e){if(typeof i=="number")return isNaN(i)?"NaN":Number.isFinite(i)?typeof e=="number"?{num:i.toFixed(e)}:i:i<0?"NegativeInfinity":"PositiveInfinity";if(i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER)return Number(i);let t=x(i);return Number(i).toString()===t?Number(i):{num:t}}var He=["number","finite_number","complex","finite_complex","imaginary","real","finite_real","rational","finite_rational","integer","finite_integer","non_finite_number"],Li=["indexed_collection","list","tuple"],Ke=[...Li,"collection","set","record","dictionary"],Qe=["scalar",...He,"boolean","string"],Gi=["value","color",...Ke,...Qe],Yi=["expression","symbol","function",...Gi],Ui=["any","unknown","nothing","never","error",...Yi],_t=new Set(He),qt=new Set(Ke),Zt=new Set(Qe),me=new Set(Ui);function Lt(i){return typeof i=="string"?me.has(i):typeof i!="object"||!("kind"in i)?!1:i.kind==="signature"||i.kind==="union"||i.kind==="intersection"||i.kind==="negation"||i.kind==="value"||i.kind==="tuple"||i.kind==="list"||i.kind==="record"||i.kind==="dictionary"||i.kind==="set"||i.kind==="symbol"||i.kind==="expression"||i.kind==="numeric"||i.kind==="collection"||i.kind==="indexed_collection"||i.kind==="reference"}var ze=class{input;pos=0;line=1;column=1;tokens=[];constructor(e){this.input=e}saveState(){return{pos:this.pos,line:this.line,column:this.column,tokens:[...this.tokens]}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column,this.tokens=e.tokens}error(e){throw new Error(`Lexer error at line ${this.line}, column ${this.column}: ${e}`)}peek(e=0){let t=this.pos+e;return t<this.input.length?this.input[t]:""}advance(){let e=this.input[this.pos++];return e===`
3
+ "use strict";var Numerics=(()=>{var Ti=Object.defineProperty;var Un=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var jn=Object.prototype.hasOwnProperty;var $n=(i,e)=>{for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},Wn=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jn(e))!jn.call(i,r)&&r!==t&&Ti(i,r,{get:()=>e[r],enumerable:!(n=Un(e,r))||n.enumerable});return i};var Xn=i=>Wn(Ti({},"__esModule",{value:!0}),i);var Us={};$n(Us,{BigNumericValue:()=>ni,DEFAULT_PRECISION:()=>Tt,DEFAULT_TOLERANCE:()=>Di,ExactNumericValue:()=>X,LARGEST_SMALL_PRIME:()=>bt,MACHINE_PRECISION:()=>vt,MACHINE_PRECISION_BITS:()=>Si,MAX_BIGINT_DIGITS:()=>Et,MAX_ITERATION:()=>Mt,MAX_SYMBOLIC_TERMS:()=>Bt,MachineNumericValue:()=>ri,NumericValue:()=>R,SMALL_INTEGER:()=>P,add:()=>ne,airyAi:()=>Fn,airyBi:()=>Cn,areCompatibleUnits:()=>ls,asMachineRational:()=>kr,besselI:()=>oe,besselJ:()=>H,besselK:()=>An,besselY:()=>hi,beta:()=>Sn,bigBeta:()=>wn,bigDigamma:()=>Xi,bigGamma:()=>vn,bigGammaln:()=>Tn,bigInterquartileRange:()=>us,bigKurtosis:()=>is,bigLambertW:()=>Pn,bigMean:()=>Xr,bigMedian:()=>oi,bigMode:()=>ss,bigPolygamma:()=>Bn,bigPopulationStandardDeviation:()=>zr,bigPopulationVariance:()=>ln,bigPrimeFactors:()=>Pi,bigQuartiles:()=>fn,bigSkewness:()=>ns,bigStandardDeviation:()=>Kr,bigTrigamma:()=>Hi,bigVariance:()=>an,bigZeta:()=>kn,bigint:()=>V,bigintCanonicalInteger:()=>Me,bigintFactorial:()=>Ai,bigintGcd:()=>ie,bigintLcm:()=>Je,bigintValue:()=>Or,bignumFactorial2:()=>nn,bignumGcd:()=>ji,bignumLcm:()=>tn,canonicalInteger:()=>ee,cantorEnumerateComplexNumbers:()=>At,cantorEnumerateIntegers:()=>Ot,cantorEnumerateNaturalNumbers:()=>Ft,cantorEnumeratePositiveRationals:()=>Rt,cantorEnumerateRationals:()=>Dt,centeredDiff8thOrder:()=>St,chop:()=>Pt,complexGamma:()=>et,complexGammaln:()=>it,convertCompoundUnit:()=>Ns,convertUnit:()=>Nn,determinant:()=>on,digamma:()=>pi,dimensionsEqual:()=>mi,div:()=>wr,erf:()=>Ni,erfInv:()=>In,erfc:()=>$i,extrapolate:()=>Le,factorial:()=>kt,factorial2:()=>xt,findNamedUnit:()=>fs,fresnelC:()=>Gn,fresnelS:()=>Ln,fromDigits:()=>_i,gamma:()=>G,gammaln:()=>he,gcd:()=>_,getExpressionDimension:()=>re,getExpressionScale:()=>se,getUnitDimension:()=>li,getUnitScale:()=>hn,interquartileRange:()=>os,interval:()=>Yr,intervalContains:()=>Ur,intervalSubset:()=>Jr,inverse:()=>we,isBigRational:()=>je,isDimensionless:()=>as,isInMachineRange:()=>xe,isInteger:()=>W,isMachineRational:()=>A,isNeg:()=>Br,isNegativeOne:()=>Xe,isOne:()=>We,isPositive:()=>$e,isPrime:()=>gr,isPrimeBigint:()=>yt,isRational:()=>vr,isZero:()=>te,kurtosis:()=>es,lambertW:()=>Dn,lcm:()=>Ue,limit:()=>Ye,machineDenominator:()=>Mr,machineNumerator:()=>Er,mean:()=>Wr,median:()=>si,modPow:()=>It,mode:()=>rs,monteCarloEstimate:()=>$r,mul:()=>L,neg:()=>Fi,nextDown:()=>wt,nextUp:()=>Ri,numberToExpression:()=>O,numberToString:()=>x,parseUnitDSL:()=>hs,polygamma:()=>Ki,populationStandardDeviation:()=>Qr,populationVariance:()=>cn,pow:()=>xr,primeFactors:()=>Ge,quartiles:()=>mn,rationalAsFloat:()=>Oi,rationalGcd:()=>Ci,rationalize:()=>Sr,reduceRationalSquareRoot:()=>Dr,reducedInteger:()=>Ct,reducedRational:()=>Be,sinc:()=>Yn,skewness:()=>ts,sqrt:()=>Pr,standardDeviation:()=>Hr,trigamma:()=>gi,variance:()=>un,version:()=>Ys,zeta:()=>Qi});var R=class{get bignumRe(){}im;get bignumIm(){}isZeroWithTolerance(e){return this.isZero}valueOf(){return this.im===0?this.bignumRe?this.bignumRe.toNumber():this.re:this.toString()}[Symbol.toPrimitive](e){return e==="string"?this.toString():this.valueOf()}toJSON(){if(this.im===0){let e=this.re;if(Number.isFinite(e))return e}return this.N().toString()}print(){let e=console.log;e?.(this.toString())}};var tt=new Map,Hn=1e5;function E(i){if(i<=Hn){let e=tt.get(i);return e===void 0&&(e=10n**BigInt(i),tt.set(i,e)),e}return 10n**BigInt(i)}function J(i){if(i<0n&&(i=-i),i===0n)return 0;let e=0,t=1;for(;i>>BigInt(t)>0n;)t*=2;for(let n=t>>1;n>=1;n>>=1)i>>BigInt(n)>0n&&(e+=n,i>>=BigInt(n));return e+1}function st(i,e,t){return i*e>>BigInt(t)}function ot(i,e,t){return(i<<BigInt(t))/e}function Ie(i,e){if(i===0n)return 0n;if(i<0n)throw new RangeError("fpsqrt: negative input");let t=i<<BigInt(e),n;if(e<Kn){n=Mi(t);let a;do a=n,n=(n+t/n)/2n;while(F(n-a)>1n)}else n=Bi(t,J(t));let r=(n+t/n)/2n,s=F(n*n-t);return F(r*r-t)<s?r:n}function Mi(i){let e=J(i);if(e<=1023){let o=Math.sqrt(Number(i));if(Number.isFinite(o)&&o>=1)return BigInt(Math.floor(o))}let t=e-52,n=Number(i>>BigInt(t)),r=Math.sqrt(n);t&1&&(r*=Math.SQRT2);let s=BigInt(Math.round(r))<<BigInt(t>>1);return s>0n?s:1n}var ut=1024,Kn=640;function Bi(i,e){if(e<ut){let s=Mi(i),o;do o=s,s=(s+i/s)/2n;while(F(s-o)>1n);for(;s*s>i;)s-=1n;for(;(s+1n)*(s+1n)<=i;)s+=1n;return s}let t=e>>2<<1,n=Bi(i>>BigInt(t),e-t)<<BigInt(t>>1),r;do r=n,n=(n+i/n)/2n;while(F(n-r)>1n);for(;n*n>i;)n-=1n;for(;(n+1n)*(n+1n)<=i;)n+=1n;return n}function F(i){return i<0n?-i:i}function k(i){if(i===0n)return 1;if(i<0n&&(i=-i),i<0x20000000000000n)return Math.floor(Math.log10(Number(i)))+1;let e=0,t=i,n=1;for(;t>>BigInt(n)>0n;)n*=2;for(let s=n>>1;s>=1;s>>=1)t>>BigInt(s)>0n&&(e+=s,t>>=BigInt(s));e+=1;let r=Math.ceil(e*.30102999566398);return i<E(r-1)?r-1:i>=E(r)?r+1:r}function Re(i,e){let t=BigInt(e),n=1n<<t;if(i===0n)return n;let r=0,s=i,o=n>>1n;for(;F(s)>o;)s=s/2n,r++;let a=n,c=s;a+=c;for(let l=2;c=(c*s>>t)/BigInt(l),c!==0n;l++)a+=c;for(let l=0;l<r;l++)a=a*a>>t;return a}var Qn=2300;function wi(i,e){let t=1n<<BigInt(e);if(i<=0n)throw new RangeError("fpln: input must be positive");return i===t?0n:e>=Qn?ir(i,e):zn(i,e)}function zn(i,e){let t=BigInt(e),n=1n<<t,r=Number(i),s=Number(n),o,a=i,c=0,l=2;if(Number.isFinite(r)&&Number.isFinite(s)&&r>0&&s>0){let f=r/s;if(Number.isFinite(f)&&f>0){let d=Math.log(f);Number.isFinite(d)?(o=BigInt(Math.round(d*s)),l=48):o=vi(i,e)}else o=vi(i,e)}else{a=i;let f=n<<1n,d=n>>1n;for(;a>f||a<d;)a=Ie(a,e),c++;o=vi(a,e)}for(let f=Math.min(e,Math.max(8,2*l));f<e;){let d=BigInt(f),h=BigInt(e-f),N=o>>h,p=Re(N,f);if(p===0n){o=o/2n;continue}let g=a>>h;o=N+(g<<d)/p-(1n<<d)<<h,f=Math.min(e,2*f)}let m=0n;for(let f=0;f<100;f++){let d=Re(o,e);if(d===0n){o=o/2n;continue}let h=o+(a<<t)/d-n,N=F(h-o);if(N<=1n||N<100000n&&m>0n&&m<100000n&&N*4n>=m)break;m=N,o=h}for(let f=0;f<c;f++)o=2n*o;return o}var K=null;function er(i){if(K!==null){if(K.bits===i)return K.value;if(K.bits>i)return K.value>>BigInt(K.bits-i)}let e=Math.ceil(i*Fe)+12,t;if(e<=rt.length){let n=rt.slice(0,e);t=(BigInt(n)<<BigInt(i))/E(n.length)}else t=ur(i);return K={bits:i,value:t},t}function ir(i,e){let t=BigInt(e),n=J(i)-e,r=Math.max(2,Math.ceil(e/2+4-n)),s=i<<BigInt(r-2),o=1n<<t,a=s;for(;F(o-a)>1n;){let l=o+a>>1n;a=Te(o*a),o=l}return Oe(e)*s/(2n*o)-BigInt(r)*er(e)}var nt=6243314768165359n;function vi(i,e){let t=BigInt(J(i)-e);return e>=53?t*nt<<BigInt(e-53):t*nt>>BigInt(53-e)}var ce="314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635",Fe=Math.log10(2),rt="693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095326366642654104239157814952043740430385500801944170641671518644712839968171784546957026271631064546150257207402481637773389638550695260668341137273873722928956493547025762652098859693201965058554764703306793654432547632744951250406069438147104689946506220167720424524529612687946546193165174681392672504103802546259656869144192871608293803172714367782654877566485085674077648451464439940461422603193096735402574446070308096085047486638523138181676751438667476647890881437141985494231519973548803751658612753529166100071053558249879414729509293113897155998205654392871700072180857610252368892132449713893203784393530887748259701715591070882368362758984258918535302436342143670611892367891923723146723217205340164925687274778234453534764811494186423867767744060695626573796008670762571991847340226514628379048830620330611446300737194890027436439650025809365194430411911506080948793067865158870900605203468429736193841289652556539686022194122924207574321757489097706752687115817051137009158942665478595964890653058460258668382940022833005382074005677053046787001841624044188332327983863490015631218895606505531512721993983320307514084260914790012651682434438935724727882054862715527418772430024897945401961872339808608316648114909306675193393128904316413706813977764981769748689038877899912965036192707108892641052309247839173735012298424204995689359922066022046549415106139187885744245577510206837030866619480896412186807790208181588580001688115973056186676199187395200766719214592236720602539595436541655311295175989940056000366513567569051245926825743946483168332624901803824240824231452306140963805700702551387702681785163069025513703234053802145019015374029509942262995779647427138157363801729873940704242179972266962979939312706935747240493386530879758721699645129446491883771156701678598804981838896784134938314014073166472765327635919233511233389338709513209059272185471328975470797891384445466676192702885533423429899321803769154973340267546758873236778342916191810430116091695265547859732891763545556742863877463987101912431754255888301206779210280341206879759143081283307230300883494705792496591005860012341561757413272465943",tr=13591409n,nr=545140134n,rr=10939058860032000n,sr=47.11;function Ae(i,e){if(e-i===1){let l,m;if(i===0)l=1n,m=1n;else{l=BigInt(6*i-5)*BigInt(2*i-1)*BigInt(6*i-1);let d=BigInt(i);m=d*d*d*rr}let f=l*(tr+nr*BigInt(i));return i&1&&(f=-f),[l,m,f]}let t=i+e>>1,[n,r,s]=Ae(i,t),[o,a,c]=Ae(t,e);return[n*o,r*a,a*s+n*c]}function at(i){return Math.max(2,Math.floor(i/sr)+3)}function or(i){let[,e,t]=Ae(0,at(i)),n=1n<<BigInt(i),r=Te(10005n*n*n);return e*426880n*r/t}function ct(i){let[,e,t]=Ae(0,at(Math.ceil(i/Fe))),n=E(i),r=Te(10005n*n*n);return e*426880n*r/t}function Ei(i,e){if(e-i===1){let l=i===0?1n:BigInt(2*i-1),m=i===0?1n:9n*BigInt(2*i+1);return[l,m,l]}let t=i+e>>1,[n,r,s]=Ei(i,t),[o,a,c]=Ei(t,e);return[n*o,r*a,a*s+n*c]}function ur(i){let e=Math.max(2,Math.ceil(i/3.169925)+5),[,t,n]=Ei(0,e);return(n<<BigInt(i+1))/(3n*t)}function Te(i){if(i<0n)throw new RangeError("bigintSqrt: negative input");if(i===0n)return 0n;let e=J(i);if(e>=ut)return Bi(i,e);let t=Mi(i),n;do n=t,t=(t+i/t)/2n;while(F(t-n)>1n);for(;t*t>i;)t-=1n;for(;(t+1n)*(t+1n)<=i;)t+=1n;return t}var Q=null;function Oe(i){if(Q!==null){if(Q.bits===i)return Q.value;if(Q.bits>i)return Q.value>>BigInt(Q.bits-i)}let e=ar(i);return Q={bits:i,value:e},e}function ar(i){let e=Math.ceil(i*Fe)+12;if(e+1<=ce.length){let t=ce.slice(0,e+1);return(BigInt(t)<<BigInt(i))/E(t.length-1)}return or(i)}function Ce(i,e){let t=BigInt(e),n=1n<<t;if(i===0n)return[0n,n];let r=Oe(e),s=2n*r,o=r/2n,a,c=F(i);if(c>n<<30n){let B=J(c)-e+64,Y=e+B,S=i<<BigInt(B),be=2n*Oe(Y),Ii=S%be;Ii<0n&&(Ii+=be),a=Ii>>BigInt(B)}else a=i%s;a<0n&&(a+=s);let l=1n,m=1n;a>3n*o?(a=s-a,l=-1n):a>r?(a=a-r,l=-1n,m=-1n):a>o&&(a=r-a,m=-1n);let f=Math.round(e*Fe),d=Math.min(18,Math.max(2,Math.ceil(.87*Math.sqrt(f)))),h=0,N=n>>BigInt(d);for(;a>N;)a=a/2n,h++;let p=a,g=n,b=a,T=n,y=a*a,w=2n*t;for(let B=2;;B+=2){if(T=(T*y>>w)/(BigInt(B)*BigInt(B-1)),T===0n){b=(b*y>>w)/(BigInt(B+1)*BigInt(B)),b!==0n&&(B%4===2?(g-=T,p-=b):(g+=T,p+=b));break}if(b=(b*y>>w)/(BigInt(B+1)*BigInt(B)),B%4===2?(g-=T,p-=b):(g+=T,p+=b),b===0n)break}for(let B=0;B<h;B++){let Y=2n*p*g>>t,S=(2n*g*g>>t)-n;p=Y,g=S}return[l*p,m*g]}function ye(i,e){if(i===0n)return 0n;if(i<0n)return-ye(-i,e);let t=BigInt(e),n=1n<<t,s=Oe(e)/2n;if(i>n){let h=(n<<t)/i;return s-ye(h,e)}let o=4n*n/10n,a=0,c=i;for(;c>o;){let h=c*c,N=(n<<t)+h>>t,p=Ie(N,e);c=(c<<t)/(n+p),a++}let l=c,m=c,f=c*c,d=2n*t;for(let h=3;m=m*f>>d,m!==0n;h+=2)h%4===3?l-=m/BigInt(h):l+=m/BigInt(h);for(let h=0;h<a;h++)l=2n*l;return l}var ki=NaN,u=class i{static precision=50;static ZERO=Object.freeze(Object.assign(Object.create(i.prototype),{significand:0n,exponent:0}));static ONE=Object.freeze(Object.assign(Object.create(i.prototype),{significand:1n,exponent:0}));static TWO=Object.freeze(Object.assign(Object.create(i.prototype),{significand:2n,exponent:0}));static NEGATIVE_ONE=Object.freeze(Object.assign(Object.create(i.prototype),{significand:-1n,exponent:0}));static HALF=Object.freeze(Object.assign(Object.create(i.prototype),{significand:5n,exponent:-1}));static NAN=Object.freeze(Object.assign(Object.create(i.prototype),{significand:0n,exponent:NaN}));static POSITIVE_INFINITY=Object.freeze(Object.assign(Object.create(i.prototype),{significand:1n,exponent:1/0}));static NEGATIVE_INFINITY=Object.freeze(Object.assign(Object.create(i.prototype),{significand:-1n,exponent:1/0}));static _piFullPrecision=null;static _piCache=null;static _piCachePrecision=0;static _eulerGammaCache=null;static _eulerGammaCachePrecision=0;static get PI(){let e=i.precision;if(i._piCache!==null&&i._piCachePrecision===e)return i._piCache;let t=e+4,n;if(t+1<=ce.length)i._piFullPrecision===null&&(i._piFullPrecision=new i(ce[0]+"."+ce.slice(1))),n=i._piFullPrecision.toPrecision(t);else{let r=t+4;n=v(ct(r),-r).toPrecision(t)}return i._piCache=n,i._piCachePrecision=e,n}static get EULER_GAMMA(){let e=i.precision;if(i._eulerGammaCache!==null&&i._eulerGammaCachePrecision>=e)return i._eulerGammaCache.toPrecision(e);let t=mr(e);return i._eulerGammaCache=t,i._eulerGammaCachePrecision=e,t}significand;exponent;constructor(e){if(e instanceof i){this.significand=e.significand,this.exponent=e.exponent;return}if(typeof e=="bigint"){[this.significand,this.exponent]=Ve(e,0);return}if(typeof e=="number"){[this.significand,this.exponent]=fr(e);return}[this.significand,this.exponent]=dt(e)}isNaN(){return Number.isNaN(this.exponent)}isZero(){return this.exponent===0&&this.significand===0n}isFinite(){return Number.isFinite(this.exponent)}isInteger(){return this.isFinite()&&this.exponent>=0}isPositive(){return this.significand>0n}isNegative(){return this.significand<0n}cmp(e){if(typeof e=="number"){if(Number.isNaN(e))return ki;let h=this.exponent;if(Number.isNaN(h))return ki;if(e===0)return this.significand===0n?0:this.significand>0n?1:-1;if(!Number.isFinite(h))return e===1/0?this.significand>0n?0:-1:e===-1/0?this.significand<0n?0:1:this.significand>0n?1:-1;if(this.significand===0n)return e>0?-1:1;if(e===1/0)return-1;if(e===-1/0)return 1;if(this.significand>0n!=e>0)return this.significand>0n?1:-1;if(Number.isInteger(e)&&h>=0&&h<=15){let N=this.significand*E(h),p=BigInt(e);return N<p?-1:N>p?1:0}e=new i(e)}let t=this.exponent,n=e.exponent,r=this.significand,s=e.significand;if(t!==t||n!==n)return ki;if(!Number.isFinite(t)||!Number.isFinite(n))return!Number.isFinite(t)&&!Number.isFinite(n)?r===s?0:r>s?1:-1:Number.isFinite(t)?s>0n?-1:1:r>0n?1:-1;if(r===0n)return s===0n?0:s>0n?-1:1;if(s===0n)return r>0n?1:-1;if(r>0n&&s<0n)return 1;if(r<0n&&s>0n)return-1;if(t===n)return r<s?-1:r>s?1:0;let o=k(r),a=k(s),c=o+t,l=a+n;if(c!==l){let h=r>0n?1:-1;return c>l?h:-h}let m=r,f=s,d=Math.abs(t-n);if(d>1e3){let h=o,N=a,p=Math.max(h,N)+1;h<p&&(m=m*E(p-h)),N<p&&(f=f*E(p-N))}else t<n?f=f*E(d):m=m*E(d);return m<f?-1:m>f?1:0}eq(e){return typeof e=="number"?e===0?this.significand===0n&&this.exponent===0:e===1?this.significand===1n&&this.exponent===0:e===-1?this.significand===-1n&&this.exponent===0:Number.isInteger(e)&&Number.isFinite(this.exponent)&&this.exponent>=0&&this.exponent<=15?this.significand*E(this.exponent)===BigInt(e):this.cmp(e)===0:this.significand===e.significand&&this.exponent===e.exponent}lt(e){return this.cmp(e)===-1}lte(e){let t=this.cmp(e);return t===-1||t===0}gt(e){return this.cmp(e)===1}gte(e){let t=this.cmp(e);return t===1||t===0}add(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(t===n)return v(this.significand+e.significand,t);let o=t-n;return o>0?v(this.significand*E(o)+e.significand,n):v(this.significand+e.significand*E(-o),t)}if(t!==t||n!==n)return i.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(n);return r&&s?this.significand!==e.significand?i.NAN:this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:r?this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:e.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}sub(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(t===n)return v(this.significand-e.significand,t);let o=t-n;return o>0?v(this.significand*E(o)-e.significand,n):v(this.significand-e.significand*E(-o),t)}if(t!==t||n!==n)return i.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(n);return r&&s?this.significand===e.significand?i.NAN:this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:r?this.significand>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY:e.significand>0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY}mul(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n))return v(this.significand*e.significand,t+n);if(t!==t||n!==n||this.significand===0n||e.significand===0n)return i.NAN;let r=this.significand>0n?1n:-1n,s=e.significand>0n?1n:-1n;return r*s>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}neg(){let e=this.significand;return e===0n?this:Number.isFinite(this.exponent)?v(-e,this.exponent):e>0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY}abs(){return this.significand>=0n?this:Number.isFinite(this.exponent)?v(-this.significand,this.exponent):i.POSITIVE_INFINITY}floor(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.trunc();return this.significand<0n?t.sub(v(1n,0)):t}return this}ceil(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.trunc();return this.significand>0n?t.add(v(1n,0)):t}return this}round(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=v(5n,-1);return this.significand>0n?this.add(t).trunc():this.sub(t).trunc()}return this}trunc(){let e=this.exponent;if(e>=0)return this;if(Number.isFinite(e)){let t=this.significand/E(-e);return v(t===0n?0n:t,0)}return this}div(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent,r=this.significand,s=e.significand;if(Number.isFinite(t)&&Number.isFinite(n)){if(s===0n)return r===0n?i.NAN:r>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY;if(r===0n)return v(0n,0);let c=i.precision,l=10,m=r<0n?-r:r,f=s<0n?-s:s,d=k(m),h=k(f),N=c+l+Math.max(0,h-d),p=E(N),g=r*p/s,b=t-n-N;return v(g,b).toPrecision(c)}if(t!==t||n!==n)return i.NAN;let o=!Number.isFinite(t),a=!Number.isFinite(n);if(o&&a)return i.NAN;if(o){let c=r>0n?1n:-1n,l=s>0n?1n:s<0n?-1n:1n;return c*l>0n?i.POSITIVE_INFINITY:i.NEGATIVE_INFINITY}return v(0n,0)}inv(){return v(1n,0).div(this)}divToward(e,t){typeof e=="number"&&(e=new i(e));let n=this.exponent,r=e.exponent,s=this.significand,o=e.significand;if(!Number.isFinite(n)||!Number.isFinite(r)||o===0n||s===0n)return this.div(e);let a=s<0n!=o<0n,c=s<0n?-s:s,l=o<0n?-o:o,m=i.precision,d=m+10+Math.max(0,k(l)-k(c)),h=c*E(d),N=h/l,p=h%l!==0n,g=n-r-d,b=a?t==="floor":t==="ceiling",[T,y]=lt(N,p,g,m,b);return v(a?-T:T,y)}sqrtToward(e){if(this.significand===0n)return this.exponent!==this.exponent?this:i.ZERO;if(!Number.isFinite(this.exponent))return this.significand>0n?i.POSITIVE_INFINITY:i.NAN;if(this.significand<0n)return i.NAN;let t=i.precision,n=4,r=this.significand,s=this.exponent,o=s+k(r)-1,a=Math.floor(o/2),c=t+n-a;s+2*c<0&&(c=Math.ceil(-s/2)+1);let l=s+2*c,m=l>=0?r*E(l):r/E(-l),f=Te(m),d=f*f!==m,[h,N]=lt(f,d,-c,t,e==="ceiling");return v(h,N)}mod(e){typeof e=="number"&&(e=new i(e));let t=this.exponent,n=e.exponent;if(Number.isFinite(t)&&Number.isFinite(n)){if(e.significand===0n)return i.NAN;if(this.significand===0n)return v(0n,0);let r=t-n,s=r>=0?this.significand*E(r):this.significand,o=r>=0?e.significand:e.significand*E(-r),a=s/o;return this.sub(v(a,0).mul(e))}return t!==t||n!==n||!Number.isFinite(t)?i.NAN:new i(this)}pow(e){if(typeof e=="number"&&(e=new i(e)),this.isNaN()||e.isNaN()||!e.isFinite())return i.NAN;if(e.isInteger()){let l=e.toBigInt();if(l===0n)return v(1n,0);if(!this.isFinite())return l>0n?this.significand<0n&&l%2n!==0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY:v(0n,0);if(this.isZero())return l>0n?v(0n,0):i.POSITIVE_INFINITY;if(l<0n)return this.pow(e.neg()).inv();let m=this.significand<0n?-this.significand:this.significand,f=k(m),d=f>15?f-15:0,h=d>0?Number(m/10n**BigInt(d)):Number(m),N=Math.log10(h)+d+this.exponent,p=Number(l)*N;if(p>9e15)return this.significand<0n&&l%2n!==0n?i.NEGATIVE_INFINITY:i.POSITIVE_INFINITY;if(p<-9e15)return v(0n,0);let g=i.precision,b=v(1n,0),T=this,y=l;for(;y>0n;)y&1n&&(b=b.mul(T).toPrecision(g)),y>>=1n,y>0n&&(T=T.mul(T).toPrecision(g));return b}if(!this.isFinite())return this.significand<0n?i.NAN:e.significand>0n?i.POSITIVE_INFINITY:i.ZERO;if(this.isZero())return e.significand>0n?i.ZERO:i.POSITIVE_INFINITY;if(this.significand<0n)return i.NAN;let t=this.significand,n=this.exponent+k(t)-1,r=e.significand<0n?-e.significand:e.significand,o=e.exponent+k(r)-1+Math.log10(Math.abs(n)*2.303+3)+1,a=Math.min(20,Math.max(2,Math.ceil(o)+2)),c=i.precision;i.precision=c+a;try{let l=lr(this,c+a);return e.mul(l).exp().toPrecision(c)}finally{i.precision=c}}toNumber(){return Number.isFinite(this.exponent)?this.significand===0n?0:this.exponent===0?Number(this.significand):Number(this.toString()):this.exponent!==this.exponent?NaN:this.significand>0n?1/0:-1/0}toString(){if(!Number.isFinite(this.exponent))return this.exponent!==this.exponent?"NaN":this.significand>0n?"Infinity":"-Infinity";if(this.significand===0n)return"0";let e=this.significand<0n,t=(e?-this.significand:this.significand).toString(),n=t.length,r=n+this.exponent-1,s=e?"-":"";if(r>20||r<-6){let c=n===1?t:t[0]+"."+t.slice(1),l=r>=0?"+":"";return`${s}${c}e${l}${r}`}if(this.exponent>=0)return s+t+"0".repeat(this.exponent);let o=-this.exponent;if(o<n){let c=t.slice(0,n-o),l=t.slice(n-o);return`${s}${c}.${l}`}let a=o-n;return`${s}0.${"0".repeat(a)}${t}`}toFixed(e){let t=e??0;if(!Number.isFinite(this.exponent))return this.exponent!==this.exponent?"NaN":this.significand>0n?"Infinity":"-Infinity";let n=this.significand<0n,r=n?-this.significand:this.significand,s=this.exponent+t,o;if(s>=0)o=r*E(s);else{let f=E(-s),d=r/f,h=r%f,N=f/2n;h>N?o=d+1n:h<N||f%2n!==0n||d%2n===0n?o=d:o=d+1n}let a=n&&o!==0n?"-":"",c=o.toString();if(t===0)return`${a}${c}`;if(c.length<=t){let f=c.padStart(t,"0");return`${a}0.${f}`}let l=c.slice(0,c.length-t),m=c.slice(c.length-t);return`${a}${l}.${m}`}toPrecision(e){if(this.significand===0n||!Number.isFinite(this.exponent))return this;let t=this.significand<0n?-this.significand:this.significand,n=k(t);if(n<=e)return this;let r=n-e,s=E(r),o=t/s,a=t-o*s,c=s/2n;(a>c||a===c&&o%2n!==0n)&&(o+=1n);let l=this.significand<0n?-o:o;return v(l,this.exponent+r)}toBigInt(){if(!Number.isFinite(this.exponent))throw this.exponent!==this.exponent?new RangeError("Cannot convert NaN to BigInt"):new RangeError("Cannot convert Infinity to BigInt");if(this.exponent>=0)return this.significand*E(this.exponent);let e=E(-this.exponent);return this.significand/e}},cr=8,ve=[];function lr(i,e){let t=i.significand,n=i.exponent;for(let s=ve.length-1;s>=0;s--){let o=ve[s];if(o.prec===e&&o.exp===n&&o.sig===t)return o.ln}let r=i.ln();return ve.push({sig:t,exp:n,prec:e,ln:r}),ve.length>cr&&ve.shift(),r}function mr(i){let e=i+20+Math.ceil(Math.log10(i+10)),t=u.precision;u.precision=e;try{let n=Math.ceil(e*Math.LN10/4)+5,r=new u(n),s=r.mul(r),o=u.ONE,a=u.ONE,c=u.ZERO,l=u.ZERO,m=u.ONE.div(new u(10).pow(e)),f=6*n+100;for(let d=1;d<=f;d++){let h=new u(d).mul(d);if(o=o.mul(s).div(h).toPrecision(e),l=l.add(u.ONE.div(d)).toPrecision(e),a=a.add(o).toPrecision(e),c=c.add(o.mul(l)).toPrecision(e),d>n&&o.lt(a.mul(m)))break}return c.div(a).sub(r.ln()).toPrecision(i)}finally{u.precision=t}}function v(i,e){let[t,n]=Ve(i,e),r=Object.create(u.prototype);return r.significand=t,r.exponent=n,r}function lt(i,e,t,n,r){if(i===0n)return[r&&e?1n:0n,t];let s=k(i);if(s<=n)return[r&&e?i+1n:i,t];let o=s-n,a=E(o),c=i/a,l=e||i%a!==0n;return r&&l&&(c+=1n),[c,t+o]}var mt=1000000000n,ft=1000n;function Ve(i,e){if(i===0n)return[0n,0];for(;i%mt===0n;)i/=mt,e+=9;for(;i%ft===0n;)i/=ft,e+=3;for(;i%10n===0n;)i/=10n,e+=1;return[i,e]}function fr(i){return Number.isNaN(i)?[0n,NaN]:i===1/0?[1n,1/0]:i===-1/0?[-1n,1/0]:Number.isInteger(i)?Ve(BigInt(i),0):dt(i.toString())}function dt(i){if(i=i.trim(),i===""||i==="NaN")return[0n,NaN];if(i==="Infinity"||i==="+Infinity")return[1n,1/0];if(i==="-Infinity")return[-1n,1/0];let e,t=0,n=i.search(/[eE]/);if(n!==-1){if(e=i.slice(0,n),t=Number(i.slice(n+1)),!Number.isFinite(t))return[0n,NaN]}else e=i;let r=!1;e.startsWith("-")?(r=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let s=e.indexOf("."),o,a;s===-1?(o=e,a=""):(o=e.slice(0,s),a=e.slice(s+1)),o=o.replace(/^0+/,"")||"0";let c=o+a;if(c.length===0||!/^\d+$/.test(c))return[0n,NaN];let l=BigInt(c);r&&(l=-l);let m=-a.length;return Ve(l,m+t)}var dr=Math.log2(10),hr=Math.log10(2),Nr=16,xi=1e6;function j(i,e){let t=Math.ceil(e*dr)+Nr,n=BigInt(t);return i.exponent>=0?[i.significand*E(i.exponent)<<n,t]:[(i.significand<<n)/E(-i.exponent),t]}function $(i,e,t){if(i===0n)return u.ZERO;let n=i<0n,r=n?-i:i,s=BigInt(e),o=J(r)-e,a=Math.floor(o*hr),c=t+4-a,l,m;if(c>=0)l=r*E(c)+(1n<<s-1n)>>s,m=-c;else{let d=E(-c)<<s;l=(r+d/2n)/d,m=-c}if(l===0n)return u.ZERO;let f=k(l);if(f>t){let d=f-t,h=E(d),N=h/2n,p=l%h;l=l/h,p>=N&&(l+=1n),m+=d}return v(n?-l:l,m)}function C(i){let e=i.significand<0n?-i.significand:i.significand;return i.exponent+k(e)-1}var ht=BigInt(Number.MAX_SAFE_INTEGER),z=null;function pt(i){if(z!==null){if(z.bits===i)return z.value;if(z.bits>i)return z.value>>BigInt(z.bits-i)}let e=wi(10n<<BigInt(i),i);return z={bits:i,value:e},e}u.prototype.sqrt=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.significand<0n)return u.NAN;let i=u.precision,e=i+10,t=C(this),n=Math.floor(t/2),r=v(this.significand,this.exponent-2*n),[s,o]=j(r,e),a=Ie(s,o),c=$(a,o,i);return v(c.significand,c.exponent+n)};u.prototype.cbrt=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;if(this.significand<0n)return this.neg().cbrt().neg();let i=u.precision,e=i+10,t=C(this),n=Math.floor(t/3),r=v(this.significand,this.exponent-3*n),[s,o]=j(r,e),a=s<<BigInt(2*o),c,l=r.toNumber();if(o<=1e3&&Number.isFinite(l)&&l>0){let d=Number(1n<<BigInt(o)),h=Math.cbrt(l);Number.isFinite(h)&&h>0?(c=BigInt(Math.floor(h*d)),c===0n&&(c=1n)):c=Nt(a)}else c=Nt(a);let m;do{m=c;let d=c*c;if(d===0n){c=1n;break}c=(2n*c+a/d)/3n}while(F(c-m)>1n);{let d=(2n*c+a/(c*c))/3n,h=F(c*c*c-a);F(d*d*d-a)<h&&(c=d)}let f=$(c,o,i);return v(f.significand,f.exponent+n)};u.sqrt=function(i){return i.sqrt()};u.cbrt=function(i){return i.cbrt()};u.prototype.exp=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.ZERO;if(this.isZero())return u.ONE;if(C(this)>=17)return this.significand>0n?u.POSITIVE_INFINITY:u.ZERO;let i=u.precision,e=this.significand<0n?-this.significand:this.significand,t=Math.max(0,this.exponent+k(e)),n=i+20+t,[r,s]=j(this,n),o=pt(s),a=r/o,c=r-a*o;if(c<0n&&(a-=1n,c+=o),a>ht||a<-ht)return a>0n?u.POSITIVE_INFINITY:u.ZERO;let l=$(Re(c,s),s,i),m=l.exponent+Number(a);return Number.isSafeInteger(m)?v(l.significand,m):a>0n?u.POSITIVE_INFINITY:u.ZERO};u.prototype.ln=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.isZero())return u.NEGATIVE_INFINITY;if(this.significand<0n)return u.NAN;if(this.eq(1))return u.ZERO;let i=u.precision,e=this.significand,t=k(e),n=this.exponent+t-1,r=v(e,-(t-1)),s=Math.abs(n).toString().length,o=i+20+s,[a,c]=j(r,o),l=pt(c),m=wi(a,c)+BigInt(n)*l;return $(m,c,i)};u.prototype.log=function(i){let e=i instanceof u?i:new u(i);return this.ln().div(e.ln())};u.exp=function(i){return i.exp()};u.ln=function(i){return i.ln()};u.log10=function(i){return i.log(10)};u.log2=function(i){return i.log(2)};u.prototype.sin=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0);if(e+t+30>xi)return u.NAN;let[n,r]=j(this,t),[s]=Ce(n,r);return $(s,r,i)};u.prototype.cos=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ONE;let i=u.precision,e=i+15;if(C(this)+e+30>xi)return u.NAN;let[n,r]=j(this,e),[,s]=Ce(n,r);return $(s,r,i)};u.prototype.tan=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0);if(e+t+30>xi)return u.NAN;let[n,r]=j(this,t),[s,o]=Ce(n,r);if(o===0n)return s>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let a=(s<<BigInt(r))/o;return $(a,r,i)};u.prototype.atan=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite()){let o=u.PI.div(u.TWO);return this.significand>0n?o:o.neg()}let i=u.precision,e=C(this);if(e<0&&-2*e>=i+4)return this.toPrecision(i);let t=i+15+(e<0?-e:0),[n,r]=j(this,t),s=ye(n,r);return $(s,r,i)};u.prototype.asin=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=this.abs(),e=u.ONE;if(i.gt(e))return u.NAN;if(i.eq(e)){let h=u.PI.div(u.TWO);return this.significand>0n?h:h.neg()}let t=u.precision,n=C(this);if(n<0&&-2*n>=t+4)return this.toPrecision(t);let r=t+20+(n<0?-n:0),[s,o]=j(this,r),a=1n<<BigInt(o),c=st(s,s,o),l=a-c,m=Ie(l,o),f=ot(s,m,o),d=ye(f,o);return $(d,o,t)};u.prototype.acos=function(){return this.isNaN()?u.NAN:this.isFinite()?this.abs().gt(u.ONE)?u.NAN:this.eq(1)?u.ZERO:this.eq(-1)?u.PI:u.PI.div(u.TWO).sub(this.asin()):u.NAN};u.sin=function(i){return i.sin()};u.cos=function(i){return i.cos()};u.tan=function(i){return i.tan()};u.asin=function(i){return i.asin()};u.acos=function(i){return i.acos()};u.atan=function(i){return i.atan()};u.atan2=function(i,e){let t=i instanceof u?i:new u(i);if(t.isNaN()||e.isNaN())return u.NAN;let n=u.PI,r=n.div(u.TWO);if(e.isZero())return t.isZero()?u.ZERO:t.significand>0n?r:r.neg();let s=t.div(e);return e.significand>0n?s.atan():t.significand>=0n?s.atan().add(n):s.atan().sub(n)};u.prototype.sinh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let i=u.precision,e=C(this);if(e<0){if(-2*e>=i+4)return this.toPrecision(i);let r=u.precision;u.precision=i-e+5;try{let s=this.exp();return s.sub(s.inv()).div(u.TWO).toPrecision(i)}finally{u.precision=r}}if(Math.abs(this.toNumber())>1.16*(i+3)){let r=this.abs().exp().div(u.TWO);return this.significand>0n?r:r.neg()}let t=this.exp(),n=t.inv();return t.sub(n).div(u.TWO)};u.prototype.cosh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ONE;if(!this.isFinite())return u.POSITIVE_INFINITY;let i=u.precision;if(Math.abs(this.toNumber())>1.16*(i+3))return this.abs().exp().div(u.TWO);let e=this.exp(),t=e.inv();return e.add(t).div(u.TWO)};u.prototype.tanh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.ONE:u.NEGATIVE_ONE;let i=u.precision,e=C(this);if(e<0){if(-2*e>=i+4)return this.toPrecision(i);let n=u.precision;u.precision=i-e+5;try{let r=this.mul(u.TWO).exp();return r.sub(u.ONE).div(r.add(u.ONE)).toPrecision(i)}finally{u.precision=n}}if(Math.abs(this.toNumber())>1.16*(i+3))return this.significand>0n?u.ONE:u.NEGATIVE_ONE;let t=this.mul(u.TWO).exp();return t.sub(u.ONE).div(t.add(u.ONE))};u.sinh=function(i){return i.sinh()};u.cosh=function(i){return i.cosh()};u.tanh=function(i){return i.tanh()};u.prototype.expm1=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_ONE;if(this.isZero())return u.ZERO;let i=u.precision,e=C(this);if(e<0&&-e>=i+2)return this.toPrecision(i);if(e<0){let t=u.precision;u.precision=i-e+5;try{return this.exp().sub(u.ONE).toPrecision(i)}finally{u.precision=t}}return this.exp().sub(u.ONE)};u.prototype.log1p=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.isZero())return u.ZERO;let i=u.ONE.add(this);if(i.isZero())return u.NEGATIVE_INFINITY;if(i.significand<0n)return u.NAN;let e=u.precision,t=C(this);if(t<0&&-t>=e+2)return this.toPrecision(e);if(t<0){let n=u.precision;u.precision=e-t+5;try{return u.ONE.add(this).ln().toPrecision(e)}finally{u.precision=n}}return u.ONE.add(this).ln()};u.prototype.asinh=function(){if(this.isNaN())return u.NAN;if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;let i=this.significand<0n,e=this.abs(),t=u.precision,n=C(this);if(n<0&&-2*n>=t+4)return this.toPrecision(t);let r=()=>e.add(e.mul(e).add(u.ONE).sqrt()).ln(),s;if(n<0){let o=u.precision;u.precision=t-n+5;try{s=r().toPrecision(t)}finally{u.precision=o}}else s=r();return i?s.neg():s};u.prototype.acosh=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:u.NAN;if(this.lt(u.ONE))return u.NAN;if(this.eq(1))return u.ZERO;let i=this.sub(u.ONE).div(u.TWO).sqrt();return u.TWO.mul(i.asinh())};u.prototype.atanh=function(){if(this.isNaN())return u.NAN;if(!this.isFinite())return u.NAN;if(this.isZero())return u.ZERO;let i=this.abs();if(i.eq(1))return this.significand>0n?u.POSITIVE_INFINITY:u.NEGATIVE_INFINITY;if(i.gt(u.ONE))return u.NAN;let e=u.precision,t=C(this);if(-2*t>=e+4)return this.toPrecision(e);let n=u.precision;u.precision=e-t+5;try{return u.ONE.add(this).div(u.ONE.sub(this)).ln().div(u.TWO).toPrecision(e)}finally{u.precision=n}};u.prototype.nthRoot=function(i){if(this.isNaN()||!Number.isInteger(i)||i===0)return u.NAN;if(i===1)return this;if(i===2)return this.sqrt();if(i===3)return this.cbrt();if(i<0)return this.nthRoot(-i).inv();if(this.isZero())return u.ZERO;if(!this.isFinite())return this.significand>0n?u.POSITIVE_INFINITY:i%2===0?u.NAN:u.NEGATIVE_INFINITY;if(this.significand<0n)return i%2===0?u.NAN:this.neg().nthRoot(i).neg();let e=u.precision,t=u.precision;u.precision=e+8;try{return u.exp(this.ln().div(new u(i))).toPrecision(e)}finally{u.precision=t}};u.asinh=function(i){return i.asinh()};u.acosh=function(i){return i.acosh()};u.atanh=function(i){return i.atanh()};u.expm1=function(i){return i.expm1()};u.log1p=function(i){return i.log1p()};u.nthRoot=function(i,e){return i.nthRoot(e)};function Nt(i){let e=J(i);if(e<=1023){let c=Math.cbrt(Number(i));if(Number.isFinite(c)&&c>=1)return BigInt(Math.floor(c))}let t=e-51,n=Number(i>>BigInt(t)),r=Math.cbrt(n),s=Math.floor(t/3),o=t%3;o===1&&(r*=1.2599210498948732),o===2&&(r*=1.5874010519681994);let a=BigInt(Math.round(r))<<BigInt(s);return a>0n?a:1n}var Ee=class extends Error{cause;value;constructor({message:e,value:t,cause:n}={}){super(e??"Operation canceled"),t&&(this.value=t),this.cause=n,this.name="CancellationError"}};function le(i){if(i!==void 0&&Date.now()>=i)throw new Ee({cause:"timeout",message:"Timeout exceeded"})}var _e;function qe(){return _e}function Ze(i,e){let t=_e;_e=i;try{return e()}finally{_e=t}}function Le(i,e,t={}){let{contract:n=.125,step:r=1,power:s=2,atol:o=1e-16,rtol:a=o>0?0:Math.sqrt(Number.EPSILON),maxeval:c=1e6,breaktol:l=2,deadline:m=qe()}=t;return isFinite(e)?Ze(m,()=>{let f=r,d=Math.pow(1/n,s),h=i(e+f),N=[h],p=1/0,g=1;for(;g<c;){le(m),g+=1,f*=n,N.push(i(e+f));let b=d,T=1/0;for(let y=N.length-2;y>=0;y--){let w=N[y];N[y]=N[y+1]+(N[y+1]-N[y])/(b-1);let B=Math.abs(N[y]-w);T=Math.min(T,B),B<p&&(h=N[y],p=B),b*=d}if(T>l*p||!isFinite(T)||p<=Math.max(a*Math.abs(h),o))break}return[h,p]}):Le(f=>i(1/f),1/e,{rtol:a,atol:o,maxeval:c,contract:Math.abs(n)>1?1/n:n,step:1/r,power:s,deadline:m})}function V(i){if(typeof i=="bigint")return i;if(typeof i=="number")return Number.isInteger(i)?BigInt(i):null;if(i instanceof u)return i.isInteger()?BigInt(i.toFixed(0)):null;let e=i.toLowerCase(),t=e.match(/^([+-]?[0-9]+)e([+-]?[0-9]+)$/);if(t){let r=parseInt(t[2]);if(r<0)return null;e=t[1]+"0".repeat(r)}if(e.indexOf(".")>=0||!/^[+-]?[0-9]+$/.test(e))return null;try{return BigInt(e)}catch(r){return console.error(r instanceof Error?r.message:String(r)),null}}var pr=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]),bt=7919;function Ge(i){if(Number.isInteger(i)&&i>=0&&i<Number.MAX_SAFE_INTEGER,i<=3)return{[i]:1};let e={},t=0;for(;i%2===0;)t+=1,i/=2;for(t>0&&(e[2]=t),t=0;i%3===0;)t+=1,i/=3;t>0&&(e[3]=t);let n=!1;for(;!n;){if(i===1)return e;let r=Math.sqrt(i);n=!0;for(let s=6;s<=r+6;s+=6){if(i%(s-1)===0){e[s-1]=(e[s-1]??0)+1,i/=s-1,n=!1;break}if(i%(s+1)===0){e[s+1]=(e[s+1]??0)+1,i/=s+1,n=!1;break}}}return e[i]!==void 0?e[i]+=1:e[i]=1,e}function gr(i){return!Number.isInteger(i)||!Number.isFinite(i)||i<=1?!1:yt(BigInt(i))}var br=1n<<32n,gt=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n];function yt(i){if(i<2n)return!1;if(i<=bt)return pr.has(Number(i));if(i<br){if(i%2n===0n||i%3n===0n)return!1;for(let e=5n;e*e<=i;e+=6n)if(i%e===0n||i%(e+2n)===0n)return!1;return!0}return yr(i)}function It(i,e,t){if(t===1n)return 0n;let n=1n;for(i=(i%t+t)%t;e>0n;)e&1n&&(n=n*i%t),i=i*i%t,e>>=1n;return n}function yr(i){for(let n of gt)if(i%n===0n)return i===n;let e=i-1n,t=0n;for(;e%2n===0n;)e/=2n,t+=1n;e:for(let n of gt){let r=It(n,e,i);if(!(r===1n||r===i-1n)){for(let s=1n;s<t;s++)if(r=r*r%i,r===i-1n)continue e;return!1}}return!0}var Ir=[BigInt(4),BigInt(2),BigInt(4),BigInt(2),BigInt(4),BigInt(6),BigInt(2),BigInt(6)];function Pi(i){if(i<Number.MAX_SAFE_INTEGER){let m=Ge(Number(i)),f=new Map;for(let d of Object.keys(m))f.set(V(d),m[Number(d)]);return f}let e=i,t=new Map,n=0,r=0,s=0,o=BigInt(10);for(;e%o===BigInt(0);)n+=1,s+=1,e=e/o;for(o=BigInt(5);e%o===BigInt(0);)s+=1,e=e/o;for(o=BigInt(3);e%o===BigInt(0);)r+=1,e=e/o;for(o=BigInt(2);e%o===BigInt(0);)n+=1,e=e/o;n>0&&t.set("2",n),r>0&&t.set("3",r),s>0&&t.set("5",s),o=BigInt(7);let a="",c=0;for(;o*o<e;)e%o===BigInt(0)?(a||(a=o.toString()),t.set(a,(t.get(a)??0)+1),e=e/o):(o=o+Ir[c],a="",c=c<7?c+1:0);e!==BigInt(1)&&t.set(e.toString(),(t.get(e.toString())??0)+1);let l=new Map;for(let[m,f]of t)l.set(V(m),f);return l}var Tt=21,Si=53,vt=Math.floor(Math.log10(Math.pow(2,Si))),Di=1e-10,P=1e6,Et=1024,Mt=1e4,Bt=200;function Ri(i){if(i!==i)return i;if(i===-1/0)return-Number.MAX_VALUE;if(i===1/0||i===Number.MAX_VALUE)return 1/0;let e=i*(i<0?1-Number.EPSILON/2:1+Number.EPSILON);e===i&&(e=Number.MIN_VALUE*Number.EPSILON>0?i+Number.MIN_VALUE*Number.EPSILON:i+Number.MIN_VALUE),e===1/0&&(e=+Number.MAX_VALUE);let t=i+(e-i)/2;i<t&&t<e&&(e=t);let n=(e+i)/2;return i<n&&n<e&&(e=n),e===0?-0:e}function wt(i){return-Ri(-i)}function ee(i,e){if(i>=Number.MAX_SAFE_INTEGER)return[1,i];if(i===0)return[0,0];if(i===1)return[1,1];if(Number.isInteger(i)&&i>0&&i<Number.MAX_SAFE_INTEGER,e===2){let s=[[0,0],[1,1],[1,2],[1,3],[2,1],[1,5],[1,6],[1,7],[2,2],[3,1],[1,10],[1,11],[2,3],[1,13],[1,14],[1,15],[4,1],[1,17],[3,2],[1,19],[2,5]][i];if(s)return s}let t=Ge(i),n=BigInt(1),r=BigInt(1);for(let s of Object.keys(t)){let o=BigInt(parseInt(s)),a=BigInt(e);n=n*o**(BigInt(t[Number(s)])/a),r=r*o**(BigInt(t[Number(s)])%a)}return[Number(n),Number(r)]}function _(i,e){if(i===0)return e;if(e===0||i===e)return i;if(!Number.isInteger(i)||!Number.isInteger(e))return NaN;for(;e!==0;)[i,e]=[e,i%e];return i<0?-i:i}function Ue(i,e){if(i===0||e===0)return 0;let t=BigInt(i)*BigInt(e)/BigInt(_(i,e));return t<0n&&(t=-t),Number(t)}function kt(i){if(!Number.isInteger(i)||i<0)return NaN;if(i>=170)return 1/0;let e=1;for(let t=2;t<=i;t++)e=e*t;return e}function xt(i){if(!Number.isInteger(i)||i<0)return NaN;if(i<0)return NaN;if(i<=1)return 1;let e=i;for(;i>2;)i-=2,e*=i;return e}function Pt(i,e=Di){return typeof i=="number"&&Math.abs(i)<=e?0:i}function St(i,e,t=.1){return(i(e-4*t)/280-4*i(e-3*t)/105+i(e-2*t)/5-4*i(e-t)/5+4*i(e+t)/5-i(e+2*t)/5+4*i(e+3*t)/105-i(e+4*t)/280)/t}function Tr(i,e,t){let s=!Number.isFinite(e),o=h=>s?1/h:e+h,a=(h,N,p)=>{let g=.01*Math.max(1,Math.abs(p));for(let b=1;b<=5;b++){let T=i(o(h*Math.pow(N/h,b/6)));if(!Number.isFinite(T)||Math.abs(T-p)>g)return!1}return!0},c=s?1/t:t,l=0,m=!1,f=NaN,d=NaN;for(let h=1;h<=60;h++){let N=i(o(c));if(!Number.isFinite(N))return h-1;let p=Math.abs(N);if(h===1){l=p,f=p,d=c,c*=.125;continue}if(Math.abs(p-f)<=1e-10*Math.max(1,p))return a(d,c,N)?1/0:0;if(m&&l>1e-6&&p<1e-8*l)return h-1;p>l&&(m=!0,l=p),f=p,d=c,c*=.125}return 1/0}function Ye(i,e,t=1,n){if(t===0){let c=Ye(i,e,-1,n),l=Ye(i,e,1,n);return c===void 0||l===void 0?NaN:Math.abs(c-l)>1e-5?NaN:(c+l)/2}let r=t>0?1:-1,s=Tr(i,e,r);if(s===0)return NaN;let[o,a]=Le(i,e,{step:r,deadline:n,...Number.isFinite(s)?{maxeval:s}:{}});return Number.isFinite(o)&&a>1e-6*Math.max(1,Math.abs(o))?NaN:o}function*Dt(){yield[0,1];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;t!==0&&_(e,t)===1&&(yield[e,t],yield[-e,t])}}function*Rt(){yield[0,1];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;t!==0&&_(e,t)===1&&(yield[e,t])}}function*At(){yield[0,0];for(let i=1;;i++)for(let e=0;e<=i;e++){let t=i-e;if(t===0||_(e,t)!==1)continue;let n=e/t;for(let r=0;r<=i;r++){let s=i-r;if(s===0||_(r,s)!==1)continue;let o=r/s;yield[n,o],yield[-n,o],yield[n,-o],yield[-n,-o]}}}function*Ot(){yield 0;for(let i=1;;i++)yield i,yield-i}function*Ft(){for(let i=0;;i++)yield i}function ie(i,e){for(;e!==BigInt(0);)[i,e]=[e,i%e];return i<0?-i:i}function Je(i,e){return i*e/ie(i,e)}function Me(i,e){let t=Pi(i),n=BigInt(1),r=BigInt(1),s=BigInt(e);for(let[o,a]of t){let c=V(a);n=n*o**(c/s),r=r*o**(c%s)}return[n,r]}function Ct(i){return i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}function*Ai(i){if(i<0)return BigInt(0);if(i<10)return BigInt([1,1,2,6,24,120,720,5040,40320,362880][Number(i)]);if(i%BigInt(2)===BigInt(1))return i*(yield*Ai(i-BigInt(1)));let e=i,t=i,n=i;for(;e>2;)e-=BigInt(2),t+=e,n*=t,yield n;return n}function vr(i){return i!==null&&Array.isArray(i)}function A(i){return i!==null&&Array.isArray(i)&&typeof i[0]=="number"}function je(i){return i!==null&&Array.isArray(i)&&typeof i[0]=="bigint"}function te(i){return i[0]==0}function $e(i){return i[0]>0}function We(i){return i[0]==i[1]}function Xe(i){return i[0]===-i[1]}function W(i){return i[1]==1}function Er(i){return Number(i[0])}function Mr(i){return Number(i[1])}function Oi(i){return Number(i[0])/Number(i[1])}function Br(i){return i[0]<0}function wr(i,e){return L(i,we(e))}function ne(i,e){if(typeof i[0]=="number"&&!Number.isFinite(i[0]))return i;let t=e;if(t===null)return i;if(je(t))return i=[BigInt(i[0]),BigInt(i[1])],[t[1]*i[0]+t[0]*i[1],t[1]*i[1]];if(!Number.isFinite(t[0]))return t;if(je(i)){let s=[BigInt(t[0]),BigInt(t[1])];return[s[1]*i[0]+s[0]*i[1],s[1]*i[1]]}let n=t[1]*i[0]+t[0]*i[1],r=t[1]*i[1];return n<=9007199254740991&&n>=-9007199254740991&&r<=9007199254740991?[n,r]:!Number.isFinite(n)||!Number.isFinite(r)?[NaN,1]:[BigInt(t[1])*BigInt(i[0])+BigInt(t[0])*BigInt(i[1]),BigInt(t[1])*BigInt(i[1])]}function L(i,e){if(A(i)&&(!Number.isFinite(i[0])||!Number.isFinite(i[1])))return[NaN,1];if(A(e)&&(!Number.isFinite(e[0])||!Number.isFinite(e[1])))return[NaN,1];if(A(i)&&A(e)){let t=i[0]*e[0],n=i[1]*e[1];return t<=9007199254740991&&t>=-9007199254740991&&n<=9007199254740991?[t,n]:!Number.isFinite(t)||!Number.isFinite(n)?[NaN,1]:[BigInt(i[0])*BigInt(e[0]),BigInt(i[1])*BigInt(e[1])]}return A(i)?[BigInt(i[0])*e[0],BigInt(i[1])*e[1]]:A(e)?[BigInt(e[0])*i[0],BigInt(e[1])*i[1]]:[i[0]*e[0],i[1]*e[1]]}function Fi(i){return[-i[0],i[1]]}function we(i){return i[0]<0?[-i[1],-i[0]]:[i[1],i[0]]}function kr(i){return[Number(i[0]),Number(i[1])]}function xr(i,e){if(Number.isInteger(e),e===0)return[1,1];if(e<0&&(i=we(i),e=-e),e===1)return i;let t=BigInt(e);return[BigInt(i[0])**t,BigInt(i[1])**t]}function Pr(i){let e=Math.sqrt(Number(i[0])),t=Math.sqrt(Number(i[1]));if(Number.isInteger(e)&&Number.isInteger(t))return[e,t]}function Ci(i,e){return A(i)&&A(e)?i[1]===1&&e[1]===1?[_(i[0],e[0]),1]:[_(i[0],e[0]),Ue(i[1],e[1])]:i[1]===1&&e[1]===1?[ie(BigInt(i[0]),BigInt(e[0])),BigInt(1)]:[ie(BigInt(i[0]),BigInt(e[0])),Je(BigInt(i[1]),BigInt(e[1]))]}function Be(i){if(A(i)){if(i[1]<0&&(i=[-i[0],-i[1]]),i[0]===1||i[1]===1)return i;if(!Number.isFinite(i[1]))return[0,1];let r=_(i[0],i[1]);return r<=1?i:[i[0]/r,i[1]/r]}i[1]<0&&(i=[-i[0],-i[1]]);let e=ie(i[0],i[1]),[t,n]=e<=1?i:[i[0]/e,i[1]/e];return t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER?[Number(t),Number(n)]:[t,n]}function Sr(i){if(!Number.isFinite(i)||i%1===0)return i;let t=1e-15,n=Math.floor(i),r=1,s=0,o=n,a=1;for(;i-n>t*a*a;){i=1/(i-n),n=Math.floor(i);let c=r;r=o;let l=s;s=a,o=c+n*r,a=l+n*s}return[o,a]}function Dr(i){if(je(i)){let[a,c]=i,[l,m]=Me(a,2),[f,d]=Me(c,2);return[Be([l,f*d]),m*d]}let[e,t]=i,[n,r]=ee(e,2),[s,o]=ee(t,2);return[Be([n,s*o]),r*o]}function Vt(i){return!!(typeof i=="number"||Vi(i)||typeof i=="string"&&Rr(i))}function Vi(i){return i!==null&&typeof i=="object"&&"num"in i}function Rr(i){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(i)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(i)}function Ar(i){if(i==="N")return[0,""];let e={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},t=0,n=0;i=i.toUpperCase();for(let r=i.length-1;r>=0;r--){let s=e[i[r]];if(s===void 0)return[t,i.slice(r)];s<n?t-=s:t+=s,n=s}return[t,""]}function _i(i,e){if(i=i.trim(),i.length===0)return[NaN,""];if(i.startsWith("+"))return _i(i.slice(1),e);if(i.startsWith("-")){let[r,s]=_i(i.slice(1),e);return[-r,s]}let t=10;if(typeof e=="string"&&(e=e.toLowerCase()),i.startsWith("0x"))t=16,i=i.slice(2);else if(i.startsWith("0b"))t=2,i=i.slice(2);else{if(e==="roman")return Ar(i);if(e==="base64"||e==="base-64")try{return[parseInt(btoa(i)),""]}catch{return[NaN,""]}else typeof e=="number"?t=e:typeof e=="string"&&(t=parseInt(e))}let n=0;for(let r=0;r<i.length;r++){let s={" ":-1,"\xA0":-1,"\u2000":-1,"\u2001":-1,"\u2002":-1,"\u2003":-1,"\u2004":-1,"\u2005":-1,"\u2006":-1,"\u2007":-1,"\u2008":-1,"\u2009":-1,"\u200A":-1,"\u200B":-1,"\u202F":-1,"\u205F":-1,_:-1,",":-1,0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,g:16,h:17,i:18,j:19,k:20,l:21,m:22,n:23,o:24,p:25,q:26,r:27,s:28,t:29,u:30,v:31,w:32,x:33,y:34,z:35}[i[r]];if(s!==-1){if(s===void 0)return[n,i.substring(r)];if(s>=t)return[n,i.substring(r)];n=n*t+s}}return[n,""]}function x(i,e){if(typeof e=="number"&&typeof i=="number")return i.toFixed(e);let t=i.toString();if(typeof i=="number"&&Number.isInteger(i)&&t.includes("e")){let n=BigInt(i).toString(),r=n.match(/0+$/);if((r?r[0].length:0)<=5)return n}else if(typeof i=="bigint"){let n=t.match(/0+$/),r=n?n[0].length:0;if(r>5)return`${t.slice(0,-r)}e+${r}`}return t}function Or(i){if(typeof i=="number")return Number.isInteger(i)?BigInt(i):null;if(i==null||!Vt(i))return null;let e=Vi(i)?i.num:i;if(typeof e=="number")return Number.isInteger(e)?BigInt(e):null;if(typeof e!="string")return null;let t=e.toLowerCase().replace(/[nd]$/,"").replace(/[\u0009-\u000d\u0020\u00a0]/g,"");return t==="nan"||/^(infinity|\+infinity|oo|\+oo|-infinity|-oo)$/.test(t)?null:V(t)}function O(i,e){if(typeof i=="number")return isNaN(i)?"NaN":Number.isFinite(i)?typeof e=="number"?{num:i.toFixed(e)}:i:i<0?"NegativeInfinity":"PositiveInfinity";if(i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER)return Number(i);let t=x(i);return Number(i).toString()===t?Number(i):{num:t}}var He=["number","finite_number","complex","finite_complex","imaginary","real","finite_real","rational","finite_rational","integer","finite_integer","non_finite_number"],qi=["indexed_collection","list","tuple"],Ke=[...qi,"collection","set","record","dictionary"],Qe=["scalar",...He,"boolean","string"],Zi=["value","color",...Ke,...Qe],Li=["expression","symbol","function",...Zi],Gi=["any","unknown","nothing","never","error",...Li],_t=new Set(He),qt=new Set(Ke),Zt=new Set(Qe),me=new Set(Gi);function Lt(i){return typeof i=="string"?me.has(i):typeof i!="object"||!("kind"in i)?!1:i.kind==="signature"||i.kind==="union"||i.kind==="intersection"||i.kind==="negation"||i.kind==="value"||i.kind==="tuple"||i.kind==="list"||i.kind==="record"||i.kind==="dictionary"||i.kind==="set"||i.kind==="symbol"||i.kind==="expression"||i.kind==="numeric"||i.kind==="collection"||i.kind==="indexed_collection"||i.kind==="reference"}var ze=class{input;pos=0;line=1;column=1;tokens=[];constructor(e){this.input=e}saveState(){return{pos:this.pos,line:this.line,column:this.column,tokens:[...this.tokens]}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column,this.tokens=e.tokens}error(e){throw new Error(`Lexer error at line ${this.line}, column ${this.column}: ${e}`)}peek(e=0){let t=this.pos+e;return t<this.input.length?this.input[t]:""}advance(){let e=this.input[this.pos++];return e===`
4
4
  `?(this.line++,this.column=1):this.column++,e}match(e){if(this.input.slice(this.pos,this.pos+e.length)===e){for(let t=0;t<e.length;t++)this.advance();return!0}return!1}isEOF(){return this.pos>=this.input.length}skipWhitespace(){for(;!this.isEOF()&&/\s/.test(this.peek());)this.advance()}readIdentifier(){let e="";for(;!this.isEOF()&&/[a-zA-Z0-9_]/.test(this.peek());)e+=this.advance();return e}readVerbatimString(){if(!this.match("`"))return"";let e="";for(;!this.isEOF()&&this.peek()!=="`";)this.match("\\`")?e+="`":this.match("\\\\")?e+="\\":e+=this.advance();return this.isEOF()&&this.error("Unterminated verbatim string"),this.advance(),e}readStringLiteral(){let e=this.advance(),t="";for(;!this.isEOF()&&this.peek()!==e;)this.match("\\"+e)?t+=e:this.match("\\\\")?t+="\\":t+=this.advance();return this.isEOF()&&this.error("Unterminated string literal"),this.advance(),t}readNumber(){let e="";if((this.peek()==="-"||this.peek()==="+")&&(e+=this.advance()),this.match("0x")||this.match("0X")){for(e+="x";!this.isEOF()&&/[0-9a-fA-F]/.test(this.peek());)e+=this.advance();return"0"+e}if(this.match("0b")||this.match("0B")){for(e+="b";!this.isEOF()&&/[01]/.test(this.peek());)e+=this.advance();return"0"+e}for(;!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();if(this.peek()==="."&&/[0-9]/.test(this.peek(1)))for(e+=this.advance();!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(e+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(e+=this.advance());!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();return e}createToken(e,t){return{type:e,value:t,position:this.pos-t.length,line:this.line,column:this.column-t.length}}nextToken(){if(this.skipWhitespace(),this.isEOF())return this.createToken("EOF","");let e=this.pos,t=this.peek();if(this.match("->"))return this.createToken("->","->");if(this.match(".."))return this.createToken("..","..");if(this.match("+\u221E")||this.match("+oo"))return this.createToken("PLUS_INFINITY",this.input.slice(e,this.pos));if(this.match("-\u221E")||this.match("-oo"))return this.createToken("MINUS_INFINITY",this.input.slice(e,this.pos));if(this.match("+infinity"))return this.createToken("PLUS_INFINITY","+infinity");if(this.match("-infinity"))return this.createToken("MINUS_INFINITY","-infinity");if(/[a-zA-Z_]/.test(t)){let n=this.readIdentifier();switch(n){case"true":return this.createToken("TRUE",n);case"false":return this.createToken("FALSE",n);case"nan":return this.createToken("NAN",n);case"infinity":return this.createToken("INFINITY",n);case"oo":return this.createToken("INFINITY",n);default:return this.createToken("IDENTIFIER",n)}}switch(t){case"|":return this.advance(),this.createToken("|","|");case"&":return this.advance(),this.createToken("&","&");case"!":return this.advance(),this.createToken("!","!");case"^":return this.advance(),this.createToken("^","^");case"(":return this.advance(),this.createToken("(","(");case")":return this.advance(),this.createToken(")",")");case"<":return this.advance(),this.createToken("<","<");case">":return this.advance(),this.createToken(">",">");case"[":return this.advance(),this.createToken("[","[");case"]":return this.advance(),this.createToken("]","]");case",":return this.advance(),this.createToken(",",",");case":":return this.advance(),this.createToken(":",":");case"?":return this.advance(),this.createToken("?","?");case"*":return this.advance(),this.createToken("*","*");case"+":return/[0-9]/.test(this.peek(1))?this.createToken("NUMBER_LITERAL",this.readNumber()):(this.advance(),this.createToken("+","+"));case"x":return/[0-9]/.test(this.peek(1))?(this.advance(),this.createToken("x","x")):(this.advance(),this.createToken("x","x"))}if(t==='"'||t==="'")return this.createToken("STRING_LITERAL",this.readStringLiteral());if(t==="`")return this.createToken("VERBATIM_STRING",this.readVerbatimString());if(/[0-9]/.test(t)||t==="-"&&/[0-9]/.test(this.peek(1))){let n=this.readNumber();return this.peek()==="x"&&/[0-9]/.test(this.peek(1)),this.createToken("NUMBER_LITERAL",n)}if(t==="\u221E")return this.advance(),this.createToken("INFINITY","\u221E");this.error(`Unexpected character: ${t}`)}tokenize(){let e=[];for(;!this.isEOF();){let t=this.nextToken();if(t&&(e.push(t),t.type==="EOF"))break}return e}peekToken(){if(this.tokens.length===0){let e=this.nextToken();e&&this.tokens.push(e)}return this.tokens[0]||this.createToken("EOF","")}consumeToken(){if(this.tokens.length===0){let e=this.nextToken();if(e)return e}return this.tokens.shift()||this.createToken("EOF","")}matchToken(e){return this.peekToken().type===e?(this.consumeToken(),!0):!1}expectToken(e){let t=this.consumeToken();return t.type!==e&&this.error(`Expected ${e}, got ${t.type}`),t}};var ei=class{lexer;typeResolver;current;constructor(e,t){this.lexer=new ze(e),this.typeResolver=t?.typeResolver??{forward:()=>{},resolve:()=>{},get names(){return[]}},this.current=this.lexer.consumeToken()}error(e,t){this.errorAtToken(this.current,e,t)}errorAtToken(e,t,n){let r=this.lexer.input,o=r.split(`
5
5
  `)[e.line-1]||r,a=e.column,c=" ".repeat(Math.max(0,a-1))+"^",l=["","Invalid type",`| ${o}`,`| ${c}`,"|",`| ${t}`];throw n&&l.push(`| ${n}`),l.push(""),new Error(l.join(`
6
- `))}advance(){let e=this.current;return this.current=this.lexer.consumeToken(),e}match(e){return this.current.type===e?(this.advance(),!0):!1}expect(e){return this.current.type!==e&&this.error(`Expected ${e}, got ${this.current.type}`),this.advance()}createNode(e,t={}){return{kind:e,position:this.current.position,line:this.current.line,column:this.current.column,...t}}parseType(){this.checkForNakedFunctionSignature();let e=this.parseUnionType();if(e||this.error("Expected a type"),this.current.type!=="EOF")if(this.current.type==="->"||this.current.type==="+"||this.current.type==="*"||this.current.type==="?")this.error("Function signatures must be enclosed in parentheses","For example `(x: number) -> number`");else if(this.current.type==="("){let t=this.lexer.input;t.includes("set(")||t.includes("collection(")||t.includes("list(")||t.includes("tuple(")?t.includes("set(")?this.error("Use `set<integer>` instead of `set(integer)`."):t.includes("collection(")?this.error("Use `collection<type>` instead of `collection(type)`.","For example `collection<number>`"):t.includes("list(")?this.error("Use `list<type>` instead of `list(type)`.","For example `list<number>`"):t.includes("tuple(")&&this.error("Use `tuple<type1, type2>` instead of `tuple(type1, type2)`.","For example `tuple<string, number>`"):this.error("Unexpected token after type")}else this.error("Unexpected token after type");return e}checkForNakedFunctionSignature(){if(this.current.type==="IDENTIFIER"){let e=this.lexer.saveState(),t=this.current;try{let n=this.current;if(this.advance(),this.current.type===":"){this.advance();let r=!1,s=0,o=10;for(;this.current.type!=="EOF"&&s<o;){if(this.current.type==="->"){r=!0;break}if(this.current.type==="+"||this.current.type==="*"||this.current.type==="?"){if(this.advance(),this.current.type==="->"){r=!0;break}s++}this.advance(),s++}r&&(this.lexer.restoreState(e),this.current=t,this.errorAtToken(n,"Function signatures must be enclosed in parentheses","For example `(z: string*) -> boolean`"))}this.lexer.restoreState(e),this.current=t}catch(n){if(this.lexer.restoreState(e),this.current=t,n instanceof Error&&n.message.includes("Function signatures must be enclosed"))throw n}}}parseUnionType(){let e=this.parseIntersectionType();if(!e)return;let t=[e];for(;this.match("|");){let n=this.parseIntersectionType();n||this.error("Expected type after |"),t.push(n)}return t.length===1?t[0]:this.createNode("union",{types:t})}parseIntersectionType(){let e=this.parsePrimaryType();if(!e)return;let t=[e];for(;this.match("&");){let n=this.parsePrimaryType();n||this.error("Expected type after &"),t.push(n)}return t.length===1?t[0]:this.createNode("intersection",{types:t})}parsePrimaryType(){if(this.match("!")){let e=this.parsePrimaryType();return e||this.error("Expected type after !"),this.createNode("negation",{type:e})}if(this.current.type==="("){let e=this.parseFunctionSignature();if(e)return e;if(this.match("(")){let t=this.parseUnionType();if(t||this.error("Expected type after ("),this.current.type===","){let n=[this.createNode("named_element",{name:void 0,type:t})];for(;this.match(",");){let r=this.parseUnionType();r||this.error("Expected type after ,"),n.push(this.createNode("named_element",{name:void 0,type:r}))}return this.expect(")"),this.createNode("tuple",{elements:n})}return this.expect(")"),this.createNode("group",{type:t})}}return this.parseListType()||this.parseTupleType()||this.parseRecordType()||this.parseDictionaryType()||this.parseSetType()||this.parseCollectionType()||this.parseExpressionType()||this.parseSymbolType()||this.parseNumericType()||this.parsePrimitiveType()||this.parseValue()||this.parseTypeReference()}isFunctionSignature(){let e=this.lexer.saveState(),t=this.current;this.advance();let n=1;for(;n>0&&this.current.type!=="EOF";)this.current.type==="("?n++:this.current.type===")"&&n--,this.advance();let r=this.current.type==="->";return this.lexer.restoreState(e),this.current=t,r}parseFunctionSignature(){if(this.current.type!=="("||!this.isFunctionSignature())return;let e=[];if(this.advance(),!this.match(")")){do{let o=this.parseArgument();o||this.error("Expected argument"),e.push(o)}while(this.match(","));this.expect(")")}this.expect("->");let t=this.parseUnionType();t||this.error("Expected return type after ->");let n=e.some(o=>o.modifier==="optional"),r=e.some(o=>o.modifier==="variadic_zero"||o.modifier==="variadic_one"),s=e.filter(o=>o.modifier==="variadic_zero"||o.modifier==="variadic_one").length;return n&&r&&this.error("Variadic arguments cannot be used with optional arguments"),s>1&&this.error("There can be only one variadic argument"),this.createNode("function_signature",{arguments:e,returnType:t})}parseArgument(){let e=this.parseNamedElement();if(!e)return;let t;return this.match("?")?t="optional":this.match("*")?t="variadic_zero":this.match("+")&&(t="variadic_one"),this.createNode("argument",{element:e,modifier:t})}parseNamedElement(){let e;if(this.current.type==="IDENTIFIER"||this.current.type==="VERBATIM_STRING"){let n=this.current;if(this.lexer.peekToken().type===":"){e=n.value,this.advance(),this.advance();let s=this.parseUnionType();return s?this.createNode("named_element",{name:e,type:s}):void 0}}let t=this.parseUnionType();if(t)return this.createNode("named_element",{name:void 0,type:t})}parseListType(){if(this.current.type==="IDENTIFIER"){let e=this.current,n=this.lexer.peekToken().type==="<";switch(e.value){case"list":return n?(this.advance(),this.parseListTypeImpl()):void 0;case"vector":return n?(this.advance(),this.parseVectorType()):(this.advance(),this.createNode("list",{elementType:this.createNode("primitive",{name:"number"}),dimensions:void 0}));case"matrix":return n?(this.advance(),this.parseMatrixType()):(this.advance(),this.createNode("matrix",{elementType:this.createNode("primitive",{name:"number"}),dimensions:[this.createNode("dimension",{size:-1}),this.createNode("dimension",{size:-1})]}));case"tensor":return n?(this.advance(),this.parseTensorType()):(this.advance(),this.createNode("list",{elementType:this.createNode("primitive",{name:"number"}),dimensions:void 0}));default:return}}}parseListTypeImpl(){let e=this.createNode("primitive",{name:"any"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let n=this.parseUnionType();n&&(e=n,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}return this.createNode("list",{elementType:e,dimensions:t})}parseVectorType(){let e=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(this.current.type==="NUMBER_LITERAL")t=parseInt(this.advance().value);else{let n=this.parseUnionType();n&&(e=n,this.match("^")&&(this.current.type==="NUMBER_LITERAL"?t=parseInt(this.advance().value):this.error("Expected number after ^")))}this.expect(">")}return this.createNode("vector",{elementType:e,size:t})}parseMatrixType(){let e=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let n=this.parseUnionType();n&&(e=n,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}else t=[this.createNode("dimension",{size:null}),this.createNode("dimension",{size:null})];return this.createNode("matrix",{elementType:e,dimensions:t})}parseTensorType(){let e=this.createNode("primitive",{name:"number"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("tensor",{elementType:e})}parseDimensions(){let e=this.parseDimension();if(!e)return;let t=[e];for(;;){let n=this.current;if(n.type==="IDENTIFIER"&&/^(x\d+)+$/.test(n.value)){this.advance();for(let r of n.value.match(/x(\d+)/g))t.push(this.createNode("dimension",{size:parseInt(r.slice(1))}))}else if(n.type==="IDENTIFIER"&&n.value==="x"){let r=this.lexer.peekToken();r.type!=="NUMBER_LITERAL"&&r.type!=="?"&&this.error("Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"),this.advance(),t.push(this.parseDimension())}else break}return t}parseDimension(){if(this.match("?"))return this.createNode("dimension",{size:null});if(this.current.type==="NUMBER_LITERAL"){let e=parseInt(this.advance().value);return this.createNode("dimension",{size:e})}}parseCaretDimensions(){let e=this.match("("),t=this.parseDimensions();return e&&this.expect(")"),t}parseTupleType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="tuple"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let t=[];if(this.current.type!==">"){let n=this.parseNamedElement();n||this.error("Expected tuple element"),t.push(n);let r=n.name!==void 0;for(;this.match(",");){let s=this.parseNamedElement();s||this.error("Expected tuple element"),r&&!s.name&&this.error("All tuple elements should be named, or none. Previous elements were named, but this one isn't."),!r&&s.name&&this.error("All tuple elements should be named, or none. Previous elements were not named, but this one is."),t.push(s)}}return this.expect(">"),this.createNode("tuple",{elements:t})}}parseRecordType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="record"){this.advance();let e=[];if(this.match("<")){if(this.current.type!==">")do{let t=this.parseRecordEntry();t||this.error("Expected record entry"),e.push(t)}while(this.match(","));this.expect(">")}return this.createNode("record",{entries:e})}}parseRecordEntry(){let e;if(this.current.type==="IDENTIFIER")e=this.advance().value;else if(this.current.type==="VERBATIM_STRING")e=this.advance().value;else return;this.expect(":");let t=this.parseUnionType();return t||this.error("Expected value type"),this.createNode("record_entry",{key:e,valueType:t})}parseDictionaryType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="dictionary"){this.advance();let e=this.createNode("primitive",{name:"any"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("dictionary",{valueType:e})}}parseSetType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="set"){this.advance();let e=this.createNode("primitive",{name:"any"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("set",{elementType:e})}}parseCollectionType(){if(this.current.type==="IDENTIFIER"){let e=this.current.value==="indexed_collection",t=this.current.value==="collection";if(e||t){this.advance();let n=this.createNode("primitive",{name:"any"});if(this.match("<")){let r=this.parseUnionType();r&&(n=r),this.expect(">")}return this.createNode("collection",{elementType:n,indexed:e})}}}parseExpressionType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="expression"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let n=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("expression",{operator:n})}}parseSymbolType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="symbol"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let n=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("symbol",{name:n})}}parseNumericType(){if(this.current.type==="IDENTIFIER"&&["real","finite_real","rational","finite_rational","integer","finite_integer"].includes(this.current.value)){let t=this.advance().value;if(this.match("<")){let n=this.parseValue();this.expect("..");let r=this.parseValue();this.expect(">");let s=n?.value??-1/0,o=r?.value??1/0;return(Number.isNaN(s)||Number.isNaN(o))&&this.error("Invalid numeric type","Lower and upper bounds must be valid numbers"),s>o&&this.error(`Invalid range: ${s}..${o}`,"The lower bound must be less than the upper bound"),this.createNode("numeric",{baseType:t,lowerBound:n,upperBound:r})}return this.createNode("numeric",{baseType:t})}}parsePrimitiveType(){if(this.current.type==="IDENTIFIER"){let e=this.current.value;if(me.has(e))return this.advance(),this.createNode("primitive",{name:e})}}parseValue(){let e,t;switch(this.current.type){case"STRING_LITERAL":e=this.advance().value,t="string";break;case"NUMBER_LITERAL":e=parseFloat(this.advance().value),t="number";break;case"TRUE":this.advance(),e=!0,t="boolean";break;case"FALSE":this.advance(),e=!1,t="boolean";break;case"NAN":this.advance(),e=NaN,t="nan";break;case"INFINITY":case"PLUS_INFINITY":this.advance(),e=1/0,t="infinity";break;case"MINUS_INFINITY":this.advance(),e=-1/0,t="infinity";break;default:return}return this.createNode("value",{value:e,valueType:t})}parseTypeReference(){let e=this.current.type==="IDENTIFIER"&&this.current.value==="type";if(e&&this.advance(),this.current.type==="IDENTIFIER"){let t=this.current,n=this.advance().value;return this.typeResolver.resolve(n)?this.createNode("type_reference",{name:n,isForward:e}):e&&this.typeResolver.forward(n)?this.createNode("type_reference",{name:n,isForward:!0}):(e||this.errorAtToken(t,`Unknown type "${n}"`,"Syntax error. The type was not recognized."),this.createNode("type_reference",{name:n,isForward:e}))}}};function Gt(i,e){switch(i.kind){case"function_signature":return e.visitFunctionSignature(i);case"union":return e.visitUnionType(i);case"intersection":return e.visitIntersectionType(i);case"negation":return e.visitNegationType(i);case"group":return e.visitGroupType(i);case"list":return e.visitListType(i);case"vector":return e.visitVectorType(i);case"matrix":return e.visitMatrixType(i);case"tensor":return e.visitTensorType(i);case"tuple":return e.visitTupleType(i);case"record":return e.visitRecordType(i);case"dictionary":return e.visitDictionaryType(i);case"set":return e.visitSetType(i);case"collection":return e.visitCollectionType(i);case"expression":return e.visitExpressionType(i);case"symbol":return e.visitSymbolType(i);case"numeric":return e.visitNumericType(i);case"primitive":return e.visitPrimitiveType(i);case"type_reference":return e.visitTypeReference(i);case"value":return e.visitValue(i);default:throw new Error(`Unknown node kind: ${i.kind}`)}}var Ji=class{typeResolver;constructor(e){this.typeResolver=e??{forward:()=>{},resolve:()=>{},get names(){return[]}}}buildType(e){return Gt(e,this)}visitFunctionSignature(e){let t=[],n=[],r,s;for(let c of e.arguments){let l=this.buildNamedElement(c.element);switch(c.modifier){case"optional":n.push(l);break;case"variadic_zero":r=l,s=0;break;case"variadic_one":r=l,s=1;break;default:t.push(l);break}}let o=this.buildType(e.returnType),a={kind:"signature",args:t.length>0?t:void 0,result:o};return n.length>0&&(a.optArgs=n),r&&(a.variadicArg=r,a.variadicMin=s),a}visitUnionType(e){return{kind:"union",types:e.types.map(n=>this.buildType(n))}}visitIntersectionType(e){return{kind:"intersection",types:e.types.map(n=>this.buildType(n))}}visitNegationType(e){return{kind:"negation",type:this.buildType(e.type)}}visitGroupType(e){return this.buildType(e.type)}visitListType(e){let t=this.buildType(e.elementType),n=e.dimensions?.map(r=>this.buildDimension(r));return{kind:"list",elements:t,dimensions:n}}visitVectorType(e){let t=this.buildType(e.elementType);return e.size!==void 0?{kind:"list",elements:t,dimensions:[e.size]}:{kind:"list",elements:t}}visitMatrixType(e){let t=this.buildType(e.elementType);if(e.dimensions){let n=e.dimensions.map(r=>this.buildDimension(r));return{kind:"list",elements:t,dimensions:n}}return{kind:"list",elements:t,dimensions:[-1,-1]}}visitTensorType(e){return{kind:"list",elements:this.buildType(e.elementType)}}visitTupleType(e){return{kind:"tuple",elements:e.elements.map(n=>this.buildNamedElement(n))}}visitRecordType(e){if(e.entries.length===0)return"record";let t={};for(let n of e.entries)t[n.key]=this.buildType(n.valueType);return{kind:"record",elements:t}}visitDictionaryType(e){let t=this.buildType(e.valueType);return this.isAnyType(t)?"dictionary":{kind:"dictionary",values:t}}visitSetType(e){let t=this.buildType(e.elementType);return this.isAnyType(t)?"set":{kind:"set",elements:t}}visitCollectionType(e){let t=this.buildType(e.elementType);return e.indexed?this.isAnyType(t)?"indexed_collection":{kind:"indexed_collection",elements:t}:this.isAnyType(t)?"collection":{kind:"collection",elements:t}}visitExpressionType(e){return{kind:"expression",operator:e.operator}}visitSymbolType(e){return{kind:"symbol",name:e.name}}visitNumericType(e){if(!e.lowerBound&&!e.upperBound)return e.baseType;let t=e.lowerBound?this.buildValue(e.lowerBound):-1/0,n=e.upperBound?this.buildValue(e.upperBound):1/0;return t===-1/0&&n===1/0?e.baseType:{kind:"numeric",type:e.baseType,lower:t,upper:n}}visitPrimitiveType(e){return e.name}visitTypeReference(e){let t=this.typeResolver.resolve(e.name);if(t)return t;if(e.isForward){let n=this.typeResolver.forward(e.name);if(n)return n}return e.name}visitValue(e){return{kind:"value",value:e.value}}buildNamedElement(e){let t=this.buildType(e.type);return e.name?{name:e.name,type:t}:{type:t}}buildDimension(e){return e.size??-1}buildValue(e){return e.value}isAnyType(e){return e==="any"||typeof e=="object"&&"kind"in e&&e.kind==="primitive"&&"name"in e&&e.name==="any"}};function Yt(i,e){return new Ji(e).buildType(i)}var ii=new Map,Cr=2048;function Ut(i){if(i===null||typeof i!="object"||Object.isFrozen(i))return i;Object.freeze(i);for(let e of Object.values(i))Ut(e);return i}function ji(i,e){if(i===void 0)return;if(Lt(i))return i;if(typeof i!="string")return;let t=e===void 0;if(t){let n=ii.get(i);if(n!==void 0)return n}try{let r=new ei(i,{typeResolver:e}).parseType(),s=Yt(r,e);return t&&(ii.size>=Cr&&ii.clear(),ii.set(i,Ut(s))),s}catch(n){throw new Error(`Failed to parse type "${i}": ${n instanceof Error?n.message:String(n)}`)}}var Jt={number:He,non_finite_number:[],finite_number:["finite_complex","finite_real","finite_integer","finite_rational"],complex:["finite_complex","imaginary","finite_real","finite_rational","finite_integer","non_finite_number"],finite_complex:["imaginary","finite_real","finite_rational","finite_integer"],imaginary:[],real:["rational","integer","finite_real","finite_rational","finite_integer","non_finite_number"],finite_real:["finite_rational","finite_integer"],rational:["finite_rational","finite_integer","integer","non_finite_number"],finite_rational:["finite_integer"],integer:["finite_integer","non_finite_number"],finite_integer:[],any:Ui,unknown:[],nothing:[],never:[],error:[],value:Gi,scalar:Qe,collection:Ke,indexed_collection:Li,list:[],set:[],tuple:[],record:[],dictionary:[],function:[],symbol:[],boolean:[],string:[],color:[],expression:Yi},Wt=(()=>{let i={},e=t=>{if(i[t])return i[t];let n=new Set([t]);i[t]=n;for(let r of Jt[t])if(r!==t)for(let s of e(r))n.add(s);return n};for(let t of Object.keys(Jt))e(t);return i})();function ke(i,e){return e==="any"||i==="never"?!0:i==="unknown"||e==="unknown"?!1:i===e?!0:Wt[e].has(i)}function I(i,e){if(typeof i=="string"&&!me.has(i)&&(i=ji(i)),typeof e=="string"&&!me.has(e)&&(e=ji(e)),e==="any"||i==="never")return!0;if(e==="never")return!1;if(e==="error")return i==="error";if(e==="nothing")return i==="nothing";if(i==="nothing")return!1;if(e==="unknown")return!0;if(i==="unknown")return!1;if(typeof e=="string")return typeof i=="string"?ke(i,e):i.kind==="value"?typeof i.value=="boolean"?e==="boolean":typeof i.value=="number"?Number.isInteger(i.value)?ke("integer",e):ke("real",e):typeof i.value=="boolean"?ke("boolean",e):typeof i.value=="string"?ke("string",e):!1:i.kind==="union"?i.types.every(t=>I(t,e)):i.kind==="intersection"?i.types.some(t=>I(t,e)):i.kind==="negation"?!I(i.type,e):i.kind==="numeric"?!!I(i.type,e):e==="number"?Xt(i):e==="symbol"?$i(i):e==="expression"?Vr(i):e==="function"?en(i):e==="scalar"?Ht(i):e==="value"?zt(i):e==="indexed_collection"?Qt(i):e==="collection"?Kt(i):e==="tuple"?i.kind==="tuple":e==="list"?i.kind==="list":e==="set"?i.kind==="set":e==="record"?i.kind==="record":e==="dictionary"?i.kind==="dictionary":!1;if(e.kind==="union")return typeof i!="string"&&i.kind==="union"?i.types.every(t=>e.types.some(n=>I(t,n))):e.types.some(t=>I(i,t));if(e.kind==="expression"){if(i==="symbol")return!0;if(typeof i=="string")return!1;if(i.kind==="expression")return e.operator==="Symbol"?$i(i):i.operator===e.operator;if(i.kind==="symbol")return!0}if(typeof i=="string")return!1;if(e.kind==="reference"){if(i.kind==="reference")return i.name===e.name;if(e.alias===!0&&e.def)return I(i,e.def)}if(i.kind==="union")return i.types.some(t=>I(t,e));if(i.kind==="intersection"&&e.kind==="intersection")return e.types.every(t=>i.types.some(n=>I(n,t)));if(i.kind==="intersection")return i.types.every(t=>I(t,e));if(e.kind==="intersection")return e.types.every(t=>I(i,t));if(i.kind==="signature"&&e.kind==="signature"){if(!I(i.result,e.result))return!1;if(i.optArgs||i.variadicArg){if(e.args){if(!i.args||i.args.length!==e.args.length)return!1;for(let t=0;t<e.args.length;t++)if(!I(e.args[t].type,i.args[t].type))return!1}else if(i.args)return!1;if(e.optArgs){if(!i.optArgs||i.optArgs.length!==e.optArgs.length)return!1;for(let t=0;t<i.optArgs.length;t++)if(!I(e.optArgs[t].type,i.optArgs[t].type))return!1}else if(i.optArgs)return!1;if(e.variadicArg){if(!i.variadicArg||i.variadicMin!=e.variadicMin||!I(e.variadicArg.type,i.variadicArg.type))return!1}else if(i.variadicArg)return!1}else{if(e.args&&!i.args)return!1;let t=0;if(e.args){if(i.args.length<e.args.length)return!1;for(;t<e.args.length;){if(!I(e.args[t].type,i.args[t].type))return!1;t+=1}}if(e.optArgs){if(t>=i.args.length)return!0;for(let n=0;n<e.optArgs.length;n++){if(!I(e.optArgs[n].type,i.args[t].type))return!1;if(t+=1,t>=i.args.length)return!0}}if(e.variadicArg){if(t>=i.args.length&&e.variadicMin===0)return!0;if(e.variadicMin>0&&t+e.variadicMin>i.args.length)return!1;for(;t<i.args.length;){if(!I(e.variadicArg.type,i.args[t].type))return!1;t+=1}}}return!0}if(i.kind==="record"&&e.kind==="record"){for(let t of Object.keys(e.elements))if(!(t in i.elements)||!I(i.elements[t],e.elements[t]))return!1;return!0}if(i.kind==="dictionary"&&e.kind==="dictionary")return I(i.values,e.values);if(e.kind==="indexed_collection")return i.kind==="indexed_collection"||i.kind==="list"?I(i.elements,e.elements):i.kind==="tuple"?i.elements.every(t=>I(t.type,e.elements)):!1;if(e.kind==="collection"){if(i.kind==="collection"||i.kind==="indexed_collection"||i.kind==="list")return I(i.elements,e.elements);if(i.kind==="tuple")return i.elements.every(t=>I(t.type,e.elements));if(i.kind==="set")return I(i.elements,e.elements);if(i.kind==="dictionary")return I({kind:"tuple",elements:[{type:"string"},{type:i.values}]},e.elements);if(i.kind==="record")return I({kind:"tuple",elements:[{type:"string"},{type:Lr(...Object.values(i.elements))}]},e.elements)}if(i.kind==="tuple"&&e.kind==="tuple"){if(i.elements.length!==e.elements.length)return!1;for(let t=0;t<i.elements.length;t++){let n=i.elements[t],r=e.elements[t];if(!I(n.type,r.type)||n.name!==r.name)return!1}return!0}if(e.kind==="list"&&i.kind==="list"){if(!I(i.elements,e.elements))return!1;if(e.dimensions){if(!i.dimensions||i.dimensions.length!==e.dimensions.length)return!1;for(let t=0;t<i.dimensions.length;t++)if(e.dimensions[t]!==-1&&i.dimensions[t]!==e.dimensions[t])return!1}return!0}if(i.kind==="symbol"&&e.kind==="symbol")return i.name===e.name;if(i.kind==="numeric"&&e.kind==="numeric")return!(!I(i.type,e.type)||(i.lower??-1/0)<(e.lower??-1/0)||(i.upper??1/0)>(e.upper??1/0));if(e.kind==="set"&&i.kind==="set")return!!I(i.elements,e.elements);if(i.kind==="negation"&&e.kind==="negation")return I(i.type,e.type);if(e.kind==="negation")return!I(i,e.type);if(e.kind==="value"&&i.kind==="value")return e.value===i.value;if(i.kind==="value"){if(typeof i.value=="boolean")return I("boolean",e);if(typeof i.value=="number")return Number.isInteger(i.value)?I("integer",e):I("real",e);if(typeof i.value=="string")return I("string",e)}return!1}function Xt(i){return typeof i=="string"?_t.has(i):i.kind==="value"?typeof i.value=="number":i.kind==="numeric"}function Ht(i){return Xt(i)?!0:typeof i=="string"?Zt.has(i):i.kind==="value"?["string","boolean","number"].includes(typeof i.value):!1}function Kt(i){return Qt(i)?!0:typeof i=="string"?qt.has(i):["collection","set","record","dictionary"].includes(i.kind)}function Qt(i){return typeof i=="string"?!1:["indexed_collection","list","tuple"].includes(i.kind)}function zt(i){return Ht(i)||Kt(i)}function en(i){return i==="function"||typeof i!="string"&&i.kind==="signature"}function Vr(i){return typeof i=="string"&&["expression","symbol","function"].includes(i)||zt(i)||en(i)||$i(i)?!0:typeof i=="string"?!1:i.kind==="expression"}function $i(i){return i==="symbol"?!0:typeof i=="string"?!1:i.kind==="symbol"?!0:i.kind==="expression"?i.operator==="Symbol":!1}function _r(i,e){if(i===e)return i;if(i==="any"||e==="any")return"any";if(i==="never")return e;if(e==="never")return i;if(i==="unknown")return e;if(e==="unknown")return i;if(i==="nothing")return e;if(e==="nothing")return i;if(I(i,e))return e;if(I(e,i))return i;let t=Gr(i,e);return qr.has(t)?Zr(i,e):t}var qr=new Set(["scalar","value","function","expression","collection","indexed_collection","list","set","tuple","record","dictionary","map","any"]);function Zr(i,e){let t=[],n=new Set,r=s=>{if(typeof s=="object"&&s.kind==="union"){for(let a of s.types)r(a);return}let o=typeof s=="string"?s:JSON.stringify(s);n.has(o)||(n.add(o),t.push(s))};return r(i),r(e),t.length===1?t[0]:{kind:"union",types:t}}function Lr(...i){return i.length===0?"nothing":i.length===1?i[0]:i.reduce((e,t)=>_r(e,t))}var jt=["non_finite_number","finite_integer","integer","finite_rational","rational","finite_real","real","imaginary","finite_complex","complex","finite_number","number","list","record","dictionary","set","tuple","indexed_collection","collection","scalar","value","function","expression"],$t=new Map;function Gr(i,e){if(i===e)return i;if(i==="any"||e==="any")return"any";if(i==="never")return e;if(e==="never")return i;if(i==="unknown")return e;if(e==="unknown")return i;if(i==="nothing")return e;if(e==="nothing")return i;if(typeof i=="string"&&typeof e=="string"){let t=i<e?`${i}|${e}`:`${e}|${i}`,n=$t.get(t);if(n===void 0){n="any";for(let r of jt){let s=Wt[r];if(s.has(i)&&s.has(e)){n=r;break}}$t.set(t,n)}return n}for(let t of jt)if(I(i,t)&&I(e,t))return t;return"any"}var X=class i extends R{rational;radical;im=0;factory;constructor(e,t){if(super(),this.factory=t,typeof e=="number"){!Number.isFinite(e)||Number.isInteger(e),this.rational=[e,1],this.radical=1;return}if(typeof e=="bigint"){this.rational=[e,BigInt(1)],this.radical=1;return}typeof e!="object"||"im"in e;let n=1;if(typeof n!="number"||Number.isInteger(n),n==0){this.rational=[0,1],this.radical=1;return}let r=e.rational?[...e.rational]:[1,1];n!=1&&(typeof n=="bigint"?r=L(r,[n,BigInt(1)]):r=L(r,[n,1])),this.rational=r,this.radical=e.radical??1,this.radical<=P&&this.radical>=1,this.normalize()}get type(){return this.isNaN?"number":this.isPositiveInfinity||this.isNegativeInfinity?"non_finite_number":this.radical!==1?(te(this.rational),"finite_real"):W(this.rational)?"finite_integer":"finite_rational"}get isExact(){return!0}get asExact(){return this}toJSON(){if(this.isNaN)return"NaN";if(this.isPositiveInfinity)return"PositiveInfinity";if(this.isNegativeInfinity)return"NegativeInfinity";if(this.isZero)return 0;if(this.isOne)return 1;if(this.isNegativeOne)return-1;let e=t=>W(t)?O(t[0]):["Rational",O(t[0]),O(t[1])];return this.radical===1?e(this.rational):We(this.rational)?["Sqrt",this.radical]:Xe(this.rational)?["Negate",["Sqrt",this.radical]]:this.rational[0]==1?["Divide",["Sqrt",this.radical],O(this.rational[1])]:this.rational[0]==-1?["Negate",["Divide",["Sqrt",this.radical],O(this.rational[1])]]:["Multiply",e(this.rational),["Sqrt",this.radical]]}clone(e){return new i(e,this.factory)}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";let e=n=>W(n)?x(n[0]):`${x(n[0])}/${x(n[1])}`;if(this.radical===1)return e(this.rational);let t=n=>`sqrt(${x(n)})`;return We(this.rational)?t(this.radical):Xe(this.rational)?`-${t(this.radical)}`:this.rational[0]==1?`${t(this.radical)}/${x(this.rational[1])}`:this.rational[0]==-1?`-${t(this.radical)}/${x(this.rational[1])}`:`${e(this.rational)}${t(this.radical)}`}get sign(){return te(this.rational)?0:$e(this.rational)?1:-1}get re(){return Ci(this.rational)*Math.sqrt(this.radical)}get bignumRe(){let e,t=this.rational;return A(t)?e=new u(t[0]).div(t[1]):e=new u(t[0]).div(new u(t[1])),this.radical===1?e:e.mul(new u(this.radical).sqrt())}get numerator(){return this.rational[1]==1?this:this.clone({rational:A(this.rational)?[this.rational[0],1]:[this.rational[0],BigInt(1)],radical:this.radical})}get denominator(){return A(this.rational)?this.clone(this.rational[1]):this.clone({rational:[this.rational[1],BigInt(1)]})}normalize(){if(Number.isInteger(this.radical)&&this.radical>0&&Number.isFinite(this.radical),isNaN(this.radical)){this.rational=[NaN,1],this.radical=1;return}let[e,t]=this.rational;if(t==0){this.rational=[NaN,1],this.radical=1;return}if(this.radical===0||e===0){this.rational=[0,1],this.radical=1;return}if(this.radical>=4){let[n,r]=ee(this.radical,2);n!==1&&(this.rational=L(this.rational,[n,1])),this.radical=r}this.rational=Be(this.rational)}get isNaN(){return Number.isNaN(this.rational[0])}get isPositiveInfinity(){return this.rational[0]==1/0}get isNegativeInfinity(){return this.rational[0]==-1/0}get isComplexInfinity(){return!1}get isZero(){return te(this.rational)}get isOne(){return!(this.rational[0]!==this.rational[1]||this.radical!==1)}get isNegativeOne(){return!(this.rational[0]!==-this.rational[1]||this.radical!==1)}sgn(){if(!Number.isNaN(this.rational[0]))return te(this.rational)?0:$e(this.rational)?1:-1}N(){return this.isZero||this.isOne||this.isNegativeOne?this:this.rational[1]==1&&this.radical===1?this:this.factory(this.bignumRe)}neg(){return this.isZero?this:this.clone({rational:Vi(this.rational),radical:this.radical})}inv(){return this.isNaN?this:this.isPositiveInfinity||this.isNegativeInfinity?this.clone(0):this.isZero?this.clone(1/0):this.isOne?this:this.isNegativeOne?this:this.clone({rational:L([BigInt(this.rational[1]),BigInt(1)],we([BigInt(this.rational[0])*BigInt(this.radical),BigInt(1)])),radical:this.radical})}add(e){return typeof e=="number"?e===0?this:Number.isInteger(e)&&this.radical===1?this.clone({rational:ne(this.rational,[e,1])}):this.factory(this.bignumRe).add(e):e.isZero?this:this.isZero?e:e instanceof i?this.radical===e.radical?this.clone({rational:ne(this.rational,e.rational),radical:this.radical}):this.factory(this.bignumRe).add(e):e.add(this)}sub(e){return this.add(e.neg())}mul(e){if(e===0)return this.isPositiveInfinity||this.isNegativeInfinity||this.isNaN?this.clone(NaN):this.clone(0);if(e===1)return this;if(e===-1)return this.neg();if(typeof e=="number")return Number.isInteger(e)?this.clone({rational:L(this.rational,[e,1]),radical:this.radical}):this.factory(this.bignumRe).mul(e);if(e instanceof u)return this.factory(e).mul(this);if(e.im!==0)return e.mul(this);if(e.isZero)return this.isPositiveInfinity||this.isNegativeInfinity||this.isNaN?this.clone(NaN):e;if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isNaN)return e;if(this.isZero)return e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN?this.clone(NaN):this;if(this.isOne)return e;if(this.isNegativeOne)return e.neg();if(!(e instanceof i))return e.mul(this);let t=BigInt(this.radical)*BigInt(e.radical);return t>BigInt(P)?this.factory(this.bignumRe).mul(e):this.clone({rational:L(this.rational,e.rational),radical:Number(t)})}div(e){if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({rational:L(this.rational,[1,e]),radical:this.radical});if(this.isNaN)return this;if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(this.isZero)return e.isZero?this.clone(NaN):e.isNaN?e:this;if(e.isNaN)return e;if(e.isZero)return this.clone(this.sign*(1/0));if(!(e instanceof i))return this.factory(this.bignumRe).div(e);if(e.im!==0)return this.factory(this.bignumRe).div(e);let t=L(this.rational,[BigInt(e.rational[1]),BigInt(e.rational[0])*BigInt(e.radical)]),n=BigInt(this.radical)*BigInt(e.radical);return n>BigInt(P)?this.factory(this.bignumRe).div(e):this.clone({rational:t,radical:Number(n)})}pow(e){if(Array.isArray(e),this.isNaN)return this;if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;if(e.im)e={re:e.re,im:e.im};else{if(e instanceof i&&e.radical===1&&e.rational[0]==1)return this.root(Number(e.rational[1]));e=e.re}}if(e===.5)return this.sqrt();if(typeof e=="object"&&("re"in e||"im"in e))return this.factory(this.bignumRe).pow(e);if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.factory({im:1/0})}if(e<0)return this.pow(-e).inv();if(e%1===.5)return this.pow(Math.floor(e)).mul(this.sqrt());if(this.radical>P||this.rational[0]>P||this.rational[0]<-P||this.rational[1]>P)return this.factory(this.bignumRe).pow(e);if(this.sign<0){if(Number.isInteger(e)){let t=e%2===0?1:-1,n=BigInt(e),r=BigInt(this.radical)**n;return r>BigInt(P)?this.factory(this.bignumRe).pow(e):this.clone({rational:[BigInt(t)*(-BigInt(this.rational[0]))**n,BigInt(this.rational[1])**n],radical:Number(r)})}return this.factory({im:(-this.re)**e})}else if(Number.isInteger(e)){let t=BigInt(e),n=BigInt(this.radical)**t;return n>BigInt(P)?this.factory(this.bignumRe).pow(e):this.clone({rational:[BigInt(this.rational[0])**t,BigInt(this.rational[1])**t],radical:Number(n)})}return this.factory(this.bignumRe).pow(e)}root(e){if(e===0)return this.clone(NaN);if(this.isNaN)return this;if(this.isZero)return this;if(e===1)return this;if(e===-1)return this.inv();if(e<0)return this.root(-e).inv();if(e%1===.5)return this.root(Math.floor(e)).sqrt();if(this.sign<0&&Number.isInteger(e)&&e%2===1)return this.neg().root(e).neg();if(this.radical===1){if(this.sign>0){let t=this.re;if(Number.isInteger(t)){if(t>0){let n=Math.pow(t,1/e);if(Number.isInteger(n))return this.clone(n)}return this.factory(this.bignumRe).root(e)}}return this.factory(this.bignumRe).root(e)}if(this.sign<0)return this.factory({im:Math.pow(-this.re,1/e)});if(this.radical>P||this.rational[0]>P||this.rational[0]<-P||this.rational[1]>P)return this.factory(this.bignumRe).root(e);if(this.rational[1]==1){let t=Math.pow(this.rational[0],1/e);if(Number.isInteger(t))return this.clone(t)}return this.factory(this.bignumRe).root(e)}sqrt(){if(this.isZero||this.isOne)return this;if(this.radical===1)if(A(this.rational)){let[e,t]=this.rational;return e*t>P?this.factory(this.bignumRe).sqrt():e>0?this.clone({radical:e*t,rational:[1,t]}):this.factory({im:Math.sqrt(-e*t)/t})}else return this.factory(this.bignumRe).sqrt();if(this.sign>0){let e=Math.sqrt(this.re);if(Number.isInteger(e))return this.clone(e)}return this.factory(this.bignumRe).sqrt()}gcd(e){if(!(e instanceof i))return e.gcd(this);if(this.isOne||e.im!==0||e.isOne)return this.clone(1);let t=_i(this.rational,e.rational),n=_(this.radical,e.radical);return this.clone({rational:t,radical:n})}abs(){return this.sign===-1?this.neg():this}ln(e){return this.isZero?this.clone(NaN):this.isPositiveInfinity?this.clone(1/0):this.sign<0?this.clone(NaN):this.isOne?this.clone(0):this.isNegativeOne?this.factory({im:Math.PI}):this.factory(this.bignumRe).ln(e)}exp(){return this.isNaN?this.clone(NaN):this.isZero?this.clone(1):this.isNegativeInfinity?this.clone(0):this.isPositiveInfinity?this.clone(1/0):this.factory(this.bignumRe).exp()}_integerPart(e){let t=BigInt(this.rational[0]),n=BigInt(this.rational[1]);n<0n&&(t=-t,n=-n);let r;if(e==="round"){let s=2n*t+n,o=2n*n;r=s/o,s%o!==0n&&s<0n&&(r-=1n)}else r=t/n,t%n!==0n&&(e==="floor"&&t<0n&&(r-=1n),e==="ceil"&&t>0n&&(r+=1n));return this.clone({rational:[r,BigInt(1)],radical:1})}floor(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("floor"):this.clone(Math.floor(this.re))}ceil(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("ceil"):this.clone(Math.ceil(this.re))}round(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("round"):this.clone(Math.round(this.re))}eq(e){return typeof e=="number"?this.radical===1&&W(this.rational)&&this.rational[0]==e:e instanceof i?this.radical===e.radical&&this.rational[0]==e.rational[0]&&this.rational[1]==e.rational[1]:e.im===0&&e.re===this.re}lt(e){if(this.im===0)return typeof e=="number"?this.re<e:this.re<e.re}lte(e){if(this.im===0)return typeof e=="number"?this.re<=e:this.re<=e.re}gt(e){if(this.im===0)return typeof e=="number"?this.re>e:this.re>e.re}gte(e){if(this.im===0)return typeof e=="number"?this.re>=e:this.re>=e.re}static sum(e,t){if(e.length===1)return e;if(e.some(a=>!a.isExact)){if(e.length===2)return[e[0].add(e[1])];let a=t(0);for(let c of e)a=a.add(c);return[a]}let n=0,r=[0,1],s=[];for(let a of e){if(a.isNaN)return[new i(NaN,t)];if(!a.isZero)if(n+=a.im,a instanceof i){let c=a.rational;if(a.radical===1)r=ne(r,c);else{let l=s.findIndex(m=>m.radical===a.radical);l===-1?s.push({multiple:c,radical:a.radical}):s[l].multiple=ne(s[l].multiple,c)}}else{I(a.type,"integer");let c=BigInt(a.bignumRe.toFixed(0));r=ne(r,[c,BigInt(1)])}}if(te(r)&&s.length===0)return n===0?[new i(0,t)]:[t({im:n})];let o=[];return n!==0&&o.push(t({im:n})),s.length===0?o.push(new i({rational:r},t)):(s.push({multiple:r,radical:1}),o.push(...s.map(a=>new i({rational:a.multiple,radical:a.radical},t)))),o}};function Wi(i,e){for(i.isInteger()&&e.isInteger();!e.isZero();)[i,e]=[e,i.mod(e)];return i.abs()}function tn(i,e){return i.mul(e).div(Wi(i,e)).abs()}function*nn(i){if(!i.isInteger()||i.isNegative())return u.NAN;if(i.lt(1))return u.ONE;let e=i;for(;i.gt(2);)i=i.sub(2),e=e.mul(i),yield e;return e}function xe(i){if(!i.isFinite()||i.isZero())return!0;let n=(i.significand<0n?-i.significand:i.significand).toString().length;if(n>17)return!1;let r=n+i.exponent-1;return r<309&&r>-308}var ni=class i extends R{decimal;constructor(e){if(super(),typeof e=="number")this.decimal=new u(e),this.im=0;else if(e instanceof u)this.decimal=e,this.im=0;else{let t=e.re instanceof u?e.re:new u(e.re??0);this.decimal=t,this.im=e.im??0}this.decimal.isNaN()?this.im=NaN:isNaN(this.im)&&(this.decimal=u.NAN)}get type(){return this.isNaN?"number":this.isComplexInfinity?"complex":this.im!==0?this.decimal.isZero()?"imaginary":"finite_complex":this.decimal.isFinite()?this.decimal.isInteger()?"finite_integer":"finite_real":"non_finite_number"}get isExact(){return this.im===0&&this.decimal.isInteger()}get asExact(){if(this.isExact)return this._makeExact(V(this.decimal))}toJSON(){return this.isNaN?"NaN":this.isPositiveInfinity?"PositiveInfinity":this.isNegativeInfinity?"NegativeInfinity":this.isComplexInfinity?"ComplexInfinity":this.im===0?xe(this.decimal)?this.decimal.toNumber():{num:ti(this.decimal)}:xe(this.decimal)?["Complex",O(this.decimal.toNumber()),O(this.im)]:["Complex",{num:ti(this.decimal)},O(this.im)]}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";if(this.im===0)return ti(this.decimal.toPrecision(u.precision));if(this.decimal.isZero())return this.im===1?"i":this.im===-1?"-i":`${x(this.im)}i`;if(this.isComplexInfinity)return"~oo";let e="";return this.im===1?e="+ i":this.im===-1?e="- i":this.im>0?e=`+ ${this.im}i`:e=`- ${-this.im}i`,`(${ti(this.decimal)} ${e})`}clone(e){return new i(e)}_makeExact(e){return new X(e,t=>this.clone(t))}get re(){return this.decimal.toNumber()}get bignumRe(){return this.decimal}get numerator(){return this}get denominator(){return this._makeExact(1)}get isNaN(){return this.decimal.isNaN()}get isPositiveInfinity(){return this.im===0&&!this.decimal.isFinite()&&!this.decimal.isNaN()&&this.decimal.isPositive()}get isNegativeInfinity(){return this.im===0&&!this.decimal.isFinite()&&!this.decimal.isNaN()&&this.decimal.isNegative()}get isComplexInfinity(){return!Number.isFinite(this.im)&&!Number.isNaN(this.im)}get isZero(){return this.im===0&&this.decimal.isZero()}isZeroWithTolerance(e){let t=typeof e=="number"?e:e.toNumber();if(Math.abs(this.im)>t)return!1;let n=typeof e=="number"?new u(e):e;return this.decimal.abs().lte(n)}get isOne(){return this.im===0&&this.decimal.eq(1)}get isNegativeOne(){return this.im===0&&this.decimal.eq(-1)}sgn(){if(this.im===0){if(this.decimal.isZero())return 0;if(this.decimal.isPositive())return 1;if(this.decimal.isNegative())return-1}}N(){return this}neg(){return this.isZero?this:this.clone({re:this.decimal.neg(),im:-this.im})}inv(){if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.clone(this.decimal.inv());let e=this.re*this.re+this.im*this.im,t=this.decimal.mul(this.decimal).add(this.im*this.im);return this.clone({re:this.decimal.div(t),im:-this.im/e})}add(e){return typeof e=="number"?e===0?this:this.clone({re:this.decimal.add(e),im:this.im}):e.isZero?this:this.isZero?this.clone({re:e.bignumRe??e.re,im:e.im}):this.clone({re:this.decimal.add(e.bignumRe??e.re),im:this.im+e.im})}sub(e){return this.add(e.neg())}mul(e){if(this.isZero)return e instanceof R&&(e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN)?this._makeExact(NaN):this;if(e===1)return this;if(e===-1)return this.neg();if(e===0)return this.isNaN||this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0);if(this.isOne)return typeof e=="number"||e instanceof u?this.clone(e):this.clone({re:e.bignumRe??e.re,im:e.im});if(typeof e=="number")return this.im===0?this.clone(this.decimal.mul(e)):this.clone({re:this.decimal.mul(e),im:this.im*e});if(e instanceof u)return this.im===0?this.clone(this.decimal.mul(e)):this.clone({re:this.decimal.mul(e),im:this.im*e.toNumber()});if(this.isNegativeOne){let t=e.neg();return this.clone({re:t.bignumRe??t.re,im:t.im})}return e.isOne?this:e.isNegativeOne?this.neg():e.isZero?this.isNaN||this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0):this.im===0&&e.im===0?this.clone(this.decimal.mul(e.bignumRe??e.re)):this.clone({re:this.decimal.mul(e.bignumRe??e.re).sub(this.im*e.im),im:this.re*e.im+this.im*e.re})}div(e){if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({re:this.decimal.div(e),im:this.im/e});if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isZero)return this.isZero||this.isNaN?this.clone(NaN):this.im!==0?this.clone({im:1/0}):this.clone(this.decimal.isNegative()?-1/0:1/0);if(this.im===0&&e.im===0)return this.clone(this.decimal.div(e.bignumRe??e.re));let[t,n]=[this.re,this.im],[r,s]=[e.re,e.im],o=r*r+s*s,a=e.bignumRe??new u(e.re),c=a.mul(a).add(s*s);return this.clone({re:this.decimal.mul(a).add(n*s).div(c),im:(n*r-t*s)/o})}pow(e){if(Array.isArray(e),this.isNaN)return this;if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;e.im?e={re:e.re,im:e.im}:e=e.re}if(typeof e=="object"&&("re"in e||"im"in e)){let[c,l]=[e?.re??0,e?.im??0];if(Number.isNaN(l)||Number.isNaN(c))return this.clone(NaN);if(l===0)e=c;else{if(this.im===1/0)return this.clone(NaN);if(this.isNegativeInfinity)return this.clone(0);if(this.isPositiveInfinity)return this.clone({im:1/0});if(this.isZero)return c>0?this.clone(0):this.clone(NaN);let m=this.decimal,f=this.im,d=m.mul(m).add(f*f).sqrt().ln(),h=u.atan2(f,m),N=d.mul(c).sub(h.mul(l)),p=h.mul(c).add(d.mul(l)),g=N.exp();return this.clone({re:g.mul(p.cos()),im:fe(g.mul(p.sin()).toNumber())})}}if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.clone({im:1/0})}if(e<0)return this.pow(-e).inv();if(this.im===0)return this.clone(this.decimal.pow(e));let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t),o=r.pow(e),a=s.mul(e);return this.clone({re:o.mul(a.cos()),im:fe(o.mul(a.sin()).toNumber())})}root(e){if(!Number.isInteger(e))return this._makeExact(NaN);if(e===0)return this._makeExact(NaN);if(e===1)return this;if(this.isZero)return this;if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.decimal.isNegative()?e%2===0?this._makeExact(NaN):e===3?this.clone(this.decimal.cbrt()):this.clone(this.decimal.neg().ln().div(e).exp().neg()):e===2?this.clone(this.decimal.sqrt()):e===3?this.clone(this.decimal.cbrt()):this.clone(this.decimal.ln().div(e).exp());let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t),o=r.ln().div(e).exp(),a=s.div(e);return this.clone({re:o.mul(a.cos()),im:fe(o.mul(a.sin()).toNumber())})}sqrt(){if(this.isZero||this.isOne)return this;if(this.im!==0){let e=this.decimal,t=this.im,n=e.mul(e).add(t*t).sqrt(),r=e.add(n).div(2),s=n.sub(e).div(2),o=r.isNegative()?u.ZERO:r.sqrt(),a=fe(Math.sign(t)*(s.isNegative()?0:s.sqrt().toNumber()));return this.clone({re:o,im:a})}return this.decimal.isPositive()?this.clone(this.decimal.sqrt()):this.clone({im:Math.sqrt(-this.re)})}gcd(e){if(this.isZero)return e;if(e.isZero)return this;if(this.im!==0||e.im!==0)return this._makeExact(NaN);if(!this.decimal.isInteger())return this._makeExact(1);let t=e.bignumRe?new u(e.bignumRe):new u(e.re);if(!t.isInteger())return this._makeExact(1);let n=this.decimal;for(;!t.isZero();){let r=t;t=n.mod(t),n=r}return this.clone(n.abs())}abs(){return this.im===0?this.decimal.isPositive()?this:this.clone(this.decimal.neg()):this.clone(this.decimal.pow(2).add(this.im**2).sqrt())}ln(e){if(this.isZero)return this._makeExact(NaN);if(this.isNegativeInfinity)return this._makeExact(NaN);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im===0)return this.decimal.isNegative()?this._makeExact(NaN):this.isOne?this._makeExact(0):this.isNegativeOne?this.clone({im:Math.PI}):e===void 0?this.clone(this.decimal.ln()):this.clone(this.decimal.log(e));let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t).toNumber();return e===void 0?this.clone({re:r.ln(),im:s}):this.clone({re:r.log(e),im:s})}exp(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(1);if(this.isNegativeInfinity)return this._makeExact(0);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im!==0){let e=this.decimal.exp();return this.clone({re:e.mul(fe(Math.cos(this.im))),im:fe(e.mul(Math.sin(this.im)).toNumber())})}return this.clone(this.decimal.exp())}floor(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.floor()))}ceil(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.ceil()))}round(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.round()))}eq(e){return this.isNaN?!1:typeof e=="number"?this.im===0&&this.decimal.eq(e):e.isNaN?!1:Number.isFinite(this.im)?this.decimal.eq(e.bignumRe??e.re)&&this.im-e.im===0:!Number.isFinite(e.im)}lt(e){if(this.im===0)return typeof e=="number"?this.decimal.lt(e):this.decimal.lt(e.bignumRe??e.re)}lte(e){if(this.im===0)return typeof e=="number"?this.decimal.lte(e):this.decimal.lte(e.bignumRe??e.re)}gt(e){if(this.im===0)return typeof e=="number"?this.decimal.gt(e):this.decimal.gt(e.bignumRe??e.re)}gte(e){if(this.im===0)return typeof e=="number"?this.decimal.gte(e):this.decimal.gte(e.bignumRe??e.re)}};function ti(i){let e=i.toString();if(i.isInteger()&&e.includes("e")){let t=i.toFixed(0),n=t.match(/0+$/);if((n?n[0].length:0)<=5)return t}return e}function fe(i){return Math.abs(i)<=1e-14?0:i}var ri=class i extends R{decimal;constructor(e){if(super(),typeof e=="number")this.decimal=e,this.im=0;else if(e instanceof u)this.decimal=e.toNumber(),this.im=0;else{let t=e.re===void 0?0:e.re instanceof u?e.re.toNumber():e.re;this.decimal=t,this.im=e.im??0,isFinite(this.im)||(this.decimal=this.im)}isNaN(this.im)}_makeExact(e){return new X(e,t=>this.clone(t))}get type(){return this.isNaN?"number":this.isComplexInfinity?"complex":this.im!==0?this.decimal===0?"imaginary":"finite_complex":Number.isFinite(this.decimal)?Number.isInteger(this.decimal)?"finite_integer":"finite_real":"non_finite_number"}get isExact(){return this.im===0&&Number.isInteger(this.decimal)}get asExact(){if(this.isExact)return this._makeExact(this.decimal)}toJSON(){return this.isNaN?"NaN":this.isPositiveInfinity?"PositiveInfinity":this.isNegativeInfinity?"NegativeInfinity":this.im===0?O(this.decimal):["Complex",O(this.decimal),O(this.im)]}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";if(this.im===0)return x(this.decimal);if(this.decimal===0)return this.im===1?"i":this.im===-1?"-i":`${x(this.im)}i`;if(this.isComplexInfinity)return"~oo";let e="";return this.im===1?e="+ i":this.im===-1?e="- i":this.im>0?e=`+ ${x(this.im)}i`:e=`- ${x(-this.im)}i`,`(${x(this.decimal)} ${e})`}clone(e){return new i(e)}get re(){return this.decimal}get bignumRe(){}get numerator(){return this}get denominator(){return this._makeExact(1)}get isNaN(){return Number.isNaN(this.decimal)}get isPositiveInfinity(){return!Number.isFinite(this.decimal)&&this.decimal>0&&this.im===0}get isNegativeInfinity(){return!Number.isFinite(this.decimal)&&this.decimal<0&&this.im===0}get isComplexInfinity(){return!Number.isFinite(this.im)&&!Number.isNaN(this.im)}get isZero(){return this.im===0&&this.decimal===0}isZeroWithTolerance(e){let t=e instanceof u?e.toNumber():e;return Math.abs(this.im)<=t&&Math.abs(this.decimal)<t}get isOne(){return this.im===0&&this.decimal===1}get isNegativeOne(){return this.im===0&&this.decimal===-1}sgn(){if(!(this.im!==0||!Number.isFinite(this.decimal)))return Math.sign(this.decimal)}N(){return this}neg(){return this.isNaN?this._makeExact(NaN):this.isZero?this:this.clone({re:-this.decimal,im:-this.im})}inv(){if(this.isNaN)return this._makeExact(NaN);if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.clone(1/this.decimal);let e=this.re*this.re+this.im*this.im;return this.clone({re:this.decimal/e,im:-this.im/e})}add(e){return this.isNaN?this._makeExact(NaN):typeof e=="number"?e===0?this:this.clone({re:this.decimal+e,im:this.im}):e.isZero?this:this.isZero?this.clone({re:e.bignumRe??e.re,im:e.im}):this.clone({re:this.decimal+e.re,im:this.im+e.im})}sub(e){return this.add(e.neg())}mul(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return e instanceof R&&(e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN)?this._makeExact(NaN):this;if(e instanceof u&&(e=e.toNumber()),e===1)return this;if(e===-1)return this.neg();if(e===0)return this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0);if(this.isOne)return typeof e=="number"||e instanceof u?this.clone(e):this.clone({re:e.bignumRe??e.re,im:e.im});if(typeof e=="number")return this.im===0?this.clone(this.decimal*e):this.clone({re:this.decimal*e,im:this.im*e});if(this.isNegativeOne){let t=e.neg();return this.clone({re:t.bignumRe??t.re,im:t.im})}return e.isOne?this:e.isNegativeOne?this.neg():e.isZero?this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0):this.im===0&&e.im===0?this.clone(this.decimal*e.re):this.clone({re:this.decimal*e.re-this.im*e.im,im:this.re*e.im+this.im*e.re})}div(e){if(this.isNaN)return this._makeExact(NaN);if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({re:this.decimal/e,im:this.im/e});if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isZero)return this.clone(this.isZero?NaN:1/0);if(this.im===0&&e.im===0)return this.clone(this.decimal/e.re);let[t,n]=[this.decimal,this.im],[r,s]=[e.re,e.im],o=r*r+s*s;return this.clone({re:(t*r+n*s)/o,im:(n*r-t*s)/o})}pow(e){if(Array.isArray(e),this.isNaN)return this._makeExact(NaN);if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;e.im?e={re:e.re,im:e.im}:e=e.re}if(typeof e=="object"&&("re"in e||"im"in e)){let[c,l]=[e?.re??0,e?.im??0];if(Number.isNaN(l)||Number.isNaN(c))return this.clone(NaN);if(l===0)e=c;else{if(this.im===1/0)return this.clone(NaN);if(this.isNegativeInfinity)return this.clone(0);if(this.isPositiveInfinity)return this.clone({im:1/0});if(this.isZero)return c>0?this.clone(0):this.clone(NaN);let m=this.decimal,f=this.im,d=.5*Math.log(m*m+f*f),h=Math.atan2(f,m),N=c*d-l*h,p=c*h+l*d,g=Math.exp(N);return this.clone({re:rn(g*Math.cos(p)),im:rn(g*Math.sin(p))})}}if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.clone({im:1/0})}if(e<0&&this.im===0)return this.clone(1/this.decimal**-e);if(this.im===0)return this.clone(this.decimal**e);let t=this.decimal,n=this.im,r=Math.sqrt(t*t+n*n),s=Math.atan2(n,t),o=r**e,a=s*e;return this.clone({re:o*Math.cos(a),im:o*Math.sin(a)})}root(e){if(this.isNaN)return this._makeExact(NaN);if(e===0)return this.clone(NaN);if(this.isNaN)return this;if(this.isZero)return this;if(this.isOne)return this;if(this.isNegativeOne)return this;if(e===1)return this;if(e===2)return this.sqrt();if(e===3)return this.clone(Math.cbrt(this.decimal));if(this.im===0)return this.decimal<0?e%2===0?this.clone(NaN):this.clone(-Math.pow(-this.decimal,1/e)):this.clone(Math.pow(this.decimal,1/e));let t=this.decimal,n=this.im,r=Math.hypot(t,n),s=Math.atan2(n,t),o=Math.pow(r,1/e),a=s/e;return this.clone({re:o*Math.cos(a),im:o*Math.sin(a)})}sqrt(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero||this.isOne)return this;if(this.im!==0){let e=this.decimal,t=this.im,n=Math.sqrt(e*e+t*t),r=Math.sqrt((e+n)/2),s=Math.sign(t)*Math.sqrt((n-e)/2);return this.clone({re:r,im:s})}return this.decimal>0?this.clone(Math.sqrt(this.decimal)):this.clone({im:Math.sqrt(-this.decimal)})}gcd(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return e;if(e.isZero)return this;if(this.im!==0||e.im!==0)return this._makeExact(NaN);if(!Number.isInteger(this.decimal))return this._makeExact(1);let t=e.re;if(!Number.isInteger(t))return this._makeExact(1);let n=this.decimal;for(;t!==0;){let r=t;t=n%t,n=r}return this.clone(Math.abs(n))}abs(){return this.isNaN?this._makeExact(NaN):this.im===0?this.decimal>0?this:this.clone(-this.decimal):this.clone(Math.sqrt(this.decimal**2+this.im**2))}ln(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(NaN);if(this.isNegativeInfinity)return this._makeExact(NaN);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im===0)return this.decimal<0?this._makeExact(NaN):this.isOne?this._makeExact(0):this.isNegativeOne?this.clone({im:Math.PI}):e===void 0?this.clone(Math.log(this.decimal)):this.clone(Math.log(this.decimal)/Math.log(e));let t=this.decimal,n=this.im,r=Math.hypot(t,n),s=Math.atan2(n,t),o=e===void 0?Math.log(r):Math.log(r)/Math.log(e);return this.clone({re:o,im:s})}exp(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(1);if(this.isNegativeInfinity)return this._makeExact(0);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im!==0){let e=Math.exp(this.decimal);return this.clone({re:e*Math.cos(this.im),im:e*Math.sin(this.im)})}return this.clone(Math.exp(this.decimal))}floor(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.floor(this.decimal))}ceil(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.ceil(this.decimal))}round(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.round(this.decimal))}eq(e){return this.isNaN?!1:typeof e=="number"?this.im===0&&this.decimal===e:e.isNaN?!1:Number.isFinite(this.im)?this.decimal===e.re&&this.im===e.im:!Number.isFinite(e.im)}lt(e){if(this.im===0)return typeof e=="number"?this.decimal<e:this.decimal<e.re}lte(e){if(this.im===0)return typeof e=="number"?this.decimal<=e:this.decimal<=e.re}gt(e){if(this.im===0)return typeof e=="number"?this.decimal>e:this.decimal>e.re}gte(e){if(this.im===0)return typeof e=="number"?this.decimal>=e:this.decimal>=e.re}};function rn(i){return Math.abs(i)<=1e-14?0:i}function sn(i){return i?._kind==="number"}function Yr(i){return i?._kind==="symbol"}function Pe(i,e){return(i?._kind==="function"||i?._kind==="tensor")&&(e===void 0||i.operator===e)}function Ur(i){if(Pe(i,"Interval")){let e=i.op1,t=i.op2,n=!1,r=!1;Pe(e,"Open")?(n=!0,e=e.op1):Pe(e,"Closed")&&(e=e.op1),Pe(t,"Open")?(r=!0,t=t.op1):Pe(t,"Closed")&&(t=t.op1);let s=e.N(),o=t.N();return!sn(s)||!sn(o)?void 0:{start:s.re,openStart:n,end:o.re,openEnd:r}}if(Yr(i)){if(i.symbol==="EmptySet")return{start:0,openStart:!0,end:0,openEnd:!0};if(i.symbol==="RealNumbers")return{start:-1/0,openStart:!1,end:1/0,openEnd:!1};if(i.symbol==="NegativeNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!0};if(i.symbol==="NonPositiveNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!1};if(i.symbol==="PositiveNumbers")return{start:0,openStart:!0,end:1/0,openEnd:!1};if(i.symbol==="NonNegativeNumbers")return{start:0,openStart:!1,end:1/0,openEnd:!1}}}function Jr(i,e){return!((i.openStart?e<=i.start:e<i.start)||(i.openEnd?e>=i.end:e>i.end))}function jr(i,e){if(!i.openStart&&e.openStart){if(i.start<=e.start)return!1}else if(i.start<e.start)return!1;if(!i.openEnd&&e.openEnd){if(i.end>=e.end)return!1}else if(i.end>e.end)return!1;return!0}function on(i){let e=i.length;if(e===1)return i[0][0];if(e===2)return i[0][0]*i[1][1]-i[0][1]*i[1][0];let t=[],n=0;for(let r=0;r<e;r++){let s=0;for(let o=1;o<e;o++){let a=0;for(let c=0;c<e;c++)c!==r&&(t[s][a]=i[o][c],a++);s++}n=n+Math.pow(-1,r)*i[0][r]*on(t)}return n}function $r(i,e){if(e===0)return{estimate:i,error:e};let t=Math.abs(e),n=Math.floor(Math.log10(t)),r=2,s=Math.pow(10,n-(r-1)),o=Math.round(e/s)*s,a=Math.max(0,-(n-(r-1)));return{estimate:Number(i.toFixed(a)),error:o}}function Wr(i,e,t,n=1e5,r){r??=qe();let s;e===-1/0&&t===1/0?s=()=>{let g=Math.random(),b=Math.tan(Math.PI*(g-.5));return i(b)*Math.PI*(1+b*b)}:e===-1/0?s=()=>{let g=Math.random();return i(t+Math.log(g))/g}:t===1/0?s=()=>{let g=Math.random();return i(e-Math.log(g))/g}:s=()=>i(e+Math.random()*(t-e));let o=0,a=0,c=0;Ze(r,()=>{for(let g=0;g<n;g++){if((g&63)===0&&r!==void 0&&Date.now()>=r){g===0&&le(r);break}let b;try{b=s()}catch(T){if(T instanceof Ee&&c>0)break;throw T}o+=b,a+=b*b,c++}});let l=o/c,m=(a-c*l*l)/(c-1),f=Math.sqrt(m/c),d=isFinite(e)&&isFinite(t)?t-e:1,h=l*d,N=f*d;return $r(h,N)}function Xr(i){let e=0,t=0;for(let n of i)e+=n,t++;return t===0?NaN:e/t}function Hr(i){let e=u.ZERO,t=0;for(let n of i)e=e.add(n),t++;return t===0?u.NAN:e.div(new u(t))}function si(i){let e=[...i].sort((n,r)=>n-r),t=Math.floor(e.length/2);return e.length%2===0?(e[t-1]+e[t])/2:e[t]}function oi(i){let e=[...i].sort((n,r)=>n.cmp(r)),t=Math.floor(e.length/2);return e.length%2===0?e[t-1].add(e[t]).div(u.TWO):e[t]}function un(i){let e=0,t=0,n=0;for(let r of i)e+=r,t+=r*r,n++;return n===0?NaN:(t-e*e/n)/(n-1)}function an(i){let e=u.ZERO,t=u.ZERO,n=0;for(let r of i)e=e.add(r),t=t.add(r.mul(r)),n++;return n===0?u.NAN:t.sub(e.mul(e).div(new u(n))).div(new u(n-1))}function cn(i){let e=0,t=0,n=0;for(let r of i)e+=r,t+=r*r,n++;return n===0?NaN:(t-e*e/n)/n}function ln(i){let e=u.ZERO,t=u.ZERO,n=0;for(let r of i)e=e.add(r),t=t.add(r.mul(r)),n++;return n===0?u.NAN:t.sub(e.mul(e).div(new u(n))).div(new u(n))}function Kr(i){return Math.sqrt(un(i))}function Qr(i){return an(i).sqrt()}function zr(i){return Math.sqrt(cn(i))}function es(i){return ln(i).sqrt()}function is(i){let e=0,t=0,n=0,r=0,s=0;for(let m of i){let f=m;if(!Number.isFinite(f))return NaN;e+=f,t+=f*f,n+=f*f*f,r+=f*f*f*f,s++}if(s===0)return NaN;let o=s,a=e/o,c=(t-e*e/o)/o;return(r-4*a*n+6*a*a*t-4*a*a*a*e+o*a*a*a*a)/o/(c*c)}function ts(i){let e=u.ZERO,t=u.ZERO,n=u.ZERO,r=u.ZERO,s=0;for(let l of i){let m=l;if(!m.isFinite())return u.NAN;e=e.add(m),t=t.add(m.mul(m)),n=n.add(m.mul(m).mul(m)),r=r.add(m.mul(m).mul(m).mul(m)),s++}if(s===0)return u.NAN;let o=e.div(s),a=t.sub(e.mul(e).div(s)).div(s);return r.sub(o.mul(n).mul(4)).add(o.mul(o).mul(t).mul(6)).sub(o.mul(o).mul(o).mul(e).mul(4)).add(o.mul(o).mul(o).mul(o).mul(s)).div(s).div(a.mul(a))}function ns(i){let e=0,t=0,n=0,r=0;for(let l of i){let m=l;if(!Number.isFinite(m))return NaN;e+=m,t+=m*m,n+=m*m*m,r++}if(r===0)return NaN;let s=r,o=e/s,a=(t-e*e/s)/s;return(n-3*o*t+3*o*o*e-s*o*o*o)/s/Math.pow(a,3/2)}function rs(i){let e=u.ZERO,t=u.ZERO,n=u.ZERO,r=0;for(let c of i){let l=c;if(!l.isFinite())return u.NAN;e=e.add(l),t=t.add(l.mul(l)),n=n.add(l.mul(l).mul(l)),r++}if(r===0)return u.NAN;let s=e.div(r),o=t.sub(e.mul(e).div(r)).div(r);return n.sub(s.mul(t).mul(3)).add(s.mul(s).mul(e).mul(3)).sub(s.mul(s).mul(s).mul(r)).div(r).div(o.mul(o.sqrt()))}function ss(i){let e={};for(let r of i)e[r]=(e[r]??0)+1;let t=0,n=NaN;for(let r in e){let s=e[r];s>t&&(t=s,n=+r)}return n}function os(i){let e={};for(let r of i)e[r.toString()]=(e[r.toString()]??0)+1;let t=0,n=u.NAN;for(let r in e){let s=e[r];s>t&&(t=s,n=new u(r))}return n}function mn(i){let e=[...i].sort((o,a)=>o-a),t=Math.floor(e.length/2),n=si(e.slice(0,t)),r=si(e),s=si(e.slice(t));return[n,r,s]}function fn(i){let e=[...i].sort((o,a)=>o.cmp(a)),t=Math.floor(e.length/2),n=oi(e.slice(0,t)),r=oi(e),s=oi(e.slice(t));return[n,r,s]}function us(i){let[e,,t]=mn(i);return t-e}function as(i){let[e,,t]=fn(i);return t.sub(e)}var ui={Q:1e30,R:1e27,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,G:1e9,M:1e6,k:1e3,h:100,da:10,d:.1,c:.01,m:.001,\u00B5:1e-6,\u03BC:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-24,r:1e-27,q:1e-30},dn=new Set(["m","g","s","A","K","mol","cd","Hz","N","Pa","J","W","C","V","F","ohm","S","Wb","T","H","lm","lx","Bq","Gy","Sv","kat","eV","L","bar"]),ai={m:{dimension:[1,0,0,0,0,0,0],scale:1},kg:{dimension:[0,1,0,0,0,0,0],scale:1},g:{dimension:[0,1,0,0,0,0,0],scale:.001},s:{dimension:[0,0,1,0,0,0,0],scale:1},A:{dimension:[0,0,0,1,0,0,0],scale:1},K:{dimension:[0,0,0,0,1,0,0],scale:1},mol:{dimension:[0,0,0,0,0,1,0],scale:1},cd:{dimension:[0,0,0,0,0,0,1],scale:1},Hz:{dimension:[0,0,-1,0,0,0,0],scale:1},N:{dimension:[1,1,-2,0,0,0,0],scale:1},Pa:{dimension:[-1,1,-2,0,0,0,0],scale:1},J:{dimension:[2,1,-2,0,0,0,0],scale:1},W:{dimension:[2,1,-3,0,0,0,0],scale:1},C:{dimension:[0,0,1,1,0,0,0],scale:1},V:{dimension:[2,1,-3,-1,0,0,0],scale:1},F:{dimension:[-2,-1,4,2,0,0,0],scale:1},ohm:{dimension:[2,1,-3,-2,0,0,0],scale:1},S:{dimension:[-2,-1,3,2,0,0,0],scale:1},Wb:{dimension:[2,1,-2,-1,0,0,0],scale:1},T:{dimension:[0,1,-2,-1,0,0,0],scale:1},H:{dimension:[2,1,-2,-2,0,0,0],scale:1},lm:{dimension:[0,0,0,0,0,0,1],scale:1},lx:{dimension:[-2,0,0,0,0,0,1],scale:1},Bq:{dimension:[0,0,-1,0,0,0,0],scale:1},Gy:{dimension:[2,0,-2,0,0,0,0],scale:1},Sv:{dimension:[2,0,-2,0,0,0,0],scale:1},kat:{dimension:[0,0,-1,0,0,1,0],scale:1},degC:{dimension:[0,0,0,0,1,0,0],scale:1,offset:273.15},degF:{dimension:[0,0,0,0,1,0,0],scale:5/9,offset:459.67},min:{dimension:[0,0,1,0,0,0,0],scale:60},h:{dimension:[0,0,1,0,0,0,0],scale:3600},d:{dimension:[0,0,1,0,0,0,0],scale:86400},ha:{dimension:[2,0,0,0,0,0,0],scale:1e4},L:{dimension:[3,0,0,0,0,0,0],scale:.001},t:{dimension:[0,1,0,0,0,0,0],scale:1e3},eV:{dimension:[2,1,-2,0,0,0,0],scale:1602176634e-28},Da:{dimension:[0,1,0,0,0,0,0],scale:16605390666e-37},au:{dimension:[1,0,0,0,0,0,0],scale:149597870700},deg:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/180},rad:{dimension:[0,0,0,0,0,0,0],scale:1},grad:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/200},turn:{dimension:[0,0,0,0,0,0,0],scale:2*Math.PI},arcmin:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/10800},arcsec:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/648e3},percent:{dimension:[0,0,0,0,0,0,0],scale:.01},ppm:{dimension:[0,0,0,0,0,0,0],scale:1e-6},dB:{dimension:[0,0,0,0,0,0,0],scale:1},Np:{dimension:[0,0,0,0,0,0,0],scale:1},in:{dimension:[1,0,0,0,0,0,0],scale:.0254},ft:{dimension:[1,0,0,0,0,0,0],scale:.3048},mi:{dimension:[1,0,0,0,0,0,0],scale:1609.344},lb:{dimension:[0,1,0,0,0,0,0],scale:.45359237},oz:{dimension:[0,1,0,0,0,0,0],scale:.028349523125},gal:{dimension:[3,0,0,0,0,0,0],scale:.003785411784},atm:{dimension:[-1,1,-2,0,0,0,0],scale:101325},bar:{dimension:[-1,1,-2,0,0,0,0],scale:1e5},cal:{dimension:[2,1,-2,0,0,0,0],scale:4.184},kWh:{dimension:[2,1,-2,0,0,0,0],scale:36e5},\u00C5:{dimension:[1,0,0,0,0,0,0],scale:1e-10}};function mi(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]}function cs(i){return i[0]===0&&i[1]===0&&i[2]===0&&i[3]===0&&i[4]===0&&i[5]===0&&i[6]===0}function ls(i){if(i.length>2){let e=i.slice(0,2),t=i.slice(2);if(ui[e]!==void 0&&dn.has(t)){let n=ai[t];if(n)return{prefixScale:ui[e],baseEntry:n}}}if(i.length>1){let e=i.slice(0,1),t=i.slice(1);if(ui[e]!==void 0&&dn.has(t)){let n=ai[t];if(n)return{prefixScale:ui[e],baseEntry:n}}}return null}function ci(i){let e=ai[i];if(e)return e;let t=ls(i);return t?{dimension:t.baseEntry.dimension,scale:t.prefixScale*t.baseEntry.scale}:null}function li(i){let e=ci(i);return e?e.dimension:null}function hn(i){let e=ci(i);return e?e.scale:null}function ms(i,e){let t=li(i),n=li(e);return!t||!n?!1:mi(t,n)}var fs=new Map(["N","J","W","Pa","Hz","C","V","F","ohm","S","Wb","T","H","lm","lx","Gy","kat"].map(i=>[ai[i].dimension.join(","),i]));function ds(i){return fs.get(i.join(","))??null}function Nn(i,e,t){let n=ci(e),r=ci(t);if(!n||!r||!mi(n.dimension,r.dimension))return null;let s=n.offset??0,o=r.offset??0;return(i+s)*n.scale/r.scale-o}function re(i){if(typeof i=="string")return li(i);if(!Array.isArray(i)||i.length<2)return null;let e=i[0];if(e==="Multiply"){let t=[0,0,0,0,0,0,0];for(let n=1;n<i.length;n++){let r=re(i[n]);if(!r)return null;for(let s=0;s<7;s++)t[s]+=r[s]}return t}if(e==="Divide"){if(i.length!==3)return null;let t=re(i[1]),n=re(i[2]);return!t||!n?null:t.map((r,s)=>r-n[s])}if(e==="Power"){if(i.length!==3)return null;let t=re(i[1]),n=i[2];return!t||typeof n!="number"?null:t.map(r=>r*n)}return null}function se(i){if(typeof i=="string")return hn(i);if(!Array.isArray(i)||i.length<2)return null;let e=i[0];if(e==="Multiply"){let t=1;for(let n=1;n<i.length;n++){let r=se(i[n]);if(r===null)return null;t*=r}return t}if(e==="Divide"){if(i.length!==3)return null;let t=se(i[1]),n=se(i[2]);return t===null||n===null||n===0?null:t/n}if(e==="Power"){if(i.length!==3)return null;let t=se(i[1]),n=i[2];return t===null||typeof n!="number"?null:Math.pow(t,n)}return null}function hs(i){let e=i.indexOf("^");if(e===-1)return i;let t=i.slice(0,e),n=i.slice(e+1),r=parseInt(n,10);return isNaN(r)?i:["Power",t,r]}function Se(i){if(i=i.trim(),i.length===0)return null;if(i[0]==="("&&i[i.length-1]===")"){let r=0,s=!0;for(let o=0;o<i.length-1;o++)if(i[o]==="("?r++:i[o]===")"&&r--,r===0&&o<i.length-1){s=!1;break}if(s)return Se(i.slice(1,-1))}let e=-1,t=[],n=0;for(let r=0;r<i.length;r++)i[r]==="("?n++:i[r]===")"?n--:n===0&&(i[r]==="/"&&e===-1?e=r:i[r]==="*"&&t.push(r));if(e!==-1){let r=i.slice(0,e).trim(),s=i.slice(e+1).trim(),o=Se(r),a=Se(s);return!o||!a?null:["Divide",o,a]}if(t.length>0){let r=[],s=0;for(let a of t)r.push(i.slice(s,a).trim()),s=a+1;r.push(i.slice(s).trim());let o=r.filter(a=>a.length>0).map(a=>Se(a));return o.some(a=>a===null)?null:o.length===1?o[0]:["Multiply",...o]}return i[0]==="("?null:hs(i)}function Ns(i){return i=i.trim(),i.length===0?null:/[/*^()]/.test(i)?Se(i):i}function ps(i,e,t){if(typeof e=="string"&&typeof t=="string")return Nn(i,e,t);let n=re(e),r=re(t);if(!n||!r||!mi(n,r))return null;let s=se(e),o=se(t);return s===null||o===null||o===0?null:i*s/o}var pn=7,gn=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23];function he(i){if(i<0)return NaN;let e=0;for(;i<10;)e+=Math.log(i),i+=1;let t=Math.PI,n=i*i*i;return i*Math.log(i)-i-.5*Math.log(i)+.5*Math.log(2*t)+1/(12*i)-1/(360*n)+1/(1260*n*i*i)-e}function G(i){if(i<.5)return Math.PI/(Math.sin(Math.PI*i)*G(1-i));if(i>100)return Math.exp(he(i));i-=1;let e=gn[0];for(let n=1;n<pn+2;n++)e+=gn[n]/(i+n);let t=i+pn+.5;return Math.sqrt(2*Math.PI)*Math.pow(t,i+.5)*Math.exp(-t)*e}function gs(i){let t=Math.log(1-i*i),n=2/(Math.PI*.147)+t/2;return Math.sign(i)*Math.sqrt(Math.sqrt(n*n-t/.147)-n)}function In(i){if(Number.isNaN(i)||i<-1||i>1)return NaN;if(i===0)return 0;if(i===1)return 1/0;if(i===-1)return-1/0;let e=i<0?-1:1,t=Math.abs(i),n=gs(t),r=Math.sqrt(Math.PI)/2;for(let s=0;s<4;s++)n-=(Ni(n)-t)*r*Math.exp(n*n);return e*n}function Xi(i){if(Number.isNaN(i))return NaN;if(!Number.isFinite(i))return i>0?0:2;if(i<0)return 2-Xi(-i);if(i<2)return 1-Ni(i);let e=1e-300,t=i===0?e:i,n=t,r=0;for(let s=1;s<=500;s++){let o=s/2;r=i+o*r,r===0&&(r=e),r=1/r,n=i+o/n,n===0&&(n=e);let a=n*r;if(t*=a,Math.abs(a-1)<1e-17)break}return Math.exp(-i*i)/(Math.sqrt(Math.PI)*t)}function Ni(i){if(Number.isNaN(i))return NaN;if(i===0)return 0;if(!Number.isFinite(i))return i>0?1:-1;let e=i<0?-1:1,t=Math.abs(i);if(t>=6)return e;let n=t*t,r=t,s=t;for(let o=1;o<200&&(r*=2*n/(2*o+1),s+=r,!(r<s*1e-18));o++);return e*(2/Math.sqrt(Math.PI))*Math.exp(-n)*s}function ue(i,e){let t=u.precision;u.precision=t+i;try{return e().toPrecision(t)}finally{u.precision=t}}var ae=24;function Tn(i,e){return e.isFinite()?ue(ae,()=>Hi(i,e)):u.NAN}function Hi(i,e){if(!e.isFinite())return u.NAN;if(e.lt(u.HALF)){let y=u.PI,w=y.mul(e).sin().abs();return w.isZero()?u.NAN:y.ln().sub(w.ln()).sub(Hi(i,u.ONE.sub(e)))}if(e.isInteger()&&e.isPositive()){let y=e.toNumber();if(y<=1)return u.ZERO;let w=1n;for(let B=2;B<y;B++)w*=BigInt(B);return new u(w.toString()).ln()}let t=e.sub(u.HALF);if(t.isInteger()&&!t.isNegative()){let y=t.toNumber();if(y===0)return u.PI.ln().div(u.TWO);let w=1n;for(let S=2;S<=2*y;S++)w*=BigInt(S);let B=1n;for(let S=2;S<=y;S++)B*=BigInt(S);let Y=4n**BigInt(y);return new u(w.toString()).ln().add(u.PI.ln().div(u.TWO)).sub(new u(Y.toString()).ln()).sub(new u(B.toString()).ln())}let n=u.precision,r=10,s=Math.ceil(n),o=e.toNumber(),a=Math.max(0,Math.ceil(s-o)),c=u.ONE,l=e;for(let y=0;y<a;y++)c=c.mul(l).toPrecision(n),l=l.add(u.ONE);let m=a>0?c.ln():u.ZERO,f=Math.max(20,Math.ceil(.6*n)+20),d=De(i,f),h=l.sub(u.HALF).mul(l.ln()).sub(l).add(u.PI.mul(u.TWO).ln().div(u.TWO)),N=u.ONE.div(l),p=N.mul(N).toPrecision(n),g=N,b=new u(10).pow(-(n+r)),T=Math.min(f,d.length);for(let y=0;y<T;y++){let w=2*(y+1),[B,Y]=d[y],S=BigInt(w)*BigInt(w-1),be=new u(B.toString()).div(new u((Y*S).toString())).mul(g).toPrecision(n);if(y>0&&be.abs().lt(b))break;h=h.add(be),g=g.mul(p).toPrecision(n)}return h.sub(m)}function vn(i,e){if(e.isInteger()&&e.isPositive()){let t=e.toNumber(),n=1n;for(let r=2;r<t;r++)n*=BigInt(r);return new u(n.toString())}return ue(ae,()=>Ne(i,e))}function Ne(i,e){if(e.lt(u.HALF)){let t=u.PI,n=t.mul(e).sin();return n.isZero()?u.NAN:t.div(n.mul(Ne(i,u.ONE.sub(e))))}return Hi(i,e).exp()}function bn(i,e){for(;e!==0n;){let t=e;e=i%e,i=t}return i}function fi(i){return i<0n?-i:i}function yn(i){let e=[[1n,1n],[-1n,2n]];for(let n=2;n<=2*i;n++){if(n%2===1){e.push([0n,1n]);continue}let r=BigInt(n+1),s=0n,o=1n,a=1n;for(let f=0;f<n;f++){f>0&&(a=a*(r-BigInt(f)+1n)/BigInt(f));let[d,h]=e[f];if(d!==0n&&(s=s*h+a*d*o,o=o*h,f%8===7)){let N=bn(fi(s),o);s/=N,o/=N}}let c=-s,l=r*o,m=bn(fi(c),fi(l));c/=m,l/=m,l<0n&&(c=-c,l=-l),e.push([c,l])}let t=[];for(let n=1;n<=i;n++)t.push(e[2*n]);return t}function De(i,e){return i._cache("bernoulli-even-rationals",()=>yn(e),t=>t.length>=e?t:yn(e))}function Ki(i,e){return e.isFinite()?ue(ae,()=>En(i,e)):u.NAN}function En(i,e){if(e.isNegative()){if(e.isInteger())return u.NAN;let h=u.PI,N=h.mul(e),p=N.cos().div(N.sin());return En(i,u.ONE.sub(e)).sub(h.mul(p))}if(e.isZero())return u.NAN;let t=u.precision,n=10,r=Math.max(7,Math.ceil(t)),s=new u(0),o=e;for(;o.lt(r);)s=s.sub(u.ONE.div(o)),o=o.add(u.ONE);let a=Math.max(20,Math.ceil(.6*t)+20),c=De(i,a);s=s.add(o.ln()).sub(u.ONE.div(o.mul(2)));let l=o.mul(o).toPrecision(t),m=l,f=new u(10).pow(-(t+n)),d=Math.min(a,c.length);for(let h=0;h<d;h++){let[N,p]=c[h],g=BigInt(2*(h+1)),b=new u(N.toString()).div(new u((p*g).toString()).mul(l));if(h>0&&b.abs().lt(f))break;s=s.sub(b),l=l.mul(m).toPrecision(t)}return s}function Qi(i,e){return e.isFinite()?ue(ae,()=>Mn(i,e)):u.NAN}function Mn(i,e){if(e.isNegative()){if(e.isInteger())return u.NAN;let h=u.PI,N=h.mul(e).sin();return h.mul(h).div(N.mul(N)).sub(Mn(i,u.ONE.sub(e)))}if(e.isZero())return u.NAN;let t=u.precision,n=10,r=Math.max(7,Math.ceil(t)),s=new u(0),o=e;for(;o.lt(r);)s=s.add(u.ONE.div(o.mul(o))),o=o.add(u.ONE);let a=Math.max(20,Math.ceil(.6*t)+20),c=De(i,a);s=s.add(u.ONE.div(o)),s=s.add(u.ONE.div(o.mul(o).mul(2)));let l=o.mul(o).mul(o).toPrecision(t),m=o.mul(o).toPrecision(t),f=new u(10).pow(-(t+n)),d=Math.min(a,c.length);for(let h=0;h<d;h++){let[N,p]=c[h],g=new u(N.toString()).div(new u(p.toString()).mul(l));if(h>0&&g.abs().lt(f))break;s=s.add(g),l=l.mul(m).toPrecision(t)}return s}function Bn(i,e,t){let n=e.toNumber();return!Number.isInteger(n)||n<0?u.NAN:n===0?Ki(i,t):n===1?Qi(i,t):!t.isFinite()||t.isZero()?u.NAN:ue(ae,()=>bs(i,n,t))}function bs(i,e,t){let n=b=>{let T=u.ONE;for(let y=2;y<=b;y++)T=T.mul(y);return T},r=u.precision,s=10,o=Math.max(7,Math.ceil(r)),a=t,c=new u(0),l=e%2===0?-1:1;if(a.isNegative()){if(a.isInteger())return u.NAN;let b=e%2===0?1:-1;for(;a.lt(1);)c=c.add(new u(b).mul(n(e)).div(a.pow(e+1))),a=a.add(u.ONE)}for(;a.lt(o);)c=c.add(new u(l).mul(n(e)).div(a.pow(e+1))),a=a.add(u.ONE);let m=Math.max(20,Math.ceil(.6*r)+20),f=De(i,m),d=e%2===0?-1:1;c=c.add(new u(d).mul(n(e-1)).div(a.pow(e))),c=c.add(new u(d).mul(n(e)).div(a.pow(e+1).mul(2)));let h=a.pow(e+2).toPrecision(r),N=a.mul(a).toPrecision(r),p=new u(10).pow(-(r+s)),g=Math.min(m,f.length);for(let b=0;b<g;b++){let T=2*(b+1),[y,w]=f[b],B=1n;for(let U=0;U<T;U++)B*=BigInt(e+U);let Y=1n;for(let U=2;U<=T;U++)Y*=BigInt(U);let S=new u((BigInt(d)*y*B).toString()).div(new u((w*Y).toString()).mul(h));if(b>0&&S.abs().lt(p))break;c=c.add(S),h=h.mul(N).toPrecision(r)}return c}function wn(i,e,t){return ue(ae,()=>Ne(i,e).mul(Ne(i,t)).div(Ne(i,e.add(t))))}function kn(i,e){return e.isFinite()?e.eq(1)?new u(1/0):ue(ae,()=>xn(i,e)):u.NAN}function xn(i,e){let t=u.PI;if(e.isZero())return u.HALF.neg();if(e.isInteger()&&e.isPositive()){let d=e.toNumber();if(d%2===0&&d>=2){let h=d/2,N=De(i,h),[p,g]=N[h-1],b=new u(fi(p).toString()).div(new u(g.toString())),T=t.mul(2),y=u.ONE;for(let w=2;w<=d;w++)y=y.mul(w);return b.mul(T.pow(d)).div(y.mul(2))}}if(e.isNegative())return new u(2).pow(e).mul(t.pow(e.sub(1))).mul(t.mul(e).div(2).sin()).mul(Ne(i,u.ONE.sub(e))).mul(xn(i,u.ONE.sub(e)));let n=u.precision,r=Math.max(22,Math.ceil(1.32*n)+3),o=new u(3).add(new u(8).sqrt()).pow(r),a=o.add(u.ONE.div(o)).div(2),c=u.NEGATIVE_ONE,l=a.neg(),m=u.ZERO;for(let d=0;d<r;d++)(d&255)===0&&le(i._deadline),l=c.sub(l),m=m.add(l.div(new u(d+1).pow(e))),c=c.mul(new u(d+r).mul(d-r)).div(new u(d).add(u.HALF).mul(d+1));return m.div(a).div(u.ONE.sub(new u(2).pow(u.ONE.sub(e))))}function Pn(i,e){if(!e.isFinite())return e;if(e.isZero())return new u(0);let n=u.ONE.div(u.ONE.exp()).neg(),r=new u(10).pow(-i.precision),s=new u(10).pow(-15);if(e.sub(n).abs().lt(s))return u.NEGATIVE_ONE;if(e.lt(n))return u.NAN;let o,a=e.toNumber();if(a<0){let c=Math.sqrt(2*(Math.E*a+1));o=new u(-1+c-c*c/3+11/72*c*c*c)}else if(a<=1)o=new u(a*(1-a*(1-1.5*a)));else if(a<100){let c=Math.log(a);o=new u(c-Math.log(c))}else{let c=e.ln(),l=c.ln();o=c.sub(l).add(l.div(c))}for(let c=0;c<100;c++){let l=o.exp(),f=o.mul(l).sub(e),d=l.mul(o.add(1)),h=l.mul(o.add(2)),N=f.div(d.sub(f.mul(h).div(d.mul(2))));if(o=o.sub(N),N.abs().lt(r.mul(o.abs().add(1))))break}return o}var di=.5772156649015329,pe=[1/6,-1/30,1/42,-1/30,5/66,-691/2730,7/6,-3617/510,43867/798,-174611/330];function pi(i){if(!isFinite(i))return NaN;if(i<0)return Number.isInteger(i)?NaN:pi(1-i)-Math.PI/Math.tan(Math.PI*i);if(i===0)return NaN;let e=0,t=i;for(;t<7;)e-=1/t,t+=1;e+=Math.log(t)-1/(2*t);let n=t*t;for(let r=0;r<pe.length;r++)e-=pe[r]/(2*(r+1)*n),n*=t*t;return e}function gi(i){if(!isFinite(i))return NaN;if(i<0){if(Number.isInteger(i))return NaN;let r=Math.sin(Math.PI*i);return Math.PI*Math.PI/(r*r)-gi(1-i)}if(i===0)return NaN;let e=0,t=i;for(;t<7;)e+=1/(t*t),t+=1;e+=1/t+1/(2*t*t);let n=t*t*t;for(let r=0;r<pe.length;r++)e+=pe[r]/n,n*=t*t;return e}function zi(i,e){if(!Number.isInteger(i)||i<0)return NaN;if(i===0)return pi(e);if(i===1)return gi(e);if(!isFinite(e)||e===0)return NaN;if(e<0){if(Number.isInteger(e))return NaN;let a=0,c=e,l=i%2===0?1:-1;for(;c<1;)a+=l*de(i)/Math.pow(c,i+1),c+=1;return a+zi(i,c)}let t=0,n=e,r=i%2===0?-1:1;for(;n<7;)t+=r*de(i)/Math.pow(n,i+1),n+=1;let s=i%2===0?-1:1;t+=s*de(i-1)/Math.pow(n,i),t+=s*de(i)/(2*Math.pow(n,i+1));let o=Math.pow(n,i+2);for(let a=0;a<Math.min(pe.length,6);a++){let c=2*(a+1),l=1;for(let m=0;m<c;m++)l*=i+m;t+=s*pe[a]*l/(de(c)*o),o*=n*n}return t}function de(i){if(i<=1)return 1;let e=1;for(let t=2;t<=i;t++)e*=t;return e}function Sn(i,e){return i>100||e>100||i+e>100?Math.exp(he(i)+he(e)-he(i+e)):G(i)*G(e)/G(i+e)}function et(i){if(!isFinite(i))return NaN;if(i===1)return 1/0;if(i===0)return-.5;if(i===2)return Math.PI*Math.PI/6;if(i===4)return Math.PI**4/90;if(i===6)return Math.PI**6/945;if(i===8)return Math.PI**8/9450;if(i<0)return Math.pow(2,i)*Math.pow(Math.PI,i-1)*Math.sin(Math.PI*i/2)*G(1-i)*et(1-i);let e=22,t=ys(e),n=t[e],r=0;for(let s=0;s<=e;s++)r+=(s%2===0?1:-1)*(t[s]-n)/Math.pow(s+1,i);return-1/(n*(1-Math.pow(2,1-i)))*r}function ys(i){let e=new Array(i+1);e[0]=1;for(let t=1;t<=i;t++)e[t]=e[t-1]+Is(i,t);return e}function Is(i,e){e>i-e&&(e=i-e);let t=1;for(let n=0;n<e;n++)t=t*(i-n)/(n+1);return t}function Dn(i){if(!isFinite(i))return i;if(i===0)return 0;let e=1/Math.E;if(i<-e)return NaN;if(Math.abs(i+e)<1e-15)return-1;let t;if(i<0){let n=Math.sqrt(2*(Math.E*i+1));t=-1+n-n*n/3+11/72*n*n*n}else if(i<=1)t=i*(1-i*(1-1.5*i));else if(i<100){let n=Math.log(i);t=n-Math.log(n)}else{let n=Math.log(i),r=Math.log(n);t=n-r+r/n}for(let n=0;n<30;n++){let r=Math.exp(t),o=t*r-i,a=r*(t+1),c=r*(t+2),l=o/(a-o*c/(2*a));if(t-=l,Math.abs(l)<1e-15*(1+Math.abs(t)))break}return t}function H(i,e){return!isFinite(e)||!Number.isInteger(i)?NaN:e===0?i===0?1:0:i<0?(i=-i,i%2===0?H(i,e):-H(i,e)):e<0?i%2===0?H(i,-e):-H(i,-e):e>25+i*i/2?vs(i,e):e<5+i?Ts(i,e):Es(i,e)}function Ts(i,e){let t=e/2,n=-(e*e)/4,r=1;for(let o=1;o<=i;o++)r/=o;let s=r;for(let o=1;o<=60&&(r*=n/(o*(i+o)),s+=r,!(Math.abs(r)<Math.abs(s)*1e-16));o++);return s*Math.pow(t,i)}function Rn(i,e){let t=4*i*i,n=1,r=0,s=1,o=8*e;for(let a=1;a<=20;a++){s*=t-(2*a-1)*(2*a-1);let c=de(a)*Math.pow(o,a),l=s/c;if(a%2===1?r+=(a%4===1?1:-1)*l:n+=(a%4===2?-1:1)*l,Math.abs(l)<1e-15)break}return[n,r]}function vs(i,e){let t=e-(i/2+.25)*Math.PI,[n,r]=Rn(i,e);return Math.sqrt(2/(Math.PI*e))*(n*Math.cos(t)-r*Math.sin(t))}function Es(i,e){let t=Math.max(i+20,Math.ceil(e)+30),n=0,r=1,s=new Array(t+1);s[t]=r;for(let c=t;c>=1;c--){let l=2*c/e*r-n;n=r,r=l,s[c-1]=r}let o=s[0];for(let c=2;c<=t;c+=2)o+=2*s[c];let a=1/o;return s[i]*a}function hi(i,e){if(!isFinite(e)||!Number.isInteger(i))return NaN;if(e<=0)return NaN;if(i<0)return i=-i,i%2===0?hi(i,e):-hi(i,e);if(e>12+i*i/4)return ws(i,e);let t=Ms(e);if(i===0)return t;let n=Bs(e);if(i===1)return n;let r=t,s=n;for(let o=1;o<i;o++){let a=2*o/e*s-r;r=s,s=a}return s}function Ms(i){let e=i/2,t=e*e,n=H(0,i),r=0,s=1,o=0;for(let a=1;a<=60&&(o+=1/a,s*=-t/(a*a),r-=s*o,!(Math.abs(s*o)<Math.abs(r)*1e-16));a++);return 2/Math.PI*(n*(Math.log(e)+di)+r)}function Bs(i){let e=i/2,t=e*e,n=H(1,i),r=0,s=1,o=1;for(let a=0;a<=60;a++){a>0&&(o*=a,s*=t);let c=o*(a+1),l=0;for(let p=1;p<=a;p++)l+=1/p;let m=l+1/(a+1),f=-di+l,d=-di+m,N=(a%2===0?1:-1)*(f+d)*s/(o*c);if(r+=N,a>3&&Math.abs(N)<1e-16*Math.abs(r))break}return-2/(Math.PI*i)+2/Math.PI*Math.log(e)*n-e/Math.PI*r}function ws(i,e){let t=e-(i/2+.25)*Math.PI,[n,r]=Rn(i,e);return Math.sqrt(2/(Math.PI*e))*(n*Math.sin(t)+r*Math.cos(t))}function oe(i,e){return!isFinite(e)||!Number.isInteger(i)?NaN:e===0?i===0?1:0:(i<0&&(i=-i),e<0?i%2===0?oe(i,-e):-oe(i,-e):e>40?xs(i,e):ks(i,e))}function ks(i,e){let t=e/2,n=e*e/4,r=1;for(let o=1;o<=i;o++)r/=o;let s=r;for(let o=1;o<=80&&(r*=n/(o*(i+o)),s+=r,!(Math.abs(r)<Math.abs(s)*1e-16));o++);return s*Math.pow(t,i)}function xs(i,e){let t=4*i*i,n=1,r=1;for(let s=1;s<=12;s++){let o=t-(2*s-1)*(2*s-1);if(n*=o/(s*8*e),r+=n,Math.abs(n)<1e-15)break}return Math.exp(e)/Math.sqrt(2*Math.PI*e)*r}function An(i,e){if(!isFinite(e)||!Number.isInteger(i))return NaN;if(e<=0)return NaN;if(i<0&&(i=-i),e>40)return Ss(i,e);let t=On(e);if(i===0)return t;let n=Ps(e);if(i===1)return n;let r=t,s=n;for(let o=1;o<i;o++){let a=2*o/e*s+r;r=s,s=a}return s}function On(i){let e=i/2,t=e*e,n=oe(0,i),r=0,s=1,o=0;for(let a=1;a<=60&&(o+=1/a,s*=t/(a*a),r+=s*o,!(Math.abs(s*o)<Math.abs(r)*1e-16&&a>3));a++);return-(Math.log(e)+di)*n+r}function Ps(i){let e=oe(0,i),t=oe(1,i),n=On(i);return(1/i-t*n)/e}function Ss(i,e){let t=4*i*i,n=1,r=1;for(let s=1;s<=12;s++){let o=t-(2*s-1)*(2*s-1);if(n*=o/(s*8*e),r+=n,Math.abs(n)<1e-15)break}return Math.sqrt(Math.PI/(2*e))*Math.exp(-e)*r}function Fn(i){if(!isFinite(i))return NaN;if(i>5){let a=.6666666666666666*Math.pow(i,1.5);return Ds(i,a)}if(i<-5){let a=-i,c=2/3*Math.pow(a,1.5);return Rs(a,c)}let e=1/(Math.pow(3,2/3)*G(2/3)),t=1/(Math.pow(3,1/3)*G(1/3)),n=1,r=i,s=1,o=i;for(let a=1;a<=80;a++){let c=3*a;if(s*=i*i*i/((c-1)*c),o*=i*i*i/(c*(c+1)),n+=s,r+=o,Math.abs(s)+Math.abs(o)<1e-16*(Math.abs(n)+Math.abs(r)))break}return e*n-t*r}function Ds(i,e){let t=Math.pow(i,.25),n=1,r=1,s=[1,5/72,385/10368,85085/2239488,37182145/644972544];for(let o=1;o<s.length;o++)r=s[o]/Math.pow(e,o),n+=(o%2===0?1:-1)*r;return Math.exp(-e)/(2*Math.sqrt(Math.PI)*t)*n}function Rs(i,e){let t=Math.pow(i,.25);return Math.sin(e+Math.PI/4)/(Math.sqrt(Math.PI)*t)}function Cn(i){if(!isFinite(i))return NaN;if(i>5){let a=.6666666666666666*Math.pow(i,1.5);return As(i,a)}if(i<-5){let a=-i,c=2/3*Math.pow(a,1.5);return Os(a,c)}let e=1/(Math.pow(3,2/3)*G(2/3)),t=1/(Math.pow(3,1/3)*G(1/3)),n=1,r=i,s=1,o=i;for(let a=1;a<=80;a++){let c=3*a;if(s*=i*i*i/((c-1)*c),o*=i*i*i/(c*(c+1)),n+=s,r+=o,Math.abs(s)+Math.abs(o)<1e-16*(Math.abs(n)+Math.abs(r)))break}return Math.sqrt(3)*(e*n+t*r)}function As(i,e){let t=Math.pow(i,.25),n=1,r=1,s=[1,5/72,385/10368,85085/2239488,37182145/644972544];for(let o=1;o<s.length;o++)r=s[o]/Math.pow(e,o),n+=r;return Math.exp(e)/(Math.sqrt(Math.PI)*t)*n}function Os(i,e){let t=Math.pow(i,.25);return Math.cos(e+Math.PI/4)/(Math.sqrt(Math.PI)*t)}var Fs=[-2991.8191940101983,708840.0452577386,-6297414862058625e-8,25489088057337637e-7,-4429795180596978e-5,3180162978765678e-4],Cs=[1,281.3762688899943,45584.78108065326,5173438887700964e-9,4193202458981112e-7,22441179564534092e-6,607366389490085e-3],Vs=[-49884311457357354e-24,9504280628298596e-21,-.0006451914356839651,.018884331939670384,-.20552590095501388,1],_s=[399982968972496e-26,9154392157746574e-25,12500186247959882e-23,12226278902417902e-21,.0008680295429417843,.04121420907221998,1],Vn=[.4215435550436775,.1434079197807589,.011522095507358577,.000345017939782574,46361374928786735e-22,3055689837902576e-23,10230451416490724e-26,17201074326816183e-29,13428327623306275e-32,3763297112699879e-35],_n=[1,.7515863983533789,.11688892585919138,.0064405152650885865,.00015593440916415301,18462756734893055e-22,11269922476399903e-24,36014002958937136e-27,5887545336215784e-29,45200143407412973e-33,12544323709001127e-36],qn=[.5044420736433832,.1971028335255234,.018764858409257526,.0006840793809153931,11513882611188428e-21,9828524436884223e-23,44534441586175015e-26,10826804113902088e-28,1375554606332618e-30,8363544356306774e-34,18695871016278324e-38],Zn=[1,1.4749575992512833,.33774898912002,.02536037414203388,.0008146791071843061,12754507566772912e-21,10431458965757199e-23,46068072851523205e-26,11027321506624028e-28,13879653125957886e-31,8391588162831187e-34,18695871016278324e-38];function q(i,e){let t=e[0];for(let n=1;n<e.length;n++)t=t*i+e[n];return t}function Ln(i){if(!isFinite(i))return i!==i?NaN:i>0?.5:-.5;let e=i<0?-1:1;if(i=Math.abs(i),i<1.6){let t=i*i,n=t*t;return e*i*t*q(n,Fs)/q(n,Cs)}if(i<36974){let t=i*i,n=Math.PI*t,r=1/(n*n),s=1-r*q(r,Vn)/q(r,_n),o=1/n*q(r,qn)/q(r,Zn),a=Math.PI/2*t,c=Math.cos(a),l=Math.sin(a);return e*(.5-(s*c+o*l)/(Math.PI*i))}return e*.5}function Gn(i){if(!isFinite(i))return i!==i?NaN:i>0?.5:-.5;let e=i<0?-1:1;if(i=Math.abs(i),i<1.6){let t=i*i,n=t*t;return e*i*q(n,Vs)/q(n,_s)}if(i<36974){let t=i*i,n=Math.PI*t,r=1/(n*n),s=1-r*q(r,Vn)/q(r,_n),o=1/n*q(r,qn)/q(r,Zn),a=Math.PI/2*t,c=Math.cos(a),l=Math.sin(a);return e*(.5+(s*l-o*c)/(Math.PI*i))}return e*.5}function Yn(i){return i===0?1:Math.sin(i)/i}var D=Math.cosh||function(i){return Math.abs(i)<1e-9?1-i:(Math.exp(i)+Math.exp(-i))*.5},Z=Math.sinh||function(i){return Math.abs(i)<1e-9?i:(Math.exp(i)-Math.exp(-i))*.5},qs=function(i){var e=Math.PI/4;if(-e>i||i>e)return Math.cos(i)-1;var t=i*i;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Zs=function(i,e){var t=Math.abs(i),n=Math.abs(e);return t<3e3&&n<3e3?Math.sqrt(t*t+n*n):(t<n?(t=n,n=i/e):n=e/i,t*Math.sqrt(1+n*n))},ge=function(){throw SyntaxError("Invalid Param")};function it(i,e){var t=Math.abs(i),n=Math.abs(e);return i===0?Math.log(n):e===0?Math.log(t):t<3e3&&n<3e3?Math.log(i*i+e*e)*.5:(i=i/2,e=e/2,.5*Math.log(i*i+e*e)+Math.LN2)}var Ls=function(i,e){var t={re:0,im:0};if(i==null)t.re=t.im=0;else if(e!==void 0)t.re=i,t.im=e;else switch(typeof i){case"object":if("im"in i&&"re"in i)t.re=i.re,t.im=i.im;else if("abs"in i&&"arg"in i){if(!Number.isFinite(i.abs)&&Number.isFinite(i.arg))return M.INFINITY;t.re=i.abs*Math.cos(i.arg),t.im=i.abs*Math.sin(i.arg)}else if("r"in i&&"phi"in i){if(!Number.isFinite(i.r)&&Number.isFinite(i.phi))return M.INFINITY;t.re=i.r*Math.cos(i.phi),t.im=i.r*Math.sin(i.phi)}else i.length===2?(t.re=i[0],t.im=i[1]):ge();break;case"string":t.im=t.re=0;var n=i.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,s=0;n===null&&ge();for(var o=0;o<n.length;o++){var a=n[o];a===" "||a===" "||a===`
7
- `||(a==="+"?r++:a==="-"?s++:a==="i"||a==="I"?(r+s===0&&ge(),n[o+1]!==" "&&!isNaN(Number(n[o+1]))?(t.im+=parseFloat((s%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((s%2?"-":"")+"1"),r=s=0):((r+s===0||isNaN(Number(a)))&&ge(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((s%2?"-":"")+a),o++):t.re+=parseFloat((s%2?"-":"")+a),r=s=0))}r+s>0&&ge();break;case"number":t.im=0,t.re=i;break;default:ge()}return isNaN(t.re)||isNaN(t.im),t},M=class i{constructor(e,t){this.re=0,this.im=0;var n=Ls(e,t);this.re=n.re,this.im=n.im}sign(){var e=this.abs();return new i(this.re/e,this.im/e)}add(e,t){var n=new i(e,t);return this.isInfinite()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:new i(this.re+n.re,this.im+n.im)}sub(e,t){var n=new i(e,t);return this.isInfinite()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:new i(this.re-n.re,this.im-n.im)}mul(e,t){var n=new i(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:n.im===0&&this.im===0?new i(this.re*n.re,0):new i(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)}div(e,t){var n=new i(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return i.NAN;if(this.isInfinite()||n.isZero())return i.INFINITY;if(this.isZero()||n.isInfinite())return i.ZERO;e=this.re,t=this.im;var r=n.re,s=n.im,o,a;return s===0?new i(e/r,t/r):Math.abs(r)<Math.abs(s)?(a=r/s,o=r*a+s,new i((e*a+t)/o,(t*a-e)/o)):(a=s/r,o=s*a+r,new i((e+t*a)/o,(t-e*a)/o))}pow(e,t){var n=new i(e,t);if(e=this.re,t=this.im,n.isZero())return i.ONE;if(n.im===0){if(t===0&&e>0)return new i(Math.pow(e,n.re),0);if(e===0)switch((n.re%4+4)%4){case 0:return new i(Math.pow(t,n.re),0);case 1:return new i(0,Math.pow(t,n.re));case 2:return new i(-Math.pow(t,n.re),0);case 3:return new i(0,-Math.pow(t,n.re))}}if(e===0&&t===0&&n.re>0&&n.im>=0)return i.ZERO;var r=Math.atan2(t,e),s=it(e,t);return e=Math.exp(n.re*s-n.im*r),t=n.im*s+n.re*r,new i(e*Math.cos(t),e*Math.sin(t))}sqrt(){var e=this.re,t=this.im,n=this.abs(),r,s;if(e>=0){if(t===0)return new i(Math.sqrt(e),0);r=.5*Math.sqrt(2*(n+e))}else r=Math.abs(t)/Math.sqrt(2*(n-e));return e<=0?s=.5*Math.sqrt(2*(n-e)):s=Math.abs(t)/Math.sqrt(2*(n+e)),new i(r,t<0?-s:s)}exp(){var e=Math.exp(this.re);return this.im,new i(e*Math.cos(this.im),e*Math.sin(this.im))}expm1(){var e=this.re,t=this.im;return new i(Math.expm1(e)*Math.cos(t)+qs(t),Math.exp(e)*Math.sin(t))}log(){var e=this.re,t=this.im;return t===0&&e>0,new i(it(e,t),Math.atan2(t,e))}abs(){return Zs(this.re,this.im)}arg(){return Math.atan2(this.im,this.re)}sin(){var e=this.re,t=this.im;return new i(Math.sin(e)*D(t),Math.cos(e)*Z(t))}cos(){var e=this.re,t=this.im;return new i(Math.cos(e)*D(t),-Math.sin(e)*Z(t))}tan(){var e=2*this.re,t=2*this.im,n=Math.cos(e)+D(t);return new i(Math.sin(e)/n,Z(t)/n)}cot(){var e=2*this.re,t=2*this.im,n=Math.cos(e)-D(t);return new i(-Math.sin(e)/n,Z(t)/n)}sec(){var e=this.re,t=this.im,n=.5*D(2*t)+.5*Math.cos(2*e);return new i(Math.cos(e)*D(t)/n,Math.sin(e)*Z(t)/n)}csc(){var e=this.re,t=this.im,n=.5*D(2*t)-.5*Math.cos(2*e);return new i(Math.sin(e)*D(t)/n,-Math.cos(e)*Z(t)/n)}asin(){var e=this.re,t=this.im,n=new i(t*t-e*e+1,-2*e*t).sqrt(),r=new i(n.re-t,n.im+e).log();return new i(r.im,-r.re)}acos(){var e=this.re,t=this.im,n=new i(t*t-e*e+1,-2*e*t).sqrt(),r=new i(n.re-t,n.im+e).log();return new i(Math.PI/2-r.im,r.re)}atan(){var e=this.re,t=this.im;if(e===0){if(t===1)return new i(0,1/0);if(t===-1)return new i(0,-1/0)}var n=e*e+(1-t)*(1-t),r=new i((1-t*t-e*e)/n,-2*e/n).log();return new i(-.5*r.im,.5*r.re)}acot(){var e=this.re,t=this.im;if(t===0)return new i(Math.atan2(1,e),0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).atan():new i(e!==0?e/0:0,t!==0?-t/0:0).atan()}asec(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(0,1/0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).acos():new i(e!==0?e/0:0,t!==0?-t/0:0).acos()}acsc(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(Math.PI/2,1/0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).asin():new i(e!==0?e/0:0,t!==0?-t/0:0).asin()}sinh(){var e=this.re,t=this.im;return new i(Z(e)*Math.cos(t),D(e)*Math.sin(t))}cosh(){var e=this.re,t=this.im;return new i(D(e)*Math.cos(t),Z(e)*Math.sin(t))}tanh(){var e=2*this.re,t=2*this.im,n=D(e)+Math.cos(t);return new i(Z(e)/n,Math.sin(t)/n)}coth(){var e=2*this.re,t=2*this.im,n=D(e)-Math.cos(t);return new i(Z(e)/n,-Math.sin(t)/n)}csch(){var e=this.re,t=this.im,n=Math.cos(2*t)-D(2*e);return new i(-2*Z(e)*Math.cos(t)/n,2*D(e)*Math.sin(t)/n)}sech(){var e=this.re,t=this.im,n=Math.cos(2*t)+D(2*e);return new i(2*D(e)*Math.cos(t)/n,-2*Z(e)*Math.sin(t)/n)}asinh(){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(){var e=this.acos();if(e.im<=0){var t=e.re;e.re=-e.im,e.im=t}else{var t=e.im;e.im=-e.re,e.re=t}return e}atanh(){var e=this.re,t=this.im,n=e>1&&t===0,r=1-e,s=1+e,o=r*r+t*t,a=o!==0?new i((s*r-t*t)/o,(t*r+s*t)/o):new i(e!==-1?e/0:0,t!==0?t/0:0),c=a.re;return a.re=it(a.re,a.im)/2,a.im=Math.atan2(a.im,c)/2,n&&(a.im=-a.im),a}acoth(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(0,Math.PI/2);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).atanh():new i(e!==0?e/0:0,t!==0?-t/0:0).atanh()}acsch(){var e=this.re,t=this.im;if(t===0)return new i(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).asinh():new i(e!==0?e/0:0,t!==0?-t/0:0).asinh()}asech(){var e=this.re,t=this.im;if(this.isZero())return i.INFINITY;var n=e*e+t*t;return n!==0?new i(e/n,-t/n).acosh():new i(e!==0?e/0:0,t!==0?-t/0:0).acosh()}inverse(){if(this.isZero())return i.INFINITY;if(this.isInfinite())return i.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new i(e/n,-t/n)}conjugate(){return new i(this.re,-this.im)}neg(){return new i(-this.re,-this.im)}ceil(e){return e=Math.pow(10,e||0),new i(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)}floor(e){return e=Math.pow(10,e||0),new i(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)}round(e){return e=Math.pow(10,e||0),new i(Math.round(this.re*e)/e,Math.round(this.im*e)/e)}equals(e,t){var n=new i(e,t);return Math.abs(n.re-this.re)<=i.EPSILON&&Math.abs(n.im-this.im)<=i.EPSILON}clone(){return new i(this.re,this.im)}toString(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<i.EPSILON&&(e=0),Math.abs(t)<i.EPSILON&&(t=0),t===0?n+e:(e!==0?(n+=e,n+=" ",t<0?(t=-t,n+="-"):n+="+",n+=" "):t<0&&(t=-t,n+="-"),t!==1&&(n+=t),n+"i"))}toVector(){return[this.re,this.im]}valueOf(){return this.im===0?this.re:null}isNaN(){return isNaN(this.re)||isNaN(this.im)}isZero(){return this.im===0&&this.re===0}isFinite(){return isFinite(this.re)&&isFinite(this.im)}isInfinite(){return!(this.isNaN()||this.isFinite())}};M.ZERO=new M(0,0);M.ONE=new M(1,0);M.I=new M(0,1);M.PI=new M(Math.PI,0);M.E=new M(Math.E,0);M.INFINITY=new M(1/0,1/0);M.NAN=new M(NaN,NaN);M.EPSILON=1e-15;var bi=7,yi=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23],Gs=Math.sqrt(2*Math.PI),Ys=.5*Math.log(2*Math.PI);function tt(i){if(i.re<.5){let r=i.mul(Math.PI).sin();return new M(Math.PI,0).div(r.mul(tt(new M(1,0).sub(i))))}let e=i.sub(1),t=new M(yi[0],0);for(let r=1;r<bi+2;r++)t=t.add(new M(yi[r],0).div(e.add(r)));let n=e.add(bi+.5);return new M(Gs,0).mul(n.pow(e.add(.5))).mul(n.neg().exp()).mul(t)}function nt(i){if(i.re<.5){let r=i.mul(Math.PI).sin();return new M(Math.PI,0).div(r).log().sub(nt(new M(1,0).sub(i)))}let e=i.sub(1),t=new M(yi[0],0);for(let r=1;r<bi+2;r++)t=t.add(new M(yi[r],0).div(e.add(r)));let n=e.add(bi+.5);return new M(Ys,0).add(e.add(.5).mul(n.log())).sub(n).add(t.log())}var ta=new M(NaN,NaN),na=new M(1,0),ra=new M(0,0);var Us="0.63.0";return Xn(Js);})();
6
+ `))}advance(){let e=this.current;return this.current=this.lexer.consumeToken(),e}match(e){return this.current.type===e?(this.advance(),!0):!1}expect(e){return this.current.type!==e&&this.error(`Expected ${e}, got ${this.current.type}`),this.advance()}createNode(e,t={}){return{kind:e,position:this.current.position,line:this.current.line,column:this.current.column,...t}}parseType(){this.checkForNakedFunctionSignature();let e=this.parseUnionType();if(e||this.error("Expected a type"),this.current.type!=="EOF")if(this.current.type==="->"||this.current.type==="+"||this.current.type==="*"||this.current.type==="?")this.error("Function signatures must be enclosed in parentheses","For example `(x: number) -> number`");else if(this.current.type==="("){let t=this.lexer.input;t.includes("set(")||t.includes("collection(")||t.includes("list(")||t.includes("tuple(")?t.includes("set(")?this.error("Use `set<integer>` instead of `set(integer)`."):t.includes("collection(")?this.error("Use `collection<type>` instead of `collection(type)`.","For example `collection<number>`"):t.includes("list(")?this.error("Use `list<type>` instead of `list(type)`.","For example `list<number>`"):t.includes("tuple(")&&this.error("Use `tuple<type1, type2>` instead of `tuple(type1, type2)`.","For example `tuple<string, number>`"):this.error("Unexpected token after type")}else this.error("Unexpected token after type");return e}checkForNakedFunctionSignature(){if(this.current.type==="IDENTIFIER"){let e=this.lexer.saveState(),t=this.current;try{let n=this.current;if(this.advance(),this.current.type===":"){this.advance();let r=!1,s=0,o=10;for(;this.current.type!=="EOF"&&s<o;){if(this.current.type==="->"){r=!0;break}if(this.current.type==="+"||this.current.type==="*"||this.current.type==="?"){if(this.advance(),this.current.type==="->"){r=!0;break}s++}this.advance(),s++}r&&(this.lexer.restoreState(e),this.current=t,this.errorAtToken(n,"Function signatures must be enclosed in parentheses","For example `(z: string*) -> boolean`"))}this.lexer.restoreState(e),this.current=t}catch(n){if(this.lexer.restoreState(e),this.current=t,n instanceof Error&&n.message.includes("Function signatures must be enclosed"))throw n}}}parseUnionType(){let e=this.parseIntersectionType();if(!e)return;let t=[e];for(;this.match("|");){let n=this.parseIntersectionType();n||this.error("Expected type after |"),t.push(n)}return t.length===1?t[0]:this.createNode("union",{types:t})}parseIntersectionType(){let e=this.parsePrimaryType();if(!e)return;let t=[e];for(;this.match("&");){let n=this.parsePrimaryType();n||this.error("Expected type after &"),t.push(n)}return t.length===1?t[0]:this.createNode("intersection",{types:t})}parsePrimaryType(){if(this.match("!")){let e=this.parsePrimaryType();return e||this.error("Expected type after !"),this.createNode("negation",{type:e})}if(this.current.type==="("){let e=this.parseFunctionSignature();if(e)return e;if(this.match("(")){let t=this.parseUnionType();if(t||this.error("Expected type after ("),this.current.type===","){let n=[this.createNode("named_element",{name:void 0,type:t})];for(;this.match(",");){let r=this.parseUnionType();r||this.error("Expected type after ,"),n.push(this.createNode("named_element",{name:void 0,type:r}))}return this.expect(")"),this.createNode("tuple",{elements:n})}return this.expect(")"),this.createNode("group",{type:t})}}return this.parseListType()||this.parseTupleType()||this.parseRecordType()||this.parseDictionaryType()||this.parseSetType()||this.parseCollectionType()||this.parseExpressionType()||this.parseSymbolType()||this.parseNumericType()||this.parsePrimitiveType()||this.parseValue()||this.parseTypeReference()}isFunctionSignature(){let e=this.lexer.saveState(),t=this.current;this.advance();let n=1;for(;n>0&&this.current.type!=="EOF";)this.current.type==="("?n++:this.current.type===")"&&n--,this.advance();let r=this.current.type==="->";return this.lexer.restoreState(e),this.current=t,r}parseFunctionSignature(){if(this.current.type!=="("||!this.isFunctionSignature())return;let e=[];if(this.advance(),!this.match(")")){do{let o=this.parseArgument();o||this.error("Expected argument"),e.push(o)}while(this.match(","));this.expect(")")}this.expect("->");let t=this.parseUnionType();t||this.error("Expected return type after ->");let n=e.some(o=>o.modifier==="optional"),r=e.some(o=>o.modifier==="variadic_zero"||o.modifier==="variadic_one"),s=e.filter(o=>o.modifier==="variadic_zero"||o.modifier==="variadic_one").length;return n&&r&&this.error("Variadic arguments cannot be used with optional arguments"),s>1&&this.error("There can be only one variadic argument"),this.createNode("function_signature",{arguments:e,returnType:t})}parseArgument(){let e=this.parseNamedElement();if(!e)return;let t;return this.match("?")?t="optional":this.match("*")?t="variadic_zero":this.match("+")&&(t="variadic_one"),this.createNode("argument",{element:e,modifier:t})}parseNamedElement(){let e;if(this.current.type==="IDENTIFIER"||this.current.type==="VERBATIM_STRING"){let n=this.current;if(this.lexer.peekToken().type===":"){e=n.value,this.advance(),this.advance();let s=this.parseUnionType();return s?this.createNode("named_element",{name:e,type:s}):void 0}}let t=this.parseUnionType();if(t)return this.createNode("named_element",{name:void 0,type:t})}parseListType(){if(this.current.type==="IDENTIFIER"){let e=this.current,n=this.lexer.peekToken().type==="<";switch(e.value){case"list":return n?(this.advance(),this.parseListTypeImpl()):void 0;case"vector":return n?(this.advance(),this.parseVectorType()):(this.advance(),this.createNode("list",{elementType:this.createNode("primitive",{name:"number"}),dimensions:void 0}));case"matrix":return n?(this.advance(),this.parseMatrixType()):(this.advance(),this.createNode("matrix",{elementType:this.createNode("primitive",{name:"number"}),dimensions:[this.createNode("dimension",{size:-1}),this.createNode("dimension",{size:-1})]}));case"tensor":return n?(this.advance(),this.parseTensorType()):(this.advance(),this.createNode("list",{elementType:this.createNode("primitive",{name:"number"}),dimensions:void 0}));default:return}}}parseListTypeImpl(){let e=this.createNode("primitive",{name:"any"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let n=this.parseUnionType();n&&(e=n,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}return this.createNode("list",{elementType:e,dimensions:t})}parseVectorType(){let e=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(this.current.type==="NUMBER_LITERAL")t=parseInt(this.advance().value);else{let n=this.parseUnionType();n&&(e=n,this.match("^")&&(this.current.type==="NUMBER_LITERAL"?t=parseInt(this.advance().value):this.error("Expected number after ^")))}this.expect(">")}return this.createNode("vector",{elementType:e,size:t})}parseMatrixType(){let e=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let n=this.parseUnionType();n&&(e=n,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}else t=[this.createNode("dimension",{size:null}),this.createNode("dimension",{size:null})];return this.createNode("matrix",{elementType:e,dimensions:t})}parseTensorType(){let e=this.createNode("primitive",{name:"number"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("tensor",{elementType:e})}parseDimensions(){let e=this.parseDimension();if(!e)return;let t=[e];for(;;){let n=this.current;if(n.type==="IDENTIFIER"&&/^(x\d+)+$/.test(n.value)){this.advance();for(let r of n.value.match(/x(\d+)/g))t.push(this.createNode("dimension",{size:parseInt(r.slice(1))}))}else if(n.type==="IDENTIFIER"&&n.value==="x"){let r=this.lexer.peekToken();r.type!=="NUMBER_LITERAL"&&r.type!=="?"&&this.error("Expected a positive integer literal or `?` after x. For example: `2x3` or `2x?`"),this.advance(),t.push(this.parseDimension())}else break}return t}parseDimension(){if(this.match("?"))return this.createNode("dimension",{size:null});if(this.current.type==="NUMBER_LITERAL"){let e=parseInt(this.advance().value);return this.createNode("dimension",{size:e})}}parseCaretDimensions(){let e=this.match("("),t=this.parseDimensions();return e&&this.expect(")"),t}parseTupleType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="tuple"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let t=[];if(this.current.type!==">"){let n=this.parseNamedElement();n||this.error("Expected tuple element"),t.push(n);let r=n.name!==void 0;for(;this.match(",");){let s=this.parseNamedElement();s||this.error("Expected tuple element"),r&&!s.name&&this.error("All tuple elements should be named, or none. Previous elements were named, but this one isn't."),!r&&s.name&&this.error("All tuple elements should be named, or none. Previous elements were not named, but this one is."),t.push(s)}}return this.expect(">"),this.createNode("tuple",{elements:t})}}parseRecordType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="record"){this.advance();let e=[];if(this.match("<")){if(this.current.type!==">")do{let t=this.parseRecordEntry();t||this.error("Expected record entry"),e.push(t)}while(this.match(","));this.expect(">")}return this.createNode("record",{entries:e})}}parseRecordEntry(){let e;if(this.current.type==="IDENTIFIER")e=this.advance().value;else if(this.current.type==="VERBATIM_STRING")e=this.advance().value;else return;this.expect(":");let t=this.parseUnionType();return t||this.error("Expected value type"),this.createNode("record_entry",{key:e,valueType:t})}parseDictionaryType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="dictionary"){this.advance();let e=this.createNode("primitive",{name:"any"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("dictionary",{valueType:e})}}parseSetType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="set"){this.advance();let e=this.createNode("primitive",{name:"any"});if(this.match("<")){let t=this.parseUnionType();t&&(e=t),this.expect(">")}return this.createNode("set",{elementType:e})}}parseCollectionType(){if(this.current.type==="IDENTIFIER"){let e=this.current.value==="indexed_collection",t=this.current.value==="collection";if(e||t){this.advance();let n=this.createNode("primitive",{name:"any"});if(this.match("<")){let r=this.parseUnionType();r&&(n=r),this.expect(">")}return this.createNode("collection",{elementType:n,indexed:e})}}}parseExpressionType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="expression"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let n=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("expression",{operator:n})}}parseSymbolType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="symbol"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let n=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("symbol",{name:n})}}parseNumericType(){if(this.current.type==="IDENTIFIER"&&["real","finite_real","rational","finite_rational","integer","finite_integer"].includes(this.current.value)){let t=this.advance().value;if(this.match("<")){let n=this.parseValue();this.expect("..");let r=this.parseValue();this.expect(">");let s=n?.value??-1/0,o=r?.value??1/0;return(Number.isNaN(s)||Number.isNaN(o))&&this.error("Invalid numeric type","Lower and upper bounds must be valid numbers"),s>o&&this.error(`Invalid range: ${s}..${o}`,"The lower bound must be less than the upper bound"),this.createNode("numeric",{baseType:t,lowerBound:n,upperBound:r})}return this.createNode("numeric",{baseType:t})}}parsePrimitiveType(){if(this.current.type==="IDENTIFIER"){let e=this.current.value;if(me.has(e))return this.advance(),this.createNode("primitive",{name:e})}}parseValue(){let e,t;switch(this.current.type){case"STRING_LITERAL":e=this.advance().value,t="string";break;case"NUMBER_LITERAL":e=parseFloat(this.advance().value),t="number";break;case"TRUE":this.advance(),e=!0,t="boolean";break;case"FALSE":this.advance(),e=!1,t="boolean";break;case"NAN":this.advance(),e=NaN,t="nan";break;case"INFINITY":case"PLUS_INFINITY":this.advance(),e=1/0,t="infinity";break;case"MINUS_INFINITY":this.advance(),e=-1/0,t="infinity";break;default:return}return this.createNode("value",{value:e,valueType:t})}parseTypeReference(){let e=this.current.type==="IDENTIFIER"&&this.current.value==="type";if(e&&this.advance(),this.current.type==="IDENTIFIER"){let t=this.current,n=this.advance().value;return this.typeResolver.resolve(n)?this.createNode("type_reference",{name:n,isForward:e}):e&&this.typeResolver.forward(n)?this.createNode("type_reference",{name:n,isForward:!0}):(e||this.errorAtToken(t,`Unknown type "${n}"`,"Syntax error. The type was not recognized."),this.createNode("type_reference",{name:n,isForward:e}))}}};function Gt(i,e){switch(i.kind){case"function_signature":return e.visitFunctionSignature(i);case"union":return e.visitUnionType(i);case"intersection":return e.visitIntersectionType(i);case"negation":return e.visitNegationType(i);case"group":return e.visitGroupType(i);case"list":return e.visitListType(i);case"vector":return e.visitVectorType(i);case"matrix":return e.visitMatrixType(i);case"tensor":return e.visitTensorType(i);case"tuple":return e.visitTupleType(i);case"record":return e.visitRecordType(i);case"dictionary":return e.visitDictionaryType(i);case"set":return e.visitSetType(i);case"collection":return e.visitCollectionType(i);case"expression":return e.visitExpressionType(i);case"symbol":return e.visitSymbolType(i);case"numeric":return e.visitNumericType(i);case"primitive":return e.visitPrimitiveType(i);case"type_reference":return e.visitTypeReference(i);case"value":return e.visitValue(i);default:throw new Error(`Unknown node kind: ${i.kind}`)}}var Yi=class{typeResolver;constructor(e){this.typeResolver=e??{forward:()=>{},resolve:()=>{},get names(){return[]}}}buildType(e){return Gt(e,this)}visitFunctionSignature(e){let t=[],n=[],r,s;for(let c of e.arguments){let l=this.buildNamedElement(c.element);switch(c.modifier){case"optional":n.push(l);break;case"variadic_zero":r=l,s=0;break;case"variadic_one":r=l,s=1;break;default:t.push(l);break}}let o=this.buildType(e.returnType),a={kind:"signature",args:t.length>0?t:void 0,result:o};return n.length>0&&(a.optArgs=n),r&&(a.variadicArg=r,a.variadicMin=s),a}visitUnionType(e){return{kind:"union",types:e.types.map(n=>this.buildType(n))}}visitIntersectionType(e){return{kind:"intersection",types:e.types.map(n=>this.buildType(n))}}visitNegationType(e){return{kind:"negation",type:this.buildType(e.type)}}visitGroupType(e){return this.buildType(e.type)}visitListType(e){let t=this.buildType(e.elementType),n=e.dimensions?.map(r=>this.buildDimension(r));return{kind:"list",elements:t,dimensions:n}}visitVectorType(e){let t=this.buildType(e.elementType);return e.size!==void 0?{kind:"list",elements:t,dimensions:[e.size]}:{kind:"list",elements:t}}visitMatrixType(e){let t=this.buildType(e.elementType);if(e.dimensions){let n=e.dimensions.map(r=>this.buildDimension(r));return{kind:"list",elements:t,dimensions:n}}return{kind:"list",elements:t,dimensions:[-1,-1]}}visitTensorType(e){return{kind:"list",elements:this.buildType(e.elementType)}}visitTupleType(e){return{kind:"tuple",elements:e.elements.map(n=>this.buildNamedElement(n))}}visitRecordType(e){if(e.entries.length===0)return"record";let t={};for(let n of e.entries)t[n.key]=this.buildType(n.valueType);return{kind:"record",elements:t}}visitDictionaryType(e){let t=this.buildType(e.valueType);return this.isAnyType(t)?"dictionary":{kind:"dictionary",values:t}}visitSetType(e){let t=this.buildType(e.elementType);return this.isAnyType(t)?"set":{kind:"set",elements:t}}visitCollectionType(e){let t=this.buildType(e.elementType);return e.indexed?this.isAnyType(t)?"indexed_collection":{kind:"indexed_collection",elements:t}:this.isAnyType(t)?"collection":{kind:"collection",elements:t}}visitExpressionType(e){return{kind:"expression",operator:e.operator}}visitSymbolType(e){return{kind:"symbol",name:e.name}}visitNumericType(e){if(!e.lowerBound&&!e.upperBound)return e.baseType;let t=e.lowerBound?this.buildValue(e.lowerBound):-1/0,n=e.upperBound?this.buildValue(e.upperBound):1/0;return t===-1/0&&n===1/0?e.baseType:{kind:"numeric",type:e.baseType,lower:t,upper:n}}visitPrimitiveType(e){return e.name}visitTypeReference(e){let t=this.typeResolver.resolve(e.name);if(t)return t;if(e.isForward){let n=this.typeResolver.forward(e.name);if(n)return n}return e.name}visitValue(e){return{kind:"value",value:e.value}}buildNamedElement(e){let t=this.buildType(e.type);return e.name?{name:e.name,type:t}:{type:t}}buildDimension(e){return e.size??-1}buildValue(e){return e.value}isAnyType(e){return e==="any"||typeof e=="object"&&"kind"in e&&e.kind==="primitive"&&"name"in e&&e.name==="any"}};function Yt(i,e){return new Yi(e).buildType(i)}var ii=new Map,Fr=2048;function Ut(i){if(i===null||typeof i!="object"||Object.isFrozen(i))return i;Object.freeze(i);for(let e of Object.values(i))Ut(e);return i}function Ui(i,e){if(i===void 0)return;if(Lt(i))return i;if(typeof i!="string")return;let t=e===void 0;if(t){let n=ii.get(i);if(n!==void 0)return n}try{let r=new ei(i,{typeResolver:e}).parseType(),s=Yt(r,e);return t&&(ii.size>=Fr&&ii.clear(),ii.set(i,Ut(s))),s}catch(n){throw new Error(`Failed to parse type "${i}": ${n instanceof Error?n.message:String(n)}`)}}var Jt={number:He,non_finite_number:[],finite_number:["finite_complex","finite_real","finite_integer","finite_rational"],complex:["finite_complex","imaginary","finite_real","finite_rational","finite_integer","non_finite_number"],finite_complex:["imaginary","finite_real","finite_rational","finite_integer"],imaginary:[],real:["rational","integer","finite_real","finite_rational","finite_integer","non_finite_number"],finite_real:["finite_rational","finite_integer"],rational:["finite_rational","finite_integer","integer","non_finite_number"],finite_rational:["finite_integer"],integer:["finite_integer","non_finite_number"],finite_integer:[],any:Gi,unknown:[],nothing:[],never:[],error:[],value:Zi,scalar:Qe,collection:Ke,indexed_collection:qi,list:[],set:[],tuple:[],record:[],dictionary:[],function:[],symbol:[],boolean:[],string:[],color:[],expression:Li},Wt=(()=>{let i={},e=t=>{if(i[t])return i[t];let n=new Set([t]);i[t]=n;for(let r of Jt[t])if(r!==t)for(let s of e(r))n.add(s);return n};for(let t of Object.keys(Jt))e(t);return i})();function ke(i,e){return e==="any"||i==="never"?!0:i==="unknown"||e==="unknown"?!1:i===e?!0:Wt[e].has(i)}function I(i,e){if(typeof i=="string"&&!me.has(i)&&(i=Ui(i)),typeof e=="string"&&!me.has(e)&&(e=Ui(e)),e==="any"||i==="never")return!0;if(e==="never")return!1;if(e==="error")return i==="error";if(e==="nothing")return i==="nothing";if(i==="nothing")return!1;if(e==="unknown")return!0;if(i==="unknown")return!1;if(typeof e=="string")return typeof i=="string"?ke(i,e):i.kind==="value"?typeof i.value=="boolean"?e==="boolean":typeof i.value=="number"?Number.isInteger(i.value)?ke("integer",e):ke("real",e):typeof i.value=="boolean"?ke("boolean",e):typeof i.value=="string"?ke("string",e):!1:i.kind==="union"?i.types.every(t=>I(t,e)):i.kind==="intersection"?i.types.some(t=>I(t,e)):i.kind==="negation"?!I(i.type,e):i.kind==="numeric"?!!I(i.type,e):e==="number"?Xt(i):e==="symbol"?Ji(i):e==="expression"?Cr(i):e==="function"?en(i):e==="scalar"?Ht(i):e==="value"?zt(i):e==="indexed_collection"?Qt(i):e==="collection"?Kt(i):e==="tuple"?i.kind==="tuple":e==="list"?i.kind==="list":e==="set"?i.kind==="set":e==="record"?i.kind==="record":e==="dictionary"?i.kind==="dictionary":!1;if(e.kind==="union")return typeof i!="string"&&i.kind==="union"?i.types.every(t=>e.types.some(n=>I(t,n))):e.types.some(t=>I(i,t));if(e.kind==="expression"){if(i==="symbol")return!0;if(typeof i=="string")return!1;if(i.kind==="expression")return e.operator==="Symbol"?Ji(i):i.operator===e.operator;if(i.kind==="symbol")return!0}if(typeof i=="string")return!1;if(e.kind==="reference"){if(i.kind==="reference")return i.name===e.name;if(e.alias===!0&&e.def)return I(i,e.def)}if(i.kind==="union")return i.types.some(t=>I(t,e));if(i.kind==="intersection"&&e.kind==="intersection")return e.types.every(t=>i.types.some(n=>I(n,t)));if(i.kind==="intersection")return i.types.every(t=>I(t,e));if(e.kind==="intersection")return e.types.every(t=>I(i,t));if(i.kind==="signature"&&e.kind==="signature"){if(!I(i.result,e.result))return!1;if(i.optArgs||i.variadicArg){if(e.args){if(!i.args||i.args.length!==e.args.length)return!1;for(let t=0;t<e.args.length;t++)if(!I(e.args[t].type,i.args[t].type))return!1}else if(i.args)return!1;if(e.optArgs){if(!i.optArgs||i.optArgs.length!==e.optArgs.length)return!1;for(let t=0;t<i.optArgs.length;t++)if(!I(e.optArgs[t].type,i.optArgs[t].type))return!1}else if(i.optArgs)return!1;if(e.variadicArg){if(!i.variadicArg||i.variadicMin!=e.variadicMin||!I(e.variadicArg.type,i.variadicArg.type))return!1}else if(i.variadicArg)return!1}else{if(e.args&&!i.args)return!1;let t=0;if(e.args){if(i.args.length<e.args.length)return!1;for(;t<e.args.length;){if(!I(e.args[t].type,i.args[t].type))return!1;t+=1}}if(e.optArgs){if(t>=i.args.length)return!0;for(let n=0;n<e.optArgs.length;n++){if(!I(e.optArgs[n].type,i.args[t].type))return!1;if(t+=1,t>=i.args.length)return!0}}if(e.variadicArg){if(t>=i.args.length&&e.variadicMin===0)return!0;if(e.variadicMin>0&&t+e.variadicMin>i.args.length)return!1;for(;t<i.args.length;){if(!I(e.variadicArg.type,i.args[t].type))return!1;t+=1}}}return!0}if(i.kind==="record"&&e.kind==="record"){for(let t of Object.keys(e.elements))if(!(t in i.elements)||!I(i.elements[t],e.elements[t]))return!1;return!0}if(i.kind==="dictionary"&&e.kind==="dictionary")return I(i.values,e.values);if(e.kind==="indexed_collection")return i.kind==="indexed_collection"||i.kind==="list"?I(i.elements,e.elements):i.kind==="tuple"?i.elements.every(t=>I(t.type,e.elements)):!1;if(e.kind==="collection"){if(i.kind==="collection"||i.kind==="indexed_collection"||i.kind==="list")return I(i.elements,e.elements);if(i.kind==="tuple")return i.elements.every(t=>I(t.type,e.elements));if(i.kind==="set")return I(i.elements,e.elements);if(i.kind==="dictionary")return I({kind:"tuple",elements:[{type:"string"},{type:i.values}]},e.elements);if(i.kind==="record")return I({kind:"tuple",elements:[{type:"string"},{type:Zr(...Object.values(i.elements))}]},e.elements)}if(i.kind==="tuple"&&e.kind==="tuple"){if(i.elements.length!==e.elements.length)return!1;for(let t=0;t<i.elements.length;t++){let n=i.elements[t],r=e.elements[t];if(!I(n.type,r.type)||n.name!==r.name)return!1}return!0}if(e.kind==="list"&&i.kind==="list"){if(!I(i.elements,e.elements))return!1;if(e.dimensions){if(!i.dimensions||i.dimensions.length!==e.dimensions.length)return!1;for(let t=0;t<i.dimensions.length;t++)if(e.dimensions[t]!==-1&&i.dimensions[t]!==e.dimensions[t])return!1}return!0}if(i.kind==="symbol"&&e.kind==="symbol")return i.name===e.name;if(i.kind==="numeric"&&e.kind==="numeric")return!(!I(i.type,e.type)||(i.lower??-1/0)<(e.lower??-1/0)||(i.upper??1/0)>(e.upper??1/0));if(e.kind==="set"&&i.kind==="set")return!!I(i.elements,e.elements);if(i.kind==="negation"&&e.kind==="negation")return I(i.type,e.type);if(e.kind==="negation")return!I(i,e.type);if(e.kind==="value"&&i.kind==="value")return e.value===i.value;if(i.kind==="value"){if(typeof i.value=="boolean")return I("boolean",e);if(typeof i.value=="number")return Number.isInteger(i.value)?I("integer",e):I("real",e);if(typeof i.value=="string")return I("string",e)}return!1}function Xt(i){return typeof i=="string"?_t.has(i):i.kind==="value"?typeof i.value=="number":i.kind==="numeric"}function Ht(i){return Xt(i)?!0:typeof i=="string"?Zt.has(i):i.kind==="value"?["string","boolean","number"].includes(typeof i.value):!1}function Kt(i){return Qt(i)?!0:typeof i=="string"?qt.has(i):["collection","set","record","dictionary"].includes(i.kind)}function Qt(i){return typeof i=="string"?!1:["indexed_collection","list","tuple"].includes(i.kind)}function zt(i){return Ht(i)||Kt(i)}function en(i){return i==="function"||typeof i!="string"&&i.kind==="signature"}function Cr(i){return typeof i=="string"&&["expression","symbol","function"].includes(i)||zt(i)||en(i)||Ji(i)?!0:typeof i=="string"?!1:i.kind==="expression"}function Ji(i){return i==="symbol"?!0:typeof i=="string"?!1:i.kind==="symbol"?!0:i.kind==="expression"?i.operator==="Symbol":!1}function Vr(i,e){if(i===e)return i;if(i==="any"||e==="any")return"any";if(i==="never")return e;if(e==="never")return i;if(i==="unknown")return e;if(e==="unknown")return i;if(i==="nothing")return e;if(e==="nothing")return i;if(I(i,e))return e;if(I(e,i))return i;let t=Lr(i,e);return _r.has(t)?qr(i,e):t}var _r=new Set(["scalar","value","function","expression","collection","indexed_collection","list","set","tuple","record","dictionary","map","any"]);function qr(i,e){let t=[],n=new Set,r=s=>{if(typeof s=="object"&&s.kind==="union"){for(let a of s.types)r(a);return}let o=typeof s=="string"?s:JSON.stringify(s);n.has(o)||(n.add(o),t.push(s))};return r(i),r(e),t.length===1?t[0]:{kind:"union",types:t}}function Zr(...i){return i.length===0?"nothing":i.length===1?i[0]:i.reduce((e,t)=>Vr(e,t))}var jt=["non_finite_number","finite_integer","integer","finite_rational","rational","finite_real","real","imaginary","finite_complex","complex","finite_number","number","list","record","dictionary","set","tuple","indexed_collection","collection","scalar","value","function","expression"],$t=new Map;function Lr(i,e){if(i===e)return i;if(i==="any"||e==="any")return"any";if(i==="never")return e;if(e==="never")return i;if(i==="unknown")return e;if(e==="unknown")return i;if(i==="nothing")return e;if(e==="nothing")return i;if(typeof i=="string"&&typeof e=="string"){let t=i<e?`${i}|${e}`:`${e}|${i}`,n=$t.get(t);if(n===void 0){n="any";for(let r of jt){let s=Wt[r];if(s.has(i)&&s.has(e)){n=r;break}}$t.set(t,n)}return n}for(let t of jt)if(I(i,t)&&I(e,t))return t;return"any"}var X=class i extends R{rational;radical;im=0;factory;constructor(e,t){if(super(),this.factory=t,typeof e=="number"){!Number.isFinite(e)||Number.isInteger(e),this.rational=[e,1],this.radical=1;return}if(typeof e=="bigint"){this.rational=[e,BigInt(1)],this.radical=1;return}typeof e!="object"||"im"in e;let n=1;if(typeof n!="number"||Number.isInteger(n),n==0){this.rational=[0,1],this.radical=1;return}let r=e.rational?[...e.rational]:[1,1];n!=1&&(typeof n=="bigint"?r=L(r,[n,BigInt(1)]):r=L(r,[n,1])),this.rational=r,this.radical=e.radical??1,this.radical<=P&&this.radical>=1,this.normalize()}get type(){return this.isNaN?"number":this.isPositiveInfinity||this.isNegativeInfinity?"non_finite_number":this.radical!==1?(te(this.rational),"finite_real"):W(this.rational)?"finite_integer":"finite_rational"}get isExact(){return!0}get asExact(){return this}toJSON(){if(this.isNaN)return"NaN";if(this.isPositiveInfinity)return"PositiveInfinity";if(this.isNegativeInfinity)return"NegativeInfinity";if(this.isZero)return 0;if(this.isOne)return 1;if(this.isNegativeOne)return-1;let e=t=>W(t)?O(t[0]):["Rational",O(t[0]),O(t[1])];return this.radical===1?e(this.rational):We(this.rational)?["Sqrt",this.radical]:Xe(this.rational)?["Negate",["Sqrt",this.radical]]:this.rational[0]==1?["Divide",["Sqrt",this.radical],O(this.rational[1])]:this.rational[0]==-1?["Negate",["Divide",["Sqrt",this.radical],O(this.rational[1])]]:["Multiply",e(this.rational),["Sqrt",this.radical]]}clone(e){return new i(e,this.factory)}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";let e=n=>W(n)?x(n[0]):`${x(n[0])}/${x(n[1])}`;if(this.radical===1)return e(this.rational);let t=n=>`sqrt(${x(n)})`;return We(this.rational)?t(this.radical):Xe(this.rational)?`-${t(this.radical)}`:this.rational[0]==1?`${t(this.radical)}/${x(this.rational[1])}`:this.rational[0]==-1?`-${t(this.radical)}/${x(this.rational[1])}`:`${e(this.rational)}${t(this.radical)}`}get sign(){return te(this.rational)?0:$e(this.rational)?1:-1}get re(){return Oi(this.rational)*Math.sqrt(this.radical)}get bignumRe(){let e,t=this.rational;return A(t)?e=new u(t[0]).div(t[1]):e=new u(t[0]).div(new u(t[1])),this.radical===1?e:e.mul(new u(this.radical).sqrt())}get numerator(){return this.rational[1]==1?this:this.clone({rational:A(this.rational)?[this.rational[0],1]:[this.rational[0],BigInt(1)],radical:this.radical})}get denominator(){return A(this.rational)?this.clone(this.rational[1]):this.clone({rational:[this.rational[1],BigInt(1)]})}normalize(){if(Number.isInteger(this.radical)&&this.radical>0&&Number.isFinite(this.radical),isNaN(this.radical)){this.rational=[NaN,1],this.radical=1;return}let[e,t]=this.rational;if(t==0){this.rational=[NaN,1],this.radical=1;return}if(this.radical===0||e===0){this.rational=[0,1],this.radical=1;return}if(this.radical>=4){let[n,r]=ee(this.radical,2);n!==1&&(this.rational=L(this.rational,[n,1])),this.radical=r}this.rational=Be(this.rational)}get isNaN(){return Number.isNaN(this.rational[0])}get isPositiveInfinity(){return this.rational[0]==1/0}get isNegativeInfinity(){return this.rational[0]==-1/0}get isComplexInfinity(){return!1}get isZero(){return te(this.rational)}get isOne(){return!(this.rational[0]!==this.rational[1]||this.radical!==1)}get isNegativeOne(){return!(this.rational[0]!==-this.rational[1]||this.radical!==1)}sgn(){if(!Number.isNaN(this.rational[0]))return te(this.rational)?0:$e(this.rational)?1:-1}N(){return this.isZero||this.isOne||this.isNegativeOne?this:this.rational[1]==1&&this.radical===1?this:this.factory(this.bignumRe)}neg(){return this.isZero?this:this.clone({rational:Fi(this.rational),radical:this.radical})}inv(){return this.isNaN?this:this.isPositiveInfinity||this.isNegativeInfinity?this.clone(0):this.isZero?this.clone(1/0):this.isOne?this:this.isNegativeOne?this:this.clone({rational:L([BigInt(this.rational[1]),BigInt(1)],we([BigInt(this.rational[0])*BigInt(this.radical),BigInt(1)])),radical:this.radical})}add(e){return typeof e=="number"?e===0?this:Number.isInteger(e)&&this.radical===1?this.clone({rational:ne(this.rational,[e,1])}):this.factory(this.bignumRe).add(e):e.isZero?this:this.isZero?e:e instanceof i?this.radical===e.radical?this.clone({rational:ne(this.rational,e.rational),radical:this.radical}):this.factory(this.bignumRe).add(e):e.add(this)}sub(e){return this.add(e.neg())}mul(e){if(e===0)return this.isPositiveInfinity||this.isNegativeInfinity||this.isNaN?this.clone(NaN):this.clone(0);if(e===1)return this;if(e===-1)return this.neg();if(typeof e=="number")return Number.isInteger(e)?this.clone({rational:L(this.rational,[e,1]),radical:this.radical}):this.factory(this.bignumRe).mul(e);if(e instanceof u)return this.factory(e).mul(this);if(e.im!==0)return e.mul(this);if(e.isZero)return this.isPositiveInfinity||this.isNegativeInfinity||this.isNaN?this.clone(NaN):e;if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isNaN)return e;if(this.isZero)return e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN?this.clone(NaN):this;if(this.isOne)return e;if(this.isNegativeOne)return e.neg();if(!(e instanceof i))return e.mul(this);let t=BigInt(this.radical)*BigInt(e.radical);return t>BigInt(P)?this.factory(this.bignumRe).mul(e):this.clone({rational:L(this.rational,e.rational),radical:Number(t)})}div(e){if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({rational:L(this.rational,[1,e]),radical:this.radical});if(this.isNaN)return this;if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(this.isZero)return e.isZero?this.clone(NaN):e.isNaN?e:this;if(e.isNaN)return e;if(e.isZero)return this.clone(this.sign*(1/0));if(!(e instanceof i))return this.factory(this.bignumRe).div(e);if(e.im!==0)return this.factory(this.bignumRe).div(e);let t=L(this.rational,[BigInt(e.rational[1]),BigInt(e.rational[0])*BigInt(e.radical)]),n=BigInt(this.radical)*BigInt(e.radical);return n>BigInt(P)?this.factory(this.bignumRe).div(e):this.clone({rational:t,radical:Number(n)})}pow(e){if(Array.isArray(e),this.isNaN)return this;if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;if(e.im)e={re:e.re,im:e.im};else{if(e instanceof i&&e.radical===1&&e.rational[0]==1)return this.root(Number(e.rational[1]));e=e.re}}if(e===.5)return this.sqrt();if(typeof e=="object"&&("re"in e||"im"in e))return this.factory(this.bignumRe).pow(e);if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.factory({im:1/0})}if(e<0)return this.pow(-e).inv();if(e%1===.5)return this.pow(Math.floor(e)).mul(this.sqrt());if(this.radical>P||this.rational[0]>P||this.rational[0]<-P||this.rational[1]>P)return this.factory(this.bignumRe).pow(e);if(this.sign<0){if(Number.isInteger(e)){let t=e%2===0?1:-1,n=BigInt(e),r=BigInt(this.radical)**n;return r>BigInt(P)?this.factory(this.bignumRe).pow(e):this.clone({rational:[BigInt(t)*(-BigInt(this.rational[0]))**n,BigInt(this.rational[1])**n],radical:Number(r)})}return this.factory({im:(-this.re)**e})}else if(Number.isInteger(e)){let t=BigInt(e),n=BigInt(this.radical)**t;return n>BigInt(P)?this.factory(this.bignumRe).pow(e):this.clone({rational:[BigInt(this.rational[0])**t,BigInt(this.rational[1])**t],radical:Number(n)})}return this.factory(this.bignumRe).pow(e)}root(e){if(e===0)return this.clone(NaN);if(this.isNaN)return this;if(this.isZero)return this;if(e===1)return this;if(e===-1)return this.inv();if(e<0)return this.root(-e).inv();if(e%1===.5)return this.root(Math.floor(e)).sqrt();if(this.sign<0&&Number.isInteger(e)&&e%2===1)return this.neg().root(e).neg();if(this.radical===1){if(this.sign>0){let t=this.re;if(Number.isInteger(t)){if(t>0){let n=Math.pow(t,1/e);if(Number.isInteger(n))return this.clone(n)}return this.factory(this.bignumRe).root(e)}}return this.factory(this.bignumRe).root(e)}if(this.sign<0)return this.factory({im:Math.pow(-this.re,1/e)});if(this.radical>P||this.rational[0]>P||this.rational[0]<-P||this.rational[1]>P)return this.factory(this.bignumRe).root(e);if(this.rational[1]==1){let t=Math.pow(this.rational[0],1/e);if(Number.isInteger(t))return this.clone(t)}return this.factory(this.bignumRe).root(e)}sqrt(){if(this.isZero||this.isOne)return this;if(this.radical===1)if(A(this.rational)){let[e,t]=this.rational;return e*t>P?this.factory(this.bignumRe).sqrt():e>0?this.clone({radical:e*t,rational:[1,t]}):this.factory({im:Math.sqrt(-e*t)/t})}else return this.factory(this.bignumRe).sqrt();if(this.sign>0){let e=Math.sqrt(this.re);if(Number.isInteger(e))return this.clone(e)}return this.factory(this.bignumRe).sqrt()}gcd(e){if(!(e instanceof i))return e.gcd(this);if(this.isOne||e.im!==0||e.isOne)return this.clone(1);let t=Ci(this.rational,e.rational),n=_(this.radical,e.radical);return this.clone({rational:t,radical:n})}abs(){return this.sign===-1?this.neg():this}ln(e){return this.isZero?this.clone(NaN):this.isPositiveInfinity?this.clone(1/0):this.sign<0?this.clone(NaN):this.isOne?this.clone(0):this.isNegativeOne?this.factory({im:Math.PI}):this.factory(this.bignumRe).ln(e)}exp(){return this.isNaN?this.clone(NaN):this.isZero?this.clone(1):this.isNegativeInfinity?this.clone(0):this.isPositiveInfinity?this.clone(1/0):this.factory(this.bignumRe).exp()}_integerPart(e){let t=BigInt(this.rational[0]),n=BigInt(this.rational[1]);n<0n&&(t=-t,n=-n);let r;if(e==="round"){let s=2n*t+n,o=2n*n;r=s/o,s%o!==0n&&s<0n&&(r-=1n)}else r=t/n,t%n!==0n&&(e==="floor"&&t<0n&&(r-=1n),e==="ceil"&&t>0n&&(r+=1n));return this.clone({rational:[r,BigInt(1)],radical:1})}floor(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("floor"):this.clone(Math.floor(this.re))}ceil(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("ceil"):this.clone(Math.ceil(this.re))}round(){return this.isNaN?this.clone(NaN):this.radical===1&&W(this.rational)?this:this.radical===1?this._integerPart("round"):this.clone(Math.round(this.re))}eq(e){return typeof e=="number"?this.radical===1&&W(this.rational)&&this.rational[0]==e:e instanceof i?this.radical===e.radical&&this.rational[0]==e.rational[0]&&this.rational[1]==e.rational[1]:e.im===0&&e.re===this.re}lt(e){if(this.im===0)return typeof e=="number"?this.re<e:this.re<e.re}lte(e){if(this.im===0)return typeof e=="number"?this.re<=e:this.re<=e.re}gt(e){if(this.im===0)return typeof e=="number"?this.re>e:this.re>e.re}gte(e){if(this.im===0)return typeof e=="number"?this.re>=e:this.re>=e.re}static sum(e,t){if(e.length===1)return e;if(e.some(a=>!a.isExact)){if(e.length===2)return[e[0].add(e[1])];let a=t(0);for(let c of e)a=a.add(c);return[a]}let n=0,r=[0,1],s=[];for(let a of e){if(a.isNaN)return[new i(NaN,t)];if(!a.isZero)if(n+=a.im,a instanceof i){let c=a.rational;if(a.radical===1)r=ne(r,c);else{let l=s.findIndex(m=>m.radical===a.radical);l===-1?s.push({multiple:c,radical:a.radical}):s[l].multiple=ne(s[l].multiple,c)}}else{I(a.type,"integer");let c=BigInt(a.bignumRe.toFixed(0));r=ne(r,[c,BigInt(1)])}}if(te(r)&&s.length===0)return n===0?[new i(0,t)]:[t({im:n})];let o=[];return n!==0&&o.push(t({im:n})),s.length===0?o.push(new i({rational:r},t)):(s.push({multiple:r,radical:1}),o.push(...s.map(a=>new i({rational:a.multiple,radical:a.radical},t)))),o}};function ji(i,e){for(i.isInteger()&&e.isInteger();!e.isZero();)[i,e]=[e,i.mod(e)];return i.abs()}function tn(i,e){return i.mul(e).div(ji(i,e)).abs()}function*nn(i){if(!i.isInteger()||i.isNegative())return u.NAN;if(i.lt(1))return u.ONE;let e=i;for(;i.gt(2);)i=i.sub(2),e=e.mul(i),yield e;return e}function xe(i){if(!i.isFinite()||i.isZero())return!0;let n=(i.significand<0n?-i.significand:i.significand).toString().length;if(n>17)return!1;let r=n+i.exponent-1;return r<309&&r>-308}var ni=class i extends R{decimal;constructor(e){if(super(),typeof e=="number")this.decimal=new u(e),this.im=0;else if(e instanceof u)this.decimal=e,this.im=0;else{let t=e.re instanceof u?e.re:new u(e.re??0);this.decimal=t,this.im=e.im??0}this.decimal.isNaN()?this.im=NaN:isNaN(this.im)&&(this.decimal=u.NAN)}get type(){return this.isNaN?"number":this.isComplexInfinity?"complex":this.im!==0?this.decimal.isZero()?"imaginary":"finite_complex":this.decimal.isFinite()?this.decimal.isInteger()?"finite_integer":"finite_real":"non_finite_number"}get isExact(){return this.im===0&&this.decimal.isInteger()}get asExact(){if(this.isExact)return this._makeExact(V(this.decimal))}toJSON(){return this.isNaN?"NaN":this.isPositiveInfinity?"PositiveInfinity":this.isNegativeInfinity?"NegativeInfinity":this.isComplexInfinity?"ComplexInfinity":this.im===0?xe(this.decimal)?this.decimal.toNumber():{num:ti(this.decimal)}:xe(this.decimal)?["Complex",O(this.decimal.toNumber()),O(this.im)]:["Complex",{num:ti(this.decimal)},O(this.im)]}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";if(this.im===0)return ti(this.decimal.toPrecision(u.precision));if(this.decimal.isZero())return this.im===1?"i":this.im===-1?"-i":`${x(this.im)}i`;if(this.isComplexInfinity)return"~oo";let e="";return this.im===1?e="+ i":this.im===-1?e="- i":this.im>0?e=`+ ${this.im}i`:e=`- ${-this.im}i`,`(${ti(this.decimal)} ${e})`}clone(e){return new i(e)}_makeExact(e){return new X(e,t=>this.clone(t))}get re(){return this.decimal.toNumber()}get bignumRe(){return this.decimal}get numerator(){return this}get denominator(){return this._makeExact(1)}get isNaN(){return this.decimal.isNaN()}get isPositiveInfinity(){return this.im===0&&!this.decimal.isFinite()&&!this.decimal.isNaN()&&this.decimal.isPositive()}get isNegativeInfinity(){return this.im===0&&!this.decimal.isFinite()&&!this.decimal.isNaN()&&this.decimal.isNegative()}get isComplexInfinity(){return!Number.isFinite(this.im)&&!Number.isNaN(this.im)}get isZero(){return this.im===0&&this.decimal.isZero()}isZeroWithTolerance(e){let t=typeof e=="number"?e:e.toNumber();if(Math.abs(this.im)>t)return!1;let n=typeof e=="number"?new u(e):e;return this.decimal.abs().lte(n)}get isOne(){return this.im===0&&this.decimal.eq(1)}get isNegativeOne(){return this.im===0&&this.decimal.eq(-1)}sgn(){if(this.im===0){if(this.decimal.isZero())return 0;if(this.decimal.isPositive())return 1;if(this.decimal.isNegative())return-1}}N(){return this}neg(){return this.isZero?this:this.clone({re:this.decimal.neg(),im:-this.im})}inv(){if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.clone(this.decimal.inv());let e=this.re*this.re+this.im*this.im,t=this.decimal.mul(this.decimal).add(this.im*this.im);return this.clone({re:this.decimal.div(t),im:-this.im/e})}add(e){return typeof e=="number"?e===0?this:this.clone({re:this.decimal.add(e),im:this.im}):e.isZero?this:this.isZero?this.clone({re:e.bignumRe??e.re,im:e.im}):this.clone({re:this.decimal.add(e.bignumRe??e.re),im:this.im+e.im})}sub(e){return this.add(e.neg())}mul(e){if(this.isZero)return e instanceof R&&(e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN)?this._makeExact(NaN):this;if(e===1)return this;if(e===-1)return this.neg();if(e===0)return this.isNaN||this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0);if(this.isOne)return typeof e=="number"||e instanceof u?this.clone(e):this.clone({re:e.bignumRe??e.re,im:e.im});if(typeof e=="number")return this.im===0?this.clone(this.decimal.mul(e)):this.clone({re:this.decimal.mul(e),im:this.im*e});if(e instanceof u)return this.im===0?this.clone(this.decimal.mul(e)):this.clone({re:this.decimal.mul(e),im:this.im*e.toNumber()});if(this.isNegativeOne){let t=e.neg();return this.clone({re:t.bignumRe??t.re,im:t.im})}return e.isOne?this:e.isNegativeOne?this.neg():e.isZero?this.isNaN||this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0):this.im===0&&e.im===0?this.clone(this.decimal.mul(e.bignumRe??e.re)):this.clone({re:this.decimal.mul(e.bignumRe??e.re).sub(this.im*e.im),im:this.re*e.im+this.im*e.re})}div(e){if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({re:this.decimal.div(e),im:this.im/e});if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isZero)return this.isZero||this.isNaN?this.clone(NaN):this.im!==0?this.clone({im:1/0}):this.clone(this.decimal.isNegative()?-1/0:1/0);if(this.im===0&&e.im===0)return this.clone(this.decimal.div(e.bignumRe??e.re));let[t,n]=[this.re,this.im],[r,s]=[e.re,e.im],o=r*r+s*s,a=e.bignumRe??new u(e.re),c=a.mul(a).add(s*s);return this.clone({re:this.decimal.mul(a).add(n*s).div(c),im:(n*r-t*s)/o})}pow(e){if(Array.isArray(e),this.isNaN)return this;if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;e.im?e={re:e.re,im:e.im}:e=e.re}if(typeof e=="object"&&("re"in e||"im"in e)){let[c,l]=[e?.re??0,e?.im??0];if(Number.isNaN(l)||Number.isNaN(c))return this.clone(NaN);if(l===0)e=c;else{if(this.im===1/0)return this.clone(NaN);if(this.isNegativeInfinity)return this.clone(0);if(this.isPositiveInfinity)return this.clone({im:1/0});if(this.isZero)return c>0?this.clone(0):this.clone(NaN);let m=this.decimal,f=this.im,d=m.mul(m).add(f*f).sqrt().ln(),h=u.atan2(f,m),N=d.mul(c).sub(h.mul(l)),p=h.mul(c).add(d.mul(l)),g=N.exp();return this.clone({re:g.mul(p.cos()),im:fe(g.mul(p.sin()).toNumber())})}}if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.clone({im:1/0})}if(e<0)return this.pow(-e).inv();if(this.im===0)return this.clone(this.decimal.pow(e));let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t),o=r.pow(e),a=s.mul(e);return this.clone({re:o.mul(a.cos()),im:fe(o.mul(a.sin()).toNumber())})}root(e){if(!Number.isInteger(e))return this._makeExact(NaN);if(e===0)return this._makeExact(NaN);if(e===1)return this;if(this.isZero)return this;if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.decimal.isNegative()?e%2===0?this._makeExact(NaN):e===3?this.clone(this.decimal.cbrt()):this.clone(this.decimal.neg().ln().div(e).exp().neg()):e===2?this.clone(this.decimal.sqrt()):e===3?this.clone(this.decimal.cbrt()):this.clone(this.decimal.ln().div(e).exp());let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t),o=r.ln().div(e).exp(),a=s.div(e);return this.clone({re:o.mul(a.cos()),im:fe(o.mul(a.sin()).toNumber())})}sqrt(){if(this.isZero||this.isOne)return this;if(this.im!==0){let e=this.decimal,t=this.im,n=e.mul(e).add(t*t).sqrt(),r=e.add(n).div(2),s=n.sub(e).div(2),o=r.isNegative()?u.ZERO:r.sqrt(),a=fe(Math.sign(t)*(s.isNegative()?0:s.sqrt().toNumber()));return this.clone({re:o,im:a})}return this.decimal.isPositive()?this.clone(this.decimal.sqrt()):this.clone({im:Math.sqrt(-this.re)})}gcd(e){if(this.isZero)return e;if(e.isZero)return this;if(this.im!==0||e.im!==0)return this._makeExact(NaN);if(!this.decimal.isInteger())return this._makeExact(1);let t=e.bignumRe?new u(e.bignumRe):new u(e.re);if(!t.isInteger())return this._makeExact(1);let n=this.decimal;for(;!t.isZero();){let r=t;t=n.mod(t),n=r}return this.clone(n.abs())}abs(){return this.im===0?this.decimal.isPositive()?this:this.clone(this.decimal.neg()):this.clone(this.decimal.pow(2).add(this.im**2).sqrt())}ln(e){if(this.isZero)return this._makeExact(NaN);if(this.isNegativeInfinity)return this._makeExact(NaN);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im===0)return this.decimal.isNegative()?this._makeExact(NaN):this.isOne?this._makeExact(0):this.isNegativeOne?this.clone({im:Math.PI}):e===void 0?this.clone(this.decimal.ln()):this.clone(this.decimal.log(e));let t=this.decimal,n=this.im,r=t.mul(t).add(n*n).sqrt(),s=u.atan2(n,t).toNumber();return e===void 0?this.clone({re:r.ln(),im:s}):this.clone({re:r.log(e),im:s})}exp(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(1);if(this.isNegativeInfinity)return this._makeExact(0);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im!==0){let e=this.decimal.exp();return this.clone({re:e.mul(fe(Math.cos(this.im))),im:fe(e.mul(Math.sin(this.im)).toNumber())})}return this.clone(this.decimal.exp())}floor(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.floor()))}ceil(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.ceil()))}round(){return this.isNaN||this.im!==0?this._makeExact(NaN):this.decimal.isInteger()?this:this._makeExact(V(this.decimal.round()))}eq(e){return this.isNaN?!1:typeof e=="number"?this.im===0&&this.decimal.eq(e):e.isNaN?!1:Number.isFinite(this.im)?this.decimal.eq(e.bignumRe??e.re)&&this.im-e.im===0:!Number.isFinite(e.im)}lt(e){if(this.im===0)return typeof e=="number"?this.decimal.lt(e):this.decimal.lt(e.bignumRe??e.re)}lte(e){if(this.im===0)return typeof e=="number"?this.decimal.lte(e):this.decimal.lte(e.bignumRe??e.re)}gt(e){if(this.im===0)return typeof e=="number"?this.decimal.gt(e):this.decimal.gt(e.bignumRe??e.re)}gte(e){if(this.im===0)return typeof e=="number"?this.decimal.gte(e):this.decimal.gte(e.bignumRe??e.re)}};function ti(i){let e=i.toString();if(i.isInteger()&&e.includes("e")){let t=i.toFixed(0),n=t.match(/0+$/);if((n?n[0].length:0)<=5)return t}return e}function fe(i){return Math.abs(i)<=1e-14?0:i}var ri=class i extends R{decimal;constructor(e){if(super(),typeof e=="number")this.decimal=e,this.im=0;else if(e instanceof u)this.decimal=e.toNumber(),this.im=0;else{let t=e.re===void 0?0:e.re instanceof u?e.re.toNumber():e.re;this.decimal=t,this.im=e.im??0,isFinite(this.im)||(this.decimal=this.im)}isNaN(this.im)}_makeExact(e){return new X(e,t=>this.clone(t))}get type(){return this.isNaN?"number":this.isComplexInfinity?"complex":this.im!==0?this.decimal===0?"imaginary":"finite_complex":Number.isFinite(this.decimal)?Number.isInteger(this.decimal)?"finite_integer":"finite_real":"non_finite_number"}get isExact(){return this.im===0&&Number.isInteger(this.decimal)}get asExact(){if(this.isExact)return this._makeExact(this.decimal)}toJSON(){return this.isNaN?"NaN":this.isPositiveInfinity?"PositiveInfinity":this.isNegativeInfinity?"NegativeInfinity":this.im===0?O(this.decimal):["Complex",O(this.decimal),O(this.im)]}toString(){if(this.isZero)return"0";if(this.isOne)return"1";if(this.isNegativeOne)return"-1";if(this.im===0)return x(this.decimal);if(this.decimal===0)return this.im===1?"i":this.im===-1?"-i":`${x(this.im)}i`;if(this.isComplexInfinity)return"~oo";let e="";return this.im===1?e="+ i":this.im===-1?e="- i":this.im>0?e=`+ ${x(this.im)}i`:e=`- ${x(-this.im)}i`,`(${x(this.decimal)} ${e})`}clone(e){return new i(e)}get re(){return this.decimal}get bignumRe(){}get numerator(){return this}get denominator(){return this._makeExact(1)}get isNaN(){return Number.isNaN(this.decimal)}get isPositiveInfinity(){return!Number.isFinite(this.decimal)&&this.decimal>0&&this.im===0}get isNegativeInfinity(){return!Number.isFinite(this.decimal)&&this.decimal<0&&this.im===0}get isComplexInfinity(){return!Number.isFinite(this.im)&&!Number.isNaN(this.im)}get isZero(){return this.im===0&&this.decimal===0}isZeroWithTolerance(e){let t=e instanceof u?e.toNumber():e;return Math.abs(this.im)<=t&&Math.abs(this.decimal)<t}get isOne(){return this.im===0&&this.decimal===1}get isNegativeOne(){return this.im===0&&this.decimal===-1}sgn(){if(!(this.im!==0||!Number.isFinite(this.decimal)))return Math.sign(this.decimal)}N(){return this}neg(){return this.isNaN?this._makeExact(NaN):this.isZero?this:this.clone({re:-this.decimal,im:-this.im})}inv(){if(this.isNaN)return this._makeExact(NaN);if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.im===0)return this.clone(1/this.decimal);let e=this.re*this.re+this.im*this.im;return this.clone({re:this.decimal/e,im:-this.im/e})}add(e){return this.isNaN?this._makeExact(NaN):typeof e=="number"?e===0?this:this.clone({re:this.decimal+e,im:this.im}):e.isZero?this:this.isZero?this.clone({re:e.bignumRe??e.re,im:e.im}):this.clone({re:this.decimal+e.re,im:this.im+e.im})}sub(e){return this.add(e.neg())}mul(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return e instanceof R&&(e.isPositiveInfinity||e.isNegativeInfinity||e.isComplexInfinity||e.isNaN)?this._makeExact(NaN):this;if(e instanceof u&&(e=e.toNumber()),e===1)return this;if(e===-1)return this.neg();if(e===0)return this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0);if(this.isOne)return typeof e=="number"||e instanceof u?this.clone(e):this.clone({re:e.bignumRe??e.re,im:e.im});if(typeof e=="number")return this.im===0?this.clone(this.decimal*e):this.clone({re:this.decimal*e,im:this.im*e});if(this.isNegativeOne){let t=e.neg();return this.clone({re:t.bignumRe??t.re,im:t.im})}return e.isOne?this:e.isNegativeOne?this.neg():e.isZero?this.isPositiveInfinity||this.isNegativeInfinity||this.isComplexInfinity?this._makeExact(NaN):this.clone(0):this.im===0&&e.im===0?this.clone(this.decimal*e.re):this.clone({re:this.decimal*e.re-this.im*e.im,im:this.re*e.im+this.im*e.re})}div(e){if(this.isNaN)return this._makeExact(NaN);if(typeof e=="number")return e===1?this:e===-1?this.neg():e===0?this.clone(NaN):this.clone({re:this.decimal/e,im:this.im/e});if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isZero)return this.clone(this.isZero?NaN:1/0);if(this.im===0&&e.im===0)return this.clone(this.decimal/e.re);let[t,n]=[this.decimal,this.im],[r,s]=[e.re,e.im],o=r*r+s*s;return this.clone({re:(t*r+n*s)/o,im:(n*r-t*s)/o})}pow(e){if(Array.isArray(e),this.isNaN)return this._makeExact(NaN);if(typeof e=="number"&&isNaN(e))return this.clone(NaN);if(e instanceof R){if(e.isNaN)return this.clone(NaN);if(e.isZero)return this.clone(1);if(e.isOne)return this;e.im?e={re:e.re,im:e.im}:e=e.re}if(typeof e=="object"&&("re"in e||"im"in e)){let[c,l]=[e?.re??0,e?.im??0];if(Number.isNaN(l)||Number.isNaN(c))return this.clone(NaN);if(l===0)e=c;else{if(this.im===1/0)return this.clone(NaN);if(this.isNegativeInfinity)return this.clone(0);if(this.isPositiveInfinity)return this.clone({im:1/0});if(this.isZero)return c>0?this.clone(0):this.clone(NaN);let m=this.decimal,f=this.im,d=.5*Math.log(m*m+f*f),h=Math.atan2(f,m),N=c*d-l*h,p=c*h+l*d,g=Math.exp(N);return this.clone({re:rn(g*Math.cos(p)),im:rn(g*Math.sin(p))})}}if(this.isPositiveInfinity){if(e===-1)return this.clone(0);if(e===1/0)return this.clone(1/0);if(e===-1/0)return this.clone(0)}else if(this.isNegativeInfinity&&e===1/0)return this.clone(NaN);if((e===1/0||e===-1/0)&&(this.isOne||this.isNegativeOne))return this.clone(NaN);if(e===1)return this;if(e===-1)return this.inv();if(e===0)return this.clone(1);if(this.isZero){if(e>0)return this;if(e<0)return this.clone({im:1/0})}if(e<0&&this.im===0)return this.clone(1/this.decimal**-e);if(this.im===0)return this.clone(this.decimal**e);let t=this.decimal,n=this.im,r=Math.sqrt(t*t+n*n),s=Math.atan2(n,t),o=r**e,a=s*e;return this.clone({re:o*Math.cos(a),im:o*Math.sin(a)})}root(e){if(this.isNaN)return this._makeExact(NaN);if(e===0)return this.clone(NaN);if(this.isNaN)return this;if(this.isZero)return this;if(this.isOne)return this;if(this.isNegativeOne)return this;if(e===1)return this;if(e===2)return this.sqrt();if(e===3)return this.clone(Math.cbrt(this.decimal));if(this.im===0)return this.decimal<0?e%2===0?this.clone(NaN):this.clone(-Math.pow(-this.decimal,1/e)):this.clone(Math.pow(this.decimal,1/e));let t=this.decimal,n=this.im,r=Math.hypot(t,n),s=Math.atan2(n,t),o=Math.pow(r,1/e),a=s/e;return this.clone({re:o*Math.cos(a),im:o*Math.sin(a)})}sqrt(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero||this.isOne)return this;if(this.im!==0){let e=this.decimal,t=this.im,n=Math.sqrt(e*e+t*t),r=Math.sqrt((e+n)/2),s=Math.sign(t)*Math.sqrt((n-e)/2);return this.clone({re:r,im:s})}return this.decimal>0?this.clone(Math.sqrt(this.decimal)):this.clone({im:Math.sqrt(-this.decimal)})}gcd(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return e;if(e.isZero)return this;if(this.im!==0||e.im!==0)return this._makeExact(NaN);if(!Number.isInteger(this.decimal))return this._makeExact(1);let t=e.re;if(!Number.isInteger(t))return this._makeExact(1);let n=this.decimal;for(;t!==0;){let r=t;t=n%t,n=r}return this.clone(Math.abs(n))}abs(){return this.isNaN?this._makeExact(NaN):this.im===0?this.decimal>0?this:this.clone(-this.decimal):this.clone(Math.sqrt(this.decimal**2+this.im**2))}ln(e){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(NaN);if(this.isNegativeInfinity)return this._makeExact(NaN);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im===0)return this.decimal<0?this._makeExact(NaN):this.isOne?this._makeExact(0):this.isNegativeOne?this.clone({im:Math.PI}):e===void 0?this.clone(Math.log(this.decimal)):this.clone(Math.log(this.decimal)/Math.log(e));let t=this.decimal,n=this.im,r=Math.hypot(t,n),s=Math.atan2(n,t),o=e===void 0?Math.log(r):Math.log(r)/Math.log(e);return this.clone({re:o,im:s})}exp(){if(this.isNaN)return this._makeExact(NaN);if(this.isZero)return this._makeExact(1);if(this.isNegativeInfinity)return this._makeExact(0);if(this.isPositiveInfinity)return this._makeExact(1/0);if(this.im!==0){let e=Math.exp(this.decimal);return this.clone({re:e*Math.cos(this.im),im:e*Math.sin(this.im)})}return this.clone(Math.exp(this.decimal))}floor(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.floor(this.decimal))}ceil(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.ceil(this.decimal))}round(){return this.isNaN||this.im!==0?this._makeExact(NaN):Number.isInteger(this.decimal)?this:this._makeExact(Math.round(this.decimal))}eq(e){return this.isNaN?!1:typeof e=="number"?this.im===0&&this.decimal===e:e.isNaN?!1:Number.isFinite(this.im)?this.decimal===e.re&&this.im===e.im:!Number.isFinite(e.im)}lt(e){if(this.im===0)return typeof e=="number"?this.decimal<e:this.decimal<e.re}lte(e){if(this.im===0)return typeof e=="number"?this.decimal<=e:this.decimal<=e.re}gt(e){if(this.im===0)return typeof e=="number"?this.decimal>e:this.decimal>e.re}gte(e){if(this.im===0)return typeof e=="number"?this.decimal>=e:this.decimal>=e.re}};function rn(i){return Math.abs(i)<=1e-14?0:i}function sn(i){return i?._kind==="number"}function Gr(i){return i?._kind==="symbol"}function Pe(i,e){return(i?._kind==="function"||i?._kind==="tensor")&&(e===void 0||i.operator===e)}function Yr(i){if(Pe(i,"Interval")){let e=i.op1,t=i.op2,n=!1,r=!1;Pe(e,"Open")?(n=!0,e=e.op1):Pe(e,"Closed")&&(e=e.op1),Pe(t,"Open")?(r=!0,t=t.op1):Pe(t,"Closed")&&(t=t.op1);let s=e.N(),o=t.N();return!sn(s)||!sn(o)?void 0:{start:s.re,openStart:n,end:o.re,openEnd:r}}if(Gr(i)){if(i.symbol==="EmptySet")return{start:0,openStart:!0,end:0,openEnd:!0};if(i.symbol==="RealNumbers")return{start:-1/0,openStart:!1,end:1/0,openEnd:!1};if(i.symbol==="NegativeNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!0};if(i.symbol==="NonPositiveNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!1};if(i.symbol==="PositiveNumbers")return{start:0,openStart:!0,end:1/0,openEnd:!1};if(i.symbol==="NonNegativeNumbers")return{start:0,openStart:!1,end:1/0,openEnd:!1}}}function Ur(i,e){return!((i.openStart?e<=i.start:e<i.start)||(i.openEnd?e>=i.end:e>i.end))}function Jr(i,e){if(!i.openStart&&e.openStart){if(i.start<=e.start)return!1}else if(i.start<e.start)return!1;if(!i.openEnd&&e.openEnd){if(i.end>=e.end)return!1}else if(i.end>e.end)return!1;return!0}function on(i){let e=i.length;if(e===1)return i[0][0];if(e===2)return i[0][0]*i[1][1]-i[0][1]*i[1][0];let t=[],n=0;for(let r=0;r<e;r++){let s=0;for(let o=1;o<e;o++){let a=0;for(let c=0;c<e;c++)c!==r&&(t[s][a]=i[o][c],a++);s++}n=n+Math.pow(-1,r)*i[0][r]*on(t)}return n}function jr(i,e){if(e===0)return{estimate:i,error:e};let t=Math.abs(e),n=Math.floor(Math.log10(t)),r=2,s=Math.pow(10,n-(r-1)),o=Math.round(e/s)*s,a=Math.max(0,-(n-(r-1)));return{estimate:Number(i.toFixed(a)),error:o}}function $r(i,e,t,n=1e5,r){r??=qe();let s;e===-1/0&&t===1/0?s=()=>{let g=Math.random(),b=Math.tan(Math.PI*(g-.5));return i(b)*Math.PI*(1+b*b)}:e===-1/0?s=()=>{let g=Math.random();return i(t+Math.log(g))/g}:t===1/0?s=()=>{let g=Math.random();return i(e-Math.log(g))/g}:s=()=>i(e+Math.random()*(t-e));let o=0,a=0,c=0;Ze(r,()=>{for(let g=0;g<n;g++){if((g&63)===0&&r!==void 0&&Date.now()>=r){g===0&&le(r);break}let b;try{b=s()}catch(T){if(T instanceof Ee&&c>0)break;throw T}o+=b,a+=b*b,c++}});let l=o/c,m=(a-c*l*l)/(c-1),f=Math.sqrt(m/c),d=isFinite(e)&&isFinite(t)?t-e:1,h=l*d,N=f*d;return jr(h,N)}function Wr(i){let e=0,t=0;for(let n of i)e+=n,t++;return t===0?NaN:e/t}function Xr(i){let e=u.ZERO,t=0;for(let n of i)e=e.add(n),t++;return t===0?u.NAN:e.div(new u(t))}function si(i){let e=[...i].sort((n,r)=>n-r),t=Math.floor(e.length/2);return e.length%2===0?(e[t-1]+e[t])/2:e[t]}function oi(i){let e=[...i].sort((n,r)=>n.cmp(r)),t=Math.floor(e.length/2);return e.length%2===0?e[t-1].add(e[t]).div(u.TWO):e[t]}function un(i){let e=0,t=0,n=0;for(let r of i)e+=r,t+=r*r,n++;return n===0?NaN:(t-e*e/n)/(n-1)}function an(i){let e=u.ZERO,t=u.ZERO,n=0;for(let r of i)e=e.add(r),t=t.add(r.mul(r)),n++;return n===0?u.NAN:t.sub(e.mul(e).div(new u(n))).div(new u(n-1))}function cn(i){let e=0,t=0,n=0;for(let r of i)e+=r,t+=r*r,n++;return n===0?NaN:(t-e*e/n)/n}function ln(i){let e=u.ZERO,t=u.ZERO,n=0;for(let r of i)e=e.add(r),t=t.add(r.mul(r)),n++;return n===0?u.NAN:t.sub(e.mul(e).div(new u(n))).div(new u(n))}function Hr(i){return Math.sqrt(un(i))}function Kr(i){return an(i).sqrt()}function Qr(i){return Math.sqrt(cn(i))}function zr(i){return ln(i).sqrt()}function es(i){let e=0,t=0,n=0,r=0,s=0;for(let m of i){let f=m;if(!Number.isFinite(f))return NaN;e+=f,t+=f*f,n+=f*f*f,r+=f*f*f*f,s++}if(s===0)return NaN;let o=s,a=e/o,c=(t-e*e/o)/o;return(r-4*a*n+6*a*a*t-4*a*a*a*e+o*a*a*a*a)/o/(c*c)}function is(i){let e=u.ZERO,t=u.ZERO,n=u.ZERO,r=u.ZERO,s=0;for(let l of i){let m=l;if(!m.isFinite())return u.NAN;e=e.add(m),t=t.add(m.mul(m)),n=n.add(m.mul(m).mul(m)),r=r.add(m.mul(m).mul(m).mul(m)),s++}if(s===0)return u.NAN;let o=e.div(s),a=t.sub(e.mul(e).div(s)).div(s);return r.sub(o.mul(n).mul(4)).add(o.mul(o).mul(t).mul(6)).sub(o.mul(o).mul(o).mul(e).mul(4)).add(o.mul(o).mul(o).mul(o).mul(s)).div(s).div(a.mul(a))}function ts(i){let e=0,t=0,n=0,r=0;for(let l of i){let m=l;if(!Number.isFinite(m))return NaN;e+=m,t+=m*m,n+=m*m*m,r++}if(r===0)return NaN;let s=r,o=e/s,a=(t-e*e/s)/s;return(n-3*o*t+3*o*o*e-s*o*o*o)/s/Math.pow(a,3/2)}function ns(i){let e=u.ZERO,t=u.ZERO,n=u.ZERO,r=0;for(let c of i){let l=c;if(!l.isFinite())return u.NAN;e=e.add(l),t=t.add(l.mul(l)),n=n.add(l.mul(l).mul(l)),r++}if(r===0)return u.NAN;let s=e.div(r),o=t.sub(e.mul(e).div(r)).div(r);return n.sub(s.mul(t).mul(3)).add(s.mul(s).mul(e).mul(3)).sub(s.mul(s).mul(s).mul(r)).div(r).div(o.mul(o.sqrt()))}function rs(i){let e={};for(let r of i)e[r]=(e[r]??0)+1;let t=0,n=NaN;for(let r in e){let s=e[r];s>t&&(t=s,n=+r)}return n}function ss(i){let e={};for(let r of i)e[r.toString()]=(e[r.toString()]??0)+1;let t=0,n=u.NAN;for(let r in e){let s=e[r];s>t&&(t=s,n=new u(r))}return n}function mn(i){let e=[...i].sort((o,a)=>o-a),t=Math.floor(e.length/2),n=si(e.slice(0,t)),r=si(e),s=si(e.slice(t));return[n,r,s]}function fn(i){let e=[...i].sort((o,a)=>o.cmp(a)),t=Math.floor(e.length/2),n=oi(e.slice(0,t)),r=oi(e),s=oi(e.slice(t));return[n,r,s]}function os(i){let[e,,t]=mn(i);return t-e}function us(i){let[e,,t]=fn(i);return t.sub(e)}var ui={Q:1e30,R:1e27,Y:1e24,Z:1e21,E:1e18,P:1e15,T:1e12,G:1e9,M:1e6,k:1e3,h:100,da:10,d:.1,c:.01,m:.001,\u00B5:1e-6,\u03BC:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-24,r:1e-27,q:1e-30},dn=new Set(["m","g","s","A","K","mol","cd","Hz","N","Pa","J","W","C","V","F","ohm","S","Wb","T","H","lm","lx","Bq","Gy","Sv","kat","eV","L","bar"]),ai={m:{dimension:[1,0,0,0,0,0,0],scale:1},kg:{dimension:[0,1,0,0,0,0,0],scale:1},g:{dimension:[0,1,0,0,0,0,0],scale:.001},s:{dimension:[0,0,1,0,0,0,0],scale:1},A:{dimension:[0,0,0,1,0,0,0],scale:1},K:{dimension:[0,0,0,0,1,0,0],scale:1},mol:{dimension:[0,0,0,0,0,1,0],scale:1},cd:{dimension:[0,0,0,0,0,0,1],scale:1},Hz:{dimension:[0,0,-1,0,0,0,0],scale:1},N:{dimension:[1,1,-2,0,0,0,0],scale:1},Pa:{dimension:[-1,1,-2,0,0,0,0],scale:1},J:{dimension:[2,1,-2,0,0,0,0],scale:1},W:{dimension:[2,1,-3,0,0,0,0],scale:1},C:{dimension:[0,0,1,1,0,0,0],scale:1},V:{dimension:[2,1,-3,-1,0,0,0],scale:1},F:{dimension:[-2,-1,4,2,0,0,0],scale:1},ohm:{dimension:[2,1,-3,-2,0,0,0],scale:1},S:{dimension:[-2,-1,3,2,0,0,0],scale:1},Wb:{dimension:[2,1,-2,-1,0,0,0],scale:1},T:{dimension:[0,1,-2,-1,0,0,0],scale:1},H:{dimension:[2,1,-2,-2,0,0,0],scale:1},lm:{dimension:[0,0,0,0,0,0,1],scale:1},lx:{dimension:[-2,0,0,0,0,0,1],scale:1},Bq:{dimension:[0,0,-1,0,0,0,0],scale:1},Gy:{dimension:[2,0,-2,0,0,0,0],scale:1},Sv:{dimension:[2,0,-2,0,0,0,0],scale:1},kat:{dimension:[0,0,-1,0,0,1,0],scale:1},degC:{dimension:[0,0,0,0,1,0,0],scale:1,offset:273.15},degF:{dimension:[0,0,0,0,1,0,0],scale:5/9,offset:459.67},min:{dimension:[0,0,1,0,0,0,0],scale:60},h:{dimension:[0,0,1,0,0,0,0],scale:3600},d:{dimension:[0,0,1,0,0,0,0],scale:86400},ha:{dimension:[2,0,0,0,0,0,0],scale:1e4},L:{dimension:[3,0,0,0,0,0,0],scale:.001},t:{dimension:[0,1,0,0,0,0,0],scale:1e3},eV:{dimension:[2,1,-2,0,0,0,0],scale:1602176634e-28},Da:{dimension:[0,1,0,0,0,0,0],scale:16605390666e-37},au:{dimension:[1,0,0,0,0,0,0],scale:149597870700},deg:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/180},rad:{dimension:[0,0,0,0,0,0,0],scale:1},grad:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/200},turn:{dimension:[0,0,0,0,0,0,0],scale:2*Math.PI},arcmin:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/10800},arcsec:{dimension:[0,0,0,0,0,0,0],scale:Math.PI/648e3},percent:{dimension:[0,0,0,0,0,0,0],scale:.01},ppm:{dimension:[0,0,0,0,0,0,0],scale:1e-6},dB:{dimension:[0,0,0,0,0,0,0],scale:1},Np:{dimension:[0,0,0,0,0,0,0],scale:1},in:{dimension:[1,0,0,0,0,0,0],scale:.0254},ft:{dimension:[1,0,0,0,0,0,0],scale:.3048},mi:{dimension:[1,0,0,0,0,0,0],scale:1609.344},lb:{dimension:[0,1,0,0,0,0,0],scale:.45359237},oz:{dimension:[0,1,0,0,0,0,0],scale:.028349523125},gal:{dimension:[3,0,0,0,0,0,0],scale:.003785411784},atm:{dimension:[-1,1,-2,0,0,0,0],scale:101325},bar:{dimension:[-1,1,-2,0,0,0,0],scale:1e5},cal:{dimension:[2,1,-2,0,0,0,0],scale:4.184},kWh:{dimension:[2,1,-2,0,0,0,0],scale:36e5},\u00C5:{dimension:[1,0,0,0,0,0,0],scale:1e-10}};function mi(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]&&i[3]===e[3]&&i[4]===e[4]&&i[5]===e[5]&&i[6]===e[6]}function as(i){return i[0]===0&&i[1]===0&&i[2]===0&&i[3]===0&&i[4]===0&&i[5]===0&&i[6]===0}function cs(i){if(i.length>2){let e=i.slice(0,2),t=i.slice(2);if(ui[e]!==void 0&&dn.has(t)){let n=ai[t];if(n)return{prefixScale:ui[e],baseEntry:n}}}if(i.length>1){let e=i.slice(0,1),t=i.slice(1);if(ui[e]!==void 0&&dn.has(t)){let n=ai[t];if(n)return{prefixScale:ui[e],baseEntry:n}}}return null}function ci(i){let e=ai[i];if(e)return e;let t=cs(i);return t?{dimension:t.baseEntry.dimension,scale:t.prefixScale*t.baseEntry.scale}:null}function li(i){let e=ci(i);return e?e.dimension:null}function hn(i){let e=ci(i);return e?e.scale:null}function ls(i,e){let t=li(i),n=li(e);return!t||!n?!1:mi(t,n)}var ms=new Map(["N","J","W","Pa","Hz","C","V","F","ohm","S","Wb","T","H","lm","lx","Gy","kat"].map(i=>[ai[i].dimension.join(","),i]));function fs(i){return ms.get(i.join(","))??null}function Nn(i,e,t){let n=ci(e),r=ci(t);if(!n||!r||!mi(n.dimension,r.dimension))return null;let s=n.offset??0,o=r.offset??0;return(i+s)*n.scale/r.scale-o}function re(i){if(typeof i=="string")return li(i);if(!Array.isArray(i)||i.length<2)return null;let e=i[0];if(e==="Multiply"){let t=[0,0,0,0,0,0,0];for(let n=1;n<i.length;n++){let r=re(i[n]);if(!r)return null;for(let s=0;s<7;s++)t[s]+=r[s]}return t}if(e==="Divide"){if(i.length!==3)return null;let t=re(i[1]),n=re(i[2]);return!t||!n?null:t.map((r,s)=>r-n[s])}if(e==="Power"){if(i.length!==3)return null;let t=re(i[1]),n=i[2];return!t||typeof n!="number"?null:t.map(r=>r*n)}return null}function se(i){if(typeof i=="string")return hn(i);if(!Array.isArray(i)||i.length<2)return null;let e=i[0];if(e==="Multiply"){let t=1;for(let n=1;n<i.length;n++){let r=se(i[n]);if(r===null)return null;t*=r}return t}if(e==="Divide"){if(i.length!==3)return null;let t=se(i[1]),n=se(i[2]);return t===null||n===null||n===0?null:t/n}if(e==="Power"){if(i.length!==3)return null;let t=se(i[1]),n=i[2];return t===null||typeof n!="number"?null:Math.pow(t,n)}return null}function ds(i){let e=i.indexOf("^");if(e===-1)return i;let t=i.slice(0,e),n=i.slice(e+1),r=parseInt(n,10);return isNaN(r)?i:["Power",t,r]}function Se(i){if(i=i.trim(),i.length===0)return null;if(i[0]==="("&&i[i.length-1]===")"){let r=0,s=!0;for(let o=0;o<i.length-1;o++)if(i[o]==="("?r++:i[o]===")"&&r--,r===0&&o<i.length-1){s=!1;break}if(s)return Se(i.slice(1,-1))}let e=-1,t=[],n=0;for(let r=0;r<i.length;r++)i[r]==="("?n++:i[r]===")"?n--:n===0&&(i[r]==="/"&&e===-1?e=r:i[r]==="*"&&t.push(r));if(e!==-1){let r=i.slice(0,e).trim(),s=i.slice(e+1).trim(),o=Se(r),a=Se(s);return!o||!a?null:["Divide",o,a]}if(t.length>0){let r=[],s=0;for(let a of t)r.push(i.slice(s,a).trim()),s=a+1;r.push(i.slice(s).trim());let o=r.filter(a=>a.length>0).map(a=>Se(a));return o.some(a=>a===null)?null:o.length===1?o[0]:["Multiply",...o]}return i[0]==="("?null:ds(i)}function hs(i){return i=i.trim(),i.length===0?null:/[/*^()]/.test(i)?Se(i):i}function Ns(i,e,t){if(typeof e=="string"&&typeof t=="string")return Nn(i,e,t);let n=re(e),r=re(t);if(!n||!r||!mi(n,r))return null;let s=se(e),o=se(t);return s===null||o===null||o===0?null:i*s/o}var pn=7,gn=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23];function he(i){if(i<0)return NaN;let e=0;for(;i<10;)e+=Math.log(i),i+=1;let t=Math.PI,n=i*i*i;return i*Math.log(i)-i-.5*Math.log(i)+.5*Math.log(2*t)+1/(12*i)-1/(360*n)+1/(1260*n*i*i)-e}function G(i){if(i<.5)return Math.PI/(Math.sin(Math.PI*i)*G(1-i));if(i>100)return Math.exp(he(i));i-=1;let e=gn[0];for(let n=1;n<pn+2;n++)e+=gn[n]/(i+n);let t=i+pn+.5;return Math.sqrt(2*Math.PI)*Math.pow(t,i+.5)*Math.exp(-t)*e}function ps(i){let t=Math.log(1-i*i),n=2/(Math.PI*.147)+t/2;return Math.sign(i)*Math.sqrt(Math.sqrt(n*n-t/.147)-n)}function In(i){if(Number.isNaN(i)||i<-1||i>1)return NaN;if(i===0)return 0;if(i===1)return 1/0;if(i===-1)return-1/0;let e=i<0?-1:1,t=Math.abs(i),n=ps(t),r=Math.sqrt(Math.PI)/2;for(let s=0;s<4;s++)n-=(Ni(n)-t)*r*Math.exp(n*n);return e*n}function $i(i){if(Number.isNaN(i))return NaN;if(!Number.isFinite(i))return i>0?0:2;if(i<0)return 2-$i(-i);if(i<2)return 1-Ni(i);let e=1e-300,t=i===0?e:i,n=t,r=0;for(let s=1;s<=500;s++){let o=s/2;r=i+o*r,r===0&&(r=e),r=1/r,n=i+o/n,n===0&&(n=e);let a=n*r;if(t*=a,Math.abs(a-1)<1e-17)break}return Math.exp(-i*i)/(Math.sqrt(Math.PI)*t)}function Ni(i){if(Number.isNaN(i))return NaN;if(i===0)return 0;if(!Number.isFinite(i))return i>0?1:-1;let e=i<0?-1:1,t=Math.abs(i);if(t>=6)return e;let n=t*t,r=t,s=t;for(let o=1;o<200&&(r*=2*n/(2*o+1),s+=r,!(r<s*1e-18));o++);return e*(2/Math.sqrt(Math.PI))*Math.exp(-n)*s}function ue(i,e){let t=u.precision;u.precision=t+i;try{return e().toPrecision(t)}finally{u.precision=t}}var ae=24;function Tn(i,e){return e.isFinite()?ue(ae,()=>Wi(i,e)):u.NAN}function Wi(i,e){if(!e.isFinite())return u.NAN;if(e.lt(u.HALF)){let y=u.PI,w=y.mul(e).sin().abs();return w.isZero()?u.NAN:y.ln().sub(w.ln()).sub(Wi(i,u.ONE.sub(e)))}if(e.isInteger()&&e.isPositive()){let y=e.toNumber();if(y<=1)return u.ZERO;let w=1n;for(let B=2;B<y;B++)w*=BigInt(B);return new u(w.toString()).ln()}let t=e.sub(u.HALF);if(t.isInteger()&&!t.isNegative()){let y=t.toNumber();if(y===0)return u.PI.ln().div(u.TWO);let w=1n;for(let S=2;S<=2*y;S++)w*=BigInt(S);let B=1n;for(let S=2;S<=y;S++)B*=BigInt(S);let Y=4n**BigInt(y);return new u(w.toString()).ln().add(u.PI.ln().div(u.TWO)).sub(new u(Y.toString()).ln()).sub(new u(B.toString()).ln())}let n=u.precision,r=10,s=Math.ceil(n),o=e.toNumber(),a=Math.max(0,Math.ceil(s-o)),c=u.ONE,l=e;for(let y=0;y<a;y++)c=c.mul(l).toPrecision(n),l=l.add(u.ONE);let m=a>0?c.ln():u.ZERO,f=Math.max(20,Math.ceil(.6*n)+20),d=De(i,f),h=l.sub(u.HALF).mul(l.ln()).sub(l).add(u.PI.mul(u.TWO).ln().div(u.TWO)),N=u.ONE.div(l),p=N.mul(N).toPrecision(n),g=N,b=new u(10).pow(-(n+r)),T=Math.min(f,d.length);for(let y=0;y<T;y++){let w=2*(y+1),[B,Y]=d[y],S=BigInt(w)*BigInt(w-1),be=new u(B.toString()).div(new u((Y*S).toString())).mul(g).toPrecision(n);if(y>0&&be.abs().lt(b))break;h=h.add(be),g=g.mul(p).toPrecision(n)}return h.sub(m)}function vn(i,e){if(e.isInteger()&&e.isPositive()){let t=e.toNumber(),n=1n;for(let r=2;r<t;r++)n*=BigInt(r);return new u(n.toString())}return ue(ae,()=>Ne(i,e))}function Ne(i,e){if(e.lt(u.HALF)){let t=u.PI,n=t.mul(e).sin();return n.isZero()?u.NAN:t.div(n.mul(Ne(i,u.ONE.sub(e))))}return Wi(i,e).exp()}function bn(i,e){for(;e!==0n;){let t=e;e=i%e,i=t}return i}function fi(i){return i<0n?-i:i}function yn(i){let e=[[1n,1n],[-1n,2n]];for(let n=2;n<=2*i;n++){if(n%2===1){e.push([0n,1n]);continue}let r=BigInt(n+1),s=0n,o=1n,a=1n;for(let f=0;f<n;f++){f>0&&(a=a*(r-BigInt(f)+1n)/BigInt(f));let[d,h]=e[f];if(d!==0n&&(s=s*h+a*d*o,o=o*h,f%8===7)){let N=bn(fi(s),o);s/=N,o/=N}}let c=-s,l=r*o,m=bn(fi(c),fi(l));c/=m,l/=m,l<0n&&(c=-c,l=-l),e.push([c,l])}let t=[];for(let n=1;n<=i;n++)t.push(e[2*n]);return t}function De(i,e){return i._cache("bernoulli-even-rationals",()=>yn(e),t=>t.length>=e?t:yn(e))}function Xi(i,e){return e.isFinite()?ue(ae,()=>En(i,e)):u.NAN}function En(i,e){if(e.isNegative()){if(e.isInteger())return u.NAN;let h=u.PI,N=h.mul(e),p=N.cos().div(N.sin());return En(i,u.ONE.sub(e)).sub(h.mul(p))}if(e.isZero())return u.NAN;let t=u.precision,n=10,r=Math.max(7,Math.ceil(t)),s=new u(0),o=e;for(;o.lt(r);)s=s.sub(u.ONE.div(o)),o=o.add(u.ONE);let a=Math.max(20,Math.ceil(.6*t)+20),c=De(i,a);s=s.add(o.ln()).sub(u.ONE.div(o.mul(2)));let l=o.mul(o).toPrecision(t),m=l,f=new u(10).pow(-(t+n)),d=Math.min(a,c.length);for(let h=0;h<d;h++){let[N,p]=c[h],g=BigInt(2*(h+1)),b=new u(N.toString()).div(new u((p*g).toString()).mul(l));if(h>0&&b.abs().lt(f))break;s=s.sub(b),l=l.mul(m).toPrecision(t)}return s}function Hi(i,e){return e.isFinite()?ue(ae,()=>Mn(i,e)):u.NAN}function Mn(i,e){if(e.isNegative()){if(e.isInteger())return u.NAN;let h=u.PI,N=h.mul(e).sin();return h.mul(h).div(N.mul(N)).sub(Mn(i,u.ONE.sub(e)))}if(e.isZero())return u.NAN;let t=u.precision,n=10,r=Math.max(7,Math.ceil(t)),s=new u(0),o=e;for(;o.lt(r);)s=s.add(u.ONE.div(o.mul(o))),o=o.add(u.ONE);let a=Math.max(20,Math.ceil(.6*t)+20),c=De(i,a);s=s.add(u.ONE.div(o)),s=s.add(u.ONE.div(o.mul(o).mul(2)));let l=o.mul(o).mul(o).toPrecision(t),m=o.mul(o).toPrecision(t),f=new u(10).pow(-(t+n)),d=Math.min(a,c.length);for(let h=0;h<d;h++){let[N,p]=c[h],g=new u(N.toString()).div(new u(p.toString()).mul(l));if(h>0&&g.abs().lt(f))break;s=s.add(g),l=l.mul(m).toPrecision(t)}return s}function Bn(i,e,t){let n=e.toNumber();return!Number.isInteger(n)||n<0?u.NAN:n===0?Xi(i,t):n===1?Hi(i,t):!t.isFinite()||t.isZero()?u.NAN:ue(ae,()=>gs(i,n,t))}function gs(i,e,t){let n=b=>{let T=u.ONE;for(let y=2;y<=b;y++)T=T.mul(y);return T},r=u.precision,s=10,o=Math.max(7,Math.ceil(r)),a=t,c=new u(0),l=e%2===0?-1:1;if(a.isNegative()){if(a.isInteger())return u.NAN;let b=e%2===0?1:-1;for(;a.lt(1);)c=c.add(new u(b).mul(n(e)).div(a.pow(e+1))),a=a.add(u.ONE)}for(;a.lt(o);)c=c.add(new u(l).mul(n(e)).div(a.pow(e+1))),a=a.add(u.ONE);let m=Math.max(20,Math.ceil(.6*r)+20),f=De(i,m),d=e%2===0?-1:1;c=c.add(new u(d).mul(n(e-1)).div(a.pow(e))),c=c.add(new u(d).mul(n(e)).div(a.pow(e+1).mul(2)));let h=a.pow(e+2).toPrecision(r),N=a.mul(a).toPrecision(r),p=new u(10).pow(-(r+s)),g=Math.min(m,f.length);for(let b=0;b<g;b++){let T=2*(b+1),[y,w]=f[b],B=1n;for(let U=0;U<T;U++)B*=BigInt(e+U);let Y=1n;for(let U=2;U<=T;U++)Y*=BigInt(U);let S=new u((BigInt(d)*y*B).toString()).div(new u((w*Y).toString()).mul(h));if(b>0&&S.abs().lt(p))break;c=c.add(S),h=h.mul(N).toPrecision(r)}return c}function wn(i,e,t){return ue(ae,()=>Ne(i,e).mul(Ne(i,t)).div(Ne(i,e.add(t))))}function kn(i,e){return e.isFinite()?e.eq(1)?new u(1/0):ue(ae,()=>xn(i,e)):u.NAN}function xn(i,e){let t=u.PI;if(e.isZero())return u.HALF.neg();if(e.isInteger()&&e.isPositive()){let d=e.toNumber();if(d%2===0&&d>=2){let h=d/2,N=De(i,h),[p,g]=N[h-1],b=new u(fi(p).toString()).div(new u(g.toString())),T=t.mul(2),y=u.ONE;for(let w=2;w<=d;w++)y=y.mul(w);return b.mul(T.pow(d)).div(y.mul(2))}}if(e.isNegative())return new u(2).pow(e).mul(t.pow(e.sub(1))).mul(t.mul(e).div(2).sin()).mul(Ne(i,u.ONE.sub(e))).mul(xn(i,u.ONE.sub(e)));let n=u.precision,r=Math.max(22,Math.ceil(1.32*n)+3),o=new u(3).add(new u(8).sqrt()).pow(r),a=o.add(u.ONE.div(o)).div(2),c=u.NEGATIVE_ONE,l=a.neg(),m=u.ZERO;for(let d=0;d<r;d++)(d&255)===0&&le(i._deadline),l=c.sub(l),m=m.add(l.div(new u(d+1).pow(e))),c=c.mul(new u(d+r).mul(d-r)).div(new u(d).add(u.HALF).mul(d+1));return m.div(a).div(u.ONE.sub(new u(2).pow(u.ONE.sub(e))))}function Pn(i,e){if(!e.isFinite())return e;if(e.isZero())return new u(0);let n=u.ONE.div(u.ONE.exp()).neg(),r=new u(10).pow(-i.precision),s=new u(10).pow(-15);if(e.sub(n).abs().lt(s))return u.NEGATIVE_ONE;if(e.lt(n))return u.NAN;let o,a=e.toNumber();if(a<0){let c=Math.sqrt(2*(Math.E*a+1));o=new u(-1+c-c*c/3+11/72*c*c*c)}else if(a<=1)o=new u(a*(1-a*(1-1.5*a)));else if(a<100){let c=Math.log(a);o=new u(c-Math.log(c))}else{let c=e.ln(),l=c.ln();o=c.sub(l).add(l.div(c))}for(let c=0;c<100;c++){let l=o.exp(),f=o.mul(l).sub(e),d=l.mul(o.add(1)),h=l.mul(o.add(2)),N=f.div(d.sub(f.mul(h).div(d.mul(2))));if(o=o.sub(N),N.abs().lt(r.mul(o.abs().add(1))))break}return o}var di=.5772156649015329,pe=[1/6,-1/30,1/42,-1/30,5/66,-691/2730,7/6,-3617/510,43867/798,-174611/330];function pi(i){if(!isFinite(i))return NaN;if(i<0)return Number.isInteger(i)?NaN:pi(1-i)-Math.PI/Math.tan(Math.PI*i);if(i===0)return NaN;let e=0,t=i;for(;t<7;)e-=1/t,t+=1;e+=Math.log(t)-1/(2*t);let n=t*t;for(let r=0;r<pe.length;r++)e-=pe[r]/(2*(r+1)*n),n*=t*t;return e}function gi(i){if(!isFinite(i))return NaN;if(i<0){if(Number.isInteger(i))return NaN;let r=Math.sin(Math.PI*i);return Math.PI*Math.PI/(r*r)-gi(1-i)}if(i===0)return NaN;let e=0,t=i;for(;t<7;)e+=1/(t*t),t+=1;e+=1/t+1/(2*t*t);let n=t*t*t;for(let r=0;r<pe.length;r++)e+=pe[r]/n,n*=t*t;return e}function Ki(i,e){if(!Number.isInteger(i)||i<0)return NaN;if(i===0)return pi(e);if(i===1)return gi(e);if(!isFinite(e)||e===0)return NaN;if(e<0){if(Number.isInteger(e))return NaN;let a=0,c=e,l=i%2===0?1:-1;for(;c<1;)a+=l*de(i)/Math.pow(c,i+1),c+=1;return a+Ki(i,c)}let t=0,n=e,r=i%2===0?-1:1;for(;n<7;)t+=r*de(i)/Math.pow(n,i+1),n+=1;let s=i%2===0?-1:1;t+=s*de(i-1)/Math.pow(n,i),t+=s*de(i)/(2*Math.pow(n,i+1));let o=Math.pow(n,i+2);for(let a=0;a<Math.min(pe.length,6);a++){let c=2*(a+1),l=1;for(let m=0;m<c;m++)l*=i+m;t+=s*pe[a]*l/(de(c)*o),o*=n*n}return t}function de(i){if(i<=1)return 1;let e=1;for(let t=2;t<=i;t++)e*=t;return e}function Sn(i,e){return i>100||e>100||i+e>100?Math.exp(he(i)+he(e)-he(i+e)):G(i)*G(e)/G(i+e)}function Qi(i){if(!isFinite(i))return NaN;if(i===1)return 1/0;if(i===0)return-.5;if(i===2)return Math.PI*Math.PI/6;if(i===4)return Math.PI**4/90;if(i===6)return Math.PI**6/945;if(i===8)return Math.PI**8/9450;if(i<0)return Math.pow(2,i)*Math.pow(Math.PI,i-1)*Math.sin(Math.PI*i/2)*G(1-i)*Qi(1-i);let e=22,t=bs(e),n=t[e],r=0;for(let s=0;s<=e;s++)r+=(s%2===0?1:-1)*(t[s]-n)/Math.pow(s+1,i);return-1/(n*(1-Math.pow(2,1-i)))*r}function bs(i){let e=new Array(i+1);e[0]=1;for(let t=1;t<=i;t++)e[t]=e[t-1]+ys(i,t);return e}function ys(i,e){e>i-e&&(e=i-e);let t=1;for(let n=0;n<e;n++)t=t*(i-n)/(n+1);return t}function Dn(i){if(!isFinite(i))return i;if(i===0)return 0;let e=1/Math.E;if(i<-e)return NaN;if(Math.abs(i+e)<1e-15)return-1;let t;if(i<0){let n=Math.sqrt(2*(Math.E*i+1));t=-1+n-n*n/3+11/72*n*n*n}else if(i<=1)t=i*(1-i*(1-1.5*i));else if(i<100){let n=Math.log(i);t=n-Math.log(n)}else{let n=Math.log(i),r=Math.log(n);t=n-r+r/n}for(let n=0;n<30;n++){let r=Math.exp(t),o=t*r-i,a=r*(t+1),c=r*(t+2),l=o/(a-o*c/(2*a));if(t-=l,Math.abs(l)<1e-15*(1+Math.abs(t)))break}return t}function H(i,e){return!isFinite(e)||!Number.isInteger(i)?NaN:e===0?i===0?1:0:i<0?(i=-i,i%2===0?H(i,e):-H(i,e)):e<0?i%2===0?H(i,-e):-H(i,-e):e>25+i*i/2?Ts(i,e):e<5+i?Is(i,e):vs(i,e)}function Is(i,e){let t=e/2,n=-(e*e)/4,r=1;for(let o=1;o<=i;o++)r/=o;let s=r;for(let o=1;o<=60&&(r*=n/(o*(i+o)),s+=r,!(Math.abs(r)<Math.abs(s)*1e-16));o++);return s*Math.pow(t,i)}function Rn(i,e){let t=4*i*i,n=1,r=0,s=1,o=8*e;for(let a=1;a<=20;a++){s*=t-(2*a-1)*(2*a-1);let c=de(a)*Math.pow(o,a),l=s/c;if(a%2===1?r+=(a%4===1?1:-1)*l:n+=(a%4===2?-1:1)*l,Math.abs(l)<1e-15)break}return[n,r]}function Ts(i,e){let t=e-(i/2+.25)*Math.PI,[n,r]=Rn(i,e);return Math.sqrt(2/(Math.PI*e))*(n*Math.cos(t)-r*Math.sin(t))}function vs(i,e){let t=Math.max(i+20,Math.ceil(e)+30),n=0,r=1,s=new Array(t+1);s[t]=r;for(let c=t;c>=1;c--){let l=2*c/e*r-n;n=r,r=l,s[c-1]=r}let o=s[0];for(let c=2;c<=t;c+=2)o+=2*s[c];let a=1/o;return s[i]*a}function hi(i,e){if(!isFinite(e)||!Number.isInteger(i))return NaN;if(e<=0)return NaN;if(i<0)return i=-i,i%2===0?hi(i,e):-hi(i,e);if(e>12+i*i/4)return Bs(i,e);let t=Es(e);if(i===0)return t;let n=Ms(e);if(i===1)return n;let r=t,s=n;for(let o=1;o<i;o++){let a=2*o/e*s-r;r=s,s=a}return s}function Es(i){let e=i/2,t=e*e,n=H(0,i),r=0,s=1,o=0;for(let a=1;a<=60&&(o+=1/a,s*=-t/(a*a),r-=s*o,!(Math.abs(s*o)<Math.abs(r)*1e-16));a++);return 2/Math.PI*(n*(Math.log(e)+di)+r)}function Ms(i){let e=i/2,t=e*e,n=H(1,i),r=0,s=1,o=1;for(let a=0;a<=60;a++){a>0&&(o*=a,s*=t);let c=o*(a+1),l=0;for(let p=1;p<=a;p++)l+=1/p;let m=l+1/(a+1),f=-di+l,d=-di+m,N=(a%2===0?1:-1)*(f+d)*s/(o*c);if(r+=N,a>3&&Math.abs(N)<1e-16*Math.abs(r))break}return-2/(Math.PI*i)+2/Math.PI*Math.log(e)*n-e/Math.PI*r}function Bs(i,e){let t=e-(i/2+.25)*Math.PI,[n,r]=Rn(i,e);return Math.sqrt(2/(Math.PI*e))*(n*Math.sin(t)+r*Math.cos(t))}function oe(i,e){return!isFinite(e)||!Number.isInteger(i)?NaN:e===0?i===0?1:0:(i<0&&(i=-i),e<0?i%2===0?oe(i,-e):-oe(i,-e):e>40?ks(i,e):ws(i,e))}function ws(i,e){let t=e/2,n=e*e/4,r=1;for(let o=1;o<=i;o++)r/=o;let s=r;for(let o=1;o<=80&&(r*=n/(o*(i+o)),s+=r,!(Math.abs(r)<Math.abs(s)*1e-16));o++);return s*Math.pow(t,i)}function ks(i,e){let t=4*i*i,n=1,r=1;for(let s=1;s<=12;s++){let o=t-(2*s-1)*(2*s-1);if(n*=o/(s*8*e),r+=n,Math.abs(n)<1e-15)break}return Math.exp(e)/Math.sqrt(2*Math.PI*e)*r}function An(i,e){if(!isFinite(e)||!Number.isInteger(i))return NaN;if(e<=0)return NaN;if(i<0&&(i=-i),e>40)return Ps(i,e);let t=On(e);if(i===0)return t;let n=xs(e);if(i===1)return n;let r=t,s=n;for(let o=1;o<i;o++){let a=2*o/e*s+r;r=s,s=a}return s}function On(i){let e=i/2,t=e*e,n=oe(0,i),r=0,s=1,o=0;for(let a=1;a<=60&&(o+=1/a,s*=t/(a*a),r+=s*o,!(Math.abs(s*o)<Math.abs(r)*1e-16&&a>3));a++);return-(Math.log(e)+di)*n+r}function xs(i){let e=oe(0,i),t=oe(1,i),n=On(i);return(1/i-t*n)/e}function Ps(i,e){let t=4*i*i,n=1,r=1;for(let s=1;s<=12;s++){let o=t-(2*s-1)*(2*s-1);if(n*=o/(s*8*e),r+=n,Math.abs(n)<1e-15)break}return Math.sqrt(Math.PI/(2*e))*Math.exp(-e)*r}function Fn(i){if(!isFinite(i))return NaN;if(i>5){let a=.6666666666666666*Math.pow(i,1.5);return Ss(i,a)}if(i<-5){let a=-i,c=2/3*Math.pow(a,1.5);return Ds(a,c)}let e=1/(Math.pow(3,2/3)*G(2/3)),t=1/(Math.pow(3,1/3)*G(1/3)),n=1,r=i,s=1,o=i;for(let a=1;a<=80;a++){let c=3*a;if(s*=i*i*i/((c-1)*c),o*=i*i*i/(c*(c+1)),n+=s,r+=o,Math.abs(s)+Math.abs(o)<1e-16*(Math.abs(n)+Math.abs(r)))break}return e*n-t*r}function Ss(i,e){let t=Math.pow(i,.25),n=1,r=1,s=[1,5/72,385/10368,85085/2239488,37182145/644972544];for(let o=1;o<s.length;o++)r=s[o]/Math.pow(e,o),n+=(o%2===0?1:-1)*r;return Math.exp(-e)/(2*Math.sqrt(Math.PI)*t)*n}function Ds(i,e){let t=Math.pow(i,.25);return Math.sin(e+Math.PI/4)/(Math.sqrt(Math.PI)*t)}function Cn(i){if(!isFinite(i))return NaN;if(i>5){let a=.6666666666666666*Math.pow(i,1.5);return Rs(i,a)}if(i<-5){let a=-i,c=2/3*Math.pow(a,1.5);return As(a,c)}let e=1/(Math.pow(3,2/3)*G(2/3)),t=1/(Math.pow(3,1/3)*G(1/3)),n=1,r=i,s=1,o=i;for(let a=1;a<=80;a++){let c=3*a;if(s*=i*i*i/((c-1)*c),o*=i*i*i/(c*(c+1)),n+=s,r+=o,Math.abs(s)+Math.abs(o)<1e-16*(Math.abs(n)+Math.abs(r)))break}return Math.sqrt(3)*(e*n+t*r)}function Rs(i,e){let t=Math.pow(i,.25),n=1,r=1,s=[1,5/72,385/10368,85085/2239488,37182145/644972544];for(let o=1;o<s.length;o++)r=s[o]/Math.pow(e,o),n+=r;return Math.exp(e)/(Math.sqrt(Math.PI)*t)*n}function As(i,e){let t=Math.pow(i,.25);return Math.cos(e+Math.PI/4)/(Math.sqrt(Math.PI)*t)}var Os=[-2991.8191940101983,708840.0452577386,-6297414862058625e-8,25489088057337637e-7,-4429795180596978e-5,3180162978765678e-4],Fs=[1,281.3762688899943,45584.78108065326,5173438887700964e-9,4193202458981112e-7,22441179564534092e-6,607366389490085e-3],Cs=[-49884311457357354e-24,9504280628298596e-21,-.0006451914356839651,.018884331939670384,-.20552590095501388,1],Vs=[399982968972496e-26,9154392157746574e-25,12500186247959882e-23,12226278902417902e-21,.0008680295429417843,.04121420907221998,1],Vn=[.4215435550436775,.1434079197807589,.011522095507358577,.000345017939782574,46361374928786735e-22,3055689837902576e-23,10230451416490724e-26,17201074326816183e-29,13428327623306275e-32,3763297112699879e-35],_n=[1,.7515863983533789,.11688892585919138,.0064405152650885865,.00015593440916415301,18462756734893055e-22,11269922476399903e-24,36014002958937136e-27,5887545336215784e-29,45200143407412973e-33,12544323709001127e-36],qn=[.5044420736433832,.1971028335255234,.018764858409257526,.0006840793809153931,11513882611188428e-21,9828524436884223e-23,44534441586175015e-26,10826804113902088e-28,1375554606332618e-30,8363544356306774e-34,18695871016278324e-38],Zn=[1,1.4749575992512833,.33774898912002,.02536037414203388,.0008146791071843061,12754507566772912e-21,10431458965757199e-23,46068072851523205e-26,11027321506624028e-28,13879653125957886e-31,8391588162831187e-34,18695871016278324e-38];function q(i,e){let t=e[0];for(let n=1;n<e.length;n++)t=t*i+e[n];return t}function Ln(i){if(!isFinite(i))return i!==i?NaN:i>0?.5:-.5;let e=i<0?-1:1;if(i=Math.abs(i),i<1.6){let t=i*i,n=t*t;return e*i*t*q(n,Os)/q(n,Fs)}if(i<36974){let t=i*i,n=Math.PI*t,r=1/(n*n),s=1-r*q(r,Vn)/q(r,_n),o=1/n*q(r,qn)/q(r,Zn),a=Math.PI/2*t,c=Math.cos(a),l=Math.sin(a);return e*(.5-(s*c+o*l)/(Math.PI*i))}return e*.5}function Gn(i){if(!isFinite(i))return i!==i?NaN:i>0?.5:-.5;let e=i<0?-1:1;if(i=Math.abs(i),i<1.6){let t=i*i,n=t*t;return e*i*q(n,Cs)/q(n,Vs)}if(i<36974){let t=i*i,n=Math.PI*t,r=1/(n*n),s=1-r*q(r,Vn)/q(r,_n),o=1/n*q(r,qn)/q(r,Zn),a=Math.PI/2*t,c=Math.cos(a),l=Math.sin(a);return e*(.5+(s*l-o*c)/(Math.PI*i))}return e*.5}function Yn(i){return i===0?1:Math.sin(i)/i}var D=Math.cosh||function(i){return Math.abs(i)<1e-9?1-i:(Math.exp(i)+Math.exp(-i))*.5},Z=Math.sinh||function(i){return Math.abs(i)<1e-9?i:(Math.exp(i)-Math.exp(-i))*.5},_s=function(i){var e=Math.PI/4;if(-e>i||i>e)return Math.cos(i)-1;var t=i*i;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},qs=function(i,e){var t=Math.abs(i),n=Math.abs(e);return t<3e3&&n<3e3?Math.sqrt(t*t+n*n):(t<n?(t=n,n=i/e):n=e/i,t*Math.sqrt(1+n*n))},ge=function(){throw SyntaxError("Invalid Param")};function zi(i,e){var t=Math.abs(i),n=Math.abs(e);return i===0?Math.log(n):e===0?Math.log(t):t<3e3&&n<3e3?Math.log(i*i+e*e)*.5:(i=i/2,e=e/2,.5*Math.log(i*i+e*e)+Math.LN2)}var Zs=function(i,e){var t={re:0,im:0};if(i==null)t.re=t.im=0;else if(e!==void 0)t.re=i,t.im=e;else switch(typeof i){case"object":if("im"in i&&"re"in i)t.re=i.re,t.im=i.im;else if("abs"in i&&"arg"in i){if(!Number.isFinite(i.abs)&&Number.isFinite(i.arg))return M.INFINITY;t.re=i.abs*Math.cos(i.arg),t.im=i.abs*Math.sin(i.arg)}else if("r"in i&&"phi"in i){if(!Number.isFinite(i.r)&&Number.isFinite(i.phi))return M.INFINITY;t.re=i.r*Math.cos(i.phi),t.im=i.r*Math.sin(i.phi)}else i.length===2?(t.re=i[0],t.im=i[1]):ge();break;case"string":t.im=t.re=0;var n=i.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,s=0;n===null&&ge();for(var o=0;o<n.length;o++){var a=n[o];a===" "||a===" "||a===`
7
+ `||(a==="+"?r++:a==="-"?s++:a==="i"||a==="I"?(r+s===0&&ge(),n[o+1]!==" "&&!isNaN(Number(n[o+1]))?(t.im+=parseFloat((s%2?"-":"")+n[o+1]),o++):t.im+=parseFloat((s%2?"-":"")+"1"),r=s=0):((r+s===0||isNaN(Number(a)))&&ge(),n[o+1]==="i"||n[o+1]==="I"?(t.im+=parseFloat((s%2?"-":"")+a),o++):t.re+=parseFloat((s%2?"-":"")+a),r=s=0))}r+s>0&&ge();break;case"number":t.im=0,t.re=i;break;default:ge()}return isNaN(t.re)||isNaN(t.im),t},M=class i{constructor(e,t){this.re=0,this.im=0;var n=Zs(e,t);this.re=n.re,this.im=n.im}sign(){var e=this.abs();return new i(this.re/e,this.im/e)}add(e,t){var n=new i(e,t);return this.isInfinite()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:new i(this.re+n.re,this.im+n.im)}sub(e,t){var n=new i(e,t);return this.isInfinite()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:new i(this.re-n.re,this.im-n.im)}mul(e,t){var n=new i(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?i.NAN:this.isInfinite()||n.isInfinite()?i.INFINITY:n.im===0&&this.im===0?new i(this.re*n.re,0):new i(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)}div(e,t){var n=new i(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return i.NAN;if(this.isInfinite()||n.isZero())return i.INFINITY;if(this.isZero()||n.isInfinite())return i.ZERO;e=this.re,t=this.im;var r=n.re,s=n.im,o,a;return s===0?new i(e/r,t/r):Math.abs(r)<Math.abs(s)?(a=r/s,o=r*a+s,new i((e*a+t)/o,(t*a-e)/o)):(a=s/r,o=s*a+r,new i((e+t*a)/o,(t-e*a)/o))}pow(e,t){var n=new i(e,t);if(e=this.re,t=this.im,n.isZero())return i.ONE;if(n.im===0){if(t===0&&e>0)return new i(Math.pow(e,n.re),0);if(e===0)switch((n.re%4+4)%4){case 0:return new i(Math.pow(t,n.re),0);case 1:return new i(0,Math.pow(t,n.re));case 2:return new i(-Math.pow(t,n.re),0);case 3:return new i(0,-Math.pow(t,n.re))}}if(e===0&&t===0&&n.re>0&&n.im>=0)return i.ZERO;var r=Math.atan2(t,e),s=zi(e,t);return e=Math.exp(n.re*s-n.im*r),t=n.im*s+n.re*r,new i(e*Math.cos(t),e*Math.sin(t))}sqrt(){var e=this.re,t=this.im,n=this.abs(),r,s;if(e>=0){if(t===0)return new i(Math.sqrt(e),0);r=.5*Math.sqrt(2*(n+e))}else r=Math.abs(t)/Math.sqrt(2*(n-e));return e<=0?s=.5*Math.sqrt(2*(n-e)):s=Math.abs(t)/Math.sqrt(2*(n+e)),new i(r,t<0?-s:s)}exp(){var e=Math.exp(this.re);return this.im,new i(e*Math.cos(this.im),e*Math.sin(this.im))}expm1(){var e=this.re,t=this.im;return new i(Math.expm1(e)*Math.cos(t)+_s(t),Math.exp(e)*Math.sin(t))}log(){var e=this.re,t=this.im;return t===0&&e>0,new i(zi(e,t),Math.atan2(t,e))}abs(){return qs(this.re,this.im)}arg(){return Math.atan2(this.im,this.re)}sin(){var e=this.re,t=this.im;return new i(Math.sin(e)*D(t),Math.cos(e)*Z(t))}cos(){var e=this.re,t=this.im;return new i(Math.cos(e)*D(t),-Math.sin(e)*Z(t))}tan(){var e=2*this.re,t=2*this.im,n=Math.cos(e)+D(t);return new i(Math.sin(e)/n,Z(t)/n)}cot(){var e=2*this.re,t=2*this.im,n=Math.cos(e)-D(t);return new i(-Math.sin(e)/n,Z(t)/n)}sec(){var e=this.re,t=this.im,n=.5*D(2*t)+.5*Math.cos(2*e);return new i(Math.cos(e)*D(t)/n,Math.sin(e)*Z(t)/n)}csc(){var e=this.re,t=this.im,n=.5*D(2*t)-.5*Math.cos(2*e);return new i(Math.sin(e)*D(t)/n,-Math.cos(e)*Z(t)/n)}asin(){var e=this.re,t=this.im,n=new i(t*t-e*e+1,-2*e*t).sqrt(),r=new i(n.re-t,n.im+e).log();return new i(r.im,-r.re)}acos(){var e=this.re,t=this.im,n=new i(t*t-e*e+1,-2*e*t).sqrt(),r=new i(n.re-t,n.im+e).log();return new i(Math.PI/2-r.im,r.re)}atan(){var e=this.re,t=this.im;if(e===0){if(t===1)return new i(0,1/0);if(t===-1)return new i(0,-1/0)}var n=e*e+(1-t)*(1-t),r=new i((1-t*t-e*e)/n,-2*e/n).log();return new i(-.5*r.im,.5*r.re)}acot(){var e=this.re,t=this.im;if(t===0)return new i(Math.atan2(1,e),0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).atan():new i(e!==0?e/0:0,t!==0?-t/0:0).atan()}asec(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(0,1/0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).acos():new i(e!==0?e/0:0,t!==0?-t/0:0).acos()}acsc(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(Math.PI/2,1/0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).asin():new i(e!==0?e/0:0,t!==0?-t/0:0).asin()}sinh(){var e=this.re,t=this.im;return new i(Z(e)*Math.cos(t),D(e)*Math.sin(t))}cosh(){var e=this.re,t=this.im;return new i(D(e)*Math.cos(t),Z(e)*Math.sin(t))}tanh(){var e=2*this.re,t=2*this.im,n=D(e)+Math.cos(t);return new i(Z(e)/n,Math.sin(t)/n)}coth(){var e=2*this.re,t=2*this.im,n=D(e)-Math.cos(t);return new i(Z(e)/n,-Math.sin(t)/n)}csch(){var e=this.re,t=this.im,n=Math.cos(2*t)-D(2*e);return new i(-2*Z(e)*Math.cos(t)/n,2*D(e)*Math.sin(t)/n)}sech(){var e=this.re,t=this.im,n=Math.cos(2*t)+D(2*e);return new i(2*D(e)*Math.cos(t)/n,-2*Z(e)*Math.sin(t)/n)}asinh(){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(){var e=this.acos();if(e.im<=0){var t=e.re;e.re=-e.im,e.im=t}else{var t=e.im;e.im=-e.re,e.re=t}return e}atanh(){var e=this.re,t=this.im,n=e>1&&t===0,r=1-e,s=1+e,o=r*r+t*t,a=o!==0?new i((s*r-t*t)/o,(t*r+s*t)/o):new i(e!==-1?e/0:0,t!==0?t/0:0),c=a.re;return a.re=zi(a.re,a.im)/2,a.im=Math.atan2(a.im,c)/2,n&&(a.im=-a.im),a}acoth(){var e=this.re,t=this.im;if(e===0&&t===0)return new i(0,Math.PI/2);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).atanh():new i(e!==0?e/0:0,t!==0?-t/0:0).atanh()}acsch(){var e=this.re,t=this.im;if(t===0)return new i(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return n!==0?new i(e/n,-t/n).asinh():new i(e!==0?e/0:0,t!==0?-t/0:0).asinh()}asech(){var e=this.re,t=this.im;if(this.isZero())return i.INFINITY;var n=e*e+t*t;return n!==0?new i(e/n,-t/n).acosh():new i(e!==0?e/0:0,t!==0?-t/0:0).acosh()}inverse(){if(this.isZero())return i.INFINITY;if(this.isInfinite())return i.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new i(e/n,-t/n)}conjugate(){return new i(this.re,-this.im)}neg(){return new i(-this.re,-this.im)}ceil(e){return e=Math.pow(10,e||0),new i(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)}floor(e){return e=Math.pow(10,e||0),new i(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)}round(e){return e=Math.pow(10,e||0),new i(Math.round(this.re*e)/e,Math.round(this.im*e)/e)}equals(e,t){var n=new i(e,t);return Math.abs(n.re-this.re)<=i.EPSILON&&Math.abs(n.im-this.im)<=i.EPSILON}clone(){return new i(this.re,this.im)}toString(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<i.EPSILON&&(e=0),Math.abs(t)<i.EPSILON&&(t=0),t===0?n+e:(e!==0?(n+=e,n+=" ",t<0?(t=-t,n+="-"):n+="+",n+=" "):t<0&&(t=-t,n+="-"),t!==1&&(n+=t),n+"i"))}toVector(){return[this.re,this.im]}valueOf(){return this.im===0?this.re:null}isNaN(){return isNaN(this.re)||isNaN(this.im)}isZero(){return this.im===0&&this.re===0}isFinite(){return isFinite(this.re)&&isFinite(this.im)}isInfinite(){return!(this.isNaN()||this.isFinite())}};M.ZERO=new M(0,0);M.ONE=new M(1,0);M.I=new M(0,1);M.PI=new M(Math.PI,0);M.E=new M(Math.E,0);M.INFINITY=new M(1/0,1/0);M.NAN=new M(NaN,NaN);M.EPSILON=1e-15;var bi=7,yi=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23],Ls=Math.sqrt(2*Math.PI),Gs=.5*Math.log(2*Math.PI);function et(i){if(i.re<.5){let r=i.mul(Math.PI).sin();return new M(Math.PI,0).div(r.mul(et(new M(1,0).sub(i))))}let e=i.sub(1),t=new M(yi[0],0);for(let r=1;r<bi+2;r++)t=t.add(new M(yi[r],0).div(e.add(r)));let n=e.add(bi+.5);return new M(Ls,0).mul(n.pow(e.add(.5))).mul(n.neg().exp()).mul(t)}function it(i){if(i.re<.5){let r=i.mul(Math.PI).sin();return new M(Math.PI,0).div(r).log().sub(it(new M(1,0).sub(i)))}let e=i.sub(1),t=new M(yi[0],0);for(let r=1;r<bi+2;r++)t=t.add(new M(yi[r],0).div(e.add(r)));let n=e.add(bi+.5);return new M(Gs,0).add(e.add(.5).mul(n.log())).sub(n).add(t.log())}var ia=new M(NaN,NaN),ta=new M(1,0),na=new M(0,0);var Ys="0.64.0";return Xn(Us);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  complex-esm/dist/src/complex.js: