@cortex-js/compute-engine 0.129.0 → 0.129.1

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 (433) hide show
  1. package/dist/esm-min/chunks/{chunk-RKFNDUDQ.js → chunk-75MH3VS7.js} +3 -3
  2. package/dist/esm-min/chunks/{chunk-3XFZFOXD.js → chunk-S6UB43FH.js} +1 -1
  3. package/dist/esm-min/cli/epsil.js +1 -1
  4. package/dist/esm-min/compile.js +2 -2
  5. package/dist/esm-min/compute-engine.js +2 -2
  6. package/dist/esm-min/core.js +2 -2
  7. package/dist/esm-min/epsil.js +3 -3
  8. package/dist/esm-min/identities.js +2 -2
  9. package/dist/esm-min/integration-rules.js +3 -3
  10. package/dist/esm-min/interval.js +2 -2
  11. package/dist/esm-min/latex-syntax.js +2 -2
  12. package/dist/esm-min/math-json.js +2 -2
  13. package/dist/esm-min/numerics.js +2 -2
  14. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  15. package/dist/types/big-decimal/index.d.ts +1 -1
  16. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  17. package/dist/types/big-decimal/utils.d.ts +1 -1
  18. package/dist/types/common/ansi-codes.d.ts +1 -1
  19. package/dist/types/common/cache-stats.d.ts +1 -1
  20. package/dist/types/common/configuration-change.d.ts +1 -1
  21. package/dist/types/common/debug-hook.d.ts +1 -1
  22. package/dist/types/common/debug.d.ts +1 -1
  23. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  24. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  25. package/dist/types/common/interruptible.d.ts +1 -1
  26. package/dist/types/common/kleene.d.ts +1 -1
  27. package/dist/types/common/one-of.d.ts +1 -1
  28. package/dist/types/common/signals.d.ts +1 -1
  29. package/dist/types/common/styled-text.d.ts +1 -1
  30. package/dist/types/common/terminal.d.ts +1 -1
  31. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  32. package/dist/types/common/type/boxed-type.d.ts +1 -1
  33. package/dist/types/common/type/compatibility.d.ts +1 -1
  34. package/dist/types/common/type/conditional-conformance.d.ts +1 -1
  35. package/dist/types/common/type/effects.d.ts +1 -1
  36. package/dist/types/common/type/facts.d.ts +1 -1
  37. package/dist/types/common/type/immutable.d.ts +1 -1
  38. package/dist/types/common/type/instantiate.d.ts +1 -1
  39. package/dist/types/common/type/intern.d.ts +1 -1
  40. package/dist/types/common/type/lexer.d.ts +1 -1
  41. package/dist/types/common/type/numeric-range.d.ts +1 -1
  42. package/dist/types/common/type/parse.d.ts +1 -1
  43. package/dist/types/common/type/parser.d.ts +1 -1
  44. package/dist/types/common/type/primitive.d.ts +1 -1
  45. package/dist/types/common/type/reduce.d.ts +1 -1
  46. package/dist/types/common/type/reference.d.ts +1 -1
  47. package/dist/types/common/type/serialize.d.ts +1 -1
  48. package/dist/types/common/type/size-cap.d.ts +1 -1
  49. package/dist/types/common/type/subtype.d.ts +1 -1
  50. package/dist/types/common/type/type-builder.d.ts +1 -1
  51. package/dist/types/common/type/types.d.ts +1 -1
  52. package/dist/types/common/type/utils.d.ts +1 -1
  53. package/dist/types/common/type/variance.d.ts +1 -1
  54. package/dist/types/common/type/widen-value.d.ts +1 -1
  55. package/dist/types/common/utils.d.ts +1 -1
  56. package/dist/types/compile.d.ts +1 -1
  57. package/dist/types/compute-engine/assume.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/ambient-chain.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/async-only-descendants.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/binders.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/binding-sites.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/binding-tombstone.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-character.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/boxed-object.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/broadcast-cell-widening.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/broadcast-lift-type.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/call-result-type.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/callback-arity.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/collection-element-memo.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/conditional-value.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/cycle-guard.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/definition-guards.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/derive-application-type.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/diophantine.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/effects-inference.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/effects-of.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/effects-provenance.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/error-value.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/exp-to-trig.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/explain-labels.d.ts +1 -1
  103. package/dist/types/compute-engine/boxed-expression/explain.d.ts +1 -1
  104. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  105. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  106. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  107. package/dist/types/compute-engine/boxed-expression/function-literal.d.ts +1 -1
  108. package/dist/types/compute-engine/boxed-expression/generic-instantiation.d.ts +1 -1
  109. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  110. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  111. package/dist/types/compute-engine/boxed-expression/inferred-annotations.d.ts +1 -1
  112. package/dist/types/compute-engine/boxed-expression/infinite-point.d.ts +1 -1
  113. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  114. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  115. package/dist/types/compute-engine/boxed-expression/literal-tier.d.ts +1 -1
  116. package/dist/types/compute-engine/boxed-expression/logarithm.d.ts +1 -1
  117. package/dist/types/compute-engine/boxed-expression/machine-number.d.ts +1 -1
  118. package/dist/types/compute-engine/boxed-expression/match-dispatch.d.ts +1 -1
  119. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  120. package/dist/types/compute-engine/boxed-expression/modular-arithmetic.d.ts +1 -1
  121. package/dist/types/compute-engine/boxed-expression/multivariate-gcd.d.ts +1 -1
  122. package/dist/types/compute-engine/boxed-expression/multivariate-poly.d.ts +1 -1
  123. package/dist/types/compute-engine/boxed-expression/named-arguments.d.ts +1 -1
  124. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  125. package/dist/types/compute-engine/boxed-expression/number-set-types.d.ts +1 -1
  126. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  127. package/dist/types/compute-engine/boxed-expression/object-deps.d.ts +1 -1
  128. package/dist/types/compute-engine/boxed-expression/object-walk.d.ts +1 -1
  129. package/dist/types/compute-engine/boxed-expression/operand-descriptor.d.ts +1 -1
  130. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  131. package/dist/types/compute-engine/boxed-expression/overload.d.ts +1 -1
  132. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  133. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  134. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  135. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  136. package/dist/types/compute-engine/boxed-expression/provisional-application.d.ts +1 -1
  137. package/dist/types/compute-engine/boxed-expression/recursive-list-builder.d.ts +1 -1
  138. package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +1 -1
  139. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  140. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  141. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  142. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  143. package/dist/types/compute-engine/boxed-expression/solve-congruence.d.ts +1 -1
  144. package/dist/types/compute-engine/boxed-expression/solve-domain.d.ts +1 -1
  145. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  146. package/dist/types/compute-engine/boxed-expression/solve-system.d.ts +1 -1
  147. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  148. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  149. package/dist/types/compute-engine/boxed-expression/tensor-view.d.ts +1 -1
  150. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  151. package/dist/types/compute-engine/boxed-expression/tuple-pattern.d.ts +1 -1
  152. package/dist/types/compute-engine/boxed-expression/type-compatibility-error.d.ts +1 -1
  153. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  154. package/dist/types/compute-engine/boxed-expression/type-provenance.d.ts +1 -1
  155. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  156. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  157. package/dist/types/compute-engine/boxed-expression/value-membership.d.ts +1 -1
  158. package/dist/types/compute-engine/checkpoint-journal.d.ts +1 -1
  159. package/dist/types/compute-engine/checkpoint.d.ts +1 -1
  160. package/dist/types/compute-engine/clause-identity.d.ts +1 -1
  161. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  162. package/dist/types/compute-engine/compilation/angular-unit.d.ts +1 -1
  163. package/dist/types/compute-engine/compilation/auto-escalation.d.ts +1 -1
  164. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  165. package/dist/types/compute-engine/compilation/builtin-callback.d.ts +1 -1
  166. package/dist/types/compute-engine/compilation/color-space-fact.d.ts +1 -1
  167. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  168. package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
  169. package/dist/types/compute-engine/compilation/cse.d.ts +1 -1
  170. package/dist/types/compute-engine/compilation/deprecation-warnings.d.ts +1 -1
  171. package/dist/types/compute-engine/compilation/derivative-closed-form.d.ts +1 -1
  172. package/dist/types/compute-engine/compilation/diagnostics.d.ts +1 -1
  173. package/dist/types/compute-engine/compilation/fixed-width-unroll.d.ts +1 -1
  174. package/dist/types/compute-engine/compilation/function-purity.d.ts +1 -1
  175. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  176. package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
  177. package/dist/types/compute-engine/compilation/gpu-value-facts.d.ts +1 -1
  178. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  179. package/dist/types/compute-engine/compilation/javascript-selection-fusion.d.ts +1 -1
  180. package/dist/types/compute-engine/compilation/javascript-statements.d.ts +1 -1
  181. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  182. package/dist/types/compute-engine/compilation/javascript-value-facts.d.ts +1 -1
  183. package/dist/types/compute-engine/compilation/jet-derivative.d.ts +1 -1
  184. package/dist/types/compute-engine/compilation/protocol-dispatch.d.ts +1 -1
  185. package/dist/types/compute-engine/compilation/provable-kind.d.ts +1 -1
  186. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  187. package/dist/types/compute-engine/compilation/storage-hints.d.ts +1 -1
  188. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  189. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  190. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  191. package/dist/types/compute-engine/declaration-origin.d.ts +1 -1
  192. package/dist/types/compute-engine/differential-equation-utils.d.ts +1 -1
  193. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  194. package/dist/types/compute-engine/engine-boxing-state.d.ts +1 -1
  195. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  196. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  197. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  198. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  199. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  200. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  201. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  202. package/dist/types/compute-engine/engine-inspectable-scope.d.ts +1 -1
  203. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  204. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  205. package/dist/types/compute-engine/engine-protocols.d.ts +1 -1
  206. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  207. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  208. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  209. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  210. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  211. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  212. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  213. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  214. package/dist/types/compute-engine/function-properties/index.d.ts +1 -1
  215. package/dist/types/compute-engine/function-properties/types.d.ts +1 -1
  216. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  217. package/dist/types/compute-engine/fungrim/loader.d.ts +1 -1
  218. package/dist/types/compute-engine/fungrim/types.d.ts +1 -1
  219. package/dist/types/compute-engine/global-types.d.ts +1 -1
  220. package/dist/types/compute-engine/implicit-compile.d.ts +1 -1
  221. package/dist/types/compute-engine/index.d.ts +1 -1
  222. package/dist/types/compute-engine/inference-rollback.d.ts +1 -1
  223. package/dist/types/compute-engine/interpret-oeis.d.ts +1 -1
  224. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  225. package/dist/types/compute-engine/interval/collections.d.ts +1 -1
  226. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  227. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  228. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  229. package/dist/types/compute-engine/interval/integrate.d.ts +1 -1
  230. package/dist/types/compute-engine/interval/rounding.d.ts +1 -1
  231. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  232. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  233. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  234. package/dist/types/compute-engine/latex-syntax/delimiter-tables.d.ts +1 -1
  235. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  236. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  237. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  238. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  239. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
  240. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  241. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  242. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  243. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  244. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  245. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  246. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  247. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  248. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  249. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  250. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  251. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  252. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  253. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  254. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  255. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  256. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  257. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  258. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  259. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  260. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  261. package/dist/types/compute-engine/latex-syntax/style-options.d.ts +1 -1
  262. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  263. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  264. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  265. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  266. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  267. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  268. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  269. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  270. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  271. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  272. package/dist/types/compute-engine/library/core.d.ts +1 -1
  273. package/dist/types/compute-engine/library/distributions.d.ts +1 -1
  274. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  275. package/dist/types/compute-engine/library/library.d.ts +1 -1
  276. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  277. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  278. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  279. package/dist/types/compute-engine/library/map-auto-compile.d.ts +1 -1
  280. package/dist/types/compute-engine/library/map-broadcast-shape.d.ts +1 -1
  281. package/dist/types/compute-engine/library/map-exact-proof.d.ts +1 -1
  282. package/dist/types/compute-engine/library/map-lowering.d.ts +1 -1
  283. package/dist/types/compute-engine/library/measurement-arithmetic.d.ts +1 -1
  284. package/dist/types/compute-engine/library/missing-data.d.ts +1 -1
  285. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  286. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  287. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  288. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  289. package/dist/types/compute-engine/library/random-utils.d.ts +1 -1
  290. package/dist/types/compute-engine/library/regexp.d.ts +1 -1
  291. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  292. package/dist/types/compute-engine/library/ring-constructions.d.ts +1 -1
  293. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  294. package/dist/types/compute-engine/library/special-functions.d.ts +1 -1
  295. package/dist/types/compute-engine/library/statistics-data.d.ts +1 -1
  296. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  297. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  298. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  299. package/dist/types/compute-engine/library/type-value-utils.d.ts +1 -1
  300. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  301. package/dist/types/compute-engine/library/units.d.ts +1 -1
  302. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  303. package/dist/types/compute-engine/map-auto-compile-stats.d.ts +1 -1
  304. package/dist/types/compute-engine/multi-clause.d.ts +1 -1
  305. package/dist/types/compute-engine/nonlinear-fit.d.ts +1 -1
  306. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  307. package/dist/types/compute-engine/numeric-value/exact-integer-value.d.ts +1 -1
  308. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  309. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  310. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  311. package/dist/types/compute-engine/numerics/bernoulli.d.ts +1 -1
  312. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  313. package/dist/types/compute-engine/numerics/complex-esm-augment.d.ts +1 -1
  314. package/dist/types/compute-engine/numerics/differential-equations.d.ts +1 -1
  315. package/dist/types/compute-engine/numerics/diophantine.d.ts +1 -1
  316. package/dist/types/compute-engine/numerics/distributions.d.ts +1 -1
  317. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  318. package/dist/types/compute-engine/numerics/gauss-kronrod.d.ts +1 -1
  319. package/dist/types/compute-engine/numerics/interval-arithmetic.d.ts +1 -1
  320. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  321. package/dist/types/compute-engine/numerics/levenberg-marquardt.d.ts +1 -1
  322. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  323. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  324. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  325. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  326. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  327. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  328. package/dist/types/compute-engine/numerics/oscillatory-quadrature.d.ts +1 -1
  329. package/dist/types/compute-engine/numerics/polynomial-roots.d.ts +1 -1
  330. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  331. package/dist/types/compute-engine/numerics/random.d.ts +1 -1
  332. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  333. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  334. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  335. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  336. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  337. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  338. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  339. package/dist/types/compute-engine/numerics/value-scaled-caps.d.ts +1 -1
  340. package/dist/types/compute-engine/oeis.d.ts +1 -1
  341. package/dist/types/compute-engine/rubi/compile.d.ts +1 -1
  342. package/dist/types/compute-engine/rubi/driver.d.ts +1 -1
  343. package/dist/types/compute-engine/rubi/explain-trace.d.ts +1 -1
  344. package/dist/types/compute-engine/rubi/loader.d.ts +1 -1
  345. package/dist/types/compute-engine/rubi/match.d.ts +1 -1
  346. package/dist/types/compute-engine/rubi/normal-form.d.ts +1 -1
  347. package/dist/types/compute-engine/rubi/rubi-utils.d.ts +1 -1
  348. package/dist/types/compute-engine/rubi/types.d.ts +1 -1
  349. package/dist/types/compute-engine/sequence.d.ts +1 -1
  350. package/dist/types/compute-engine/sum-representation.d.ts +1 -1
  351. package/dist/types/compute-engine/symbolic/angular-unit.d.ts +1 -1
  352. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  353. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  354. package/dist/types/compute-engine/symbolic/differential-equations.d.ts +1 -1
  355. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  356. package/dist/types/compute-engine/symbolic/explain-derivative.d.ts +1 -1
  357. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  358. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  359. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  360. package/dist/types/compute-engine/symbolic/interior-pole.d.ts +1 -1
  361. package/dist/types/compute-engine/symbolic/interpret.d.ts +1 -1
  362. package/dist/types/compute-engine/symbolic/limit.d.ts +1 -1
  363. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  364. package/dist/types/compute-engine/symbolic/recurrences.d.ts +1 -1
  365. package/dist/types/compute-engine/symbolic/residue.d.ts +1 -1
  366. package/dist/types/compute-engine/symbolic/series.d.ts +1 -1
  367. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  368. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  369. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  370. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  371. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  372. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  373. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  374. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  375. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  376. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  377. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  378. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  379. package/dist/types/compute-engine/symbolic/solver-utils.d.ts +1 -1
  380. package/dist/types/compute-engine/symbolic/trig-rewrite.d.ts +1 -1
  381. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  382. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  383. package/dist/types/compute-engine/type-constructors.d.ts +1 -1
  384. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  385. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  386. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  387. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  388. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  389. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  390. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  391. package/dist/types/compute-engine/types.d.ts +1 -1
  392. package/dist/types/compute-engine.d.ts +1 -1
  393. package/dist/types/core.d.ts +1 -1
  394. package/dist/types/epsil/characters.d.ts +1 -1
  395. package/dist/types/epsil/definition-sites.d.ts +1 -1
  396. package/dist/types/epsil/diagnostics.d.ts +1 -1
  397. package/dist/types/epsil/error-location.d.ts +1 -1
  398. package/dist/types/epsil/execute-epsil.d.ts +1 -1
  399. package/dist/types/epsil/formatter.d.ts +1 -1
  400. package/dist/types/epsil/lexer.d.ts +1 -1
  401. package/dist/types/epsil/library-names.d.ts +1 -1
  402. package/dist/types/epsil/match-exhaustiveness.d.ts +1 -1
  403. package/dist/types/epsil/occurrences.d.ts +1 -1
  404. package/dist/types/epsil/operators.d.ts +1 -1
  405. package/dist/types/epsil/parse-epsil.d.ts +1 -1
  406. package/dist/types/epsil/parser.d.ts +1 -1
  407. package/dist/types/epsil/reserved-words.d.ts +1 -1
  408. package/dist/types/epsil/resolve-library-names.d.ts +1 -1
  409. package/dist/types/epsil/serialize-epsil.d.ts +1 -1
  410. package/dist/types/epsil/signature-notes.d.ts +1 -1
  411. package/dist/types/epsil/static-diagnostics.d.ts +1 -1
  412. package/dist/types/epsil/tokens.d.ts +1 -1
  413. package/dist/types/epsil.d.ts +2 -2
  414. package/dist/types/identities.d.ts +1 -1
  415. package/dist/types/integration-rules.d.ts +1 -1
  416. package/dist/types/interval.d.ts +1 -1
  417. package/dist/types/latex-syntax.d.ts +2 -2
  418. package/dist/types/math-json/symbols.d.ts +1 -1
  419. package/dist/types/math-json/types.d.ts +1 -1
  420. package/dist/types/math-json/utils.d.ts +1 -1
  421. package/dist/types/math-json.d.ts +2 -2
  422. package/dist/types/numerics.d.ts +1 -1
  423. package/dist/umd-min/compile.cjs +2 -2
  424. package/dist/umd-min/compute-engine.cjs +2 -2
  425. package/dist/umd-min/core.cjs +2 -2
  426. package/dist/umd-min/epsil.cjs +3 -3
  427. package/dist/umd-min/identities.cjs +2 -2
  428. package/dist/umd-min/integration-rules.cjs +2 -2
  429. package/dist/umd-min/interval.cjs +2 -2
  430. package/dist/umd-min/latex-syntax.cjs +2 -2
  431. package/dist/umd-min/math-json.cjs +2 -2
  432. package/dist/umd-min/numerics.cjs +2 -2
  433. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- /** Interval 0.129.0 */
1
+ /** Interval 0.129.1 */
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.Interval = {}));})(this, (function (exports) { 'use strict';
3
3
  "use strict";var Interval=(()=>{var Eo=Object.defineProperty;var Dp=Object.getOwnPropertyDescriptor;var Cp=Object.getOwnPropertyNames;var Op=Object.prototype.hasOwnProperty;var Bp=(e,n)=>{for(var t in n)Eo(e,t,{get:n[t],enumerable:!0})},Fp=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Cp(n))!Op.call(e,r)&&r!==t&&Eo(e,r,{get:()=>n[r],enumerable:!(i=Dp(n,r))||i.enumerable});return e};var Lp=e=>Fp(Eo({},"__esModule",{value:!0}),e);var U0={};Bp(U0,{IntervalArithmetic:()=>Pp,_mul:()=>mi,abs:()=>Hi,acos:()=>xr,acosh:()=>kr,acot:()=>wr,acoth:()=>Cr,acsc:()=>Ar,acsch:()=>Or,add:()=>Xn,and:()=>Gr,asec:()=>Rr,asech:()=>Br,asin:()=>br,asinh:()=>Ir,atan:()=>Er,atan2:()=>Tr,atanh:()=>Mr,binomial:()=>lr,ceil:()=>Yi,chop:()=>fo,clamp:()=>Wr,containsExtremum:()=>le,containsZero:()=>ce,cos:()=>pr,cosh:()=>vr,cot:()=>gr,coth:()=>_r,csc:()=>yr,csch:()=>Pr,div:()=>Qn,equal:()=>Lt,erf:()=>po,erfc:()=>mo,exp:()=>zi,exp2:()=>go,factorial:()=>ar,factorial2:()=>ur,floor:()=>Wi,fract:()=>Xi,fresnelC:()=>Vr,fresnelS:()=>Lr,gamma:()=>sr,gammaln:()=>or,gcd:()=>cr,getValue:()=>Pe,greater:()=>$r,greaterEqual:()=>qr,heaviside:()=>ir,hypot:()=>ho,isNegative:()=>An,isNonNegative:()=>qt,isNonPositive:()=>zt,isPoint:()=>jt,isPositive:()=>$t,lcm:()=>fr,less:()=>Jr,lessEqual:()=>jr,ln:()=>Gi,log10:()=>Ui,log2:()=>Zi,max:()=>er,mergeDomainClip:()=>ft,midpoint:()=>Ut,min:()=>Qi,mod:()=>nr,mul:()=>On,negate:()=>gi,not:()=>Zr,notEqual:()=>zr,ok:()=>T,or:()=>Ur,piecewise:()=>Hr,point:()=>ke,pow:()=>ct,powInterval:()=>qi,remainder:()=>tr,round:()=>Ft,sec:()=>hr,sech:()=>Dr,sign:()=>rr,sin:()=>dr,sinc:()=>Fr,sinh:()=>Nr,sqrt:()=>ji,square:()=>$i,sub:()=>Kn,tan:()=>mr,tanh:()=>Sr,trunc:()=>Ki,unionResults:()=>je,unwrap:()=>Jn,unwrapOrPropagate:()=>S,version:()=>G0,width:()=>Gt});function T(e){return{kind:"interval",value:e}}function ke(e){return{lo:e,hi:e}}function le(e,n,t){let i=Math.ceil((e.lo-n)/t),r=n+i*t,s=1e-15;return r>=e.lo-s&&r<=e.hi+s}function je(e,n){if(e.kind==="empty")return n;if(n.kind==="empty")return e;if(e.kind==="singular"&&e.value===void 0||n.kind==="singular"&&n.value===void 0)return{kind:"singular"};if(e.kind==="entire"||n.kind==="entire")return{kind:"entire"};if(e.kind==="singular"||n.kind==="singular"){let a=[e,n].filter(Ku),u=Pe(e),l=Pe(n);return{...Qu(a),kind:"singular",value:{lo:Math.min(u.lo,l.lo),hi:Math.max(u.hi,l.hi)}}}let t=e.value,i=n.value,r=e.kind==="partial"?e.domainClipped:null,s=n.kind==="partial"?n.domainClipped:null,o={lo:Math.min(t.lo,i.lo),hi:Math.max(t.hi,i.hi)};if(r||s){let a=ft(r,s);return{kind:"partial",value:o,domainClipped:a}}return{kind:"interval",value:o}}function ft(e,n){return e==="both"||n==="both"?"both":e===null?n:n===null||e===n?e:"both"}function jt(e){return e.lo===e.hi}function ce(e){return e.lo<=0&&e.hi>=0}function $t(e){return e.lo>0}function An(e){return e.hi<0}function qt(e){return e.lo>=0}function zt(e){return e.hi<=0}function Gt(e){return e.hi-e.lo}function Ut(e){return(e.lo+e.hi)/2}function Pe(e){if(e.kind==="interval"||e.kind==="partial"||e.kind==="singular")return e.value}function Jn(e){return"kind"in e?Pe(e):e}function S(...e){let n=[];for(let t of e)if("kind"in t){if(t.kind==="empty")return{kind:"empty"};if(t.kind==="entire")return{kind:"entire"};if(t.kind==="singular"){if(t.value===void 0)return t;n.push(t.value);continue}n.push(t.value)}else n.push(t);return n}function ie(e,n,t,i){let r={kind:"singular"};return e!==void 0&&(r.at=e),i!==void 0&&i!==0&&(r.atOperand=i),n!==void 0&&(r.continuity=n),Number.isFinite(t.lo)&&Number.isFinite(t.hi)&&(r.value=t),r}function Ku(e){return typeof e=="object"&&e!==null&&e.kind==="singular"&&e.value!==void 0}function Qu(e){let n,t=!1;for(let r of e)n===void 0||r.at!==void 0&&(n.at===void 0||r.at<n.at)?(n={at:r.at,atOperand:r.atOperand,continuity:r.continuity},t=!1):r.at===n.at&&!t&&(r.atOperand!==n.atOperand?t=!0:r.continuity!==n.continuity&&(n={at:n.at,atOperand:n.atOperand}));let i={};return t||(n?.at!==void 0&&(i.at=n.at),n?.atOperand!==void 0&&(i.atOperand=n.atOperand),n?.continuity!==void 0&&(i.continuity=n.continuity)),i}function Vp(e){return typeof e=="object"&&e!==null&&e.kind==="partial"}function Jp(e,n){if(!e.some(Vp)||typeof n!="object"||n===null)return n;let t=n,i=t.kind===void 0?t:t.kind==="interval"?t.value:void 0;return i===void 0||Number.isNaN(i.lo)||Number.isNaN(i.hi)?n:{kind:"partial",value:i,domainClipped:"both"}}function I(e){let n=e;return(...i)=>{let r=i.filter(Ku),s=Jp(i,n(...i));if(r.length===0||typeof s!="object"||s===null)return s;let o=s,a=o.kind===void 0?o:o.kind==="interval"?o.value:void 0;return a===void 0||!Number.isFinite(a.lo)||!Number.isFinite(a.hi)||a.lo===a.hi?s:{...Qu(r),kind:"singular",value:a}}}var el=new Map,$p=1e5;function L(e){if(e<=$p){let n=el.get(e);return n===void 0&&(n=10n**BigInt(e),el.set(e,n)),n}return 10n**BigInt(e)}function cn(e){if(e<0n&&(e=-e),e===0n)return 0;let n=0,t=1;for(;e>>BigInt(t)>0n;)t*=2;for(let i=t>>1;i>=1;i>>=1)e>>BigInt(i)>0n&&(n+=i,e>>=BigInt(i));return n+1}function tl(e,n,t){return e*n>>BigInt(t)}function il(e,n,t){return(e<<BigInt(t))/n}function Qr(e,n){if(e===0n)return 0n;if(e<0n)throw new RangeError("fpsqrt: negative input");let t=e<<BigInt(n),i;if(n<qp){i=No(t);let a;do a=i,i=(i+t/i)/2n;while(De(i-a)>1n)}else i=vo(t,cn(t));let r=(i+t/i)/2n,s=De(i*i-t);return De(r*r-t)<s?r:i}function No(e){let n=cn(e);if(n<=1023){let o=Math.sqrt(Number(e));if(Number.isFinite(o)&&o>=1)return BigInt(Math.floor(o))}let t=n-52,i=Number(e>>BigInt(t)),r=Math.sqrt(i);t&1&&(r*=Math.SQRT2);let s=BigInt(Math.round(r))<<BigInt(t>>1);return s>0n?s:1n}var rl=1024,qp=640;function vo(e,n){if(n<rl){let s=No(e),o;do o=s,s=(s+e/s)/2n;while(De(s-o)>1n);for(;s*s>e;)s-=1n;for(;(s+1n)*(s+1n)<=e;)s+=1n;return s}let t=n>>2<<1,i=vo(e>>BigInt(t),n-t)<<BigInt(t>>1),r;do r=i,i=(i+e/i)/2n;while(De(i-r)>1n);for(;i*i>e;)i-=1n;for(;(i+1n)*(i+1n)<=e;)i+=1n;return i}function De(e){return e<0n?-e:e}function mt(e){if(e===0n)return 1;if(e<0n&&(e=-e),e<0x20000000000000n){let i=Number(e);return i<1e8?i<1e4?i<100?i<10?1:2:i<1e3?3:4:i<1e6?i<1e5?5:6:i<1e7?7:8:i<1e12?i<1e10?i<1e9?9:10:i<1e11?11:12:i<1e14?i<1e13?13:14:i<1e15?15:16}let n=e.toString(16).length*4,t=Math.ceil(n*.30102999566398);for(;e<L(t-1);)t--;for(;e>=L(t);)t++;return t}var zp=.7;function So(e,n){if(e===0n)return 1n<<BigInt(n);let t=Math.round(zp*Math.sqrt(n)),i=t+8,r=n+i,s=BigInt(r),o=1n<<s,a=BigInt(i),u=e<<a,l=u<0n,c=l?-u:u,f=Math.max(0,cn(c)-r+t);c>>=BigInt(f),u=l?-c:c;let p=o,h=u;p+=h;for(let y=2;h=(h*u>>s)/BigInt(y),h!==0n;y++)p+=h;for(let y=0;y<f;y++)p=p*p>>s;return p+(1n<<a-1n)>>a}var Gp=4e4;function Io(e,n){let t=1n<<BigInt(n);if(e<=0n)throw new RangeError("fpln: input must be positive");return e===t?0n:n>=Gp?Hp(e,n):Up(e,n)}function Up(e,n){let t=BigInt(n),i=1n<<t,r=52,s=n-r,o;if(s>0){let y=Number(e>>BigInt(s))/2**r;o=BigInt(Math.round(Math.log(y)*2**r))<<BigInt(s)}else{let y=Number(e)/Number(i);o=BigInt(Math.round(Math.log(y)*Number(i)))}let a=e*So(-o,n)>>t,l=(a-i<<t)/(a+i),c=l<0n?-l:l,f=c*c>>t,p=c,h=c;for(let y=3n;p=p*f>>t,p!==0n;y+=2n)h+=p/y;return o+(l<0n?-2n:2n)*h}var jn=null;function Zp(e){if(jn!==null){if(jn.bits===e)return jn.value;if(jn.bits>e)return jn.value>>BigInt(jn.bits-e)}let n=Math.ceil(e*es)+12,t;if(n<=nl.length){let i=nl.slice(0,n);t=(BigInt(i)<<BigInt(e))/L(i.length)}else t=em(e);return jn={bits:e,value:t},t}function Hp(e,n){let t=BigInt(n),i=cn(e)-n,r=Math.max(2,Math.ceil(n/2+4-i)),s=e<<BigInt(r-2),o=1n<<t,a=s;for(;De(o-a)>1n;){let l=o+a>>1n;a=Ht(o*a),o=l}return Kr(n)*s/(2n*o)-BigInt(r)*Zp(n)}var pt="314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635",es=Math.log10(2),nl="693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481020570685733685520235758130557032670751635075961930727570828371435190307038623891673471123350115364497955239120475172681574932065155524734139525882950453007095326366642654104239157814952043740430385500801944170641671518644712839968171784546957026271631064546150257207402481637773389638550695260668341137273873722928956493547025762652098859693201965058554764703306793654432547632744951250406069438147104689946506220167720424524529612687946546193165174681392672504103802546259656869144192871608293803172714367782654877566485085674077648451464439940461422603193096735402574446070308096085047486638523138181676751438667476647890881437141985494231519973548803751658612753529166100071053558249879414729509293113897155998205654392871700072180857610252368892132449713893203784393530887748259701715591070882368362758984258918535302436342143670611892367891923723146723217205340164925687274778234453534764811494186423867767744060695626573796008670762571991847340226514628379048830620330611446300737194890027436439650025809365194430411911506080948793067865158870900605203468429736193841289652556539686022194122924207574321757489097706752687115817051137009158942665478595964890653058460258668382940022833005382074005677053046787001841624044188332327983863490015631218895606505531512721993983320307514084260914790012651682434438935724727882054862715527418772430024897945401961872339808608316648114909306675193393128904316413706813977764981769748689038877899912965036192707108892641052309247839173735012298424204995689359922066022046549415106139187885744245577510206837030866619480896412186807790208181588580001688115973056186676199187395200766719214592236720602539595436541655311295175989940056000366513567569051245926825743946483168332624901803824240824231452306140963805700702551387702681785163069025513703234053802145019015374029509942262995779647427138157363801729873940704242179972266962979939312706935747240493386530879758721699645129446491883771156701678598804981838896784134938314014073166472765327635919233511233389338709513209059272185471328975470797891384445466676192702885533423429899321803769154973340267546758873236778342916191810430116091695265547859732891763545556742863877463987101912431754255888301206779210280341206879759143081283307230300883494705792496591005860012341561757413272465943",Wp=13591409n,Yp=545140134n,Xp=10939058860032000n,Kp=47.11;function Xr(e,n){if(n-e===1){let l,c;if(e===0)l=1n,c=1n;else{l=BigInt(6*e-5)*BigInt(2*e-1)*BigInt(6*e-1);let p=BigInt(e);c=p*p*p*Xp}let f=l*(Wp+Yp*BigInt(e));return e&1&&(f=-f),[l,c,f]}let t=e+n>>1,[i,r,s]=Xr(e,t),[o,a,u]=Xr(t,n);return[i*o,r*a,a*s+i*u]}function sl(e){return Math.max(2,Math.floor(e/Kp)+3)}function Qp(e){let[,n,t]=Xr(0,sl(e)),i=1n<<BigInt(e),r=Ht(10005n*i*i);return n*426880n*r/t}function ol(e){let[,n,t]=Xr(0,sl(Math.ceil(e/es))),i=L(e),r=Ht(10005n*i*i);return n*426880n*r/t}function To(e,n){if(n-e===1){let l=e===0?1n:BigInt(2*e-1),c=e===0?1n:9n*BigInt(2*e+1);return[l,c,l]}let t=e+n>>1,[i,r,s]=To(e,t),[o,a,u]=To(t,n);return[i*o,r*a,a*s+i*u]}function em(e){let n=Math.max(2,Math.ceil(e/3.169925)+5),[,t,i]=To(0,n);return(i<<BigInt(e+1))/(3n*t)}function Ht(e){if(e<0n)throw new RangeError("bigintSqrt: negative input");if(e===0n)return 0n;let n=cn(e);if(n>=rl)return vo(e,n);let t=No(e),i;do i=t,t=(t+e/t)/2n;while(De(t-i)>1n);for(;t*t>e;)t-=1n;for(;(t+1n)*(t+1n)<=e;)t+=1n;return t}var $n=null;function Kr(e){if($n!==null){if($n.bits===e)return $n.value;if($n.bits>e)return $n.value>>BigInt($n.bits-e)}let n=nm(e);return $n={bits:e,value:n},n}function nm(e){let n=Math.ceil(e*es)+12;if(n+1<=pt.length){let t=pt.slice(0,n+1);return(BigInt(t)<<BigInt(e))/L(t.length-1)}return Qp(e)}function ns(e,n){let t=BigInt(n),i=1n<<t;if(e===0n)return[0n,i];let r=Kr(n),s=2n*r,o=r/2n,a,u=De(e);if(u>i<<30n){let $=cn(u)-n+64,ln=n+$,wn=e<<BigInt($),Jt=2n*Kr(ln),xo=wn%Jt;xo<0n&&(xo+=Jt),a=xo>>BigInt($)}else a=e%s;a<0n&&(a+=s);let l=1n,c=1n;a>3n*o?(a=s-a,l=-1n):a>r?(a=a-r,l=-1n,c=-1n):a>o&&(a=r-a,c=-1n);let f=Math.round(n*es),p=Math.min(18,Math.max(2,Math.ceil(.87*Math.sqrt(f)))),h=0,y=i>>BigInt(p);for(;a>y;)a=a/2n,h++;let N=a,D=i,R=a,z=i,J=a*a,K=2n*t;for(let $=2;;$+=2){if(z=(z*J>>K)/(BigInt($)*BigInt($-1)),z===0n){R=(R*J>>K)/(BigInt($+1)*BigInt($)),R!==0n&&($%4===2?(D-=z,N-=R):(D+=z,N+=R));break}if(R=(R*J>>K)/(BigInt($+1)*BigInt($)),$%4===2?(D-=z,N-=R):(D+=z,N+=R),R===0n)break}for(let $=0;$<h;$++){let ln=2n*N*D>>t,wn=(2n*D*D>>t)-i;N=ln,D=wn}return[l*N,c*D]}function Zt(e,n){if(e===0n)return 0n;if(e<0n)return-Zt(-e,n);let t=BigInt(n),i=1n<<t,s=Kr(n)/2n;if(e>i){let h=(i<<t)/e;return s-Zt(h,n)}let o=4n*i/10n,a=0,u=e;for(;u>o;){let h=u*u,y=(i<<t)+h>>t,N=Qr(y,n);u=(u<<t)/(i+N),a++}let l=u,c=u,f=u*u,p=2n*t;for(let h=3;c=c*f>>p,c!==0n;h+=2)h%4===3?l-=c/BigInt(h):l+=c/BigInt(h);for(let h=0;h<a;h++)l=2n*l;return l}var ko=NaN,m=class e{static precision=50;static ZERO=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:0n,exponent:0}));static ONE=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:1n,exponent:0}));static TWO=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:2n,exponent:0}));static NEGATIVE_ONE=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:-1n,exponent:0}));static HALF=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:5n,exponent:-1}));static NAN=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:0n,exponent:NaN}));static POSITIVE_INFINITY=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:1n,exponent:1/0}));static NEGATIVE_INFINITY=Object.freeze(Object.assign(Object.create(e.prototype),{_digits:1,significand:-1n,exponent:1/0}));static _piFullPrecision=null;static _piCache=null;static _piCachePrecision=0;static _eulerGammaCache=null;static _eulerGammaCachePrecision=0;static get PI(){let n=e.precision;if(e._piCache!==null&&e._piCachePrecision===n)return e._piCache;let t=n+4,i;if(t+1<=pt.length)e._piFullPrecision===null&&(e._piFullPrecision=new e(pt[0]+"."+pt.slice(1))),i=e._piFullPrecision.toPrecision(t);else{let r=t+4;i=B(ol(r),-r).toPrecision(t)}return e._piCache=i,e._piCachePrecision=n,i}static get EULER_GAMMA(){let n=e.precision;if(e._eulerGammaCache!==null&&e._eulerGammaCachePrecision>=n)return e._eulerGammaCache.toPrecision(n);let t=rm(n);return e._eulerGammaCache=t,e._eulerGammaCachePrecision=n,t}significand;exponent;_digits;_digitCount(){return this._digits??(this._digits=mt(this.significand))}constructor(n){if(n instanceof e){this.significand=n.significand,this.exponent=n.exponent;return}if(typeof n=="bigint"){[this.significand,this.exponent]=ts(n,0);return}if(typeof n=="number"){[this.significand,this.exponent]=sm(n);return}[this.significand,this.exponent]=cl(n)}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(n){if(typeof n=="number"){if(Number.isNaN(n))return ko;let h=this.exponent;if(Number.isNaN(h))return ko;if(n===0)return this.significand===0n?0:this.significand>0n?1:-1;if(!Number.isFinite(h))return n===1/0?this.significand>0n?0:-1:n===-1/0?this.significand<0n?0:1:this.significand>0n?1:-1;if(this.significand===0n)return n>0?-1:1;if(n===1/0)return-1;if(n===-1/0)return 1;if(this.significand>0n!=n>0)return this.significand>0n?1:-1;if(Number.isInteger(n)&&h>=0&&h<=15){let y=this.significand*L(h),N=BigInt(n);return y<N?-1:y>N?1:0}n=new e(n)}let t=this.exponent,i=n.exponent,r=this.significand,s=n.significand;if(t!==t||i!==i)return ko;if(!Number.isFinite(t)||!Number.isFinite(i))return!Number.isFinite(t)&&!Number.isFinite(i)?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===i)return r<s?-1:r>s?1:0;let o=this._digitCount(),a=n._digitCount(),u=o+t,l=a+i;if(u!==l){let h=r>0n?1:-1;return u>l?h:-h}let c=r,f=s,p=Math.abs(t-i);if(p>1e3){let h=o,y=a,N=Math.max(h,y)+1;h<N&&(c=c*L(N-h)),y<N&&(f=f*L(N-y))}else t<i?f=f*L(p):c=c*L(p);return c<f?-1:c>f?1:0}eq(n){return typeof n=="number"?n===0?this.significand===0n&&this.exponent===0:n===1?this.significand===1n&&this.exponent===0:n===-1?this.significand===-1n&&this.exponent===0:Number.isInteger(n)&&Number.isFinite(this.exponent)&&this.exponent>=0&&this.exponent<=15?this.significand*L(this.exponent)===BigInt(n):this.cmp(n)===0:this.significand===n.significand&&this.exponent===n.exponent}lt(n){return this.cmp(n)===-1}lte(n){let t=this.cmp(n);return t===-1||t===0}gt(n){return this.cmp(n)===1}gte(n){let t=this.cmp(n);return t===1||t===0}add(n){typeof n=="number"&&(n=new e(n));let t=this.exponent,i=n.exponent;if(Number.isFinite(t)&&Number.isFinite(i)){if(t===i)return B(this.significand+n.significand,t);let o=t-i;return o>0?B(this.significand*L(o)+n.significand,i):B(this.significand+n.significand*L(-o),t)}if(t!==t||i!==i)return e.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(i);return r&&s?this.significand!==n.significand?e.NAN:this.significand>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY:r?this.significand>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY:n.significand>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY}sub(n){typeof n=="number"&&(n=new e(n));let t=this.exponent,i=n.exponent;if(Number.isFinite(t)&&Number.isFinite(i)){if(t===i)return B(this.significand-n.significand,t);let o=t-i;return o>0?B(this.significand*L(o)-n.significand,i):B(this.significand-n.significand*L(-o),t)}if(t!==t||i!==i)return e.NAN;let r=!Number.isFinite(t),s=!Number.isFinite(i);return r&&s?this.significand===n.significand?e.NAN:this.significand>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY:r?this.significand>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY:n.significand>0n?e.NEGATIVE_INFINITY:e.POSITIVE_INFINITY}mul(n){typeof n=="number"&&(n=new e(n));let t=this.exponent,i=n.exponent;if(Number.isFinite(t)&&Number.isFinite(i))return B(this.significand*n.significand,t+i);if(t!==t||i!==i||this.significand===0n||n.significand===0n)return e.NAN;let r=this.significand>0n?1n:-1n,s=n.significand>0n?1n:-1n;return r*s>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY}_mulToPrecision(n,t){typeof n=="number"&&(n=new e(n));let i=this.exponent,r=n.exponent,s=this.significand,o=n.significand;if(s!==0n&&o!==0n&&Number.isFinite(i)&&Number.isFinite(r)){let a=s*o,u=i+r,l=this._digitCount()+n._digitCount()-1,f=(a<0n?-a:a)>=L(l)?l+1:l;return f<=t?B(a,u):al(a,u).roundToPrecKnownDigits(t,f)}return this.mul(n).toPrecision(t)}neg(){let n=this.significand;return n===0n?this:Number.isFinite(this.exponent)?B(-n,this.exponent):n>0n?e.NEGATIVE_INFINITY:e.POSITIVE_INFINITY}abs(){return this.significand>=0n?this:Number.isFinite(this.exponent)?B(-this.significand,this.exponent):e.POSITIVE_INFINITY}floor(){let n=this.exponent;if(n>=0)return this;if(Number.isFinite(n)){let t=this.trunc();return this.significand<0n?t.sub(B(1n,0)):t}return this}ceil(){let n=this.exponent;if(n>=0)return this;if(Number.isFinite(n)){let t=this.trunc();return this.significand>0n?t.add(B(1n,0)):t}return this}round(){let n=this.exponent;if(n>=0)return this;if(Number.isFinite(n)){let t=B(5n,-1);return this.significand>0n?this.add(t).trunc():this.sub(t).trunc()}return this}trunc(){let n=this.exponent;if(n>=0)return this;if(Number.isFinite(n)){let t=this.significand/L(-n);return B(t===0n?0n:t,0)}return this}div(n){typeof n=="number"&&(n=new e(n));let t=this.exponent,i=n.exponent,r=this.significand,s=n.significand;if(Number.isFinite(t)&&Number.isFinite(i)){if(s===0n)return r===0n?e.NAN:r>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY;if(r===0n)return B(0n,0);let u=e.precision,l=10,c=this._digitCount(),f=n._digitCount(),p=u+l+Math.max(0,f-c),h=L(p),y=r*h/s,N=t-i-p,D=y<0n?-y:y,R=c+p-f,z=D>=L(R)?R+1:R;return al(y,N).roundToPrecKnownDigits(u,z)}if(t!==t||i!==i)return e.NAN;let o=!Number.isFinite(t),a=!Number.isFinite(i);if(o&&a)return e.NAN;if(o){let u=r>0n?1n:-1n,l=s>0n?1n:s<0n?-1n:1n;return u*l>0n?e.POSITIVE_INFINITY:e.NEGATIVE_INFINITY}return B(0n,0)}inv(){return B(1n,0).div(this)}divToward(n,t){typeof n=="number"&&(n=new e(n));let i=this.exponent,r=n.exponent,s=this.significand,o=n.significand;if(!Number.isFinite(i)||!Number.isFinite(r)||o===0n||s===0n)return this.div(n);let a=s<0n!=o<0n,u=s<0n?-s:s,l=o<0n?-o:o,c=e.precision,p=c+10+Math.max(0,n._digitCount()-this._digitCount()),h=u*L(p),y=h/l,N=h%l!==0n,D=i-r-p,R=this._digitCount()+p-n._digitCount(),z=y>=L(R)?R+1:R,J=a?t==="floor":t==="ceiling",[K,$]=Mo(y,N,D,c,J,z);return B(a?-K:K,$)}sqrtToward(n){if(this.significand===0n)return this.exponent!==this.exponent?this:e.ZERO;if(!Number.isFinite(this.exponent))return this.significand>0n?e.POSITIVE_INFINITY:e.NAN;if(this.significand<0n)return e.NAN;let t=e.precision,i=4,r=this.significand,s=this.exponent,o=s+this._digitCount()-1,a=Math.floor(o/2),u=t+i-a;s+2*u<0&&(u=Math.ceil(-s/2)+1);let l=s+2*u,c=l>=0?r*L(l):r/L(-l),f=Ht(c),p=f*f!==c,[h,y]=Mo(f,p,-u,t,n==="ceiling");return B(h,y)}mod(n){typeof n=="number"&&(n=new e(n));let t=this.exponent,i=n.exponent;if(Number.isFinite(t)&&Number.isFinite(i)){if(n.significand===0n)return e.NAN;if(this.significand===0n)return B(0n,0);let r=t-i,s=r>=0?this.significand*L(r):this.significand,o=r>=0?n.significand:n.significand*L(-r),a=s/o;return this.sub(B(a,0).mul(n))}return t!==t||i!==i||!Number.isFinite(t)?e.NAN:new e(this)}pow(n){if(typeof n=="number"&&(n=new e(n)),this.isNaN()||n.isNaN()||!n.isFinite())return e.NAN;if(n.isInteger()){let a=n.toBigInt();if(a===0n)return B(1n,0);if(!this.isFinite())return a>0n?this.significand<0n&&a%2n!==0n?e.NEGATIVE_INFINITY:e.POSITIVE_INFINITY:B(0n,0);if(this.isZero())return a>0n?B(0n,0):e.POSITIVE_INFINITY;if(a<0n)return this.pow(n.neg()).inv();let u=this.significand<0n?-this.significand:this.significand,l=this._digitCount(),c=l>15?l-15:0,f=c>0?Number(u/10n**BigInt(c)):Number(u),p=Math.log10(f)+c+this.exponent,h=Number(a)*p;if(h>9e15)return this.significand<0n&&a%2n!==0n?e.NEGATIVE_INFINITY:e.POSITIVE_INFINITY;if(h<-9e15)return B(0n,0);let y=e.precision,N=a.toString(2).length,D=Math.min(2*N+5,100),R=y+D,z=B(1n,0),J=this,K=a;for(;K>0n;)K&1n&&(z=z._mulToPrecision(J,R)),K>>=1n,K>0n&&(J=J._mulToPrecision(J,R));return z.toPrecision(y)}if(!this.isFinite())return this.significand<0n?e.NAN:n.significand>0n?e.POSITIVE_INFINITY:e.ZERO;if(this.isZero())return n.significand>0n?e.ZERO:e.POSITIVE_INFINITY;if(this.significand<0n)return e.NAN;let t=this.exponent+this._digitCount()-1,r=n.exponent+n._digitCount()-1+Math.log10(Math.abs(t)*2.303+3)+1,s=Math.min(20,Math.max(2,Math.ceil(r)+2)),o=e.precision;e.precision=o+s;try{let a=im(this,o+s);return n.mul(a).exp().toPrecision(o)}finally{e.precision=o}}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 n=this.significand<0n,t=(n?-this.significand:this.significand).toString(),i=t.length,r=i+this.exponent-1,s=n?"-":"";if(r>20||r<-6){let u=i===1?t:t[0]+"."+t.slice(1),l=r>=0?"+":"";return`${s}${u}e${l}${r}`}if(this.exponent>=0)return s+t+"0".repeat(this.exponent);let o=-this.exponent;if(o<i){let u=t.slice(0,i-o),l=t.slice(i-o);return`${s}${u}.${l}`}let a=o-i;return`${s}0.${"0".repeat(a)}${t}`}toFixed(n){let t=n??0;if(!Number.isFinite(this.exponent))return this.exponent!==this.exponent?"NaN":this.significand>0n?"Infinity":"-Infinity";let i=this.significand<0n,r=i?-this.significand:this.significand,s=this.exponent+t,o,a;if(s>=0)a=r===0n,o=a?"0":r.toString()+"0".repeat(s);else{let f=L(-s),p=r/f,h=r%f,y=f/2n,N;h>y?N=p+1n:h<y||f%2n!==0n||p%2n===0n?N=p:N=p+1n,a=N===0n,o=N.toString()}let u=i&&!a?"-":"";if(t===0)return`${u}${o}`;if(o.length<=t){let f=o.padStart(t,"0");return`${u}0.${f}`}let l=o.slice(0,o.length-t),c=o.slice(o.length-t);return`${u}${l}.${c}`}toPrecision(n){if(this.significand===0n||!Number.isFinite(this.exponent))return this;let t=this._digitCount();return t<=n?this:this.roundToPrecKnownDigits(n,t)}roundToPrecKnownDigits(n,t){let i=this.significand<0n?-this.significand:this.significand,r=t-n,s=L(r),o=i/s,a=i-o*s,u=s/2n;(a>u||a===u&&o%2n!==0n)&&(o+=1n);let l=this.significand<0n?-o:o;return B(l,this.exponent+r)}toPrecisionToward(n,t){if(this.significand===0n||!Number.isFinite(this.exponent))return this;let i=this._digitCount();if(i<=n)return this;let r=this.significand<0n,[s,o]=Mo(r?-this.significand:this.significand,!1,this.exponent,n,t==="ceiling"!==r,i);return B(r?-s:s,o)}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*L(this.exponent);let n=L(-this.exponent);return this.significand/n}},tm=8,Wt=[];function im(e,n){let t=e.significand,i=e.exponent;for(let s=Wt.length-1;s>=0;s--){let o=Wt[s];if(o.prec===n&&o.exp===i&&o.sig===t)return o.ln}let r=e.ln();return Wt.push({sig:t,exp:i,prec:n,ln:r}),Wt.length>tm&&Wt.shift(),r}function rm(e){let n=e+20+Math.ceil(Math.log10(e+10)),t=m.precision;m.precision=n;try{let i=Math.ceil(n*Math.LN10/4)+5,r=new m(i),s=r.mul(r),o=m.ONE,a=m.ONE,u=m.ZERO,l=m.ZERO,c=m.ONE.div(new m(10).pow(n)),f=6*i+100;for(let p=1;p<=f;p++){let h=new m(p).mul(p);if(o=o.mul(s).div(h).toPrecision(n),l=l.add(m.ONE.div(p)).toPrecision(n),a=a.add(o).toPrecision(n),u=u.add(o.mul(l)).toPrecision(n),p>i&&o.lt(a.mul(c)))break}return u.div(a).sub(r.ln()).toPrecision(e)}finally{m.precision=t}}function B(e,n){let[t,i]=ts(e,n),r=Object.create(m.prototype);return r.significand=t,r.exponent=i,r}function al(e,n){let t=Object.create(m.prototype);return t.significand=e,t.exponent=n,t}function Mo(e,n,t,i,r,s){if(e===0n)return[r&&n?1n:0n,t];let o=s??mt(e);if(o<=i)return[r&&n?e+1n:e,t];let a=o-i,u=L(a),l=e/u,c=n||e%u!==0n;return r&&c&&(l+=1n),[l,t+a]}var ul=1000000000n,ll=1000n;function ts(e,n){if(e===0n)return[0n,0];if((e&1n)!==0n)return[e,n];if(e%10n!==0n)return[e,n];for(;e%ul===0n;)e/=ul,n+=9;for(;e%ll===0n;)e/=ll,n+=3;for(;e%10n===0n;)e/=10n,n+=1;return[e,n]}function sm(e){return Number.isNaN(e)?[0n,NaN]:e===1/0?[1n,1/0]:e===-1/0?[-1n,1/0]:Number.isInteger(e)?ts(BigInt(e),0):cl(e.toString())}function cl(e){if(e=e.trim(),e===""||e==="NaN")return[0n,NaN];if(e==="Infinity"||e==="+Infinity")return[1n,1/0];if(e==="-Infinity")return[-1n,1/0];let n,t=0,i=e.search(/[eE]/);if(i!==-1){if(n=e.slice(0,i),t=Number(e.slice(i+1)),!Number.isFinite(t))return[0n,NaN]}else n=e;let r=!1;n.startsWith("-")?(r=!0,n=n.slice(1)):n.startsWith("+")&&(n=n.slice(1));let s=n.indexOf("."),o,a;s===-1?(o=n,a=""):(o=n.slice(0,s),a=n.slice(s+1)),o=o.replace(/^0+/,"")||"0";let u=o+a;if(u.length===0||!/^\d+$/.test(u))return[0n,NaN];let l=BigInt(u);r&&(l=-l);let c=-a.length;return ts(l,c+t)}var om=Math.log2(10),pl=Math.log10(2),am=16,Ao=1e6;function fn(e,n){let t=Math.ceil(n*om)+am,i=BigInt(t);return e.exponent>=0?[e.significand*L(e.exponent)<<i,t]:[(e.significand<<i)/L(-e.exponent),t]}function dn(e,n,t){if(e===0n)return m.ZERO;let i=e<0n,r=i?-e:e,s=BigInt(n),o=cn(r)-n,a=Math.floor(o*pl),u=t+4-a,l,c;if(u>=0)l=r*L(u)+(1n<<s-1n)>>s,c=-u;else{let p=L(-u)<<s;l=(r+p/2n)/p,c=-u}if(l===0n)return m.ZERO;let f=mt(l);if(f>t){let p=f-t,h=L(p),y=h/2n,N=l%h;l=l/h,N>=y&&(l+=1n),c+=p}return B(i?-l:l,c)}function me(e){return e.exponent+e._digitCount()-1}function wo(e,n){if(e===0n)return 0;let t=e<0n?-e:e,i=n*pl-(mt(t)-1);return i>0?Math.ceil(i):0}var ml=5,fl=BigInt(Number.MAX_SAFE_INTEGER),qn=null;function gl(e){if(qn!==null){if(qn.bits===e)return qn.value;if(qn.bits>e)return qn.value>>BigInt(qn.bits-e)}let n=Io(10n<<BigInt(e),e);return qn={bits:e,value:n},n}m.prototype.sqrt=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NAN;if(this.significand<0n)return m.NAN;let e=m.precision,n=e+10,t=me(this),i=Math.floor(t/2),r=B(this.significand,this.exponent-2*i),[s,o]=fn(r,n),a=Qr(s,o),u=dn(a,o,e);return B(u.significand,u.exponent+i)};m.prototype.cbrt=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NEGATIVE_INFINITY;if(this.significand<0n)return this.neg().cbrt().neg();let e=m.precision,n=e+10,t=me(this),i=Math.floor(t/3),r=B(this.significand,this.exponent-3*i),[s,o]=fn(r,n),a=s<<BigInt(2*o),u,l=r.toNumber();if(o<=1e3&&Number.isFinite(l)&&l>0){let p=Number(1n<<BigInt(o)),h=Math.cbrt(l);Number.isFinite(h)&&h>0?(u=BigInt(Math.floor(h*p)),u===0n&&(u=1n)):u=dl(a)}else u=dl(a);let c;do{c=u;let p=u*u;if(p===0n){u=1n;break}u=(2n*u+a/p)/3n}while(De(u-c)>1n);{let p=(2n*u+a/(u*u))/3n,h=De(u*u*u-a);De(p*p*p-a)<h&&(u=p)}let f=dn(u,o,e);return B(f.significand,f.exponent+i)};m.sqrt=function(e){return e.sqrt()};m.cbrt=function(e){return e.cbrt()};m.prototype.exp=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.ZERO;if(this.isZero())return m.ONE;if(me(this)>=17)return this.significand>0n?m.POSITIVE_INFINITY:m.ZERO;let e=m.precision,n=Math.max(0,this.exponent+this._digitCount()),t=e+20+n,[i,r]=fn(this,t),s=gl(r),o=i/s,a=i-o*s;if(a<0n&&(o-=1n,a+=s),o>fl||o<-fl)return o>0n?m.POSITIVE_INFINITY:m.ZERO;let u=dn(So(a,r),r,e),l=u.exponent+Number(o);return Number.isSafeInteger(l)?B(u.significand,l):o>0n?m.POSITIVE_INFINITY:m.ZERO};m.prototype.ln=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NAN;if(this.isZero())return m.NEGATIVE_INFINITY;if(this.significand<0n)return m.NAN;if(this.eq(1))return m.ZERO;let e=m.precision,n=this.significand,t=this._digitCount(),i=this.exponent+t-1,r=B(n,-(t-1)),s=Math.abs(i).toString().length,o=0;if(i===0||i===-1){let p=this.sub(m.ONE);if(!p.isZero()){let h=me(p);h<0&&(o=-h)}}let a=e+20+s+o,[u,l]=fn(r,a),c=gl(l),f=Io(u,l)+BigInt(i)*c;return dn(f,l,e)};m.prototype.log=function(e){let n=e instanceof m?e:new m(e),t=m.precision;m.precision=t+10;try{return this.ln().div(n.ln()).toPrecision(t)}finally{m.precision=t}};m.exp=function(e){return e.exp()};m.ln=function(e){return e.ln()};m.log10=function(e){return e.log(10)};m.log2=function(e){return e.log(2)};m.prototype.sin=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.isZero())return m.ZERO;let e=m.precision,n=me(this);if(n<0&&-2*n>=e+4)return this.toPrecision(e);let t=e+15+(n<0?-n:0);if(n+t+30>Ao)return m.NAN;let[i,r]=fn(this,t),[s]=ns(i,r);return dn(s,r,e)};m.prototype.cos=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.isZero())return m.ONE;let e=m.precision,n=me(this),t=0;for(let i=0;;i++){let r=e+15+t;if(n+r+30>Ao)return m.NAN;let[s,o]=fn(this,r),[,a]=ns(s,o);if(a===0n){if(i>=3)return m.ZERO;t+=e+30;continue}let u=wo(a,o);if(u<=t+ml||i>=3)return dn(a,o,e);t=u+5}};m.prototype.tan=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.isZero())return m.ZERO;let e=m.precision,n=me(this);if(n<0&&-2*n>=e+4)return this.toPrecision(e);let t=n<0?-n:0,i=0;for(let r=0;;r++){let s=e+15+t+i;if(n+s+30>Ao)return m.NAN;let[o,a]=fn(this,s),[u,l]=ns(o,a);if(l===0n){if(r>=3)return u>0n?m.POSITIVE_INFINITY:m.NEGATIVE_INFINITY;i+=e+30;continue}let c=Math.max(u===0n?0:wo(u,a),wo(l,a));if(c<=i+ml||r>=3){let f=(u<<BigInt(a))/l;return dn(f,a,e)}i=c+5}};m.prototype.atan=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite()){let o=m.PI.div(m.TWO);return this.significand>0n?o:o.neg()}let e=m.precision,n=me(this);if(n<0&&-2*n>=e+4)return this.toPrecision(e);let t=e+15+(n<0?-n:0),[i,r]=fn(this,t),s=Zt(i,r);return dn(s,r,e)};m.prototype.asin=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.isZero())return m.ZERO;let e=this.abs(),n=m.ONE;if(e.gt(n))return m.NAN;if(e.eq(n)){let h=m.PI.div(m.TWO);return this.significand>0n?h:h.neg()}let t=m.precision,i=me(this);if(i<0&&-2*i>=t+4)return this.toPrecision(t);let r=t+20+(i<0?-i:0),[s,o]=fn(this,r),a=1n<<BigInt(o),u=tl(s,s,o),l=a-u,c=Qr(l,o),f=il(s,c,o),p=Zt(f,o);return dn(p,o,t)};m.prototype.acos=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.abs().gt(m.ONE))return m.NAN;if(this.eq(1))return m.ZERO;if(this.eq(-1))return m.PI;let n=m.precision,t=m.precision;m.precision=n+10;try{let i=m.TWO;if(this.significand>=0n){let s=m.ONE.sub(this)._mulToPrecision(m.HALF,n+10).sqrt();return i._mulToPrecision(s.asin(),n)}let r=m.ONE.add(this)._mulToPrecision(m.HALF,n+10).sqrt();return m.PI.sub(i.mul(r.asin())).toPrecision(n)}finally{m.precision=t}};m.sin=function(e){return e.sin()};m.cos=function(e){return e.cos()};m.tan=function(e){return e.tan()};m.asin=function(e){return e.asin()};m.acos=function(e){return e.acos()};m.atan=function(e){return e.atan()};m.atan2=function(e,n){let t=e instanceof m?e:new m(e);if(t.isNaN()||n.isNaN())return m.NAN;let i=m.PI,r=i.div(m.TWO);if(n.isZero())return t.isZero()?m.ZERO:t.significand>0n?r:r.neg();let s=t.div(n);return n.significand>0n?s.atan():t.significand>=0n?s.atan().add(i):s.atan().sub(i)};m.prototype.sinh=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NEGATIVE_INFINITY;let e=m.precision,n=me(this);if(n<0){if(-2*n>=e+4)return this.toPrecision(e);let r=m.precision;m.precision=e-n+5;try{let s=this.exp();return s.sub(s.inv())._mulToPrecision(m.HALF,e)}finally{m.precision=r}}if(Math.abs(this.toNumber())>1.16*(e+3)){let r=this.abs().exp().div(m.TWO);return this.significand>0n?r:r.neg()}let t=this.exp(),i=t.inv();return t.sub(i).div(m.TWO)};m.prototype.cosh=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ONE;if(!this.isFinite())return m.POSITIVE_INFINITY;let e=m.precision;if(Math.abs(this.toNumber())>1.16*(e+3))return this.abs().exp().div(m.TWO);let n=this.exp(),t=n.inv();return n.add(t).div(m.TWO)};m.prototype.tanh=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.ONE:m.NEGATIVE_ONE;let e=m.precision,n=me(this);if(n<0){if(-2*n>=e+4)return this.toPrecision(e);let i=m.precision;m.precision=e-n+5;try{let r=this.mul(m.TWO).exp();return r.sub(m.ONE).div(r.add(m.ONE)).toPrecision(e)}finally{m.precision=i}}if(Math.abs(this.toNumber())>1.16*(e+3))return this.significand>0n?m.ONE:m.NEGATIVE_ONE;let t=this.mul(m.TWO).exp();return t.sub(m.ONE).div(t.add(m.ONE))};m.sinh=function(e){return e.sinh()};m.cosh=function(e){return e.cosh()};m.tanh=function(e){return e.tanh()};m.prototype.expm1=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NEGATIVE_ONE;if(this.isZero())return m.ZERO;let e=m.precision,n=me(this);if(n<0&&-n>=e+2)return this.toPrecision(e);if(n<0){let t=m.precision;m.precision=e-n+5;try{return this.exp().sub(m.ONE).toPrecision(e)}finally{m.precision=t}}return this.exp().sub(m.ONE)};m.prototype.log1p=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NAN;if(this.isZero())return m.ZERO;let e=m.ONE.add(this);if(e.isZero())return m.NEGATIVE_INFINITY;if(e.significand<0n)return m.NAN;let n=m.precision,t=me(this);if(t<0&&-t>=n+2)return this.toPrecision(n);if(t<0){let i=m.precision;m.precision=n-t+5;try{return m.ONE.add(this).ln().toPrecision(n)}finally{m.precision=i}}return m.ONE.add(this).ln()};m.prototype.asinh=function(){if(this.isNaN())return m.NAN;if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NEGATIVE_INFINITY;let e=this.significand<0n,n=this.abs(),t=m.precision,i=me(this);if(i<0&&-2*i>=t+4)return this.toPrecision(t);let r=()=>n.add(n.mul(n).add(m.ONE).sqrt()).ln(),s;if(i<0){let o=m.precision;m.precision=t-i+5;try{s=r().toPrecision(t)}finally{m.precision=o}}else s=r();return e?s.neg():s};m.prototype.acosh=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:m.NAN;if(this.lt(m.ONE))return m.NAN;if(this.eq(1))return m.ZERO;let e=this.sub(m.ONE).div(m.TWO).sqrt();return m.TWO.mul(e.asinh())};m.prototype.atanh=function(){if(this.isNaN())return m.NAN;if(!this.isFinite())return m.NAN;if(this.isZero())return m.ZERO;let e=this.abs();if(e.eq(1))return this.significand>0n?m.POSITIVE_INFINITY:m.NEGATIVE_INFINITY;if(e.gt(m.ONE))return m.NAN;let n=m.precision,t=me(this);if(-2*t>=n+4)return this.toPrecision(n);let i=m.precision;m.precision=n-t+5;try{return m.ONE.add(this).div(m.ONE.sub(this)).ln()._mulToPrecision(m.HALF,n)}finally{m.precision=i}};m.prototype.nthRoot=function(e){if(this.isNaN()||!Number.isInteger(e)||e===0)return m.NAN;if(e===1)return this;if(e===2)return this.sqrt();if(e===3)return this.cbrt();if(e<0)return this.nthRoot(-e).inv();if(this.isZero())return m.ZERO;if(!this.isFinite())return this.significand>0n?m.POSITIVE_INFINITY:e%2===0?m.NAN:m.NEGATIVE_INFINITY;if(this.significand<0n)return e%2===0?m.NAN:this.neg().nthRoot(e).neg();let n=m.precision,t=m.precision;m.precision=n+8;try{return m.exp(this.ln().div(new m(e))).toPrecision(n)}finally{m.precision=t}};m.asinh=function(e){return e.asinh()};m.acosh=function(e){return e.acosh()};m.atanh=function(e){return e.atanh()};m.expm1=function(e){return e.expm1()};m.log1p=function(e){return e.log1p()};m.nthRoot=function(e,n){return e.nthRoot(n)};function dl(e){let n=cn(e);if(n<=1023){let u=Math.cbrt(Number(e));if(Number.isFinite(u)&&u>=1)return BigInt(Math.floor(u))}let t=n-51,i=Number(e>>BigInt(t)),r=Math.cbrt(i),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 fE=1n<<32n;var dE=[BigInt(4),BigInt(2),BigInt(4),BigInt(2),BigInt(4),BigInt(6),BigInt(2),BigInt(6)];var um=53,hl=Math.floor(Math.log10(Math.pow(2,um))),lm=1e-10;var zn=1e6;function Ee(e){if(e!==e)return e;if(e===-1/0)return-Number.MAX_VALUE;if(e===1/0||e===Number.MAX_VALUE)return 1/0;let n=e*(e<0?1-Number.EPSILON/2:1+Number.EPSILON);n===e&&(n=Number.MIN_VALUE*Number.EPSILON>0?e+Number.MIN_VALUE*Number.EPSILON:e+Number.MIN_VALUE),n===1/0&&(n=+Number.MAX_VALUE);let t=e+(n-e)/2;e<t&&t<n&&(n=t);let i=(n+e)/2;return e<i&&i<n&&(n=i),n===0?-0:n}function Ce(e){return-Ee(-e)}function gt(e,n){if(e===0)return n;if(n===0||e===n)return e;if(!Number.isInteger(e)||!Number.isInteger(n))return NaN;for(;n!==0;)[e,n]=[n,e%n];return e<0?-e:e}function Ro(e,n){if(e===0||n===0)return 0;let t=BigInt(e)*BigInt(n)/BigInt(gt(e,n));return t<0n&&(t=-t),Number(t)}function _o(e){if(!Number.isInteger(e)||e<0)return NaN;if(e>170)return 1/0;let n=1;for(let t=2;t<=e;t++)n=n*t;return n}function Po(e){if(!Number.isInteger(e)||e<0)return NaN;if(e<0)return NaN;if(e<=1)return 1;let n=e;for(;e>2;)if(e-=2,n*=e,!Number.isFinite(n))return n;return n}function rs(e,n=lm){return typeof e=="number"&&Math.abs(e)<=n?0:e}var yl=new WeakSet,cm=4096,ss=new Map;function Do(e,n,t,i=!1,r=!1){let s=`${e}:${Object.is(n,-0)?"-0":n}:${Object.is(t,-0)?"-0":t}:${i?1:0}${r?1:0}`,o=ss.get(s);if(o!==void 0)return o;let a={kind:"numeric",type:e};return n!==void 0&&(a.lower=n),t!==void 0&&(a.upper=t),i&&(a.lowerOpen=!0),r&&(a.upperOpen=!0),Object.freeze(a),yl.add(a),ss.size>=cm&&ss.clear(),ss.set(s,a),a}function bl(e){return yl.has(e)}function Rn(e,n,t,i=!1,r=!1){let s=n===0?0:n,o=t===0?0:t;if(Number.isFinite(s)||(i=!1),Number.isFinite(o)||(r=!1),fm(e)){if(Number.isFinite(s)){let a=i?Math.floor(s)+1:Math.ceil(s);(!i||a!==s)&&(s=a,i=!1)}if(Number.isFinite(o)){let a=r?Math.ceil(o)-1:Math.floor(o);(!r||a!==o)&&(o=a,r=!1)}}return s>o||s===o&&(i||r)?"never":s===-1/0&&o===1/0?e:Do(e,s===-1/0?void 0:s,o===1/0?void 0:o,i,r)}function fm(e){return e==="integer"}var Xt=["console","entropy","environment","fs_read","fs_write","network","random","scope","state","time"],dm=new Set(Xt);function os(e){return dm.has(e)}function xl(e){return e===void 0||e!=="any"&&e.length===0}function as(e){return pm(e,!0)}function pm(e,n){if(e===void 0)return;if(e==="any")return"any";if(typeof e=="string"||typeof e?.[Symbol.iterator]!="function")throw new Error(`Invalid effect set \`${String(e)}\`. Expected \`'any'\` or a collection of effect labels. The effect labels are ${Xt.join(", ")}`);let t=[...new Set(e)].sort();for(let i of t)if(!os(i))throw new Error(`Unknown effect label \`${i}\`. The effect labels are ${Xt.join(", ")}`);return t.length>0?t:n?[]:void 0}function Kt(e,n){return xl(e)||n==="any"?!0:e==="any"||xl(n)?!1:e.every(t=>n.includes(t))}function Qt(e,n){return e===void 0?n===void 0?void 0:n:n===void 0?e:e==="any"||n==="any"?"any":as([...e,...n])}function Co(e){return e==="any"?"any":e.length===0?"pure":[...e].sort().join(" ")}var us=["number","complex","imaginary","real","rational","integer","infinity","nan"],Oo=["indexed_collection","list","tuple","range","string"],ls=Object.freeze({kind:"indexed_collection",elements:"integer"}),cs=Object.freeze({kind:"indexed_collection",elements:"character"}),Bo=Object.freeze({kind:"list",elements:"unknown"}),Fo=Object.freeze({kind:"set",elements:"unknown"}),ei=Object.freeze({kind:"dictionary",values:"unknown"}),fs=Object.freeze({kind:"collection",elements:"unknown"}),ni=Object.freeze({kind:"indexed_collection",elements:"unknown"}),ht=Object.freeze({kind:"collection",elements:"any"}),ti=Object.freeze({kind:"indexed_collection",elements:"any"}),SE=Object.freeze({kind:"dictionary",values:"any"}),Lo=Object.freeze({kind:"union",types:[{kind:"value",value:1/0},{kind:"value",value:-1/0}]}),Vo=Object.freeze({kind:"union",types:["real",{kind:"value",value:1/0},{kind:"value",value:-1/0}]}),ds=[...Oo,"collection","set","record","dictionary"],ps=["scalar",...us,"boolean","character"],Jo=["value","color","regexp","type","object",...ds,...ps],jo=["expression","symbol","function",...Jo],$o=["any","unknown","nothing","missing","never","error",...jo],pn=new Set(us),El=new Set(ds),Tl=new Set(ps),Gn=new Set($o),ii="Variadic arguments cannot be used with optional arguments";function Te(e){if(typeof e=="string")return!1;switch(e.kind){case"signature":return(e.optArgs?.length??0)>0&&e.variadicArg!==void 0?!0:Te(e.result)||(e.args?.some(n=>Te(n.type))??!1)||(e.optArgs?.some(n=>Te(n.type))??!1)||e.variadicArg!==void 0&&Te(e.variadicArg.type)||(e.typeParams?.some(n=>n.bound!==void 0&&Te(n.bound))??!1);case"record":case"object":return Object.values(e.elements).some(Te);case"union":case"intersection":return e.types.some(Te);case"negation":return Te(e.type);case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":return Te(e.elements);case"dictionary":return Te(e.values);case"tuple":return e.elements.some(n=>Te(n.type));case"reference":return e.args?.some(Te)??!1;default:return!1}}function yt(e){return typeof e!="string"?!1:Gn.has(e)}function ms(e){return typeof e=="string"?Gn.has(e):typeof e!="object"||!("kind"in e)?!1:e.kind==="signature"||e.kind==="union"||e.kind==="intersection"||e.kind==="negation"||e.kind==="value"||e.kind==="tuple"||e.kind==="list"||e.kind==="record"||e.kind==="object"||e.kind==="dictionary"||e.kind==="set"||e.kind==="broadcastable"||e.kind==="symbol"||e.kind==="expression"||e.kind==="numeric"||e.kind==="collection"||e.kind==="indexed_collection"||e.kind==="variable"||e.kind==="reference"}var Nl=Object.freeze({complexInfinity:!0});function ge(e){return typeof e=="object"&&e!==null&&e.complexInfinity===!0}var mm=1,vl=2,Sl=3,Go=4,gm=5,hm=6,ym=7,bm=8,xm=9,Em=10,Tm=11,qo=Go,zo=!1;function Qe(e){if(typeof e=="string")return e;zo=!0;try{return A(e)}finally{zo=!1}}function A(e,n=0){if(typeof e=="string")return e;let t="";switch(e.kind){case"value":typeof e.value=="string"?t=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?t=e.value?"true":"false":ge(e.value)?t="~oo":e.value===1/0?t="+oo":e.value===-1/0?t="-oo":t=e.value.toString();break;case"reference":t=e.args===void 0?e.name:`${e.name}<${e.args.map(c=>A(c)).join(", ")}>`;break;case"variable":t=e.name;break;case"negation":t=`!${A(e.type,Go)}`;break;case"union":{let c=[],f=p=>{typeof p=="object"&&p.kind==="union"?p.types.forEach(f):c.push(A(p,vl))};if(e.types.forEach(f),c.includes("+oo")&&c.includes("-oo")){let p=c.filter(h=>h!=="+oo"&&h!=="-oo");p.push("signed_infinity"),t=p.sort().join(" | ")}else t=c.sort().join(" | ");break}case"intersection":t=e.types.map(c=>A(c,Sl)).join(" & ");break;case"expression":t=`expression<${ri(e.operator)}>`;break;case"symbol":t=`symbol<${ri(e.name)}>`;break;case"numeric":{let c=Number.isFinite(e.lower)?`${e.lower}${e.lowerOpen?"<":""}`:"",f=Number.isFinite(e.upper)?`${e.upperOpen?"<":""}${e.upper}`:"";t=c===""&&f===""?`${e.type}`:`${e.type}<${c}..${f}>`;break}case"list":if(e.dimensions&&typeof e.elements=="string"&&pn.has(e.elements)){if(e.dimensions===void 0)e.elements==="number"&&(t="tensor");else if(e.dimensions.length===1)e.elements==="number"?e.dimensions[0]<0?t="vector":t=`vector<${e.dimensions[0]}>`:e.dimensions[0]<0?t=`vector<${A(e.elements)}>`:t=`vector<${A(e.elements)}^${e.dimensions[0]}>`;else if(e.dimensions.length===2){let c=e.dimensions;e.elements==="number"?c[0]<0&&c[1]<0?t="matrix":t=`matrix<${c[0]}x${c[1]}>`:c[0]<0&&c[1]<0?t=`matrix<${A(e.elements)}>`:t=`matrix<${A(e.elements)}^(${c[0]}x${c[1]})>`}}if(!t){let c=e.dimensions;if(c!==void 0&&c.length<=2&&c.every(f=>f<0))t=`${c.length===1?"vector":"matrix"}<${A(e.elements)}>`;else if(c!==void 0&&c.some(f=>f<0)){let f=A(e.elements);for(let p=c.length-1;p>=0;p--)f=c[p]<0?`list<${f}>`:`list<${f}^${c[p]}>`;t=f}else{let f=c?c.length===1?`^${c[0].toString()}`:`^(${c.join("x")})`:"";t=`list<${A(e.elements)}${f}>`}}break;case"record":t=`record{${Object.entries(e.elements).map(([c,f])=>`${ri(c)}: ${A(f)}`).join(", ")}}`;break;case"object":t=`object{${Object.entries(e.elements).map(([c,f])=>`${ri(c)}: ${A(f)}`).join(", ")}}`;break;case"dictionary":t=`dictionary<${A(e.values)}>`;break;case"set":t=`set<${A(e.elements)}>`;break;case"broadcastable":t=`broadcastable<${A(e.elements)}>`;break;case"collection":t=`collection<${A(e.elements)}>`;break;case"indexed_collection":t=`indexed_collection<${A(e.elements)}>`;break;case"tuple":if(e.elements.length===0)t="tuple";else if(e.elements.length===1){let[c]=e.elements;t=`tuple<${bt(c)}>`}else t="tuple<"+e.elements.map(c=>bt(c)).join(", ")+">";break;case"signature":let r=e.args?e.args.map(c=>bt(c)).join(", "):"",s=e.optArgs?e.optArgs.map(c=>bt(c,qo)+"?").join(", "):"",o=e.variadicArg?e.variadicMin===0?`${bt(e.variadicArg,qo)}*`:`${bt(e.variadicArg,qo)}+`:"",a=[r,s,o].filter(c=>c).join(", "),u=e.effects===void 0||zo&&e.effects!=="any"&&!e.effects.length?"":` ${Co(e.effects)}`,l=e.typeParams?.length?` where ${e.typeParams.map(c=>{let f=c.bound===void 0?void 0:A(c.bound),p=f===void 0||f==="unknown"?c.name:`${c.name}: ${f}`;return c.protocols?.length?`${p} is ${c.protocols.join(" & ")}`:p}).join(", ")}`:"";t=`(${a})${u} -> ${A(e.result)}${l}`;break;default:t="error"}return n>0&&n>Nm(e.kind)?`(${t})`:t}function bt(e,n=0){return e.name?`${ri(e.name)}: ${A(e.type,n)}`:A(e.type,n)}function ri(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?e:`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}\``}function Nm(e){switch(e){case"negation":return Go;case"union":return vl;case"intersection":return Sl;case"list":return gm;case"record":case"object":return hm;case"dictionary":return ym;case"set":return bm;case"collection":case"indexed_collection":case"broadcastable":return xm;case"tuple":return Em;case"signature":return mm;case"value":case"variable":case"numeric":case"expression":case"symbol":case"reference":return Tm;default:return 0}}function Uo(e,n){let t={kind:"reference",name:e.name,args:n};return Object.defineProperty(t,"def",{get:()=>e.def,enumerable:!0,configurable:!0}),Object.defineProperty(t,"alias",{get:()=>e.alias,set:i=>{e.alias=i},enumerable:!0,configurable:!0}),Object.defineProperty(t,"decl",{value:e,enumerable:!1,configurable:!0}),t}function Ne(e){return e.decl??e}function Zo(e,n){if(n===e.args)return e;let t=Object.getOwnPropertyDescriptors(e);return t.args={value:n,writable:!0,enumerable:!0,configurable:!0},Object.create(Object.getPrototypeOf(e),t)}var vm="_forwardArity";function Ho(e,n){let t=e;t._forwardArity===void 0&&Object.defineProperty(e,vm,{value:new Set,enumerable:!1,writable:!0,configurable:!0}),t._forwardArity.add(n)}function xt(e,n){let t=Ne(e);return t._varianceState!=="verified"?"inout":t.typeParams?.[n]?.variance??"out"}var en=class extends Error{code;constructor(n,t){super(`${n}: ${t}`),this.code=n}};function mn(e,n){throw new en(e,n)}function _n(e){return typeof e!="object"?!1:e.kind==="signature"?e.typeParams!==void 0&&e.typeParams.length>0:e.kind==="intersection"?e.types.some(n=>typeof n=="object"&&n.kind==="signature"&&n.typeParams!==void 0&&n.typeParams.length>0):!1}function Pn(e){let n=new Set;return $e(e,void 0,n),n}function $e(e,n,t){if(typeof e!="string")switch(e.kind){case"variable":(n===void 0||!n.has(e.name))&&t.add(e.name);return;case"signature":{let i=n;if(e.typeParams!==void 0&&e.typeParams.length>0){i=new Set(n);for(let r of e.typeParams)i.add(r.name);for(let r of e.typeParams)r.bound!==void 0&&$e(r.bound,n,t)}for(let r of Et(e))$e(r.type,i,t);$e(e.result,i,t);return}case"union":case"intersection":for(let i of e.types)$e(i,n,t);return;case"negation":$e(e.type,n,t);return;case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":$e(e.elements,n,t);return;case"tuple":for(let i of e.elements)$e(i.type,n,t);return;case"dictionary":$e(e.values,n,t);return;case"record":case"object":for(let i of Object.values(e.elements))$e(i,n,t);return;case"reference":if(e.args!==void 0)for(let i of e.args)$e(i,n,t);return;default:return}}function ze(e){return qe(e,void 0)}function qe(e,n){if(typeof e=="string")return!1;switch(e.kind){case"variable":return n===void 0||!n.has(e.name);case"signature":{let t=n;if(e.typeParams!==void 0&&e.typeParams.length>0){t=new Set(n);for(let i of e.typeParams)t.add(i.name);for(let i of e.typeParams)if(i.bound!==void 0&&qe(i.bound,n))return!0}for(let i of Et(e))if(qe(i.type,t))return!0;return qe(e.result,t)}case"union":case"intersection":for(let t of e.types)if(qe(t,n))return!0;return!1;case"negation":return qe(e.type,n);case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":return qe(e.elements,n);case"tuple":for(let t of e.elements)if(qe(t.type,n))return!0;return!1;case"dictionary":return qe(e.values,n);case"record":case"object":for(let t of Object.values(e.elements))if(qe(t,n))return!0;return!1;case"reference":if(e.args!==void 0){for(let t of e.args)if(qe(t,n))return!0}return!1;default:return!1}}function Et(e){let n=[];return e.args&&n.push(...e.args),e.optArgs&&n.push(...e.optArgs),e.variadicArg&&n.push(e.variadicArg),n}function Il(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function gs(e){let n=e.def;if(n===void 0)return;let t=Ne(e).typeParams,i=e.args;if(t===void 0||t.length===0||i===void 0)return n;if(t.length!==i.length)return;let r={};return t.forEach((s,o)=>r[s.name]=i[o]),Q(n,r)}function Q(e,n){if(typeof e=="string")return e;switch(e.kind){case"variable":{let t=Il(n,e.name)?n[e.name]:void 0;return t===void 0?e:t}case"signature":{let t=Wo(e.args,n),i=Wo(e.optArgs,n),r=e.variadicArg===void 0?void 0:wl(e.variadicArg,n),s=Q(e.result,n),o=e.typeParams?.filter(l=>!Il(n,l.name)||n[l.name]===void 0),a=e.typeParams!==void 0&&o.length!==e.typeParams.length;if(!a&&t===e.args&&i===e.optArgs&&r===e.variadicArg&&s===e.result)return e;let u={...e,result:s};return t!==void 0&&(u.args=t),i!==void 0&&(u.optArgs=i),r!==void 0&&(u.variadicArg=r),a&&(o.length===0?delete u.typeParams:u.typeParams=o),u}case"union":case"intersection":{let t=kl(e.types,n);return t===e.types?e:{...e,types:t}}case"negation":{let t=Q(e.type,n);return t===e.type?e:{...e,type:t}}case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":{let t=Q(e.elements,n);return t===e.elements?e:{...e,elements:t}}case"tuple":{let t=Wo(e.elements,n);return t===e.elements?e:{...e,elements:t}}case"dictionary":{let t=Q(e.values,n);return t===e.values?e:{...e,values:t}}case"record":case"object":{let t=!1,i={};for(let[r,s]of Object.entries(e.elements)){let o=Q(s,n);o!==s&&(t=!0),i[r]=o}return t?{...e,elements:i}:e}case"reference":{if(e.args===void 0)return e;let t=kl(e.args,n);return t===e.args?e:Zo(e,t)}default:return e}}function kl(e,n){let t=!1,i=e.map(r=>{let s=Q(r,n);return s!==r&&(t=!0),s});return t?i:e}function wl(e,n){let t=Q(e.type,n);return t===e.type?e:{...e,type:t}}function Wo(e,n){if(e===void 0)return;let t=!1,i=e.map(r=>{let s=wl(r,n);return s!==r&&(t=!0),s});return t?i:e}function hs(e,n){if(typeof e=="object"&&e.kind==="intersection"){for(let t of e.types)Ml(t,n);return}Ml(e,n)}function Ml(e,n){if(typeof e=="object"&&e.kind==="signature"&&e.typeParams!==void 0&&e.typeParams.length>0){Sm(e,e.typeParams,n);return}ve(e,new Set,null,new Set)}function Sm(e,n,t){let i=new Set;for(let o of n)i.has(o.name)&&mn("unsupported-variable-position",`The type variable \`${o.name}\` is declared more than once in the same \`where\` clause`),i.add(o.name),o.protocols!==void 0&&o.protocols.length>0&&t?.conformsTo===void 0&&mn("protocol-conformance-unsupported",`Protocol conformance constraints (\`where ${o.name} is ${o.protocols.join(" & ")}\`) require an engine's protocol registry; this type was declared without one`);for(let o of n){if(o.bound===void 0)continue;Pn(o.bound).size>0&&mn("unsupported-variable-position",`The bound of the type variable \`${o.name}\` must be a ground type: \`${A(o.bound)}\` refers to a type variable`);let a=new Set;ve(o.bound,i,"bound",a)}let r=new Set;for(let o of Et(e))ve(o.type,i,null,r);let s=new Set;ve(e.result,i,null,s);for(let o of n)r.has(o.name)||(s.has(o.name)&&mn("unsolvable-type-variable",`The type variable \`${o.name}\` occurs only in the result of its signature, so it can never be solved. Write the ground type directly`),mn("unsolvable-type-variable",`The type variable \`${o.name}\` is quantified but never used`))}var Im={intersection:"cannot appear in an intersection. To constrain a type variable, declare a bound on it instead: `where T: number`",negation:"cannot appear in a negation",bound:"cannot appear in a bound"};function ve(e,n,t,i){if(typeof e!="string")switch(e.kind){case"variable":t!==null&&mn("unsupported-variable-position",`The type variable \`${e.name}\` ${Im[t]}`),n.has(e.name)||mn("unresolved-type-variable",`The type variable \`${e.name}\` is not quantified by a \`where\` clause`),i.add(e.name);return;case"signature":e.typeParams!==void 0&&e.typeParams.length>0&&mn("unsupported-variable-position","A `where` clause can only quantify a top-level signature (or one arm of an overload set), not a nested one. Parenthesize a nested clause: `((A) -> B where A, B)`");for(let r of Et(e))ve(r.type,n,t,i);ve(e.result,n,t,i);return;case"union":{let r=e.types.filter(s=>ze(s));r.length>1&&mn("unsupported-variable-position",`At most one arm of a union can refer to a type variable, but \`${A(e)}\` has ${r.length}. Nothing at a call site says which arm a value took, so neither variable could be solved`);for(let s of e.types)ve(s,n,t,i);return}case"intersection":for(let r of e.types)ve(r,n,"intersection",i);return;case"negation":ve(e.type,n,"negation",i);return;case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":ve(e.elements,n,t,i);return;case"tuple":for(let r of e.elements)ve(r.type,n,t,i);return;case"dictionary":ve(e.values,n,t,i);return;case"record":case"object":for(let r of Object.values(e.elements))ve(r,n,t,i);return;case"reference":if(e.args!==void 0)for(let r of e.args)ve(r,n,t,i);return;default:return}}var Ko;function Al(e){Ko=e}function U(){if(Ko===void 0)throw new Error("Type algebra not registered: import `./subtype.js` before using the type-variable solver");return Ko}function Rl(e,n){return n==="any"?!0:U().isSubtype(e,n)}function _l(e,n,t){let i=e.typeParams??[];if(i.length===0)return{bindings:Object.create(null),absorbed:new Set,unbound:new Set,matched:!0,failures:[]};let r={params:i,declared:new Map(i.map(f=>[f.name,f.bound])),lower:new Map,upper:new Map,lifted:new Set,matched:!0},s=Bl(e,n.length),o=s.map((f,p)=>{let h=n[p];return f===void 0||h===void 0||t?.skip?.(p)||t?.inferable?.(p)||!t?.lifted?.(p)||!Cl(f)?h:(r.lifted.add(f.name),Fl(h))});for(let f=0;f<s.length;f++){let p=s[f],h=o[f];p===void 0||h===void 0||t?.skip?.(f)||t?.inferable?.(f)||we(r,p,h,f,"lower",!0,!0)||(r.matched=!1)}for(let f=0;f<s.length;f++){let p=s[f],h=o[f];p===void 0||h===void 0||t?.skip?.(f)||t?.inferable?.(f)||we(r,p,h,f,"upper",!0,!0)}let a=Object.create(null),u=new Set,l=new Set;for(let f of i){let p=r.lower.get(f.name),h=Xo(r,f.name);if(p&&p.length>0){let y=Am(p);a[f.name]=y.type,y.absorbed&&u.add(f.name)}else h.length>0?a[f.name]=U().narrow(...h.map(y=>y.type)):(a[f.name]=f.bound??"unknown",f.bound===void 0&&l.add(f.name))}let c=[];for(let f of i){if(u.has(f.name))continue;let p=r.lifted.has(f.name),h=p?Xo(r,f.name).filter(ue=>!ue.declared):Xo(r,f.name);if(h.length===0)continue;let y=a[f.name],N=U().narrow(...h.map(ue=>ue.type)),D=N==="never"&&h.some(ue=>ue.type!=="never");if(!D&&U().isSubtype(y,N))continue;let R=p?void 0:f.bound,z=r.lower.get(f.name)??[],J=wm(z);if(R!==void 0&&!U().isSubtype(y,R)){let ue=z.find(Jt=>Jt.index!==void 0&&!U().isSubtype(Jt.type,R))??z[0];c.push({kind:"bound",variable:f.name,solution:y,expected:R,index:ue?.index,detail:`\`${f.name}\` is declared with bound \`${A(R)}\`, but was solved to \`${A(y)}\`${J}`});continue}let K=h.filter(ue=>ue.index!==void 0),$=h.find(ue=>!U().isSubtype(y,ue.type))??K[K.length-1]??h[0],ln=h.filter(ue=>ue!==$),wn=D&&ln.length>0?U().narrow(...ln.map(ue=>ue.type)):y;c.push({kind:"upper",variable:f.name,solution:y,expected:$.type,index:$.index,pin:wn,detail:D?`\`${f.name}\` has incompatible requirements (${h.map(ue=>`\`${A(ue.type)}\``).join(", ")})`:`\`${f.name}\` was solved to \`${A(y)}\`${J}; this position requires \`${f.name} <: ${A($.type)}\``})}return km(i,a,r,t?.resolver,c),{bindings:a,absorbed:u,unbound:l,matched:r.matched,failures:c}}function km(e,n,t,i,r){let s=i?.conformsTo;if(s!==void 0)for(let o of e){if(o.protocols===void 0||o.protocols.length===0)continue;let a=n[o.name];if(!(a===void 0||!Mm(a))){for(let u of o.protocols)if(!s(a,u)){r.push({kind:"protocol",variable:o.name,protocol:u,solution:a,expected:a,index:(t.lower.get(o.name)??[])[0]?.index,detail:`\`${o.name}\` was solved to \`${A(a)}\`, which does not conform to the \`${u}\` protocol`});break}}}}function Mm(e){return typeof e=="string"?e!=="unknown"&&e!=="any"&&e!=="value"&&e!=="expression":e.kind!=="union"&&e.kind!=="intersection"&&e.kind!=="variable"}function Pl(e,n,t){let i=_l(e,n,t);return!i.matched||i.failures.length>0?null:i.bindings}function Dl(e,n){if(n.typeParams!==void 0&&n.typeParams.length>0)return!1;let t=[...n.args??[],...n.optArgs??[],...n.variadicArg?[n.variadicArg]:[]].map(s=>s.type),i=Pl(e,t);if(i===null)return!1;let r=Q(e,i);return _n(r)?!1:U().isSubtype(r,n)}function Qo(e,n){if(typeof n!="object")return U().isSubtype(e,n);if(n.kind==="intersection")return n.types.every(s=>Qo(e,s));if(n.kind!=="signature"||n.typeParams===void 0||n.typeParams.length===0)return U().isSubtype(e,n);let t={...n};delete t.typeParams;let i={kind:"signature",typeParams:n.typeParams,args:[{type:t}],result:"nothing"},r=Pl(i,[e]);return r===null?!1:U().isSubtype(e,Q(t,r))}function Tt(e){if(!_n(e)||typeof e!="object")return e;if(e.kind==="intersection")return{...e,types:e.types.map(Tt)};if(e.kind!=="signature")return e;let n=Object.create(null);for(let t of e.typeParams??[])n[t.name]=t.bound??"unknown";return Q(e,n)}function Cl(e){return typeof e=="object"&&e.kind==="variable"}function Ol(e,n){let t=e.args?.length??0;if(n<t)return e.args[n].type;let i=e.optArgs?.length??0;return n<t+i?e.optArgs[n-t].type:e.variadicArg?.type}function Bl(e,n){let t=[];for(let i=0;i<n;i++)t.push(Ol(e,i));return t}function Yo(e,n,t,i,r){if(ze(t))return;let s=e.get(n);s?s.push({type:t,index:i,top:r}):e.set(n,[{type:t,index:i,top:r}])}function Xo(e,n){let t=e.upper.get(n)??[],i=e.declared.get(n);return i===void 0?t:[...t,{type:i,declared:!0}]}function wm(e){let n=e.map(t=>t.index).filter(t=>t!==void 0).map(t=>t+1);return n.length===0?"":n.length===1?` (from argument ${n[0]})`:` (from arguments ${n.join(", ")})`}function Am(e){let n=e.some(i=>i.top===!0&&(i.type==="unknown"||i.type==="any"));if(e.some(i=>i.type==="unknown"))return{type:"unknown",absorbed:n};if(e.some(i=>i.type==="any"))return{type:"any",absorbed:n};let t=e.filter(i=>i.type!=="never");return t.length===0?{type:"never",absorbed:!1}:{type:U().widen(...t.map(i=>i.type)),absorbed:!1}}function si(e,n=!0){return ze(e)?Me(e,n,!1):e}function Me(e,n,t){if(typeof e=="string"||!ze(e))return e;switch(e.kind){case"variable":return n?"any":"never";case"signature":{let i={...e,result:Me(e.result,n,t)};return e.args&&(i.args=e.args.map(r=>({...r,type:Me(r.type,!n,t)}))),e.optArgs&&(i.optArgs=e.optArgs.map(r=>({...r,type:Me(r.type,!n,t)}))),e.variadicArg&&(i.variadicArg={...e.variadicArg,type:Me(e.variadicArg.type,!n,t)}),delete i.typeParams,i}case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":return{...e,elements:Me(e.elements,n,t)};case"tuple":return{...e,elements:e.elements.map(i=>({...i,type:Me(i.type,n,t)}))};case"dictionary":return{...e,values:Me(e.values,n,t)};case"record":{let i={};for(let[r,s]of Object.entries(e.elements))i[r]=Me(s,n,t);return{...e,elements:i}}case"object":{if(t&&Object.values(e.elements).some(r=>ze(r)))return n?"any":"never";let i={};for(let[r,s]of Object.entries(e.elements))i[r]=Me(s,n,t);return{...e,elements:i}}case"union":case"intersection":return{...e,types:e.types.map(i=>Me(i,n,t))};case"negation":return{...e,type:Me(e.type,!n,t)};case"reference":{if(e.args===void 0)return e;let i=Ne(e);return t&&e.args.some((r,s)=>ze(r)&&xt(e,s)==="inout")?n?"any":"never":Zo(e,e.args.map((r,s)=>Me(r,i.typeParams?.[s]?.variance==="in"?!n:n,t)))}default:return e}}function oi(e){if(typeof e=="string")return e==="range"?"integer":e==="string"?"character":e==="collection"||e==="indexed_collection"||e==="list"||e==="set"||e==="tuple"||e==="dictionary"||e==="record"?"unknown":void 0;if(e.kind==="collection"||e.kind==="indexed_collection")return e.elements;if(e.kind==="list"){let n=e.dimensions;return n&&n.length>1?{kind:"list",elements:e.elements,dimensions:n.slice(1)}:e.elements}if(e.kind==="set"||e.kind==="broadcastable")return e.elements;if(e.kind==="tuple")return U().widen(...e.elements.map(n=>n.type));if(e.kind==="dictionary")return{kind:"tuple",elements:[{type:"string"},{type:e.values}]};if(e.kind==="record")return{kind:"tuple",elements:[{type:"string"},{type:U().widen(...Object.values(e.elements))}]}}function Fl(e){if(typeof e=="object"&&e.kind==="union")return e.types.every(t=>Rm(t))?U().widen(...e.types.map(t=>Fl(t))):e;if(e==="list"||e==="indexed_collection")return"unknown";if(e==="range")return"integer";if(typeof e!="object"||!Ll.has(e.kind))return e;let n=oi(e);if(n===void 0)return e;if(e.kind==="list")for(;typeof n=="object"&&n.kind==="list";){let t=oi(n);if(t===void 0)break;n=t}return n}function Rm(e){return e==="list"||e==="indexed_collection"||e==="range"?!0:typeof e=="object"&&Ll.has(e.kind)}var Ll=new Set(["list","indexed_collection","broadcastable"]),Un=null;function we(e,n,t,i,r,s,o){if(Cl(n))return r==="lower"&&s?Yo(e.lower,n.name,t,i,o):r==="upper"&&!s&&Yo(e.upper,n.name,t,i,o),!0;if(!ze(n))return r!=="lower"?!0:s?U().isSubtype(t,n):U().isSubtype(n,t);if(typeof t=="object"&&t.kind==="union"){let a=!0;for(let u of t.types)we(e,n,u,i,r,s,o)||(a=!1);return a}if(typeof n=="string")return!0;switch(t==="range"&&(t=ls),t==="string"&&(n.kind==="list"||n.kind==="set"||n.kind==="collection"||n.kind==="indexed_collection")&&(t=cs),n.kind){case"signature":{if(typeof t!="object"||t.kind!=="signature")return r!=="lower"||!s?!0:U().isSubtype(t,si(n,!0));if(t.typeParams!==void 0&&t.typeParams.length>0)return!0;let a=we(e,n.result,t.result,i,r,s,!1),u=Et(n),l=Et(t),c=Math.min(u.length,l.length);for(let f=0;f<c;f++)we(e,u[f].type,l[f].type,i,r,!s,!1)||(a=!1);return a}case"broadcastable":{let a=typeof t=="object"&&(t.kind==="broadcastable"||t.kind==="list"||t.kind==="indexed_collection")||t==="list"||t==="indexed_collection"?oi(t):t;return we(e,n.elements,a,i,r,s,!1)}case"tuple":{if(r==="lower"&&s&&!U().isSubtype(t,si(n,!0)))return!1;if(typeof t!="object"||t.kind!=="tuple")return!0;if(t.elements.length!==n.elements.length)return r!=="lower";let a=!0;for(let u=0;u<n.elements.length;u++)we(e,n.elements[u].type,t.elements[u].type,i,r,s,!1)||(a=!1);return a}case"dictionary":return r==="lower"&&s&&!U().isSubtype(t,si(n,!0))?!1:typeof t!="object"||t.kind!=="dictionary"?!0:we(e,n.values,t.values,i,r,s,!1);case"record":case"object":{if(r==="lower"&&s&&!U().isSubtype(t,si(n,!0)))return!1;if(typeof t!="object"||t.kind!==n.kind)return!0;let a=!0;for(let[u,l]of Object.entries(n.elements)){let c=t.elements[u];c!==void 0&&(we(e,l,c,i,r,s,!1)||(a=!1))}return a}case"list":case"set":case"collection":case"indexed_collection":{if(r==="lower"&&s&&!U().isSubtype(t,si(n,!0)))return!1;let a=oi(t);return a===void 0?!0:we(e,n.elements,a,i,r,s,!1)}case"reference":{if(n.alias===!0&&n.def!==void 0){Un===null&&(Un=new Set);let u=Ne(n);if(Un.has(u))return!0;Un.add(u);try{let l=gs(n);if(l!==void 0)return we(e,l,t,i,r,s,o)}finally{Un.delete(u),Un.size===0&&(Un=null)}}if(n.args===void 0)return!0;if(typeof t!="object"||t.kind!=="reference"||t.name!==n.name||t.args===void 0||t.args.length!==n.args.length)return r!=="lower";let a=!0;for(let u=0;u<n.args.length;u++)we(e,n.args[u],t.args[u],i,r,s,!1)||(a=!1);return a}case"union":{if(r!=="lower"||!s)return!0;let a=[];for(let u of n.types){if(ze(u)){a.push(u);continue}if(U().isSubtype(t,u)){for(let l of Pn(n))Yo(e.lower,l,"never",i,!1);return!0}}return a.length===1?we(e,a[0],t,i,r,s,o):!0}default:return!0}}function _m(e){return e==="\u211D"||e==="\u2124"||e==="\u211A"||e==="\u2102"||e==="\u2115"}var ai=class{input;pos=0;line=1;column=1;tokens=[];tolerant;constructor(n,t){this.input=n,this.tolerant=t?.tolerant??!1}saveState(){return{pos:this.pos,line:this.line,column:this.column,tokens:[...this.tokens]}}restoreState(n){this.pos=n.pos,this.line=n.line,this.column=n.column,this.tokens=n.tokens}error(n){throw new Error(`Lexer error at line ${this.line}, column ${this.column}: ${n}`)}peek(n=0){let t=this.pos+n;return t<this.input.length?this.input[t]:""}advance(){let n=this.input[this.pos++];return n===`
4
4
  `?(this.line++,this.column=1):this.column++,n}match(n){if(this.input.slice(this.pos,this.pos+n.length)===n){for(let t=0;t<n.length;t++)this.advance();return!0}return!1}isEOF(){return this.pos>=this.input.length}skipTrivia(){for(;!this.isEOF();){if(/\s/.test(this.peek())){this.advance();continue}if(this.peek()==="/"&&this.peek(1)==="/"){for(;!this.isEOF()&&!/[\n\r\u2028\u2029]/.test(this.peek());)this.advance();continue}if(this.peek()==="/"&&this.peek(1)==="*"){this.skipBlockComment();continue}break}}skipBlockComment(){this.advance(),this.advance();let n=1;for(;n>0&&!this.isEOF();)this.peek()==="/"&&this.peek(1)==="*"?(n++,this.advance(),this.advance()):this.peek()==="*"&&this.peek(1)==="/"?(n--,this.advance(),this.advance()):this.advance();n>0&&!this.tolerant&&this.error("Unterminated comment")}readIdentifier(){let n="";for(;!this.isEOF()&&/[a-zA-Z0-9_]/.test(this.peek());)n+=this.advance();return n}readVerbatimString(){if(!this.match("`"))return"";let n="";for(;!this.isEOF()&&this.peek()!=="`";)this.match("\\`")?n+="`":this.match("\\\\")?n+="\\":n+=this.advance();return this.isEOF()&&this.error("Unterminated verbatim string"),this.advance(),n}readStringLiteral(){let n=this.advance(),t="";for(;!this.isEOF()&&this.peek()!==n;)this.match("\\"+n)?t+=n:this.match("\\\\")?t+="\\":t+=this.advance();return this.isEOF()&&this.error("Unterminated string literal"),this.advance(),t}readNumber(){let n="";if((this.peek()==="-"||this.peek()==="+")&&(n+=this.advance()),this.match("0x")||this.match("0X")){for(n+="x";!this.isEOF()&&/[0-9a-fA-F]/.test(this.peek());)n+=this.advance();return"0"+n}if(this.match("0b")||this.match("0B")){for(n+="b";!this.isEOF()&&/[01]/.test(this.peek());)n+=this.advance();return"0"+n}for(;!this.isEOF()&&/[0-9]/.test(this.peek());)n+=this.advance();if(this.peek()==="."&&/[0-9]/.test(this.peek(1)))for(n+=this.advance();!this.isEOF()&&/[0-9]/.test(this.peek());)n+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(n+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(n+=this.advance());!this.isEOF()&&/[0-9]/.test(this.peek());)n+=this.advance();return n}createToken(n,t){return{type:n,value:t,position:this.pos-t.length,line:this.line,column:this.column-t.length}}nextToken(){if(this.skipTrivia(),this.isEOF())return this.createToken("EOF","");let n=this.pos,t=this.peek();if(this.match("->"))return this.createToken("->","->");if(this.peek()==="<"&&this.input.startsWith("<..",this.pos)&&this.pos>0&&/[0-9.∞o+\-]/.test(this.input[this.pos-1]))return this.match("<.."),this.createToken("<..","<..");if(this.input.startsWith("..<",this.pos)&&this.pos+3<this.input.length&&!/\s/.test(this.input[this.pos+3]))return this.match("..<"),this.createToken("..<","..<");if(this.match(".."))return this.createToken("..","..");if(this.match("+\u221E")||this.match("+oo"))return this.createToken("PLUS_INFINITY",this.input.slice(n,this.pos));if(this.match("-\u221E")||this.match("-oo"))return this.createToken("MINUS_INFINITY",this.input.slice(n,this.pos));if(this.match("~\u221E")||this.match("~oo"))return this.createToken("COMPLEX_INFINITY",this.input.slice(n,this.pos));if(this.match("+infinity")||this.match("+Infinity"))return this.createToken("PLUS_INFINITY",this.input.slice(n,this.pos));if(this.match("-infinity")||this.match("-Infinity"))return this.createToken("MINUS_INFINITY",this.input.slice(n,this.pos));if(_m(t)&&!/[a-zA-Z0-9_]/.test(this.peek(1)))return this.advance(),this.createToken("IDENTIFIER",t);if(/[a-zA-Z_]/.test(t)){let i=this.readIdentifier();switch(i){case"true":return this.createToken("TRUE",i);case"false":return this.createToken("FALSE",i);case"NaN":return this.createToken("NAN",i);case"Infinity":case"oo":return this.createToken("INFINITY",i);default:return this.createToken("IDENTIFIER",i)}}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 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 i=this.readNumber();return this.peek()==="x"&&/[0-9]/.test(this.peek(1)),this.createToken("NUMBER_LITERAL",i)}if(t==="\u221E")return this.advance(),this.createToken("INFINITY","\u221E");if(this.tolerant)return this.createToken("EOF","");this.error(`Unexpected character: ${t}`)}tokenize(){let n=[];for(;!this.isEOF();){let t=this.nextToken();if(t&&(n.push(t),t.type==="EOF"))break}return n}peekToken(){if(this.tokens.length===0){let n=this.nextToken();n&&this.tokens.push(n)}return this.tokens[0]||this.createToken("EOF","")}consumeToken(){if(this.tokens.length===0){let n=this.nextToken();if(n)return n}return this.tokens.shift()||this.createToken("EOF","")}matchToken(n){return this.peekToken().type===n?(this.consumeToken(),!0):!1}expectToken(n){let t=this.consumeToken();return t.type!==n&&this.error(`Expected ${n}, got ${t.type}`),t}};var Pm=Object.assign(Object.create(null),{finite_number:"complex",finite_complex:"complex",finite_real:"real",finite_rational:"rational",finite_integer:"integer"}),Dm=Object.assign(Object.create(null),{\u211D:"real",\u2124:"integer",\u211A:"rational",\u2102:"complex"});function Vl(e){return Dm[e]??Pm[e]??e}var ys=class{lexer;typeResolver;current;allowTrailing;_end=0;_typeVarScopes=[];allowWhere;allowObjectType;blockFollows;_sawWhere=!1;_sawForwardRef=!1;constructor(n,t){this.allowTrailing=t?.allowTrailing??!1,this.allowWhere=t?.allowWhere??!0,this.allowObjectType=t?.allowObjectType??!1,this.blockFollows=t?.blockFollows??!1,t?.typeVars!==void 0&&t.typeVars.length>0&&this._typeVarScopes.push(new Set(t.typeVars.map(i=>i.name))),this.lexer=new ai(n,{tolerant:this.allowTrailing}),this.typeResolver=t?.typeResolver??{forward:()=>{},resolve:()=>{},get names(){return[]}},this.current=this.lexer.consumeToken()}get endOffset(){return this._end}get sawWhereClause(){return this._sawWhere}get sawForwardRef(){return this._sawForwardRef}error(n,t){this.errorAtToken(this.current,n,t)}errorAtToken(n,t,i,r){let s=this.lexer.input;this.allowTrailing&&(s=s.slice(0,n.position+n.value.length));let a=s.split(`
5
5
  `)[n.line-1]||s,u=n.column,l=" ".repeat(Math.max(0,u-1))+"^",c=["","Invalid type",`| ${a}`,`| ${l}`,"|",`| ${t}`];i&&c.push(`| ${i}`),c.push("");let f=new Error(c.join(`
6
6
  `));throw f.position=n.position,f.rawMessage=t,r!==void 0&&(f.code=r),f}advance(){let n=this.current;return this._end=n.position+n.value.length,this.current=this.lexer.consumeToken(),n}match(n){return this.current.type===n?(this.advance(),!0):!1}expect(n){return this.current.type!==n&&this.error(`Expected ${n}, got ${this.current.type}`),this.advance()}createNode(n,t={}){return{kind:n,position:this.current.position,line:this.current.line,column:this.current.column,...t}}parseType(){this.checkForNakedFunctionSignature();let n=this.allowWhere?this.parseConstrainedType():this.parseUnionType();if(n||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==="IDENTIFIER"&&os(this.current.value))this.error("Function signatures must be enclosed in parentheses","For example `(real) random -> real`");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 n}parseTypePrefix(){this.checkForNakedFunctionSignature();let n=this.allowWhere?this.parseConstrainedType():this.parseUnionType();return n||this.error("Expected a type"),n}checkForNakedFunctionSignature(){if(this.current.type==="IDENTIFIER"){let n=this.lexer.saveState(),t=this.current;try{let i=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(n),this.current=t,this.errorAtToken(i,"Function signatures must be enclosed in parentheses","For example `(z: string*) -> boolean`"))}this.lexer.restoreState(n),this.current=t}catch(i){if(this.lexer.restoreState(n),this.current=t,i instanceof Error&&i.message.includes("Function signatures must be enclosed"))throw i}}}parseUnionType(){let n=this.parseIntersectionType();if(!n)return;let t=[n];for(;this.match("|");){let r=this.parseIntersectionType();r||this.error("Expected type after |"),t.push(r)}if(t.length===1)return t[0];let i=[];for(let r of t)r.kind==="union"?i.push(...r.types):i.push(r);return this.createNode("union",{types:i})}parseIntersectionType(){let n=this.parsePrimaryType();if(!n)return;let t=[n];for(;this.match("&");){let i=this.parsePrimaryType();i||this.error("Expected type after &"),t.push(i)}return t.length===1?t[0]:this.createNode("intersection",{types:t})}isTypeVariable(n){for(let t=this._typeVarScopes.length-1;t>=0;t--)if(this._typeVarScopes[t].has(n))return!0;return!1}parseConstrainedType(){let n=this.scanWhereClauseNames();n!==null&&(this._sawWhere=!0,this._typeVarScopes.push(new Set(n)));try{let t=this.parseUnionType();if(!t)return;if(this.current.type==="IDENTIFIER"&&this.current.value==="where"){let i=this.parseWhereClause();return this.createNode("constrained",{typeParams:i,body:t})}return t}finally{n!==null&&this._typeVarScopes.pop()}}scanWhereClauseNames(){let n=this.lexer.input,t=this.current.position;if(!n.includes("where",t))return null;let i=new ai(n.slice(t),{tolerant:!0}),r=0,s=i.consumeToken();for(;s.type!=="EOF";){switch(s.type){case"(":case"<":case"[":case"{":r+=1;break;case")":case">":case"]":case"}":if(r-=1,r<0)return null;break;case",":if(r===0)return null;break;case"IDENTIFIER":if(r===0&&s.value==="where"){let o=[];for(s=i.consumeToken();;){if(s.type!=="IDENTIFIER")return o;o.push(s.value);let a=0;for(s=i.consumeToken();s.type!=="EOF";){if(s.type==="("||s.type==="<"||s.type==="["||s.type==="{")a+=1;else if(s.type===")"||s.type===">"||s.type==="]"||s.type==="}"){if(a-=1,a<0)return o}else if(s.type===","&&a===0)break;s=i.consumeToken()}if(s.type==="EOF")return o;s=i.consumeToken()}}break}s=i.consumeToken()}return null}parseWhereClause(){this._sawWhere=!0,this.advance();let n=new Set,t=[];do{this.current.type!=="IDENTIFIER"&&this.error("Expected a type variable name after `where`","For example `(T) -> T where T`");let i=this.current,r=this.advance().value;r==="where"&&this.errorAtToken(i,"The type name `where` is reserved"),n.has(r)&&this.errorAtToken(i,`The type variable \`${r}\` is declared more than once`),n.add(r);let s;this.match(":")&&(s=this.parseUnionType(),s||this.error(`Expected a type after the bound of \`${r}\``,"For example `(T) -> T where T: number`"));let o;if(this.current.type==="IDENTIFIER"&&this.current.value==="is"){this.advance(),o=[];do this.current.type!=="IDENTIFIER"&&this.error("Expected a protocol name after `is`","For example `(T) -> T where T: collection is Hashable`"),o.push(this.advance().value);while(this.match("&"))}t.push(this.createNode("type_param",{name:r,bound:s,protocols:o}))}while(this.match(","));return t}checkForLegacyForall(){let n=this.lexer.saveState(),t=this.current,i=this.current,r=!1;try{if(this.advance(),this.current.type==="IDENTIFIER"){this.advance();let s=this.current.type;r=s===":"||s===","||s==="."}}finally{this.lexer.restoreState(n),this.current=t}r&&this.errorAtToken(i,"The `forall T. \u2026` prefix syntax was replaced by a trailing `where` clause","For example `(T) -> T where T: number`")}parsePrimaryType(){if(this.current.type==="IDENTIFIER"){if(this.isTypeVariable(this.current.value)){let n=this.advance().value;return this.createNode("type_variable",{name:n})}this.current.value==="forall"&&this.checkForLegacyForall()}if(this.match("!")){let n=this.parsePrimaryType();return n||this.error("Expected type after !"),this.createNode("negation",{type:n})}if(this.current.type==="("){let n=this.parseFunctionSignature();if(n)return n;if(this.match("(")){let t=this.parseConstrainedType();if(t||this.error("Expected type after ("),this.current.type===","){let i=[this.createNode("named_element",{name:void 0,type:t})];for(;this.match(",");){let r=this.parseUnionType();r||this.error("Expected type after ,"),i.push(this.createNode("named_element",{name:void 0,type:r}))}return this.expect(")"),this.createNode("tuple",{elements:i})}return this.expect(")"),this.createNode("group",{type:t})}}return this.parseListType()||this.parseTupleType()||this.parseRecordType()||this.parseObjectType()||this.parseDictionaryType()||this.parseSetType()||this.parseBroadcastableType()||this.parseCallbackType()||this.parseCollectionType()||this.parseExpressionType()||this.parseSymbolType()||this.parseNumericType()||this.parseSignedInfinityName()||this.parsePrimitiveType()||this.parseValue()||this.parseTypeReference()}parseSignedInfinityName(){if(!(this.current.type!=="IDENTIFIER"||this.current.value!=="signed_infinity"&&this.current.value!=="non_finite_number"))return this.advance(),this.createNode("union",{types:[this.createNode("value",{value:1/0,valueType:"infinity"}),this.createNode("value",{value:-1/0,valueType:"infinity"})]})}isFunctionSignature(){let n=this.lexer.saveState(),t=this.current;this.advance();let i=1;for(;i>0&&this.current.type!=="EOF";)this.current.type==="("?i++:this.current.type===")"&&i--,this.advance();for(;this.current.type==="IDENTIFIER"||this.current.type==="!";)this.advance();let r=this.current.type==="->";return this.lexer.restoreState(n),this.current=t,r}parseEffectSpecifiers(){if(this.current.type!=="IDENTIFIER"&&this.current.type!=="!")return;let n=!1,t=!1,i=[];for(;this.current.type==="IDENTIFIER"||this.current.type==="!";){this.current.type==="!"&&this.error("The `!` effect complement form is reserved and not yet supported","Enumerate the effect labels instead, for example `(real) console scope -> real`");let r=this.current,s=r.value;if(this.advance(),s==="pure"){(i.length>0||n||t)&&this.errorAtToken(r,"`pure` cannot be combined with other effect labels",'Use `pure` alone to mean "no effects", or omit it entirely'),t=!0;continue}if(t&&this.errorAtToken(r,"`pure` cannot be combined with other effect labels",'Use `pure` alone to mean "no effects", or omit it entirely'),s==="any"){(i.length>0||n)&&this.errorAtToken(r,"`any` cannot be combined with other effect labels",'Use `any` alone to mean "unknown effects"'),n=!0;continue}n&&this.errorAtToken(r,"`any` cannot be combined with other effect labels",'Use `any` alone to mean "unknown effects"'),os(s)||this.errorAtToken(r,`Unknown effect label \`${s}\``,`The effect labels are ${Xt.join(", ")}`),i.includes(s)&&this.errorAtToken(r,`Duplicate effect label \`${s}\``),i.push(s)}return t?[]:n?"any":i.sort()}parseFunctionSignature(){if(this.current.type!=="("||!this.isFunctionSignature())return;let n=[],t=[];if(this.advance(),!this.match(")")){do{let c=this.current,f=this.parseArgument();f||this.error("Expected argument"),n.push(f),t.push(c)}while(this.match(","));this.expect(")")}let i=this.parseEffectSpecifiers();this.expect("->");let r=this.parseUnionType();r||this.error("Expected return type after ->");let s=n.some(c=>c.modifier==="optional"),o=n.some(c=>c.modifier==="variadic_zero"||c.modifier==="variadic_one"),a=n.filter(c=>c.modifier==="variadic_zero"||c.modifier==="variadic_one").length;s&&o&&this.error(ii),a>1&&this.error("There can be only one variadic argument");let u=!1,l=!1;for(let c=0;c<n.length;c++){let f=n[c].modifier;l&&this.errorAtToken(t[c],"A variadic argument must be the last argument"),f==="variadic_zero"||f==="variadic_one"?l=!0:f==="optional"?u=!0:u&&this.errorAtToken(t[c],"A required argument cannot follow an optional argument")}return this.createNode("function_signature",{arguments:n,effects:i,returnType:r})}parseArgument(){let n=this.parseNamedElement();if(!n)return;let t;return this.match("?")?t="optional":this.match("*")?t="variadic_zero":this.match("+")&&(t="variadic_one"),this.createNode("argument",{element:n,modifier:t})}parseNamedElement(){let n;if(this.current.type==="IDENTIFIER"||this.current.type==="VERBATIM_STRING"){let i=this.current;if(this.lexer.peekToken().type===":"){n=i.value,this.advance(),this.advance();let s=this.parseUnionType();return s?this.createNode("named_element",{name:n,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 n=this.current,i=this.lexer.peekToken().type==="<";switch(n.value){case"list":return i?(this.advance(),this.parseListTypeImpl()):void 0;case"vector":return i?(this.advance(),this.parseVectorType()):(this.advance(),this.createNode("vector",{elementType:this.createNode("primitive",{name:"number"}),size:void 0}));case"matrix":return i?(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 i?(this.advance(),this.parseTensorType()):(this.advance(),this.createNode("list",{elementType:this.createNode("primitive",{name:"number"}),dimensions:void 0}));default:return}}}parseListTypeImpl(){let n=this.createNode("primitive",{name:"unknown"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let i=this.parseUnionType();i&&(n=i,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}return this.createNode("list",{elementType:n,dimensions:t})}parseVectorType(){let n=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(this.current.type==="NUMBER_LITERAL")t=parseInt(this.advance().value);else{let i=this.parseUnionType();i&&(n=i,this.match("^")&&(this.current.type==="NUMBER_LITERAL"?t=parseInt(this.advance().value):this.error("Expected number after ^")))}this.expect(">")}return this.createNode("vector",{elementType:n,size:t})}parseMatrixType(){let n=this.createNode("primitive",{name:"number"}),t;if(this.match("<")){if(t=this.parseDimensions(),!t){let i=this.parseUnionType();i&&(n=i,this.match("^")&&(t=this.parseCaretDimensions()))}this.expect(">")}else t=[this.createNode("dimension",{size:null}),this.createNode("dimension",{size:null})];return this.createNode("matrix",{elementType:n,dimensions:t})}parseTensorType(){let n=this.createNode("primitive",{name:"number"});if(this.match("<")){let t=this.parseUnionType();t&&(n=t),this.expect(">")}return this.createNode("tensor",{elementType:n})}parseDimensions(){let n=this.parseDimension();if(!n)return;let t=[n];for(;;){let i=this.current;if(i.type==="IDENTIFIER"&&/^(x\d+)+$/.test(i.value)){this.advance();for(let r of i.value.match(/x(\d+)/g))t.push(this.createNode("dimension",{size:parseInt(r.slice(1))}))}else if(i.type==="IDENTIFIER"&&i.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 n=parseInt(this.advance().value);return this.createNode("dimension",{size:n})}}parseCaretDimensions(){let n=this.match("("),t=this.parseDimensions();return n&&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 i=this.parseNamedElement();i||this.error("Expected tuple element"),t.push(i);let r=i.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})}}startsFieldList(){if(this.current.type!=="{")return!1;let n=this.current.position,t=this.lexer.saveState(),i=this.current,r=this._end,s;try{this.advance();let o=this.current;o.type==="}"?s=!0:o.type!=="IDENTIFIER"&&o.type!=="VERBATIM_STRING"?s=!1:(this.advance(),s=this.current.type===":")}finally{this.lexer.restoreState(t),this.current=i,this._end=r}return s?!this.blockFollows||this.blockFollowsFieldList(n):!1}blockFollowsFieldList(n){let t=this.lexer.input,i=0,r=n;for(;r<t.length;r++){let o=t[r];if(o==='"'||o==="`"){for(r+=1;r<t.length&&t[r]!==o;)r+=t[r]==="\\"?2:1;if(r>=t.length)return!1;continue}if(o==="{")i+=1;else if(o==="}"&&(i-=1,i===0))break}if(r>=t.length)return!1;let s=r+1;for(;s<t.length&&/\s/.test(t[s]);)s+=1;return s>=t.length?!1:t[s]==="{"||/^where\b/.test(t.slice(s))}parseFieldList(n){let t=[];if(this.expect("{"),this.current.type!=="}")do{let i=this.parseRecordEntry();i||this.error(`Expected ${n} field`),t.push(i)}while(this.match(","));return this.expect("}"),t}parseRecordType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="record"){let n=this.current;this.advance();let t=[];return this.startsFieldList()?t=this.parseFieldList("record"):this.current.type==="<"&&this.errorAtToken(n,"A record type is written with braces: `record{key: type, \u2026}`","For example `record{x: integer, y: integer}`","record-type-angle-brackets"),this.createNode("record",{entries:t})}}parseObjectType(){if(this.current.type!=="IDENTIFIER"||this.current.value!=="object")return;let n=this.current;this.advance();let t=[];return this.startsFieldList()?(t=this.parseFieldList("object"),t.length>0&&!this.allowObjectType&&this.errorAtToken(n,"An `object{\u2026}` type may only be the definition of a named type","Object types are nominal: declare one with `type Person = object{\u2026}` (not `type alias`), then refer to `Person` here","object-type-not-inline")):this.current.type==="<"&&this.errorAtToken(n,"An object type is written with braces: `object{field: type, \u2026}`","For example `type Person = object{name: string, age: integer}`","object-type-angle-brackets"),this.createNode("object",{entries:t})}parseRecordEntry(){let n;if(this.current.type==="IDENTIFIER")n=this.advance().value;else if(this.current.type==="VERBATIM_STRING")n=this.advance().value;else return;this.expect(":");let t=this.parseUnionType();return t||this.error("Expected value type"),this.createNode("record_entry",{key:n,valueType:t})}parseDictionaryType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="dictionary"){this.advance();let n=this.createNode("primitive",{name:"unknown"});if(this.match("<")){let t=this.parseUnionType();t&&(n=t),this.expect(">")}return this.createNode("dictionary",{valueType:n})}}parseSetType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="set"){if(this.lexer.peekToken().type!=="<")return;this.advance();let n=this.createNode("primitive",{name:"unknown"});if(this.match("<")){let t=this.parseUnionType();t&&(n=t),this.expect(">")}return this.createNode("set",{elementType:n})}}parseBroadcastableType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="broadcastable"){this.advance();let n=this.createNode("primitive",{name:"any"});if(this.match("<")){let t=this.parseUnionType();t&&(n=t),this.expect(">")}return this.createNode("broadcastable",{elementType:n})}}parseCallbackType(){this.current.type!=="IDENTIFIER"||this.current.value!=="callback"||this.lexer.peekToken().type==="<"&&this.error("The `callback<\u2026>` constructor was retired: write the arrow directly (e.g. `(T) any -> boolean`) \u2014 callback operands are admitted by compatibility, not subtyping")}parseCollectionType(){if(this.current.type==="IDENTIFIER"){let n=this.current.value==="indexed_collection",t=this.current.value==="collection";if(n||t){this.advance();let i=this.createNode("primitive",{name:"unknown"});if(this.match("<")){let r=this.parseUnionType();r&&(i=r),this.expect(">")}return this.createNode("collection",{elementType:i,indexed:n})}}}parseExpressionType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="expression"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let i=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("expression",{operator:i})}}parseSymbolType(){if(this.current.type==="IDENTIFIER"&&this.current.value==="symbol"){if(this.lexer.peekToken().type!=="<")return;this.advance(),this.expect("<");let i=this.expect("IDENTIFIER").value;return this.expect(">"),this.createNode("symbol",{name:i})}}parseNumericType(){if(this.current.type==="IDENTIFIER"){let n=["real","rational","integer"];if(this.current.value==="\u2115")return this.advance(),this.createNode("numeric",{baseType:"integer",lowerBound:this.createNode("value",{value:0,valueType:"number"})});let t=Vl(this.current.value);if(n.includes(t)){this.advance();let i=t;if(this.match("<")){let r=this.parseValue(),s=!1,o=!1;if(this.match("<..")){s=!0;let c=this.current;c.type==="<"&&(this.advance(),this.current.position!==c.position+1&&this.error("Invalid numeric type","The `<` marker must touch its bound"),o=!0)}else this.match("..<")?o=!0:this.expect("..");let a=this.parseValue();this.expect(">"),s&&r===void 0&&this.error("Invalid numeric type","An open lower bound needs a bound value"),o&&a===void 0&&this.error("Invalid numeric type","An open upper bound needs a bound value");let u=r?.value??-1/0,l=a?.value??1/0;(Number.isNaN(u)||Number.isNaN(l))&&this.error("Invalid numeric type","Lower and upper bounds must be valid numbers");for(let c of[r,a])c!==void 0&&c.valueType!=="number"&&c.valueType!=="infinity"&&this.error("Invalid numeric type","Lower and upper bounds must be valid numbers");return u>l&&this.error(`Invalid range: ${u}..${l}`,"The lower bound must be less than the upper bound"),(s&&!Number.isFinite(u)||o&&!Number.isFinite(l))&&this.error("Invalid numeric type","An open bound must be a finite number"),this.createNode("numeric",{baseType:i,lowerBound:r,upperBound:a,...s?{lowerOpen:!0}:{},...o?{upperOpen:!0}:{}})}return this.createNode("numeric",{baseType:i})}}}parsePrimitiveType(){if(this.current.type==="IDENTIFIER"){let n=Vl(this.current.value);if(Gn.has(n)){if(n==="type"){let t=this.lexer.saveState(),i=this.current;this.advance();let r=this.current.type==="IDENTIFIER";if(this.lexer.restoreState(t),this.current=i,r)return}return this.advance(),this.createNode("primitive",{name:n})}}}parseValue(){let n,t;switch(this.current.type){case"STRING_LITERAL":n=this.advance().value,t="string";break;case"NUMBER_LITERAL":n=parseFloat(this.advance().value),t="number";break;case"TRUE":this.advance(),n=!0,t="boolean";break;case"FALSE":this.advance(),n=!1,t="boolean";break;case"NAN":this.advance(),n=NaN,t="nan";break;case"INFINITY":case"PLUS_INFINITY":this.advance(),n=1/0,t="infinity";break;case"MINUS_INFINITY":this.advance(),n=-1/0,t="infinity";break;case"COMPLEX_INFINITY":this.advance(),n=Nl,t="complex_infinity";break;default:return}return this.createNode("value",{value:n,valueType:t})}parseTypeReference(){let n=this.current.type==="IDENTIFIER"&&this.current.value==="type";if(n&&(this._sawForwardRef=!0,this.advance()),this.current.type==="IDENTIFIER"){let t=this.current,i=this.advance().value,r=this.parseTypeArguments();return this.typeResolver.resolve(i)?this.createNode("type_reference",{name:i,isForward:n,args:r}):n&&this.typeResolver.forward(i)?this.createNode("type_reference",{name:i,isForward:!0,args:r}):(n||this.errorAtToken(t,`Unknown type "${i}"`,"Syntax error. The type was not recognized."),this.createNode("type_reference",{name:i,isForward:n,args:r}))}}parseTypeArguments(){if(this.current.type!=="<")return;if(this.advance(),this.current.type===">")return this.advance(),[];let n=[];do{let t=this.parseUnionType();t||this.error("Expected a type argument"),n.push(t)}while(this.match(","));return this.current.type!==">"&&this.error("Expected `>` to close the type arguments","For example `Pair<integer>`"),this.advance(),n}};function Jl(e,n){switch(e.kind){case"function_signature":return n.visitFunctionSignature(e);case"constrained":return n.visitConstrainedType(e);case"type_variable":return n.visitTypeVariable(e);case"union":return n.visitUnionType(e);case"intersection":return n.visitIntersectionType(e);case"negation":return n.visitNegationType(e);case"group":return n.visitGroupType(e);case"list":return n.visitListType(e);case"vector":return n.visitVectorType(e);case"matrix":return n.visitMatrixType(e);case"tensor":return n.visitTensorType(e);case"tuple":return n.visitTupleType(e);case"record":return n.visitRecordType(e);case"object":return n.visitObjectType(e);case"dictionary":return n.visitDictionaryType(e);case"set":return n.visitSetType(e);case"broadcastable":return n.visitBroadcastableType(e);case"collection":return n.visitCollectionType(e);case"expression":return n.visitExpressionType(e);case"symbol":return n.visitSymbolType(e);case"numeric":return n.visitNumericType(e);case"primitive":return n.visitPrimitiveType(e);case"type_reference":return n.visitTypeReference(e);case"value":return n.visitValue(e);default:throw new Error(`Unknown node kind: ${e.kind}`)}}var ea=class{typeResolver;_typeVarScopes=[];constructor(n,t){this.typeResolver=n??{forward:()=>{},resolve:()=>{},get names(){return[]}},t!==void 0&&t.length>0&&this._typeVarScopes.push(t)}buildType(n){return Jl(n,this)}visitFunctionSignature(n){let t=[],i=[],r,s;for(let u of n.arguments){let l=this.buildNamedElement(u.element);switch(u.modifier){case"optional":i.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(n.returnType),a={kind:"signature",args:t.length>0?t:void 0,result:o};return n.effects!==void 0&&(a.effects=n.effects),i.length>0&&(a.optArgs=i),r&&(a.variadicArg=r,a.variadicMin=s),a}visitConstrainedType(n){let t=n.typeParams.map(s=>{let o={name:s.name};if(s.bound!==void 0){let a=this.buildType(s.bound);a!=="unknown"&&(o.bound=a)}return s.protocols!==void 0&&s.protocols.length>0&&(o.protocols=s.protocols),o});this._typeVarScopes.push(t);let i;try{i=this.buildType(n.body)}finally{this._typeVarScopes.pop()}if(typeof i=="string"||i.kind!=="signature")throw new en("unsupported-variable-position","A `where` clause can only quantify a function signature. To constrain one arm of an overload set, parenthesize it: `((list<T>) -> T where T) & \u2026`");return{...i,typeParams:t}}variableBound(n){for(let t=this._typeVarScopes.length-1;t>=0;t--){let i=this._typeVarScopes[t].find(r=>r.name===n);if(i!==void 0)return i.bound??"any"}}visitTypeVariable(n){return{kind:"variable",name:n.name}}visitUnionType(n){return{kind:"union",types:n.types.map(i=>this.buildType(i))}}visitIntersectionType(n){return{kind:"intersection",types:n.types.map(i=>this.buildType(i))}}visitNegationType(n){return{kind:"negation",type:this.buildType(n.type)}}visitGroupType(n){return this.buildType(n.type)}visitListType(n){let t=this.buildType(n.elementType),i=n.dimensions?.map(r=>this.buildDimension(r));return i===void 0&&this.isUnknownType(t)?"list":{kind:"list",elements:t,dimensions:i}}visitVectorType(n){let t=this.buildType(n.elementType);return n.size!==void 0?{kind:"list",elements:t,dimensions:[n.size]}:{kind:"list",elements:t,dimensions:[-1]}}visitMatrixType(n){let t=this.buildType(n.elementType);if(n.dimensions){let i=n.dimensions.map(r=>this.buildDimension(r));return{kind:"list",elements:t,dimensions:i}}return{kind:"list",elements:t,dimensions:[-1,-1]}}visitTensorType(n){let t=this.buildType(n.elementType);return this.isUnknownType(t)?"list":{kind:"list",elements:t}}visitTupleType(n){return{kind:"tuple",elements:n.elements.map(i=>this.buildNamedElement(i))}}visitRecordType(n){if(n.entries.length===0)return"record";let t=Object.create(null);for(let i of n.entries)t[i.key]=this.buildType(i.valueType);return{kind:"record",elements:t}}visitObjectType(n){if(n.entries.length===0)return"object";let t=Object.create(null);for(let i of n.entries)t[i.key]=this.buildType(i.valueType);return{kind:"object",elements:t}}visitDictionaryType(n){let t=this.buildType(n.valueType);return this.isUnknownType(t)?"dictionary":{kind:"dictionary",values:t}}visitSetType(n){let t=this.buildType(n.elementType);return this.isUnknownType(t)?"set":{kind:"set",elements:t}}visitBroadcastableType(n){return{kind:"broadcastable",elements:this.buildType(n.elementType)}}visitCollectionType(n){let t=this.buildType(n.elementType);return n.indexed?this.isUnknownType(t)?"indexed_collection":{kind:"indexed_collection",elements:t}:this.isUnknownType(t)?"collection":{kind:"collection",elements:t}}visitExpressionType(n){return{kind:"expression",operator:n.operator}}visitSymbolType(n){return{kind:"symbol",name:n.name}}visitNumericType(n){if(!n.lowerBound&&!n.upperBound)return n.baseType;let t=n.lowerBound?this.buildValue(n.lowerBound):-1/0,i=n.upperBound?this.buildValue(n.upperBound):1/0;return t===-1/0&&i===1/0?n.baseType:Rn(n.baseType,t,i,n.lowerOpen===!0,n.upperOpen===!0)}visitPrimitiveType(n){return n.name}visitTypeReference(n){let t=this.typeResolver.resolve(n.name),i=Cm(t);if(n.isForward&&n.args===void 0&&i!==void 0&&i.def===void 0&&i.typeParams===void 0&&Ho(i,0),n.args!==void 0||i?.typeParams!==void 0){let r=this.applyTypeReference(n,i);if(r!==void 0)return r}if(t)return t;if(n.isForward){let r=this.typeResolver.forward(n.name);if(r)return r}return n.name}applyTypeReference(n,t){let i=n.name,r=t?.typeParams,s=n.args;if(s===void 0&&Nt("generic-alias-arity",`The type "${i}" is generic: it takes ${r.length} type argument${r.length===1?"":"s"} (write \`${i}<\u2026>\`)`),t===void 0)return;if(n.isForward&&t.def===void 0&&r===void 0)return Ho(t,s.length),Uo(t,s.map(u=>this.buildType(u)));r===void 0&&(t.def===void 0&&Nt("generic-alias-forward-reference",`The type "${i}" is a forward reference and cannot take type arguments`),Nt("generic-alias-arity",`The type "${i}" is not generic: it takes no type arguments, but ${s.length} ${s.length===1?"was":"were"} given`)),t.alias===!0&&t.def===void 0&&Nt("generic-alias-self-reference",`The generic type alias "${i}" cannot refer to itself: a generic alias is expanded eagerly, so its body has no definition to expand into yet`),s.length!==r.length&&Nt("generic-alias-arity",`The type "${i}" takes ${r.length} type argument${r.length===1?"":"s"}, but ${s.length} ${s.length===1?"was":"were"} given`);let o=Object.create(null),a=[];for(let u=0;u<r.length;u++){let l=this.buildType(s[u]);r[u].bound!==void 0&&this.checkArgumentBound(i,l,r[u]),o[r[u].name]=l,a.push(l)}return t.alias!==!0?Uo(t,a):Q(t.def,o)}checkArgumentBound(n,t,i){let r=i.bound,s=t,o=Pn(t);if(o.size>0){let u=Object.create(null);for(let l of o)u[l]=this.variableBound(l)??"any";s=Q(t,u)}if(Rl(s,r))return;let a=o.size>0?` (an open argument is admitted by its own declared bound, \`${A(s)}\`)`:"";Nt("generic-alias-bound",`The type argument \`${A(t)}\` does not satisfy the bound \`${A(r)}\` of the parameter \`${i.name}\` of "${n}"${a}`)}visitValue(n){return{kind:"value",value:n.value}}buildNamedElement(n){let t=this.buildType(n.type);return n.name?{name:n.name,type:t}:{type:t}}buildDimension(n){return n.size??-1}buildValue(n){return n.value}isAnyType(n){return n==="any"||typeof n=="object"&&"kind"in n&&n.kind==="primitive"&&"name"in n&&n.name==="any"}isUnknownType(n){return n==="unknown"||typeof n=="object"&&"kind"in n&&n.kind==="primitive"&&"name"in n&&n.name==="unknown"}};function Cm(e){if(!(typeof e!="object"||e===null))return e.kind==="reference"?e:void 0}function Nt(e,n){throw new en(e,n)}function jl(e,n,t){return new ea(n,t).buildType(e)}var Om=["sgn","type","effects","lazyValue","storedValue","elementMemo","collectionFacet","typeParse"],Bm=["hit","hitConstant","hitFastPath","missCold","missGeneration","missGenerationWasted","missEpoch","missScope","missKeyShape","missDependency","declineCycle","declineStore","evictClear"],Fm=["generation","mutationGeneration","semanticEpoch","valueWrite","ephemeralValueWrite"],Lm=["clean","dirty"],Zn=(()=>{if(typeof process>"u")return!1;let e=process.env?.CE_CACHE_STATS;return e!==void 0&&e!=="0"})(),$l=Zn||typeof process<"u"&&!1;function Vm(){let e={};for(let n of Bm)e[n]=0;return e}var Jm=(()=>{let e={};for(let n of Om)e[n]=Vm();return e})(),PT=(()=>{let e={};for(let n of Fm)e[n]=0;return e})(),DT=(()=>{let e={};for(let n of Lm)e[n]=0;return e})();function ui(e,n){Jm[e][n]+=1}var bs=new Map,jm=2048;function zl(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;Object.freeze(e);for(let n of Object.values(e))zl(n);return e}function re(e,n,t,i){if(e===void 0)return;if(ms(e))return e;if(typeof e!="string")return;if(i?.allowObjectType===!0)return $m(li(e,n,t,i).type);if(t!==void 0)return li(e,n,t).type;let r=bs.get(e);if(r!==void 0)return Zn&&ui("typeParse","hit"),r;if(n!==void 0){try{let o=li(e,void 0,void 0);if(!o.sawForwardRef)return ql(e,o.type)}catch{}return li(e,n,void 0).type}let s=li(e,void 0,void 0);return s.sawForwardRef?s.type:ql(e,s.type)}function ql(e,n){return bs.size>=jm&&(Zn&&ui("typeParse","evictClear"),bs.clear()),Zn&&ui("typeParse","missCold"),bs.set(e,zl(n)),n}function li(e,n,t,i){try{let r=new ys(e,{typeResolver:n,typeVars:t,allowObjectType:i?.allowObjectType}),s=r.parseType(),o=jl(s,n,t);return r.sawWhereClause&&hs(o,n),{type:o,sawForwardRef:r.sawForwardRef}}catch(r){let s=new Error(`Failed to parse type "${e}": ${r instanceof Error?r.message:String(r)}`);throw r instanceof en&&(s.code=r.code,s.rawMessage=r.message),s.code??=r.code,s.rawMessage??=r.rawMessage,s}}function $m(e){if(!(typeof e=="object"&&e.kind==="object"?Object.values(e.elements).some(Ae):Ae(e)))return e;let t=new Error("object-type-not-inline: an `object{\u2026}` type may only be the definition of a named type. Object types are nominal: declare one with `type Person = object{\u2026}` (not `type alias`), then refer to `Person` here");throw t.code="object-type-not-inline",t.rawMessage="An `object{\u2026}` type may only be the definition of a named type",t}function Ae(e){if(typeof e=="string")return!1;switch(e.kind){case"object":return!0;case"record":return Object.values(e.elements).some(Ae);case"union":case"intersection":return e.types.some(Ae);case"negation":return Ae(e.type);case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":return Ae(e.elements);case"dictionary":return Ae(e.values);case"tuple":return e.elements.some(n=>Ae(n.type));case"signature":return Ae(e.result)||(e.args?.some(n=>Ae(n.type))??!1)||(e.optArgs?.some(n=>Ae(n.type))??!1)||e.variadicArg!==void 0&&Ae(e.variadicArg.type);case"reference":return e.args?.some(Ae)??!1;default:return!1}}var qm=new Set(["list","set","tuple","record","dictionary","collection","indexed_collection","signature","object"]),Gl={number:us,infinity:[],nan:[],complex:["imaginary","real","rational","integer"],imaginary:[],real:["rational","integer"],rational:["integer"],integer:[],any:$o,unknown:[],nothing:[],missing:[],never:[],error:[],value:Jo,scalar:ps,collection:ds,indexed_collection:Oo,list:[],range:[],set:[],tuple:[],record:[],object:[],dictionary:["record"],function:[],symbol:[],boolean:[],string:[],character:[],color:[],regexp:[],type:[],expression:jo},ci=(()=>{let e={},n=t=>{if(e[t])return e[t];let i=new Set([t]);e[t]=i;for(let r of Gl[t])if(r!==t)for(let s of n(r))i.add(s);return i};for(let t of Object.keys(Gl))n(t);return e})();function gn(e,n){return n==="any"||e==="never"?!0:n==="never"?!1:n==="error"?e==="error":n==="nothing"?e==="nothing":e==="nothing"?!1:n==="missing"?e==="missing":e==="missing"?!1:n==="unknown"?e!=="any"&&e!=="error":e==="unknown"?!1:e===n?!0:ci[n].has(e)}function fi(e,n){if(e===n)return[e];let t=ci[e],i=ci[n];if(t.has(n))return[n];if(i.has(e))return[e];let r=e<n?`${e}|${n}`:`${n}|${e}`,s=Ul.get(r);if(s)return s;let o=[];for(let u of t)i.has(u)&&o.push(u);let a=o.filter(u=>!o.some(l=>l!==u&&ci[l].has(u)));return Ul.set(r,a),a}var Ul=new Map,Hn=null;function na(e){if(Hn===null)Hn=new Set;else if(Hn.has(e))return!1;return Hn.add(e),!0}function ta(e){Hn.delete(e),Hn.size===0&&(Hn=null)}var Dn=null;function zm(e,n){Dn===null&&(Dn=new Map);let t=Dn.get(e);if(t===void 0)t=new Set,Dn.set(e,t);else if(t.has(n))return!1;return t.add(n),!0}function Gm(e,n){let t=Dn.get(e);t.delete(n),t.size===0&&Dn.delete(e),Dn.size===0&&(Dn=null)}function Yn(e){return e==="never"}function Z(e,n){if(Wn("provablyDisjoint",e),Wn("provablyDisjoint",n),e==="never"||n==="never")return!0;if(e==="any"||n==="any")return!1;if(typeof e=="object"&&e.kind==="reference"){let o=ia(e);if(o===void 0)return!1;let a=Ne(e);if(!na(a))return!1;try{return Z(o,n)}finally{ta(a)}}if(typeof n=="object"&&n.kind==="reference"){let o=ia(n);if(o===void 0)return!1;let a=Ne(n);if(!na(a))return!1;try{return Z(e,o)}finally{ta(a)}}if(e==="unknown"||n==="unknown"||x(e,n)||x(n,e))return!1;if(typeof e=="object"&&e.kind==="union")return e.types.every(o=>Z(o,n));if(typeof n=="object"&&n.kind==="union")return n.types.every(o=>Z(e,o));if(typeof n=="object"&&n.kind==="broadcastable")return Z(e,n.elements)&&Z(e,{kind:"indexed_collection",elements:n.elements});if(typeof e=="object"&&e.kind==="broadcastable")return Z(e.elements,n)&&Z({kind:"indexed_collection",elements:e.elements},n);if(typeof e=="object"&&e.kind==="intersection")return e.types.some(o=>Z(o,n));if(typeof n=="object"&&n.kind==="intersection")return n.types.some(o=>Z(e,o));if(typeof e=="object"&&e.kind==="negation"&&x(n,e.type)||typeof n=="object"&&n.kind==="negation"&&x(e,n.type)||typeof e=="object"&&e.kind==="value"||typeof n=="object"&&n.kind==="value")return!0;if(typeof e=="object"&&e.kind==="numeric"&&typeof n=="object"&&n.kind==="numeric"){if(fi(e.type,n.type).length===0)return!0;let o=e.lower??-1/0,a=e.upper??1/0,u=n.lower??-1/0,l=n.upper??1/0;return a<u||l<o}let t=(o,a)=>{if(o==="string"&&typeof a!="string"&&!(a.kind!=="collection"&&a.kind!=="indexed_collection"))return!x("character",a.elements)},i=t(e,n)??t(n,e);if(i!==void 0)return i;let r=Zl(e),s=Zl(n);return r!==void 0&&s!==void 0&&fi(r,s).length===0}function Zl(e){if(Wn("typeCategory",e),typeof e=="string")return e;switch(e.kind){case"list":return"list";case"set":return"set";case"tuple":return"tuple";case"record":return"record";case"object":return"object";case"dictionary":return"dictionary";case"collection":return"collection";case"indexed_collection":return"indexed_collection";case"signature":return"function";case"symbol":return"symbol";case"expression":return"expression";case"numeric":return e.type;default:return}}function Um(e,n){return e===void 0||n===void 0?!0:e.length!==n.length?!1:e.every((t,i)=>t===-1||n[i]===-1||t===n[i])}var xs=Object.assign(Object.create(null),{list:Bo,set:Fo,dictionary:ei,collection:fs,indexed_collection:ni});function he(e,n){if(e==="never"||n==="never")return!1;if(typeof e=="object"&&e.kind==="union")return e.types.some(t=>he(t,n));if(typeof n=="object"&&n.kind==="union")return n.types.some(t=>he(e,t));if(typeof e=="object"&&e.kind==="broadcastable")return he(e.elements,n)||he({kind:"indexed_collection",elements:e.elements},n);if(typeof n=="object"&&n.kind==="broadcastable")return he(e,n.elements)||he(e,{kind:"indexed_collection",elements:n.elements});if(typeof e=="string"&&e in xs&&(e=xs[e]),typeof n=="string"&&n in xs&&(n=xs[n]),typeof e=="object"&&typeof n=="object"){if(e.kind==="list"&&n.kind==="list"){if(Um(e.dimensions,n.dimensions)&&he(e.elements,n.elements))return!0}else if(e.kind==="tuple"&&n.kind==="tuple"){let t=n.elements;if(e.elements.length===t.length&&e.elements.every((i,r)=>{let s=t[r];return i.name!==void 0&&s.name!==void 0&&i.name!==s.name?!1:he(i.type,s.type)}))return!0}else if(e.kind===n.kind&&(e.kind==="set"||e.kind==="collection"||e.kind==="indexed_collection")){let t=n.elements;if(he(e.elements,t))return!0}else if(e.kind!==n.kind){let t=[e.kind,n.kind],i=t.includes("collection")&&(t.includes("list")||t.includes("set")||t.includes("indexed_collection")),r=t.includes("indexed_collection")&&t.includes("list");if(i||r){let s=e.elements,o=n.elements;if(he(s,o))return!0}else if(t.includes("collection")&&t.includes("dictionary")){let s=e.kind==="dictionary"?e:n,o=e.kind==="collection"?e:n,a={kind:"tuple",elements:[{type:"string"},{type:s.values}]};if(he(a,o.elements))return!0}}}return x(e,n)||x(n,e)}function Hl(e,n){let t=e.args?.length??0;if(n<t)return e.args[n].type;let i=e.optArgs?.length??0;return n<t+i?e.optArgs[n-t].type:e.variadicArg?.type}function Wl(e){let n=e.args?.length??0,t=e.optArgs?.length??0;if(e.variadicArg){let i=e.variadicMin??0;return{min:i>0?n+t+i:n,max:1/0}}return{min:n,max:n+t}}function Yl(e){return e.typeParams!==void 0&&e.typeParams.length>0}function Zm(e,n){let t=e.typeParams,i=n.typeParams;if(t.length!==i.length)return!1;let r=Object.create(null);for(let a=0;a<t.length;a++){let u=t[a].bound,l=i[a].bound;if(u===void 0!=(l===void 0)||u!==void 0&&Qe(u)!==Qe(l))return!1;r[t[a].name]={kind:"variable",name:i[a].name}}let s=Q(e,r),o={...n};return delete o.typeParams,Qe(s)===Qe(o)}var Hm={queries:0};function x(e,n){if($l&&Hm.queries++,typeof e=="string"&&!Gn.has(e)&&(e=re(e)),typeof n=="string"&&!Gn.has(n)&&(n=re(n)),typeof e=="string"&&typeof n=="string")return gn(e,n);if(typeof n!="string"&&qm.has(n.kind)&&(typeof e=="string"?e==="boolean"||pn.has(e):e.kind==="numeric"||e.kind==="value"&&typeof e.value!="string"))return!1;if(typeof e!="string"&&e.kind==="reference"&&e.alias===!0&&e.def!==void 0&&!(typeof n!="string"&&n.kind==="reference"&&n.name===e.name)){if(!na(e))return!1;try{let t=gs(e);return t===void 0?!1:x(t,n)}finally{ta(e)}}if(n==="any"||e==="never")return!0;if(n==="never")return!1;if(n==="error")return e==="error";if(n==="nothing")return e==="nothing";if(e==="nothing"&&typeof n=="string")return!1;if(n==="missing")return e==="missing";if(e==="missing"&&typeof n=="string")return!1;if(n==="unknown")return e==="any"||e==="error"?!1:typeof e!="string"&&e.kind==="union"?e.types.every(t=>x(t,"unknown")):!0;if(e==="unknown"&&typeof n=="string")return!1;if(typeof n=="string")return typeof e=="string"?gn(e,n):e.kind==="broadcastable"?x(e.elements,n)&&x({kind:"indexed_collection",elements:e.elements},n):e.kind==="value"?typeof e.value=="boolean"?n==="boolean":ge(e.value)?gn("infinity",n):typeof e.value=="number"?Number.isNaN(e.value)?gn("nan",n):Number.isFinite(e.value)?Number.isInteger(e.value)?gn("integer",n):gn("real",n):gn("infinity",n):typeof e.value=="string"?gn("string",n):!1:e.kind==="union"?e.types.every(t=>x(t,n)):e.kind==="intersection"?e.types.some(t=>x(t,n)):e.kind==="negation"?!1:e.kind==="numeric"?!!x(e.type,n):n==="number"?ec(e):n==="symbol"?ra(e):n==="expression"?Km(e):n==="function"?ic(e):n==="scalar"?nc(e):n==="value"?tc(e):n==="indexed_collection"?x(e,ni):n==="collection"?x(e,fs):n==="tuple"?e.kind==="tuple"&&e.elements.every(t=>x(t.type,"unknown")):n==="list"?e.kind==="list"&&x(e.elements,"unknown"):n==="set"?e.kind==="set"&&x(e.elements,"unknown"):n==="record"?e.kind==="record"&&Object.values(e.elements).every(t=>x(t,"unknown")):n==="object"?Es(e):n==="dictionary"?x(e,ei):!1;if(n.kind==="union"){let t=n.types,i=r=>x(r.elements,n)&&x({kind:"indexed_collection",elements:r.elements},n);return typeof e!="string"&&e.kind==="broadcastable"?i(e):typeof e!="string"&&e.kind==="union"?e.types.every(r=>{if(typeof r!="string"){if(r.kind==="broadcastable")return i(r);if(r.kind==="union")return x(r,n)}return t.some(s=>x(r,s))}):t.some(r=>x(e,r))}if(n.kind==="negation")return typeof e!="string"&&e.kind==="negation"?x(n.type,e.type):Z(e,n.type);if(n.kind==="expression"){if(e==="symbol")return n.operator==="Symbol";if(typeof e=="string")return!1;if(e.kind==="expression")return n.operator==="Symbol"?ra(e):e.operator===n.operator;if(e.kind==="symbol")return n.operator==="Symbol"}if(n.kind==="broadcastable"){if(typeof e!="string"&&e.kind==="broadcastable")return x(e.elements,n.elements);if(typeof e!="string"&&e.kind==="union")return e.types.every(i=>x(i,n));if(x(e,n.elements))return!0;let t=Xm(e);return t!==void 0?x(t,n.elements):!1}if(typeof e!="string"&&e.kind==="broadcastable")return x(e.elements,n)&&x({kind:"indexed_collection",elements:e.elements},n);if(n.kind==="reference"){if(typeof e!="string"&&e.kind==="reference"&&tg(e,n))return!0;if(n.alias===!0&&n.def){if(!zm(n,e))return!1;try{let t=gs(n);return t===void 0?!1:x(e,t)}finally{Gm(n,e)}}}if(n.kind==="intersection")return n.types.every(t=>x(e,t));if(e==="range")return x(ls,n);if(e==="string")return x(cs,n);if(e==="list")return x(Bo,n);if(e==="set")return x(Fo,n);if(e==="dictionary")return x(ei,n);if(e==="collection")return x(fs,n);if(e==="indexed_collection")return x(ni,n);if(e==="record")return x(ei,n);if(e==="tuple")return x(ni,n);if(typeof e=="string")return!1;if(e.kind==="union")return e.types.every(t=>x(t,n));if(e.kind==="intersection")return e.types.some(t=>x(t,n));if(e.kind==="signature"&&n.kind==="signature"){let t=Yl(e),i=Yl(n);if(t||i)return t&&i?Zm(e,n):i?!1:Dl(e,n);if(!Kt(e.effects,n.effects)||!x(e.result,n.result))return!1;let r=Wl(e),s=Wl(n);if(r.min>s.min||r.max<s.max)return!1;let o=Math.max((e.args?.length??0)+(e.optArgs?.length??0),(n.args?.length??0)+(n.optArgs?.length??0));for(let a=0;a<o;a++){let u=Hl(n,a);if(u===void 0)break;let l=Hl(e,a);if(l===void 0||!x(u,l))return!1}if(n.variadicArg){let a=e.variadicArg?.type;if(a===void 0||!x(n.variadicArg.type,a))return!1}return!0}if(e.kind==="record"&&n.kind==="record"){for(let t of Object.keys(n.elements))if(!Object.prototype.hasOwnProperty.call(e.elements,t)||!x(e.elements[t],n.elements[t]))return!1;return!0}if(e.kind==="object"&&n.kind==="object"){let t=Object.keys(e.elements),i=Object.keys(n.elements);if(t.length!==i.length)return!1;for(let r of i)if(!Object.prototype.hasOwnProperty.call(e.elements,r)||!x(e.elements[r],n.elements[r])||!x(n.elements[r],e.elements[r]))return!1;return!0}if(e.kind==="object"||n.kind==="object")return!1;if(e.kind==="dictionary"&&n.kind==="dictionary")return x(e.values,n.values);if(e.kind==="record"&&n.kind==="dictionary")return Object.values(e.elements).every(t=>x(t,n.values));if(n.kind==="indexed_collection")return e.kind==="indexed_collection"?x(e.elements,n.elements):e.kind==="list"?x(e.elements,n.elements)||Xl(e,n.elements):e.kind==="tuple"?e.elements.every(t=>x(t.type,n.elements)):!1;if(n.kind==="collection"){if(e.kind==="collection"||e.kind==="indexed_collection")return x(e.elements,n.elements);if(e.kind==="list")return x(e.elements,n.elements)||Xl(e,n.elements);if(e.kind==="tuple")return e.elements.every(t=>x(t.type,n.elements));if(e.kind==="set")return x(e.elements,n.elements);if(e.kind==="dictionary")return x({kind:"tuple",elements:[{type:"string"},{type:e.values}]},n.elements);if(e.kind==="record")return x({kind:"tuple",elements:[{type:"string"},{type:hn(...Object.values(e.elements))}]},n.elements)}if(e.kind==="tuple"&&n.kind==="tuple"){if(e.elements.length!==n.elements.length)return!1;for(let t=0;t<e.elements.length;t++){let i=e.elements[t],r=n.elements[t];if(!x(i.type,r.type)||r.name!==void 0&&i.name!==r.name)return!1}return!0}if(n.kind==="list"&&e.kind==="list"){let t=x(e.elements,n.elements);if(!t&&e.dimensions!==void 0&&e.dimensions.length>=2&&typeof n.elements!="string"&&n.elements.kind==="list"){let i={kind:"list",elements:e.elements,dimensions:e.dimensions.slice(1)};if(x(i,n.elements)&&(!n.dimensions||n.dimensions.length===1&&(n.dimensions[0]===-1||n.dimensions[0]===e.dimensions[0])))return!0}if(!t)return!1;if(n.dimensions){if(!e.dimensions||e.dimensions.length!==n.dimensions.length)return!1;for(let i=0;i<e.dimensions.length;i++)if(n.dimensions[i]!==-1&&e.dimensions[i]!==n.dimensions[i])return!1}return!0}if(e.kind==="symbol"&&n.kind==="symbol")return e.name===n.name;if(n.kind==="numeric"&&e.kind==="value"){if(ge(e.value)||typeof e.value!="number"||Number.isNaN(e.value))return!1;let t=Number.isFinite(e.value)?Number.isInteger(e.value)?"integer":"real":"infinity";if(!gn(t,n.type))return!1;let i=n.lower??-1/0,r=n.upper??1/0;return!(e.value<i||e.value===i&&n.lowerOpen===!0||e.value>r||e.value===r&&n.upperOpen===!0)}if(e.kind==="numeric"&&n.kind==="numeric"){if(!x(e.type,n.type))return!1;let t=e.lower??-1/0,i=n.lower??-1/0,r=e.upper??1/0,s=n.upper??1/0;return!(t<i||t===i&&n.lowerOpen===!0&&e.lowerOpen!==!0||r>s||r===s&&n.upperOpen===!0&&e.upperOpen!==!0)}if(n.kind==="set"&&e.kind==="set")return!!x(e.elements,n.elements);if(n.kind==="value"&&e.kind==="value")return n.value===e.value||typeof n.value=="number"&&Number.isNaN(n.value)&&typeof e.value=="number"&&Number.isNaN(e.value)||ge(n.value)&&ge(e.value);if(e.kind==="value"){if(typeof e.value=="boolean")return x("boolean",n);if(ge(e.value))return x("infinity",n);if(typeof e.value=="number")return Number.isNaN(e.value)?x("nan",n):Number.isFinite(e.value)?Number.isInteger(e.value)?x("integer",n):x("real",n):x("infinity",n);if(typeof e.value=="string")return x("string",n)}return!1}function ec(e){return typeof e=="string"?pn.has(e):e.kind==="value"?typeof e.value=="number"||ge(e.value):e.kind==="numeric"}function nc(e){return ec(e)?!0:typeof e=="string"?Tl.has(e):e.kind==="value"?["string","boolean","number"].includes(typeof e.value):!1}function ia(e){let n=new Set;for(;typeof e=="object"&&e.kind==="reference";){let t=Ne(e);if(e.def===void 0||n.has(t))return;n.add(t);let i=t.typeParams;if(e.args!==void 0&&i!==void 0){let r=Object.create(null),s=Math.min(i.length,e.args.length);for(let o=0;o<s;o++)r[i[o].name]=e.args[o];e=Q(e.def,r)}else e=e.def}return e}function Es(e,n){if(e==="object")return!0;if(typeof e=="string")return!1;if(e.kind==="object")return!0;if(e.kind==="reference"){let t=Ne(e);if(n===void 0&&(n=new Set),n.has(t))return!1;n.add(t);let i=t.def;return i===void 0?!1:Es(i,n)}return!1}function Wm(e){return Ym(e)?!0:typeof e=="string"?El.has(e):["collection","set","record","dictionary"].includes(e.kind)}function Ym(e){return typeof e=="string"?!1:["indexed_collection","list","tuple"].includes(e.kind)}function Xm(e){if(typeof e=="string")return e==="indexed_collection"||e==="list"?"unknown":e==="range"?"integer":void 0;if(e.kind==="indexed_collection")return e.elements;if(e.kind==="list"){let n=e.dimensions;return n&&n.length>1?{kind:"list",elements:e.elements,dimensions:n.slice(1)}:e.elements}}function Xl(e,n){let t=e.dimensions;return!t||t.length<=1?!1:x({kind:"list",elements:e.elements,dimensions:t.slice(1)},n)}function tc(e){return nc(e)||Wm(e)||Es(e)}function ic(e){return e==="function"||typeof e!="string"&&e.kind==="signature"}function Km(e){return typeof e=="string"&&["expression","symbol","function"].includes(e)||tc(e)||ic(e)||ra(e)?!0:typeof e=="string"?!1:e.kind==="expression"}function ra(e){return e==="symbol"?!0:typeof e=="string"?!1:e.kind==="symbol"?!0:e.kind==="expression"?e.operator==="Symbol":!1}function Qm(e,n){return e===n?e:e==="any"?n:n==="any"||x(e,n)?e:x(n,e)?n:"never"}function eg(e,n){if(e===n)return e;if(e==="any"||n==="any")return"any";if(e==="never")return n;if(n==="never")return e;if(e==="unknown")return n;if(n==="unknown")return e;if(e==="nothing")return n;if(n==="nothing")return e;if(x(e,n))return n;if(x(n,e))return e;let t=sg(e,n);return ng.has(t)?rg(e,n):t}var ng=new Set(["scalar","value","function","expression","collection","indexed_collection","list","set","tuple","record","object","dictionary","map","any"]);function tg(e,n){if(e.name!==n.name)return!1;let t=e.args,i=n.args;if(t===void 0||i===void 0)return t===i;if(t.length!==i.length)return!1;let r=e.decl,s=n.decl;return r!==void 0&&s!==void 0&&r!==s?!1:t.every((o,a)=>{switch(xt(n,a)){case"out":return x(o,i[a]);case"in":return x(i[a],o);default:return x(o,i[a])&&x(i[a],o)}})}function ig(e,n){return e==="def"?void 0:n}function rg(e,n){let t=[],i=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,ig);i.has(o)||(i.add(o),t.push(s))};return r(e),r(n),t.length===1?t[0]:{kind:"union",types:t}}function Ts(...e){return rc("narrow",e),e.length===0?"any":e.length===1?e[0]:e.reduce((n,t)=>Qm(n,t))}function hn(...e){return sa(e)}function sa(e){return rc("widen",e),e.length===0?"never":e.length===1?e[0]:e.reduce((n,t)=>eg(n,t))}var Kl=["infinity","integer","rational","real","imaginary","complex","nan","number","list","record","object","dictionary","set","tuple","indexed_collection","collection","scalar","value","function","expression"],Ql=new Map;function sg(e,n){if(e===n)return e;if(e==="any"||n==="any")return"any";if(e==="never")return n;if(n==="never")return e;if(e==="unknown")return n;if(n==="unknown")return e;if(e==="nothing")return n;if(n==="nothing")return e;if(typeof e=="string"&&typeof n=="string"){let t=e<n?`${e}|${n}`:`${n}|${e}`,i=Ql.get(t);if(i===void 0){i="any";for(let r of Kl){let s=ci[r];if(s.has(e)&&s.has(n)){i=r;break}}Ql.set(t,i)}return i}for(let t of Kl)if(x(e,t)&&x(n,t))return t;return"any"}function rc(e,n){for(let t of n)Wn(e,t)}function Wn(e,n){typeof n=="object"&&n.kind==="variable"&&`${e}${n.name}`}Al({isSubtype:x,widen:hn,narrow:Ts});function oc(e){return typeof e=="string"?pn.has(e):e.kind==="numeric"||e.kind==="value"&&(typeof e.value=="number"||ge(e.value))}function di(e){if(!(!e||typeof e=="string")){if(e.kind==="signature")return[e];if(e.kind==="union"||e.kind==="intersection"){let n=[];for(let t of e.types){if(typeof t=="string"||t.kind!=="signature")return;n.push(t)}return n.length>0?n:void 0}}}function og(e){let n;for(let t of e)n=Qt(n,t.effects);return n}function yn(e){if(e===void 0||typeof e=="string")return;if(e.kind==="signature")return sc(e.effects);if(e.kind==="union"){let t;for(let i of e.types)t=Qt(t,yn(i));return t}if(e.kind!=="intersection")return;let n=di(e);return n===void 0?void 0:sc(og(n))}function sc(e){if(e===void 0||e==="any"||e.length<=1)return e;for(let n=1;n<e.length;n++)if(e[n-1]>=e[n])return[...new Set(e)].sort();return e}function Ns(e){let n,t=e;for(;typeof t=="object"&&t.kind==="reference"&&t.alias===!0&&t.def!==void 0;){n??=new Set;let i=Ne(t);if(n.has(i))return t;n.add(i);let r=i.typeParams,s=t.args;if(s!==void 0&&r!==void 0){let o=Object.create(null);for(let a=0;a<r.length;a++)s[a]!==void 0&&(o[r[a].name]=s[a]);t=Q(t.def,o)}else t=t.def}return t}function nn(e){if(e==="missing")return!0;if(typeof e=="string")return!1;switch(e.kind){case"union":case"intersection":return e.types.some(nn);case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":return nn(e.elements);case"tuple":return e.elements.some(n=>nn(n.type));case"dictionary":return nn(e.values);case"record":case"object":return Object.values(e.elements).some(n=>nn(n));default:return!1}}function ac(e){return x("complex",e)||x(e,"number")&&!x(e,"real")}var oa=typeof process<"u"&&process.env?.CE_TYPE_FACTS_ASSERT==="1",ag=re("matrix"),ug=re("vector");var vs=class{constructor(n,t){this.type=n;this.cacheable=t}type;cacheable;known=0;yes=0;no=0;shapeKnown=!1;cachedShape;get numericScalar(){return this.read(0)}get integer(){return this.read(1)}get rational(){return this.read(2)}get real(){return this.read(3)}get imaginary(){return this.read(4)}get complex(){return this.read(5)}get belowNumber(){return this.read(6)}get couldBeNumber(){return this.read(7)}get finite(){return this.read(8)}get nan(){return this.read(9)}get infinity(){return this.read(10)}get extendedReal(){return this.read(11)}get couldBeNonReal(){return this.read(12)}get collection(){return this.read(13)}get indexed(){return this.read(14)}get tupleShaped(){return this.read(15)}get matrix(){return this.read(16)}get vector(){return this.read(17)}get containsMissing(){return this.read(18)}get unknownOrAny(){return this.read(19)}get numberMembership(){return this.read(20)}get infinityMembership(){return this.read(21)}get shape(){if(!this.cacheable)return aa(this.type);if(this.shapeKnown||(this.cachedShape=aa(this.type),this.shapeKnown=!0),oa&&this.cachedShape!==aa(this.type))throw new Error("Stale type shape fact");return this.cachedShape}get finiteCollection(){return this.shape!==void 0?!0:void 0}read(n){if(!this.cacheable)return this.compute(n);let t=1<<n;if((this.known&t)===0){let r=this.computeFromFacts(n);if(this.known|=t,r===!0?this.yes|=t:r===!1&&(this.no|=t),oa&&r!==this.compute(n))throw new Error(`Incorrect derived type fact ${n}`);return r}let i=(this.yes&t)!==0?!0:(this.no&t)!==0?!1:void 0;if(oa&&i!==this.compute(n))throw new Error(`Stale type fact ${n}`);return i}computeFromFacts(n){let t=this.type;if(typeof t=="object"&&t.kind==="numeric"&&(n>=1&&n<=6||n===9||n===10))return Is(t.type).read(n);switch(n){case 8:return this.complex?!0:this.infinity||this.nan?!1:void 0;case 11:return this.real||x(t,Vo);case 12:return x("complex",t)||this.belowNumber&&!this.real;case 20:return t==="unknown"||t==="any"?void 0:this.belowNumber?!0:this.couldBeNumber?void 0:!1;case 21:return t==="unknown"||t==="any"?void 0:this.infinity?!0:Z(t,"infinity")?!1:void 0;default:return this.compute(n)}}compute(n){let t=this.type;switch(n){case 0:return oc(t);case 1:return x(t,"integer");case 2:return x(t,"rational");case 3:return x(t,"real");case 4:return x(t,"imaginary");case 5:return x(t,"complex");case 6:return x(t,"number");case 7:return!Z(t,"number");case 8:return x(t,"complex")?!0:x(t,"infinity")||x(t,"nan")?!1:void 0;case 9:return x(t,"nan");case 10:return x(t,"infinity");case 11:return x(t,"real")||x(t,Vo);case 12:return ac(t);case 13:return x(t,ht)?!0:Z(t,ht)?!1:void 0;case 14:return x(t,ti)?!0:Z(t,ti)?!1:void 0;case 15:{let i=Ns(t);return i==="tuple"||typeof i=="object"&&i.kind==="tuple"}case 16:return x(t,ag);case 17:return x(t,ug);case 18:return nn(t);case 19:return t==="unknown"||t==="any";case 20:return uc(t,"number");case 21:return uc(t,"infinity")}}};function uc(e,n){if(!(e==="unknown"||e==="any"))return x(e,n)?!0:Z(e,n)?!1:void 0}function aa(e){if(typeof e=="object"&&e.kind==="list"&&Array.isArray(e.dimensions)&&e.dimensions.length>0&&e.dimensions.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0))return e.dimensions}var lc=new Map,cc=new WeakMap,fc=new WeakSet;function ua(e,n){if(e===null||typeof e!="object"||bl(e)||fc.has(e))return!0;if(!Object.isFrozen(e))return!1;let t=Object.getPrototypeOf(e);if(t!==null&&t!==(Array.isArray(e)?Array.prototype:Object.prototype))return!1;let i=e;if(i.kind==="reference"||i.kind==="variable"||i.kind==="signature"&&i.typeParams!==void 0||n?.has(e))return!1;n??=new Set,n.add(e);for(let r of Reflect.ownKeys(e)){let s=Object.getOwnPropertyDescriptor(e,r);if(!("value"in s)||!ua(s.value,n))return n.delete(e),!1}return n.delete(e),fc.add(e),!0}function Ss(e){return ua(e)}function Is(e){if(typeof e=="string"){let t=lc.get(e);return t===void 0&&(t=new vs(e,!0),lc.set(e,t)),t}let n=cc.get(e);return n===void 0&&(n=new vs(e,ua(e)),cc.set(e,n)),n}var la=22250738585072014e-324;var dc=134217729;function lg(e,n,t){let i=dc*e,r=i-(i-e),s=e-r,o=dc*n,a=o-(o-n),u=n-a;return s*u-(t-r*a-s*a-r*u)}var cg=new Float64Array(1),N1=new BigUint64Array(cg.buffer);function pi(e,n){let t=e+n;if(!Number.isFinite(t))return!1;let i=t-e;return e-(t-i)+(n-i)===0}function Ge(e,n,t){return!Number.isFinite(t)||t!==e*n?!1:t===0?e===0||n===0:fg(e,n,t)?lg(e,n,t)===0:!1}function fg(e,n,t){let i=Math.abs(t);return i>=la&&i<=1e300&&Math.abs(e)<=1e150&&Math.abs(n)<=1e150&&Math.abs(e)>=la&&Math.abs(n)>=la}var se={lo:!1,hi:!1},mc={lo:!0,hi:!0},fa={lo:!0,hi:!1},dg={lo:!1,hi:!0};function fe(e,n){return e?n?mc:fa:n?dg:se}function ee(e){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Jn(e)}function pg(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let n=e;if(n.kind===void 0)return typeof n.lo=="number"&&typeof n.hi=="number"?n:void 0;if(n.kind==="interval"||n.kind==="partial"||n.kind==="singular")return n.value}function mg(e){for(let n of e){if(typeof n=="number"){if(!Number.isFinite(n))return!1;continue}let t=ee(n);if(t!==void 0&&(!Number.isFinite(t.lo)||!Number.isFinite(t.hi)))return!1}return!0}function pc(e,n,t,i){if(!Number.isFinite(e)&&((n<0?e!==1/0:e!==-1/0)||!mg(i)))return e;let r=e;for(let s=0;s<t;s++)r=n<0?Ce(r):Ee(r);return r}function ca(e,n,t,i){let r=pg(e);if(r===void 0||Number.isNaN(r.lo)&&Number.isNaN(r.hi))return e;let s=t?t(i,r):se;if(s.lo&&s.hi)return e;let o=s.lo?r.lo:pc(r.lo,-1,n,i),a=s.hi?r.hi:pc(r.hi,1,n,i);if(o===r.lo&&a===r.hi)return e;let u={lo:o,hi:a},l=e.kind;return l===void 0?u:l==="interval"?(e.value=u,e):{...e,value:u}}function gc(e,n,t){let i=e;if(i.length===1){let s=[void 0];return a=>{let u=i(a);return s[0]=a,ca(u,n,t,s)}}if(i.length===2){let s=[void 0,void 0];return(a,u)=>{let l=i(a,u);return s[0]=a,s[1]=u,ca(l,n,t,s)}}return(...s)=>ca(i(...s),n,t,s)}function de(e,n=1){return gc(e,n,void 0)}function C(e,n,t=1){return gc(e,t,n)}function Cn(e,n){return(t,i)=>{let r=e(t,i);if(r.lo&&r.hi)return r;let s=n(t,i);return fe(r.lo||s.lo,r.hi||s.hi)}}function hc(e){let n=ee(e[0]),t=ee(e[1]);return n===void 0||t===void 0?se:fe(pi(n.lo,t.lo),pi(n.hi,t.hi))}function yc(e){let n=ee(e[0]),t=ee(e[1]);return n===void 0||t===void 0?se:fe(pi(n.lo,-t.hi),pi(n.hi,-t.lo))}function gg(e,n,t){let i=!1,r=!1,s=!1,o=!1,a=e.lo===e.hi?1:2,u=n.lo===n.hi?1:2;for(let l=0;l<a;l++){let c=l===0?e.lo:e.hi;for(let f=0;f<u;f++){let p=f===0?n.lo:n.hi,h=c===0||p===0,y=h?0:c*p,N=y===t.lo,D=y===t.hi;if(!N&&!D)continue;let R=h||Ge(c,p,y);N&&(i=!0,R||(r=!0)),D&&(s=!0,R||(o=!0))}}return fe(i&&!r,s&&!o)}function da(e,n){let t=ee(e[0]),i=ee(e[1]);return t===void 0||i===void 0?se:gg(t,i,n)}function bc(e,n){let t=ee(e[0]);if(t===void 0)return se;let i=hg(t,n);return fe(n.lo===0||i.lo,i.hi)}function hg(e,n){let t=!1,i=!1,r=!1,s=!1,o=e.lo===e.hi?1:2;for(let a=0;a<o;a++){let u=a===0?e.lo:e.hi,l=u*u,c=l===n.lo,f=l===n.hi;if(!c&&!f)continue;let p=u===0||Ge(u,u,l);c&&(t=!0,p||(i=!0)),f&&(r=!0,p||(s=!0))}return fe(t&&!i,r&&!s)}function xc(e,n){let t=ee(e[0]);if(t===void 0)return se;let i=(r,s)=>Ge(r,r,r*r)&&r*r===s;return fe(n.lo===0||i(n.lo,t.lo),i(n.hi,t.hi))}function pa(e,n){let t=ee(e[0]),i=ee(e[1]);return t===void 0||i===void 0?se:Tc(t,i,n)}function Ec(e,n){let t=ee(e[0]),i=ee(e[1]);return t===void 0||i===void 0?se:Tc({lo:-t.hi,hi:-t.lo},i,n)}function Tc(e,n,t){let i=!1,r=!1,s=!1,o=!1,a=e.lo===e.hi?1:2,u=n.lo===n.hi?1:2;for(let l=0;l<a;l++){let c=l===0?e.lo:e.hi;for(let f=0;f<u;f++){let p=f===0?n.lo:n.hi,h=c===0||p===1/0||p===-1/0,y=h?0:c/p,N=y===t.lo,D=y===t.hi;if(!N&&!D)continue;let R=h||Ge(y,p,y*p)&&y*p===c;N&&(i=!0,R||(r=!0)),D&&(s=!0,R||(o=!0))}}return fe(i&&!r,s&&!o)}var Nc=64;function vc(e,n){if(!Number.isInteger(n)||n<0||n>Nc)return NaN;let t=1;for(let i=0;i<n;i++){let r=t*e;if(t!==0&&e!==0&&!Ge(t,e,r))return NaN;t=r}return t}function Sc(e,n,t){if(!Number.isInteger(n)||n<0||n>Nc)return n>=0&&t.lo===0?fa:se;let i=!1,r=!1,s=!1,o=!1,a=e.lo===e.hi?1:2;for(let u=0;u<a;u++){let l=u===0?e.lo:e.hi,c=Math.pow(l,n),f=c===t.lo,p=c===t.hi;if(!f&&!p)continue;let h=vc(l,n)===c;f&&(i=!0,h||(r=!0)),p&&(s=!0,h||(o=!0))}return fe(t.lo===0||i&&!r,s&&!o)}function Ic(e,n){let t=ee(e[0]),i=e[1];return t===void 0||typeof i!="number"?se:Sc(t,i,n)}function kc(e,n){let t=ee(e[0]),i=ee(e[1]);return t===void 0||i===void 0?se:i.lo!==i.hi||!Number.isInteger(i.lo)?t.lo===-1&&t.hi===-1?fe(n.lo===-1,n.hi===1):n.lo===0?fa:se:Sc(t,i.lo,n)}function bn(e,n){if(n.lo!==n.hi||!Number.isSafeInteger(n.lo))return se;for(let t of e){let i=ee(t);if(i===void 0||i.lo!==i.hi||!Number.isInteger(i.lo))return se}return mc}function ye(e,n){return(t,i)=>fe(i.lo===e,i.hi===n)}var Mc=(e,n)=>{let t=ee(e[1]);if(t===void 0)return se;let i=Math.max(Math.abs(t.lo),Math.abs(t.hi));return t.lo>0?fe(n.lo===0,n.hi===i):t.hi<0?fe(n.lo===-i,n.hi===0):se};function Re(e,n){let t=ee(e[0]);return t===void 0?se:fe(t.lo===0&&n.lo===0,t.hi===0&&n.hi===0)}function wc(e,n){return(t,i)=>{let r=ee(t[0]);return r===void 0||r.lo!==e||r.hi!==e?se:fe(i.lo===n,i.hi===n)}}function ks(e){return(n,t)=>{let i=ee(n[0]);if(i===void 0)return se;let r=(s,o)=>o===1&&s===0||e!==void 0&&vc(e,s)===o;return fe(r(t.lo,i.lo),r(t.hi,i.hi))}}function yg(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:i.lo+r.lo,hi:i.hi+r.hi})}function Ac(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:i.lo-r.hi,hi:i.hi-r.lo})}function bg(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:-t.hi,hi:-t.lo})}function mi(e,n){let t=[vt(e.lo,n.lo),vt(e.lo,n.hi),vt(e.hi,n.lo),vt(e.hi,n.hi)];return{lo:Math.min(...t),hi:Math.max(...t)}}function vt(e,n){return e===0||n===0?0:e*n}function St(e,n){return e===0||n===1/0||n===-1/0?0:e/n}function Rc(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T(mi(i,r))}function xg(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(i.lo!==i.hi)return T(mi(i,r));let s=vt(i.lo,r.lo),o=vt(i.lo,r.hi);return T({lo:Math.min(s,o),hi:Math.max(s,o)})}function Eg(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(r.lo!==r.hi||r.lo===0)return ma(i,r);let s=St(i.lo,r.lo),o=St(i.hi,r.lo);return T({lo:Math.min(s,o),hi:Math.max(s,o)})}function _c(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return ma(i,r)}function Tg(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return ma({lo:-i.hi,hi:-i.lo},r)}function ma(e,n){if(n.lo>0||n.hi<0){let t=[St(e.lo,n.lo),St(e.lo,n.hi),St(e.hi,n.lo),St(e.hi,n.hi)];return T({lo:Math.min(...t),hi:Math.max(...t)})}return n.lo<0&&n.hi>0?{kind:"singular"}:n.lo===0&&n.hi>0?e.lo>=0?{kind:"partial",value:{lo:e.lo/n.hi,hi:1/0},domainClipped:"hi"}:e.hi<=0?{kind:"partial",value:{lo:-1/0,hi:e.hi/n.hi},domainClipped:"lo"}:{kind:"entire"}:n.hi===0&&n.lo<0?e.lo>=0?{kind:"partial",value:{lo:-1/0,hi:e.lo/n.lo},domainClipped:"lo"}:e.hi<=0?{kind:"partial",value:{lo:e.hi/n.lo,hi:1/0},domainClipped:"hi"}:{kind:"entire"}:{kind:"empty"}}var Xn=I(C(yg,hc)),Kn=I(C(Ac,yc)),gi=I(bg),On=I(C(Rc,da)),Qn=I(C(_c,pa)),ga=I(C(Tg,Ec)),ha=I(C(xg,da)),ya=I(C(Eg,pa)),Pc=I(Ac),Dc=I(Rc),Ue=I(_c);var Ms=7,ws=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23];function It(e){if(e<0)return NaN;if(e===1||e===2)return 0;let n=e-1,t=ws[0];for(let r=1;r<Ms+2;r++)t+=ws[r]/(n+r);let i=n+Ms+.5;return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(i)-i+Math.log(t)}var Ng=171.6243769563027;function Cc(e){e-=1;let n=ws[0];for(let i=1;i<Ms+2;i++)n+=ws[i]/(e+i);let t=e+Ms+.5;return Math.sqrt(2*Math.PI)*Math.pow(t,e+.5)*Math.exp(-t)*n}function As(e,n){if(n<=0)return 1;if(n===1)return e;let t=n>>>1;return As(e,t)*As(e+t,n-t)}function Ze(e){if(e<=0&&Number.isInteger(e))return NaN;if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Ze(1-e));if(e>Ng)return 1/0;if(Number.isInteger(e))return As(1,e-1);if(e>=2){let n=Math.floor(e)-1,t=e-n;return Cc(t)*As(t,n)}return Cc(e)}function Rs(e){if(Number.isNaN(e))return NaN;if(!Number.isFinite(e))return e>0?0:2;if(e<0)return 2-Rs(-e);if(e<2)return 1-_s(e);let n=1e-300,t=e===0?n:e,i=t,r=0;for(let s=1;s<=500;s++){let o=s/2;r=e+o*r,r===0&&(r=n),r=1/r,i=e+o/i,i===0&&(i=n);let a=i*r;if(t*=a,Math.abs(a-1)<1e-17)break}return Math.exp(-e*e)/(Math.sqrt(Math.PI)*t)}function _s(e){if(Number.isNaN(e))return NaN;if(e===0)return 0;if(!Number.isFinite(e))return e>0?1:-1;let n=e<0?-1:1,t=Math.abs(e);if(t>=6)return n;let i=t*t,r=t,s=t;for(let o=1;o<200&&(r*=2*i/(2*o+1),s+=r,!(r<s*1e-18));o++);return n*(2/Math.sqrt(Math.PI))*Math.exp(-i)*s}var D1=[1/6,-1/30,1/42,-1/30,5/66,-691/2730,7/6,-3617/510,43867/798,-174611/330];var vg=[-2991.8191940101983,708840.0452577386,-6297414862058625e-8,25489088057337637e-7,-4429795180596978e-5,3180162978765678e-4],Sg=[1,281.3762688899943,45584.78108065326,5173438887700964e-9,4193202458981112e-7,22441179564534092e-6,607366389490085e-3],Ig=[-49884311457357354e-24,9504280628298596e-21,-.0006451914356839651,.018884331939670384,-.20552590095501388,1],kg=[399982968972496e-26,9154392157746574e-25,12500186247959882e-23,12226278902417902e-21,.0008680295429417843,.04121420907221998,1],Oc=[.4215435550436775,.1434079197807589,.011522095507358577,.000345017939782574,46361374928786735e-22,3055689837902576e-23,10230451416490724e-26,17201074326816183e-29,13428327623306275e-32,3763297112699879e-35],Bc=[1,.7515863983533789,.11688892585919138,.0064405152650885865,.00015593440916415301,18462756734893055e-22,11269922476399903e-24,36014002958937136e-27,5887545336215784e-29,45200143407412973e-33,12544323709001127e-36],Fc=[.5044420736433832,.1971028335255234,.018764858409257526,.0006840793809153931,11513882611188428e-21,9828524436884223e-23,44534441586175015e-26,10826804113902088e-28,1375554606332618e-30,8363544356306774e-34,18695871016278324e-38],Lc=[1,1.4749575992512833,.33774898912002,.02536037414203388,.0008146791071843061,12754507566772912e-21,10431458965757199e-23,46068072851523205e-26,11027321506624028e-28,13879653125957886e-31,8391588162831187e-34,18695871016278324e-38];function Oe(e,n){let t=n[0];for(let i=1;i<n.length;i++)t=t*e+n[i];return t}var Vc=6e15;function Jc(e){let t=134217729*e,i=t-(t-e),r=e-i,s=i*i%4+2*(i*r%2)+r*r%4;return s%=4,s<0&&(s+=4),Math.PI/2*s}function kt(e){if(!isFinite(e))return e!==e?NaN:e>0?.5:-.5;let n=e<0?-1:1;if(e=Math.abs(e),e<1.6){let t=e*e,i=t*t;return n*e*t*Oe(i,vg)/Oe(i,Sg)}if(e<Vc){let t=e*e,i=Math.PI*t,r=1/(i*i),s=1-r*Oe(r,Oc)/Oe(r,Bc),o=1/i*Oe(r,Fc)/Oe(r,Lc),a=Jc(e),u=Math.cos(a),l=Math.sin(a);return n*(.5-(s*u+o*l)/(Math.PI*e))}return n*.5}function Mt(e){if(!isFinite(e))return e!==e?NaN:e>0?.5:-.5;let n=e<0?-1:1;if(e=Math.abs(e),e<1.6){let t=e*e,i=t*t;return n*e*Oe(i,Ig)/Oe(i,kg)}if(e<Vc){let t=e*e,i=Math.PI*t,r=1/(i*i),s=1-r*Oe(r,Oc)/Oe(r,Bc),o=1/i*Oe(r,Fc)/Oe(r,Lc),a=Jc(e),u=Math.cos(a),l=Math.sin(a);return n*(.5+(s*l-o*u)/(Math.PI*e))}return n*.5}function Mg(e){let n=[];for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);if(i>=55296&&i<=56319){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343){let s=i-55296,o=r-56320;i=2**16+s*2**10+o,t++}}n.push(i)}return n}var Ps=8205,jc=[127462,127487];function $c(e){return e===Ps||e===65038||e===65039||e>=127995&&e<=128e3||e>=129456&&e<=129460||e>=917536&&e<=917632}function wg(e){return e>=jc[0]&&e<=jc[1]}function qc(e){if(/^[\u0020-\u00FF]*$/.test(e))return e;let n=[],t=Mg(e),i=0;for(;i<t.length;){let r=t[i++],s=t[i];if(s===Ps){let o=i-1;for(i+=2;t[i]===Ps;)i+=2;n.push(String.fromCodePoint(...t.slice(o,i)))}else if($c(s)){let o=i-1;for(;$c(t[i]);)i+=t[i]===Ps?2:1;n.push(String.fromCodePoint(...t.slice(o,i)))}else wg(r)?(i+=1,n.push(String.fromCodePoint(...t.slice(i-2,i)))):n.push(String.fromCodePoint(r))}return n}var Ag={"\u2070":"0","\xB9":"1","\xB2":"2","\xB3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u207B":"-","\u2071":"i",\u207F:"n"},Rg={"\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u208B":"-"},zc=new Map;function _g(e){let n=zc.get(e.source);if(!n){let t=e.source.startsWith("^")?e.source.slice(1):e.source;n=new RegExp(t,"y"),zc.set(e.source,n)}return n}var ba=class{s;pos;joined;offsets=null;obeyspaces=!1;constructor(n){if(n=n.normalize("NFC"),n=n.replace(/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/g,""),n=n.replace(/\u2212/g,"-"),n=n.replace(/[⁰¹²³⁴⁵⁶⁷⁸⁹⁻ⁱⁿ]+/g,t=>`^{${Array.from(t).map(r=>Ag[r]).join("")}}`),n=n.replace(/[₀₁₂₃₄₅₆₇₈₉₋]+/g,t=>`_{${Array.from(t).map(r=>Rg[r]).join("")}}`),this.s=qc(n),this.pos=0,typeof this.s=="string")this.joined=this.s;else{this.joined=this.s.join("");let t=new Array(this.s.length+1),i=0;for(let r=0;r<this.s.length;r++)t[r]=i,i+=this.s[r].length;t[this.s.length]=i,this.offsets=t}}end(){return this.pos>=this.s.length}get(){return this.pos<this.s.length?this.s[this.pos++]:""}peek(){return this.s[this.pos]}match(n){let t=_g(n);typeof this.s=="string"?t.lastIndex=this.pos:t.lastIndex=this.offsets[this.pos<this.s.length?this.pos:this.s.length];let i=t.exec(this.joined);return i?.[0]?(this.pos+=i[0].length,i[0]):null}next(){if(this.end())return null;if(!this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]+/))return"<space>";if(this.obeyspaces&&this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]/))return"<space>";let n=this.get();if(n==="\\"){if(!this.end()){let t=this.match(/^[a-zA-Z]+/);if(t)this.match(/^[ \f\n\r\t\v\xA0\u2028\u2029]*/);else if(t=this.get(),t===" ")return"<space>";return"\\"+t}}else{if(n==="{")return"<{>";if(n==="}")return"<}>";if(n==="^"){if(this.peek()==="^"){this.get();let t=this.match(/^(\^(\^(\^(\^[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f])?[0-9a-f][0-9a-f]/);if(t)return String.fromCodePoint(parseInt(t.slice(t.lastIndexOf("^")+1),16))}return n}else if(n==="#"){if(!this.end()){let t=!1;if(/[0-9?]/.test(this.peek())&&(t=!0,this.pos+1<this.s.length)){let i=this.s[this.pos+1];t=/[^0-9A-Za-z]/.test(i)}return t?"#"+this.get():"#"}}else if(n==="$")return this.peek()==="$"?(this.get(),"<$$>"):"<$>"}return n}};function Pg(e,n){let t=e.next();if(!t)return[];let i=[];if(t!=="\\relax"){if(t==="\\noexpand")t=e.next(),t&&i.push(t);else if(t==="\\obeyspaces")e.obeyspaces=!0;else if(t==="\\space"||t==="~")i.push("<space>");else if(t==="\\bgroup")i.push("<{>");else if(t==="\\egroup")i.push("<}>");else if(t==="\\string")t=e.next(),t&&(t[0]==="\\"?Array.from(t).forEach(r=>i.push(r==="\\"?"\\backslash":r)):t==="<{>"?i.push("\\{"):t==="<space>"?i.push("~"):t==="<}>"&&i.push("\\}"));else if(t==="\\csname"){let r="",s=!1,o=[];do o.length===0&&(t=e.next(),o=t?[t]:[]),s=o.length===0,!s&&t==="\\endcsname"&&(s=!0,o.shift()),s||(s=t==="<$>"||t==="<$$>"||t==="<{>"||t==="<}>"||!!t&&t.length>1&&t[0]==="\\"),s||(r+=o.shift());while(!s);r&&i.push("\\"+r),i=i.concat(o)}else if(t!=="\\endcsname")if(t.length>1&&t[0]==="#"){let r=t.slice(1),s=n;i=i.concat(be(s?.[r]??s?.["?"]??"\\placeholder{}",n))}else i.push(t)}return i}function be(e,n=[],t){let r=e.toString().split(/(\r?\n)/),s="",o="",a=0;for(let c=0;c<r.length;c+=2){let f=r[c],p=r[c+1]??"";s+=o,o=" ";let h=f.match(/((?:\\%)|[^%])*/);if(h!==null&&(s+=h[0],t!==void 0&&h[0].length<f.length)){let y=a+h[0].length,N=a+f.length;t.push({start:y,end:N,discardedLength:f.length-h[0].length})}a+=f.length+p.length}let u=new ba(s),l=[];do l.push(...Pg(u,n));while(!u.end());return l}function v(e){let n="",t="";for(let i of e)i!=null&&(typeof i=="string"&&(/[a-zA-Z]/.test(i[0])&&(t+=n),/\\[a-zA-Z]+\*?$/.test(i)?n=" ":n=""),t+=i.toString());return t}function xn(e,n,t){return n.includes(e)&&(n=`{${n}}`),/^[0-9]$/.test(t)?`${n}${e}${t}`:`${n}${e}{${t}}`}function wt(e){let n=[];if(Array.isArray(e))for(let i of e)if(Array.isArray(i))for(let r of i)n.push(r);else n.push(i);else n=[e];return v(n.map(i=>({"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"})[i]??i))}function xa(){return Object.create(null)}var w=245,hi=260,He=270,q=275,V=390,W=600,Ea=650,yi=700,tn=810;function Ds(e,n){return(t,i,r)=>{let s=t.parseExpression({...r,minPrec:n});return s===null?null:["Not",[e,i,s]]}}var et=[{latexTrigger:["\\not","<"],kind:"infix",associativity:"any",precedence:246,parse:"NotLess"},{name:"NotLess",latexTrigger:["\\nless"],kind:"infix",associativity:"any",precedence:246},{latexTrigger:["<"],kind:"infix",associativity:"any",precedence:245,parse:"Less"},{name:"Less",latexTrigger:["\\lt"],kind:"infix",associativity:"any",precedence:245},{latexTrigger:["<","="],kind:"infix",associativity:"any",precedence:241,parse:"LessEqual"},{name:"LessEqual",latexTrigger:["\\le"],kind:"infix",associativity:"any",precedence:241},{latexTrigger:["\\leq"],kind:"infix",associativity:"any",precedence:241,parse:"LessEqual"},{latexTrigger:["\\leqslant"],kind:"infix",associativity:"any",precedence:w+5,parse:"LessEqual"},{latexTrigger:["\u2264"],kind:"infix",associativity:"any",precedence:241,parse:"LessEqual"},{latexTrigger:["\u2265"],kind:"infix",associativity:"any",precedence:242,parse:"GreaterEqual"},{latexTrigger:["\u2260"],kind:"infix",associativity:"right",precedence:255,parse:"NotEqual"},{name:"LessNotEqual",latexTrigger:["\\lneqq"],kind:"infix",associativity:"any",precedence:w},{name:"NotLessNotEqual",latexTrigger:["\\nleqq"],kind:"infix",associativity:"any",precedence:w},{name:"LessOverEqual",latexTrigger:["\\leqq"],kind:"infix",associativity:"any",precedence:w+5},{name:"GreaterOverEqual",latexTrigger:["\\geqq"],kind:"infix",associativity:"any",precedence:w+5,parse:"GreaterEqual"},{name:"Equal",latexTrigger:["="],kind:"infix",associativity:"right",precedence:w},{latexTrigger:["*","="],kind:"infix",associativity:"right",precedence:w,parse:"StarEqual"},{name:"StarEqual",latexTrigger:["\\star","="],kind:"infix",associativity:"right",precedence:w},{name:"PlusEqual",latexTrigger:["+","="],kind:"infix",associativity:"right",precedence:w},{name:"MinusEqual",latexTrigger:["-","="],kind:"infix",associativity:"right",precedence:w},{name:"SlashEqual",latexTrigger:["/","="],kind:"infix",associativity:"right",precedence:w},{latexTrigger:["=","="],kind:"infix",associativity:"right",precedence:w,parse:"Equal"},{name:"EqualEqualEqual",latexTrigger:["=","=","="],kind:"infix",associativity:"right",precedence:w+5},{name:"Tilde",latexTrigger:["\\sim"],kind:"infix",associativity:"right",precedence:w},{name:"NotTilde",latexTrigger:["\\nsim"],kind:"infix",associativity:"right",precedence:w},{name:"TildeEqual",latexTrigger:["\\simeq"],kind:"infix",associativity:"right",precedence:w},{name:"TildeFullEqual",latexTrigger:["\\cong"],kind:"infix",associativity:"right",precedence:w},{name:"NotTildeFullEqual",latexTrigger:["\\ncong"],kind:"infix",associativity:"right",precedence:w},{name:"Approx",latexTrigger:["\\approx"],kind:"infix",associativity:"right",precedence:247},{latexTrigger:["\u2248"],kind:"infix",associativity:"right",precedence:247,parse:"Approx"},{name:"NotApprox",latexTrigger:["\\not","\\approx"],kind:"infix",associativity:"right",precedence:247},{name:"ApproxEqual",latexTrigger:["\\approxeq"],kind:"infix",associativity:"right",precedence:w},{name:"NotApproxEqual",latexTrigger:["\\not","\\approxeq"],kind:"infix",associativity:"right",precedence:250},{name:"NotEqual",latexTrigger:["\\ne"],kind:"infix",associativity:"right",precedence:255},{latexTrigger:["\\neq"],kind:"infix",associativity:"right",precedence:255,parse:"NotEqual"},{latexTrigger:["\\not","="],kind:"infix",associativity:"right",precedence:255,parse:"NotEqual"},{latexTrigger:["\\not","\\le"],kind:"infix",associativity:"right",precedence:241,parse:Ds("LessEqual",241)},{latexTrigger:["\\not","\\leq"],kind:"infix",associativity:"right",precedence:241,parse:Ds("LessEqual",241)},{latexTrigger:["\\not","\\ge"],kind:"infix",associativity:"right",precedence:242,parse:Ds("GreaterEqual",242)},{latexTrigger:["\\not","\\geq"],kind:"infix",associativity:"right",precedence:242,parse:Ds("GreaterEqual",242)},{name:"Unequal",latexTrigger:["!","="],kind:"infix",associativity:"right",precedence:w,parse:"NotEqual"},{name:"GreaterEqual",latexTrigger:["\\ge"],kind:"infix",associativity:"right",precedence:242},{latexTrigger:["\\geq"],kind:"infix",associativity:"right",precedence:242,parse:"GreaterEqual"},{latexTrigger:[">","="],kind:"infix",associativity:"right",precedence:243,parse:"GreaterEqual"},{latexTrigger:["\\geqslant"],kind:"infix",associativity:"right",precedence:w+5,parse:"GreaterEqual"},{name:"GreaterNotEqual",latexTrigger:["\\gneqq"],kind:"infix",associativity:"right",precedence:w},{name:"NotGreaterNotEqual",latexTrigger:["\\ngeqq"],kind:"infix",associativity:"right",precedence:w},{latexTrigger:[">"],kind:"infix",associativity:"right",precedence:245,parse:"Greater"},{name:"Greater",latexTrigger:["\\gt"],kind:"infix",associativity:"right",precedence:245},{name:"NotGreater",latexTrigger:["\\ngtr"],kind:"infix",associativity:"right",precedence:244},{latexTrigger:["\\not",">"],kind:"infix",associativity:"right",precedence:244,parse:"NotGreater"},{name:"RingEqual",latexTrigger:["\\circeq"],kind:"infix",associativity:"right",precedence:w},{name:"TriangleEqual",latexTrigger:["\\triangleq"],kind:"infix",associativity:"right",precedence:w},{name:"DotEqual",latexTrigger:["\\doteq"],kind:"infix",associativity:"right",precedence:w+5},{name:"DotEqualDot",latexTrigger:["\\doteqdot"],kind:"infix",associativity:"right",precedence:w+5},{name:"FallingDotEqual",latexTrigger:["\\fallingdotseq"],kind:"infix",associativity:"right",precedence:w+5},{name:"RisingDotEqual",latexTrigger:["\\fallingdotseq"],kind:"infix",associativity:"right",precedence:w+5},{name:"QuestionEqual",latexTrigger:["\\questeq"],kind:"infix",associativity:"right",precedence:w},{name:"MuchLess",latexTrigger:["\\ll"],kind:"infix",associativity:"right",precedence:w},{name:"MuchGreater",latexTrigger:["\\gg"],kind:"infix",associativity:"right",precedence:w},{name:"Precedes",latexTrigger:["\\prec"],kind:"infix",associativity:"right",precedence:w},{name:"Succeeds",latexTrigger:["\\succ"],kind:"infix",associativity:"right",precedence:w},{name:"PrecedesEqual",latexTrigger:["\\preccurlyeq"],kind:"infix",associativity:"right",precedence:w},{name:"SucceedsEqual",latexTrigger:["\\curlyeqprec"],kind:"infix",associativity:"right",precedence:w},{name:"NotPrecedes",latexTrigger:["\\nprec"],kind:"infix",associativity:"right",precedence:w},{name:"NotSucceeds",latexTrigger:["\\nsucc"],kind:"infix",associativity:"right",precedence:w},{name:"Between",latexTrigger:["\\between"],kind:"infix",associativity:"right",precedence:w+5}];var Cs=new Set(["Integers","RationalNumbers","RealNumbers","ComplexNumbers"]),Gc;function Ta(e){return typeof e!="string"?!1:(Gc??=new Set(et.map(n=>n.name).filter(n=>typeof n=="string")),Gc.has(e))}function bi(e){return typeof e!="string"?!1:["Less","LessEqual","Greater","GreaterEqual"].includes(e)}function xi(e){return typeof e!="string"?!1:["Equal","NotEqual"].includes(e)}var pe=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Be=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},Cg=function(e){var n=Math.PI/4;if(-n>e||e>n)return Math.cos(e)-1;var t=e*e;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Og=function(e,n){var t=Math.abs(e),i=Math.abs(n);return t<3e3&&i<3e3?Math.sqrt(t*t+i*i):(t<i?(t=i,i=e/n):i=n/e,t*Math.sqrt(1+i*i))},At=function(){throw SyntaxError("Invalid Param")};function Na(e,n){var t=Math.abs(e),i=Math.abs(n);return e===0?Math.log(i):n===0?Math.log(t):t<3e3&&i<3e3?Math.log(e*e+n*n)*.5:(e=e/2,n=n/2,.5*Math.log(e*e+n*n)+Math.LN2)}var Bg=function(e,n){var t={re:0,im:0};if(e==null)t.re=t.im=0;else if(n!==void 0)t.re=e,t.im=n;else switch(typeof e){case"object":if("im"in e&&"re"in e)t.re=e.re,t.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return ne.INFINITY;t.re=e.abs*Math.cos(e.arg),t.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return ne.INFINITY;t.re=e.r*Math.cos(e.phi),t.im=e.r*Math.sin(e.phi)}else e.length===2?(t.re=e[0],t.im=e[1]):At();break;case"string":t.im=t.re=0;var i=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,s=0;i===null&&At();for(var o=0;o<i.length;o++){var a=i[o];a===" "||a===" "||a===`
7
7
  `||(a==="+"?r++:a==="-"?s++:a==="i"||a==="I"?(r+s===0&&At(),i[o+1]!==" "&&!isNaN(Number(i[o+1]))?(t.im+=parseFloat((s%2?"-":"")+i[o+1]),o++):t.im+=parseFloat((s%2?"-":"")+"1"),r=s=0):((r+s===0||isNaN(Number(a)))&&At(),i[o+1]==="i"||i[o+1]==="I"?(t.im+=parseFloat((s%2?"-":"")+a),o++):t.re+=parseFloat((s%2?"-":"")+a),r=s=0))}r+s>0&&At();break;case"number":t.im=0,t.re=e;break;default:At()}return isNaN(t.re)||isNaN(t.im),t},ne=class e{constructor(n,t){this.re=0,this.im=0;var i=Bg(n,t);this.re=i.re,this.im=i.im}sign(){var n=this.abs();return new e(this.re/n,this.im/n)}add(n,t){var i=new e(n,t);return this.isInfinite()&&i.isInfinite()?e.NAN:this.isInfinite()||i.isInfinite()?e.INFINITY:new e(this.re+i.re,this.im+i.im)}sub(n,t){var i=new e(n,t);return this.isInfinite()&&i.isInfinite()?e.NAN:this.isInfinite()||i.isInfinite()?e.INFINITY:new e(this.re-i.re,this.im-i.im)}mul(n,t){var i=new e(n,t);return this.isInfinite()&&i.isZero()||this.isZero()&&i.isInfinite()?e.NAN:this.isInfinite()||i.isInfinite()?e.INFINITY:i.im===0&&this.im===0?new e(this.re*i.re,0):new e(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)}div(n,t){var i=new e(n,t);if(this.isZero()&&i.isZero()||this.isInfinite()&&i.isInfinite())return e.NAN;if(this.isInfinite()||i.isZero())return e.INFINITY;if(this.isZero()||i.isInfinite())return e.ZERO;n=this.re,t=this.im;var r=i.re,s=i.im,o,a;return s===0?new e(n/r,t/r):Math.abs(r)<Math.abs(s)?(a=r/s,o=r*a+s,new e((n*a+t)/o,(t*a-n)/o)):(a=s/r,o=s*a+r,new e((n+t*a)/o,(t-n*a)/o))}pow(n,t){var i=new e(n,t);if(n=this.re,t=this.im,i.isZero())return e.ONE;if(i.im===0){if(t===0&&n>0)return new e(Math.pow(n,i.re),0);if(n===0)switch((i.re%4+4)%4){case 0:return new e(Math.pow(t,i.re),0);case 1:return new e(0,Math.pow(t,i.re));case 2:return new e(-Math.pow(t,i.re),0);case 3:return new e(0,-Math.pow(t,i.re))}}if(n===0&&t===0&&i.re>0&&i.im>=0)return e.ZERO;var r=Math.atan2(t,n),s=Na(n,t);return n=Math.exp(i.re*s-i.im*r),t=i.im*s+i.re*r,new e(n*Math.cos(t),n*Math.sin(t))}sqrt(){var n=this.re,t=this.im,i=this.abs(),r,s;if(n>=0){if(t===0)return new e(Math.sqrt(n),0);r=.5*Math.sqrt(2*(i+n))}else r=Math.abs(t)/Math.sqrt(2*(i-n));return n<=0?s=.5*Math.sqrt(2*(i-n)):s=Math.abs(t)/Math.sqrt(2*(i+n)),new e(r,t<0?-s:s)}exp(){var n=Math.exp(this.re);return this.im,new e(n*Math.cos(this.im),n*Math.sin(this.im))}expm1(){var n=this.re,t=this.im;return new e(Math.expm1(n)*Math.cos(t)+Cg(t),Math.exp(n)*Math.sin(t))}log(){var n=this.re,t=this.im;return t===0&&n>0,new e(Na(n,t),Math.atan2(t,n))}abs(){return Og(this.re,this.im)}arg(){return Math.atan2(this.im,this.re)}sin(){var n=this.re,t=this.im;return new e(Math.sin(n)*pe(t),Math.cos(n)*Be(t))}cos(){var n=this.re,t=this.im;return new e(Math.cos(n)*pe(t),-Math.sin(n)*Be(t))}tan(){var n=2*this.re,t=2*this.im,i=Math.cos(n)+pe(t);return new e(Math.sin(n)/i,Be(t)/i)}cot(){var n=2*this.re,t=2*this.im,i=Math.cos(n)-pe(t);return new e(-Math.sin(n)/i,Be(t)/i)}sec(){var n=this.re,t=this.im,i=.5*pe(2*t)+.5*Math.cos(2*n);return new e(Math.cos(n)*pe(t)/i,Math.sin(n)*Be(t)/i)}csc(){var n=this.re,t=this.im,i=.5*pe(2*t)-.5*Math.cos(2*n);return new e(Math.sin(n)*pe(t)/i,-Math.cos(n)*Be(t)/i)}asin(){var n=this.re,t=this.im,i=new e(t*t-n*n+1,-2*n*t).sqrt(),r=new e(i.re-t,i.im+n).log();return new e(r.im,-r.re)}acos(){var n=this.re,t=this.im,i=new e(t*t-n*n+1,-2*n*t).sqrt(),r=new e(i.re-t,i.im+n).log();return new e(Math.PI/2-r.im,r.re)}atan(){var n=this.re,t=this.im;if(n===0){if(t===1)return new e(0,1/0);if(t===-1)return new e(0,-1/0)}var i=n*n+(1-t)*(1-t),r=new e((1-t*t-n*n)/i,-2*n/i).log();return new e(-.5*r.im,.5*r.re)}acot(){var n=this.re,t=this.im;if(t===0)return new e(Math.atan2(1,n),0);var i=n*n+t*t;return i!==0?new e(n/i,-t/i).atan():new e(n!==0?n/0:0,t!==0?-t/0:0).atan()}asec(){var n=this.re,t=this.im;if(n===0&&t===0)return new e(0,1/0);var i=n*n+t*t;return i!==0?new e(n/i,-t/i).acos():new e(n!==0?n/0:0,t!==0?-t/0:0).acos()}acsc(){var n=this.re,t=this.im;if(n===0&&t===0)return new e(Math.PI/2,1/0);var i=n*n+t*t;return i!==0?new e(n/i,-t/i).asin():new e(n!==0?n/0:0,t!==0?-t/0:0).asin()}sinh(){var n=this.re,t=this.im;return new e(Be(n)*Math.cos(t),pe(n)*Math.sin(t))}cosh(){var n=this.re,t=this.im;return new e(pe(n)*Math.cos(t),Be(n)*Math.sin(t))}tanh(){var n=2*this.re,t=2*this.im,i=pe(n)+Math.cos(t);return new e(Be(n)/i,Math.sin(t)/i)}coth(){var n=2*this.re,t=2*this.im,i=pe(n)-Math.cos(t);return new e(Be(n)/i,-Math.sin(t)/i)}csch(){var n=this.re,t=this.im,i=Math.cos(2*t)-pe(2*n);return new e(-2*Be(n)*Math.cos(t)/i,2*pe(n)*Math.sin(t)/i)}sech(){var n=this.re,t=this.im,i=Math.cos(2*t)+pe(2*n);return new e(2*pe(n)*Math.cos(t)/i,-2*Be(n)*Math.sin(t)/i)}asinh(){var n=this.im;this.im=-this.re,this.re=n;var t=this.asin();return this.re=-this.im,this.im=n,n=t.re,t.re=-t.im,t.im=n,t}acosh(){var n=this.acos();if(n.im<=0){var t=n.re;n.re=-n.im,n.im=t}else{var t=n.im;n.im=-n.re,n.re=t}return n}atanh(){var n=this.re,t=this.im,i=n>1&&t===0,r=1-n,s=1+n,o=r*r+t*t,a=o!==0?new e((s*r-t*t)/o,(t*r+s*t)/o):new e(n!==-1?n/0:0,t!==0?t/0:0),u=a.re;return a.re=Na(a.re,a.im)/2,a.im=Math.atan2(a.im,u)/2,i&&(a.im=-a.im),a}acoth(){var n=this.re,t=this.im;if(n===0&&t===0)return new e(0,Math.PI/2);var i=n*n+t*t;return i!==0?new e(n/i,-t/i).atanh():new e(n!==0?n/0:0,t!==0?-t/0:0).atanh()}acsch(){var n=this.re,t=this.im;if(t===0)return new e(n!==0?Math.log(n+Math.sqrt(n*n+1)):1/0,0);var i=n*n+t*t;return i!==0?new e(n/i,-t/i).asinh():new e(n!==0?n/0:0,t!==0?-t/0:0).asinh()}asech(){var n=this.re,t=this.im;if(this.isZero())return e.INFINITY;var i=n*n+t*t;return i!==0?new e(n/i,-t/i).acosh():new e(n!==0?n/0:0,t!==0?-t/0:0).acosh()}inverse(){if(this.isZero())return e.INFINITY;if(this.isInfinite())return e.ZERO;var n=this.re,t=this.im,i=n*n+t*t;return new e(n/i,-t/i)}conjugate(){return new e(this.re,-this.im)}neg(){return new e(-this.re,-this.im)}ceil(n){return n=Math.pow(10,n||0),new e(Math.ceil(this.re*n)/n,Math.ceil(this.im*n)/n)}floor(n){return n=Math.pow(10,n||0),new e(Math.floor(this.re*n)/n,Math.floor(this.im*n)/n)}round(n){return n=Math.pow(10,n||0),new e(Math.round(this.re*n)/n,Math.round(this.im*n)/n)}equals(n,t){var i=new e(n,t);return Math.abs(i.re-this.re)<=e.EPSILON&&Math.abs(i.im-this.im)<=e.EPSILON}clone(){return new e(this.re,this.im)}toString(){var n=this.re,t=this.im,i="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(n)<e.EPSILON&&(n=0),Math.abs(t)<e.EPSILON&&(t=0),t===0?i+n:(n!==0?(i+=n,i+=" ",t<0?(t=-t,i+="-"):i+="+",i+=" "):t<0&&(t=-t,i+="-"),t!==1&&(i+=t),i+"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())}};ne.ZERO=new ne(0,0);ne.ONE=new ne(1,0);ne.I=new ne(0,1);ne.PI=new ne(Math.PI,0);ne.E=new ne(Math.E,0);ne.INFINITY=new ne(1/0,1/0);ne.NAN=new ne(NaN,NaN);ne.EPSILON=1e-15;var K1=(()=>{if(typeof process>"u")return!1;let e=process.env?.CE_CHECKPOINT_CANARY;return e!==void 0&&e!=="0"})();var Lg=new WeakSet;function Sa(e){return typeof e=="object"&&Lg.has(e)}function G(e){if(typeof e=="string")return yt(e)?e:"error";switch(e.kind){case"union":return ka(e);case"intersection":return Wg(e);case"negation":return Jg(e);case"collection":case"indexed_collection":return Yg(e.kind,e);case"list":return Xg(e);case"set":return Kg(e);case"broadcastable":return Qg(e);case"tuple":return eh(e);case"record":return nh(e);case"object":return th(e);case"dictionary":return ih(e);case"signature":return rh(e);case"value":return e;case"reference":return e;case"numeric":return e.lower!==void 0&&e.upper!==void 0&&e.lower>e.upper?"never":e;case"symbol":return e;case"expression":return e;case"variable":return e;default:throw new Error(`Unknown type kind: ${e}`)}}function H(e){return typeof e!="object"||Object.isFrozen(e)||Object.prototype.hasOwnProperty.call(e,"toString")||Object.defineProperty(e,"toString",{value:()=>A(e)}),e}function Vg(e){return typeof e=="string"?!1:A(e)!==Qe(e)}function Hc(e,n,t,i){let r=n.get(t);if(r===void 0){n.set(t,e.length),e.push(i);return}typeof i!="string"&&A(i)!==t&&!Vg(e[r])&&(e[r]=i)}function Jg(e){let n=G(e.type);return n==="never"?"any":n==="any"?"never":H({kind:"negation",type:n})}function jg(e){let n=[],t=new Map,i=r=>{if(typeof r=="object"&&r.kind==="union"){for(let s of r.types)i(s);return}Hc(n,t,Qe(r),r)};for(let r of e)i(G(r));return n}function $g(e){return e.map(n=>[typeof n=="string"?n:A(n),n]).sort((n,t)=>n[0]<t[0]?-1:n[0]>t[0]?1:0).map(([,n])=>n)}function ka(e){let n=jg(e.types);if(n.length===0)return"never";if(n.some(i=>i==="error"))return"error";if(n.length===1)return H(n[0]);let t=[];for(let i of n)if(t.findIndex(s=>x(i,s))===-1){for(let s=t.length-1;s>=0;s--)x(t[s],i)&&t.splice(s,1);t.push(i)}return t.length===1?H(t[0]):H({kind:"union",types:$g(t)})}function Os(e,n){if(Wn("meet",e),Wn("meet",n),x(e,n))return e;if(x(n,e))return n;let t=Uc(e);if(t!==void 0)return Os(t,n);let i=Uc(n);if(i!==void 0)return Os(e,i);if(typeof e=="object"&&e.kind==="union")return Zc(e.types,n);if(typeof n=="object"&&n.kind==="union")return Zc(n.types,e);let r=typeof e=="object"&&e.kind==="negation"?e:void 0,s=typeof n=="object"&&n.kind==="negation"?n:void 0;if(r!==void 0&&s!==void 0)return G({kind:"negation",type:{kind:"union",types:[r.type,s.type]}});if(r!==void 0||s!==void 0){let u=(r??s).type,l=r!==void 0?n:e;if(x(l,u))return"never";let c=Wc(u),f=Ia(l);if(c!==void 0&&f!==null&&typeof l=="object"){let p=f.lower??-1/0,h=f.upper??1/0,y=f.lowerOpen===!0,N=f.upperOpen===!0,D=[];for(let J of c)if(!(J<p||J>h)){if(J===p&&J===h)return"never";J===p?y=!0:J===h?N=!0:D.push(J)}let R=Rn(f.type,p,h,y,N);if(D.length===0)return R;let z=D.length===1?{kind:"negation",type:{kind:"value",value:D[0]}}:{kind:"negation",type:{kind:"union",types:D.map(J=>({kind:"value",value:J}))}};return{kind:"intersection",types:[R,z]}}return}if(typeof e=="string"&&typeof n=="string"){let u=fi(e,n);return u.length===0?"never":u.length===1?u[0]:{kind:"union",types:u}}if(typeof e=="object"&&e.kind==="numeric"||typeof n=="object"&&n.kind==="numeric"){let u=Ia(e),l=Ia(n);if(u&&l)return Hg(u,l)}let o=qg(e,n);if(o!==void 0)return o;let a=zg(e,n)??Gg(e,n);if(a!==void 0)return a;if(!Ug(e,n))return"never"}function Uc(e){if(!(typeof e!="object"||e.kind!=="broadcastable"))return{kind:"union",types:[e.elements,{kind:"indexed_collection",elements:e.elements}]}}function qg(e,n){if(typeof e!="object"||typeof n!="object"||e.kind!==n.kind)return;let t=(i,r)=>G({kind:"intersection",types:[i,r]});switch(e.kind){case"list":{let i=n;return(e.dimensions?.join()??"")!==(i.dimensions?.join()??"")?void 0:H({...e,elements:t(e.elements,i.elements)})}case"set":case"collection":case"indexed_collection":return H({...e,elements:t(e.elements,n.elements)});case"dictionary":return H({...e,values:t(e.values,n.values)});default:return}}function zg(e,n){if(typeof e!="object"||typeof n!="object"||e.kind!=="tuple"||n.kind!=="tuple")return;if(e.elements.length!==n.elements.length)return"never";let t=[];for(let i=0;i<e.elements.length;i++){let r=e.elements[i],s=n.elements[i];if(r.name!==void 0&&s.name!==void 0&&r.name!==s.name)return"never";let o=G({kind:"intersection",types:[r.type,s.type]});if(Yn(o))return"never";let a=r.name??s.name;t.push(a===void 0?{type:o}:{name:a,type:o})}return H({kind:"tuple",elements:t})}function Gg(e,n){if(typeof e!="object"||typeof n!="object"||e.kind!=="record"||n.kind!=="record")return;let t={...e.elements};for(let[i,r]of Object.entries(n.elements)){if(!Object.prototype.hasOwnProperty.call(t,i)){t[i]=r;continue}let s=G({kind:"intersection",types:[t[i],r]});if(Yn(s))return"never";t[i]=s}return H({kind:"record",elements:t})}function Ug(e,n){return typeof e=="object"&&typeof n=="object"&&e.kind==="signature"&&n.kind==="signature"}function Zg(e){let n=[],t=new Map,i=r=>{if(typeof r=="object"&&r.kind==="intersection"){for(let s of r.types)i(s);return}Hc(n,t,Qe(r),r)};for(let r of e)i(G(r));return n}function Ia(e){return typeof e=="object"?e.kind==="numeric"?e:null:pn.has(e)?{kind:"numeric",type:e}:null}function Hg(e,n){let t=fi(e.type,n.type);if(t.length===0)return"never";let i=e.lower??-1/0,r=n.lower??-1/0,s=e.upper??1/0,o=n.upper??1/0,a=Math.max(i,r),u=Math.min(s,o),l=i===a&&e.lowerOpen===!0||r===a&&n.lowerOpen===!0,c=s===u&&e.upperOpen===!0||o===u&&n.upperOpen===!0;if(a>u||a===u&&(l||c))return"never";let f=a!==-1/0||u!==1/0,p=[];for(let h of t)f&&(h==="infinity"||h==="nan")||p.push(Rn(h,a,u,l,c));return p.length===0?"never":p.length===1?p[0]:ka({kind:"union",types:p})}function Wc(e){if(typeof e=="object"){if(e.kind==="value")return typeof e.value=="number"&&!Number.isNaN(e.value)?[e.value]:void 0;if(e.kind==="union"){let n=[];for(let t of e.types){let i=Wc(t);if(i===void 0)return;n.push(...i)}return n}}}function Zc(e,n){let t=[];for(let i of e){let r=Os(i,n);r!==void 0&&Yn(r)||t.push(r===void 0?{kind:"intersection",types:[i,n]}:r)}return t.length===0?"never":t.length===1?t[0]:ka({kind:"union",types:t})}function Wg(e){let n=Zg(e.types);if(n.length===0)return"any";if(n.some(i=>i==="error"))return"error";let t=[];for(let i of n){let r=i,s=-1;for(let o=0;o<t.length;){let a=Os(t[o],r);if(a!==void 0&&Yn(a))return"never";if(a===void 0){o+=1;continue}s===-1&&(s=o),t.splice(o,1),r=a}s===-1?t.push(r):t.splice(s,0,r)}return t.length===1?H(t[0]):H({...e,types:t})}function Yg(e,n){let t=G(n.elements);return t==="error"?"error":t==="nothing"?H({kind:e,elements:"nothing"}):t==="unknown"?e:H({...n,elements:t})}function Xg(e){let n=G(e.elements);if(n==="error")return"error";if(n==="nothing")return H({kind:"list",elements:"nothing"});let t=e.dimensions;return t&&(t=t.filter(i=>i>=1||i===-1),t.length===0)?"nothing":n==="unknown"&&t===void 0?"list":H({...e,dimensions:t,elements:n})}function Kg(e){let n=G(e.elements);return n==="error"?"error":n==="nothing"?H({kind:"set",elements:"nothing"}):n==="unknown"?"set":H({...e,elements:n})}function Qg(e){let n=G(e.elements);return n==="error"?"error":H({...e,elements:n})}function eh(e){let n=e.elements.map(t=>({...t,type:G(t.type)}));return n.length===0?"nothing":n.some(t=>t.type==="error")?"error":n.some(t=>Yn(t.type))?"never":(n=n.filter(t=>t.type!=="nothing"),n.length===0?"nothing":H({...e,elements:n}))}function nh(e){let n={};for(let[t,i]of Object.entries(e.elements))n[t]=G(i);return Object.values(n).some(t=>t==="error")?"error":Object.values(n).some(t=>Yn(t))?"never":(n=Object.fromEntries(Object.entries(n).filter(([t,i])=>i!=="nothing")),Object.keys(n).length===0?"record":H({...e,elements:n}))}function th(e){let n={};for(let[t,i]of Object.entries(e.elements))n[t]=G(i);return Object.values(n).some(t=>t==="error")?"error":H({...e,elements:n})}function ih(e){let n=G(e.values);return n==="error"?"error":n==="nothing"?H({kind:"dictionary",values:"nothing"}):n==="unknown"?"dictionary":H({kind:"dictionary",values:n})}function rh(e){let n=e.args?.map(s=>({...s,type:G(s.type)})),t=e.optArgs?.map(s=>({...s,type:G(s.type)})),i=e.variadicArg?{...e.variadicArg,type:G(e.variadicArg.type)}:void 0,r=G(e.result);return n?.some(s=>s.type==="error")||t?.some(s=>s.type==="error")||i?.type==="error"||r==="error"?"error":(t=t?.filter(s=>s.type!=="nothing"),n?.length===0&&(t=void 0),t?.length===0&&(t=void 0),i?.type==="nothing"&&(i=void 0),H({...e,args:n,optArgs:t,variadicArg:i,variadicMin:i?e.variadicMin:void 0,effects:e.effects===void 0?void 0:as(e.effects),result:r}))}function Ma(e){if(typeof e=="string"||e.kind==="numeric"&&e.type!=="rational")return e;let t=We(e,!0,{co:new Map,contra:new Map});return t===e||x(e,t)||t==="error"&&G(e),t}function We(e,n,t){if(typeof e=="string")return e;let i=n?t.co:t.contra,r=i.get(e);if(r!==void 0)return r;let s=sh(e,n,t);return i.set(e,s),s}function sh(e,n,t){switch(e.kind){case"value":{if(!n)return e;let i=e.value;return ge(i)?"infinity":typeof i!="number"?e:Number.isNaN(i)?"nan":Number.isFinite(i)?Number.isInteger(i)?"integer":"real":Lo}case"union":case"intersection":{let i=e.types.map(r=>We(r,n,t));return i.every((r,s)=>r===e.types[s])?e:G({...e,types:i})}case"negation":{let i=We(e.type,!n,t);return i===e.type?e:{...e,type:i}}case"list":case"set":case"collection":case"indexed_collection":case"broadcastable":{let i=We(e.elements,n,t);return i===e.elements?e:{...e,elements:i}}case"dictionary":{let i=We(e.values,n,t);return i===e.values?e:{...e,values:i}}case"tuple":{let i=e.elements.map(r=>{let s=We(r.type,n,t);return s===r.type?r:{...r,type:s}});return i.every((r,s)=>r===e.elements[s])?e:{...e,elements:i}}case"signature":{let i=!n,r=f=>{if(!f)return{changed:!1,els:f};let p=f.map(h=>{let y=We(h.type,i,t);return y===h.type?h:{...h,type:y}});return{changed:p.some((h,y)=>h!==f[y]),els:p}},s=r(e.args),o=r(e.optArgs),a=e.variadicArg?We(e.variadicArg.type,i,t):void 0,u=We(e.result,n,t),l=e.typeParams?.map(f=>{if(f.bound===void 0)return f;let p=We(f.bound,n,t);return p===f.bound?f:{...f,bound:p}}),c=l!==void 0&&l.some((f,p)=>f!==e.typeParams[p]);return!s.changed&&!o.changed&&(e.variadicArg===void 0||a===e.variadicArg.type)&&u===e.result&&!c?e:{...e,...s.els!==void 0?{args:s.els}:{},...o.els!==void 0?{optArgs:o.els}:{},...e.variadicArg!==void 0?{variadicArg:{...e.variadicArg,type:a}}:{},...l!==void 0?{typeParams:l}:{},result:u}}case"reference":{if(!e.args)return e;let i=e.args.map((r,s)=>{let o=xt(e,s);return o==="inout"?r:We(r,o==="out"?n:!n,t)});return i.every((r,s)=>r===e.args[s])?e:{...e,args:i}}case"numeric":return n&&e.type==="rational"&&typeof e.lower=="number"&&e.lower===e.upper&&Number.isFinite(e.lower)?e.type:e;case"object":case"record":case"variable":case"symbol":case"expression":return e;default:return e}}var oh={primitives:new Map,composites:new WeakMap,results:new WeakMap},Yc=new WeakMap;function Xc(e){if(e===void 0)return oh;let n=Yc.get(e);return n===void 0&&(n={primitives:new Map,composites:new WeakMap,results:new WeakMap},Yc.set(e,n)),n}function Kc(e){if(!(e===null||typeof e!="object"||Object.isFrozen(e))){Object.freeze(e);for(let n of Object.values(e))Kc(n)}}var Se=class e{static unknown=new e("unknown");static number=new e("number");static signed_infinity=new e("+oo | -oo");static infinity=new e("infinity");static nan=new e("nan");static complex=new e("complex");static real=new e("real");static integer=new e("integer");static string=new e("string");static character=new e("character");static dictionary=new e("dictionary");static setNumber=new e("set<number>");static setComplex=new e("set<complex>");static setImaginary=new e("set<imaginary>");static setReal=new e("set<real>");static setRational=new e("set<rational>");static setInteger=new e("set<integer>");type;#n;#e;get facts(){return this.#n?.type===this.type?this.#n:this.#n=Is(this.type)}static from(n,t){if(n instanceof e)return n;let i=typeof n=="string"&&!yt(n)?re(n,t):n,r=Xc(t);if(typeof i=="string"){let o=r.primitives.get(i);return(o===void 0||o.type!==i)&&(o=new e(i,t),r.primitives.set(i,o)),o}if(!Sa(i)&&!Ss(i))return new e(i,t);let s=r.composites.get(i);return(s===void 0||s.type!==i)&&(s=new e(i,t),r.composites.set(i,s)),s}static forResult(n,t){if(n===void 0)return;let i=n instanceof e?n:void 0;t=i?.typeResolver??t;let r=i?.typeResolver===t?i:void 0,s=i?.type??(typeof n=="string"&&!yt(n)?re(n,t):n);if(r!==void 0&&r.#e===s)return r;if(typeof s=="string"||Sa(s))return r??e.from(s,t);let o=Ss(s),a=Xc(t),u=o?a.results.get(s):void 0;if(u!==void 0&&u.boxed.type===u.type)return u.type===s&&r!==void 0?(r.#e=s,r):(u.boxed.#e=u.type,u.boxed);let l=Ma(s);o&&l!==s&&Kc(l);let c=l===s&&r!==void 0?r:e.from(l,t);if(o){c.#e=l;let f={boxed:c,type:l};a.results.set(s,f),typeof l=="object"&&a.results.set(l,f)}return c}isPolymorphic;_typeResolver;get typeResolver(){return this._typeResolver}static _resolverOf(n){for(let t of n)if(t instanceof e&&t._typeResolver!==void 0)return t._typeResolver}static widen(...n){return new e(hn(...n.map(t=>t instanceof e?t.type:t)),e._resolverOf(n))}static narrow(...n){return new e(Ts(...n.map(t=>t instanceof e?t.type:t)),e._resolverOf(n))}constructor(n,t){if(this._typeResolver=t,typeof n=="string"?this.type=re(n,t):this.type=n,this.isPolymorphic=_n(this.type),typeof this.type=="object"&&typeof n!="string"){if(Te(this.type)){let i=new Error(`The type \`${A(this.type)}\` is invalid: ${ii}`);throw i.code="variadic-with-optional",i.rawMessage=ii,i}if(this.isPolymorphic)hs(this.type,t);else if(ze(this.type))throw new en("unresolved-type-variable",`The type \`${A(this.type)}\` refers to a type variable that is not quantified by a \`where\` clause: an open type is not declarable`)}}_resolve(n){if(n instanceof e)return n.type;if(typeof n!="string"||yt(n))return n;try{return re(n)}catch(t){if(this._typeResolver===void 0)throw t;return re(n,this._typeResolver)}}matches(n){let t=this._resolve(n);if(!this.isPolymorphic&&_n(t))return Qo(this.type,t);if(!this.isPolymorphic)switch(t){case"integer":return this.facts.integer;case"rational":return this.facts.rational;case"real":return this.facts.real;case"imaginary":return this.facts.imaginary;case"complex":return this.facts.complex;case"number":return this.facts.belowNumber;case"nan":return this.facts.nan;case"infinity":return this.facts.infinity}return x(this.type,t)}is(n){let t=this._resolve(n);return x(this.type,t)&&x(t,this.type)}isDisjointFrom(n){return Z(this.type,this._resolve(n))}couldMatch(n){let t=this._resolve(n);return this.isPolymorphic||_n(t)?he(Tt(this.type),Tt(t)):he(this.type,t)}get unionMembers(){return typeof this.type=="object"&&this.type.kind==="union"?this.type.types.map(n=>new e(n,this._typeResolver)):[this]}get effects(){return yn(this.type)}get isUnknown(){return this.type==="unknown"}toString(){return A(this.type)}toJSON(){return this.toString()}[Symbol.toPrimitive](n){return n==="string"?this.toString():null}valueOf(){return this.toString()}};function Qc(e,n){for(;n!==BigInt(0);)[e,n]=[n,e%n];return e<0?-e:e}function ef(e){return e!==null&&Array.isArray(e)&&typeof e[0]=="number"}function Bs(e){if(ef(e)){if(e[1]<0&&(e=[-e[0],-e[1]]),e[0]===1||e[1]===1)return e;if(!Number.isFinite(e[1]))return[0,1];let r=gt(e[0],e[1]);return r<=1?e:[e[0]/r,e[1]/r]}e[1]<0&&(e=[-e[0],-e[1]]);let n=Qc(e[0],e[1]),[t,i]=n<=1?e:[e[0]/n,e[1]/n];return t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?[Number(t),Number(i)]:[t,i]}function Ei(e,n){if(!Number.isFinite(e))return null;for(let t=1;t<=1e6;t*=10){let i=e*t;if(Number.isInteger(i))return!Number.isSafeInteger(i)||!Number.isSafeInteger(n*t)?null:Bs([i,n*t])}return null}var Ti=["Error","'missing'"];function Ye(e){return!!(typeof e=="number"||Rt(e)||typeof e=="string"&&Js(e))}function Rt(e){return e!==null&&typeof e=="object"&&"num"in e}function Fs(e){return e!==null&&typeof e=="object"&&"sym"in e}function rf(e){return e!==null&&typeof e=="object"&&"str"in e}function sf(e){return e!==null&&typeof e=="object"&&"dict"in e&&typeof e.dict=="object"&&!Array.isArray(e.dict)&&e.dict!==null}function _t(e){return e!==null&&typeof e=="object"&&"fn"in e&&Array.isArray(e.fn)&&e.fn.length>0&&typeof e.fn[0]=="string"}function _(e){return e==null?null:typeof e=="object"&&"str"in e?e.str:typeof e!="string"?null:e.length>=2&&e.at(0)==="'"&&e.at(-1)==="'"?e.substring(1,e.length-1):Js(e)||_a(e)?null:e}function Aa(e){if(e==null||_(e)!==null)return null;let n=g(e);return n?[n,...b(e).map(t=>Aa(t)).filter(t=>t!==null)]:e}function g(e){return Array.isArray(e)?e[0]:e==null?"":_t(e)?e.fn[0]:""}function b(e){return Array.isArray(e)?e.slice(1):e!==void 0&&_t(e)?e.fn.slice(1):[]}function d(e,n){return Array.isArray(e)?e[n]??null:e===null||!_t(e)?null:e.fn[n]??null}function P(e){return e==null?0:Array.isArray(e)?Math.max(0,e.length-1):_t(e)?Math.max(0,e.fn.length-1):0}function Ra(e){return e==null?null:g(e)==="Hold"?d(e,1):e}function E(e){return typeof e=="string"&&_a(e)?e.length>=2&&e.at(0)==="`"&&e.at(-1)==="`"?e.slice(1,-1):e:e==null?null:Fs(e)?e.sym:null}function nf(e){let n=g(e);if(n==="KeyValuePair"||n==="Tuple"||n==="Pair"){let[t,i]=b(e),r=_(t);return r?[r,i??"Nothing"]:null}return null}function of(e){if(e===null)return null;if(sf(e))return e;let n=nf(e);if(n)return{dict:{[n[0]]:tf(n[1])??"Nothing"}};if(g(e)==="Dictionary"){let t={};for(let i of b(e)){let r=nf(i);r&&(t[r[0]]=tf(r[1])??"Nothing")}return{dict:t}}return null}function Ls(e){return{dict:Object.fromEntries(Object.entries(e).map(([t,i])=>[t,wa(i)??"Nothing"]))}}function uh(e){if(e=e.toLowerCase().replace(/[nd]$/,"").replace(/[\u0009-\u000d\u0020\u00a0]/g,""),e==="nan")return NaN;if(/^(infinity|\+infinity|oo|\+oo)$/i.test(e))return 1/0;if(/^(-infinity|-oo)$/.test(e))return-1/0;if(/\([0-9]+\)/.test(e)){let[n,t,i,r]=e.match(/(.+)\(([0-9]+)\)(.*)$/)??[];e=t+i.repeat(Math.ceil(16/i.length))+(r??"")}return parseFloat(e)}function M(e){return typeof e=="number"?e:typeof e=="string"&&Js(e)?uh(e):e!==void 0&&Rt(e)?M(e.num):null}function nt(e){if(e==null)return null;if(E(e)==="Half")return[1,2];let n=g(e);if(!n)return null;let t=null,i=null;if(n==="Negate"){let r=nt(b(e)[0]);if(r)return[-r[0],r[1]]}if(n==="Rational"||n==="Divide"){let[r,s]=b(e);t=M(r)??NaN,i=M(s)??NaN}if(n==="Power"){let[r,s]=b(e),o=M(s);o===1?(t=M(r),i=1):o===-1&&(t=1,i=M(r))}if(n==="Multiply"){let[r,s]=b(e);if(g(s)==="Power"){let[o,a]=b(s);M(a)===-1&&(t=M(r),i=M(o))}}return t===null||i===null?null:Number.isInteger(t)&&Number.isInteger(i)?[t,i]:null}function Vs(e,n){let t=null;if(Array.isArray(e)&&(t=e),_t(e)&&(t=e.fn),t===null)return[];let i=1,r=[];for(;i<t.length;)r.push(n(t[i])),i+=1;return r}function af(e,n,t){let i=g(n),r=g(t);return i===e&&r===e?[e,...b(n),...b(t)]:i===e?[e,...b(n),t]:r===e?[e,n,...b(t)]:[e,n,t]}function En(e){if(e==null)return null;let n=g(e);if(n==="Delimiter"){if(e=d(e,1),e===null)return[];if(n=g(e),n!=="Sequence")return[e]}return n!=="Sequence"?null:b(e)}function F(e){return e==null||e==="Nothing"?!0:g(e)==="Sequence"&&P(e)===0}function O(e){return F(e)?Ti:e}function Js(e){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(e)||/^[+-]?(0|[1-9][0-9]*)(\.([0-9]+(\([0-9]+\))?|\([0-9]+\)))?([eE][+-]?[0-9]+)?$/.test(e)}function _a(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)||e.length>=2&&e[0]==="`"&&e[e.length-1]==="`"}function wa(e){if(typeof e=="string")return{str:e};if(typeof e=="number")return{num:e.toString()};if(typeof e=="boolean")return e?"True":"False";if(Array.isArray(e))return["List",...e.map(n=>wa(n)??"Nothing")];if(e===null)return null;if(typeof e=="object"){let n={};for(let t in e)n[t]=wa(e[t])??"Nothing";return{dict:n}}return _t(e)||Fs(e)||Rt(e)||rf(e)||sf(e)?e:null}function tf(e){return e==null?null:rf(e)?e.str:Rt(e)?parseFloat(e.num):Fs(e)?e.sym:typeof e=="string"||typeof e=="number"?e:Array.isArray(e)?{fn:e}:e}function uf(e,n){return typeof e=="number"?Number.isFinite(e)?parseFloat(e.toPrecision(n)):e:e.toPrecision(n)}function Ni(e,n){return e.toFixed(n)}function Pa(e,n,t="auto"){if(t==="max")return{value:String(e),error:String(n)};if(typeof t=="object"&&"fractional"in t){let u=t.fractional;return{value:Ni(e,u),error:Ni(n,u)}}let i=t==="auto"?2:t.significant,r=uf(n,i),s=parseInt(r.toExponential().split("e")[1],10),o=i-1-s;if(o>0)return{value:Ni(e,o),error:Ni(r,o)};let a=Math.pow(10,-o);return{value:String(Math.round(e/a)*a),error:String(Math.round(r/a)*a)}}var yv=Object.freeze([0,1]);var qs=class e{_items;_version=0;constructor(n){n?n instanceof e?this._items=new Map(n._items):this._items=new Map(n):this._items=new Map}get size(){return this._items.size}get version(){return this._version}has(n){for(let t of this._items.keys())if(t.isSame(n))return!0;return!1}get(n){for(let[t,i]of this._items)if(t.isSame(n))return i}clear(){this._version+=1,this._items.clear()}set(n,t){this._version+=1;for(let i of this._items.keys())if(i.isSame(n)){this._items.set(i,t);return}this._items.set(n,t)}delete(n){this._version+=1;for(let t of this._items.keys())if(t.isSame(n)){this._items.delete(t);return}this._items.delete(n)}[Symbol.iterator](){return this._items.entries()}entries(){return this._items.entries()}};var NI=Object.freeze(new qs);var vI=Object.freeze(new Map);var SI=Object.freeze({bySubject:new Map,membership:new Map,geEdges:new Map,inequalitySubjects:new Set,typeByDefinition:new Map});var ek=[0,-1,1,Math.PI,Math.E,-Math.PI,-Math.E,.5,-.5];var jk=typeof process<"u"&&process.env?.CE_DEBUG_DEPS!==void 0&&process.env.CE_DEBUG_DEPS!=="0";var Uh=new Map;function Tn(e){for(let[n,t]of Object.entries(e))Uh.set(n,t)}Tn({"simplify-terms":"Simplify the terms",fu:"Apply trigonometric simplification (Fu algorithm)","exp-to-trig":"Rewrite exponentials as trigonometric functions (Euler\u2019s formula)","simplify-relational-operator":"Simplify both sides of the relation",addition:"Add the terms",multiplication:"Multiply the factors",division:"Divide the terms",negation:"Negate",power:"Evaluate the power",root:"Evaluate the root",sqrt:"Evaluate the square root",rational:"Simplify the fraction",expand:"Expand the expression","cancel common polynomial factors":"Cancel the common factors","partial fraction decomposition":"Decompose into partial fractions","a/a -> 1":"Cancel the common factor: a\u2044a = 1","combined powers":"Combine the powers","combined powers with same base":"Combine powers with the same base","x^n * x^m -> x^{n+m}":"Combine powers with the same base: x\u207F\xB7x\u1D50 = x\u207F\u207A\u1D50","x * x^n -> x^{n+1}":"Combine powers with the same base: x\xB7x\u207F = x\u207F\u207A\xB9","a^m / a^n -> a^{m-n}":"Subtract the exponents: a\u1D50\u2044a\u207F = a\u1D50\u207B\u207F","a^m / a -> a^{m-1}":"Subtract the exponents: a\u1D50\u2044a = a\u1D50\u207B\xB9","a / a^n -> a^{1-n}":"Subtract the exponents: a\u2044a\u207F = a\xB9\u207B\u207F","(-x)^n -> -x^n when n is odd":"Factor out the sign: (\u2212x)\u207F = \u2212x\u207F for odd n","(-x)^n -> x^n when n is even":"Drop the sign: (\u2212x)\u207F = x\u207F for even n","(-x)^{n/m} -> x^{n/m} when n is even and m is odd":"Drop the sign: (\u2212x)\u207F\u141F\u1D50 = x\u207F\u141F\u1D50 for even n and odd m","(-x)^{n/m} -> -x^{n/m} when n and m are odd":"Factor out the sign: (\u2212x)\u207F\u141F\u1D50 = \u2212x\u207F\u141F\u1D50 for odd n and m","root(-a, n) -> -root(a, n) when n odd":"Factor the sign out of the odd root: \u207F\u221A(\u2212a) = \u2212\u207F\u221Aa","a / (b/c)^d -> a * (c/b)^d":"Dividing by (b\u2044c)\u1D48 is multiplying by (c\u2044b)\u1D48","denest \u221A(a+b\u221Ac) -> \u221Ax+\u221Ay":"Denest the radical","sqrt(x^2) -> |x|":"Apply \u221A(x\xB2) = |x|","sqrt(x^{2n}) -> |x|^n":"Apply \u221A(x\xB2\u207F) = |x|\u207F","root(x^n, n) -> x when n odd":"Apply \u207F\u221A(x\u207F) = x for odd n","root(x^n, n) -> |x| when n even":"Apply \u207F\u221A(x\u207F) = |x| for even n","root(x^m, n) -> |x|^{m/n}":"Rewrite the root as a power: \u207F\u221A(x\u1D50) = |x|\u1D50\u141F\u207F","root(1, n) -> 1":"A root of 1 is 1","root(0, n) -> 0 when n > 0":"A root of 0 is 0","root(root(x, m), n) -> x^{1/(m*n)}":"Combine the nested roots: \u207F\u221A(\u1D50\u221Ax) = x^(1\u2044(m\xB7n))","sqrt(sqrt(x)) -> x^{1/4}":"Combine the nested roots: \u221A(\u221Ax) = x^(1\u20444)","root(sqrt(x), n) -> x^{1/(2n)}":"Combine the nested roots: \u207F\u221A(\u221Ax) = x^(1\u2044(2n))","sqrt(root(x, n)) -> x^{1/(2n)}":"Combine the nested roots: \u221A(\u207F\u221Ax) = x^(1\u2044(2n))","root(product, n) -> factored":"Distribute the root over the product",ln:"Simplify the natural logarithm",log:"Simplify the logarithm","combine ln terms":"Combine the logarithms","combine log terms":"Combine the logarithms","e^ln(x) -> x":"Apply e^(ln x) = x: exp and ln are inverses","c^log_c(x) -> x":"Apply c^(log\uA700 x) = x: the exponential and the logarithm are inverses","e^(ln(x) + y) -> x * e^y":"Split the exponent: e^(ln x + y) = x\xB7e\u02B8","e^(ln(x) * y) -> x^y":"Apply e^(y\xB7ln x) = x\u02B8","c^(log_c(x) + y) -> x * c^y":"Split the exponent: c^(log\uA700 x + y) = x\xB7c\u02B8","c^(log_c(x) * y) -> x^y":"Apply c^(y\xB7log\uA700 x) = x\u02B8","ln(e^x * y) -> x + ln(y)":"Expand the logarithm: ln(e\u02E3\xB7y) = x + ln y","log_c(c) -> 1":"The logarithm of the base is 1","log_c(c^x) -> x":"Apply log\uA700(c\u02E3) = x: the logarithm and the exponential are inverses","log_c(c^x * y) -> x + log_c(y)":"Expand the logarithm: log\uA700(c\u02E3\xB7y) = x + log\uA700 y","log_c(c^x / y) -> x - log_c(y)":"Expand the logarithm: log\uA700(c\u02E3\u2044y) = x \u2212 log\uA700 y","log_c(y / c^x) -> log_c(y) - x":"Expand the logarithm: log\uA700(y\u2044c\u02E3) = log\uA700 y \u2212 x","log_c(x^n) -> n*log_c(x)":"Bring the exponent out: log(x\u207F) = n\xB7log x","log_c(x^n) -> n*log_c(|x|) when n even":"Bring the exponent out: log(x\u207F) = n\xB7log|x| for even n","log_c(x^{p/q}) -> (p/q)*log_c(x)":"Bring the exponent out: log(x\u1D56\u141F\u{107A5}) = (p\u2044q)\xB7log x","log_c(x^{p/q}) -> (p/q)*log_c(|x|) when p even":"Bring the exponent out: log(x\u1D56\u141F\u{107A5}) = (p\u2044q)\xB7log|x| for even p","ln(a)/ln(b) -> k when a = b^k":"Recognize the logarithm ratio: ln(b\u1D4F)\u2044ln(b) = k","log_{1/c}(a) -> -log_c(a)":"Invert the base: log\u2081\u2044\uA700(a) = \u2212log\uA700(a)","log_c(a) / log_c(b) -> ln(a) / ln(b)":"Change of base: log\uA700(a)\u2044log\uA700(b) = ln(a)\u2044ln(b)","log_c(a) / ln(a) -> 1/ln(c)":"Change of base: log\uA700(a)\u2044ln(a) = 1\u2044ln(c)","ln(a) / log_c(a) -> ln(c)":"Change of base: ln(a)\u2044log\uA700(a) = ln(c)","log base 0 or 1 -> NaN":"A logarithm base of 0 or 1 is undefined","log_c(0) -> NaN":"The logarithm of 0 is undefined","abs-negate":"Apply |\u2212x| = |x|","|-x| -> |x|":"Apply |\u2212x| = |x|","|x| -> x":"Drop the absolute value: the argument is non-negative","|x| -> -x":"Resolve the absolute value: the argument is non-positive","|xy| -> x|y| when x >= 0":"Move the non-negative factor out of the absolute value","|x/y| -> |x|/y when y >= 0":"Move the non-negative denominator out of the absolute value","|x/y| -> x/|y| when x >= 0":"Move the non-negative numerator out of the absolute value","|x|^n -> x^n when n is even":"Drop the absolute value: |x|\u207F = x\u207F for even n","|x^n| -> x^n when n is even":"Drop the absolute value: x\u207F \u2265 0 for even n","|x^n| -> |x|^n when n is odd":"Move the absolute value onto the base: |x\u207F| = |x|\u207F for odd n","|x|^(p/q) -> x^(p/q) when p is even":"Drop the absolute value: |x|\u1D56\u141F\u{107A5} = x\u1D56\u141F\u{107A5} for even p","|x^(p/q)| -> x^(p/q) when p is even":"Drop the absolute value: x\u1D56\u141F\u{107A5} \u2265 0 for even p","|x^(p/q)| -> |x|^(p/q) when p is odd":"Move the absolute value onto the base: |x\u1D56\u141F\u{107A5}| = |x|\u1D56\u141F\u{107A5} for odd p","sign positive":"The sign of a positive quantity is 1","sign negative":"The sign of a negative quantity is \u22121","sign zero":"The sign of zero is 0","sin\xB2(x) + cos\xB2(x) -> 1":"Apply the Pythagorean identity: sin\xB2x + cos\xB2x = 1","a*sin\xB2(x) + a*cos\xB2(x) -> a":"Apply the Pythagorean identity: sin\xB2x + cos\xB2x = 1","tan\xB2(x) + 1 -> sec\xB2(x)":"Apply the Pythagorean identity: tan\xB2x + 1 = sec\xB2x","1 + cot\xB2(x) -> csc\xB2(x)":"Apply the Pythagorean identity: 1 + cot\xB2x = csc\xB2x","sin(x)cos(y)+cos(x)sin(y) -> sin(x+y)":"Apply the angle-addition identity: sin x cos y + cos x sin y = sin(x + y)","sin(x)cos(y)-cos(x)sin(y) -> sin(x-y)":"Apply the angle-subtraction identity: sin x cos y \u2212 cos x sin y = sin(x \u2212 y)"});Tn({"solve.move-terms":"Move all terms to one side","solve.simplify":"Simplify the equation","solve.apply-inverse":"Apply the inverse function to both sides","solve.equate-exponents":"The bases are equal, so equate the exponents","solve.apply-tangent":"Take the tangent of both sides to clear the inverse trigonometric functions","solve.clear-denominators":"Multiply through to clear the denominators","solve.square-both-sides":"Square both sides to eliminate the radical","solve.substitute":"Substitute a new variable","solve.substituted-equation":"Rewrite the equation in the substituted variable","solve.back-substitute":"Substitute back to the original variable","solve.factor-zero-product":"A product is zero exactly when one of its factors is zero","solve.harmonize":"Rewrite the equation in an equivalent form","solve.expand":"Expand the equation","solve.quadratic-formula":"Apply the quadratic formula","solve.rational-roots":"Find the rational roots (rational-root theorem)","solve.polynomial-roots":"Find the remaining roots of the polynomial","solve.candidates":"Candidate solutions","solve.validate-roots":"Check each candidate in the original equation; reject the extraneous ones","solve.filter-domain":"Discard solutions outside the domain of the variable","solve.roots":"The solutions","solve.template":"Solve the matched equation pattern","solve.system.eliminate":"Eliminate a variable from the remaining equations","solve.system.back-substitute":"Substitute the known value back to solve for the next variable","solve.system.parametric":"Express the solutions in terms of a free parameter","solve.system.solve-for":"Solve one equation for one variable","solve.system.substitute":"Substitute into the remaining equations","solve.system.product-sum":"Rewrite the sum and product conditions as a quadratic","solve.case":"Consider the next case","solve.system.normalize-inequality":"Rewrite the inequality with zero on the right-hand side","solve.system.intersect-boundaries":"Find the intersection points of the boundary lines","solve.system.vertices":"Keep the corner points that satisfy every inequality","solve.system.check-constraints":"Substitute the candidate solution into each constraint","solve.system.reject":"Reject the candidate: it violates a constraint"});Tn({"solve.linear-monomial":"A multiple of the unknown is zero when the unknown is zero","solve.reciprocal":"Solve the reciprocal equation","solve.linear":"Isolate the unknown: subtract the constant, then divide by the coefficient","solve.linear-negated":"Isolate the unknown: subtract the constant, then divide by the coefficient","solve.power":"Take the n-th root of both sides","solve.power-negative-root":"Take the n-th root of both sides (negative root)","solve.quadratic-no-constant-zero":"Factor out the unknown: one solution is 0","solve.quadratic-no-constant":"Factor out the unknown and solve the remaining linear factor","solve.quadratic-formula-positive":"Apply the quadratic formula (positive branch)","solve.quadratic-formula-negative":"Apply the quadratic formula (negative branch)","solve.exponential":"Take the logarithm of both sides","solve.exponential-natural":"Take the natural logarithm of both sides","solve.exponential-natural-unit-exponent":"Take the natural logarithm of both sides","solve.exponential-natural-simple":"Take the natural logarithm of both sides","solve.exponential-natural-unit-coefficient":"Take the natural logarithm of both sides","solve.logarithm-base":"Exponentiate both sides to clear the logarithm","solve.logarithm-base-no-constant":"Exponentiate both sides to clear the logarithm","solve.absolute-value-positive":"Resolve the absolute value (positive case)","solve.absolute-value-negative":"Resolve the absolute value (negative case)","solve.quadratic-in-sqrt-positive":"Solve as a quadratic in the square root of the unknown","solve.quadratic-in-sqrt-negative":"Solve as a quadratic in the square root of the unknown","solve.quadratic-in-sqrt-negated-positive":"Solve as a quadratic in the square root of the unknown","solve.quadratic-in-sqrt-negated-negative":"Solve as a quadratic in the square root of the unknown","solve.radical":"Isolate the radical, then square both sides","solve.logarithm-natural-scaled":"Exponentiate both sides to clear the logarithm","solve.logarithm-natural":"Exponentiate both sides to clear the logarithm","solve.sine":"Apply the inverse sine","solve.sine-second-branch":"Apply the inverse sine (second branch: \u03C0 \u2212 arcsin)","solve.sine-unit":"Apply the inverse sine","solve.sine-unit-second-branch":"Apply the inverse sine (second branch: \u03C0 \u2212 arcsin)","solve.cosine":"Apply the inverse cosine","solve.cosine-negative-branch":"Apply the inverse cosine (negative branch)","solve.cosine-unit":"Apply the inverse cosine","solve.cosine-unit-negative-branch":"Apply the inverse cosine (negative branch)","solve.tangent":"Apply the inverse tangent","solve.tangent-unit":"Apply the inverse tangent","solve.cotangent":"Apply the inverse cotangent","solve.cotangent-unit":"Apply the inverse cotangent","solve.sine-cosine-linear-combination":"Rewrite a\xB7sin x + b\xB7cos x as a single sinusoid"});Tn({"integrate.constant":"The integral of a constant: \u222Bc dx = c\xB7x","integrate.variable":"The integral of the variable: \u222Bx dx = x\xB2/2","integrate.sum":"Integrate term by term: \u222B(u+v) dx = \u222Bu dx + \u222Bv dx","integrate.constant-factor":"Move the constant factor out of the integral","integrate.collected-power":"Integrate the power of the linear expression","integrate.hyperbolic-to-exp":"Rewrite the hyperbolic functions as exponentials","integrate.trig-to-exp":"Rewrite the trigonometric functions as exponentials","integrate.by-parts":"Integrate by parts","integrate.si-ci":"Express the integral with the sine and cosine integral functions Si and Ci","integrate.trig-to-single-exp":"Substitute a single exponential for the trigonometric functions","integrate.exponential-substitution":"Substitute for the exponential and integrate the rational function","integrate.partial-fractions":"Integrate using partial-fraction decomposition","integrate.previous-result":"Use the integral computed earlier","integrate.simplify":"Simplify the result","integrate.antiderivative":"Find the antiderivative of the integrand","integrate.fundamental-theorem":"Apply the Fundamental Theorem of Calculus: \u222B\u1D43\u1D47 f dx = F(b) \u2212 F(a)","integrate.evaluate-bounds":"Evaluate the antiderivative at the bounds"});Tn({"derivative.sum-rule":"Apply the sum rule: (u + v)\u2032 = u\u2032 + v\u2032","derivative.product-rule":"Apply the product rule: (u\xB7v)\u2032 = u\u2032\xB7v + u\xB7v\u2032","derivative.quotient-rule":"Apply the quotient rule: (u\u2044v)\u2032 = (u\u2032\xB7v \u2212 u\xB7v\u2032)\u2044v\xB2","derivative.power-rule":"Apply the power rule: (u\u207F)\u2032 = n\xB7u\u207F\u207B\xB9\xB7u\u2032","derivative.exponential-rule":"Differentiate the exponential: (a\u1D58)\u2032 = a\u1D58\xB7ln(a)\xB7u\u2032","derivative.general-power-rule":"Differentiate by logarithmic differentiation: (f^g)\u2032 = f^g\xB7(g\u2032\xB7ln f + g\xB7f\u2032\u2044f)","derivative.chain-rule":"Apply the chain rule: f(u)\u2032 = f\u2032(u)\xB7u\u2032","derivative.known-derivative":"Differentiate using a known derivative","derivative.constant-multiple":"Apply the constant-multiple rule: (c\xB7u)\u2032 = c\xB7u\u2032","derivative.rewrite":"Rewrite in an equivalent differentiable form","derivative.piecewise-rule":"Differentiate each piece on its own region; the conditions are unchanged","derivative.tuple-norm":"Differentiate a norm: \u2016p\u2016\u2032 = (\u03A3 Re(c\u0304\u1D62\xB7c\u1D62\u2032)) / \u2016p\u2016","derivative.expand-definition":"Expand the definition of the function","derivative.zero":"The expression is locally constant: its derivative is 0","derivative.simplify":"Simplify the result"});{let e=["Sin","Tan","Cot","Csc","Sinh","Tanh","Coth","Csch","Arcsin","Arctan","Arccsc","Arsinh","Artanh","Arcsch"],n=["Cos","Sec","Cosh","Sech"],t={};for(let i of e){let r=i.toLowerCase();t[`${i}(-x) -> -${i}(x)`]=`Use the odd symmetry: ${r}(\u2212x) = \u2212${r}(x)`}for(let i of n){let r=i.toLowerCase();t[`${i}(-x) -> ${i}(x)`]=`Use the even symmetry: ${r}(\u2212x) = ${r}(x)`}Tn(t)}{let e=["Sin","Tan","Cot","Csc","Sinh","Tanh","Coth","Csch","Arcsin","Arctan","Arccot","Arccsc","Arsinh","Artanh","Arcoth","Arcsch"],n=["Cos","Sec","Cosh","Sech"],t={};for(let i of e){let r=i.toLowerCase();t[`|${i}(x)| -> ${i}(|x|) (odd function)`]=`Move the absolute value onto the argument: |${r}(x)| = ${r}(|x|) because ${r} is odd`}for(let i of n){let r=i.toLowerCase();t[`${i}(|x|) -> ${i}(x) (even function)`]=`Drop the absolute value: ${r}(|x|) = ${r}(x) because ${r} is even`}Tn(t)}Tn({"Sin(\u03C0 + x) -> -Sin(x)":"Shift the angle by \u03C0: sin(\u03C0 + x) = \u2212sin(x)","Cos(\u03C0 + x) -> -Cos(x)":"Shift the angle by \u03C0: cos(\u03C0 + x) = \u2212cos(x)","Tan(\u03C0 + x) -> Tan(x)":"Use the period \u03C0 of tangent: tan(\u03C0 + x) = tan(x)","Cot(\u03C0 + x) -> Cot(x)":"Use the period \u03C0 of cotangent: cot(\u03C0 + x) = cot(x)","Sec(\u03C0 + x) -> -Sec(x)":"Shift the angle by \u03C0: sec(\u03C0 + x) = \u2212sec(x)","Csc(\u03C0 + x) -> -Csc(x)":"Shift the angle by \u03C0: csc(\u03C0 + x) = \u2212csc(x)","Sin(\u03C0/2 - x) -> Cos(x)":"Apply the cofunction identity: sin(\u03C0\u20442 \u2212 x) = cos(x)","Cos(\u03C0/2 - x) -> Sin(x)":"Apply the cofunction identity: cos(\u03C0\u20442 \u2212 x) = sin(x)","Tan(\u03C0/2 - x) -> Cot(x)":"Apply the cofunction identity: tan(\u03C0\u20442 \u2212 x) = cot(x)","Cot(\u03C0/2 - x) -> Tan(x)":"Apply the cofunction identity: cot(\u03C0\u20442 \u2212 x) = tan(x)","Sec(\u03C0/2 - x) -> Csc(x)":"Apply the cofunction identity: sec(\u03C0\u20442 \u2212 x) = csc(x)","Csc(\u03C0/2 - x) -> Sec(x)":"Apply the cofunction identity: csc(\u03C0\u20442 \u2212 x) = sec(x)"});{let e=["Sin","Cos","Tan","Cot","Sec","Csc","Arcsin","Arccos"],n={};for(let t of e)n[`${t}(infinity) -> NaN`]=`${t.toLowerCase()} has no limit at infinity`;for(let t of["arctan(+inf) -> \u03C0/2","arctan(-inf) -> -\u03C0/2","arccot(+inf) -> 0","arccot(-inf) -> \u03C0","arcsec(\xB1inf) -> \u03C0/2","arccsc(\xB1inf) -> 0","sinh(+inf) -> +inf","sinh(-inf) -> -inf","cosh(+inf) -> +inf","cosh(-inf) -> +inf","tanh(+inf) -> 1","tanh(-inf) -> -1","coth(+inf) -> 1","coth(-inf) -> -1","sech(+inf) -> 0","sech(-inf) -> 0","csch(+inf) -> 0","csch(-inf) -> 0","arsinh(+inf) -> +inf","arsinh(-inf) -> -inf","arcosh(+inf) -> +inf","arcoth(\xB1inf) -> 0","arcsch(\xB1inf) -> 0","ln(+inf) -> +inf","log_c(+inf) -> +inf when c > 1","log_c(+inf) -> -inf when 0 < c < 1","log_c(0) -> -inf when c > 1","log_c(0) -> +inf when 0 < c < 1","log_inf(x) -> 0","root(+inf, n) -> +inf when n > 0"])n[t]="Evaluate the limit at infinity";for(let t of["artanh(\xB1inf) -> NaN","arsech(\xB1inf) -> NaN","arcosh(-inf) -> NaN","log_inf(inf) -> NaN"])n[t]="The value is undefined at infinity";for(let t of["root(x, 0) -> NaN","root(0, n) -> NaN when n <= 0"])n[t]="The root is undefined";Tn(n)}function Fe(e,n,t){e.indexOf("#1")<0&&e.indexOf("#2")<0&&(e=`#1 ${e} #2`);let i=e.split(/(#\d+)/).filter(r=>r.trim()!=="").map(r=>r.trim());return v(i.map(r=>{switch(r){case"#1":return n;case"#2":return t;default:return r}}))}var _e={"(":["\\lparen","("],")":["\\rparen",")"],"[":["\\lbrack","\\[","["],"]":["\\rbrack","\\]","]"],"<":["<","\\langle"],">":[">","\\rangle"],"{":["\\{","\\lbrace"],"}":["\\}","\\rbrace"],":":[":","\\colon"],"|":["|","\\|","\\lvert","\\rvert"],"||":["||","\\Vert","\\lVert","\\rVert","\\|"]},Le={"\\left":"\\right","\\bigl":"\\bigr","\\Bigl":"\\Bigr","\\biggl":"\\biggr","\\Biggl":"\\Biggr","\\big":"\\big","\\Big":"\\Big","\\bigg":"\\bigg","\\Bigg":"\\Bigg","\\mathopen":"\\mathclose","\\mleft":"\\mright"},tt=new Set(Object.values(Le));function Zh(e){let n=e.index;e.skipVisualSpace();let t=!1;return e.match("(")&&(e.skipVisualSpace(),t=e.peek==="\\bmod"||e.peek==="\\pmod"||e.peek==="\\mod"||e.matchAll(["m","o","d"])),e.index=n,t}function Hh(e,n){let t=e.index;if(e.skipVisualSpace(),e.match("(")){if(e.skipVisualSpace(),e.match("\\bmod")||e.match("\\pmod")||e.match("\\mod")||e.matchAll(["m","o","d"])){e.skipVisualSpace();let s=e.parseExpression({...n,minPrec:0})??e.parseGroup();if(e.skipVisualSpace(),s!==null&&e.match(")"))return s}return e.index=t,null}let i=e.parseExpression({...n,minPrec:tn});if(i!==null&&g(i)==="Mod"){let r=P(i)>=2?d(i,2):d(i,1);if(r!==null)return r}return e.index=t,null}function Ii(e,n,t){let i=e.parseExpression({...t,minPrec:w,condition:s=>Zh(s)||(t.condition?.(s)??!1)}),r=Hh(e,t);return r!==null?g(n)==="Congruent"?["And",n,["Congruent",O(d(n,2)),O(i),r]]:["Congruent",n,O(i),r]:["IdenticallyEqual",n,O(i)]}var yf=[{name:"True",standaloneSymbol:!0,kind:"symbol",latexTrigger:["\\top"]},{kind:"symbol",latexTrigger:"\\mathrm{True}",parse:"True"},{kind:"symbol",latexTrigger:"\\operatorname{True}",parse:"True"},{kind:"symbol",latexTrigger:"\\mathsf{T}",parse:"True"},{name:"False",standaloneSymbol:!0,kind:"symbol",latexTrigger:["\\bot"]},{kind:"symbol",latexTrigger:"\\operatorname{False}",parse:"False"},{kind:"symbol",latexTrigger:"\\mathsf{F}",parse:"False"},{name:"And",kind:"infix",latexTrigger:["\\land"],precedence:235},{kind:"infix",latexTrigger:["\\wedge"],parse:"And",precedence:235},{kind:"infix",latexTrigger:"\\&",parse:"And",precedence:235},{kind:"infix",latexTrigger:"\\operatorname{and}",parse:"And",precedence:235},{name:"Or",kind:"infix",latexTrigger:["\\lor"],precedence:230},{kind:"infix",latexTrigger:["\\vee"],parse:"Or",precedence:230},{kind:"infix",latexTrigger:"\\operatorname{or}",parse:"Or",precedence:230},{name:"Xor",kind:"infix",latexTrigger:["\\veebar"],precedence:232},{name:"Not",kind:"prefix",latexTrigger:["\\lnot"],precedence:880},{kind:"prefix",latexTrigger:["\\neg"],parse:"Not",precedence:880},{name:"Nand",kind:"infix",latexTrigger:["\\barwedge"],precedence:232},{name:"Nor",kind:"infix",latexTrigger:["\u22BD"],precedence:232},{kind:"function",symbolTrigger:"and",parse:"And"},{kind:"function",symbolTrigger:"or",parse:"Or"},{kind:"function",symbolTrigger:"not",parse:"Not"},{name:"Implies",kind:"infix",precedence:220,associativity:"right",latexTrigger:["\\implies"],serialize:"\\implies"},{latexTrigger:["\\Rightarrow"],kind:"infix",precedence:220,associativity:"right",parse:"Implies"},{latexTrigger:["\\Longrightarrow"],kind:"infix",precedence:220,associativity:"right",parse:"Implies"},{latexTrigger:["\\longrightarrow"],kind:"infix",precedence:220,associativity:"right",parse:"Implies"},{latexTrigger:["=",">"],kind:"infix",precedence:220,associativity:"right",parse:(e,n,t)=>{if(e.options.strict!==!1)return null;let i=e.parseExpression({...t,minPrec:220});return i===null?null:["Implies",n,i]}},{name:"Equivalent",latexTrigger:["\\iff"],kind:"infix",associativity:"right",precedence:219},{latexTrigger:["\\Leftrightarrow"],kind:"infix",associativity:"right",precedence:219,parse:"Equivalent"},{latexTrigger:["\\leftrightarrow"],kind:"infix",associativity:"right",precedence:219,parse:"Equivalent"},{latexTrigger:["\\Longleftrightarrow"],kind:"infix",associativity:"right",precedence:219,parse:"Equivalent"},{latexTrigger:["\\longleftrightarrow"],kind:"infix",associativity:"right",precedence:219,parse:"Equivalent"},{latexTrigger:["<","=",">"],kind:"infix",precedence:219,associativity:"right",parse:(e,n,t)=>{if(e.options.strict!==!1)return null;let i=e.parseExpression({...t,minPrec:219});return i===null?null:["Equivalent",n,i]}},{name:"IdenticallyEqual",latexTrigger:["\\equiv"],kind:"infix",associativity:"right",precedence:w,parse:Ii},{latexTrigger:["\u2261"],kind:"infix",associativity:"right",precedence:w,parse:Ii},{latexTrigger:["\\equiv"],kind:"prefix",precedence:w,parse:(e,n)=>Ii(e,e.error("missing",e.index),n??{minPrec:0})},{latexTrigger:["\\not","\\equiv"],kind:"infix",associativity:"right",precedence:w,parse:(e,n,t)=>["Not",Ii(e,n,t)]},{latexTrigger:["\u2262"],kind:"infix",associativity:"right",precedence:w,parse:(e,n,t)=>["Not",Ii(e,n,t)]},{latexTrigger:["\\pmod"],kind:"infix",precedence:w-1,parse:(e,n)=>{let t=e.parseGroup()??e.parseToken();return["Mod",n,O(t)]}},{name:"Proves",kind:"infix",latexTrigger:["\\vdash"],precedence:220,associativity:"right",serialize:"\\vdash"},{name:"Entails",kind:"infix",latexTrigger:["\\vDash"],precedence:220,associativity:"right",serialize:"\\vDash"},{name:"Satisfies",kind:"infix",latexTrigger:["\\models"],precedence:220,associativity:"right",serialize:"\\models"},{name:"ForAll",kind:"prefix",latexTrigger:["\\forall"],precedence:200,serialize:ki("\\forall"),parse:Bn("ForAll")},{name:"Exists",kind:"prefix",latexTrigger:["\\exists"],precedence:200,serialize:ki("\\exists"),parse:Bn("Exists")},{name:"ExistsUnique",kind:"prefix",latexTrigger:["\\exists","!"],precedence:200,serialize:ki("\\exists!"),parse:Bn("ExistsUnique")},{name:"NotForAll",kind:"prefix",latexTrigger:["\\lnot","\\forall"],precedence:200,serialize:ki("\\lnot\\forall"),parse:Bn("NotForAll")},{name:"NotExists",kind:"prefix",latexTrigger:["\\lnot","\\exists"],precedence:200,serialize:ki("\\lnot\\exists"),parse:Bn("NotExists")},{name:"KroneckerDelta",kind:"prefix",latexTrigger:["\\delta","_"],precedence:200,serialize:(e,n)=>{let t=b(n);return t.length===0?"\\delta":t.every(i=>E(i))?`\\delta_{${t.map(i=>e.serialize(i)).join("")}}`:`\\delta_{${t.map(i=>e.serialize(i)).join(", ")}}`},parse:e=>{let n=e.parseGroup();if(n===null){let i=e.parseToken();return i?["KroneckerDelta",i]:null}let t=En(n);return t&&t.length<=2?["KroneckerDelta",...t]:g(n)==="InvisibleOperator"?["KroneckerDelta",...b(n)]:n!==null?["KroneckerDelta",n]:null}},{name:"Boole",kind:"matchfix",openTrigger:"[",closeTrigger:"]",parse:(e,n)=>{let t=g(n);return!t||!et.some(i=>i.name===t)?null:["Boole",n]}},{kind:"matchfix",openTrigger:"\\llbracket",closeTrigger:"\\rrbracket",parse:(e,n)=>{let t=g(n);return!t||!et.some(i=>i.name===t)?null:["Boole",n]}},{name:"Predicate",serialize:(e,n)=>{let t=b(n);if(t.length===0)return"";let i=t[0],r=typeof i=="string"?i:e.serialize(i);if(t.length===1)return r;let s=t.slice(1).map(o=>e.serialize(o));return`${r}(${s.join(", ")})`}}];function ki(e){return(n,t)=>{let i=b(t);if(i.length===0)return e;if(i.length===1)return`${e} ${n.serialize(i[0])}`;let r=n.serialize(i[0]),s=n.wrap(i[1],w);return`${e} ${r}, ${s}`}}function Gs(e,n){return e.peek==="\\to"||e.peek==="\\rightarrow"||e.peek==="\\implies"||e.peek==="\\Rightarrow"||e.peek==="\\iff"||e.peek==="\\Leftrightarrow"||e.peek==="\\land"||e.peek==="\\wedge"||e.peek==="\\lor"||e.peek==="\\vee"||(n?.condition?.(e)??!1)}var Wh=new Set(["And","Or","Not","Xor","Nand","Nor","Implies","Equivalent","IdenticallyEqual","ForAll","Exists","ExistsUnique","NotForAll","NotExists","Element","NotElement","Subset","SubsetEqual","Superset","SupersetEqual","NotSubset","NotSuperset","NotSubsetNotEqual","NotSupersetNotEqual","SquareSubset","SquareSubsetEqual","SquareSuperset","SquareSupersetEqual","Divides","NotDivides","Predicate"]);function bf(e){if(e===null)return!1;let n=g(e);return n==="Delimiter"?P(e)>=1&&bf(d(e,1)):n==="InvisibleOperator"?P(e)===2&&typeof d(e,1)=="string"&&g(d(e,2))==="Delimiter":n===""?typeof e=="string":Ta(n)?!0:Wh.has(n)}function Bn(e){return(n,t)=>{let i=n.index,r=n._diagnosticsCheckpoint(),s=n.options.quantifierScope!=="loose",o=n.parseSymbol(t),a=typeof o=="string"?o:null;if(o){if(n.skipSpace(),n.match(",")||n.match("\\mid")||n.match(".")||n.match(":")||n.match("\\colon")){let p=s?{...t,condition:y=>Gs(y,t)}:t;n.enterQuantifierScope();let h=n.parseExpression(p);return n.exitQuantifierScope(),a&&n._pruneUndeclared([a],r),[e,o,O(h)]}n.enterQuantifierScope();let f=n.parseEnclosure();if(n.exitQuantifierScope(),f&&(n.skipSpace(),n.atTerminator(t)||Gs(n,t)))return a&&n._pruneUndeclared([a],r),[e,o,O(f)]}n.index=i;let u={...t,condition:f=>f.peek===":"||f.peek==="\\colon"||(t?.condition?.(f)??!1)},l=i;for(;;){let f=l,p={...u,condition:N=>(N.peek==="("||N.peek==="\\left")&&N.index>f||u.condition(N)};n.index=i,n.enterQuantifierScope();let h=n.parseExpression(p);n.exitQuantifierScope();let y=n.index;if(h!==null&&g(h)!==""){n.skipSpace(),n.enterQuantifierScope();let N=n.parseEnclosure();if(n.exitQuantifierScope(),n.skipSpace(),bf(N)&&(n.atTerminator(t)||Gs(n,t)))return[e,h,O(N)]}if(h===null||y<=l)break;l=y}n.index=i,n.enterQuantifierScope();let c=n.parseExpression(u);if(n.exitQuantifierScope(),c===null)return null;if(n.skipSpace(),n.matchAny([",","\\mid",":","\\colon"])){let f=s?{...t,condition:h=>Gs(h,t)}:t;n.enterQuantifierScope();let p=n.parseExpression(f);return n.exitQuantifierScope(),[e,c,O(p)]}if(n.match("(")){n.enterQuantifierScope();let f=n.parseExpression(t);return n.exitQuantifierScope(),n.match(")")?[e,c,O(f)]:null}return g(c)!==""?[e,c,"True"]:null}}var Fa;function Tf(e){if(!Fa){let t=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;Fa=new RegExp(t,"u")}return Fa.test(e)}function it(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)||Dt.test(e)?!0:Tf(e)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(e):!1}var Yh="\\u{FE0F}",Xh="\\u{20E3}",Kh="\\u{200D}",Qh="\\p{RI}\\p{RI}",ey="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",xf=`(?:\\p{EMod}|${Yh}${Xh}?|${ey})`,ny="(?:(?=\\P{XIDC})(?=[^\\x23\\x2a\\x30-\\x39])\\p{Emoji})",Ef=`(?:${ny}${xf}*|\\p{Emoji}${xf}+|${Qh})`,Nf=`(?:${Ef})(${Kh}${Ef})*`,ty=new RegExp(`(?:${Nf})+`,"u"),Dt=new RegExp(`^(?:${Nf})+$`,"u");function La(e){return typeof e!="string"?"not-a-string":e===""?"empty-string":e.normalize()!==e?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(e)?"unexpected-bidi-marker":Dt.test(e)?"valid":/\p{XIDC}/u.test(e)&&ty.test(e)?"unexpected-mixed-emoji":Tf(e)?it(e)?"valid":it(e[0])?"invalid-char":"invalid-first-char":"unexpected-script"}var Fn=[["alpha","\\alpha",945],["beta","\\beta",946],["gamma","\\gamma",947],["delta","\\delta",948],["epsilon","\\epsilon",949],["epsilonSymbol","\\varepsilon",1013],["zeta","\\zeta",950],["eta","\\eta",951],["theta","\\theta",952],["thetaSymbol","\\vartheta",977],["iota","\\iota",953],["kappa","\\kappa",954],["kappaSymbol","\\varkappa",1008],["lambda","\\lambda",955],["mu","\\mu",956],["nu","\\nu",957],["xi","\\xi",958],["omicron","\\omicron",959],["pi","\\pi",960],["piSymbol","\\varpi",982],["rho","\\rho",961],["rhoSymbol","\\varrho",1009],["sigma","\\sigma",963],["finalSigma","\\varsigma",962],["tau","\\tau",964],["phi","\\phi",981],["phiLetter","\\varphi",966],["upsilon","\\upsilon",965],["chi","\\chi",967],["psi","\\psi",968],["omega","\\omega",969],["Alpha","\\Alpha",913],["Beta","\\Beta",914],["Gamma","\\Gamma",915],["Delta","\\Delta",916],["Epsilon","\\Epsilon",917],["Zeta","\\Zeta",918],["Eta","\\Eta",919],["Theta","\\Theta",920],["Iota","\\Iota",921],["Kappa","\\Kappa",922],["Lambda","\\Lambda",923],["Mu","\\Mu",924],["Nu","\\Nu",925],["Xi","\\Xi",926],["Omicron","\\Omicron",927],["CapitalPi","\\Pi",928],["Rho","\\Rho",929],["Sigma","\\Sigma",931],["Tau","\\Tau",932],["Phi","\\Phi",934],["Upsilon","\\Upsilon",933],["Chi","\\Chi",935],["Psi","\\Psi",936],["Omega","\\Omega",937],["digamma","\\digamma",989],["aleph","\\aleph",8501],["bet","\\beth",8502],["gimel","\\gimel",8503],["dalet","\\daleth",8504],["ell","\\ell",8467],["turnedCapitalF","\\Finv",8498],["turnedCapitalG","\\Game",8513],["weierstrass","\\wp",8472],["eth","\\eth",240],["invertedOhm","\\mho",8487],["hBar","\\hbar",295],["hSlash","\\hslash",8463],["blackClubSuit","\\clubsuit",9827],["whiteHeartSuit","\\heartsuit",9825],["blackSpadeSuit","\\spadesuit",9824],["whiteDiamondSuit","\\diamondsuit",9826],["sharp","\\sharp",9839],["flat","\\flat",9837],["natural","\\natural",9838]],vf=[...Fn.map(([e,n,t])=>({kind:"symbol",name:e,latexTrigger:[n],parse:e})),...Fn.map(([e,n,t])=>({kind:"symbol",latexTrigger:[String.fromCodePoint(t)],parse:e}))];var Mi=null;function iy(){if(!Mi){Mi=new Map;for(let[e,n]of Fn)Mi.has(n)||Mi.set(n,e)}return Mi}var Sf={"\\mathord":"","\\mathop":"","\\mathbin":"","\\mathrel":"","\\mathopen":"","\\mathclose":"","\\mathpunct":"","\\mathinner":"","\\operatorname":"","\\text":"","\\mathrm":"_upright","\\mathit":"_italic","\\mathbf":"_bold","\\bold":"_bold","\\boldsymbol":"_bold","\\bm":"_bold","\\mathscr":"_script","\\mathcal":"_calligraphic","\\mathfrak":"_fraktur","\\mathsf":"_sansserif","\\mathtt":"_monospace","\\mathbb":"_doublestruck"},ry={"\\mathring":"_ring","\\hat":"_hat","\\tilde":"_tilde","\\vec":"_vec","\\overline":"_bar","\\underline":"_underbar","\\dot":"_dot","\\ddot":"_ddot","\\dddot":"_dddot","\\ddddot":"_ddddot","\\acute":"_acute","\\grave":"_grave","\\breve":"_breve","\\check":"_check"};function If(e,n){if(e.atEnd)return null;let t=e.peek,i={"\\_":"_","\\#":"hash"}[t];if(!i&&!n.toplevel&&(i={"+":"plus","-":"minus","\\plusmn":"pm","\\pm":"pm","\\ast":"ast","\\dag":"dag","\\ddag":"ddag","\\bot":"bottom","\\top":"top","\\bullet":"bullet","\\cir":"circle","\\diamond":"diamond","\\times":"times","\\square":"square","\\star":"star"}[t]),i)return e.nextToken(),i;let r=iy().get(t);if(r!==void 0)return e.nextToken(),r;let s=e.parseChar();if(s!==null)return/^\p{XIDC}+$/u.test(s)?s:[...s].length===1?"____"+s.codePointAt(0).toString(16).toUpperCase().padStart(6,"0"):s;let o=e.peek;return o&&/^[\p{XIDC}\p{M}]/u.test(o)?e.nextToken():null}function wi(e){let n=Va(e),t=ry[e.peek]??null;if(t){if(e.nextToken(),!e.match("<{>"))return null;let s=wi(e);if(s===null||!e.match("<}>"))return null;n=`${s}${t}`}if(n===null){for(n="";!e.atEnd;){let s=e.peek;if(s==="<}>"||s==="_"||s==="^")break;if(s==="<space>"){e.nextToken();continue}if(Dt.test(n+s)){n+=e.nextToken();continue}let o=If(e,{toplevel:!1});if(o===null)return null;n+=o}for(;!e.atEnd&&/\d/.test(e.peek);)n+=e.nextToken()}for(;!e.atEnd;)if(e.match("\\degree"))n+="_deg";else if(e.matchAll(["^","\\circ"]))n+="_deg";else if(e.matchAll(["^","\\prime"]))n+="_prime";else if(e.matchAll(["^","<{>","\\prime","<}>"]))n+="_prime";else if(e.matchAll(["^","<{>","\\doubleprime","<}>"]))n+="_dprime";else if(e.matchAll(["^","<{>","\\prime","\\prime","<}>"]))n+="_dprime";else break;let i=[],r=[];for(;!e.atEnd;)if(e.match("_")){let s=e.match("<{>"),o=wi(e);if(s&&!e.match("<}>")||o===null)return null;r.push(o)}else if(e.match("^")){let s=e.match("<{>"),o=wi(e);if(s&&!e.match("<}>")||o===null)return null;i.push(o)}else break;return i.length>0&&(n+="__"+i.join("")),r.length>0&&(n+="_"+r.join("")),n}function Va(e){let n=Sf[e.peek]??null;if(n===null)return null;let t=e.index;if(e.nextToken(),e.match("<{>")){let i="",r={0:"zero",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine"}[e.peek]??"";r&&(i=r,e.nextToken());let s=wi(e);return s===null||!e.match("<}>")?(e.index=t,null):(i+=s,n==="_upright"&&i.length>1?i:i+n)}return e.index=t,null}function Ja(e){let n=e.index,t=Va(e);if(t!==null)return it(t)?null:e.error(["invalid-symbol",{str:La(t)}],n);if(e.index=n,(Sf[e.peek]??null)===null)return null;if(e.nextToken(),!e.match("<{>"))return e.index=n,null;let r=e.index,s=0;for(;!e.atEnd&&!(s===0&&e.peek==="<}>");)e.peek==="<{>"&&(s+=1),e.peek==="<}>"&&(s-=1),e.nextToken();let o=e.latex(r,e.index);return it(o)?(e.index=n,null):(e.match("<}>"),e.error(["invalid-symbol",{str:La(o)}],n))}function Ct(e,n,t){for(;!e.atEnd&&e.peek==="_";){let r=e.index,s=null,o=()=>{if(s===null)return!1;let u=n+"_"+s;return t&&e.resolveSymbol(u)===void 0?(e.index=r,!1):(n=u,!0)};if(e.nextToken(),e.match("<{>")){let u=e.peek;if(u==="("||u==="\\lparen"||u==="\\left"){e.index=r;break}let l=wi(e);if(l===""&&e.peek==="<}>"){e.match("<}>");continue}let c=l!==null&&/plus|minus|times|ast/.test(l);if(l===null||l.includes(",")||c||e.peek!=="<}>"){e.index=r;break}e.match("<}>"),s=l}else{let u=e.peek;if(e.options.strict===!1&&/^[0-9]$/.test(u)){let l="";for(;!e.atEnd&&/^[0-9]$/.test(e.peek);)l+=e.peek,e.nextToken();s=l}else if(/^[a-zA-Z0-9]$/.test(u)||/^\p{XIDS}$/u.test(u))e.nextToken(),s=u;else{e.index=r;break}}if(!o())break}return n}function Ai(e){if(/^[a-zA-Z]$/.test(e.peek)||/^\p{XIDS}$/u.test(e.peek)){let i=e.nextToken(),r=e.resolveSymbol(i);if(r?.subscriptEvaluate)return i;let s=r?.type.matches("indexed_collection<any>")??!1;return Ct(e,i,s)}let n=Va(e);if(!n){for(n="";!e.atEnd&&Dt.test(n+e.peek);)n+=e.nextToken();n||(n=null)}let t=e.index;if(n??=If(e,{toplevel:!0}),n&&(n=n.normalize(),it(n))){if(e.peek==="_"&&!e.isFunctionTriggerName(n)){let i=e.resolveSymbol(n);i?.subscriptEvaluate||(n=Ct(e,n,i?.type.matches("indexed_collection<any>")??!1))}return n}return e.index=t,null}var sy={x:"PointX",y:"PointY",z:"PointZ",real:"Real",re:"Real",imag:"Imaginary",im:"Imaginary",count:"Length",length:"Length",total:"Sum",max:"Max",min:"Min"};function ja(e){return sy[e]??null}var oy={join:"Join"};function ay(e){if(e.peek==="(")return!0;if(e.peek!=="\\left")return!1;let n=e.index;e.nextToken();let t=e.peek;return e.index=n,t==="("}function kf(e){let n=null;if(typeof e=="number")Number.isSafeInteger(e)&&e>=0&&(n=e.toString());else if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.num=="string"){let t=e.num;/^[0-9]+$/.test(t)&&(n=t)}return n===null||!/^[0-9]+$/.test(n)?null:n}function uy(e,n){if(!(typeof n=="number"&&Number.isInteger(n)&&n>=2)){let a=E(n);if(a===null||a==="Nothing")return null;let u=kf(e);if(u===null)return null;let l=[],c=u.length;for(let p=0;p<c;p++){let h=u.charCodeAt(p)-48;if(h===0)continue;let y=c-1-p;if(y===0)l.push(h);else if(y===1)l.push(h===1?a:["Multiply",h,a]);else{let N=["Power",a,y];l.push(h===1?N:["Multiply",h,N])}}return["BaseForm",l.length===0?0:l.length===1?l[0]:["Add",...l],a]}let t=n,i=kf(e);if(i===null)return null;let r=BigInt(t),s=0n;for(let a=0;a<i.length;a++){let u=i.charCodeAt(a)-48;if(u>=t)return null;s=s*r+BigInt(u)}return["BaseForm",s<=BigInt(Number.MAX_SAFE_INTEGER)?Number(s):{num:s.toString()},t]}function ly(e){if(typeof e=="number")return Number.isSafeInteger(e)?BigInt(e):null;if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.num=="string"){let n=e.num;if(/^[+-]?[0-9]+$/.test(n))return BigInt(n)}return null}function cy(e,n){if(e==null)return null;let t=g(e)==="Add"?[...b(e)]:[e],i=new Map;for(let o of t){let a,u,l=f=>{if(E(f)===n)return 1;if(g(f)==="Square"&&E(d(f,1))===n)return 2;if(g(f)==="Power"&&E(d(f,1))===n){let p=M(d(f,2));return p===null?null:p}return null},c=E(o);if(c!==null){if(c!==n)return null;a=1,u=1}else if(g(o)==="Power"||g(o)==="Square"){let f=l(o);if(f===null)return null;a=1,u=f}else if(g(o)==="Multiply"){let f=[...b(o)];if(f.length!==2)return null;let p=M(f[0]);if(p===null)return null;a=p;let h=l(f[1]);if(h===null)return null;u=h}else{let f=M(o);if(f===null)return null;a=f,u=0}if(!Number.isInteger(a)||a<0||a>9||!Number.isInteger(u)||u<0||u>40||i.has(u))return null;i.set(u,a)}let r=Math.max(0,...i.keys()),s="";for(let o=r;o>=0;o--)s+=String(i.get(o)??0);return s}function fy(e,n){if(e===0n)return"0";let t=BigInt(n),i=[],r=e;for(;r>0n;){let s=Number(r%t);if(s<10)i.push(String.fromCharCode(48+s));else if(s<36)i.push(String.fromCharCode(97+s-10));else return null;r=r/t}return i.reverse().join("")}function dy(e,n){if(e.skipVisualSpace(),!Ye(n)&&typeof e.peek=="string"&&/^\d$/.test(e.peek)){let i="";for(;typeof e.peek=="string"&&/^\d$/.test(e.peek);)i+=e.nextToken();return["InvisibleOperator",n,{num:"0."+i}]}if(e.match("\\operatorname")){let i=e.parseStringGroup();if(i===null)return null;let r=i.trim(),s=oy[r];if(s!==void 0){let a=ay(e)?e.parseArguments("enclosure")??[]:[];return[s,n,...a]}let o=ja(r);return o===null?null:[o,n]}let t=e.peek;if(typeof t=="string"&&t.startsWith("\\")){let i=t.slice(1),r=ja(i);return r!==null?(e.nextToken(),[r,n]):null}if(typeof t=="string"&&/^[a-zA-Z]$/.test(t)){let i=E(n);if(i!==null&&e.resolveSymbol(i)?.type.matches("dictionary<any>")){let s="";for(;typeof e.peek=="string"&&/^[a-zA-Z]$/.test(e.peek);)s+=e.nextToken();return["At",n,{str:s}]}let r=ja(t);return r===null?null:(e.nextToken(),[r,n])}return null}function py(e){let n=e;return g(n)==="Delimiter"&&(n=d(n,1)??n),g(n)==="Sequence"?b(n):[e]}function jf(e){let n=g(e);return bi(n)||xi(n)||["And","Or","Not","Element","NotElement"].includes(n)}function my(e){let n=[];for(let t=0;t<e.length;t++){let i=e[t];if(g(i)==="Colon"&&P(i)===2)n.push(d(i,1),d(i,2));else if(jf(i))n.push(i,1);else if(t===e.length-1)n.push("True",i);else return null}return n}function Mf(e,n,t){e.addBoundary(t),e.skipVisualSpace();let i=e.parseExpression({minPrec:0});if(i===null||(e.skipVisualSpace(),!e.matchBoundary()))return e.removeBoundary(),null;let r=py(i);if(r.length>1||g(r[0])==="Colon"){if(r.some(s=>g(s)==="Colon")){let s=my(r);if(s!==null)return["Multiply",n,["Which",...s]]}else if(r.every(jf))return["When",n,["Or",...r]]}return["When",n,i]}var gy={"+":"Add","-":"Subtract","*":"Multiply","\\cdot":"Multiply","\\times":"Multiply","\\circ":"Ring","\\cup":"Union","\\cap":"Intersection","\\oplus":"CirclePlus","\\otimes":"CircleTimes","\\star":"Star"};function hy(e,n,t){let i=gy[e.peek];if(i===void 0)return null;let r=e.index;return e.nextToken(),e.skipSpace(),e.peek===t||e.atTerminator(n)?i:(e.index=r,null)}var Za=new WeakSet;function $f(e){return typeof e=="object"&&e!==null&&Za.has(e)}function $a(e,n,t,i,r,s){if(n&&n.minPrec>=i)return null;let o=l=>{g(l)==="Sequence"?a.push(...b(l)):a.push(l)},a=[];t?o(t):a.push("Nothing");let u=!1;for(;!u;){for(u=!0,e.skipSpace();e.match(r);)a.push("Nothing"),e.skipSpace();if(e.skipVisualSpace(),e.atTerminator(n))a.push("Nothing"),s&&(s.trailingEmpty=!0);else{let l=hy(e,n,r);if(l!==null)a.push(l),u=!1;else{let c=e.parseExpression({...n,minPrec:i});c!==null?o(c):a.push("Nothing"),u=c===null}}u||(e.skipSpace(),u=!e.match(r),u||e.skipVisualSpace())}return a}function yy(e,n){if(!n)return"";let t=b(n);if(t.length===0)return"";if(t.length===1)return e.serialize(t[0]);let i=t.map(s=>e.serialize(s)),r=[i[0]];for(let s=1;s<i.length;s++){let o=i[s-1],a=i[s],u=/[0-9]$/.test(o)&&/^[-+0-9]/.test(a);r.push(u?", ":" ",a)}return v(r)}function by(e,n){let t=g(n);if(t!=="Divide"&&t!=="Rational"||P(n)!==2||!e.options.prettify)return!1;let i=e.options.fractionStyle(n,e.level+1);return i==="inline-solidus"||i==="nice-solidus"}function xy(e,n){if(!n)return"";let t=b(n);if(t.length===0)return"";if(t.length===1)return e.serialize(t[0]);let i=t.map((s,o)=>{let a=e.serialize(s);return o<t.length-1&&by(e,s)?e.wrapString(a,e.groupStyle(n,e.level+1)):a}),r=i[0];for(let s=1;s<i.length;s++){let o=E(t[s-1]);o!==null&&/^[A-Z]$/.test(o)&&/^(\\left)?\(/.test(i[s])?r=Fe(e.options.multiply,r,i[s]):r=v([r,i[s]])}return r}function rt(e=""){return(n,t)=>{if(!t)return"";let i=b(t);if(i.length===0)return"";if(i.length===1)return n.serialize(i[0]);e={"&":"\\&",":":"\\colon","|":"\\mvert","-":"-","\xB7":"\\cdot","\u2012":"-","\u2013":"--","\u2014":"---","\u2015":"-","\u2022":"\\bullet","\u2026":"\\ldots"}[e]??e;let r=i.reduce((s,o)=>(s.push(n.serialize(o),e),s),[]);return r.pop(),v(r)}}var Ey=[{surface:"if",kind:"prefix",precedence:245,operatorname:!0,build:Vy},{surface:"for",kind:"prefix",precedence:245,operatorname:!0,build:Jy},{surface:"for",kind:"infix",precedence:19,associativity:"none",operatorname:!0,build:(e,n,t)=>{let i=e.index,r=Kf(e,n,t);if(r!==null)return r;e.index=i;let s=Lf(e,t);return s===null?(e.index=i,null):["ForAll",s,Vf(n)]}},{surface:"break",kind:"prefix",precedence:245,operatorname:!0,build:()=>["Break"]},{surface:"continue",kind:"prefix",precedence:245,operatorname:!0,build:()=>["Continue"]},{surface:"return",kind:"prefix",precedence:245,operatorname:!0,build:(e,n)=>["Return",e.parseExpression(n)??"Nothing"]},{surface:"for all",kind:"prefix",precedence:200,build:(e,n)=>Bn("ForAll")(e,n)},{surface:"for all",kind:"infix",precedence:19,associativity:"none",build:(e,n,t)=>{let i=e.index,r=Lf(e,t);return r===null?(e.index=i,null):["ForAll",r,Vf(n)]}},{surface:"there exists",kind:"prefix",precedence:200,build:(e,n)=>Bn("Exists")(e,n)},{surface:"where",kind:"infix",precedence:21,associativity:"none",operatorname:!0,build:(e,n,t)=>$y(e,n,t)},{surface:"such that",kind:"infix",precedence:21,associativity:"right",build:(e,n,t)=>["Colon",n,e.parseExpression({...t,minPrec:21})??"Nothing"]},{surface:"and",kind:"prefix",precedence:235,build:(e,n)=>(e.skipVisualSpace(),e.parseExpression(n)??"Nothing")},{surface:"and",kind:"infix",precedence:235,associativity:"right",build:(e,n,t)=>["And",n,e.parseExpression({...t,minPrec:235})??"Nothing"]},{surface:"or",kind:"infix",precedence:230,associativity:"right",build:(e,n,t)=>["Or",n,e.parseExpression({...t,minPrec:230})??"Nothing"]},{surface:"iff",kind:"infix",precedence:219,associativity:"right",build:(e,n,t)=>["Equivalent",n,e.parseExpression({...t,minPrec:219})??"Nothing"]},{surface:"if and only if",kind:"infix",precedence:219,associativity:"right",build:(e,n,t)=>["Equivalent",n,e.parseExpression({...t,minPrec:219})??"Nothing"]}];function Ty(){let e=[];for(let n of Ey){let t=n.surface;for(let i of["\\text","\\keyword"])if(n.kind==="prefix"){let r=n.build;e.push({latexTrigger:[i],kind:"prefix",precedence:n.precedence,parse:(s,o)=>{let a=s.index;return Qa(s,t)?r(s,o):(s.index=a,null)}})}else{let r=n.build;e.push({latexTrigger:[i],kind:"infix",associativity:n.associativity??"right",precedence:n.precedence,parse:(s,o,a)=>{let u=s.index;return Qa(s,t)?r(s,o,a):(s.index=u,null)}})}if(n.operatorname)if(n.kind==="prefix"){let i=n.build;e.push({symbolTrigger:t,kind:"prefix",precedence:n.precedence,parse:(r,s)=>i(r,s)})}else{let i=n.build;e.push({symbolTrigger:t,kind:"infix",associativity:n.associativity??"right",precedence:n.precedence,parse:(r,s,o)=>i(r,s,o)})}}return e.push({latexTrigger:["\\keyword"],parse:n=>oe(n)}),e}function Xe(e,n,t){let i=e.options.keywordStyle??"text";if(i==="keyword")return`\\keyword{${n}}`;if(i==="operatorname")return`\\operatorname{${n}}`;let r=t?.lead?" ":"",s=t?.trail?" ":"";return`\\text{${r}${n}${s}}`}var vn="topic_marker";function qf(e,n){if(E(e)===vn)return[n,!0];let t=g(e);if(!t)return[e,!1];let i=!1,r=b(e).map(s=>{let[o,a]=qf(s,n);return a&&(i=!0),o});return i?[[t,...r],!0]:[e,!1]}function zf(e,n){let[t,i]=qf(e,n);return i?t:["Pipe",n,e]}function Ri(e,n,t){let i=e.parseExpression({minPrec:21})??"Nothing";return zf(i,n)}function _i(e,n){let t=e.parseExpression({minPrec:21})??"Nothing",i="_";return["Function",zf(t,i),i]}var Ha="\\operatorname{Block}(";function Gf(e){let n="\\begin{cases}",t="\\end{cases}";if(e.startsWith(n)){let r=1,s=n.length;for(;s<e.length;)if(e.startsWith(n,s))r+=1,s+=n.length;else if(e.startsWith(t,s)){if(r-=1,s+=t.length,r===0)return s===e.length}else s+=1;return!1}if(!e.startsWith(Ha))return!1;let i=0;for(let r=Ha.length-1;r<e.length;r++)if(e[r]==="(")i+=1;else if(e[r]===")"&&(i-=1,i===0))return r===e.length-1;return!1}function qa(e,n){if(n===null)return"";let t=e.serialize(n);return g(n)!=="Block"||Gf(t)?t:v(["\\left(",t,"\\right)"])}var Wa=240,wf=new Set([..._e["("],..._e["["],..._e["{"],..._e["<"],"<{>"]),za=new Set([..._e[")"],..._e["]"],..._e["}"],..._e[">"],"<}>"]),Ny=new RegExp(`(?:${[...Object.keys(Le),...tt].map(e=>e.replace(/\\/g,"\\\\")).join("|")})(?![a-zA-Z])`,"g");function Uf(e){if(/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))return!0;try{return re(e)!==void 0}catch{return!1}}function vy(e,n){let t=E(n);if(!t)return null;let i=e.index,r=0,s=!1,o=-1,a="",u=i;for(;!e.atEnd;){let p=e.peek,h=p===">"&&a==="-";if(p==='"')s=!s;else if(!s&&!h){if(r===0&&(p===","||p==="\\mapsto"||za.has(p))){o=tt.has(a)?u:e.index;break}wf.has(p)?r+=1:za.has(p)&&(r-=1)}a=p,u=e.index,e.nextToken()}if(o<0||o===i)return e.index=i,null;let l=e.peek==="\\mapsto";if(!l){let p=0,h="";for(;!e.atEnd;){let y=e.nextToken(),N=y===">"&&h==="-";if(h=y,!N){if(wf.has(y))p+=1;else if(za.has(y)){if(p===0)break;p-=1}}}e.skipSpace(),l=e.peek==="\\mapsto"}if(!l)return e.index=i,null;let c=e.latex(i,o).replace(Ny,"");c=c.trim();let f=/^\\(?:mathrm|text|operatorname)\{(.*)\}$/s.exec(c);return f&&(c=f[1].trim()),Uf(c)?(e.index=o,["Typed",t,{str:c}]):(e.index=i,null)}function Af(e,n,t){if(n===null)return null;let i=vy(e,n);if(i!==null)return i;let r=O(e.parseExpression({...t,minPrec:Wa}));return["Colon",n,r]}var Zf=[{latexTrigger:["\\placeholder"],kind:"symbol",parse:e=>{for(;e.match("<space>"););if(e.match("["))for(;!e.match("]")&&!e.atBoundary;)e.nextToken();for(;e.match("<space>"););if(e.match("<{>"))for(;!e.match("<}>")&&!e.atBoundary;)e.nextToken();return"Nothing"}},{name:"ContinuationPlaceholder",standaloneSymbol:!0,latexTrigger:["\\dots"]},{latexTrigger:["\\ldots"],parse:"ContinuationPlaceholder"},{latexTrigger:["\\cdots"],parse:"ContinuationPlaceholder"},{latexTrigger:["\\dotsb"],parse:"ContinuationPlaceholder"},{latexTrigger:["\\dotsc"],parse:"ContinuationPlaceholder"},{latexTrigger:["\\dotsm"],parse:"ContinuationPlaceholder"},{latexTrigger:["\u2026"],parse:"ContinuationPlaceholder"},{latexTrigger:[".",".","."],parse:"ContinuationPlaceholder"},{latexTrigger:["\\vdots"],parse:"ContinuationPlaceholder"},{latexTrigger:["\\ddots"],parse:"ContinuationPlaceholder"},{name:"Typed",serialize:(e,n)=>e.serialize(d(n,1))},{name:"Function",latexTrigger:["\\mapsto"],kind:"infix",precedence:He,parse:(e,n,t)=>{let i=e.operandDiagnosticCheckpoint,r=[],s=[],o=c=>{let f=g(c)==="Typed"?E(d(c,1)):E(c);return f?(s.push(f),r.push(g(c)==="Typed"?c:f),!0):!1},a=!0;if(g(n)==="Delimiter"){let c=d(n,1);c==null||c==="Nothing"?a=!1:n=c}if(a){if(g(n)==="Sequence"){for(let c of b(n))if(!o(c))return null}else if(!o(n))return null}let u=e.parseExpression({...t??{},minPrec:21})??"Nothing",l=!1;return g(u)==="Delimiter"&&(l=!0,u=d(u,1)??"Nothing"),g(u)==="Sequence"&&(u=[l?"Tuple":"Block",...b(u)]),e._pruneUndeclared(s,i),["Function",u,...r]},serialize:(e,n)=>{let t=b(n),i=o=>{if(g(o)!=="Typed")return null;let a=d(o,2),u=_(a)??E(a);return u!==null&&Uf(u)?u:null},r=o=>i(o)!==null,s=o=>{if(g(o)!=="Typed")return e.serialize(o);let a=e.serialize(d(o,1)??"Nothing"),u=i(o);return u===null?a:v([a,"\\colon",u])};return t.length<1?"()\\mapsto()":t.length===1?v(["()","\\mapsto",e.serialize(d(n,1))]):t.length===2&&!r(d(n,2))?v([e.serialize(d(n,2)),"\\mapsto",e.serialize(d(n,1))]):v([e.wrapString(b(n)?.slice(1).map(s).join(", "),"normal"),"\\mapsto",e.serialize(d(n,1))])}},{name:"Apply",kind:"function",symbolTrigger:"apply",serialize:(e,n)=>{let t=d(n,1),i=g(t);if(i==="Derivative"){let o=ky(e,n);if(o!==null)return o}if(i==="InverseFunction"||i==="Derivative"){let o=e.options.applyFunctionStyle(n,e.level),a=b(n).slice(1);return e.serializeFunction(t,e.dictionary.ids.get(i))+e.wrapString(a.map(u=>e.serialize(u)).join(", "),o)}if(i==="Function"){let o=b(n).slice(1);return v([e.wrapString(e.serialize(t),"normal"),e.wrapString(o.map(a=>e.serialize(a)).join(", "),"normal")])}let r=d(n,2);if(typeof t=="string"||!r){let o=b(n);return e.serialize(o)}if(P(n)===2)return v([e.wrap(t,20),"\\lhd",e.wrap(r,20)]);let s=e.options.applyFunctionStyle(n,e.level);return v(["\\operatorname{apply}",e.wrapString(e.serialize(i)+", "+e.serialize(["List",...b(n)]),s)])}},{latexTrigger:"\\lhd",kind:"infix",precedence:20,parse:"Apply"},{name:vn,standaloneSymbol:!0,serialize:"\\square"},{name:"Pipe",latexTrigger:"\\rhd",kind:"infix",precedence:20,parse:Ri},{latexTrigger:"\\triangleright",kind:"infix",precedence:20,parse:Ri},{latexTrigger:"\\vartriangleright",kind:"infix",precedence:20,parse:Ri},{latexTrigger:"|>",kind:"infix",precedence:20,parse:Ri},{latexTrigger:["\u22B3"],kind:"infix",precedence:20,parse:Ri},{latexTrigger:"|>",kind:"prefix",precedence:20,parse:_i},{latexTrigger:"\\rhd",kind:"prefix",precedence:20,parse:_i},{latexTrigger:"\\triangleright",kind:"prefix",precedence:20,parse:_i},{latexTrigger:"\\vartriangleright",kind:"prefix",precedence:20,parse:_i},{latexTrigger:["\u22B3"],kind:"prefix",precedence:20,parse:_i},{name:"EvaluateAt",openTrigger:".",closeTrigger:"|",kind:"matchfix",serialize:(e,n)=>{let t=d(n,1);if(!t)return"";let i=b(n).slice(1);if(g(t)==="Function"){let r=b(t).slice(1),s=d(t,1);if(g(s)==="Block"&&P(s)===1&&(s=d(s,1)),r.length===1&&i.length===2)return`\\left.\\left(${e.serialize(s)}\\right)\\right|_{${e.serialize(i[0])}}^{${e.serialize(i[1])}}`;if(r.length>0)return`\\left.\\left(${e.serialize(s)}\\right)\\right|_{${r.map((o,a)=>`${e.serialize(o)}=${e.serialize(i[a])}`).join(", ")}}`}return`\\left.\\left(${e.serialize(t)}\\right)\\right|_{${i.map(r=>e.serialize(r)).join(", ")}}`}},{name:"Assign",latexTrigger:"\\coloneq",kind:"infix",associativity:"right",precedence:hi,serialize:(e,n)=>{let t=Ra(d(n,1));if(g(d(n,2))==="Function"){let i=d(n,2),r=Ra(d(i,1)),s=b(i).slice(1);return v([e.serialize(t),e.wrapString(s.map(o=>e.serialize(o)).join(", "),e.options.applyFunctionStyle(n,e.level)),"\\coloneq",e.serialize(r)])}return v([e.serialize(t),"\\coloneq",e.serialize(d(n,2))])},parse:Zs},{latexTrigger:"\\coloneqq",kind:"infix",associativity:"right",precedence:hi,parse:Zs},{latexTrigger:"\\colonequals",kind:"infix",associativity:"right",precedence:hi,parse:Zs},{latexTrigger:[":","="],kind:"infix",associativity:"right",precedence:hi,parse:Zs},{name:"Colon",latexTrigger:":",kind:"infix",associativity:"right",precedence:Wa,parse:Af,serialize:(e,n)=>v([e.serialize(d(n,1)),"\\colon",e.serialize(d(n,2))])},{latexTrigger:"\\colon",kind:"infix",associativity:"right",precedence:Wa,parse:Af},{name:"BaseForm",serialize:(e,n)=>{let t=M(d(n,2))??NaN;if(isFinite(t)&&t>=2&&Number.isInteger(t)){let r=ly(d(n,1));if(r!==null&&r>=0n){let s=fy(r,t);if(s!==null)return/^[0-9]+$/.test(s)?`${s}_{${t}}`:`\\mathrm{${s}}_{${t}}`}}let i=E(d(n,2));if(i!==null){let r=cy(d(n,1),i);if(r!==null)return`${r}_{${i}}`}return"\\operatorname{BaseForm}("+e.serialize(d(n,1))+", "+e.serialize(d(n,2))+")"}},{name:"Sequence",serialize:yy},{name:"InvisibleOperator",serialize:xy},{name:"Delimiter",serialize:(e,n)=>{let t=e.options.groupStyle(n,e.level+1),i=d(n,1);if(P(n)===1){let c=g(i);if(c==="List"||c==="Set"||c==="Tuple"||c==="Pair"||c==="Triple"||c==="Single")return e.wrapString(e.serialize(i),t,"()")}let r={Set:"{,}",List:"[,]",Tuple:"(,)",Single:"(,)",Pair:"(,)",Triple:"(,)",Sequence:"(,)",String:'""'}[g(i)],s=r?i:["Sequence",i];if(r??="(,)",P(n)>1){let c=_(d(n,2));typeof c=="string"&&c.length<=3&&(r=c)}let[o,a,u]=["","",""];r.length===3?[o,a,u]=r:r.length===2?[o,u]=r:r.length===1&&(a=r);let l=i===null?"":rt(a)(e,s);return e.wrapString(l,t,o+u)}},{name:"Tuple",serialize:(e,n)=>v(["(",rt(",")(e,n),P(n)===1?",":"",")"])},{name:"Pair",serialize:(e,n)=>v(["(",rt(",")(e,n),")"])},{name:"Triple",serialize:(e,n)=>v(["(",rt(",")(e,n),")"])},{name:"Single",serialize:(e,n)=>v(["(",rt(",")(e,n),P(n)===1?",":"",")"])},{name:"Domain",serialize:(e,n)=>g(n)==="Error"?e.serialize(n):`\\mathbf{${e.serialize(d(n,1))}}`},{latexTrigger:["\\mathtip"],parse:e=>{let n=e.parseGroup();return e.parseGroup(),n}},{latexTrigger:["\\texttip"],parse:e=>{let n=e.parseGroup();return e.parseGroup(),n}},{latexTrigger:["\\error"],parse:e=>["Error",e.parseGroup()]},{name:"Error",serialize:(e,n)=>{let t=d(n,1);if(_(t)==="missing")return`\\error{${e.options.missingSymbol??"\\placeholder{}"}}`;let i=Iy(e,n)||"\\blacksquare",r=g(t)==="ErrorCode"?_(d(t,1)):_(t);if(r==="no-product-between-points"){let s=_(d(t,2));return`\\mathtip{\\error{${i}}}{\\text{points have no implicit product}${s==="dimension-mismatch"?"\\text{ \u2014 they have different dimensions}":s==="cross-applies"?"\\text{ \u2014 }\\mathrm{Dot}\\text{ is the inner product, }\\mathrm{Cross}\\text{ the cross product}":"\\text{ \u2014 use }\\mathrm{Dot}\\text{ for the inner product}"}}`}return r==="no-division-by-point"?`\\mathtip{\\error{${i}}}{\\text{a point cannot be a divisor}}`:r==="incompatible-type"?E(d(t,3))==="Undefined"?`\\mathtip{\\error{${i}}}{\\notin ${e.serialize(d(t,2))}}`:`\\mathtip{\\error{${i}}}{\\in ${e.serialize(d(t,3))}\\notin ${e.serialize(d(t,2))}}`:typeof r=="string"?`\\error{${i}}`:`\\error{${i}}`}},{name:"ErrorCode",serialize:(e,n)=>{let t=_(d(n,1));return t==="missing"?e.options.missingSymbol??"\\placeholder{}":t==="unexpected-command"||t==="unexpected-operator"||t==="unexpected-token"||t==="invalid-symbol"||t==="unknown-environment"||t==="unexpected-base"||t==="incompatible-type"||t==="no-product-between-points"||t==="no-division-by-point"?"":`\\texttip{\\error{\\blacksquare}}{\\mathtt{${t}}}`}},{name:"FromLatex",serialize:(e,n)=>`\\texttt{${Ga(_(d(n,1)))}}`},{name:"Latex",serialize:(e,n)=>n===null?"":v(Vs(n,t=>_(t)??e.serialize(t)))},{name:"LatexString",serialize:(e,n)=>n===null?"":v(Vs(n,t=>e.serialize(t)))},{name:"LatexTokens",serialize:Sy},{kind:"postfix",precedence:850,latexTrigger:["."],parse:dy},{name:"At",kind:"postfix",precedence:810,latexTrigger:["["],parse:Hs("]"),serialize:(e,n)=>{let t=b(n),i=e.wrap(t[0]??"Nothing",tn),r=t.slice(1).map(s=>e.serialize(s));return e.indexStyle(n,e.level)==="bracket"?v([i,"[",r.join(", "),"]"]):xn("_",i,r.join(","))}},{kind:"postfix",precedence:810,latexTrigger:["\\lbrack"],parse:Hs("\\rbrack")},{kind:"postfix",precedence:810,latexTrigger:["\\left","\\lbrack"],parse:Hs("\\right","\\rbrack")},{kind:"postfix",precedence:810,latexTrigger:["\\left","["],parse:Hs("\\right","]")},{name:"When",kind:"postfix",precedence:800,latexTrigger:["\\left","\\{"],parse:(e,n)=>Mf(e,n,["\\right","\\}"]),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);if(t===null||i===null)return"";let s=(g(i)==="And"?b(i)??[]:[i]).map(o=>`\\left\\{${e.serialize(o)}\\right\\}`).join("");return`${e.wrap(t,800)}${s}`}},{kind:"postfix",precedence:800,latexTrigger:["\\{"],parse:(e,n)=>Mf(e,n,["\\}"])},{kind:"postfix",latexTrigger:["_"],parse:(e,n,t)=>{let i=e.parseGroup()??e.parseToken();i===null&&e.options.strict===!1&&e.peek==="("&&(i=e.parseEnclosure());let r=E(n);if(i!==null&&(r&&e.resolveSymbol(r)?.type.matches("indexed_collection<any>")||g(n)==="List"))return g(i)==="Delimiter"&&(i=d(i,1)??"Nothing"),g(i)==="Sequence"?["At",n,...b(i)]:["At",n,i];if(i!==null){let s=uy(n,i);if(s!==null)return s}return i!==null&&E(i)==="Nothing"?n:["Subscript",n,i]}},{name:"List",kind:"matchfix",openTrigger:"[",closeTrigger:"]",parse:Hf,serialize:By},{kind:"matchfix",openTrigger:"(",closeTrigger:")",parse:wy},{name:"AngleBracket",kind:"matchfix",openTrigger:["\\langle"],closeTrigger:["\\rangle"],parse:(e,n)=>{if(n===null||F(n))return["AngleBracket"];let t=n;return g(t)==="Delimiter"&&(t=d(t,1)??t),g(t)==="Sequence"||g(t)==="List"?["AngleBracket",...b(t)]:["AngleBracket",t]},serialize:(e,n)=>v(["\\langle ",b(n).map(t=>e.serialize(t)).join(", ")," \\rangle"])},{latexTrigger:[","],kind:"infix",precedence:20,parse:(e,n,t)=>{let i={trailingEmpty:!1},r=$a(e,t,n,20,",",i);if(r===null)return null;let s=["Sequence",...r];return i.trailingEmpty&&Za.add(s),["Delimiter",s,{str:","}]}},{latexTrigger:[","],kind:"prefix",precedence:20,parse:(e,n)=>{let t={trailingEmpty:!1},i=$a(e,n,null,20,",",t);if(i===null)return null;let r=["Sequence",...i];return t.trailingEmpty&&Za.add(r),["Delimiter",r,{str:","}]}},{name:"Range",latexTrigger:[".","."],kind:"infix",precedence:800,parse:(e,n)=>e.peek==="."?null:Us(e,n),serialize:(e,n)=>{let t=b(n);if(t.length===0)return"";if(t.length===1)return"1.."+e.serialize(d(n,1));if(t.length===2)return e.wrap(d(n,1),800)+".."+e.wrap(d(n,2),800);if(t.length===3){let i=M(d(n,3)),r=M(d(n,1));return i!==null&&r!==null?e.wrap(d(n,1),800)+".."+e.wrap(r+i,800)+".."+e.wrap(d(n,2),800):e.wrap(d(n,1),800)+"..("+(e.wrap(d(n,1),q)+"+"+e.wrap(d(n,3),q))+").."+e.wrap(d(n,2),800)}return""}},{latexTrigger:[".",".","."],kind:"infix",precedence:W,parse:(e,n)=>Us(e,n,!0)},{latexTrigger:["\\ldots"],kind:"infix",precedence:W,parse:(e,n)=>Us(e,n,!0)},{latexTrigger:["\\dots"],kind:"infix",precedence:W,parse:(e,n)=>Us(e,n,!0)},{latexTrigger:[";"],kind:"infix",precedence:19,parse:(e,n,t)=>{let i={trailingEmpty:!1},r=$a(e,t,n,19,";",i);if(r===null)return null;let s=!1;return r.length>1&&i.trailingEmpty&&(r.pop(),s=!0),r.some(o=>g(o)==="Assign")||s&&r.length===1?Jf(r):["Delimiter",["Sequence",...r],"';'"]}},...Ty(),{name:"Block",serialize:(e,n)=>{let t=b(n);if(!t||t.length===0)return"";let i=t.filter(s=>g(s)!=="Declare"),r=i.map(s=>e.serialize(s));return r.length===1?`${r[0]};`:i.some(s=>g(s)==="Assign")?r.join("; "):i.every(s=>{let o=g(s);return xi(o)||bi(o)})?v([Ha,r.join(", "),")"]):v(["\\begin{cases}",r.join("\\\\"),"\\end{cases}"])}},{name:"If",serialize:(e,n)=>{let t=b(n);return!t||t.length<3?"":v([Xe(e,"if",{trail:!0}),e.serialize(t[0]),Xe(e,"then",{lead:!0,trail:!0}),e.serialize(t[1]),Xe(e,"else",{lead:!0,trail:!0}),e.serialize(t[2])])}},{name:"Loop",serialize:(e,n)=>{let t=b(n);if(!t||t.length===0)return"";let i=t[0],r=t.slice(1);if(r.length===1&&g(r[0])==="Element"){let s=r[0],o=d(s,1),a=d(s,2);if(g(a)==="Range"){let u=d(a,1),l=d(a,2);return v([Xe(e,"for",{trail:!0}),e.serialize(o),Xe(e,"from",{lead:!0,trail:!0}),e.serialize(u),Xe(e,"to",{lead:!0,trail:!0}),e.serialize(l),Xe(e,"do",{lead:!0,trail:!0}),qa(e,i)])}}return v(["\\operatorname{Loop}(",t.map(s=>qa(e,s)).join(", "),")"])}},{name:"Comprehension",serialize:(e,n)=>{let t=b(n);if(!t||t.length<2)return"";let i=t[0],s=t.slice(1).map(u=>{let l=d(u,1),c=d(u,2);return v([e.serialize(l)," = ",e.serialize(c)])}).join(", "),o=qa(e,i),a=v([o," \\operatorname{for} ",s]);return v(["\\left[",a,"\\right]"])}},{name:"Break",serialize:e=>Xe(e,"break")},{name:"Continue",serialize:e=>Xe(e,"continue")},{name:"Return",serialize:(e,n)=>{let t=d(n,1);return t===null||E(t)==="Nothing"?Xe(e,"return"):v([Xe(e,"return",{trail:!0}),e.serialize(t)])}},{name:"CharacterFrom",serialize:(e,n)=>{let t=_(d(n,1));return t===null?`\\operatorname{CharacterFrom}(${e.serialize(d(n,1))})`:`\\text{${Ga(t)}}`}},{name:"Text",serialize:(e,n)=>{let t=b(n);if(t.length===0)return"";let i=-1,r=-1;for(let a=0;a<t.length;a++)_(t[a])!==null&&(i<0&&(i=a),r=a);if(i<0)return v(t.map(a=>e.serialize(a)));let s=[];for(let a=0;a<i;a++)s.push(e.serialize(t[a]));let o="";for(let a=i;a<=r;a++){let u=_(t[a]);u!==null?o+=Ga(u):g(t[a])==="Annotated"||g(t[a])==="Text"?o+=e.serialize(t[a]):o+="$"+e.serialize(t[a])+"$"}s.push("\\text{"+o+"}");for(let a=r+1;a<t.length;a++)s.push(e.serialize(t[a]));return v(s)}},{name:"String",latexTrigger:["\\text"],parse:e=>oe(e),serialize:(e,n)=>{let t=b(n);return t.length===0?"\\text{}":v(["\\text{",t.map(i=>e.serialize(i)).join(""),"}"])}},{name:"Subscript",latexTrigger:["_"],kind:"infix",serialize:(e,n)=>P(n)===2?e.serialize(d(n,1))+"_{"+e.serialize(d(n,2))+"}":"_{"+e.serialize(d(n,1))+"}"},{name:"IndexedSequence",serialize:(e,n)=>{let t=Ka(d(n,1)),i=d(n,2),r=d(n,3),s=P(n)>=4?b(n)?.[3]??null:null,o=`\\left\\{${e.serialize(t)}\\right\\}_{${e.serialize(i)}=${e.serialize(r)}}`;return s===null?o:`${o}^{${e.serialize(s)}}`}},{name:"Superplus",latexTrigger:["^","+"],kind:"postfix"},{name:"Subplus",latexTrigger:["_","+"],kind:"postfix"},{name:"Superminus",latexTrigger:["^","-"],kind:"postfix",parse:(e,n)=>e.options.strict===!1&&/^[0-9]$/.test(e.peek)?null:["Superminus",n]},{name:"Subminus",latexTrigger:["_","-"],kind:"postfix"},{latexTrigger:["^","*"],kind:"postfix",parse:(e,n)=>["Superstar",n]},{latexTrigger:["_","*"],kind:"postfix",parse:(e,n)=>["Substar",n]},{name:"Substar",latexTrigger:["_","\\star"],kind:"postfix"},{name:"Superdagger",latexTrigger:["^","\\dagger"],kind:"postfix"},{latexTrigger:["^","\\dag"],kind:"postfix",parse:(e,n)=>["Superdagger",n]},{name:"Prime",latexTrigger:["^","\\prime"],kind:"postfix",parse:(e,n)=>Nn(e,n,1),serialize:(e,n)=>{let t=M(d(n,2))??1,i=e.serialize(d(n,1));return t===1?i+"^{\\prime}":t===2?i+"^{\\doubleprime}":t===3?i+"^{\\tripleprime}":i+"^{("+e.serialize(d(n,2))+")}"}},{latexTrigger:"^{\\prime\\prime}",kind:"postfix",parse:(e,n)=>Nn(e,n,2)},{latexTrigger:"^{\\prime\\prime\\prime}",kind:"postfix",parse:(e,n)=>Nn(e,n,3)},{latexTrigger:["^","\\doubleprime"],kind:"postfix",parse:(e,n)=>Nn(e,n,2)},{latexTrigger:["^","\\tripleprime"],kind:"postfix",parse:(e,n)=>Nn(e,n,3)},{latexTrigger:"'",kind:"postfix",precedence:810,parse:(e,n)=>Nn(e,n,1)},{latexTrigger:"\\prime",kind:"postfix",precedence:810,parse:(e,n)=>Nn(e,n,1)},{latexTrigger:"\\doubleprime",kind:"postfix",precedence:810,parse:(e,n)=>Nn(e,n,2)},{latexTrigger:"\\tripleprime",kind:"postfix",precedence:810,parse:(e,n)=>Nn(e,n,3)},{latexTrigger:["^","<{>","("],kind:"postfix",parse:(e,n,t)=>{let i=E(n);if(!i||!e.resolveSymbol(i)?.type.matches("function"))return null;e.addBoundary([")"]);let r=e.parseExpression(t);return e.matchBoundary()?e.match("<}>")?["Derivative",n,r]:null:(e.removeBoundary(),null)}},{name:"InverseFunction",latexTrigger:"^{-1",kind:"postfix",parse:(e,n)=>{if(g(n)==="Matrix")return e.match("<}>"),["Inverse",n];let t=E(n);if(!t)return null;let i=e.resolveSymbol(t)?.type;if(i!==void 0&&i.type!=="never"&&i.matches(new Se("matrix")))return e.match("<}>"),["Inverse",n];if(!i?.matches("function"))return null;let r=0;for(;!e.atEnd&&!e.match("<}>");)if(e.match("'"))r++;else if(e.match("\\prime"))r++;else if(e.match("\\doubleprime"))r+=2;else if(e.match("\\tripleprime"))r+=3;else return null;return r===1?["Derivative",["InverseFunction",n]]:r>0?["Derivative",["InverseFunction",n],r]:["InverseFunction",n]},serialize:(e,n)=>e.serialize(d(n,1))+"^{-1}"},{name:"Derivative",serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=b(n).slice(1);if(i.length>1)return t+"^{("+i.map(s=>e.serialize(s)).join(", ")+")}";let r=M(i[0])??1;return r===1?t+"^{\\prime}":r===2?t+"^{\\doubleprime}":r===3?t+"^{\\tripleprime}":t+"^{("+e.serialize(i[0])+")}"}},{name:"D",serialize:(e,n)=>{if(g(n)!=="D")return"D";let t=d(n,1),i=d(n,2);if(!t||!i)return`\\operatorname{D}(${(b(n)??[]).map(f=>e.serialize(f)).join(", ")})`;let r=1,s=t;for(;g(s)==="D";){let c=d(s,2);if(E(c)===E(i))r++,s=d(s,1);else break}let o=s;g(s)==="Function"&&(o=d(s,1)??s);let a=e.serialize(o),u=e.wrapShort(o),l=e.serialize(i);return u!==a?r===1?`\\frac{\\mathrm{d}${u}}{\\mathrm{d}${l}}`:`\\frac{\\mathrm{d}^{${r}}${u}}{\\mathrm{d}${l}^{${r}}}`:r===1?`\\frac{\\mathrm{d}}{\\mathrm{d}${l}}${u}`:`\\frac{\\mathrm{d}^{${r}}}{\\mathrm{d}${l}^{${r}}}${u}`}},{name:"NewtonDerivative1",latexTrigger:["\\dot"],kind:"prefix",precedence:740,parse:e=>{let n=e.parseGroup();if(n===null)return null;let t=e.options.timeDerivativeVariable;return["D",n,t]}},{name:"NewtonDerivative2",latexTrigger:["\\ddot"],kind:"prefix",precedence:740,parse:e=>{let n=e.parseGroup();if(n===null)return null;let t=e.options.timeDerivativeVariable;return["D",["D",n,t],t]}},{name:"NewtonDerivative3",latexTrigger:["\\dddot"],kind:"prefix",precedence:740,parse:e=>{let n=e.parseGroup();if(n===null)return null;let t=e.options.timeDerivativeVariable;return["D",["D",["D",n,t],t],t]}},{name:"NewtonDerivative4",latexTrigger:["\\ddddot"],kind:"prefix",precedence:740,parse:e=>{let n=e.parseGroup();if(n===null)return null;let t=e.options.timeDerivativeVariable;return["D",["D",["D",["D",n,t],t],t],t]}},{name:"EulerDerivative",latexTrigger:["D"],kind:"expression",parse:e=>{let n=1,t=null,i=!1;for(;!i;)if(e.match("_")){if(t=e.parseGroup()??e.parseToken(),!t)return null}else if(e.match("^")){let a=e.parseGroup()??e.parseToken();n=M(a)??1}else i=!0;if(!t||E(t)===null||e.resolveSymbol(`D_${E(t)}`)!==void 0)return null;let r=e.resolveSymbol("D")?.type;if(r&&!r.matches("function"))return null;e.skipSpace();let s=e.parseExpression({minPrec:740});if(!s)return null;let o=s;for(let a=0;a<n;a++)o=["D",o,t];return o}},{kind:"environment",name:"Which",symbolTrigger:"cases",parse:Ua,serialize:(e,n)=>{let t=[],i=b(n);if(i.length>0)for(let r=0;r<=i.length-2;r+=2){let s=[];s.push(e.serialize(i[r+1])),s.push(e.serialize(i[r])),t.push(s.join("&"))}return v(["\\begin{cases}",t.join("\\\\"),"\\end{cases}"])}},{kind:"environment",symbolTrigger:"dcases",parse:Ua},{kind:"environment",symbolTrigger:"rcases",parse:Ua},{kind:"environment",symbolTrigger:"aligned",parse:Ke},{kind:"environment",symbolTrigger:"aligned*",parse:Ke},{kind:"environment",symbolTrigger:"align",parse:Ke},{kind:"environment",symbolTrigger:"align*",parse:Ke},{kind:"environment",symbolTrigger:"gather",parse:Ke},{kind:"environment",symbolTrigger:"gather*",parse:Ke},{kind:"environment",symbolTrigger:"gathered",parse:Ke},{kind:"environment",symbolTrigger:"split",parse:Ke},{kind:"environment",symbolTrigger:"multline",parse:Ke},{kind:"environment",symbolTrigger:"multline*",parse:Ke},{kind:"environment",symbolTrigger:"eqnarray",parse:Ke}];function oe(e,n){if(!e.match("<{>"))return"''";let t=[],i="",r=null,s=()=>{r!==null&&i?t.push(["Annotated",`'${i}'`,Ls(r)]):i&&t.push(`'${i}'`),i="",r=null};for(;!e.atEnd&&!e.match("<}>");)if(e.peek==="<{>")s(),t.push(oe(e));else if(e.match("\\textbf"))s(),t.push(oe(e,{fontWeight:"bold"}));else if(e.match("\\textmd"))s(),t.push(oe(e,{fontStyle:"normal"}));else if(e.match("\\textup"))s(),t.push(oe(e,{fontStyle:"normal"}));else if(e.match("\\textsl"))s(),t.push(oe(e,{fontStyle:"italic"}));else if(e.match("\\textit"))s(),t.push(oe(e,{fontStyle:"italic"}));else if(e.match("\\texttt"))s(),t.push(oe(e,{fontFamily:"monospace"}));else if(e.match("\\textsf"))s(),t.push(oe(e,{fontFamily:"sans-serif"}));else if(e.match("\\textcolor")){let a=e.index,u=e.parseStringGroup();if(u!==null){s();let l=oe(e);t.push(["Annotated",l,Ls({color:u})])}else e.index=a,i+="\\textcolor"}else if(e.match("\\color")){let a=e.parseStringGroup();a!==null&&(s(),r={color:a})}else if(e.match("<space>"))i+=" ";else if(e.match("<$>")){let a=e.index,u=e.parseExpression()??"Nothing";e.skipSpace(),e.match("<$>")?(s(),t.push(u)):(i+="$",e.index=a)}else if(e.match("<$$>")){let a=e.index,u=e.parseExpression()??"Nothing";e.skipSpace(),e.match("<$$>")?(s(),t.push(u)):(i+="$$",e.index=a)}else{let a=e.parseChar()??e.nextToken();i+={"\\enskip":"\u2002","\\enspace":"\u2002","\\quad":"\u2003","\\qquad":"\u2003\u2003","\\space":"\u2003","\\ ":"\u2003","\\;":"\u2004","\\,":"\u2009","\\:":"\u205F","\\!":"","\\{":"{","\\}":"}","\\$":"$","\\&":"&","\\#":"#","\\%":"%","\\_":"_","\\textbackslash":"\\","\\textasciitilde":"~","\\textasciicircum":"^","\\textless":"<","\\textgreater":">","\\textbar":"|","\\textunderscore":"_","\\textbraceleft":"{","\\textbraceright":"}","\\textasciigrave":"`","\\textquotesingle":"'","\\textquotedblleft":"\u201C","\\textquotedblright":"\u201D","\\textquotedbl":'"',"\\textquoteleft":"\u2018","\\textquoteright":"\u2019","\\textbullet":"\u2022","\\textdagger":"\u2020","\\textdaggerdbl":"\u2021","\\textsection":"\xA7","\\textparagraph":"\xB6","\\textperiodcentered":"\xB7","\\textellipsis":"\u2026","\\textemdash":"\u2014","\\textendash":"\u2013","\\textregistered":"\xAE","\\texttrademark":"\u2122","\\textdegree":"\xB0"}[a]??a}s();let o;return t.length===1?o=t[0]:t.every(a=>_(a)!==null)?o="'"+t.map(a=>_(a)).join("")+"'":o=["Text",...t],n?["Annotated",o,Ls(n)]:o}function Sy(e,n){return n===null?"":v(Vs(n,t=>{let i=_(t);return i===null?e.serialize(t):i==="<{>"?"{":i==="<}>"?"}":i==="<$>"?"$":i==="<$$>"?"$$":i==="<space>"?" ":i}))}function Ga(e){return e===null?"":e.replace(/[{}\[\]\\:\-\$%]/g,n=>({"{":"\\lbrace ","}":"\\rbrace ","[":"\\lbrack ","]":"\\rbrack ",":":"\\colon ","\\":"\\backslash "})[n]??"\\"+n)}function Iy(e,n){let t=d(n,2);return t===null||g(t)==="ErrorTrace"?"":g(t)==="LatexString"?_(d(t,1))??"":g(t)==="Hold"?e.serialize(d(t,1)):e.serialize(t)}function ky(e,n){let t=d(n,1);if(g(t)!=="Derivative")return null;let i=[];for(let c of b(t).slice(1)){let f=M(c);if(f===null||!Number.isInteger(f)||f<0)return null;i.push(f)}if(i.length<2)return null;let r=b(n).slice(1);if(r.length!==i.length)return null;let s=i.reduce((c,f)=>c+f,0);if(s===0)return null;let o=[];for(let c=0;c<i.length;c++){if(i[c]===0)continue;if(!E(r[c]))return null;let f=e.serialize(r[c]);o.push(i[c]===1?`\\partial ${f}`:`\\partial ${f}^{${i[c]}}`)}let a=s===1?"\\partial":`\\partial^{${s}}`,u=e.serialize(d(t,1)),l=r.map(c=>e.serialize(c)).join(", ");return`\\frac{${a}}{${o.join(" ")}} ${u}(${l})`}function My(e,n){if(e.atEnd||e.peek!=="_")return n;let t=E(n);if(t!==null&&!e.isFunctionTriggerName(t)){let s=e.resolveSymbol(t);if(!s?.subscriptEvaluate){let o=e.index,a=Ct(e,t,s?.type.matches("indexed_collection<any>")??!1);if(a!==t)return a;if(e.index!==o)return n}}let i=e.index;e.nextToken();let r=e.parseGroup()??e.parseToken();return r===null||F(r)?(e.index=i,n):["Subscript",n,r]}function Nn(e,n,t){for(;!e.atEnd;)if(e.match("'")||e.match("\\prime"))t++;else if(e.match("\\doubleprime"))t+=2;else if(e.match("\\tripleprime"))t+=3;else break;n=My(e,n);let i=g(n);if(i==="Derivative"||i==="Prime"){let l=M(d(n,2))??1;return[i,O(d(n,1)),l+t]}let r=g(n),s=r==="Subscript"?E(d(n,1)):E(n),a=s!==null&&(r===""||r==="Subscript")?e.resolveSymbol(s)?.type.matches("function")===!0:r!=="";e.skipSpace();let u=e.parseArguments("enclosure");return u&&u.length>0?["Apply",["Derivative",n,t],...u]:a?t===1?["Derivative",n]:["Derivative",n,t]:t===1?["Prime",O(n)]:["Prime",O(n),t]}function wy(e,n){if(F(n))return["Delimiter"];let t=g(n);if(t==="Range"&&Di.delete(n),t==="Delimiter"&&d(n,2)!==null){let i=_(d(n,2));if(i?.length===1)return["Delimiter",d(n,1)??"Nothing",{str:`(${i})`}]}return t==="Matrix"&&(_(d(n,2))??"..")===".."?["Matrix",d(n,1)]:["Delimiter",n]}function Hf(e,n){if(F(n))return["List"];let t=g(n);if(t==="Range"||t==="Linspace"||t==="Comprehension")return t==="Range"&&Di.delete(n),n;if(t==="Sequence"){let i=b(n),r=Ys(i,e);return r||["List",...i]}if(t==="Delimiter"){let i=_(d(n,2))??"...";if(i===";"||i===".;.")return["List",...(b(d(n,1))??[]).map(r=>Hf(e,r))];if(i===","||i===".,."){if(n=d(n,1),g(n)==="Sequence"){let r=b(n),s=Ys(r,e);return s||["List",...r]}return["List",n??"Nothing"]}}if(n!=null){let i=nu(n);if(i)return["Range",i.sample,i.end]}return["List",n]}function Pi(e){let n=M(e);if(n!==null)return n;if(g(e)==="Negate"){let t=M(d(e,1));if(t!==null)return-t}return null}var Di=new WeakSet;function Ay(e,n){let t=Ei(e,1),i=Ei(n,1);if(t===null||i===null)return null;let r=t[0]*i[1]-i[0]*t[1],s=t[1]*i[1];return!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||s===0?null:r/s}function Wf(e){let n=M(e);if(n!==null)return{num:n,den:1};let t=g(e);if(t==="Negate"){let i=d(e,1);if(i==null)return null;let r=Wf(i);return r===null?null:{num:-r.num,den:r.den}}if(t==="Divide"||t==="Rational"){if(P(e)!==2)return null;let i=Pi(d(e,1)),r=Pi(d(e,2));return i===null||r===null||!Number.isInteger(i)||!Number.isInteger(r)||r===0?null:{num:i,den:r}}return null}function Rf(e,n){n<0&&([e,n]=[-e,-n]);let t=Ry(Math.abs(e),n);return[e,n]=[e/t,n/t],n===1?e:["Divide",e,n]}function Ry(e,n){for(;n!==0;)[e,n]=[n,e%n];return e===0?1:e}var _y=new Set(["Add","Subtract","Multiply","InvisibleOperator","Negate"]);function _f(e){if(g(e)==="Range"&&b(e).length===2&&Di.has(e))return{start:d(e,1),end:d(e,2)};let n=nu(e);return n===null?null:{start:n.sample,end:n.end}}function nu(e){let n=g(e);if(!_y.has(n))return null;let t=b(e);if(n==="Negate"){if(t.length!==1)return null;let o=_f(t[0]);return o===null?null:{sample:["Negate",o.start],end:o.end}}if(t.length<2)return null;let i=_f(t[t.length-1]);if(i===null)return null;let r=t.slice(0,-1);return{sample:[n,...r,i.start],end:i.end}}function Ws(e){let n=g(e);if(n==="InvisibleOperator"||n==="Multiply"){let t=b(e);if(t.length>=2&&E(t[0])==="ContinuationPlaceholder"){let i=t.slice(1);return i.length===1?i[0]:[n,...i]}return null}if(n==="Negate"){let t=Ws(d(e,1));return t===null?null:["Negate",t]}if(n==="Subtract"){let t=Ws(d(e,1));return t===null?null:["Subtract",t,d(e,2)]}if(n==="Add"){let t=b(e),i=Ws(t[0]);return i===null?null:["Add",i,...t.slice(1)]}return null}function Ys(e,n){if(e.length>=2){let f=e[e.length-1],p=e[e.length-2];if(E(p)!=="ContinuationPlaceholder")if(g(f)==="Range"&&b(f).length===2&&Di.has(f))e=[...e.slice(0,-1),d(f,1),"ContinuationPlaceholder",d(f,2)];else{let h=nu(f);if(h!==null)e=[...e.slice(0,-1),h.sample,"ContinuationPlaceholder",h.end];else{let y=Ws(f);y!==null&&(e=[...e.slice(0,-1),"ContinuationPlaceholder",y])}}}if(e.length<3)return null;let t=e[e.length-2];if(E(t)!=="ContinuationPlaceholder")return null;let i=e.slice(0,-2),r=e[e.length-1];if(i.length===1){let f=i[0];return E(f)==="ContinuationPlaceholder"?null:["Range",M(f)??f,r]}if(i.length<2)return null;let s=n.options.tolerance,o=i.map(Wf);if(o.every(f=>f!==null)){let f=o,p=f.map(y=>y.num/y.den),h=Ay(p[p.length-1],p[p.length-2])??p[p.length-1]-p[p.length-2];if(Math.abs(h)<s)return n.error("degenerate-range-step",n.index);for(let y=1;y<p.length;y++)if(Math.abs(p[y]-p[y-1]-h)>s)return n.error("inconsistent-range-samples",n.index);if(f.some(y=>y.den!==1)){let y=f[f.length-1],N=f[f.length-2];return["Range",Rf(f[0].num,f[0].den),r,Rf(y.num*N.den-N.num*y.den,y.den*N.den)]}return["Range",p[0],r,h]}let a=i.map(Xf);if(a.some(f=>f===null))return Oy(i,r,s)??Py(i,r);let u=a.map(f=>f.coeff),l=a[0].sym;if(a.some(f=>f.sym!==l))return null;let c=u[u.length-1]-u[u.length-2];if(Math.abs(c)<s)return n.error("degenerate-range-step",n.index);for(let f=1;f<u.length;f++)if(Math.abs(u[f]-u[f-1]-c)>s)return n.error("inconsistent-range-samples",n.index);return["Range",Df(u[0],l),r,Df(c,l)]}var tu=new Set(["Add","Subtract","Negate","Multiply","InvisibleOperator","Divide","Rational","Power","Square","Sqrt","Root"]);function Xs(e){if(M(e)!==null)return!0;let n=g(e);if(n===null||!tu.has(n))return!1;if(n==="InvisibleOperator"){let t=b(e);for(let i=0;i+1<t.length;i++)if(E(t[i])!==null&&g(t[i+1])==="Delimiter")return!1}return!0}function Ya(e){if(M(e)!==null||E(e)!==null)return!0;let n=g(e);return n===null||n!=="Delimiter"&&(!tu.has(n)||!Xs(e))?!1:b(e).every(Ya)}function Xa(e,n){let t=E(e);if(t!==null){n.add(t);return}for(let i of b(e))Xa(i,n)}function Yf(e){let n=M(e);if(n!==null)return n;let t=g(e);if(t===null||!tu.has(t)||!Xs(e))return null;let i=b(e).map(Yf);if(i.some(o=>o===null))return null;let r=i,s=null;return t==="Add"?s=r.reduce((o,a)=>o+a,0):t==="Multiply"||t==="InvisibleOperator"?s=r.reduce((o,a)=>o*a,1):t==="Subtract"&&r.length===2?s=r[0]-r[1]:t==="Negate"&&r.length===1?s=-r[0]:(t==="Divide"||t==="Rational")&&r.length===2?s=r[0]/r[1]:t==="Power"&&r.length===2?s=Math.pow(r[0],r[1]):t==="Square"&&r.length===1?s=r[0]*r[0]:t==="Sqrt"&&r.length===1?s=Math.sqrt(r[0]):t==="Root"&&r.length===2&&(s=Math.pow(r[0],1/r[1])),s===null||!Number.isFinite(s)?null:s}function Py(e,n){if(e.length!==2)return null;let[t,i]=e;if(!Xs(i))return null;let r=Yf(t);if(r===null){if(!Xs(t)||!Ya(t)||!Ya(i))return null;let o=new Set,a=new Set;Xa(t,o),Xa(i,a);for(let l of o)if(!a.has(l))return null;let u=new Set;for(let l of o){let c=Pf(l);c!==null&&u.add(c)}for(let l of a){if(o.has(l))continue;let c=Pf(l);if(c!==null&&u.has(c))return null}}let s=r===0?i:Dy(t,i)??["Subtract",i,t];return["Range",t,n,s]}function Pf(e){let n=e.indexOf("_");return n>0?e.slice(0,n):null}function Dy(e,n){if(g(e)!=="Add"||g(n)!=="Add")return null;let t=b(e),i=b(n);if(i.length<=t.length)return null;for(let s=0;s<t.length;s++)if(JSON.stringify(t[s])!==JSON.stringify(i[s]))return null;let r=i.slice(t.length);return r.length===1?r[0]:["Add",...r]}function Xf(e){let n=E(e);if(n!==null)return n.includes("_")?null:{coeff:1,sym:n};let t=g(e);if(t==="Negate"){let i=d(e,1);if(!i)return null;let r=Xf(i);return r===null?null:{coeff:-r.coeff,sym:r.sym}}if(t==="Multiply"||t==="InvisibleOperator"){let i=b(e);if(i.length!==2)return null;let r=Pi(i[0]),s=E(i[1]);return r===null||s===null||s.includes("_")?null:{coeff:r,sym:s}}return null}function Df(e,n){return e===1?n:e===-1?["Negate",n]:["Multiply",e,n]}function Cf(e){if(g(e)==="Add"){let n=[],t=0;for(let r of b(e)){let s=Pi(r);s!==null?t+=s:n.push(r)}return n.length===0?null:{base:n.length===1?n[0]:["Add",...n],offset:t}}return Pi(e)!==null?null:{base:e,offset:0}}function Cy(e,n){return n===0?e:g(e)==="Add"?["Add",...b(e),n]:["Add",e,n]}function Oy(e,n,t){let i=e.map(Cf);if(i.some(l=>l===null))return null;let r=i,s=JSON.stringify(r[0].base);if(r.some(l=>JSON.stringify(l.base)!==s))return null;let o=Cf(n);if(o===null||JSON.stringify(o.base)!==s)return null;let a=r.map(l=>l.offset),u=a[a.length-1]-a[a.length-2];if(Math.abs(u)<t)return null;for(let l=1;l<a.length;l++)if(Math.abs(a[l]-a[l-1]-u)>t)return null;return["Range",Cy(r[0].base,a[0]),n,u]}function By(e,n){return P(n)>1&&b(n).every(t=>{let i=g(t);return xi(i)||bi(i)})?v(["\\begin{cases}",rt("\\\\")(e,n),"\\end{cases}"]):v(["\\bigl\\lbrack",rt(", ")(e,n),"\\bigr\\rbrack"])}function Us(e,n,t=!1){if(n===null)return null;let i=e.parseExpression({minPrec:270});if(i===null)return t?["Sequence",n,"ContinuationPlaceholder"]:null;if(t&&g(n)==="InvisibleOperator"&&b(n).some(s=>_(s)!==null))return["InvisibleOperator",...b(n),"ContinuationPlaceholder",i];if(g(i)==="Range"){let s=d(i,1),o=d(i,2);return s&&o?["Range",n,o,["Subtract",s,n]]:null}let r=["Range",n,i];return Di.add(r),r}var Ks={"(":"(",")":")","[":"\\lbrack","]":"\\rbrack","\u27E6":"\\llbrack","\u27E7":"\\rrbrack","{":"\\lbrace","}":"\\rbrace","<":"\\langle",">":"\\rangle","\u2016":"\\Vert","\\":"\\backslash","\u2308":"\\lceil","\u2309":"\\rceil","\u230A":"\\lfloor","\u230B":"\\rfloor","\u231C":"\\ulcorner","\u231D":"\\urcorner","\u231E":"\\llcorner","\u231F":"\\lrcorner","\u23B0":"\\lmoustache","\u23B1":"\\rmoustache"};function Ka(e){if(e===null)return"Nothing";let n=g(e);if(!n)return e;let t=b(e)??[];return n.length>1&&n.endsWith("_")&&t.length===1?["Subscript",n.slice(0,-1),Ka(t[0])]:[n,...t.map(i=>Ka(i))]}function Of(e,n,t){if(!n||n.length===0)return;let i=[];for(let r of n){let s=E(r);s&&i.push(s)}e._pruneUndeclared(i,t)}function Bf(e,n,t,i){let r=()=>e.parseExpression({...i??{},minPrec:20}),s=e.resolveSymbol(n)?.type.type,o=s!==void 0&&typeof s=="object"&&s.kind==="signature"?[...s.args??[],...s.optArgs??[]]:void 0;if(!t||!o||o.length===0)return r();let a=!1;try{for(let u=0;u<t.length;u++){let l=E(t[u]),c=o[u]?.type;!l||c===void 0||(a||(e.pushSymbolTable(),a=!0),e.addSymbol(l,new Se(c)))}return r()}finally{a&&e.popSymbolTable()}}function Zs(e,n,t){let i=e.operandDiagnosticCheckpoint,r=(t?.minPrec??0)>=19,s=E(n);if(s&&s.includes("_")){let u=s.indexOf("_"),l=s.substring(0,u),c=s.substring(u+1),f=parseInt(c,10),p=!isNaN(f)&&String(f)===c?f:c,h=p!==""&&(typeof p=="number"||typeof p=="string"&&p.length===1);(e.resolveSymbol(l)?.type.matches("indexed_collection<any>")||!r&&h)&&(n=["Subscript",l,p])}if(g(n)==="InvisibleOperator"&&P(n)===2&&g(d(n,2))==="Delimiter"){let u=E(d(n,1));if(!u)return null;let l=d(d(n,2),1),c=[];g(l)==="Sequence"?c=[...b(l)]:l&&(c=[l]);let f=Bf(e,u,c,t);return f===null?null:(Of(e,c,i),e._pruneJuxtaposition(u,i),e._pruneUndeclared([u],i),["Assign",u,["Function",f,...c??[]]])}if(g(n)==="Subscript"&&E(d(n,1))){let u=E(d(n,1));if(!e.resolveSymbol(u)?.type.matches("indexed_collection<any>")){let f=d(n,2),p=(f!==null&&typeof f=="string"?f:void 0)??(f!==null&&typeof f=="number"?String(f):void 0);if(p&&r){let h=e.parseExpression({...t??{},minPrec:20});return h===null?null:["Assign",u+"_"+p,h]}}let l=e.parseExpression({...t??{},minPrec:20});if(l===null)return null;let c=d(n,2);return _(c)!==null?["Assign",n,l]:E(c)?["Assign",n,l]:["Assign",n,l]}let o=g(n);if(o){let u=b(n),l=Bf(e,o,u,t);return l===null?null:(Of(e,u,i),e._pruneJuxtaposition(o,i),e._pruneUndeclared([o],i),["Assign",o,["Function",l,...u]])}if(!E(n))return null;let a=e.parseExpression({...t??{},minPrec:20});return a===null?null:["Assign",n,a]}function Ua(e){let n=e.parseTabular();if(!n)return["List"];if(n.every(i=>{if(i.length!==1)return!1;let r=g(i[0]);return bi(r)||xi(r)}))return["List",...n.map(i=>i[0])];if(n.length>=2&&n.every(i=>i.length===1))return["Block",...n.map(i=>i[0])];let t=[];for(let i of n)if(i.length===1)t.push("True"),t.push(i[0]);else if(i.length===2){let s=_(i[1])?null:Aa(i[1]);t.push(s===null||s==="Nothing"?"True":s),t.push(i[0])}return["Which",...t]}var Fy={"=":"Equal","\\ne":"NotEqual","\\neq":"NotEqual","<":"Less","\\lt":"Less",">":"Greater","\\gt":"Greater","\\le":"LessEqual","\\leq":"LessEqual","\\ge":"GreaterEqual","\\geq":"GreaterEqual"};function Ff(e){return e.atBoundary||e.peek==="\\\\"||e.peek==="\\cr"}function Ly(e){let n=i=>i.peek==="&"||i.peek==="\\\\"||i.peek==="\\cr"||i.peek===","||i.peek===";",t=null;for(;!Ff(e)&&(e.skipSpace(),!Ff(e));){if(e.match("&"))continue;if(e.peek===","||e.peek==="."||e.peek===";"){e.nextToken();continue}let i=Fy[e.peek];if(i!==void 0&&t!==null){e.nextToken();let s=e.parseExpression({minPrec:0,condition:n});t=[i,t,O(s)];continue}let r=e.parseExpression({minPrec:0,condition:n});if(r===null){e.nextToken();continue}t=t===null?r:["InvisibleOperator",t,r]}return t}function Ke(e){let n=[];for(;!e.atBoundary;){let t=e.index,i=Ly(e);if(i!==null&&n.push(i),e.skipSpace(),(e.match("\\\\")||e.match("\\cr"))&&e.parseOptionalGroup(),e.index===t){if(e.atBoundary)break;e.nextToken()}}return["List",...n]}function Qa(e,n){let t=e.index;if(!e.match("<{>"))return e.index=t,!1;for(;e.match("<space>"););for(let i=0;i<n.length;i++)if(n[i]===" "){if(!e.match("<space>"))return e.index=t,!1;for(;e.match("<space>"););}else{if(e.peek!==n[i])return e.index=t,!1;e.nextToken()}for(;e.match("<space>"););return e.match("<}>")?!0:(e.index=t,!1)}function st(e,n){let t=e.index;e.skipVisualSpace();let i=e._diagnosticsCheckpoint();if(e.match("\\text")||e.match("\\keyword")){if(Qa(e,n))return e._rollbackDiagnostics(i),!0;e.index=t}let r=e.index,s=e.parseSymbol();return e._rollbackDiagnostics(i),s!==null&&E(s)===n?!0:(e.index=r,!1)}function ot(e,n){let t=e.index,i=st(e,n);return e.index=t,i}function Vy(e,n){e.skipVisualSpace();let t=e.parseExpression({minPrec:0,condition:s=>ot(s,"then")});if(t===null||!st(e,"then"))return null;e.skipVisualSpace();let i=e.parseExpression({minPrec:0,condition:s=>ot(s,"else")});if(i===null||!st(e,"else"))return null;e.skipVisualSpace();let r=e.parseExpression(n)??"Nothing";return["If",t,i,r]}function Jy(e,n){let t=e.parseExpression({minPrec:0,condition:a=>ot(a,"from")}),i=t?E(t):null;if(!i||!st(e,"from"))return null;let r=e.parseExpression({minPrec:0,condition:a=>ot(a,"to")});if(r===null||!st(e,"to"))return null;let s=e.parseExpression({minPrec:0,condition:a=>ot(a,"do")});return s===null||!st(e,"do")?null:["Loop",e.parseExpression(n)??"Nothing",["Element",i,["Range",r,s]]]}function Kf(e,n,t){let i={minPrec:21,condition:s=>{if(t?.condition?.(s))return!0;let o=s.index;s.skipVisualSpace();let a=s.peek===",";return s.index=o,!!(a||ot(s,"where")||ot(s,"with"))}},r=[];do{e.skipVisualSpace();let s=e.parseExpression(i);if(s===null)break;let o=g(s);if(o!=="Equal"&&o!=="Assign")return null;let a=d(s,1),u=d(s,2);if(!a||!u)return null;r.push(["Element",a,u]),e.skipVisualSpace()}while(e.match(","));return r.length===0?null:["Comprehension",n,...r]}var jy=new Set(["Less","Greater","LessEqual","GreaterEqual","Equal","NotEqual","Element"]);function Qf(e){if(e===null)return!1;let n=g(e);if(!n)return!1;if(jy.has(n))return!0;if(n==="And"||n==="Or"){let t=b(e);return t.length===0?!1:t.every(i=>Qf(i))}return!1}function Lf(e,n){e.skipVisualSpace();let t=e.parseExpression(n);return Qf(t)?t:null}function Vf(e){if(g(e)!=="Delimiter")return e;let n=d(e,1);return g(n)!=="Sequence"||P(e)!==2||_(d(e,2))!==","?e:["Tuple",...b(n)]}function $y(e,n,t){let i={minPrec:21,condition:a=>{if(t?.condition?.(a))return!0;let u=a.index;a.skipVisualSpace();let l=a.peek===",";return a.index=u,l}},r=[];do{e.skipVisualSpace();let a=e.parseExpression(i);if(!a)break;r.push(a),e.skipVisualSpace()}while(e.match(","));if(r.length===0)return null;let s=e.index;if(st(e,"for")){let a=Kf(e,n,t);if(a){let u=[];for(let l of r){let c=eu(l);g(c)==="Assign"&&u.push(["Declare",d(c,1)]),u.push(c)}return u.push(a),["Block",...u]}e.index=s}let o=[];for(let a of r){let u=eu(a);g(u)==="Assign"&&o.push(["Declare",d(u,1)]),o.push(u)}return o.push(n),["Block",...o]}function Jf(e){let n=[];for(let t of e){let i=eu(t);g(i)==="Assign"&&n.push(["Declare",d(i,1)]),n.push(i)}return["Block",...n]}function eu(e){if(g(e)!=="Assign")return e;let n=d(e,1);if(g(n)!=="Subscript")return e;let t=E(d(n,1));if(!t)return e;let i=d(n,2),r=(typeof i=="string"?i:void 0)??(typeof i=="number"?String(i):void 0);return r?["Assign",`${t}_${r}`,d(e,2)??"Nothing"]:e}function qy(e){if(g(e)!=="Delimiter")return!1;if(P(e)<2)return!0;let n=_(d(e,2));return typeof n=="string"&&n.length>=2&&n[0]==="("}var zy=new Set(["Delimiter","List","Sequence","InvisibleOperator","Error","At"]);function Gy(e){let n=g(e);return typeof n!="string"||n===""?!1:!zy.has(n)}function Hs(...e){return(n,t)=>{if(!E(t)&&g(t)!=="List"&&g(t)!=="At"&&!qy(t)&&!Gy(t))return null;let i=null;if(e.length===0){if(i=n.parseGroup()??n.parseExpression({minPrec:0}),i===null)return null}else if(e.length>1){if(n.addBoundary(e),i=n.parseExpression({minPrec:0}),i===null||!n.matchBoundary())return n.removeBoundary(),null}else if(i=n.parseExpression({minPrec:0}),i===null||!n.matchAll(e))return null;return e.length===0&&_(i)!==null?null:(g(i)==="Delimiter"&&(i=d(i,1)??"Nothing"),g(i)==="Sequence"?["At",t,...b(i)]:["At",t,i])}}var ed=[{name:"To",latexTrigger:["\\to"],kind:"infix",precedence:270},{latexTrigger:["\\rightarrow"],kind:"infix",precedence:270,parse:"To"},{latexTrigger:["-",">"],kind:"infix",precedence:270,parse:(e,n,t)=>{if(e.options.strict!==!1)return null;let i=e.parseExpression({...t,minPrec:270});return i===null?null:["To",n,i]}}];function Uy(e){let n=!!e.matchAny(["-","\u2212"]);for(;e.matchAny(["+","\uFE62"])||e.skipSpace();)e.matchAny(["-","\u2212"])&&(n=!n);return n?"-":"+"}function Ln(e,n,t="whole"){let i=[],r=!1;for(;!r;){for(;/^[0-9]$/.test(e.peek);)i.push(e.nextToken()),e.skipVisualSpace();r=!0;let s=t==="whole"?n.wholeDigitGroupSeparatorTokens:n.fractionalDigitGroupSeparatorTokens;if(t!=="none"){let o=e.index;e.skipVisualSpace();let a=n.decimalSeparatorTokens.length===3&&n.decimalSeparatorTokens[0]==="<{>"&&n.decimalSeparatorTokens[1]===","&&n.decimalSeparatorTokens[2]==="<}>";s.length>0&&e.matchAll(s)||!a&&e.matchAll(["<{>",",","<}>"])?(e.skipVisualSpace(),/^[0-9]$/.test(e.peek)?r=!1:e.index=o):e.index=o}}return i.join("")}function iu(e,n,t){let i=e.index,r=Uy(e),s=Ln(e,n,t);return s?r==="-"?"-"+s:s:(e.index=i,"")}function Zy(e,n){let t=e.index;if(e.skipVisualSpace(),e.matchAny(["e","E"])){let i=iu(e,n,"none");if(i)return i}if(e.index=t,e.match("\\times")&&(e.skipVisualSpace(),e.matchAll(["1","0"])&&(e.skipVisualSpace(),e.match("^")))){if(e.skipVisualSpace(),/^[0-9]$/.test(e.peek))return e.nextToken();if(e.match("<{>")){e.skipVisualSpace();let i=iu(e,n,"whole");if(e.skipVisualSpace(),i&&e.match("<}>"))return i}}if(e.index=t,e.skipVisualSpace(),e.match("\\%"))return"-2";if(e.index=t,e.matchAll(n.exponentProductTokens)&&(e.skipVisualSpace(),e.matchAll(n.beginExponentMarkerTokens))){e.skipVisualSpace();let i=iu(e,n,"none");if(e.skipVisualSpace(),i&&e.matchAll(n.endExponentMarkerTokens))return i}return e.index=t,""}function nd(e){let n=e.index;if(e.matchAll(["\\overset","<{>"])&&(e.match(".")||e.match("\\cdots"))&&e.matchAll(["<}>","<{>"])){let t=e.nextToken();if(t&&/^\d$/.test(t)&&e.match("<}>"))return t}return e.index=n,null}function Hy(e){let n=e.length;for(let t=1;t<=n>>1;t++){let i=e.slice(n-t),r=1;for(;(r+1)*t<=n&&e.startsWith(i,n-(r+1)*t);)r+=1;if(r>=(t===1?3:2))return[e.slice(0,n-r*t),i]}return null}function Wy(e){let n=e.peek;return n==="\\overline"||n==="\\overset"||n==="\\wideparen"||n==="\\overarc"||n==="("||n==="\\left"}function su(e,n){let t=e.index,i=e.options.repeatingDecimal,r="";if((i==="auto"||i==="parentheses")&&e.match("("))return r=Ln(e,n,"fraction"),r&&e.match(")")?`(${r})`:(e.index=t,"");if(e.index=t,(i==="auto"||i==="parentheses")&&e.matchAll(["\\left","("]))return r=Ln(e,n,"fraction"),r&&e.matchAll(["\\right",")"])?`(${r})`:(e.index=t,"");if(e.index=t,(i==="auto"||i==="vinculum")&&e.matchAll(["\\overline","<{>"]))return r=Ln(e,n,"fraction"),r&&e.match("<}>")?`(${r})`:(e.index=t,"");if(e.index=t,(i==="auto"||i==="arc")&&(e.matchAll(["\\wideparen","<{>"])||e.matchAll(["\\overarc","<{>"])))return r=Ln(e,n,"fraction"),r&&e.match("<}>")?`(${r})`:(e.index=t,"");if(e.index=t,i==="auto"||i==="dots"){let s=nd(e);if(s!==null){if(r=Ln(e,n,"fraction"),!r)return`(${s})`;let o=nd(e);if(o!==null)return`(${s}${r}${o})`}}return e.index=t,""}function ru(e){return e===0?{num:"0"}:Number.isInteger(e)&&Math.abs(e)<zn?e:{num:e.toString()}}function td(e,n){let t=e.options.parseNumbers;if(t===!1||t==="never")return null;let i=e.index;e.skipVisualSpace();let r=1;for(;e.peek==="-"||e.peek==="+";)e.match("-")?r=-r:e.match("+"),e.skipVisualSpace();let s="",o="",a=!1;if(e.match(".")||e.matchAll(n.decimalSeparatorTokens)){let p=e.peek;(/^[\d]$/.test(p)||Wy(e))&&(a=!0,s="0")}else s=Ln(e,n,"whole");if(!s)return e.index=i,null;let u=e.index,l=!1;(a||e.match(".")||e.matchAll(n.decimalSeparatorTokens))&&(o=Ln(e,n,"fraction"),l=!0);let c=!1;if(l){let p=su(e,n);if(p&&(o+=p,c=!0),(e.match("\\ldots")||e.matchAll(n.truncationMarkerTokens))&&!c){let h=Hy(o);h&&(o=`${h[0]}(${h[1]})`,c=!0)}}if(l&&!o){let p=e.peek,h=typeof p=="string"&&(/^[a-zA-Z]$/.test(p)||p==="\\operatorname"||p==="\\max"||p==="\\min"||p===".");return(a||h)&&(e.index=u),s.length<10?ru(r*parseInt(s,10)):{num:r<0?"-"+s:s}}let f=Zy(e,n);if(!l&&!f&&s.length<10)return ru(r*parseInt(s,10));if(!c&&e.options.parseNumbers==="rational"){let p=s.length>16||s.length===16&&s>"9007199254740991";if(!o){if(p){let K=r<0?"-"+s:s;return f?["Multiply",{num:K},["Power",10,f]]:{num:K}}let J=parseInt(s,10);return f?["Multiply",r*J,["Power",10,f]]:ru(r*J)}let h=o.length;if(s.length+h>15){let J=BigInt(s),K=BigInt(o),$=BigInt(10)**BigInt(h),ln=J*$+K,wn=r<0?-ln:ln;return f?["Multiply",["Rational",{num:wn.toString()},Number($)],["Power",10,f]]:["Rational",{num:wn.toString()},Number($)]}let N=parseInt(s,10),D=parseInt(o,10),R=N*10**h+D,z=10**h;return f?["Multiply",["Rational",r*R,z],["Power",10,f]]:["Rational",r*R,z]}return{num:(r<0?"-":"")+s+(l?"."+o:"")+(f?"e"+f:"")}}function sd(e,n){return e===null?!1:typeof e=="string"?e===n||e.split("_").includes(n):Array.isArray(e)?e.some(t=>sd(t,n)):!1}function ou(e,n){if(typeof e=="string"){let t=e.indexOf("_");return t>0&&e.substring(t+1)===n?[e.substring(0,t)+"_",n]:e}return Array.isArray(e)?g(e)==="Subscript"&&typeof d(e,1)=="string"&&sd(d(e,2),n)?[d(e,1)+"_",ou(d(e,2),n)]:[e[0],...e.slice(1).map(t=>ou(t,n))]:e}function Yy(e){if(e==="NonNegativeIntegers")return 0;if(e==="PositiveIntegers")return 1}function Xy(e){let n,t=e;if(g(e)==="Power"&&(n=d(e,2)??void 0,t=d(e,1)),t===null||g(t)!=="Subscript")return e;let i=d(t,1);if(i===null||g(i)!=="Set"||(b(i)?.length??0)!==1)return e;let r=d(t,2);if(r===null)return e;let s,o;if(g(r)==="Equal"){let u=d(r,1);if(typeof u!="string")return e;s=u,o=d(r,2)??void 0}else if(g(r)==="Element"){let u=d(r,1);if(typeof u!="string")return e;let l=Yy(d(r,2));if(l===void 0)return e;s=u,o=l}else return e;if(s===void 0||o===void 0)return e;let a=ou(d(i,1),s);return n===void 0?["IndexedSequence",a,s,o]:["IndexedSequence",a,s,o,n]}function Ky(e){if(g(e)==="List")return null;let n=g(e)==="Delimiter"?d(e,1):e;if(n===null)return null;if(g(n)==="Sequence"){let t=b(n)??[];if(t.length!==1)return null;n=t[0]}return n}function Qy(e){let n,t=e;if(g(e)==="Power"){let a=d(e,1),u=d(e,2);if(a===null||u===null)return e;t=a,n=u}if(g(t)!=="Subscript")return e;let i=d(t,1);if(i===null||g(i)!=="Norm"||(b(i)?.length??0)!==1)return e;let r=d(t,2);if(r===null)return e;let s=Ky(r);if(s===null)return e;let o=["Norm",d(i,1),E(s)==="F"?{str:"Frobenius"}:s];return n===void 0?o:["Power",o,n]}var eb=new Set([...'!"#$%&(),/;:?@[]\\`|~'.split(""),"\\left","\\bigl","\\mleft"]),nb=new Set(["\\!","\\,","\\:","\\;","\\enskip","\\enspace","\\space","\\quad","\\qquad"]),tb=["pt","em","mu","ex","mm","cm","in","bp","sp","dd","cc","pc","nc","nd"].map(e=>[...e]),Qs={sin:"Sin",cos:"Cos",tan:"Tan",cot:"Cot",sec:"Sec",csc:"Csc",sinh:"Sinh",cosh:"Cosh",tanh:"Tanh",coth:"Coth",sech:"Sech",csch:"Csch",arcsin:"Arcsin",arccos:"Arccos",arctan:"Arctan",arccot:"Arccot",arcsec:"Arcsec",arccsc:"Arccsc",asin:"Arcsin",acos:"Arccos",atan:"Arctan",acot:"Arccot",asec:"Arcsec",acsc:"Arccsc",atan2:"Arctan2",arcsinh:"Arsinh",arccosh:"Arcosh",arctanh:"Artanh",arccoth:"Arcoth",arcsech:"Arsech",arccsch:"Arcsch",asinh:"Arsinh",acosh:"Arcosh",atanh:"Artanh",log:"Log",ln:"Ln",exp:"Exp",lg:"Lg",lb:"Lb",sqrt:"Sqrt",abs:"Abs",sgn:"Sgn",sign:"Sgn",floor:"Floor",ceil:"Ceil",round:"Round",max:"Max",min:"Min",gcd:"Gcd",lcm:"Lcm",cbrt:"Root",binom:"Binomial",nCr:"Binomial",nPr:"Permutations"},id={"<space>":" ","<$$>":"$$","<$>":"$","<{>":"{","<}>":"}"},eo=null;function ib(){if(!eo){eo=new Map;for(let[,e,n]of Fn)eo.set(e,String.fromCodePoint(n))}return eo}var au={"(":")","[":"]","|":"|","\\{":"\\}","\\[":"\\]","\\lbrace":"\\rbrace","\\lparen":"\\rparen","\\langle":"\\rangle","\\lfloor":"\\rfloor","\\lceil":"\\rceil","\\vert":"\\vert","\\lvert":"\\rvert","\\Vert":"\\Vert","\\lVert":"\\rVert","\\|":"\\|","\\lbrack":"\\rbrack","\\ulcorner":"\\urcorner","\\llcorner":"\\lrcorner","\\lgroup":"\\rgroup","\\lmoustache":"\\rmoustache","\\llbracket":"\\rrbracket"},od=new Set(["\\vert","\\lvert","\\rvert","\\Vert","\\lVert","\\rVert","\\|"]);function rb(e){return e.every(n=>n==="|"||od.has(n))}function sb(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e instanceof Se)return"BoxedType";if(typeof e=="string")return`"${e}"`;if(typeof e=="object"){let n=e.constructor?.name;return n&&n!=="Object"?n:"object"}return`${typeof e} (${String(e)})`}var rd=class e{options;_index=0;symbolTable={parent:null,ids:xa()};pushSymbolTable(){this._symbolTableGen+=1,this.symbolTable={parent:this.symbolTable,ids:xa()}}popSymbolTable(){this._symbolTableGen+=1,this.symbolTable=this.symbolTable.parent??this.symbolTable}addSymbol(n,t){if(this._symbolTableGen+=1,typeof t=="string"&&(t=new Se(t)),n in this.symbolTable.ids&&!this.symbolTable.ids[n].is(t.type))throw new Error(`Symbol ${n} already declared as a different type`);this.symbolTable.ids[n]=t}_reversedIntervalDepth=0;_quantifierScopeDepth=0;get inQuantifierScope(){return this._quantifierScopeDepth>0}enterQuantifierScope(){this._quantifierScopeDepth++}exitQuantifierScope(){this._quantifierScopeDepth>0&&this._quantifierScopeDepth--}get index(){return this._index}set index(n){if(this.diagnostics!==null&&this.diagnostics.length>0&&n<this._index){let i=this.tokenPrefixOffsets()[Math.max(0,Math.min(n,this._tokens.length))],r=this.diagnostics,s=0;for(let o=0;o<r.length;o++)r[o].start>=i||(r[s++]=r[o]);r.length=s}this._index=n,this._lastPeek="",this._peekCounter=0}_tokens;_positiveInfinityTokens;_negativeInfinityTokens;_notANumberTokens;_decimalSeparatorTokens;_wholeDigitGroupSeparatorTokens;_fractionalDigitGroupSeparatorTokens;_exponentProductTokens;_beginExponentMarkerTokens;_endExponentMarkerTokens;_truncationMarkerTokens;_imaginaryUnitTokens;_dictionary;_boundaries=[];_boundaryBarrier=0;_lastPeek="";_peekCounter=0;_lookAheadCache=null;_lookAheadIndex=-1;_tokenPrefixOffsets=null;_symbolTableGen=0;_symCandidateIndex=-1;_symCandidateGen=-1;_symCandidate=null;_symCandidateCount=0;diagnostics;_diagnosticSeq=0;emitDiagnostic(n,t,i,r){if(this.diagnostics===null)return;let[s,o]=this.sourceOffsets(t,i),a=this._diagnosticSeq++;this.diagnostics.push(r!==void 0?{code:n,start:s,end:o,detail:r,_seq:a}:{code:n,start:s,end:o,_seq:a})}_diagnosticsCheckpoint(){return this._diagnosticSeq}_rollbackDiagnostics(n){if(this.diagnostics===null)return;let t=this.diagnostics,i=0;for(let r=0;r<t.length;r++)t[r]._seq<n&&(t[i++]=t[r]);t.length=i}_pruneUndeclared(n,t,i,r){if(this.diagnostics===null)return;let s=n instanceof Set?n:new Set(n);if(s.size===0)return;if(this.options.onBoundVariable)for(let h of s)this.options.onBoundVariable(h);let o=this.tokenPrefixOffsets(),a=this._tokens.length,u=h=>o[Math.max(0,Math.min(h,a))],l=i===void 0?-1/0:u(i),c=(r??[]).map(([h,y])=>[u(h),u(y)]),f=this.diagnostics,p=0;for(let h=0;h<f.length;h++){let y=f[h],N=y.detail?.name;if(y.code==="undeclared-symbol"&&y._seq>=t&&typeof N=="string"&&s.has(N)){let R=y.start>=l,z=c.some(([J,K])=>y.start>=J&&y.start<K);if(R||z)continue}f[p++]=y}f.length=p}_pruneJuxtaposition(n,t){if(this.diagnostics===null)return;let i=this.diagnostics,r=0;for(let s=0;s<i.length;s++){let o=i[s];o.code==="juxtaposition-as-multiply"&&o._seq>=t&&o.detail?.name===n||(i[r++]=o)}i.length=r}get operandDiagnosticCheckpoint(){return this._operandDiagnosticCheckpoint}_operandDiagnosticCheckpoint=0;get operandStartIndex(){return this._operandStartIndex}_operandStartIndex=0;get ownedChain(){return this._ownedChain}_ownedChain=null;_appendAssociativeOperand(n,t,i){if(t===this._ownedChain&&Array.isArray(t)&&t[0]===n){let s=t;return g(i)===n?s.push(...b(i)):s.push(i),t}let r=af(n,t,i);return this._ownedChain=r,r}resolveSymbol(n){let t=this.symbolTable;for(;t;){if(n in t.ids)return{type:t.ids[n]};t=t.parent}let i=this.options.resolveSymbol?.(n);if(i==null)return;let r=i.type;if(r instanceof Se)return i;if(typeof r=="string")try{return{...i,type:new Se(r)}}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`ce.parse(): resolveSymbol("${n}") returned invalid type string "${r}". ${o}`)}throw new Error(`ce.parse(): resolveSymbol("${n}") must return a \`type\` that is a BoxedType or a type string, received ${sb(r)}`)}isFunctionTriggerName(n){return this._dictionary.symbolTriggerDefs.get("function")?.has(n)??!1}emitSymbolReference(n,t,i){this.diagnostics!==null&&this.resolveSymbol(n)===void 0&&this.emitDiagnostic("undeclared-symbol",t,i,{name:n,type:"unknown"})}constructor(n,t,i){this._tokens=n,this.options=i,this._dictionary=t,this.diagnostics=i.diagnostics?[]:null,this._positiveInfinityTokens=be(this.options.positiveInfinity),this._negativeInfinityTokens=be(this.options.negativeInfinity),this._notANumberTokens=be(this.options.notANumber),this._decimalSeparatorTokens=be(this.options.decimalSeparator),this._wholeDigitGroupSeparatorTokens=[],this._fractionalDigitGroupSeparatorTokens=[],this.options.digitGroupSeparator&&(typeof this.options.digitGroupSeparator=="string"?(this._wholeDigitGroupSeparatorTokens=be(this.options.digitGroupSeparator),this._fractionalDigitGroupSeparatorTokens=this._wholeDigitGroupSeparatorTokens):Array.isArray(this.options.digitGroupSeparator)&&(this._wholeDigitGroupSeparatorTokens=be(this.options.digitGroupSeparator[0]),this._fractionalDigitGroupSeparatorTokens=be(this.options.digitGroupSeparator[1]))),this._exponentProductTokens=be(this.options.exponentProduct),this._beginExponentMarkerTokens=be(this.options.beginExponentMarker),this._endExponentMarkerTokens=be(this.options.endExponentMarker),this._truncationMarkerTokens=be(this.options.truncationMarker),this._imaginaryUnitTokens=be(this.options.imaginaryUnit),this._numberFormatTokens={decimalSeparatorTokens:this._decimalSeparatorTokens,wholeDigitGroupSeparatorTokens:this._wholeDigitGroupSeparatorTokens,fractionalDigitGroupSeparatorTokens:this._fractionalDigitGroupSeparatorTokens,exponentProductTokens:this._exponentProductTokens,beginExponentMarkerTokens:this._beginExponentMarkerTokens,endExponentMarkerTokens:this._endExponentMarkerTokens,truncationMarkerTokens:this._truncationMarkerTokens}}_numberFormatTokens;get peek(){let n=this._tokens[this.index];if(n===this._lastPeek?this._peekCounter+=1:this._peekCounter=0,this._peekCounter>=1024){let t=`Infinite loop detected while parsing "${this.latex(0)}" at "${this._lastPeek}" (index ${this.index})`;throw console.error(t),new Error(t)}return this._lastPeek=n,n}nextToken(){return this._tokens[this.index++]}get atEnd(){return this.index>=this._tokens.length}atTerminator(n){return this.atBoundary||((n?.condition&&n.condition(this))??!1)}get atBoundary(){if(this.atEnd)return!0;let n=this.index;for(let t=0;t<this._boundaries.length;t++){let i=this._boundaries[t];if(!(t<this._boundaryBarrier&&rb(i.tokens))&&!(i.minIndex!==void 0&&n<i.minIndex)&&this.matchBoundaryTokens(i.tokens))return this.index=n,!0}return!1}matchBoundaryTokens(n){return this.matchAll(n)?!0:n.length===2&&tt.has(n[0])&&this._tokens[this.index]===n[0]&&this._tokens[this.index+1]==="."?(this.index+=2,!0):!1}addBoundary(n,t){this._boundaries.push({index:this.index,tokens:n,minIndex:t})}removeBoundary(){this._boundaries.pop()}matchBoundary(){let n=this._boundaries[this._boundaries.length-1];if(n?.minIndex!==void 0&&this.index<n.minIndex)return!1;let t=n&&this.matchBoundaryTokens(n.tokens);return t&&this._boundaries.pop(),t}boundaryError(n){let t=this._boundaries[this._boundaries.length-1];return this._boundaries.pop(),this.error(n,t.index)}canSkipMatchfixReparsing(n,t,i){return i||t.length!==1?!1:(n==="("||n==="\\lparen")&&(t[0]==="]"||t[0]==="\\rbrack")||(n==="]"||n==="\\rbrack")&&(t[0]==="["||t[0]==="\\lbrack")}latex(n,t){return wt(this._tokens.slice(n,t))}sourceOffsets(n,t=this.index){let i=this.tokenPrefixOffsets(),r=this._tokens.length,s=i[Math.max(0,Math.min(n,r))],o=i[Math.max(0,Math.min(t,r))];return s<=o?[s,o]:[o,s]}tokenPrefixOffsets(){if(this._tokenPrefixOffsets!==null)return this._tokenPrefixOffsets;let n=this._tokens,t=new Array(n.length+1);t[0]=0;let i=0,r="";for(let s=0;s<n.length;s++){let o=id[n[s]]??n[s];/[a-zA-Z]/.test(o[0])&&(i+=r.length),r=/\\[a-zA-Z]+\*?$/.test(o)?" ":"",i+=o.length,t[s+1]=i}return this._tokenPrefixOffsets=t,t}lookAhead(){if(this._lookAheadIndex===this.index&&this._lookAheadCache!==null)return this._lookAheadCache;let n=this._dictionary.triggerStartMax.get(this._tokens[this.index])??0,t=Math.min(n,this._tokens.length-this.index),i=[],r="",s="";for(let o=0;o<t;o++){let a=this._tokens[this.index+o],u=id[a]??a;/[a-zA-Z]/.test(u[0])&&(r+=s),s=/\\[a-zA-Z]+\*?$/.test(u)?" ":"",r+=u,i[t-1-o]=[o+1,r]}return this._lookAheadCache=i,this._lookAheadIndex=this.index,i}peekDefinitions(n){if(this.atEnd)return[];let t=[],i=this._dictionary,r;switch(n){case"infix":r=i.infixByTrigger;break;case"prefix":r=i.prefixByTrigger;break;case"postfix":r=i.postfixByTrigger;break;case"function":r=i.functionByTrigger;break;case"symbol":r=i.symbolByTrigger;break;case"expression":r=i.expressionByTrigger;break;case"operator":r=i.operatorByTrigger;break}let s=i.universalDefs.get(n);if(s)for(let a of s)t.push([a,0]);for(let[a,u]of this.lookAhead()){let l=r.get(u);if(l)for(let c of l)t.push([c,a])}let o=i.symbolTriggerDefs.get(n);if(o){let a,u;if(this._symCandidateIndex===this.index&&this._symCandidateGen===this._symbolTableGen)a=this._symCandidate,u=this._symCandidateCount;else{let l=this.index;a=Ai(this)?.trim()??null,u=this.index-l,this.index=l,this._symCandidateIndex=l,this._symCandidateGen=this._symbolTableGen,this._symCandidate=a,this._symCandidateCount=u}if(a&&u>0){let l=o.get(a);if(l)for(let c of l)t.push([c,u])}}return t}skipSpaceTokens(){for(;this.match("<space>"););}skipSpace(){if(!this.atEnd&&this.peek==="<{>"){let t=this.index;for(this.nextToken();this.match("<space>"););if(this.nextToken()==="<}>")return this.skipSpace(),!0;this.index=t}if(!this.options.skipSpace)return!1;let n=!1;for(;this.match("<space>");)n=!0;return n&&this.skipSpace(),n}skipVisualSpace(){if(this.options.skipSpace){if(this.skipSpace(),nb.has(this.peek)&&(this.nextToken(),this.skipVisualSpace()),this.match("\\hspace")&&(this.match("*"),this.parseStringGroup(),this.skipVisualSpace()),this.match("\\hskip")||this.match("\\kern")){for(this.skipSpace(),this.match("-")||this.match("+");/^[\d.]$/.test(this.peek);)this.nextToken();for(let n of tb)if(this.matchAll(n))break;this.skipVisualSpace()}this.skipSpace()}}match(n){return this._tokens[this.index]!==n?!1:(this.index++,!0)}matchAll(n){if(n.length===0)return!1;let t,i=0;do t=this._tokens[this.index+i]===n[i++];while(t&&i<n.length);return t&&(this.index+=i),t}matchAny(n){return n.includes(this._tokens[this.index])?this._tokens[this.index++]:""}parseLatexNumber(n=!0){let t=!1,i=this.peek;for(;i==="<space>"||i==="+"||i==="-";)i==="-"&&(t=!t),this.nextToken(),i=this.peek;let r=10,s=["0","1","2","3","4","5","6","7","8","9"];if(this.match("'"))r=8,s=["0","1","2","3","4","5","6","7"],n=!0;else if(this.match('"')||this.match("x"))r=16,s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],n=!0;else if(this.match("`"))return i=this.nextToken(),i?i.startsWith("\\")&&i.length===2?(t?-1:1)*(i.codePointAt(1)??0):(t?-1:1)*(i.codePointAt(0)??0):null;let o="";for(;s.includes(this.peek);)o+=this.nextToken();if(!n&&this.match("."))for(o+=".";s.includes(this.peek);)o+=this.nextToken();let a=n?Number.parseInt(o,r):Number.parseFloat(o);return Number.isNaN(a)?null:t?-a:a}parseChar(){let n=this.index,t=0;for(;this.match("^");)t+=1;if(t<2&&(this.index=n),t>=2){let i="",r=0;for(;r!=t;){let s=this.matchAny(["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]);if(!s)break;i+=s,r+=1}if(i.length===t)return String.fromCodePoint(Number.parseInt(i,16))}else if(this.match("\\char")){let i=Math.floor(this.parseLatexNumber()??Number.NaN);return(!Number.isFinite(i)||i<0||i>1114111)&&(i=10067),String.fromCodePoint(i)}else if(this.match("\\unicode"))if(this.skipSpaceTokens(),this.match("<{>")){let i=this.parseLatexNumber();if(this.match("<}>")&&i!==null&&i>=0&&i<=1114111)return String.fromCodePoint(i)}else{let i=this.parseLatexNumber();if(i!==null&&i>=0&&i<=1114111)return String.fromCodePoint(i)}return this.index=n,null}matchDelimiter(n,t){let i=this.index,r=Le[this.peek];r&&this.nextToken();let s=r&&this.peek==="<{>";if(s&&this.nextToken(),Array.isArray(n)){if(Array.isArray(t),n.length===1){if(!(_e[n[0]]??[n[0]]).includes(this.peek))return this.index=i,!1;if(this.nextToken(),s&&!this.match("<}>"))return this.index=i,!1;let c=t[0],f=r?s?[r,"<{>",c,"<}>"]:[r,c]:[c];return this.addBoundary(f),!0}if(!this.matchAll(n))return this.index=i,!1;let u=r?[r,...t]:t;return this.addBoundary(u),!0}if(Array.isArray(t),n==="||"&&this.matchAll(["|","|"]))return this.addBoundary(["|","|"]),!0;if(!(_e[n]??[n]).includes(this.peek))return this.index=i,!1;if(n=this.nextToken(),s&&!this.match("<}>"))return this.index=i,!1;let o=au[n]??t,a=r?s?[r,"<{>",o,"<}>"]:[r,o]:[o];return this.addBoundary(a),!0}parseGroup(){let n=this.index;if(this.skipSpaceTokens(),this.match("<{>")){this.addBoundary(["<}>"]);let t=this._boundaryBarrier;this._boundaryBarrier=this._boundaries.length-1;try{let i=this.parseExpression();if(this.skipSpace(),this.matchBoundary())return i??"Nothing";for(;!this.matchBoundary()&&!this.atEnd;)this.nextToken();if(g(i)==="Error")return i;let r=this.error("expected-closing-delimiter",n);return i!==null?["InvisibleOperator",i,r]:r}finally{this._boundaryBarrier=t}}return this.index=n,null}parseOptionalGroup(){let n=this.index;if(this.skipSpaceTokens(),this.match("[")){this.addBoundary(["]"]);let t=this.parseExpression();return this.skipSpace(),this.matchBoundary()?t:this.boundaryError("expected-closing-delimiter")}return this.index=n,null}parseToken(){return this.skipSpace(),eb.has(this.peek)?null:/^[0-9]$/.test(this.peek)?parseInt(this.nextToken(),10):this.parseGenericExpression()??this.parseSymbol()}parseTabular(){let n=[],t=[],i=null;for(;!this.atBoundary;)if(this.skipSpace(),this.match("&"))t.push(i??"Nothing"),i=null;else if(this.match("\\\\")||this.match("\\cr"))this.skipSpace(),this.parseOptionalGroup(),i!==null&&t.push(i),n.push(t),t=[],i=null;else{let r=[],s=this.peek;for(;s!=="&"&&s!=="\\\\"&&s!=="\\cr"&&!this.atBoundary;)i=this.parseExpression({minPrec:0,condition:o=>{let a=o.peek;return a==="&"||a==="\\\\"||a==="\\cr"}}),i!==null?r.push(i):(r.push(["Error","'unexpected-token'",{str:wt(s)}]),this.nextToken()),this.skipSpace(),s=this.peek;r.length>1?i=["Sequence",...r]:i=r[0]??"Nothing"}return i!==null&&t.push(i),t.length>0&&n.push(t),n}parseStringGroupContent(){let n=this.index,t="",i=0;for(;!this.atEnd&&(!this.atBoundary||i>0);){let r=this.nextToken();if(r==="<$>"||r==="<$$>")return this.index=n,"";if(r==="<{>")i+=1,t+="\\{";else if(r==="<}>")i-=1,t+="\\}";else if(r==="<space>")t+=" ";else if(r[0]==="\\"){let s=ib().get(r);t+=s??r}else t+=r}return t}parseStringGroup(n,t){n===void 0&&(n=!1);let i=this.index;for(;this.match("<space>"););if(this.match(n?"[":"<{>")){let r=this.index;this.addBoundary([n?"]":"<}>"]);let s=this.parseStringGroupContent();if(this.matchBoundary())return t&&t.push(...this._tokens.slice(r,this.index-1)),s;this.removeBoundary()}return this.index=i,null}parseDoubleQuoteString(){if(this.peek!=='"')return null;let n=this.index;this.nextToken(),this.addBoundary(['"']);let t=this.parseStringGroupContent();return this.matchBoundary()?{str:t}:(this.removeBoundary(),this.error("expected-closing-delimiter",n))}parseEnvironment(n){let t=this.index;if(!this.match("\\begin"))return null;let i=[],r=this.parseStringGroup(!1,i)?.trim();if(!r)return this.error("expected-environment-name",t);for(;i[0]==="<space>";)i.shift();for(;i[i.length-1]==="<space>";)i.pop();this.addBoundary(["\\end","<{>",...i,"<}>"]);for(let s of this.getDefs("environment"))if(s.symbolTrigger===r){let o=s.parse(this,n);return this.skipSpace(),this.matchBoundary()?o!==null?this.decorate(o,t):(this.index=t,null):this.boundaryError("unbalanced-environment")}return this.parseTabular(),this.skipSpace(),this.matchBoundary()?this.error(["unknown-environment",{str:r}],t):this.boundaryError("unbalanced-environment")}parseRepeatingDecimal(){return su(this,this._numberFormatTokens)}parseNumber(){return td(this,this._numberFormatTokens)}parsePrefixOperator(n){n||(n={minPrec:0}),n.minPrec||(n={...n,minPrec:0});let t=this.index;for(let[i,r]of this.peekDefinitions("prefix")){this.index=t+r;let s=i.parse(this,{...n,minPrec:i.precedence+1});if(s!==null)return s}return this.index=t,null}parseInfixOperator(n,t){t??={minPrec:0},t.minPrec,t.minPrec===void 0&&(t={...t,minPrec:0});let i=this.index;for(let[r,s]of this.peekDefinitions("infix"))if(r.precedence>=t.minPrec){this.index=i+s;let o=r.parse(this,n,t);if(o!==null)return o}if(this.index=i,this.peek==="\\textcolor"){let r=this.parseStyledInfixOperator(n,t);if(r!==null)return r;this.index=i}return null}parseStyledInfixOperator(n,t){let i=this.index;if(!this.match("\\textcolor"))return null;if(this.parseStringGroup()===null)return this.index=i,null;if(this.skipSpace(),!this.match("<{>"))return this.index=i,null;this.skipSpace();let r=this.index;for(let[s,o]of this.peekDefinitions("infix")){if(s.precedence<t.minPrec)continue;if(this.index=r+o,this.skipSpace(),!this.match("<}>")){this.index=r;continue}let a=s.parse(this,n,t);if(a!==null)return a;this.index=r}return this.index=i,null}wouldMatchTextInfix(n){let t=this.index;for(let[i,r]of n){if(i.kind!=="infix")continue;if(this.index=t+r,i.parse(this,"Nothing",{minPrec:0})!==null)return this.index=t,!0}return this.index=t,!1}parseArguments(n="enclosure",t){if(this.atTerminator(t))return null;let i=this.index,r=this.parseEnclosure();if(n==="enclosure")return r===null?null:En(r)??[r];if(n==="implicit"){if(g(r)==="Delimiter"){let o=d(r,1);return g(o)==="Sequence"?b(o):o===null?[]:[o]}if(r!==null)return[r];let s=this.parseExpression({...t,minPrec:V});return s===null?null:[s]}return this.index=i,null}parseBraceArguments(){let n=this.index,t=[];for(;this.peek==="<{>";){let i=this.index,r=this.parseGroup();if(r===null||r==="Nothing"){this.index=i;break}t.push(...En(r)??[r])}return t.length===0?(this.index=n,null):t}parseEnclosure(){let n=this.index,t=this.peek,i=Le[t],r=i?this._tokens[this.index+1]:t;i&&r==="<{>"&&(r=this._tokens[this.index+2]);let s=this._dictionary.matchfixByOpen.get(r)??[];s.length===0&&!r&&(s=[...this.getDefs("matchfix")]);for(let o of s){this.index=n;let a=Array.isArray(o.openTrigger)&&o.openTrigger.length===1&&(o.openTrigger[0]==="]"||o.openTrigger[0]==="\\rbrack")&&Array.isArray(o.closeTrigger)&&o.closeTrigger.length===1&&(o.closeTrigger[0]==="["||o.closeTrigger[0]==="\\lbrack");if(a&&this._reversedIntervalDepth>0)continue;if(o.closeTokens.size>0){let N=!1,D=this._tokens;for(let R=n;R<D.length;R++){if(o.closeTokens.has(D[R])){N=!0;break}if(i&&tt.has(D[R])&&D[R+1]==="."){N=!0;break}}if(!N)continue}if(typeof o.openTrigger=="string"&&o.openTrigger==="."&&!Le[t]||!this.matchDelimiter(o.openTrigger,o.closeTrigger))continue;let l=this.index;this.skipSpace(),this.skipVisualSpace(),a&&(this._reversedIntervalDepth+=1);let c=this.parseExpression();a&&(this._reversedIntervalDepth-=1),this.skipSpace();let f=this._boundaries[this._boundaries.length-1]?.tokens,p=this.matchBoundary(),h=typeof o.openTrigger=="string"&&typeof o.closeTrigger=="string"&&o.openTrigger===o.closeTrigger||Array.isArray(o.openTrigger)&&Array.isArray(o.closeTrigger)&&o.openTrigger.length===o.closeTrigger.length&&o.openTrigger.every((N,D)=>N===o.closeTrigger[D]);if(p&&F(c)&&h&&f){this.index=l,this.skipSpace(),this.skipVisualSpace(),this.addBoundary(f,this.index+1);let N=this._boundaryBarrier;this._boundaryBarrier=this._boundaries.length-1,a&&(this._reversedIntervalDepth+=1);try{c=this.parseExpression()}finally{this._boundaryBarrier=N}if(a&&(this._reversedIntervalDepth-=1),this.skipSpace(),!this.matchBoundary()){if(this.removeBoundary(),this.index=n,!this.atEnd)continue;return null}}else if(!p){let N=this._boundaries[this._boundaries.length-1]?.tokens;if(!N){this.index=n;continue}if(this.canSkipMatchfixReparsing(r,N,h)){this.removeBoundary(),this.index=n;continue}else if(this.removeBoundary(),this.index=l,this.skipSpace(),a&&(this._reversedIntervalDepth+=1),c=this.parseExpression(),a&&(this._reversedIntervalDepth-=1),this.skipSpace(),!this.matchAll(N)){if(this.index=n,!this.atEnd)continue;return null}}let y=o.parse(this,c??"Nothing");if(y!==null)return y}return this.index=n,null}parseGenericExpression(n){if(this.atTerminator(n))return null;let t=this.index,i=null,r=this.peekDefinitions("expression")??[];for(let[s,o]of r)if(this.index=t+o,typeof s.parse=="function"){if(i=s.parse(this,n),i!==null)return i}else return s.name;return this.index=t,null}parseFunction(n){if(this.atTerminator(n))return null;let t=this.index,i=null,r="enclosure";for(let[a,u]of this.peekDefinitions("function"))if(this.index=t+u,typeof a.parse=="function"){if(i=a.parse(this,n),i!==null)return i}else{i=a.name,r=a.arguments??"enclosure";break}let s=!1;if(i===null&&(this.index=t,i=Ai(this),typeof i=="string"&&this.emitSymbolReference(i,t,this.index),!this.isFunctionOperator(i))){if(!this.looksLikePredicate(i))return this.index=t,null;s=!0}do{let a=this.parsePostfixOperator(i,n);if(a===null)break;i=a}while(!0);let o=this.parseArguments(r,n);return o===null?i:s&&typeof i=="string"&&this.inQuantifierScope?["Predicate",i,...o]:typeof i=="string"?[i,...o]:["Apply",i,...o]}parseSymbol(n){if(this.atTerminator(n))return null;let t=this.index;for(let[r,s]of this.peekDefinitions("symbol")){this.index=t+s;let o=typeof r.parse=="function"?r.parse(this,n):r.name;if(o!==null){if(typeof o=="string"&&this.peek==="_"){let a=this.resolveSymbol(o);if(!a?.subscriptEvaluate){let u=Ct(this,o,a?.type.matches("indexed_collection<any>")??!1);return u!==o&&!this.resolveSymbol(u)?.type.matches("error")&&this.emitSymbolReference(u,t,this.index),u}}return o}}this.index=t;let i=Ai(this);return i!==null&&!this.resolveSymbol(i)?.type.matches("error")?(this.emitSymbolReference(i,t,this.index),i):(this.index=t,null)}peekBareWord(){let n=this.index;for(;this._tokens[n]==="<space>";)n++;let t="";for(;n<this._tokens.length&&/^[a-zA-Z]$/.test(this._tokens[n]);)t+=this._tokens[n],n++;return t}tryParseBareFunction(n){if(this.options.strict!==!1)return null;let t=this.index;if(t>0&&/^[a-zA-Z]$/.test(this._tokens[t-1]))return null;let i="";for(;!this.atEnd&&/^[a-zA-Z]$/.test(this.peek);)i+=this.peek,this.index++;if(!i)return this.index=t,null;if(!this.atEnd&&/^[0-9]$/.test(this.peek)){let l="",c=this.index;for(;c<this._tokens.length&&/^[0-9]$/.test(this._tokens[c]);)l+=this._tokens[c],c++;for(let f=l.length;f>=1;f--)if(Qs[i+l.slice(0,f)]!==void 0){i+=l.slice(0,f),this.index+=f;break}}this.skipSpace();let r=null;if(this.peek==="_"){if(this.index++,r=this.parseGroup(),r===null){if(!this.atEnd&&/^[a-zA-Z]$/.test(this.peek))r=this.peek,this.index++;else{let l="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)l+=this.peek,this.index++;l&&(r=parseInt(l))}if(r===null)return this.index=t,null}this.skipSpace()}if(r===null&&i==="log"&&!this.atEnd&&/^[0-9]$/.test(this.peek)){let l="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)l+=this.peek,this.index++;r=parseInt(l),this.skipSpace()}let s=null;if(this.peek==="^"){if(this.index++,s=this.parseGroup(),s===null){let l=!1;this.peek==="-"&&(l=!0,this.index++);let c="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)c+=this.peek,this.index++;if(c){let f=parseInt(c);s=l?-f:f}else return this.index=t,null}this.skipSpace()}let o=Qs[i];if(!o)return this.index=t,null;let a;if(this.peek==="("?a=this.parseArguments("enclosure",n):a=this.parseArguments("implicit",{...n,minPrec:V,condition:l=>{let c=this.peekBareWord();return c.length>0&&Qs[c]!==void 0||(n?.condition?.(l)??!1)}}),a===null)return this.index=t,null;if(i==="cbrt"){let l=["Root",a[0]??"Nothing",3];return s!==null?["Power",l,s]:l}if(i==="nPr"){let l=["Multiply",["Binomial",a[0]??"Nothing",a[1]??"Nothing"],["Factorial",a[1]??"Nothing"]];return s!==null?["Power",l,s]:l}let u;if(i==="log"&&r!==null?r===2?u=["Lb",...a]:r===10?u=["Log",...a]:u=["Log",a[0],r]:u=[o,...a],s===-1&&Array.isArray(u)){let[l,...c]=u;return["Apply",["InverseFunction",l],...c]}return s!==null?["Power",u,s]:u}static BARE_SYMBOL_MAP={alpha:"alpha",beta:"beta",gamma:"gamma",delta:"delta",epsilon:"epsilon",varepsilon:"varepsilon",zeta:"zeta",eta:"eta",theta:"theta",vartheta:"vartheta",iota:"iota",kappa:"kappa",lambda:"lambda",mu:"mu",nu:"nu",xi:"xi",omicron:"omicron",pi:"Pi",rho:"rho",sigma:"sigma",tau:"tau",upsilon:"upsilon",phi:"phi",varphi:"varphi",chi:"chi",psi:"psi",omega:"omega",Gamma:"Gamma",Delta:"Delta",Theta:"Theta",Lambda:"Lambda",Xi:"Xi",Sigma:"Sigma",Upsilon:"Upsilon",Phi:"Phi",Psi:"Psi",Omega:"Omega",oo:"PositiveInfinity",inf:"PositiveInfinity",ii:"ImaginaryUnit"};tryParseBareSymbol(){if(this.options.strict!==!1)return null;let n=this.index;if(n>0&&/^[a-zA-Z]$/.test(this._tokens[n-1]))return null;let t="";for(;!this.atEnd&&/^[a-zA-Z]$/.test(this.peek);)t+=this.peek,this.index++;if(!t)return this.index=n,null;let i=e.BARE_SYMBOL_MAP[t];return i?(this.emitSymbolReference(i,n,this.index),i):(this.index=n,null)}static SEGMENTABLE_SYMBOLS=Object.fromEntries(Object.entries(e.BARE_SYMBOL_MAP).filter(([n])=>!["oo","inf","ii"].includes(n)));static MAX_SEGMENTABLE_LENGTH=Math.max(...Object.keys(e.SEGMENTABLE_SYMBOLS).map(n=>n.length));static SEGMENTABLE_SYMBOL_VALUES=new Set(Object.values(e.SEGMENTABLE_SYMBOLS));tryParseBareRun(){if(this.options.strict!==!1)return null;let n=this.index;if(n>0&&/^[a-zA-Z]$/.test(this._tokens[n-1]))return null;let t="";for(;!this.atEnd&&/^[a-zA-Z]$/.test(this.peek);)t+=this.peek,this.index++;if(t.length<2)return this.index=n,null;if(Qs[t]!==void 0)return this.emitSymbolReference(t,n,this.index),t;let i=e.SEGMENTABLE_SYMBOLS,r=[],s=!1,o=0;for(;o<t.length;){let a=!1,u=Math.min(t.length-o,e.MAX_SEGMENTABLE_LENGTH);for(let l=u;l>=2;l--){let c=t.slice(o,o+l);if(i[c]!==void 0){r.push(i[c]),o+=l,a=!0,s=!0;break}}a||(this.emitSymbolReference(t[o],n+o,n+o+1),r.push(t[o]),o+=1)}return s?r.length===1?r[0]:["Multiply",...r]:(this.index=n,null)}parseSupsub(n){if(this.atEnd)return n;let t=this.index;if(this.options.strict===!1&&typeof n=="string"&&(n.length===1&&/^[a-zA-Z]$/.test(n)||e.SEGMENTABLE_SYMBOL_VALUES.has(n))&&/^[0-9]$/.test(this.peek)){let u="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)u+=this.peek,this.index++;return this.parseSupsub(["Subscript",n,parseInt(u)])}this.skipSpace();let i=[],r=[],s=t;for(;this.peek==="_"||this.peek==="^";){if(this.match("_"))if(s=this.index,this.match("_")||this.match("^"))r.push(this.error("syntax-error",s));else{let u=this.parseGroup();if(u===null&&this.options.strict===!1){let l="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)l+=this.peek,this.index++;l&&(u=parseInt(l))}if(u??=this.parseToken(),u===null&&this.options.strict===!1&&this.peek==="("&&(u=this.parseEnclosure()),u??=this.parseStringGroup(),u===null)return this.error("missing",t);r.push(u)}else if(this.match("^"))if(s=this.index,this.match("_")||this.match("^"))i.push(this.error("syntax-error",s));else{let u=this.parseGroup();if(u===null&&this.options.strict===!1){let l=this.index,c=!1;this.peek==="-"&&(c=!0,this.index++);let f="";for(;!this.atEnd&&/^[0-9]$/.test(this.peek);)f+=this.peek,this.index++;if(f){let p=parseInt(f);u=c?-p:p}else this.index=l}if(u??=this.parseToken(),u===null&&this.options.strict===!1&&this.peek==="("&&(u=this.parseEnclosure()),u===null)return this.error("missing",t);i.push(u)}s=this.index,this.skipSpace()}if(i.length===0&&r.length===0)return this.index=t,n;let o=n,a=r.filter(u=>!F(u));if(a.length>0){let u=this._dictionary.infixByTrigger.get("_")??[];if(u){let l=["Subscript",o,a.length===1?a[0]:["List",...a]];for(let c of u)if(typeof c.parse=="function"?o=c.parse(this,l,{minPrec:0}):o=l,o!==null)break}}if(i.length>0){let u=this._dictionary.infixByTrigger.get("^")??[];if(u){let l=i.filter(c=>{if(F(c))return!1;let f=_(c);return!(f!==null&&/^(?:st|nd|rd|th)$/i.test(f))});if(l.length>1)return this.error("unexpected-superscript",t);if(l.length!==0){let c=l[0],f=["Superscript",o,c];for(let p of u)if(typeof p.parse=="function"?o=p.parse(this,f,{minPrec:0}):o=f,o!==null)break}}}return o===null&&(this.index=t),o}parsePostfixOperator(n,t){if(n===null||this.atEnd)return null;let i=this.index;if(this.skipVisualSpace(),this.index!==i){let s=this._tokens[this.index];s==="\\{"||s==="\\left"&&this._tokens[this.index+1]==="\\{"||(this.index=i)}let r=this.index;for(let[s,o]of this.peekDefinitions("postfix")){this.index=r+o;let a=s.parse(this,n,t);if(a!==null)return a}return this.index=i,null}parseSyntaxError(){let n=this.index;if(this.peek==="^")return this.index+=1,["Superscript",this.error("missing",n),O(this.parseGroup())];let t=this.peekDefinitions("operator");if(t.length>0){if(t=this.peekDefinitions("postfix"),t.length>0){let[a,u]=t[0];if(this.index+=u,typeof a.parse=="function"){let c=a.parse(this,this.error("missing",n));if(c!==null)return c}let l=this.index;if(this.index=n,this.peekDefinitions("prefix").length===0&&this.peekDefinitions("infix").length===0)return this.index=l,this.error("unexpected-operator",n)}if(t=this.peekDefinitions("prefix"),t.length>0){let[a,u]=t[0];if(this.index+=u,typeof a.parse=="function"){let l=a.parse(this,{minPrec:0});if(l!==null)return l}return a.name?[a.name,this.parseExpression()??this.error("missing",n)]:this.error("unexpected-operator",n)}if(t=this.peekDefinitions("infix"),t.length>0){let[a,u]=t[0];this.index+=u;let l=a.parse(this,this.error("missing",n),{minPrec:0});return l!==null?l:this.error("unexpected-operator",n)}}let i=this.index,r=Ja(this);if(r!==null)return r;if(r=Ai(this),r!==null)return this.error(["unexpected-symbol",{str:r}],i);let s=this.peek;if(!s)return this.error("syntax-error",n);if(ob(this))return this.error("unexpected-delimiter",n);if(s[0]!=="\\")return this.nextToken(),this.error(["unexpected-token",{str:wt(s)}],n);let o=this.nextToken();if(this.skipSpaceTokens(),o==="\\end"){let a=this.parseStringGroup();return a===null?this.error("expected-environment-name",n):this.error(["unbalanced-environment",{str:a}],n)}for(;this.match("[");){let a=0;for(;!this.atEnd&&a===0&&this.peek!=="]";)this.peek==="["&&(a+=1),this.peek==="]"&&(a-=1),this.nextToken();this.match("]")}for(;this.match("<{>");){let a=0;for(;!this.atEnd&&a===0&&this.peek!=="<}>";)this.peek==="<{>"&&(a+=1),this.peek==="<}>"&&(a-=1),this.nextToken();this.match("<}>")}return this.error(["unexpected-command",{str:wt(o)}],n)}parsePrimary(n){if(this.atBoundary||this.atTerminator(n))return null;let t=null,i=this.index;if(this.match("<}>"))return this.error("unexpected-closing-delimiter",i);if(t??=this.parseGroup(),t??=this.parseNumber(),t??=this.parseDoubleQuoteString(),t??=this.parseEnclosure(),t??=this.parseEnvironment(n),t===null&&this.matchAll(this._positiveInfinityTokens)&&(t="PositiveInfinity"),t===null&&this.matchAll(this._negativeInfinityTokens)&&(t="NegativeInfinity"),t===null&&this.matchAll(this._notANumberTokens)&&(t="NaN"),t===null&&this.matchAll(this._imaginaryUnitTokens)&&(t="ImaginaryUnit"),t??=this.tryParseBareFunction(n),t??=this.tryParseBareSymbol(),t??=this.tryParseBareRun(),t??=this.parseGenericExpression(n)??this.parseFunction(n)??this.parseSymbol(n)??Ja(this),t!==null&&F(t))return this.parsePrimary(n);if(t!==null){t=this.decorate(t,i);let r=null,s=this.index;do{if(r=this.parsePostfixOperator(t,n),t=r??t,this.index===s&&r!==null){this.index;break}s=this.index}while(r!==null)}if(t!==null&&(t=this.parseSupsub(t)),t!==null&&(t=Xy(t)),t!==null&&(t=Qy(t)),t!==null){let r=null,s=this.index;do{if(r=this.parsePostfixOperator(t,n),t=r??t,this.index===s&&r!==null){this.index;break}s=this.index}while(r!==null)}if(t===null&&(t=this.options.parseUnexpectedToken?.(null,this)??null,t===null&&this.peek.startsWith("\\")&&!od.has(this.peek))){if(this.peek==="\\"){let r=this.index;if(this.nextToken(),this.skipVisualSpace(),this.atEnd)return this.emitDiagnostic("recovered",r,this.index,{skipped:this.latex(r,this.index)}),this.decorate(null,i);this.index=r}this.nextToken(),t=this.error("unexpected-command",i)}return this.decorate(t,i)}parseExpression(n){this.skipSpace();let t=this.index;if(this.atBoundary)return this.index=t,null;let i=this._diagnosticsCheckpoint();n??={minPrec:0},n.minPrec,n.minPrec===void 0&&(n={...n,minPrec:0});let r=this._ownedChain;this._ownedChain=null;let s=this.parsePrefixOperator({...n,minPrec:0});if(s??=this.parsePrimary(n),s!==null){let o=!1;for(;!o&&!this.atTerminator(n);){this.skipSpace(),this._operandDiagnosticCheckpoint=i,this._operandStartIndex=t;let a=this.parseInfixOperator(s,n);if(a===null&&n.minPrec<=Ea){let u=this.peekDefinitions("operator");if((u.length===0||u.every(([l])=>l.latexTrigger==="\\text"||l.latexTrigger==="\\keyword"))&&!(u.length>0&&this.wouldMatchTextInfix(u))){let l=this.index,c=this.parseExpression({...n,minPrec:Ea+1});c!==null?(this.emitJuxtapositionDiagnostic(s,c,t,l),g(s)==="InvisibleOperator"?g(c)==="InvisibleOperator"?a=["InvisibleOperator",...b(s),...b(c)]:a=["InvisibleOperator",...b(s),c]:g(c)==="InvisibleOperator"?a=["InvisibleOperator",s,...b(c)]:a=["InvisibleOperator",s,c]):a===null&&(a=this.options.parseUnexpectedToken?.(s,this)??null)}}a!==null?s=a:o=!0}}return this._ownedChain=r,this.decorate(s,t)}decorate(n,t){if(n===null)return null;if(!this.options.preserveLatex)return n;let i=this.latex(t,this.index);return Array.isArray(n)?n={latex:i,fn:n}:typeof n=="number"?n={latex:i,num:Number(n).toString()}:typeof n=="string"?n.startsWith("'")?n={latex:i,str:n.slice(1,-1)}:n={latex:i,sym:n}:typeof n=="object"&&n!==null&&(n.latex=i),n}error(n,t){let i;typeof n=="string"?(n.startsWith("'"),i={str:n}):(n[0].startsWith("'"),i=["ErrorCode",{str:n[0]},...n.slice(1)]);let r=this.latex(t,this.index),s=r?["Error",i,["LatexString",{str:r}]]:["Error",i],a=typeof n=="string"&&n==="missing"?this.sourceOffsets(t,t):this.sourceOffsets(t,this.index);return{fn:s,sourceOffsets:a}}emitJuxtapositionDiagnostic(n,t,i,r){if(this.diagnostics===null)return;let s=g(t);if(s!=="Delimiter"&&s!=="Matrix")return;let o=null,a=i,u,l=E(n);if(l!==null)o=l;else if(g(n)==="__unit__")o=E(d(n,1)),o!==null&&(u="unit");else if(g(n)==="InvisibleOperator"){let p=this.trailingLetterRun(r);if(p===null)return;o=p.name,a=p.startToken}if(o===null)return;let c=this.resolveSymbol(o),f=c===void 0?"unknown":c.type.matches("function")?"function":"value";this.emitDiagnostic("juxtaposition-as-multiply",a,this.index,u!==void 0?{name:o,declaredAs:f,lexedAs:u}:{name:o,declaredAs:f})}trailingLetterRun(n){let t=n;for(;t>0&&this._tokens[t-1]==="<space>";)t--;let i="";for(;t>0&&/^[a-zA-Z]$/.test(this._tokens[t-1]);)i=this._tokens[t-1]+i,t--;return i.length===0?null:{name:i,startToken:t}}isFunctionOperator(n){return n===null||n==="D"||n==="N"?!1:!!this.resolveSymbol(n)?.type.matches("function")}looksLikePredicate(n){if(n===null||typeof n!="string"||!/^[A-Z]$/.test(n))return!1;let t=this.resolveSymbol(n)?.type;return t!==void 0&&!t.isUnknown&&!t.matches("function")?!1:(this.skipSpace(),this.peek==="("||this.peek==="\\left")}*getDefs(n){if(n==="operator")for(let t=this._dictionary.defs.length-1;t>=0;t--){let i=this._dictionary.defs[t];/^prefix|infix|postfix/.test(i.kind)&&(yield i)}else for(let t=this._dictionary.defs.length-1;t>=0;t--){let i=this._dictionary.defs[t];i.kind===n&&(yield i)}}};function ob(e){let n=e.peek;return Object.values(au).includes(n)||au[n]?(e.nextToken(),!0):Le[n]||Object.values(Le).includes(n)?(e.nextToken(),e.nextToken(),!0):!1}function sn(e,n,t){if(F(e))return null;let i,r=g(e);if(r==="Delimiter"){let l=_(d(e,2));if(l!==","&&l!=="(,)"&&l!=="[,]")return null;let c=d(e,1);g(c)==="Sequence"?i=[...b(c)]:i=c?[c]:[]}else if(r==="Sequence")i=[...b(e)];else return null;if(i.length!==2)return null;let[s,o]=i;return["Interval",n?["Open",s]:s,t?["Open",o]:o]}function cu(e){if(e===null)return null;if(g(e)==="List"&&P(e)===2)return["Interval",d(e,1),d(e,2)];if(g(e)==="Delimiter"){let n=_(d(e,2))??"(,)";if(n!==","&&n!=="(,)"&&n!=="()")return e;let t=d(e,1);if(g(t)==="Sequence"&&P(t)===2)return["Interval",["Open",d(t,1)],["Open",d(t,2)]]}return e}var ab=["<{>",...Object.keys(Le)],ub=["[","\\lbrack","(","\\lparen"];function fu(e,n){let t=e.index;for(n!==void 0&&(e.index=n),e.skipVisualSpace();ab.includes(e.peek);)e.nextToken(),e.skipVisualSpace();let i=ub.includes(e.peek);return e.index=t,i}function lu(e,n){return fu(e,e.operandStartIndex)?cu(n):n}function ld(e){let n=d(e,1),t=d(e,2),i=!1,r=!1;return g(n)==="Open"&&(n=d(n,1),i=!0),g(t)==="Open"&&(t=d(t,1),r=!0),{lower:n,upper:t,openLower:i,openUpper:r}}function cd(e,n){let{lower:t,upper:i,openLower:r,openUpper:s}=ld(n);return v([r?"\\lparen":"\\lbrack",e.serialize(t),", ",e.serialize(i),s?"\\rparen":"\\rbrack"])}function lb(e,n){let{lower:t,upper:i,openLower:r,openUpper:s}=ld(n);return r&&s?v(["\\rbrack",e.serialize(t),", ",e.serialize(i),"\\lbrack"]):!r&&!s?v(["\\mathrm{Interval}(",e.serialize(t),", ",e.serialize(i),")"]):cd(e,n)}function cb(e,n,t){if(n!==null&&g(n)==="Interval")return cd(e,n);let i=du(e,n);return i!==null?i:e.wrap(n,t)}function du(e,n){if(n===null||P(n)!==2)return null;let t=g(n);return t!=="List"&&t!=="Tuple"&&t!=="Pair"?null:v([`\\operatorname{${t==="List"?"List":"Tuple"}}(`,e.serialize(d(n,1)),", ",e.serialize(d(n,2)),")"])}function on(e,n,t){return(i,r)=>{let s=P(r);return s===0?"":s===1?i.serializeFunction(r):v([...b(r)].flatMap((o,a)=>{let u=t==="both"||a>0?cb(i,o,n+1):i.wrap(o,n+1);return a<s-1?[u,e]:[u]}))}}function ae(e,n,t){return(i,r,s)=>{if(r===null)return null;let o=t==="rhs"||g(r)===e?r:lu(i,r),a=fu(i),u=O(i.parseExpression({...s,minPrec:t==="chain"?n+1:n})),l=a?cu(u):u;return t==="chain"?i._appendAssociativeOperand(e,o,l):[e,o,l]}}var uu=new Set(["Less","LessEqual","Greater","GreaterEqual","Equal","NotEqual","And","Or","Not"]);function ad(e){if(e==null)return!1;let n=E(e);return n!==null&&Cs.has(n)}function fd(e,n,t){let i=E(n);if(i===null||!Cs.has(i)||e.resolveSymbol(i)?.type.matches("set<any>")!==!0)return null;let r=g(t);return(r==="InvisibleOperator"||r==="Multiply")&&P(t)===2&&E(d(t,2))===i?["QuotientRing",n,d(t,1)]:null}var dd=[{name:"AlgebraicNumbers",latexTrigger:"\\overline\\Q"},{latexTrigger:"\\bar\\Q",parse:"AlgebraicNumbers"},{name:"ComplexNumbers",standaloneSymbol:!0,latexTrigger:["\\C"]},{latexTrigger:"\\mathbb{C}",parse:"ComplexNumbers"},{name:"UpperHalfPlane",standaloneSymbol:!0,latexTrigger:"\\mathbb{C}^+"},{latexTrigger:"\\mathbb{C}^{+}",parse:"UpperHalfPlane"},{latexTrigger:"\\C^+",parse:"UpperHalfPlane"},{latexTrigger:"\\C^{+}",parse:"UpperHalfPlane"},{name:"ImaginaryNumbers",latexTrigger:["\\imaginaryI","\\R"]},{name:"EmptySet",standaloneSymbol:!0,latexTrigger:["\\emptyset"]},{latexTrigger:["\\varnothing"],parse:"EmptySet"},{name:"Integers",standaloneSymbol:!0,latexTrigger:["\\Z"]},{latexTrigger:"\\mathbb{Z}",parse:"Integers"},{name:"Primes",standaloneSymbol:!0,latexTrigger:["\\mathbb{P}"]},{name:"RationalNumbers",standaloneSymbol:!0,latexTrigger:["\\Q"]},{latexTrigger:"\\mathbb{Q}",parse:"RationalNumbers"},{name:"RealNumbers",standaloneSymbol:!0,latexTrigger:["\\R"]},{latexTrigger:"\\mathbb{R}",parse:"RealNumbers"},{name:"TranscendentalNumbers",standaloneSymbol:!0,latexTrigger:"\\R-\\bar\\Q"},{latexTrigger:"\\R\\backslash\\bar\\Q",parse:"TranscendentalNumbers"},{name:"NegativeNumbers",standaloneSymbol:!0,latexTrigger:"\\R_{<0}"},{latexTrigger:"\\R^-",parse:"NegativeNumbers"},{latexTrigger:"\\R^{-}",parse:"NegativeNumbers"},{latexTrigger:"\\R^-",parse:"NegativeNumbers"},{latexTrigger:"\\R_-",parse:"NegativeNumbers"},{latexTrigger:"\\R_{-}",parse:"NegativeNumbers"},{latexTrigger:"\\R_{\\lt0}",parse:"NegativeNumbers"},{latexTrigger:"\\R^{\\lt}",parse:"NegativeNumbers"},{latexTrigger:"\\R^{<}",parse:"NegativeNumbers"},{latexTrigger:"\\R^{\\lt0}",parse:"NegativeNumbers"},{latexTrigger:"\\R^{<0}",parse:"NegativeNumbers"},{name:"NonPositiveNumbers",standaloneSymbol:!0,latexTrigger:"\\R_{\\le0}"},{latexTrigger:"\\R_{\\leq0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R_{\\leqslant0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\leq0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\le0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\leqslant0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{-0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\leq}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\le}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{\\leqslant}",parse:"NonPositiveNumbers"},{latexTrigger:"\\R^{0-}",parse:"NonPositiveNumbers"},{name:"PositiveNumbers",standaloneSymbol:!0,latexTrigger:"\\R_{>0}"},{latexTrigger:"\\R^+",parse:"PositiveNumbers"},{latexTrigger:"\\R^{+}",parse:"PositiveNumbers"},{latexTrigger:"\\R_+",parse:"PositiveNumbers"},{latexTrigger:"\\R_{+}",parse:"PositiveNumbers"},{latexTrigger:"\\R_{\\gt0}",parse:"PositiveNumbers"},{latexTrigger:"\\R^{\\gt}",parse:"PositiveNumbers"},{latexTrigger:"\\R^{\\gt 0}",parse:"PositiveNumbers"},{latexTrigger:"\\R^{>}",parse:"PositiveNumbers"},{latexTrigger:"\\R^{>0}",parse:"PositiveNumbers"},{name:"NonNegativeNumbers",standaloneSymbol:!0,latexTrigger:"\\R_{\\geq0}"},{latexTrigger:"\\R_{\\ge0}",parse:"NonNegativeNumbers"},{latexTrigger:"\\R_{\\geqslant0}",parse:"NonNegativeNumbers"},{latexTrigger:"\\R^{0+}",parse:"NonNegativeNumbers"},{latexTrigger:"\\R^{\\geq}",parse:"NonNegativeNumbers"},{latexTrigger:"\\R^{\\ge}",parse:"NonNegativeNumbers"},{latexTrigger:"\\R^{\\geqslant}",parse:"NonNegativeNumbers"},{name:"ExtendedRealNumbers",standaloneSymbol:!0,latexTrigger:"\\overline\\R"},{latexTrigger:"\\bar\\R",parse:"ExtendedRealNumbers"},{name:"NegativeIntegers",standaloneSymbol:!0,latexTrigger:"\\Z_{<0}"},{latexTrigger:"\\Z_{\\lt0}",parse:"NegativeIntegers"},{latexTrigger:"\\Z^-",parse:"NegativeIntegers"},{latexTrigger:"\\Z^{-}",parse:"NegativeIntegers"},{latexTrigger:"\\Z_-",parse:"NegativeIntegers"},{latexTrigger:"\\Z_{-}",parse:"NegativeIntegers"},{latexTrigger:"\\Z^{\\lt}",parse:"NegativeIntegers"},{latexTrigger:"\\Z^{<}",parse:"NegativeIntegers"},{latexTrigger:"\\Z^{\\lt0}",parse:"NegativeIntegers"},{latexTrigger:"\\Z^{<0}",parse:"NegativeIntegers"},{name:"NonPositiveIntegers",standaloneSymbol:!0,latexTrigger:"\\Z_{\\le0}"},{latexTrigger:"\\Z_{\\leq0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z_{\\leqslant0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{-0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\leq}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\le}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\leqslant}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\leq0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\le0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{\\leqslant0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\Z^{0-}",parse:"NonPositiveIntegers"},{name:"PositiveIntegers",standaloneSymbol:!0,latexTrigger:"\\N^*"},{latexTrigger:"\\Z_{>0}",parse:"PositiveIntegers"},{latexTrigger:"\\Z_{\\gt0}",parse:"PositiveIntegers"},{latexTrigger:"\\Z^{+}",parse:"PositiveIntegers"},{latexTrigger:"\\Z_+",parse:"PositiveIntegers"},{latexTrigger:"\\Z_{+}",parse:"PositiveIntegers"},{latexTrigger:"\\Z^{\\gt}",parse:"PositiveIntegers"},{latexTrigger:"\\Z^{\\gt0}",parse:"PositiveIntegers"},{latexTrigger:"\\N^+",parse:"PositiveIntegers"},{latexTrigger:"\\N^{+}",parse:"PositiveIntegers"},{latexTrigger:"\\N^*",parse:"PositiveIntegers"},{latexTrigger:"\\N^{*}",parse:"PositiveIntegers"},{latexTrigger:"\\N^\\star",parse:"PositiveIntegers"},{latexTrigger:"\\N^{\\star}",parse:"PositiveIntegers"},{latexTrigger:"\\N_1",parse:"PositiveIntegers"},{latexTrigger:"\\N_{1}",parse:"PositiveIntegers"},{latexTrigger:"\\N_{>0}",parse:"PositiveIntegers"},{latexTrigger:"\\N_{\\gt0}",parse:"PositiveIntegers"},{latexTrigger:"\\N_{\\geq1}",parse:"PositiveIntegers"},{latexTrigger:"\\N_{\\ge1}",parse:"PositiveIntegers"},{latexTrigger:"\\N_{\\geqslant1}",parse:"PositiveIntegers"},{name:"NonNegativeIntegers",standaloneSymbol:!0,latexTrigger:["\\N"]},{latexTrigger:"\\Z^{+0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\geq}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\ge}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\geqslant}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\geq0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\ge0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{\\geqslant0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z_{\\geq0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z_{\\ge0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z_{\\geqslant0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\Z^{0+}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}",parse:"NonNegativeIntegers"},{latexTrigger:"\\N_0",parse:"NonNegativeIntegers"},{latexTrigger:"\\N_{0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\N_{\\geq0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\N_{\\ge0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\N_{\\geqslant0}",parse:"NonNegativeIntegers"},{name:"ExtendedIntegers",standaloneSymbol:!0,latexTrigger:"\\overline\\Z"},{latexTrigger:"\\bar\\Z",parse:"ExtendedIntegers"},{name:"ExtendedRationalNumbers",standaloneSymbol:!0,latexTrigger:"\\overline\\Q"},{latexTrigger:"\\bar\\Q",parse:"ExtendedRationalNumbers"},{name:"ExtendedComplexNumbers",standaloneSymbol:!0,latexTrigger:"\\overline\\C"},{latexTrigger:"\\bar\\C",parse:"ExtendedComplexNumbers"},{latexTrigger:"\\mathbb{R}_{>0}",parse:"PositiveNumbers"},{latexTrigger:"\\mathbb{R}_{\\gt0}",parse:"PositiveNumbers"},{latexTrigger:"\\mathbb{R}_+",parse:"PositiveNumbers"},{latexTrigger:"\\mathbb{R}_{+}",parse:"PositiveNumbers"},{latexTrigger:"\\mathbb{R}_{\\geq0}",parse:"NonNegativeNumbers"},{latexTrigger:"\\mathbb{R}_{\\ge0}",parse:"NonNegativeNumbers"},{latexTrigger:"\\mathbb{R}_{\\geqslant0}",parse:"NonNegativeNumbers"},{latexTrigger:"\\mathbb{R}_{<0}",parse:"NegativeNumbers"},{latexTrigger:"\\mathbb{R}_{\\lt0}",parse:"NegativeNumbers"},{latexTrigger:"\\mathbb{R}_-",parse:"NegativeNumbers"},{latexTrigger:"\\mathbb{R}_{-}",parse:"NegativeNumbers"},{latexTrigger:"\\mathbb{R}_{\\leq0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\mathbb{R}_{\\le0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\mathbb{R}_{\\leqslant0}",parse:"NonPositiveNumbers"},{latexTrigger:"\\mathbb{Z}_{>0}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}_{\\gt0}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}_+",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}_{+}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}^+",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}^{+}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{Z}_{\\geq0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{\\ge0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{\\geqslant0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{<0}",parse:"NegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{\\lt0}",parse:"NegativeIntegers"},{latexTrigger:"\\mathbb{Z}_-",parse:"NegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{-}",parse:"NegativeIntegers"},{latexTrigger:"\\mathbb{Z}_{\\leq0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\mathbb{Z}_{\\le0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\mathbb{Z}_{\\leqslant0}",parse:"NonPositiveIntegers"},{latexTrigger:"\\mathbb{N}_{>0}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{\\gt0}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}^+",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}^{+}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}^*",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}^{*}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_0",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}_{0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}_{\\geq0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}_{\\ge0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}_{\\geqslant0}",parse:"NonNegativeIntegers"},{latexTrigger:"\\mathbb{N}_1",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{1}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{\\geq1}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{\\ge1}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{\\geqslant1}",parse:"PositiveIntegers"},{latexTrigger:"\\mathbb{N}_{>1}",parse:()=>["Set",["Element","n","NonNegativeIntegers"],["Condition",["Greater","n",1]]]},{latexTrigger:"\\N_{>1}",parse:()=>["Set",["Element","n","NonNegativeIntegers"],["Condition",["Greater","n",1]]]},{name:"Adjoin",serialize:(e,n)=>{let t=b(n);if(!ad(t[0]))return e.serializeFunction(n);let i=e.wrap(t[0]??"Nothing",tn),r=t.slice(1).map(s=>e.serialize(s));return v([i,"[",r.join(", "),"]"])}},{name:"QuotientRing",serialize:(e,n)=>{if(!ad(d(n,1)))return e.serializeFunction(n);let t=e.wrap(d(n,1)??"Nothing",tn);return v([t,"_{",e.serialize(d(n,2)),"}"])}},{kind:"postfix",precedence:W,latexTrigger:["/"],parse:(e,n)=>{let t=E(n);if(t===null||!Cs.has(t)||e.resolveSymbol(t)?.type.matches("set<any>")!==!0)return null;let i=e.index,r=e.parseExpression({minPrec:W});return r!==null&&g(r)==="InvisibleOperator"&&P(r)===2&&E(d(r,2))===t?["QuotientRing",n,d(r,1)]:(e.index=i,null)}},{latexTrigger:["^","\\complement"],kind:"postfix",parse:(e,n)=>["Complement",n]},{name:"Complement",latexTrigger:["^","<{>","\\complement","<}>"],kind:"postfix",serialize:(e,n)=>v([e.serialize(d(n,1)),"^\\complement"])},{name:"Intersection",latexTrigger:["\\cap"],kind:"infix",precedence:350,parse:ae("Intersection",350,"both"),serialize:on("\\cap",350,"both")},{latexTrigger:["\u2229"],kind:"infix",precedence:350,parse:ae("Intersection",350,"both")},{name:"Interval",serialize:ud},{kind:"matchfix",openTrigger:["["],closeTrigger:[")"],parse:(e,n)=>sn(n,!1,!0)},{kind:"matchfix",openTrigger:["\\lbrack"],closeTrigger:["\\rparen"],parse:(e,n)=>sn(n,!1,!0)},{kind:"matchfix",openTrigger:["\\lbrack"],closeTrigger:[")"],parse:(e,n)=>sn(n,!1,!0)},{kind:"matchfix",openTrigger:["["],closeTrigger:["\\rparen"],parse:(e,n)=>sn(n,!1,!0)},{kind:"matchfix",openTrigger:["("],closeTrigger:["]"],parse:(e,n)=>sn(n,!0,!1)},{kind:"matchfix",openTrigger:["\\lparen"],closeTrigger:["\\rbrack"],parse:(e,n)=>sn(n,!0,!1)},{kind:"matchfix",openTrigger:["\\lparen"],closeTrigger:["]"],parse:(e,n)=>sn(n,!0,!1)},{kind:"matchfix",openTrigger:["("],closeTrigger:["\\rbrack"],parse:(e,n)=>sn(n,!0,!1)},{kind:"matchfix",openTrigger:["]"],closeTrigger:["["],parse:(e,n)=>sn(n,!0,!0)},{kind:"matchfix",openTrigger:["\\rbrack"],closeTrigger:["\\lbrack"],parse:(e,n)=>sn(n,!0,!0)},{name:"Multiple",serialize:ud},{name:"Union",latexTrigger:["\\cup"],kind:"infix",precedence:350,parse:ae("Union",350,"both"),serialize:on("\\cup",350,"both")},{latexTrigger:["\u222A"],kind:"infix",precedence:350,parse:ae("Union",350,"both")},{name:"Divides",latexTrigger:["\\mid"],kind:"infix",precedence:160},{name:"NotDivides",latexTrigger:["\\nmid"],kind:"infix",precedence:160},{name:"Set",kind:"matchfix",openTrigger:"{",closeTrigger:"}",parse:(e,n)=>{if(F(n))return"EmptySet";g(n)=="Delimiter"&&_(d(n,2))===","&&(n=d(n,1));let t=g(n);if(t==="Divides"){let i=d(n,1),r=d(n,2);if(i!==null&&r!==null)return["Set",i,["Condition",r]]}if(t==="Colon"){let i=d(n,1),r=d(n,2);if(i!==null&&r!==null){let s=g(i);return s!==null&&uu.has(s)?["Which",i,r]:["Set",i,["Condition",r]]}}if(t==="Sequence"){let i=b(n);i.length>1&&$f(n)&&(i=i.slice(0,-1));let r=i.filter(l=>g(l)==="Colon");if(r.length>0&&r.every(l=>{let c=d(l,1),f=c!==null?g(c):null;return f!==null&&uu.has(f)})){let l=[];for(let c=0;c<i.length;c++){let f=i[c];if(g(f)==="Colon"){let p=d(f,1),h=d(f,2);if(p===null||h===null)return["Set",...i];l.push(p,h)}else{if(c!==i.length-1)return["Set",...i];l.push("True",f)}}return["Which",...l]}let o=i[0],a=g(o);if(a==="Colon"||a==="Divides"){let l=d(o,1),c=d(o,2),f=l!==null?g(l):null;if(l!==null&&c!==null&&!(f!==null&&uu.has(f))){let p=[c,...i.slice(1)];return["Set",l,["Condition",p.length===1?p[0]:["And",...p]]]}}let u=Ys(i,e);return u||["Set",...i]}return["Set",n]},serialize:(e,n)=>{if(P(n)===2&&g(d(n,2))==="Condition"){let t=d(n,2);return v(["\\lbrace",e.serialize(d(n,1)),"\\mid",e.serialize(d(t,1)),"\\rbrace"])}return v(["\\lbrace",b(n).map(t=>e.serialize(t)).join(", "),"\\rbrace"])}},{name:"SetMinus",latexTrigger:["\\setminus"],kind:"infix",precedence:650,parse:ae("SetMinus",650,"both"),serialize:on("\\setminus",650,"both")},{latexTrigger:["\\backslash"],kind:"infix",precedence:650,parse:ae("SetMinus",650,"both")},{name:"SymmetricDifference",latexTrigger:["\\triangle"],kind:"infix",precedence:w,parse:ae("SymmetricDifference",w,"both"),serialize:on("\\triangle",w,"both")},{latexTrigger:["\\ni"],kind:"infix",associativity:"none",precedence:160,parse:(e,n,t)=>{let i=lu(e,n),r=e.parseExpression(t);return r===null?null:["Element",r,i]}},{name:"Element",latexTrigger:["\\in"],kind:"infix",precedence:241,parse:ae("Element",241,"rhs"),serialize:on("\\in",241,"rhs")},{latexTrigger:["\u2208"],kind:"infix",precedence:241,parse:ae("Element",241,"rhs")},{name:"NotElement",latexTrigger:["\\notin"],kind:"infix",precedence:240,parse:ae("NotElement",240,"rhs"),serialize:on("\\notin",240,"rhs")},{latexTrigger:["\u2209"],kind:"infix",precedence:240,parse:ae("NotElement",240,"rhs")},{name:"NotSubset",latexTrigger:["\\nsubset"],kind:"infix",associativity:"none",precedence:240},{name:"NotSuperset",latexTrigger:["\\nsupset"],kind:"infix",associativity:"none",precedence:240},{name:"NotSubsetNotEqual",latexTrigger:["\\nsubseteq"],kind:"infix",associativity:"none",precedence:240},{name:"NotSupersetNotEqual",latexTrigger:["\\nsupseteq"],kind:"infix",associativity:"none",precedence:240},{latexTrigger:["\\not","\\in"],kind:"infix",precedence:240,parse:ae("NotElement",240,"rhs")},{latexTrigger:["\\not","\\subset"],kind:"infix",associativity:"none",precedence:240,parse:"NotSubset"},{latexTrigger:["\\not","\\supset"],kind:"infix",associativity:"none",precedence:240,parse:"NotSuperset"},{latexTrigger:["\\not","\\subseteq"],kind:"infix",associativity:"none",precedence:240,parse:(e,n,t)=>{let i=lu(e,n),r=fu(e),s=e.parseExpression({...t,minPrec:240});return s===null?null:["Not",["SubsetEqual",i,r?cu(s):s]]}},{name:"SquareSubset",latexTrigger:["\\sqsubset"],kind:"infix",associativity:"none",precedence:265},{name:"SquareSubsetEqual",latexTrigger:["\\sqsubseteq"],kind:"infix",associativity:"none",precedence:265},{name:"SquareSuperset",latexTrigger:["\\sqsupset"],kind:"infix",associativity:"none",precedence:265},{name:"SquareSupersetEqual",latexTrigger:["\\sqsupseteq"],kind:"infix",associativity:"none",precedence:265},{name:"Subset",latexTrigger:["\\subset"],kind:"infix",associativity:"none",precedence:240,parse:ae("Subset",240,"chain"),serialize:on("\\subset",240,"both")},{latexTrigger:["\\subsetneq"],kind:"infix",associativity:"none",precedence:240,parse:ae("Subset",240,"chain")},{latexTrigger:["\\varsubsetneqq"],kind:"infix",associativity:"none",precedence:240,parse:ae("Subset",240,"chain")},{name:"SubsetEqual",latexTrigger:["\\subseteq"],kind:"infix",associativity:"none",precedence:240,parse:ae("SubsetEqual",240,"chain"),serialize:on("\\subseteq",240,"both")},{name:"Superset",latexTrigger:["\\supset"],kind:"infix",associativity:"none",precedence:240,parse:ae("Superset",240,"chain"),serialize:on("\\supset",240,"both")},{latexTrigger:["\\supsetneq"],kind:"infix",associativity:"none",precedence:240,parse:ae("Superset",240,"chain")},{latexTrigger:["\\varsupsetneq"],kind:"infix",associativity:"none",precedence:240,parse:ae("Superset",240,"chain")},{name:"SupersetEqual",latexTrigger:["\\supseteq"],kind:"infix",associativity:"none",precedence:240,parse:ae("SupersetEqual",240,"chain"),serialize:on("\\supseteq",240,"both")}];function ud(e,n){if(n===null)return"";let t=g(n);if(!t)return"";if(t==="Range")return v(["\\mathopen\\lbrack",e.serialize(d(n,1)),", ",e.serialize(d(n,2)),"\\mathclose\\rbrack"]);if(t==="Interval")return lb(e,n);let i=e.numericSetStyle(n,e.level);return""}function no(e,n){if(n==="none")return e;if(n==="0...360"){let t=e%360;return(t<0?t+360:t)||0}if(n==="-180...180"){let t=e%360;return t>180&&(t-=360),t<-180&&(t+=360),t||0}return e}function fb(e){let n=e<0?-1:1,t=Math.abs(e),i=Math.floor(t),r=(t-i)*60,s=Math.floor(r),o=(r-s)*60,a=Math.round(o*1e3)/1e3,u=s,l=i;return a>=60&&(a=0,u++),u>=60&&(u=0,l++),{deg:n*l||0,min:n*u||0,sec:a===0?0:n*a}}function to(e){let{deg:n,min:t,sec:i}=fb(e),r=`${n}\xB0`;if(Math.abs(i)>.001){let s=i%1===0?i.toString():i.toFixed(2);r+=`${Math.abs(t)}'${Math.abs(Number(s))}"`}else Math.abs(t)>0?r+=`${Math.abs(t)}'`:r+=`0'0"`;return r}function db(e){if(typeof e=="number")return e===2;let n=typeof e=="object"&&!Array.isArray(e)&&"num"in e?e.num:typeof e=="string"?e:void 0;return typeof n!="string"?!1:/^\+?0*2(\.0*)?$/.test(n.trim())}function pb(e){return e.includes("\\vert")||e.includes("|")}function mb(e,n){let t=e.groupStyle(n,e.level+1),i=e.serialize(d(n,1));return t==="big"?v(["\\Bigl\\vert",i,"\\Bigr\\vert"]):t==="scaled"||pb(i)?v(["\\left\\vert",i,"\\right\\vert"]):v(["\\vert",i,"\\vert"])}function gb(e,n){if(n===null||db(n))return"";if(E(n)==="PositiveInfinity"||_(n)==="Infinity")return"_\\infty";if(_(n)==="Frobenius")return"_F";let t=e.serialize(n);return t.length===1?`_${t}`:`_{${t}}`}function Md(e){if(g(e)!=="Multiply")return[[],[]];let n=[],t=[];for(let i of b(e))if(g(i)==="Power"){let r=d(i,1),s=d(i,2);if(g(s)==="Negate"){let o=d(s,1);r&&o&&t.push(["Power",r,o])}else{let o=M(s)??NaN;o===-1?r&&t.push(r):o<0?r&&t.push(["Power",r,-o]):n.push(i)}}else if(g(i)==="Rational"&&P(i)===2||g(i)==="Divide"){let r=d(i,1),s=d(i,2);M(r)!==1&&n.push(r),M(s)!==1&&t.push(s)}else{let r=nt(i);r!==null?(r[0]!==1&&n.push(r[0]),t.push(r[1])):n.push(i)}return[n,t]}function pd(e){let n=e.parseOptionalGroup(),t=e.parseGroup(),i=t??e.parseToken();if(F(i)){if(n===null&&t===null)return"Sqrt";let r=e.error("missing",e.index);return n!==null?["Root",r,O(n)]:["Sqrt",r]}return n!==null?["Root",i,n]:["Sqrt",i]}function hb(e){if(typeof e=="number")return-e;if(typeof e=="string")return e.startsWith("-")?e.slice(1):e.startsWith("+")?"-"+e.slice(1):"-"+e;let n=e.num;return n.startsWith("-")?{num:n.slice(1)}:n.startsWith("+")?{num:"-"+n.slice(1)}:{num:"-"+n}}function gu(e,n){if(n==null)return!1;if(E(n)==="ContinuationPlaceholder")return!0;let t=g(n);return t==="Add"||t==="Subtract"||t==="Negate"?t==="Add"&&n===e.ownedChain?!1:b(n).some(i=>gu(e,i)):!1}function wd(e){if(g(e)==="Subtract"){let n=d(e,1),t=d(e,2);return[...wd(n),["Negate",t]]}return[e]}function md(e,n,t,i){if(g(n)!=="Add"||!(gu(e,t)||gu(e,i)))return n;let s=[];for(let o of b(n))s.push(...wd(o));return["Add",...s]}function yb(e,n){if(!n)return"\\pm";let t=d(n,1),i=d(n,2);if(t===null)return"\\pm";if(i===null)return e.serialize(t);let r=M(t),s=M(i);if(r!==null&&s!==null&&Number.isFinite(r)&&Number.isFinite(s)&&s>0){let{value:o,error:a}=Pa(r,s,e.options.digits);return v([o,"\\pm",a])}return v([e.serialize(t),"\\pm",e.serialize(i)])}function Bi(e,n,t,i){return t==null?"\\sqrt{}":(i=i??2,n==="solidus"?xn("^",e.wrapShort(t),"1/"+e.serialize(i)):n==="quotient"?xn("^",e.wrapShort(t),"\\frac{1}{"+e.serialize(i)+"}"):M(i)===2?"\\sqrt{"+e.serialize(t)+"}":"\\sqrt["+e.serialize(i)+"]{"+e.serialize(t)+"}")}var bb=new Set(["Pi","ExponentialE","ImaginaryUnit","GoldenRatio","EulerGamma","CatalanConstant","MachineEpsilon"]);function hu(e,n){let t=E(e);if(t!==null)return t===n;for(let i of b(e))if(hu(i,n))return!0;return!1}function Ad(e){let n=E(e);if(n!==null)return bb.has(n)?null:n;for(let t of b(e)){let i=Ad(t);if(i!==null)return i}return null}function Sn(e,n){if(Ye(e))return 0;let t=E(e);if(t!==null)return t===n?1:0;let i=g(e);if(!i)return 0;if(i==="Negate")return Sn(d(e,1),n);if(i==="Multiply"){let r=0;for(let s of b(e)){let o=Sn(s,n);if(o===void 0)return;r+=o}return r}if(i==="Divide"){let r=Sn(d(e,1),n),s=Sn(d(e,2),n);return r===void 0||s===void 0?void 0:r-s}if(i==="Power"){let r=d(e,1),s=d(e,2),o=Sn(r,n);if(o===void 0)return;if(o===0)return hu(s,n)?void 0:0;let a=M(s);return a===null||!Number.isInteger(a)?void 0:o*a}if(i==="Square"){let r=Sn(d(e,1),n);return r===void 0?void 0:r*2}if(i==="Add"||i==="Subtract"){let r;for(let s of b(e)){let o=Sn(s,n);o!==void 0&&(r===void 0||o>r)&&(r=o)}return r}return hu(e,n)?void 0:0}function xb(e){let n=e;return g(n)==="Negate"&&(n=d(n,1)),g(n)==="BigO"?d(n,1):null}function Eb(e){let n=e.map(xb);if(!n.some(u=>u!==null))return e;let t=null;for(let u of n)if(u!==null&&(t=Ad(u),t!==null))break;if(t===null)return e;let i=n.find(u=>u!==null),r=(Sn(i,t)??0)>=0,s=[],o=[];for(let u=0;u<e.length;u++)n[u]!==null?o.push(e[u]):s.push(e[u]);let a=u=>Sn(u,t)??0;return s.sort((u,l)=>r?a(u)-a(l):a(l)-a(u)),[...s,...o]}function Tb(e,n){e.level-=1;let t=g(n),i="",r=d(n,1);if(t==="Negate")i="-"+e.wrap(r,q+1);else if(t==="Subtract"){i=e.wrap(r,q);let s=d(n,2);if(s!==null){let o=e.wrap(s,q);o[0]==="-"?i+="+"+o.slice(1):o[0]==="+"?i+="-"+o.slice(1):i=i+"-"+o}}else if(t==="Add"){let s=Eb(b(n));if(e.options.prettify&&s.length===2&&e.options.invisiblePlus!=="+"){let[o,a]=s,[u,l]=[o,a],c=M(u),f=nt(l);if((c===null||f===null)&&([u,l]=[a,o],c=M(u),f=nt(l)),c!==null&&f!==null&&isFinite(c)&&Number.isInteger(c)&&c>=0&&c<=1e3&&isFinite(f[0])&&isFinite(f[1])&&f[0]>0&&f[0]<=100&&f[1]<=100)return i=Fe(e.options.invisiblePlus,e.serialize(u),e.serialize(l)),e.level+=1,i}if(e.options.prettify&&s.length===2){let[o,a]=Li(s[0]),[u,l]=Li(s[1]);if(a<0&&l>0)return i=e.wrap(u,q)+"-"+e.wrap(o,q),e.level+=1,i}i=g(s[0])==="Range"?e.wrap(s[0],q):e.serialize(s[0]);for(let o=1;o<s.length;o++)if(r=s[o],e.options.prettify){let[a,u]=Li(r),l=e.wrap(a,q);u>0?l.startsWith("+")||l.startsWith("-")?i+=l:i+="+"+l:l.startsWith("+")?i+="-"+l.slice(1):l.startsWith("-")?i+="+"+l.slice(1):i+="-"+l}else{let a=e.wrap(r,q);a[0]==="-"||a[0]==="+"?i+=a:i+="+"+a}}return e.level+=1,i}function Rd(e){return b(e).some(n=>g(n)==="Negate"?E(d(n,1))==="ContinuationPlaceholder":E(n)==="ContinuationPlaceholder")}function gd(e){if(e==null||g(e)!=="Multiply")return!1;let n=t=>{if(E(t)==="ContinuationPlaceholder")return!0;let i=g(t);return i==="Negate"?E(d(t,1))==="ContinuationPlaceholder":i==="Multiply"||i==="Sequence"?b(t).some(n):!1};return b(e).some(n)}function hd(e,n,t){let i=o=>g(o)==="InvisibleOperator"&&Rd(o)?b(o):null,r=i(n),s=i(t);return r!==null||s!==null?["Multiply",...r??[n],...s??[t]]:e._appendAssociativeOperand("Multiply",n,t)}function _d(e,n){if(n===null)return"";e.level-=1;let t="",i=Rd(n)||b(n).some(gd);if(e.options.prettify===!0&&!i){let[c,f]=Md(n);f.length>0&&(f.length===1&&f[0]===1?c.length===0?t="1":c.length===1?t=e.serialize(c[0]):t=_d(e,["Multiply",...c]):t=e.serialize(["Divide",c.length===1?c[0]:["Multiply",...c],f.length===1?f[0]:["Multiply",...f]]))}if(t)return e.level+=1,t;let r=!1,s=null,o=P(n)+1,a=b(n);e.options.prettify===!0&&a.length===2&&Ye(a[1])&&!Ye(a[0])&&(a=[a[1],a[0]]);let u=!1,l=null;for(let c=1;c<o;c++){if(s=a[c-1],s===null)continue;let f;if(Ye(s)){f=e.serialize(s),f==="-1"&&!t?(t="",r=!r):(f[0]==="-"&&(f=f.slice(1),r=!r),t?t=Fe(e.options.multiply,t,f):t=f),u=!0,l=null;continue}if(g(s)==="Power"){let h=nt(d(s,2));if(h!=null){let[y,N]=h;if(y===1&&N!==null){let D=Bi(e,e.rootStyle(s,e.level),d(s,1),N);t&&i?t=Fe(e.options.multiply,t,D):t+=D,u=!1,l=null;continue}}}if(g(s)==="Power"&&!isNaN(M(d(s,1))??NaN)){f=e.serialize(s),t?t=Fe(e.options.multiply,t,f):t=f,u=!0,l=null;continue}g(s)==="Negate"&&(s=d(s,1),r=!r),f=g(s)==="Mod"&&P(s)===2?e.wrap(s,W+1):gd(s)?e.wrap(s,V+1):e.wrap(s,V);let p=E(s)==="ContinuationPlaceholder";if(!t)t=f;else{let h=g(s);i?t=Fe(e.options.multiply,t,f):u&&(h==="Divide"||h==="Rational")?t=Fe(e.options.multiply,t,f):/^\d/.test(f)?t=Fe(e.options.multiply,t,f):l!==null&&(Nb(s)||/^[A-Z]$/.test(l)&&/^(\\left)?\(/.test(f))?t=Fe(e.options.multiply,t,f):e.options.invisibleMultiply?t=Fe(e.options.invisibleMultiply,t,f):t=v([t,f])}u=!1,l=p?null:E(s)}return e.level+=1,r?"-"+t:t}function Nb(e){if(e===null)return!1;let n=g(e);if(n==="Tuple"||n==="Pair"||n==="Triple")return P(e)>=2;if(n==="Delimiter"){let t=d(e,1);if(g(t)!=="Sequence"||P(t)<2)return!1;let i=_(d(e,2));return i==null||i.startsWith("(")}return!1}function so(e){let n=e.parseGroup();return n===null?O(e.parseToken()):F(n)?e.error("missing",e.index):n}var yd=q;function io(e){let n=so(e),t=so(e),i=g(t)==="PartialDerivative"?[t]:g(t)==="Multiply"||g(t)==="Sequence"||g(t)==="InvisibleOperator"?b(t).filter(u=>g(u)==="PartialDerivative"):[];if(i.length>0){let u=g(n)==="PartialDerivative"?d(n,1):null;(u==null||u==="Nothing")&&(u=bd(O(e.parseExpression({minPrec:yd}))));let l=[];for(let f of i){let p=d(f,1),h=g(p)==="List"?b(p):[p];for(let y of h)y&&y!=="Nothing"&&l.push(y)}let c=M(d(n,2))??1;if(l.length===1&&c>1)for(let f=1;f<c;f++)l.push(l[0]);if(l.length>0)return["D",u,...l]}let r=u=>u==="d"||u==="d_upright"||u==="differentialD",s=null,o=null;{let u=g(n),l=u==="Multiply"||u==="InvisibleOperator"||u==="Sequence"?[...b(n)]:[n],c=l[0];if(r(E(c)))s=1;else if(g(c)==="Power"&&r(E(d(c,1)))){let f=M(d(c,2));f!==null&&f>0&&(s=f)}if(s!==null&&l.length>1){let f=l.slice(1);o=f.length===1?f[0]:["Multiply",...f]}}if(s!==null){let u=[],l=!1,c=f=>{if(!f)return;let p=E(f);if(p&&r(p)){l=!0;return}if(p){u.push(f);return}let h=g(f);if(h==="Sequence"||h==="Multiply"||h==="InvisibleOperator")for(let y of b(f))c(y);else if(h==="Power"){let y=d(f,1);y&&!r(E(y))&&u.push(y)}};if(c(t),l||(u.length=0),u.length===0){let f=E(t);f&&f.length>1&&f[0]==="d"&&u.push(f.slice(1))}if(u.length===1&&s>1)for(let f=1;f<s;f++)u.push(u[0]);if(u.length>0){let p=o??bd(O(e.parseExpression({minPrec:yd})));for(let h of u)p=["D",p,h];return p}}let a=fd(e,n,t);return a!==null?a:["Divide",n,t]}function Ci(e,n,t){if(e.match("_")){let r=e.parseGroup()??e.parseToken();if(r===null)return null;let s=e.parseArguments("implicit");return s===null||s.length===0?null:t==="first"?[n,r,...s]:[n,...s,r]}let i=e.parseArguments("enclosure");return i===null?n:[n,...i]}function bd(e){return g(e)==="List"&&P(e)===1?d(e,1):e}function vb(e,n,t){let i=e.parseExpression({...t,minPrec:W+1});if(i===null)return["Divide",n,Ti];let r=Sb(n,i);return r||["Divide",n,i]}function Sb(e,n){let t=E(e);if(t!=="d"&&t!=="d_upright"&&t!=="differentialD")return null;let i=g(n);if(i!=="InvisibleOperator"&&i!=="Multiply")return null;let r=b(n);if(r.length<3)return null;let s=E(r[0]);if(s!=="d"&&s!=="d_upright"&&s!=="differentialD")return null;let o=r[1];if(!E(o))return null;let a=r.length===3?r[2]:["InvisibleOperator",...r.slice(2)];return["D",Fi(a),o]}function Fi(e){if(g(e)==="Delimiter")return Fi(d(e,1));if(g(e)==="InvisibleOperator"){let n=b(e);return n.length===2&&E(n[0])&&g(n[1])==="Delimiter"?[E(n[0]),Fi(n[1])]:["InvisibleOperator",...n.map(t=>Fi(t))]}if(Array.isArray(e)){let n=e[0];if(typeof n!="string")return e;let t=[n];for(let i=1;i<e.length;i++)t.push(Fi(e[i]));return t}return e}function xd(e,n){if(n===null)return"";let t=O(d(n,1)),i=O(d(n,2)),r=e.options.prettify?e.fractionStyle(n,e.level):"quotient";if(r==="inline-solidus"||r==="nice-solidus"){let u=e.wrapShort(t),l=e.wrapShort(i);return r==="inline-solidus"?`${u}/${l}`:`{}^{${u}}\\!\\!/\\!{}_{${l}}`}else{if(r==="reciprocal")return M(t)===1?e.wrap(i)+"^{-1}":e.wrap(t)+e.wrap(i)+"^{-1}";if(r==="factor")return M(i)===1?e.wrap(t):"\\frac{1}{"+e.serialize(i)+"}"+e.wrapString(e.serialize(t),e.groupStyle(n,1))}let s="\\frac";r==="block-quotient"?s="\\dfrac":r==="inline-quotient"&&(s="\\tfrac");let o=e.serialize(t),a=e.serialize(i);return`${s}{${o}}{${a}}`}function pu(e){let n=so(e),t=so(e);return["Binomial",n,O(t)]}function Ib(e,n){if(n===null)return"";let t=e.serialize(O(d(n,1))),i=e.serialize(O(d(n,2)));return`\\binom{${t}}{${i}}`}function mu(e,n){if(!n)return"";let t=g(n),i=O(d(n,1));if(t==="Sqrt")return Bi(e,e.rootStyle(n,e.level-1),i,2);let r=O(d(n,2));if(t==="Root")return Bi(e,e.rootStyle(n,e.level-1),i,r);if(e.options.prettify){let o=M(r)??1;if(o===-1)return e.serialize(["Divide","1",i]);if(o<0)return e.serialize(["Divide","1",["Power",i,-o]]);if(g(r)==="Divide"||g(r)==="Rational"){let a=M(d(r,1)),u=M(d(r,2));if(a===1){let l=e.rootStyle(n,e.level);return Bi(e,l,i,d(r,2))}if(a===-1)return u===2?e.serialize(["Divide","1",["Sqrt",i]]):e.serialize(["Divide","1",["Root",i,d(r,2)??Ti]]);if(u===2)return`${e.serialize(["Sqrt",i])}^{${e.serialize(d(r,1))}}`}else if(g(r)==="Power"&&M(d(r,2))===-1){let a=e.rootStyle(n,e.level);return Bi(e,a,i,d(r,1))}}return xn("^",(o=>o.startsWith("-")?e.wrapString(o,"normal"):o)(e.wrapShort(i)),e.serialize(r))}function Oi(e,n){e.skipSpace();let t=e.index,i=e.parseNumber(),r=null,s=null;if(i!==null&&(e.match("'")||e.match("\\prime"))){r=M(i),e.skipSpace();let u=e.index,l=e.parseNumber();l!==null&&(e.match('"')||e.match("\\doubleprime"))?s=M(l):e.index=u}else return e.index=t,["Degrees",n];let o=M(n);if(o!==null&&r!==null){let u=3600*o+60*r+(s??0),l=Ei(u,3600);if(l===null)return["Degrees",u/3600];let[c,f]=l;return f===1?["Degrees",c]:["Degrees",["Rational",c,f]]}let a=[["Quantity",n,"deg"]];return a.push(["Quantity",i,"arcmin"]),s!==null&&a.push(["Quantity",s,"arcsec"]),["Add",...a]}var Pd=[{name:"CatalanConstant",standaloneSymbol:!0,latexTrigger:"\\operatorname{G}",serialize:"\\operatorname{G}"},{latexTrigger:"\\mathrm{G}",parse:"CatalanConstant"},{name:"GoldenRatio",standaloneSymbol:!0,latexTrigger:"\\varphi"},{name:"EulerGamma",standaloneSymbol:!0,latexTrigger:"\\gamma",serialize:"\\operatorname{EulerGamma}",parse:e=>e.resolveSymbol("gamma")===void 0?"EulerGamma":null},{name:"Degrees",latexTrigger:["\\degree"],kind:"postfix",precedence:880,parse:(e,n)=>Oi(e,n),serialize:(e,n)=>{let t=e.options,i=d(n,1);if(t.dmsFormat||t.angleNormalization&&t.angleNormalization!=="none"){let r=M(i);if(r===null){let s=nt(i);s!==null&&s[1]!==0&&(r=s[0]/s[1])}if(r!==null){let s=r;return t.angleNormalization&&t.angleNormalization!=="none"&&(s=no(s,t.angleNormalization)),t.dmsFormat?to(s):`${s}\xB0`}}return v([e.serialize(i),"\\degree"])}},{latexTrigger:["\\degree"],kind:"postfix",precedence:880,parse:(e,n)=>Oi(e,n)},{latexTrigger:["^","<{>","\\circ","<}>"],kind:"postfix",parse:(e,n)=>Oi(e,n)},{latexTrigger:["^","\\circ"],kind:"postfix",parse:(e,n)=>Oi(e,n)},{latexTrigger:["\xB0"],kind:"postfix",precedence:880,parse:(e,n)=>Oi(e,n)},{latexTrigger:["\\ang"],parse:e=>{let n=e.parseGroup();return n===null?["Degrees"]:["Degrees",n]}},{name:"DMS",serialize:(e,n)=>{let t=M(d(n,1)),i=M(d(n,2)),r=M(d(n,3));if(t!==null){let o=i??0,a=r??0,u=`${t}\xB0`;return(o!==0||a!==0)&&(u+=`${o}'`),a!==0&&(u+=`${a}"`),u}let s=[];for(let o of[1,2,3]){let a=d(n,o);a!==null&&s.push(e.serialize(a))}return`\\operatorname{DMS}(${s.join(", ")})`}},{latexTrigger:["\\infty"],parse:"PositiveInfinity"},{latexTrigger:["\\infin"],parse:"PositiveInfinity"},{latexTrigger:["\u221E"],parse:"PositiveInfinity"},{name:"PositiveInfinity",serialize:e=>e.options.positiveInfinity},{name:"NegativeInfinity",serialize:e=>e.options.negativeInfinity},{name:"ComplexInfinity",standaloneSymbol:!0,latexTrigger:["\\tilde","\\infty"],serialize:"\\tilde\\infty"},{latexTrigger:["\\tilde","<{>","\\infty","<}>"],parse:"ComplexInfinity"},{name:"Pi",standaloneSymbol:!0,kind:"symbol",latexTrigger:["\\pi"]},{latexTrigger:["\u03C0"],parse:"Pi"},{name:"ExponentialE",standaloneSymbol:!0,latexTrigger:["\\exponentialE"],parse:"ExponentialE",serialize:"\\exponentialE"},{latexTrigger:"\\operatorname{e}",parse:"ExponentialE"},{latexTrigger:"\\mathrm{e}",parse:"ExponentialE"},{kind:"function",symbolTrigger:"exp",parse:e=>Sd(e)},{latexTrigger:"\\exp",parse:e=>Sd(e)},{name:"ImaginaryUnit",latexTrigger:["\\imaginaryI"]},{latexTrigger:"\\operatorname{i}",parse:"ImaginaryUnit"},{latexTrigger:"\\mathrm{i}",parse:"ImaginaryUnit"},{name:"Abs",kind:"matchfix",openTrigger:"|",closeTrigger:"|",parse:(e,n)=>F(n)?null:["Abs",n],serialize:(e,n)=>mb(e,n)},{kind:"matchfix",openTrigger:["\\vert"],closeTrigger:["\\vert"],parse:(e,n)=>F(n)?null:["Abs",n]},{symbolTrigger:"abs",kind:"function",parse:"Abs"},{latexTrigger:["\\abs"],kind:"function",parse:"Abs"},{name:"Add",latexTrigger:["+"],kind:"infix",associativity:"any",precedence:q,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:q+1});if(i===null)return null;if(g(i)==="Negate"){let r=d(i,1);if(Ye(r))return md(e,e._appendAssociativeOperand("Add",n,hb(r)),n,i)}return md(e,e._appendAssociativeOperand("Add",n,i),n,i)},serialize:Tb},{kind:"prefix",latexTrigger:["+"],precedence:q,parse:(e,n)=>e.parseExpression({...n,minPrec:400})},{name:"Ceil",kind:"matchfix",openTrigger:"\\lceil",closeTrigger:"\\rceil",parse:(e,n)=>F(n)?null:["Ceil",n]},{kind:"matchfix",openTrigger:["\u2308"],closeTrigger:["\u2309"],parse:(e,n)=>F(n)?null:["Ceil",n]},{symbolTrigger:"ceil",kind:"function",parse:"Ceil"},{name:"Chop",symbolTrigger:"chop",kind:"function",parse:"Chop"},{name:"Complex",precedence:q-1,serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=M(d(n,2));if(i===0)return t;let r=i===1?"\\imaginaryI":i===-1?"-\\imaginaryI":v([e.serialize(d(n,2)),"\\imaginaryI"]);return M(d(n,1))===0?r:i!==null&&i<0?v([t,r]):v([t,"+",r])}},{name:"Divide",latexTrigger:"\\frac",precedence:W,parse:io,serialize:xd},{latexTrigger:"\\dfrac",precedence:W,parse:io},{latexTrigger:"\\tfrac",precedence:W,parse:io},{latexTrigger:"\\cfrac",precedence:W,parse:io},{name:"Binomial",latexTrigger:"\\binom",parse:pu,serialize:Ib},{latexTrigger:"\\dbinom",parse:pu},{latexTrigger:"\\tbinom",parse:pu},{kind:"infix",latexTrigger:"\\over",associativity:"none",precedence:W,parse:"Divide"},{kind:"infix",latexTrigger:"\\choose",associativity:"none",precedence:W,parse:"Binomial"},{latexTrigger:["\\/"],kind:"infix",associativity:"left",precedence:W,parse:"Divide"},{latexTrigger:["/"],kind:"infix",associativity:"left",precedence:W,parse:vb},{latexTrigger:["\\div"],kind:"infix",associativity:"left",precedence:W,parse:"Divide"},{name:"Exp",serialize:(e,n)=>{let t=d(n,1);return E(t)||M(t)!==null?v(["\\exponentialE^{",e.serialize(t),"}"]):v(["\\exp",e.wrap(O(t))])}},{name:"Factorial",latexTrigger:["!"],kind:"postfix",precedence:tn,parse:(e,n)=>e.peek==="="?null:["Factorial",n]},{name:"Factorial2",latexTrigger:["!","!"],kind:"postfix",precedence:tn},{name:"Floor",kind:"matchfix",openTrigger:"\\lfloor",closeTrigger:"\\rfloor",parse:(e,n)=>F(n)?null:["Floor",n]},{kind:"matchfix",openTrigger:["\u230A"],closeTrigger:["\u230B"],parse:(e,n)=>F(n)?null:["Floor",n]},{symbolTrigger:"floor",kind:"function",parse:"Floor"},{latexTrigger:["\\floor"],kind:"function",parse:"Floor"},{latexTrigger:["\\Gamma"],parse:"Gamma"},{latexTrigger:["\\zeta"],kind:"function",parse:"Zeta"},{latexTrigger:["\\Beta"],kind:"function",parse:"Beta"},{name:"LambertW",latexTrigger:["\\operatorname{W}"],kind:"function",parse:e=>Ci(e,"LambertW","last"),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{W}_{"+e.serialize(i)+"}"+e.wrapArguments(["LambertW",t]):"\\operatorname{W}"+e.wrapArguments(n)}},{name:"BesselJ",latexTrigger:["\\operatorname{J}"],kind:"function",parse:e=>Ci(e,"BesselJ","first"),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{J}_{"+e.serialize(t)+"}"+e.wrapArguments(["BesselJ",i]):"\\operatorname{J}"+e.wrapArguments(n)}},{name:"BesselY",latexTrigger:["\\operatorname{Y}"],kind:"function",parse:e=>Ci(e,"BesselY","first"),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{Y}_{"+e.serialize(t)+"}"+e.wrapArguments(["BesselY",i]):"\\operatorname{Y}"+e.wrapArguments(n)}},{name:"BesselI",latexTrigger:["\\operatorname{I}"],kind:"function",parse:e=>Ci(e,"BesselI","first"),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{I}_{"+e.serialize(t)+"}"+e.wrapArguments(["BesselI",i]):"\\operatorname{I}"+e.wrapArguments(n)}},{name:"BesselK",latexTrigger:["\\operatorname{K}"],kind:"function",parse:e=>Ci(e,"BesselK","first"),serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{K}_{"+e.serialize(t)+"}"+e.wrapArguments(["BesselK",i]):"\\operatorname{K}"+e.wrapArguments(n)}},{name:"PolyLog",latexTrigger:["\\operatorname{Li}"],kind:"function",parse:e=>{if(!e.match("_"))return null;let n=e.parseGroup()??e.parseToken();if(n===null)return null;let t=e.parseArguments("implicit");return t===null?["PolyLog",n]:["PolyLog",n,...t]},serialize:(e,n)=>{let t=d(n,1),i=d(n,2);return t!==null&&i!==null?"\\operatorname{Li}_{"+e.serialize(t)+"}"+e.wrapArguments(["PolyLog",i]):"\\operatorname{Li}"+e.wrapArguments(n)}},{name:"LogIntegral",latexTrigger:["\\operatorname{li}"],kind:"function",serialize:(e,n)=>"\\operatorname{li}"+e.wrapArguments(n)},{name:"AiryAi",latexTrigger:["\\operatorname{Ai}"],kind:"function",serialize:(e,n)=>"\\operatorname{Ai}"+e.wrapArguments(n)},{name:"AiryBi",latexTrigger:["\\operatorname{Bi}"],kind:"function",serialize:(e,n)=>"\\operatorname{Bi}"+e.wrapArguments(n)},{name:"AiryAiPrime",kind:"function",serialize:(e,n)=>"\\operatorname{Ai}'"+e.wrapArguments(n)},{name:"AiryBiPrime",kind:"function",serialize:(e,n)=>"\\operatorname{Bi}'"+e.wrapArguments(n)},{name:"GCD",latexTrigger:["\\gcd"],kind:"function"},{symbolTrigger:"gcd",kind:"function",parse:"GCD"},{symbolTrigger:"GCD",kind:"function",parse:"GCD"},{name:"Half",serialize:"\\frac12"},{name:"Lg",standaloneSymbol:!0,latexTrigger:["\\lg"],serialize:(e,n)=>E(n)!==null?"\\lg":"\\log_{10}"+e.wrapArguments(n),parse:e=>Id(e)},{kind:"function",symbolTrigger:"lg",parse:e=>Id(e)},{name:"Lb",standaloneSymbol:!0,latexTrigger:"\\lb",parse:e=>kd(e)},{kind:"function",symbolTrigger:"lb",parse:e=>kd(e)},{name:"Ln",standaloneSymbol:!0,latexTrigger:["\\ln"],parse:e=>ro("Ln",e),serialize:(e,n)=>E(n)!==null?"\\ln":"\\ln"+e.wrapArguments(n)},{kind:"function",symbolTrigger:"ln",parse:e=>ro("Ln",e)},{name:"Log",standaloneSymbol:!0,latexTrigger:["\\log"],parse:e=>ro("Log",e),serialize:(e,n)=>{if(E(n)!==null)return"\\log";let[t,i]=b(n);return i===void 0?"\\log"+e.wrapArguments(n):v(["\\log_{",e.serialize(i),"}",e.wrap(t)])}},{kind:"function",symbolTrigger:"log",parse:e=>ro("Log",e)},{name:"LCM",latexTrigger:["\\lcm"],kind:"function"},{symbolTrigger:"lcm",kind:"function",parse:"LCM"},{symbolTrigger:"LCM",kind:"function",parse:"LCM"},{symbolTrigger:"max",kind:"function",parse:"Max",arguments:"implicit"},{symbolTrigger:"min",kind:"function",parse:"Min",arguments:"implicit"},{name:"Max",latexTrigger:"\\max",kind:"function",arguments:"implicit"},{name:"Min",latexTrigger:"\\min",kind:"function",arguments:"implicit"},{name:"Supremum",latexTrigger:"\\sup",kind:"function",arguments:"implicit"},{name:"Infimum",latexTrigger:"\\inf",kind:"function",arguments:"implicit"},{name:"Limit",latexTrigger:"\\lim",kind:"expression",parse:e=>{let n=e._diagnosticsCheckpoint();if(!e.match("_"))return null;let t=e.index,i=e.parseGroup(),r=e.index;if(g(i)!=="To")return null;let s=e.parseExpression({minPrec:V});if(!s)return null;let o=E(d(i,1));o&&e._pruneUndeclared([o],n,r,[[t,r]]);let a=d(i,2),u;g(a)==="PseudoInverse"&&P(a)===1?(u=1,a=d(a,1)):g(a)==="Superminus"&&P(a)===1&&(u=-1,a=d(a,1));let l=["Function",s,d(i,1)];return u===void 0?["Limit",l,a]:["Limit",l,a,u]},serialize:(e,n)=>{let t=d(n,1),i=d(t,2),r=d(n,2),s=M(d(n,3)),o=s===1?"^{+}":s===-1?"^{-}":"";return v(["\\lim_{",e.serialize(i),"\\to",e.serialize(r)+o,"}",e.serialize(d(t,1))])}},{name:"MinusPlus",latexTrigger:["\\mp"],kind:"infix",associativity:"any",precedence:He},{latexTrigger:["\u2213"],kind:"infix",associativity:"any",precedence:He,parse:"MinusPlus"},{name:"Multiply",latexTrigger:["\\times"],kind:"infix",associativity:"any",precedence:V,serialize:_d},{latexTrigger:["\\cdot"],kind:"infix",associativity:"any",precedence:V,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:V+2});return i===null?null:hd(e,n,i)}},{latexTrigger:["\xD7"],kind:"infix",associativity:"any",precedence:V,parse:"Multiply"},{latexTrigger:["\xB7"],kind:"infix",associativity:"any",precedence:V,parse:"Multiply"},{name:"CirclePlus",latexTrigger:["\\oplus"],kind:"infix",associativity:"any",precedence:q},{latexTrigger:["\u2295"],kind:"infix",associativity:"any",precedence:q,parse:"CirclePlus"},{name:"CircleMinus",latexTrigger:["\\ominus"],kind:"infix",precedence:q},{latexTrigger:["\u2296"],kind:"infix",precedence:q,parse:"CircleMinus"},{name:"CircleTimes",latexTrigger:["\\otimes"],kind:"infix",associativity:"any",precedence:V},{latexTrigger:["\u2297"],kind:"infix",associativity:"any",precedence:V,parse:"CircleTimes"},{name:"CircleDot",latexTrigger:["\\odot"],kind:"infix",associativity:"any",precedence:V},{latexTrigger:["\u2299"],kind:"infix",associativity:"any",precedence:V,parse:"CircleDot"},{name:"CircledAst",latexTrigger:["\\circledast"],kind:"infix",associativity:"any",precedence:V},{latexTrigger:["\u229B"],kind:"infix",associativity:"any",precedence:V,parse:"CircledAst"},{name:"Star",latexTrigger:["\\star"],kind:"infix",associativity:"any",precedence:V},{latexTrigger:["\u22C6"],kind:"infix",associativity:"any",precedence:V,parse:"Star"},{latexTrigger:["\u22C5"],kind:"infix",associativity:"any",precedence:V,parse:"Multiply"},{latexTrigger:["*"],kind:"infix",associativity:"any",precedence:V,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:V+2});return i===null?["Multiply",n,Ti]:hd(e,n,i)}},{name:"Mod",latexTrigger:"\\bmod",kind:"infix",precedence:W,serialize:(e,n)=>{if(P(n)!==2)return"";let t=!!e.options.invisibleMultiply,i=a=>{if(t&&g(a)==="Multiply"){let[,u]=Md(a);if(!(e.options.prettify===!0&&u.length>0&&!(u.length===1&&u[0]===1)))return e.wrap(a,V+1)}return e.wrap(a,V)},r=d(n,1),s=g(r)==="Mod"?e.wrap(r,W+1):i(r),o=i(d(n,2));return v([s,"\\bmod",o])}},{latexTrigger:"\\mod",kind:"infix",precedence:W,parse:"Mod"},{latexTrigger:"\\operatorname{mod}",kind:"function",parse:"Mod"},{latexTrigger:["\\mod"],kind:"function",parse:"Mod"},{latexTrigger:"\\pmod",kind:"prefix",precedence:w,parse:e=>{let n=e.parseGroup()??e.parseToken();return["Mod",e.error("missing",e.index),O(n)]}},{name:"Congruent",serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=e.serialize(d(n,2));if(d(n,3)===null)return v([t,"\\equiv",i]);let r=e.serialize(d(n,3));return v([t,"\\equiv",i,"\\pmod{",r,"}"])}},{name:"Negate",latexTrigger:["-"],kind:"prefix",precedence:yi+1,parse:(e,n)=>{e.skipSpace();let t=e.parseExpression({...n,minPrec:yi+3});return t===null?null:["Negate",t]}},{kind:"matchfix",openTrigger:"||",closeTrigger:"||",parse:(e,n)=>F(n)?null:["Norm",n]},{name:"Norm",kind:"matchfix",openTrigger:["\\left","\\Vert"],closeTrigger:["\\right","\\Vert"],parse:(e,n)=>F(n)?null:["Norm",n],serialize:(e,n)=>{let t=d(n,1),i=gb(e,d(n,2));if(g(t)==="Matrix"){let r=d(t,1),s=d(t,2),o=s?["Matrix",r,{str:"\u2016\u2016"},s]:["Matrix",r,{str:"\u2016\u2016"}];return e.serialize(o)+i}return`\\left\\Vert ${e.serialize(t)}\\right\\Vert${i}`}},{name:"Measurement",latexTrigger:["\\pm"],kind:"infix",associativity:"any",precedence:He,serialize:yb},{latexTrigger:["\\pm"],kind:"prefix",precedence:He,parse:(e,n)=>{let t=e.parseExpression({...n,minPrec:400});return["Measurement",0,O(t)]}},{latexTrigger:["\\plusmn"],kind:"infix",associativity:"any",precedence:He,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:400});return["Measurement",n,O(i)]}},{latexTrigger:["\\plusmn"],kind:"prefix",precedence:He,parse:(e,n)=>{let t=e.parseExpression({...n,minPrec:400});return["Measurement",0,O(t)]}},{latexTrigger:["\xB1"],kind:"infix",associativity:"any",precedence:He,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:400});return["Measurement",n,O(i)]}},{latexTrigger:["\xB1"],kind:"prefix",precedence:He,parse:(e,n)=>{let t=e.parseExpression({...n,minPrec:400});return["Measurement",0,O(t)]}},{name:"Power",latexTrigger:["^"],kind:"infix",serialize:mu},{latexTrigger:"\\prod",precedence:V,name:"Product",parse:Td("Product",V),serialize:vd("\\prod")},{latexTrigger:["*","*"],kind:"infix",associativity:"right",precedence:yi,parse:(e,n,t)=>{if(e.options.strict!==!1)return null;let i=e.parseExpression({...t,minPrec:yi});return i===null?null:["Power",n,i]}},{name:"Rational",precedence:W,serialize:(e,n)=>n&&P(n)===1?"\\operatorname{Rational}"+e.wrapArguments(n):xd(e,n)},{name:"Reduce",serialize:(e,n)=>{let t=d(n,1);if(!t)return"";let i=d(n,2);return E(i)==="Add"?`\\sum ${e.serialize(t)}`:E(i)==="Multiply"?`\\prod ${e.serialize(t)}`:`\\operatorname{Reduce}\\left(${e.serialize(t)}, ${e.serialize(d(n,2))}\\right)`}},{name:"Root",serialize:mu},{name:"Round",symbolTrigger:"round",kind:"function"},{name:"Square",precedence:720,serialize:(e,n)=>{let t=e.wrapShort(d(n,1));return(t.startsWith("-")?e.wrapString(t,"normal"):t)+"^2"}},{latexTrigger:["\\sum"],precedence:q,name:"Sum",parse:Td("Sum",V),serialize:vd("\\sum")},{name:"Heaviside",symbolTrigger:"Heaviside",kind:"function"},{name:"Sign",symbolTrigger:"sgn",kind:"function"},{symbolTrigger:"sign",kind:"function",parse:"Sign"},{latexTrigger:["\\sign"],kind:"function",parse:"Sign"},{name:"Sqrt",latexTrigger:["\\sqrt"],parse:pd,serialize:mu},{latexTrigger:["\u221A"],parse:pd},{latexTrigger:["\xBD"],parse:()=>["Rational",1,2]},{latexTrigger:["\u2153"],parse:()=>["Rational",1,3]},{latexTrigger:["\xBC"],parse:()=>["Rational",1,4]},{latexTrigger:["\xBE"],parse:()=>["Rational",3,4]},{latexTrigger:["\u2154"],parse:()=>["Rational",2,3]},{name:"Subtract",latexTrigger:["-"],kind:"infix",associativity:"left",precedence:q+2,parse:(e,n,t)=>{let i=e.parseExpression({...t,minPrec:q+3});return i===null?null:["Subtract",n,i]},serialize:(e,n)=>{let t=e.wrap(d(n,1),q+2),i=e.wrap(d(n,2),q+3);return i.startsWith("-")&&(i=e.wrapString(i,"normal")),v([t,"-",i])}},{name:"Distance",latexTrigger:["\\operatorname{distance}"],kind:"function",serialize:(e,n)=>"\\operatorname{distance}"+e.wrapArguments(n)}];function kb(e,n){if(e!==null){if(E(e))return{index:E(e)??"Nothing",upper:n};if(Ye(e))return{index:"Nothing",lower:e,upper:n};if(g(e)==="GreaterEqual"){let t=E(d(e,1))??"Nothing",i=d(e,2)??1;return{index:t,lower:i,upper:n}}if(g(e)==="LessEqual"){let t=b(e)??[];if(t.length===3)return{index:E(t[1])??"Nothing",lower:t[0],upper:t[2]};if(t.length===2){if(E(t[0]))return{index:E(t[0]),upper:t[1]};if(E(t[1]))return{index:E(t[1]),lower:t[0],upper:n}}}if(g(e)==="Equal"){let t=E(d(e,1))??"Nothing",i=d(e,2);if(g(i)==="Range"){let s=d(i,1)??1,o=d(i,2)??void 0;return{index:t,lower:s,upper:o}}return{index:t,lower:i??1,upper:n}}if(g(e)==="Element")return{index:E(d(e,1))??"Nothing",element:e}}}function Mb(e){let n=g(e);return n?new Set(["Less","LessEqual","Greater","GreaterEqual","NotEqual","And","Or","Not"]).has(n):!1}function Ed(e){if(e===null)return[];let n=En(e);if(n)return[...n];if(g(e)==="Tuple"){let t=b(e);return t?[...t]:[e]}return[e]}function wb(e,n){F(e)&&(e=null),F(n)&&(n=null);let t=Ed(e),i=Ed(n),r=[],s=0;for(;s<t.length;){let o=t[s],a=kb(o,i[s]);if(a){if(a.element&&s+1<t.length){let u=t[s+1];if(Mb(u)&&g(u)!=="Element"&&g(u)!=="Equal"){let l=a.element;if(Array.isArray(l)&&l.length>=3){let c=[l[0],...l.slice(1),u];a.element=c}s++}}r.push(a)}s++}return r}function Ab(e){let n=new Set;for(let t of e)if(t.index&&t.index!=="Nothing"&&n.add(t.index),t.element){let i=E(d(t.element,1));i&&n.add(i)}return n}function Td(e,n){return t=>{t.skipSpace();let i=t._diagnosticsCheckpoint();t.pushSymbolTable();let r=null,s=null,o=-1,a=-1;for(;!(s&&r)&&(t.peek==="_"||t.peek==="^");)t.match("_")?(o=t.index,s=t.parseGroup()??t.parseToken(),a=t.index):t.match("^")&&(r=t.parseGroup()??t.parseToken()),t.skipSpace();if(!r&&!s){let p=t.parseExpression({minPrec:n});return t.popSymbolTable(),p?[e,p]:null}let u=wb(s,r),l=t.index,c=t.parseExpression({minPrec:n});if(t.popSymbolTable(),t._pruneUndeclared(Ab(u),i,l,o>=0?[[o,a]]:void 0),c===null)return[e];let f=[];for(let p of u){if(p.element){f.push(p.element);continue}let h=p.lower,y=p.upper,N=p.index??"Nothing";y!=null?f.push(["Tuple",N,h??1,y]):h!=null?f.push(["Tuple",N,h]):f.push(["Tuple",N])}return[e,c,...f]}}var Rb=new Set(["Tuple","Triple","Pair","Single","Limits","Element"]);function Nd(e){return e==null||E(e)==="Nothing"?null:e}function _b(e){let n=[],t=b(e);if(t.length<=1)return n;for(let i of t.slice(1)){let r=g(i);if(r&&Rb.has(r)){n.push(i);continue}break}return n}function Pb(e,n){if(g(n)==="Element"){let l=e.serialize(d(n,1)),c=d(n,2),f=du(e,c)??e.serialize(c);return{sub:`${l}\\in ${f}`}}let t=d(n,1);t!==null&&g(t)==="Hold"&&(t=d(t,1));let i=Nd(d(n,2)),r=Nd(d(n,3)),s={},o=t?E(t):null,a=o!==null&&o!=="Nothing",u=a&&t?e.serialize(t):void 0;return a&&i!==null&&u?s.sub=`${u}=${e.serialize(i)}`:a&&u?s.sub=u:i!==null&&(s.sub=e.serialize(i)),r!==null&&(s.sup=e.serialize(r)),s}function vd(e){return(n,t)=>{let i=d(t,1);if(i===null)return e;let r=_b(t),s=e;if(r.length>0){let o=[],a=[];for(let u of r){let l=Pb(n,u);l.sub&&o.push(l.sub),l.sup&&a.push(l.sup)}o.length>0&&(s=xn("_",s,o.join(", "))),a.length>0&&(s=xn("^",s,a.join(", ")))}return v([s,n.wrap(i,V)])}}function yu(e){return e.skipSpace(),e.match("^")?e.parseGroup()??e.parseToken():null}function Db(e){return M(e)===-1?!0:g(e)==="Negate"&&M(d(e,1))===1}function bu(e,n,t){return n===null?e:Db(n)?t():["Power",e,n]}function Sd(e){let n=yu(e),t=e.parseArguments("implicit");return t===null?n===null?"Exp":["Power","Exp",n]:bu(["Exp",...t],n,()=>["Ln",t[0]])}function ro(e,n){let t=null;n.match("_")&&(t=n.parseGroup()??n.parseToken());let i=yu(n),r=n.parseArguments("implicit");if(r===null&&t===null&&i===null)return e;r===null&&(r=[vn]);let s=()=>e==="Ln"?["Exp",r[0]]:["Power",t??10,r[0]],o;return t===null?o=[e,...r]:t===10?o=["Log",r[0]]:t===2?o=["Lb",...r]:o=["Log",r[0],t],bu(o,i,s)}function Id(e){let n=yu(e),t=e.parseArguments("implicit");return t===null&&n===null?"Lg":(t===null&&(t=[vn]),bu(["Log",...t,10],n,()=>["Power",10,t[0]]))}function kd(e){let n=e.parseArguments("implicit");return n===null?"Lb":["Log",n[0],2]}function Li(e){let n=1,t=e;do{e=t;let i=g(e);if(i==="Negate")n*=-1,t=d(e,1);else if(i==="Multiply"){let[r,s]=Li(d(e,1));s<0&&(n*=-1,r===1?t=["Multiply",...b(e).slice(1)]:t=["Multiply",r,...b(e).slice(1)])}else if(i==="Divide"||i==="Rational"){let[r,s]=Li(d(e,1));s<0&&(n*=-1,t=[i,r,d(e,2)])}else{let r=M(e);r!==null&&r<0&&(n*=-1,t=-r)}}while(t!==e);return[e,n]}var Dd=[{name:"Real",kind:"function",latexTrigger:["\\Re"],arguments:"implicit"},{name:"Imaginary",kind:"function",latexTrigger:["\\Im"],arguments:"implicit"},{name:"Argument",kind:"function",latexTrigger:["\\arg"],arguments:"implicit"},{symbolTrigger:"arg",kind:"function",parse:"Argument",arguments:"implicit"},{symbolTrigger:"real",kind:"function",parse:"Real",arguments:"implicit"},{symbolTrigger:"imag",kind:"function",parse:"Imaginary",arguments:"implicit"},{name:"Conjugate",latexTrigger:["^","\\star"],kind:"postfix"}];function k(e){return(n,t)=>{let i={"\\arcsin":"Arcsin","\\arccos":"Arccos","\\arctan":"Arctan","\\arctg":"Arctan","\\arcctg":"Arccot","\\arcsec":"Arcsec","\\arccsc":"Arccsc","\\arsinh":"Arsinh","\\arcsinh":"Arsinh","\\arcosh":"Arcosh","\\arccosh":"Arcosh","\\artanh":"Artanh","\\arctanh":"Artanh","\\arsech":"Arsech","\\arcsech":"Arsech","\\arcsch":"Arcsch","\\arccsch":"Arcsch","\\arcoth":"Arcoth","\\arccoth":"Arcoth","\\ch":"Cosh","\\cos":"Cos","\\cosh":"Cosh","\\cosec":"Csc","\\cot":"Cot","\\cotg":"Cot","\\ctg":"Cot","\\csc":"Csc","\\csch":"Csch","\\coth":"Coth","\\cth":"Coth","\\sec":"Sec","\\sech":"Sech","\\sin":"Sin","\\sinh":"Sinh","\\sh":"Sinh","\\tan":"Tan","\\tg":"Tan","\\tanh":"Tanh","\\th":"Tanh"},r=i[e??""]??e??"";if(n.atTerminator(t))return r;let s=r;do{let f=n.parsePostfixOperator(s,t);if(f===null)break;s=f}while(!0);n.skipSpace();let o=null;n.match("^")&&(o=n.parseGroup()??n.parseToken()),n.skipSpace();let a=n.parseArguments("implicit",{minPrec:V,condition:f=>i[f.peek]!==void 0||(t?.condition?.(f)??!1)});a===null&&o!==null&&(a=[vn]);let l=a?.length===2&&(s==="Arctan"||Array.isArray(s)&&s[0]==="InverseFunction"&&s[1]==="Tan")?"Arctan2":s,c=a===null?s:typeof l=="string"?[l,...a]:["Apply",l,...a];return o===null?c:["Power",c,o]}}var Cd=[{name:"Arcsin",standaloneSymbol:!0,latexTrigger:["\\arcsin"],parse:k("Arcsin")},{name:"Arccos",standaloneSymbol:!0,latexTrigger:["\\arccos"],parse:k("Arccos")},{name:"Arctan",standaloneSymbol:!0,latexTrigger:["\\arctan"],parse:k("Arctan")},{name:"Arctan2",serialize:(e,n)=>`\\arctan(${e.serialize(d(n,1))}, ${e.serialize(d(n,2))})`},{latexTrigger:["\\arctg"],parse:k("Arctan")},{symbolTrigger:"arctg",parse:k("Arctan")},{name:"Arccot",standaloneSymbol:!0,symbolTrigger:"arcctg",parse:k("Arccot")},{latexTrigger:["\\arcctg"],parse:k("Arccot")},{name:"Arcoth",standaloneSymbol:!0,symbolTrigger:"arcoth",parse:k("Arcoth")},{symbolTrigger:"arccoth",parse:k("Arcoth")},{latexTrigger:["\\arcoth"],parse:k("Arcoth")},{latexTrigger:["\\arccoth"],parse:k("Arcoth")},{name:"Arcsec",symbolTrigger:"arcsec",parse:k("Arcsec")},{latexTrigger:["\\arcsec"],parse:k("Arcsec")},{name:"Arccsc",standaloneSymbol:!0,symbolTrigger:"arccsc",parse:k("Arccsc")},{latexTrigger:["\\arccsc"],parse:k("Arccsc")},{name:"Arsinh",standaloneSymbol:!0,symbolTrigger:"arsinh",parse:k("Arsinh")},{symbolTrigger:"arcsinh",parse:k("Arsinh")},{latexTrigger:["\\arsinh"],parse:k("Arsinh")},{latexTrigger:["\\arcsinh"],parse:k("Arsinh")},{name:"Arcosh",standaloneSymbol:!0,symbolTrigger:"arcosh",parse:k("Arcosh")},{symbolTrigger:"arccosh",parse:k("Arcosh")},{latexTrigger:"\\arcosh",parse:k("Arcosh")},{latexTrigger:"\\arccosh",parse:k("Arcosh")},{name:"Artanh",standaloneSymbol:!0,symbolTrigger:"artanh",parse:k("Artanh")},{symbolTrigger:"arctanh",parse:k("Artanh")},{latexTrigger:"\\artanh",parse:k("Artanh")},{latexTrigger:["\\arctanh"],parse:k("Artanh")},{name:"Arsech",standaloneSymbol:!0,symbolTrigger:"arsech",parse:k("Arsech")},{symbolTrigger:"arcsech",parse:k("Arsech")},{latexTrigger:["\\arsech"],parse:k("Arsech")},{latexTrigger:["\\arcsech"],parse:k("Arsech")},{name:"Arcsch",standaloneSymbol:!0,symbolTrigger:"arcsch",parse:k("Arcsch")},{symbolTrigger:"arccsch",parse:k("Arcsch")},{latexTrigger:["\\arcsch"],parse:k("Arcsch")},{latexTrigger:["\\arccsch"],parse:k("Arcsch")},{name:"Cosec",standaloneSymbol:!0,symbolTrigger:"cosec",parse:k("Cosec")},{latexTrigger:["\\cosec"],parse:k("Cosec")},{name:"Cosh",standaloneSymbol:!0,latexTrigger:["\\cosh"],parse:k("Cosh")},{latexTrigger:["\\ch"],parse:k("Cosh")},{name:"Cot",standaloneSymbol:!0,latexTrigger:["\\cot"],parse:k("Cot")},{latexTrigger:["\\cotg"],parse:k("Cot")},{latexTrigger:["\\ctg"],parse:k("Cot")},{name:"Csc",standaloneSymbol:!0,latexTrigger:["\\csc"],parse:k("Csc")},{name:"Csch",standaloneSymbol:!0,latexTrigger:["\\csch"],parse:k("Csch")},{symbolTrigger:"csch",parse:k("Csch")},{name:"Coth",standaloneSymbol:!0,latexTrigger:["\\coth"],parse:k("Coth")},{latexTrigger:["\\cth"],parse:k("Coth")},{symbolTrigger:"cth",parse:k("Coth")},{latexTrigger:["\\coth"],parse:k("Coth")},{name:"Sec",standaloneSymbol:!0,latexTrigger:["\\sec"],parse:k("Sec")},{name:"Sech",standaloneSymbol:!0,symbolTrigger:"sech",parse:k("Sech")},{latexTrigger:["\\sech"],parse:k("Sech")},{name:"Sinh",standaloneSymbol:!0,latexTrigger:["\\sinh"],parse:k("Sinh")},{latexTrigger:["\\sh"],parse:k("Sinh")},{name:"Tan",standaloneSymbol:!0,latexTrigger:["\\tan"],parse:k("Tan")},{latexTrigger:["\\tg"],parse:k("Tan")},{name:"Tanh",standaloneSymbol:!0,latexTrigger:["\\tanh"],parse:k("Tanh")},{latexTrigger:["\\th"],parse:k("Tanh")},{name:"Cos",standaloneSymbol:!0,latexTrigger:["\\cos"],parse:k("Cos")},{name:"Sin",standaloneSymbol:!0,latexTrigger:["\\sin"],parse:k("Sin")},{name:"Sinc",symbolTrigger:"sinc",kind:"function"},{name:"FresnelS",symbolTrigger:"FresnelS",kind:"function"},{name:"FresnelC",symbolTrigger:"FresnelC",kind:"function"},{symbolTrigger:"sin",parse:k("Sin")},{symbolTrigger:"cos",parse:k("Cos")},{symbolTrigger:"tan",parse:k("Tan")},{symbolTrigger:"sec",parse:k("Sec")},{symbolTrigger:"csc",parse:k("Csc")},{symbolTrigger:"cot",parse:k("Cot")},{symbolTrigger:"sinh",parse:k("Sinh")},{symbolTrigger:"cosh",parse:k("Cosh")},{symbolTrigger:"tanh",parse:k("Tanh")},{symbolTrigger:"coth",parse:k("Coth")},{symbolTrigger:"arcsin",parse:k("Arcsin")},{symbolTrigger:"asin",parse:k("Arcsin")},{symbolTrigger:"arccos",parse:k("Arccos")},{symbolTrigger:"acos",parse:k("Arccos")},{symbolTrigger:"arctan",parse:k("Arctan")},{symbolTrigger:"atan",parse:k("Arctan")},{symbolTrigger:"asinh",parse:k("Arsinh")},{symbolTrigger:"acosh",parse:k("Arcosh")},{symbolTrigger:"atanh",parse:k("Artanh")}];function Ot(e,n=1){return t=>{let i=t._diagnosticsCheckpoint();t.skipVisualSpace(),t.match("\\limits"),t.skipSpace();let r=null,s=null;for(;!(s!==null&&r!==null)&&(t.peek==="_"||t.peek==="^");)t.match("_")?s=t.parseGroup()??t.parseToken():t.match("^")&&(r=t.parseGroup()??t.parseToken()),t.skipSpace();F(s)&&(s=null),F(r)&&(r=null);let o=[s??"Nothing"],a=[r??"Nothing"];t.skipVisualSpace();let u=t.index,[l,c]=Cb(t,n);if(l&&c.length===0){if(g(l)==="Add"||g(l)==="Subtract"){let f=[],p=[];for(let h of b(l))if(c)p.push(h);else{let y;[y,c]=In(h),f.push(y??h)}if(c!==null&&p.length>0)return["Add",Od(e,["Add",...f],{indexes:c,subs:o,sups:a})??"Nothing",...p]}else if(g(l)==="Divide"){let f;[f,c]=In(d(l,1)),f!==null&&c!==null&&(l=["Divide",f,d(l,2)])}}return c.length>0&&t._pruneUndeclared(c,i,u),Od(e,l,{indexes:c,subs:o,sups:a})}}function Od(e,n,t){if(!n)return null;if(t.sups.length===0&&t.subs.length===0)return[e,n,...t.indexes];let i=t.indexes.length===0?g(n)==="Function"?b(n).slice(1):[]:t.indexes,r=Math.max(t.sups.length,t.subs.length,i.length);if(i.length===0)for(let o=0;o<r;o++)i.push("Nothing");else if(i.length!==r)for(let o=i.length;o<r;o++)i.push(["Error","'missing'"]);if(t.subs.length!==r)for(let o=t.subs.length;o<r;o++)t.subs.push("Nothing");if(t.sups.length!==r)for(let o=t.sups.length;o<r;o++)t.sups.push("Nothing");let s=i.map((o,a)=>{let u=t.sups[a],l=t.subs[a];return l==="Nothing"&&u==="Nothing"?o:["Tuple",o,l,u]});return[e,n,...s]}function Cb(e,n=1){let t=!1,i=e.parseExpression({minPrec:266,condition:()=>{let r=e.index;return t=Jd(e),e.index=r,t}});return i!==null&&!t?In(i):[i,Ob(e,n)]}function Ob(e,n){let t=[];for(;t.length<n&&Jd(e);){e.skipVisualSpace();let i=E(e.parseSymbol());if(i===null)return t;t.push(i)}return t}function In(e){let n=g(e),t=d(e,1);if(t===null)return[e,[]];if(n==="Sequence"&&P(e)===1)return In(t);if(n==="Multiply"||n==="InvisibleOperator"){let i=b(e);if(i){let[r,s]=Fb(i);return r.length>0?[[n,...r],s]:[null,s]}}else if(n==="Delimiter"){let[i,r]=In(t);if(r)return i===null?[null,r]:[["Delimiter",["Sequence",i],...b(e).slice(1)],r]}else if(n==="Add"){let i=b(e);if(i.length>0){let[r,s]=In(i[i.length-1]);if(s.length>0){if(r)return[["Add",...i.slice(0,-1),r],s];if(i.length>2)return[["Add",...i.slice(0,-1)],s];if(i.length>2)return[i[0],s]}}}else if(n==="Negate"){let[i,r]=In(t);if(r.length>0)return[i?["Negate",i]:null,r]}else if(n==="Divide"){let[i,r]=In(t);if(r.length>0)return[["Divide",i??1,d(e,2)],r]}else{let i=b(e);if(i.length===1){let[r,s]=In(i[0]);if(s.length>0)return[[g(e),r],s]}}return[e,[]]}function Bd(e){return(n,t)=>{if(d(t,1)===null)return e;let i=d(t,1),r=[];g(i)==="BuiltInFunction"?(r=["x"],i=[d(i,1),"x"]):g(i)==="Function"?(r=b(i).slice(1),i=d(i,1)):E(i)?r=[]:r=[];let s=b(t).slice(1),o=[],a=s.map((c,f)=>{if(E(c)==="Nothing")return o.push(E(r[f])??"Nothing"),"";if(E(c))return o.push(E(c)??"Nothing"),"";let p=g(c);if(p==="Tuple"||p==="Triple"||p==="Pair"||p==="Limits"||p==="Range"){if(P(c)===3){let h=d(c,1);o.push(E(h)??"Nothing");let y=d(c,2),N=d(c,3);return E(y)==="Nothing"&&(y=null),E(N)==="Nothing"&&(N=null),y!==null&&N!==null?`_{${n.serialize(y)}}^{${n.serialize(N)}}`:y!==null?`_{${n.serialize(y)}}`:N!==null?`^{${n.serialize(N)}}`:""}return`_{${n.serialize(c)}}`}if(P(c)===2){if(E(d(c,1))){o.push(E(d(c,1))??"Nothing");let N=d(c,2);return E(N)==="Nothing"?"":`_{${n.serialize(N)}}`}o.push(E(r[f])??"Nothing");let h=d(c,1),y=d(c,2);if(E(h)==="Nothing"&&(h=null),E(y)==="Nothing"&&(y=null),h!==null&&y!==null)return`_{${n.serialize(h)}}^{${n.serialize(y)}}`;if(h!==null)return`_{${n.serialize(h)}}`;if(y!==null)return`^{${n.serialize(y)}}`}else o.push(E(r[f])??"Nothing")}),u=o.filter(c=>E(c)!=="Nothing").map(c=>`\\mathrm{d}${n.serialize(E(c)??"x")}`);if(u.length>0&&(u=["\\,",...u]),a.length===0)return`${e}\\,${n.serialize(i)}\\!${u.join(" ")}`;let l=Bb(e,a);return l!==null?l+"\\!"+n.serialize(i)+u.join(" "):a.reverse().map(c=>`${e}${c}`).join("")+"\\!"+n.serialize(i)+u.join(" ")}}function Bb(e,n){let t=n.length;if(t!==2&&t!==3)return null;let r={"\\int":["\\iint","\\iiint"],"\\oint":["\\oiint","\\oiiint"]}[e];return!r||n.slice(1).some(s=>s)?null:r[t-2]+(n[0]??"")}var Vd=[{kind:"expression",name:"Integrate",latexTrigger:["\\int"],parse:Ot("Integrate"),serialize:Bd("\\int")},{kind:"expression",latexTrigger:["\\iint"],parse:Ot("Integrate",2)},{kind:"expression",latexTrigger:["\\iiint"],parse:Ot("Integrate",3)},{kind:"expression",name:"CircularIntegrate",latexTrigger:["\\oint"],parse:Ot("CircularIntegrate"),serialize:Bd("\\oint")},{kind:"expression",latexTrigger:["\\oiint"],parse:Ot("CircularIntegrate",2)},{kind:"expression",latexTrigger:["\\oiiint"],parse:Ot("CircularIntegrate",3)},{kind:"expression",name:"Series",serialize:(e,n)=>"\\operatorname{Series}"+e.wrapArguments(n)},{kind:"expression",name:"Normal",serialize:(e,n)=>"\\operatorname{Normal}"+e.wrapArguments(n)},{kind:"expression",name:"InterpolatingFunction",serialize:(e,n)=>{let t=d(n,1),i="";if(g(t)==="List"&&P(t)>0){let o=b(t),a=o[0],u=o[o.length-1],l=h=>typeof h=="number"?h:h!==null&&typeof h=="object"&&"num"in h?parseFloat(h.num):null,c=l(d(a,1)),f=l(d(u,1)),p=l(d(u,2));if(c!==null&&f!==null&&p!==null){let h=y=>e.serialize(Math.round(y*1e6)/1e6);i=`\\left[${h(c)}, ${h(f+p)}\\right]`}}let r=P(n)>1?d(n,2):null,s=r===null?"":`\\left(${e.serialize(r)}\\right)`;return`\\operatorname{InterpolatingFunction}_{${i}}${s}`}},{kind:"expression",name:"BigO",latexTrigger:["\\mathcal","<{>","O","<}>"],parse:Fd,serialize:(e,n)=>"O\\left("+e.serialize(d(n,1))+"\\right)"},{kind:"expression",latexTrigger:["\\operatorname","<{>","O","<}>"],parse:Fd},{kind:"expression",latexTrigger:["\\mathrm","<{>","D","<}>"],parse:e=>Ld(e,"D_upright")},{kind:"expression",latexTrigger:["\\operatorname","<{>","D","<}>"],parse:e=>Ld(e,"D")}];function Fd(e){let n=e.parseArguments();return n===null?"BigO":["BigO",...n]}function Ld(e,n){let t=e.parseArguments();return t===null||t.length===0?n:["D",...t]}function Jd(e){let n=e.index;for(;e.match("\\cdot")||e.skipVisualSpace(););return e.matchAll(["\\mathrm","<{>","d","<}>"])||e.matchAll(["\\operatorname","<{>","d","<}>"])||e.match("d")||e.match("\\differentialD")?!0:(e.index=n,!1)}function Fb(e){let n=[...e],t=[];for(;n.length>0;){let i;if([n,i]=Lb(n),!i)break;t.push(i)}return[n,t]}function Lb(e){if(e.length<2)return[e,""];let n=e[e.length-2];if(n==="d"||n==="d_upright"){let t=E(e[e.length-1]);if(t)return[e.slice(0,-2),t]}return[e,""]}var Vb=new Set(["Integers","RationalNumbers","RealNumbers","ComplexNumbers","NonNegativeIntegers","AlgebraicNumbers","TranscendentalNumbers","ImaginaryNumbers","ExtendedRealNumbers","ExtendedIntegers","ExtendedRationalNumbers","ExtendedComplexNumbers"]),jd={Integers:"PositiveIntegers",NonNegativeIntegers:"PositiveIntegers",RealNumbers:"PositiveNumbers",ComplexNumbers:"UpperHalfPlane"},$d=[{name:"Matrix",serialize:(e,n)=>{let t=b(d(n,1));return xu(e,t,_(d(n,2)),_(d(n,3)))}},{name:"Vector",serialize:(e,n)=>{let t=b(n);return xu(e,t.map(i=>["List",i]),_(d(n,2)),_(d(n,3)))}},{kind:"environment",symbolTrigger:"pmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:"()"},{str:n}]:[t,i]}},{kind:"environment",symbolTrigger:"bmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:"[]"},{str:n}]:[t,i,{str:"[]"}]}},{kind:"environment",symbolTrigger:"Bmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:"{}"},{str:n}]:[t,i,{str:"{}"}]}},{kind:"environment",symbolTrigger:"vmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?["Determinant",[t,i,{str:n}]]:["Determinant",[t,i]]}},{kind:"environment",symbolTrigger:"Vmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?["Norm",[t,i,{str:n}]]:["Norm",[t,i]]}},{kind:"environment",symbolTrigger:"smallmatrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:"()"},{str:n}]:[t,i]}},{kind:"environment",symbolTrigger:"array",parse:e=>{let n=Mn(e,!1),[t,i]=kn(e);return n?[t,i,{str:".."},{str:n}]:[t,i,{str:".."}]}},{kind:"environment",symbolTrigger:"matrix",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:".."},{str:n}]:[t,i,{str:".."}]}},{kind:"environment",symbolTrigger:"matrix*",parse:e=>{let n=Mn(e),[t,i]=kn(e);return n?[t,i,{str:".."},{str:n}]:[t,i,{str:".."}]}},{name:"ConjugateTranspose",kind:"postfix",latexTrigger:["^","\\star"]},{kind:"postfix",latexTrigger:["^","\\H"],parse:"ConjugateTranspose"},{kind:"postfix",latexTrigger:["^","\\dagger"],parse:(e,n)=>["ConjugateTranspose",n]},{kind:"postfix",latexTrigger:["^","\\ast"],parse:(e,n)=>["ConjugateTranspose",n]},{kind:"postfix",latexTrigger:["^","\\top"],parse:(e,n)=>["Transpose",n]},{kind:"postfix",latexTrigger:["^","\\intercal"],parse:(e,n)=>["Transpose",n]},{name:"Transpose",kind:"postfix",latexTrigger:["^","T"]},{name:"PseudoInverse",kind:"postfix",latexTrigger:["^","+"],parse:(e,n)=>{if(typeof n=="string"){if(n in jd)return jd[n];if(Vb.has(n))return null}return["PseudoInverse",n]}},{name:"Inverse",serialize:(e,n)=>e.serialize(d(n,1))+"^{-1}"},{name:"Trace",kind:"function",latexTrigger:"\\tr",arguments:"implicit",serialize:(e,n)=>Bt(e,n,"\\tr")},{symbolTrigger:"tr",kind:"function",parse:"Trace",arguments:"implicit"},{name:"Kernel",kind:"function",latexTrigger:"\\ker",arguments:"implicit",serialize:(e,n)=>Bt(e,n,"\\ker")},{symbolTrigger:"ker",kind:"function",parse:"Kernel",arguments:"implicit"},{name:"Dimension",kind:"function",latexTrigger:"\\dim",arguments:"implicit",serialize:(e,n)=>Bt(e,n,"\\dim")},{symbolTrigger:"dim",kind:"function",parse:"Dimension",arguments:"implicit"},{name:"Degree",kind:"function",latexTrigger:"\\deg",arguments:"implicit",serialize:(e,n)=>Bt(e,n,"\\deg")},{symbolTrigger:"deg",kind:"function",parse:"Degree",arguments:"implicit"},{name:"Hom",kind:"function",latexTrigger:"\\hom",arguments:"implicit",serialize:(e,n)=>Bt(e,n,"\\hom")},{symbolTrigger:"hom",kind:"function",parse:"Hom",arguments:"implicit"},{name:"Determinant",kind:"function",latexTrigger:"\\det",arguments:"implicit",serialize:(e,n)=>{let t=d(n,1);if(g(t)==="Matrix"){let i=b(d(t,1));return xu(e,i,"||",_(d(t,2)))}return Bt(e,n,"\\det")}},{symbolTrigger:"det",kind:"function",parse:"Determinant",arguments:"implicit"},{name:"MatrixMultiply",serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=e.serialize(d(n,2));return`${t} \\cdot ${i}`}},{name:"HadamardProduct",latexTrigger:["\\odot"],kind:"infix",associativity:"any",precedence:V}];function kn(e){let n=e.parseTabular();return n?["Matrix",["List",...n.map(t=>["List",...t])]]:["",null]}function Mn(e,n=!0){let t=e.parseStringGroup(n)?.trim();if(!t)return"";let i="";for(let r of t)r==="c"&&(i+="="),r==="l"&&(i+="<"),r==="r"&&(i+=">"),r==="|"&&(i+="|"),r===":"&&(i+=":");return i}function Bt(e,n,t){if(b(n).length!==1)return`${t}${e.wrapArguments(n)}`;let r=d(n,1),s=e.serialize(r);return typeof r=="string"||typeof r=="number"?`${t} ${s}`:`${t}\\left(${s}\\right)`}function xu(e,n,t,i){t??="()";let[r,s]=["",""];typeof t=="string"&&t.length===2&&([r,s]=t);let o="";if(i)for(let c of i)c==="<"?o+="l":c===">"?o+="r":c==="="?o+="c":c==="|"?o+="|":c===":"&&(o+=":");let a=[];for(let c of n??[]){let f=[];for(let p of b(c))f.push(e.serialize(p));a.push(f.join(" & "))}let u=a.join(`\\\\
8
- `),l=o.length>0?`[${o}]`:"";return r==="("&&s===")"?v(["\\begin{pmatrix}",l,u,"\\end{pmatrix}"]):r==="["&&s==="]"?v(["\\begin{bmatrix}",l,u,"\\end{bmatrix}"]):r==="{"&&s==="}"?v(["\\begin{Bmatrix}",l,u,"\\end{Bmatrix}"]):r==="|"&&s==="|"?v(["\\begin{vmatrix}",l,u,"\\end{vmatrix}"]):r==="\u2016"&&s==="\u2016"?v(["\\begin{Vmatrix}",l,u,"\\end{Vmatrix}"]):r==="{"&&s==="."?v(["\\begin{dcases}",l,u,"\\end{dcases}"]):r==="."&&s==="}"?v(["\\begin{rcases}",l,u,"\\end{rcases}"]):o||r!=="."||s!=="."?v(["\\left",Ks[r]??r,"\\begin{array}",`{${o}}`,u,"\\end{array}","\\right",Ks[s]??s]):v(["\\begin{matrix}",u,"\\end{matrix}"])}var Jb=["NormalDistribution","BinomialDistribution","PoissonDistribution","UniformDistribution","ExponentialDistribution","PDF","CDF","Quantile","GammaRegularized","BetaRegularized","Covariance","PopulationCovariance","Correlation","LinearRegression","PolynomialFit","FindFit","FindRoot"],qd=[...Jb.map(e=>({kind:"expression",name:e,serialize:(n,t)=>`\\operatorname{${e}}`+n.wrapArguments(t)})),{name:"Mean",kind:"function",symbolTrigger:"mean"},{name:"Median",kind:"function",symbolTrigger:"median"},{name:"StandarDeviation",kind:"function",symbolTrigger:"stddev"},{latexTrigger:["\\bar"],kind:"expression",parse:(e,n)=>{let t=e.parseGroup()??e.parseToken();return!t||!E(t)?null:["Mean",t]}},{latexTrigger:"\\operatorname{var}",kind:"function",parse:"Variance"},{latexTrigger:"\\operatorname{cov}",kind:"function",parse:"Covariance"},{latexTrigger:"\\operatorname{corr}",kind:"function",parse:"Correlation"},{symbolTrigger:"erf",kind:"function",parse:"Erf"},{symbolTrigger:"erfc",kind:"function",parse:"Erfc"}];var oo={__proto__:null,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},zd=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"]),ao={__proto__:null,m:{dimension:[1,0,0,0,0,0,0,0],scale:1},kg:{dimension:[0,1,0,0,0,0,0,0],scale:1},g:{dimension:[0,1,0,0,0,0,0,0],scale:.001},s:{dimension:[0,0,1,0,0,0,0,0],scale:1},A:{dimension:[0,0,0,1,0,0,0,0],scale:1},K:{dimension:[0,0,0,0,1,0,0,0],scale:1},mol:{dimension:[0,0,0,0,0,1,0,0],scale:1},cd:{dimension:[0,0,0,0,0,0,1,0],scale:1},Hz:{dimension:[0,0,-1,0,0,0,0,0],scale:1},N:{dimension:[1,1,-2,0,0,0,0,0],scale:1},Pa:{dimension:[-1,1,-2,0,0,0,0,0],scale:1},J:{dimension:[2,1,-2,0,0,0,0,0],scale:1},W:{dimension:[2,1,-3,0,0,0,0,0],scale:1},C:{dimension:[0,0,1,1,0,0,0,0],scale:1},V:{dimension:[2,1,-3,-1,0,0,0,0],scale:1},F:{dimension:[-2,-1,4,2,0,0,0,0],scale:1},ohm:{dimension:[2,1,-3,-2,0,0,0,0],scale:1},S:{dimension:[-2,-1,3,2,0,0,0,0],scale:1},Wb:{dimension:[2,1,-2,-1,0,0,0,0],scale:1},T:{dimension:[0,1,-2,-1,0,0,0,0],scale:1},H:{dimension:[2,1,-2,-2,0,0,0,0],scale:1},lm:{dimension:[0,0,0,0,0,0,1,0],scale:1},lx:{dimension:[-2,0,0,0,0,0,1,0],scale:1},Bq:{dimension:[0,0,-1,0,0,0,0,0],scale:1},Gy:{dimension:[2,0,-2,0,0,0,0,0],scale:1},Sv:{dimension:[2,0,-2,0,0,0,0,0],scale:1},kat:{dimension:[0,0,-1,0,0,1,0,0],scale:1},degC:{dimension:[0,0,0,0,1,0,0,0],scale:1,offset:273.15},degF:{dimension:[0,0,0,0,1,0,0,0],scale:5/9,offset:459.67},min:{dimension:[0,0,1,0,0,0,0,0],scale:60},h:{dimension:[0,0,1,0,0,0,0,0],scale:3600},d:{dimension:[0,0,1,0,0,0,0,0],scale:86400},wk:{dimension:[0,0,1,0,0,0,0,0],scale:604800},ha:{dimension:[2,0,0,0,0,0,0,0],scale:1e4},L:{dimension:[3,0,0,0,0,0,0,0],scale:.001},t:{dimension:[0,1,0,0,0,0,0,0],scale:1e3},eV:{dimension:[2,1,-2,0,0,0,0,0],scale:1602176634e-28},Da:{dimension:[0,1,0,0,0,0,0,0],scale:16605390666e-37},au:{dimension:[1,0,0,0,0,0,0,0],scale:149597870700},deg:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/180},rad:{dimension:[0,0,0,0,0,0,0,0],scale:1},grad:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/200},turn:{dimension:[0,0,0,0,0,0,0,0],scale:2*Math.PI},arcmin:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/10800},arcsec:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/648e3},percent:{dimension:[0,0,0,0,0,0,0,0],scale:.01},ppm:{dimension:[0,0,0,0,0,0,0,0],scale:1e-6},dB:{dimension:[0,0,0,0,0,0,0,0],scale:1},Np:{dimension:[0,0,0,0,0,0,0,0],scale:1},in:{dimension:[1,0,0,0,0,0,0,0],scale:.0254},ft:{dimension:[1,0,0,0,0,0,0,0],scale:.3048},yd:{dimension:[1,0,0,0,0,0,0,0],scale:.9144},mi:{dimension:[1,0,0,0,0,0,0,0],scale:1609.344},lb:{dimension:[0,1,0,0,0,0,0,0],scale:.45359237},oz:{dimension:[0,1,0,0,0,0,0,0],scale:.028349523125},gal:{dimension:[3,0,0,0,0,0,0,0],scale:.003785411784},qt:{dimension:[3,0,0,0,0,0,0,0],scale:.000946352946},pt:{dimension:[3,0,0,0,0,0,0,0],scale:.000473176473},cup:{dimension:[3,0,0,0,0,0,0,0],scale:.0002365882365},atm:{dimension:[-1,1,-2,0,0,0,0,0],scale:101325},bar:{dimension:[-1,1,-2,0,0,0,0,0],scale:1e5},cal:{dimension:[2,1,-2,0,0,0,0,0],scale:4.184},kWh:{dimension:[2,1,-2,0,0,0,0,0],scale:36e5},\u00C5:{dimension:[1,0,0,0,0,0,0,0],scale:1e-10},USD:{dimension:[0,0,0,0,0,0,0,1],scale:1},cent:{dimension:[0,0,0,0,0,0,0,1],scale:.01}};function jb(e){if(e.length>2){let n=e.slice(0,2),t=e.slice(2);if(oo[n]!==void 0&&zd.has(t)){let i=ao[t];if(i)return{prefixScale:oo[n],baseEntry:i}}}if(e.length>1){let n=e.slice(0,1),t=e.slice(1);if(oo[n]!==void 0&&zd.has(t)){let i=ao[t];if(i)return{prefixScale:oo[n],baseEntry:i}}}return null}function $b(e){let n=ao[e];if(n)return n;let t=jb(e);return t?{dimension:t.baseEntry.dimension,scale:t.prefixScale*t.baseEntry.scale}:null}function Eu(e){let n=$b(e);return n?n.dimension:null}var vR=new Map(["N","J","W","Pa","Hz","C","V","F","ohm","S","Wb","T","H","lm","lx","Gy","kat"].map(e=>[ao[e].dimension.join(","),e]));function qb(e){let n=e.indexOf("^");if(n===-1)return e;let t=e.slice(0,n),i=e.slice(n+1),r=parseInt(i,10);return isNaN(r)?e:["Power",t,r]}function Vi(e){if(e=e.trim(),e.length===0)return null;if(e[0]==="("&&e[e.length-1]===")"){let r=0,s=!0;for(let o=0;o<e.length-1;o++)if(e[o]==="("?r++:e[o]===")"&&r--,r===0&&o<e.length-1){s=!1;break}if(s)return Vi(e.slice(1,-1))}let n=-1,t=[],i=0;for(let r=0;r<e.length;r++)e[r]==="("?i++:e[r]===")"?i--:i===0&&(e[r]==="/"&&n===-1?n=r:e[r]==="*"&&t.push(r));if(n!==-1){let r=e.slice(0,n).trim(),s=e.slice(n+1).trim(),o=Vi(r),a=Vi(s);return!o||!a?null:["Divide",o,a]}if(t.length>0){let r=[],s=0;for(let a of t)r.push(e.slice(s,a).trim()),s=a+1;r.push(e.slice(s).trim());let o=r.filter(a=>a.length>0).map(a=>Vi(a));return o.some(a=>a===null)?null:o.length===1?o[0]:["Multiply",...o]}return e[0]==="("?null:qb(e)}function Gd(e){return e=e.trim(),e.length===0?null:/[/*^()]/.test(e)?Vi(e):e}function Wd(e){for(;e.peek==="<space>";)e.nextToken();if(!e.match("<{>"))return null;let n="",t=0;for(;!e.atEnd;){let i=e.peek;if(i==="<}>"&&t===0)return e.nextToken(),n;if(i==="<}>"){t--,e.nextToken();continue}if(i==="<{>"){t++,e.nextToken();continue}if(i==="<space>"){n.length>0&&!n.endsWith(" ")&&(n+=" "),e.nextToken();continue}if(i==="<$>"){n+="$",e.nextToken();continue}if(i==="\\cdot"){n+="*",e.nextToken();continue}if(i==="^"){n+="^",e.nextToken();continue}n+=i,e.nextToken()}return null}var Yd=new Set(["d"]),zb={__proto__:null,inch:"in",inches:"in","in.":"in",foot:"ft",feet:"ft","ft.":"ft",mile:"mi",miles:"mi",yard:"yd",yards:"yd",meter:"m",meters:"m",metre:"m",metres:"m",centimeter:"cm",centimeters:"cm",centimetre:"cm",centimetres:"cm",kilometer:"km",kilometers:"km",kilometre:"km",kilometres:"km",gallon:"gal",gallons:"gal",quart:"qt",quarts:"qt",pint:"pt",pints:"pt",cup:"cup",cups:"cup",liter:"L",liters:"L",litre:"L",litres:"L",ounce:"oz",ounces:"oz",pound:"lb",pounds:"lb",gram:"g",grams:"g",kilogram:"kg",kilograms:"kg",second:"s",seconds:"s",minute:"min",minutes:"min",hour:"h",hours:"h",day:"d",days:"d",week:"wk",weeks:"wk",dollar:"USD",dollars:"USD",$:"USD",cent:"cent",cents:"cent",degree:"deg",degrees:"deg",mph:"mi/h",per:"/"};function Gb(e){return e.replace(/\$|[A-Za-z.]+/g,n=>zb[n]??n)}function Tu(e){if(!e)return null;let n=e.trim();if(n.length===0||Yd.has(n))return null;let t=Gb(n).replace(/\s+/g,"");if(Eu(t)!==null)return t;if(/[/*^]/.test(t))try{let i=Gd(t);if(i!==null&&Nu(i))return i}catch{return null}return null}function Nu(e){if(typeof e=="string")return Eu(e)!==null;if(!Array.isArray(e))return!1;let n=e[0];return n==="Multiply"||n==="Divide"?e.slice(1).every(t=>Nu(t)):n==="Power"?Nu(e[1]):!1}function Ub(e){let n=e.index;if(!e.match("^"))return null;if(e.match("<{>")){let i="";for(;!e.atEnd&&e.peek!=="<}>";)i+=e.peek,e.nextToken();return e.match("<}>")?i:(e.index=n,null)}if(e.atEnd)return e.index=n,null;let t=e.peek;return e.nextToken(),t}var Ud=e=>{let n=e.index,t=Wd(e);if(t===null)return e.index=n,null;let i=e.index;if(!Yd.has(t.trim())){let s=Ub(e);if(s!==null){let o=Tu(`${t}^${s}`);if(o!==null)return["__unit__",o];e.index=i}}let r=Tu(t);return r===null?(e.index=n,null):["__unit__",r]};function at(e){let n=E(e);if(n!==null)return n;if(typeof e=="number")return String(e);let t=g(e);if(!t)return"";if(t==="Divide"){let i=d(e,1),r=d(e,2);return`${at(i)}/${at(r)}`}if(t==="Multiply"){let i=[];if(Array.isArray(e))for(let r=1;r<e.length;r++)i.push(at(e[r]));return i.join("\\cdot ")}if(t==="Power"){let i=d(e,1),r=d(e,2),s=typeof r=="number"?String(r):E(r)??String(r);return`${at(i)}^{${s}}`}if(t==="Square"){let i=d(e,1);return`${at(i)}^{2}`}return""}function Zd(e){let n=e.parseGroup();if(n===null)return null;let t=Xd(e);return t===null?null:["Quantity",n,t]}function Hd(e){return Xd(e)}function Xd(e){let n=e.index,t=Wd(e);if(t===null)return e.index=n,null;let i=Tu(t);return i===null?(e.index=n,null):i}var Kd=[{latexTrigger:"\\mathrm",kind:"expression",parse:Ud},{latexTrigger:"\\text",kind:"expression",parse:Ud},{latexTrigger:"\\qty",parse:Zd},{latexTrigger:"\\SI",parse:Zd},{latexTrigger:"\\unit",parse:Hd},{latexTrigger:"\\si",parse:Hd},{name:"Quantity",serialize:(e,n)=>{let t=d(n,1),i=d(n,2);if(t===null||i===null)return"";let r=E(i),s=r==="deg"||r==="rad"||r==="arcmin"||r==="arcsec",o=e.options;if(s&&(o.dmsFormat||o.angleNormalization&&o.angleNormalization!=="none")){let l=M(t);if(l===null){let f=e.serialize(t),p=at(i);return v([f,"\\,",`\\mathrm{${p}}`])}let c=l;return r==="rad"?c=c*180/Math.PI:r==="arcmin"?c=c/60:r==="arcsec"&&(c=c/3600),o.angleNormalization&&o.angleNormalization!=="none"&&(c=no(c,o.angleNormalization)),o.dmsFormat?to(c):`${c}\xB0`}let a=e.serialize(t);g(t)==="Measurement"&&(a=`\\left(${a}\\right)`);let u=at(i);return v([a,"\\,",`\\mathrm{${u}}`])}}];var Zb=["pt","em","mu","ex","mm","cm","in","bp","sp","dd","cc","pc","nc","nd"];function Qd(e){for(e.skipSpace(),(e.peek==="-"||e.peek==="+")&&e.nextToken();/^[\d.]$/.test(e.peek);)e.nextToken();for(let n of Zb)if(e.matchAll([...n]))return}function Hb(e){return n=>{let t=n.parseGroup();return t===null?[e]:[e,t]}}function xe(e,n){return{name:e,latexTrigger:[n],parse:Hb(e),serialize:(t,i)=>{let r=d(i,1);return r===null?n:`${n}{${t.serialize(r)}}`}}}function Vn(e,n){return(t,i)=>{let r=t.parseExpression({...i??{},minPrec:V});if(r===null||F(r))return n??[e];let s=g(r);return s==="InvisibleOperator"||s==="Multiply"?[e,...b(r)]:[e,r]}}function ep(e){return(n,t)=>{let i=b(t);return i.length===0?e:e+" "+i.map(r=>n.serialize(r)).join("")}}function np(e){return n=>{let t=n.parseGroup()??n.parseToken();if(t===null||F(t))return[e];let i=g(t);return i==="InvisibleOperator"||i==="Multiply"?[e,...b(t)]:[e,t]}}function tp(e){return(n,t)=>{let i=b(t);return e+"{"+i.map(r=>n.serialize(r)).join("")+"}"}}function uo(e){return n=>{let t=n.parseExpression();return t!==null&&!F(t)?["Annotated",t,{dict:{mathStyle:e}}]:"Nothing"}}function an(e){return n=>{let t=n.parseExpression();return t!==null&&!F(t)?["Annotated",t,{dict:{size:e}}]:"Nothing"}}var ip=[{name:"Overscript",latexTrigger:["\\overset"],kind:"infix",precedence:700},{name:"Underscript",latexTrigger:["\\underset"],kind:"infix",precedence:700},{name:"Ring",latexTrigger:["\\circ"],kind:"infix",precedence:265},{name:"StringJoin",latexTrigger:["\\lt","\\gt"],kind:"infix",precedence:780},{name:"Starstar",latexTrigger:["\\star","\\star"],kind:"infix",precedence:780},{name:"PartialDerivative",latexTrigger:["\\partial"],kind:"prefix",parse:e=>{let n=!1,t="Nothing",i="Nothing";for(;!n;)e.skipSpace(),e.match("_")?i=e.parseGroup()??e.parseToken():e.match("^")?t=e.parseGroup()??e.parseToken():n=!0;if(i===null||t===null)return null;if(i!=="Nothing"){let a=En(i)??[i];e.skipSpace();let u=e.parseGroup()??e.parseSymbol()??"Nothing";if(!F(u)){let f=e.parseArguments();f&&(u=[u,...f])}let l=M(t)??1,c=a.length===1&&l>1?Array.from({length:l},()=>a[0]):[...a];return["D",u,...c]}let r=[],s=()=>{e.skipSpace();let o=e.parseGroup()??e.parseSymbol()??"Nothing",a=1;if(g(o)==="Power")a=M(d(o,2))??1,o=d(o,1)??o;else if(e.match("^")){let u=e.parseGroup()??e.parseToken();a=M(u)??1}for(let u=0;u<a;u++)r.push(o)};for(s();e.skipSpace(),!!e.match("\\partial");)s();return r.length===1?["PartialDerivative",r[0],t]:["PartialDerivative",["List",...r],t]},precedence:740},xe("OverBar","\\overline"),xe("UnderBar","\\underline"),xe("OverVector","\\vec"),xe("OverTilde","\\tilde"),xe("OverHat","\\hat"),xe("OverRightArrow","\\overrightarrow"),xe("OverLeftArrow","\\overleftarrow"),xe("OverRightDoubleArrow","\\Overrightarrow"),xe("OverLeftHarpoon","\\overleftharpoon"),xe("OverRightHarpoon","\\overrightharpoon"),xe("OverLeftRightArrow","\\overleftrightarrow"),xe("OverBrace","\\overbrace"),xe("UnderBrace","\\underbrace"),xe("OverLineSegment","\\overlinesegment"),xe("OverGroup","\\overgroup"),{latexTrigger:["\\textcolor"],parse:e=>{let n=e.index,t=e.parseStringGroup(),i=e.parseGroup();return t!==null?i!==null?["Annotated",i,{dict:{color:t}}]:"Nothing":(e.index=n,"Nothing")}},{latexTrigger:["\\colorbox"],parse:e=>{let n=e.index,t=e.parseStringGroup(),i=e.parseGroup();return t!==null?i!==null?["Annotated",i,{dict:{backgroundColor:t}}]:"Nothing":(e.index=n,"Nothing")}},{latexTrigger:["\\boxed"],parse:e=>{let n=e.parseGroup();return n!==null?["Annotated",n,{dict:{border:!0}}]:"Nothing"}},...["\\cancel","\\bcancel","\\xcancel"].map(e=>({latexTrigger:[e],parse:n=>n.parseGroup()??"Nothing"})),{latexTrigger:["\\cancelto"],parse:e=>{let n=e.parseGroup();return e.parseGroup(),n??"Nothing"}},{latexTrigger:["\\textbf"],parse:e=>oe(e,{fontWeight:"bold"})},{latexTrigger:["\\textit"],parse:e=>oe(e,{fontStyle:"italic"})},{latexTrigger:["\\emph"],parse:e=>oe(e,{fontStyle:"italic"})},{latexTrigger:["\\textup"],parse:e=>oe(e,{fontStyle:"normal"})},{latexTrigger:["\\texttt"],parse:e=>oe(e,{fontFamily:"monospace"})},{latexTrigger:["\\textsf"],parse:e=>oe(e,{fontFamily:"sans-serif"})},{latexTrigger:["\\textrm"],parse:e=>oe(e)},{latexTrigger:["\\mbox"],parse:e=>oe(e)},{latexTrigger:["\\displaystyle"],parse:uo("normal")},{latexTrigger:["\\textstyle"],parse:uo("compact")},{latexTrigger:["\\scriptstyle"],parse:uo("script")},{latexTrigger:["\\scriptscriptstyle"],parse:uo("scriptscript")},{latexTrigger:["\\color"],parse:e=>{let n=e.parseStringGroup();if(n!==null){let t=e.parseExpression();if(t!==null&&!F(t))return["Annotated",t,{dict:{color:n}}]}return"Nothing"}},{latexTrigger:["\\tiny"],parse:an(1)},{latexTrigger:["\\scriptsize"],parse:an(2)},{latexTrigger:["\\footnotesize"],parse:an(3)},{latexTrigger:["\\small"],parse:an(4)},{latexTrigger:["\\normalsize"],parse:an(5)},{latexTrigger:["\\large"],parse:an(6)},{latexTrigger:["\\Large"],parse:an(7)},{latexTrigger:["\\LARGE"],parse:an(8)},{latexTrigger:["\\huge"],parse:an(9)},{latexTrigger:["\\Huge"],parse:an(10)},{name:"Annotated",serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=of(d(n,2));if(i==null)return t;let r=_(d(n,1));r!==null&&(i.dict.fontFamily==="monospace"||i.dict.fontFamily==="sans-serif"||i.dict.fontWeight==="bold"||i.dict.fontStyle==="italic"||i.dict.fontStyle==="normal")&&(t=r),i.dict.mathStyle==="normal"?t=v(["{\\displaystyle",t,"}"]):i.dict.mathStyle==="compact"?t=v(["{\\textstyle",t,"}"]):i.dict.mathStyle==="script"?t=v(["{\\scriptstyle",t,"}"]):i.dict.mathStyle==="scriptscript"&&(t=v(["{\\scriptscriptstyle",t,"}"]));let s=i.dict.size;return s!==null&&s>=1&&s<=10&&(t=v(["{",{1:"\\tiny",2:"\\scriptsize",3:"\\footnotesize",4:"\\small",5:"\\normalsize",6:"\\large",7:"\\Large",8:"\\LARGE",9:"\\huge",10:"\\Huge"}[s],t,"}"])),i.dict.fontFamily==="monospace"?t=v(["\\texttt{",t,"}"]):i.dict.fontFamily==="sans-serif"&&(t=v(["\\textsf{",t,"}"])),i.dict.fontWeight==="bold"&&(t=v(["\\textbf{",t,"}"])),i.dict.fontStyle==="italic"?t=v(["\\textit{",t,"}"]):i.dict.fontStyle==="normal"&&(t=v(["\\textup{",t,"}"])),i.dict.color&&(t=v(["\\textcolor{",i.dict.color,"}{",t,"}"])),i.dict.backgroundColor&&(t=v(["\\colorbox{",i.dict.backgroundColor,"}{",t,"}"])),(i.dict.border===!0||i.dict.border==="True")&&(t=v(["\\boxed{",t,"}"])),t}},{latexTrigger:["\\!"],parse:()=>["HorizontalSpacing",-3]},{latexTrigger:["\\ "],parse:()=>["HorizontalSpacing",6]},{latexTrigger:["\\:"],parse:()=>["HorizontalSpacing",4]},{latexTrigger:["\\enskip"],parse:()=>["HorizontalSpacing",9]},{latexTrigger:["\\quad"],parse:()=>["HorizontalSpacing",18]},{latexTrigger:["\\qquad"],parse:()=>["HorizontalSpacing",36]},{latexTrigger:["\\,"],parse:()=>["HorizontalSpacing",3]},{latexTrigger:["\\;"],parse:()=>["HorizontalSpacing",5]},{latexTrigger:["\\enspace"],parse:()=>["HorizontalSpacing",9]},{latexTrigger:["\\hspace"],parse:e=>(e.peek==="*"&&e.nextToken(),e.parseStringGroup(),["HorizontalSpacing",0])},{latexTrigger:["\\hskip"],parse:e=>(Qd(e),["HorizontalSpacing",0])},{latexTrigger:["\\kern"],parse:e=>(Qd(e),["HorizontalSpacing",0])},{latexTrigger:["\\phantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\vphantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\hphantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\placeholder"],parse:e=>(e.parseOptionalGroup(),e.parseGroup()??"Nothing")},{latexTrigger:["\\smash"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\strut"],parse:e=>"Nothing"},{latexTrigger:["\\mathstrut"],parse:e=>"Nothing"},{name:"HorizontalSpacing",serialize:(e,n)=>{if(d(n,2)!==null){let i=_(d(n,2)),r=e.serialize(d(n,1));return i==="bin"?`\\mathbin{${r}}`:i==="op"?`\\mathop{${r}}`:i==="rel"?`\\mathrel{${r}}`:i==="ord"?`\\mathord{${r}}`:i==="open"?`\\mathopen{${r}}`:i==="close"?`\\mathclose{${r}}`:i==="punct"?`\\mathpunct{${r}}`:i==="inner"?`\\mathinner{${r}}`:r}let t=M(d(n,1));return t===null?"":{"-3":"\\!",6:"\\ ",3:"\\,",4:"\\:",5:"\\;",9:"\\enspace",18:"\\quad",36:"\\qquad"}[t]??""}},{latexTrigger:"\\operatorname{count}",kind:"function",parse:"Length"},{latexTrigger:"\\operatorname{length}",kind:"function",parse:"Length"},{latexTrigger:"\\operatorname{nCr}",kind:"function",parse:"Choose"},{latexTrigger:"\\operatorname{nPr}",parse:e=>{let n=e.parseArguments("enclosure");return!n||n.length!==2?null:["Multiply",["Choose",n[0],n[1]],["Factorial",n[1]]]}},{latexTrigger:"\\operatorname{random}",kind:"function",parse:"Random"},{latexTrigger:"\\operatorname{shuffle}",kind:"function",parse:"RandomShuffle"},{latexTrigger:"\\operatorname{repeat}",kind:"function",parse:"Repeat"},{latexTrigger:"\\operatorname{join}",kind:"function",parse:"Join"},{latexTrigger:"\\operatorname{range}",kind:"function",parse:"Range"},{latexTrigger:"\\operatorname{unique}",kind:"function",parse:"Unique"},{latexTrigger:"\\operatorname{sort}",kind:"function",parse:"Sort"},{latexTrigger:"\\operatorname{reverse}",kind:"function",parse:"Reverse"},{latexTrigger:"\\operatorname{total}",kind:"function",parse:"Sum"},{latexTrigger:"\\operatorname{histogram}",kind:"function",parse:"Histogram"},{latexTrigger:"\\operatorname{pdf}",kind:"function",parse:"PDF"},{latexTrigger:"\\operatorname{cdf}",kind:"function",parse:"CDF"},{name:"Triangle",latexTrigger:["\\operatorname{triangle}"],kind:"function",serialize:(e,n)=>"\\operatorname{triangle}"+e.wrapArguments(n)},{name:"GeometricVector",latexTrigger:["\\operatorname{vector}"],kind:"function",serialize:(e,n)=>"\\operatorname{vector}"+e.wrapArguments(n)},{name:"Sphere",latexTrigger:["\\operatorname{sphere}"],kind:"function",serialize:(e,n)=>"\\operatorname{sphere}"+e.wrapArguments(n)},{name:"Segment",latexTrigger:["\\operatorname{segment}"],kind:"function",serialize:(e,n)=>"\\operatorname{segment}"+e.wrapArguments(n)},{name:"Polygon",latexTrigger:["\\operatorname{polygon}"],kind:"function",serialize:(e,n)=>"\\operatorname{polygon}"+e.wrapArguments(n)},{name:"PointList",latexTrigger:["\\operatorname{PointList}"],kind:"function",serialize:(e,n)=>"\\operatorname{PointList}"+e.wrapArguments(n)},{name:"Angle",latexTrigger:["\\angle"],kind:"prefix",precedence:w,parse:Vn("Angle"),serialize:ep("\\angle")},{latexTrigger:["\\varangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\measuredangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\Varangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\u2220"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\u2221"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\triangle"],kind:"prefix",precedence:w,parse:Vn("Triangle")},{name:"Quadrilateral",latexTrigger:["\\square"],kind:"prefix",precedence:w,parse:Vn("Quadrilateral",vn),serialize:ep("\\square")},{name:"Perpendicular",latexTrigger:["\\perp"],kind:"infix",precedence:w},{name:"Parallel",latexTrigger:["\\parallel"],kind:"infix",precedence:w},{name:"Arc",latexTrigger:["\\widehat"],parse:np("Arc"),serialize:tp("\\widehat")},{name:"OverParen",latexTrigger:["\\overparen"],parse:np("OverParen"),serialize:tp("\\overparen")}];var rp=[{name:"Rgb",latexTrigger:["\\operatorname{rgb}"],kind:"function",serialize:(e,n)=>"\\operatorname{rgb}"+e.wrapArguments(n)},{name:"Hsv",latexTrigger:["\\operatorname{hsv}"],kind:"function",serialize:(e,n)=>"\\operatorname{hsv}"+e.wrapArguments(n)},{name:"Hsl",latexTrigger:["\\operatorname{hsl}"],kind:"function",serialize:(e,n)=>"\\operatorname{hsl}"+e.wrapArguments(n)},{name:"Oklab",latexTrigger:["\\operatorname{oklab}"],kind:"function",serialize:(e,n)=>"\\operatorname{oklab}"+e.wrapArguments(n)},{name:"Oklch",latexTrigger:["\\operatorname{oklch}"],kind:"function",serialize:(e,n)=>"\\operatorname{oklch}"+e.wrapArguments(n)},{name:"AsRgb",latexTrigger:["\\operatorname{asRgb}"],kind:"function",serialize:(e,n)=>"\\operatorname{asRgb}"+e.wrapArguments(n)},{name:"AsHsv",latexTrigger:["\\operatorname{asHsv}"],kind:"function",serialize:(e,n)=>"\\operatorname{asHsv}"+e.wrapArguments(n)},{name:"AsHsl",latexTrigger:["\\operatorname{asHsl}"],kind:"function",serialize:(e,n)=>"\\operatorname{asHsl}"+e.wrapArguments(n)},{name:"AsOklab",latexTrigger:["\\operatorname{asOklab}"],kind:"function",serialize:(e,n)=>"\\operatorname{asOklab}"+e.wrapArguments(n)},{name:"AsOklch",latexTrigger:["\\operatorname{asOklch}"],kind:"function",serialize:(e,n)=>"\\operatorname{asOklch}"+e.wrapArguments(n)},{name:"ColorDelta",latexTrigger:["\\operatorname{colorDelta}"],kind:"function",serialize:(e,n)=>"\\operatorname{colorDelta}"+e.wrapArguments(n)}];var Wb=[{name:"Mu0",standaloneSymbol:!0,kind:"symbol",latexTrigger:"\\mu_0"},{name:"VacuumPermittivity",standaloneSymbol:!0,kind:"symbol",latexTrigger:"\\varepsilon_0"}];var Yb=[...Zf,...vf,...ed,...yf,...dd,...et,...Pd,...Dd,...Cd,...Vd,...$d,...qd,...Kd,...ip,...Wb,...rp];var tx=new Set(["Simplify","Expand","ExpandAll","Factor","Together","Distribute","TrigExpand"]);var hP=new Set([...tx,"ReplaceAll"]);var Ji=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]];function Su(e,n){for(;e>=Ji.length;){let t=Ji.length,i=[1],r=Ji[t-1];for(let s=1;s<t;s++)i[s]=r[s-1]+r[s];i[t]=1,Ji.push(i)}return Ji[e][n]}function kx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Mx(t)}function Mx(e){return e.hi<0?{kind:"empty"}:e.lo>=0?T({lo:Math.sqrt(e.lo),hi:Math.sqrt(e.hi)}):{kind:"partial",value:{lo:0,hi:Math.sqrt(e.hi)},domainClipped:"lo"}}function wx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T({lo:t.lo*t.lo,hi:t.hi*t.hi}):t.hi<=0?T({lo:t.hi*t.hi,hi:t.lo*t.lo}):T({lo:0,hi:Math.max(t.lo*t.lo,t.hi*t.hi)})}function up(e,n){return n===0?{lo:1,hi:1}:n===1?e:n%2===0?e.lo>=0?{lo:Math.pow(e.lo,n),hi:Math.pow(e.hi,n)}:e.hi<=0?{lo:Math.pow(e.hi,n),hi:Math.pow(e.lo,n)}:{lo:0,hi:Math.max(Math.pow(e.lo,n),Math.pow(e.hi,n))}:{lo:Math.pow(e.lo,n),hi:Math.pow(e.hi,n)}}function Mu(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;if(Number.isInteger(n)){if(n>=0)return T(up(i,n));{if(ce(i))return{kind:"singular"};let r=up(i,-n);return T({lo:1/r.hi,hi:1/r.lo})}}else return An(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:n>0?{lo:0,hi:Math.pow(i.hi,n)}:{lo:Math.pow(i.hi,n),hi:1/0},domainClipped:"lo"}:n>0?T({lo:Math.pow(i.lo,n),hi:Math.pow(i.hi,n)}):i.lo===0?{kind:"partial",value:{lo:Math.pow(i.hi,n),hi:1/0},domainClipped:"hi"}:T({lo:Math.pow(i.hi,n),hi:Math.pow(i.lo,n)})}function Ax(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(r.lo===r.hi&&Number.isInteger(r.lo))return Mu(i,r.lo);if(i.hi<=0)return i.lo===-1&&i.hi===-1&&Math.floor(r.hi)>Math.floor(r.lo)?T({lo:-1,hi:1}):{kind:"empty"};if(i.lo<=0){let o=i.lo<0,a=[Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)],u=r.lo>=0,l=u?{lo:0,hi:Math.max(...a)}:r.hi>0?{lo:0,hi:1/0}:{lo:Math.min(...a),hi:1/0};return o?{kind:"partial",value:l,domainClipped:"lo"}:u?T(l):{kind:"partial",value:l,domainClipped:"lo"}}let s=[Math.pow(i.lo,r.lo),Math.pow(i.lo,r.hi),Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)];return T({lo:Math.min(...s),hi:Math.max(...s)})}var Rx={lo:1,hi:1};function _x(e,n,t){let i=S(e);if(!Array.isArray(i))return i;let[r]=i;if(t%2!==0&&n<0&&r.lo<0&&r.hi>=0)return{kind:"singular",at:0};let s=co(T(r),t);return n>=0?ct(s,n):Qn(Rx,ct(s,-n))}function Px(e,n){let t=1,i=e,r=n;for(;r>0;){if(r%2===1){let s=t*i;t=Ge(t,i,s)?s:Ee(s)}if(r=Math.floor(r/2),r>0){let s=i*i;i=Ge(i,i,s)?s:Ee(s)}}return t}function Dx(e,n){let t=1,i=e,r=n;for(;r>0;){if(r%2===1){let s=t*i;t=Ge(t,i,s)?s:Ce(s)}if(r=Math.floor(r/2),r>0){let s=i*i;i=Ge(i,i,s)?s:Ce(s)}}return t}function Cx(e,n){let t=e,i=n;for(;i>1e3;)t*=2**1e3,i-=1e3;for(;i<-1e3;)t*=2**-1e3,i+=1e3;return t*2**i}var lp=12;function lo(e,n){if(!(e>0)||!Number.isFinite(e)||n===1)return{lo:e,hi:e};let t=0,i=e;n<=2e3&&(t=Math.round(Math.log2(e)/n),t!==0&&(i=Cx(e,-n*t)));let r=Math.pow(i,1/n),s=r,o=1;for(let l=0;Px(s,n)>i;l++){if(l>=lp){s=0;break}for(let c=0;c<o;c++)s=Ce(s);o+=o}let a=r;o=1;for(let l=0;Dx(a,n)<i;l++){if(l>=lp){a=1/0;break}for(let c=0;c<o;c++)a=Ee(a);o+=o}if(t===0)return{lo:s,hi:a};let u=2**t;return{lo:s*u,hi:a*u}}function cp(e,n){return e<0?-lo(-e,n).hi:lo(e,n).lo}function Iu(e,n){return e<0?-lo(-e,n).lo:lo(e,n).hi}function Ox(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;return!Number.isInteger(n)||n<=0?Mu(T(i),1/n):n%2===0?An(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:{lo:0,hi:Iu(i.hi,n)},domainClipped:"lo"}:T({lo:cp(i.lo,n),hi:Iu(i.hi,n)}):T({lo:cp(i.lo,n),hi:Iu(i.hi,n)})}function Bx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.exp(t.lo),hi:Math.exp(t.hi)})}function Fx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log(t.lo),hi:Math.log(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log(t.hi)},domainClipped:"lo"}}function Lx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log10(t.lo),hi:Math.log10(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log10(t.hi)},domainClipped:"lo"}}function Vx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log2(t.lo),hi:Math.log2(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log2(t.hi)},domainClipped:"lo"}}function Jx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T(t):t.hi<=0?T({lo:-t.hi,hi:-t.lo}):T({lo:0,hi:Math.max(-t.lo,t.hi)})}function jx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?T({lo:i,hi:r}):ie(i+1,"right",{lo:i,hi:r})}function $x(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.ceil(t.lo),r=Math.ceil(t.hi);return i===r?T({lo:i,hi:r}):ie(i,"left",{lo:i,hi:r})}function ut(e){return Number.isNaN(e.lo)||Number.isNaN(e.hi)}var lt={lo:NaN,hi:NaN};function qx(e){return Math.sign(e)*Math.round(Math.abs(e))}function zx(e,n){if(ut(e))return T(lt);let t=n(e.lo),i=n(e.hi);if(t===i)return T({lo:t,hi:i});let r=t+.5;return ie(r,n(r)===t+1?"right":"left",{lo:Math.min(t,i),hi:Math.max(t,i)})}function Gx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return zx(t,qx)}function Ux(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?T({lo:t.lo-i,hi:t.hi-i}):ie(i+1,"right",{lo:0,hi:1})}function Zx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.trunc(t.lo),r=Math.trunc(t.hi);if(i===r)return T({lo:i,hi:r});let s={lo:i,hi:r};if(t.lo>=0)return ie(i+1,"right",s);let o=Math.ceil(t.lo);return o!==0?ie(o,"left",s):ie(1,"right",s)}function Hx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:Math.min(i.lo,r.lo),hi:Math.min(i.hi,r.hi)})}function Wx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:Math.max(i.lo,r.lo),hi:Math.max(i.hi,r.hi)})}function Yx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(ut(i)||ut(r))return T(lt);if(ce(r))return{kind:"singular"};if(i.lo===i.hi&&r.lo===r.hi){let p=i.lo,h=r.lo;if(!Number.isFinite(p)||!Number.isFinite(h))return T(lt);let y=p%h;if(y===0||Math.sign(y)===Math.sign(h))return T({lo:y+0,hi:y+0});let N=y+h,D=N-y,R=y-(N-D)+(h-D);return R===0?T({lo:N,hi:N}):R<0?T({lo:Ce(N),hi:N}):T({lo:N,hi:Ee(N)})}let s=Math.abs(r.lo===r.hi?r.lo:Math.max(Math.abs(r.lo),Math.abs(r.hi))),o=r.hi<0,a=Math.floor(i.lo/s),u=Math.floor(i.hi/s),l=o?{lo:-s,hi:0}:{lo:0,hi:s};if(a!==u)return ie((a+1)*s,"right",l);let c=i.lo-s*a,f=i.hi-s*a;return o?c===0?ie(i.lo,"right",l):T({lo:c-s,hi:f-s}):T({lo:Math.min(c,f),hi:Math.max(c,f)})}function Xx(e,n){return Pc(e,Dc(n,Ft(Ue(e,n))))}function Kx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Number.isNaN(t.lo)||Number.isNaN(t.hi)?T({lo:NaN,hi:NaN}):t.lo>0?T({lo:1,hi:1}):t.hi<0?T({lo:0,hi:0}):t.lo===0&&t.hi===0?T({lo:.5,hi:.5}):t.lo>=0?ie(0,void 0,{lo:.5,hi:1}):t.hi<=0?ie(0,void 0,{lo:0,hi:.5}):ie(0,void 0,{lo:0,hi:1})}function Qx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Number.isNaN(t.lo)||Number.isNaN(t.hi)?T({lo:NaN,hi:NaN}):t.lo>0?T({lo:1,hi:1}):t.hi<0?T({lo:-1,hi:-1}):t.lo===0&&t.hi===0?T({lo:0,hi:0}):t.lo>=0?ie(0,void 0,{lo:0,hi:1}):t.hi<=0?ie(0,void 0,{lo:-1,hi:0}):ie(0,void 0,{lo:-1,hi:1})}var fp=1.4616321449683622,e0=.8856031944108887;function n0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t0(t)}var dp=[-.504083008264455,-1.573498473162391,-2.610720868444145,-3.635293366436901,-4.653163765628266,-5.667162441556885,-6.678418213073426,-7.687788325031709,-8.695764163640956,-9.702672540001863];function mp(e){let t=-Math.floor(e)-1;return t>=0&&t<dp.length?dp[t]:null}function t0(e){if(e.hi>=0&&e.lo<=0)return{kind:"singular",at:0};if(e.lo<0){let n=Math.ceil(e.lo),t=Math.floor(e.hi);if(n<=t)return{kind:"singular",at:n};let i=Ze(e.lo),r=Ze(e.hi),s=Math.min(i,r),o=Math.max(i,r),a=mp(e.lo);if(a!==null){if(a>=e.lo&&a<=e.hi){let u=Ze(a);s=Math.min(s,u),o=Math.max(o,u)}}else Math.floor(e.lo)%2===0?s=Math.min(s,0):o=Math.max(o,0);return T({lo:s,hi:o})}return e.lo>=fp?T({lo:Ze(e.lo),hi:Ze(e.hi)}):e.hi<=fp?T({lo:Ze(e.hi),hi:Ze(e.lo)}):T({lo:e0,hi:Math.max(Ze(e.lo),Ze(e.hi))})}function i0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return r0(t)}function r0(e){if(e.hi>=0&&e.lo<=0)return{kind:"singular",at:0};if(e.lo<0){let n=Math.ceil(e.lo),t=Math.floor(e.hi);if(n<=t)return{kind:"singular",at:n};let i=It(e.lo),r=It(e.hi),s=Math.min(i,r),o=Math.max(i,r),a=mp(e.lo);return a!==null?a>=e.lo&&a<=e.hi&&(s=Math.min(s,It(a))):s=-1/0,T({lo:s,hi:o})}return T({lo:It(e.lo),hi:It(e.hi)})}function s0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo<0)return{kind:"empty"};let i=_o(Math.round(t.lo)),r=_o(Math.round(t.hi));return!Number.isFinite(i)||!Number.isFinite(r)?T({lo:Math.min(i,r),hi:Math.max(i,r)}):T({lo:i,hi:r})}function o0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo<0)return{kind:"empty"};let i=Po(Math.round(t.lo)),r=Po(Math.round(t.hi));return!Number.isFinite(i)||!Number.isFinite(r)?T({lo:Math.min(i,r),hi:Math.max(i,r)}):T({lo:i,hi:r})}var ku=4096;function pp(e,n,t){let i=Math.round(e),r=Math.round(n);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||r-i+1>t)return null;let s=[];for(let o=i;o<=r;o++)s.push(o);return s}function wu(e,n,t){let i=pp(e.lo,e.hi,ku),r=pp(n.lo,n.hi,ku);if(!i||!r||i.length*r.length>ku)return null;let s=1/0,o=-1/0;for(let a of i)for(let u of r){let l=t(a,u);Number.isFinite(l)&&(l<s&&(s=l),l>o&&(o=l))}return s===1/0?null:T({lo:s,hi:o})}function a0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,Su);if(o)return o;let a=Math.round(r.hi);return T({lo:0,hi:Su(a,Math.floor(a/2))})}function u0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,gt);if(o)return o;let a=Math.max(Math.abs(Math.round(r.lo)),Math.abs(Math.round(r.hi)),Math.abs(Math.round(s.lo)),Math.abs(Math.round(s.hi)));return T({lo:0,hi:a})}function l0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,Ro);if(o)return o;let a=Math.max(Math.abs(Math.round(r.lo)),Math.abs(Math.round(r.hi))),u=Math.max(Math.abs(Math.round(s.lo)),Math.abs(Math.round(s.hi)));return T({lo:0,hi:a*u})}function c0(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;return T({lo:rs(i.lo,n),hi:rs(i.hi,n)})}function f0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:_s(t.lo),hi:_s(t.hi)})}function d0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Rs(t.hi),hi:Rs(t.lo)})}function p0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.pow(2,t.lo),hi:Math.pow(2,t.hi)})}function m0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=[Math.hypot(r.lo,s.lo),Math.hypot(r.lo,s.hi),Math.hypot(r.hi,s.lo),Math.hypot(r.hi,s.hi)],a=Math.min(...o);return r.lo<=0&&r.hi>=0&&(a=Math.min(a,Math.abs(s.lo),Math.abs(s.hi))),s.lo<=0&&s.hi>=0&&(a=Math.min(a,Math.abs(r.lo),Math.abs(r.hi))),r.lo<=0&&r.hi>=0&&s.lo<=0&&s.hi>=0&&(a=0),T({lo:a,hi:Math.max(...o)})}var ji=I(C(kx,xc)),$i=I(C(wx,bc)),ct=I(C(Mu,Ic)),qi=I(C(Ax,kc)),Au=I(_x),co=I(Ox),zi=I(C(Bx,ye(0,1/0))),Gi=I(C(Fx,ks())),Ui=I(C(Lx,ks(10))),Zi=I(C(Vx,ks(2))),Hi=I(Jx),Wi=I(jx),Yi=I($x),Ft=I(Gx),Xi=I(Ux),Ki=I(Zx),Qi=I(Hx),er=I(Wx),nr=I(C(Yx,Cn(bn,Mc))),tr=I(C(Xx,bn,3)),ir=I(Kx),rr=I(Qx),sr=I(de(n0)),or=I(de(i0)),ar=I(C(s0,bn)),ur=I(C(o0,bn)),lr=I(C(a0,bn)),cr=I(C(u0,bn)),fr=I(C(l0,bn)),fo=I(c0),po=I(C(f0,Cn(Re,ye(-1,1)))),mo=I(C(d0,ye(0,2))),go=I(C(p0,Cn(bn,ye(0,1/0)))),ho=I(C(m0,ye(0,1/0),2));var un=2*Math.PI,te=Math.PI,Ve=Math.PI/2,gp=3*Math.PI/2;function g0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=un)return T({lo:-1,hi:1});let i=Math.sin(t.lo),r=Math.sin(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,Ve,un)&&(o=1),le(t,gp,un)&&(s=-1),T({lo:s,hi:o})}function h0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=un)return T({lo:-1,hi:1});let i=Math.cos(t.lo),r=Math.cos(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,0,un)&&(o=1),le(t,te,un)&&(s=-1),T({lo:s,hi:o})}function y0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,Ve,te)){let s=Math.ceil((t.lo-Ve)/te);return{kind:"singular",at:Ve+s*te}}let i=Math.tan(t.lo),r=Math.tan(t.hi);return i>1e10&&r<-1e10||i<-1e10&&r>1e10?{kind:"singular"}:T({lo:i,hi:r})}function b0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,0,te))return{kind:"singular",at:Math.ceil(t.lo/te)*te};let i=1/Math.tan(t.lo),r=1/Math.tan(t.hi);return T({lo:Math.min(i,r),hi:Math.max(i,r)})}function x0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,Ve,te)){let a=Math.ceil((t.lo-Ve)/te);return{kind:"singular",at:Ve+a*te}}let i=1/Math.cos(t.lo),r=1/Math.cos(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,0,un)&&(s=Math.min(s,1),o=Math.max(o,1)),le(t,te,un)&&(s=Math.min(s,-1),o=Math.max(o,-1)),T({lo:s,hi:o})}function E0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,0,te))return{kind:"singular",at:Math.ceil(t.lo/te)*te};let i=1/Math.sin(t.lo),r=1/Math.sin(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,Ve,un)&&(s=Math.min(s,1),o=Math.max(o,1)),le(t,gp,un)&&(s=Math.min(s,-1),o=Math.max(o,-1)),T({lo:s,hi:o})}function hp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.asin(i),hi:Math.asin(r)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return T({lo:Math.asin(t.lo),hi:Math.asin(t.hi)})}function yp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.acos(r),hi:Math.acos(i)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return T({lo:Math.acos(t.hi),hi:Math.acos(t.lo)})}function T0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.atan(t.lo),hi:Math.atan(t.hi)})}function N0(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t,s=i.lo===0?0:i.lo,o=i.hi===0?0:i.hi,a=r.lo===0?0:r.lo,u=r.hi===0?0:r.hi;if(s===o&&a===u){let c=Math.atan2(s,a);return T({lo:c,hi:c})}let l=[];return l.push(Math.atan2(s,a)),l.push(Math.atan2(s,u)),l.push(Math.atan2(o,a)),l.push(Math.atan2(o,u)),a<0&&s<0&&o>=0?ie(0,"right",{lo:Ce(-te),hi:Ee(te)}):s===0&&a<0&&u>=0?ie(0,"right",{lo:0,hi:Ee(te)},1):a===0&&u===0&&s<=0&&o>=0?ie(0,void 0,{lo:s<0?Ce(-Ve):0,hi:o>0?Ee(Ve):0}):T({lo:Math.min(...l),hi:Math.max(...l)})}function Du(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.sinh(t.lo),hi:Math.sinh(t.hi)})}function Cu(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T({lo:Math.cosh(t.lo),hi:Math.cosh(t.hi)}):t.hi<=0?T({lo:Math.cosh(t.hi),hi:Math.cosh(t.lo)}):T({lo:1,hi:Math.max(Math.cosh(t.lo),Math.cosh(t.hi))})}function v0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.tanh(t.lo),hi:Math.tanh(t.hi)})}function bp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.asinh(t.lo),hi:Math.asinh(t.hi)})}function xp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<1?{kind:"empty"}:t.lo<1?{kind:"partial",value:{lo:0,hi:Math.acosh(t.hi)},domainClipped:"lo"}:T({lo:Math.acosh(t.lo),hi:Math.acosh(t.hi)})}function Ep(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>=1||t.hi<=-1)return{kind:"empty"};if(t.lo<=-1||t.hi>=1){let i=Math.max(t.lo,-1+Number.EPSILON),r=Math.min(t.hi,1-Number.EPSILON);return{kind:"partial",value:{lo:Math.atanh(i),hi:Math.atanh(r)},domainClipped:t.lo<=-1&&t.hi>=1?"both":t.lo<=-1?"lo":"hi"}}return T({lo:Math.atanh(t.lo),hi:Math.atanh(t.hi)})}function S0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Ve-Math.atan(t.hi),hi:Ve-Math.atan(t.lo)})}function I0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:hp(Ue(T({lo:1,hi:1}),T(t)))}function k0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:yp(Ue(T({lo:1,hi:1}),T(t)))}function M0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ue(Cu(t),Du(t))}function w0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ue(T({lo:1,hi:1}),Du(t))}function A0(e){return Ue(T({lo:1,hi:1}),Cu(e))}function R0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ep(Ue(T({lo:1,hi:1}),T(t)))}function _0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:bp(Ue(T({lo:1,hi:1}),T(t)))}function P0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:xp(Ue(T({lo:1,hi:1}),T(t)))}var Ru=[4.49341,7.72525,10.90412,14.06619,17.22076,20.3713,23.51945,26.66605,29.8116,32.95639];function D0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=l=>l===0?1:Math.sin(l)/l,r=i(t.lo),s=r,o=l=>{l<r&&(r=l),l>s&&(s=l)};o(i(t.hi)),t.lo<=0&&t.hi>=0&&o(1);let a=Ru[Ru.length-1];for(let l of Ru)l>=t.lo&&l<=t.hi&&o(i(l)),-l>=t.lo&&-l<=t.hi&&o(i(-l));let u=1/0;return t.hi>a&&(u=Math.min(u,Math.max(t.lo,a))),t.lo<-a&&(u=Math.min(u,-Math.min(t.hi,-a))),Number.isFinite(u)&&u>0&&(o(1/u),o(-1/u)),T({lo:r,hi:s})}var _u=[],Pu=[];for(let e=1;e<=20;e++)_u.push(Math.sqrt(2*e)),Pu.push(Math.sqrt(2*e-1));function C0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=kt(t.lo),r=i,s=o=>{o<i&&(i=o),o>r&&(r=o)};s(kt(t.hi)),t.lo<=0&&t.hi>=0&&s(0);for(let o of _u)o>=t.lo&&o<=t.hi&&s(kt(o)),-o>=t.lo&&-o<=t.hi&&s(kt(-o));return Tp(t,_u,kt,s),T({lo:i,hi:r})}function Tp(e,n,t,i){let r=n[n.length-1],s=Math.abs(t(r)-.5);e.hi>r&&(i(.5+s),i(.5-s)),e.lo<-r&&(i(-.5-s),i(-.5+s))}function O0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=Mt(t.lo),r=i,s=o=>{o<i&&(i=o),o>r&&(r=o)};s(Mt(t.hi)),t.lo<=0&&t.hi>=0&&s(0);for(let o of Pu)o>=t.lo&&o<=t.hi&&s(Mt(o)),-o>=t.lo&&-o<=t.hi&&s(Mt(-o));return Tp(t,Pu,Mt,s),T({lo:i,hi:r})}var dr=I(C(g0,Cn(Re,ye(-1,1)))),pr=I(C(h0,ye(-1,1))),mr=I(C(y0,Re)),gr=I(de(b0)),hr=I(de(x0)),yr=I(de(E0)),br=I(C(hp,Re)),xr=I(C(yp,ye(0,1/0))),Er=I(C(T0,Re)),Tr=I(de(N0)),Nr=I(C(Du,Re)),vr=I(C(Cu,ye(1,1/0))),Sr=I(C(v0,Cn(Re,ye(-1,1)))),Ir=I(C(bp,Re)),kr=I(C(xp,ye(0,1/0))),Mr=I(C(Ep,Re)),wr=I(de(S0)),Ar=I(de(I0)),Rr=I(de(k0)),_r=I(de(M0)),Pr=I(de(w0)),Dr=I(C(A0,Cn(ye(0,1),wc(0,1)))),Cr=I(de(R0)),Or=I(de(_0)),Br=I(de(P0)),Fr=I(C(D0,ye(-1/0,1))),Lr=I(C(C0,Re)),Vr=I(C(O0,Re));function Ie(e){return"kind"in e?e:{kind:"interval",value:e}}function Jr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<r.lo?"true":i.lo>=r.hi?"false":"maybe"}function jr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<=r.lo?"true":i.lo>r.hi?"false":"maybe"}function $r(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>r.hi?"true":i.hi<=r.lo?"false":"maybe"}function qr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>=r.hi?"true":i.hi<r.lo?"false":"maybe"}function Lt(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo===i.hi&&r.lo===r.hi&&i.lo===r.lo?"true":i.hi<r.lo||r.hi<i.lo?"false":"maybe"}function zr(e,n){let t=Lt(e,n);return t==="true"?"false":t==="false"?"true":"maybe"}function Gr(e,n){return e==="false"||n==="false"?"false":e==="true"&&n==="true"?"true":"maybe"}function Ur(e,n){return e==="true"||n==="true"?"true":e==="false"&&n==="false"?"false":"maybe"}function Zr(e){return e==="true"?"false":e==="false"?"true":"maybe"}function B0(e,n,t,i){if(e==="true"||e==="false"||e==="maybe"){let f=e,p=n,h=t;switch(f){case"true":return Ie(p());case"false":return Ie(h());case"maybe":return je(Ie(p()),Ie(h()))}}let r=e,s=n,o=t,a=i,u=S(r);if(!Array.isArray(u))return u;let[l]=u;switch(s(l)){case"true":return Ie(o(l));case"false":return Ie(a(l));case"maybe":let f=Ie(o(l)),p=Ie(a(l));return je(f,p)}}function Ou(e,n){return je(Ie(e),Ie(n))}function Bu(e,n){if(e==="false")return{kind:"empty"};let t=Ie(n());return e==="true"?t:t.kind==="interval"?{kind:"partial",value:t.value,domainClipped:"both"}:t.kind==="partial"?{...t,domainClipped:"both"}:t}function F0(e,n,t){let i=S(e,n,t);if(!Array.isArray(i))return i;let[r,s,o]=i,a={lo:Math.max(r.lo,s.lo),hi:Math.max(r.hi,s.hi)},u=Math.min(a.lo,o.lo),l=Math.min(a.hi,o.hi);return{kind:"interval",value:{lo:u,hi:l}}}var Hr=I(B0),Wr=I(F0);var Vu=256,Np=65536,vp=16,L0=4*Np,Yr=0,Fu=0;function Sp(e){return n=>Yr>1&&--Fu<0?{kind:"entire"}:e(n)}function Ip(){if(Yr===0)Fu=L0;else if(Fu<=0)return{kind:"entire"};Yr++}function Vt(e){return Number.isFinite(e.lo)&&Number.isFinite(e.hi)}function kp(e){if(e===null||typeof e!="object"||Array.isArray(e))return{kind:"entire"};if(!("kind"in e))return typeof e.lo!="number"||typeof e.hi!="number"?{kind:"entire"}:void 0;if(e.kind==="singular")return e.value===void 0?e:void 0;if(e.kind==="empty"||e.kind==="entire")return{kind:e.kind}}function Mp(e){return"kind"in e&&e.kind==="partial"}function yo(e){return"kind"in e?e.value:e}function wp(e){return Math.max(Math.abs(e.lo),Math.abs(e.hi))}function V0(e){let n=(e.ops+1)*Number.EPSILON*e.mag;return{lo:e.value.lo-n,hi:e.value.hi+n}}function J0(e){if(!Vt(e.value))return{kind:"singular"};let n=V0(e);return e.clipped?{kind:"partial",value:n,domainClipped:"both"}:T(n)}function Ap(e,n,t){let i=kp(n);if(i!==void 0)return i;Mp(n)&&(e.clipped=!0);let r=Xn(e.value,On(n,t));e.value=yo(r),e.mag+=wp(yo(n))*t.hi,e.ops+=3}function Lu(e,n,t,i){let r={value:ke(0),clipped:!1,mag:0,ops:0};if(n===t)return r;let s=t-n;for(let o=0;o<i;o++){let a=o===0?n:n+o*s/i,u=o===i-1?t:n+(o+1)*s/i,l=Math.min(a,u),c=Math.max(a,u),f=Ap(r,e({lo:l,hi:c}),ke(c-l));if(f!==void 0)return f}return r}function j0(e,n,t,i=Vu){let r=Ip();if(r!==void 0)return r;try{return Rp(Sp(e),n,t,i)}finally{Yr--}}function Rp(e,n,t,i){let r=S(n,t);if(!Array.isArray(r))return r;let[s,o]=r;if(!Vt(s)||!Vt(o))return{kind:"entire"};let a=o.lo<s.lo,u=a?Lu(e,o.lo,s.lo,i):Lu(e,s.lo,o.lo,i);if("kind"in u)return u;if(a&&(u.value={lo:-u.value.hi,hi:-u.value.lo}),o.hi>o.lo){let l=Ap(u,e(o),{lo:0,hi:o.hi-o.lo});if(l!==void 0)return l}if(s.hi>s.lo){let l=e(s),c=kp(l);if(c!==void 0)return c;Mp(l)&&(u.clipped=!0);let f={lo:0,hi:s.hi-s.lo};u.value=yo(Kn(u.value,On(l,f))),u.mag+=wp(yo(l))*f.hi,u.ops+=3}return J0(u)}function $0(e,n,t,i,r=Vu){let s=Ip();if(s!==void 0)return s;try{let o=Sp(n),a=S(t,i);if(!Array.isArray(a))return a;let[u,l]=a;if(!Vt(u)||!Vt(l))return e();let c=Math.min(u.lo,l.lo),f=Math.max(u.hi,l.hi),p=Lu(o,c,f,vp);return!("kind"in p)&&!p.clipped&&Vt(p.value)?e():Rp(o,t,i,r)}finally{Yr--}}var Ju=I(j0),ju=I($0);function bo(e){if(e===null||typeof e!="object"||!("kind"in e))return;let n=e;return Pe(n)===void 0?n:void 0}function Je(){return{lo:NaN,hi:NaN}}function qu(e){if(typeof e=="number")return T(ke(e));if(!Array.isArray(e)&&e!==null&&typeof e=="object"){if("kind"in e)return e;if("lo"in e&&"hi"in e)return T(e)}}function q0(e,n){if(!Array.isArray(e))return bo(e)??Je();let t=S(n);if(!Array.isArray(t))return t;let i=t[0];if(Number.isNaN(i.lo)||Number.isNaN(i.hi))return Je();let r=e.length,s=Math.ceil(i.lo),o=Math.floor(i.hi);if(s>o)return Je();let a=Math.max(s,-r),u=Math.min(o,r),l=s<a||o>u;if(a>u)return Je();let c;for(let p=a;p<=u;p++){if(p===0){l=!0;continue}let h=p>0?p-1:r+p,y=qu(e[h]);if(y===void 0)return{kind:"entire"};c=c===void 0?y:je(c,y)}if(c===void 0)return Je();if(!l)return c;let f=Pe(c);return f===void 0?c:{kind:"partial",value:f,domainClipped:"both"}}function zu(e){return Array.isArray(e)?T(ke(e.length)):bo(e)??Je()}function Gu(e,n){if(!Array.isArray(e))return bo(e)??Je();if(!Number.isInteger(n)||n<0||n>=e.length)return Je();let t=qu(e[n]);return t===void 0?{kind:"entire"}:t}var Uu=I(q0);function _p(e){return typeof e=="number"?ke(e):e??Je()}var z0=1e6;function Zu(e,...n){return Wu(!1,e,n)}function Hu(e,...n){return Wu(!0,e,n)}function Wu(e,n,t){let i=-1;for(let s of t)if(Array.isArray(s)){if(i<0)i=s.length;else if(s.length!==i)return Je()}if(i<0)return n(...t);if(i===0)return e?[]:Je();let r=new Array(i);for(let s=0;s<i;s++){let o=!1,a=t.map(u=>{let l=Array.isArray(u)?_p(u[s]):u;return Array.isArray(l)&&(o=!0),l});r[s]=o?Wu(e,n,a):n(...a)}return r}function Yu(e,n){return Array.isArray(n)?n.map(t=>e(_p(t))):bo(n)??Je()}function $u(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;let n=qu(e);if(n===void 0)return;let t=Pe(n);if(t!==void 0&&!(!Number.isFinite(t.lo)||t.lo!==t.hi))return t.lo}function Xu(e,n,t){let i=$u(e);if(i===void 0)return{kind:"entire"};let r,s,o;if(n===void 0)[r,s,o]=[1,i,1];else{let l=$u(n);if(l===void 0)return{kind:"entire"};if(t===void 0)[r,s,o]=[i,l,l>=i?1:-1];else{let c=$u(t);if(c===void 0)return{kind:"entire"};[r,s,o]=[i,l,c]}}if(o===0)return[];let a=Math.max(0,Math.floor((s-r)/o)+1);if(!Number.isFinite(a)||a>z0)return{kind:"entire"};let u=new Array(a);for(let l=0;l<a;l++)u[l]=ke(r+l*o);return u}var Pp={ok:T,point:ke,containsExtremum:le,unionResults:je,mergeDomainClip:ft,isPoint:jt,containsZero:ce,isPositive:$t,isNegative:An,isNonNegative:qt,isNonPositive:zt,width:Gt,midpoint:Ut,getValue:Pe,unwrap:Jn,unwrapOrPropagate:S,add:Xn,sub:Kn,mul:On,div:Qn,negDiv:ga,negate:gi,scale:ha,scaleDiv:ya,sqrt:ji,square:$i,pow:ct,powInterval:qi,powRational:Au,nthRoot:co,exp:zi,ln:Gi,log10:Ui,log2:Zi,abs:Hi,floor:Wi,ceil:Yi,round:Ft,fract:Xi,trunc:Ki,min:Qi,max:er,mod:nr,remainder:tr,heaviside:ir,sign:rr,gamma:sr,gammaln:or,factorial:ar,factorial2:ur,binomial:lr,gcd:cr,lcm:fr,chop:fo,erf:po,erfc:mo,exp2:go,hypot:ho,at:Uu,length:zu,component:Gu,bcast:Zu,bcastFn:Hu,map:Yu,range:Xu,sin:dr,cos:pr,tan:mr,cot:gr,sec:hr,csc:yr,asin:br,acos:xr,atan:Er,atan2:Tr,sinh:Nr,cosh:vr,tanh:Sr,asinh:Ir,acosh:kr,atanh:Mr,acot:wr,acsc:Ar,asec:Rr,coth:_r,csch:Pr,sech:Dr,acoth:Cr,acsch:Or,asech:Br,sinc:Fr,fresnelS:Lr,fresnelC:Vr,less:Jr,lessEqual:jr,greater:$r,greaterEqual:qr,equal:Lt,notEqual:zr,and:Gr,or:Ur,not:Zr,piecewise:Hr,hull:Ou,res:Ie,restrict:Bu,clamp:Wr,integrate:Ju,integrateClosed:ju};var G0="0.129.0";return Lp(U0);})();
8
+ `),l=o.length>0?`[${o}]`:"";return r==="("&&s===")"?v(["\\begin{pmatrix}",l,u,"\\end{pmatrix}"]):r==="["&&s==="]"?v(["\\begin{bmatrix}",l,u,"\\end{bmatrix}"]):r==="{"&&s==="}"?v(["\\begin{Bmatrix}",l,u,"\\end{Bmatrix}"]):r==="|"&&s==="|"?v(["\\begin{vmatrix}",l,u,"\\end{vmatrix}"]):r==="\u2016"&&s==="\u2016"?v(["\\begin{Vmatrix}",l,u,"\\end{Vmatrix}"]):r==="{"&&s==="."?v(["\\begin{dcases}",l,u,"\\end{dcases}"]):r==="."&&s==="}"?v(["\\begin{rcases}",l,u,"\\end{rcases}"]):o||r!=="."||s!=="."?v(["\\left",Ks[r]??r,"\\begin{array}",`{${o}}`,u,"\\end{array}","\\right",Ks[s]??s]):v(["\\begin{matrix}",u,"\\end{matrix}"])}var Jb=["NormalDistribution","BinomialDistribution","PoissonDistribution","UniformDistribution","ExponentialDistribution","PDF","CDF","Quantile","GammaRegularized","BetaRegularized","Covariance","PopulationCovariance","Correlation","LinearRegression","PolynomialFit","FindFit","FindRoot"],qd=[...Jb.map(e=>({kind:"expression",name:e,serialize:(n,t)=>`\\operatorname{${e}}`+n.wrapArguments(t)})),{name:"Mean",kind:"function",symbolTrigger:"mean"},{name:"Median",kind:"function",symbolTrigger:"median"},{name:"StandarDeviation",kind:"function",symbolTrigger:"stddev"},{latexTrigger:["\\bar"],kind:"expression",parse:(e,n)=>{let t=e.parseGroup()??e.parseToken();return!t||!E(t)?null:["Mean",t]}},{latexTrigger:"\\operatorname{var}",kind:"function",parse:"Variance"},{latexTrigger:"\\operatorname{cov}",kind:"function",parse:"Covariance"},{latexTrigger:"\\operatorname{corr}",kind:"function",parse:"Correlation"},{symbolTrigger:"erf",kind:"function",parse:"Erf"},{symbolTrigger:"erfc",kind:"function",parse:"Erfc"}];var oo={__proto__:null,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},zd=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"]),ao={__proto__:null,m:{dimension:[1,0,0,0,0,0,0,0],scale:1},kg:{dimension:[0,1,0,0,0,0,0,0],scale:1},g:{dimension:[0,1,0,0,0,0,0,0],scale:.001},s:{dimension:[0,0,1,0,0,0,0,0],scale:1},A:{dimension:[0,0,0,1,0,0,0,0],scale:1},K:{dimension:[0,0,0,0,1,0,0,0],scale:1},mol:{dimension:[0,0,0,0,0,1,0,0],scale:1},cd:{dimension:[0,0,0,0,0,0,1,0],scale:1},Hz:{dimension:[0,0,-1,0,0,0,0,0],scale:1},N:{dimension:[1,1,-2,0,0,0,0,0],scale:1},Pa:{dimension:[-1,1,-2,0,0,0,0,0],scale:1},J:{dimension:[2,1,-2,0,0,0,0,0],scale:1},W:{dimension:[2,1,-3,0,0,0,0,0],scale:1},C:{dimension:[0,0,1,1,0,0,0,0],scale:1},V:{dimension:[2,1,-3,-1,0,0,0,0],scale:1},F:{dimension:[-2,-1,4,2,0,0,0,0],scale:1},ohm:{dimension:[2,1,-3,-2,0,0,0,0],scale:1},S:{dimension:[-2,-1,3,2,0,0,0,0],scale:1},Wb:{dimension:[2,1,-2,-1,0,0,0,0],scale:1},T:{dimension:[0,1,-2,-1,0,0,0,0],scale:1},H:{dimension:[2,1,-2,-2,0,0,0,0],scale:1},lm:{dimension:[0,0,0,0,0,0,1,0],scale:1},lx:{dimension:[-2,0,0,0,0,0,1,0],scale:1},Bq:{dimension:[0,0,-1,0,0,0,0,0],scale:1},Gy:{dimension:[2,0,-2,0,0,0,0,0],scale:1},Sv:{dimension:[2,0,-2,0,0,0,0,0],scale:1},kat:{dimension:[0,0,-1,0,0,1,0,0],scale:1},degC:{dimension:[0,0,0,0,1,0,0,0],scale:1,offset:273.15},degF:{dimension:[0,0,0,0,1,0,0,0],scale:5/9,offset:459.67},min:{dimension:[0,0,1,0,0,0,0,0],scale:60},h:{dimension:[0,0,1,0,0,0,0,0],scale:3600},d:{dimension:[0,0,1,0,0,0,0,0],scale:86400},wk:{dimension:[0,0,1,0,0,0,0,0],scale:604800},ha:{dimension:[2,0,0,0,0,0,0,0],scale:1e4},L:{dimension:[3,0,0,0,0,0,0,0],scale:.001},t:{dimension:[0,1,0,0,0,0,0,0],scale:1e3},eV:{dimension:[2,1,-2,0,0,0,0,0],scale:1602176634e-28},Da:{dimension:[0,1,0,0,0,0,0,0],scale:16605390666e-37},au:{dimension:[1,0,0,0,0,0,0,0],scale:149597870700},deg:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/180},rad:{dimension:[0,0,0,0,0,0,0,0],scale:1},grad:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/200},turn:{dimension:[0,0,0,0,0,0,0,0],scale:2*Math.PI},arcmin:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/10800},arcsec:{dimension:[0,0,0,0,0,0,0,0],scale:Math.PI/648e3},percent:{dimension:[0,0,0,0,0,0,0,0],scale:.01},ppm:{dimension:[0,0,0,0,0,0,0,0],scale:1e-6},dB:{dimension:[0,0,0,0,0,0,0,0],scale:1},Np:{dimension:[0,0,0,0,0,0,0,0],scale:1},in:{dimension:[1,0,0,0,0,0,0,0],scale:.0254},ft:{dimension:[1,0,0,0,0,0,0,0],scale:.3048},yd:{dimension:[1,0,0,0,0,0,0,0],scale:.9144},mi:{dimension:[1,0,0,0,0,0,0,0],scale:1609.344},lb:{dimension:[0,1,0,0,0,0,0,0],scale:.45359237},oz:{dimension:[0,1,0,0,0,0,0,0],scale:.028349523125},gal:{dimension:[3,0,0,0,0,0,0,0],scale:.003785411784},qt:{dimension:[3,0,0,0,0,0,0,0],scale:.000946352946},pt:{dimension:[3,0,0,0,0,0,0,0],scale:.000473176473},cup:{dimension:[3,0,0,0,0,0,0,0],scale:.0002365882365},atm:{dimension:[-1,1,-2,0,0,0,0,0],scale:101325},bar:{dimension:[-1,1,-2,0,0,0,0,0],scale:1e5},cal:{dimension:[2,1,-2,0,0,0,0,0],scale:4.184},kWh:{dimension:[2,1,-2,0,0,0,0,0],scale:36e5},\u00C5:{dimension:[1,0,0,0,0,0,0,0],scale:1e-10},USD:{dimension:[0,0,0,0,0,0,0,1],scale:1},cent:{dimension:[0,0,0,0,0,0,0,1],scale:.01}};function jb(e){if(e.length>2){let n=e.slice(0,2),t=e.slice(2);if(oo[n]!==void 0&&zd.has(t)){let i=ao[t];if(i)return{prefixScale:oo[n],baseEntry:i}}}if(e.length>1){let n=e.slice(0,1),t=e.slice(1);if(oo[n]!==void 0&&zd.has(t)){let i=ao[t];if(i)return{prefixScale:oo[n],baseEntry:i}}}return null}function $b(e){let n=ao[e];if(n)return n;let t=jb(e);return t?{dimension:t.baseEntry.dimension,scale:t.prefixScale*t.baseEntry.scale}:null}function Eu(e){let n=$b(e);return n?n.dimension:null}var vR=new Map(["N","J","W","Pa","Hz","C","V","F","ohm","S","Wb","T","H","lm","lx","Gy","kat"].map(e=>[ao[e].dimension.join(","),e]));function qb(e){let n=e.indexOf("^");if(n===-1)return e;let t=e.slice(0,n),i=e.slice(n+1),r=parseInt(i,10);return isNaN(r)?e:["Power",t,r]}function Vi(e){if(e=e.trim(),e.length===0)return null;if(e[0]==="("&&e[e.length-1]===")"){let r=0,s=!0;for(let o=0;o<e.length-1;o++)if(e[o]==="("?r++:e[o]===")"&&r--,r===0&&o<e.length-1){s=!1;break}if(s)return Vi(e.slice(1,-1))}let n=-1,t=[],i=0;for(let r=0;r<e.length;r++)e[r]==="("?i++:e[r]===")"?i--:i===0&&(e[r]==="/"&&n===-1?n=r:e[r]==="*"&&t.push(r));if(n!==-1){let r=e.slice(0,n).trim(),s=e.slice(n+1).trim(),o=Vi(r),a=Vi(s);return!o||!a?null:["Divide",o,a]}if(t.length>0){let r=[],s=0;for(let a of t)r.push(e.slice(s,a).trim()),s=a+1;r.push(e.slice(s).trim());let o=r.filter(a=>a.length>0).map(a=>Vi(a));return o.some(a=>a===null)?null:o.length===1?o[0]:["Multiply",...o]}return e[0]==="("?null:qb(e)}function Gd(e){return e=e.trim(),e.length===0?null:/[/*^()]/.test(e)?Vi(e):e}function Wd(e){for(;e.peek==="<space>";)e.nextToken();if(!e.match("<{>"))return null;let n="",t=0;for(;!e.atEnd;){let i=e.peek;if(i==="<}>"&&t===0)return e.nextToken(),n;if(i==="<}>"){t--,e.nextToken();continue}if(i==="<{>"){t++,e.nextToken();continue}if(i==="<space>"){n.length>0&&!n.endsWith(" ")&&(n+=" "),e.nextToken();continue}if(i==="<$>"){n+="$",e.nextToken();continue}if(i==="\\cdot"){n+="*",e.nextToken();continue}if(i==="^"){n+="^",e.nextToken();continue}n+=i,e.nextToken()}return null}var Yd=new Set(["d"]),zb={__proto__:null,inch:"in",inches:"in","in.":"in",foot:"ft",feet:"ft","ft.":"ft",mile:"mi",miles:"mi",yard:"yd",yards:"yd",meter:"m",meters:"m",metre:"m",metres:"m",centimeter:"cm",centimeters:"cm",centimetre:"cm",centimetres:"cm",kilometer:"km",kilometers:"km",kilometre:"km",kilometres:"km",gallon:"gal",gallons:"gal",quart:"qt",quarts:"qt",pint:"pt",pints:"pt",cup:"cup",cups:"cup",liter:"L",liters:"L",litre:"L",litres:"L",ounce:"oz",ounces:"oz",pound:"lb",pounds:"lb",gram:"g",grams:"g",kilogram:"kg",kilograms:"kg",second:"s",seconds:"s",minute:"min",minutes:"min",hour:"h",hours:"h",day:"d",days:"d",week:"wk",weeks:"wk",dollar:"USD",dollars:"USD",$:"USD",cent:"cent",cents:"cent",degree:"deg",degrees:"deg",mph:"mi/h",per:"/"};function Gb(e){return e.replace(/\$|[A-Za-z.]+/g,n=>zb[n]??n)}function Tu(e){if(!e)return null;let n=e.trim();if(n.length===0||Yd.has(n))return null;let t=Gb(n).replace(/\s+/g,"");if(Eu(t)!==null)return t;if(/[/*^]/.test(t))try{let i=Gd(t);if(i!==null&&Nu(i))return i}catch{return null}return null}function Nu(e){if(typeof e=="string")return Eu(e)!==null;if(!Array.isArray(e))return!1;let n=e[0];return n==="Multiply"||n==="Divide"?e.slice(1).every(t=>Nu(t)):n==="Power"?Nu(e[1]):!1}function Ub(e){let n=e.index;if(!e.match("^"))return null;if(e.match("<{>")){let i="";for(;!e.atEnd&&e.peek!=="<}>";)i+=e.peek,e.nextToken();return e.match("<}>")?i:(e.index=n,null)}if(e.atEnd)return e.index=n,null;let t=e.peek;return e.nextToken(),t}var Ud=e=>{let n=e.index,t=Wd(e);if(t===null)return e.index=n,null;let i=e.index;if(!Yd.has(t.trim())){let s=Ub(e);if(s!==null){let o=Tu(`${t}^${s}`);if(o!==null)return["__unit__",o];e.index=i}}let r=Tu(t);return r===null?(e.index=n,null):["__unit__",r]};function at(e){let n=E(e);if(n!==null)return n;if(typeof e=="number")return String(e);let t=g(e);if(!t)return"";if(t==="Divide"){let i=d(e,1),r=d(e,2);return`${at(i)}/${at(r)}`}if(t==="Multiply"){let i=[];if(Array.isArray(e))for(let r=1;r<e.length;r++)i.push(at(e[r]));return i.join("\\cdot ")}if(t==="Power"){let i=d(e,1),r=d(e,2),s=typeof r=="number"?String(r):E(r)??String(r);return`${at(i)}^{${s}}`}if(t==="Square"){let i=d(e,1);return`${at(i)}^{2}`}return""}function Zd(e){let n=e.parseGroup();if(n===null)return null;let t=Xd(e);return t===null?null:["Quantity",n,t]}function Hd(e){return Xd(e)}function Xd(e){let n=e.index,t=Wd(e);if(t===null)return e.index=n,null;let i=Tu(t);return i===null?(e.index=n,null):i}var Kd=[{latexTrigger:"\\mathrm",kind:"expression",parse:Ud},{latexTrigger:"\\text",kind:"expression",parse:Ud},{latexTrigger:"\\qty",parse:Zd},{latexTrigger:"\\SI",parse:Zd},{latexTrigger:"\\unit",parse:Hd},{latexTrigger:"\\si",parse:Hd},{name:"Quantity",serialize:(e,n)=>{let t=d(n,1),i=d(n,2);if(t===null||i===null)return"";let r=E(i),s=r==="deg"||r==="rad"||r==="arcmin"||r==="arcsec",o=e.options;if(s&&(o.dmsFormat||o.angleNormalization&&o.angleNormalization!=="none")){let l=M(t);if(l===null){let f=e.serialize(t),p=at(i);return v([f,"\\,",`\\mathrm{${p}}`])}let c=l;return r==="rad"?c=c*180/Math.PI:r==="arcmin"?c=c/60:r==="arcsec"&&(c=c/3600),o.angleNormalization&&o.angleNormalization!=="none"&&(c=no(c,o.angleNormalization)),o.dmsFormat?to(c):`${c}\xB0`}let a=e.serialize(t);g(t)==="Measurement"&&(a=`\\left(${a}\\right)`);let u=at(i);return v([a,"\\,",`\\mathrm{${u}}`])}}];var Zb=["pt","em","mu","ex","mm","cm","in","bp","sp","dd","cc","pc","nc","nd"];function Qd(e){for(e.skipSpace(),(e.peek==="-"||e.peek==="+")&&e.nextToken();/^[\d.]$/.test(e.peek);)e.nextToken();for(let n of Zb)if(e.matchAll([...n]))return}function Hb(e){return n=>{let t=n.parseGroup();return t===null?[e]:[e,t]}}function xe(e,n){return{name:e,latexTrigger:[n],parse:Hb(e),serialize:(t,i)=>{let r=d(i,1);return r===null?n:`${n}{${t.serialize(r)}}`}}}function Vn(e,n){return(t,i)=>{let r=t.parseExpression({...i??{},minPrec:V});if(r===null||F(r))return n??[e];let s=g(r);return s==="InvisibleOperator"||s==="Multiply"?[e,...b(r)]:[e,r]}}function ep(e){return(n,t)=>{let i=b(t);return i.length===0?e:e+" "+i.map(r=>n.serialize(r)).join("")}}function np(e){return n=>{let t=n.parseGroup()??n.parseToken();if(t===null||F(t))return[e];let i=g(t);return i==="InvisibleOperator"||i==="Multiply"?[e,...b(t)]:[e,t]}}function tp(e){return(n,t)=>{let i=b(t);return e+"{"+i.map(r=>n.serialize(r)).join("")+"}"}}function uo(e){return n=>{let t=n.parseExpression();return t!==null&&!F(t)?["Annotated",t,{dict:{mathStyle:e}}]:"Nothing"}}function an(e){return n=>{let t=n.parseExpression();return t!==null&&!F(t)?["Annotated",t,{dict:{size:e}}]:"Nothing"}}var ip=[{name:"Overscript",latexTrigger:["\\overset"],kind:"infix",precedence:700},{name:"Underscript",latexTrigger:["\\underset"],kind:"infix",precedence:700},{name:"Ring",latexTrigger:["\\circ"],kind:"infix",precedence:265},{name:"StringJoin",latexTrigger:["\\lt","\\gt"],kind:"infix",precedence:780},{name:"Starstar",latexTrigger:["\\star","\\star"],kind:"infix",precedence:780},{name:"PartialDerivative",latexTrigger:["\\partial"],kind:"prefix",parse:e=>{let n=!1,t="Nothing",i="Nothing";for(;!n;)e.skipSpace(),e.match("_")?i=e.parseGroup()??e.parseToken():e.match("^")?t=e.parseGroup()??e.parseToken():n=!0;if(i===null||t===null)return null;if(i!=="Nothing"){let a=En(i)??[i];e.skipSpace();let u=e.parseGroup()??e.parseSymbol()??"Nothing";if(!F(u)){let f=e.parseArguments();f&&(u=[u,...f])}let l=M(t)??1,c=a.length===1&&l>1?Array.from({length:l},()=>a[0]):[...a];return["D",u,...c]}let r=[],s=()=>{e.skipSpace();let o=e.parseGroup()??e.parseSymbol()??"Nothing",a=1;if(g(o)==="Power")a=M(d(o,2))??1,o=d(o,1)??o;else if(e.match("^")){let u=e.parseGroup()??e.parseToken();a=M(u)??1}for(let u=0;u<a;u++)r.push(o)};for(s();e.skipSpace(),!!e.match("\\partial");)s();return r.length===1?["PartialDerivative",r[0],t]:["PartialDerivative",["List",...r],t]},precedence:740},xe("OverBar","\\overline"),xe("UnderBar","\\underline"),xe("OverVector","\\vec"),xe("OverTilde","\\tilde"),xe("OverHat","\\hat"),xe("OverRightArrow","\\overrightarrow"),xe("OverLeftArrow","\\overleftarrow"),xe("OverRightDoubleArrow","\\Overrightarrow"),xe("OverLeftHarpoon","\\overleftharpoon"),xe("OverRightHarpoon","\\overrightharpoon"),xe("OverLeftRightArrow","\\overleftrightarrow"),xe("OverBrace","\\overbrace"),xe("UnderBrace","\\underbrace"),xe("OverLineSegment","\\overlinesegment"),xe("OverGroup","\\overgroup"),{latexTrigger:["\\textcolor"],parse:e=>{let n=e.index,t=e.parseStringGroup(),i=e.parseGroup();return t!==null?i!==null?["Annotated",i,{dict:{color:t}}]:"Nothing":(e.index=n,"Nothing")}},{latexTrigger:["\\colorbox"],parse:e=>{let n=e.index,t=e.parseStringGroup(),i=e.parseGroup();return t!==null?i!==null?["Annotated",i,{dict:{backgroundColor:t}}]:"Nothing":(e.index=n,"Nothing")}},{latexTrigger:["\\boxed"],parse:e=>{let n=e.parseGroup();return n!==null?["Annotated",n,{dict:{border:!0}}]:"Nothing"}},...["\\cancel","\\bcancel","\\xcancel"].map(e=>({latexTrigger:[e],parse:n=>n.parseGroup()??"Nothing"})),{latexTrigger:["\\cancelto"],parse:e=>{let n=e.parseGroup();return e.parseGroup(),n??"Nothing"}},{latexTrigger:["\\textbf"],parse:e=>oe(e,{fontWeight:"bold"})},{latexTrigger:["\\textit"],parse:e=>oe(e,{fontStyle:"italic"})},{latexTrigger:["\\emph"],parse:e=>oe(e,{fontStyle:"italic"})},{latexTrigger:["\\textup"],parse:e=>oe(e,{fontStyle:"normal"})},{latexTrigger:["\\texttt"],parse:e=>oe(e,{fontFamily:"monospace"})},{latexTrigger:["\\textsf"],parse:e=>oe(e,{fontFamily:"sans-serif"})},{latexTrigger:["\\textrm"],parse:e=>oe(e)},{latexTrigger:["\\mbox"],parse:e=>oe(e)},{latexTrigger:["\\displaystyle"],parse:uo("normal")},{latexTrigger:["\\textstyle"],parse:uo("compact")},{latexTrigger:["\\scriptstyle"],parse:uo("script")},{latexTrigger:["\\scriptscriptstyle"],parse:uo("scriptscript")},{latexTrigger:["\\color"],parse:e=>{let n=e.parseStringGroup();if(n!==null){let t=e.parseExpression();if(t!==null&&!F(t))return["Annotated",t,{dict:{color:n}}]}return"Nothing"}},{latexTrigger:["\\tiny"],parse:an(1)},{latexTrigger:["\\scriptsize"],parse:an(2)},{latexTrigger:["\\footnotesize"],parse:an(3)},{latexTrigger:["\\small"],parse:an(4)},{latexTrigger:["\\normalsize"],parse:an(5)},{latexTrigger:["\\large"],parse:an(6)},{latexTrigger:["\\Large"],parse:an(7)},{latexTrigger:["\\LARGE"],parse:an(8)},{latexTrigger:["\\huge"],parse:an(9)},{latexTrigger:["\\Huge"],parse:an(10)},{name:"Annotated",serialize:(e,n)=>{let t=e.serialize(d(n,1)),i=of(d(n,2));if(i==null)return t;let r=_(d(n,1));r!==null&&(i.dict.fontFamily==="monospace"||i.dict.fontFamily==="sans-serif"||i.dict.fontWeight==="bold"||i.dict.fontStyle==="italic"||i.dict.fontStyle==="normal")&&(t=r),i.dict.mathStyle==="normal"?t=v(["{\\displaystyle",t,"}"]):i.dict.mathStyle==="compact"?t=v(["{\\textstyle",t,"}"]):i.dict.mathStyle==="script"?t=v(["{\\scriptstyle",t,"}"]):i.dict.mathStyle==="scriptscript"&&(t=v(["{\\scriptscriptstyle",t,"}"]));let s=i.dict.size;return s!==null&&s>=1&&s<=10&&(t=v(["{",{1:"\\tiny",2:"\\scriptsize",3:"\\footnotesize",4:"\\small",5:"\\normalsize",6:"\\large",7:"\\Large",8:"\\LARGE",9:"\\huge",10:"\\Huge"}[s],t,"}"])),i.dict.fontFamily==="monospace"?t=v(["\\texttt{",t,"}"]):i.dict.fontFamily==="sans-serif"&&(t=v(["\\textsf{",t,"}"])),i.dict.fontWeight==="bold"&&(t=v(["\\textbf{",t,"}"])),i.dict.fontStyle==="italic"?t=v(["\\textit{",t,"}"]):i.dict.fontStyle==="normal"&&(t=v(["\\textup{",t,"}"])),i.dict.color&&(t=v(["\\textcolor{",i.dict.color,"}{",t,"}"])),i.dict.backgroundColor&&(t=v(["\\colorbox{",i.dict.backgroundColor,"}{",t,"}"])),(i.dict.border===!0||i.dict.border==="True")&&(t=v(["\\boxed{",t,"}"])),t}},{latexTrigger:["\\!"],parse:()=>["HorizontalSpacing",-3]},{latexTrigger:["\\ "],parse:()=>["HorizontalSpacing",6]},{latexTrigger:["\\:"],parse:()=>["HorizontalSpacing",4]},{latexTrigger:["\\enskip"],parse:()=>["HorizontalSpacing",9]},{latexTrigger:["\\quad"],parse:()=>["HorizontalSpacing",18]},{latexTrigger:["\\qquad"],parse:()=>["HorizontalSpacing",36]},{latexTrigger:["\\,"],parse:()=>["HorizontalSpacing",3]},{latexTrigger:["\\;"],parse:()=>["HorizontalSpacing",5]},{latexTrigger:["\\enspace"],parse:()=>["HorizontalSpacing",9]},{latexTrigger:["\\hspace"],parse:e=>(e.peek==="*"&&e.nextToken(),e.parseStringGroup(),["HorizontalSpacing",0])},{latexTrigger:["\\hskip"],parse:e=>(Qd(e),["HorizontalSpacing",0])},{latexTrigger:["\\kern"],parse:e=>(Qd(e),["HorizontalSpacing",0])},{latexTrigger:["\\phantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\vphantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\hphantom"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\placeholder"],parse:e=>(e.parseOptionalGroup(),e.parseGroup()??"Nothing")},{latexTrigger:["\\smash"],parse:e=>(e.parseGroup(),"Nothing")},{latexTrigger:["\\strut"],parse:e=>"Nothing"},{latexTrigger:["\\mathstrut"],parse:e=>"Nothing"},{name:"HorizontalSpacing",serialize:(e,n)=>{if(d(n,2)!==null){let i=_(d(n,2)),r=e.serialize(d(n,1));return i==="bin"?`\\mathbin{${r}}`:i==="op"?`\\mathop{${r}}`:i==="rel"?`\\mathrel{${r}}`:i==="ord"?`\\mathord{${r}}`:i==="open"?`\\mathopen{${r}}`:i==="close"?`\\mathclose{${r}}`:i==="punct"?`\\mathpunct{${r}}`:i==="inner"?`\\mathinner{${r}}`:r}let t=M(d(n,1));return t===null?"":{"-3":"\\!",6:"\\ ",3:"\\,",4:"\\:",5:"\\;",9:"\\enspace",18:"\\quad",36:"\\qquad"}[t]??""}},{latexTrigger:"\\operatorname{count}",kind:"function",parse:"Length"},{latexTrigger:"\\operatorname{length}",kind:"function",parse:"Length"},{latexTrigger:"\\operatorname{nCr}",kind:"function",parse:"Choose"},{latexTrigger:"\\operatorname{nPr}",parse:e=>{let n=e.parseArguments("enclosure");return!n||n.length!==2?null:["Multiply",["Choose",n[0],n[1]],["Factorial",n[1]]]}},{latexTrigger:"\\operatorname{random}",kind:"function",parse:"Random"},{latexTrigger:"\\operatorname{shuffle}",kind:"function",parse:"RandomShuffle"},{latexTrigger:"\\operatorname{repeat}",kind:"function",parse:"Repeat"},{latexTrigger:"\\operatorname{join}",kind:"function",parse:"Join"},{latexTrigger:"\\operatorname{range}",kind:"function",parse:"Range"},{latexTrigger:"\\operatorname{unique}",kind:"function",parse:"Unique"},{latexTrigger:"\\operatorname{sort}",kind:"function",parse:"Sort"},{latexTrigger:"\\operatorname{reverse}",kind:"function",parse:"Reverse"},{latexTrigger:"\\operatorname{total}",kind:"function",parse:"Sum"},{latexTrigger:"\\operatorname{histogram}",kind:"function",parse:"Histogram"},{latexTrigger:"\\operatorname{pdf}",kind:"function",parse:"PDF"},{latexTrigger:"\\operatorname{cdf}",kind:"function",parse:"CDF"},{name:"Triangle",latexTrigger:["\\operatorname{triangle}"],kind:"function",serialize:(e,n)=>"\\operatorname{triangle}"+e.wrapArguments(n)},{name:"GeometricVector",latexTrigger:["\\operatorname{vector}"],kind:"function",serialize:(e,n)=>"\\operatorname{vector}"+e.wrapArguments(n)},{name:"Sphere",latexTrigger:["\\operatorname{sphere}"],kind:"function",serialize:(e,n)=>"\\operatorname{sphere}"+e.wrapArguments(n)},{name:"Segment",latexTrigger:["\\operatorname{segment}"],kind:"function",serialize:(e,n)=>"\\operatorname{segment}"+e.wrapArguments(n)},{name:"Polygon",latexTrigger:["\\operatorname{polygon}"],kind:"function",serialize:(e,n)=>"\\operatorname{polygon}"+e.wrapArguments(n)},{name:"PointList",latexTrigger:["\\operatorname{PointList}"],kind:"function",serialize:(e,n)=>"\\operatorname{PointList}"+e.wrapArguments(n)},{name:"Angle",latexTrigger:["\\angle"],kind:"prefix",precedence:w,parse:Vn("Angle"),serialize:ep("\\angle")},{latexTrigger:["\\varangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\measuredangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\Varangle"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\u2220"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\u2221"],kind:"prefix",precedence:w,parse:Vn("Angle")},{latexTrigger:["\\triangle"],kind:"prefix",precedence:w,parse:Vn("Triangle")},{name:"Quadrilateral",latexTrigger:["\\square"],kind:"prefix",precedence:w,parse:Vn("Quadrilateral",vn),serialize:ep("\\square")},{name:"Perpendicular",latexTrigger:["\\perp"],kind:"infix",precedence:w},{name:"Parallel",latexTrigger:["\\parallel"],kind:"infix",precedence:w},{name:"Arc",latexTrigger:["\\widehat"],parse:np("Arc"),serialize:tp("\\widehat")},{name:"OverParen",latexTrigger:["\\overparen"],parse:np("OverParen"),serialize:tp("\\overparen")}];var rp=[{name:"Rgb",latexTrigger:["\\operatorname{rgb}"],kind:"function",serialize:(e,n)=>"\\operatorname{rgb}"+e.wrapArguments(n)},{name:"Hsv",latexTrigger:["\\operatorname{hsv}"],kind:"function",serialize:(e,n)=>"\\operatorname{hsv}"+e.wrapArguments(n)},{name:"Hsl",latexTrigger:["\\operatorname{hsl}"],kind:"function",serialize:(e,n)=>"\\operatorname{hsl}"+e.wrapArguments(n)},{name:"Oklab",latexTrigger:["\\operatorname{oklab}"],kind:"function",serialize:(e,n)=>"\\operatorname{oklab}"+e.wrapArguments(n)},{name:"Oklch",latexTrigger:["\\operatorname{oklch}"],kind:"function",serialize:(e,n)=>"\\operatorname{oklch}"+e.wrapArguments(n)},{name:"AsRgb",latexTrigger:["\\operatorname{asRgb}"],kind:"function",serialize:(e,n)=>"\\operatorname{asRgb}"+e.wrapArguments(n)},{name:"AsHsv",latexTrigger:["\\operatorname{asHsv}"],kind:"function",serialize:(e,n)=>"\\operatorname{asHsv}"+e.wrapArguments(n)},{name:"AsHsl",latexTrigger:["\\operatorname{asHsl}"],kind:"function",serialize:(e,n)=>"\\operatorname{asHsl}"+e.wrapArguments(n)},{name:"AsOklab",latexTrigger:["\\operatorname{asOklab}"],kind:"function",serialize:(e,n)=>"\\operatorname{asOklab}"+e.wrapArguments(n)},{name:"AsOklch",latexTrigger:["\\operatorname{asOklch}"],kind:"function",serialize:(e,n)=>"\\operatorname{asOklch}"+e.wrapArguments(n)},{name:"ColorDelta",latexTrigger:["\\operatorname{colorDelta}"],kind:"function",serialize:(e,n)=>"\\operatorname{colorDelta}"+e.wrapArguments(n)}];var Wb=[{name:"Mu0",standaloneSymbol:!0,kind:"symbol",latexTrigger:"\\mu_0"},{name:"VacuumPermittivity",standaloneSymbol:!0,kind:"symbol",latexTrigger:"\\varepsilon_0"}];var Yb=[...Zf,...vf,...ed,...yf,...dd,...et,...Pd,...Dd,...Cd,...Vd,...$d,...qd,...Kd,...ip,...Wb,...rp];var tx=new Set(["Simplify","Expand","ExpandAll","Factor","Together","Distribute","TrigExpand"]);var hP=new Set([...tx,"ReplaceAll"]);var Ji=[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1],[1,7,21,35,35,21,7,1],[1,8,28,56,70,56,28,8,1]];function Su(e,n){for(;e>=Ji.length;){let t=Ji.length,i=[1],r=Ji[t-1];for(let s=1;s<t;s++)i[s]=r[s-1]+r[s];i[t]=1,Ji.push(i)}return Ji[e][n]}function kx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Mx(t)}function Mx(e){return e.hi<0?{kind:"empty"}:e.lo>=0?T({lo:Math.sqrt(e.lo),hi:Math.sqrt(e.hi)}):{kind:"partial",value:{lo:0,hi:Math.sqrt(e.hi)},domainClipped:"lo"}}function wx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T({lo:t.lo*t.lo,hi:t.hi*t.hi}):t.hi<=0?T({lo:t.hi*t.hi,hi:t.lo*t.lo}):T({lo:0,hi:Math.max(t.lo*t.lo,t.hi*t.hi)})}function up(e,n){return n===0?{lo:1,hi:1}:n===1?e:n%2===0?e.lo>=0?{lo:Math.pow(e.lo,n),hi:Math.pow(e.hi,n)}:e.hi<=0?{lo:Math.pow(e.hi,n),hi:Math.pow(e.lo,n)}:{lo:0,hi:Math.max(Math.pow(e.lo,n),Math.pow(e.hi,n))}:{lo:Math.pow(e.lo,n),hi:Math.pow(e.hi,n)}}function Mu(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;if(Number.isInteger(n)){if(n>=0)return T(up(i,n));{if(ce(i))return{kind:"singular"};let r=up(i,-n);return T({lo:1/r.hi,hi:1/r.lo})}}else return An(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:n>0?{lo:0,hi:Math.pow(i.hi,n)}:{lo:Math.pow(i.hi,n),hi:1/0},domainClipped:"lo"}:n>0?T({lo:Math.pow(i.lo,n),hi:Math.pow(i.hi,n)}):i.lo===0?{kind:"partial",value:{lo:Math.pow(i.hi,n),hi:1/0},domainClipped:"hi"}:T({lo:Math.pow(i.hi,n),hi:Math.pow(i.lo,n)})}function Ax(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(r.lo===r.hi&&Number.isInteger(r.lo))return Mu(i,r.lo);if(i.hi<=0)return i.lo===-1&&i.hi===-1&&Math.floor(r.hi)>Math.floor(r.lo)?T({lo:-1,hi:1}):{kind:"empty"};if(i.lo<=0){let o=i.lo<0,a=[Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)],u=r.lo>=0,l=u?{lo:0,hi:Math.max(...a)}:r.hi>0?{lo:0,hi:1/0}:{lo:Math.min(...a),hi:1/0};return o?{kind:"partial",value:l,domainClipped:"lo"}:u?T(l):{kind:"partial",value:l,domainClipped:"lo"}}let s=[Math.pow(i.lo,r.lo),Math.pow(i.lo,r.hi),Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)];return T({lo:Math.min(...s),hi:Math.max(...s)})}var Rx={lo:1,hi:1};function _x(e,n,t){let i=S(e);if(!Array.isArray(i))return i;let[r]=i;if(t%2!==0&&n<0&&r.lo<0&&r.hi>=0)return{kind:"singular",at:0};let s=co(T(r),t);return n>=0?ct(s,n):Qn(Rx,ct(s,-n))}function Px(e,n){let t=1,i=e,r=n;for(;r>0;){if(r%2===1){let s=t*i;t=Ge(t,i,s)?s:Ee(s)}if(r=Math.floor(r/2),r>0){let s=i*i;i=Ge(i,i,s)?s:Ee(s)}}return t}function Dx(e,n){let t=1,i=e,r=n;for(;r>0;){if(r%2===1){let s=t*i;t=Ge(t,i,s)?s:Ce(s)}if(r=Math.floor(r/2),r>0){let s=i*i;i=Ge(i,i,s)?s:Ce(s)}}return t}function Cx(e,n){let t=e,i=n;for(;i>1e3;)t*=2**1e3,i-=1e3;for(;i<-1e3;)t*=2**-1e3,i+=1e3;return t*2**i}var lp=12;function lo(e,n){if(!(e>0)||!Number.isFinite(e)||n===1)return{lo:e,hi:e};let t=0,i=e;n<=2e3&&(t=Math.round(Math.log2(e)/n),t!==0&&(i=Cx(e,-n*t)));let r=Math.pow(i,1/n),s=r,o=1;for(let l=0;Px(s,n)>i;l++){if(l>=lp){s=0;break}for(let c=0;c<o;c++)s=Ce(s);o+=o}let a=r;o=1;for(let l=0;Dx(a,n)<i;l++){if(l>=lp){a=1/0;break}for(let c=0;c<o;c++)a=Ee(a);o+=o}if(t===0)return{lo:s,hi:a};let u=2**t;return{lo:s*u,hi:a*u}}function cp(e,n){return e<0?-lo(-e,n).hi:lo(e,n).lo}function Iu(e,n){return e<0?-lo(-e,n).lo:lo(e,n).hi}function Ox(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;return!Number.isInteger(n)||n<=0?Mu(T(i),1/n):n%2===0?An(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:{lo:0,hi:Iu(i.hi,n)},domainClipped:"lo"}:T({lo:cp(i.lo,n),hi:Iu(i.hi,n)}):T({lo:cp(i.lo,n),hi:Iu(i.hi,n)})}function Bx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.exp(t.lo),hi:Math.exp(t.hi)})}function Fx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log(t.lo),hi:Math.log(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log(t.hi)},domainClipped:"lo"}}function Lx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log10(t.lo),hi:Math.log10(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log10(t.hi)},domainClipped:"lo"}}function Vx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<=0?{kind:"empty"}:t.lo>0?T({lo:Math.log2(t.lo),hi:Math.log2(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log2(t.hi)},domainClipped:"lo"}}function Jx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T(t):t.hi<=0?T({lo:-t.hi,hi:-t.lo}):T({lo:0,hi:Math.max(-t.lo,t.hi)})}function jx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?T({lo:i,hi:r}):ie(i+1,"right",{lo:i,hi:r})}function $x(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.ceil(t.lo),r=Math.ceil(t.hi);return i===r?T({lo:i,hi:r}):ie(i,"left",{lo:i,hi:r})}function ut(e){return Number.isNaN(e.lo)||Number.isNaN(e.hi)}var lt={lo:NaN,hi:NaN};function qx(e){return Math.sign(e)*Math.round(Math.abs(e))}function zx(e,n){if(ut(e))return T(lt);let t=n(e.lo),i=n(e.hi);if(t===i)return T({lo:t,hi:i});let r=t+.5;return ie(r,n(r)===t+1?"right":"left",{lo:Math.min(t,i),hi:Math.max(t,i)})}function Gx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return zx(t,qx)}function Ux(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?T({lo:t.lo-i,hi:t.hi-i}):ie(i+1,"right",{lo:0,hi:1})}function Zx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(ut(t))return T(lt);let i=Math.trunc(t.lo),r=Math.trunc(t.hi);if(i===r)return T({lo:i,hi:r});let s={lo:i,hi:r};if(t.lo>=0)return ie(i+1,"right",s);let o=Math.ceil(t.lo);return o!==0?ie(o,"left",s):ie(1,"right",s)}function Hx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:Math.min(i.lo,r.lo),hi:Math.min(i.hi,r.hi)})}function Wx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;return T({lo:Math.max(i.lo,r.lo),hi:Math.max(i.hi,r.hi)})}function Yx(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t;if(ut(i)||ut(r))return T(lt);if(ce(r))return{kind:"singular"};if(i.lo===i.hi&&r.lo===r.hi){let p=i.lo,h=r.lo;if(!Number.isFinite(p)||!Number.isFinite(h))return T(lt);let y=p%h;if(y===0||Math.sign(y)===Math.sign(h))return T({lo:y+0,hi:y+0});let N=y+h,D=N-y,R=y-(N-D)+(h-D);return R===0?T({lo:N,hi:N}):R<0?T({lo:Ce(N),hi:N}):T({lo:N,hi:Ee(N)})}let s=Math.abs(r.lo===r.hi?r.lo:Math.max(Math.abs(r.lo),Math.abs(r.hi))),o=r.hi<0,a=Math.floor(i.lo/s),u=Math.floor(i.hi/s),l=o?{lo:-s,hi:0}:{lo:0,hi:s};if(a!==u)return ie((a+1)*s,"right",l);let c=i.lo-s*a,f=i.hi-s*a;return o?c===0?ie(i.lo,"right",l):T({lo:c-s,hi:f-s}):T({lo:Math.min(c,f),hi:Math.max(c,f)})}function Xx(e,n){return Pc(e,Dc(n,Ft(Ue(e,n))))}function Kx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Number.isNaN(t.lo)||Number.isNaN(t.hi)?T({lo:NaN,hi:NaN}):t.lo>0?T({lo:1,hi:1}):t.hi<0?T({lo:0,hi:0}):t.lo===0&&t.hi===0?T({lo:.5,hi:.5}):t.lo>=0?ie(0,void 0,{lo:.5,hi:1}):t.hi<=0?ie(0,void 0,{lo:0,hi:.5}):ie(0,void 0,{lo:0,hi:1})}function Qx(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return Number.isNaN(t.lo)||Number.isNaN(t.hi)?T({lo:NaN,hi:NaN}):t.lo>0?T({lo:1,hi:1}):t.hi<0?T({lo:-1,hi:-1}):t.lo===0&&t.hi===0?T({lo:0,hi:0}):t.lo>=0?ie(0,void 0,{lo:0,hi:1}):t.hi<=0?ie(0,void 0,{lo:-1,hi:0}):ie(0,void 0,{lo:-1,hi:1})}var fp=1.4616321449683622,e0=.8856031944108887;function n0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t0(t)}var dp=[-.504083008264455,-1.573498473162391,-2.610720868444145,-3.635293366436901,-4.653163765628266,-5.667162441556885,-6.678418213073426,-7.687788325031709,-8.695764163640956,-9.702672540001863];function mp(e){let t=-Math.floor(e)-1;return t>=0&&t<dp.length?dp[t]:null}function t0(e){if(e.hi>=0&&e.lo<=0)return{kind:"singular",at:0};if(e.lo<0){let n=Math.ceil(e.lo),t=Math.floor(e.hi);if(n<=t)return{kind:"singular",at:n};let i=Ze(e.lo),r=Ze(e.hi),s=Math.min(i,r),o=Math.max(i,r),a=mp(e.lo);if(a!==null){if(a>=e.lo&&a<=e.hi){let u=Ze(a);s=Math.min(s,u),o=Math.max(o,u)}}else Math.floor(e.lo)%2===0?s=Math.min(s,0):o=Math.max(o,0);return T({lo:s,hi:o})}return e.lo>=fp?T({lo:Ze(e.lo),hi:Ze(e.hi)}):e.hi<=fp?T({lo:Ze(e.hi),hi:Ze(e.lo)}):T({lo:e0,hi:Math.max(Ze(e.lo),Ze(e.hi))})}function i0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return r0(t)}function r0(e){if(e.hi>=0&&e.lo<=0)return{kind:"singular",at:0};if(e.lo<0){let n=Math.ceil(e.lo),t=Math.floor(e.hi);if(n<=t)return{kind:"singular",at:n};let i=It(e.lo),r=It(e.hi),s=Math.min(i,r),o=Math.max(i,r),a=mp(e.lo);return a!==null?a>=e.lo&&a<=e.hi&&(s=Math.min(s,It(a))):s=-1/0,T({lo:s,hi:o})}return T({lo:It(e.lo),hi:It(e.hi)})}function s0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo<0)return{kind:"empty"};let i=_o(Math.round(t.lo)),r=_o(Math.round(t.hi));return!Number.isFinite(i)||!Number.isFinite(r)?T({lo:Math.min(i,r),hi:Math.max(i,r)}):T({lo:i,hi:r})}function o0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo<0)return{kind:"empty"};let i=Po(Math.round(t.lo)),r=Po(Math.round(t.hi));return!Number.isFinite(i)||!Number.isFinite(r)?T({lo:Math.min(i,r),hi:Math.max(i,r)}):T({lo:i,hi:r})}var ku=4096;function pp(e,n,t){let i=Math.round(e),r=Math.round(n);if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||r-i+1>t)return null;let s=[];for(let o=i;o<=r;o++)s.push(o);return s}function wu(e,n,t){let i=pp(e.lo,e.hi,ku),r=pp(n.lo,n.hi,ku);if(!i||!r||i.length*r.length>ku)return null;let s=1/0,o=-1/0;for(let a of i)for(let u of r){let l=t(a,u);Number.isFinite(l)&&(l<s&&(s=l),l>o&&(o=l))}return s===1/0?null:T({lo:s,hi:o})}function a0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,Su);if(o)return o;let a=Math.round(r.hi);return T({lo:0,hi:Su(a,Math.floor(a/2))})}function u0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,gt);if(o)return o;let a=Math.max(Math.abs(Math.round(r.lo)),Math.abs(Math.round(r.hi)),Math.abs(Math.round(s.lo)),Math.abs(Math.round(s.hi)));return T({lo:0,hi:a})}function l0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=wu(r,s,Ro);if(o)return o;let a=Math.max(Math.abs(Math.round(r.lo)),Math.abs(Math.round(r.hi))),u=Math.max(Math.abs(Math.round(s.lo)),Math.abs(Math.round(s.hi)));return T({lo:0,hi:a*u})}function c0(e,n){let t=S(e);if(!Array.isArray(t))return t;let[i]=t;return T({lo:rs(i.lo,n),hi:rs(i.hi,n)})}function f0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:_s(t.lo),hi:_s(t.hi)})}function d0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Rs(t.hi),hi:Rs(t.lo)})}function p0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.pow(2,t.lo),hi:Math.pow(2,t.hi)})}function m0(e,n){let t=S(e);if(!Array.isArray(t))return t;let i=S(n);if(!Array.isArray(i))return i;let[r]=t,[s]=i,o=[Math.hypot(r.lo,s.lo),Math.hypot(r.lo,s.hi),Math.hypot(r.hi,s.lo),Math.hypot(r.hi,s.hi)],a=Math.min(...o);return r.lo<=0&&r.hi>=0&&(a=Math.min(a,Math.abs(s.lo),Math.abs(s.hi))),s.lo<=0&&s.hi>=0&&(a=Math.min(a,Math.abs(r.lo),Math.abs(r.hi))),r.lo<=0&&r.hi>=0&&s.lo<=0&&s.hi>=0&&(a=0),T({lo:a,hi:Math.max(...o)})}var ji=I(C(kx,xc)),$i=I(C(wx,bc)),ct=I(C(Mu,Ic)),qi=I(C(Ax,kc)),Au=I(_x),co=I(Ox),zi=I(C(Bx,ye(0,1/0))),Gi=I(C(Fx,ks())),Ui=I(C(Lx,ks(10))),Zi=I(C(Vx,ks(2))),Hi=I(Jx),Wi=I(jx),Yi=I($x),Ft=I(Gx),Xi=I(Ux),Ki=I(Zx),Qi=I(Hx),er=I(Wx),nr=I(C(Yx,Cn(bn,Mc))),tr=I(C(Xx,bn,3)),ir=I(Kx),rr=I(Qx),sr=I(de(n0)),or=I(de(i0)),ar=I(C(s0,bn)),ur=I(C(o0,bn)),lr=I(C(a0,bn)),cr=I(C(u0,bn)),fr=I(C(l0,bn)),fo=I(c0),po=I(C(f0,Cn(Re,ye(-1,1)))),mo=I(C(d0,ye(0,2))),go=I(C(p0,Cn(bn,ye(0,1/0)))),ho=I(C(m0,ye(0,1/0),2));var un=2*Math.PI,te=Math.PI,Ve=Math.PI/2,gp=3*Math.PI/2;function g0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=un)return T({lo:-1,hi:1});let i=Math.sin(t.lo),r=Math.sin(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,Ve,un)&&(o=1),le(t,gp,un)&&(s=-1),T({lo:s,hi:o})}function h0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=un)return T({lo:-1,hi:1});let i=Math.cos(t.lo),r=Math.cos(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,0,un)&&(o=1),le(t,te,un)&&(s=-1),T({lo:s,hi:o})}function y0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,Ve,te)){let s=Math.ceil((t.lo-Ve)/te);return{kind:"singular",at:Ve+s*te}}let i=Math.tan(t.lo),r=Math.tan(t.hi);return i>1e10&&r<-1e10||i<-1e10&&r>1e10?{kind:"singular"}:T({lo:i,hi:r})}function b0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,0,te))return{kind:"singular",at:Math.ceil(t.lo/te)*te};let i=1/Math.tan(t.lo),r=1/Math.tan(t.hi);return T({lo:Math.min(i,r),hi:Math.max(i,r)})}function x0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,Ve,te)){let a=Math.ceil((t.lo-Ve)/te);return{kind:"singular",at:Ve+a*te}}let i=1/Math.cos(t.lo),r=1/Math.cos(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,0,un)&&(s=Math.min(s,1),o=Math.max(o,1)),le(t,te,un)&&(s=Math.min(s,-1),o=Math.max(o,-1)),T({lo:s,hi:o})}function E0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.hi-t.lo>=te)return{kind:"singular"};if(le(t,0,te))return{kind:"singular",at:Math.ceil(t.lo/te)*te};let i=1/Math.sin(t.lo),r=1/Math.sin(t.hi),s=Math.min(i,r),o=Math.max(i,r);return le(t,Ve,un)&&(s=Math.min(s,1),o=Math.max(o,1)),le(t,gp,un)&&(s=Math.min(s,-1),o=Math.max(o,-1)),T({lo:s,hi:o})}function hp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.asin(i),hi:Math.asin(r)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return T({lo:Math.asin(t.lo),hi:Math.asin(t.hi)})}function yp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.acos(r),hi:Math.acos(i)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return T({lo:Math.acos(t.hi),hi:Math.acos(t.lo)})}function T0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.atan(t.lo),hi:Math.atan(t.hi)})}function N0(e,n){let t=S(e,n);if(!Array.isArray(t))return t;let[i,r]=t,s=i.lo===0?0:i.lo,o=i.hi===0?0:i.hi,a=r.lo===0?0:r.lo,u=r.hi===0?0:r.hi;if(s===o&&a===u){let c=Math.atan2(s,a);return T({lo:c,hi:c})}let l=[];return l.push(Math.atan2(s,a)),l.push(Math.atan2(s,u)),l.push(Math.atan2(o,a)),l.push(Math.atan2(o,u)),a<0&&s<0&&o>=0?ie(0,"right",{lo:Ce(-te),hi:Ee(te)}):s===0&&a<0&&u>=0?ie(0,"right",{lo:0,hi:Ee(te)},1):a===0&&u===0&&s<=0&&o>=0?ie(0,void 0,{lo:s<0?Ce(-Ve):0,hi:o>0?Ee(Ve):0}):T({lo:Math.min(...l),hi:Math.max(...l)})}function Du(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.sinh(t.lo),hi:Math.sinh(t.hi)})}function Cu(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.lo>=0?T({lo:Math.cosh(t.lo),hi:Math.cosh(t.hi)}):t.hi<=0?T({lo:Math.cosh(t.hi),hi:Math.cosh(t.lo)}):T({lo:1,hi:Math.max(Math.cosh(t.lo),Math.cosh(t.hi))})}function v0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.tanh(t.lo),hi:Math.tanh(t.hi)})}function bp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Math.asinh(t.lo),hi:Math.asinh(t.hi)})}function xp(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return t.hi<1?{kind:"empty"}:t.lo<1?{kind:"partial",value:{lo:0,hi:Math.acosh(t.hi)},domainClipped:"lo"}:T({lo:Math.acosh(t.lo),hi:Math.acosh(t.hi)})}function Ep(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;if(t.lo>=1||t.hi<=-1)return{kind:"empty"};if(t.lo<=-1||t.hi>=1){let i=Math.max(t.lo,-1+Number.EPSILON),r=Math.min(t.hi,1-Number.EPSILON);return{kind:"partial",value:{lo:Math.atanh(i),hi:Math.atanh(r)},domainClipped:t.lo<=-1&&t.hi>=1?"both":t.lo<=-1?"lo":"hi"}}return T({lo:Math.atanh(t.lo),hi:Math.atanh(t.hi)})}function S0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return T({lo:Ve-Math.atan(t.hi),hi:Ve-Math.atan(t.lo)})}function I0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:hp(Ue(T({lo:1,hi:1}),T(t)))}function k0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:yp(Ue(T({lo:1,hi:1}),T(t)))}function M0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ue(Cu(t),Du(t))}function w0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ue(T({lo:1,hi:1}),Du(t))}function A0(e){return Ue(T({lo:1,hi:1}),Cu(e))}function R0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:Ep(Ue(T({lo:1,hi:1}),T(t)))}function _0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:bp(Ue(T({lo:1,hi:1}),T(t)))}function P0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n;return ce(t)?{kind:"singular",at:0}:xp(Ue(T({lo:1,hi:1}),T(t)))}var Ru=[4.49341,7.72525,10.90412,14.06619,17.22076,20.3713,23.51945,26.66605,29.8116,32.95639];function D0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=l=>l===0?1:Math.sin(l)/l,r=i(t.lo),s=r,o=l=>{l<r&&(r=l),l>s&&(s=l)};o(i(t.hi)),t.lo<=0&&t.hi>=0&&o(1);let a=Ru[Ru.length-1];for(let l of Ru)l>=t.lo&&l<=t.hi&&o(i(l)),-l>=t.lo&&-l<=t.hi&&o(i(-l));let u=1/0;return t.hi>a&&(u=Math.min(u,Math.max(t.lo,a))),t.lo<-a&&(u=Math.min(u,-Math.min(t.hi,-a))),Number.isFinite(u)&&u>0&&(o(1/u),o(-1/u)),T({lo:r,hi:s})}var _u=[],Pu=[];for(let e=1;e<=20;e++)_u.push(Math.sqrt(2*e)),Pu.push(Math.sqrt(2*e-1));function C0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=kt(t.lo),r=i,s=o=>{o<i&&(i=o),o>r&&(r=o)};s(kt(t.hi)),t.lo<=0&&t.hi>=0&&s(0);for(let o of _u)o>=t.lo&&o<=t.hi&&s(kt(o)),-o>=t.lo&&-o<=t.hi&&s(kt(-o));return Tp(t,_u,kt,s),T({lo:i,hi:r})}function Tp(e,n,t,i){let r=n[n.length-1],s=Math.abs(t(r)-.5);e.hi>r&&(i(.5+s),i(.5-s)),e.lo<-r&&(i(-.5-s),i(-.5+s))}function O0(e){let n=S(e);if(!Array.isArray(n))return n;let[t]=n,i=Mt(t.lo),r=i,s=o=>{o<i&&(i=o),o>r&&(r=o)};s(Mt(t.hi)),t.lo<=0&&t.hi>=0&&s(0);for(let o of Pu)o>=t.lo&&o<=t.hi&&s(Mt(o)),-o>=t.lo&&-o<=t.hi&&s(Mt(-o));return Tp(t,Pu,Mt,s),T({lo:i,hi:r})}var dr=I(C(g0,Cn(Re,ye(-1,1)))),pr=I(C(h0,ye(-1,1))),mr=I(C(y0,Re)),gr=I(de(b0)),hr=I(de(x0)),yr=I(de(E0)),br=I(C(hp,Re)),xr=I(C(yp,ye(0,1/0))),Er=I(C(T0,Re)),Tr=I(de(N0)),Nr=I(C(Du,Re)),vr=I(C(Cu,ye(1,1/0))),Sr=I(C(v0,Cn(Re,ye(-1,1)))),Ir=I(C(bp,Re)),kr=I(C(xp,ye(0,1/0))),Mr=I(C(Ep,Re)),wr=I(de(S0)),Ar=I(de(I0)),Rr=I(de(k0)),_r=I(de(M0)),Pr=I(de(w0)),Dr=I(C(A0,Cn(ye(0,1),wc(0,1)))),Cr=I(de(R0)),Or=I(de(_0)),Br=I(de(P0)),Fr=I(C(D0,ye(-1/0,1))),Lr=I(C(C0,Re)),Vr=I(C(O0,Re));function Ie(e){return"kind"in e?e:{kind:"interval",value:e}}function Jr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<r.lo?"true":i.lo>=r.hi?"false":"maybe"}function jr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<=r.lo?"true":i.lo>r.hi?"false":"maybe"}function $r(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>r.hi?"true":i.hi<=r.lo?"false":"maybe"}function qr(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>=r.hi?"true":i.hi<r.lo?"false":"maybe"}function Lt(e,n){let t=S(e,n);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo===i.hi&&r.lo===r.hi&&i.lo===r.lo?"true":i.hi<r.lo||r.hi<i.lo?"false":"maybe"}function zr(e,n){let t=Lt(e,n);return t==="true"?"false":t==="false"?"true":"maybe"}function Gr(e,n){return e==="false"||n==="false"?"false":e==="true"&&n==="true"?"true":"maybe"}function Ur(e,n){return e==="true"||n==="true"?"true":e==="false"&&n==="false"?"false":"maybe"}function Zr(e){return e==="true"?"false":e==="false"?"true":"maybe"}function B0(e,n,t,i){if(e==="true"||e==="false"||e==="maybe"){let f=e,p=n,h=t;switch(f){case"true":return Ie(p());case"false":return Ie(h());case"maybe":return je(Ie(p()),Ie(h()))}}let r=e,s=n,o=t,a=i,u=S(r);if(!Array.isArray(u))return u;let[l]=u;switch(s(l)){case"true":return Ie(o(l));case"false":return Ie(a(l));case"maybe":let f=Ie(o(l)),p=Ie(a(l));return je(f,p)}}function Ou(e,n){return je(Ie(e),Ie(n))}function Bu(e,n){if(e==="false")return{kind:"empty"};let t=Ie(n());return e==="true"?t:t.kind==="interval"?{kind:"partial",value:t.value,domainClipped:"both"}:t.kind==="partial"?{...t,domainClipped:"both"}:t}function F0(e,n,t){let i=S(e,n,t);if(!Array.isArray(i))return i;let[r,s,o]=i,a={lo:Math.max(r.lo,s.lo),hi:Math.max(r.hi,s.hi)},u=Math.min(a.lo,o.lo),l=Math.min(a.hi,o.hi);return{kind:"interval",value:{lo:u,hi:l}}}var Hr=I(B0),Wr=I(F0);var Vu=256,Np=65536,vp=16,L0=4*Np,Yr=0,Fu=0;function Sp(e){return n=>Yr>1&&--Fu<0?{kind:"entire"}:e(n)}function Ip(){if(Yr===0)Fu=L0;else if(Fu<=0)return{kind:"entire"};Yr++}function Vt(e){return Number.isFinite(e.lo)&&Number.isFinite(e.hi)}function kp(e){if(e===null||typeof e!="object"||Array.isArray(e))return{kind:"entire"};if(!("kind"in e))return typeof e.lo!="number"||typeof e.hi!="number"?{kind:"entire"}:void 0;if(e.kind==="singular")return e.value===void 0?e:void 0;if(e.kind==="empty"||e.kind==="entire")return{kind:e.kind}}function Mp(e){return"kind"in e&&e.kind==="partial"}function yo(e){return"kind"in e?e.value:e}function wp(e){return Math.max(Math.abs(e.lo),Math.abs(e.hi))}function V0(e){let n=(e.ops+1)*Number.EPSILON*e.mag;return{lo:e.value.lo-n,hi:e.value.hi+n}}function J0(e){if(!Vt(e.value))return{kind:"singular"};let n=V0(e);return e.clipped?{kind:"partial",value:n,domainClipped:"both"}:T(n)}function Ap(e,n,t){let i=kp(n);if(i!==void 0)return i;Mp(n)&&(e.clipped=!0);let r=Xn(e.value,On(n,t));e.value=yo(r),e.mag+=wp(yo(n))*t.hi,e.ops+=3}function Lu(e,n,t,i){let r={value:ke(0),clipped:!1,mag:0,ops:0};if(n===t)return r;let s=t-n;for(let o=0;o<i;o++){let a=o===0?n:n+o*s/i,u=o===i-1?t:n+(o+1)*s/i,l=Math.min(a,u),c=Math.max(a,u),f=Ap(r,e({lo:l,hi:c}),ke(c-l));if(f!==void 0)return f}return r}function j0(e,n,t,i=Vu){let r=Ip();if(r!==void 0)return r;try{return Rp(Sp(e),n,t,i)}finally{Yr--}}function Rp(e,n,t,i){let r=S(n,t);if(!Array.isArray(r))return r;let[s,o]=r;if(!Vt(s)||!Vt(o))return{kind:"entire"};let a=o.lo<s.lo,u=a?Lu(e,o.lo,s.lo,i):Lu(e,s.lo,o.lo,i);if("kind"in u)return u;if(a&&(u.value={lo:-u.value.hi,hi:-u.value.lo}),o.hi>o.lo){let l=Ap(u,e(o),{lo:0,hi:o.hi-o.lo});if(l!==void 0)return l}if(s.hi>s.lo){let l=e(s),c=kp(l);if(c!==void 0)return c;Mp(l)&&(u.clipped=!0);let f={lo:0,hi:s.hi-s.lo};u.value=yo(Kn(u.value,On(l,f))),u.mag+=wp(yo(l))*f.hi,u.ops+=3}return J0(u)}function $0(e,n,t,i,r=Vu){let s=Ip();if(s!==void 0)return s;try{let o=Sp(n),a=S(t,i);if(!Array.isArray(a))return a;let[u,l]=a;if(!Vt(u)||!Vt(l))return e();let c=Math.min(u.lo,l.lo),f=Math.max(u.hi,l.hi),p=Lu(o,c,f,vp);return!("kind"in p)&&!p.clipped&&Vt(p.value)?e():Rp(o,t,i,r)}finally{Yr--}}var Ju=I(j0),ju=I($0);function bo(e){if(e===null||typeof e!="object"||!("kind"in e))return;let n=e;return Pe(n)===void 0?n:void 0}function Je(){return{lo:NaN,hi:NaN}}function qu(e){if(typeof e=="number")return T(ke(e));if(!Array.isArray(e)&&e!==null&&typeof e=="object"){if("kind"in e)return e;if("lo"in e&&"hi"in e)return T(e)}}function q0(e,n){if(!Array.isArray(e))return bo(e)??Je();let t=S(n);if(!Array.isArray(t))return t;let i=t[0];if(Number.isNaN(i.lo)||Number.isNaN(i.hi))return Je();let r=e.length,s=Math.ceil(i.lo),o=Math.floor(i.hi);if(s>o)return Je();let a=Math.max(s,-r),u=Math.min(o,r),l=s<a||o>u;if(a>u)return Je();let c;for(let p=a;p<=u;p++){if(p===0){l=!0;continue}let h=p>0?p-1:r+p,y=qu(e[h]);if(y===void 0)return{kind:"entire"};c=c===void 0?y:je(c,y)}if(c===void 0)return Je();if(!l)return c;let f=Pe(c);return f===void 0?c:{kind:"partial",value:f,domainClipped:"both"}}function zu(e){return Array.isArray(e)?T(ke(e.length)):bo(e)??Je()}function Gu(e,n){if(!Array.isArray(e))return bo(e)??Je();if(!Number.isInteger(n)||n<0||n>=e.length)return Je();let t=qu(e[n]);return t===void 0?{kind:"entire"}:t}var Uu=I(q0);function _p(e){return typeof e=="number"?ke(e):e??Je()}var z0=1e6;function Zu(e,...n){return Wu(!1,e,n)}function Hu(e,...n){return Wu(!0,e,n)}function Wu(e,n,t){let i=-1;for(let s of t)if(Array.isArray(s)){if(i<0)i=s.length;else if(s.length!==i)return Je()}if(i<0)return n(...t);if(i===0)return e?[]:Je();let r=new Array(i);for(let s=0;s<i;s++){let o=!1,a=t.map(u=>{let l=Array.isArray(u)?_p(u[s]):u;return Array.isArray(l)&&(o=!0),l});r[s]=o?Wu(e,n,a):n(...a)}return r}function Yu(e,n){return Array.isArray(n)?n.map(t=>e(_p(t))):bo(n)??Je()}function $u(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;let n=qu(e);if(n===void 0)return;let t=Pe(n);if(t!==void 0&&!(!Number.isFinite(t.lo)||t.lo!==t.hi))return t.lo}function Xu(e,n,t){let i=$u(e);if(i===void 0)return{kind:"entire"};let r,s,o;if(n===void 0)[r,s,o]=[1,i,1];else{let l=$u(n);if(l===void 0)return{kind:"entire"};if(t===void 0)[r,s,o]=[i,l,l>=i?1:-1];else{let c=$u(t);if(c===void 0)return{kind:"entire"};[r,s,o]=[i,l,c]}}if(o===0)return[];let a=Math.max(0,Math.floor((s-r)/o)+1);if(!Number.isFinite(a)||a>z0)return{kind:"entire"};let u=new Array(a);for(let l=0;l<a;l++)u[l]=ke(r+l*o);return u}var Pp={ok:T,point:ke,containsExtremum:le,unionResults:je,mergeDomainClip:ft,isPoint:jt,containsZero:ce,isPositive:$t,isNegative:An,isNonNegative:qt,isNonPositive:zt,width:Gt,midpoint:Ut,getValue:Pe,unwrap:Jn,unwrapOrPropagate:S,add:Xn,sub:Kn,mul:On,div:Qn,negDiv:ga,negate:gi,scale:ha,scaleDiv:ya,sqrt:ji,square:$i,pow:ct,powInterval:qi,powRational:Au,nthRoot:co,exp:zi,ln:Gi,log10:Ui,log2:Zi,abs:Hi,floor:Wi,ceil:Yi,round:Ft,fract:Xi,trunc:Ki,min:Qi,max:er,mod:nr,remainder:tr,heaviside:ir,sign:rr,gamma:sr,gammaln:or,factorial:ar,factorial2:ur,binomial:lr,gcd:cr,lcm:fr,chop:fo,erf:po,erfc:mo,exp2:go,hypot:ho,at:Uu,length:zu,component:Gu,bcast:Zu,bcastFn:Hu,map:Yu,range:Xu,sin:dr,cos:pr,tan:mr,cot:gr,sec:hr,csc:yr,asin:br,acos:xr,atan:Er,atan2:Tr,sinh:Nr,cosh:vr,tanh:Sr,asinh:Ir,acosh:kr,atanh:Mr,acot:wr,acsc:Ar,asec:Rr,coth:_r,csch:Pr,sech:Dr,acoth:Cr,acsch:Or,asech:Br,sinc:Fr,fresnelS:Lr,fresnelC:Vr,less:Jr,lessEqual:jr,greater:$r,greaterEqual:qr,equal:Lt,notEqual:zr,and:Gr,or:Ur,not:Zr,piecewise:Hr,hull:Ou,res:Ie,restrict:Bu,clamp:Wr,integrate:Ju,integrateClosed:ju};var G0="0.129.1";return Lp(U0);})();
9
9
  /*! Bundled license information:
10
10
 
11
11
  complex-esm/dist/src/complex.js: