@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.
- package/dist/esm-min/chunks/{chunk-RKFNDUDQ.js → chunk-75MH3VS7.js} +3 -3
- package/dist/esm-min/chunks/{chunk-3XFZFOXD.js → chunk-S6UB43FH.js} +1 -1
- package/dist/esm-min/cli/epsil.js +1 -1
- package/dist/esm-min/compile.js +2 -2
- package/dist/esm-min/compute-engine.js +2 -2
- package/dist/esm-min/core.js +2 -2
- package/dist/esm-min/epsil.js +3 -3
- package/dist/esm-min/identities.js +2 -2
- package/dist/esm-min/integration-rules.js +3 -3
- package/dist/esm-min/interval.js +2 -2
- package/dist/esm-min/latex-syntax.js +2 -2
- package/dist/esm-min/math-json.js +2 -2
- package/dist/esm-min/numerics.js +2 -2
- package/dist/types/big-decimal/big-decimal.d.ts +1 -1
- package/dist/types/big-decimal/index.d.ts +1 -1
- package/dist/types/big-decimal/transcendentals.d.ts +1 -1
- package/dist/types/big-decimal/utils.d.ts +1 -1
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/cache-stats.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/debug-hook.d.ts +1 -1
- package/dist/types/common/debug.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/kleene.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/styled-text.d.ts +1 -1
- package/dist/types/common/terminal.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/compatibility.d.ts +1 -1
- package/dist/types/common/type/conditional-conformance.d.ts +1 -1
- package/dist/types/common/type/effects.d.ts +1 -1
- package/dist/types/common/type/facts.d.ts +1 -1
- package/dist/types/common/type/immutable.d.ts +1 -1
- package/dist/types/common/type/instantiate.d.ts +1 -1
- package/dist/types/common/type/intern.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/numeric-range.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/reference.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/size-cap.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +1 -1
- package/dist/types/common/type/variance.d.ts +1 -1
- package/dist/types/common/type/widen-value.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compile.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ambient-chain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/async-only-descendants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/binders.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/binding-sites.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/binding-tombstone.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-character.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-object.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/broadcast-cell-widening.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/broadcast-lift-type.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/call-result-type.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/callback-arity.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/collection-element-memo.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/conditional-value.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cycle-guard.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/definition-guards.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/derive-application-type.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/diophantine.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/effects-inference.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/effects-of.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/effects-provenance.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/error-value.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/exp-to-trig.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/explain-labels.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/explain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/function-literal.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/generic-instantiation.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/inferred-annotations.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/infinite-point.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/literal-tier.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/logarithm.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/machine-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match-dispatch.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/modular-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/multivariate-gcd.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/multivariate-poly.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/named-arguments.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/number-set-types.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/object-deps.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/object-walk.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/operand-descriptor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/overload.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/provisional-application.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/recursive-list-builder.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-congruence.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/tensor-view.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/tuple-pattern.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-compatibility-error.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-provenance.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/value-membership.d.ts +1 -1
- package/dist/types/compute-engine/checkpoint-journal.d.ts +1 -1
- package/dist/types/compute-engine/checkpoint.d.ts +1 -1
- package/dist/types/compute-engine/clause-identity.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/angular-unit.d.ts +1 -1
- package/dist/types/compute-engine/compilation/auto-escalation.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
- package/dist/types/compute-engine/compilation/builtin-callback.d.ts +1 -1
- package/dist/types/compute-engine/compilation/color-space-fact.d.ts +1 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
- package/dist/types/compute-engine/compilation/cse.d.ts +1 -1
- package/dist/types/compute-engine/compilation/deprecation-warnings.d.ts +1 -1
- package/dist/types/compute-engine/compilation/derivative-closed-form.d.ts +1 -1
- package/dist/types/compute-engine/compilation/diagnostics.d.ts +1 -1
- package/dist/types/compute-engine/compilation/fixed-width-unroll.d.ts +1 -1
- package/dist/types/compute-engine/compilation/function-purity.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-value-facts.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-selection-fusion.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-statements.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-value-facts.d.ts +1 -1
- package/dist/types/compute-engine/compilation/jet-derivative.d.ts +1 -1
- package/dist/types/compute-engine/compilation/protocol-dispatch.d.ts +1 -1
- package/dist/types/compute-engine/compilation/provable-kind.d.ts +1 -1
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/storage-hints.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/declaration-origin.d.ts +1 -1
- package/dist/types/compute-engine/differential-equation-utils.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-boxing-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-inspectable-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-protocols.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.d.ts +1 -1
- package/dist/types/compute-engine/function-properties/index.d.ts +1 -1
- package/dist/types/compute-engine/function-properties/types.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/fungrim/loader.d.ts +1 -1
- package/dist/types/compute-engine/fungrim/types.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/implicit-compile.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +1 -1
- package/dist/types/compute-engine/inference-rollback.d.ts +1 -1
- package/dist/types/compute-engine/interpret-oeis.d.ts +1 -1
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/collections.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/integrate.d.ts +1 -1
- package/dist/types/compute-engine/interval/rounding.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/delimiter-tables.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-colors.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/style-options.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/colors.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/distributions.d.ts +1 -1
- package/dist/types/compute-engine/library/fractals.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/map-auto-compile.d.ts +1 -1
- package/dist/types/compute-engine/library/map-broadcast-shape.d.ts +1 -1
- package/dist/types/compute-engine/library/map-exact-proof.d.ts +1 -1
- package/dist/types/compute-engine/library/map-lowering.d.ts +1 -1
- package/dist/types/compute-engine/library/measurement-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/missing-data.d.ts +1 -1
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/random-utils.d.ts +1 -1
- package/dist/types/compute-engine/library/regexp.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/ring-constructions.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics-data.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
- package/dist/types/compute-engine/library/type-value-utils.d.ts +1 -1
- package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/map-auto-compile-stats.d.ts +1 -1
- package/dist/types/compute-engine/multi-clause.d.ts +1 -1
- package/dist/types/compute-engine/nonlinear-fit.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-integer-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bernoulli.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/complex-esm-augment.d.ts +1 -1
- package/dist/types/compute-engine/numerics/differential-equations.d.ts +1 -1
- package/dist/types/compute-engine/numerics/diophantine.d.ts +1 -1
- package/dist/types/compute-engine/numerics/distributions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/gauss-kronrod.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/levenberg-marquardt.d.ts +1 -1
- package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/oscillatory-quadrature.d.ts +1 -1
- package/dist/types/compute-engine/numerics/polynomial-roots.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/random.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/numerics/value-scaled-caps.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/rubi/compile.d.ts +1 -1
- package/dist/types/compute-engine/rubi/driver.d.ts +1 -1
- package/dist/types/compute-engine/rubi/explain-trace.d.ts +1 -1
- package/dist/types/compute-engine/rubi/loader.d.ts +1 -1
- package/dist/types/compute-engine/rubi/match.d.ts +1 -1
- package/dist/types/compute-engine/rubi/normal-form.d.ts +1 -1
- package/dist/types/compute-engine/rubi/rubi-utils.d.ts +1 -1
- package/dist/types/compute-engine/rubi/types.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/sum-representation.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/angular-unit.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/differential-equations.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/explain-derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/interior-pole.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/interpret.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/limit.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/recurrences.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/residue.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/series.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/solver-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/trig-rewrite.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/type-constructors.d.ts +1 -1
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +1 -1
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/epsil/characters.d.ts +1 -1
- package/dist/types/epsil/definition-sites.d.ts +1 -1
- package/dist/types/epsil/diagnostics.d.ts +1 -1
- package/dist/types/epsil/error-location.d.ts +1 -1
- package/dist/types/epsil/execute-epsil.d.ts +1 -1
- package/dist/types/epsil/formatter.d.ts +1 -1
- package/dist/types/epsil/lexer.d.ts +1 -1
- package/dist/types/epsil/library-names.d.ts +1 -1
- package/dist/types/epsil/match-exhaustiveness.d.ts +1 -1
- package/dist/types/epsil/occurrences.d.ts +1 -1
- package/dist/types/epsil/operators.d.ts +1 -1
- package/dist/types/epsil/parse-epsil.d.ts +1 -1
- package/dist/types/epsil/parser.d.ts +1 -1
- package/dist/types/epsil/reserved-words.d.ts +1 -1
- package/dist/types/epsil/resolve-library-names.d.ts +1 -1
- package/dist/types/epsil/serialize-epsil.d.ts +1 -1
- package/dist/types/epsil/signature-notes.d.ts +1 -1
- package/dist/types/epsil/static-diagnostics.d.ts +1 -1
- package/dist/types/epsil/tokens.d.ts +1 -1
- package/dist/types/epsil.d.ts +2 -2
- package/dist/types/identities.d.ts +1 -1
- package/dist/types/integration-rules.d.ts +1 -1
- package/dist/types/interval.d.ts +1 -1
- package/dist/types/latex-syntax.d.ts +2 -2
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/dist/types/numerics.d.ts +1 -1
- package/dist/umd-min/compile.cjs +2 -2
- package/dist/umd-min/compute-engine.cjs +2 -2
- package/dist/umd-min/core.cjs +2 -2
- package/dist/umd-min/epsil.cjs +3 -3
- package/dist/umd-min/identities.cjs +2 -2
- package/dist/umd-min/integration-rules.cjs +2 -2
- package/dist/umd-min/interval.cjs +2 -2
- package/dist/umd-min/latex-syntax.cjs +2 -2
- package/dist/umd-min/math-json.cjs +2 -2
- package/dist/umd-min/numerics.cjs +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Compute Engine 0.129.
|
|
2
|
-
import{$ as el,$a as Jf,$b as Q,$c as SL,$d as Bt,$e as $v,$f as Qd,$g as Xu,$h as Zo,$i as W2,$j as S5,$k as yh,A as Gf,Aa as Z,Ab as Xt,Ac as vL,Ae as S2,Af as s3,Ag as v3,Ah as U3,Aj as rE,Ak as R5,B as WC,Ba as YF,Bb as e2,Bc as nc,Be as _2,Bf as Kd,Bg as Qu,Bh as H3,Bi as Cr,Bj as Zn,Bk as fE,C as Qa,Ca as ZF,Cb as Ud,Cc as ul,Ce as BL,Cf as Lv,Cg as E3,Ch as G3,Ci as m5,Cj as Ei,Ck as A5,D as DF,Da as Hu,Db as jg,Dc as EL,De as VL,Df as u3,Dg as cc,Dh as W3,Dj as fr,Dk as T5,E as Ag,Ea as se,Eb as Hd,Ec as Wu,Ed as Ev,Ee as Iv,Ef as a3,Eg as Gv,Eh as Y3,Ei as g5,Ej as gc,Ek as I5,F as re,Fa as fe,Fb as On,Fc as Yu,Fe as ho,Ff as A2,Fg as Wv,Fh as Xv,Fi as nE,Fj as X2,Fk as cE,G as FF,Ga as co,Gb as Ps,Gc as qo,Gd as AL,Ge as Yd,Gf as l3,Gg as x3,Gh as sh,Gi as sp,Gj as vo,Gk as k5,H as _t,Ha as JF,Hb as sr,Hc as T,He as jL,Hf as Bv,Hg as S3,Hh as Z3,Hi as sn,Hj as b5,Hk as ua,I as LF,Ia as KC,Ib as Er,Ic as C,Id as TL,Ie as ic,If as f3,Ig as Yv,Ih as J3,Ii as ta,Ij as v5,Ik as hc,J as K0,Ja as KF,Jb as qg,Jc as ur,Jd as xv,Je as on,Jf as c3,Jg as dc,Jh as K3,Ji as H2,Jj as fp,Jk as le,K as BF,Ka as QF,Kb as Ds,Kc as g,Kd as rc,Ke as Zg,Kf as pl,Kg as Wo,Kh as Q3,Kj as E5,Kk as M5,L as wt,La as XF,Lb as ov,Lc as j,Ld as IL,Le as w2,Lg as $2,Lh as X3,Lj as cp,Lk as $5,M as Xa,Ma as nv,Mb as sv,Mc as Ye,Md as Sv,Me as qL,Mf as uc,Mg as Zv,Mh as wr,Mi as G2,Mj as x5,Mk as dE,N as pt,Na as Ln,Nb as uv,Nc as al,Nd as _v,Ne as Ue,Nf as d3,Ng as _3,Nh as B2,Ni as Ji,Nj as dh,Nk as Cl,O as cn,Oa as Yf,Ob as Xf,Oc as Qe,Od as wv,Oe as Zd,Of as Ku,Og as Yo,Oh as e5,Oi as Us,Oj as iE,Ok as O5,P as Q0,Pa as eL,Pb as sl,Pc as Vn,Pd as kL,Pe as kv,Pf as yo,Pg as th,Ph as uh,Pj as oE,Pk as yc,Q as zi,Qa as $g,Qb as Fs,Qc as f2,Qd as ML,Qe as zL,Qf as Vv,Qh as n5,Qj as oa,Qk as gp,R as VF,Ra as tv,Rb as av,Rc as ll,Rd as pn,Re as Mv,Rf as Zi,Rg as w3,Rh as t5,Rj as dp,Rk as Jo,S as jF,Sa as Og,Sb as lv,Sc as c2,Sd as $L,Se as Ju,Sf as p3,Sg as C3,Sh as V2,Sj as sE,Sk as Oe,T as qF,Ta as Pg,Tb as zg,Tc as d2,Td as OL,Te as C2,Tf as m3,Tg as N3,Th as Ct,Tj as ph,Tk as P5,U as zF,Ua as Zf,Ub as ec,Uc as Gi,Ud as Cv,Ue as UL,Uf as Te,Ug as R3,Uh as r5,Uj as Gs,Uk as D5,V as YC,Va as Gu,Vb as n2,Vc as dv,Vd as Nv,Ve as HL,Vf as ml,Vg as O2,Vh as i5,Vj as pp,Vk as gh,W as ks,Wa as Dg,Wb as rL,Wc as xL,Wd as _r,We as js,Wf as ac,Wg as A3,Wh as j2,Wj as uE,Wk as en,X as K,Xa as we,Xb as iL,Xc as er,Xd as nr,Xe as GL,Xf as gl,Xg as T3,Xh as Be,Xj as aE,Xk as aa,Ya as rl,Yb as oL,Yc as P,Yd as Xr,Ye as WL,Yf as Qg,Yg as rh,Yh as q2,Yj as cr,Yk as bc,Z as UF,Za as il,Zb as t2,Zc as zo,Zd as mo,Ze as YL,Zf as bo,Zg as pe,Zh as Fr,Zi as El,Zj as Un,Zk as F5,_ as Tg,_a as vi,_b as J,_c as pv,_d as ar,_e as ZL,_f as Xg,_g as _n,_h as o5,_i as tE,_j as ge,_k as hh,a as W,aa as dn,ab as rv,ac as sL,ad as tc,ae as Rv,af as Ov,ag as jv,ah as I3,ai as jn,aj as up,ak as eN,al as L5,b as D,ba as bi,bb as iv,bc as Lt,bd as mv,be as An,bf as JL,bg as hl,bh as k3,bi as zs,bj as ra,bk as qe,bl as B5,c as Fe,ca as O,cb as nL,cc as r2,cd as p2,ce as Zu,cf as Jg,cg as Xd,ch as M3,ci as qn,cj as Lr,ck as xi,cl as bh,d as TF,da as nl,db as oe,dc as uL,dd as Gd,de as nt,df as oc,dg as eh,dh as Xe,di as zn,dj as Br,dk as nN,dl as pE,e as je,ea as fo,eb as Fg,ec as aL,ed as gv,ee as ei,ef as KL,eg as nh,eh as $3,ei as Pn,ej as Y2,ek as ae,el as V5,f as W0,fa as zu,fb as tL,fc as lL,fd as m2,fe as tt,ff as QL,fg as yl,fh as P2,fi as z2,fj as Z2,fk as un,g as IF,ga as Ig,gb as po,gc as fL,gd as fl,ge as b2,gf as XL,gg as bl,gh as O3,gi as s5,gj as J2,gk as Nt,h as kF,ha as me,hb as Bn,hc as fv,hd as hv,he as Gg,hf as e3,hg as ep,hh as Jv,hi as u5,hj as K2,hk as te,i as xn,ia as Ui,ib as Hi,ic as cL,id as Ug,ie as mt,if as n3,ig as T2,ih as P3,ii as ah,ij as ia,ik as sa,j as $e,ja as HF,jb as qd,jc as i2,jd as yv,je as v2,jf as Pv,jg as g3,jh as gt,ji as U2,jk as Sl,k as Y0,ka as tl,kb as k,kc as dL,kd as _L,ke as Uo,kf as Dv,kg as qv,kh as D2,ki as ea,kk as tN,l as Sn,la as X0,lb as QC,lc as o2,ld as bv,le as Av,lf as Kg,lg as h3,lh as ih,li as lh,lk as rN,m as rn,ma as GF,mb as Ne,mc as pL,md as g2,me as E2,mf as Wi,mg as np,mh as D3,mj as fh,mk as mp,n as MF,na as Ft,nb as ee,nc as xr,nd as wL,ne as go,nf as Go,ng as zv,nh as F3,ni as eE,nk as _5,o as Z0,oa as WF,ob as Lg,oc as mL,od as h2,oe as Wg,of as N2,og as y3,oh as L3,oi as ip,ok as iN,p as Uf,pa as kg,pb as ol,pc as Ls,pd as CL,pe as lr,pf as sc,pg as vl,ph as B3,pi as na,pj as ch,pk as ve,q as $F,qa as Uu,qb as Bg,qc as Bs,qd as vv,qe as Vs,qf as t3,qg as I2,qh as Kv,qi as op,qj as mc,qk as an,ra as Wf,rb as Kf,rc as s2,rd as NL,re as Ho,rf as Yi,rg as Uv,rh as oh,ri as a5,rj as ap,rk as Rt,s as jd,sa as br,sb as zd,sc as u2,sd as y2,se as Yg,sf as r3,sg as b3,sh as Qv,sj as Hs,sk as Nr,t as OF,ta as ev,tb as vr,tc as gL,td as Wd,te as PL,tf as i3,tg as qs,th as F2,ti as pc,tj as lp,tk as lE,u as Is,ua as ZC,ub as XC,uc as hL,ud as Sr,ue as tr,uf as R2,ug as tp,uh as L2,ui as l5,uj as h5,uk as _l,v as PF,va as Mg,vb as Qf,vc as yL,ve as Tv,vf as Fv,vg as k2,vh as V3,vi as f5,vj as y5,vk as mh,w as Hf,wa as Ms,wb as $s,wc as cv,we as x2,wf as o3,wg as lc,wh as j3,wi as c5,wk as wl,x as HC,xa as JC,xb as Vg,xc as a2,xe as DL,xf as cl,xg as M2,xh as q3,xi as d5,xj as Vt,xk as w5,y as GC,ya as We,yb as Os,yc as l2,yd as RL,ye as FL,yf as dl,yg as fc,yh as z3,yi as p5,yj as Q2,yk as C5,z as J0,za as Rn,zb as Qr,zc as bL,zd as Hg,ze as LL,zf as Jd,zg as Hv,zh as rp,zi as De,zj as xl,zk as N5}from"./chunk-3XFZFOXD.js";function j5(e,n){if(e.length>6)return`${e.length}${q5(e.length)}`,[];let t=[],r=(i,o=[])=>{if(i.length===0)(!n||n(o))&&t.push([...o]);else for(let s=0;s<i.length;s++){let u=i.slice(),a=u.splice(s,1);r(u.slice(),o.concat(a))}};return r(e),t}function q5(e){return e<=1?1:e*q5(e-1)}function z5(e){for(let n in e)n.startsWith("_")&&e.hasOwnProperty(n)&&Object.defineProperty(e,n,{enumerable:!1,configurable:!0,writable:!0,value:e[n]})}var oN=new WeakSet;function hE(e){e!==void 0&&oN.add(e)}function sN(e){return e!==void 0&&oN.has(e)}var mE=new WeakMap,gE=new WeakMap;function U5(e,n){e!==void 0&&(n===void 0?mE.delete(e):mE.set(e,n))}function H5(e){return e===void 0?void 0:mE.get(e)}function G5(e,n){e!==void 0&&(n===void 0?gE.delete(e):gE.set(e,n))}function W5(e){return e===void 0?void 0:gE.get(e)}function hp(e){e!==void 0&&(mE.delete(e),gE.delete(e),oN.delete(e))}function Y5(e){if(typeof e=="object"&&e.kind==="signature"){let n={...e};return delete n.effects,n}return{kind:"signature",variadicArg:{type:"any"},variadicMin:0,result:"unknown"}}function uN(e,n){let t=e.args?.length??0,r=n.args?.length??0,i=e.optArgs?.length??0,o=n.optArgs?.length??0;if(t!==r||i!==o||e.variadicArg===void 0!=(n.variadicArg===void 0)||e.variadicArg&&(e.variadicMin??0)!==(n.variadicMin??0))return!1;let s=(u,a)=>O(u,a)&&O(a,u);for(let u=0;u<t;u++)if(!s(e.args[u].type,n.args[u].type))return!1;for(let u=0;u<i;u++)if(!s(e.optArgs[u].type,n.optArgs[u].type))return!1;return!(e.variadicArg&&!s(e.variadicArg.type,n.variadicArg.type))}var Ko=new WeakMap;function Lre(e){return Ko.has(e)||Ko.set(e,new Map),Ko.get(e)}function Bre(e,n){Lre(e).set(n.name,n)}function Vre(e){if(typeof e=="number")return{type:"exact",values:[e]};let t=e.split(",").map(i=>i.trim()).map(i=>{let o=Number(i);return isNaN(o)?i:o});return{type:t.some(i=>typeof i=="string")?"pattern":"exact",values:t}}function jre(e,n){if(e.values.length!==n.length)return!1;let t=new Map;for(let r=0;r<e.values.length;r++){let i=e.values[r],o=n[r];if(typeof i=="number"){if(i!==o)return!1}else if(t.has(i)){if(t.get(i)!==o)return!1}else t.set(i,o)}return!0}function qre(e){let n=[];for(let[t,r]of e){let i=Vre(t),o=i.values.filter(s=>typeof s=="string").length;n.push({pattern:i,value:r,variableCount:o})}return n.sort((t,r)=>t.pattern.type!==r.pattern.type?t.pattern.type==="exact"?-1:1:t.variableCount-r.variableCount),n}function zre(e,n){for(let{pattern:t,value:r}of e)if(jre(t,n))return r}function Ure(e,n,t){for(let r=0;r<n.length;r++){let i=n[r],o=e[r],s=t[i];if(s&&(s.min!==void 0&&o<s.min||s.max!==void 0&&o>s.max))return!1}return!0}function Hre(e,n,t,r){let i={};for(let u=0;u<t.length;u++)i[t[u]]=e.number(r[u]);let s=n.subs(i).evaluate();if(C(s)){if(s.symbol==="True")return!0;if(s.symbol==="False")return!1}return T(s)?s.re!==0:!1}function aN(e,n,t){let r=t.variables!==void 0&&t.variables.length>1,i=t.variables??[t.variable??"n"],o=i[0],s=t.memoize??!0,u=s?new Map:null,a=t.domain??{},l=t.recurrence,f=null,c=null;t.constraints&&(c=typeof t.constraints=="string"?e.parse(t.constraints):t.constraints);let d=new Map;for(let[m,h]of Object.entries(t.base)){let y=r?String(m):Number(m);d.set(y,typeof h=="number"?e.number(h):h)}let p=r?qre(d):null;return Bre(e,{name:n,variable:r?void 0:o,variables:r?i:void 0,isMultiIndex:r,base:d,memoize:s,memo:u,domain:a,constraints:c??void 0}),(m,{engine:h,numericApproximation:y})=>{f===null&&(f=typeof l=="string"?h.parse(l):l);let b;if(g(m,"Sequence")?b=m.ops.map(_=>_.evaluate().re):g(m,"Tuple")?b=m.ops.map(_=>_.evaluate().re):g(m,"Delimiter")?b=m.ops.map(_=>_.evaluate().re):b=[m.evaluate().re],!b.every(_=>Number.isInteger(_)))return;if(r){let _=a;if(Object.keys(_).length>0&&!Ure(b,i,_))return}else{let _=a,A=b[0];if(_.min!==void 0&&A<_.min||_.max!==void 0&&A>_.max)return}if(c&&!Hre(h,c,i,b))return;let v=r?b.join(","):b[0],E=h._factsHidden()?`facts-hidden|${v}`:v;if(u?.has(E))return u.get(E);if(r){let _=zre(p,b);if(_!==void 0)return u&&u.set(E,_),_}else{let _=b[0];if(d.has(_))return d.get(_)}let x={};for(let _=0;_<i.length;_++)x[i[_]]=h.number(b[_]);let S=f.subs(x),w=y?S.N():S.evaluate();return u&&T(w)&&u.set(E,w),T(w)?w:void 0}}function lN(e,n,t){return!t.base||Object.keys(t.base).length===0?{valid:!1,error:`Sequence "${n}" requires at least one base case`}:t.recurrence?(typeof t.recurrence=="string"?e.parse(t.recurrence):t.recurrence).isValid?{valid:!0}:{valid:!1,error:`Invalid recurrence for "${n}": expression contains errors`}:{valid:!1,error:`Sequence "${n}" requires a recurrence relation`}}var vc=new WeakMap;function vh(e,n){vc.has(e)||vc.set(e,new Map);let t=vc.get(e);return t.has(n)||t.set(n,{base:new Map,isMultiIndex:!1}),t.get(n)}function Z5(e,n,t,r){vh(e,n).base.set(t,r),yE(e,n)}function fN(e,n,t,r){let i=vh(e,n);i.base.set(t,r),i.isMultiIndex=!0,yE(e,n)}function cN(e,n,t,r){let i=vh(e,n);i.recurrence={variable:t,latex:ap(r.json)},yE(e,n)}function J5(e,n,t,r){let i=vh(e,n);i.recurrence={variables:t,latex:ap(r.json)},i.isMultiIndex=!0,yE(e,n)}function yE(e,n){let t=vh(e,n);if(t.base.size===0||!t.recurrence)return;let r={};for(let[l,f]of t.base)r[l]=f;let i={base:r,recurrence:t.recurrence.latex};t.isMultiIndex||t.recurrence.variables?i.variables=t.recurrence.variables:i.variable=t.recurrence.variable;let o=lN(e,n,i);if(!o.valid)throw new Error(o.error);let s=aN(e,n,i),a=e.context.lexicalScope.bindings.get(n);if(a){let l=cr(a);Un(e,n,a,{subscriptEvaluate:s}),e._noteStateEvent({kind:"redefine",callableBefore:l,callableAfter:!0})}else e.declare(n,{subscriptEvaluate:s});vc.get(e).delete(n)}function Eh(e,n){if(g(e)){if(e.operator==="Subscript"){let t=e.op1;if(C(t,n))return!0}return e.ops.some(t=>Eh(t,n))}return!1}function dN(e){if(C(e))return e.symbol;let n=e.symbols;if(n.length===1)return n[0];let t=["n","k","i","j","m"];for(let r of t)if(n.includes(r))return r}function K5(e,n){let r=vc.get(e)?.get(n);if(r){let o=Array.from(r.base.keys());return r.isMultiIndex||o.sort((s,u)=>s-u),{status:"pending",hasBase:r.base.size>0,hasRecurrence:!!r.recurrence,baseIndices:o,variable:r.recurrence?.variable,variables:r.recurrence?.variables}}let i=e.lookupDefinition(n);if(i&&J(i)&&i.value.subscriptEvaluate){let s=Ko.get(e)?.get(n);if(s){let u=Array.from(s.base.keys());return s.isMultiIndex||u.sort((a,l)=>a-l),{status:"complete",hasBase:!0,hasRecurrence:!0,baseIndices:u,variable:s.variable,variables:s.variables}}return{status:"complete",hasBase:!0,hasRecurrence:!0,baseIndices:[]}}return{status:"not-a-sequence",hasBase:!1,hasRecurrence:!1,baseIndices:[]}}function Q5(e,n){let r=Ko.get(e)?.get(n);if(!r)return;let i=Array.from(r.base.keys());return r.isMultiIndex||i.sort((o,s)=>o-s),{name:r.name,variable:r.variable,variables:r.variables,baseIndices:i,memoize:r.memoize,domain:r.domain,cacheSize:r.memo?.size??0,isMultiIndex:r.isMultiIndex}}function X5(e){let n=Ko.get(e),t=vc.get(e);return{registry:n===void 0?void 0:[...n.entries()].map(([r,i])=>({name:r,meta:i,fields:{...i,base:new Map(i.base)}})),pending:t===void 0?void 0:[...t.entries()].map(([r,i])=>({name:r,entry:i,fields:{...i,base:new Map(i.base)}}))}}function eB(e,n){let t=n,r=Ko.get(e);if(r!==void 0){let o=new Map((t.registry??[]).map(s=>[s.name,s]));for(let s of[...r.keys()])o.has(s)||r.delete(s);for(let{name:s,meta:u,fields:a}of t.registry??[])Object.assign(u,a),u.base=new Map(a.base),u.memo?.clear(),r.set(s,u)}let i=vc.get(e);if(i!==void 0){let o=new Map((t.pending??[]).map(s=>[s.name,s]));for(let s of[...i.keys()])o.has(s)||i.delete(s);for(let{name:s,entry:u,fields:a}of t.pending??[])Object.assign(u,a),u.base=new Map(a.base),u.recurrence=a.recurrence,i.set(s,u)}}function nB(e){let n=Ko.get(e);return n?Array.from(n.keys()):[]}function pN(e,n){return Ko.get(e)?.has(n)??!1}function tB(e,n){let t=Ko.get(e);if(t)if(n!==void 0){let r=t.get(n);r?.memo&&r.memo.clear()}else for(let r of t.values())r.memo&&r.memo.clear()}function rB(e,n){let r=Ko.get(e)?.get(n);if(r?.memo)return new Map(r.memo)}function iB(e,n,t,r,i=1){if(!Number.isInteger(t)||!Number.isInteger(r)||i<=0||!Number.isInteger(i)||!pN(e,n))return;let o=[];for(let s=t;i>0?s<=r:s>=r;s+=i){let a=e.parse(`${n}_{${s}}`).evaluate();if(T(a))o.push(a);else return}return o}var Ws=class extends Error{code;declaredName;constructor(n,t,r){super(r),this.code=n,this.declaredName=t}};function xh(e,n,t,r){if(!(t===void 0||r===void 0)&&t.batch===r.batch&&t.statementId!==r.statementId)throw new Ws(e==="type"?"type-redefinition":"protocol-redefinition",n,`The ${e} "${n}" is already declared${uB(t)} in this program. A second declaration of a name in one program is a mistake; to redefine it interactively, re-run it as a separate program.`)}function oB(e,n,t){if(!(n===void 0||t===void 0)&&n.batch===t.batch&&!sB(n,t))throw new Ws("function-redefinition",e,`A clause of "${e}" with this parameter list is already defined${uB(n)} in this program, and this one would silently replace it. Give the clauses different parameter lists to dispatch between them, or edit the existing clause in place; to redefine it interactively, re-run it as a separate program.`)}function sB(e,n){if(e.statementId===n.statementId)return!0;let t=e.firstRange,r=n.firstRange;return t!==void 0&&r!==void 0&&t[0]===r[0]&&t[1]===r[1]}function Sh(e,n){return e===void 0||n===void 0||e.batch!==n.batch?!1:sB(e,n)}function uB(e){let n=e.firstRange;return n===void 0?" earlier":` at characters ${n[0]}-${n[1]}`}function Gre(e,n){for(let t of cn(e))if(n.has(t))return!0;return!1}function Ec(e,n,t,r){if(typeof e=="object"&&e.kind==="variable"){if(!t.has(e.name))return!1;let i=r[e.name];return i!==void 0?Ag(i)===Ag(n):(r[e.name]=n,!0)}if(!Gre(e,t))return O(n,e);if(typeof e!="object")return!1;if(typeof n=="object"&&n.kind==="reference"&&n.alias===!0&&n.def!==void 0)return Ec(e,n.def,t,r);if(typeof n!="object"||n.kind!==e.kind)return!1;switch(e.kind){case"list":{let i=n;return e.dimensions!==void 0&&e.dimensions.join()!==(i.dimensions?.join()??"")?!1:Ec(e.elements,i.elements,t,r)}case"set":case"collection":case"indexed_collection":case"broadcastable":return Ec(e.elements,n.elements,t,r);case"dictionary":return Ec(e.values,n.values,t,r);case"reference":{let i=n;if(e.name!==i.name)return!1;let o=e.args,s=i.args;return o===void 0||s===void 0||o.length!==s.length?!1:o.every((u,a)=>Ec(u,s[a],t,r))}case"tuple":{let i=e.elements??[],o=n.elements??[];return i.length!==o.length?!1:i.every((s,u)=>{let a=o[u];return s.name!==void 0&&a.name!==void 0&&s.name!==a.name?!1:Ec(s.type,a.type,t,r)})}default:return!1}}function bE(e,n,t,r){let i=new Set(n.map(s=>s.name)),o=Object.create(null);if(!Ec(e,t,i,o))return null;for(let s of n){let u=o[s.name];if(u===void 0)return null;if(jF(u)){if(s.bound!==void 0&&!O(u,s.bound))return null;for(let a of s.protocols??[])if(!r(u,a))return null}}return zi(e,o)}function vE(e,n){let t=Object.create(null);for(let r of n)t[r.name]=r.bound??"unknown";return zi(e,t)}function xc(e,n,t){let r=e.length,i=n.length;if(Math.abs(r-i)>t)return t+1;if(r===0)return i;if(i===0)return r;let o=new Array(i+1),s=new Array(i+1),u=new Array(i+1);for(let a=0;a<=i;a++)s[a]=a;for(let a=1;a<=r;a++){u[0]=a;let l=u[0];for(let f=1;f<=i;f++){let c=e[a-1]===n[f-1]?0:1,d=Math.min(s[f]+1,u[f-1]+1,s[f-1]+c);a>1&&f>1&&e[a-1]===n[f-2]&&e[a-2]===n[f-1]&&(d=Math.min(d,o[f-2]+1)),u[f]=d,d<l&&(l=d)}if(l>t)return t+1;[o,s,u]=[s,u,o]}return s[i]}function mN(e,n){let r=null,i=1/0;for(let o of n){let s=xc(e,o,7);if(s===0)return o;s<=7&&s<i&&(i=s,r=o)}return r}function gN(e){if(g(e,"Function")){let r=e.nops-1;return r===0?{required:0,max:1/0}:{required:r,max:r}}if(!C(e))return;let n=e.engine.lookupDefinition(e.symbol);if(n===void 0)return;let t="operator"in n?n.operator.signature.type:n.value.type?.type;return Wre(t)}function Wre(e){if(e===void 0||Ms(e))return;let n=Uu(e);if(n===void 0||n.length!==1)return;let t=n[0];if(t.typeParams!==void 0&&t.typeParams.length>0)return;let r=t.args?.length??0,i=t.optArgs?.length??0;if(t.variadicArg!==void 0){let o=t.variadicMin??0;return{required:o>0?r+i+o:r,max:1/0}}return{required:r,max:r+i}}function Yre(e){return`${e.count} argument${e.count===1?"":"s"} (${e.describes})`}function hN(e){let n=t=>`${t} parameter${t===1?"":"s"}`;return e.required===e.max?`declares ${n(e.required)}`:e.max===1/0?`requires at least ${n(e.required)}`:`takes ${e.required} to ${n(e.max)}`}function Zre(e){if(!g(e,"Function"))return;let n=[];for(let t of e.ops.slice(1)){if(!C(t))return;n.push(t.symbol)}return n.length>0?n:void 0}function Jre(e){if(e===void 0)return;let n=Z(e.type.type);if(n!==void 0&&!(typeof n!="object"||n.kind!=="tuple"))return n.elements?.length}function yp(e,n,t,r){let i=gN(e);if(i===void 0)return;let o=Array.isArray(t)?t:[t];if(o.length===0||o.some(c=>c.count>=i.required&&c.count<=i.max))return;let s=e.engine,u=o.map(Yre).join(" or "),a=C(e)?e.symbol:e.toString(),l=`${n} calls its callback with ${u}; \`${a}\` ${hN(i)}`,f=o.length===1&&o[0].count===1&&o[0].destructurable===!0&&i.required===i.max&&i.required>=2&&Jre(r)===i.required?Zre(e):void 0;return f!==void 0&&(l+=`. To take a ${f.length===2?"pair":"tuple"} apart, use a tuple pattern parameter: ((${f.join(", ")})) => \u2026`),s.error(["callback-arity",l])}function EE(e,n){let t=n;if(cn(t).size===0&&dn(t,"function"))return{rule:"not-callable",actual:t};let r=yN(t);if(r===void 0)return;let i;for(let o of r){let s=Kre(e,o);if(s===void 0)return;i??=s}return i}function yN(e){if(typeof e=="string")return e==="function"||e==="unknown"||e==="any"?void 0:[];switch(e.kind){case"signature":return[e];case"variable":return;case"union":case"intersection":{let n=[];for(let t of e.types){let r=yN(t);if(r===void 0)return;n.push(...r)}return n}case"reference":return e.alias===!0&&e.def!==void 0?yN(e.def):void 0;default:return cn(e).size===0&&dn(e,"function")?[]:void 0}}function Kre(e,n){let t=e.args??[];for(let o=0;o<t.length;o++){let s=t[o].type;if(s==="never"||s==="nothing")continue;let u=Qre(n,o);if(u!==void 0&&!(cn(s).size>0||cn(u).size>0)&&dn(s,u))return{rule:"disjoint-parameter",position:o,expected:s,actual:u}}let r=e.result,i=n.result;if(i!=="never"&&!(cn(r).size>0||cn(i).size>0)&&dn(r,i))return{rule:"disjoint-result",expected:r,actual:i}}function Qre(e,n){let t=e.args??[];if(n<t.length)return t[n].type;let r=e.optArgs??[];return n-t.length<r.length?r[n-t.length].type:e.variadicArg?.type}function aB(e,n){let t=Uu(e);if(t===void 0)return!1;for(let r of t){let i=r.args?.length??0,o=r.variadicArg!==void 0?1/0:i+(r.optArgs?.length??0);if(n>=i&&n<=o)return!1}return!0}function Ve(e){return C(e)&&e.symbol.startsWith("_")||e.operator==="Wildcard"||e.operator==="WildcardSequence"||e.operator==="WildcardOptionalSequence"}function mn(e){if(C(e)&&e.symbol.startsWith("_"))return e.symbol;if(g(e)&&e.nops===1){let n=e.op1;if(e.operator==="Wildcard")return`_${n}`;if(e.operator==="WildcardSequence")return`__${n}`;if(e.operator==="WildcardOptionalSequence")return`___${n}`}return e.operator==="Wildcard"?"_":e.operator==="WildcardSequence"?"__":e.operator==="WildcardOptionalSequence"?"___":null}function rr(e){if(typeof e=="string")return e.startsWith("_")?e.startsWith("__")?e.startsWith("___")?"OptionalSequence":"Sequence":"Wildcard":null;if(C(e)){let n=e.symbol;return n.startsWith("_")?n.startsWith("__")?n.startsWith("___")?"OptionalSequence":"Sequence":"Wildcard":null}if(g(e)){if(e.operator==="Wildcard")return"Wildcard";if(e.operator==="WildcardSequence")return"Sequence";if(e.operator==="WildcardOptionalSequence")return"OptionalSequence"}return null}var Nl=class extends De{_kind="string";[Symbol.toStringTag]="[BoxedString]";_string;_utf8Buffer;_unicodeScalarValues;_graphemes;_isAscii;constructor(n,t,r){super(n,r);let i=t.normalize(),o=!0,s=!0;for(let u=0;u<i.length;u++){let a=i.charCodeAt(u);if(a>=128||a===13)if(o=!1,a>=55296&&a<=56319){let l=i.charCodeAt(u+1);l>=56320&&l<=57343?u++:s=!1}else a>=56320&&a<=57343&&(s=!1)}this._isAscii=o,this._string=s?i:bN(i)}get json(){return`'${this._string}'`}get hash(){return Ei("String"+this._string)}get operator(){return"String"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(n){}get value(){return this}get type(){return k.string}get complexity(){return 19}get string(){return this._string}get buffer(){if(this._utf8Buffer===void 0){let n=new TextEncoder;this._utf8Buffer=n.encode(this._string)}return this._utf8Buffer}get unicodeScalars(){return this._unicodeScalarValues===void 0&&(this._unicodeScalarValues=vN(this._string)),this._unicodeScalarValues}get graphemes(){return this._graphemes===void 0&&(this._graphemes=this._isAscii?this._string.split(""):Cr(this._string)),this._graphemes}get isCollection(){return!0}get isIndexedCollection(){return!0}get isFiniteCollection(){return!0}get count(){return this.graphemes.length}get shape(){return[this.count]}get rank(){return 1}*each(){for(let n of this.graphemes)yield this.engine.character(n)}at(n){let t=this.graphemes;if(n<0&&(n=t.length+n+1),!(n<1||n>t.length))return this.engine.character(t[n-1])}contains(n){let t=Ye(n)||j(n)?n.string:void 0;return t===void 0?!1:this.graphemes.includes(t)}match(n,t){return rE(n)||(n=this.engine.expr(n,{form:"raw"})),Ve(n)?{[mn(n)]:this}:!j(n)&&!Ye(n)?null:this._string===n.string?{}:null}};function bN(e){return e.toWellFormed?.()??Xre(e)}function Xre(e){let n="";for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=e[t]+e[t+1],t++):n+="\uFFFD"}else r>=56320&&r<=57343?n+="\uFFFD":n+=e[t]}return n}function vN(e){let n=[];for(let t=0;t<e.length;t++){let r=e.codePointAt(t);n.push(r),r>65535&&t++}return n}function bp(e){return e.length===0?!1:e.length===1&&e.charCodeAt(0)<128&&e!=="\r"?!0:Cr(e.normalize()).length===1}var xE=class extends De{_kind="character";[Symbol.toStringTag]="[BoxedCharacter]";_string;_unicodeScalarValues;constructor(n,t,r){super(n,r),this._string=bN(t.normalize())}get json(){return["CharacterFrom",`'${this._string}'`]}get hash(){return Ei("String"+this._string)}get operator(){return"CharacterFrom"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(n){}get value(){return this}get type(){return k.character}get complexity(){return 19}get string(){return this._string}get unicodeScalars(){return this._unicodeScalarValues===void 0&&(this._unicodeScalarValues=vN(this._string)),this._unicodeScalarValues}match(n,t){return rE(n)||(n=this.engine.expr(n,{form:"raw"})),Ve(n)?{[mn(n)]:this}:!Ye(n)&&!j(n)?null:this._string===n.string?{}:null}};function SE(e,n){if(j(n)&&bp(n.string))return e.character(n.string)}var lB=K("indexed_collection<number>");function _h(e){return e.isCollection||lr(e.type.type)}function dB(e){let n=Ln(e);return typeof n!="string"&&"elements"in n&&n.elements==="never"?!1:PL(n)}function EN(e,n,t,r){return O(t,"number")&&dB(n.type.type)?e.typeError(r??t,n.type,n):n}function RN(e,n){e._withoutFacts(()=>{let t="real";for(let r of n)if(r.type.facts.couldBeNonReal){t="number";break}for(let r of n)if(nr(r)){if(r.isLazyCollection)continue;for(let i of r.each())_h(i)||i._infer(()=>t)}else _h(r)||r._infer(()=>t)})}function pB(e,n,t){if(typeof n=="string"||n.kind!=="signature")return;let r=new Map;for(let o of n.typeParams??[])o.bound!==void 0&&O(o.bound,"number")&&r.set(o.name,o.bound);if(r.size===0)return;let i=o=>{let s=iv(n,o);if(!(s===void 0||typeof s=="string"||s.kind!=="variable"))return r.get(s.name)};e._withoutFacts(()=>{t.forEach((o,s)=>{let u=i(s);if(u!==void 0)if(nr(o)){if(o.isLazyCollection)return;for(let a of o.each())_h(a)||a._infer(()=>u)}else _h(o)||o._infer(()=>u)})})}function ln(e,n,t){if(n=ge(n),!e.strict){if(n.length>=t)return n;let o=[...n];for(;o.length<t;)o.push(e.error("missing"));return o}if(n.length===t)return n;let r=[...n.slice(0,t)],i=Math.min(t,n.length);for(;i<t;)r.push(e.error("missing")),i+=1;for(;i<n.length;)r.push(e.error("unexpected-argument",n[i].toString())),i+=1;return r}function NE(e,n){if(!C(n))return null;r2(e);let t=n.symbol;if(!/^[A-Z]$/.test(t)||!n.operatorDefinition)return null;let r=e.context.lexicalScope;for(;r&&!r.bindings.has(t);)r=r.parent;if(!r)return null;let i=r.bindings.get(t);if(!r.parent){if(!Q(i)||i.operator instanceof Vt&&i.operator._isLambda)return null;e.declare(t,"unknown");let o=e.context.lexicalScope;for(;o&&!o.bindings.has(t);)o=o.parent;let s=o?.bindings.get(t);return o&&s&&J(s)&&(s.value._isDevolvedShadow=!0,e._boxingState.noteDevolvedShadow(o)),e.box(t)}return J(i)&&i.value._isDevolvedShadow?e.box(t):null}function Rr(e,n,t){let r=typeof t=="number"?t:t?.count,i=typeof t=="number"?void 0:t?.flatten;if(i&&n.some(a=>Gi(a))?n=ge(n):i&&n.some(a=>dv(a))?n=S5(n,i):n=ge(n,i),!e.strict){let a=n;if(r!==void 0&&n.length<r){let l=[...n];for(;l.length<r;)l.push(e.error("missing"));a=l}return e._withoutFacts(()=>{let l="real";for(let f of a)if(f.type.facts.couldBeNonReal){l="number";break}for(let f of a)_h(f)||f._infer(()=>l)}),a}let o=!0;r??=n.length;let s=[],u=Math.max(r-1,n.length-1);for(let a=0;a<=u;a++){let l=n[a];if(a>r-1)o=!1,s.push(e.error("unexpected-argument",l.toString()));else if(l===void 0)o=!1,s.push(e.error("missing"));else if(!l.isValid)o=!1,s.push(l);else if(l.isNumber)s.push(l);else if(l.operator==="Quantity")s.push(l);else if(C(l)&&!e.lookupDefinition(l.symbol))s.push(l);else if(l.type.isUnknown||l.type.type==="any")s.push(l);else if(dB(l.type.type))o=!1,s.push(e.typeError("number",l.type,l));else if(l.type.facts.containsMissing){let f=Ln(l.type.type);f!=="never"&&dn(f,"number")&&!Yg(f)&&!tr(f)?(o=!1,s.push(e.typeError("number",l.type,l))):s.push(l)}else if(Yg(l.type.type))s.push(l);else if(tr(l.type.type))s.push(l);else if(pe(l))s.push(l);else if(nr(l))if(l.type.matches(lB))s.push(l);else if(l.isLazyCollection)s.push(l);else{let f=!0;for(let c of l.each()){let d=c.type.type;if(!(C(c)&&typeof d!="string"&&d.kind==="signature")&&!c.type.isUnknown&&!c.isNumber){f=!1;break}}f?s.push(l):(o=!1,s.push(e.typeError("number",l.type,l)))}else if(l.isIndexedCollection&&l.isFiniteCollection===void 0&&l.type.matches(lB))s.push(l);else if(l.valueDefinition?.inferredType&&O("number",l.type.type))s.push(l);else if(l.operatorDefinition?.inferredSignature&&O("number",l.type.type))s.push(l);else if(l.operator==="Hold"||l.valueDefinition?.value?.operator==="Hold")s.push(l);else if(l.type.couldMatch("number"))s.push(l);else{let f=l.operatorDefinition?NE(e,l):null;f?s.push(f):(o=!1,s.push(e.typeError("number",l.type,l)))}}return o&&RN(e,s),s}var eie=K("broadcastable<number> | missing | nothing | function | error");function Si(e,n){let t=n.find(r=>r.isValid&&!T(r)&&(r.type.type==="never"||!r.type.facts.belowNumber)&&r.type.isDisjointFrom(eie));if(t!==void 0)return e.typeError("number",t.type,t)}function xp(e){return e.some(n=>C(n,"Missing"))&&!e.some(n=>n.isCollection||n.type.matches("collection<any>"))}function Sp(e,n){if(n===void 0)return e.NaN;let t=Ln(n.type.type);return O(t,"number")?e.NaN:e.Missing}var fB=new Set(["list","set","collection","indexed_collection","dictionary","tuple","record"]);function AN(e){let n=fe(e);return typeof n!="string"&&n.kind==="union"?n.types.map(t=>fe(t)):[n]}function mB(e){return typeof e=="string"?fB.has(e):fB.has(e.kind)}function nie(e){let n=fe(e);if(typeof n=="string"||n.kind!=="union")return!1;let t=!1,r=!1;for(let i of AN(n)){if(i==="function"||typeof i!="string"&&i.kind==="signature"){t=!0;continue}if(!O(i,"number"))return!1;r=!0}return t&&r}function IE(e){if(cn(e).size>0)return!0;let n=AN(e);return n.some(t=>t==="function"||t==="any"||t==="unknown"||typeof t!="string"&&t.kind==="signature")?!0:n.every(mB)}var cB=new WeakMap;function tie(e,n){let t=cB.get(e);if(t!==void 0&&t.signature===n)return t.arms;let r=n.type,i=null;typeof r!="string"&&(r.kind==="signature"?i=[r]:i=Yi(r)??null);let o=u=>IE(u)?null:{t:u,collectionArm:AN(u).some(mB)},s=null;return i!==null&&i.length>0&&(s=i.map(u=>{let a=(u.args??[]).map(f=>o(f.type)),l=(u.optArgs??[]).map(f=>o(f.type));return{req:a,opt:l,varParam:u.variadicArg===void 0?null:o(u.variadicArg.type),minArity:u.args?.length??0,maxArity:u.variadicArg!==void 0?1/0:(u.args?.length??0)+(u.optArgs?.length??0)}}),s.some(u=>u.varParam!==null||u.req.some(a=>a!==null)||u.opt.some(a=>a!==null))||(s=null)),cB.set(e,{signature:n,arms:s}),s}function xN(e,n){if(n<e.req.length)return e.req[n];let t=n-e.req.length;return t<e.opt.length?e.opt[t]:e.varParam}function gB(e,n,t,r,i,o){if(i.length===0)return;let s=tie(n,t);if(s===null)return;let u=s.filter(f=>i.length>=f.minArity&&i.length<=f.maxArity);if(u.length===0)return;let a=(f,c,d)=>{if(!f.isValid)return!1;let p=N2(f);if(p===void 0&&!C(f,"Nothing")||r&&Ho(f))return!1;if(f.isNaN===!0&&o!==void 0){let m=o(d);if(m==="propagate"||m==="handle")return!1}return c.collectionArm&&p!==void 0&&(g(p,"List")||g(p,"Tuple"))?!1:Wi(f,c.t)==="refute"},l=!1;for(let f of u){let c=!0;for(let d=0;d<i.length;d++){let p=xN(f,d);if(p!==null&&a(i[d],p,d)){c=!1,l=!0;break}}if(c)return}if(l){for(let f=0;f<i.length;f++){let c=u.map(p=>xN(p,f));if(c.some(p=>p===null||!a(i[f],p,f)))continue;let d=c.length===1?c[0].t:Bn({kind:"union",types:c.map(p=>p.t)});return e.typeError(d,i[f].type,i[f])}for(let f=0;f<i.length;f++){let c=xN(u[0],f);if(c!==null&&a(i[f],c,f))return e.typeError(c.t,i[f].type,i[f])}}}function SN(e,n){if(!g(e,"List")&&!g(e,"Tuple")||typeof n=="string")return;if(e.operator==="Tuple"&&n.kind==="tuple"){if(n.elements.length!==e.nops)return;e.ops.forEach((r,i)=>{let o=n.elements[i].type;o==="unknown"||o==="any"||C(r)&&r._infer(()=>o,"narrow")});return}let t=Z(n);if(!(t===void 0||t==="unknown"||t==="any"))for(let r of e.ops)C(r)&&r._infer(()=>t,"narrow")}function _N(e,n,t,r=!1){let i=n.valueDefinition,o=i.value,s=o===void 0?e._staticAssignmentEvidence?.get(i):void 0;if(o===void 0&&s===void 0)return r||n._infer(()=>t,"narrow"),"narrowed";let u=o!==void 0?o.type.type:s;return O(u,t)?"admitted":"fall-through"}function RE(e,n){if(IE(n)&&!nie(n))return!1;if(N2(e)!==void 0)return Wi(e,n)==="admit";if(C(e)){let t=e.valueDefinition,r=t===void 0?void 0:e.engine._staticAssignmentEvidence?.get(t);if(r!==void 0&&!O(r,n))return!1}return Hi(e.type.type,n)}function rt(e,n,t){if(n==null)return e.error("missing");if(t===void 0)return e.error("unexpected-argument",n.toString());if(n=n.canonical,!n.isValid||n.type.matches(t))return n;let r=TE(e,n,t);return r!==void 0?r:Go(t)&&Wi(n,t)!=="refute"||Dg(n.type.type,t)||AE(n,t)||Pg(n.type.type,t)||RE(n,t)?n:e.typeError(t,n.type,n)}function rie(e){if(typeof e=="object"){if(e.kind==="signature")return[e];if(e.kind==="union")return e.types.filter(n=>typeof n=="object"&&n.kind==="signature")}return[]}function AE(e,n){let t=e.type.type;if(typeof t!="object"||t.kind!=="signature")return!1;for(let r of rie(n)){let i=h3(t,r);if(i!==t&&O(i,r))return!0}return!1}function TN(e){if(e==="character")return!0;if(typeof e=="string"||e.kind!=="union")return!1;let n=!1;for(let t of e.types){if(O("string",t))return!1;t==="character"&&(n=!0)}return n}function TE(e,n,t){if(j(n)&&TN(t))return SE(e,n)}function kE(e,n){if(!g(e,"Function")||typeof n!="object"||n.kind!=="signature")return n;let t=n.args??[];if(t.length===0)return n;let r=e.ops.slice(1),i=!1,o=t.map((s,u)=>{let a=r[u];return a===void 0||gl(a)!==void 0||s.type==="unknown"?s:(i=!0,{...s,type:"unknown"})});return i?{...n,args:o}:n}function Ep(e){if(typeof e=="object"){if(e.kind==="reference")return e.alias!==!0||e.def===void 0?void 0:Ep(e.def);if(e.kind==="signature")return[e];if(e.kind==="union"){let n=[];for(let t of e.types)typeof t=="object"&&t.kind==="signature"&&n.push(t);return n.length>0?n:void 0}if(e.kind==="intersection"){let n=[];for(let t of e.types){if(typeof t!="object"||t.kind!=="signature")return;n.push(t)}return n.length>0?n:void 0}}}function _E(e,n,t){if(t===void 0)return;let r=Ep(n);if(r===void 0)return;let i=kE(e,e.type.type);if(cn(i).size>0||dn(i,"function")||r.some(u=>R2(u,i)))return;let o=[],s=new Set;for(let u of r){let{min:a,max:l}=i3(u),f=Number.isFinite(l)?Array.from({length:l-a+1},(c,d)=>[a+d,"per the declared parameter list"]):[[a,"at least, per the declared parameter list"]];for(let[c,d]of f){let p=`${c}:${d}`;s.has(p)||(s.add(p),o.push({count:c,describes:d}))}}return yp(e,t,o)}function wN(e,n,t,r){let i=Ep(t);if(i===void 0)return;let o=kE(n,n.type.type);if(cn(o).size>0||dn(o,"function"))return;let s=!1;for(let u of i)if(R2(u,o)&&(s=!0,!!Wf(o,u)&&EE(u,o)===void 0))return"admit";return s?e.typeError(r??t,n.type,n):"admit"}function wh(e,n,t){if(n.length===t.length&&n.every((i,o)=>i.type.matches(t[o])))return n;let r=[];for(let i=0;i<=t.length-1;i++)r.push(rt(e,n[i],t[i]));for(let i=t.length;i<=n.length-1;i++)r.push(e.error("unexpected-argument",n[i].toString()));return r}function CN(e,n,t,r){if(!r?.(t)||!e.type.facts.containsMissing)return!1;let i=Ln(e.type.type);return i==="never"||O(i,n)}function wE(e,n,t){if(!t||e.isNaN!==!0)return!1;let r=t(n);return r==="propagate"||r==="handle"}function ht(e,n,t,r,i,o,s,u){if(n.some($=>$.operator==="Spread"))return null;if(!e.strict){if(typeof t!="string"&&t.kind==="signature"){let $=t.args?.length??0;if(n.length<$){let L=[...n];for(;L.length<$;)L.push(e.error("missing"));return L}}else{let $=Yi(t);if($){let L=Math.min(...$.map(z=>z.args?.length??0));if(n.length<L){let z=[...n];for(;z.length<L;)z.push(e.error("missing"));return z}}}return null}if(typeof t=="string")return null;let a,l,f;if(t.kind==="signature")a=t;else{let $=Yi(t);if(!$)return null;let L={lazy:r,threadable:i,couldBeUnkeyedCollection:Ho,stripMissing:s,freshMatrixRepair:(ce,ze)=>CE(e,ce,ze,o)},z=ce=>(ze,En,tn,Nn)=>e._withBoxingPassWindow(()=>e._withRolledBackInference(()=>{let _e=ht(e,Nn,ze,r,i,o,s,{trial:!0,overlapTrial:ce||void 0,armSolution:tn,nanPolicyAt:u?.nanPolicyAt,operatorName:u?.operatorName,checkNumericCollections:u?.checkNumericCollections});if(_e===null)return null;let fn=[];return _e.forEach((Xn,Ja)=>{Xn.isValid||fn.push(Ja)}),fn.length===0?null:fn},{forbidsRepairs:!0})),U=z(!1),H=dl(e,n,$,L,void 0,U);u?.resolutionOut!==void 0&&(u.resolutionOut.resolution=H);let{selected:X,viable:G,selectedSolution:ne}=H;if(!X){let ce=dl(e,n,$,L,void 0,z(!0));ce.selected&&(u?.resolutionOut!==void 0&&(u.resolutionOut.resolution=ce),{selected:X,viable:G,selectedSolution:ne}=ce)}if(!X){let{arityViable:ce,arityTarget:ze,refuted:En}=Lv(e,n,$,L,U);if(ce.length===0){let Nn=ze??n.length,_e=n.map((fn,Xn)=>Xn<Nn?fn:e.error("unexpected-argument",fn.toString()));for(;_e.length<Nn;)_e.push(e.error("missing"));return _e}let tn=n.map((Nn,_e)=>{let fn=En.get(_e);return fn===void 0?Nn:_E(Nn,fn,u?.operatorName)??e.typeError(fn,Nn.type,Nn)});return tn.every(Nn=>Nn.isValid)&&(tn[0]=e.error("unexpected-argument",n[0]?.toString()??"")),tn}a=X,l=G,f=ne}let c=[],d=!0,p=!1,m=new Set,h=JL(a),y=h?f??u?.armSolution??KL(h,n,{threadable:i,stripMissing:s,lazy:r,resolver:e._typeResolver}):void 0,b=!1,v=$=>{if(!y)return $;let L=Pv($,y.bindings);return L!==void 0?L:(b=!0,"any")},E=new Set;y&&y.absorbed.size>0&&h&&YC(h,n.length).forEach((L,z)=>{if(L!==void 0){for(let U of cn(L))if(y.absorbed.has(U)){E.add(z);return}}});let x=a.args?.map($=>v($.type))??[],S=a.optArgs?.map($=>v($.type))??[],w=a.variadicArg===void 0?void 0:v(a.variadicArg.type),_=a.variadicMin??0,A=y&&y.unbound.size>0?{...y.bindings,...Object.fromEntries([...y.unbound].map($=>[$,"unknown"]))}:void 0,N=($,L)=>{if(A===void 0)return L;let z=Pv($,A);return z===void 0?L:Bn(z)},I=a.args?.map(($,L)=>N($.type,x[L]))??[],B=a.optArgs?.map(($,L)=>N($.type,S[L]))??[],F=a.variadicArg===void 0||w===void 0?void 0:N(a.variadicArg.type,w),q=($,L)=>{if(b)return;if(!l)return L;let z=u3(l,$);if(!(z!==void 0&&cn(z).size>0))return z},M=0;for(let $ of x){let L=M,z=n[M++];if(!z){c.push(e.error("missing")),d=!1;continue}if(r){c.push(z);continue}if(!z.isValid){c.push(z),d=!1;continue}if(z.type.isUnknown||z.type.type==="any"){c.push(z);continue}if(oc(i,L)&&Ho(z)){let X=u?.checkNumericCollections?EN(e,z,$,I[L]):z;c.push(X),X.isValid||(d=!1);continue}if(E.has(L)){c.push(z),m.add(c.length-1);continue}let U=_E(z,$,u?.operatorName);if(U!==void 0){c.push(U),d=!1;continue}if(z.valueDefinition?.inferredType&&z.type.matches($)){c.push(z);continue}if(e._withoutFacts(()=>!b&&z.valueDefinition?.inferredType&&O($,z.type.type)&&!Go($)&&Ep($)===void 0&&Wf(z.type.type,$)?_N(e,z,$,u?.noInference):"fall-through")!=="fall-through"){c.push(z);continue}if(z.operatorDefinition?.inferredSignature&&z.type.matches($)){c.push(z);continue}if(Dg(z.type.type,$)){c.push(z);continue}if(!z.type.matches($)){let X=wN(e,z,$,I[L]);if(X==="admit"){c.push(z),m.add(c.length-1);continue}if(X!==void 0){c.push(X),d=!1;continue}let G=TE(e,z,$);if(G!==void 0){c.push(G),p=!0;continue}if(Go($)&&Wi(z,$)!=="refute"){c.push(z),m.add(c.length-1);continue}if(CN(z,$,L,s)){c.push(z),m.add(c.length-1);continue}if(wE(z,L,u?.nanPolicyAt)){c.push(z),m.add(c.length-1);continue}if(u?.trial){if(CE(e,z,$,o)){c.push(z);continue}if(Fv(e,z)){c.push(z);continue}}else{let ne=NN(e,z,$,o);if(ne){c.push(ne),p=!0;continue}let ce=NE(e,z);if(ce!==null){c.push(ce),p=!0;continue}}if(Pg(z.type.type,$)){c.push(z),m.add(c.length-1);continue}if(AE(z,$)){c.push(z);continue}if((!u?.trial||u?.overlapTrial)&&RE(z,$)){c.push(z),m.add(c.length-1);continue}c.push(e.typeError(I[L]??$,z.type,z)),d=!1;continue}c.push(z)}for(let $ of S){let L=n[M];if(!L)break;if(r){c.push(L),M+=1;continue}if(!L.isValid){c.push(L),d=!1,M+=1;continue}if(L.type.isUnknown||L.type.type==="any"){c.push(L),M+=1;continue}if(oc(i,M)&&Ho(L)){let H=u?.checkNumericCollections?EN(e,L,$,B[M-x.length]):L;c.push(H),H.isValid||(d=!1),M+=1;continue}if(E.has(M)){c.push(L),m.add(c.length-1),M+=1;continue}let z=_E(L,$,u?.operatorName);if(z!==void 0){c.push(z),d=!1,M+=1;continue}if(L.valueDefinition?.inferredType&&L.type.matches($)){c.push(L),M+=1;continue}if(e._withoutFacts(()=>!b&&L.valueDefinition?.inferredType&&O($,L.type.type)&&!Go($)&&Ep($)===void 0&&Wf(L.type.type,$)?_N(e,L,$,u?.noInference):"fall-through")!=="fall-through"){c.push(L),M+=1;continue}if(Dg(L.type.type,$)){c.push(L),M+=1;continue}if(!L.type.matches($)){let H=wN(e,L,$,B[M-x.length]);if(H==="admit"){c.push(L),m.add(c.length-1),M+=1;continue}if(H!==void 0){c.push(H),d=!1,M+=1;continue}let X=TE(e,L,$);if(X!==void 0){c.push(X),p=!0,M+=1;continue}if(Go($)&&Wi(L,$)!=="refute"){c.push(L),m.add(c.length-1),M+=1;continue}if(CN(L,$,M,s)){c.push(L),m.add(c.length-1),M+=1;continue}if(wE(L,M,u?.nanPolicyAt)){c.push(L),m.add(c.length-1),M+=1;continue}if(u?.trial){if(CE(e,L,$,o)){c.push(L),M+=1;continue}if(Fv(e,L)){c.push(L),M+=1;continue}}else{let G=NN(e,L,$,o);if(G){c.push(G),p=!0,M+=1;continue}let ne=NE(e,L);if(ne!==null){c.push(ne),p=!0,M+=1;continue}}if(Pg(L.type.type,$)){c.push(L),m.add(c.length-1),M+=1;continue}if(AE(L,$)){c.push(L),M+=1;continue}if((!u?.trial||u?.overlapTrial)&&RE(L,$)){c.push(L),m.add(c.length-1),M+=1;continue}c.push(e.typeError(B[M-x.length]??$,L.type,L)),d=!1,M+=1;continue}c.push(L),M+=1}if(w){let $=0;for(let L of n.slice(M)){if(M+=1,$+=1,r){c.push(L);continue}if(!L.isValid){c.push(L),d=!1;continue}if(L.type.isUnknown||L.type.type==="any"){c.push(L);continue}if(oc(i,M-1)&&Ho(L)){let H=u?.checkNumericCollections?EN(e,L,w,F):L;c.push(H),H.isValid||(d=!1);continue}if(E.has(M-1)){c.push(L),m.add(c.length-1);continue}let z=_E(L,w,u?.operatorName);if(z!==void 0){c.push(z),d=!1;continue}if(L.valueDefinition?.inferredType&&L.type.matches(w)){c.push(L);continue}if(e._withoutFacts(()=>!b&&L.valueDefinition?.inferredType&&O(w,L.type.type)&&!Go(w)&&Ep(w)===void 0&&Wf(L.type.type,w)?_N(e,L,w,u?.noInference):"fall-through")!=="fall-through"){c.push(L);continue}if(Dg(L.type.type,w)){c.push(L);continue}if(!L.type.matches(w)){let H=wN(e,L,w,F);if(H==="admit"){c.push(L),m.add(c.length-1);continue}if(H!==void 0){c.push(H),d=!1;continue}let X=TE(e,L,w);if(X!==void 0){c.push(X),p=!0;continue}if(Go(w)&&Wi(L,w)!=="refute"){c.push(L),m.add(c.length-1);continue}if(CN(L,w,M-1,s)){c.push(L),m.add(c.length-1);continue}if(wE(L,M-1,u?.nanPolicyAt)){c.push(L),m.add(c.length-1);continue}if(u?.trial){if(CE(e,L,w,o)){c.push(L);continue}if(Fv(e,L)){c.push(L);continue}}else{let G=NN(e,L,w,o);if(G){c.push(G),p=!0;continue}let ne=NE(e,L);if(ne!==null){c.push(ne),p=!0;continue}}if(Pg(L.type.type,w)){c.push(L),m.add(c.length-1);continue}if(AE(L,w)){c.push(L);continue}if((!u?.trial||u?.overlapTrial)&&RE(L,w)){c.push(L),m.add(c.length-1);continue}c.push(e.typeError(F??w,L.type,L)),d=!1;continue}c.push(L)}$<_&&(c.push(e.error("missing")),d=!1)}if(M<n.length)for(let $ of n.slice(M))c.push(e.error("unexpected-argument",$.toString())),d=!1;if(y&&y.failures.length>0&&h){let $=YC(h,n.length);for(let L of y.failures){let z=L.index??0;if(z>=c.length||!c[z].isValid)continue;if(L.kind==="bound"&&wE(n[z],z,u?.nanPolicyAt)){m.add(z);continue}if(L.kind==="protocol"){c[z]=e.error(["protocol-constraint-unsatisfied",`\`${re(L.solution)}\` does not conform to the \`${L.protocol}\` protocol (\`${L.variable}\` is constrained by \`where ${L.variable} is ${L.protocol}\`)`],n[z]?.toString()),d=!1;continue}let U=$[z],H=L.kind==="upper"&&L.pin!==void 0?L.pin:L.kind==="bound"?L.expected:void 0,X=H!==void 0&&U!==void 0?Pv(U,{...y.bindings,[L.variable]:H})??L.expected:L.expected;c[z]=e.typeError(X,n[z]?.type,n[z]),d=!1}}if(!d)return c;let V=p?c:n;return u?.noInference||e._withoutFacts(()=>{M=0;for(let $ of x){let L=q(M,$);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho(V[M]))&&(V[M]._infer(()=>L),SN(V[M],L)),M+=1}for(let $ of S){if(!V[M])break;let L=q(M,$);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho(V[M]))&&(V[M]._infer(()=>L),SN(V[M],L)),M+=1}if(w)for(let $ of V.slice(M)){let L=q(M,w);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho($))&&($._infer(()=>L),SN($,L)),M+=1}}),p?c:null}function hB(e,n){return e.type("matrix").matches(n)}function CE(e,n,t,r){if(!r||!hB(e,t))return!1;let i=new Set;for(let s of n.freeVariables){let u=e.lookupDefinition(s);!u||!J(u)||!u.value.inferredType||(r.has(u.value)||u.value.type.isUnknown)&&i.add(s)}if(i.size===0)return!1;let o=vp(n,i);return o!==null&&o.size>0}function NN(e,n,t,r){if(!r||!hB(e,t))return null;let i=new Set;for(let d of n.freeVariables){let p=e.lookupDefinition(d);!p||!J(p)||!p.value.inferredType||(r.has(p.value)||p.value.type.isUnknown)&&i.add(d)}if(i.size===0)return null;let o=vp(n,i);if(!o||o.size===0)return null;r2(e);let s=new Map,u=new Map,a=new Map,l=[],f=Lt(e);for(let d of o){let p=e.lookupDefinition(d);if(!p||!J(p)||!p.value.inferredType)return null;s.set(d,p.value._typeSlotSnapshot()),u.set(d,p.value._typeProvenance?.slice()),a.set(d,p.value.type);let m=p.value.type.isUnknown;if(f!==void 0){let h=p.value,y=h._typeSlotSnapshot();f.record({undo:()=>h._restoreTypeSlots(y)})}if(p.value.type=e.type("matrix"),p.value.inferredType=!1,Ls(e,p.value,{type:p.value.type,kind:"inferred",axis:"type",cause:n,epoch:Bs(e)}),m&&e._inferenceTxDepth>0&&!e._freshlyInferred?.has(p.value)){let h=e._freshlyInferred??=new Set;if(f!==void 0){let y=p.value;f.record({undo:()=>h.delete(y)})}h.add(p.value),l.push(p.value)}}e._noteStateEvent({kind:"inference"});let c=e.box(n.json);if(c.type.matches(t)){let d=e._narrowingSink;for(let p of o){let m=e.lookupDefinition(p);m&&J(m)&&(m.value.inferredType=!0,d!==void 0&&d._recordNarrowing(p,m,a.get(p),m.value.type))}return c}for(let d of o){let p=e.lookupDefinition(d);p&&J(p)&&(p.value._restoreTypeSlots(s.get(d)),p.value._typeProvenance=u.get(d))}for(let d of l)e._freshlyInferred?.delete(d);return e._noteStateEvent({kind:"inference"}),null}function vp(e,n){if(C(e))return n.has(e.symbol)?new Set([e.symbol]):null;if(!g(e))return null;if(e.operator==="Negate")return vp(e.op1,n);if(e.operator==="Add"||e.operator==="Subtract"){let t=new Set;for(let r of e.ops){let i=vp(r,n);if(!i)return null;for(let o of i)t.add(o)}return t}if(e.operator==="Multiply"){let t=e.ops.map(r=>vp(r,n)).filter(r=>r!==null);return t.length!==1?null:t[0]}return e.operator==="Power"&&e.op2?.isInteger===!0?vp(e.op1,n):null}function iie(e){let{symbols:n,operators:t}=oie(e.engine),r={},i=o=>{if(C(o)&&!o.symbol.startsWith("_")){if(!(o.symbol in r)&&!n.includes(o.symbol)){let s=mN(o.symbol,n);s&&(r[o.symbol]=s)}}else if(g(o)&&!o.operator.startsWith("_")){let s=o.operator;if(!(s in r)&&!t.includes(s)){let u=mN(s,t);u&&(r[s]=u)}for(let u of o.ops)i(u)}};return i(e),r}function oie(e){let n=[],t=[],r=e.context.lexicalScope;for(;r;){for(let[i,o]of r.bindings)J(o)&&n.push(i),Q(o)&&t.push(i);r=r.parent}return{symbols:n,operators:t}}function Ch(e){let n=iie(e);if(Object.keys(n).length===0)return"";if(Object.keys(n).length===1){let[r,i]=Object.entries(n)[0];return`Unknown symbol "${r}". Did you mean "${i}"?`}let t=[];for(let[r,i]of Object.entries(n))t.push(`- "${r}" -> "${i}"?`);return`Unknown symbols found:
|
|
1
|
+
/** Compute Engine 0.129.1 */
|
|
2
|
+
import{$ as el,$a as Jf,$b as Q,$c as SL,$d as Bt,$e as $v,$f as Qd,$g as Xu,$h as Zo,$i as W2,$j as S5,$k as yh,A as Gf,Aa as Z,Ab as Xt,Ac as vL,Ae as S2,Af as s3,Ag as v3,Ah as U3,Aj as rE,Ak as R5,B as WC,Ba as YF,Bb as e2,Bc as nc,Be as _2,Bf as Kd,Bg as Qu,Bh as H3,Bi as Cr,Bj as Zn,Bk as fE,C as Qa,Ca as ZF,Cb as Ud,Cc as ul,Ce as BL,Cf as Lv,Cg as E3,Ch as G3,Ci as m5,Cj as Ei,Ck as A5,D as DF,Da as Hu,Db as jg,Dc as EL,De as VL,Df as u3,Dg as cc,Dh as W3,Dj as fr,Dk as T5,E as Ag,Ea as se,Eb as Hd,Ec as Wu,Ed as Ev,Ee as Iv,Ef as a3,Eg as Gv,Eh as Y3,Ei as g5,Ej as gc,Ek as I5,F as re,Fa as fe,Fb as On,Fc as Yu,Fe as ho,Ff as A2,Fg as Wv,Fh as Xv,Fi as nE,Fj as X2,Fk as cE,G as FF,Ga as co,Gb as Ps,Gc as qo,Gd as AL,Ge as Yd,Gf as l3,Gg as x3,Gh as sh,Gi as sp,Gj as vo,Gk as k5,H as _t,Ha as JF,Hb as sr,Hc as T,He as jL,Hf as Bv,Hg as S3,Hh as Z3,Hi as sn,Hj as b5,Hk as ua,I as LF,Ia as KC,Ib as Er,Ic as C,Id as TL,Ie as ic,If as f3,Ig as Yv,Ih as J3,Ii as ta,Ij as v5,Ik as hc,J as K0,Ja as KF,Jb as qg,Jc as ur,Jd as xv,Je as on,Jf as c3,Jg as dc,Jh as K3,Ji as H2,Jj as fp,Jk as le,K as BF,Ka as QF,Kb as Ds,Kc as g,Kd as rc,Ke as Zg,Kf as pl,Kg as Wo,Kh as Q3,Kj as E5,Kk as M5,L as wt,La as XF,Lb as ov,Lc as j,Ld as IL,Le as w2,Lg as $2,Lh as X3,Lj as cp,Lk as $5,M as Xa,Ma as nv,Mb as sv,Mc as Ye,Md as Sv,Me as qL,Mf as uc,Mg as Zv,Mh as wr,Mi as G2,Mj as x5,Mk as dE,N as pt,Na as Ln,Nb as uv,Nc as al,Nd as _v,Ne as Ue,Nf as d3,Ng as _3,Nh as B2,Ni as Ji,Nj as dh,Nk as Cl,O as cn,Oa as Yf,Ob as Xf,Oc as Qe,Od as wv,Oe as Zd,Of as Ku,Og as Yo,Oh as e5,Oi as Us,Oj as iE,Ok as O5,P as Q0,Pa as eL,Pb as sl,Pc as Vn,Pd as kL,Pe as kv,Pf as yo,Pg as th,Ph as uh,Pj as oE,Pk as yc,Q as zi,Qa as $g,Qb as Fs,Qc as f2,Qd as ML,Qe as zL,Qf as Vv,Qh as n5,Qj as oa,Qk as gp,R as VF,Ra as tv,Rb as av,Rc as ll,Rd as pn,Re as Mv,Rf as Zi,Rg as w3,Rh as t5,Rj as dp,Rk as Jo,S as jF,Sa as Og,Sb as lv,Sc as c2,Sd as $L,Se as Ju,Sf as p3,Sg as C3,Sh as V2,Sj as sE,Sk as Oe,T as qF,Ta as Pg,Tb as zg,Tc as d2,Td as OL,Te as C2,Tf as m3,Tg as N3,Th as Ct,Tj as ph,Tk as P5,U as zF,Ua as Zf,Ub as ec,Uc as Gi,Ud as Cv,Ue as UL,Uf as Te,Ug as R3,Uh as r5,Uj as Gs,Uk as D5,V as YC,Va as Gu,Vb as n2,Vc as dv,Vd as Nv,Ve as HL,Vf as ml,Vg as O2,Vh as i5,Vj as pp,Vk as gh,W as ks,Wa as Dg,Wb as rL,Wc as xL,Wd as _r,We as js,Wf as ac,Wg as A3,Wh as j2,Wj as uE,Wk as en,X as K,Xa as we,Xb as iL,Xc as er,Xd as nr,Xe as GL,Xf as gl,Xg as T3,Xh as Be,Xj as aE,Xk as aa,Ya as rl,Yb as oL,Yc as P,Yd as Xr,Ye as WL,Yf as Qg,Yg as rh,Yh as q2,Yj as cr,Yk as bc,Z as UF,Za as il,Zb as t2,Zc as zo,Zd as mo,Ze as YL,Zf as bo,Zg as pe,Zh as Fr,Zi as El,Zj as Un,Zk as F5,_ as Tg,_a as vi,_b as J,_c as pv,_d as ar,_e as ZL,_f as Xg,_g as _n,_h as o5,_i as tE,_j as ge,_k as hh,a as W,aa as dn,ab as rv,ac as sL,ad as tc,ae as Rv,af as Ov,ag as jv,ah as I3,ai as jn,aj as up,ak as eN,al as L5,b as D,ba as bi,bb as iv,bc as Lt,bd as mv,be as An,bf as JL,bg as hl,bh as k3,bi as zs,bj as ra,bk as qe,bl as B5,c as Fe,ca as O,cb as nL,cc as r2,cd as p2,ce as Zu,cf as Jg,cg as Xd,ch as M3,ci as qn,cj as Lr,ck as xi,cl as bh,d as TF,da as nl,db as oe,dc as uL,dd as Gd,de as nt,df as oc,dg as eh,dh as Xe,di as zn,dj as Br,dk as nN,dl as pE,e as je,ea as fo,eb as Fg,ec as aL,ed as gv,ee as ei,ef as KL,eg as nh,eh as $3,ei as Pn,ej as Y2,ek as ae,el as V5,f as W0,fa as zu,fb as tL,fc as lL,fd as m2,fe as tt,ff as QL,fg as yl,fh as P2,fi as z2,fj as Z2,fk as un,g as IF,ga as Ig,gb as po,gc as fL,gd as fl,ge as b2,gf as XL,gg as bl,gh as O3,gi as s5,gj as J2,gk as Nt,h as kF,ha as me,hb as Bn,hc as fv,hd as hv,he as Gg,hf as e3,hg as ep,hh as Jv,hi as u5,hj as K2,hk as te,i as xn,ia as Ui,ib as Hi,ic as cL,id as Ug,ie as mt,if as n3,ig as T2,ih as P3,ii as ah,ij as ia,ik as sa,j as $e,ja as HF,jb as qd,jc as i2,jd as yv,je as v2,jf as Pv,jg as g3,jh as gt,ji as U2,jk as Sl,k as Y0,ka as tl,kb as k,kc as dL,kd as _L,ke as Uo,kf as Dv,kg as qv,kh as D2,ki as ea,kk as tN,l as Sn,la as X0,lb as QC,lc as o2,ld as bv,le as Av,lf as Kg,lg as h3,lh as ih,li as lh,lk as rN,m as rn,ma as GF,mb as Ne,mc as pL,md as g2,me as E2,mf as Wi,mg as np,mh as D3,mj as fh,mk as mp,n as MF,na as Ft,nb as ee,nc as xr,nd as wL,ne as go,nf as Go,ng as zv,nh as F3,ni as eE,nk as _5,o as Z0,oa as WF,ob as Lg,oc as mL,od as h2,oe as Wg,of as N2,og as y3,oh as L3,oi as ip,ok as iN,p as Uf,pa as kg,pb as ol,pc as Ls,pd as CL,pe as lr,pf as sc,pg as vl,ph as B3,pi as na,pj as ch,pk as ve,q as $F,qa as Uu,qb as Bg,qc as Bs,qd as vv,qe as Vs,qf as t3,qg as I2,qh as Kv,qi as op,qj as mc,qk as an,ra as Wf,rb as Kf,rc as s2,rd as NL,re as Ho,rf as Yi,rg as Uv,rh as oh,ri as a5,rj as ap,rk as Rt,s as jd,sa as br,sb as zd,sc as u2,sd as y2,se as Yg,sf as r3,sg as b3,sh as Qv,sj as Hs,sk as Nr,t as OF,ta as ev,tb as vr,tc as gL,td as Wd,te as PL,tf as i3,tg as qs,th as F2,ti as pc,tj as lp,tk as lE,u as Is,ua as ZC,ub as XC,uc as hL,ud as Sr,ue as tr,uf as R2,ug as tp,uh as L2,ui as l5,uj as h5,uk as _l,v as PF,va as Mg,vb as Qf,vc as yL,ve as Tv,vf as Fv,vg as k2,vh as V3,vi as f5,vj as y5,vk as mh,w as Hf,wa as Ms,wb as $s,wc as cv,we as x2,wf as o3,wg as lc,wh as j3,wi as c5,wk as wl,x as HC,xa as JC,xb as Vg,xc as a2,xe as DL,xf as cl,xg as M2,xh as q3,xi as d5,xj as Vt,xk as w5,y as GC,ya as We,yb as Os,yc as l2,yd as RL,ye as FL,yf as dl,yg as fc,yh as z3,yi as p5,yj as Q2,yk as C5,z as J0,za as Rn,zb as Qr,zc as bL,zd as Hg,ze as LL,zf as Jd,zg as Hv,zh as rp,zi as De,zj as xl,zk as N5}from"./chunk-S6UB43FH.js";function j5(e,n){if(e.length>6)return`${e.length}${q5(e.length)}`,[];let t=[],r=(i,o=[])=>{if(i.length===0)(!n||n(o))&&t.push([...o]);else for(let s=0;s<i.length;s++){let u=i.slice(),a=u.splice(s,1);r(u.slice(),o.concat(a))}};return r(e),t}function q5(e){return e<=1?1:e*q5(e-1)}function z5(e){for(let n in e)n.startsWith("_")&&e.hasOwnProperty(n)&&Object.defineProperty(e,n,{enumerable:!1,configurable:!0,writable:!0,value:e[n]})}var oN=new WeakSet;function hE(e){e!==void 0&&oN.add(e)}function sN(e){return e!==void 0&&oN.has(e)}var mE=new WeakMap,gE=new WeakMap;function U5(e,n){e!==void 0&&(n===void 0?mE.delete(e):mE.set(e,n))}function H5(e){return e===void 0?void 0:mE.get(e)}function G5(e,n){e!==void 0&&(n===void 0?gE.delete(e):gE.set(e,n))}function W5(e){return e===void 0?void 0:gE.get(e)}function hp(e){e!==void 0&&(mE.delete(e),gE.delete(e),oN.delete(e))}function Y5(e){if(typeof e=="object"&&e.kind==="signature"){let n={...e};return delete n.effects,n}return{kind:"signature",variadicArg:{type:"any"},variadicMin:0,result:"unknown"}}function uN(e,n){let t=e.args?.length??0,r=n.args?.length??0,i=e.optArgs?.length??0,o=n.optArgs?.length??0;if(t!==r||i!==o||e.variadicArg===void 0!=(n.variadicArg===void 0)||e.variadicArg&&(e.variadicMin??0)!==(n.variadicMin??0))return!1;let s=(u,a)=>O(u,a)&&O(a,u);for(let u=0;u<t;u++)if(!s(e.args[u].type,n.args[u].type))return!1;for(let u=0;u<i;u++)if(!s(e.optArgs[u].type,n.optArgs[u].type))return!1;return!(e.variadicArg&&!s(e.variadicArg.type,n.variadicArg.type))}var Ko=new WeakMap;function Lre(e){return Ko.has(e)||Ko.set(e,new Map),Ko.get(e)}function Bre(e,n){Lre(e).set(n.name,n)}function Vre(e){if(typeof e=="number")return{type:"exact",values:[e]};let t=e.split(",").map(i=>i.trim()).map(i=>{let o=Number(i);return isNaN(o)?i:o});return{type:t.some(i=>typeof i=="string")?"pattern":"exact",values:t}}function jre(e,n){if(e.values.length!==n.length)return!1;let t=new Map;for(let r=0;r<e.values.length;r++){let i=e.values[r],o=n[r];if(typeof i=="number"){if(i!==o)return!1}else if(t.has(i)){if(t.get(i)!==o)return!1}else t.set(i,o)}return!0}function qre(e){let n=[];for(let[t,r]of e){let i=Vre(t),o=i.values.filter(s=>typeof s=="string").length;n.push({pattern:i,value:r,variableCount:o})}return n.sort((t,r)=>t.pattern.type!==r.pattern.type?t.pattern.type==="exact"?-1:1:t.variableCount-r.variableCount),n}function zre(e,n){for(let{pattern:t,value:r}of e)if(jre(t,n))return r}function Ure(e,n,t){for(let r=0;r<n.length;r++){let i=n[r],o=e[r],s=t[i];if(s&&(s.min!==void 0&&o<s.min||s.max!==void 0&&o>s.max))return!1}return!0}function Hre(e,n,t,r){let i={};for(let u=0;u<t.length;u++)i[t[u]]=e.number(r[u]);let s=n.subs(i).evaluate();if(C(s)){if(s.symbol==="True")return!0;if(s.symbol==="False")return!1}return T(s)?s.re!==0:!1}function aN(e,n,t){let r=t.variables!==void 0&&t.variables.length>1,i=t.variables??[t.variable??"n"],o=i[0],s=t.memoize??!0,u=s?new Map:null,a=t.domain??{},l=t.recurrence,f=null,c=null;t.constraints&&(c=typeof t.constraints=="string"?e.parse(t.constraints):t.constraints);let d=new Map;for(let[m,h]of Object.entries(t.base)){let y=r?String(m):Number(m);d.set(y,typeof h=="number"?e.number(h):h)}let p=r?qre(d):null;return Bre(e,{name:n,variable:r?void 0:o,variables:r?i:void 0,isMultiIndex:r,base:d,memoize:s,memo:u,domain:a,constraints:c??void 0}),(m,{engine:h,numericApproximation:y})=>{f===null&&(f=typeof l=="string"?h.parse(l):l);let b;if(g(m,"Sequence")?b=m.ops.map(_=>_.evaluate().re):g(m,"Tuple")?b=m.ops.map(_=>_.evaluate().re):g(m,"Delimiter")?b=m.ops.map(_=>_.evaluate().re):b=[m.evaluate().re],!b.every(_=>Number.isInteger(_)))return;if(r){let _=a;if(Object.keys(_).length>0&&!Ure(b,i,_))return}else{let _=a,A=b[0];if(_.min!==void 0&&A<_.min||_.max!==void 0&&A>_.max)return}if(c&&!Hre(h,c,i,b))return;let v=r?b.join(","):b[0],E=h._factsHidden()?`facts-hidden|${v}`:v;if(u?.has(E))return u.get(E);if(r){let _=zre(p,b);if(_!==void 0)return u&&u.set(E,_),_}else{let _=b[0];if(d.has(_))return d.get(_)}let x={};for(let _=0;_<i.length;_++)x[i[_]]=h.number(b[_]);let S=f.subs(x),w=y?S.N():S.evaluate();return u&&T(w)&&u.set(E,w),T(w)?w:void 0}}function lN(e,n,t){return!t.base||Object.keys(t.base).length===0?{valid:!1,error:`Sequence "${n}" requires at least one base case`}:t.recurrence?(typeof t.recurrence=="string"?e.parse(t.recurrence):t.recurrence).isValid?{valid:!0}:{valid:!1,error:`Invalid recurrence for "${n}": expression contains errors`}:{valid:!1,error:`Sequence "${n}" requires a recurrence relation`}}var vc=new WeakMap;function vh(e,n){vc.has(e)||vc.set(e,new Map);let t=vc.get(e);return t.has(n)||t.set(n,{base:new Map,isMultiIndex:!1}),t.get(n)}function Z5(e,n,t,r){vh(e,n).base.set(t,r),yE(e,n)}function fN(e,n,t,r){let i=vh(e,n);i.base.set(t,r),i.isMultiIndex=!0,yE(e,n)}function cN(e,n,t,r){let i=vh(e,n);i.recurrence={variable:t,latex:ap(r.json)},yE(e,n)}function J5(e,n,t,r){let i=vh(e,n);i.recurrence={variables:t,latex:ap(r.json)},i.isMultiIndex=!0,yE(e,n)}function yE(e,n){let t=vh(e,n);if(t.base.size===0||!t.recurrence)return;let r={};for(let[l,f]of t.base)r[l]=f;let i={base:r,recurrence:t.recurrence.latex};t.isMultiIndex||t.recurrence.variables?i.variables=t.recurrence.variables:i.variable=t.recurrence.variable;let o=lN(e,n,i);if(!o.valid)throw new Error(o.error);let s=aN(e,n,i),a=e.context.lexicalScope.bindings.get(n);if(a){let l=cr(a);Un(e,n,a,{subscriptEvaluate:s}),e._noteStateEvent({kind:"redefine",callableBefore:l,callableAfter:!0})}else e.declare(n,{subscriptEvaluate:s});vc.get(e).delete(n)}function Eh(e,n){if(g(e)){if(e.operator==="Subscript"){let t=e.op1;if(C(t,n))return!0}return e.ops.some(t=>Eh(t,n))}return!1}function dN(e){if(C(e))return e.symbol;let n=e.symbols;if(n.length===1)return n[0];let t=["n","k","i","j","m"];for(let r of t)if(n.includes(r))return r}function K5(e,n){let r=vc.get(e)?.get(n);if(r){let o=Array.from(r.base.keys());return r.isMultiIndex||o.sort((s,u)=>s-u),{status:"pending",hasBase:r.base.size>0,hasRecurrence:!!r.recurrence,baseIndices:o,variable:r.recurrence?.variable,variables:r.recurrence?.variables}}let i=e.lookupDefinition(n);if(i&&J(i)&&i.value.subscriptEvaluate){let s=Ko.get(e)?.get(n);if(s){let u=Array.from(s.base.keys());return s.isMultiIndex||u.sort((a,l)=>a-l),{status:"complete",hasBase:!0,hasRecurrence:!0,baseIndices:u,variable:s.variable,variables:s.variables}}return{status:"complete",hasBase:!0,hasRecurrence:!0,baseIndices:[]}}return{status:"not-a-sequence",hasBase:!1,hasRecurrence:!1,baseIndices:[]}}function Q5(e,n){let r=Ko.get(e)?.get(n);if(!r)return;let i=Array.from(r.base.keys());return r.isMultiIndex||i.sort((o,s)=>o-s),{name:r.name,variable:r.variable,variables:r.variables,baseIndices:i,memoize:r.memoize,domain:r.domain,cacheSize:r.memo?.size??0,isMultiIndex:r.isMultiIndex}}function X5(e){let n=Ko.get(e),t=vc.get(e);return{registry:n===void 0?void 0:[...n.entries()].map(([r,i])=>({name:r,meta:i,fields:{...i,base:new Map(i.base)}})),pending:t===void 0?void 0:[...t.entries()].map(([r,i])=>({name:r,entry:i,fields:{...i,base:new Map(i.base)}}))}}function eB(e,n){let t=n,r=Ko.get(e);if(r!==void 0){let o=new Map((t.registry??[]).map(s=>[s.name,s]));for(let s of[...r.keys()])o.has(s)||r.delete(s);for(let{name:s,meta:u,fields:a}of t.registry??[])Object.assign(u,a),u.base=new Map(a.base),u.memo?.clear(),r.set(s,u)}let i=vc.get(e);if(i!==void 0){let o=new Map((t.pending??[]).map(s=>[s.name,s]));for(let s of[...i.keys()])o.has(s)||i.delete(s);for(let{name:s,entry:u,fields:a}of t.pending??[])Object.assign(u,a),u.base=new Map(a.base),u.recurrence=a.recurrence,i.set(s,u)}}function nB(e){let n=Ko.get(e);return n?Array.from(n.keys()):[]}function pN(e,n){return Ko.get(e)?.has(n)??!1}function tB(e,n){let t=Ko.get(e);if(t)if(n!==void 0){let r=t.get(n);r?.memo&&r.memo.clear()}else for(let r of t.values())r.memo&&r.memo.clear()}function rB(e,n){let r=Ko.get(e)?.get(n);if(r?.memo)return new Map(r.memo)}function iB(e,n,t,r,i=1){if(!Number.isInteger(t)||!Number.isInteger(r)||i<=0||!Number.isInteger(i)||!pN(e,n))return;let o=[];for(let s=t;i>0?s<=r:s>=r;s+=i){let a=e.parse(`${n}_{${s}}`).evaluate();if(T(a))o.push(a);else return}return o}var Ws=class extends Error{code;declaredName;constructor(n,t,r){super(r),this.code=n,this.declaredName=t}};function xh(e,n,t,r){if(!(t===void 0||r===void 0)&&t.batch===r.batch&&t.statementId!==r.statementId)throw new Ws(e==="type"?"type-redefinition":"protocol-redefinition",n,`The ${e} "${n}" is already declared${uB(t)} in this program. A second declaration of a name in one program is a mistake; to redefine it interactively, re-run it as a separate program.`)}function oB(e,n,t){if(!(n===void 0||t===void 0)&&n.batch===t.batch&&!sB(n,t))throw new Ws("function-redefinition",e,`A clause of "${e}" with this parameter list is already defined${uB(n)} in this program, and this one would silently replace it. Give the clauses different parameter lists to dispatch between them, or edit the existing clause in place; to redefine it interactively, re-run it as a separate program.`)}function sB(e,n){if(e.statementId===n.statementId)return!0;let t=e.firstRange,r=n.firstRange;return t!==void 0&&r!==void 0&&t[0]===r[0]&&t[1]===r[1]}function Sh(e,n){return e===void 0||n===void 0||e.batch!==n.batch?!1:sB(e,n)}function uB(e){let n=e.firstRange;return n===void 0?" earlier":` at characters ${n[0]}-${n[1]}`}function Gre(e,n){for(let t of cn(e))if(n.has(t))return!0;return!1}function Ec(e,n,t,r){if(typeof e=="object"&&e.kind==="variable"){if(!t.has(e.name))return!1;let i=r[e.name];return i!==void 0?Ag(i)===Ag(n):(r[e.name]=n,!0)}if(!Gre(e,t))return O(n,e);if(typeof e!="object")return!1;if(typeof n=="object"&&n.kind==="reference"&&n.alias===!0&&n.def!==void 0)return Ec(e,n.def,t,r);if(typeof n!="object"||n.kind!==e.kind)return!1;switch(e.kind){case"list":{let i=n;return e.dimensions!==void 0&&e.dimensions.join()!==(i.dimensions?.join()??"")?!1:Ec(e.elements,i.elements,t,r)}case"set":case"collection":case"indexed_collection":case"broadcastable":return Ec(e.elements,n.elements,t,r);case"dictionary":return Ec(e.values,n.values,t,r);case"reference":{let i=n;if(e.name!==i.name)return!1;let o=e.args,s=i.args;return o===void 0||s===void 0||o.length!==s.length?!1:o.every((u,a)=>Ec(u,s[a],t,r))}case"tuple":{let i=e.elements??[],o=n.elements??[];return i.length!==o.length?!1:i.every((s,u)=>{let a=o[u];return s.name!==void 0&&a.name!==void 0&&s.name!==a.name?!1:Ec(s.type,a.type,t,r)})}default:return!1}}function bE(e,n,t,r){let i=new Set(n.map(s=>s.name)),o=Object.create(null);if(!Ec(e,t,i,o))return null;for(let s of n){let u=o[s.name];if(u===void 0)return null;if(jF(u)){if(s.bound!==void 0&&!O(u,s.bound))return null;for(let a of s.protocols??[])if(!r(u,a))return null}}return zi(e,o)}function vE(e,n){let t=Object.create(null);for(let r of n)t[r.name]=r.bound??"unknown";return zi(e,t)}function xc(e,n,t){let r=e.length,i=n.length;if(Math.abs(r-i)>t)return t+1;if(r===0)return i;if(i===0)return r;let o=new Array(i+1),s=new Array(i+1),u=new Array(i+1);for(let a=0;a<=i;a++)s[a]=a;for(let a=1;a<=r;a++){u[0]=a;let l=u[0];for(let f=1;f<=i;f++){let c=e[a-1]===n[f-1]?0:1,d=Math.min(s[f]+1,u[f-1]+1,s[f-1]+c);a>1&&f>1&&e[a-1]===n[f-2]&&e[a-2]===n[f-1]&&(d=Math.min(d,o[f-2]+1)),u[f]=d,d<l&&(l=d)}if(l>t)return t+1;[o,s,u]=[s,u,o]}return s[i]}function mN(e,n){let r=null,i=1/0;for(let o of n){let s=xc(e,o,7);if(s===0)return o;s<=7&&s<i&&(i=s,r=o)}return r}function gN(e){if(g(e,"Function")){let r=e.nops-1;return r===0?{required:0,max:1/0}:{required:r,max:r}}if(!C(e))return;let n=e.engine.lookupDefinition(e.symbol);if(n===void 0)return;let t="operator"in n?n.operator.signature.type:n.value.type?.type;return Wre(t)}function Wre(e){if(e===void 0||Ms(e))return;let n=Uu(e);if(n===void 0||n.length!==1)return;let t=n[0];if(t.typeParams!==void 0&&t.typeParams.length>0)return;let r=t.args?.length??0,i=t.optArgs?.length??0;if(t.variadicArg!==void 0){let o=t.variadicMin??0;return{required:o>0?r+i+o:r,max:1/0}}return{required:r,max:r+i}}function Yre(e){return`${e.count} argument${e.count===1?"":"s"} (${e.describes})`}function hN(e){let n=t=>`${t} parameter${t===1?"":"s"}`;return e.required===e.max?`declares ${n(e.required)}`:e.max===1/0?`requires at least ${n(e.required)}`:`takes ${e.required} to ${n(e.max)}`}function Zre(e){if(!g(e,"Function"))return;let n=[];for(let t of e.ops.slice(1)){if(!C(t))return;n.push(t.symbol)}return n.length>0?n:void 0}function Jre(e){if(e===void 0)return;let n=Z(e.type.type);if(n!==void 0&&!(typeof n!="object"||n.kind!=="tuple"))return n.elements?.length}function yp(e,n,t,r){let i=gN(e);if(i===void 0)return;let o=Array.isArray(t)?t:[t];if(o.length===0||o.some(c=>c.count>=i.required&&c.count<=i.max))return;let s=e.engine,u=o.map(Yre).join(" or "),a=C(e)?e.symbol:e.toString(),l=`${n} calls its callback with ${u}; \`${a}\` ${hN(i)}`,f=o.length===1&&o[0].count===1&&o[0].destructurable===!0&&i.required===i.max&&i.required>=2&&Jre(r)===i.required?Zre(e):void 0;return f!==void 0&&(l+=`. To take a ${f.length===2?"pair":"tuple"} apart, use a tuple pattern parameter: ((${f.join(", ")})) => \u2026`),s.error(["callback-arity",l])}function EE(e,n){let t=n;if(cn(t).size===0&&dn(t,"function"))return{rule:"not-callable",actual:t};let r=yN(t);if(r===void 0)return;let i;for(let o of r){let s=Kre(e,o);if(s===void 0)return;i??=s}return i}function yN(e){if(typeof e=="string")return e==="function"||e==="unknown"||e==="any"?void 0:[];switch(e.kind){case"signature":return[e];case"variable":return;case"union":case"intersection":{let n=[];for(let t of e.types){let r=yN(t);if(r===void 0)return;n.push(...r)}return n}case"reference":return e.alias===!0&&e.def!==void 0?yN(e.def):void 0;default:return cn(e).size===0&&dn(e,"function")?[]:void 0}}function Kre(e,n){let t=e.args??[];for(let o=0;o<t.length;o++){let s=t[o].type;if(s==="never"||s==="nothing")continue;let u=Qre(n,o);if(u!==void 0&&!(cn(s).size>0||cn(u).size>0)&&dn(s,u))return{rule:"disjoint-parameter",position:o,expected:s,actual:u}}let r=e.result,i=n.result;if(i!=="never"&&!(cn(r).size>0||cn(i).size>0)&&dn(r,i))return{rule:"disjoint-result",expected:r,actual:i}}function Qre(e,n){let t=e.args??[];if(n<t.length)return t[n].type;let r=e.optArgs??[];return n-t.length<r.length?r[n-t.length].type:e.variadicArg?.type}function aB(e,n){let t=Uu(e);if(t===void 0)return!1;for(let r of t){let i=r.args?.length??0,o=r.variadicArg!==void 0?1/0:i+(r.optArgs?.length??0);if(n>=i&&n<=o)return!1}return!0}function Ve(e){return C(e)&&e.symbol.startsWith("_")||e.operator==="Wildcard"||e.operator==="WildcardSequence"||e.operator==="WildcardOptionalSequence"}function mn(e){if(C(e)&&e.symbol.startsWith("_"))return e.symbol;if(g(e)&&e.nops===1){let n=e.op1;if(e.operator==="Wildcard")return`_${n}`;if(e.operator==="WildcardSequence")return`__${n}`;if(e.operator==="WildcardOptionalSequence")return`___${n}`}return e.operator==="Wildcard"?"_":e.operator==="WildcardSequence"?"__":e.operator==="WildcardOptionalSequence"?"___":null}function rr(e){if(typeof e=="string")return e.startsWith("_")?e.startsWith("__")?e.startsWith("___")?"OptionalSequence":"Sequence":"Wildcard":null;if(C(e)){let n=e.symbol;return n.startsWith("_")?n.startsWith("__")?n.startsWith("___")?"OptionalSequence":"Sequence":"Wildcard":null}if(g(e)){if(e.operator==="Wildcard")return"Wildcard";if(e.operator==="WildcardSequence")return"Sequence";if(e.operator==="WildcardOptionalSequence")return"OptionalSequence"}return null}var Nl=class extends De{_kind="string";[Symbol.toStringTag]="[BoxedString]";_string;_utf8Buffer;_unicodeScalarValues;_graphemes;_isAscii;constructor(n,t,r){super(n,r);let i=t.normalize(),o=!0,s=!0;for(let u=0;u<i.length;u++){let a=i.charCodeAt(u);if(a>=128||a===13)if(o=!1,a>=55296&&a<=56319){let l=i.charCodeAt(u+1);l>=56320&&l<=57343?u++:s=!1}else a>=56320&&a<=57343&&(s=!1)}this._isAscii=o,this._string=s?i:bN(i)}get json(){return`'${this._string}'`}get hash(){return Ei("String"+this._string)}get operator(){return"String"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(n){}get value(){return this}get type(){return k.string}get complexity(){return 19}get string(){return this._string}get buffer(){if(this._utf8Buffer===void 0){let n=new TextEncoder;this._utf8Buffer=n.encode(this._string)}return this._utf8Buffer}get unicodeScalars(){return this._unicodeScalarValues===void 0&&(this._unicodeScalarValues=vN(this._string)),this._unicodeScalarValues}get graphemes(){return this._graphemes===void 0&&(this._graphemes=this._isAscii?this._string.split(""):Cr(this._string)),this._graphemes}get isCollection(){return!0}get isIndexedCollection(){return!0}get isFiniteCollection(){return!0}get count(){return this.graphemes.length}get shape(){return[this.count]}get rank(){return 1}*each(){for(let n of this.graphemes)yield this.engine.character(n)}at(n){let t=this.graphemes;if(n<0&&(n=t.length+n+1),!(n<1||n>t.length))return this.engine.character(t[n-1])}contains(n){let t=Ye(n)||j(n)?n.string:void 0;return t===void 0?!1:this.graphemes.includes(t)}match(n,t){return rE(n)||(n=this.engine.expr(n,{form:"raw"})),Ve(n)?{[mn(n)]:this}:!j(n)&&!Ye(n)?null:this._string===n.string?{}:null}};function bN(e){return e.toWellFormed?.()??Xre(e)}function Xre(e){let n="";for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=e[t]+e[t+1],t++):n+="\uFFFD"}else r>=56320&&r<=57343?n+="\uFFFD":n+=e[t]}return n}function vN(e){let n=[];for(let t=0;t<e.length;t++){let r=e.codePointAt(t);n.push(r),r>65535&&t++}return n}function bp(e){return e.length===0?!1:e.length===1&&e.charCodeAt(0)<128&&e!=="\r"?!0:Cr(e.normalize()).length===1}var xE=class extends De{_kind="character";[Symbol.toStringTag]="[BoxedCharacter]";_string;_unicodeScalarValues;constructor(n,t,r){super(n,r),this._string=bN(t.normalize())}get json(){return["CharacterFrom",`'${this._string}'`]}get hash(){return Ei("String"+this._string)}get operator(){return"CharacterFrom"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(n){}get value(){return this}get type(){return k.character}get complexity(){return 19}get string(){return this._string}get unicodeScalars(){return this._unicodeScalarValues===void 0&&(this._unicodeScalarValues=vN(this._string)),this._unicodeScalarValues}match(n,t){return rE(n)||(n=this.engine.expr(n,{form:"raw"})),Ve(n)?{[mn(n)]:this}:!Ye(n)&&!j(n)?null:this._string===n.string?{}:null}};function SE(e,n){if(j(n)&&bp(n.string))return e.character(n.string)}var lB=K("indexed_collection<number>");function _h(e){return e.isCollection||lr(e.type.type)}function dB(e){let n=Ln(e);return typeof n!="string"&&"elements"in n&&n.elements==="never"?!1:PL(n)}function EN(e,n,t,r){return O(t,"number")&&dB(n.type.type)?e.typeError(r??t,n.type,n):n}function RN(e,n){e._withoutFacts(()=>{let t="real";for(let r of n)if(r.type.facts.couldBeNonReal){t="number";break}for(let r of n)if(nr(r)){if(r.isLazyCollection)continue;for(let i of r.each())_h(i)||i._infer(()=>t)}else _h(r)||r._infer(()=>t)})}function pB(e,n,t){if(typeof n=="string"||n.kind!=="signature")return;let r=new Map;for(let o of n.typeParams??[])o.bound!==void 0&&O(o.bound,"number")&&r.set(o.name,o.bound);if(r.size===0)return;let i=o=>{let s=iv(n,o);if(!(s===void 0||typeof s=="string"||s.kind!=="variable"))return r.get(s.name)};e._withoutFacts(()=>{t.forEach((o,s)=>{let u=i(s);if(u!==void 0)if(nr(o)){if(o.isLazyCollection)return;for(let a of o.each())_h(a)||a._infer(()=>u)}else _h(o)||o._infer(()=>u)})})}function ln(e,n,t){if(n=ge(n),!e.strict){if(n.length>=t)return n;let o=[...n];for(;o.length<t;)o.push(e.error("missing"));return o}if(n.length===t)return n;let r=[...n.slice(0,t)],i=Math.min(t,n.length);for(;i<t;)r.push(e.error("missing")),i+=1;for(;i<n.length;)r.push(e.error("unexpected-argument",n[i].toString())),i+=1;return r}function NE(e,n){if(!C(n))return null;r2(e);let t=n.symbol;if(!/^[A-Z]$/.test(t)||!n.operatorDefinition)return null;let r=e.context.lexicalScope;for(;r&&!r.bindings.has(t);)r=r.parent;if(!r)return null;let i=r.bindings.get(t);if(!r.parent){if(!Q(i)||i.operator instanceof Vt&&i.operator._isLambda)return null;e.declare(t,"unknown");let o=e.context.lexicalScope;for(;o&&!o.bindings.has(t);)o=o.parent;let s=o?.bindings.get(t);return o&&s&&J(s)&&(s.value._isDevolvedShadow=!0,e._boxingState.noteDevolvedShadow(o)),e.box(t)}return J(i)&&i.value._isDevolvedShadow?e.box(t):null}function Rr(e,n,t){let r=typeof t=="number"?t:t?.count,i=typeof t=="number"?void 0:t?.flatten;if(i&&n.some(a=>Gi(a))?n=ge(n):i&&n.some(a=>dv(a))?n=S5(n,i):n=ge(n,i),!e.strict){let a=n;if(r!==void 0&&n.length<r){let l=[...n];for(;l.length<r;)l.push(e.error("missing"));a=l}return e._withoutFacts(()=>{let l="real";for(let f of a)if(f.type.facts.couldBeNonReal){l="number";break}for(let f of a)_h(f)||f._infer(()=>l)}),a}let o=!0;r??=n.length;let s=[],u=Math.max(r-1,n.length-1);for(let a=0;a<=u;a++){let l=n[a];if(a>r-1)o=!1,s.push(e.error("unexpected-argument",l.toString()));else if(l===void 0)o=!1,s.push(e.error("missing"));else if(!l.isValid)o=!1,s.push(l);else if(l.isNumber)s.push(l);else if(l.operator==="Quantity")s.push(l);else if(C(l)&&!e.lookupDefinition(l.symbol))s.push(l);else if(l.type.isUnknown||l.type.type==="any")s.push(l);else if(dB(l.type.type))o=!1,s.push(e.typeError("number",l.type,l));else if(l.type.facts.containsMissing){let f=Ln(l.type.type);f!=="never"&&dn(f,"number")&&!Yg(f)&&!tr(f)?(o=!1,s.push(e.typeError("number",l.type,l))):s.push(l)}else if(Yg(l.type.type))s.push(l);else if(tr(l.type.type))s.push(l);else if(pe(l))s.push(l);else if(nr(l))if(l.type.matches(lB))s.push(l);else if(l.isLazyCollection)s.push(l);else{let f=!0;for(let c of l.each()){let d=c.type.type;if(!(C(c)&&typeof d!="string"&&d.kind==="signature")&&!c.type.isUnknown&&!c.isNumber){f=!1;break}}f?s.push(l):(o=!1,s.push(e.typeError("number",l.type,l)))}else if(l.isIndexedCollection&&l.isFiniteCollection===void 0&&l.type.matches(lB))s.push(l);else if(l.valueDefinition?.inferredType&&O("number",l.type.type))s.push(l);else if(l.operatorDefinition?.inferredSignature&&O("number",l.type.type))s.push(l);else if(l.operator==="Hold"||l.valueDefinition?.value?.operator==="Hold")s.push(l);else if(l.type.couldMatch("number"))s.push(l);else{let f=l.operatorDefinition?NE(e,l):null;f?s.push(f):(o=!1,s.push(e.typeError("number",l.type,l)))}}return o&&RN(e,s),s}var eie=K("broadcastable<number> | missing | nothing | function | error");function Si(e,n){let t=n.find(r=>r.isValid&&!T(r)&&(r.type.type==="never"||!r.type.facts.belowNumber)&&r.type.isDisjointFrom(eie));if(t!==void 0)return e.typeError("number",t.type,t)}function xp(e){return e.some(n=>C(n,"Missing"))&&!e.some(n=>n.isCollection||n.type.matches("collection<any>"))}function Sp(e,n){if(n===void 0)return e.NaN;let t=Ln(n.type.type);return O(t,"number")?e.NaN:e.Missing}var fB=new Set(["list","set","collection","indexed_collection","dictionary","tuple","record"]);function AN(e){let n=fe(e);return typeof n!="string"&&n.kind==="union"?n.types.map(t=>fe(t)):[n]}function mB(e){return typeof e=="string"?fB.has(e):fB.has(e.kind)}function nie(e){let n=fe(e);if(typeof n=="string"||n.kind!=="union")return!1;let t=!1,r=!1;for(let i of AN(n)){if(i==="function"||typeof i!="string"&&i.kind==="signature"){t=!0;continue}if(!O(i,"number"))return!1;r=!0}return t&&r}function IE(e){if(cn(e).size>0)return!0;let n=AN(e);return n.some(t=>t==="function"||t==="any"||t==="unknown"||typeof t!="string"&&t.kind==="signature")?!0:n.every(mB)}var cB=new WeakMap;function tie(e,n){let t=cB.get(e);if(t!==void 0&&t.signature===n)return t.arms;let r=n.type,i=null;typeof r!="string"&&(r.kind==="signature"?i=[r]:i=Yi(r)??null);let o=u=>IE(u)?null:{t:u,collectionArm:AN(u).some(mB)},s=null;return i!==null&&i.length>0&&(s=i.map(u=>{let a=(u.args??[]).map(f=>o(f.type)),l=(u.optArgs??[]).map(f=>o(f.type));return{req:a,opt:l,varParam:u.variadicArg===void 0?null:o(u.variadicArg.type),minArity:u.args?.length??0,maxArity:u.variadicArg!==void 0?1/0:(u.args?.length??0)+(u.optArgs?.length??0)}}),s.some(u=>u.varParam!==null||u.req.some(a=>a!==null)||u.opt.some(a=>a!==null))||(s=null)),cB.set(e,{signature:n,arms:s}),s}function xN(e,n){if(n<e.req.length)return e.req[n];let t=n-e.req.length;return t<e.opt.length?e.opt[t]:e.varParam}function gB(e,n,t,r,i,o){if(i.length===0)return;let s=tie(n,t);if(s===null)return;let u=s.filter(f=>i.length>=f.minArity&&i.length<=f.maxArity);if(u.length===0)return;let a=(f,c,d)=>{if(!f.isValid)return!1;let p=N2(f);if(p===void 0&&!C(f,"Nothing")||r&&Ho(f))return!1;if(f.isNaN===!0&&o!==void 0){let m=o(d);if(m==="propagate"||m==="handle")return!1}return c.collectionArm&&p!==void 0&&(g(p,"List")||g(p,"Tuple"))?!1:Wi(f,c.t)==="refute"},l=!1;for(let f of u){let c=!0;for(let d=0;d<i.length;d++){let p=xN(f,d);if(p!==null&&a(i[d],p,d)){c=!1,l=!0;break}}if(c)return}if(l){for(let f=0;f<i.length;f++){let c=u.map(p=>xN(p,f));if(c.some(p=>p===null||!a(i[f],p,f)))continue;let d=c.length===1?c[0].t:Bn({kind:"union",types:c.map(p=>p.t)});return e.typeError(d,i[f].type,i[f])}for(let f=0;f<i.length;f++){let c=xN(u[0],f);if(c!==null&&a(i[f],c,f))return e.typeError(c.t,i[f].type,i[f])}}}function SN(e,n){if(!g(e,"List")&&!g(e,"Tuple")||typeof n=="string")return;if(e.operator==="Tuple"&&n.kind==="tuple"){if(n.elements.length!==e.nops)return;e.ops.forEach((r,i)=>{let o=n.elements[i].type;o==="unknown"||o==="any"||C(r)&&r._infer(()=>o,"narrow")});return}let t=Z(n);if(!(t===void 0||t==="unknown"||t==="any"))for(let r of e.ops)C(r)&&r._infer(()=>t,"narrow")}function _N(e,n,t,r=!1){let i=n.valueDefinition,o=i.value,s=o===void 0?e._staticAssignmentEvidence?.get(i):void 0;if(o===void 0&&s===void 0)return r||n._infer(()=>t,"narrow"),"narrowed";let u=o!==void 0?o.type.type:s;return O(u,t)?"admitted":"fall-through"}function RE(e,n){if(IE(n)&&!nie(n))return!1;if(N2(e)!==void 0)return Wi(e,n)==="admit";if(C(e)){let t=e.valueDefinition,r=t===void 0?void 0:e.engine._staticAssignmentEvidence?.get(t);if(r!==void 0&&!O(r,n))return!1}return Hi(e.type.type,n)}function rt(e,n,t){if(n==null)return e.error("missing");if(t===void 0)return e.error("unexpected-argument",n.toString());if(n=n.canonical,!n.isValid||n.type.matches(t))return n;let r=TE(e,n,t);return r!==void 0?r:Go(t)&&Wi(n,t)!=="refute"||Dg(n.type.type,t)||AE(n,t)||Pg(n.type.type,t)||RE(n,t)?n:e.typeError(t,n.type,n)}function rie(e){if(typeof e=="object"){if(e.kind==="signature")return[e];if(e.kind==="union")return e.types.filter(n=>typeof n=="object"&&n.kind==="signature")}return[]}function AE(e,n){let t=e.type.type;if(typeof t!="object"||t.kind!=="signature")return!1;for(let r of rie(n)){let i=h3(t,r);if(i!==t&&O(i,r))return!0}return!1}function TN(e){if(e==="character")return!0;if(typeof e=="string"||e.kind!=="union")return!1;let n=!1;for(let t of e.types){if(O("string",t))return!1;t==="character"&&(n=!0)}return n}function TE(e,n,t){if(j(n)&&TN(t))return SE(e,n)}function kE(e,n){if(!g(e,"Function")||typeof n!="object"||n.kind!=="signature")return n;let t=n.args??[];if(t.length===0)return n;let r=e.ops.slice(1),i=!1,o=t.map((s,u)=>{let a=r[u];return a===void 0||gl(a)!==void 0||s.type==="unknown"?s:(i=!0,{...s,type:"unknown"})});return i?{...n,args:o}:n}function Ep(e){if(typeof e=="object"){if(e.kind==="reference")return e.alias!==!0||e.def===void 0?void 0:Ep(e.def);if(e.kind==="signature")return[e];if(e.kind==="union"){let n=[];for(let t of e.types)typeof t=="object"&&t.kind==="signature"&&n.push(t);return n.length>0?n:void 0}if(e.kind==="intersection"){let n=[];for(let t of e.types){if(typeof t!="object"||t.kind!=="signature")return;n.push(t)}return n.length>0?n:void 0}}}function _E(e,n,t){if(t===void 0)return;let r=Ep(n);if(r===void 0)return;let i=kE(e,e.type.type);if(cn(i).size>0||dn(i,"function")||r.some(u=>R2(u,i)))return;let o=[],s=new Set;for(let u of r){let{min:a,max:l}=i3(u),f=Number.isFinite(l)?Array.from({length:l-a+1},(c,d)=>[a+d,"per the declared parameter list"]):[[a,"at least, per the declared parameter list"]];for(let[c,d]of f){let p=`${c}:${d}`;s.has(p)||(s.add(p),o.push({count:c,describes:d}))}}return yp(e,t,o)}function wN(e,n,t,r){let i=Ep(t);if(i===void 0)return;let o=kE(n,n.type.type);if(cn(o).size>0||dn(o,"function"))return;let s=!1;for(let u of i)if(R2(u,o)&&(s=!0,!!Wf(o,u)&&EE(u,o)===void 0))return"admit";return s?e.typeError(r??t,n.type,n):"admit"}function wh(e,n,t){if(n.length===t.length&&n.every((i,o)=>i.type.matches(t[o])))return n;let r=[];for(let i=0;i<=t.length-1;i++)r.push(rt(e,n[i],t[i]));for(let i=t.length;i<=n.length-1;i++)r.push(e.error("unexpected-argument",n[i].toString()));return r}function CN(e,n,t,r){if(!r?.(t)||!e.type.facts.containsMissing)return!1;let i=Ln(e.type.type);return i==="never"||O(i,n)}function wE(e,n,t){if(!t||e.isNaN!==!0)return!1;let r=t(n);return r==="propagate"||r==="handle"}function ht(e,n,t,r,i,o,s,u){if(n.some($=>$.operator==="Spread"))return null;if(!e.strict){if(typeof t!="string"&&t.kind==="signature"){let $=t.args?.length??0;if(n.length<$){let L=[...n];for(;L.length<$;)L.push(e.error("missing"));return L}}else{let $=Yi(t);if($){let L=Math.min(...$.map(z=>z.args?.length??0));if(n.length<L){let z=[...n];for(;z.length<L;)z.push(e.error("missing"));return z}}}return null}if(typeof t=="string")return null;let a,l,f;if(t.kind==="signature")a=t;else{let $=Yi(t);if(!$)return null;let L={lazy:r,threadable:i,couldBeUnkeyedCollection:Ho,stripMissing:s,freshMatrixRepair:(ce,ze)=>CE(e,ce,ze,o)},z=ce=>(ze,En,tn,Nn)=>e._withBoxingPassWindow(()=>e._withRolledBackInference(()=>{let _e=ht(e,Nn,ze,r,i,o,s,{trial:!0,overlapTrial:ce||void 0,armSolution:tn,nanPolicyAt:u?.nanPolicyAt,operatorName:u?.operatorName,checkNumericCollections:u?.checkNumericCollections});if(_e===null)return null;let fn=[];return _e.forEach((Xn,Ja)=>{Xn.isValid||fn.push(Ja)}),fn.length===0?null:fn},{forbidsRepairs:!0})),U=z(!1),H=dl(e,n,$,L,void 0,U);u?.resolutionOut!==void 0&&(u.resolutionOut.resolution=H);let{selected:X,viable:G,selectedSolution:ne}=H;if(!X){let ce=dl(e,n,$,L,void 0,z(!0));ce.selected&&(u?.resolutionOut!==void 0&&(u.resolutionOut.resolution=ce),{selected:X,viable:G,selectedSolution:ne}=ce)}if(!X){let{arityViable:ce,arityTarget:ze,refuted:En}=Lv(e,n,$,L,U);if(ce.length===0){let Nn=ze??n.length,_e=n.map((fn,Xn)=>Xn<Nn?fn:e.error("unexpected-argument",fn.toString()));for(;_e.length<Nn;)_e.push(e.error("missing"));return _e}let tn=n.map((Nn,_e)=>{let fn=En.get(_e);return fn===void 0?Nn:_E(Nn,fn,u?.operatorName)??e.typeError(fn,Nn.type,Nn)});return tn.every(Nn=>Nn.isValid)&&(tn[0]=e.error("unexpected-argument",n[0]?.toString()??"")),tn}a=X,l=G,f=ne}let c=[],d=!0,p=!1,m=new Set,h=JL(a),y=h?f??u?.armSolution??KL(h,n,{threadable:i,stripMissing:s,lazy:r,resolver:e._typeResolver}):void 0,b=!1,v=$=>{if(!y)return $;let L=Pv($,y.bindings);return L!==void 0?L:(b=!0,"any")},E=new Set;y&&y.absorbed.size>0&&h&&YC(h,n.length).forEach((L,z)=>{if(L!==void 0){for(let U of cn(L))if(y.absorbed.has(U)){E.add(z);return}}});let x=a.args?.map($=>v($.type))??[],S=a.optArgs?.map($=>v($.type))??[],w=a.variadicArg===void 0?void 0:v(a.variadicArg.type),_=a.variadicMin??0,A=y&&y.unbound.size>0?{...y.bindings,...Object.fromEntries([...y.unbound].map($=>[$,"unknown"]))}:void 0,N=($,L)=>{if(A===void 0)return L;let z=Pv($,A);return z===void 0?L:Bn(z)},I=a.args?.map(($,L)=>N($.type,x[L]))??[],B=a.optArgs?.map(($,L)=>N($.type,S[L]))??[],F=a.variadicArg===void 0||w===void 0?void 0:N(a.variadicArg.type,w),q=($,L)=>{if(b)return;if(!l)return L;let z=u3(l,$);if(!(z!==void 0&&cn(z).size>0))return z},M=0;for(let $ of x){let L=M,z=n[M++];if(!z){c.push(e.error("missing")),d=!1;continue}if(r){c.push(z);continue}if(!z.isValid){c.push(z),d=!1;continue}if(z.type.isUnknown||z.type.type==="any"){c.push(z);continue}if(oc(i,L)&&Ho(z)){let X=u?.checkNumericCollections?EN(e,z,$,I[L]):z;c.push(X),X.isValid||(d=!1);continue}if(E.has(L)){c.push(z),m.add(c.length-1);continue}let U=_E(z,$,u?.operatorName);if(U!==void 0){c.push(U),d=!1;continue}if(z.valueDefinition?.inferredType&&z.type.matches($)){c.push(z);continue}if(e._withoutFacts(()=>!b&&z.valueDefinition?.inferredType&&O($,z.type.type)&&!Go($)&&Ep($)===void 0&&Wf(z.type.type,$)?_N(e,z,$,u?.noInference):"fall-through")!=="fall-through"){c.push(z);continue}if(z.operatorDefinition?.inferredSignature&&z.type.matches($)){c.push(z);continue}if(Dg(z.type.type,$)){c.push(z);continue}if(!z.type.matches($)){let X=wN(e,z,$,I[L]);if(X==="admit"){c.push(z),m.add(c.length-1);continue}if(X!==void 0){c.push(X),d=!1;continue}let G=TE(e,z,$);if(G!==void 0){c.push(G),p=!0;continue}if(Go($)&&Wi(z,$)!=="refute"){c.push(z),m.add(c.length-1);continue}if(CN(z,$,L,s)){c.push(z),m.add(c.length-1);continue}if(wE(z,L,u?.nanPolicyAt)){c.push(z),m.add(c.length-1);continue}if(u?.trial){if(CE(e,z,$,o)){c.push(z);continue}if(Fv(e,z)){c.push(z);continue}}else{let ne=NN(e,z,$,o);if(ne){c.push(ne),p=!0;continue}let ce=NE(e,z);if(ce!==null){c.push(ce),p=!0;continue}}if(Pg(z.type.type,$)){c.push(z),m.add(c.length-1);continue}if(AE(z,$)){c.push(z);continue}if((!u?.trial||u?.overlapTrial)&&RE(z,$)){c.push(z),m.add(c.length-1);continue}c.push(e.typeError(I[L]??$,z.type,z)),d=!1;continue}c.push(z)}for(let $ of S){let L=n[M];if(!L)break;if(r){c.push(L),M+=1;continue}if(!L.isValid){c.push(L),d=!1,M+=1;continue}if(L.type.isUnknown||L.type.type==="any"){c.push(L),M+=1;continue}if(oc(i,M)&&Ho(L)){let H=u?.checkNumericCollections?EN(e,L,$,B[M-x.length]):L;c.push(H),H.isValid||(d=!1),M+=1;continue}if(E.has(M)){c.push(L),m.add(c.length-1),M+=1;continue}let z=_E(L,$,u?.operatorName);if(z!==void 0){c.push(z),d=!1,M+=1;continue}if(L.valueDefinition?.inferredType&&L.type.matches($)){c.push(L),M+=1;continue}if(e._withoutFacts(()=>!b&&L.valueDefinition?.inferredType&&O($,L.type.type)&&!Go($)&&Ep($)===void 0&&Wf(L.type.type,$)?_N(e,L,$,u?.noInference):"fall-through")!=="fall-through"){c.push(L),M+=1;continue}if(Dg(L.type.type,$)){c.push(L),M+=1;continue}if(!L.type.matches($)){let H=wN(e,L,$,B[M-x.length]);if(H==="admit"){c.push(L),m.add(c.length-1),M+=1;continue}if(H!==void 0){c.push(H),d=!1,M+=1;continue}let X=TE(e,L,$);if(X!==void 0){c.push(X),p=!0,M+=1;continue}if(Go($)&&Wi(L,$)!=="refute"){c.push(L),m.add(c.length-1),M+=1;continue}if(CN(L,$,M,s)){c.push(L),m.add(c.length-1),M+=1;continue}if(wE(L,M,u?.nanPolicyAt)){c.push(L),m.add(c.length-1),M+=1;continue}if(u?.trial){if(CE(e,L,$,o)){c.push(L),M+=1;continue}if(Fv(e,L)){c.push(L),M+=1;continue}}else{let G=NN(e,L,$,o);if(G){c.push(G),p=!0,M+=1;continue}let ne=NE(e,L);if(ne!==null){c.push(ne),p=!0,M+=1;continue}}if(Pg(L.type.type,$)){c.push(L),m.add(c.length-1),M+=1;continue}if(AE(L,$)){c.push(L),M+=1;continue}if((!u?.trial||u?.overlapTrial)&&RE(L,$)){c.push(L),m.add(c.length-1),M+=1;continue}c.push(e.typeError(B[M-x.length]??$,L.type,L)),d=!1,M+=1;continue}c.push(L),M+=1}if(w){let $=0;for(let L of n.slice(M)){if(M+=1,$+=1,r){c.push(L);continue}if(!L.isValid){c.push(L),d=!1;continue}if(L.type.isUnknown||L.type.type==="any"){c.push(L);continue}if(oc(i,M-1)&&Ho(L)){let H=u?.checkNumericCollections?EN(e,L,w,F):L;c.push(H),H.isValid||(d=!1);continue}if(E.has(M-1)){c.push(L),m.add(c.length-1);continue}let z=_E(L,w,u?.operatorName);if(z!==void 0){c.push(z),d=!1;continue}if(L.valueDefinition?.inferredType&&L.type.matches(w)){c.push(L);continue}if(e._withoutFacts(()=>!b&&L.valueDefinition?.inferredType&&O(w,L.type.type)&&!Go(w)&&Ep(w)===void 0&&Wf(L.type.type,w)?_N(e,L,w,u?.noInference):"fall-through")!=="fall-through"){c.push(L);continue}if(Dg(L.type.type,w)){c.push(L);continue}if(!L.type.matches(w)){let H=wN(e,L,w,F);if(H==="admit"){c.push(L),m.add(c.length-1);continue}if(H!==void 0){c.push(H),d=!1;continue}let X=TE(e,L,w);if(X!==void 0){c.push(X),p=!0;continue}if(Go(w)&&Wi(L,w)!=="refute"){c.push(L),m.add(c.length-1);continue}if(CN(L,w,M-1,s)){c.push(L),m.add(c.length-1);continue}if(wE(L,M-1,u?.nanPolicyAt)){c.push(L),m.add(c.length-1);continue}if(u?.trial){if(CE(e,L,w,o)){c.push(L);continue}if(Fv(e,L)){c.push(L);continue}}else{let G=NN(e,L,w,o);if(G){c.push(G),p=!0;continue}let ne=NE(e,L);if(ne!==null){c.push(ne),p=!0;continue}}if(Pg(L.type.type,w)){c.push(L),m.add(c.length-1);continue}if(AE(L,w)){c.push(L);continue}if((!u?.trial||u?.overlapTrial)&&RE(L,w)){c.push(L),m.add(c.length-1);continue}c.push(e.typeError(F??w,L.type,L)),d=!1;continue}c.push(L)}$<_&&(c.push(e.error("missing")),d=!1)}if(M<n.length)for(let $ of n.slice(M))c.push(e.error("unexpected-argument",$.toString())),d=!1;if(y&&y.failures.length>0&&h){let $=YC(h,n.length);for(let L of y.failures){let z=L.index??0;if(z>=c.length||!c[z].isValid)continue;if(L.kind==="bound"&&wE(n[z],z,u?.nanPolicyAt)){m.add(z);continue}if(L.kind==="protocol"){c[z]=e.error(["protocol-constraint-unsatisfied",`\`${re(L.solution)}\` does not conform to the \`${L.protocol}\` protocol (\`${L.variable}\` is constrained by \`where ${L.variable} is ${L.protocol}\`)`],n[z]?.toString()),d=!1;continue}let U=$[z],H=L.kind==="upper"&&L.pin!==void 0?L.pin:L.kind==="bound"?L.expected:void 0,X=H!==void 0&&U!==void 0?Pv(U,{...y.bindings,[L.variable]:H})??L.expected:L.expected;c[z]=e.typeError(X,n[z]?.type,n[z]),d=!1}}if(!d)return c;let V=p?c:n;return u?.noInference||e._withoutFacts(()=>{M=0;for(let $ of x){let L=q(M,$);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho(V[M]))&&(V[M]._infer(()=>L),SN(V[M],L)),M+=1}for(let $ of S){if(!V[M])break;let L=q(M,$);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho(V[M]))&&(V[M]._infer(()=>L),SN(V[M],L)),M+=1}if(w)for(let $ of V.slice(M)){let L=q(M,w);L!==void 0&&!r&&!m.has(M)&&(!oc(i,M)||!Ho($))&&($._infer(()=>L),SN($,L)),M+=1}}),p?c:null}function hB(e,n){return e.type("matrix").matches(n)}function CE(e,n,t,r){if(!r||!hB(e,t))return!1;let i=new Set;for(let s of n.freeVariables){let u=e.lookupDefinition(s);!u||!J(u)||!u.value.inferredType||(r.has(u.value)||u.value.type.isUnknown)&&i.add(s)}if(i.size===0)return!1;let o=vp(n,i);return o!==null&&o.size>0}function NN(e,n,t,r){if(!r||!hB(e,t))return null;let i=new Set;for(let d of n.freeVariables){let p=e.lookupDefinition(d);!p||!J(p)||!p.value.inferredType||(r.has(p.value)||p.value.type.isUnknown)&&i.add(d)}if(i.size===0)return null;let o=vp(n,i);if(!o||o.size===0)return null;r2(e);let s=new Map,u=new Map,a=new Map,l=[],f=Lt(e);for(let d of o){let p=e.lookupDefinition(d);if(!p||!J(p)||!p.value.inferredType)return null;s.set(d,p.value._typeSlotSnapshot()),u.set(d,p.value._typeProvenance?.slice()),a.set(d,p.value.type);let m=p.value.type.isUnknown;if(f!==void 0){let h=p.value,y=h._typeSlotSnapshot();f.record({undo:()=>h._restoreTypeSlots(y)})}if(p.value.type=e.type("matrix"),p.value.inferredType=!1,Ls(e,p.value,{type:p.value.type,kind:"inferred",axis:"type",cause:n,epoch:Bs(e)}),m&&e._inferenceTxDepth>0&&!e._freshlyInferred?.has(p.value)){let h=e._freshlyInferred??=new Set;if(f!==void 0){let y=p.value;f.record({undo:()=>h.delete(y)})}h.add(p.value),l.push(p.value)}}e._noteStateEvent({kind:"inference"});let c=e.box(n.json);if(c.type.matches(t)){let d=e._narrowingSink;for(let p of o){let m=e.lookupDefinition(p);m&&J(m)&&(m.value.inferredType=!0,d!==void 0&&d._recordNarrowing(p,m,a.get(p),m.value.type))}return c}for(let d of o){let p=e.lookupDefinition(d);p&&J(p)&&(p.value._restoreTypeSlots(s.get(d)),p.value._typeProvenance=u.get(d))}for(let d of l)e._freshlyInferred?.delete(d);return e._noteStateEvent({kind:"inference"}),null}function vp(e,n){if(C(e))return n.has(e.symbol)?new Set([e.symbol]):null;if(!g(e))return null;if(e.operator==="Negate")return vp(e.op1,n);if(e.operator==="Add"||e.operator==="Subtract"){let t=new Set;for(let r of e.ops){let i=vp(r,n);if(!i)return null;for(let o of i)t.add(o)}return t}if(e.operator==="Multiply"){let t=e.ops.map(r=>vp(r,n)).filter(r=>r!==null);return t.length!==1?null:t[0]}return e.operator==="Power"&&e.op2?.isInteger===!0?vp(e.op1,n):null}function iie(e){let{symbols:n,operators:t}=oie(e.engine),r={},i=o=>{if(C(o)&&!o.symbol.startsWith("_")){if(!(o.symbol in r)&&!n.includes(o.symbol)){let s=mN(o.symbol,n);s&&(r[o.symbol]=s)}}else if(g(o)&&!o.operator.startsWith("_")){let s=o.operator;if(!(s in r)&&!t.includes(s)){let u=mN(s,t);u&&(r[s]=u)}for(let u of o.ops)i(u)}};return i(e),r}function oie(e){let n=[],t=[],r=e.context.lexicalScope;for(;r;){for(let[i,o]of r.bindings)J(o)&&n.push(i),Q(o)&&t.push(i);r=r.parent}return{symbols:n,operators:t}}function Ch(e){let n=iie(e);if(Object.keys(n).length===0)return"";if(Object.keys(n).length===1){let[r,i]=Object.entries(n)[0];return`Unknown symbol "${r}". Did you mean "${i}"?`}let t=[];for(let[r,i]of Object.entries(n))t.push(`- "${r}" -> "${i}"?`);return`Unknown symbols found:
|
|
3
3
|
${t.join(`
|
|
4
4
|
`)}`}function sie(e){return{get names(){return e.names},resolve:n=>e.resolve(n),forward:()=>{throw new Error('A forward reference ("type X") is not allowed in a type value')},conformsTo:e.conformsTo?(n,t)=>e.conformsTo(n,t):void 0}}function Qo(e,n){try{let t=K(n,sie(e._typeResolver)),r=Bn(t);return{canonicalText:re(r),type:r}}catch(t){return{error:t.rawMessage??(t instanceof Error?t.message:String(t))}}}function Eo(e){if(g(e,"TypeFrom")&&e.nops===1&&j(e.op1))return e.op1.string}function _p(e){return pt(e)}var uie=new Set(["List","Tuple","Set","RegExp","TypeFrom","Error"]);function Nh(e,n){if(T(n)||j(n)||Ye(n)||C(n,"True")||C(n,"False")||C(n,"Nothing")||C(n,"Missing"))return!0;if(Qe(n))return n.values.every(i=>Nh(e,i));if(!g(n))return!1;let t=n.operator;if(t==="Error")return!0;if(t==="TypeFrom")return Eo(n)!==void 0;if(t==="RegExp")return!0;if(uie.has(t))return n.ops.every(i=>Nh(e,i));let r=e._typeRegistry[t];return r!==void 0&&r.def!==void 0&&r.alias!==!0}function yB(e,n,t){let r=e.type(t);if(n.type.matches(r))return!0;if(Nh(e,n)||n.type.isDisjointFrom(r))return!1}function OE(e,n){return e._protocolRegistry[n]}function aie(e){return Object.values(e._protocolRegistry)}var la="Self";function lie(e){return e===la||Xa(e)}function kN(e){let n={kind:"reference",name:la,alias:!1,def:"any"};return{get names(){return[...e.names,la]},forward:t=>t===la?n:e.forward(t),resolve:t=>t===la?n:e.resolve(t),conformsTo:e.conformsTo}}function fie(e,n){try{return e._typeResolver.resolve(n)!==void 0}catch{return!1}}function Sc(e){return e instanceof Error?e.message:String(e)}function PE(e,n,t,r){if(!Hu(n))throw Error(`The protocol name "${n}" is invalid`);if(lie(n))throw Error(`The protocol name "${n}" is reserved`);if(Z0(n)||fie(e,n))throw Error(`The protocol name "${n}" is already a type; protocols and types share no names`);let i=e._protocolRegistry,o=i[n],s=r?.fromStatement===!0,u=r?.origin;if(o!==void 0){if(xh("protocol",n,o._declOrigin,u),!s||!o.declaredByStatement)throw Error(`The protocol "${n}" is already declared`);if(Sh(o._declOrigin,u))return}let a=Object.create(null),l=kN(e._typeResolver);for(let[c,d]of Object.entries(t?.functions??{})){if(!Hu(c))throw Error(`The protocol member name "${c}" is invalid`);if(c.startsWith(Ar)||c.startsWith(_i))throw Error(`The protocol member name "${c}" is reserved: the \`${Ar}\` and \`${_i}\` prefixes name property accessors`);let p;try{p=K(d,l)}catch(m){throw Error(`The signature of \`${n}.${c}\` does not parse: ${Sc(m)}`)}if(typeof p!="object"||p.kind!=="signature")throw Error(`The member \`${n}.${c}\` must declare a function signature, e.g. \`(self: Self) -> integer\``);cie(n,c,p),die(n,c,p),a[c]={kind:"function",signature:d}}for(let c of["readonly","readwrite"])for(let[d,p]of Object.entries(t?.[c]??{})){if(!Hu(d))throw Error(`The protocol member name "${d}" is invalid`);if(a[d]!==void 0)throw Error(`The protocol "${n}" declares the member "${d}" twice`);try{K(p,l)}catch(m){throw Error(`The type of the property \`${n}.${d}\` does not parse: ${Sc(m)}`)}a[d]={kind:c,type:p}}if(o!==void 0){let c=e._protocolRegistryRollbackPoint();o.members=a,o.declaredByStatement=s,u===void 0?delete o._declOrigin:o._declOrigin=u;for(let m of o.conformances){let h=m._authored;if(h===void 0)continue;let y=LE(e,o,m.target,m.targetKey,h,m.where),b=_c(e,o,m);m.pending=y!==null||!b,Rl(e,o,m,y,!0)}let d=o.conformances.filter(m=>m._authored===void 0).map(m=>({edge:m,impl:m.impl,pending:m.pending}));Ah(e,o);for(let m of d)(m.edge.impl!==m.impl||m.edge.pending!==m.pending)&&Rl(e,o,m.edge,null,!0);e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange(),Rh(e);let p=Cp(e);if(p.length>0)throw c(),Rh(e),Error(`conformance-widens-declared-contract: ${FE(p,"replacing this protocol","keep the previous declaration")}`);return}let f={name:n,members:a,conformances:[],declaredByStatement:s};u!==void 0&&(f._declOrigin=u),i[n]=f,e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange(),Rh(e)}function cie(e,n,t){let r=t.args?.[0];if(r===void 0||re(r.type)!==la)throw Error(`protocol-self-required: the first argument of \`${e}.${n}\` must be of type \`Self\``)}function die(e,n,t){let r=t.optArgs!==void 0&&t.optArgs.length>0?"an optional argument":t.variadicArg!==void 0?"a variadic argument":t.typeParams!==void 0&&t.typeParams.length>0?"a type parameter":void 0;if(r!==void 0)throw Error(`The signature of \`${e}.${n}\` declares ${r}; a protocol member may not be optional, variadic or generic`)}function CB(e,n,t,r=!1){if(typeof e=="string")return null;switch(e.kind){case"union":case"intersection":case"negation":return`the conformance target \`${n}\` is a ${e.kind} type; a conforming type must be named and ground \u2014 declare a nominal type and conform that instead`;case"tuple":case"record":case"signature":return`the conformance target \`${n}\` is an anonymous structural type; declare a nominal wrapper (\`type Pt = ${n}\`) and conform that instead`;case"variable":return r?`the conformance target \`${n}\` is a bare type variable; a conditional conformance must name a type constructor (\`type list<T> is \u2026\`)`:`the conformance target \`${n}\` is a type variable; a conditional conformance needs a trailing \`where\` clause to bind it (\`type list<T> is \u2026 where T\`)`;case"reference":return e.alias===!0?`Use a nominal type (\`type Pt\`) to conform to protocol \`${t[0]??"\u2026"}\`. Structural types (\`type alias\`) cannot conform to protocols.`:null;default:return null}}function MN(e,n){let t=Qo(e,n);return"error"in t||!e.type(t.type).matches("type")||!e.type("type").matches(t.type)?null:"The `type` primitive cannot conform to a protocol: a type-value subject of `Conforms` asks about the type it HOLDS, which is unambiguous only while `type` itself conforms to nothing"}var bB=new WeakMap;function NB(e,n){let t=bB.get(n.members);if(t!==void 0)return t;let r=pie(e,n);return bB.set(n.members,r),r}function pie(e,n){let t=[],r=[];for(let[i,o]of Object.entries(n.members)){if(o.kind==="readwrite"){t.push(i);continue}if(o.kind!=="function")continue;let s=da(e,n,i);if(s===null)continue;let u=br(s);u!==void 0&&Is(["state"],u)&&r.push(i)}return t.length>0?{kind:"readwrite",members:t}:r.length>0?{kind:"state",members:r}:null}function mie(e){let n=typeof e=="object"&&e.kind==="reference",t=nl(e)??e,r=O("object",t),i=typeof t=="string"?"builtin":t.kind,o=(s,u)=>({article:s,plural:u,redeclarable:n,admitsObject:r});switch(i){case"record":return o("a record","records");case"tuple":return o("a tuple","tuples");case"list":return o("a list","lists");case"set":return o("a set","sets");case"dictionary":return o("a dictionary","dictionaries");case"collection":case"indexed_collection":return o("a collection","collections");case"signature":return o("a function type","function types");default:return n?o("a nominal value type","nominal value types"):o("a builtin type","builtin types")}}function $N(e,n,t,r){let i=NB(e,n);if(i===null||zu(t))return null;let{article:o,plural:s,redeclarable:u,admitsObject:a}=mie(t),l=i.kind==="readwrite"?`the \`${n.name}\` protocol has settable properties`:`the \`${n.name}\` protocol declares the \`state\` effect on \`${i.members.join("`, `")}\``;if(a)return`${l}. \`${r}\` is not an object type \u2014 a value of that type may or may not be an object \u2014 so only an object type can conform.`;let f=u?`and ${s} are immutable; declare \`${r}\` as an object type to conform`:"which has no state to change; only an object type can conform";return`${l}. \`${r}\` is ${o}, ${f}.`}function gie(e){return(n,t)=>e._typeResolver.conformsTo?.(n,t)??!1}function RB(e){return e.map(n=>{let t=n.name;return n.bound!==void 0&&(t+=`: ${re(n.bound)}`),n.protocols!==void 0&&n.protocols.length>0&&(t+=` is ${n.protocols.join(" & ")}`),t}).join(", ")}function vB(e){return typeof e=="string"?e:e.kind==="reference"?`reference:${e.name}`:e.kind}function AB(e,n,t){let r=/^\s*where\b/.test(t)?t.trim():`where ${t.trim()}`,i=`(self: ${n}) -> nothing ${r}`,o;try{o=K(i,e._typeResolver)}catch(a){return{problem:`the conditional conformance \`${n} \u2026 ${r}\` does not parse: ${Sc(a)}. Every variable of the head must be bound by the clause`}}if(typeof o!="object"||o.kind!=="signature")return{problem:`the conformance target \`${n}\` is invalid`};let s=o.args?.[0]?.type,u=o.typeParams;return s===void 0||u===void 0||u.length===0?{problem:`the \`where\` clause of \`${n}\` binds no type variable`}:{head:s,params:u}}function TB(e,n,t){return n.where===void 0?O(t,n.target)?n.target:null:bE(n.target,n.where,t,gie(e))}function DE(e){return e.where===void 0?e.target:vE(e.target,e.where)}function hie(e,n,t){return TB(e,n,t)!==null?!0:O(DE(n),t)}function IB(e,n,t,r,i){if(t.length===0)return e.error(["protocol-conformance-target-invalid","Expected at least one protocol name"]);if(r!==void 0&&t.length>1)return e.error(["protocol-implementation-split",`provide a separate implementation block for each of \`${t.join("`, `")}\``]);let o=[];for(let m of t){let h=e._protocolRegistry[m];if(h===void 0)return e.error(["protocol-unknown",`the protocol \`${m}\` is unknown`]);o.push(h)}let s=i?.where,u,a;if(s!==void 0){let m=AB(e,n,s);if(m.problem!==void 0)return e.error(["protocol-conformance-target-invalid",m.problem]);u=m.head,a=m.params}else try{u=K(n,e._typeResolver)}catch{return e.error(["protocol-target-unknown",`the type \`${n}\` is unknown`])}let l=CB(u,n,t,a!==void 0);if(l!==null)return e.error(["protocol-conformance-target-invalid",l]);let f=a===void 0?re(u):`${re(u)} where ${RB(a)}`;for(let m of o){let h=OB(m,u,f,a);if(h!==null)return e.error(["protocol-conformance-overlap",h]);let y=PB(m,u,f,a);if(y!==null)return e.error(["protocol-conformance-overlap",`\`${f}\` overlaps \`${y.other}\` (meet \`${y.meet}\`) for the protocol \`${m.name}\`, and neither contains the other. Conform the common supertype, or disjoint refinements, instead.`]);let b=$N(e,m,u,n);if(b!==null)return e.error(["protocol-requires-object",b])}let c=e._epsilBatchId;if(r!==void 0&&c!==void 0){let m=o[0].conformances.find(h=>h.targetKey===f)?._implOrigin;if(m!==void 0&&m.batch===c&&m.block!==i?.block)return e.error(["protocol-implementation-duplicate",`the type \`${f}\` already has an implementation of the \`${o[0].name}\` protocol in this batch`]);if(i?.fromStatementRoute===!0&&m!==void 0&&m.batch===c&&i.block!==void 0&&m.block===i.block)return null}if(r!==void 0&&(r=Aie(e,r,u,f,a)),r!==void 0){let m=LE(e,o[0],u,f,r,a);if(m!==null)return e.error([m.code,...m.errorArgs??[m.message]])}let d=e._protocolRegistryRollbackPoint(),p=!1;for(let m of o){let h=m.conformances.find(b=>b.targetKey===f);if(h!==void 0){r!==void 0&&(p=!0,h._authored=r,h.impl=r,c===void 0?delete h._implOrigin:h._implOrigin={batch:c,block:i?.block},h.pending=!_c(e,m,h),delete h._pendingReason,Rl(e,m,h,null),Ah(e,m),e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange());continue}let y={target:u,targetKey:f,pending:!0,declaredByStatement:!0};a!==void 0&&(y.where=a),r!==void 0&&(y._authored=r,y.impl=r,c!==void 0&&(y._implOrigin={batch:c,block:i?.block})),m.conformances.push(y),r!==void 0&&(y.pending=!_c(e,m,y),Rl(e,m,y,null)),p=!0,Ah(e,m),e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange()}if(p){let m=Cp(e);if(m.length>0)return d(),e.error(["conformance-widens-declared-contract",FE(m)])}return null}function Cp(e){let n=[],t=new Set,r=new Set,i=e.context.lexicalScope;for(;i;){for(let[o,s]of i.bindings){if(t.has(o)||(t.add(o),r.has(s)))continue;r.add(s);let u=yie(e,o,s);u!==null&&n.push(u)}i=i.parent}return n}function yie(e,n,t){if(Q(t)){let r=t.operator;if(!r.effectsDeclared)return null;let i=r._lambdaLiteral;return i===void 0?null:EB(e,n,i,r.effects)}if(J(t)){let r=t.value;if(!r.effectsDeclared)return null;let i=br(r.type.type);if(i===void 0)return null;let o=r.value;return o===void 0||!g(o,"Function")?null:EB(e,n,o,i)}return null}function EB(e,n,t,r){let i;try{i=vl(e,t,{selfName:n})}catch{return null}if(i.unresolvedHead||Is(i.effects,r))return null;let o=GC(i.effects,r===void 0||r==="any"?void 0:r);return{name:n,declared:r,inferred:i.effects,exceeding:o===void 0||o==="any"||HC(o)?"any":o}}function FE(e,n="registering this conformance",t="do not register this conformance"){let r=o=>o===void 0?"pure":Gf(o),i=e.map(o=>`\`${o.name}\` declares \`${r(o.declared)}\` but would infer \`${r(o.inferred)}\` (exceeding: \`${r(o.exceeding)}\`)`).join("; ");return`${n} would make dispatched calls more effectful than declared contracts allow: ${i}. Widen or remove those effect annotations, or ${t}`}function IN(e,n){let t=Object.keys(e);if(t.length===0)return!0;if(n===void 0)return!1;let r=i=>Object.prototype.hasOwnProperty.call(n,i);for(let i of t){let o=e[i].kind;if(o==="function"){if(!r(i))return!1;continue}if(!r(`${Ar}${i}`)||o==="readwrite"&&!r(`${_i}${i}`))return!1}return!0}function bie(e,n){let t=i=>n!==void 0&&Object.prototype.hasOwnProperty.call(n,i),r=[];for(let[i,o]of Object.entries(e))o.kind!=="function"&&(t(`${Ar}${i}`)||r.push(`get ${i}`),o.kind==="readwrite"&&!t(`${_i}${i}`)&&r.push(`set ${i}`));return r}function wc(e){return typeof e._fieldBacked=="string"}function kB(e,n,t,r,i){let o=new Set,s=[];if(i!==void 0)return{satisfied:o,conflicts:s};let u=fo(t);if(u===void 0)return{satisfied:o,conflicts:s};let a=fa(e._typeResolver,t,re(t)),l=(f,c)=>Object.prototype.hasOwnProperty.call(f,c);for(let[f,c]of Object.entries(n.members)){if(c.kind==="function"||!l(u.elements,f))continue;let d=u.elements[f];if(r!==void 0&&(l(r,`${Ar}${f}`)||l(r,`${_i}${f}`))){s.push(f);continue}let p;try{p=K(c.type,a)}catch{continue}MB(d,p,c.kind)&&o.add(f)}return{satisfied:o,conflicts:s}}function MB(e,n,t){return t==="readwrite"?O(e,n)&&O(n,e):O(e,n)}function vie(e){return{host:n=>{if(Vn(n)&&!(fo(n.type.type)!==void 0&&n._fieldType(e)===void 0))return n._field(e)},_fieldBacked:e}}function Eie(e,n){return{host:(t,r)=>{if(!Vn(t)||r===void 0)return;let i=t._fieldType(n);if(i===void 0)return fo(t.type.type)===void 0?(t._store(n,r),t):e.error(["protocol-implementation-missing",`\`${n}\` cannot be written on this value: it was constructed with a layout that has no stored field \`${n}\`. Rebuild it from the current declaration of \`${re(t.type.type)}\`.`]);let o=rt(e,r,i);return o.isValid?(t._store(n,r),t):o},_fieldBacked:n}}function _c(e,n,t){let r=NB(e,n)!==null&&!zu(t.target),i=t._authored,{satisfied:o}=kB(e,n,t.target,i,t.where);if(o.size===0)return i===void 0?delete t.impl:t.impl=i,!r&&IN(n.members,t.impl);let s=new Map;for(let l of o)s.set(`${Ar}${l}`,l),n.members[l].kind==="readwrite"&&s.set(`${_i}${l}`,l);let u=t.impl;if(u!==void 0&&xie(u,i,s))return!r&&IN(n.members,u);let a=Object.create(null);if(i!==void 0)for(let[l,f]of Object.entries(i))a[l]=f;for(let[l,f]of s){let c=u?.[l];a[l]=c!==void 0&&wc(c)&&c._fieldBacked===f?c:l.startsWith(Ar)?vie(f):Eie(e,f)}return t.impl=a,!r&&IN(n.members,a)}function xie(e,n,t){let r=n===void 0?[]:Object.keys(n);if(Object.keys(e).length!==r.length+t.size)return!1;for(let i of r)if(e[i]!==n[i])return!1;for(let[i,o]of t){let s=e[i];if(s===void 0||!wc(s)||s._fieldBacked!==o)return!1}return!0}function Ah(e,n,t=!1){let r=n.conformances.filter(s=>s._authored===void 0),i=!1;for(let s of r)s.pending=!_c(e,n,s),Rl(e,n,s,null,t),s.pending&&(i=!0);if(!i)return;let o=!0;for(;o;){o=!1;for(let s of r){if(!s.pending)continue;let u=DE(s);n.conformances.some(l=>l!==s&&!l.pending&&l.where===void 0&&O(u,l.target))&&(s.pending=!1,delete s._pendingReason,o=!0)}}}function Rl(e,n,t,r,i=!1,o=()=>!1){if(!t.pending){delete t._pendingReason;return}if(r!==null){t._pendingReason=`${r.code}: ${r.message}`;return}if(!i)return;let s=$N(e,n,t.target,t.targetKey);if(s!==null){t._pendingReason=s;return}if(fo(t.target)===void 0){delete t._pendingReason;return}let u=bie(n.members,t.impl);if(u.length===0){let a=Sie(n,t,o);if(a!==void 0){t._pendingReason=`the implementation inherited from \`${a.targetKey}\` no longer applies${a._pendingReason===void 0?"":`: ${a._pendingReason}`}`;return}delete t._pendingReason;return}t._pendingReason=`the layout of \`${t.targetKey}\` does not satisfy \`${u.join("`, `")}\` \u2014 write the accessor, or give \`${t.targetKey}\` a stored field of the property's own type`}function Sie(e,n,t){if(n._authored!==void 0)return;let r=DE(n),i=e.conformances.filter(o=>o!==n&&o.pending&&o.where===void 0&&O(r,o.target)&&t(o));if(i.length!==0)return i.reduce((o,s)=>O(s.target,o.target)?s:o)}function $B(e){let n=e._protocolRegistryRollbackPoint(),t=[],r=i=>i.edge.impl!==i.impl||i.edge.pending!==i.pending;try{for(let a of Object.values(e._protocolRegistry))for(let l of a.conformances){let f={record:a,edge:l,impl:l.impl,pending:l.pending,reason:l._pendingReason,failure:null};t.push(f);let c=l._authored;if(c===void 0)continue;f.failure=LE(e,a,l.target,l.targetKey,c,l.where);let d=_c(e,a,l);l.pending=f.failure!==null||!d}t.some(a=>a.edge.pending!==a.pending)&&e._noteConformanceRegistryChange();let i=t.filter(a=>a.edge._authored!==void 0&&a.pending&&!a.edge.pending),o=i.length>0?_ie(e,i,a=>{a.edge.pending=a.pending,a.impl===void 0?delete a.edge.impl:a.edge.impl=a.impl}):new Set;for(let a of Object.values(e._protocolRegistry))Ah(e,a);let s=new Map(t.map(a=>[a.edge,a.pending])),u=a=>s.get(a)===!1||o.has(a);for(let a of t)!o.has(a.edge)&&(r(a)||a.edge._pendingReason!==a.reason||a.edge.pending&&a.edge._pendingReason?.startsWith("conformance-widens-declared-contract:")===!0)&&Rl(e,a.record,a.edge,a.failure,!0,u)}catch(i){throw n(),Error(`conformance-resettle-failed: the type was declared, but re-running conformance for it failed: ${Sc(i)}`)}t.some(r)&&(e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange())}function _ie(e,n,t){let r=new Set;if(Cp(e).length===0)return r;let i=n.map(f=>({s:f,fulfilled:f.edge.impl})),o=f=>{t(f.s),e._noteConformanceRegistryChange()},s=f=>{f.fulfilled===void 0?delete f.s.edge.impl:f.s.edge.impl=f.fulfilled,f.s.edge.pending=!1,e._noteConformanceRegistryChange()};for(let f of i)o(f);let u=new Map(Cp(e).map(f=>[f.name,Gf(f.exceeding)])),a=()=>Cp(e).filter(f=>u.get(f.name)!==Gf(f.exceeding)),l=[];for(let f of i){s(f);let c=a();c.length!==0&&(o(f),l.push({e:f,culprit:c}))}for(let{e:f,culprit:c}of l)r.add(f.s.edge),f.s.edge._pendingReason=`conformance-widens-declared-contract: ${FE(c,"satisfying this conformance again","leave it unsatisfied")}`;return r}function OB(e,n,t,r){let i=vB(n);for(let o of e.conformances){if(o.targetKey===t||r===void 0&&o.where===void 0||vB(o.target)!==i)continue;let s=r!==void 0?t:o.targetKey,u=r!==void 0?o.targetKey:t;return`\`${s}\` is a conditional conformance to \`${e.name}\`, and \`${u}\` already conforms on the same head \`${i}\`. v1 allows at most one conformance per head and protocol \u2014 no specialization among conditional witnesses.`}return null}function PB(e,n,t,r){if(r!==void 0)return null;for(let i of e.conformances)if(i.targetKey!==t&&i.where===void 0&&!(O(n,i.target)||O(i.target,n))&&Hi(n,i.target))return{other:i.targetKey,meet:wie(n,i.target)};return null}function wie(e,n){try{return re(Bn({kind:"intersection",types:[e,n]}))}catch{return"a non-empty intersection"}}var Ar="__get__",_i="__set__";function fa(e,n,t,r,i){let o={kind:"reference",name:t,alias:!0,def:n},s=Object.create(null);for(let a of r??[])s[a.name]={kind:"reference",name:a.name,alias:i?.opaqueVariables!==!0,def:a.bound??"any"};let u=a=>a===la?o:Object.prototype.hasOwnProperty.call(s,a)?s[a]:void 0;return{get names(){return[...e.names,la,...Object.keys(s)]},forward:a=>u(a)??e.forward(a),resolve:a=>u(a)??e.resolve(a),conformsTo:e.conformsTo}}function Th(e){if(e!==void 0)return j(e)?e.string:P(e)}function Cie(e,n,t){try{K(n,e._typeResolver);return}catch{}try{let r=re(K(n,t));return ev(n)?`(${r})`:r}catch{return}}function Nie(e,n,t){if(!g(n,"Function")||n.nops===0)return n;let r=o=>{if(g(o,"Typed")&&o.nops===2||g(o,"Declare")&&o.nops>=2)return 1},i=o=>{if(!g(o))return o;let s=r(o),u=o.ops.map((a,l)=>l===s?a:i(a));if(s!==void 0){let a=Th(o.ops[s]),l=a===void 0?void 0:Cie(e,a,t);l!==void 0&&(u[s]=e.string(l))}return u.every((a,l)=>a===o.ops[l])?o:e._fn(o.operator,u,{canonical:!1})};return i(n)}var xB=new WeakMap;function Rie(e,n,t,r){let i=xB.get(n);i===void 0&&(i=new Map,xB.set(n,i));let o=i.get(r);if(o!==void 0)return o;let s=Nie(e,n,t);return i.set(r,s),s}function Aie(e,n,t,r,i){if(i!==void 0)return n;let o=fa(e._typeResolver,t,r),s=!1,u=Object.create(null);for(let[a,l]of Object.entries(n)){if(!Np(l)){u[a]=l;continue}let f=Rie(e,l,o,r);f!==l&&(s=!0),u[a]=f}return s?u:n}function ON(e,n){if(!g(e,"Function"))return null;let t=[],r=[];for(let s of e.ops.slice(1)){let u=g(s,"Typed")?Th(s.ops[1]):void 0;if(u===void 0){t.push("any"),r.push(!0);continue}t.push(K(u,n)),r.push(!1)}let i=Xg(e),o=i===void 0?void 0:Th(i.ops[1]);if(o===void 0)return{args:t};if(!ev(o)){let s=K(o,n);if(typeof s=="object"&&s.kind==="signature"){let u=s.args??[],a=s.typeParams??[];if(u.length===t.length)for(let l=0;l<t.length;l++)r[l]===!0&&(t[l]=vE(u[l].type,a));return{args:t,result:s.result,effects:br(s)}}}return{args:t,result:K(o,n)}}function Tie(e){let n=Object.create(null);for(let t of e??[])n[t.name]={kind:"reference",name:t.name,alias:!1,def:t.bound??"any"};return n}function Iie(e,n,t){let r;try{r=ON(e,n)}catch{return}if(r?.result!==void 0)return zi(r.result,t)}function DB(e,n,t,r){let i=n==="any"?"`any` (unknown)":`\`${Gf(n)}\``,o=GC(n,t==="any"?void 0:t),s=o===void 0||o==="any"||HC(o)?"any":Gf(o);return`${e} ${i}; the requirement's ceiling on \`${r}\` is \`${Gf(t)}\` \u2014 exceeded by \`${s}\`. Make the implementation purer, or widen the ceiling`}function kie(e,n,t,r){let i=n.args??[];if(e.args.length!==i.length)return`it takes ${e.args.length} parameter${e.args.length===1?"":"s"}; the requirement takes ${i.length}`;for(let s=0;s<i.length;s++)if(!O(i[s].type,e.args[s]))return`argument ${s+1} is \`${re(e.args[s])}\`; expected \`${re(i[s].type)}\` or a supertype`;if((r?.checkResult??!0)&&e.result!==void 0&&!O(e.result,n.result))return`the result is \`${re(e.result)}\`; expected \`${re(n.result)}\` or a subtype`;let o=br(n);return o!==void 0&&!Is(e.effects,o)?DB("it declares the effects",e.effects,o,t):null}function Mie(e,n){if(e.length<3)return;let t=e.length>=6?2:1,r,i=t+1;for(let o of n){if(o===e)return o;let s=xc(e.toLowerCase(),o.toLowerCase(),t);s<i&&(i=s,r=o)}return r}function SB(e,n,t){let r=Mie(n,t);return{code:"protocol-member-unknown",message:`\`${n}\` is not a member of the \`${e}\` protocol.`+(r!==void 0?` Did you mean \`${r}\`?`:"")}}function LE(e,n,t,r,i,o){let s=n.members,u=Object.keys(s),a=kB(e,n,t,i,o);if(a.conflicts.length>0){let b=a.conflicts[0],v=Object.prototype.hasOwnProperty.call(i,`${Ar}${b}`)?"get":"set";return{code:"object-property-conflict",message:`\`${b}\` is a stored field of \`${re(t)}\` and also has an explicit \`${v}\` accessor in this implementation of \`${n.name}\`. A property is field-backed or computed, never both \u2014 drop the accessor, or rename the stored field.`}}let l=o===void 0?r:re(t),f=Tie(o),c=o===void 0?t:zi(t,f),d=o===void 0?void 0:fa(e._typeResolver,c,l,o,{opaqueVariables:!0});o!==void 0&&(t=vE(t,o));let p=fa(e._typeResolver,t,l,o),m=(b,v,E=p)=>{let x=s[b];try{if(v===null){let _=K(x.signature,E);if(typeof _!="object"||_.kind!=="signature")throw Error("not a signature");return _}let S=K(x.type,E),w={name:"self",type:K(la,E)};return v==="get"?{kind:"signature",args:[w],result:S}:{kind:"signature",args:[w,{name:"value",type:S}],result:"any"}}catch(S){return{code:"protocol-signature-mismatch",message:`the requirement \`${n.name}.${b}\` does not parse at \`Self = ${l}\`: ${Sc(S)}`}}};for(let b of Object.keys(i)){let v=b.startsWith(Ar)?"get":b.startsWith(_i)?"set":null,E=v===null?b:b.slice(Ar.length),x=s[E];if(v===null){if(x!==void 0&&x.kind!=="function")return{code:"protocol-member-unknown",message:`\`${E}\` is a ${x.kind} PROPERTY of the \`${n.name}\` protocol, not a function; implement it with \`get ${E}(\u2026)\``};if(x===void 0)return SB(n.name,E,u)}else{if(x?.kind==="function")return{code:"protocol-member-unknown",message:`\`${E}\` is a FUNCTION member of the \`${n.name}\` protocol, not a property; implement it with \`function ${E}(\u2026)\``};if(x===void 0)return SB(n.name,E,u);if(v==="set"&&x.kind==="readonly")return{code:"protocol-property-readonly-set",message:`the property \`${n.name}.${E}\` is \`readonly\`; it has no \`set\` handler`}}let S=i[b];if(!Np(S))continue;let w=m(E,v);if(!("kind"in w))return w;let _;try{_=ON(S,p)}catch(F){return{code:"protocol-signature-mismatch",message:`the signature of \`${wp(v,E)}\` does not parse at \`Self = ${l}\`: ${Sc(F)}`}}if(o!==void 0&&_?.effects!==void 0)return{code:"protocol-conditional-member-effects",message:`a member of a conditional conformance cannot carry an effect specifier (\`${ep(_.effects)}\` on \`${wp(v,E)}\`); remove it \u2014 the member's effects are inferred. A conformance to a ground type (\`type Box = object{\u2026} is ${n.name} { \u2026 }\`) accepts specifiers.`};let A=_===null?"it is not a function literal":kie(_,w,`${n.name}.${E}`,{checkResult:v!=="set"&&d===void 0});if(A!==null)return{code:"protocol-signature-mismatch",message:`the signature of \`${wp(v,E)}\` does not match \`${n.name}.${E}\` at \`Self = ${l}\` \u2014 expected \`${re(w)}\` (${A})`};let N=v===null?br(w):void 0,I=_?.effects;if(N!==void 0||I!==void 0){let F;try{F=vl(e,S)}catch{F=void 0}if(F!==void 0&&!F.unresolvedHead){if(N!==void 0&&!Is(F.effects,N))return{code:"protocol-signature-mismatch",message:`the body of \`${wp(v,E)}\` ${DB("infers the effects",F.effects,N,`${n.name}.${E}`)}`};if(I!==void 0&&!Is(F.effects,I))return{code:"incompatible-type",message:`the body of \`${wp(v,E)}\` infers the effects \`${ep(F.effects)}\`, which the effects it declares (\`${ep(I)}\`) do not cover`,errorArgs:[`${ep(I)} effects`,`${ep(F.effects)} effects`]}}}let B=d===void 0||_===null?void 0:Iie(S,d,f);if(d!==void 0&&v!=="set"){let F=m(E,v,d);if(!("kind"in F))return F;if(B!==void 0&&!O(B,F.result))return{code:"protocol-signature-mismatch",message:`the signature of \`${wp(v,E)}\` does not match \`${n.name}.${E}\` at \`Self = ${l}\` \u2014 expected \`${re(F)}\` (the result is \`${re(B)}\`; expected \`${re(F.result)}\` or a subtype at every instantiation of the clause)`}}}let h=[],y=b=>Object.prototype.hasOwnProperty.call(i,b);for(let b of u){let v=s[b].kind;if(v==="function"){y(b)||h.push(b);continue}a.satisfied.has(b)||(y(`${Ar}${b}`)||h.push(`get ${b}`),v==="readwrite"&&!y(`${_i}${b}`)&&h.push(`set ${b}`))}return h.length>0?{code:"protocol-implementation-missing",message:`the \`${n.name}\` protocol expects a definition of \`${h.join("`, `")}\``}:null}function wp(e,n){return e===null?n:`${e} ${n}`}function Np(e){return typeof e.host!="function"}function FB(e,n,t,r,i){let o=i?.where;if(o!==void 0&&typeof o!="string")throw Error('protocol-conformance-target-invalid: the `where` option must be the clause source text, e.g. `{ where: "T is Comparable" }`');let s=e._protocolRegistry[t];if(s===void 0)throw Error(`protocol-unknown: the protocol \`${t}\` is unknown`);let u,a;if(o!==void 0){let E=AB(e,n,o);if(E.problem!==void 0)throw Error(`protocol-conformance-target-invalid: ${E.problem}`);u=E.head,a=E.params}else try{u=K(n,e._typeResolver)}catch{throw Error(`protocol-target-unknown: the type \`${n}\` is unknown`)}let l=CB(u,n,[t],a!==void 0);if(l!==null)throw Error(`protocol-conformance-target-invalid: ${l}`);let f=MN(e,n);if(f!==null)throw Error(`protocol-conformance-target-invalid: ${f}`);let c=$N(e,s,u,n);if(c!==null)throw Error(`protocol-requires-object: ${c}`);let d=a===void 0?re(u):`${re(u)} where ${RB(a)}`,p=s.conformances.find(E=>E.targetKey===d);if(p?._authored!==void 0)throw Error(`protocol-implementation-duplicate: the type \`${d}\` already has an implementation of the \`${t}\` protocol`);if(p===void 0){let E=OB(s,u,d,a);if(E!==null)throw Error(`protocol-conformance-overlap: ${E}`);let x=PB(s,u,d,a);if(x!==null)throw Error(`protocol-conformance-overlap: \`${d}\` overlaps \`${x.other}\` (meet \`${x.meet}\`) for the protocol \`${t}\`, and neither contains the other`)}let m=Object.create(null),h=(E,x)=>{if(typeof x!="function")throw Error(`The implementation of \`${t}.${E}\` must be a function`);if(m[E]!==void 0)throw Error(`protocol-implementation-duplicate: the implementation of \`${t}\` provides \`${E}\` more than once`);m[E]={host:x}};for(let[E,x]of Object.entries(r.functions??{}))h(E,x);for(let[E,x]of Object.entries(r.getters??{}))h(`${Ar}${E}`,x);for(let[E,x]of Object.entries(r.setters??{}))h(`${_i}${E}`,x);let y=LE(e,s,u,d,m,a);if(y!==null)throw Error(`${y.code}: ${y.message}`);let b=e._protocolRegistryRollbackPoint();if(p!==void 0)p._authored=m,p.impl=m,p.pending=!_c(e,s,p),delete p._pendingReason,Rl(e,s,p,null);else{let E={target:u,targetKey:d,_authored:m,impl:m,pending:!1,declaredByStatement:!1};a!==void 0&&(E.where=a),s.conformances.push(E),E.pending=!_c(e,s,E),Rl(e,s,E,null)}Ah(e,s),e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange();let v=Cp(e);if(v.length>0)throw b(),Error(`conformance-widens-declared-contract: ${FE(v)}`)}var LB="_protocolDispatcher";function xo(e){return e===void 0||!Q(e)?!1:e.operator[LB]===!0}function $ie(e){return e._staticTypeCheckDepth>0&&e.context.name==="epsil:static-check"?e.context.lexicalScope:e._evalContextStack[1]?.lexicalScope??e.context.lexicalScope}function ca(e,n){let t=[];for(let r of aie(e))r.members[n]?.kind==="function"&&t.push(r);return t}function da(e,n,t){return BB(n,t,kN(e._typeResolver))}function PN(e,n,t,r){return BB(n,t,fa(e._typeResolver,r,re(r)))}function BB(e,n,t){let r=e.members[n];if(r===void 0||r.kind!=="function")return null;try{let i=K(r.signature,t);return typeof i!="object"||i.kind!=="signature"?null:i}catch{return null}}function Rh(e){let n=$ie(e),t=new Set;for(let r of Object.values(e._protocolRegistry))for(let[i,o]of Object.entries(r.members))o.kind==="function"&&t.add(i);for(let[r,i]of[...n.bindings])!t.has(r)&&xo(i)&&(xr(e,n.bindings,r,r,"declare"),n.bindings.delete(r),e._noteStateEvent({kind:"binding-repair"}));for(let r of t)Pie(e,n,r)}function Oie(e){return J(e)?e.value.inferredType&&e.value.value===void 0:Q(e)?e.operator.inferredSignature&&e.operator.evaluate===void 0&&e.operator.canonical===void 0:!1}function Pie(e,n,t){let r=n.bindings.get(t),i=xo(r);if(r!==void 0&&!i&&!Oie(r))return;if(!i){let u=n.parent===null?void 0:Fr(t,n.parent);if(u!==void 0&&!xo(u))return}let o=Lie(e,t);if(o===null)return;try{i?Un(e,t,r,o):e.declare(t,o,n)}catch{return}let s=n.bindings.get(t);s!==void 0&&Q(s)&&(Hs(e,s.operator,"redefine"),s.operator[LB]=!0,s.operator._deriveEffects=Fie(e,t))}function Die(e,n){let t;for(let r of ca(e,n)){let i=da(e,r,n);if(i===null)continue;let o=br(i);if(o!==void 0){if(t=Hf(t,o),t==="any")return"any";continue}for(let s of r.conformances){if(s.pending)continue;let u=s.impl?.[n];if(u!==void 0&&Np(u)){try{t=Hf(t,vl(e,u).effects),t=Hf(t,ON(u,kN(e._typeResolver))?.effects)}catch{t="any"}if(t==="any")return"any"}}}return t}function Fie(e,n){let t=-1,r=-1,i,o=!1;return()=>{if(o||t===e._conformanceVersion&&r===e._callableVersion)return i;o=!0;try{return i=Die(e,n),e._rollbackFrames.length===0&&(t=e._conformanceVersion,r=e._callableVersion),i}finally{o=!1}}}function Lie(e,n){let t=ca(e,n);if(t.length===0)return null;let r=t.map(a=>da(e,a,n)).filter(a=>a!==null);if(r.length===0)return null;let i=new Set(r.map(a=>a.args?.length??0)),o=i.size===1?{kind:"signature",args:Array.from({length:[...i][0]},(a,l)=>{let f=Bie(r,l);return f===void 0?{type:"any"}:{name:f,type:"any"}}),result:"unknown"}:{kind:"signature",variadicArg:{type:"any"},variadicMin:1,result:"unknown"},s;for(let a of r)s=Hf(s,br(a));s!==void 0&&!jd(s)&&(o.effects=s);let u=t.map(a=>a.name);return{description:`Protocol member \`${n}\` (${u.map(a=>`\`${a}\``).join(", ")}); dispatches on the runtime type of its first argument.`,...s!==void 0&&!jd(s)?{effects:s}:{pure:!0},lazy:!1,signature:o,canonical:(a,{engine:l})=>jie(l,n,a),type:(a,{engine:l})=>k.forResult(UB(l,n,null,a),l._typeResolver),evaluate:(a,l)=>GB(l.engine,n,null,a,l)}}function Bie(e,n){let t=e[0].args?.[n]?.name;if(t!==void 0){for(let r=1;r<e.length;r++)if(e[r].args?.[n]?.name!==t)return;return t}}function VB(e){let n=e[0];if(!(n===void 0||!n.isValid))return n._literalType!==void 0?Ft(n.type.type):qd(n.type.type)}function jB(e,n,t){let r=ca(e,n);if(r.length===0||t===void 0||!So(t))return r;let i=r.filter(o=>o.conformances.some(s=>hie(e,s,t)));return i.length>0?i:r.every(o=>o.conformances.length===0)?r:null}function qB(e,n,t,r){let i=new Set(n.map(l=>da(e,l,t)?.args?.length)),o=[...r],s=i.size===1?[...i][0]:void 0;s!==void 0&&(o=[...ln(e,o,s)]);let u=VB(o);if(u===void 0||!So(u))return o;let a=n.map(l=>PN(e,l,t,u));if(a.some(l=>l===null))return o;for(let l=1;l<o.length;l++){if(!o[l].isValid)continue;let f=a.map(c=>c.args?.[l]?.type);f.some(c=>c===void 0)||(o[l]=rt(e,o[l],Vie(f)))}return o}function Vie(e){let n=[...new Map(e.map(t=>[re(t),t])).values()];return n.length===1?n[0]:me(...n)}function jie(e,n,t){if(ca(e,n).length===0)return e._fn(n,[...t]);let r=VB(t),i=jB(e,n,r);return i===null?e._fn(n,[e.error(["protocol-implementation-missing",`no implementation of \`${n}\` applies to a value of type \`${re(r)}\``],t[0].toString()),...t.slice(1)]):e._fn(n,qB(e,i,n,t))}function zB(e,n){let t=KB(n);if(t===null)return e._fn("ProtocolMember",[...n]);let r=e._protocolRegistry[t.protocol];return r===void 0||r.members[t.member]?.kind!=="function"?e._fn("ProtocolMember",[...n]):e._fn("ProtocolMember",[n[0],n[1],...qB(e,[r],t.member,t.args)])}function UB(e,n,t,r){if(r.some(a=>a.type==="error"))return"error";let i=t!==null?[t]:jB(e,n,qie(r));if(i===null||i.length===0)return;let o=r[0],s=o===void 0?"unknown":HB(o),u=[];for(let a of i){let l=PN(e,a,n,s);if(l===null)return;u.push(zie(l.result))}if(u.length!==0)return u.length===1?u[0]:me(...u)}function HB(e){return e.structureOf?.()?.kind==="number"?Ft(e.type):qd(e.type)}function qie(e){let n=e[0];if(!(n===void 0||n.type==="error"))return HB(n)}function zie(e){return typeof e!="string"&&e.kind==="reference"&&e.alias&&(e.def==="unknown"||e.def==="any")?e.def:e}function GB(e,n,t,r,i){let o=r[0];if(o===void 0)return;let s=t!==null?[t]:ca(e,n);if(s.length===0||!o.isValid)return;let u=o._literalType!==void 0?Ft(o.type.type):qd(o.type.type);if(!So(u))return;let a=Ih(e,s,n,u);if(a.length===0)return e.error(["protocol-implementation-missing",`no implementation of \`${n}\` applies to a value of type \`${re(u)}\``],e.function(n,[...r],{form:"raw"}).toString());if(a.length>1){let d=[...new Set(a.map(p=>`${p.record.name}(${p.edge.targetKey})`))];return e.error(["protocol-call-ambiguous",`\`${n}\` applies to a value of type \`${re(u)}\` through ${d.map(p=>`\`${p}\``).join(" and ")}. Use a qualified name to narrow the one you meant.`],e.function(n,[...r],{form:"raw"}).toString())}let l=a[0],f=da(e,l.record,n)?.args?.length;if(f!==void 0&&f!==r.length)return e.error(["protocol-signature-mismatch",`\`${l.record.name}.${n}\` takes ${f} argument${f===1?"":"s"}; it was called with ${r.length}`],e.function(n,[...r],{form:"raw"}).toString());let c=Uie(e,PN(e,l.record,n,u),r);return c!==null?c:BE(e,l.impl,r,i)}function Uie(e,n,t){let r=n?.args;if(r===void 0)return null;for(let i=1;i<t.length;i++){let o=t[i],s=r[i]?.type;if(o===void 0||s===void 0||!o.isValid||!So(o.type.type))continue;let u=rt(e,o,s);if(!u.isValid)return u}return null}function Ih(e,n,t,r){let i=[];for(let o of n)for(let s of o.conformances){if(s.pending)continue;let u=s.impl?.[t];if(u===void 0)continue;let a=TB(e,s,r);a!==null&&i.push({record:o,edge:s,impl:u,target:a})}return i.filter(o=>!i.some(s=>s!==o&&O(s.target,o.target)&&!O(o.target,s.target)))}function So(e){return typeof e=="string"?e!=="unknown"&&e!=="any"&&e!=="value"&&e!=="expression":e.kind!=="union"&&e.kind!=="intersection"&&e.kind!=="variable"}function BE(e,n,t,r){if(Np(n))return Ct(n,t,{numericApproximation:r.numericApproximation});let i;try{i=n.host(...t)}catch(o){return e.error(["protocol-implementation-missing",Sc(o)])}return Hie(e,i)}function Hie(e,n){return qo(n)?n:typeof n=="string"?e.string(n):typeof n=="boolean"?n?e.True:e.False:typeof n=="number"||typeof n=="bigint"?e.number(n):n==null?e.Nothing:e.box(n)}function Rp(e,n){let t=P(n);if(t!==void 0&&n.valueDefinition?.value===void 0)return OE(e,t)}function WB(e,n,t){if(!t)return OE(e,n)}function YB(e,n,t){return da(e,n,t)}function ZB(e,n,t,r){let i=e._protocolRegistry[n];if(i===void 0||i.members[t]?.kind!=="function")return null;if(r!==void 0){let o=Fr(n,r);if(o!==void 0&&J(o)&&o.value.value!==void 0)return null}return da(e,i,t)}function JB(e,n,t){let r=da(e,n,t);if(r===null)return;let i=r.args?.length??0,o=Gie(r,i);return e.box(["Function",["ProtocolMember",{str:n.name},{str:t},...o],...o])}function Gie(e,n){let t=(e.args??[]).map(o=>o.name),r=Array.from({length:n},(o,s)=>`x${s+1}`);if(t.length!==n||t.some(o=>o===void 0))return r;let i=t;return new Set(i).size!==i.length?r:i}function KB(e){let n=j(e[0])?e[0].string:P(e[0]),t=j(e[1])?e[1].string:P(e[1]);return n===void 0||t===void 0?null:{protocol:n,member:t,args:e.slice(2)}}function QB(e,n,t){let r=KB(n);if(r===null)return;let i=e._protocolRegistry[r.protocol];return i===void 0?e.error(["protocol-unknown",`the protocol \`${r.protocol}\` is unknown`]):i.members[r.member]?.kind!=="function"?e.error(["unknown-field",r.member],r.protocol):GB(e,r.member,i,r.args,t)}function ME(e){let n=e?.structureOf?.();if(n?.kind==="string")return n.text;if(n?.kind==="symbol")return n.name}function Wie(e){let n=ME(e[0]),t=ME(e[1]);return n===void 0||t===void 0?null:{protocol:n,member:t,args:e.slice(2)}}function XB(e,n){let t=Wie(n);if(t===null)return;let r=OE(e,t.protocol);if(r!==void 0)return UB(e,t.member,r,t.args)}function VE(e,n,t){return(t!==void 0?[t]:Object.values(e._protocolRegistry)).filter(i=>{let o=i.members[n];return o!==void 0&&o.kind!=="function"})}function DN(e,n,t){let r=ca(e,t);return r.length===0?[]:So(n)?[...new Set(Ih(e,r,t,n).map(i=>i.record.name))]:[]}function kh(e,n,t,r){let i=VE(e,t,r);if(i.length===0)return{status:"none"};if(!So(n))return{status:"undecided"};let o=Ih(e,i,`${Ar}${t}`,n);if(o.length===0)return{status:"none"};if(o.length>1)return{status:"ambiguous",through:[...new Set(o.map(a=>`${a.record.name}(${a.edge.targetKey})`))]};let s=o[0],u=s.record.members[t];return u.kind==="function"?{status:"none"}:{status:"found",record:s.record,edge:s.edge,kind:u.kind,declared:u.type}}function Yie(e,n,t,r){let i=kh(e,n,t,r);if(i.status!=="found")return!1;let o=i.edge.impl?.[`${Ar}${t}`];return o!==void 0&&wc(o)}function FN(e,n,t,r){return e.error(["protocol-property-ambiguous",`the property \`${n}\` applies to a value of type \`${re(t)}\` through ${r.map(i=>`\`${i}\``).join(" and ")}. Qualify it \u2014 \`x.(${r[0]?.split("(")[0]??"Protocol"}.${n})\` \u2014 to narrow the one you meant.`])}function jE(e,n,t,r){if(n==="error")return;let i=kh(e,n,t,r);if(i.status==="undecided")return"unknown";if(i.status==="ambiguous")return"error";if(i.status!=="none")try{return K(i.declared,fa(e._typeResolver,n,re(n)))}catch{return"error"}}function LN(e,n,t,r,i){if(!n.isValid)return;let o=n.type.type,s=kh(e,o,t,i);if(s.status==="none"||s.status==="undecided")return;if(s.status==="ambiguous")return FN(e,t,o,s.through);let u=s.edge.impl?.[`${Ar}${t}`];if(u!==void 0){if(wc(u)){if(!Vn(n))return;let a=qE(e,n,u._fieldBacked,s,!0);return a!==null?a:n._field(u._fieldBacked)}return BE(e,u,[n],r)}}function qE(e,n,t,r,i=!1){let o=n._fieldType(t),s=n.type.type;if(fo(s)===void 0)return null;if(o!==void 0){let u=fo(r.edge.target);if(u!==void 0&&Object.prototype.hasOwnProperty.call(u.elements,t)&&u.elements[t]===o)return i?_B(e,n,t,r,void 0,o):null;let a=e6(e,r.record.name,t,r.declared,s);if(a===void 0)return null;if(MB(o,a,r.kind))return i?_B(e,n,t,r,a):null}return e.error(["protocol-implementation-missing",`no implementation of the \`${r.record.name}.${t}\` property applies to this value: it was constructed with a layout in which \`${t}\` ${o===void 0?"is not a stored field":`is declared \`${re(o)}\``}, which does not satisfy the requirement. Rebuild it from the current declaration of \`${re(s)}\`.`])}function _B(e,n,t,r,i,o){let s=n._field(t);if(s===void 0||!s.isValid||!So(s.type.type)||o!==void 0&&O(s.type.type,o))return null;let u=n.type.type,a=i??e6(e,r.record.name,t,r.declared,u);return a===void 0||O(s.type.type,a)?null:e.error(["protocol-implementation-missing",`no implementation of the \`${r.record.name}.${t}\` property applies to this value: its stored \`${t}\` holds \`${re(s.type.type)}\`, which the property's \`${re(a)}\` does not admit. It was built before \`${re(u)}\` \u2014 or a type its layout refers to \u2014 was re-declared; rebuild it from the current declaration.`])}var wB=new WeakMap;function e6(e,n,t,r,i){let o=()=>{try{return K(r,fa(e._typeResolver,i,re(i)))}catch{return}};if(typeof i!="object"||i===null)return o();let s=wB.get(i);s===void 0&&(s=new Map,wB.set(i,s));let u=`${n}\0${t}`,a=s.get(u);if(a!==void 0&&a.conformance===e._conformanceVersion&&a.callable===e._callableVersion)return a.value;let l=o();return s.set(u,{conformance:e._conformanceVersion,callable:e._callableVersion,value:l}),l}function Zie(e){let n=j(e[0])?e[0].string:P(e[0]),t=j(e[1])?e[1].string:P(e[1]),r=e[2];return n===void 0||t===void 0||r===void 0?null:{protocol:n,name:t,base:r,value:e[3]}}function Jie(e){let n=ME(e[0]),t=ME(e[1]),r=e[2];return n===void 0||t===void 0||r===void 0?null:{protocol:n,name:t,base:r,value:e[3]}}function n6(e,n){let t=Jie(n);if(t===null)return;let r=OE(e,t.protocol);return r===void 0?"error":t.value!==void 0?t.value.type:jE(e,t.base.type,t.name,r)??"error"}function t6(e,n,t){let r=Zie(n);if(r===null)return;let i=e._protocolRegistry[r.protocol];if(i===void 0)return e.error(["protocol-unknown",`the protocol \`${r.protocol}\` is unknown`]);let o=i.members[r.name];if(o===void 0||o.kind==="function")return e.error(["unknown-field",r.name],i.name);if(r.value===void 0){if(!r.base.isValid||!So(r.base.type.type))return;let m=LN(e,r.base,r.name,t,i);return m!==void 0?m:Yie(e,r.base.type.type,r.name,i)?void 0:$E(e,r.base,r.name,i)}let s=r.base;if(!s.isValid)return;let u=s.type.type;if(u==="error")return;let a=So(u);if(a&&!zu(u))return Ap(e,r.name,u);if(o.kind==="readonly")return BN(e,i.name,r.name);if(!a||!Vn(s))return;let l=Ih(e,[i],`${_i}${r.name}`,u);if(l.length===0)return $E(e,s,r.name,i);if(l.length>1)return FN(e,r.name,u,l.map(m=>`${m.record.name}(${m.edge.targetKey})`));let f=l[0],c=f.record.members[r.name],d=c===void 0||c.kind==="function"?null:r6(e,u,c.type,r.value);if(d!==null)return d;if(wc(f.impl)&&c!==void 0&&c.kind!=="function"&&Vn(s)){let m=qE(e,s,f.impl._fieldBacked,{status:"found",record:f.record,edge:f.edge,kind:c.kind,declared:c.type});if(m!==null)return m}let p=BE(e,f.impl,[s,r.value],t);if(p!==void 0)return p.isValid?r.value:p}function Ap(e,n,t){return e.error(["immutable-value-assignment",`\`${re(t)}\` is not an object type, and only an object's fields can be assigned. Build an updated copy with the new \`${n}\`, or declare the type as \`object{\u2026}\``])}function r6(e,n,t,r){if(!r.isValid||!So(r.type.type))return null;let i;try{i=K(t,fa(e._typeResolver,n,re(n)))}catch{return null}let o=rt(e,r,i);return o.isValid?null:o}function $E(e,n,t,r){return e.error(["protocol-implementation-missing",`no implementation of the \`${r.name}.${t}\` property applies to a value of type \`${re(n.type.type)}\``])}function BN(e,n,t){return e.error(["protocol-property-readonly-set",`the property \`${n}.${t}\` is \`readonly\`; it cannot be assigned`])}function i6(e,n,t){let r=e._protocolRegistry[n];if(r===void 0)return e.error(["protocol-unknown",`the protocol \`${n}\` is unknown`]);let i=r.members[t];if(i===void 0||i.kind==="function")return e.error(["unknown-field",t],r.name)}function VN(e,n,t,r){if(!n.isValid)return;let i=n.type.type;if(i!=="error"&&So(i)&&!zu(i))return Ap(e,t,i);if(!Vn(n))return;let o=kh(e,i,t,r);if(o.status!=="found")return;if(o.kind==="readonly")return BN(e,o.record.name,t);let s=o.edge.impl?.[`${_i}${t}`];if(!(s===void 0||!wc(s)))return qE(e,n,s._fieldBacked,o)??void 0}function o6(e,n,t,r,i){if(!n.isValid||!Vn(n))return;let o=n.type.type,s=kh(e,o,t);if(s.status==="none"||s.status==="undecided")return;if(s.status==="ambiguous")return FN(e,t,o,s.through);if(s.kind==="readonly")return BN(e,s.record.name,t);let u=r6(e,o,s.declared,r);if(u!==null)return u;let a=s.edge.impl?.[`${_i}${t}`];if(a===void 0)return $E(e,n,t,s.record);if(wc(a)){let f=qE(e,n,a._fieldBacked,s);if(f!==null)return f}let l=BE(e,a,[n,r],i);return l===void 0?$E(e,n,t,s.record):l.isValid?r:l}function Kie(e){return e.startsWith(Ar)?e.slice(Ar.length):e.startsWith(_i)?e.slice(_i.length):null}function Mh(e,n,t){let r=Kie(n),i=r??n,o;if(t!==void 0){let u=e._protocolRegistry[t],a=u?.members[i];if(a===void 0||(r===null?a.kind!=="function":a.kind==="function"))return null;o=[u]}else if(o=r===null?ca(e,i):VE(e,i),o.length===0)return null;let s=[];for(let u of o)u.conformances.forEach((a,l)=>{if(a.pending)return;let f=a.impl?.[n];f!==void 0&&s.push({record:u,edge:a,edgeIndex:l,target:a.target,widest:DE(a),conditional:a.where!==void 0,host:!Np(f)})});return s}function s6(e,n,t,r){if(!So(t))return{status:"undecided"};let i=Mh(e,n,r);if(i===null||i.length===0)return{status:"none"};let o=[...new Set(i.map(a=>a.record))],s=Ih(e,o,n,t);if(s.length===0)return{status:"none"};if(s.length>1)return{status:"ambiguous"};let u=s[0];return{status:"unique",record:u.record,edge:u.edge,target:u.target}}function u6(e,n,t){let r=da(e,n,t);if(r!==null&&!((r.optArgs?.length??0)>0||r.variadicArg!==void 0))return r.args?.length??0}function jN(e,n,t){let r=n.impl?.[t];if(r===void 0||!Np(r)||n.where!==void 0||!g(r,"Function"))return null;let i=fa(e._typeResolver,n.target,n.targetKey),o=a=>{try{let l=re(K(a,i));return ev(a)?`(${l})`:l}catch{return null}},s=[];for(let a of r.ops.slice(1)){if(!g(a,"Typed")){s.push(a);continue}let l=Th(a.ops[1]);if(l===void 0){s.push(a);continue}let f=o(l);if(f===null)return null;s.push(e._fn("Typed",[a.ops[0],e.string(f)],{canonical:!1}))}let u=r.ops[0];if(g(u,"Typed")){let a=Th(u.ops[1]);if(a!==void 0){let l=o(a);if(l===null)return null;u=e._fn("Typed",[u.ops[0],e.string(l)],{canonical:!1})}}return e._fn("Function",[u,...s],{canonical:!1})}var Ys=class extends Error{code;constructor(n,t){super(t),this.name="CheckpointError",this.code=n}},zE=class{id;label;engine;window;snapshot;contextStack;_live=!0;get live(){return this._live}constructor(n,t,r,i,o,s){this.engine=n,this.id=t,this.label=r,this.window=i,this.snapshot=o,this.contextStack=s}};function qN(e,n){let t=r=>{throw new Ys("checkpoint-not-quiescent",`${n}: the engine is not at a quiescent cell boundary (${r}). Checkpoint operations are legal only between statements, with no evaluation, static pre-pass or declaration batch in progress.`)};if(e._checkpointPoisoned)throw new Ys("checkpoint-restore-failed",`${n}: a previous restore failed and left this engine poisoned. Its state is no longer covered by the checkpoint contract \u2014 rebuild the engine and replay from the baseline instead.`);e._staticTypeCheckDepth!==0&&t("a static pre-pass is running"),e._staticAssignmentEvidence!==void 0&&t("static assignment evidence is installed"),e._epsilDeclarationRoute&&t("an Epsil declaration route is open"),e._epsilBatchId!==void 0&&t("an Epsil batch is executing"),e._rollbackFrames.length!==0&&t("an inference rollback frame is open"),e._inferenceTxDepth!==0&&t("a boxing pass is in progress"),e._boxingState.frameDepth()!==0&&t("a boxing repair frame is open"),e._evaluationDepth!==0&&t("an evaluation is in progress"),e._inFlightAsyncEvaluations!==0&&t("an asynchronous evaluation is suspended")}function Qie(e,n,t){let r=e._evalContextStack;if(r.length>t.length)throw new Ys("checkpoint-not-quiescent",`${n}: ${r.length-t.length} scope(s) have been pushed since this checkpoint was taken. Pop back to the checkpoint's scope before restoring.`);if(!(r.length===t.length&&t.every((o,s)=>r[s]===o)))throw new Ys("checkpoint-not-quiescent",`${n}: the evaluation-context stack no longer contains the frames this checkpoint captured (now ${r.length} frame(s), captured ${t.length}). A live checkpoint's frames should be impossible to pop without retiring it, so this indicates a frame-discard site that missed the checkpoint-retirement hook \u2014 an engine bug, not a caller scope mismatch.`)}function a6(e,n,t){if(!(n instanceof zE)||n.engine!==e)throw new Ys("checkpoint-foreign-engine",`${t}: this checkpoint belongs to a different engine.`);if(!n._live)throw new Ys("checkpoint-dead",`${t}: checkpoint ${n.id} is no longer live \u2014 it was discarded, or invalidated by a restore to an earlier checkpoint.`);return n}function Xie(e){return e._evalContextStack.map(n=>({context:n,entries:[...n.assumptions.entries()],dirty:n._assumptionsDirty,assumedValues:[...n.assumedValues.entries()]}))}function eoe(e){for(let{context:n,entries:t,dirty:r,assumedValues:i}of e){n.assumptions.clear();for(let[o,s]of t){let u=s.filter(a=>!a.subjects.some(l=>l.def.disposed));u.length!==0&&n.assumptions.set(o,u)}n._assumptionsDirty=r,n.assumedValues.clear();for(let[o,s]of i)o.disposed||n.assumedValues.set(o,s)}}function noe(e){let n=e;return{precision:e.precision,tolerance:e.tolerance,angularUnit:e.angularUnit,strict:e.strict,jit:e.jit,costFunction:n._cost,integrationProvider:n._integrationProvider,iterationLimit:e.iterationLimit,recursionLimit:e.recursionLimit,maxCollectionSize:e.maxCollectionSize,latexOptions:{...n._latexOptions},ruleStores:[n._simplificationRules,n._solveRules,n._harmonizationRules].map(t=>({store:t,rules:[...t.rules]})),compilationTargets:e._listCompilationTargets().map(t=>[t,e._getCompilationTarget(t)])}}function toe(e,n){let t=e;e.precision=n.precision,e.tolerance=n.tolerance,e.angularUnit=n.angularUnit,e.strict=n.strict,e.jit=n.jit,t._cost=n.costFunction,t._integrationProvider=n.integrationProvider,e.iterationLimit=n.iterationLimit,e.recursionLimit=n.recursionLimit,e.maxCollectionSize=n.maxCollectionSize,t._latexOptions={...n.latexOptions};for(let{store:i,rules:o}of n.ruleStores)i.rules=[...o];let r=new Map(n.compilationTargets);for(let i of e._listCompilationTargets())r.has(i)||e._unregisterCompilationTarget(i);for(let[i,o]of r)e._getCompilationTarget(i)!==o&&e._registerCompilationTarget(i,o)}function l6(e,n){qN(e,"checkpoint()");let t={typeRegistry:e._typeRegistryRollbackPoint(),protocolRegistry:e._protocolRegistryRollbackPoint(),assumptions:Xie(e),config:noe(e),sequences:X5(e)},r=new o2;e._checkpointWindow=r;let i=new zE(e,e._nextCheckpointId++,n,r,t,[...e._evalContextStack]);return e._checkpointStack.push(i),i}function f6(e,n){qN(e,"restore()");let t=a6(e,n,"restore()");Qie(e,"restore()",t.contextStack);let r=e._checkpointStack,i=r.indexOf(t);i>=0;let o=r.slice(i),s=o.map(a=>a.window).filter(a=>a!==void 0).reverse(),u;e._checkpointWindow=void 0;try{for(let c of o)c._live=!1,c.window=void 0;r.length=i;let a=new Set,l=[];for(let c of s){for(let p of c.owners())a.add(p);for(let p of c.created())l.push(p);let d=c.undo();u??=d}t.snapshot.typeRegistry(),t.snapshot.protocolRegistry(),eoe(t.snapshot.assumptions),toe(e,t.snapshot.config),eB(e,t.snapshot.sequences);for(let c of l)try{c.dispose()}catch(d){u??={error:d}}e._cacheStore.purgeValues();for(let c of a)hp(c);for(let c of e._checkpointResetHooks??[])try{c()}catch(d){u??={error:d}}e._noteStateEvent({kind:"config"}),e._noteConformanceRegistryChange();for(let c of a){let d=c;typeof d._writeVersion=="number"&&(d._writeVersion+=1),typeof d._version=="number"&&(d._version+=1)}Rh(e);let f=new o2;t._live=!0,t.window=f,r.push(t),e._checkpointWindow=f}catch(a){throw e._checkpointWindow=void 0,e._checkpointPoisoned=!0,new Ys("checkpoint-restore-failed",`restore(): a throw escaped the mutation phase and the engine is now poisoned. Rebuild the engine and replay from the baseline. Cause: ${String(a)}`)}if(u!==void 0)throw e._checkpointPoisoned=!0,new Ys("checkpoint-restore-failed",`restore(): an undo entry threw while unwinding; engine state is only partially restored and is now poisoned. Rebuild the engine and replay from the baseline. Cause: ${String(u.error)}`)}function c6(e,n){let t=e._checkpointStack,r=t.length;for(;r>0&&t[r-1].contextStack.includes(n);)r--;if(r===t.length)return;let i=r>0?t[r-1].window:void 0,o=t.slice(r);for(let s=o.length-1;s>=0;s--){let u=s>0?o[s-1].window:i,a=o[s].window;a!==void 0&&u!==void 0&&a.foldInto(u),o[s]._live=!1,o[s].window=void 0}t.length=r,e._checkpointWindow=i}function d6(e,n){qN(e,"discard()");let t=a6(e,n,"discard()"),r=e._checkpointStack,i=r.indexOf(t);i>=0;let o=t.window,s=i>0?r[i-1]:void 0;o!==void 0&&s?.window!==void 0&&o.foldInto(s.window),r.splice(i,1),t._live=!1,t.window=void 0,e._checkpointWindow=r[r.length-1]?.window}var ni={attempts:0,compiledHits:0,revalidations:0,recompiles:0,elementFallbacks:0,nanDoubleChecks:0};function roe(e){return oe(e).finite}function ioe(e){return oe(e).collection}function ooe(e){return oe(e).indexed}function soe(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}function uoe(e){let n=new Map,t=r=>{if(!g(r,"List"))return[];let i=n.get(r);if(i!==void 0)return i;let o;for(let u of r.ops){let a=t(u);if(o===void 0)o=a;else{let l=0;for(;l<o.length&&l<a.length&&o[l]===a[l];)l++;l<o.length&&(o=o.slice(0,l))}if(o.length===0)break}let s=[r.nops,...o??[]];return n.set(r,s),s};return t(e)}function x6(e,n){if(C(e)){let t={kind:"symbol",name:e.symbol},r=e.valueDefinition;if(r!==void 0){r.inferredType===!0&&(t.inferred=!0);let i=e.engine.contextStack[0]?.lexicalScope.bindings.get(e.symbol);i!==void 0&&"value"in i&&i.value===r&&(t.system=!0)}return t}if(j(e))return{kind:"string",text:e.string};if(T(e)){let t=e.isSame(0)?0:e.isSame(1)?1:void 0,r,i=!1,o={kind:"number",tier:pv(e),get rational(){if(!i){i=!0;let s=qe(e);s!==void 0&&(r=[BigInt(s[0]),BigInt(s[1])])}return r}};return t!==void 0&&(o.literal=t),o}if(g(e,"Function")){let t=eh(e),r=t===void 0?void 0:x6(t,n);return r===void 0?void 0:{kind:"function-literal",parameters:e.ops.slice(1).map(i=>{if(Zi(i))return{name:Te(i),rest:!0};let o=gl(i),s=Te(i);return o===void 0?{name:s}:{name:s,annotated:o}}),body:r}}if(g(e,"Tuple")){let t=e.ops,r;return{kind:"tuple",arity:e.nops,get elements(){return r??=t.map(i=>wi(i,void 0,n))}}}if(g(e,"List")){let t=e.ops,r;return{kind:"list-literal",shape:uoe(e),get elements(){return r??=t.map(i=>wi(i,void 0,n))}}}if(g(e)){let t=e.ops,r;return{kind:"application",head:e.operator,get children(){return r??=t.map(i=>wi(i,void 0,n))}}}}function wi(e,n,t){if(n===void 0){let i=t?.get(e);if(i!==void 0)return i}TF&&aoe.built++;let r=new UN(e,n,t);return n===void 0&&t?.set(e,r),r}var aoe={built:0},p6=1,m6=2,g6=4,h6=8,y6=16,b6=32,v6=64,E6=128,zN=class{#e;#n;_computed=0;_shape;_finite;_sgn;_closed;_collection;_finiteCollection;_indexed;_elementType;constructor(n,t){this.#e=n,this.#n=t}get finite(){return this._computed&p6||(this._computed|=p6,this._finite=this.finiteOf()),this._finite}get sgn(){if(!(this._computed&m6)){this._computed|=m6;let n=this.#e,t;(T(n)||C(n)||g(n))&&(t=n.sgn),this._sgn=t??Jf(this.#n.type)}return this._sgn}get closed(){return this._computed&g6||(this._computed|=g6,this._closed=this.#e.isConstant),this._closed}get collection(){if(!(this._computed&h6)){this._computed|=h6;let n=ioe(this.#n.type);this._collection=n===!0||this.#e.isCollection===!0?!0:n}return this._collection}get finiteCollection(){return this._computed&y6||(this._computed|=y6,this._finiteCollection=this.shape!==void 0?!0:this.collection!==!1?this.#e.isFiniteCollection:void 0),this._finiteCollection}get indexed(){if(!(this._computed&b6)){this._computed|=b6;let n=ooe(this.#n.type);this._indexed=n===!0||this.#e.isIndexedCollection===!0?!0:n}return this._indexed}get shape(){return this._computed&E6||(this._computed|=E6,this._shape=soe(this.#n.type)),this._shape}get elementType(){if(!(this._computed&v6)){this._computed|=v6;let n=this.#e;this._elementType=!g(n)||this.collection===!1?void 0:n.operatorDefinition?.collection?.elttype?.(n)}return this._elementType}finiteOf(){let n=roe(this.#n.type);if(n!==void 0)return n;let t=this.#e;if(T(t))return t.isFinite;if(C(t)){let r=t.valueDefinition?.value;return r!==void 0&&T(r)?r.isFinite:void 0}if(g(t)&&O(this.#n.type,"number"))return t.isFinite}},UN=class{#e;#n;_facts;_type;_structure;_structureComputed=!1;constructor(n,t,r){this.#e=n,this.#n=r,this._type=t,t===void 0&&!T(n)&&(this._type=n.type.type)}get facts(){return this._facts??=new zN(this.#e,this)}get type(){return this._type??=this.#e._literalType??this.#e.type.type}structureOf=()=>(this._structureComputed||(this._structureComputed=!0,this._structure=x6(this.#e,this.#n??=new Map)),this._structure)},UE=class{constructor(n,t=void 0){this.type=n;this.closed=t}type;closed;get finite(){return oe(this.type).finite}get sgn(){return Jf(this.type)}get collection(){return oe(this.type).collection}get finiteCollection(){return oe(this.type).finiteCollection}get indexed(){return oe(this.type).indexed}get shape(){return oe(this.type).shape}};function Vr(e,n){return{type:e,facts:new UE(e,n)}}function HE(e,n="__boundSymbol"){return{type:e,facts:new UE(e,!1),structureOf:()=>({kind:"symbol",name:n})}}function ti(e,n){if(O(e,n))return!0;if(dn(e,n))return!1}var loe=(()=>{try{return typeof process<"u"&&process.env!==void 0&&(process.env.CE_TYPE_PURITY_GUARD??"")!==""}catch{return!1}})();function GE(e,n,t){if(!loe)return t();let r=e._anyVersion,i=e._semanticVersion,o=e._worldVersion,s=e._callableVersion,u=e._scratchDeclarationScopes.length,a,l=!1;try{return t()}catch(f){throw a=f,l=!0,f}finally{l&&foe(a)||coe(e,n,r,i,o,s,u)}}var S6="modified engine state while deriving a type";function foe(e){return e instanceof Error&&e.message.includes(S6)}function coe(e,n,t,r,i,o,s){{let u=[];if(e._anyVersion!==t&&u.push("any"),e._semanticVersion!==r&&u.push("semantic"),e._worldVersion!==i&&u.push("world"),e._callableVersion!==o&&u.push("callable"),e._scratchDeclarationScopes.length!==s&&u.push("scratch-scopes"),u.length>0)throw new Error(`The type handler of "${n}" ${S6} (moved: ${u.join(", ")}). A type handler must not declare, canonicalize, or evaluate anything.`)}}async function _6(e,n){return await w6(e,n)??e}async function w6(e,n){let t;for(let r=0;r<e.length;r++){let i=await doe(e[r],n);i!==e[r]&&t===void 0&&(t=e.slice(0,r)),t!==void 0&&t.push(i)}return t}async function doe(e,n){if(!g(e))return e;let t=e.operatorDefinition;if(t!==void 0){if(t.evaluateAsync!==void 0&&t.evaluate===void 0)return e.evaluateAsync(n);if(t.selectsOperands)return t.evaluateAsync!==void 0?e.evaluateAsync(n):e;if(t.scoped||t.holdClass==="quote")return e}let r=await w6(e.ops,n);return r===void 0?e:e.engine.function(e.operator,r)}function WE(e){return e.engine._hasAsyncOnlyOperator?C6(e):!1}function C6(e){if(!g(e))return!1;let n=e.operatorDefinition;if(n!==void 0){if(n.evaluateAsync!==void 0&&n.evaluate===void 0)return!0;if(n.holdClass==="quote")return!1}return e.ops.some(C6)}var Jn=class e{vars;terms;constructor(n,t){this.vars=n,this.terms=t??new Map}static zero(n){return new e(n)}static constant(n,t){let r=new e(n);return t!==0n&&r.terms.set(e.key(n.map(()=>0)),t),r}static key(n){return n.join(",")}static exp(n){return n===""?[]:n.split(",").map(Number)}clone(){return new e(this.vars,new Map(this.terms))}isZero(){return this.terms.size===0}get nbTerms(){return this.terms.size}asConstant(){if(this.terms.size===0)return 0n;if(this.terms.size===1){let n=[...this.terms.keys()][0];if(e.exp(n).every(t=>t===0))return this.terms.get(n)}}accumulate(n,t){if(t===0n)return;let r=e.key(n),i=(this.terms.get(r)??0n)+t;i===0n?this.terms.delete(r):this.terms.set(r,i)}add(n){let t=this.clone();for(let[r,i]of n.terms)t.accumulate(e.exp(r),i);return t}sub(n){let t=this.clone();for(let[r,i]of n.terms)t.accumulate(e.exp(r),-i);return t}neg(){let n=new e(this.vars);for(let[t,r]of this.terms)n.terms.set(t,-r);return n}mul(n){let t=new e(this.vars);for(let[r,i]of this.terms){let o=e.exp(r);for(let[s,u]of n.terms){let a=e.exp(s);t.accumulate(o.map((l,f)=>l+a[f]),i*u)}}return t}scaleInt(n){if(n===0n)return e.zero(this.vars);let t=new e(this.vars);for(let[r,i]of this.terms)t.terms.set(r,i*n);return t}equals(n){if(this.terms.size!==n.terms.size)return!1;for(let[t,r]of this.terms)if(n.terms.get(t)!==r)return!1;return!0}maxNorm(){let n=0n;for(let t of this.terms.values()){let r=t<0n?-t:t;r>n&&(n=r)}return n}contentInteger(){let n=0n;for(let t of this.terms.values())n=$h(n,t);return n===0n?1n:n}divExactInteger(n){let t=new e(this.vars);for(let[r,i]of this.terms){if(i%n!==0n)throw new Error("MPoly.divExactInteger: not divisible");t.terms.set(r,i/n)}return t}primitivePartInteger(){if(this.isZero())return this;let n=this.contentInteger(),t=this.leadingLex();return t&&t.c<0n&&(n=-n),n===1n?this:this.divExactInteger(n)}degreeIn(n){let t=0;for(let r of this.terms.keys())t=Math.max(t,e.exp(r)[n]??0);return t}totalDegree(){let n=0;for(let t of this.terms.keys())n=Math.max(n,e.exp(t).reduce((r,i)=>r+i,0));return n}leadingLex(){let n,t="";for(let r of this.terms.keys()){let i=e.exp(r);(!n||poe(i,n))&&(n=i,t=r)}return n?{exp:n,c:this.terms.get(t)}:void 0}static tryDivide(n,t){if(t.isZero())return null;let r=t.leadingLex(),i=n.clone(),o=new e(n.vars),s=0;for(;!i.isZero();){if(++s>5e5)return null;let u=i.leadingLex();if(!u.exp.every((c,d)=>c>=r.exp[d])||u.c%r.c!==0n)return null;let a=u.exp.map((c,d)=>c-r.exp[d]),l=u.c/r.c;o.accumulate(a,l);let f=new e(n.vars);f.terms.set(e.key(a),l),i=i.sub(t.mul(f))}return o}evalVar(n,t){let r=this.vars.filter((o,s)=>s!==n),i=new e(r);for(let[o,s]of this.terms){let u=e.exp(o);i.accumulate(u.filter((a,l)=>l!==n),s*t**BigInt(u[n]))}return i}coeffsInVar(n){let t=this.degreeIn(n),r=this.vars.filter((o,s)=>s!==n),i=Array.from({length:t+1},()=>new e(r));for(let[o,s]of this.terms){let u=e.exp(o);i[u[n]].accumulate(u.filter((a,l)=>l!==n),s)}return i}static fromVarCoeffs(n,t,r){let i=new e(r);for(let o=0;o<n.length;o++)for(let[s,u]of n[o].terms){let a=e.exp(s),l=[],f=0;for(let c=0;c<r.length;c++)l.push(c===t?o:a[f++]);i.accumulate(l,u)}return i}modP(n){let t=new e(this.vars),r=n/2n;for(let[i,o]of this.terms){let s=(o%n+n)%n;s>r&&(s-=n),s!==0n&&t.terms.set(i,s)}return t}};function $h(e,n){for(e=e<0n?-e:e,n=n<0n?-n:n;n;)[e,n]=[n,e%n];return e}function poe(e,n){for(let t=0;t<e.length;t++)if(e[t]!==n[t])return e[t]>n[t];return!1}function HN(e,n,t){let r=e.expr(["Expand",n]).evaluate(),i=new Map(t.map((l,f)=>[l,f])),o=[],s=g(r,"Add")?r.ops:[r];for(let l of s){let f=t.map(()=>0),c=1n,d=1n,p=[l];for(;p.length;){let m=p.pop();if(g(m,"Negate")){c=-c,p.push(m.ops[0]);continue}if(g(m,"Multiply")){for(let y of m.ops)p.push(y);continue}if(C(m)&&i.has(m.symbol)){f[i.get(m.symbol)]+=1;continue}if(g(m,"Power")){let y=m.ops[0],b=m.ops[1];if(C(y)&&i.has(y.symbol)&&b.isInteger){let v=YE(b);if(v===null||v<0n)return null;f[i.get(y.symbol)]+=Number(v);continue}return null}let h=moe(m);if(h===null)return null;c*=h.num,d*=h.den}o.push({exp:f,num:c,den:d})}let u=1n;for(let l of o)u=u/$h(u,l.den)*l.den;let a=new Jn(t);for(let l of o){let f=l.num*(u/l.den);if(f!==0n){let c=Jn.key(l.exp),d=(a.terms.get(c)??0n)+f;d===0n?a.terms.delete(c):a.terms.set(c,d)}}return a}function GN(e,n){if(n.isZero())return e.expr(0);let t=[];for(let[r,i]of n.terms){let o=Jn.exp(r),s=[];o.forEach((a,l)=>{a===1?s.push(e.symbol(n.vars[l])):a>1&&s.push(e.expr(["Power",e.symbol(n.vars[l]),a]))});let u=e.number(i);s.length===0?t.push(u):t.push(e.function("Multiply",[u,...s]))}return t.length===1?t[0]:e.function("Add",t)}function YE(e){if(!e.isInteger)return null;try{return BigInt(e.toString())}catch{return null}}function moe(e){if(!T(e))return null;if(e.isInteger){let r=YE(e);return r===null?null:{num:r,den:1n}}let n=e.numerator,t=e.denominator;if(n&&t){let r=YE(n),i=YE(t);if(r!==null&&i!==null&&i!==0n)return{num:r,den:i}}return null}function I6(e,n,t,r){let i=HN(e,n,r),o=HN(e,t,r);if(!i||!o||i.isZero()||o.isZero())return null;YN=k6;let s=i.contentInteger(),u=o.contentInteger(),a=$h(s,u),l=i.divExactInteger(s),f=o.divExactInteger(u),c=$h(N6(l).contentInteger(),N6(f).contentInteger());for(let d of goe){if(l.maxNorm()%d===0n||f.maxNorm()%d===0n)continue;let p;try{p=ZE(l.modP(d),f.modP(d),r,d,c)}catch{p=null}if(!p||p.isZero())continue;let m=p.primitivePartInteger();if(Jn.tryDivide(l,m)===null||Jn.tryDivide(f,m)===null)continue;let h=m.scaleInt(a).primitivePartInteger(),y=a===1n?m:h;return Jn.tryDivide(i,y)&&Jn.tryDivide(o,y)?GN(e,y):GN(e,m)}return null}var goe=[1000000007n,1000000009n,998244353n,2147483647n,2305843009213693951n],k6=4e6,YN=k6;function JN(e){if(YN-=e,YN<0)throw new Error("multivariateGCD: budget exceeded")}function _o(e,n){let t=e%n;return t<0n?t+n:t}function Oh(e,n){let[t,r]=[_o(e,n),n],[i,o]=[1n,0n];for(;r!==0n;){let s=t/r;[t,r]=[r,t-s*r],[i,o]=[o,i-s*o]}if(t!==1n)throw new Error("modInverse: not invertible");return _o(i,n)}function N6(e){return e.coeffsInVar(0).at(-1)??Jn.zero(e.vars.slice(1))}function ZE(e,n,t,r,i=1n){if(JN(e.nbTerms+n.nbTerms+1),t.length===0)return Jn.constant([],1n);if(t.length===1)return $6(e,n,r);let o=t.slice(1),s=e.coeffsInVar(0),u=n.coeffsInVar(0),a=R6(s,o,r),l=R6(u,o,r);if(!a||!l)return null;let f=ZE(a,l,o,r);if(!f)return null;let c=T6(e,a,r),d=T6(n,l,r);if(!c||!d)return null;let p=hoe(c,d,t,r,i);return p?P6(ZN(f,0,t),p,r).modP(r):null}function hoe(e,n,t,r,i){let o=t.slice(1),s=e.coeffsInVar(0).at(-1),u=n.coeffsInVar(0).at(-1),a=ZE(s,u,o,r);if(!a)return null;let l=i===1n?a:JE(a,i,r);return M6(e,n,t,r,l)}function M6(e,n,t,r,i){if(t.length===1){let d=$6(e,n,r);if(!d)return null;let p=i.asConstant();return p===void 0?null:JE(d,_o(p,r),r).modP(r)}let o=t.length-1,s=o-1,u=t.filter((d,p)=>p!==o),a=Math.min(e.degreeIn(o),n.degreeIn(o)),l=-1,f=[],c=[];for(let d=0n;d<r&&f.length<=a;d++){let p=WN(i,s,d,r);if(p.isZero())continue;let m=WN(e,o,d,r),h=WN(n,o,d,r);if(m.degreeIn(0)<e.degreeIn(0)||h.degreeIn(0)<n.degreeIn(0))continue;let y=M6(m,h,u,r,p);if(!y)return null;let b=y.degreeIn(0);if(l<0||b<l)l=b,f.length=0,c.length=0;else if(b>l)continue;f.push(d),c.push(y)}return f.length<a+1&&f.length===0?null:Eoe(f,c,o,t,r)}function R6(e,n,t){let r=e.filter(o=>!o.isZero());if(r.length===0)return Jn.zero(n);let i=r[0];for(let o=1;o<r.length;o++){let s=ZE(i,r[o],n,t);if(!s)return null;if(i=s,i.asConstant()!==void 0)break}return i}function $6(e,n,t){let r=e.vars,i=A6(e,t),o=A6(n,t);for(;o.length>0;){let s=voe(i,o,t);i=o,o=s}return i=boe(i,t),yoe(i,r,t)}function A6(e,n){let t=e.degreeIn(0),r=new Array(t+1).fill(0n);for(let[i,o]of e.terms)r[Jn.exp(i)[0]]=_o(o,n);return O6(r)}function yoe(e,n,t){let r=new Jn(n);for(let i=0;i<e.length;i++){let o=_o(e[i],t);if(o!==0n){let s=o;s>t/2n&&(s-=t),r.terms.set(String(i),s)}}return r}function O6(e){let n=e.length;for(;n>0&&e[n-1]===0n;)n--;return e.slice(0,n)}function boe(e,n){if(e.length===0)return e;let t=Oh(e[e.length-1],n);return e.map(r=>_o(r*t,n))}function voe(e,n,t){let r=e.slice(),i=n.length-1,o=Oh(n[i],t);for(let s=r.length-1;s>=i;s--){if(r[s]===0n)continue;let u=_o(r[s]*o,t);for(let a=0;a<=i;a++)r[s-i+a]=_o(r[s-i+a]-u*n[a],t)}return O6(r)}function Eoe(e,n,t,r,i){let o=e.length,s=n.map(a=>a.modP(i));for(let a=1;a<o;a++)for(let l=o-1;l>=a;l--){let f=Oh(_o(e[l]-e[l-a],i),i);s[l]=JE(s[l].sub(s[l-1]),f,i).modP(i)}let u=ZN(s[o-1],t,r);for(let a=o-2;a>=0;a--){let l=xoe(t,e[a],r,i);u=P6(u,l,i).add(ZN(s[a],t,r)).modP(i)}return u.modP(i)}function xoe(e,n,t,r){let i=new Jn(t),o=t.map((u,a)=>a===e?1:0);i.terms.set(Jn.key(o),1n);let s=_o(-n,r);return s!==0n&&i.terms.set(Jn.key(t.map(()=>0)),s>r/2n?s-r:s),i}function P6(e,n,t){return JN(e.nbTerms*n.nbTerms+1),e.mul(n).modP(t)}function WN(e,n,t,r){return e.evalVar(n,t).modP(r)}function JE(e,n,t){return e.scaleInt(_o(n,t)).modP(t)}function ZN(e,n,t){return Jn.fromVarCoeffs([e],n,t)}function T6(e,n,t){let r=e.coeffsInVar(0),i=n.asConstant(),o=[];for(let s of r){if(s.isZero()){o.push(s);continue}if(i!==void 0)o.push(JE(s,Oh(i,t),t));else{let u=Soe(s,n,t);if(!u)return null;o.push(u)}}return Jn.fromVarCoeffs(o,0,e.vars)}function Soe(e,n,t){if(n.isZero())return null;let r=n.leadingLex(),i=Oh(r.c,t),o=e.modP(t),s=new Jn(e.vars),u=0;for(;!o.isZero();){if(++u>2e5)return null;JN(n.nbTerms+1);let a=o.leadingLex();if(!a.exp.every((d,p)=>d>=r.exp[p]))return null;let l=a.exp.map((d,p)=>d-r.exp[p]),f=_o(a.c*i,t),c=new Jn(e.vars);c.terms.set(Jn.key(l),f),s.terms.set(Jn.key(l),f>t/2n?f-t:f),o=o.sub(n.mul(c)).modP(t)}return s}function de(e,n){if(T(e))return 0;if(C(e))return e.symbol===n?1:0;if(!g(e))return e.has(n)?-1:0;let t=e.operator;if(t==="Negate")return de(e.op1,n);if(t==="Add"||t==="Subtract"){let r=0;for(let i of e.ops){let o=de(i,n);if(o<0)return-1;r=Math.max(r,o)}return r}if(t==="Multiply"){let r=0;for(let i of e.ops){let o=de(i,n);if(o<0)return-1;r+=o}return r}if(t==="Power"){let r=de(e.op1,n);if(r<0)return-1;if(r===0)return e.op2.has(n)?-1:0;let i=ae(e.op2);return i===null||i<0?-1:r*i}return e.has(n)?-1:0}function ye(e,n){let t=e.engine,r=de(e,n);if(r<0)return null;let i=new Array(r+1).fill(t.Zero),o=en(e),s=(a,l)=>l>r?!1:(i[l]=t.function("Add",[i[l],a]),!0),u=a=>{let l=de(a,n);if(l<0)return!1;if(l===0)return s(a,0);if(C(a,n))return s(t.One,1);if(g(a,"Negate")){if(de(a.op1,n)===0)return s(a,0);let c=ye(a.op1,n);if(!c)return!1;for(let d=0;d<c.length;d++)c[d].isSame(0)||s(c[d].neg(),d);return!0}if(g(a,"Power")){if(C(a.op1,n)){let f=ae(a.op2);if(f!==null&&f>=0)return s(t.One,f)}return a.op1.has(n)?!1:s(a,0)}if(g(a,"Multiply")){let f=a.ops,c=t.One,d=0;for(let p of f)if(!p.has(n))c=t.function("Multiply",[c,p]);else if(C(p,n))d+=1;else if(g(p,"Power")&&C(p.op1,n)){let m=ae(p.op2);if(m!==null&&m>=0)d+=m;else return!1}else return!1;return s(c,d)}return!1};if(g(o,"Add")){for(let a of o.ops)if(!u(a))return null}else if(!u(o))return null;return i}function Zs(e,n){if(e.length===0)return e[0]?.engine.Zero??null;let t=e[0].engine,r=t.symbol(n),i=[];for(let o=0;o<e.length;o++){let s=e[o];if(!s.isSame(0))if(o===0)i.push(s);else if(o===1)s.isSame(1)?i.push(r):s.isSame(-1)?i.push(r.neg()):i.push(s.mul(r));else{let u=t.expr(["Power",n,o]);s.isSame(1)?i.push(u):s.isSame(-1)?i.push(u.neg()):i.push(s.mul(u))}}return i.length===0?t.Zero:i.length===1?i[0]:le(...i)}function jr(e,n,t){ee(e.engine._deadlineFrame);let r=e.engine,i=ye(e,t),o=ye(n,t);if(!i||!o||o.every(m=>m.isSame(0)))return null;let s=m=>{for(let h=m.length-1;h>=0;h--)if(!m[h].isSame(0))return h;return-1},u=s(i),a=s(o);if(a<0)return null;if(u<0)return[r.Zero,r.Zero];if(u<a)return[r.Zero,e];let l=i.map(m=>m),f=new Array(u-a+1).fill(r.Zero),c=o[a];for(let m=u;m>=a;m--){if(l[m].isSame(0))continue;let h=l[m].div(c);f[m-a]=h;for(let y=0;y<=a;y++){let b=h.mul(o[y]);l[m-a+y]=l[m-a+y].sub(b)}}let d=Zs(f,t),p=Zs(l,t);return[d,p]}function Ph(e,n,t){let r=e.engine,i=de(e,t),o=de(n,t);if(i<0||o<0)return r.One;let s=ye(e,t),u=ye(n,t);if(!s||s.every(f=>f.isSame(0)))return KN(n,t);if(!u||u.every(f=>f.isSame(0)))return KN(e,t);let a=e,l=n;for(;;){ee(r._deadlineFrame);let f=ye(l,t);if(!f)return r.One;if(f.every(p=>p.isSame(0)))break;if(KE(f)===0)return r.One;let c=jr(a,l,t);if(!c)return r.One;let[,d]=c;a=l,l=d}return KN(a,t)}function KE(e){for(let n=e.length-1;n>=0;n--)if(!e[n].isSame(0))return n;return-1}function D6(e,n,t){return QN(e,n,t)??void 0}function QN(e,n,t){let r=e.engine;ee(r._deadlineFrame);let i=ye(e,t),o=ye(n,t);if(!i||!o)return null;let s=KE(i),u=KE(o);if(s<0||u<0)return r.Zero;if(s===0&&u===0)return r.One;if(u===0)return o[0].pow(s);if(s===0)return i[0].pow(u);if(s<u){let m=QN(n,e,t);return m===null?null:s*u%2===0?m:m.neg()}let a=jr(e,n,t);if(!a)return null;let l=a[1],f=ye(l,t);if(!f)return null;let c=KE(f);if(c<0)return r.Zero;let d=QN(n,l,t);if(d===null)return null;let p=o[u].pow(s-c).mul(d);return s*u%2!==0&&(p=p.neg()),p}function F6(e){if(e.length<2)return;let n=new Set;for(let t of e)for(let r of t.unknowns)n.add(r);if(n.size===1){let t=[...n][0];for(let i of e)if(de(i,t)<0)return;let r=Ph(e[0],e[1],t);for(let i=2;i<e.length;i++)r=Ph(r,e[i],t);return de(r,t)<1?void 0:r}if(n.size>=2){let t=QE(e[0],e[1]);for(let r=2;r<e.length&&t!==void 0;r++)t=QE(t,e[r]);return t}}function QE(e,n){let t=e.engine,r=t.expr(["Expand",e]).evaluate(),i=t.expr(["Expand",n]).evaluate(),o=a=>g(a,"Add")?a.ops.length:1;if(o(r)>80||o(i)>80)return;let s=[...new Set([...r.unknowns,...i.unknowns])];if(s.length<2)return;let u=I6(t,r,i,s);if(u!==null&&u.unknowns.length!==0)return u}function KN(e,n){let t=ye(e,n);if(!t)return e;let r=null;for(let o=t.length-1;o>=0;o--)if(!t[o].isSame(0)){r=t[o];break}if(!r||r.isSame(1))return e;let i=t.map(o=>o.div(r));return Zs(i,n)}function Al(e,n){if(!g(e,"Divide"))return e;let t=e.op1,r=e.op2,i=de(t,n),o=de(r,n);if(i<0||o<0)return e;let s=Ph(t,r,n),u=s;if(new Set([...t.unknowns,...r.unknowns]).size>=2)if(de(s,n)<=0)s=QE(t,r)??s;else{let c=QE(t,r);if(c){let d=c.unknowns.length,p=s.unknowns.length;(d>p||d===p&&mp(c)>mp(s))&&(s=c)}}let l=c=>{if(c.unknowns.length===0)return null;let d=jr(t,c,n),p=jr(r,c,n);if(!d||!p)return null;let[m,h]=d,[y,b]=p;if(!h.isSame(0)||!b.isSame(0))return null;let v=ye(y,n);return v&&v.length===1&&v[0].isSame(1)?m:m.div(y)};return l(s)??(s!==u?l(u):null)??e}function L6(e,n){return(e%n+n)%n}function Js(e,n){if(n<=0n)return null;let t=te(e);if(t!==null)return L6(t,n);if(g(e,"Negate")){let r=Js(e.op1,n);return r===null?null:(n-r)%n}if(g(e,"Add")){let r=0n;for(let i of e.ops){let o=Js(i,n);if(o===null)return null;r=(r+o)%n}return r}if(g(e,"Subtract")){let r=Js(e.op1,n),i=Js(e.op2,n);return r===null||i===null?null:L6(r-i,n)}if(g(e,"Multiply")){let r=1n;for(let i of e.ops){let o=Js(i,n);if(o===null)return null;r=r*o%n}return r}if(g(e,"Power")){let r=Js(e.op1,n);if(r===null)return null;let i=te(e.op2);if(i===null)return null;if(i>=0n)return Qr(r,i,n);let o=Gd(r,n);return o===null?null:Qr(o,-i,n)}if(g(e,"Factorial")){let r=te(e.op1);if(r===null||r<0n)return null;if(r>=n)return 0n;if(r>10000n)return null;let i=ol(),o=1n,s=0;for(let u=2n;u<=r;u++)(++s&1023)===0&&ee(i),o=o*u%n;return o}return null}function Cc(e){return typeof e=="number"?!Number.isFinite(e):!(e.bignumRe!==void 0?e.bignumRe.isFinite():Number.isFinite(e.re))||!Number.isFinite(e.im)}function B6(e){if(e.isNaN===!0)return"nan";if(e.isInfinity===!0)return e.isPositive===!0?"pos-inf":e.isNegative===!0?"directed-inf":T(e)?"complex-inf":void 0;if(T(e))return Cc(e.numericValue)?"directed-inf":e.isSame(0)?"zero":e.isSame(1)?"one":"finite"}var V6=e=>e==="zero"||e==="pos-inf"||e==="directed-inf"||e==="complex-inf";function j6(e){return e.isNegative===!0?Math.PI:T(e)?Math.atan2(e.im,e.re):Math.PI}function _oe(e){return e.isGreater(1)===!0?"positive":e.isPositive===!0&&e.isLess(1)===!0?"negative":"complex"}function woe(e){if(T(e)){let n=e.numericValue;if(typeof n!="number"&&n.bignumRe!==void 0)return n.bignumRe.ln().toNumber()}return Math.log(e.re)}function Tl(e,n,t,r){let i=t===void 0||C(t,"ExponentialE"),o=B6(n),s=i?void 0:B6(t);if(o==="nan"||s==="nan")return e.NaN;if(o===void 0)return;if(!i&&s===void 0)return o==="one"?e.Zero:void 0;if(i)return o==="zero"?e.NegativeInfinity:o==="one"?e.Zero:o==="pos-inf"?e.PositiveInfinity:o==="complex-inf"?e.ComplexInfinity:o==="directed-inf"&&r?e.number(e._numericValue({re:1/0,im:j6(n)})):void 0;if(s==="one")return o==="one"?e.NaN:e.ComplexInfinity;if(V6(s))return V6(o)?e.NaN:e.Zero;if(o==="finite")return;if(o==="one")return e.Zero;if(o==="complex-inf")return e.ComplexInfinity;let u=_oe(t);if(o==="zero"||o==="pos-inf")return u==="complex"?e.ComplexInfinity:o==="pos-inf"==(u==="positive")?e.PositiveInfinity:e.NegativeInfinity;if(!r)return;if(u==="complex")return e.ComplexInfinity;let a=woe(t);return e.number(e._numericValue({re:a>0?1/0:-1/0,im:j6(n)/a}))}function Coe(e,n){for(e<0n&&(e=-e),n<0n&&(n=-n);n!==0n;)[e,n]=[n,e%n];return e}function XN(e,n){n<0n&&(e=-e,n=-n);let t=Coe(e,n);return t===0n?[0n,1n]:[e/t,n/t]}function Noe(e){let n=1n;for(let t=2;t<=e;t++)n*=BigInt(t);return n}var Dh=[[1n,1n],[-1n,2n]];function Nc(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`bernoulliRational: invalid index ${e}`);for(let n=Dh.length;n<=e;n++){if(n%2===1){Dh.push([0n,1n]);continue}let t=BigInt(n+1),r=0n,i=1n,o=1n;for(let s=0;s<n;s++){s>0&&(o=o*(t-BigInt(s)+1n)/BigInt(s));let[u,a]=Dh[s];u!==0n&&(r=r*a+o*u*i,i=i*a)}Dh.push(XN(-r,t*i))}return Dh[e]}function q6(e){if(!Number.isInteger(e)||e<1)throw new RangeError(`zetaEvenCoefficient: invalid index ${e}`);let[n,t]=Nc(2*e),r=n<0n?-n:n;return XN(r*2n**BigInt(2*e-1),t*Noe(2*e))}function z6(e){if(!Number.isInteger(e)||e<1)throw new RangeError(`zetaNegativeInteger: invalid index ${e}`);let[n,t]=Nc(e+1);return XN(-n,t*BigInt(e+1))}var n1=7,t1=[.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=t1[0];for(let i=1;i<n1+2;i++)t+=t1[i]/(n+i);let r=n+n1+.5;return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(r)-r+Math.log(t)}function Rc(e){if(!Number.isFinite(e)||e<0)return 1/0;if(e<2)return 1;let n=it(e+1)/Math.LN10;return Number.isFinite(n)?n:1/0}var Roe=171.6243769563027;function U6(e){e-=1;let n=t1[0];for(let r=1;r<n1+2;r++)n+=t1[r]/(e+r);let t=e+n1+.5;return Math.sqrt(2*Math.PI)*Math.pow(t,e+.5)*Math.exp(-t)*n}function r1(e,n){if(n<=0)return 1;if(n===1)return e;let t=n>>>1;return r1(e,t)*r1(e+t,n-t)}function Re(e){if(e<=0&&Number.isInteger(e))return NaN;if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Re(1-e));if(e>Roe)return 1/0;if(Number.isInteger(e))return r1(1,e-1);if(e>=2){let n=Math.floor(e)-1,t=e-n;return U6(t)*r1(t,n)}return U6(e)}function Aoe(e){if(e<=0)return NaN;if(e<1.5){let s=0,u=1;for(let a=1;a<200;a++){u*=-e/a;let l=-u/a;if(s+=l,Math.abs(l)<1e-18)break}return-x1-Math.log(e)+s}let n=1e-300,t=e+1,r=1/n,i=1/t,o=i;for(let s=1;s<200;s++){let u=-s*s;t+=2,i=u*i+t,Math.abs(i)<n&&(i=n),r=t+u/r,Math.abs(r)<n&&(r=n),i=1/i;let a=i*r;if(o*=a,Math.abs(a-1)<1e-16)break}return o*Math.exp(-e)}function Toe(e,n){let t=1/e,r=t;for(let i=1;i<1e3&&(t*=n/(e+i),r+=t,!(Math.abs(t)<Math.abs(r)*1e-17));i++);return Math.exp(e*Math.log(n)-n)*r}function Ioe(e,n){let r=n+1-e,i=1/1e-300,o=1/r,s=o;for(let u=1;u<1e3;u++){let a=-u*(u-e);r+=2,o=a*o+r,Math.abs(o)<1e-300&&(o=1e-300),i=r+a/i,Math.abs(i)<1e-300&&(i=1e-300),o=1/o;let l=o*i;if(s*=l,Math.abs(l-1)<1e-16)break}return Math.exp(e*Math.log(n)-n)*s}function koe(e,n){let t=Aoe(n),r=Math.exp(-n);for(let i=0;i>e;i--)t=(t-Math.pow(n,i-1)*r)/(i-1);return t}function s1(e,n){return Number.isNaN(e)||Number.isNaN(n)?NaN:n<0?NaN:n===0?Re(e):Number.isInteger(e)&&e<=0?koe(e,n):n<e+1?Re(e)-Toe(e,n):Ioe(e,n)}var ri=1e-300;function Moe(e,n){if(n===0)return 0;let t=e,r=1/e,i=r;for(let o=0;o<1e3&&(t+=1,r*=n/t,i+=r,!(Math.abs(r)<Math.abs(i)*1e-16));o++);return i*Math.exp(e*Math.log(n)-n-it(e))}function $oe(e,n){let t=n+1-e,r=1/ri,i=1/t,o=i;for(let s=1;s<1e3;s++){let u=-s*(s-e);t+=2,i=u*i+t,Math.abs(i)<ri&&(i=ri),r=t+u/r,Math.abs(r)<ri&&(r=ri),i=1/i;let a=i*r;if(o*=a,Math.abs(a-1)<1e-16)break}return Math.exp(e*Math.log(n)-n-it(e))*o}function Op(e,n){return Number.isNaN(e)||Number.isNaN(n)?NaN:e<=0||n<0?NaN:n===0?1:n<e+1?1-Moe(e,n):$oe(e,n)}function H6(e,n,t){let r=e+n,i=e+1,o=e-1,s=1,u=1-r*t/i;Math.abs(u)<ri&&(u=ri),u=1/u;let a=u;for(let l=1;l<1e3;l++){let f=2*l,c=l*(n-l)*t/((o+f)*(e+f));u=1+c*u,Math.abs(u)<ri&&(u=ri),s=1+c/s,Math.abs(s)<ri&&(s=ri),u=1/u,a*=u*s,c=-(e+l)*(r+l)*t/((e+f)*(i+f)),u=1+c*u,Math.abs(u)<ri&&(u=ri),s=1+c/s,Math.abs(s)<ri&&(s=ri),u=1/u;let d=u*s;if(a*=d,Math.abs(d-1)<1e-16)break}return a}function Pp(e,n,t){if(Number.isNaN(e)||Number.isNaN(n)||Number.isNaN(t))return NaN;if(n<=0||t<=0||e<0||e>1)return NaN;if(e===0)return 0;if(e===1)return 1;let r=Math.exp(it(n+t)-it(n)-it(t)+n*Math.log(e)+t*Math.log(1-e));return e<(n+1)/(n+t+2)?r*H6(n,t,e)/n:1-r*H6(t,n,1-e)/t}function t4(e){let t=Math.log(1-e*e),r=2/(Math.PI*.147)+t/2;return Math.sign(e)*Math.sqrt(Math.sqrt(r*r-t/.147)-r)}function Dp(e){if(Number.isNaN(e)||e<-1||e>1)return NaN;if(e===0)return 0;if(e===1)return 1/0;if(e===-1)return-1/0;let n=e<0?-1:1,t=Math.abs(e),r=t4(t),i=Math.sqrt(Math.PI)/2,o=1-t,s=t>.9;for(let u=0;u<5;u++){let a=s?o-ga(r):ha(r)-t;r-=a*i*Math.exp(r*r)}return n*r}function ga(e){if(Number.isNaN(e))return NaN;if(!Number.isFinite(e))return e>0?0:2;if(e<0)return 2-ga(-e);if(e<2)return 1-ha(e);let n=1e-300,t=e===0?n:e,r=t,i=0;for(let o=1;o<=500;o++){let s=o/2;i=e+s*i,i===0&&(i=n),i=1/i,r=e+s/r,r===0&&(r=n);let u=r*i;if(t*=u,Math.abs(u-1)<1e-17)break}return Math.exp(-e*e)/(Math.sqrt(Math.PI)*t)}function ha(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 r=t*t,i=t,o=t;for(let s=1;s<200&&(i*=2*r/(2*s+1),o+=i,!(i<o*1e-18));s++);return n*(2/Math.sqrt(Math.PI))*Math.exp(-r)*o}function Qs(e,n){let t=D.precision;D.precision=t+e;try{return n().toPrecision(t)}finally{D.precision=t}}var Xs=24,eR=2e4,Ooe=500;function r4(e,n){return n.isFinite()?Qs(Xs,()=>Il(e,n)):D.NAN}function Il(e,n){if(!n.isFinite())return D.NAN;if(n.lt(D.HALF)){let E=D.PI,x=E.mul(n).sin().abs();return x.isZero()?D.NAN:E.ln().sub(x.ln()).sub(Il(e,D.ONE.sub(n)))}if(n.isInteger()&&n.isPositive()){let E=n.toNumber();if(E<=1)return D.ZERO;if(E<=eR){let x=1n,S=0;for(let w=2;w<E;w++)(++S&4095)===0&&ee(e._deadlineFrame),x*=BigInt(w);return new D(x.toString()).ln()}}let t=n.sub(D.HALF);if(t.isInteger()&&!t.isNegative()){let E=t.toNumber();if(E===0)return D.PI.ln().div(D.TWO);if(E<=eR){let x=0,S=1n;for(let A=2;A<=2*E;A++)(++x&4095)===0&&ee(e._deadlineFrame),S*=BigInt(A);let w=1n;for(let A=2;A<=E;A++)(++x&4095)===0&&ee(e._deadlineFrame),w*=BigInt(A);let _=4n**BigInt(E);return new D(S.toString()).ln().add(D.PI.ln().div(D.TWO)).sub(new D(_.toString()).ln()).sub(new D(w.toString()).ln())}}let r=D.precision,i=10,o=Math.ceil(r),s=n.toNumber(),u=Math.max(0,Math.ceil(o-s)),a=D.ONE,l=n;for(let E=0;E<u;E++)a=a._mulToPrecision(l,r),l=l.add(D.ONE);let f=u>0?a.ln():D.ZERO,c=Math.max(20,Math.ceil(.6*r)+20),d=Vh(e,c),p=l.sub(D.HALF).mul(l.ln()).sub(l).add(D.PI.mul(D.TWO).ln().div(D.TWO)),m=D.ONE.div(l),h=m._mulToPrecision(m,r),y=m,b=new D(10).pow(-(r+i)),v=Math.min(c,d.length);for(let E=0;E<v;E++){let x=2*(E+1),[S,w]=d[E],_=BigInt(x)*BigInt(x-1),N=new D(S.toString()).div(new D((w*_).toString()))._mulToPrecision(y,r);if(E>0&&N.abs().lt(b))break;p=p.add(N),y=y._mulToPrecision(h,r)}return p.sub(f)}function At(e,n){if(n.isInteger()&&n.isPositive()){let t=n.toNumber();if(t<=eR){let r=1n,i=0;for(let o=2;o<t;o++)(++i&4095)===0&&ee(e._deadlineFrame),r*=BigInt(o);return new D(r.toString())}}return Qs(Xs,()=>Tp(e,n))}function Tp(e,n){if(n.lt(D.HALF)){let t=D.PI,r=t.mul(n).sin();return r.isZero()?D.NAN:t.div(r.mul(Tp(e,D.ONE.sub(n))))}return Il(e,n).exp()}function G6(e,n){for(;n!==0n;){let t=n;n=e%n,e=t}return e}function e1(e){return e<0n?-e:e}function Poe(e,n){let t=[[1n,1n],[-1n,2n]];for(let i=2;i<=2*e;i++){if((i&255)===0&&ee(n),i%2===1){t.push([0n,1n]);continue}let o=BigInt(i+1),s=0n,u=1n,a=1n;for(let d=0;d<i;d++){d>0&&(a=a*(o-BigInt(d)+1n)/BigInt(d));let[p,m]=t[d];if(p!==0n&&(s=s*m+a*p*u,u=u*m,d%8===7)){let h=G6(e1(s),u);s/=h,u/=h}}let l=-s,f=o*u,c=G6(e1(l),e1(f));l/=c,f/=c,f<0n&&(l=-l,f=-f),t.push([l,f])}let r=[];for(let i=1;i<=e;i++)r.push(t[2*i]);return r}var W6=new WeakMap;function Vh(e,n){let t=W6.get(e);if(t&&t.length>=n)return t;let r=n+Math.min(64,Math.ceil(n/2)),i=Poe(r,e._deadline);return W6.set(e,i),i}function tR(e,n){return n.isFinite()?Qs(Xs,()=>i4(e,n)):D.NAN}function i4(e,n){if(n.isNegative()){if(n.isInteger())return D.NAN;let p=D.PI,m=p.mul(n),h=m.cos().div(m.sin());return i4(e,D.ONE.sub(n)).sub(p.mul(h))}if(n.isZero())return D.NAN;let t=D.precision,r=10,i=Math.max(7,Math.ceil(t)),o=new D(0),s=n;for(;s.lt(i);)o=o.sub(D.ONE.div(s)),s=s.add(D.ONE);let u=Math.max(20,Math.ceil(.6*t)+20),a=Vh(e,u);o=o.add(s.ln()).sub(D.ONE.div(s.mul(2)));let l=s._mulToPrecision(s,t),f=l,c=new D(10).pow(-(t+r)),d=Math.min(u,a.length);for(let p=0;p<d;p++){let[m,h]=a[p],y=BigInt(2*(p+1)),b=new D(m.toString()).div(new D((h*y).toString()).mul(l));if(p>0&&b.abs().lt(c))break;o=o.sub(b),l=l._mulToPrecision(f,t)}return o}function rR(e,n){return n.isFinite()?Qs(Xs,()=>o4(e,n)):D.NAN}function o4(e,n){if(n.isNegative()){if(n.isInteger())return D.NAN;let p=D.PI,m=p.mul(n).sin();return p.mul(p).div(m.mul(m)).sub(o4(e,D.ONE.sub(n)))}if(n.isZero())return D.NAN;let t=D.precision,r=10,i=Math.max(7,Math.ceil(t)),o=new D(0),s=n;for(;s.lt(i);)o=o.add(D.ONE.div(s.mul(s))),s=s.add(D.ONE);let u=Math.max(20,Math.ceil(.6*t)+20),a=Vh(e,u);o=o.add(D.ONE.div(s)),o=o.add(D.ONE.div(s.mul(s).mul(2)));let l=s.mul(s)._mulToPrecision(s,t),f=s._mulToPrecision(s,t),c=new D(10).pow(-(t+r)),d=Math.min(u,a.length);for(let p=0;p<d;p++){let[m,h]=a[p],y=new D(m.toString()).div(new D(h.toString()).mul(l));if(p>0&&y.abs().lt(c))break;o=o.add(y),l=l._mulToPrecision(f,t)}return o}function s4(e,n,t){let r=n.toNumber();return!Number.isInteger(r)||r<0?D.NAN:r===0?tR(e,t):r===1?rR(e,t):!t.isFinite()||t.isZero()?D.NAN:Qs(Xs,()=>Doe(e,r,t))}function Doe(e,n,t){let r=E=>{let x=D.ONE;for(let S=2;S<=E;S++)x=x.mul(S);return x},i=D.precision,o=10,s=Math.max(7,Math.ceil(i)),u=t,a=new D(0);if(u.isNegative()&&u.isInteger())return D.NAN;let l=n%2===0?-1:1,f=r(n);for(;u.lt(s);)a=a.add(new D(l).mul(f).div(u.pow(n+1))),u=u.add(D.ONE);let c=Math.max(20,Math.ceil(.6*i)+20),d=Vh(e,c),p=n%2===0?-1:1;a=a.add(new D(p).mul(r(n-1)).div(u.pow(n))),a=a.add(new D(p).mul(f).div(u.pow(n+1).mul(2)));let m=1n;for(let E=2;E<=n-1;E++)m*=BigInt(E);let h=u.pow(n+2).toPrecision(i),y=u._mulToPrecision(u,i),b=new D(10).pow(-(i+o)),v=Math.min(c,d.length);for(let E=0;E<v;E++){let x=2*(E+1),[S,w]=d[E],_=m;for(let I=0;I<x;I++)_*=BigInt(n+I);let A=1n;for(let I=2;I<=x;I++)A*=BigInt(I);let N=new D((BigInt(p)*S*_).toString()).div(new D((w*A).toString()).mul(h));if(E>0&&N.abs().lt(b))break;a=a.add(N),h=h._mulToPrecision(y,i)}return a}function u4(e,n,t){return Qs(Xs,()=>Tp(e,n).mul(Tp(e,t)).div(Tp(e,n.add(t))))}function a4(e,n,t){let r=D.precision,i=new D(10).pow(-r),o=n,s=D.ONE.div(n),u=s,a=2e3+20*Math.ceil(Math.abs(t.toNumber()))+20*r;for(let l=0;l<a&&((l&255)===0&&ee(e._deadlineFrame),o=o.add(D.ONE),s=s.mul(t).div(o),u=u.add(s),!s.abs().lt(u.abs().mul(i)));l++);return u}function Foe(e,n,t){let r=n.mul(t.ln()).sub(t).sub(Il(e,n)).exp();return a4(e,n,t).mul(r)}function Loe(e,n,t){return n.mul(t.ln()).sub(t).sub(Il(e,n)).exp().mul(l4(e,n,t))}function l4(e,n,t){let r=D.precision,i=new D(10).pow(-r),o=new D(10).pow(-(2*r)),s=t.add(D.ONE).sub(n),u=D.ONE.div(o),a=D.ONE.div(s),l=a,f=2e3+20*r;for(let c=1;c<f;c++){(c&255)===0&&ee(e._deadlineFrame);let d=new D(c).sub(n).mul(-c);s=s.add(D.TWO),a=d.mul(a).add(s),a.abs().lt(o)&&(a=o),u=s.add(d.div(u)),u.abs().lt(o)&&(u=o),a=D.ONE.div(a);let p=a.mul(u);if(l=l.mul(p),p.sub(D.ONE).abs().lt(i))break}return l}function f4(e,n,t){return n.isNaN()||t.isNaN()?D.NAN:!n.isFinite()||!t.isFinite()?D.NAN:!n.isNegative()||n.isInteger()?D.NAN:t.isPositive()?Qs(Xs,()=>{let r=n.mul(t.ln()).sub(t).exp().div(At(e,n));return t.lt(n.mul(2).add(D.TWO))?D.ONE.sub(a4(e,n,t).mul(r)):l4(e,n,t).mul(r)}):D.NAN}function c4(e,n,t){return n.isNaN()||t.isNaN()?D.NAN:!n.isFinite()||!t.isFinite()?D.NAN:n.isPositive()?t.isNegative()?D.NAN:t.isZero()?D.ONE:Qs(Xs,()=>t.lt(n.mul(2).add(D.TWO))?D.ONE.sub(Foe(e,n,t)):Loe(e,n,t)):D.NAN}function Y6(e,n,t,r){let i=D.precision,o=new D(10).pow(-i),s=new D(10).pow(-(2*i)),u=n.add(t),a=n.add(D.ONE),l=n.sub(D.ONE),f=D.ONE,c=D.ONE.sub(u.mul(r).div(a));c.abs().lt(s)&&(c=s),c=D.ONE.div(c);let d=c,p=1e3+10*i;for(let m=1;m<p;m++){(m&255)===0&&ee(e._deadlineFrame);let h=2*m,y=t.sub(m).mul(m).mul(r).div(l.add(h).mul(n.add(h)));c=D.ONE.add(y.mul(c)),c.abs().lt(s)&&(c=s),f=D.ONE.add(y.div(f)),f.abs().lt(s)&&(f=s),c=D.ONE.div(c),d=d.mul(c).mul(f),y=n.add(m).mul(u.add(m)).mul(r).neg().div(n.add(h).mul(a.add(h))),c=D.ONE.add(y.mul(c)),c.abs().lt(s)&&(c=s),f=D.ONE.add(y.div(f)),f.abs().lt(s)&&(f=s),c=D.ONE.div(c);let b=c.mul(f);if(d=d.mul(b),b.sub(D.ONE).abs().lt(o))break}return d}function d4(e,n,t,r){return n.isNaN()||t.isNaN()||r.isNaN()?D.NAN:!n.isFinite()||!t.isFinite()||!r.isFinite()?D.NAN:!t.isPositive()||!r.isPositive()?D.NAN:n.isNegative()||n.gt(D.ONE)?D.NAN:n.isZero()?D.ZERO:n.eq(D.ONE)?D.ONE:Qs(Xs,()=>{let i=Il(e,t.add(r)).sub(Il(e,t)).sub(Il(e,r)).add(t.mul(n.ln())).add(r.mul(D.ONE.sub(n).ln())).exp(),o=t.add(D.ONE).div(t.add(r).add(D.TWO));return n.lt(o)?i.mul(Y6(e,t,r,n)).div(t):D.ONE.sub(i.mul(Y6(e,r,t,D.ONE.sub(n))).div(r))})}function p4(e,n){return n.isFinite()?n.eq(1)?new D(1/0):Qs(Xs,()=>m4(e,n)):D.NAN}function m4(e,n){let t=D.PI;if(n.isZero())return D.HALF.neg();if(n.isInteger()&&n.isPositive()){let d=n.toNumber();if(d%2===0&&d>=2&&d<=Ooe){let p=d/2,m=Vh(e,p),[h,y]=m[p-1],b=new D(e1(h).toString()).div(new D(y.toString())),v=t.mul(2),E=D.ONE,x=0;for(let S=2;S<=d;S++)(++x&4095)===0&&ee(e._deadlineFrame),E=E.mul(S);return b.mul(v.pow(d)).div(E.mul(2))}}if(n.isNegative()&&n.isInteger()&&n.mod(D.TWO).isZero())return D.ZERO;if(n.isNegative())return new D(2).pow(n).mul(t.pow(n.sub(1))).mul(t.mul(n).div(2).sin()).mul(Tp(e,D.ONE.sub(n))).mul(m4(e,D.ONE.sub(n)));let r=D.precision;if(n.gt((r+10)*3.33))return D.ONE;let i=Math.max(22,Math.ceil(1.32*r)+3),s=new D(3).add(new D(8).sqrt()).pow(i),u=s.add(D.ONE.div(s)).div(2),a=D.NEGATIVE_ONE,l=u.neg(),f=D.ZERO;for(let d=0;d<i;d++)(d&255)===0&&ee(e._deadlineFrame),l=a.sub(l),f=f.add(l.div(new D(d+1).pow(n))),a=a.mul(new D(d+i).mul(d-i)).div(new D(d).add(D.HALF).mul(d+1));return f.div(u).div(D.ONE.sub(new D(2).pow(D.ONE.sub(n))))}function Z6(e,n,t){for(let r=0;r<100;r++){let i=e.exp(),s=e.mul(i).sub(n),u=i.mul(e.add(1)),a=i.mul(e.add(2)),l=s.div(u.sub(s.mul(a).div(u.mul(2))));if(e=e.sub(l),l.abs().lt(t.mul(e.abs().add(1))))break}return e.toPrecision(D.precision)}function g4(e,n,t=0){if(!n.isFinite())return n;let i=D.ONE.div(D.ONE.exp()).neg(),o=new D(10).pow(-D.precision),s=new D(10).pow(-15);if(t===0){if(n.isZero())return new D(0);if(n.sub(i).abs().lt(s))return D.NEGATIVE_ONE;if(n.lt(i))return D.NAN;let u,a=n.toNumber();if(a<0){let l=Math.sqrt(2*(Math.E*a+1));u=new D(-1+l-l*l/3+11/72*l*l*l)}else if(a<=1)u=new D(a*(1-a*(1-1.5*a)));else if(a<100){let l=Math.log(a);u=new D(l-Math.log(l))}else{let l=n.ln(),f=l.ln();u=l.sub(f).add(f.div(l))}return Z6(u,n,o)}if(t===-1){if(n.sub(i).abs().lt(s))return D.NEGATIVE_ONE;if(n.lt(i)||n.gte(0))return D.NAN;let u,a=n.toNumber();if(a<-.27){let l=Math.sqrt(2*(Math.E*a+1));u=new D(-1-l-l*l/3-11/72*l*l*l)}else{let l=Math.log(-a);u=new D(l-Math.log(-l))}return Z6(u,n,o)}return D.NAN}var i1=.5772156649015329,Ml=[1/6,-1/30,1/42,-1/30,5/66,-691/2730,7/6,-3617/510,43867/798,-174611/330];function Fp(e){if(!isFinite(e))return NaN;if(e<0)return Number.isInteger(e)?NaN:Fp(1-e)-Math.PI/Math.tan(Math.PI*e);if(e===0)return NaN;let n=0,t=e;for(;t<7;)n-=1/t,t+=1;n+=Math.log(t)-1/(2*t);let r=t*t;for(let i=0;i<Ml.length;i++)n-=Ml[i]/(2*(i+1)*r),r*=t*t;return n}function Lp(e){if(!isFinite(e))return NaN;if(e<0){if(Number.isInteger(e))return NaN;let i=Math.sin(Math.PI*e);return Math.PI*Math.PI/(i*i)-Lp(1-e)}if(e===0)return NaN;let n=0,t=e;for(;t<7;)n+=1/(t*t),t+=1;n+=1/t+1/(2*t*t);let r=t*t*t;for(let i=0;i<Ml.length;i++)n+=Ml[i]/r,r*=t*t;return n}function u1(e,n){if(!Number.isInteger(e)||e<0)return NaN;if(e===0)return Fp(n);if(e===1)return Lp(n);if(!isFinite(n)||n===0)return NaN;if(n<0&&Number.isInteger(n))return NaN;let t=0,r=n,i=nR(e),o=e%2===0?-1:1,s=e+10;for(;r<s;)t+=o*i/Math.pow(r,e+1),r+=1;let u=e%2===0?-1:1;t+=u*nR(e-1)/Math.pow(r,e),t+=u*i/(2*Math.pow(r,e+1));let a=i*(e+1)/(2*Math.pow(r,e+2)),l=1/0;for(let f=1;f<=Ml.length;f++){let c=Ml[f-1]*a;if(Math.abs(c)>=l)break;t+=u*c,l=Math.abs(c);let d=2*f;a*=(d+e)*(d+e+1)/((d+1)*(d+2)*r*r)}return t}function nR(e){if(e<=1)return 1;let n=1;for(let t=2;t<=e;t++)n*=t;return n}function a1(e,n){return e>100||n>100||e+n>100?Math.exp(it(e)+it(n)-it(e+n)):Re(e)*Re(n)/Re(e+n)}function eu(e){if(!isFinite(e))return NaN;if(e===1)return 1/0;if(e===0)return-.5;if(e===2)return Math.PI*Math.PI/6;if(e===4)return Math.PI**4/90;if(e===6)return Math.PI**6/945;if(e===8)return Math.PI**8/9450;if(e<0&&Number.isInteger(e)){if(e%2===0)return 0;let o=1-e;if(o/2<=Ml.length)return-Ml[o/2-1]/o}if(e<0)return Math.pow(2,e)*Math.pow(Math.PI,e-1)*Math.sin(Math.PI*e/2)*Re(1-e)*eu(1-e);if(e>=12){let o=1;for(let s=2;s<=128;s++){let u=Math.pow(s,-e);if(o+=u,u<o*1e-18)break}return o}let[n,t]=Boe(),r=0,i=0;for(let o=0;o<h4;o++){let u=(o%2===0?n[o]:-n[o])*Math.pow(o+1,-e)-i,a=r+u;i=a-r-u,r=a}return r/t/-Math.expm1((1-e)*Math.LN2)}var h4=28,XE=null;function Boe(){if(XE)return XE;let e=h4,n=1n<<64n,t=n,r=n,i=[r];for(let a=0;a<e;a++)t=t*BigInt(4*(e+a)*(e-a))/BigInt((2*a+1)*(2*a+2)),r+=t,i.push(r);let o=i[e],s=Math.pow(2,64),u=[];for(let a=0;a<e;a++)u.push(Number(o-i[a])/s);return XE=[u,Number(o)/s],XE}function Voe(e,n){let t=0,r=1;for(let i=1;i<500;i++){r*=n;let o=r/Math.pow(i,e);if(t+=o,Math.abs(o)<1e-17*(1+Math.abs(t)))break}return t}function joe(e,n){let t=Math.log(n),r=0;for(let u=1;u<e;u++)r+=1/u;let i=Math.log(-t),o=0,s=1;for(let u=0;u<200;u++){let a=u===e-1?s*(r-i):s*eu(e-u);o+=a;let l=Math.abs(a);if(u>e&&l!==0&&l<1e-16*(1+Math.abs(o)))break;s=s*t/(u+1)}return o}function y4(e,n){return!Number.isInteger(e)||e<2?NaN:Number.isNaN(n)?NaN:n===0?0:n===1?eu(e):n>=-.5&&n<=.5?Voe(e,n):n>.5&&n<1?joe(e,n):NaN}function J6(e,n){for(let t=0;t<30;t++){let r=Math.exp(e),o=e*r-n,s=r*(e+1),u=r*(e+2),a=o/(s-o*u/(2*s));if(e-=a,Math.abs(a)<1e-15*(1+Math.abs(e)))break}return e}function l1(e,n=0){if(!isFinite(e))return e;let t=1/Math.E;if(n===0){if(e===0)return 0;if(e<-t)return NaN;if(Math.abs(e+t)<1e-15)return-1;let r;if(e<0){let i=Math.sqrt(2*(Math.E*e+1));r=-1+i-i*i/3+11/72*i*i*i}else if(e<=1)r=e*(1-e*(1-1.5*e));else if(e<100){let i=Math.log(e);r=i-Math.log(i)}else{let i=Math.log(e),o=Math.log(i);r=i-o+o/i}return J6(r,e)}if(n===-1){if(e<-t||e>=0)return NaN;if(Math.abs(e+t)<1e-15)return-1;let r;if(e<-.27){let i=Math.sqrt(2*(Math.E*e+1));r=-1-i-i*i/3-11/72*i*i*i}else{let i=Math.log(-e);r=i-Math.log(-i)}return J6(r,e)}return NaN}function Ks(e,n){return!isFinite(n)||!Number.isInteger(e)?NaN:n===0?e===0?1:0:e<0?(e=-e,e%2===0?Ks(e,n):-Ks(e,n)):n<0?e%2===0?Ks(e,-n):-Ks(e,-n):n>25+e*e/2?zoe(e,n):n<5+e?qoe(e,n):Uoe(e,n)}function qoe(e,n){let t=n/2,r=-(n*n)/4,i=1;for(let s=1;s<=e;s++)i/=s;let o=i;for(let s=1;s<=60&&(i*=r/(s*(e+s)),o+=i,!(Math.abs(i)<Math.abs(o)*1e-16));s++);return o*Math.pow(t,e)}function b4(e,n){let t=4*e*e,r=1,i=0,o=1,s=8*n;for(let u=1;u<=20;u++){o*=t-(2*u-1)*(2*u-1);let a=nR(u)*Math.pow(s,u),l=o/a;if(u%2===1?i+=(u%4===1?1:-1)*l:r+=(u%4===2?-1:1)*l,Math.abs(l)<1e-15)break}return[r,i]}function zoe(e,n){let t=n-(e/2+.25)*Math.PI,[r,i]=b4(e,n);return Math.sqrt(2/(Math.PI*n))*(r*Math.cos(t)-i*Math.sin(t))}function Uoe(e,n){let t=Math.max(e+20,Math.ceil(n)+30),r=0,i=1,o=new Array(t+1);o[t]=i;for(let a=t;a>=1;a--){let l=2*a/n*i-r;r=i,i=l,o[a-1]=i}let s=o[0];for(let a=2;a<=t;a+=2)s+=2*o[a];let u=1/s;return o[e]*u}function Mp(e,n){if(!isFinite(n)||!Number.isInteger(e))return NaN;if(n<=0)return NaN;if(e<0)return e=-e,e%2===0?Mp(e,n):-Mp(e,n);if(n>12+e*e/4)return Woe(e,n);let t=Hoe(n);if(e===0)return t;let r=Goe(n);if(e===1)return r;let i=t,o=r;for(let s=1;s<e;s++){let u=2*s/n*o-i;i=o,o=u}return o}function Hoe(e){let n=e/2,t=n*n,r=Ks(0,e),i=0,o=1,s=0;for(let u=1;u<=60&&(s+=1/u,o*=-t/(u*u),i-=o*s,!(Math.abs(o*s)<Math.abs(i)*1e-16));u++);return 2/Math.PI*(r*(Math.log(n)+i1)+i)}function Goe(e){let n=e/2,t=n*n,r=Ks(1,e),i=0,o=1,s=1;for(let u=0;u<=60;u++){u>0&&(s*=u,o*=t);let a=s*(u+1),l=0;for(let h=1;h<=u;h++)l+=1/h;let f=l+1/(u+1),c=-i1+l,d=-i1+f,m=(u%2===0?1:-1)*(c+d)*o/(s*a);if(i+=m,u>3&&Math.abs(m)<1e-16*Math.abs(i))break}return-2/(Math.PI*e)+2/Math.PI*Math.log(n)*r-n/Math.PI*i}function Woe(e,n){let t=n-(e/2+.25)*Math.PI,[r,i]=b4(e,n);return Math.sqrt(2/(Math.PI*n))*(r*Math.sin(t)+i*Math.cos(t))}function pa(e,n){return!isFinite(n)||!Number.isInteger(e)?NaN:n===0?e===0?1:0:(e<0&&(e=-e),n<0?e%2===0?pa(e,-n):-pa(e,-n):n>20&&n>=e*e?Zoe(e,n):Yoe(e,n))}function Yoe(e,n){let t=n/2,r=n*n/4,i=1;for(let u=1;u<=e;u++)i/=u;let o=i,s=0;for(let u=1;u<=500;u++){i*=r/(u*(e+u));let a=i-s,l=o+a;if(s=l-o-a,o=l,Math.abs(i)<Math.abs(o)*1e-17)break}return o*Math.pow(t,e)}function Zoe(e,n){let t=4*e*e,r=1,i=1,o=1/0;for(let s=1;s<=40;s++){let u=t-(2*s-1)*(2*s-1);if(r*=-u/(s*8*n),Math.abs(r)>=o||(i+=r,o=Math.abs(r),Math.abs(r)<1e-17*Math.abs(i)))break}return Math.exp(n)/Math.sqrt(2*Math.PI*n)*i}function f1(e,n){if(!isFinite(n)||!Number.isInteger(e))return NaN;if(n<=0)return NaN;e<0&&(e=-e);let t,r;if(n>=20){if(t=K6(0,n),e===0)return t;r=K6(1,n)}else if(n>=1.5){if([t,r]=Joe(n),e===0)return t}else{if(t=v4(n),e===0)return t;r=Koe(n)}if(e===1)return r;let i=t,o=r;for(let s=1;s<e;s++){let u=2*s/n*o+i;i=o,o=u}return o}function Joe(e){let t=2*(1+e),r=1/t,i=r,o=r,s=0,u=1,a=-.25,l=.25,f=.25,c=1+f*o,d=0,p=0;for(let y=2;y<=1e4;y++){a-=2*(y-1),l=-a*l/y;let b=(s-t*u)/a;s=u,u=b,f+=l*b,t+=2,r=1/(t+a*r),o=(t*r-1)*o;let v=o-p,E=i+v;p=E-i-v,i=E;let x=f*o;if(v=x-d,E=c+v,d=E-c-v,c=E,Math.abs(x)<1e-18*Math.abs(c))break}i=.25*i;let m=Math.sqrt(Math.PI/(2*e))*Math.exp(-e)/c,h=m*(e+.5-i)/e;return[m,h]}function v4(e){let n=e/2,t=n*n,r=pa(0,e),i=0,o=1,s=0;for(let u=1;u<=60&&(s+=1/u,o*=t/(u*u),i+=o*s,!(Math.abs(o*s)<Math.abs(i)*1e-16&&u>3));u++);return-(Math.log(n)+i1)*r+i}function Koe(e){let n=pa(0,e),t=pa(1,e),r=v4(e);return(1/e-t*r)/n}function K6(e,n){let t=4*e*e,r=1,i=1,o=1/0;for(let s=1;s<=40;s++){let u=t-(2*s-1)*(2*s-1);if(r*=u/(s*8*n),Math.abs(r)>=o||(i+=r,o=Math.abs(r),Math.abs(r)<1e-17*Math.abs(i)))break}return Math.sqrt(Math.PI/(2*n))*Math.exp(-n)*i}var Q6=134217729;function X6(e,n){let t=e+n,r=t-e;return[t,e-(t-r)+(n-r)]}function $p(e,n){let t=e+n;return[t,n-(t-e)]}function Bp(e,n){let t=e*n,r=Q6*e,i=r-(r-e),o=e-i,s=Q6*n,u=s-(s-n),a=n-u;return[t,i*u-t+i*a+o*u+o*a]}function Xo(e,n){let[t,r]=X6(e[0],n[0]),[i,o]=X6(e[1],n[1]),[s,u]=$p(t,r+i);return $p(s,u+o)}function c1(e){return[-e[0],-e[1]]}function Ci(e,n){let[t,r]=Bp(e[0],n[0]);return $p(t,r+e[0]*n[1]+e[1]*n[0])}function o1(e,n){let[t,r]=Bp(e[0],n);return $p(t,r+e[1]*n)}function Ip(e,n){let t=e[0]/n,[r,i]=Bp(t,n),o=Xo(e,[-r,-i]);return $p(t,(o[0]+o[1])/n)}function Qoe(e){let n=Math.sqrt(e),[t,r]=Bp(n,n);return $p(n,(e-t-r)/(2*n))}var d1=[.3550280538878172,205233632436212e-31],p1=[.2588194037928068,-2522243111610832e-32],E4=[1.7320508075688772,10035084221806903e-32],x4=[.7853981633974483,3061616997868383e-32];function S4(e){let n=o1(Bp(e,e),e),t=[1,0],r=[e,0],i=[1,0],o=[e,0];for(let s=1;s<=200;s++){let u=3*s;if(i=Ip(Ci(i,n),(u-1)*u),o=Ip(Ci(o,n),u*(u+1)),t=Xo(t,i),r=Xo(r,o),Math.abs(i[0])+Math.abs(o[0])<1e-34*(Math.abs(t[0])+Math.abs(r[0])))break}return[t,r]}function Vp(e){let n=o1(Qoe(e),e);return Ip(o1(n,2),3)}function jp(e){return(6*e-5)*(6*e-3)*(6*e-1)/(216*e*(2*e-1))}function _4(e){let n=Vp(e),t=n[0],r=Xo(n,c1(x4)),i=Math.cos(r[0]),o=Math.sin(r[0]),s=i-o*r[1],u=o+i*r[1],a=1,l=0,f=1,c=1/0;for(let p=1;p<=60;p++){f*=jp(p)/t;let m=Math.abs(f);if(m>=c)break;c=m;let h=p%4===0||p%4===1?f:-f;if(p%2===0?a+=h:l+=h,m<1e-18)break}let d=1/(Math.sqrt(Math.PI)*Math.pow(e,.25));return[a,l,s,u,d]}function m1(e){if(!isFinite(e))return NaN;if(e>9){let r=Vp(e),i=r[0];if(!Number.isFinite(i))return 0;let o=1,s=1,u=1/0;for(let l=1;l<=60&&(s*=jp(l)/i,!(s>=u||(o+=l%2===0?s:-s,u=s,s<1e-18*o)));l++);return Math.exp(-i)*(1-r[1])/(2*Math.sqrt(Math.PI)*Math.pow(e,.25))*o}if(e<-9){let[r,i,o,s,u]=_4(-e);return u*(o*r+s*i)}let[n,t]=S4(e);return Xo(Ci(d1,n),c1(Ci(p1,t)))[0]}function g1(e){if(!isFinite(e))return NaN;if(e>9){let r=Vp(e),i=r[0];if(!Number.isFinite(i))return 1/0;let o=1,s=1,u=1/0;for(let l=1;l<=60&&(s*=jp(l)/i,!(s>=u||(o+=s,u=s,s<1e-18*o)));l++);return Math.exp(i)*(1+r[1])/(Math.sqrt(Math.PI)*Math.pow(e,.25))*o}if(e<-9){let[r,i,o,s,u]=_4(-e);return u*(-s*r+o*i)}let[n,t]=S4(e);return Ci(E4,Xo(Ci(d1,n),Ci(p1,t)))[0]}function w4(e){let n=Bp(e,e),t=o1(n,e),r=Ip(n,2),i=[1,0],o=r,s=i;for(let u=1;u<=200;u++){let a=3*u;if(r=Ip(Ci(r,t),a*(a+2)),i=Ip(Ci(i,t),(a-2)*a),o=Xo(o,r),s=Xo(s,i),Math.abs(r[0])+Math.abs(i[0])<1e-34*(Math.abs(o[0])+Math.abs(s[0])))break}return[o,s]}function C4(e){let n=Vp(e),t=n[0],r=Xo(n,c1(x4)),i=Math.cos(r[0]),o=Math.sin(r[0]),s=i-o*r[1],u=o+i*r[1],a=1,l=0,f=1,c=1/0;for(let p=1;p<=60;p++){f*=jp(p)/t;let m=f*(6*p+1)/(1-6*p),h=Math.abs(m);if(h>=c)break;c=h;let y=p%4===0||p%4===1?m:-m;if(p%2===0?a+=y:l+=y,h<1e-18)break}let d=Math.pow(e,.25)/Math.sqrt(Math.PI);return[a,l,s,u,d]}function h1(e){if(!isFinite(e))return NaN;if(e>9){let r=Vp(e),i=r[0];if(!Number.isFinite(i))return 0;let o=1,s=1,u=1/0;for(let l=1;l<=60;l++){s*=jp(l)/i;let f=s*(6*l+1)/(1-6*l),c=Math.abs(f);if(c>=u||(o+=l%2===0?f:-f,u=c,c<1e-18*Math.abs(o)))break}return-(Math.exp(-i)*(1-r[1])*Math.pow(e,.25))/(2*Math.sqrt(Math.PI))*o}if(e<-9){let[r,i,o,s,u]=C4(-e);return u*(s*r-o*i)}let[n,t]=w4(e);return Xo(Ci(d1,n),c1(Ci(p1,t)))[0]}function y1(e){if(!isFinite(e))return NaN;if(e>9){let r=Vp(e),i=r[0];if(!Number.isFinite(i))return 1/0;let o=1,s=1,u=1/0;for(let l=1;l<=60;l++){s*=jp(l)/i;let f=s*(6*l+1)/(1-6*l),c=Math.abs(f);if(c>=u||(o+=f,u=c,c<1e-18*Math.abs(o)))break}return Math.exp(i)*(1+r[1])*Math.pow(e,.25)/Math.sqrt(Math.PI)*o}if(e<-9){let[r,i,o,s,u]=C4(-e);return u*(o*r+s*i)}let[n,t]=w4(e);return Ci(E4,Xo(Ci(d1,n),Ci(p1,t)))[0]}var Xoe=[-2991.8191940101983,708840.0452577386,-6297414862058625e-8,25489088057337637e-7,-4429795180596978e-5,3180162978765678e-4],ese=[1,281.3762688899943,45584.78108065326,5173438887700964e-9,4193202458981112e-7,22441179564534092e-6,607366389490085e-3],nse=[-49884311457357354e-24,9504280628298596e-21,-.0006451914356839651,.018884331939670384,-.20552590095501388,1],tse=[399982968972496e-26,9154392157746574e-25,12500186247959882e-23,12226278902417902e-21,.0008680295429417843,.04121420907221998,1],N4=[.4215435550436775,.1434079197807589,.011522095507358577,.000345017939782574,46361374928786735e-22,3055689837902576e-23,10230451416490724e-26,17201074326816183e-29,13428327623306275e-32,3763297112699879e-35],R4=[1,.7515863983533789,.11688892585919138,.0064405152650885865,.00015593440916415301,18462756734893055e-22,11269922476399903e-24,36014002958937136e-27,5887545336215784e-29,45200143407412973e-33,12544323709001127e-36],A4=[.5044420736433832,.1971028335255234,.018764858409257526,.0006840793809153931,11513882611188428e-21,9828524436884223e-23,44534441586175015e-26,10826804113902088e-28,1375554606332618e-30,8363544356306774e-34,18695871016278324e-38],T4=[1,1.4749575992512833,.33774898912002,.02536037414203388,.0008146791071843061,12754507566772912e-21,10431458965757199e-23,46068072851523205e-26,11027321506624028e-28,13879653125957886e-31,8391588162831187e-34,18695871016278324e-38];function wo(e,n){let t=n[0];for(let r=1;r<n.length;r++)t=t*e+n[r];return t}var I4=6e15;function k4(e){let t=134217729*e,r=t-(t-e),i=e-r,o=r*r%4+2*(r*i%2)+i*i%4;return o%=4,o<0&&(o+=4),Math.PI/2*o}function nu(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,r=t*t;return n*e*t*wo(r,Xoe)/wo(r,ese)}if(e<I4){let t=e*e,r=Math.PI*t,i=1/(r*r),o=1-i*wo(i,N4)/wo(i,R4),s=1/r*wo(i,A4)/wo(i,T4),u=k4(e),a=Math.cos(u),l=Math.sin(u);return n*(.5-(o*a+s*l)/(Math.PI*e))}return n*.5}function tu(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,r=t*t;return n*e*wo(r,nse)/wo(r,tse)}if(e<I4){let t=e*e,r=Math.PI*t,i=1/(r*r),o=1-i*wo(i,N4)/wo(i,R4),s=1/r*wo(i,A4)/wo(i,T4),u=k4(e),a=Math.cos(u),l=Math.sin(u);return n*(.5+(o*l-s*a)/(Math.PI*e))}return n*.5}function b1(e){return e===0?1:Math.sin(e)/e}var iR=Math.LOG10E;function dr(e,n){let t=D.precision;D.precision=t+Math.max(0,Math.ceil(e));try{return n()}finally{D.precision=t}}function M4(e,n){let t=e.mul(e),r=t.mul(2),i=e,o=e,s=new D(10).pow(-n),u=1e3+10*Math.ceil(t.toNumber())+10*n;for(let a=1;a<=u&&(i=i.mul(r).div(2*a+1),o=o.add(i),!i.lt(o.mul(s)));a++);return o.mul(2).mul(t.neg().exp()).div(D.PI.sqrt())}function rse(e,n){let t=e.mul(e).mul(2),r=D.ONE,i=D.ONE,o=r.abs(),s=new D(10).pow(-n);for(let u=1;u<=1e5;u++){r=r.mul(2*u-1).div(t).neg();let a=r.abs();if(a.gt(o)||(o=a,i=i.add(r),a.lt(s)))break}return e.mul(e).neg().exp().div(e.mul(D.PI.sqrt())).mul(i)}function v1(e,n){if(n.isNaN())return D.NAN;if(!n.isFinite())return n.isNegative()?D.NEGATIVE_ONE:D.ONE;if(n.isZero())return D.ZERO;if(n.isNegative())return v1(e,n.neg()).neg();let t=D.precision,r=10,i=n.toNumber();return i*i*iR>=t+r?D.ONE:dr(r,()=>M4(n,t+r)).toPrecision(t)}function E1(e){if(Number.isNaN(e))return NaN;if(e===0)return 0;if(!Number.isFinite(e))return e>0?1/0:-1/0;let n=e<0?-1:1,t=Math.abs(e),r=t*t,i=t,o=t;for(let s=1;s<1e3&&(i*=r*(2*s-1)/(s*(2*s+1)),o+=i,!(i<o*1e-18));s++);return n*(2/Math.sqrt(Math.PI))*o}function ise(e,n){let t=e.mul(e),r=e,i=e,o=new D(10).pow(-n),s=1e3+10*Math.ceil(t.toNumber())+10*n;for(let u=1;u<=s&&(r=r.mul(t).mul(2*u-1).div(u*(2*u+1)),i=i.add(r),!r.lt(i.mul(o)));u++);return i.mul(2).div(D.PI.sqrt())}function oR(e,n){if(n.isNaN())return D.NAN;if(!n.isFinite())return n.isNegative()?D.NEGATIVE_INFINITY:D.POSITIVE_INFINITY;if(n.isZero())return D.ZERO;if(n.isNegative())return oR(e,n.neg()).neg();let t=D.precision,r=10;return dr(r,()=>ise(n,t+r)).toPrecision(t)}var x1=.5772156649015329;function $4(e){let i=Math.abs(e);if(i===0)return{si:0,ci:-1/0};if(!Number.isFinite(i))return{si:e>0?Math.PI/2:-Math.PI/2,ci:0};let o,s;if(i>2){let u=1,a=i,l=1e30,f=0,c=u*u+a*a,d=u/c,p=-a/c,m=d,h=p;for(let x=1;x<100;x++){let S=-x*x;u+=2;let w=S*d+u,_=S*p+a;c=w*w+_*_,d=w/c,p=-_/c,c=l*l+f*f,l=u+S*l/c,f=a-S*f/c;let A=l*d-f*p,N=l*p+f*d;if(w=m*A-h*N,_=m*N+h*A,m=w,h=_,Math.abs(A-1)+Math.abs(N)<=1e-16)break}let y=Math.cos(i),b=Math.sin(i),v=y*m+b*h,E=y*h-b*m;s=-v,o=Math.PI/2+E}else{let u=0,a=0,l=0,f=1,c=1,d=!0;for(let p=1;p<=100;p++){c*=i/p;let m=c/p;u+=f*m;let h=m/Math.abs(u);if(d?(f=-f,a=u,u=l):(l=u,u=a),h<1e-16)break;d=!d}o=a,s=l+Math.log(i)+x1}return e<0&&(o=-o),{si:o,ci:s}}function S1(e){return Number.isNaN(e)?NaN:$4(e).si}function jh(e){return Number.isNaN(e)?NaN:$4(e).ci}function O4(e){return Number.isNaN(e)?NaN:e===0?0:(ma(e)-ma(-e))/2}function sR(e){if(Number.isNaN(e))return NaN;let n=Math.abs(e);return(ma(n)+ma(-n))/2}function ose(e){if(e<=0)return NaN;if(e<=1){let a=-Math.log(e)-x1,l=1;for(let f=1;f<=200;f++){l*=-e/f;let c=-l/f;if(a+=c,Math.abs(c)<Math.abs(a)*1e-16)break}return a}let r=1e30,i=e+1,o=r,s=1/i,u=s;for(let a=1;a<=200;a++){let l=-a*a;i+=2,s=1/(l*s+i),o=i+l/o;let f=o*s;if(u*=f,Math.abs(f-1)<=1e-16)break}return u*Math.exp(-e)}function ma(e){if(Number.isNaN(e))return NaN;if(e===0)return-1/0;if(!Number.isFinite(e))return e>0?1/0:0;if(e<0)return-ose(-e);let n=1e-16,t=200,r=-Math.log(n);if(e<=r){let s=0,u=1;for(let a=1;a<=t;a++){u*=e/a;let l=u/a;if(s+=l,l<n*s)break}return s+Math.log(e)+x1}let i=0,o=1;for(let s=1;s<=t;s++){let u=o;if(o*=s/e,o<n)break;if(o<u)i+=o;else{i-=u;break}}return Math.exp(e)*(1+i)/e}function _1(e){return Number.isNaN(e)?NaN:e===0?0:e===1?-1/0:e<0?NaN:ma(Math.log(e))}function uR(e,n){if(n.isNaN())return D.NAN;if(!n.isFinite())return n.isNegative()?D.TWO:D.ZERO;if(n.isZero())return D.ONE;if(n.isNegative())return D.TWO.sub(uR(e,n.neg()));let t=D.precision,r=10,i=n.toNumber(),o=i*i*iR;return o<=t+r?dr(o+r,()=>D.ONE.sub(M4(n,t+Math.ceil(o)+r))).toPrecision(t):dr(r,()=>rse(n,t+r)).toPrecision(t)}function aR(e,n){if(n.isNaN())return D.NAN;if(n.abs().gt(D.ONE))return D.NAN;if(n.isZero())return D.ZERO;if(n.eq(D.ONE))return new D(1/0);if(n.eq(D.NEGATIVE_ONE))return new D(-1/0);if(n.isNegative())return aR(e,n.neg()).neg();let t=D.precision;return dr(15,()=>{let i,o=n.toNumber();1-o*o>0?i=new D(t4(o)):i=D.ONE.sub(n.mul(n)).ln().neg().sqrt();let s=D.PI.sqrt().div(2),u=new D(10).pow(-(t+5));for(let a=0;a<100;a++){let l=v1(e,i).sub(n).mul(s).mul(i.mul(i).exp());if(i=i.sub(l),l.abs().lt(i.abs().mul(u)))break}return i}).toPrecision(t)}function P4(e){return e.isNaN()?D.NAN:e.isFinite()?e.isZero()?D.ONE:e.sin().div(e):D.ZERO}function sse(e,n,t){let r=D.PI.div(2),i=r.mul(r),o=e.mul(e).mul(e).mul(e),s=i.mul(o),u,a;n==="s"?(u=r.mul(e).mul(e).mul(e),a=u.div(3)):(u=e,a=e);let l=new D(10).pow(-t),f=Math.PI/2*e.toNumber()**2,c=100+2*Math.ceil(f)+2*t;for(let d=1;d<=c;d++){let p=n==="s"?2*d*(2*d+1):(2*d-1)*(2*d);u=u.mul(s).div(p).neg();let m=u.div(n==="s"?4*d+3:4*d+1);if(a=a.add(m),m.abs().lt(l))break}return a}function use(e,n,t){let r=D.PI,i=r.mul(e).mul(e).div(2),o=i.mul(i).mul(4),s=r.mul(e),u=D.ONE,a=D.HALF.div(i),l=u,f=a,c=u.abs(),d=new D(10).pow(-t);for(let b=1;b<=1e5;b++){u=u.mul((4*b-3)*(4*b-1)).div(o).neg(),a=a.mul((4*b-1)*(4*b+1)).div(o).neg();let v=u.abs();if(v.gt(c)||(c=v,l=l.add(u),f=f.add(a),v.lt(d)&&a.abs().lt(d)))break}let p=l.div(s),m=f.div(s),h=i.sin(),y=i.cos();return n==="s"?D.HALF.sub(p.mul(y)).sub(m.mul(h)):D.HALF.add(p.mul(h)).sub(m.mul(y))}function ase(e){let n=e.significand<0n?-e.significand:e.significand,t=n.toString().length,r=Math.max(0,t-15),i=Number(r>0?n/10n**BigInt(r):n);return e.exponent+r+Math.log10(i)}function lR(e,n){if(e.isNaN())return D.NAN;if(!e.isFinite())return e.isNegative()?D.HALF.neg():D.HALF;if(e.isZero())return D.ZERO;if(e.isNegative())return lR(e.neg(),n).neg();let t=D.precision,r=10,i=e.toNumber(),o=Math.PI/2*i*i,s=o*iR,u=ase(e);if(s<=t+2*r)return dr(s+r,()=>sse(e,n,t+r)).toPrecision(t);if(u>t+r)return D.HALF;let a=Number.isFinite(o)?Math.log10(o):2*u+Math.log10(Math.PI/2),l=r+Math.ceil(Math.max(0,a));return dr(l,()=>use(e,n,t+r)).toPrecision(t)}function D4(e){return lR(e,"s")}function F4(e){return lR(e,"c")}function qh(e,n){if(Number.isNaN(e)||Number.isNaN(n))return NaN;if(e<0||n<0)return NaN;if(e===0||n===0)return 0;if(!isFinite(e)||!isFinite(n))return 1/0;for(let t=0;t<64&&Math.abs(e-n)>1e-17*Math.abs(e);t++){let r=.5*(e+n);n=Math.sqrt(e*n),e=r}return .5*(e+n)}function fR(e,n){if(e.isNaN()||n.isNaN()||e.isNegative()||n.isNegative())return D.NAN;if(e.isZero()||n.isZero())return D.ZERO;let t=new D(10).pow(-(D.precision-2));for(let r=0;r<200&&e.sub(n).abs().gt(t.mul(e.abs()));r++){let i=e.add(n).div(D.TWO);n=e.mul(n).sqrt(),e=i}return e.add(n).div(D.TWO)}function zh(e){return Number.isNaN(e)?NaN:e===1?1/0:e>1?NaN:Math.PI/(2*qh(1,Math.sqrt(1-e)))}function Uh(e){if(Number.isNaN(e))return NaN;if(e===1)return 1;if(e>1)return NaN;let n=1,t=Math.sqrt(1-e),r=.5*e,i=.5;for(let s=0;s<64&&Math.abs(n-t)>1e-17*n;s++){let u=.5*(n-t),a=.5*(n+t);t=Math.sqrt(n*t),n=a,i*=2,r+=i*u*u}return Math.PI/(2*n)*(1-r)}function L4(e,n){if(n.isNaN()||n.gte(D.ONE))return D.NAN;let t=D.precision;return dr(10,()=>D.PI.div(D.TWO.mul(fR(D.ONE,D.ONE.sub(n).sqrt())))).toPrecision(t)}function B4(e,n){if(n.isNaN()||n.gt(D.ONE))return D.NAN;if(n.eq(D.ONE))return D.ONE;let t=D.precision;return dr(10,()=>{let i=new D(10).pow(-(D.precision-2)),o=D.ONE,s=D.ONE.sub(n).sqrt(),u=n.div(D.TWO),a=D.HALF;for(let f=0;f<200&&o.sub(s).abs().gt(i.mul(o));f++){let c=o.sub(s).div(D.TWO),d=o.add(s).div(D.TWO);s=o.mul(s).sqrt(),o=d,a=a.mul(D.TWO),u=u.add(a.mul(c).mul(c))}return D.PI.div(D.TWO.mul(o)).mul(D.ONE.sub(u))}).toPrecision(t)}var V4=1e-24;function kp(e,n){if(Number.isNaN(e)||Number.isNaN(n)||e<0)return NaN;if(n===0)return 1/0;if(e===0)return Math.PI/(2*Math.sqrt(n));if(n<0)return Math.sqrt(e/(e-n))*kp(e-n,-n);if(e===n)return 1/Math.sqrt(e);let t=(n-e)/e;if(Math.abs(t)<.01){let i=0,o=1;for(let s=0;s<10;s++)i+=o/(2*s+1),o*=-t;return i/Math.sqrt(e)}let r=Math.sqrt(e/n);return e<n?Math.acos(r)/Math.sqrt(n-e):Math.acosh(r)/Math.sqrt(e-n)}function Hh(e,n,t){if(Number.isNaN(e)||Number.isNaN(n)||Number.isNaN(t))return NaN;if(e<0||n<0||t<0)return NaN;if((e===0?1:0)+(n===0?1:0)+(t===0?1:0)>1)return 1/0;if(n===t)return kp(e,n);if(e===t)return kp(n,e);if(e===n)return kp(t,e);let r=(e+n+t)/3,i=Math.pow(3*V4,-1/6)*Math.max(Math.abs(r-e),Math.abs(r-n),Math.abs(r-t)),[o,s,u]=[e,n,t],a=r,l=1;for(let y=0;y<64&&l*i>=Math.abs(a);y++){let b=Math.sqrt(o),v=Math.sqrt(s),E=Math.sqrt(u),x=b*v+b*E+v*E;a=(a+x)/4,o=(o+x)/4,s=(s+x)/4,u=(u+x)/4,l/=4}let f=l/a,c=(r-e)*f,d=(r-n)*f,p=-c-d,m=c*d-p*p,h=c*d*p;return Math.pow(a,-.5)*(9240-924*m+385*m*m+660*h-630*m*h)/9240}function w1(e,n,t,r){if(Number.isNaN(e)||Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(e<0||n<0||t<0)return NaN;if(r===0||(e===0?1:0)+(n===0?1:0)+(t===0?1:0)>1)return 1/0;if(r<0){let[A,N,I]=[e,n,t].sort((M,V)=>M-V),B=-r,F=(I*(A+N+B)-A*N)/(I+B),q=(F-I)*w1(A,N,I,F);return q-=3*Hh(A,N,I),q+=3*Math.sqrt(A*N*I/(A*N+F*B))*kp(A*N+F*B,F*B),q/(I+B)}let i=(e+n+t+2*r)/5,o=(r-e)*(r-n)*(r-t),s=Math.pow(.25*V4,-1/6)*Math.max(Math.abs(i-e),Math.abs(i-n),Math.abs(i-t),Math.abs(i-r)),[u,a,l,f]=[e,n,t,r],c=i,d=1,p=0;for(let A=0;A<64;A++){let N=Math.sqrt(u),I=Math.sqrt(a),B=Math.sqrt(l),F=Math.sqrt(f),q=N*I+N*B+I*B,M=(c+q)/4;u=(u+q)/4,a=(a+q)/4,l=(l+q)/4,f=(f+q)/4;let V=(F+N)*(F+I)*(F+B),$=o*d*d*d/(V*V);if(d*s<Math.abs(c))break;p+=kp(1,1+$)*d/V,d/=4,c=M}let m=d/c,h=(i-e)*m,y=(i-n)*m,b=(i-t)*m,v=(-h-y-b)/2,E=h*y+h*b+y*b-3*v*v,x=h*y*b+2*E*v+4*v*v*v,S=(2*h*y*b+E*v+3*v*v*v)*v,w=h*y*b*v*v,_=(24024-5148*E+2457*E*E+4004*x-4158*E*x-3276*S+2772*w)/24024;return d*Math.pow(c,-1.5)*_+6*p}function lse(e,n,t){return w1(e,n,t,t)}function Gh(e,n){if(Number.isNaN(e)||Number.isNaN(n))return NaN;if(Math.abs(e)>Math.PI/2){let o=Math.round(e/Math.PI),s=zh(n);return Number.isFinite(s)?2*o*s+Gh(e-o*Math.PI,n):NaN}let t=Math.sin(e),r=1-n*t*t;if(r<0)return NaN;let i=Math.cos(e);return t*Hh(i*i,r,1)}function Wh(e,n){if(Number.isNaN(e)||Number.isNaN(n))return NaN;if(Math.abs(e)>Math.PI/2){let s=Math.round(e/Math.PI),u=Uh(n);return Number.isFinite(u)?2*s*u+Wh(e-s*Math.PI,n):NaN}let t=Math.sin(e),r=1-n*t*t;if(r<0)return NaN;let i=Math.cos(e),o=t*t*t;return t*Hh(i*i,r,1)-n/3*o*lse(i*i,r,1)}function Yh(e,n){return Number.isNaN(e)||Number.isNaN(n)?NaN:e===1||n===1?1/0:n>1?NaN:Hh(0,1-n,1)+e/3*w1(0,1-n,1,1-e)}function Zh(e,n,t){if(Number.isNaN(e)||Number.isNaN(n)||Number.isNaN(t))return NaN;if(Math.abs(n)>Math.PI/2){let a=Math.round(n/Math.PI),l=Yh(e,t);return Number.isFinite(l)?2*a*l+Zh(e,n-a*Math.PI,t):NaN}let r=Math.sin(n),i=1-t*r*r;if(i<0)return NaN;let o=Math.cos(n),s=r*r*r,u=1-e*r*r;return u===0?1/0:r*Hh(o*o,i,1)+e/3*s*w1(o*o,i,1,u)}function kl(e){return Number.isInteger(e)&&e<=0}function Fh(e,n,t,r,i=1e4){let o=1,s=1;for(let u=0;u<i;u++)if(o*=(e+u)*(n+u)*r/((t+u)*(u+1)),o===0||(s+=o,u>2&&Math.abs(o)<=Number.EPSILON*Math.abs(s)))return s;return s}function Jh(e,n,t,r){if([e,n,t,r].some(Number.isNaN))return NaN;let i=kl(e)?-e:1/0,o=kl(n)?-n:1/0,s=Math.min(i,o);if(kl(t)&&(s===1/0||s>-t))return NaN;if(s!==1/0)return Fh(e,n,t,r,s+1);if(r===0)return 1;if(r===1){let f=t-e-n;return f<=0?f===0?1/0:NaN:Re(t)*Re(f)/(Re(t-e)*Re(t-n))}if(r>1)return NaN;if(r<0)return Math.pow(1-r,-e)*Jh(e,t-n,t,r/(r-1));if(r<=.5)return Fh(e,n,t,r);let u=t-e-n;if(Number.isInteger(u)){if(r<1){let f=Math.ceil(17/-Math.log10(r));if(f<=4e5)return Fh(e,n,t,r,f+10)}return NaN}let a=Re(t)*Re(u)/(Re(t-e)*Re(t-n))*Fh(e,n,1-u,1-r),l=Re(t)*Re(-u)/(Re(e)*Re(n))*Math.pow(1-r,u)*Fh(t-e,t-n,1+u,1-r);return a+l}function e4(e,n,t,r=2e4){let i=1,o=1;for(let s=0;s<r;s++)if(i*=(e+s)*t/((n+s)*(s+1)),i===0||(o+=i,s>2&&Math.abs(i)<=Number.EPSILON*Math.abs(o)))return o;return o}function Kh(e,n,t){if([e,n,t].some(Number.isNaN))return NaN;let r=kl(e)?-e:1/0;return kl(n)&&(r===1/0||r>-n)?NaN:r!==1/0?e4(e,n,t,r+1):t<0?Math.exp(t)*Kh(n-e,n,-t):e4(e,n,t)}function j4(e,n,t,r,i,o){if([e,n,t,r,i,o].some(Number.isNaN))return NaN;if(kl(r))return NaN;let s=Math.abs(i)<1||kl(n),u=Math.abs(o)<1||kl(t);if(!s||!u)return NaN;let a=1e4,l=1e4,f=0,c=1,d=0;for(let p=0;p<a;p++){let m=c,h=m;for(let y=0;y<l&&(m*=(e+p+y)*(t+y)*o/((r+p+y)*(y+1)),!(m===0||(h+=m,Math.abs(m)<=Number.EPSILON*(1+Math.abs(h)))));y++);if(f+=h,Math.abs(h)<=Number.EPSILON*(1+Math.abs(f))){if(++d>=3)return f}else d=0;if(c*=(e+p)*(n+p)*i/((r+p)*(p+1)),c===0)return f}return f}function Bh(e){return e.isInteger()&&!e.isPositive()}function Lh(e,n,t,r,i,o){let s=new D(10).pow(-(D.precision+2)),u=D.ONE,a=D.ONE;for(let l=0;l<o;l++){(l&255)===0&&ee(e._deadlineFrame);let f=new D(l);if(u=u.mul(n.add(f)).mul(t.add(f)).mul(i).div(r.add(f).mul(new D(l+1))),u.isZero()||(a=a.add(u),l>2&&u.abs().lt(s.mul(a.abs().add(D.ONE)))))return a}return a}function cR(e,n,t,r,i){if(n.isNaN()||t.isNaN()||r.isNaN()||i.isNaN())return D.NAN;let o=D.precision,s=10,u=Math.max(1e4,40*(o+s)),a=Bh(n)?-n.toNumber():1/0,l=Bh(t)?-t.toNumber():1/0,f=Math.min(a,l);if(Bh(r)&&(f===1/0||f>-r.toNumber()))return D.NAN;if(f!==1/0&&f<u)return dr(s,()=>Lh(e,n,t,r,i,f+1)).toPrecision(o);if(i.isZero())return D.ONE;let c=D.ONE;if(i.eq(c)){let p=r.sub(n).sub(t);return p.isPositive()?dr(s,()=>At(e,r).mul(At(e,p)).div(At(e,r.sub(n)).mul(At(e,r.sub(t))))).toPrecision(o):D.NAN}if(i.gt(c))return D.NAN;if(i.isNegative())return dr(s,()=>{let p=c.sub(i);return n.neg().mul(p.ln()).exp().mul(cR(e,n,r.sub(t),r,i.div(i.sub(c))))}).toPrecision(o);if(i.lte(D.HALF))return dr(s,()=>Lh(e,n,t,r,i,u)).toPrecision(o);let d=r.sub(n).sub(t);if(d.isInteger()){let p=i.toNumber();if(p<1){let m=Math.ceil((o+s+2)/-Math.log10(p))+100;if(m<=2e6)return dr(s,()=>Lh(e,n,t,r,i,m)).toPrecision(o)}return D.NAN}return dr(s,()=>{let p=c.sub(i),m=At(e,r).mul(At(e,d)).div(At(e,r.sub(n)).mul(At(e,r.sub(t)))).mul(Lh(e,n,t,c.sub(d),p,u)),h=At(e,r).mul(At(e,d.neg())).div(At(e,n).mul(At(e,t))).mul(d.mul(p.ln()).exp()).mul(Lh(e,r.sub(n),r.sub(t),c.add(d),p,u));return m.add(h)}).toPrecision(o)}function n4(e,n,t,r,i){let o=new D(10).pow(-(D.precision+2)),s=D.ONE,u=D.ONE;for(let a=0;a<i;a++){(a&255)===0&&ee(e._deadlineFrame);let l=new D(a);if(s=s.mul(n.add(l)).mul(r).div(t.add(l).mul(new D(a+1))),s.isZero()||(u=u.add(s),a>2&&s.abs().lt(o.mul(u.abs().add(D.ONE)))))return u}return u}function dR(e,n,t,r){if(n.isNaN()||t.isNaN()||r.isNaN())return D.NAN;let i=D.precision,o=10,s=Math.max(2e4,40*(i+o)),u=Bh(n)?-n.toNumber():1/0;return Bh(t)&&(u===1/0||u>-t.toNumber())?D.NAN:u!==1/0&&u<s?dr(o,()=>n4(e,n,t,r,u+1)).toPrecision(i):r.isNegative()?dr(o,()=>r.exp().mul(dR(e,t.sub(n),t,r.neg()))).toPrecision(i):dr(o,()=>n4(e,n,t,r,s)).toPrecision(i)}var C1=7,N1=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23],fse=Math.sqrt(2*Math.PI),cse=.5*Math.log(2*Math.PI);function ba(e){if(e.re<.5){let i=e.mul(Math.PI).sin();return new W(Math.PI,0).div(i.mul(ba(new W(1,0).sub(e))))}let n=e.sub(1),t=new W(N1[0],0);for(let i=1;i<C1+2;i++)t=t.add(new W(N1[i],0).div(n.add(i)));let r=n.add(C1+.5);return new W(fse,0).mul(r.pow(n.add(.5))).mul(r.neg().exp()).mul(t)}function mR(e){if(e.re<.5){let i=e.mul(Math.PI).sin();return new W(Math.PI,0).div(i).log().sub(mR(new W(1,0).sub(e)))}let n=e.sub(1),t=new W(N1[0],0);for(let i=1;i<C1+2;i++)t=t.add(new W(N1[i],0).div(n.add(i)));let r=n.add(C1+.5);return new W(cse,0).add(n.add(.5).mul(r.log())).sub(r).add(t.log())}var Ae=new W(NaN,NaN),xe=new W(1,0),ns=new W(0,0),dse=.5772156649015329;function pse(e){if(e.abs()<20||e.re<=0){let s=ns,u=xe;for(let a=1;a<500;a++){u=u.mul(e.neg()).div(a);let l=u.div(-a);if(s=s.add(l),l.abs()<1e-18*(1+s.abs()))break}return new W(-dse,0).sub(e.log()).add(s)}let n=new W(1e-300,0),t=e.add(1),r=xe.div(n),i=xe.div(t),o=i;for(let s=1;s<500;s++){let u=-s*s;t=t.add(2),i=i.mul(u).add(t),i.abs()<1e-300&&(i=n),r=t.add(r.inverse().mul(u)),r.abs()<1e-300&&(r=n),i=i.inverse();let a=i.mul(r);if(o=o.mul(a),a.sub(xe).abs()<1e-16)break}return o.mul(e.neg().exp())}function mse(e,n){let t=xe.div(e),r=t;for(let i=1;i<2e3&&(t=t.mul(n).div(e.add(i)),r=r.add(t),!(t.abs()<1e-17*r.abs()));i++);return n.pow(e).mul(n.neg().exp()).mul(r)}function gse(e,n){let t=xe,r=xe;for(let i=1;i<1e3;i++){let o=t.mul(e.sub(i)).div(n);if(o.abs()>t.abs()||(t=o,r=r.add(t),t.abs()<1e-17*r.abs()))break}return n.pow(e.sub(1)).mul(n.neg().exp()).mul(r)}function hse(e,n){let t=new W(1e-300,0),r=n.add(1).sub(e),i=xe.div(t),o=xe.div(r),s=o;for(let u=1;u<2e3;u++){let a=e.sub(u).mul(u);r=r.add(2),o=a.mul(o).add(r),o.abs()<1e-300&&(o=t),i=r.add(a.div(i)),i.abs()<1e-300&&(i=t),o=o.inverse();let l=o.mul(i);if(s=s.mul(l),l.sub(xe).abs()<1e-16)break}return n.pow(e).mul(n.neg().exp()).mul(s)}function yse(e,n){let t=pse(n),r=n.neg().exp();for(let i=0;i>e;i--)t=t.sub(n.pow(i-1).mul(r)).div(i-1);return t}function A1(e,n){if(e.isNaN()||n.isNaN())return Ae;if(n.isZero())return ba(e);let t=n.abs(),r=e.abs();return t>r+14&&t>12?gse(e,n):e.im===0&&Number.isInteger(e.re)&&e.re<=0?yse(e.re,n):n.re>0&&t>=r+1?hse(e,n):ba(e).sub(mse(e,n))}function Xh(e){let n=e.im===0?new W(e.re,0):e;return A1(ns,n)}function gR(e){return e>0?1:e<0?-1:0}function H4(e){return e.isNaN()?Ae:Xh(e.neg()).neg().add(new W(0,Math.PI*gR(e.im)))}function T1(e){if(e.isNaN())return Ae;if(e.re<0||e.re===0&&e.im<0)return T1(e.neg()).neg();let n=new W(-e.im,e.re);return Xh(n).sub(Xh(n.neg())).div(new W(0,2)).add(new W(Math.PI/2,0))}function hR(e){if(e.isNaN())return Ae;let n=new W(-e.im,e.re),t=Xh(n).add(Xh(n.neg())).mul(-.5);return(e.re<0||e.re===0&&e.im<0)&&(t=t.add(new W(0,Math.PI*gR(e.im)))),t}function G4(e){if(e.isNaN())return Ae;let n=new W(-e.im,e.re),t=T1(n);return new W(t.im,-t.re)}function yR(e){if(e.isNaN())return Ae;if(e.re<0||e.re===0&&e.im<0)return yR(e.neg()).add(new W(0,Math.PI*gR(e.im)));let n=new W(-e.im,e.re),t=hR(n);return e.re===0&&(t=t.add(new W(0,Math.PI))),t.sub(new W(0,Math.PI/2))}var bse=Math.sqrt(Math.PI);function I1(e){if(e.isNaN())return Ae;if(e.re<0||e.re===0&&e.im<0)return I1(e.neg()).neg();let n=e.mul(e);n.im===0&&(n=new W(n.re,0));let t=A1(new W(.5,0),n);return xe.sub(t.div(new W(bse,0)))}function W4(e){if(e.isNaN())return Ae;let n=new W(-e.im,e.re),t=I1(n);return new W(t.im,-t.re)}function vse(e){let[n,t]=Nc(e);return Number(n)/Number(t)}function Ese(e,n){let t=1;for(let r=0;r<n;r++)t=t*(e-r)/(r+1);return Math.round(t)}function xse(e,n){let t=ns;for(let r=0;r<=e;r++)t=t.add(n.pow(e-r).mul(Ese(e,r)*vse(r)));return t}function Sse(e,n){let t=ns,r=xe;for(let i=1;i<500;i++){r=r.mul(n);let o=r.div(Math.pow(i,e));if(t=t.add(o),o.abs()<1e-17*(1+t.abs()))break}return t}function _se(e,n){let t=n.log();if(t.re===0&&t.im===0)return new W(eu(e),0);let r=0;for(let u=1;u<e;u++)r+=1/u;let i=t.neg().log(),o=ns,s=xe;for(let u=0;u<200;u++){let a;u===e-1?a=s.mul(new W(r,0).sub(i)):a=s.mul(eu(e-u)),o=o.add(a);let l=a.abs();if(u>e&&l!==0&&l<1e-16*(1+o.abs()))break;s=s.mul(t).div(u+1)}return o}function Y4(e,n){return n.abs()<=.5?Sse(e,n):_se(e,n)}function wse(e,n){let t=new W(0,2*Math.PI),r=new W(-n.re,n.im===0?0:-n.im),i=new W(.5,0).add(r.log().div(t)),o=xse(e,i),s=Y4(e,n.inverse()),u=e%2===0?-1:1,a=1;for(let l=2;l<=e;l++)a*=l;return s.mul(u).sub(t.pow(e).div(a).mul(o))}function Z4(e,n){if(e.isNaN()||n.isNaN()||e.im!==0)return Ae;let t=Math.round(e.re);return!Number.isInteger(e.re)||Math.abs(e.re-t)>1e-12||t<2?Ae:n.isZero()?ns:n.abs()>1?wse(t,n):Y4(t,n)}function bR(e,n){if(e.isNaN()||n.isNaN())return Ae;if(e.isZero()||n.isZero())return new W(0,0);for(let t=0;t<100;t++){let r=e.add(n).mul(.5),i=e.mul(n).sqrt();if(r.sub(i).abs()>r.add(i).abs()&&(i=i.neg()),e=r,n=i,e.sub(n).abs()<=1e-17*e.abs())break}return e.add(n).mul(.5)}function vR(e){return e.isNaN()?Ae:e.equals(xe)?new W(1/0,0):new W(Math.PI/2,0).div(bR(xe,xe.sub(e).sqrt()))}function ER(e){if(e.isNaN())return Ae;if(e.equals(xe))return xe;let n=xe,t=xe.sub(e).sqrt(),r=e.mul(.5),i=.5;for(let s=0;s<100;s++){let u=n.sub(t).mul(.5),a=n.add(t).mul(.5),l=n.mul(t).sqrt();if(a.sub(l).abs()>a.add(l).abs()&&(l=l.neg()),n=a,t=l,i*=2,r=r.add(u.mul(u).mul(i)),n.sub(t).abs()<=1e-17*n.abs())break}return new W(Math.PI/2,0).div(n).mul(xe.sub(r))}var J4=1e-24;function Qh(e,n){if(e.isNaN()||n.isNaN())return Ae;if(n.isZero())return new W(1/0,0);if(e.isZero())return new W(Math.PI/2,0).div(n.sqrt());if(n.im===0&&n.re<0)return e.div(e.sub(n)).sqrt().mul(Qh(e.sub(n),n.neg()));if(e.equals(n))return e.sqrt().inverse();let t=n.sub(e).div(e);if(t.abs()<.01){let o=ns,s=xe;for(let u=0;u<10;u++)o=o.add(s.div(2*u+1)),s=s.mul(t).neg();return o.div(e.sqrt())}let r=e.sqrt(),i=n.sqrt();return r.div(i).acos().div(xe.sub(e.div(n)).sqrt().mul(i))}function k1(e,n,t){if(e.isNaN()||n.isNaN()||t.isNaN())return Ae;if(n.equals(t))return Qh(e,n);if(e.equals(t))return Qh(n,e);if(e.equals(n))return Qh(t,e);if((e.isZero()?1:0)+(n.isZero()?1:0)+(t.isZero()?1:0)>1)return new W(1/0,0);let r=e.add(n).add(t).div(3),i=Math.pow(3*J4,-1/6)*Math.max(r.sub(e).abs(),r.sub(n).abs(),r.sub(t).abs()),o=e,s=n,u=t,a=r,l=1;for(let b=0;b<64&&l*i>=a.abs();b++){let v=o.sqrt(),E=s.sqrt(),x=u.sqrt(),S=v.mul(E).add(v.mul(x)).add(E.mul(x));a=a.add(S).div(4),o=o.add(S).div(4),s=s.add(S).div(4),u=u.add(S).div(4),l/=4}let f=a.inverse().mul(l),c=r.sub(e).mul(f),d=r.sub(n).mul(f),p=c.add(d).neg(),m=c.mul(d).sub(p.mul(p)),h=c.mul(d).mul(p);return new W(9240,0).sub(m.mul(924)).add(m.mul(m).mul(385)).add(h.mul(660)).sub(m.mul(h).mul(630)).div(9240).div(a.sqrt())}function xR(e,n,t,r){if(e.isNaN()||n.isNaN()||t.isNaN()||r.isNaN())return Ae;if(r.isZero())return new W(1/0,0);if((e.isZero()?1:0)+(n.isZero()?1:0)+(t.isZero()?1:0)>1)return new W(1/0,0);let i=e.re>=0&&n.re>=0&&t.re>=0&&r.re>0;if(!i&&(e.equals(r)||n.equals(r)||t.equals(r))&&(i=!0),!i&&(r.im!==0||r.re>=0)){let N=(I,B)=>I.re===B.re&&I.im===-B.im;(e.im===0&&e.re>=0&&N(n,t)||n.im===0&&n.re>=0&&N(e,t)||t.im===0&&t.re>=0&&N(e,n))&&(i=!0)}if(!i)return Ae;let o=e.add(n).add(t).add(r.mul(2)).div(5),s=r.sub(e).mul(r.sub(n)).mul(r.sub(t)),u=Math.pow(.25*J4,-1/6)*Math.max(o.sub(e).abs(),o.sub(n).abs(),o.sub(t).abs(),o.sub(r).abs()),a=e,l=n,f=t,c=r,d=o,p=1,m=ns;for(let N=0;N<64;N++){let I=a.sqrt(),B=l.sqrt(),F=f.sqrt(),q=c.sqrt(),M=I.mul(B).add(I.mul(F)).add(B.mul(F)),V=d.add(M).div(4);a=a.add(M).div(4),l=l.add(M).div(4),f=f.add(M).div(4),c=c.add(M).div(4);let $=q.add(I).mul(q.add(B)).mul(q.add(F)),L=s.mul(p*p*p).div($.mul($));if(p*u<d.abs())break;m=m.add(Qh(xe,xe.add(L)).mul(p).div($)),p/=4,d=V}let h=d.inverse().mul(p),y=o.sub(e).mul(h),b=o.sub(n).mul(h),v=o.sub(t).mul(h),E=y.add(b).add(v).div(-2),x=y.mul(b).add(y.mul(v)).add(b.mul(v)).sub(E.mul(E).mul(3)),S=y.mul(b).mul(v).add(x.mul(E).mul(2)).add(E.mul(E).mul(E).mul(4)),w=y.mul(b).mul(v).mul(2).add(x.mul(E)).add(E.mul(E).mul(E).mul(3)).mul(E),_=y.mul(b).mul(v).mul(E).mul(E);return new W(24024,0).sub(x.mul(5148)).add(x.mul(x).mul(2457)).add(S.mul(4004)).sub(x.mul(S).mul(4158)).sub(w.mul(3276)).add(_.mul(2772)).div(24024).mul(p).div(d.pow(1.5)).add(m.mul(6))}function Cse(e,n,t){return xR(e,n,t,t)}function SR(e,n){if(e.isNaN()||n.isNaN())return Ae;if(Math.abs(e.re)>Math.PI/2){let o=Math.round(e.re/Math.PI),s=vR(n);return s.isNaN()||!Number.isFinite(s.re)?Ae:s.mul(2*o).add(SR(e.sub(o*Math.PI),n))}let t=e.sin(),r=e.cos(),i=xe.sub(n.mul(t).mul(t));return t.mul(k1(r.mul(r),i,xe))}function _R(e,n){if(e.isNaN()||n.isNaN())return Ae;if(Math.abs(e.re)>Math.PI/2){let s=Math.round(e.re/Math.PI),u=ER(n);return u.isNaN()||!Number.isFinite(u.re)?Ae:u.mul(2*s).add(_R(e.sub(s*Math.PI),n))}let t=e.sin(),r=e.cos(),i=r.mul(r),o=xe.sub(n.mul(t).mul(t));return t.mul(k1(i,o,xe)).sub(n.div(3).mul(t.pow(3)).mul(Cse(i,o,xe)))}function wR(e,n){return e.isNaN()||n.isNaN()?Ae:e.equals(xe)||n.equals(xe)?new W(1/0,0):k1(ns,xe.sub(n),xe).add(e.div(3).mul(xR(ns,xe.sub(n),xe,xe.sub(e))))}function CR(e,n,t){if(e.isNaN()||n.isNaN()||t.isNaN())return Ae;if(Math.abs(n.re)>Math.PI/2){let l=Math.round(n.re/Math.PI),f=wR(e,t);return f.isNaN()||!Number.isFinite(f.re)?Ae:f.mul(2*l).add(CR(e,n.sub(l*Math.PI),t))}let r=n.sin(),i=n.cos(),o=i.mul(i),s=r.mul(r),u=xe.sub(t.mul(s)),a=xe.sub(e.mul(s));return a.isZero()?new W(1/0,0):r.mul(k1(o,u,xe)).add(e.div(3).mul(r.pow(3)).mul(xR(o,u,xe,a)))}function ru(e){return e.im===0&&Number.isInteger(e.re)&&e.re<=0}function es(e,n,t,r,i=1e4){let o=xe,s=xe;for(let u=0;u<i;u++)if(o=o.mul(e.add(u)).mul(n.add(u)).mul(r).div(t.add(u).mul(u+1)),o.isZero()||(s=s.add(o),u>2&&o.abs()<=Number.EPSILON*s.abs()))return s;return s}function q4(e){return Number.isNaN(e.re)||Number.isNaN(e.im)?NaN:Math.hypot(e.re-Math.round(e.re),e.im)}function ya(e,n){let t=e.some(ru);if(n.some(ru))return t?Ae:new W(0,0);if(t)return Ae;let r=xe;for(let i of e)r=r.mul(ba(i));for(let i of n)r=r.div(ba(i));return r}var z4=1e-7,Nse=.92,Rse=.99;function R1(e,n,t,r,i=0){if(e.isNaN()||n.isNaN()||t.isNaN()||r.isNaN())return Ae;let o=ru(e)?-e.re:1/0,s=ru(n)?-n.re:1/0,u=Math.min(o,s);if(ru(t)&&(u===1/0||u>-t.re))return Ae;if(u!==1/0)return es(e,n,t,r,u+1);if(r.isZero())return xe;let a=xe,l=t.sub(e).sub(n),f=n.sub(e);if(r.equals(a))return l.re<=0?Ae:ya([t,l],[t.sub(e),t.sub(n)]);r.im===0&&(r=new W(r.re,-0));let c=q4(l)<=z4,d=q4(f)<=z4,p=[{kind:"direct",w:r,degenerate:!1},{kind:"pfaff",w:r.div(r.sub(1)),degenerate:!1},{kind:"one-minus-z",w:a.sub(r),degenerate:c},{kind:"inv-z",w:a.div(r),degenerate:d},{kind:"inv-one-minus-z",w:a.div(a.sub(r)),degenerate:d},{kind:"one-minus-inv-z",w:a.sub(a.div(r)),degenerate:c}];p.sort((h,y)=>h.w.abs()-y.w.abs());let m=!1;for(let h of p){let{kind:y,w:b}=h;if(b.abs()>Rse)break;if(h.degenerate){m=!0;continue}let v=b.abs()<=Nse?1e4:25e4;switch(y){case"direct":return es(e,n,t,r,v);case"pfaff":return a.sub(r).pow(e.neg()).mul(es(e,t.sub(n),t,b,v));case"one-minus-z":{let E=ya([t,l],[t.sub(e),t.sub(n)]).mul(es(e,n,a.sub(l),b,v)),x=ya([t,l.neg()],[e,n]).mul(b.pow(l)).mul(es(t.sub(e),t.sub(n),a.add(l),b,v));return E.add(x)}case"inv-z":{let E=ya([t,f],[n,t.sub(e)]).mul(r.neg().pow(e.neg())).mul(es(e,a.sub(t).add(e),a.sub(n).add(e),b,v)),x=ya([t,f.neg()],[e,t.sub(n)]).mul(r.neg().pow(n.neg())).mul(es(n,a.sub(t).add(n),a.sub(e).add(n),b,v));return E.add(x)}case"inv-one-minus-z":{let E=a.sub(r),x=ya([t,f],[n,t.sub(e)]).mul(E.pow(e.neg())).mul(es(e,t.sub(n),e.sub(n).add(1),b,v)),S=ya([t,f.neg()],[e,t.sub(n)]).mul(E.pow(n.neg())).mul(es(n,t.sub(e),n.sub(e).add(1),b,v));return x.add(S)}case"one-minus-inv-z":{let E=ya([t,l],[t.sub(e),t.sub(n)]).mul(r.pow(e.neg())).mul(es(e,e.sub(t).add(1),e.add(n).sub(t).add(1),b,v)),x=ya([t,l.neg()],[e,n]).mul(a.sub(r).pow(l)).mul(r.pow(e.sub(t))).mul(es(t.sub(e),a.sub(e),l.add(1),b,v));return E.add(x)}}}if(i===0&&m){let y=R1(e.add(1e-6),n,t.add(1e-6*Math.SQRT2),r,1),b=R1(e.sub(1e-6),n,t.sub(1e-6*Math.SQRT2),r,1);return y.add(b).mul(.5)}return Ae}function U4(e,n,t,r=2e4){let i=xe,o=xe;for(let s=0;s<r;s++)if(i=i.mul(e.add(s)).mul(t).div(n.add(s).mul(s+1)),i.isZero()||(o=o.add(i),s>2&&i.abs()<=Number.EPSILON*o.abs()))return o;return o}function NR(e,n,t){if(e.isNaN()||n.isNaN()||t.isNaN())return Ae;let r=ru(e)?-e.re:1/0;return ru(n)&&(r===1/0||r>-n.re)?Ae:r!==1/0?U4(e,n,t,r+1):t.re<0?t.exp().mul(NR(n.sub(e),n,t.neg())):U4(e,n,t)}function K4(e,n,t,r,i,o){if([e,n,t,r,i,o].some(p=>p.isNaN())||ru(r))return Ae;let s=i.abs()<1||ru(n),u=o.abs()<1||ru(t);if(!s||!u)return Ae;let a=1e4,l=1e4,f=new W(0,0),c=xe,d=0;for(let p=0;p<a;p++){let m=c,h=m;for(let y=0;y<l&&(m=m.mul(e.add(p+y)).mul(t.add(y)).mul(o).div(r.add(p+y).mul(y+1)),!(m.isZero()||(h=h.add(m),m.abs()<=Number.EPSILON*(1+h.abs()))));y++);if(f=f.add(h),h.abs()<=Number.EPSILON*(1+f.abs())){if(++d>=3)return f}else d=0;if(c=c.mul(e.add(p)).mul(n.add(p)).mul(i).div(r.add(p).mul(p+1)),c.isZero())return f}return f}function pR(e,n){return e.mul(new W(0,Math.PI*n)).exp()}function RR(e,n,t){if(n.isNaN()||t.isNaN()||t.im<=0)return Ae;let r=4e3,i=new W(0,0),o=t.im,s=Math.abs(n.im);if(e===1||e===2){for(let u=0;u<r;u++){let a=pR(t,(u+.5)*(u+.5)),l=n.mul((2*u+1)*Math.PI),f=a.mul(e===1?l.sin():l.cos());e===1&&u%2===1&&(f=f.neg()),i=i.add(f);let c=Math.exp(-Math.PI*o*(u+.5)*(u+.5)+(2*u+1)*Math.PI*s);if(u>1&&c<=1e-18*(1+i.abs()))break;if(u===r-1)return Ae}return i.mul(2)}for(let u=1;u<r;u++){let l=pR(t,u*u).mul(n.mul(2*u*Math.PI).cos());e===4&&u%2===1&&(l=l.neg()),i=i.add(l);let f=Math.exp(-Math.PI*o*u*u+2*u*Math.PI*s);if(u>1&&f<=1e-18*(1+i.abs()))break;if(u===r-1)return Ae}return xe.add(i.mul(2))}function AR(e){if(e.isNaN()||e.im<=0)return Ae;let n=e.mul(new W(0,2*Math.PI)).exp(),t=n.abs();if(t>=1)return Ae;let r=Math.min(1e5,Math.ceil(-40/Math.log10(t))+1);if(r>=1e5)return Ae;let i=xe,o=n;for(let s=1;s<=r&&(i=i.mul(xe.sub(o)),o=o.mul(n),!(o.abs()<1e-18));s++);return pR(e,1/12).mul(i)}function TR(e,n){if(n.isNaN()||!Number.isInteger(e)||e<2||e%2!==0||n.im<=0)return Ae;let t=n.mul(new W(0,2*Math.PI)).exp(),r=t.abs();if(r>=1)return Ae;let[i,o]=Nc(e);if(i===0n)return Ae;let s=2*e*Number(o)/Number(i);if(!Number.isFinite(s))return Ae;let u=Math.min(1e5,Math.ceil(-40/Math.log10(r))+1);if(u>=1e5)return Ae;let a=ns,l=t;for(let f=1;f<=u;f++){let c=l.div(xe.sub(l)).mul(new W(Math.pow(f,e-1),0));if(a=a.add(c),c.abs()*Math.abs(s)<1e-18&&f>e)break;l=l.mul(t)}return xe.sub(a.mul(new W(s,0)))}function Ac(e){if(e.isInteger===!1)return!1;if(e.isInteger!==!0)return Hi(e.type.type,"integer")?void 0:!1;if(e.isNegative)return!1;if(!T(e))return;let n=xi(e);if(n!==null)return Os(n)}function M1(e){let n=Ac(e);if(n!==void 0)return!(n===!0||e.isInteger!==!0||e.isPositive!==!0||e.isEqual(1)!==!1)}function $l(e,n,t){let r=t.evaluate();return C(r,"True")?n:C(r,"False")?null:e.function("When",[n,r])}var va=new WeakMap;function Ase(e){va.set(e,(va.get(e)??0)+1)}function Tse(e){let n=(va.get(e)??0)-1;n>0?va.set(e,n):va.delete(e)}function $1(e){return(va.get(e)??0)>0}function IR(e,n){Ase(e);try{return n()}finally{Tse(e)}}function Q4(e,n){let t=va.get(e);va.delete(e);try{return n()}finally{t!==void 0&&va.set(e,t)}}function Ni(e){return g(e)?e.op1:void 0}function O1(e){return g(e)?e.op2:void 0}function Tt(e){return g(e)?e.ops:void 0}function Ise(e){for(let n=0;n<e.length;n++){let t=e[n];for(let r=n+1;r<e.length;r++){let i=e[r];if(t.operator==="Not"&&Ni(t).isSame(i)||i.operator==="Not"&&Ni(i).isSame(t))return!0}}return!1}function kse(e){for(let n=0;n<e.length;n++){let t=e[n];for(let r=n+1;r<e.length;r++){let i=e[r];if(t.operator==="Not"&&Ni(t).isSame(i)||i.operator==="Not"&&Ni(i).isSame(t))return!0}}return!1}function ey(e,n){if(!e.some(r=>r.operator===n))return e;let t=[];for(let r of e)r.operator===n&&g(r)?t.push(...ey(r.ops,n)):t.push(r);return t}function $R(e,n,t,r){if(n.operator!==e||t.operator!==e||!g(n)||!g(t)||!n.ops.every(m=>m.isPure)||!t.ops.every(m=>m.isPure))return;let i=n.evaluate(),o=t.evaluate();if(i.operator!==e||o.operator!==e||!g(i)||!g(o))return;let s=ey(i.ops,e),u=ey(o.ops,e);if(s.length!==u.length)return;let a=[...u],l=[];for(let m of s){let h=a.findIndex(y=>m.isSame(y));h>=0?a.splice(h,1):l.push(m)}if(l.length===0)return!0;if(l.length>8)return;let f=l.map(()=>[]),c=(m,h)=>(f[m][h]??=(r?l[m].isIdenticallyEqual(a[h]):l[m].isEqual(a[h]))===!0,f[m][h]),d=new Array(a.length).fill(-1),p=(m,h)=>{for(let y=0;y<a.length;y++)if(!(h[y]||!c(m,y))&&(h[y]=!0,d[y]<0||p(d[y],h)))return d[y]=m,!0;return!1};for(let m=0;m<l.length;m++)if(!p(m,new Array(a.length).fill(!1)))return;return!0}function ny(e,{engine:n}){if(e.length===0)return n.True;e=ey(e,"And");let t=[];for(let i of e){if(i.operator==="Or"&&kse(Tt(i))&&(i=n.True),P(i)==="False")return n.False;if(P(i)!=="True"){let o=!1;for(let s of t)if(s.isSame(i))o=!0;else if(i.operator==="Not"&&Ni(i).isSame(s)||s.operator==="Not"&&Ni(s).isSame(i))return n.False;o||t.push(i)}}if(t.length===0)return n.True;if(t.length===1)return t[0];let r=Mse(t);return r.length===0?n.True:r.length===1?r[0]:n._fn("And",r)}function Mse(e){let n=[];for(let t of e){let r=t.operator==="Or"?Tt(t):void 0;if(r){let i=!1;for(let o of r){for(let s of e)if(s!==t&&o.isSame(s)){i=!0;break}if(i)break}i||n.push(t)}else n.push(t)}return n}function ty(e,{engine:n}){if(e.length===0)return n.True;e=ey(e,"Or");let t=[];for(let i of e){if(i.operator==="And"&&Ise(Tt(i))&&(i=n.False),P(i)==="True")return n.True;if(P(i)!=="False"){let o=!1;for(let s of t)if(s.isSame(i))o=!0;else if(i.operator==="Not"&&Ni(i).isSame(s)||s.operator==="Not"&&Ni(s).isSame(i))return n.True;o||t.push(i)}}if(t.length===0)return n.False;if(t.length===1)return t[0];let r=$se(t);return r.length===0?n.False:r.length===1?r[0]:n._fn("Or",r)}function $se(e){let n=[];for(let t of e){let r=t.operator==="And"?Tt(t):void 0;if(r){let i=!1;for(let o of r){for(let s of e)if(s!==t&&o.isSame(s)){i=!0;break}if(i)break}i||n.push(t)}else n.push(t)}return n}function P1(e,{engine:n}){let t=P(e[0]);if(t==="True")return n.False;if(t==="False")return n.True;if(t==="Missing")return n.Missing}function D1(e,{engine:n}){let t=P(e[0]),r=P(e[1]);if(t==="True"&&r==="True"||t==="False"&&r==="False")return n.True;if(t==="True"&&r==="False"||t==="False"&&r==="True")return n.False}function ry(e,{engine:n}){let t=P(e[0]),r=P(e[1]);if(t==="True"&&r==="True"||t==="False"&&r==="False"||t==="False"&&r==="True")return n.True;if(t==="True"&&r==="False")return n.False;if(t==="Missing"||r==="Missing")return n.Missing}function F1(e,{engine:n}){if(e.length===0)return n.False;let t=0,r=[];for(let s of e)P(s)==="True"?t++:P(s)==="False"||r.push(s);let i=[];for(let s of r){let u=i.findIndex(a=>a.isSame(s));u>=0?i.splice(u,1):i.push(s)}let o=t%2===1;if(i.length===0)return o?n.True:n.False;if(i.length===1)return o?n._fn("Not",[i[0]]):i[0];if(i.length!==r.length)return n._fn("Xor",o?[n.True,...i]:i)}function iy(e,{engine:n}){if(e.length===0)return n.False;for(let r of e)if(P(r)==="False")return n.True;if(e.some(r=>P(r)==="Missing"))return n.Missing;let t=!0;for(let r of e)if(P(r)!=="True"){t=!1;break}if(t)return n.False}function oy(e,{engine:n}){if(e.length===0)return n.True;for(let r of e)if(P(r)==="True")return n.False;if(e.some(r=>P(r)==="Missing"))return n.Missing;let t=!0;for(let r of e)if(P(r)!=="False"){t=!1;break}if(t)return n.True}function jt(e,n){let t=e.operator;if(!t||P(e)==="True"||P(e)==="False")return e;if(t==="Not"){let r=Ni(e);if(!r)return e;let i=r.operator;if(i==="Not")return jt(Ni(r),n);if(i==="And"){let o=Tt(r).map(s=>jt(n._fn("Not",[s]),n));return n._fn("Or",o)}if(i==="Or"){let o=Tt(r).map(s=>jt(n._fn("Not",[s]),n));return n._fn("And",o)}if(P(r)==="True")return n.False;if(P(r)==="False")return n.True;if(i==="Implies"){let o=Ni(r),s=O1(r);return jt(n._fn("And",[o,n._fn("Not",[s])]),n)}if(i==="Equivalent"){let o=Ni(r),s=O1(r);return jt(n._fn("Or",[n._fn("And",[o,n._fn("Not",[s])]),n._fn("And",[n._fn("Not",[o]),s])]),n)}if(i==="Xor"){let o=Tt(r);if(o.length===2){let s=o[0],u=o[1];return jt(n._fn("Or",[n._fn("And",[s,u]),n._fn("And",[n._fn("Not",[s]),n._fn("Not",[u])])]),n)}return jt(n._fn("Not",[jt(r,n)]),n)}return i==="Nand"?jt(n._fn("And",Tt(r)),n):i==="Nor"?jt(n._fn("Or",Tt(r)),n):e}if(t==="Implies"){let r=Ni(e),i=O1(e);return jt(n._fn("Or",[n._fn("Not",[r]),i]),n)}if(t==="Equivalent"){let r=Ni(e),i=O1(e);return jt(n._fn("And",[n._fn("Or",[n._fn("Not",[r]),i]),n._fn("Or",[n._fn("Not",[i]),r])]),n)}if(t==="Xor"){let r=Tt(e);if(r.length===2){let i=r[0],o=r[1];return jt(n._fn("And",[n._fn("Or",[i,o]),n._fn("Or",[n._fn("Not",[i]),n._fn("Not",[o])])]),n)}if(r.length>2){let i=n._fn("Xor",[r[0],r[1]]),o=r.slice(2);return jt(n._fn("Xor",[i,...o]),n)}return r.length===1?jt(r[0],n):n.False}if(t==="Nand"){let r=Tt(e);return jt(n._fn("Not",[n._fn("And",r)]),n)}if(t==="Nor"){let r=Tt(e);return jt(n._fn("Not",[n._fn("Or",r)]),n)}if(t==="And"||t==="Or"){let r=Tt(e).map(i=>jt(i,n));return n._fn(t,r)}return e}function kR(e,n){let t=e.operator;if(t!=="Or")return t==="And"?n._fn("And",Tt(e).map(l=>kR(l,n))):e;let r=[];for(let l of Tt(e))l.operator==="Or"?r.push(...Tt(l)):r.push(l);let i=r.findIndex(l=>l.operator==="And");if(i===-1)return e;let o=r[i],s=[...r.slice(0,i),...r.slice(i+1)],u=s.length===1?s[0]:n._fn("Or",s),a=n._fn("And",Tt(o).map(l=>n._fn("Or",[l,u])));return kR(a,n)}function X4(e,n){let t=jt(e,n);return kR(t,n).simplify()}function MR(e,n){let t=e.operator;if(t!=="And")return t==="Or"?n._fn("Or",Tt(e).map(l=>MR(l,n))):e;let r=[];for(let l of Tt(e))l.operator==="And"?r.push(...Tt(l)):r.push(l);let i=r.findIndex(l=>l.operator==="Or");if(i===-1)return e;let o=r[i],s=[...r.slice(0,i),...r.slice(i+1)],u=s.length===1?s[0]:n._fn("And",s),a=n._fn("Or",Tt(o).map(l=>n._fn("And",[l,u])));return MR(a,n)}function eV(e,n){let t=jt(e,n);return MR(t,n).simplify()}function Ol(e){let n=new Set;function t(r){if(!(P(r)==="True"||P(r)==="False")){if(C(r)&&r.operator==="Symbol"){n.add(r.symbol);return}if(g(r))for(let i of r.ops)t(i)}}return t(e),Array.from(n).sort()}function Pl(e,n,t){let r={};for(let[o,s]of Object.entries(n))r[o]=s?t.True:t.False;return e.subs(r).canonical.evaluate()}function*Dl(e){let n=e.length,t=1<<n;for(let r=0;r<t;r++){let i={};for(let o=0;o<n;o++)i[e[o]]=(r>>n-1-o&1)===1;yield i}}function Ose(e,n,t,r){return e.filter(i=>{let s=t.subs({[n]:i}).evaluate();return P(s)==="True"})}function ts(e,n){if(e.operator!=="Element")return{status:"error",reason:"expected-element-expression"};if(!g(e))return{status:"error",reason:"expected-element-expression"};let t=C(e.op1)?e.op1.symbol:void 0;if(!t)return{status:"error",reason:"expected-index-variable"};let r=e.op2;if(!r)return{status:"error",reason:"expected-domain"};let i=e.op3,o=e.nops>=3&&i&&P(i)!=="Nothing"?i:null,s=a=>{if(o){let l=Ose(a,t,o,n);return{status:"success",variable:t,values:l}}return{status:"success",variable:t,values:a}};if(r.operator==="Set"||r.operator==="List"){let a=g(r)?r.ops:void 0;if(a&&a.length<=1e3){if(r.operator==="List"&&a.length===2){let l=ae(a[0]),f=ae(a[1]);if(l!==null&&f!==null){let c=f-l+1;if(c>0&&c<=1e3){let d=[];for(let p=l;p<=f;p++)d.push(n.number(p));return s(d)}if(c>1e3)return{status:"non-enumerable",variable:t,domain:r,reason:"domain-too-large"}}}return s([...a])}return a&&a.length>1e3?{status:"non-enumerable",variable:t,domain:r,reason:"domain-too-large"}:{status:"error",reason:"empty-domain"}}if(g(r,"Range")){let a=ae(r.op1),l=ae(r.op2),f=r.ops.length>=3?ae(r.op3):1;if(a!==null&&l!==null&&f!==null&&f!==0){let c=Math.floor((l-a)/f)+1;if(c>0&&c<=1e3){let d=[];for(let p=a;f>0?p<=l:p>=l;p+=f)d.push(n.number(p));return s(d)}if(c>1e3)return{status:"non-enumerable",variable:t,domain:r,reason:"domain-too-large"}}return{status:"non-enumerable",variable:t,domain:r,reason:"non-integer-bounds"}}if(g(r,"Interval")){let a=r.op1,l=r.op2,f=!1,c=!1;g(a,"Open")?(f=!0,a=a.op1):g(a,"Closed")&&(a=a.op1),g(l,"Open")?(c=!0,l=l.op1):g(l,"Closed")&&(l=l.op1);let d=ae(a),p=ae(l);if(d!==null&&p!==null){f&&(d+=1),c&&(p-=1);let m=p-d+1;if(m>0&&m<=1e3){let h=[];for(let y=d;y<=p;y++)h.push(n.number(y));return s(h)}if(m>1e3)return{status:"non-enumerable",variable:t,domain:r,reason:"domain-too-large"}}return{status:"non-enumerable",variable:t,domain:r,reason:"non-integer-bounds"}}let u=P(r);if(u){if(["Integers","NonNegativeIntegers","PositiveIntegers","NegativeIntegers","Rationals","Reals","PositiveReals","NonNegativeReals","NegativeReals","NonPositiveReals","ExtendedReals","Complexes","ImaginaryNumbers","Numbers","ExtendedComplexes","AlgebraicNumbers","TranscendentalNumbers"].includes(u))return{status:"non-enumerable",variable:t,domain:r,reason:"infinite-domain"};let l=r.value;if(l&&l.operator==="Set"&&g(l)){let f=l.ops;if(f&&f.length<=1e3)return s([...f]);if(f&&f.length>1e3)return{status:"non-enumerable",variable:t,domain:r,reason:"domain-too-large"}}return{status:"non-enumerable",variable:t,domain:r,reason:"unknown-domain"}}return{status:"non-enumerable",variable:t,domain:r,reason:"unrecognized-domain-type"}}function B1(e,n){if(P(e)===n)return!0;if(g(e)){for(let t of e.ops)if(B1(t,n))return!0}return!1}function V1(e,n){let t=e.canonical,r=t.operator;if(r!=="ForAll"&&r!=="Exists")return[];if(!g(t))return[];let i=t.op1,o=t.op2;if(!i||!o)return[];let s=ts(i,n);if(s.status!=="success")return[];let u=V1(o,n);return[{variable:s.variable,values:s.values},...u]}function j1(e){let n=e.canonical,t=n.operator;if((t==="ForAll"||t==="Exists")&&g(n)){let r=n.op2;if(r)return j1(r)}return n}function tV(e,n,t){let r=e.map(()=>0),i=e.map(o=>o.values.length);if(i.some(o=>o===0))return t.True;for(;;){let o={};for(let l=0;l<e.length;l++)o[e[l].variable]=e[l].values[r[l]];let u=n.subs(o).canonical.evaluate();if(P(u)==="False")return t.False;if(P(u)!=="True")return;let a=e.length-1;for(;a>=0&&(r[a]++,!(r[a]<i[a]));)r[a]=0,a--;if(a<0)break}return t.True}function rV(e,n,t){let r=e.map(()=>0),i=e.map(o=>o.values.length);if(i.some(o=>o===0))return t.False;for(;;){let o={};for(let l=0;l<e.length;l++)o[e[l].variable]=e[l].values[r[l]];let u=n.subs(o).canonical.evaluate();if(P(u)==="True")return t.True;let a=e.length-1;for(;a>=0&&(r[a]++,!(r[a]<i[a]));)r[a]=0,a--;if(a<0)break}return t.False}function iV(e,n){let t=Ol(e);if(t.length===0){let r=e.evaluate();return P(r)==="True"?n.True:n.False}if(t.length>20)return n._fn("IsSatisfiable",[e]);for(let r of Dl(t)){let i=Pl(e,r,n);if(P(i)==="True")return n.True}return n.False}function oV(e,n){let t=Ol(e);if(t.length===0){let r=e.evaluate();return P(r)==="True"?n.True:n.False}if(t.length>20)return n._fn("IsTautology",[e]);for(let r of Dl(t)){let i=Pl(e,r,n);if(P(i)!=="True")return n.False}return n.True}function sV(e,n){let t=Ol(e);if(t.length>10)return n._fn("TruthTable",[e]);let r=[],i=n._fn("List",[...t.map(o=>n.string(o)),n.string("Result")]);r.push(i);for(let o of Dl(t)){let s=Pl(e,o,n),u=n._fn("List",[...t.map(a=>o[a]?n.True:n.False),s]);r.push(u)}return n._fn("List",r)}function Pse(e,n){let t=[];for(let r=n-1;r>=0;r--)t.push(e>>r&1);return t}function Dse(e){return e.filter(n=>n===1).length}function Fse(e,n){let t=-1;for(let r=0;r<e.length;r++)if(e[r]===-1||n[r]===-1){if(e[r]!==n[r])return-1}else if(e[r]!==n[r]){if(t!==-1)return-1;t=r}return t}function Lse(e,n){let t=[...e];return t[n]=-1,t}function nV(e){return e.map(n=>n===-1?"-":n.toString()).join("")}function uV(e,n){let t=Ol(e);if(t.length>12)return null;if(t.length===0){let s=e.evaluate();return P(s)==="True"?[n.True]:P(s)==="False"?[]:null}let r=[],i=0;for(let s of Dl(t)){let u=Pl(e,s,n);P(u)==="True"&&r.push(i),i++}return r.length===0?[]:r.length===1<<t.length?[n.True]:q1(r,t.length).map(s=>OR(s,t,n))}function aV(e,n){let t=Ol(e);if(t.length>12)return null;if(t.length===0){let s=e.evaluate();return P(s)==="True"?[]:P(s)==="False"?[n.False]:null}let r=[],i=0;for(let s of Dl(t)){let u=Pl(e,s,n);P(u)==="False"&&r.push(i),i++}return r.length===0?[]:r.length===1<<t.length?[n.False]:q1(r,t.length).map(s=>PR(s,t,n))}function q1(e,n){let t=new Map;for(let i of e){let o=Pse(i,n);t.set(nV(o),{term:o,combined:!1})}let r=[];for(;t.size>0;){let i=new Map,o=new Map;for(let[u,{term:a}]of t){let l=Dse(a);o.has(l)||o.set(l,[]),o.get(l).push({key:u,term:a})}let s=Array.from(o.keys()).sort((u,a)=>u-a);for(let u=0;u<s.length-1;u++){let a=o.get(s[u]),l=o.get(s[u+1]);for(let{key:f,term:c}of a)for(let{key:d,term:p}of l){let m=Fse(c,p);if(m!==-1){let h=t.get(f),y=t.get(d);h.combined=!0,y.combined=!0;let b=Lse(c,m),v=nV(b);i.has(v)||i.set(v,{term:b,combined:!1})}}}for(let{term:u,combined:a}of t.values())a||r.push(u);t=i}return r}function OR(e,n,t){let r=[];for(let i=0;i<e.length;i++)e[i]===1?r.push(t.symbol(n[i])):e[i]===0&&r.push(t._fn("Not",[t.symbol(n[i])]));return r.length===0?t.True:r.length===1?r[0]:t._fn("And",r)}function PR(e,n,t){let r=[];for(let i=0;i<e.length;i++)e[i]===0?r.push(t.symbol(n[i])):e[i]===1&&r.push(t._fn("Not",[t.symbol(n[i])]));return r.length===0?t.False:r.length===1?r[0]:t._fn("Or",r)}function lV(e,n){let t=Ol(e);if(t.length>12)return null;if(t.length===0){let u=e.evaluate();return P(u)==="True"?n.True:n.False}let r=[],i=0;for(let u of Dl(t)){let a=Pl(e,u,n);P(a)==="True"&&r.push(i),i++}if(r.length===0)return n.False;if(r.length===1<<t.length)return n.True;let o=q1(r,t.length),s=cV(o,r,t.length);return s.length===0?n.False:s.length===1?OR(s[0],t,n):n._fn("Or",s.map(u=>OR(u,t,n)))}function fV(e,n){let t=Ol(e);if(t.length>12)return null;if(t.length===0){let u=e.evaluate();return P(u)==="True"?n.True:n.False}let r=[],i=0;for(let u of Dl(t)){let a=Pl(e,u,n);P(a)==="False"&&r.push(i),i++}if(r.length===0)return n.True;if(r.length===1<<t.length)return n.False;let o=q1(r,t.length),s=cV(o,r,t.length);return s.length===0?n.True:s.length===1?PR(s[0],t,n):n._fn("And",s.map(u=>PR(u,t,n)))}function L1(e,n){let t=[],r=[];for(let s=0;s<e.length;s++)e[s]===-1&&r.push(s);let i=r.length,o=1<<i;for(let s=0;s<o;s++){let u=0;for(let a=0;a<n;a++){let l=r.indexOf(a),f;l!==-1?f=s>>i-1-l&1:f=e[a],u=u<<1|f}t.push(u)}return t}function cV(e,n,t){let r=new Set(n),i=[],o=new Map;for(let u of n)o.set(u,[]);for(let u=0;u<e.length;u++){let a=L1(e[u],t);for(let l of a)o.has(l)&&o.get(l).push(u)}let s=new Set;for(let[u,a]of o)if(a.length===1&&r.has(u)){let l=a[0];if(!s.has(l)){s.add(l),i.push(e[l]);let f=L1(e[l],t);for(let c of f)r.delete(c)}}for(;r.size>0;){let u=-1,a=0;for(let f=0;f<e.length;f++){if(s.has(f))continue;let d=L1(e[f],t).filter(p=>r.has(p)).length;d>a&&(a=d,u=f)}if(u===-1)break;s.add(u),i.push(e[u]);let l=L1(e[u],t);for(let f of l)r.delete(f)}return i}function z1(e){let n=!1;for(let t of e){if(t===!0)return!0;t===void 0&&(n=!0)}return n?void 0:!1}function Co(e){let n=!1;for(let t of e){if(t===!1)return!1;t===void 0&&(n=!0)}return n?void 0:!0}function U1(e){return e===void 0?void 0:!e}function DR(e,n){let t=!1;for(let r=0;r<e.length;r++){let i=n(e[r],r);if(i===!1)return!1;i===void 0&&(t=!0)}return t?void 0:!0}function dV(e){return e?._kind==="number"}function Bse(e){return e?._kind==="symbol"}function iu(e,n){return e?._kind==="function"&&(n===void 0||e.operator===n)}function pV(e){if(!iu(e,"Interval"))return[NaN,NaN];let n=e.op1,t=e.op2;return(iu(n,"Open")||iu(n,"Closed"))&&(n=n.op1),(iu(t,"Open")||iu(t,"Closed"))&&(t=t.op1),[n.re,t.re]}function ii(e){if(iu(e,"Interval")){let n=e.op1,t=e.op2,r=!1,i=!1;iu(n,"Open")?(r=!0,n=n.op1):iu(n,"Closed")&&(n=n.op1),iu(t,"Open")?(i=!0,t=t.op1):iu(t,"Closed")&&(t=t.op1);let o=n.N(),s=t.N();return!dV(o)||!dV(s)?void 0:{start:o.re,openStart:r,end:s.re,openEnd:i}}if(Bse(e)){if(e.symbol==="EmptySet")return{start:0,openStart:!0,end:0,openEnd:!0};if(e.symbol==="RealNumbers")return{start:-1/0,openStart:!1,end:1/0,openEnd:!1};if(e.symbol==="NegativeNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!0};if(e.symbol==="NonPositiveNumbers")return{start:-1/0,openStart:!1,end:0,openEnd:!1};if(e.symbol==="PositiveNumbers")return{start:0,openStart:!0,end:1/0,openEnd:!1};if(e.symbol==="NonNegativeNumbers")return{start:0,openStart:!1,end:1/0,openEnd:!1}}}function mV(e,n){return!((e.openStart?n<=e.start:n<e.start)||(e.openEnd?n>=e.end:n>e.end))}function qt(e,n,t){if(e.jit!=="off")try{return e._compile(n,{...t,fallback:!1,entryChecks:!1})}catch(r){if(r instanceof EvalError){e.jit="off";return}if(r instanceof Ne)throw r;return}}function qp(e,n){let t=qt(e,n);if(!t?.success||typeof t.run!="function")return;let r=t.run;return i=>{let o=r(i);return typeof o=="number"?o:NaN}}function Vse(e,n){let t=n.operatorDefinition;if(t)return t.pure===!1;let r=e.lookupDefinition(n.operator);return r&&"operator"in r?r.operator.pure===!1:!1}function jse(e,n){let t=gl(e);if(t===void 0)return!1;let r=gV(n);return r===void 0?!1:O(r,t)}function gV(e){if(e===void 0)return;let n=e.isCanonical?e:e.canonical,t=Z(se(n.type.type));if(!(t===void 0||t==="unknown"||t==="any"))return t}function H1(e){if(!g(e,"Map")||e.nops<2)return"";let n="";for(let t of e.ops.slice(1)){let r=gV(t);n+=(r===void 0?"?":re(r))+"|"}return n}function zp(e){if(!g(e,"Map")||e.nops<2)return!1;let n=e.op1;return g(n,"Function")?n.ops.slice(1).some(t=>g(t,"Typed")):!1}function Up(e){if(!g(e,"Map")||e.nops<2)return;let n=e.op1;if(!g(n,"Function"))return;let t=n.ops.slice(1),r=e.ops.slice(1),i=r.length;if(t.length!==i)return;let o=[],s=!1;for(let d=0;d<t.length;d++){let p=t[d];if(g(p,"Typed")){if(!jse(p,r[d]))return;s=!0,p=p.op1}if(!C(p))return;let m=P(p);if(m===void 0)return;o.push(m)}let u=n.ops[0];if(u===void 0)return;let a;if(g(u,"Block")){if(u.nops!==1)return;a=u.localScope??void 0,u=u.op1}let l=!1,f=!1;if(g(u,"N")&&u.nops===1&&(f=!0,u=u.op1),C(u)){let d=o.indexOf(P(u)??"");return d<0?void 0:f?{expr:e,identity:!1,op:"N",slots:[d],napprox:f,arity:i,sources:r,typeSensitive:s}:{expr:e,identity:!0,slots:[d],napprox:f,arity:i,sources:r,typeSensitive:s}}if(!g(u)||Vse(e.engine,u))return;let c=[];for(let d of u.ops){if(C(d)){let m=o.indexOf(P(d)??"");if(m>=0){c.push(m);continue}}if(d.has(o))return;let p=d.isCanonical?d:d.canonical;p.symbols.length>0&&(l=!0),c.push(p)}return{expr:e,identity:!1,op:u.operator,slots:c,napprox:f,arity:i,sources:r,closureScope:l?a:void 0,typeSensitive:s}}var vV=64,hV=32;function Tc(e){if(e===void 0||!T(e)||e.im!==0||!e.isExact)return;let n=e.re;return Number.isSafeInteger(n)?n:void 0}function No(e,n){if(!(!Number.isSafeInteger(e)||!Number.isSafeInteger(n))&&!(e>n))return{lo:e,hi:n}}function qse(e){return Math.max(Math.abs(e.lo),Math.abs(e.hi))}function zse(e,n){if(n.length!==0)switch(e){case"Add":{let t=n[0];for(let r=1;r<n.length;r++){let i=No(t.lo+n[r].lo,t.hi+n[r].hi);if(i===void 0)return;t=i}return t}case"Negate":return n.length!==1?void 0:No(-n[0].hi,-n[0].lo);case"Subtract":return n.length!==2?void 0:No(n[0].lo-n[1].hi,n[0].hi-n[1].lo);case"Multiply":{let t=n[0];for(let r=1;r<n.length;r++){let i=n[r],o=[t.lo*i.lo,t.lo*i.hi,t.hi*i.lo,t.hi*i.hi];if(!o.every(u=>Number.isSafeInteger(u)))return;let s=No(Math.min(...o),Math.max(...o));if(s===void 0)return;t=s}return t}case"Mod":{if(n.length!==2)return;let t=n[1];return!(t.lo>0||t.hi<0)||!Number.isSafeInteger(2*qse(t))?void 0:t.lo>0?No(0,t.hi-1):No(t.lo+1,0)}case"Min":return No(Math.min(...n.map(t=>t.lo)),Math.min(...n.map(t=>t.hi)));case"Max":return No(Math.max(...n.map(t=>t.lo)),Math.max(...n.map(t=>t.hi)));case"Floor":case"Ceil":case"Round":case"Truncate":return n.length!==1?void 0:n[0];case"Abs":{if(n.length!==1)return;let t=n[0];return t.lo>=0?t:t.hi<=0?No(-t.hi,-t.lo):No(0,Math.max(-t.lo,t.hi))}default:return}}function Use(e){if(!g(e,"Range"))return;let n=e.ops,t,r,i=1;if(n.length===1)t=1,r=Tc(n[0]);else if(n.length===2||n.length===3){if(t=Tc(n[0]),r=Tc(n[1]),n.length===3){let l=Tc(n[2]);if(l===void 0||l===0)return;i=l}}else return;if(t===void 0||r===void 0)return;let o=r-t;if(!Number.isSafeInteger(o))return;let s=i>0?o>=0?Math.floor(o/i)+1:0:o<=0?Math.floor(-o/-i)+1:0;if(s===0)return{interval:{lo:0,hi:0},count:0};let u=t+(s-1)*i;if(!Number.isSafeInteger(u))return;let a=No(Math.min(t,u),Math.max(t,u));return a===void 0?void 0:{interval:a,count:s}}function Hse(e){if(!g(e,"List"))return;if(e.nops===0)return{interval:{lo:0,hi:0},count:0};let n=1/0,t=-1/0;for(let i of e.ops){let o=Tc(i);if(o===void 0)return;o<n&&(n=o),o>t&&(t=o)}let r=No(n,t);return r===void 0?void 0:{interval:r,count:e.nops}}function EV(e,n){if(g(n,"Range"))return Use(n);if(g(n,"List"))return Hse(n);if(g(n,"Map")){if(e.depth>=hV)return;zp(n)&&e.typeExprs.push(n);let t=Up(n);if(t===void 0)return;e.depth++;let r=xV(e,t);return e.depth--,r}if(C(n)){if(e.dynamic=!0,e.depth>=hV)return;let t=e.ce._getSymbolValue(n.symbol);if(t===void 0)return;e.depth++;let r=EV(e,t);return e.depth--,r}}function Gse(e,n){let t=Tc(n);if(t!==void 0)return t;if(C(n)){e.dynamic=!0;let r=e.ce._getSymbolValue(n.symbol);return r===void 0?void 0:Tc(r)}}var Wse="_mapExactCompileProbe_";function Yse(e,n,t,r){e.pushScope();try{let i=[];for(let u=0;u<r;u++){let a=`${Wse}${u}`;e.declare(a,"integer"),i.push(e.symbol(a))}let o=t.map(u=>"param"in u?i[u.param]:e.number(u.value));if(o.some(u=>u===void 0))return!1;let s=e.function(n,o);return s.isValid?s.type.matches("integer"):!1}catch{return!1}finally{e.popScope()}}function xV(e,n,t){if(n.napprox||n.identity)return;let r=n.op,i=n.slots;if(r===void 0||i===void 0)return;let o=[];for(let l of n.sources){let f=EV(e,l);if(f===void 0)return;o.push(f)}if(o.length!==n.arity)return;t!==void 0&&t.push(...o);let s=[],u=[];for(let l of i)if(typeof l=="number"){let f=o[l];if(f===void 0)return;s.push(f.interval),u.push({param:l})}else{let f=Gse(e,l);if(f===void 0)return;s.push({lo:f,hi:f}),u.push({value:f})}let a=zse(r,s);if(a!==void 0&&Yse(e.ce,r,u,n.arity))return{interval:a,count:Math.min(...o.map(l=>l.count))}}function yV(e){let n="";for(let t of e)n+=H1(t)+";";return n}var bV=new WeakMap;function FR(e,n){let t=e._factsHidden(),r=bV.get(n),i=r?.factsHidden===t?r:void 0;if(i!==void 0){if(!i.dynamic&&i.typeExprs.length===0||i.generation===e._semanticVersion)return i.shape;if(!i.dynamic&&yV(i.typeExprs)===i.typeKey)return i.generation=e._semanticVersion,i.shape}let o={ce:e,dynamic:!1,typeExprs:zp(n)?[n]:[],depth:0},s=g(n,"Map")?Up(n):void 0,u=[],a=s===void 0?void 0:xV(o,s,u),l=a===void 0||s===void 0||!g(n,"Map")?void 0:{level:s,fn:n.op1,sourceBounds:u.map(f=>f.interval),count:a.count};return bV.set(n,{shape:l,dynamic:o.dynamic,typeExprs:o.typeExprs,typeKey:yV(o.typeExprs),generation:e._semanticVersion,factsHidden:t}),l}var Fl=new WeakMap;function Zse(e){if(!g(e,"Map")||e.nops<2)return;let n=e.op1;if(!g(n,"Function")||n.nops<1)return;let t=n.op1;if(g(t,"Block")&&t.nops===1&&(t=t.op1),!(!g(t,"N")||t.nops!==1))return{fn:n,inner:t.op1}}function LR(e){return e!==void 0&&T(e)&&e.im===0&&Number.isFinite(e.re)}var SV=1e5;function _V(e,n){let t=e.lookupDefinition(n);if(t&&"operator"in t){let i=t.operator._lambdaLiteral;if(i!==void 0&&g(i,"Function"))return i}let r=e._getSymbolValue(n);if(r!==void 0&&g(r,"Function"))return r}function ou(e,n,t,r){if(C(n)){let o=n.symbol;if(t.has(o)||r.has(o))return!0;let s=_V(e,o);return s===void 0?!0:(r.add(o),VR(e,s,r))}if(!g(n))return!0;let i=n.operator;if(i==="Assign"){let o=n.op1;return!C(o)||!t.has(o.symbol)?!1:ou(e,n.op2,t,r)}if(i==="Sum"||i==="Product"){let o=new Set(t);for(let s of n.ops.slice(1)){if(!g(s,"Limits")||!LR(s.op2)||!LR(s.op3)||s.op3.re-s.op2.re+1>SV)return!1;C(s.op1)&&o.add(s.op1.symbol)}return n.nops<2?!1:ou(e,n.op1,o,r)}if(i==="Loop"){if(n.nops<2)return!1;let o=n.op2;if(g(o,"Range")){if(!o.ops.every(l=>LR(l)))return!1;let[s,u,a]=o.nops===1?[1,o.op1.re,1]:[o.op1.re,o.op2.re,o.nops>2?o.op3.re:1];if(a===0||(u-s)/a+1>SV)return!1}else if(!g(o,"List")&&!g(o,"Tuple"))return!1;return ou(e,n.op1,t,r)}if(i==="Block"||i==="Declare"||i==="Function"){let o=new Set(t);if(i==="Declare")return C(n.op1)&&o.add(n.op1.symbol),n.ops.slice(1).every(s=>ou(e,s,o,r));if(i==="Function"){for(let s of n.ops.slice(1)){let u=Te(s);u&&o.add(u)}return ou(e,n.op1,o,r)}for(let s of n.ops)if(g(s,"Declare")&&C(s.op1)){if(!s.ops.slice(1).every(u=>ou(e,u,o,r)))return!1;o.add(s.op1.symbol)}else if(g(s,"Assign")&&C(s.op1)){if(!o.has(s.op1.symbol)||!ou(e,s.op2,o,r))return!1}else if(!ou(e,s,o,r))return!1;return!0}if(!t.has(i)&&!r.has(i)){let o=_V(e,i);if(o!==void 0&&(r.add(i),!VR(e,o,r)))return!1}return n.ops.every(o=>ou(e,o,t,r))}function VR(e,n,t){if(!g(n))return!1;let r=new Set;for(let i of n.ops.slice(1)){let o=Te(i);o&&r.add(o)}return ou(e,n.ops[0],r,t)}function wV(e,n){let t=Fr(n,e.context.lexicalScope),r=t!==void 0&&J(t)?t.value:void 0;return{name:n,binding:t,valueDef:r,version:r?._writeVersion??0,operatorDef:t!==void 0&&"operator"in t?t.operator:void 0}}function CV(e,n){let t=Fr(n.name,e.context.lexicalScope);if(t!==n.binding)return!0;let r=t!==void 0&&J(t)?t.value:void 0;return!!(r!==n.valueDef||r&&r._writeVersion!==n.version||(t!==void 0&&"operator"in t?t.operator:void 0)!==n.operatorDef)}function Jse(e,n){if(n.generation===e._semanticVersion&&n.tolerance===e.tolerance&&n.angularUnit===e.angularUnit)return!0;if(ni.revalidations++,n.tolerance!==e.tolerance||n.angularUnit!==e.angularUnit||n.epoch!==e._worldVersion)return!1;for(let t of n.deps??[])if(CV(e,t))return!1;return n.generation=e._semanticVersion,!0}function BR(e,n,t,r){ni.attempts++;let i=d=>({state:"no-compile",tier:n,reason:d,generation:e._semanticVersion,epoch:e._worldVersion,tolerance:e.tolerance,angularUnit:e.angularUnit}),o;if(n==="marked"){if(!VR(e,t,new Set))return i("structural");let d=t.json;if(r===void 0||!Array.isArray(d)||(o=e.box(["Function",r.json,...d.slice(2)]),!o.isValid))return i("structural")}else o=t;let s=new Set,u=new Set,a=qt(e,o,{symbolDeps:s,varsObjectRefs:u}),l=a?.freeSymbols!==void 0&&a.freeSymbols.length>0?a.freeSymbols:[...u];if(l.length>0&&e.jit!=="off")return i(wV(e,l[0]));if(a===void 0)return e.jit==="off"?void 0:i("structural");if(a.calling!=="lambda"||typeof a.run!="function"||a.unsupported!==void 0&&a.unsupported.length>0)return i("structural");let f=e.context.lexicalScope,c=g(t)&&t.isScoped?t.localScope:void 0;if(c!==void 0){for(let d of s)if(Fr(d,c)!==Fr(d,f))return i("structural")}return{state:"compiled",tier:n,fn:a.run,deps:[...s].map(d=>wV(e,d)),generation:e._semanticVersion,epoch:e._worldVersion,tolerance:e.tolerance,angularUnit:e.angularUnit}}function Hp(e,{drainStart:n=!1}={}){let t=e.engine;if(t.jit==="off"||t._factsHidden())return;let r=Zse(e),i,o,s,u=[];if(r!==void 0){if(Zn(t))return;i="marked",o=r.fn,s=r.inner}else{let d=FR(t,e);if(d===void 0||d.count<vV)return;i="exact",o=d.fn,s=void 0,u=d.sourceBounds}let a=Fl.get(e);if(n&&a&&(a.attemptedThisDrain=!1),a?.state==="no-compile"&&(a.reason==="structural"||a.reason==="abi"))return;let l=()=>i!=="exact"||FR(t,e)!==void 0,f=()=>{if(t.jit==="off")return;let d=Fl.get(e);if(d?.state==="compiled"){if(Jse(t,d))return d;if(!l()){Fl.delete(e);return}ni.recompiles++;let m=BR(t,i,o,s);if(m===void 0){Fl.delete(e);return}return m.attemptedThisDrain=d.attemptedThisDrain,Fl.set(e,m),m.state==="compiled"?m:void 0}if(d?.state==="no-compile"){let m=d.reason;if(m==="structural"||m==="abi"||m===void 0||!CV(t,m)||d.attemptedThisDrain||!l())return;d.attemptedThisDrain=!0;let h=BR(t,i,o,s);if(h===void 0){Fl.delete(e);return}return h.attemptedThisDrain=!0,Fl.set(e,h),h.state==="compiled"?h:void 0}if(!l())return;let p=BR(t,i,o,s);if(p!==void 0)return p.attemptedThisDrain=!0,Fl.set(e,p),p.state==="compiled"?p:void 0},c=0;return d=>{(++c&255)===0&&ee(t._deadlineFrame);let p=f();if(p?.state!=="compiled"||p.fn===void 0)return;let m=[];for(let E=0;E<d.length;E++){let x=d[E];if(!T(x)){ni.elementFallbacks++;return}if(i==="exact"){let S=u[E];if(S===void 0||x.im!==0||!x.isExact||!Number.isSafeInteger(x.re)||x.re<S.lo||x.re>S.hi){ni.elementFallbacks++;return}}m.push(x.im!==0?{re:x.re,im:x.im}:x.re)}let h=t._randomFrame,y=h?.next??0,b=()=>{h!==void 0&&(h.next=y)},v=p.fn(...m);if(typeof v=="number"){if(Number.isNaN(v))return ni.nanDoubleChecks++,b();if(i==="exact"){if(Number.isSafeInteger(v))return ni.compiledHits++,t.number(v)}else return ni.compiledHits++,t.number(v)}if(i!=="exact"&&typeof v=="object"&&v!==null&&"re"in v&&"im"in v){let E=v.re,x=v.im;if(typeof E=="number"&&typeof x=="number")return Number.isNaN(E)||Number.isNaN(x)?(ni.nanDoubleChecks++,b()):(ni.compiledHits++,t.number(x===0?E:t.complex(E,x)))}return p.state="no-compile",p.reason="abi",p.fn=void 0,p.deps=void 0,ni.elementFallbacks++,b()}}var NV=new WeakMap;function RV(e){let n="";for(let t of e)n+=H1(t)+";";return n}function jR(e){let n=e.engine,t=n._factsHidden(),r=NV.get(e),i=r?.factsHidden===t?r:void 0;if(i!==void 0){if(i.typeExprs.length===0||i.generation===n._semanticVersion)return i.spine??void 0;if(RV(i.typeExprs)===i.typeKey)return i.generation=n._semanticVersion,i.spine??void 0}let o=[];zp(e)&&o.push(e);let s=c=>{NV.set(e,{spine:c,typeExprs:o,typeKey:RV(o),generation:n._semanticVersion,factsHidden:t})},u=Up(e);if(!u){s(null);return}let a=[u],l;for(;;){if(u.arity!==1){l=[...u.sources];break}let c=u.sources[0];zp(c)&&o.push(c);let d=Up(c);if(!d){l=[c];break}a.push(d),u=d}a.reverse();let f={bases:l,levels:a};return s(f),f}function AV(e){for(let n of e){let t=gt(n);if(t!==void 0)return t}}function qR(e,n,t){let r=n.levels,i=r.map(o=>Hp(o.expr,{drainStart:!0}));return o=>{let s=o,u=!1;for(let a=0;a<r.length;a++){let l=r[a],f=AV(s),c;if(f===void 0&&(c=i[a]?.(s)),f===void 0&&c===void 0){let d=!1;if(u||(s=s.map(p=>p.evaluate()),u=!0,f=AV(s),d=f===void 0&&e.strict&&s.some(p=>p.isValid===!1)),f===void 0&&!d)if(l.identity)c=s[l.slots[0]];else{let p=l.slots,m=[];for(let b of p)m.push(typeof b=="number"?s[b]:b);let h=l.napprox?{numericApproximation:!0}:void 0,y=l.closureScope?.parent;if(y){e.pushScope(y);try{c=e._fn(l.op,m).evaluate(h)}finally{e.popScope()}}else c=e._fn(l.op,m).evaluate(h)}}if(f!==void 0){s=[f],u=!0;continue}if((c===void 0||c.isValid===!1)&&(c=t(l.expr),c===void 0))return;s=[c],u=!0}return s[0]}}function W1(e){let n={bucket:void 0,complexNumber:!1},t=se(e);return typeof t=="object"&&t.kind==="value"&&typeof t.value=="boolean"?{bucket:"boolean",complexNumber:!1}:typeof t=="string"?t==="nothing"?{bucket:"null",complexNumber:!1}:t==="boolean"?{bucket:"boolean",complexNumber:!1}:t==="string"?{bucket:"string",complexNumber:!1}:t==="never"||t==="unknown"||t==="any"?n:O(t,"real")?{bucket:"number",complexNumber:!1}:O(t,"number")?{bucket:"number",complexNumber:!0}:n:t.kind==="tuple"||t.kind==="list"?{bucket:"array",complexNumber:!1}:n}function Kse(e){return e==="nothing"?{shape:"nothing",arity:0}:typeof e=="object"&&e.kind==="tuple"?{shape:"tuple",arity:e.elements.length}:{shape:"value",arity:1}}function G1(e,n){let t;try{t=e._typeResolver.resolve(n)}catch{return}return t===void 0?void 0:_t(t)}function TV(e,n,t){let r=t?._sumOf;if(r===void 0)return;let i=G1(e,r)?._sumVariants;if(i!==void 0)return i.some(o=>o.name===n)?r:void 0}function Y1(e,n){let r=G1(e,n)?._sumVariants;if(r===void 0)return;let i=new Set;for(let o of r){let s=G1(e,o.name)?.def;if(s===void 0)return"tagged";let{bucket:u}=W1(s);if(u===void 0||i.has(u))return"tagged";i.add(u)}return"erased"}function Ea(e,n){let t=G1(e,n),r=TV(e,n,t);if(t===void 0||r===void 0||t.def===void 0)return;let i=Y1(e,r);if(i!==void 0)return{name:n,sum:r,policy:i,...Kse(t.def),...W1(t.def)}}function IV(e,n){let t=r=>{if(typeof r!="string")switch(r.kind){case"reference":{let i=_t(r),o=i._sumVariants!==void 0?r.name:TV(e,r.name,i);if(o!==void 0&&Y1(e,o)==="tagged")return r.name;for(let s of r.args??[]){let u=t(s);if(u!==void 0)return u}return}case"union":case"intersection":for(let i of r.types){let o=t(i);if(o!==void 0)return o}return;case"list":case"collection":case"indexed_collection":case"broadcastable":case"set":return t(r.elements);case"negation":return t(r.type);case"tuple":for(let i of r.elements){let o=t(i.type);if(o!==void 0)return o}return;case"object":case"record":for(let i of Object.values(r.elements)){let o=t(i);if(o!==void 0)return o}return;case"dictionary":return t(r.values);case"signature":return r.result===void 0?void 0:t(r.result);default:return}};return t(n)}function Ri(e,n,t){return n.every(r=>r.isCanonical)?n:n.map(r=>e.expr(r,{scope:t}))}var Qse={lo:-1/0,hi:1/0},kV=4,Gp=22250738585072014e-324;function sy(e,n,t){let r=Math.abs(e);if(!Number.isFinite(r)||r===0||r<10**n&&Number.isInteger(r))return e;if(r>=2**53||r<Gp)return new D(e).toPrecisionToward(n,t).toNumber();let i=10**(n-1),o=10**n,s=Math.floor(Math.log10(r))-(n-1);for(;r<Ic(i,s);)s-=1;for(;r>=Ic(o,s);)s+=1;let u=r/10**s,a;e<0==(t==="floor")?(a=Math.ceil(u),Ic(a-1,s)>=r?a-=1:Ic(a,s)<r&&(a+=1)):(a=Math.floor(u),Ic(a+1,s)<=r?a+=1:Ic(a,s)>r&&(a-=1));let l=Ic(a,s);return e<0?-l:l}function Ic(e,n){return n>=0?n<=22?e*10**n:+`${e}e${n}`:-n<=22?e/10**-n:+`${e}e${n}`}var UR=new Set(["integer","rational","real"]),MV=Symbol("no interval"),$V=new Map,OV=new WeakMap;function pr(e,n){if(n!==void 0)return zR(e,n);let t=typeof e=="string"?$V.get(e):OV.get(e);if(t!==void 0)return t===MV?void 0:t;if(!nL(e))return zR(e);let r=zR(e),i=r===void 0?MV:Object.freeze(r);return typeof e=="string"?$V.set(e,i):OV.set(e,i),r}function zR(e,n){if(typeof e=="string")return UR.has(e)?{...Qse,finite:!0}:void 0;switch(e.kind){case"value":{if(typeof e.value!="number"||Number.isNaN(e.value))return;let t={lo:e.value,hi:e.value};return Number.isFinite(e.value)&&(t.finite=!0),t}case"numeric":{if(!UR.has(e.type))return;let t={lo:e.lower??-1/0,hi:e.upper??1/0};return e.lowerOpen&&(t.loOpen=!0),e.upperOpen&&(t.hiOpen=!0),t.finite=!0,t}case"reference":return!e.alias||e.def===void 0||(n??=new Set,n.has(e))?void 0:(n.add(e),pr(e.def,n));case"intersection":{let t=-1/0,r=1/0,i=!1,o=!1,s=!1,u=!1;for(let l of e.types){let f=pr(l,n);f!==void 0&&(i=!0,f.finite===!0&&(u=!0),f.lo>t?(t=f.lo,o=f.loOpen===!0):f.lo===t&&f.loOpen&&(o=!0),f.hi<r?(r=f.hi,s=f.hiOpen===!0):f.hi===r&&f.hiOpen&&(s=!0))}if(!i||t>r||t===r&&(o||s))return;let a=Ro({lo:t,hi:r},o,s);return u&&(a.finite=!0),a}case"union":{let t=1/0,r=-1/0,i=!0,o=!0,s=!0;for(let a of e.types){let l=pr(a,n);if(l===void 0)return;l.finite!==!0&&(s=!1),l.lo<t?(t=l.lo,i=l.loOpen===!0):l.lo===t&&!l.loOpen&&(i=!1),l.hi>r?(r=l.hi,o=l.hiOpen===!0):l.hi===r&&!l.hiOpen&&(o=!1)}if(t>r)return;let u=Ro({lo:t,hi:r},i,o);return s&&(u.finite=!0),u}default:return}}function PV(e,n,t){let r=e+n;if(Number.isNaN(r))return NaN;if(r===1/0)return Number.isFinite(e)&&Number.isFinite(n)&&t<0?Number.MAX_VALUE:1/0;if(r===-1/0)return Number.isFinite(e)&&Number.isFinite(n)&&t>0?-Number.MAX_VALUE:-1/0;let i=r-e,o=e-(r-i)+(n-i);return t<0?o<0?Er(r):r:o>0?sr(r):r}var DV=134217729;function jV(e,n,t){let r=DV*e,i=r-(r-e),o=e-i,s=DV*n,u=s-(s-n),a=n-u;return o*a-(t-i*u-o*u-i*a)}function Z1(e,n,t){let r=e*n;if(Number.isNaN(r))return NaN;if(r===1/0)return Number.isFinite(e)&&Number.isFinite(n)&&t<0?Number.MAX_VALUE:1/0;if(r===-1/0)return Number.isFinite(e)&&Number.isFinite(n)&&t>0?-Number.MAX_VALUE:-1/0;if(r===0){if(e===0||n===0)return 0;let o=e>0==n>0;return t<0?o?0:-Number.MIN_VALUE:o?Number.MIN_VALUE:0}if(!zV(e,n,r))return t<0?Er(r):sr(r);let i=jV(e,n,r);return t<0?i<0?Er(r):r:i>0?sr(r):r}var qV=new Float64Array(1),Xse=new BigUint64Array(qV.buffer);function HR(e){if(!Number.isFinite(e)||e===0)return!1;qV[0]=Math.abs(e);let n=Xse[0],t=n&(1n<<52n)-1n;return(n>>52n&0x7ffn)===0n?t!==0n&&(t&t-1n)===0n:t===0n}function FV(e,n){if(e===1/0||e===-1/0)return 0;let t=1/e;return t===1/0?n<0?Number.MAX_VALUE:1/0:t===-1/0?n>0?-Number.MAX_VALUE:-1/0:HR(e)?t:n<0?Er(t):sr(t)}function Ro(e,n,t){return n&&Number.isFinite(e.lo)&&(e.loOpen=!0),t&&Number.isFinite(e.hi)&&(e.hiOpen=!0),e}function LV(e,n,t){return Number.isFinite(t)&&t===e+n&&Wp(e,n)}function Wp(e,n){let t=e+n;if(!Number.isFinite(t))return!1;let r=t-e;return e-(t-r)+(n-r)===0}function oi(e,n,t){return!Number.isFinite(t)||t!==e*n?!1:t===0?e===0||n===0:zV(e,n,t)?jV(e,n,t)===0:!1}function zV(e,n,t){let r=Math.abs(t);return r>=Gp&&r<=1e300&&Math.abs(e)<=1e150&&Math.abs(n)<=1e150&&Math.abs(e)>=Gp&&Math.abs(n)>=Gp}function UV(e,n){let t=PV(e.lo,n.lo,-1),r=PV(e.hi,n.hi,1),i={lo:Number.isNaN(t)?-1/0:t,hi:Number.isNaN(r)?1/0:r},o=Ro(i,(e.loOpen||n.loOpen)===!0&&LV(e.lo,n.lo,t),(e.hiOpen||n.hiOpen)===!0&&LV(e.hi,n.hi,r));return e.finite===!0&&n.finite===!0&&(o.finite=!0),o}function eue(e){return J1(Ro({lo:-e.hi,hi:-e.lo},e.hiOpen===!0,e.loOpen===!0),e)}function J1(e,...n){return e.finite!==!0&&n.every(t=>t.finite===!0)&&(e.finite=!0),e}function GR(e,n){let t=1/0,r=-1/0,i=!1,o=!1,s=!0,u=!0,a=(f,c,d,p)=>f===0&&d===0?c&&p:f===0?c:d===0?p:c||p;for(let[f,c,d,p]of[[e.lo,e.loOpen===!0,n.lo,n.loOpen===!0],[e.lo,e.loOpen===!0,n.hi,n.hiOpen===!0],[e.hi,e.hiOpen===!0,n.lo,n.loOpen===!0],[e.hi,e.hiOpen===!0,n.hi,n.hiOpen===!0]]){let m=a(f,c,d,p),h=f===0&&!Number.isFinite(d)&&n.finite===!0||d===0&&!Number.isFinite(f)&&e.finite===!0,y=h?0:Z1(f,d,-1);if(!Number.isNaN(y)){i=!0;let v=m&&(h||oi(f,d,y));y<t?(t=y,s=v):y===t&&!v&&(s=!1)}let b=h?0:Z1(f,d,1);if(!Number.isNaN(b)){o=!0;let v=m&&(h||oi(f,d,b));b>r?(r=b,u=v):b===r&&!v&&(u=!1)}}let l=Ro({lo:i?t:-1/0,hi:o?r:1/0},i&&s,o&&u);return e.finite===!0&&n.finite===!0&&(l.finite=!0),l}function K1(e){return e.lo>0||e.hi<0||e.lo===0&&e.loOpen===!0||e.hi===0&&e.hiOpen===!0}function HV(e){if(!K1(e))return;let n,t;e.hi===1/0?(n=0,t=e.finite===!0):e.hi===0?(n=-1/0,t=!1):(n=FV(e.hi,-1),t=e.hiOpen===!0&&HR(e.hi));let r,i;return e.lo===-1/0?(r=0,i=e.finite===!0):e.lo===0?(r=1/0,i=!1):(r=FV(e.lo,1),i=e.loOpen===!0&&HR(e.lo)),J1(Ro({lo:n,hi:r},t,i),e)}function GV(e,n){let t=HV(n);return t===void 0?void 0:GR(e,t)}function nue(e){return e.lo>=0?e:e.hi<=0?eue(e):J1(tue(e),e)}function tue(e){let n=-e.lo,t=e.hi,r;return n>t?r=e.loOpen===!0:t>n?r=e.hiOpen===!0:r=e.loOpen===!0&&e.hiOpen===!0,Ro({lo:0,hi:Math.max(n,t)},!1,r)}function BV(e,n){let t=rue(e,n);return t===void 0?t:J1(t,e)}function rue(e,n){if(!Number.isInteger(n)||n<1)return;if(n===1)return e;let t=(a,l,f)=>{let c=oue(a,n,f);return[c,l&&iue(a,n,c)]};if(n%2===1){let[a,l]=t(e.lo,e.loOpen===!0,-1),[f,c]=t(e.hi,e.hiOpen===!0,1);return Ro({lo:a,hi:f},l,c)}if(e.lo>=0){let[a,l]=t(e.lo,e.loOpen===!0,-1),[f,c]=t(e.hi,e.hiOpen===!0,1);return Ro({lo:a,hi:f},l,c)}if(e.hi<=0){let[a,l]=t(e.hi,e.hiOpen===!0,-1),[f,c]=t(e.lo,e.loOpen===!0,1);return Ro({lo:a,hi:f},l,c)}let[r,i]=t(e.lo,e.loOpen===!0,1),[o,s]=t(e.hi,e.hiOpen===!0,1),u;return r>o?u=i:o>r?u=s:u=i&&s,Ro({lo:0,hi:Math.max(r,o)},!1,u)}function iue(e,n,t){if(!Number.isFinite(t))return!1;let r=1,i=Math.abs(e),o=n;for(;o>0;){if(o%2===1){let s=r*i;if(!oi(r,i,s)&&!(r===1||i===1))return!1;r=s}if(o=Math.floor(o/2),o>0){let s=i*i;if(!oi(i,i,s)&&i!==1)return!1;i=s}}return Math.abs(t)===r}function WV(e,n){if(!Number.isInteger(n)||n===0)return;if(n>0)return BV(e,n);let t=BV(e,-n);return t===void 0?void 0:HV(t)}function oue(e,n,t){if(e>=0)return VV(e,n,t);let r=VV(-e,n,n%2===0?t:-t);return n%2===0?r:-r}function VV(e,n,t){let r=1,i=e,o=n;for(;o>0;)o%2===1&&(r=Z1(r,i,t)),o=Math.floor(o/2),o>0&&(i=Z1(i,i,t));return r}function uy(e){let{lo:n,hi:t}=e,r=e.loOpen===!0,i=e.hiOpen===!0;if(Number.isFinite(n)&&n!==0){let o=sy(n,kV,"floor");o!==n&&(r=!1),n=o,(!Number.isFinite(n)||Math.abs(n)<Gp)&&(n=-1/0,r=!1)}else n===0&&(n=0);if(Number.isFinite(t)&&t!==0){let o=sy(t,kV,"ceiling");o!==t&&(i=!1),t=o,(!Number.isFinite(t)||Math.abs(t)<Gp)&&(t=1/0,i=!1)}else t===0&&(t=0);return Ro({lo:n,hi:t},r,i)}function WR(e,n){let t;for(let r of e){let i=pr(r);if(i===void 0)return;t=t===void 0?i:n(t,i)}return t===void 0?void 0:uy(t)}function YR(e,n){let t=pr(n);if(t!==void 0){let r=uy(nue(t));r.lo=Math.max(r.lo,0);let i=Yp(e,r);if(typeof i!="string")return i}return tl(e)}function YV(e,n){let t=e.lo===e.hi&&!e.loOpen&&!e.hiOpen&&Number.isFinite(e.lo),r=n.lo===n.hi&&!n.loOpen&&!n.hiOpen&&Number.isFinite(n.lo);if(t&&r&&e.lo===n.lo)return"equal";if(e.hi<n.lo)return"less";if(n.hi<e.lo)return"greater";if(e.hi===n.lo&&Number.isFinite(e.hi))return e.hiOpen===!0||n.loOpen===!0?"less":"lessOrEqual";if(n.hi===e.lo&&Number.isFinite(n.hi))return n.hiOpen===!0||e.loOpen===!0?"greater":"greaterOrEqual"}function Yp(e,n){if(n===void 0||typeof e!="string"||!UR.has(e))return e;let t=Number.isFinite(n.lo),r=Number.isFinite(n.hi);return!t&&!r||t&&r&&n.lo>n.hi?e:DF(e,n.lo,n.hi,n.loOpen===!0,n.hiOpen===!0)}function ZV(e){let n=e.engine;if(e.operator==="Hold")return;let t;if(g(e)){let r=e.operatorDefinition;return r?.sgn&&(t=r.sgn(e.ops,{engine:n})),t}return C(e)||T(e)?e.sgn:"unsigned"}function Tn(e){if(e!==void 0){if(e==="positive")return!0;if(["non-positive","zero","negative"].includes(e))return!1}}function Dn(e){if(e!==void 0){if(["positive","positive-infinity","non-negative","zero"].includes(e))return!0;if(e==="negative")return!1}}function yt(e){if(e!==void 0){if(e==="negative")return!0;if(["non-negative","zero","positive"].includes(e))return!1}}function Ki(e){if(e!==void 0){if(["negative","non-positive","zero"].includes(e))return!0;if(["positive","positive-infinity"].includes(e))return!1}}var QV=K("complex | +oo | -oo"),sue=K("real<0..> | +oo | -oo");function ot(e){return e.facts.sgn}function Ll(e){let n=e.type;if(e.facts.collection!==!0&&!uue(n))return n;for(;;){let t=Z(n);if(t===void 0||t===n)return n;n=t}}function uue(e){return typeof e=="object"&&e.kind==="broadcastable"}function XV(e){return e.structureOf?.()?.kind==="number"}function aue(e){if(typeof e!="string"){if(e.kind==="value"&&typeof e.value=="number")return e.value;if(e.kind==="numeric"&&typeof e.lower=="number"&&e.lower===e.upper)return e.lower}}function ke(e){if(XV(e))return aue(e.type)}function bt(e){return e.facts.finite===!1}function lue(e){return e.facts.finite===!1&&e.facts.sgn==="unsigned"}function Jp(e){return pr(e)??{lo:-1/0,hi:1/0}}function Zp(e,n,t){if(typeof e=="string")return!1;switch(e.kind){case"negation":return O({kind:"value",value:n},e.type);case"intersection":return e.types.some(r=>Zp(r,n,t));case"union":return e.types.every(r=>Zp(r,n,t));case"reference":return!e.alias||e.def===void 0||(t??=new Set,t.has(e))?!1:(t.add(e),Zp(e.def,n,t));default:return!1}}function ZR(e,n){let t=ke(e);if(t!==void 0)return t>n;if(n===0&&Tn(e.facts.sgn)===!0)return!0;let r=Jp(e.type);return r.lo>n||r.lo===n&&r.loOpen===!0?!0:r.lo===n&&Zp(e.type,n)}function fue(e,n){let t=ke(e);return t!==void 0?t>=n:n===0&&Dn(e.facts.sgn)===!0?!0:Jp(e.type).lo>=n}function JR(e,n){let t=ke(e);if(t!==void 0)return t<n;if(n===0&&yt(e.facts.sgn)===!0)return!0;let r=Jp(e.type);return r.hi<n||r.hi===n&&r.hiOpen===!0?!0:r.hi===n&&Zp(e.type,n)}function cue(e,n){let t=ke(e);return t!==void 0?t<=n:n===0&&Ki(e.facts.sgn)===!0?!0:Jp(e.type).hi<=n}function Q1(e,n){let t=ke(e);if(t!==void 0)return t===n;let r=Jp(e.type);return r.lo===r.hi&&r.lo===n}function e8(e,n){let t=ke(e);if(t!==void 0)return t!==n;if(Zp(e.type,n))return!0;let r=Jp(e.type);if(n<r.lo||n>r.hi||n===r.lo&&r.loOpen===!0||n===r.hi&&r.hiOpen===!0)return!0;let i=e.facts.sgn;return n>0?Ki(i)===!0:n<0?Dn(i)===!0:i==="not-zero"||Tn(i)===!0||yt(i)===!0}function It(e){return e.some(n=>bt(n))?"number":e.every(n=>oe(n.type).real)?"real":"number"}function KR(e){if(e.length===0)return"number";let n=[];for(let t of e){if(t.facts.finite!==!0)return"number";let r=Ft(t.type);if(typeof r!="string"||!MF.has(r))return"number";n.push(r==="imaginary"?"complex":r)}return me(...n)}function due(e){let n=e[0],t=e[1];if(!n||bt(n))return"number";let r=ot(n),i=o=>Tn(ot(o))===!0&&o.facts.finite===!0&&e8(o,1);return ke(n)===0?t===void 0||i(t)?Sn:"number":Tn(r)===!1&&yt(r)!==!0||t&&!i(t)?"number":yt(r)===!0?"complex":Tn(r)===!0?"real":oe(n.type).complex?QV:"number"}function pue(e,n){let t=n[0];if(!t)return"number";let r=e==="Coth"||e==="Csch";if(bt(t))return r&&oe(t.type).extendedReal?"real":"number";if(!oe(t.type).real)return"number";let i=e!=="Tan"&&e!=="Sec";if(XV(t))return i&&ke(t)===0?"number":"real";if(!r&&t.facts.closed!==!1)return"number";if(!i)return"real";let o=ot(t);return Tn(o)===!0||yt(o)===!0?"real":"number"}var In=(e,n,t,r)=>({lo:e,loClosed:n,hi:t,hiClosed:r});function JV(e,n){return e.some(({lo:t,loClosed:r,hi:i,hiClosed:o})=>(r?n>=t:n>t)&&(o?n<=i:n<i))}function KV(e,n){return n.some(({lo:t,loClosed:r,hi:i,hiClosed:o})=>!(t!==-1/0&&!(r?fue(e,t):ZR(e,t))||i!==1/0&&!(o?cue(e,i):JR(e,i))))}function Ao(e,n){let t=e[0];if(!t||bt(t)||!oe(t.type).real)return"number";let r=ke(t);return typeof r=="number"&&Number.isFinite(r)&&!(n.poles.includes(r)||n.real.some(({lo:o,hi:s})=>r===o||r===s)||n.complex.some(({lo:o,hi:s})=>r===o||r===s))?JV(n.real,r)?"real":JV(n.complex,r)?"complex":n.poleType:n.poles.some(i=>Q1(t,i))?n.poleType:KV(t,n.real)?"real":KV(t,n.complex)||n.poles.every(i=>e8(t,i))?"complex":n.poleType==="number"?"number":QV}var mue={real:[In(-1,!0,1,!0)],complex:[In(-1/0,!1,-1,!1),In(1,!1,1/0,!1)],poles:[],poleType:"number"},gue={real:[In(-1/0,!1,-1,!0),In(1,!0,1/0,!1)],complex:[In(-1,!1,0,!1),In(0,!1,1,!1)],poles:[0],poleType:"number"},hue={real:[In(-1,!1,1,!1)],complex:[In(-1/0,!1,-1,!1),In(1,!1,1/0,!1)],poles:[-1,1],poleType:Sn},yue={real:[In(-1/0,!1,-1,!1),In(1,!1,1/0,!1)],complex:[In(-1,!1,1,!1)],poles:[-1,1],poleType:Sn},bue={real:[In(0,!1,1,!0)],complex:[In(-1/0,!1,0,!1),In(1,!1,1/0,!1)],poles:[0],poleType:Sn},vue={real:[In(1,!0,1/0,!1)],complex:[In(-1/0,!1,1,!1)],poles:[],poleType:"number"},Eue={real:[In(-1/0,!1,1/0,!1)],complex:[],poles:[0],poleType:"number"};function xue(e){let n=e[0];return n&&oe(n.type).extendedReal?"real":"number"}function ay(e){if(!e)return"number";let n=oe(e.type);if(!n.nan)return n.integer&&Ki(ot(e))===!0?"number":It([e])}var Sue=K("integer | signed_infinity");function ly(e){if(!e)return;let n=Ll(e),t=oe(n);if(e.facts.collection!==!0&&bt(e))return t.extendedReal?Sn:void 0;if(t.real)return"integer";if(O(n,Sn))return Sn;if(t.extendedReal)return Sue}function n8(e){if(!e)return"number";let n=e.type,t=oe(n);if(t.infinity)return Sn;if(lue(e))return"number";for(let r of["integer","rational","real"])if(t[r])return YR(r,n);return t.complex?YR("real",n):sue}function fy(e){if(e.length===0||!e.every(n=>oe(n.type).belowNumber))return"number";for(let n of["integer","rational","real"])if(e.every(t=>oe(t.type)[n]))return n;return"number"}function X1(e){if(e.length===0)return;let n=e.map(t=>Ll(t));if(!n.some(t=>O(t,"never"))){if(n.every(t=>oe(t).integer))return"integer";if(n.every(t=>oe(t).real))return"real"}}function t8(e){return e[0]?.type??"real"}function QR(e){let n=e[0];if(e.length>1&&n!==void 0&&O(n.type,$e))return n.type;let t=n?.type;return e.length>1&&t!==void 0&&typeof t!="string"&&t.kind==="broadcastable"?t:"number"}function Kp(e,n){switch(e){case"Ln":case"Log":case"Lb":case"Lg":case"Log2":case"Log10":return due(n);case"Tan":case"Sec":case"Csc":case"Cot":case"Coth":case"Csch":return pue(e,n);case"Sinh":case"Cosh":return n[0]!==void 0&&n[0].facts.finite===!1&&oe(n[0].type).extendedReal?Sn:It(n);case"Tanh":case"Sech":return n[0]!==void 0&&n[0].facts.finite===!1&&oe(n[0].type).extendedReal?"real":It(n);case"Arcsin":case"Arccos":return Ao(n,mue);case"Arcsec":case"Arccsc":return Ao(n,gue);case"Arctan":case"Arccot":return xue(n);case"Artanh":return Ao(n,hue);case"Arcoth":return Ao(n,yue);case"Arsech":return Ao(n,bue);case"Arcsch":return Ao(n,Eue);case"Arcosh":return Ao(n,vue);default:return It(n)}}function ex(e){let n=e[0],t=(n?Z(n.type):void 0)??"unknown",r=e.slice(1).map(i=>i.type);return t==="unknown"||r.some(i=>i==="unknown")?{kind:"set",elements:"unknown"}:{kind:"set",elements:me(t,...r)}}function nx(e){let n=e[0];return{kind:"set",elements:(n?Z(n.type):void 0)??"unknown"}}function kc(e){let n=e.structureOf?.();return n?.kind==="number"?n.tier:e.type}function _ue(e,n){return Bn({kind:"intersection",types:[e,n]})}var XR=K("rational | +oo | -oo"),eA=K("integer | +oo | -oo"),nA=K("complex | infinity");function mr(e,n,t){return ZL(GL(e,{elementType:n,sign:t}))}function Tr(e,n){let t=e.type;if(t.matches(n))return!0;if(el(_ue(t.type,n))||T(e))return!1}function Bl(e,n,t){let r=Tr(e,n);if(r===!1||t===!1)return!1;if(t===!0)return r}function wue(e,{engine:n}){if(e.length!==2)return"boolean";let[t,r]=e,i=r8(t);if(i===void 0)return"boolean";let o=r.structureOf?.(),s=o?.kind==="application"&&o.head==="Set",u=o?.kind==="list-literal"?o.elements:s?o.children:void 0;if(u===void 0)return"boolean";let a=u.map(f=>r8(f));if(a.some(f=>f===void 0))return"boolean";let l=!0;for(let f=0;f<u.length;f++){let c=Cue(t,i,u[f],a[f]);if(c===!0)return{kind:"value",value:!0};c===void 0&&(l=!1)}if(!l)return"boolean";if(s&&i.kind==="number"){let f=ux(t,i);if(f===void 0)return"boolean";for(let c=0;c<u.length;c++){let d=a[c];if(d.kind!=="number")continue;let p=ux(u[c],d);if(p===void 0||Math.abs(p-f)<=n.tolerance)return"boolean"}}return{kind:"value",value:!1}}function r8(e){let n=e.structureOf?.();if(n?.kind==="number"||n?.kind==="string")return n}function Cue(e,n,t,r){if(n.kind==="string"||r.kind==="string")return n.kind!=="string"||r.kind!=="string"?!1:n.text===r.text;if(n.rational!==void 0&&r.rational!==void 0)return n.rational[0]===r.rational[0]&&n.rational[1]===r.rational[1];let i=ke(e),o=ke(t);if(i!==void 0&&o!==void 0)return i===o;let s=ux(e,n),u=ux(t,r);if(s!==void 0&&u!==void 0&&s!==u)return!1}var i8=BigInt(Number.MAX_SAFE_INTEGER);function ux(e,n){let t=ke(e);if(t!==void 0)return t;if(n.kind!=="number"||n.rational===void 0)return;let[r,i]=n.rational;if(!((r<0n?-r:r)>i8||i>i8))return Number(r)/Number(i)}var s8={EmptySet:{type:"set",isConstant:!0,wikidata:"Q226183",description:"The empty set, a set containing no elements.",eq:e=>e.type.matches("set<any>")&&e.isEmptyCollection,collection:{iterator:()=>({next:()=>({value:void 0,done:!0})}),count:()=>0,isEmpty:()=>!0,isFinite:()=>!0,contains:()=>!1,subsetOf:(e,n,t)=>{if(!t)return!0;if(n.isEmptyCollection!==void 0)return!n.isEmptyCollection},eltsgn:()=>{},elttype:()=>"never"}},Numbers:{type:"set<number>",isConstant:!0,description:"The set of all numbers.",collection:{iterator:rA,count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,contains:(e,n)=>Tr(n,"number"),subsetOf:mr("Numbers","number"),eltsgn:()=>{},elttype:()=>"number"}},ComplexNumbers:{type:"set<complex>",isConstant:!0,description:"The set of all finite complex numbers.",collection:{iterator:rA,count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,contains:(e,n)=>Tr(n,"complex"),subsetOf:mr("ComplexNumbers","complex"),eltsgn:()=>{},elttype:()=>"complex"}},ExtendedComplexNumbers:{type:"set<complex | infinity>",isConstant:!0,description:"The set of all complex numbers, including infinities.",collection:{iterator:rA,count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,contains:(e,n)=>Tr(n,nA),subsetOf:mr("ExtendedComplexNumbers",nA),eltsgn:()=>{},elttype:()=>nA}},ImaginaryNumbers:{type:"set<imaginary>",isConstant:!0,description:"The set of all imaginary numbers.",collection:{iterator:$ue,count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,contains:(e,n)=>Tr(n,"imaginary"),subsetOf:mr("ImaginaryNumbers","imaginary","unsigned"),eltsgn:()=>"unsigned",elttype:()=>"imaginary"}},RealNumbers:{type:"set<real>",isConstant:!0,description:"The set of all finite real numbers.",collection:{iterator:e=>Vl(e),contains:(e,n)=>Tr(n,"real"),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("RealNumbers","real"),eltsgn:()=>{},elttype:()=>"real"}},ExtendedRealNumbers:{type:"set<real | +oo | -oo>",isConstant:!0,description:"The set of all real numbers, including infinities.",collection:{iterator:e=>Vl(e),contains:(e,n)=>Tr(n,rn),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("ExtendedRealNumbers",rn),eltsgn:()=>{},elttype:()=>rn}},Integers:{type:"set<integer>",isConstant:!0,description:"The set of all finite integers.",collection:{iterator:o8,contains:(e,n)=>Tr(n,"integer"),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("Integers","integer"),eltsgn:()=>{},elttype:()=>"integer"}},ExtendedIntegers:{type:"set<integer | +oo | -oo>",isConstant:!0,description:"The set of all integers, including infinities.",collection:{iterator:o8,contains:(e,n)=>Tr(n,eA),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("ExtendedIntegers",eA),eltsgn:()=>{},elttype:()=>eA}},RationalNumbers:{type:"set<rational>",isConstant:!0,description:"The set of all finite rational numbers.",collection:{iterator:e=>Vl(e),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,contains:(e,n)=>Tr(n,"rational"),subsetOf:mr("RationalNumbers","rational"),eltsgn:()=>{},elttype:()=>"rational"}},ExtendedRationalNumbers:{type:"set<rational | +oo | -oo>",isConstant:!0,description:"The set of all rational numbers, including infinities.",collection:{iterator:e=>Vl(e),contains:(e,n)=>Tr(n,XR),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("ExtendedRationalNumbers",XR),eltsgn:()=>{},elttype:()=>XR}},NegativeNumbers:{type:"set<real>",isConstant:!0,description:"The set of all negative real numbers.",collection:{iterator:e=>Vl(e,{sign:"-",includeZero:!1}),count:()=>1/0,contains:(e,n)=>Bl(n,"real",n.isNegative),subsetOf:mr("NegativeNumbers","real","negative"),eltsgn:()=>"negative",elttype:()=>"real"}},NonPositiveNumbers:{type:"set<real>",isConstant:!0,description:"The set of all non-positive real numbers.",collection:{iterator:e=>Vl(e,{sign:"-",includeZero:!0}),contains:(e,n)=>Bl(n,"real",n.isNonPositive),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("NonPositiveNumbers","real","non-positive"),eltsgn:()=>"non-positive",elttype:()=>"real"}},NonNegativeNumbers:{type:"set<real>",isConstant:!0,description:"The set of all non-negative real numbers.",collection:{iterator:e=>Vl(e,{sign:"+",includeZero:!0}),contains:(e,n)=>Bl(n,"real",n.isNonNegative),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("NonNegativeNumbers","real","non-negative"),eltsgn:()=>"non-negative",elttype:()=>"real"}},PositiveNumbers:{type:"set<real>",isConstant:!0,description:"The set of all positive real numbers.",collection:{iterator:e=>Vl(e,{sign:"+",includeZero:!1}),contains:(e,n)=>Bl(n,"real",n.isPositive),count:()=>1/0,subsetOf:mr("PositiveNumbers","real","positive"),eltsgn:()=>"positive",elttype:()=>"real"}},NegativeIntegers:{type:"set<integer>",isConstant:!0,description:"The set of all negative integers.",collection:{iterator:e=>ix(e.engine,-1,-1),contains:(e,n)=>Bl(n,"integer",n.isNegative),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("NegativeIntegers","integer","negative"),eltsgn:()=>"negative",elttype:()=>"integer"}},NonPositiveIntegers:{type:"set<integer>",isConstant:!0,description:"The set of all non-positive integers.",collection:{iterator:e=>ix(e.engine,0,-1),contains:(e,n)=>Bl(n,"integer",n.isNonPositive),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("NonPositiveIntegers","integer","non-positive"),eltsgn:()=>"non-positive",elttype:()=>"integer"}},NonNegativeIntegers:{type:"set<integer>",isConstant:!0,description:"The set of all non-negative integers.",collection:{iterator:e=>ix(e.engine,0,1),contains:(e,n)=>Bl(n,"integer",n.isNonNegative),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("NonNegativeIntegers","integer","non-negative"),eltsgn:()=>"non-negative",elttype:()=>"integer"}},PositiveIntegers:{type:"set<integer>",isConstant:!0,description:"The set of all positive integers.",collection:{iterator:e=>ix(e.engine,1,1),contains:(e,n)=>Bl(n,"integer",n.isPositive),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:mr("PositiveIntegers","integer","positive"),eltsgn:()=>"positive",elttype:()=>"integer"}},Primes:{type:"set<integer>",isConstant:!0,description:"The set of all prime numbers.",collection:{iterator:e=>Oue(e.engine),contains:(e,n)=>Pue(n),count:()=>1/0,isEmpty:()=>!1,isFinite:()=>!1,subsetOf:Fue,eltsgn:()=>"positive",elttype:()=>"integer"}},Element:{type:(e,n)=>k.forResult(wue(e,n),n.engine._typeResolver),complexity:11200,keywords:["element of","member"],signature:"(any, any, boolean?) -> boolean",description:`Test whether a value is an element of a collection. Optional third argument is a boolean expression (condition) for filtered iteration in Sum/Product.
|
|
5
5
|
|
|
@@ -1849,4 +1849,4 @@ return function (_) { ${i} };`)(this.IA);return new Proxy(this,{apply:(s,u,a)=>{
|
|
|
1849
1849
|
`,l[p]=p):typeof h=="string"&&(l[p]=h)}let c=this.createTarget({mode:t.mode,constantFold:!1,varsKeys:s?new Set(Object.keys(s)):void 0,foldExcludedOps:Object.keys(l).length>0?new Set(Object.keys(l)):void 0,unrollSkipHeads:r,unrollMinWidth:1,unrollConstantLists:!0,foldEmittedConstant:t.constantFold===!1?void 0:(p,m)=>z0(m,!1,gF(c)),constant:p=>EC[p],functions:p=>l?.[p]?l[p]:xte(p),var:p=>{if(s&&Object.hasOwn(s,p))return s[p];let m=EC[p];if(m!==void 0)return m;if(a.includes(p))return vte(p);if(n.engine._getSymbolValue(p)===void 0)return vte(p)},preamble:(u??"")+f,userFunctions:{defs:new Map,compiling:new Set},naming:R.newNamingContext(n,[u,f,...Object.values(l),...s?Object.values(s):[]])});c.userFunctions.root=c,n=mi(R.inlineCollectionValuedCallsAtRoot(n,c),i),a=n.unknowns,R.openCseSession(n,c,{enabled:t.cse,isOverriddenOperator:p=>Object.prototype.hasOwnProperty.call(l,p),isStringVar:p=>s!==void 0&&typeof s[p]=="string",isVarsKey:p=>s!==void 0&&Object.prototype.hasOwnProperty.call(s,p)});let d=pNe(n,c);return R.withReferences(d,n,c,s?new Set(Object.keys(s)):void 0)}};function pNe(e,n){eNe(n);let t;try{let c=Y2e(e,n),d=c===void 0&&Pte.has((Za(e,n)??e).operator);t=c!==void 0?R.compileCseRoot(e,n,0,()=>`[${c.map(p=>R.compileValueOperand(p,n)).join(", ")}]`):d?R.compileCseRoot(e,n,0,()=>qu(e,n)??R.compile(e,n)):R.compileCseRoot(e,n)}catch(c){return{target:"interval-js",success:!1,code:"",error:c.message,diagnostic:Iu(c),...R.modeReport()}}let r=R.userFunctionsPreamble(n),i=dNe(r,t,n),o=i.expression,s=RC.get(R.namingContext(n)),u=[s&&s.length>0?`let ${s.join(", ")};`:"",i.declarations].filter(c=>c).join(`
|
|
1850
1850
|
`),a=[n.preamble,i.definitions].filter(c=>c).join(`
|
|
1851
1851
|
`),l=[n.preamble,u,i.definitions].filter(c=>c).join(`
|
|
1852
|
-
`),f=new dF(o,a,u);return{target:"interval-js",success:!0,code:o,...l?{preamble:l}:{},calling:"expression",run:f}}var kC=class{_targets=new Map;register(n,t){fQ(n),dQ(t),this._targets.set(n,t)}get(n){return this._targets.get(n)}list(){return[...this._targets.keys()]}unregister(n){this._targets.delete(n)}registerDefaults(){this.register("javascript",new rg),this.register("glsl",new cg),this.register("wgsl",new k0),this.register("python",new mg),this.register("interval-js",new wg)}};var MC=class{_listeners=[];_registered=new WeakSet;_pending=!1;_version=0;listen(n){return this._registered.has(n)||(this._registered.add(n),this._listeners.push(n)),()=>this._unsubscribe(n)}_unsubscribe(n){this._registered.has(n)&&(this._registered.delete(n),this._listeners=this._listeners.filter(t=>t!==n))}notify(){if(this._pending)return;this._pending=!0;let n=this._version+1;queueMicrotask(()=>{if(n!==this._version+1){this._pending=!1;return}this.notifyNow()})}notifyNow(){this._version++;for(let n of this._listeners)try{n?.onConfigurationChange?.()}catch(t){console.error("Listener error:",t)}this._pending=!1}};function mNe(e){switch(e.kind){case"assumption":case"inference":case"config":case"binding-repair":return!0;case"redefine":case"type-write":return e.callableBefore||e.callableAfter;case"scope-pop":return e.assumptionsDirty;case"value-write":return e.callable;case"declare":return!e.scratch&&(e.callable||e.shadowsCallable);case"object-store":return!1}}var gNe=(()=>{if(typeof process>"u")return!1;let e=process.env?.CE_OBJECT_STORE_BUMPS_ANY;return e!==void 0&&e!=="0"})();function hNe(e){switch(e.kind){case"value-write":return{any:!0,semantic:!e.ephemeral,world:!1};case"declare":return e.scratch?{any:!1,semantic:!1,world:!1}:{any:!0,semantic:!1,world:!1};case"binding-repair":return{any:!0,semantic:!1,world:!1};case"redefine":return e.callableAfter?{any:!1,semantic:!0,world:!0}:{any:!1,semantic:!1,world:!1};case"type-write":return{any:!0,semantic:!1,world:!1};case"scope-pop":return{any:!e.transient&&!e.clean||e.assumptionsDirty,semantic:e.assumptionsDirty,world:e.assumptionsDirty};case"assumption":return{any:!0,semantic:!0,world:!0};case"inference":return e.valueType?{any:!1,semantic:!1,world:!1}:e.symbolSignature?{any:!0,semantic:!0,world:!0}:{any:!0,semantic:!0,world:!0};case"config":return{any:!0,semantic:!0,world:!0};case"object-store":return gNe?{any:!0,semantic:!1,world:!1}:{any:!1,semantic:!1,world:!1}}}var $C=class{_anyVersion=0;_semanticVersion=0;_worldVersion=0;_callableVersion=0;_ephemeralWriteDepth=0;_factSuppressionDepth=0;_scratchDeclarationScopes=[];_tracker=new MC;get anyVersion(){return this._anyVersion}get semanticVersion(){return this._semanticVersion}get worldVersion(){return this._worldVersion}get callableVersion(){return this._callableVersion}get ephemeralWriteDepth(){return this._ephemeralWriteDepth}set ephemeralWriteDepth(n){this._ephemeralWriteDepth=n}get factSuppressionDepth(){return this._factSuppressionDepth}set factSuppressionDepth(n){this._factSuppressionDepth=n}get scratchDeclarationScopes(){return this._scratchDeclarationScopes}noteStateEvent(n){let t=hNe(n);t.any&&(this._anyVersion+=1),t.semantic&&(this._semanticVersion+=1),t.world&&(this._worldVersion+=1),mNe(n)&&(this._callableVersion+=1),Fe&&(t.any&&W0("generation"),t.semantic&&W0("mutationGeneration"),t.world&&W0("semanticEpoch"))}reset(n){this._scratchDeclarationScopes.length=0,this.noteStateEvent({kind:"config"}),n.refreshNumericConstants(),n.resetCommonSymbols(),n.purgeCaches(),this._tracker.notifyNow()}listen(n){return this._tracker.listen(n)}};function yNe(e){return!!(e===void 0||e==="Number"||e===!0||Array.isArray(e)&&e.includes("Number"))}function Gte(e,n,t,r){let i=r?.canonical??!0,o=r?.metadata,s=t.normalize(),u=s.toLowerCase();if(u==="infinity"||u==="+infinity")return e.PositiveInfinity;if(u==="-infinity")return e.NegativeInfinity;if(e.strict&&!Ji(s))return e.error(["invalid-symbol",Us(s)],s);if(!i)return new Di(e,s,{metadata:o});if(e._isShadowedParameter(s)){let d=e._shadowedParameterType(s);if(d!==void 0){let v=e._shadowedParameterDef(s);if(v!==void 0)return new Di(e,s,{metadata:o,def:v});let E=e.context.lexicalScope;for(;E.noAutoDeclare&&E.parent;)E=E.parent;let x=E.bindings.get(s),S=x??e._declareSymbolValue(s,{type:d,inferred:!1},E);e._setShadowedParameterDef(s,S);let w=new Di(e,s,{metadata:o,def:S});return x===void 0&&J(S)&&Ls(e,S.value,{type:S.value.type,kind:"auto-declared",axis:"type",cause:w,epoch:Bs(e)}),w}let p=e._shadowedParameterDef(s);if(p!==void 0)return new Di(e,s,{metadata:o,def:p});let m=e.context.lexicalScope;for(;m.noAutoDeclare&&m.parent;)m=m.parent;let h=m.bindings.get(s),y=h??e._declareSymbolValue(s,{type:"unknown",inferred:!0},m);e._setShadowedParameterDef(s,y);let b=new Di(e,s,{metadata:o,def:y});return h===void 0&&J(y)&&Ls(e,y.value,{type:y.value.type,kind:"auto-declared",axis:"type",cause:b,epoch:Bs(e)}),b}let a=Object.hasOwn(n,s)?n[s]:void 0;if(a)return a;let l=e.lookupDefinition(s);if(J(l)&&l.value.holdUntil==="never")return l.value.value??e.Nothing;if(l)return new Di(e,s,{metadata:o,def:l});if(r?.autoDeclare===!1||e._resolveOnlyDepth>0)return new Di(e,s,{metadata:o});let f=e.context.lexicalScope;for(;f.noAutoDeclare&&f.parent;)f=f.parent;l=e._declareSymbolValue(s,{type:"unknown",inferred:!0},f),e._boxingState.isPersistentScope(f)===!1&&e._boxingState.noteTransientAutoDeclare(s);let c=new Di(e,s,{metadata:o,def:l});return J(l)&&Ls(e,l.value,{type:l.value.type,kind:"auto-declared",axis:"type",cause:c,epoch:Bs(e)}),c}function Wte(e,n,t){let r=t.bindings.get(n);if(J(r))return new Di(e,n,{def:r})}function Yte(e,n,t,r){let i=r?.metadata;if(!yNe(r?.canonical)&&fl(t))return e._fn("Rational",[e.number(t[0]),e.number(t[1])],{...i,canonical:!1});let s=ES(e,t);if(i===void 0){if(typeof s=="number"){let u=s;if(u===1)return e.One;if(u===0)return e.Zero;if(u===-1)return e.NegativeOne;if(u===2)return e.Two;if(Number.isInteger(u)&&n[u]!==void 0)return n[u]??=new xt(e,s),n[u];if(Number.isNaN(u))return e.NaN;if(!Number.isFinite(u))return u<0?e.NegativeInfinity:e.PositiveInfinity}else if(s instanceof Sr){if(s.isZero)return e.Zero;if(s.isOne)return e.One;if(s.isNegativeOne)return e.NegativeOne;if(s.isNaN)return e.NaN;if(s.isNegativeInfinity)return e.NegativeInfinity;if(s.isPositiveInfinity)return e.PositiveInfinity}}return new xt(e,s,{metadata:i})}var Ng=class{_rules;_cachedLength=-1;constructor(n){this._rules=n}get rules(){return this._rules}set rules(n){this._rules=n,this._cachedLength=-1}hasMutatedSinceLastCache(){return this._cachedLength>=0&&this._rules.length!==this._cachedLength}markCached(){this._cachedLength=this._rules.length}};var OC=class{_precision;_angularUnit;_tolerance;_bignumTolerance;_negBignumTolerance;constructor(n){let t=n?.precision??e2;t==="machine"&&(t=Math.floor(Ud)),this._precision=t,D.precision=t,this._angularUnit=n?.angularUnit??"rad",this._tolerance=jg,this._bignumTolerance=new D(jg),this._negBignumTolerance=new D(-jg),this.setTolerance(n?.tolerance??"auto")}get precision(){return this._precision}setPrecision(n){let t=n;if(t==="machine"&&(t=Ud),t==="auto"&&(t=e2),t===this._precision)return!1;if(typeof t!="number"||t<=0)throw Error('Expected "machine" or a positive number');return this._precision=Math.max(t,Ud),D.precision=this._precision,this.setTolerance("auto"),!0}get angularUnit(){return this._angularUnit}setAngularUnit(n){if(n===this._angularUnit)return!1;if(typeof n!="string")throw Error("Expected a string");return this._angularUnit=n,!0}get tolerance(){return this._tolerance}setTolerance(n){let t=n;return t==="auto"&&(t=jg),(!Number.isFinite(t)||t<0)&&(t=Math.pow(10,-this._precision+2)),t===this._tolerance?!1:(this._tolerance=t,this._bignumTolerance=new D(t),this._negBignumTolerance=new D(-t),!0)}get bignumTolerance(){return this._bignumTolerance}get negBignumTolerance(){return this._negBignumTolerance}get bignumNaN(){return D.NAN}get bignumZero(){return D.ZERO}get bignumOne(){return D.ONE}get bignumTwo(){return D.TWO}get bignumHalf(){return D.HALF}get bignumPi(){return D.PI}get bignumNegativeOne(){return D.NEGATIVE_ONE}bignum(n){if(n instanceof D)return n;try{return new D(n)}catch(t){t instanceof Error?console.error(t.message):console.error(String(t))}return D.NAN}};var PC=class{_iterationLimit=1024;_recursionLimit=256;_recursionDepth=0;_maxCollectionSize=1e4;_deadlineFrame=void 0;_randomFrame=void 0;_isVerifying=!1;get iterationLimit(){return this._iterationLimit}set iterationLimit(n){this._iterationLimit=n<=0?Number.POSITIVE_INFINITY:n}get recursionLimit(){return this._recursionLimit}set recursionLimit(n){this._recursionLimit=n<=0?Number.POSITIVE_INFINITY:n}get recursionDepth(){return this._recursionDepth}enterRecursion(){if(this._recursionDepth>=this._recursionLimit)throw new Ne({cause:"recursion-depth-exceeded",message:"Recursion limit exceeded"});this._recursionDepth+=1}exitRecursion(){this._recursionDepth>0&&(this._recursionDepth-=1)}get maxCollectionSize(){return this._maxCollectionSize}set maxCollectionSize(n){this._maxCollectionSize=n<=0?Number.POSITIVE_INFINITY:n}get deadlineFrame(){return this._deadlineFrame}set deadlineFrame(n){this._deadlineFrame=n}get deadline(){return this._deadlineFrame?.at}set deadline(n){this._deadlineFrame=n===void 0?void 0:{at:n,spans:[]}}get randomFrame(){return this._randomFrame}set randomFrame(n){this._randomFrame=n}get timeRemaining(){return this._deadlineFrame===void 0?Number.POSITIVE_INFINITY:this._deadlineFrame.at-Date.now()}get isVerifying(){return this._isVerifying}set isVerifying(n){this._isVerifying=n}shouldContinueExecution(){return this._deadlineFrame===void 0||this._deadlineFrame.at>=Date.now()}};var DC=class{_frames=[];_rootActive=!1;_isPersistentScope=null;_transientAutoDeclares=null;withRootRepair(n,t){if(this._rootActive)return n();this._rootActive=!0,this._isPersistentScope=t??null;try{return this._withRepairFrame(void 0,()=>(this._transientAutoDeclares=null,n()))}finally{this._rootActive=!1,this._isPersistentScope=null,this._transientAutoDeclares=null}}get isRootActive(){return this._rootActive}withScopedRepair(n,t){return this._rootActive?this._withRepairFrame(n,t):t()}get isRebuilding(){return this._frames.some(n=>n.rebuilding)}isPersistentScope(n){if(!(!this._rootActive||!this._isPersistentScope))return this._isPersistentScope(n)}noteTransientAutoDeclare(n){!this._rootActive||!this._isPersistentScope||(this._transientAutoDeclares??=new Set).add(n)}noteDeclarationIn(n,t){if(!this._rootActive||!this._transientAutoDeclares?.has(t)||this._isPersistentScope?.(n)!==!0)return;let r=this._frames.find(i=>i.scope===void 0);r&&(r.repairRequested=!0)}frameDepth(){return this._frames.length}hasRepairRequestedAtOrAbove(n){for(let t=n;t<this._frames.length;t++)if(this._frames[t].repairRequested)return!0;return!1}noteDevolvedShadow(n){for(let r=this._frames.length-1;r>=0;r--){let i=this._frames[r];if(i.scope===n){i.repairRequested=!0;return}}let t=this._frames.find(r=>r.scope===void 0);t&&(t.repairRequested=!0)}_withRepairFrame(n,t){let r={scope:n,repairRequested:!1,rebuilding:!1};this._frames.push(r);try{let i=t(),o=0;for(;r.repairRequested;){if(o>=3){let s="Devolved-shadow repair did not stabilize after 3 rebuilds";throw new Error(s)}r.repairRequested=!1,r.rebuilding=!0,o+=1;try{i=t()}finally{r.rebuilding=!1}}return i}finally{let i=this._frames.pop()}}};function bNe(e){if(typeof e!="string")return pQ(e),e;let n=qb.find(t=>t.name===e);if(!n)throw new Error(`Unknown standard library: "${e}"`);return n}function Zte(e){return e?X_(e.map(bNe)):[...ew()]}function vNe(e){return qb.includes(e)}function Jte(e,n){for(let t of n){let r=t.definitions;if(!r)continue;let i=!vNe(t),o=Array.isArray(r)?r:[r];for(let s of o){if(i)for(let u of Object.keys(s))e._customLibraryOperators.add(u.normalize());iZ(e,s)}}}function Rg(e,n){let t=e[n];if(!t)throw new Error(`Common symbol "${n}" failed to initialize`);return t}var FC=class{constructor(n){this.engine=n}engine;initializeCommonNumbers(){return{Zero:new xt(this.engine,0),One:new xt(this.engine,1),Half:new xt(this.engine,{rational:[1,2]}),NegativeOne:new xt(this.engine,-1),Two:new xt(this.engine,2),NaN:new xt(this.engine,Number.NaN),PositiveInfinity:new xt(this.engine,Number.POSITIVE_INFINITY),NegativeInfinity:new xt(this.engine,Number.NEGATIVE_INFINITY),I:new xt(this.engine,{rational:[0,1],imRational:[1,1]}),ComplexInfinity:new xt(this.engine,{re:1/0,im:1/0})}}bootstrapLibraries(n){let t=Zte(n);Jte(this.engine,t)}initializeCommonSymbolBindings(n){return JJ(this.engine,n),{True:Rg(n,"True"),False:Rg(n,"False"),Pi:Rg(n,"Pi"),E:Rg(n,"ExponentialE"),Nothing:Rg(n,"Nothing"),Missing:Rg(n,"Missing")}}};function Kte(e){let n=new Set,t=(r,i)=>{if(r==="never")return!0;let o=e._protocolRegistry?.[i];if(o===void 0)return!1;let s=`${Ag(r)} ${i}`;if(n.has(s))return!1;n.add(s);try{return o.conformances.some(u=>u.where===void 0?O(r,u.target):bE(u.target,u.where,r,t)!==null)}finally{n.delete(s)}};return{get names(){return Object.keys(e._typeRegistry)},resolve(r){let i=e._typeRegistry[r];if(i!==void 0)return i;if(e._protocolRegistry?.[r]!==void 0)throw new wt("protocol-in-type-position",`\`${r}\` is a protocol, not a type. Use a constrained variable: \`(x: T) -> boolean where T is ${r}\``)},forward(r){let i=e._typeRegistry[r];if(i!==void 0)return i;let o={kind:"reference",name:r,alias:!1,def:void 0};return e._typeRegistry[r]=o,o},conformsTo:t}}function LC(e,n,t){let r;typeof n=="string"?r=e.string(n):r=e.function("ErrorCode",n.map(s=>e.string(s)));let i;t!==void 0&&typeof t!="string"?i=t:t&&g5(t)?i=e.function("LatexString",[e.string(nE(t))]):typeof t=="string"&&t.length>0&&(i=e.string(t));let o=[e.expr(r)];return i&&o.push(i),e.function("Error",o)}function Qte(e){if(typeof e=="object"){if((e.kind==="collection"||e.kind==="indexed_collection"||e.kind==="set"||e.kind==="list"&&e.dimensions===void 0)&&e.elements==="any")return e.kind;if(e.kind==="dictionary"&&e.values==="any")return"dictionary"}return e}function Xte(e){let n=Qte(e);if(n!==e)return re(n);if(typeof e=="object"&&e.kind==="union"){let t=e.types.map(Qte);if(t.some((r,i)=>r!==e.types[i]))return re(Bn({...e,types:t}))}return re(e)}function ere(e,n,t,r){if(t){if(typeof r=="object"&&r!==null&&"type"in r&&"engine"in r){let o=r;$1(o.engine)&&t.toString()===o.type.toString()&&(t=Q4(o.engine,()=>o.type))}let i=typeof t=="object"&&"kind"in t?re(t):t.toString();return LC(e,["incompatible-type",Xte(n),i],r)}return LC(e,["incompatible-type",Xte(n)],r)}function BC(e,n){mQ(n);let t=xNe(n);n=t.options;let r=t.modeFromAlias;if(n?.target!==void 0&&n.cse===!0)throw new Error("CSE is not supported on direct custom targets in Phase 1; omit `cse` or use a registered target.");if(n?.target!==void 0&&n.storage!==void 0&&Object.keys(n.storage).length>0)throw new Error('The `storage` option is not supported on direct custom targets: the sampler-backed read needs the reference gate and the helper preamble a registered target provides. Omit `storage` or use a registered target (`to: "glsl"`).');if(n?.target===void 0&&n?.storage!==void 0){let i=e.engine._getCompilationTarget(n.to??"javascript")?.createTarget();i!==void 0&&ku(n.storage,[e],i,{vars:n.vars,functions:n.functions})}try{if(n?.target){let u=mi(ut(e),{skipHeads:Ef(n.operators,n.functions),iterationBudget:n.target.iterationBudget,readsLiveSource:d=>typeof n.vars?.[d]=="string"}),a=[n.preamble,n.target.preamble,...n.vars?Object.values(n.vars):[],...n.functions?Object.values(n.functions).map(d=>{let p=Cf(d);return typeof p=="string"?p:void 0}):[]];n.target.naming=R.newNamingContext(u,a),n.target.cse={enabled:!1,instances:[]},n.target.constantFold=n.constantFold,n.target.complexPromotion=n.complexPromotion,n.target.storage=void 0,n.target.mode=SNe(n.target,r&&!(n.target.supportedModes??["strict"]).includes("complex")?void 0:n.mode);let l,f;try{l=R.compileRoot(u,n.target)}catch(d){if(!f0(d)||n.target.mode!=="auto")throw d;n.target.reset?.(),n.target.mode="complex",n.target.naming=R.newNamingContext(u,a),l=R.compileRoot(u,n.target),f=d.diagnostic}let c=R.withReferences({target:n.target.language??"custom",success:!0,code:l},e,n.target,n.vars?new Set(Object.keys(n.vars)):void 0);return f!==void 0&&(c.escalation=f),c}let i=n?.to??"javascript",o=e.engine._getCompilationTarget(i);if(!o)throw new Error(`Compilation target "${i}" is not registered. Available targets: ${e.engine._listCompilationTargets().join(", ")}`);let s={fallback:n?.fallback??!0,operators:n?.operators,functions:n?.functions,vars:n?.vars,imports:n?.imports,preamble:n?.preamble,complexPromotion:n?.complexPromotion,mode:n?.mode,entryChecks:n?.entryChecks,iterationBudget:n?.iterationBudget,quadrature:n?.quadrature,symbolDeps:n?.symbolDeps,varsObjectRefs:n?.varsObjectRefs,cse:n?.cse,constantFold:n?.constantFold,storage:n?.storage};return r&&!ENe(o,"complex")&&(s.mode=void 0),o.compile(e,s)}catch(i){if(n?.fallback??!0){let o=i.message;console.warn(`Compilation fallback for "${e.operator}" (target: ${n?.to??"javascript"}): ${o}`);let s=n?.to??"javascript";if(s==="interval-js"){let a=e.engine._getCompilationTarget("interval-js");if(a)return a.compile(e,{vars:n?.vars,fallback:!0})}let u=n?.target??e.engine._getCompilationTarget(s)?.createTarget();return R.buildInterpreterFallback(e,o,s,u,n?.vars?new Set(Object.keys(n.vars)):void 0,Iu(i,o))}throw i}}var nre=new WeakMap;function ENe(e,n){let t=nre.get(e);return t===void 0&&(t=e.createTarget().supportedModes??["strict"],nre.set(e,t)),t.includes(n)}function xNe(e){return e===void 0?{options:e,modeFromAlias:!1}:Mu(e)}function SNe(e,n){let t=e.supportedModes??["strict"],r=typeof e.complexLift=="function"&&typeof e.complexIsReal=="function",i=t.includes("auto")&&r&&typeof e.reset=="function";return n===void 0?i?"auto":"strict":n==="auto"&&t.includes("auto")&&!i?"strict":n}var yF=null,bF=null;function VC(e){bF=e}function Vf(){if(!yF){if(!bF)throw new Error("ComputeEngine factory not registered. Import from the main module.");yF=bF()}return yF}function jf(e,n){if(typeof e=="string"){let t=Vf();return t.parse(e,{strict:n?.strict??!1})??t.expr("Nothing")}return qo(e)?e:Vf().expr(e)}function tre(e,n){return Vf().parse(e,n)}function rre(e,n){return Vf().expr(e,n)}function ire(e,n){return jf(e,n).simplify(n)}function ore(e,n){return jf(e,n).evaluate()}function sre(e,n){return jf(e,n).N()}function ure(e,n){Vf().declare(e,n)}function are(e,n){Vf().assign(e,n)}function lre(e,n){return en(jf(e,n))}function fre(e,n,t){return jf(e,t).solve(n)}function cre(e,n){return aa(jf(e,n))}function dre(e,n){return ss(jf(e,n))}function jC(e,n){return BC(jf(e,n),n)}var _Ne=/^(Sin|Cos|Tan|Cot|Sec|Csc)$/;function qC(e){return _Ne.test(e.operator)?!0:g(e)?e.ops.some(qC):!1}function qf(e,...n){return n.includes(e.operator)?!0:g(e)?e.ops.some(t=>qf(t,...n)):!1}function dt(e,n){let t=e.engine;if(g(e)&&e.ops.length>0){let r=e,i=r.ops.map(s=>dt(s,n));i.some((s,u)=>s!==r.ops[u])&&(e=t._fn(r.operator,i))}return n(e)??e}function vF(e,n){if(!g(e)||!g(n))return!1;let t=e.op1,r=n.op1;return t!==void 0&&r!==void 0&&t.isSame(r)}function wNe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(r){if(t==="Sec")return n.One.div(n._fn("Cos",[r]));if(t==="Csc")return n.One.div(n._fn("Sin",[r]))}}function yre(e){return dt(e,wNe)}function CNe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(r){if(t==="Tan")return n._fn("Sin",[r]).div(n._fn("Cos",[r]));if(t==="Cot")return n._fn("Cos",[r]).div(n._fn("Sin",[r]))}}function bre(e){return dt(e,CNe)}function NNe(e){let n=e.engine;if(e.operator!=="Divide"||!g(e))return;let t=e.op1,r=e.op2;if(!(!t||!r)){if(t.operator==="Sin"&&r.operator==="Cos"&&vF(t,r))return g(t)?n._fn("Tan",[t.op1]):void 0;if(t.operator==="Cos"&&r.operator==="Sin"&&vF(t,r))return g(t)?n._fn("Cot",[t.op1]):void 0}}function vre(e){return dt(e,NNe)}function RNe(e){if(g(e,"Negate"))return e.op1;if(g(e,"Multiply")){let n=e.ops.findIndex(t=>t.isSame(-1));if(n>=0){let t=e.ops.filter((r,i)=>i!==n);return t.length===1?t[0]:e.engine._fn("Multiply",t)}}}function ANe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(!r)return;let i=RNe(r);if(i){if(t==="Cos")return n._fn("Cos",[i]);if(t==="Sec")return n._fn("Sec",[i]);if(t==="Sin")return n._fn("Sin",[i]).neg();if(t==="Tan")return n._fn("Tan",[i]).neg();if(t==="Csc")return n._fn("Csc",[i]).neg();if(t==="Cot")return n._fn("Cot",[i]).neg()}}function Ere(e){return dt(e,ANe)}function TNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Sin"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.sub(n._fn("Cos",[i]).pow(2))}function EF(e){return dt(e,TNe)}function INe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Cos"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.sub(n._fn("Sin",[i]).pow(2))}function xre(e){return dt(e,INe)}function kNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Cos"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.add(n._fn("Cos",[i.mul(2)])).div(2)}function Sre(e){return dt(e,kNe)}function MNe(e){let n=e.engine;if(g(e,"Divide")){let r=e.op1,i=e.op2;if(!r||!i||!i.isSame(2))return;if(g(r,"Add")&&r.ops.length===2)return pre(n,r.ops)}let t=r=>!!(r.re===.5&&r.im===0||r.isSame(n.Half));if(g(e,"Multiply")){let r=e.ops.findIndex(i=>t(i));if(r>=0){let i=e.ops.filter((o,s)=>s!==r);if(i.length===1&&i[0].operator==="Add"){let o=i[0];if(g(o)&&o.ops.length===2)return pre(n,o.ops)}}}if(g(e,"Add")&&e.ops.length===2){let r,i,o=!1,s=u=>u.re===-.5&&u.im===0;for(let u of e.ops){if(t(u)){r=u;continue}let a=u,l=!1;if(g(u,"Negate")&&(l=!0,a=u.op1),g(a,"Divide")&&a.op2?.isSame(2)){let f=a.op1;if(f?.operator==="Cos"){i=f,o=l;continue}}if(g(a,"Multiply")){let f=a.ops.findIndex(d=>t(d));if(f>=0){let d=a.ops.filter((p,m)=>m!==f);if(d.length===1&&d[0].operator==="Cos"){i=d[0],o=l;continue}}let c=a.ops.findIndex(d=>s(d));if(c>=0){let d=a.ops.filter((p,m)=>m!==c);if(d.length===1&&d[0].operator==="Cos"){i=d[0],o=!l;continue}}}}if(r&&i){if(!g(i))return;let u=i.op1;if(!u)return;let a;if(g(u,"Multiply")){let l=u.ops.findIndex(f=>f.isSame(2));if(l>=0){let f=u.ops.filter((c,d)=>d!==l);a=f.length===1?f[0]:n._fn("Multiply",f)}}return a?o?n._fn("Sin",[a]).pow(2):n._fn("Cos",[a]).pow(2):void 0}}}function pre(e,n){let t=-1,r=-1,i=!1;for(let a=0;a<n.length;a++)if(n[a].isSame(1))t=a;else if(n[a].operator==="Cos")r=a,i=!1;else if(n[a].operator==="Negate"){let l=n[a];g(l)&&l.op1?.operator==="Cos"&&(r=a,i=!0)}if(t<0||r<0)return;let o;if(i){let a=n[r];if(!g(a))return;o=a.op1}else o=n[r];if(!g(o))return;let s=o.op1;if(!s)return;let u;if(g(s,"Multiply")){let a=s.ops.findIndex(l=>l.isSame(2));if(a>=0){let l=s.ops.filter((f,c)=>c!==a);u=l.length===1?l[0]:e._fn("Multiply",l)}}if(u)return i?e._fn("Sin",[u]).pow(2):e._fn("Cos",[u]).pow(2)}function xF(e){return dt(e,MNe)}function $Ne(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i];if(!g(o)||!g(s))continue;let u=o.op1,a=s.op1;if(!u||!a)continue;let l;if(o.operator==="Sin"&&s.operator==="Cos"?l=n._fn("Sin",[u.add(a)]).add(n._fn("Sin",[u.sub(a)])).div(2):o.operator==="Cos"&&s.operator==="Sin"?l=n._fn("Sin",[u.add(a)]).sub(n._fn("Sin",[u.sub(a)])).div(2):o.operator==="Cos"&&s.operator==="Cos"?l=n._fn("Cos",[u.add(a)]).add(n._fn("Cos",[u.sub(a)])).div(2):o.operator==="Sin"&&s.operator==="Sin"&&(l=n._fn("Cos",[u.sub(a)]).sub(n._fn("Cos",[u.add(a)])).div(2)),l){let f=t.filter((c,d)=>d!==r&&d!==i);return f.length===0?l:l.mul(f.length===1?f[0]:n._fn("Multiply",f))}}}function _re(e){return dt(e,$Ne)}function ONe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i],u;if(o.operator==="Sin"&&s.operator==="Sin"){if(!g(o)||!g(s))continue;let a=o.op1,l=s.op1;if(a&&l){let f=a.add(l).div(2),c=a.sub(l).div(2);u=n._fn("Sin",[f]).mul(n._fn("Cos",[c])).mul(2)}}else if(o.operator==="Cos"&&s.operator==="Cos"){if(!g(o)||!g(s))continue;let a=o.op1,l=s.op1;if(a&&l){let f=a.add(l).div(2),c=a.sub(l).div(2);u=n._fn("Cos",[f]).mul(n._fn("Cos",[c])).mul(2)}}else if(o.operator==="Sin"&&s.operator==="Negate"){if(!g(o)||!g(s)||s.op1?.operator!=="Sin")continue;let a=s.op1;if(!g(a))continue;let l=o.op1,f=a.op1;if(l&&f){let c=l.add(f).div(2),d=l.sub(f).div(2);u=n._fn("Cos",[c]).mul(n._fn("Sin",[d])).mul(2)}}else if(o.operator==="Cos"&&s.operator==="Negate"){if(!g(o)||!g(s)||s.op1?.operator!=="Cos")continue;let a=s.op1;if(!g(a))continue;let l=o.op1,f=a.op1;if(l&&f){let c=l.add(f).div(2),d=l.sub(f).div(2);u=n._fn("Sin",[c]).mul(n._fn("Sin",[d])).mul(-2)}}if(u){let a=t.filter((l,f)=>f!==r&&f!==i);return a.length===0?u:u.add(a.length===1?a[0]:n._fn("Add",a))}}}function zC(e){return dt(e,ONe)}function PNe(e){let n=e.engine,t=e.operator;if(t!=="Sin"&&t!=="Cos"||!g(e))return;let r=e.op1;if(r){if(g(r,"Add")&&r.ops.length===2){let[i,o]=r.ops;return t==="Sin"?n._fn("Sin",[i]).mul(n._fn("Cos",[o])).add(n._fn("Cos",[i]).mul(n._fn("Sin",[o]))):n._fn("Cos",[i]).mul(n._fn("Cos",[o])).sub(n._fn("Sin",[i]).mul(n._fn("Sin",[o])))}if(g(r,"Subtract")){let i=r.op1,o=r.op2;return!i||!o?void 0:t==="Sin"?n._fn("Sin",[i]).mul(n._fn("Cos",[o])).sub(n._fn("Cos",[i]).mul(n._fn("Sin",[o]))):n._fn("Cos",[i]).mul(n._fn("Cos",[o])).add(n._fn("Sin",[i]).mul(n._fn("Sin",[o])))}}}function wre(e){return dt(e,PNe)}function DNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i],u=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Sin"&&A.operator==="Cos"?{sin:_,cos:A}:_.operator==="Cos"&&A.operator==="Sin"?{sin:A,cos:_}:null},a=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Cos"&&A.operator==="Cos"?{cos1:_,cos2:A}:null},l=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Sin"&&A.operator==="Sin"?{sin1:_,sin2:A}:null},f=S=>g(S)?S.op1:void 0,c=u(o),d=u(s),p=g(o,"Negate")&&o.op1?u(o.op1):null,m=g(s,"Negate")&&s.op1?u(s.op1):null;if(c&&d){let S=f(c.sin),w=f(c.cos),_=f(d.sin),A=f(d.cos);if(S&&w&&_&&A&&S.isSame(A)&&w.isSame(_)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(c&&m){let S=f(c.sin),w=f(c.cos),_=f(m.sin),A=f(m.cos);if(S&&w&&_&&A&&S.isSame(A)&&w.isSame(_)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(p&&d){let S=f(p.sin),w=f(p.cos),_=f(d.sin),A=f(d.cos);if(S&&w&&_&&A&&_.isSame(w)&&A.isSame(S)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[_.sub(A)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}let h=a(o),y=a(s),b=l(o),v=l(s),E=g(o,"Negate")&&o.op1?l(o.op1):null,x=g(s,"Negate")&&s.op1?l(s.op1):null;if(h&&x){let S=f(h.cos1),w=f(h.cos2),_=f(x.sin1),A=f(x.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(E&&y){let S=f(y.cos1),w=f(y.cos2),_=f(E.sin1),A=f(E.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(h&&v){let S=f(h.cos1),w=f(h.cos2),_=f(v.sin1),A=f(v.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(b&&y){let S=f(y.cos1),w=f(y.cos2),_=f(b.sin1),A=f(b.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}}}function UC(e){return dt(e,DNe)}function FNe(e){let n=e.engine,t=e.operator;if(t!=="Sin"&&t!=="Cos"||!g(e))return;let r=e.op1;if(r&&g(r,"Multiply")){let i=r.ops,o=i.findIndex(s=>s.isSame(2));if(o>=0){let s=i.filter((a,l)=>l!==o),u=s.length===1?s[0]:n._fn("Multiply",s);return t==="Sin"?n._fn("Sin",[u]).mul(n._fn("Cos",[u])).mul(2):n._fn("Cos",[u]).pow(2).mul(2).sub(n.One)}}}function SF(e){return dt(e,FNe)}function LNe(e){let n=e.engine;if(g(e,"Multiply")){let t=e.ops,r=t.findIndex(i=>i.isSame(2));if(r>=0){let i=t.filter((u,a)=>a!==r),o,s;for(let u of i)u.operator==="Sin"&&!o?o=u:u.operator==="Cos"&&!s&&(s=u);if(o&&s&&vF(o,s)){if(!g(o))return;let u=i.filter(l=>l!==o&&l!==s),a=n._fn("Sin",[o.op1.mul(2)]);return u.length===0?a:a.mul(u.length===1?u[0]:n._fn("Multiply",u))}}}if(g(e,"Add")&&e.ops.length===2){let[t,r]=e.ops;if(g(t,"Power")&&t.op1?.operator==="Cos"&&t.op2?.isSame(2)&&r.operator==="Negate"&&g(r)&&r.op1?.operator==="Power"&&g(r.op1)&&r.op1.op1?.operator==="Sin"&&r.op1.op2?.isSame(2)){let a=t.op1,l=r.op1;if(g(a)&&g(l)){let f=l.op1;if(g(f)){let c=a.op1,d=f.op1;if(c&&d&&c.isSame(d))return n._fn("Cos",[c.mul(2)])}}}let i=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Cos"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}},o=i(t);if(o&&(r.isSame(-1)||g(r,"Negate")&&r.op1?.isSame(1)))return n._fn("Cos",[o.mul(2)]);if(o=i(r),o&&(t.isSame(-1)||g(t,"Negate")&&t.op1?.isSame(1)))return n._fn("Cos",[o.mul(2)]);let s=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Sin"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}};if(t.isSame(1)&&g(r,"Negate")&&r.op1){let a=s(r.op1);if(a)return n._fn("Cos",[a.mul(2)])}if(r.isSame(1)&&g(t,"Negate")&&t.op1){let a=s(t.op1);if(a)return n._fn("Cos",[a.mul(2)])}let u=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(-2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Sin"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}};if(t.isSame(1)){let a=u(r);if(a)return n._fn("Cos",[a.mul(2)])}if(r.isSame(1)){let a=u(t);if(a)return n._fn("Cos",[a.mul(2)])}}}function Cre(e){return dt(e,LNe)}function mre(e){let n=!1,t=e;if(g(t,"Negate")&&t.op1)n=!0,t=t.op1;else if(g(t,"Multiply")&&t.ops.length===2){let s=t.ops.findIndex(u=>u.isSame(-1));s>=0&&(n=!0,t=t.ops[1-s])}if(!g(t,"Power"))return;let r=t.op1,i=t.op2;if(!r||!i||!(i.isSame(2)||i.isSame(4))||r.operator!=="Sin"&&r.operator!=="Cos"||!g(r))return;let o=r.op1;if(o)return{func:r.operator,arg:o,power:i.isSame(2)?2:4,negated:n}}function BNe(e){let n=e.engine;if(!g(e,"Add")||e.ops.length!==2)return;let t=mre(e.ops[0]),r=mre(e.ops[1]);if(!t||!r||t.negated===r.negated||t.func===r.func||t.power!==r.power||!t.arg.isSame(r.arg))return;let i=t.negated?r:t,o=n._fn("Cos",[i.arg.mul(2)]);return i.func==="Cos"?o:o.neg()}function Nre(e){return dt(e,BNe)}function VNe(e){let n=e.engine;if(e.operator!=="Tan"||!g(e))return;let t=e.op1;if(t){if(g(t,"Add")&&t.ops.length===2){let[r,i]=t.ops,o=n._fn("Tan",[r]),s=n._fn("Tan",[i]);return o.add(s).div(n.One.sub(o.mul(s)))}if(g(t,"Subtract")){let r=t.op1,i=t.op2;if(!r||!i)return;let o=n._fn("Tan",[r]),s=n._fn("Tan",[i]);return o.sub(s).div(n.One.add(o.mul(s)))}}}function Rre(e){return dt(e,VNe)}var jNe=[{value:0,angle:[0,1]},{value:1/Math.sqrt(3),angle:[1,6]},{value:1,angle:[1,4]},{value:Math.sqrt(3),angle:[1,3]},{value:2-Math.sqrt(3),angle:[1,12]},{value:2+Math.sqrt(3),angle:[5,12]}];function qNe(e,n=1e-10){for(let t of jNe)if(Math.abs(t.value-e)<n)return t.angle}function zNe(e){if(e.operator!=="Multiply"||!g(e))return;let n=e.ops;if(n.length<2)return;let t=[],r=1;for(let i of n)if(g(i,"Tan")&&i.op1)t.push(i.op1);else if(g(i,"Negate")&&i.op1?.operator==="Sqrt"){let o=i.op1;if(g(o)){let s=o.op1;if(T(s)&&typeof s.re=="number")r*=-Math.sqrt(s.re);else return}else return}else if(g(i,"Sqrt")){let o=i.op1;if(o&&T(o)&&typeof o.re=="number")r*=Math.sqrt(o.re);else return}else if(T(i)&&typeof i.re=="number")r*=i.re;else return;if(t.length===2)return[r,t[0],t[1]]}function gre(e){if(g(e,"Multiply")){let n=!1,t;for(let r of e.ops)if(C(r,"Pi"))n=!0;else if(T(r)&&typeof r.re=="number"){let i=r.re;for(let o=1;o<=36;o++){let s=Math.round(i*o);if(Math.abs(s/o-i)<1e-10){t=[s,o];break}}}if(n&&t)return t}if(C(e,"Pi"))return[1,1]}function UNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length!==3)return;let r=[],i;for(let v=0;v<t.length;v++){let E=t[v];if(g(E,"Tan")&&E.op1)r.push({arg:E.op1,index:v});else{let x=zNe(E);x&&(i={coef:x[0],arg1:x[1],arg2:x[2],index:v})}}if(r.length!==2||!i)return;let[o,s]=r,u=o.arg.isSame(i.arg1)||o.arg.isSame(i.arg2),a=s.arg.isSame(i.arg1)||s.arg.isSame(i.arg2),l=o.arg.isSame(i.arg2)||o.arg.isSame(i.arg1),f=s.arg.isSame(i.arg2)||s.arg.isSame(i.arg1);if(!(u&&f||a&&l))return;let c=-i.coef;if(c<=0)return;let d=qNe(c);if(!d)return;let p=gre(o.arg),m=gre(s.arg);if(!p||!m)return;let h=hre(hre(p[1],m[1]),d[1]);if(p[0]*(h/p[1])+m[0]*(h/m[1])+d[0]*(h/d[1])!==h)return;let b=n._fn("Multiply",[n.number([d[0],d[1]]),n.symbol("Pi")]);return n._fn("Tan",[b]).neg()}function hre(e,n){return Math.abs(e*n)/HNe(e,n)}function HNe(e,n){for(e=Math.abs(e),n=Math.abs(n);n;){let t=n;n=e%n,e=t}return e}function Are(e){return dt(e,UNe)}function GNe(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i];if(!g(o)||!g(s))continue;let u=o.op1,a=s.op1;if(!(!u||!a)){if(o.operator==="Tan"&&s.operator==="Tan"){let l=o,f=s,c=n._fn("Cot",[u.add(a)]),d=n.One.sub(l.add(f).mul(c)),p=t.filter((m,h)=>h!==r&&h!==i);return p.length===0?d:d.mul(p.length===1?p[0]:n._fn("Multiply",p))}if(o.operator==="Cot"&&s.operator==="Cot"){let l=o,f=s,c=n._fn("Cot",[u.add(a)]),d=n.One.add(l.add(f).mul(c)),p=t.filter((m,h)=>h!==r&&h!==i);return p.length===0?d:d.mul(p.length===1?p[0]:n._fn("Multiply",p))}}}}function Tre(e){return dt(e,GNe)}function WNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||!r.isSame(2)||!g(t))return;let i=t.op1;if(i){if(t.operator==="Tan")return n._fn("Sec",[i]).pow(2).sub(n.One);if(t.operator==="Cot")return n._fn("Csc",[i]).pow(2).sub(n.One);if(t.operator==="Sec")return n.One.add(n._fn("Tan",[i]).pow(2));if(t.operator==="Csc")return n.One.add(n._fn("Cot",[i]).pow(2))}}function Ire(e){return dt(e,WNe)}function YNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length!==2)return;let r=d=>{let p=!1,m=d;if(g(d,"Negate")&&(p=!0,m=d.op1),!g(m)||m.operator!=="Power"||!m.op2?.isSame(2))return null;let h=m.op1;if(!g(h)||!h.op1)return null;let y=h.operator;return["Tan","Cot","Sec","Csc"].includes(y)?{func:y,arg:h.op1,neg:p}:null},i=r(t[0]),o=r(t[1]);if(i&&o&&i.arg.isSame(o.arg)){if(i.func==="Cot"&&!i.neg&&o.func==="Csc"&&o.neg||i.func==="Csc"&&i.neg&&o.func==="Cot"&&!o.neg)return n.number(-1);if(i.func==="Csc"&&!i.neg&&o.func==="Cot"&&o.neg||i.func==="Cot"&&i.neg&&o.func==="Csc"&&!o.neg)return n.One;if(i.func==="Tan"&&!i.neg&&o.func==="Sec"&&o.neg||i.func==="Sec"&&i.neg&&o.func==="Tan"&&!o.neg)return n.number(-1);if(i.func==="Sec"&&!i.neg&&o.func==="Tan"&&o.neg||i.func==="Tan"&&i.neg&&o.func==="Sec"&&!o.neg)return n.One}let s=-1,u=-1,a=!1;for(let d=0;d<t.length;d++){let p=t[d];p.isSame(1)?(s=d,a=!1):p.isSame(-1)||g(p,"Negate")&&p.op1?.isSame(1)?(s=d,a=!0):g(p,"Power")&&p.op2?.isSame(2)&&(u=d)}if(s<0||u<0)return;let l=t[u];if(!g(l))return;let f=l.op1;if(!f||!g(f))return;let c=f.op1;if(c){if(f.operator==="Sec"&&a)return n._fn("Tan",[c]).pow(2);if(f.operator==="Csc"&&a)return n._fn("Cot",[c]).pow(2);if(f.operator==="Tan"&&!a)return n._fn("Sec",[c]).pow(2);if(f.operator==="Cot"&&!a)return n._fn("Csc",[c]).pow(2)}}function _F(e){return dt(e,YNe)}function ZNe(e){let n=e.engine;if(!g(e,"Multiply"))return[1,n.One,e];for(let t=0;t<e.ops.length;t++){let r=e.ops[t],i;if(T(r)&&typeof r.re=="number"&&r.im===0&&(i=r.re),i!==void 0){let o=e.ops.filter((u,a)=>a!==t),s=o.length===1?o[0]:n._fn("Multiply",o);return[i,r,s]}}return[1,n.One,e]}function JNe(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(t.length<2)return;let r=[],i=[];for(let _ of t)if(g(_,"Cos")&&_.op1){let A=ZNe(_.op1);A?r.push({arg:A[2],numericMult:A[0],symbolicCoeff:A[1]}):r.push({arg:_.op1,numericMult:1,symbolicCoeff:n.One})}else i.push(_);if(r.length<2)return;let o=r[0].arg,s=r.filter(_=>_.arg.isSame(o)),u=r.filter(_=>!_.arg.isSame(o));if(s.length<2)return;s.sort((_,A)=>_.numericMult-A.numericMult);let a=[],l=[],f=[...s],c=f[0].numericMult;if(c>0){a.push(f[0]);let _=new Set([0]),A=c*2;for(;;){let N=f.findIndex((I,B)=>!_.has(B)&&Math.abs(I.numericMult-A)<1e-10);if(N===-1)break;a.push(f[N]),_.add(N),A*=2}l=f.filter((N,I)=>!_.has(I))}if(a.length<2)return;let d=a[0].numericMult,p=[...i];for(let _ of l){let A=_.symbolicCoeff.isSame(n.One)?_.arg:n._fn("Multiply",[_.symbolicCoeff,_.arg]);p.push(n._fn("Cos",[A]))}for(let _ of u){let A=_.symbolicCoeff.isSame(n.One)?_.arg:n._fn("Multiply",[_.symbolicCoeff,_.arg]);p.push(n._fn("Cos",[A]))}let m=a.length,h=a[0].symbolicCoeff,y=Math.pow(2,m);if(C(o,"Pi")){let _=1/(y+1);if(Math.abs(d-_)<1e-10){let A=n.number([1,y]);return p.length===0?A:A.mul(p.length===1?p[0]:n._fn("Multiply",p))}}let b=h.mul(y),v=h.isSame(n.One)?o:n._fn("Multiply",[h,o]),E=n._fn("Multiply",[b,o]),x=n._fn("Sin",[E]),S=n._fn("Sin",[v]),w=x.div(n.number(y).mul(S));return p.length===0?w:w.mul(p.length===1?p[0]:n._fn("Multiply",p))}function kre(e){return dt(e,JNe)}function KNe(e){if(g(e,"Power")&&e.op2?.isSame(2)){let n=e.op1;if(g(n,"Sin")&&n.op1)return{func:"Sin",arg:n.op1,coef:1};if(g(n,"Cos")&&n.op1)return{func:"Cos",arg:n.op1,coef:1}}if(g(e,"Multiply")){let n=1,t;for(let r of e.ops)if(g(r,"Power")&&r.op2?.isSame(2)){let i=r.op1;(i?.operator==="Sin"||i?.operator==="Cos")&&(t=r)}else typeof r.re=="number"&&r.im===0&&(n*=r.re);if(g(t)){let r=t.op1;if(g(r,"Sin")&&r.op1)return{func:"Sin",arg:r.op1,coef:n};if(g(r,"Cos")&&r.op1)return{func:"Cos",arg:r.op1,coef:n}}}return null}function QNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length<2)return;let r=[],i=[],o=[];for(let s=0;s<t.length;s++){let u=t[s],a=KNe(u);a?r.push({...a,index:s}):typeof u.re=="number"&&u.im===0&&T(u)?o.push({value:u.re,index:s}):i.push({expr:u,index:s})}for(let s=0;s<r.length;s++)for(let u=s+1;u<r.length;u++){let a=r[s],l=r[u];if(a.arg.isSame(l.arg)&&(a.func==="Sin"&&l.func==="Cos"||a.func==="Cos"&&l.func==="Sin")&&Math.abs(a.coef-l.coef)<1e-10){let f=a.coef,c=new Set([a.index,l.index]),d=t.filter((p,m)=>!c.has(m));return d.length===0?n.number(f):f===1?n._fn("Add",[n.One,...d]):n._fn("Add",[n.number(f),...d])}}for(let s of r)if(s.coef<0){let u=Math.abs(s.coef);for(let a of o)if(Math.abs(a.value-u)<1e-10){let l=new Set([s.index,a.index]),f=t.filter((p,m)=>!l.has(m)),c=s.func==="Sin"?"Cos":"Sin",d=n._fn(c,[s.arg]).pow(2).mul(u);return f.length===0?d:n._fn("Add",[d,...f])}}}function Mre(e){return dt(e,QNe)}var XNe=new Set(["Sin","Cos","Tan","Cot","Sec","Csc"]);function wF(e){let n=0;if(XNe.has(e.operator)&&(n=1),g(e))for(let t of e.ops)n+=wF(t);return n}function CF(e){if(C(e)||T(e))return 1;let n=1;if(g(e))for(let t of e.ops)n+=CF(t);return n}function $re(e){let n=wF(e),t=CF(e);return n*1e3+t}var Ore=$re;function NF(e,n){if(e.length===0)throw new Error("bestOf called with empty array");if(e.length===1)return e[0];let t=e[0],r=n(t);for(let i=1;i<e.length;i++){let o=n(e[i]);o<r&&(t=e[i],r=o)}return t}function U0(e,n){let t=n(e);return t.isSame(e)?null:t}function Pre(e,n){let t=U0(e,EF),r=U0(e,xre),i=[e];return t&&i.push(t),r&&i.push(r),NF(i,n)}function eRe(e,n){return Pre(e,n)}function nRe(e,n){let t=U0(e,_re),r=[e];if(t){r.push(t);let i=U0(t,UC);i&&r.push(i)}return NF(r,n)}function tRe(e,n){let t=U0(e,UC),r=[e];return t&&r.push(t),NF(r,n)}function rRe(e,n){let t=Rre(e);return t=Tre(t),t}function iRe(e,n){let t=e;return t=wre(t),t=SF(t),t=EF(t),t=Sre(t),t=SF(t),t=nRe(t,n),t=Pre(t,n),t=zC(t),t=eRe(t,n),t=zC(t),t=tRe(t,n),t}function Dre(e,n){if(!qC(e))return;let t=n?.measure??Ore,r=n?.maxIterations??100,i=e,o=0,s=e,u=t(e),a=S=>{let w=t(S);w<u&&(s=S,u=w)};i=Ere(i),a(i);let l=_F(i);a(l);let f=Ire(i);a(f),i=s;let c=xF(i);if(a(c),i=s,qf(i,"Sec","Csc")&&(i=yre(i),s=i,u=t(i)),qf(i,"Tan","Cot")){let S=rRe(i,t);a(S),i=S}if(qf(i,"Tan","Cot")&&(i=bre(i),a(i)),qf(i,"Sin","Cos")){let S=zC(i);a(S),i=s}if(qf(i,"Sin","Cos")){let S=t(i);for(;o<r;){o++;let w=iRe(i,t),_=t(w);if(a(w),_>=S)break;i=w,S=_}}let d=vre(s);a(d);let p=Cre(s);a(p);let m=Nre(s);a(m);let h=kre(s);a(h);let y=xF(s);a(y);let b=_F(s);a(b);let v=UC(s);a(v);let E=Mre(s);a(E);let x=Are(s);if(a(x),s.operator==="Add"||s.operator==="Multiply"){let S=e.engine.expr(s.json);a(S)}if(!s.isSame(e))return{value:s,because:"fu"}}function RF(e,n){if(Array.isArray(e)){if(e[0]==="InvisibleOperator")for(let t=1;t+1<e.length;t++){let r=e[t],i=e[t+1];typeof r=="string"&&Array.isArray(i)&&i[0]==="Delimiter"&&n.add(r)}for(let t of e)RF(t,n);return}e!==null&&typeof e=="object"&&"fn"in e&&Array.isArray(e.fn)&&RF(e.fn,n)}var zf=class e{static _latexSyntaxFactory=null;True;False;Pi;E;Nothing;Missing;Zero;One;Half;NegativeOne;Two;I;NaN;PositiveInfinity;NegativeInfinity;ComplexInfinity;_numericConfiguration;_cacheStore=new gw;_runtimeState=new PC;_boxingState=new DC;_configurationLifecycle=new $C;_cost;_integrationProvider;_simplificationRules=new Ng([...aJ]);_solveRules=new Ng([...s9]);_harmonizationRules=new Ng([...f9]);_compilationTargets=new kC;_fuAlgorithm=Dre;_customLibraryOperators=new Set;_commonSymbols={Pi:null,True:null,False:null,All:null,Nothing:null,Missing:null,None:null,Undefined:null,ExponentialE:null};_commonNumbers={"-5":null,"-4":null,"-3":null,"-2":null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,12:null,36:null};_commonTypes=new Map;_evalContextStack=[];get context(){return this._evalContextStack[this._evalContextStack.length-1]}get contextStack(){return[...this._evalContextStack]}set contextStack(n){this._evalContextStack=[...n]}_typeRegistry=Object.create(null);_protocolRegistry=Object.create(null);_conformanceVersionCounter=0;get _conformanceVersion(){return this._conformanceVersionCounter}_noteConformanceRegistryChange(){this._conformanceVersionCounter+=1}_staticTypeCheckDepth=0;_epsilBatchId=void 0;_staticAssignmentEvidence=void 0;_epsilDeclarationRoute=!1;_typeRegistryRollbackPoint(){let n=this._typeRegistry,t=new Set(Object.keys(n)),r=[...t].map(i=>{let o=n[i];return{r:o,def:o.def,alias:o.alias,typeParams:o.typeParams,varianceState:o._varianceState,varianceBlockedOn:o._varianceBlockedOn,declaredByStatement:o._declaredByStatement,forwardArity:o._forwardArity===void 0?void 0:new Set(o._forwardArity),sumOf:o._sumOf,sumVariants:o._sumVariants,declOrigin:o._declOrigin}});return()=>{let i=!1;for(let o of Object.keys(n))t.has(o)||(delete n[o],i=!0);for(let o of r){let s=o.r;s.def!==o.def&&(i=!0),s.def=o.def,s.alias!==o.alias&&(i=!0),s.alias=o.alias,s.typeParams!==o.typeParams&&(i=!0),o.typeParams===void 0?delete s.typeParams:s.typeParams=o.typeParams,s._varianceState!==o.varianceState&&(i=!0),o.varianceState===void 0?delete s._varianceState:s._varianceState=o.varianceState,s._varianceBlockedOn!==o.varianceBlockedOn&&(i=!0),o.varianceBlockedOn===void 0?delete s._varianceBlockedOn:s._varianceBlockedOn=o.varianceBlockedOn;let u=s;u._declaredByStatement!==o.declaredByStatement&&(i=!0),o.declaredByStatement===void 0?delete u._declaredByStatement:u._declaredByStatement=o.declaredByStatement;let a=s,l=a._forwardArity,f=o.forwardArity;(l===void 0!=(f===void 0)||l!==void 0&&f!==void 0&&(l.size!==f.size||[...f].some(c=>!l.has(c))))&&(i=!0),f===void 0?delete a._forwardArity:a._forwardArity=f,s._sumOf!==o.sumOf&&(i=!0),o.sumOf===void 0?delete s._sumOf:s._sumOf=o.sumOf,s._sumVariants!==o.sumVariants&&(i=!0),o.sumVariants===void 0?delete s._sumVariants:s._sumVariants=o.sumVariants,o.declOrigin===void 0?delete s._declOrigin:s._declOrigin=o.declOrigin,s.name in n||(n[s.name]=s,i=!0)}i&&this._noteStateEvent({kind:"config"})}}_protocolRegistryRollbackPoint(){let n=this._protocolRegistry,t=new Set(Object.keys(n)),r=[...t].map(i=>{let o=n[i];return{r:o,members:o.members,conformances:[...o.conformances],edges:o.conformances.map(s=>({c:s,impl:s.impl,authored:s._authored,origin:s._implOrigin,pending:s.pending,pendingReason:s._pendingReason})),declaredByStatement:o.declaredByStatement,declOrigin:o._declOrigin}});return()=>{let i=!1;for(let o of Object.keys(n))t.has(o)||(delete n[o],i=!0);for(let o of r){let s=o.r;s.members!==o.members&&(i=!0),s.members=o.members,s.declaredByStatement!==o.declaredByStatement&&(i=!0),s.declaredByStatement=o.declaredByStatement,o.declOrigin===void 0?delete s._declOrigin:s._declOrigin=o.declOrigin,(s.conformances.length!==o.conformances.length||o.conformances.some((u,a)=>s.conformances[a]!==u))&&(i=!0),s.conformances=o.conformances;for(let u of o.edges)u.c.impl!==u.impl&&(i=!0),u.impl===void 0?delete u.c.impl:u.c.impl=u.impl,u.authored===void 0?delete u.c._authored:u.c._authored=u.authored,u.origin===void 0?delete u.c._implOrigin:u.c._implOrigin=u.origin,u.c.pending!==u.pending&&(i=!0),u.c.pending=u.pending,u.pendingReason===void 0?delete u.c._pendingReason:u.c._pendingReason=u.pendingReason;s.name in n||(n[s.name]=s,i=!0)}i&&(this._noteStateEvent({kind:"config"}),this._noteConformanceRegistryChange())}}_rollbackFrames=[];_withRolledBackInference(n,t){this._inferenceTxDepth>0;let r=new sL({boxingRepairDepthAtOpen:this._boxingState.frameDepth(),forbidsRepairs:t?.forbidsRepairs});this._rollbackFrames.push(r);let i;try{return n()}catch(o){throw i={error:o},o}finally{let o=this._rollbackFrames.pop(),s=r.rollback();if(this._boxingState.hasRepairRequestedAtOrAbove(r.boxingRepairDepthAtOpen),s!==void 0&&this._debugBindings)throw new Error("Inference rollback failed: an undo entry threw while unwinding the frame",{cause:i?.error??s.error})}}_withBoxingPassWindow(n){uw(this);try{return n()}finally{aw(this)}}declareProtocol(n,t){PE(this,n,t)}declareProtocolImplementation(n,t,r,i){FB(this,n,t,r,i)}__typeResolver;get _typeResolver(){return this.__typeResolver??=Kte(this),this.__typeResolver}declareType(n,t,r){km(this,n,t,r)}get trace(){return this._evalContextStack.map(n=>n.name).filter(n=>n!==void 0).reverse()}get _anyVersion(){return this._configurationLifecycle.anyVersion}get _semanticVersion(){return this._configurationLifecycle.semanticVersion}get _worldVersion(){return this._configurationLifecycle.worldVersion}get _callableVersion(){return this._configurationLifecycle.callableVersion}get _ephemeralWriteDepth(){return this._configurationLifecycle.ephemeralWriteDepth}set _ephemeralWriteDepth(n){this._configurationLifecycle.ephemeralWriteDepth=n}get _factSuppressionDepth(){return this._configurationLifecycle.factSuppressionDepth}set _factSuppressionDepth(n){this._configurationLifecycle.factSuppressionDepth=n}_withoutFacts(n){if(n.constructor.name==="AsyncFunction")throw new Error("A fact-blind bracket must be synchronous: an async thunk is refused before it runs, because everything after its first await would see the assumptions again");let t=this._configurationLifecycle;t.factSuppressionDepth+=1;let r;try{r=n()}finally{t.factSuppressionDepth-=1}if(typeof r?.then=="function")throw Promise.resolve(r).then(void 0,()=>{}),new Error("A fact-blind bracket must be synchronous: its thunk returned a promise, whose work would run after the bracket closed and would see the assumptions again");return r}_factsHidden(){if(this._factSuppressionDepth===0)return!1;let n=this.context;return n===void 0?!1:(n.assumptions?.size??0)!==0||(n.assumedValues?.size??0)!==0}_cacheGeneration(){return this._anyVersion*2+(this._factsHidden()?1:0)}_nextFactId(){return this._factIdCounter+=1,this._factIdCounter}_factIdCounter=0;get _scratchDeclarationScopes(){return this._configurationLifecycle.scratchDeclarationScopes}_checkpointWindow=void 0;_checkpointStack=[];_checkpointPoisoned=!1;_nextCheckpointId=1;_invalidateCheckpointsOnFrameDiscard(n){c6(this,n)}_inFlightAsyncEvaluations=0;_evaluationDepth=0;_objectStoreEpoch=0;_applicationMemo=void 0;checkpoint(n){return l6(this,n)}restore(n){f6(this,n)}discard(n){d6(this,n)}_noteStateEvent(n){dL&&this._checkpointWindow?.noteEvent(n.kind),this._configurationLifecycle.noteStateEvent(n)}_inferenceTxDepth=0;_hasAsyncOnlyOperator=!1;_boxingEpoch=0;_debugBindings=uL();_freshlyInferred=null;_inferenceCause=null;_noteInferenceWrite(n){let t=this._inferenceCause;if(t&&t.expr===void 0&&(t.expr=this._fn(t.operator,t.ops.map(r=>this.expr(r,{form:"raw"})),{canonical:!1})),Ls(this,n.target,{type:n.to,kind:n.kind,axis:"type",cause:t?.expr,epoch:Bs(this)}),n.valueDef!==void 0&&n.from.isUnknown&&this._inferenceTxDepth>0){let r=this._freshlyInferred??=new Set,i=Lt(this);if(i!==void 0&&!r.has(n.valueDef)){let o=n.valueDef;i.record({undo:()=>r.delete(o)})}r.add(n.valueDef)}this._narrowingSink?._recordNarrowing(n.name,n.binding,n.from,n.to)}strict;get jit(){return this._jit}set jit(n){n!==this._jit&&(this._jit=n,this._noteStateEvent({kind:"config"}))}_jit="auto";static getStandardLibrary(n){return ew(n)}constructor(n){if(n!==void 0&&typeof n!="object")throw Error("Unexpected argument");this.strict=!0,this.jit="auto",this._numericConfiguration=new OC({precision:n?.precision,tolerance:n?.tolerance??"auto",angularUnit:"rad"});let t=new FC(this),r=t.initializeCommonNumbers();this.Zero=r.Zero,this.One=r.One,this.Half=r.Half,this.NegativeOne=r.NegativeOne,this.Two=r.Two,this.NaN=r.NaN,this.PositiveInfinity=r.PositiveInfinity,this.NegativeInfinity=r.NegativeInfinity,this.I=r.I,this.ComplexInfinity=r.ComplexInfinity,this._reset(),this.pushScope(void 0,"system"),this.declareType("limits","expression<Limits>"),this.declareType("distribution","expression<NormalDistribution> | expression<BinomialDistribution> | expression<PoissonDistribution> | expression<UniformDistribution> | expression<ExponentialDistribution>",{alias:!0}),t.bootstrapLibraries(n?.libraries);let i=t.initializeCommonSymbolBindings(this._commonSymbols);this.True=i.True,this.False=i.False,this.Pi=i.Pi,this.E=i.E,this.Nothing=i.Nothing,this.Missing=i.Missing,this.pushScope(void 0,"global"),this._compilationTargets.registerDefaults(),n?.latexSyntax&&(this._latexSyntax=n.latexSyntax),n?.latexOptions&&(t2(n.latexOptions),this._latexOptions={...n.latexOptions}),z5(this)}toJSON(){return"[ComputeEngine]"}[Symbol.toStringTag]="ComputeEngine";_reset(){this._configurationLifecycle.reset({refreshNumericConstants:()=>{},resetCommonSymbols:()=>KJ(this._commonSymbols),purgeCaches:()=>this._cacheStore.purgeValues()})}_listenToConfigurationChange(n){return this._configurationLifecycle.listen(n)}_compile(n,t){return BC(n,t)}_getCompilationTarget(n){return this._compilationTargets.get(n)}_listCompilationTargets(){return this._compilationTargets.list()}_registerCompilationTarget(n,t){this._compilationTargets.register(n,t)}_unregisterCompilationTarget(n){this._compilationTargets.unregister(n)}get precision(){return this._numericConfiguration.precision}set precision(n){this._numericConfiguration.setPrecision(n)&&this._reset()}get angularUnit(){return this._numericConfiguration.angularUnit}set angularUnit(n){this._numericConfiguration.setAngularUnit(n)&&this._reset()}withTimeLimit(n,t){let r=typeof n=="number"?n:n.ms,i=typeof n=="number"?void 0:n.label,o=this._runtimeState.deadlineFrame,s=Date.now()+r,u=[...o?.spans??[],...i!==void 0?[i]:[]],a=o!==void 0&&o.at<=s?{at:o.at,owner:o.owner,spans:u}:{at:s,owner:i,spans:u};this._runtimeState.deadlineFrame=a;try{return t()}finally{this._runtimeState.deadlineFrame=o}}get _deadline(){return this._runtimeState.deadline}set _deadline(n){this._runtimeState.deadline=n}get _deadlineFrame(){return this._runtimeState.deadlineFrame}set _deadlineFrame(n){this._runtimeState.deadlineFrame=n}get _timeRemaining(){return this._runtimeState.timeRemaining}get _mapAutoCompileStats(){return ni}get iterationLimit(){return this._runtimeState.iterationLimit}set iterationLimit(n){n!==this._runtimeState.iterationLimit&&(this._runtimeState.iterationLimit=n,this._noteStateEvent({kind:"config"}))}get recursionLimit(){return this._runtimeState.recursionLimit}set recursionLimit(n){this._runtimeState.recursionLimit=n}_enterRecursion(){this._runtimeState.enterRecursion()}_exitRecursion(){this._runtimeState.exitRecursion()}get maxCollectionSize(){return this._runtimeState.maxCollectionSize}set maxCollectionSize(n){this._runtimeState.maxCollectionSize=n}get _isVerifying(){return this._runtimeState.isVerifying}set _isVerifying(n){this._runtimeState.isVerifying=n}get isVerifying(){return this._runtimeState.isVerifying}get tolerance(){return this._numericConfiguration.tolerance}set tolerance(n){this._numericConfiguration.setTolerance(n)&&this._noteStateEvent({kind:"config"})}get _randomFrame(){return this._runtimeState.randomFrame}set _randomFrame(n){this._runtimeState.randomFrame=n}_random(){let n=this._runtimeState.randomFrame;if(n!==void 0){let t=n.next>>>0;return n.next=n.next+1>>>0,hL(n.seedLo,n.seedHi,t)}return Math.random()}_substream(n){return yL(this._runtimeState.randomFrame,n)}chop(n){let t=this._numericConfiguration.tolerance;return typeof n=="number"?Math.abs(n)<=t?0:n:n instanceof D?n.isPositive()&&n.lte(this._numericConfiguration.bignumTolerance)||n.isNegative()&&n.gte(this._numericConfiguration.negBignumTolerance)||n.isZero()?0:n:n instanceof W&&Math.abs(n.re)<=t&&Math.abs(n.im)<=t?0:n}bignum(n){return this._numericConfiguration.bignum(n)}complex(n,t){return n instanceof D&&(n=n.toNumber()),t instanceof D&&(t=t.toNumber()),new W(n,t)}_numericValue(n){if(n instanceof Sr)return n.asExact??n;let t=this._numericConfiguration.precision>Ud?r=>new k5(r):r=>new _5(r);if(typeof n=="number")return Number.isInteger(n)?new pn(n,t):t(n);if(typeof n=="bigint")return new pn(n,t);if(fl(n))return new pn({rational:n},t);if(n instanceof D){if(n.isInteger()){let r=Qf(n.toString());if(r!==null)return new pn(r,t)}return t(n)}if(n instanceof W)return n.im===0?this._numericValue(n.re):t({re:n.re,im:n.im});if("im"in n||"re"in n)return n.im!==void 0&&n.im!==0?t(n):n.re instanceof D&&n.re.isInteger()?new pn({rational:[Qf(n.re.toString()),BigInt(1)]},t):typeof n.re=="number"&&Number.isInteger(n.re)?new pn({rational:[n.re,1]},t):t(n);if("radical"in n||"rational"in n){let r=n;if(r.radical!==void 0&&r.radical!==1){if(!Number.isInteger(r.radical)||r.radical<1)return t({re:h2(r.rational??[1,1])*Math.sqrt(r.radical)});if(r.radical>=On){let[i,o]=qg(r.radical,2);if(o>=On)return t({re:h2(r.rational??[1,1])*Math.sqrt(r.radical)});r={...r,radical:o,rational:CL(r.rational??[1,1],[i,1])}}}return r.rational&&hv(r.rational)&&(!Number.isInteger(r.rational[0])||!Number.isInteger(r.rational[1]))?t(r):new pn(r,t)}throw Error(`Unexpected value: ${typeof n=="object"?JSON.stringify(n):String(n)}`)}get costFunction(){return this._cost??oZ}set costFunction(n){this._cost=typeof n=="function"?n:void 0}get simplificationRules(){return this._simplificationRules.rules}set simplificationRules(n){this._simplificationRules.rules=n,this._cacheStore.invalidate("standard-simplification-rules")}get solveRules(){return this._solveRules.rules}set solveRules(n){this._solveRules.rules=n,this._cacheStore.invalidate("univariate-roots-rules")}get harmonizationRules(){return this._harmonizationRules.rules}set harmonizationRules(n){this._harmonizationRules.rules=n,this._cacheStore.invalidate("harmonization-rules")}lookupDefinition(n){return IG(this,n)}normalizeIdentifier(n){if(!n)return"";if(Ji(n))return n;this.pushScope();try{let t=this.parse(n);if(C(t))return t.symbol}finally{this.popScope()}return""}operatorInfo(n){let t=this.lookupDefinition(n);if(!t||!Q(t))return;let r=t.operator,i=!!(r.evaluate||r.collection);return{kind:i?"function":"opaque",signature:r.signature,canEvaluate:i}}symbolInfo(n){let t=this.lookupDefinition(n);if(!t||!J(t))return;let r=t.value;return{kind:r.isConstant?"constant":"variable",type:r.type}}searchDefinitions(n,t){return kG(this,n,t)}suggestOperatorName(n){return MG(this,n)}functionProperties(n){return Xc(this,n)}_declareSymbolValue(n,t,r){return OG(this,n,t,r)}_declareSymbolOperator(n,t,r){return PG(this,n,t,r)}pushScope(n,t){fJ(this,n,t)}popScope(){cJ(this)}createScope(n,t){return hJ(this,n,t)}_narrowingSink=void 0;_pushEvalContext(n,t,r){d$(this,n,t,r)}_popEvalContext(){p$(this)}_removeEvalContext(n){dJ(this,n)}_inScope(n,t){return mJ(this,n,t)}_resolveOnlyDepth=0;_resolveOnly(n){this._resolveOnlyDepth+=1;try{return n()}finally{this._resolveOnlyDepth-=1}}_printStack(n){gJ(this,n)}_bindingSymbol(n,t){return Wte(this,n,t)}_shadowedParameterStack=[];_pushShadowedParameters(n,t){this._shadowedParameterStack.push({names:new Set(n),types:t,defs:new Map,boundary:this.context.lexicalScope})}_popShadowedParameters(){this._shadowedParameterStack.pop()}_isShadowedParameter(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return!0;return!1}_shadowedParameterType(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].types?.get(n)}_shadowedParameterBoundary(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].boundary}_shadowedParameterDef(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].defs.get(n)}_setShadowedParameterDef(n,t){let r=this._shadowedParameterStack;for(let i=r.length-1;i>=0;i--)if(r[i].names.has(n)){r[i].defs.set(n,t);return}}_currentShadowedParameterDefs(){let n=this._shadowedParameterStack;return n.length>0?n[n.length-1].defs:new Map}_getSymbolValue(n){return DG(this,n)}_setSymbolValue(n,t){FG(this,n,t)}declare(n,t,r){return VG(this,n,t,r)}declareSequence(n,t){return LJ(this,n,t)}getSequenceStatus(n){return BJ(this,n)}getSequence(n){return VJ(this,n)}listSequences(){return jJ(this)}isSequence(n){return qJ(this,n)}clearSequenceCache(n){zJ(this,n)}getSequenceCache(n){return UJ(this,n)}getSequenceTerms(n,t,r,i){return HJ(this,n,t,r,i)}lookupOEIS(n,t){return GJ(this,n,t)}checkSequenceOEIS(n,t,r){return WJ(this,n,t,r)}interpret(n,t){return YJ(this,n,t)}assign(n,t){return jG(this,n,t)}_shouldContinueExecution(){return this._runtimeState.shouldContinueExecution()}_checkContinueExecution(){if(!this._shouldContinueExecution())throw new Error("timeout")}_cache(n,t,r){return this._cacheStore.getOrBuild(n,()=>{let i=this._runtimeState.deadlineFrame;if(i===void 0)return t();this._runtimeState.deadlineFrame=void 0;try{return t()}finally{this._runtimeState.deadlineFrame=i}},r)}expr(n,t){let{canonical:r,structural:i}=Jb(t);return cw(this,t?.scope,()=>Ot(this,n,{canonical:r,structural:i,scope:t?.scope}))}box(n,t){return this.expr(n,t)}rebind(n,t){return cw(this,t?.scope,()=>IZ(this,n,t))}_latexSyntax;get latexSyntax(){return!this._latexSyntax&&e._latexSyntaxFactory&&(this._latexSyntax=e._latexSyntaxFactory()),this._latexSyntax}_requireLatexSyntax(){if(!this._latexSyntax&&e._latexSyntaxFactory&&(this._latexSyntax=e._latexSyntaxFactory()),!this._latexSyntax)throw new Error("LatexSyntax not available. Pass a LatexSyntax instance to the ComputeEngine constructor.");return this._latexSyntax}_latexOptions={};get latexOptions(){return this._latexOptions}set latexOptions(n){t2(n),this._latexOptions={...n}}parse(n,t){if(n==null)return null;if(typeof n!="string")throw Error("ce.parse(): expected a LaTeX string");if(t?.speculative){if(t.scope!==void 0)throw Error("ce.parse(): the `speculative` and `scope` options are mutually exclusive \u2014 `speculative` discards the parse's writes, `scope` harvests them");let{speculative:b,...v}=t,E=this.parse(n,{...v,form:"raw"});this.pushScope(void 0,"speculative-parse");try{let x=this.context.lexicalScope;if(E!==null)for(let S of new Set(E.symbols)){let w=this.lookupDefinition(S);w!==void 0&&"value"in w&&!w.value.isConstant&&(w.value.inferredType||w.value.type.isUnknown)&&this.declare(S,{inferred:!0,type:w.value.type.type,...w.value.subscriptEvaluate?{subscriptEvaluate:w.value.subscriptEvaluate}:{}},x)}return this.parse(n,v)}finally{this.popScope()}}if(t?.scope)return cw(this,t.scope,()=>this.parse(n,{...t,scope:void 0}));let r=this._requireLatexSyntax(),{form:i,canonical:o,structural:s,scope:u,speculative:a,...l}=t??{},f=l.diagnostics??this._latexOptions?.diagnostics??!1,c,d,p,m=new Set;if(f){c=[],p=v=>m.add(v);let b=new Set;d=v=>{let E=`${v.code} ${v.start} ${v.end} ${v.detail?JSON.stringify(v.detail):""}`;b.has(E)||(b.add(E),c.push(v))}}let h=l.resolveSymbol??this._latexOptions?.resolveSymbol,y=h?b=>h(b)??this._resolveSymbolFromScope(b):b=>this._resolveSymbolFromScope(b);uw(this);try{let b=r.parse(n,{tolerance:this.tolerance,...this._latexOptions,...l,resolveSymbol:y,diagnostics:f,onDiagnostic:d,onBoundVariable:p});if(b===null)return null;let v=Ot(this,b,Jb({form:i,canonical:o,structural:s}));if(c!==void 0){if(v=v._unshared(),v.isCanonical)try{let E=new Set(v.symbols),x=new Set(v.freeVariables);for(let S of c){if(S.code!=="undeclared-symbol")continue;let w=S.detail?.name;typeof w=="string"&&(m.has(w)||E.has(w)&&!x.has(w)&&`${w}`)}}catch{}for(let E of c)E.detail&&Object.freeze(E.detail),Object.freeze(E);v.parseDiagnostics=Object.freeze(c)}return v}finally{aw(this)}}_resolveSymbolFromScope(n){let t=this.lookupDefinition(n);if(t)return Q(t)?{type:t.operator.signature}:J(t)?{type:t.value.type,subscriptEvaluate:!!t.value.subscriptEvaluate}:{type:k.unknown}}appliedNonFunctions(n){let t=this.latexSyntax;if(!t)return[];let r=this._latexOptions?.resolveSymbol,i=t.parse(n,{...this._latexOptions,resolveSymbol:r?s=>r(s)??this._resolveSymbolFromScope(s):s=>this._resolveSymbolFromScope(s)}),o=new Set;return i!==null&&RF(i,o),Array.from(o).sort()}function(n,t,r){let{canonical:i,structural:o}=Jb(r);return Yb(this,n,t,{metadata:r?.metadata,canonical:i,structural:o,scope:r?.scope})}error(n,t){return LC(this,n,t)}typeError(n,t,r){return ere(this,n,t,r)}hold(n){return this._fn("Hold",[this.expr(n,{form:"raw"})])}tuple(...n){return new Ze(this,"Tuple",n.map(t=>typeof t=="number"?this.number(t):t.canonical).filter(t=>!C(t,"Nothing")),{canonical:!0})}list(n){let t=n.length;if(typeof t!="number"||!Number.isSafeInteger(t)||t<0)throw new TypeError(`list(): the length must be a non-negative safe integer, not ${String(t)}`);if(t===0)return this.function("List",[]);let r=new Array(t);for(let i=0;i<t;i++){let o=n[i];if(typeof o!="number")throw new TypeError(`list(): element ${i} is ${o===void 0?"undefined":typeof o}, not a number`);r[i]=o===0?0:o}return new Ze(this,"List",void 0,{canonical:!0,numericStore:Object.freeze(r)})}type(n){if(n instanceof k)return n;if(typeof n=="string"&&Z0(n)){let t=this._commonTypes.get(n);return t===void 0&&(t=new k(n,this._typeResolver),this._commonTypes.set(n,t)),t}return new k(n,this._typeResolver)}string(n,t){return new Nl(this,n,t)}character(n,t){if(!bp(n))throw new Error(`ce.character(): "${n}" is not exactly one grapheme cluster. A character is exactly one user-perceived character (one UAX #29 extended grapheme cluster); use ce.string() for arbitrary text, or CharacterFrom() to get a diagnostic instead of a throw.`);return new xE(this,n,t)}symbol(n,t){return Gte(this,this._commonSymbols,n,t)}number(n,t){return Yte(this,this._commonNumbers,n,t)}rules(n,t){return qy(this,n,t)}getRuleSet(n){if(n??="standard-simplification",n==="standard-simplification"){this._simplificationRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("standard-simplification-rules");let t=this._cache("standard-simplification-rules",()=>{let i=qy(this,this._simplificationRules.rules,{canonical:!0}).rules.filter(o=>o.purpose!=="expand");return{rules:Dj(i)}});return this._simplificationRules.markCached(),t}if(n==="solve-univariate"){this._solveRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("univariate-roots-rules");let t=this._cache("univariate-roots-rules",()=>qy(this,this._solveRules.rules));return this._solveRules.markCached(),t}if(n==="harmonization"){this._harmonizationRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("harmonization-rules");let t=this._cache("harmonization-rules",()=>qy(this,this._harmonizationRules.rules));return this._harmonizationRules.markCached(),t}}_fn(n,t,r){let i=r?.canonical??!0;return ll(t,this)?this.error("object-foreign-engine"):new Ze(this,n,t,{...r,canonical:i})}_object(n,t,r,i){return FZ(this,n,t,r,i)}ask(n){return v$(this,n)}verify(n){return E$(this,n)}assume(n){return OJ(this,n)}forget(n){x$(this,n)}};VC(()=>new zf);var nXe="0.129.0",rXe=zf;zf._latexSyntaxFactory=()=>new ch;VC(()=>new zf({latexSyntax:new ch}));globalThis[Symbol.for("io.cortexjs.compute-engine")]={ComputeEngine:zf,version:"0.129.0",LatexSyntax:ch,LATEX_DICTIONARY:fh,isExpression:qo,isNumber:T,isSymbol:C,isFunction:g,isString:j,isCharacter:Ye,isTensor:al,isDictionary:Qe,isObject:Vn,isCollection:c2,isIndexedCollection:d2,numericValue:er,sym:P,compile:jC};export{sN as a,Y5 as b,uN as c,bp as d,TN as e,Ea as f,qb as g,Vje as h,jje as i,Fze as j,Lze as k,R as l,rg as m,Fd as n,cg as o,k0 as p,mg as q,wg as r,Vf as s,tre as t,rre as u,ire as v,ore as w,sre as x,ure as y,are as z,lre as A,fre as B,cre as C,dre as D,jC as E,nXe as F,rXe as G};
|
|
1852
|
+
`),f=new dF(o,a,u);return{target:"interval-js",success:!0,code:o,...l?{preamble:l}:{},calling:"expression",run:f}}var kC=class{_targets=new Map;register(n,t){fQ(n),dQ(t),this._targets.set(n,t)}get(n){return this._targets.get(n)}list(){return[...this._targets.keys()]}unregister(n){this._targets.delete(n)}registerDefaults(){this.register("javascript",new rg),this.register("glsl",new cg),this.register("wgsl",new k0),this.register("python",new mg),this.register("interval-js",new wg)}};var MC=class{_listeners=[];_registered=new WeakSet;_pending=!1;_version=0;listen(n){return this._registered.has(n)||(this._registered.add(n),this._listeners.push(n)),()=>this._unsubscribe(n)}_unsubscribe(n){this._registered.has(n)&&(this._registered.delete(n),this._listeners=this._listeners.filter(t=>t!==n))}notify(){if(this._pending)return;this._pending=!0;let n=this._version+1;queueMicrotask(()=>{if(n!==this._version+1){this._pending=!1;return}this.notifyNow()})}notifyNow(){this._version++;for(let n of this._listeners)try{n?.onConfigurationChange?.()}catch(t){console.error("Listener error:",t)}this._pending=!1}};function mNe(e){switch(e.kind){case"assumption":case"inference":case"config":case"binding-repair":return!0;case"redefine":case"type-write":return e.callableBefore||e.callableAfter;case"scope-pop":return e.assumptionsDirty;case"value-write":return e.callable;case"declare":return!e.scratch&&(e.callable||e.shadowsCallable);case"object-store":return!1}}var gNe=(()=>{if(typeof process>"u")return!1;let e=process.env?.CE_OBJECT_STORE_BUMPS_ANY;return e!==void 0&&e!=="0"})();function hNe(e){switch(e.kind){case"value-write":return{any:!0,semantic:!e.ephemeral,world:!1};case"declare":return e.scratch?{any:!1,semantic:!1,world:!1}:{any:!0,semantic:!1,world:!1};case"binding-repair":return{any:!0,semantic:!1,world:!1};case"redefine":return e.callableAfter?{any:!1,semantic:!0,world:!0}:{any:!1,semantic:!1,world:!1};case"type-write":return{any:!0,semantic:!1,world:!1};case"scope-pop":return{any:!e.transient&&!e.clean||e.assumptionsDirty,semantic:e.assumptionsDirty,world:e.assumptionsDirty};case"assumption":return{any:!0,semantic:!0,world:!0};case"inference":return e.valueType?{any:!1,semantic:!1,world:!1}:e.symbolSignature?{any:!0,semantic:!0,world:!0}:{any:!0,semantic:!0,world:!0};case"config":return{any:!0,semantic:!0,world:!0};case"object-store":return gNe?{any:!0,semantic:!1,world:!1}:{any:!1,semantic:!1,world:!1}}}var $C=class{_anyVersion=0;_semanticVersion=0;_worldVersion=0;_callableVersion=0;_ephemeralWriteDepth=0;_factSuppressionDepth=0;_scratchDeclarationScopes=[];_tracker=new MC;get anyVersion(){return this._anyVersion}get semanticVersion(){return this._semanticVersion}get worldVersion(){return this._worldVersion}get callableVersion(){return this._callableVersion}get ephemeralWriteDepth(){return this._ephemeralWriteDepth}set ephemeralWriteDepth(n){this._ephemeralWriteDepth=n}get factSuppressionDepth(){return this._factSuppressionDepth}set factSuppressionDepth(n){this._factSuppressionDepth=n}get scratchDeclarationScopes(){return this._scratchDeclarationScopes}noteStateEvent(n){let t=hNe(n);t.any&&(this._anyVersion+=1),t.semantic&&(this._semanticVersion+=1),t.world&&(this._worldVersion+=1),mNe(n)&&(this._callableVersion+=1),Fe&&(t.any&&W0("generation"),t.semantic&&W0("mutationGeneration"),t.world&&W0("semanticEpoch"))}reset(n){this._scratchDeclarationScopes.length=0,this.noteStateEvent({kind:"config"}),n.refreshNumericConstants(),n.resetCommonSymbols(),n.purgeCaches(),this._tracker.notifyNow()}listen(n){return this._tracker.listen(n)}};function yNe(e){return!!(e===void 0||e==="Number"||e===!0||Array.isArray(e)&&e.includes("Number"))}function Gte(e,n,t,r){let i=r?.canonical??!0,o=r?.metadata,s=t.normalize(),u=s.toLowerCase();if(u==="infinity"||u==="+infinity")return e.PositiveInfinity;if(u==="-infinity")return e.NegativeInfinity;if(e.strict&&!Ji(s))return e.error(["invalid-symbol",Us(s)],s);if(!i)return new Di(e,s,{metadata:o});if(e._isShadowedParameter(s)){let d=e._shadowedParameterType(s);if(d!==void 0){let v=e._shadowedParameterDef(s);if(v!==void 0)return new Di(e,s,{metadata:o,def:v});let E=e.context.lexicalScope;for(;E.noAutoDeclare&&E.parent;)E=E.parent;let x=E.bindings.get(s),S=x??e._declareSymbolValue(s,{type:d,inferred:!1},E);e._setShadowedParameterDef(s,S);let w=new Di(e,s,{metadata:o,def:S});return x===void 0&&J(S)&&Ls(e,S.value,{type:S.value.type,kind:"auto-declared",axis:"type",cause:w,epoch:Bs(e)}),w}let p=e._shadowedParameterDef(s);if(p!==void 0)return new Di(e,s,{metadata:o,def:p});let m=e.context.lexicalScope;for(;m.noAutoDeclare&&m.parent;)m=m.parent;let h=m.bindings.get(s),y=h??e._declareSymbolValue(s,{type:"unknown",inferred:!0},m);e._setShadowedParameterDef(s,y);let b=new Di(e,s,{metadata:o,def:y});return h===void 0&&J(y)&&Ls(e,y.value,{type:y.value.type,kind:"auto-declared",axis:"type",cause:b,epoch:Bs(e)}),b}let a=Object.hasOwn(n,s)?n[s]:void 0;if(a)return a;let l=e.lookupDefinition(s);if(J(l)&&l.value.holdUntil==="never")return l.value.value??e.Nothing;if(l)return new Di(e,s,{metadata:o,def:l});if(r?.autoDeclare===!1||e._resolveOnlyDepth>0)return new Di(e,s,{metadata:o});let f=e.context.lexicalScope;for(;f.noAutoDeclare&&f.parent;)f=f.parent;l=e._declareSymbolValue(s,{type:"unknown",inferred:!0},f),e._boxingState.isPersistentScope(f)===!1&&e._boxingState.noteTransientAutoDeclare(s);let c=new Di(e,s,{metadata:o,def:l});return J(l)&&Ls(e,l.value,{type:l.value.type,kind:"auto-declared",axis:"type",cause:c,epoch:Bs(e)}),c}function Wte(e,n,t){let r=t.bindings.get(n);if(J(r))return new Di(e,n,{def:r})}function Yte(e,n,t,r){let i=r?.metadata;if(!yNe(r?.canonical)&&fl(t))return e._fn("Rational",[e.number(t[0]),e.number(t[1])],{...i,canonical:!1});let s=ES(e,t);if(i===void 0){if(typeof s=="number"){let u=s;if(u===1)return e.One;if(u===0)return e.Zero;if(u===-1)return e.NegativeOne;if(u===2)return e.Two;if(Number.isInteger(u)&&n[u]!==void 0)return n[u]??=new xt(e,s),n[u];if(Number.isNaN(u))return e.NaN;if(!Number.isFinite(u))return u<0?e.NegativeInfinity:e.PositiveInfinity}else if(s instanceof Sr){if(s.isZero)return e.Zero;if(s.isOne)return e.One;if(s.isNegativeOne)return e.NegativeOne;if(s.isNaN)return e.NaN;if(s.isNegativeInfinity)return e.NegativeInfinity;if(s.isPositiveInfinity)return e.PositiveInfinity}}return new xt(e,s,{metadata:i})}var Ng=class{_rules;_cachedLength=-1;constructor(n){this._rules=n}get rules(){return this._rules}set rules(n){this._rules=n,this._cachedLength=-1}hasMutatedSinceLastCache(){return this._cachedLength>=0&&this._rules.length!==this._cachedLength}markCached(){this._cachedLength=this._rules.length}};var OC=class{_precision;_angularUnit;_tolerance;_bignumTolerance;_negBignumTolerance;constructor(n){let t=n?.precision??e2;t==="machine"&&(t=Math.floor(Ud)),this._precision=t,D.precision=t,this._angularUnit=n?.angularUnit??"rad",this._tolerance=jg,this._bignumTolerance=new D(jg),this._negBignumTolerance=new D(-jg),this.setTolerance(n?.tolerance??"auto")}get precision(){return this._precision}setPrecision(n){let t=n;if(t==="machine"&&(t=Ud),t==="auto"&&(t=e2),t===this._precision)return!1;if(typeof t!="number"||t<=0)throw Error('Expected "machine" or a positive number');return this._precision=Math.max(t,Ud),D.precision=this._precision,this.setTolerance("auto"),!0}get angularUnit(){return this._angularUnit}setAngularUnit(n){if(n===this._angularUnit)return!1;if(typeof n!="string")throw Error("Expected a string");return this._angularUnit=n,!0}get tolerance(){return this._tolerance}setTolerance(n){let t=n;return t==="auto"&&(t=jg),(!Number.isFinite(t)||t<0)&&(t=Math.pow(10,-this._precision+2)),t===this._tolerance?!1:(this._tolerance=t,this._bignumTolerance=new D(t),this._negBignumTolerance=new D(-t),!0)}get bignumTolerance(){return this._bignumTolerance}get negBignumTolerance(){return this._negBignumTolerance}get bignumNaN(){return D.NAN}get bignumZero(){return D.ZERO}get bignumOne(){return D.ONE}get bignumTwo(){return D.TWO}get bignumHalf(){return D.HALF}get bignumPi(){return D.PI}get bignumNegativeOne(){return D.NEGATIVE_ONE}bignum(n){if(n instanceof D)return n;try{return new D(n)}catch(t){t instanceof Error?console.error(t.message):console.error(String(t))}return D.NAN}};var PC=class{_iterationLimit=1024;_recursionLimit=256;_recursionDepth=0;_maxCollectionSize=1e4;_deadlineFrame=void 0;_randomFrame=void 0;_isVerifying=!1;get iterationLimit(){return this._iterationLimit}set iterationLimit(n){this._iterationLimit=n<=0?Number.POSITIVE_INFINITY:n}get recursionLimit(){return this._recursionLimit}set recursionLimit(n){this._recursionLimit=n<=0?Number.POSITIVE_INFINITY:n}get recursionDepth(){return this._recursionDepth}enterRecursion(){if(this._recursionDepth>=this._recursionLimit)throw new Ne({cause:"recursion-depth-exceeded",message:"Recursion limit exceeded"});this._recursionDepth+=1}exitRecursion(){this._recursionDepth>0&&(this._recursionDepth-=1)}get maxCollectionSize(){return this._maxCollectionSize}set maxCollectionSize(n){this._maxCollectionSize=n<=0?Number.POSITIVE_INFINITY:n}get deadlineFrame(){return this._deadlineFrame}set deadlineFrame(n){this._deadlineFrame=n}get deadline(){return this._deadlineFrame?.at}set deadline(n){this._deadlineFrame=n===void 0?void 0:{at:n,spans:[]}}get randomFrame(){return this._randomFrame}set randomFrame(n){this._randomFrame=n}get timeRemaining(){return this._deadlineFrame===void 0?Number.POSITIVE_INFINITY:this._deadlineFrame.at-Date.now()}get isVerifying(){return this._isVerifying}set isVerifying(n){this._isVerifying=n}shouldContinueExecution(){return this._deadlineFrame===void 0||this._deadlineFrame.at>=Date.now()}};var DC=class{_frames=[];_rootActive=!1;_isPersistentScope=null;_transientAutoDeclares=null;withRootRepair(n,t){if(this._rootActive)return n();this._rootActive=!0,this._isPersistentScope=t??null;try{return this._withRepairFrame(void 0,()=>(this._transientAutoDeclares=null,n()))}finally{this._rootActive=!1,this._isPersistentScope=null,this._transientAutoDeclares=null}}get isRootActive(){return this._rootActive}withScopedRepair(n,t){return this._rootActive?this._withRepairFrame(n,t):t()}get isRebuilding(){return this._frames.some(n=>n.rebuilding)}isPersistentScope(n){if(!(!this._rootActive||!this._isPersistentScope))return this._isPersistentScope(n)}noteTransientAutoDeclare(n){!this._rootActive||!this._isPersistentScope||(this._transientAutoDeclares??=new Set).add(n)}noteDeclarationIn(n,t){if(!this._rootActive||!this._transientAutoDeclares?.has(t)||this._isPersistentScope?.(n)!==!0)return;let r=this._frames.find(i=>i.scope===void 0);r&&(r.repairRequested=!0)}frameDepth(){return this._frames.length}hasRepairRequestedAtOrAbove(n){for(let t=n;t<this._frames.length;t++)if(this._frames[t].repairRequested)return!0;return!1}noteDevolvedShadow(n){for(let r=this._frames.length-1;r>=0;r--){let i=this._frames[r];if(i.scope===n){i.repairRequested=!0;return}}let t=this._frames.find(r=>r.scope===void 0);t&&(t.repairRequested=!0)}_withRepairFrame(n,t){let r={scope:n,repairRequested:!1,rebuilding:!1};this._frames.push(r);try{let i=t(),o=0;for(;r.repairRequested;){if(o>=3){let s="Devolved-shadow repair did not stabilize after 3 rebuilds";throw new Error(s)}r.repairRequested=!1,r.rebuilding=!0,o+=1;try{i=t()}finally{r.rebuilding=!1}}return i}finally{let i=this._frames.pop()}}};function bNe(e){if(typeof e!="string")return pQ(e),e;let n=qb.find(t=>t.name===e);if(!n)throw new Error(`Unknown standard library: "${e}"`);return n}function Zte(e){return e?X_(e.map(bNe)):[...ew()]}function vNe(e){return qb.includes(e)}function Jte(e,n){for(let t of n){let r=t.definitions;if(!r)continue;let i=!vNe(t),o=Array.isArray(r)?r:[r];for(let s of o){if(i)for(let u of Object.keys(s))e._customLibraryOperators.add(u.normalize());iZ(e,s)}}}function Rg(e,n){let t=e[n];if(!t)throw new Error(`Common symbol "${n}" failed to initialize`);return t}var FC=class{constructor(n){this.engine=n}engine;initializeCommonNumbers(){return{Zero:new xt(this.engine,0),One:new xt(this.engine,1),Half:new xt(this.engine,{rational:[1,2]}),NegativeOne:new xt(this.engine,-1),Two:new xt(this.engine,2),NaN:new xt(this.engine,Number.NaN),PositiveInfinity:new xt(this.engine,Number.POSITIVE_INFINITY),NegativeInfinity:new xt(this.engine,Number.NEGATIVE_INFINITY),I:new xt(this.engine,{rational:[0,1],imRational:[1,1]}),ComplexInfinity:new xt(this.engine,{re:1/0,im:1/0})}}bootstrapLibraries(n){let t=Zte(n);Jte(this.engine,t)}initializeCommonSymbolBindings(n){return JJ(this.engine,n),{True:Rg(n,"True"),False:Rg(n,"False"),Pi:Rg(n,"Pi"),E:Rg(n,"ExponentialE"),Nothing:Rg(n,"Nothing"),Missing:Rg(n,"Missing")}}};function Kte(e){let n=new Set,t=(r,i)=>{if(r==="never")return!0;let o=e._protocolRegistry?.[i];if(o===void 0)return!1;let s=`${Ag(r)} ${i}`;if(n.has(s))return!1;n.add(s);try{return o.conformances.some(u=>u.where===void 0?O(r,u.target):bE(u.target,u.where,r,t)!==null)}finally{n.delete(s)}};return{get names(){return Object.keys(e._typeRegistry)},resolve(r){let i=e._typeRegistry[r];if(i!==void 0)return i;if(e._protocolRegistry?.[r]!==void 0)throw new wt("protocol-in-type-position",`\`${r}\` is a protocol, not a type. Use a constrained variable: \`(x: T) -> boolean where T is ${r}\``)},forward(r){let i=e._typeRegistry[r];if(i!==void 0)return i;let o={kind:"reference",name:r,alias:!1,def:void 0};return e._typeRegistry[r]=o,o},conformsTo:t}}function LC(e,n,t){let r;typeof n=="string"?r=e.string(n):r=e.function("ErrorCode",n.map(s=>e.string(s)));let i;t!==void 0&&typeof t!="string"?i=t:t&&g5(t)?i=e.function("LatexString",[e.string(nE(t))]):typeof t=="string"&&t.length>0&&(i=e.string(t));let o=[e.expr(r)];return i&&o.push(i),e.function("Error",o)}function Qte(e){if(typeof e=="object"){if((e.kind==="collection"||e.kind==="indexed_collection"||e.kind==="set"||e.kind==="list"&&e.dimensions===void 0)&&e.elements==="any")return e.kind;if(e.kind==="dictionary"&&e.values==="any")return"dictionary"}return e}function Xte(e){let n=Qte(e);if(n!==e)return re(n);if(typeof e=="object"&&e.kind==="union"){let t=e.types.map(Qte);if(t.some((r,i)=>r!==e.types[i]))return re(Bn({...e,types:t}))}return re(e)}function ere(e,n,t,r){if(t){if(typeof r=="object"&&r!==null&&"type"in r&&"engine"in r){let o=r;$1(o.engine)&&t.toString()===o.type.toString()&&(t=Q4(o.engine,()=>o.type))}let i=typeof t=="object"&&"kind"in t?re(t):t.toString();return LC(e,["incompatible-type",Xte(n),i],r)}return LC(e,["incompatible-type",Xte(n)],r)}function BC(e,n){mQ(n);let t=xNe(n);n=t.options;let r=t.modeFromAlias;if(n?.target!==void 0&&n.cse===!0)throw new Error("CSE is not supported on direct custom targets in Phase 1; omit `cse` or use a registered target.");if(n?.target!==void 0&&n.storage!==void 0&&Object.keys(n.storage).length>0)throw new Error('The `storage` option is not supported on direct custom targets: the sampler-backed read needs the reference gate and the helper preamble a registered target provides. Omit `storage` or use a registered target (`to: "glsl"`).');if(n?.target===void 0&&n?.storage!==void 0){let i=e.engine._getCompilationTarget(n.to??"javascript")?.createTarget();i!==void 0&&ku(n.storage,[e],i,{vars:n.vars,functions:n.functions})}try{if(n?.target){let u=mi(ut(e),{skipHeads:Ef(n.operators,n.functions),iterationBudget:n.target.iterationBudget,readsLiveSource:d=>typeof n.vars?.[d]=="string"}),a=[n.preamble,n.target.preamble,...n.vars?Object.values(n.vars):[],...n.functions?Object.values(n.functions).map(d=>{let p=Cf(d);return typeof p=="string"?p:void 0}):[]];n.target.naming=R.newNamingContext(u,a),n.target.cse={enabled:!1,instances:[]},n.target.constantFold=n.constantFold,n.target.complexPromotion=n.complexPromotion,n.target.storage=void 0,n.target.mode=SNe(n.target,r&&!(n.target.supportedModes??["strict"]).includes("complex")?void 0:n.mode);let l,f;try{l=R.compileRoot(u,n.target)}catch(d){if(!f0(d)||n.target.mode!=="auto")throw d;n.target.reset?.(),n.target.mode="complex",n.target.naming=R.newNamingContext(u,a),l=R.compileRoot(u,n.target),f=d.diagnostic}let c=R.withReferences({target:n.target.language??"custom",success:!0,code:l},e,n.target,n.vars?new Set(Object.keys(n.vars)):void 0);return f!==void 0&&(c.escalation=f),c}let i=n?.to??"javascript",o=e.engine._getCompilationTarget(i);if(!o)throw new Error(`Compilation target "${i}" is not registered. Available targets: ${e.engine._listCompilationTargets().join(", ")}`);let s={fallback:n?.fallback??!0,operators:n?.operators,functions:n?.functions,vars:n?.vars,imports:n?.imports,preamble:n?.preamble,complexPromotion:n?.complexPromotion,mode:n?.mode,entryChecks:n?.entryChecks,iterationBudget:n?.iterationBudget,quadrature:n?.quadrature,symbolDeps:n?.symbolDeps,varsObjectRefs:n?.varsObjectRefs,cse:n?.cse,constantFold:n?.constantFold,storage:n?.storage};return r&&!ENe(o,"complex")&&(s.mode=void 0),o.compile(e,s)}catch(i){if(n?.fallback??!0){let o=i.message;console.warn(`Compilation fallback for "${e.operator}" (target: ${n?.to??"javascript"}): ${o}`);let s=n?.to??"javascript";if(s==="interval-js"){let a=e.engine._getCompilationTarget("interval-js");if(a)return a.compile(e,{vars:n?.vars,fallback:!0})}let u=n?.target??e.engine._getCompilationTarget(s)?.createTarget();return R.buildInterpreterFallback(e,o,s,u,n?.vars?new Set(Object.keys(n.vars)):void 0,Iu(i,o))}throw i}}var nre=new WeakMap;function ENe(e,n){let t=nre.get(e);return t===void 0&&(t=e.createTarget().supportedModes??["strict"],nre.set(e,t)),t.includes(n)}function xNe(e){return e===void 0?{options:e,modeFromAlias:!1}:Mu(e)}function SNe(e,n){let t=e.supportedModes??["strict"],r=typeof e.complexLift=="function"&&typeof e.complexIsReal=="function",i=t.includes("auto")&&r&&typeof e.reset=="function";return n===void 0?i?"auto":"strict":n==="auto"&&t.includes("auto")&&!i?"strict":n}var yF=null,bF=null;function VC(e){bF=e}function Vf(){if(!yF){if(!bF)throw new Error("ComputeEngine factory not registered. Import from the main module.");yF=bF()}return yF}function jf(e,n){if(typeof e=="string"){let t=Vf();return t.parse(e,{strict:n?.strict??!1})??t.expr("Nothing")}return qo(e)?e:Vf().expr(e)}function tre(e,n){return Vf().parse(e,n)}function rre(e,n){return Vf().expr(e,n)}function ire(e,n){return jf(e,n).simplify(n)}function ore(e,n){return jf(e,n).evaluate()}function sre(e,n){return jf(e,n).N()}function ure(e,n){Vf().declare(e,n)}function are(e,n){Vf().assign(e,n)}function lre(e,n){return en(jf(e,n))}function fre(e,n,t){return jf(e,t).solve(n)}function cre(e,n){return aa(jf(e,n))}function dre(e,n){return ss(jf(e,n))}function jC(e,n){return BC(jf(e,n),n)}var _Ne=/^(Sin|Cos|Tan|Cot|Sec|Csc)$/;function qC(e){return _Ne.test(e.operator)?!0:g(e)?e.ops.some(qC):!1}function qf(e,...n){return n.includes(e.operator)?!0:g(e)?e.ops.some(t=>qf(t,...n)):!1}function dt(e,n){let t=e.engine;if(g(e)&&e.ops.length>0){let r=e,i=r.ops.map(s=>dt(s,n));i.some((s,u)=>s!==r.ops[u])&&(e=t._fn(r.operator,i))}return n(e)??e}function vF(e,n){if(!g(e)||!g(n))return!1;let t=e.op1,r=n.op1;return t!==void 0&&r!==void 0&&t.isSame(r)}function wNe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(r){if(t==="Sec")return n.One.div(n._fn("Cos",[r]));if(t==="Csc")return n.One.div(n._fn("Sin",[r]))}}function yre(e){return dt(e,wNe)}function CNe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(r){if(t==="Tan")return n._fn("Sin",[r]).div(n._fn("Cos",[r]));if(t==="Cot")return n._fn("Cos",[r]).div(n._fn("Sin",[r]))}}function bre(e){return dt(e,CNe)}function NNe(e){let n=e.engine;if(e.operator!=="Divide"||!g(e))return;let t=e.op1,r=e.op2;if(!(!t||!r)){if(t.operator==="Sin"&&r.operator==="Cos"&&vF(t,r))return g(t)?n._fn("Tan",[t.op1]):void 0;if(t.operator==="Cos"&&r.operator==="Sin"&&vF(t,r))return g(t)?n._fn("Cot",[t.op1]):void 0}}function vre(e){return dt(e,NNe)}function RNe(e){if(g(e,"Negate"))return e.op1;if(g(e,"Multiply")){let n=e.ops.findIndex(t=>t.isSame(-1));if(n>=0){let t=e.ops.filter((r,i)=>i!==n);return t.length===1?t[0]:e.engine._fn("Multiply",t)}}}function ANe(e){let n=e.engine,t=e.operator;if(!g(e))return;let r=e.op1;if(!r)return;let i=RNe(r);if(i){if(t==="Cos")return n._fn("Cos",[i]);if(t==="Sec")return n._fn("Sec",[i]);if(t==="Sin")return n._fn("Sin",[i]).neg();if(t==="Tan")return n._fn("Tan",[i]).neg();if(t==="Csc")return n._fn("Csc",[i]).neg();if(t==="Cot")return n._fn("Cot",[i]).neg()}}function Ere(e){return dt(e,ANe)}function TNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Sin"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.sub(n._fn("Cos",[i]).pow(2))}function EF(e){return dt(e,TNe)}function INe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Cos"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.sub(n._fn("Sin",[i]).pow(2))}function xre(e){return dt(e,INe)}function kNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||t.operator!=="Cos"||!r.isSame(2)||!g(t))return;let i=t.op1;if(i)return n.One.add(n._fn("Cos",[i.mul(2)])).div(2)}function Sre(e){return dt(e,kNe)}function MNe(e){let n=e.engine;if(g(e,"Divide")){let r=e.op1,i=e.op2;if(!r||!i||!i.isSame(2))return;if(g(r,"Add")&&r.ops.length===2)return pre(n,r.ops)}let t=r=>!!(r.re===.5&&r.im===0||r.isSame(n.Half));if(g(e,"Multiply")){let r=e.ops.findIndex(i=>t(i));if(r>=0){let i=e.ops.filter((o,s)=>s!==r);if(i.length===1&&i[0].operator==="Add"){let o=i[0];if(g(o)&&o.ops.length===2)return pre(n,o.ops)}}}if(g(e,"Add")&&e.ops.length===2){let r,i,o=!1,s=u=>u.re===-.5&&u.im===0;for(let u of e.ops){if(t(u)){r=u;continue}let a=u,l=!1;if(g(u,"Negate")&&(l=!0,a=u.op1),g(a,"Divide")&&a.op2?.isSame(2)){let f=a.op1;if(f?.operator==="Cos"){i=f,o=l;continue}}if(g(a,"Multiply")){let f=a.ops.findIndex(d=>t(d));if(f>=0){let d=a.ops.filter((p,m)=>m!==f);if(d.length===1&&d[0].operator==="Cos"){i=d[0],o=l;continue}}let c=a.ops.findIndex(d=>s(d));if(c>=0){let d=a.ops.filter((p,m)=>m!==c);if(d.length===1&&d[0].operator==="Cos"){i=d[0],o=!l;continue}}}}if(r&&i){if(!g(i))return;let u=i.op1;if(!u)return;let a;if(g(u,"Multiply")){let l=u.ops.findIndex(f=>f.isSame(2));if(l>=0){let f=u.ops.filter((c,d)=>d!==l);a=f.length===1?f[0]:n._fn("Multiply",f)}}return a?o?n._fn("Sin",[a]).pow(2):n._fn("Cos",[a]).pow(2):void 0}}}function pre(e,n){let t=-1,r=-1,i=!1;for(let a=0;a<n.length;a++)if(n[a].isSame(1))t=a;else if(n[a].operator==="Cos")r=a,i=!1;else if(n[a].operator==="Negate"){let l=n[a];g(l)&&l.op1?.operator==="Cos"&&(r=a,i=!0)}if(t<0||r<0)return;let o;if(i){let a=n[r];if(!g(a))return;o=a.op1}else o=n[r];if(!g(o))return;let s=o.op1;if(!s)return;let u;if(g(s,"Multiply")){let a=s.ops.findIndex(l=>l.isSame(2));if(a>=0){let l=s.ops.filter((f,c)=>c!==a);u=l.length===1?l[0]:e._fn("Multiply",l)}}if(u)return i?e._fn("Sin",[u]).pow(2):e._fn("Cos",[u]).pow(2)}function xF(e){return dt(e,MNe)}function $Ne(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i];if(!g(o)||!g(s))continue;let u=o.op1,a=s.op1;if(!u||!a)continue;let l;if(o.operator==="Sin"&&s.operator==="Cos"?l=n._fn("Sin",[u.add(a)]).add(n._fn("Sin",[u.sub(a)])).div(2):o.operator==="Cos"&&s.operator==="Sin"?l=n._fn("Sin",[u.add(a)]).sub(n._fn("Sin",[u.sub(a)])).div(2):o.operator==="Cos"&&s.operator==="Cos"?l=n._fn("Cos",[u.add(a)]).add(n._fn("Cos",[u.sub(a)])).div(2):o.operator==="Sin"&&s.operator==="Sin"&&(l=n._fn("Cos",[u.sub(a)]).sub(n._fn("Cos",[u.add(a)])).div(2)),l){let f=t.filter((c,d)=>d!==r&&d!==i);return f.length===0?l:l.mul(f.length===1?f[0]:n._fn("Multiply",f))}}}function _re(e){return dt(e,$Ne)}function ONe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i],u;if(o.operator==="Sin"&&s.operator==="Sin"){if(!g(o)||!g(s))continue;let a=o.op1,l=s.op1;if(a&&l){let f=a.add(l).div(2),c=a.sub(l).div(2);u=n._fn("Sin",[f]).mul(n._fn("Cos",[c])).mul(2)}}else if(o.operator==="Cos"&&s.operator==="Cos"){if(!g(o)||!g(s))continue;let a=o.op1,l=s.op1;if(a&&l){let f=a.add(l).div(2),c=a.sub(l).div(2);u=n._fn("Cos",[f]).mul(n._fn("Cos",[c])).mul(2)}}else if(o.operator==="Sin"&&s.operator==="Negate"){if(!g(o)||!g(s)||s.op1?.operator!=="Sin")continue;let a=s.op1;if(!g(a))continue;let l=o.op1,f=a.op1;if(l&&f){let c=l.add(f).div(2),d=l.sub(f).div(2);u=n._fn("Cos",[c]).mul(n._fn("Sin",[d])).mul(2)}}else if(o.operator==="Cos"&&s.operator==="Negate"){if(!g(o)||!g(s)||s.op1?.operator!=="Cos")continue;let a=s.op1;if(!g(a))continue;let l=o.op1,f=a.op1;if(l&&f){let c=l.add(f).div(2),d=l.sub(f).div(2);u=n._fn("Sin",[c]).mul(n._fn("Sin",[d])).mul(-2)}}if(u){let a=t.filter((l,f)=>f!==r&&f!==i);return a.length===0?u:u.add(a.length===1?a[0]:n._fn("Add",a))}}}function zC(e){return dt(e,ONe)}function PNe(e){let n=e.engine,t=e.operator;if(t!=="Sin"&&t!=="Cos"||!g(e))return;let r=e.op1;if(r){if(g(r,"Add")&&r.ops.length===2){let[i,o]=r.ops;return t==="Sin"?n._fn("Sin",[i]).mul(n._fn("Cos",[o])).add(n._fn("Cos",[i]).mul(n._fn("Sin",[o]))):n._fn("Cos",[i]).mul(n._fn("Cos",[o])).sub(n._fn("Sin",[i]).mul(n._fn("Sin",[o])))}if(g(r,"Subtract")){let i=r.op1,o=r.op2;return!i||!o?void 0:t==="Sin"?n._fn("Sin",[i]).mul(n._fn("Cos",[o])).sub(n._fn("Cos",[i]).mul(n._fn("Sin",[o]))):n._fn("Cos",[i]).mul(n._fn("Cos",[o])).add(n._fn("Sin",[i]).mul(n._fn("Sin",[o])))}}}function wre(e){return dt(e,PNe)}function DNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i],u=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Sin"&&A.operator==="Cos"?{sin:_,cos:A}:_.operator==="Cos"&&A.operator==="Sin"?{sin:A,cos:_}:null},a=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Cos"&&A.operator==="Cos"?{cos1:_,cos2:A}:null},l=S=>{if(S.operator!=="Multiply"||!g(S))return null;let w=S.ops;if(w.length!==2)return null;let[_,A]=w;return _.operator==="Sin"&&A.operator==="Sin"?{sin1:_,sin2:A}:null},f=S=>g(S)?S.op1:void 0,c=u(o),d=u(s),p=g(o,"Negate")&&o.op1?u(o.op1):null,m=g(s,"Negate")&&s.op1?u(s.op1):null;if(c&&d){let S=f(c.sin),w=f(c.cos),_=f(d.sin),A=f(d.cos);if(S&&w&&_&&A&&S.isSame(A)&&w.isSame(_)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(c&&m){let S=f(c.sin),w=f(c.cos),_=f(m.sin),A=f(m.cos);if(S&&w&&_&&A&&S.isSame(A)&&w.isSame(_)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(p&&d){let S=f(p.sin),w=f(p.cos),_=f(d.sin),A=f(d.cos);if(S&&w&&_&&A&&_.isSame(w)&&A.isSame(S)){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Sin",[_.sub(A)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}let h=a(o),y=a(s),b=l(o),v=l(s),E=g(o,"Negate")&&o.op1?l(o.op1):null,x=g(s,"Negate")&&s.op1?l(s.op1):null;if(h&&x){let S=f(h.cos1),w=f(h.cos2),_=f(x.sin1),A=f(x.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(E&&y){let S=f(y.cos1),w=f(y.cos2),_=f(E.sin1),A=f(E.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.add(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(h&&v){let S=f(h.cos1),w=f(h.cos2),_=f(v.sin1),A=f(v.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}if(b&&y){let S=f(y.cos1),w=f(y.cos2),_=f(b.sin1),A=f(b.sin2);if(S&&w&&_&&A&&(S.isSame(_)&&w.isSame(A)||S.isSame(A)&&w.isSame(_))){let N=t.filter((B,F)=>F!==r&&F!==i),I=n._fn("Cos",[S.sub(w)]);return N.length===0?I:I.add(N.length===1?N[0]:n._fn("Add",N))}}}}function UC(e){return dt(e,DNe)}function FNe(e){let n=e.engine,t=e.operator;if(t!=="Sin"&&t!=="Cos"||!g(e))return;let r=e.op1;if(r&&g(r,"Multiply")){let i=r.ops,o=i.findIndex(s=>s.isSame(2));if(o>=0){let s=i.filter((a,l)=>l!==o),u=s.length===1?s[0]:n._fn("Multiply",s);return t==="Sin"?n._fn("Sin",[u]).mul(n._fn("Cos",[u])).mul(2):n._fn("Cos",[u]).pow(2).mul(2).sub(n.One)}}}function SF(e){return dt(e,FNe)}function LNe(e){let n=e.engine;if(g(e,"Multiply")){let t=e.ops,r=t.findIndex(i=>i.isSame(2));if(r>=0){let i=t.filter((u,a)=>a!==r),o,s;for(let u of i)u.operator==="Sin"&&!o?o=u:u.operator==="Cos"&&!s&&(s=u);if(o&&s&&vF(o,s)){if(!g(o))return;let u=i.filter(l=>l!==o&&l!==s),a=n._fn("Sin",[o.op1.mul(2)]);return u.length===0?a:a.mul(u.length===1?u[0]:n._fn("Multiply",u))}}}if(g(e,"Add")&&e.ops.length===2){let[t,r]=e.ops;if(g(t,"Power")&&t.op1?.operator==="Cos"&&t.op2?.isSame(2)&&r.operator==="Negate"&&g(r)&&r.op1?.operator==="Power"&&g(r.op1)&&r.op1.op1?.operator==="Sin"&&r.op1.op2?.isSame(2)){let a=t.op1,l=r.op1;if(g(a)&&g(l)){let f=l.op1;if(g(f)){let c=a.op1,d=f.op1;if(c&&d&&c.isSame(d))return n._fn("Cos",[c.mul(2)])}}}let i=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Cos"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}},o=i(t);if(o&&(r.isSame(-1)||g(r,"Negate")&&r.op1?.isSame(1)))return n._fn("Cos",[o.mul(2)]);if(o=i(r),o&&(t.isSame(-1)||g(t,"Negate")&&t.op1?.isSame(1)))return n._fn("Cos",[o.mul(2)]);let s=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Sin"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}};if(t.isSame(1)&&g(r,"Negate")&&r.op1){let a=s(r.op1);if(a)return n._fn("Cos",[a.mul(2)])}if(r.isSame(1)&&g(t,"Negate")&&t.op1){let a=s(t.op1);if(a)return n._fn("Cos",[a.mul(2)])}let u=a=>{if(!g(a,"Multiply"))return;let l=a.ops.findIndex(d=>d.isSame(-2));if(l<0)return;let f=a.ops.filter((d,p)=>p!==l);if(f.length!==1)return;let c=f[0];if(g(c,"Power")&&c.op1?.operator==="Sin"&&c.op2?.isSame(2)){let d=c.op1;if(g(d))return d.op1}};if(t.isSame(1)){let a=u(r);if(a)return n._fn("Cos",[a.mul(2)])}if(r.isSame(1)){let a=u(t);if(a)return n._fn("Cos",[a.mul(2)])}}}function Cre(e){return dt(e,LNe)}function mre(e){let n=!1,t=e;if(g(t,"Negate")&&t.op1)n=!0,t=t.op1;else if(g(t,"Multiply")&&t.ops.length===2){let s=t.ops.findIndex(u=>u.isSame(-1));s>=0&&(n=!0,t=t.ops[1-s])}if(!g(t,"Power"))return;let r=t.op1,i=t.op2;if(!r||!i||!(i.isSame(2)||i.isSame(4))||r.operator!=="Sin"&&r.operator!=="Cos"||!g(r))return;let o=r.op1;if(o)return{func:r.operator,arg:o,power:i.isSame(2)?2:4,negated:n}}function BNe(e){let n=e.engine;if(!g(e,"Add")||e.ops.length!==2)return;let t=mre(e.ops[0]),r=mre(e.ops[1]);if(!t||!r||t.negated===r.negated||t.func===r.func||t.power!==r.power||!t.arg.isSame(r.arg))return;let i=t.negated?r:t,o=n._fn("Cos",[i.arg.mul(2)]);return i.func==="Cos"?o:o.neg()}function Nre(e){return dt(e,BNe)}function VNe(e){let n=e.engine;if(e.operator!=="Tan"||!g(e))return;let t=e.op1;if(t){if(g(t,"Add")&&t.ops.length===2){let[r,i]=t.ops,o=n._fn("Tan",[r]),s=n._fn("Tan",[i]);return o.add(s).div(n.One.sub(o.mul(s)))}if(g(t,"Subtract")){let r=t.op1,i=t.op2;if(!r||!i)return;let o=n._fn("Tan",[r]),s=n._fn("Tan",[i]);return o.sub(s).div(n.One.add(o.mul(s)))}}}function Rre(e){return dt(e,VNe)}var jNe=[{value:0,angle:[0,1]},{value:1/Math.sqrt(3),angle:[1,6]},{value:1,angle:[1,4]},{value:Math.sqrt(3),angle:[1,3]},{value:2-Math.sqrt(3),angle:[1,12]},{value:2+Math.sqrt(3),angle:[5,12]}];function qNe(e,n=1e-10){for(let t of jNe)if(Math.abs(t.value-e)<n)return t.angle}function zNe(e){if(e.operator!=="Multiply"||!g(e))return;let n=e.ops;if(n.length<2)return;let t=[],r=1;for(let i of n)if(g(i,"Tan")&&i.op1)t.push(i.op1);else if(g(i,"Negate")&&i.op1?.operator==="Sqrt"){let o=i.op1;if(g(o)){let s=o.op1;if(T(s)&&typeof s.re=="number")r*=-Math.sqrt(s.re);else return}else return}else if(g(i,"Sqrt")){let o=i.op1;if(o&&T(o)&&typeof o.re=="number")r*=Math.sqrt(o.re);else return}else if(T(i)&&typeof i.re=="number")r*=i.re;else return;if(t.length===2)return[r,t[0],t[1]]}function gre(e){if(g(e,"Multiply")){let n=!1,t;for(let r of e.ops)if(C(r,"Pi"))n=!0;else if(T(r)&&typeof r.re=="number"){let i=r.re;for(let o=1;o<=36;o++){let s=Math.round(i*o);if(Math.abs(s/o-i)<1e-10){t=[s,o];break}}}if(n&&t)return t}if(C(e,"Pi"))return[1,1]}function UNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length!==3)return;let r=[],i;for(let v=0;v<t.length;v++){let E=t[v];if(g(E,"Tan")&&E.op1)r.push({arg:E.op1,index:v});else{let x=zNe(E);x&&(i={coef:x[0],arg1:x[1],arg2:x[2],index:v})}}if(r.length!==2||!i)return;let[o,s]=r,u=o.arg.isSame(i.arg1)||o.arg.isSame(i.arg2),a=s.arg.isSame(i.arg1)||s.arg.isSame(i.arg2),l=o.arg.isSame(i.arg2)||o.arg.isSame(i.arg1),f=s.arg.isSame(i.arg2)||s.arg.isSame(i.arg1);if(!(u&&f||a&&l))return;let c=-i.coef;if(c<=0)return;let d=qNe(c);if(!d)return;let p=gre(o.arg),m=gre(s.arg);if(!p||!m)return;let h=hre(hre(p[1],m[1]),d[1]);if(p[0]*(h/p[1])+m[0]*(h/m[1])+d[0]*(h/d[1])!==h)return;let b=n._fn("Multiply",[n.number([d[0],d[1]]),n.symbol("Pi")]);return n._fn("Tan",[b]).neg()}function hre(e,n){return Math.abs(e*n)/HNe(e,n)}function HNe(e,n){for(e=Math.abs(e),n=Math.abs(n);n;){let t=n;n=e%n,e=t}return e}function Are(e){return dt(e,UNe)}function GNe(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(!(t.length<2))for(let r=0;r<t.length;r++)for(let i=r+1;i<t.length;i++){let o=t[r],s=t[i];if(!g(o)||!g(s))continue;let u=o.op1,a=s.op1;if(!(!u||!a)){if(o.operator==="Tan"&&s.operator==="Tan"){let l=o,f=s,c=n._fn("Cot",[u.add(a)]),d=n.One.sub(l.add(f).mul(c)),p=t.filter((m,h)=>h!==r&&h!==i);return p.length===0?d:d.mul(p.length===1?p[0]:n._fn("Multiply",p))}if(o.operator==="Cot"&&s.operator==="Cot"){let l=o,f=s,c=n._fn("Cot",[u.add(a)]),d=n.One.add(l.add(f).mul(c)),p=t.filter((m,h)=>h!==r&&h!==i);return p.length===0?d:d.mul(p.length===1?p[0]:n._fn("Multiply",p))}}}}function Tre(e){return dt(e,GNe)}function WNe(e){let n=e.engine;if(e.operator!=="Power"||!g(e))return;let t=e.op1,r=e.op2;if(!t||!r||!r.isSame(2)||!g(t))return;let i=t.op1;if(i){if(t.operator==="Tan")return n._fn("Sec",[i]).pow(2).sub(n.One);if(t.operator==="Cot")return n._fn("Csc",[i]).pow(2).sub(n.One);if(t.operator==="Sec")return n.One.add(n._fn("Tan",[i]).pow(2));if(t.operator==="Csc")return n.One.add(n._fn("Cot",[i]).pow(2))}}function Ire(e){return dt(e,WNe)}function YNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length!==2)return;let r=d=>{let p=!1,m=d;if(g(d,"Negate")&&(p=!0,m=d.op1),!g(m)||m.operator!=="Power"||!m.op2?.isSame(2))return null;let h=m.op1;if(!g(h)||!h.op1)return null;let y=h.operator;return["Tan","Cot","Sec","Csc"].includes(y)?{func:y,arg:h.op1,neg:p}:null},i=r(t[0]),o=r(t[1]);if(i&&o&&i.arg.isSame(o.arg)){if(i.func==="Cot"&&!i.neg&&o.func==="Csc"&&o.neg||i.func==="Csc"&&i.neg&&o.func==="Cot"&&!o.neg)return n.number(-1);if(i.func==="Csc"&&!i.neg&&o.func==="Cot"&&o.neg||i.func==="Cot"&&i.neg&&o.func==="Csc"&&!o.neg)return n.One;if(i.func==="Tan"&&!i.neg&&o.func==="Sec"&&o.neg||i.func==="Sec"&&i.neg&&o.func==="Tan"&&!o.neg)return n.number(-1);if(i.func==="Sec"&&!i.neg&&o.func==="Tan"&&o.neg||i.func==="Tan"&&i.neg&&o.func==="Sec"&&!o.neg)return n.One}let s=-1,u=-1,a=!1;for(let d=0;d<t.length;d++){let p=t[d];p.isSame(1)?(s=d,a=!1):p.isSame(-1)||g(p,"Negate")&&p.op1?.isSame(1)?(s=d,a=!0):g(p,"Power")&&p.op2?.isSame(2)&&(u=d)}if(s<0||u<0)return;let l=t[u];if(!g(l))return;let f=l.op1;if(!f||!g(f))return;let c=f.op1;if(c){if(f.operator==="Sec"&&a)return n._fn("Tan",[c]).pow(2);if(f.operator==="Csc"&&a)return n._fn("Cot",[c]).pow(2);if(f.operator==="Tan"&&!a)return n._fn("Sec",[c]).pow(2);if(f.operator==="Cot"&&!a)return n._fn("Csc",[c]).pow(2)}}function _F(e){return dt(e,YNe)}function ZNe(e){let n=e.engine;if(!g(e,"Multiply"))return[1,n.One,e];for(let t=0;t<e.ops.length;t++){let r=e.ops[t],i;if(T(r)&&typeof r.re=="number"&&r.im===0&&(i=r.re),i!==void 0){let o=e.ops.filter((u,a)=>a!==t),s=o.length===1?o[0]:n._fn("Multiply",o);return[i,r,s]}}return[1,n.One,e]}function JNe(e){let n=e.engine;if(e.operator!=="Multiply"||!g(e))return;let t=e.ops;if(t.length<2)return;let r=[],i=[];for(let _ of t)if(g(_,"Cos")&&_.op1){let A=ZNe(_.op1);A?r.push({arg:A[2],numericMult:A[0],symbolicCoeff:A[1]}):r.push({arg:_.op1,numericMult:1,symbolicCoeff:n.One})}else i.push(_);if(r.length<2)return;let o=r[0].arg,s=r.filter(_=>_.arg.isSame(o)),u=r.filter(_=>!_.arg.isSame(o));if(s.length<2)return;s.sort((_,A)=>_.numericMult-A.numericMult);let a=[],l=[],f=[...s],c=f[0].numericMult;if(c>0){a.push(f[0]);let _=new Set([0]),A=c*2;for(;;){let N=f.findIndex((I,B)=>!_.has(B)&&Math.abs(I.numericMult-A)<1e-10);if(N===-1)break;a.push(f[N]),_.add(N),A*=2}l=f.filter((N,I)=>!_.has(I))}if(a.length<2)return;let d=a[0].numericMult,p=[...i];for(let _ of l){let A=_.symbolicCoeff.isSame(n.One)?_.arg:n._fn("Multiply",[_.symbolicCoeff,_.arg]);p.push(n._fn("Cos",[A]))}for(let _ of u){let A=_.symbolicCoeff.isSame(n.One)?_.arg:n._fn("Multiply",[_.symbolicCoeff,_.arg]);p.push(n._fn("Cos",[A]))}let m=a.length,h=a[0].symbolicCoeff,y=Math.pow(2,m);if(C(o,"Pi")){let _=1/(y+1);if(Math.abs(d-_)<1e-10){let A=n.number([1,y]);return p.length===0?A:A.mul(p.length===1?p[0]:n._fn("Multiply",p))}}let b=h.mul(y),v=h.isSame(n.One)?o:n._fn("Multiply",[h,o]),E=n._fn("Multiply",[b,o]),x=n._fn("Sin",[E]),S=n._fn("Sin",[v]),w=x.div(n.number(y).mul(S));return p.length===0?w:w.mul(p.length===1?p[0]:n._fn("Multiply",p))}function kre(e){return dt(e,JNe)}function KNe(e){if(g(e,"Power")&&e.op2?.isSame(2)){let n=e.op1;if(g(n,"Sin")&&n.op1)return{func:"Sin",arg:n.op1,coef:1};if(g(n,"Cos")&&n.op1)return{func:"Cos",arg:n.op1,coef:1}}if(g(e,"Multiply")){let n=1,t;for(let r of e.ops)if(g(r,"Power")&&r.op2?.isSame(2)){let i=r.op1;(i?.operator==="Sin"||i?.operator==="Cos")&&(t=r)}else typeof r.re=="number"&&r.im===0&&(n*=r.re);if(g(t)){let r=t.op1;if(g(r,"Sin")&&r.op1)return{func:"Sin",arg:r.op1,coef:n};if(g(r,"Cos")&&r.op1)return{func:"Cos",arg:r.op1,coef:n}}}return null}function QNe(e){let n=e.engine;if(e.operator!=="Add"||!g(e))return;let t=e.ops;if(t.length<2)return;let r=[],i=[],o=[];for(let s=0;s<t.length;s++){let u=t[s],a=KNe(u);a?r.push({...a,index:s}):typeof u.re=="number"&&u.im===0&&T(u)?o.push({value:u.re,index:s}):i.push({expr:u,index:s})}for(let s=0;s<r.length;s++)for(let u=s+1;u<r.length;u++){let a=r[s],l=r[u];if(a.arg.isSame(l.arg)&&(a.func==="Sin"&&l.func==="Cos"||a.func==="Cos"&&l.func==="Sin")&&Math.abs(a.coef-l.coef)<1e-10){let f=a.coef,c=new Set([a.index,l.index]),d=t.filter((p,m)=>!c.has(m));return d.length===0?n.number(f):f===1?n._fn("Add",[n.One,...d]):n._fn("Add",[n.number(f),...d])}}for(let s of r)if(s.coef<0){let u=Math.abs(s.coef);for(let a of o)if(Math.abs(a.value-u)<1e-10){let l=new Set([s.index,a.index]),f=t.filter((p,m)=>!l.has(m)),c=s.func==="Sin"?"Cos":"Sin",d=n._fn(c,[s.arg]).pow(2).mul(u);return f.length===0?d:n._fn("Add",[d,...f])}}}function Mre(e){return dt(e,QNe)}var XNe=new Set(["Sin","Cos","Tan","Cot","Sec","Csc"]);function wF(e){let n=0;if(XNe.has(e.operator)&&(n=1),g(e))for(let t of e.ops)n+=wF(t);return n}function CF(e){if(C(e)||T(e))return 1;let n=1;if(g(e))for(let t of e.ops)n+=CF(t);return n}function $re(e){let n=wF(e),t=CF(e);return n*1e3+t}var Ore=$re;function NF(e,n){if(e.length===0)throw new Error("bestOf called with empty array");if(e.length===1)return e[0];let t=e[0],r=n(t);for(let i=1;i<e.length;i++){let o=n(e[i]);o<r&&(t=e[i],r=o)}return t}function U0(e,n){let t=n(e);return t.isSame(e)?null:t}function Pre(e,n){let t=U0(e,EF),r=U0(e,xre),i=[e];return t&&i.push(t),r&&i.push(r),NF(i,n)}function eRe(e,n){return Pre(e,n)}function nRe(e,n){let t=U0(e,_re),r=[e];if(t){r.push(t);let i=U0(t,UC);i&&r.push(i)}return NF(r,n)}function tRe(e,n){let t=U0(e,UC),r=[e];return t&&r.push(t),NF(r,n)}function rRe(e,n){let t=Rre(e);return t=Tre(t),t}function iRe(e,n){let t=e;return t=wre(t),t=SF(t),t=EF(t),t=Sre(t),t=SF(t),t=nRe(t,n),t=Pre(t,n),t=zC(t),t=eRe(t,n),t=zC(t),t=tRe(t,n),t}function Dre(e,n){if(!qC(e))return;let t=n?.measure??Ore,r=n?.maxIterations??100,i=e,o=0,s=e,u=t(e),a=S=>{let w=t(S);w<u&&(s=S,u=w)};i=Ere(i),a(i);let l=_F(i);a(l);let f=Ire(i);a(f),i=s;let c=xF(i);if(a(c),i=s,qf(i,"Sec","Csc")&&(i=yre(i),s=i,u=t(i)),qf(i,"Tan","Cot")){let S=rRe(i,t);a(S),i=S}if(qf(i,"Tan","Cot")&&(i=bre(i),a(i)),qf(i,"Sin","Cos")){let S=zC(i);a(S),i=s}if(qf(i,"Sin","Cos")){let S=t(i);for(;o<r;){o++;let w=iRe(i,t),_=t(w);if(a(w),_>=S)break;i=w,S=_}}let d=vre(s);a(d);let p=Cre(s);a(p);let m=Nre(s);a(m);let h=kre(s);a(h);let y=xF(s);a(y);let b=_F(s);a(b);let v=UC(s);a(v);let E=Mre(s);a(E);let x=Are(s);if(a(x),s.operator==="Add"||s.operator==="Multiply"){let S=e.engine.expr(s.json);a(S)}if(!s.isSame(e))return{value:s,because:"fu"}}function RF(e,n){if(Array.isArray(e)){if(e[0]==="InvisibleOperator")for(let t=1;t+1<e.length;t++){let r=e[t],i=e[t+1];typeof r=="string"&&Array.isArray(i)&&i[0]==="Delimiter"&&n.add(r)}for(let t of e)RF(t,n);return}e!==null&&typeof e=="object"&&"fn"in e&&Array.isArray(e.fn)&&RF(e.fn,n)}var zf=class e{static _latexSyntaxFactory=null;True;False;Pi;E;Nothing;Missing;Zero;One;Half;NegativeOne;Two;I;NaN;PositiveInfinity;NegativeInfinity;ComplexInfinity;_numericConfiguration;_cacheStore=new gw;_runtimeState=new PC;_boxingState=new DC;_configurationLifecycle=new $C;_cost;_integrationProvider;_simplificationRules=new Ng([...aJ]);_solveRules=new Ng([...s9]);_harmonizationRules=new Ng([...f9]);_compilationTargets=new kC;_fuAlgorithm=Dre;_customLibraryOperators=new Set;_commonSymbols={Pi:null,True:null,False:null,All:null,Nothing:null,Missing:null,None:null,Undefined:null,ExponentialE:null};_commonNumbers={"-5":null,"-4":null,"-3":null,"-2":null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,12:null,36:null};_commonTypes=new Map;_evalContextStack=[];get context(){return this._evalContextStack[this._evalContextStack.length-1]}get contextStack(){return[...this._evalContextStack]}set contextStack(n){this._evalContextStack=[...n]}_typeRegistry=Object.create(null);_protocolRegistry=Object.create(null);_conformanceVersionCounter=0;get _conformanceVersion(){return this._conformanceVersionCounter}_noteConformanceRegistryChange(){this._conformanceVersionCounter+=1}_staticTypeCheckDepth=0;_epsilBatchId=void 0;_staticAssignmentEvidence=void 0;_epsilDeclarationRoute=!1;_typeRegistryRollbackPoint(){let n=this._typeRegistry,t=new Set(Object.keys(n)),r=[...t].map(i=>{let o=n[i];return{r:o,def:o.def,alias:o.alias,typeParams:o.typeParams,varianceState:o._varianceState,varianceBlockedOn:o._varianceBlockedOn,declaredByStatement:o._declaredByStatement,forwardArity:o._forwardArity===void 0?void 0:new Set(o._forwardArity),sumOf:o._sumOf,sumVariants:o._sumVariants,declOrigin:o._declOrigin}});return()=>{let i=!1;for(let o of Object.keys(n))t.has(o)||(delete n[o],i=!0);for(let o of r){let s=o.r;s.def!==o.def&&(i=!0),s.def=o.def,s.alias!==o.alias&&(i=!0),s.alias=o.alias,s.typeParams!==o.typeParams&&(i=!0),o.typeParams===void 0?delete s.typeParams:s.typeParams=o.typeParams,s._varianceState!==o.varianceState&&(i=!0),o.varianceState===void 0?delete s._varianceState:s._varianceState=o.varianceState,s._varianceBlockedOn!==o.varianceBlockedOn&&(i=!0),o.varianceBlockedOn===void 0?delete s._varianceBlockedOn:s._varianceBlockedOn=o.varianceBlockedOn;let u=s;u._declaredByStatement!==o.declaredByStatement&&(i=!0),o.declaredByStatement===void 0?delete u._declaredByStatement:u._declaredByStatement=o.declaredByStatement;let a=s,l=a._forwardArity,f=o.forwardArity;(l===void 0!=(f===void 0)||l!==void 0&&f!==void 0&&(l.size!==f.size||[...f].some(c=>!l.has(c))))&&(i=!0),f===void 0?delete a._forwardArity:a._forwardArity=f,s._sumOf!==o.sumOf&&(i=!0),o.sumOf===void 0?delete s._sumOf:s._sumOf=o.sumOf,s._sumVariants!==o.sumVariants&&(i=!0),o.sumVariants===void 0?delete s._sumVariants:s._sumVariants=o.sumVariants,o.declOrigin===void 0?delete s._declOrigin:s._declOrigin=o.declOrigin,s.name in n||(n[s.name]=s,i=!0)}i&&this._noteStateEvent({kind:"config"})}}_protocolRegistryRollbackPoint(){let n=this._protocolRegistry,t=new Set(Object.keys(n)),r=[...t].map(i=>{let o=n[i];return{r:o,members:o.members,conformances:[...o.conformances],edges:o.conformances.map(s=>({c:s,impl:s.impl,authored:s._authored,origin:s._implOrigin,pending:s.pending,pendingReason:s._pendingReason})),declaredByStatement:o.declaredByStatement,declOrigin:o._declOrigin}});return()=>{let i=!1;for(let o of Object.keys(n))t.has(o)||(delete n[o],i=!0);for(let o of r){let s=o.r;s.members!==o.members&&(i=!0),s.members=o.members,s.declaredByStatement!==o.declaredByStatement&&(i=!0),s.declaredByStatement=o.declaredByStatement,o.declOrigin===void 0?delete s._declOrigin:s._declOrigin=o.declOrigin,(s.conformances.length!==o.conformances.length||o.conformances.some((u,a)=>s.conformances[a]!==u))&&(i=!0),s.conformances=o.conformances;for(let u of o.edges)u.c.impl!==u.impl&&(i=!0),u.impl===void 0?delete u.c.impl:u.c.impl=u.impl,u.authored===void 0?delete u.c._authored:u.c._authored=u.authored,u.origin===void 0?delete u.c._implOrigin:u.c._implOrigin=u.origin,u.c.pending!==u.pending&&(i=!0),u.c.pending=u.pending,u.pendingReason===void 0?delete u.c._pendingReason:u.c._pendingReason=u.pendingReason;s.name in n||(n[s.name]=s,i=!0)}i&&(this._noteStateEvent({kind:"config"}),this._noteConformanceRegistryChange())}}_rollbackFrames=[];_withRolledBackInference(n,t){this._inferenceTxDepth>0;let r=new sL({boxingRepairDepthAtOpen:this._boxingState.frameDepth(),forbidsRepairs:t?.forbidsRepairs});this._rollbackFrames.push(r);let i;try{return n()}catch(o){throw i={error:o},o}finally{let o=this._rollbackFrames.pop(),s=r.rollback();if(this._boxingState.hasRepairRequestedAtOrAbove(r.boxingRepairDepthAtOpen),s!==void 0&&this._debugBindings)throw new Error("Inference rollback failed: an undo entry threw while unwinding the frame",{cause:i?.error??s.error})}}_withBoxingPassWindow(n){uw(this);try{return n()}finally{aw(this)}}declareProtocol(n,t){PE(this,n,t)}declareProtocolImplementation(n,t,r,i){FB(this,n,t,r,i)}__typeResolver;get _typeResolver(){return this.__typeResolver??=Kte(this),this.__typeResolver}declareType(n,t,r){km(this,n,t,r)}get trace(){return this._evalContextStack.map(n=>n.name).filter(n=>n!==void 0).reverse()}get _anyVersion(){return this._configurationLifecycle.anyVersion}get _semanticVersion(){return this._configurationLifecycle.semanticVersion}get _worldVersion(){return this._configurationLifecycle.worldVersion}get _callableVersion(){return this._configurationLifecycle.callableVersion}get _ephemeralWriteDepth(){return this._configurationLifecycle.ephemeralWriteDepth}set _ephemeralWriteDepth(n){this._configurationLifecycle.ephemeralWriteDepth=n}get _factSuppressionDepth(){return this._configurationLifecycle.factSuppressionDepth}set _factSuppressionDepth(n){this._configurationLifecycle.factSuppressionDepth=n}_withoutFacts(n){if(n.constructor.name==="AsyncFunction")throw new Error("A fact-blind bracket must be synchronous: an async thunk is refused before it runs, because everything after its first await would see the assumptions again");let t=this._configurationLifecycle;t.factSuppressionDepth+=1;let r;try{r=n()}finally{t.factSuppressionDepth-=1}if(typeof r?.then=="function")throw Promise.resolve(r).then(void 0,()=>{}),new Error("A fact-blind bracket must be synchronous: its thunk returned a promise, whose work would run after the bracket closed and would see the assumptions again");return r}_factsHidden(){if(this._factSuppressionDepth===0)return!1;let n=this.context;return n===void 0?!1:(n.assumptions?.size??0)!==0||(n.assumedValues?.size??0)!==0}_cacheGeneration(){return this._anyVersion*2+(this._factsHidden()?1:0)}_nextFactId(){return this._factIdCounter+=1,this._factIdCounter}_factIdCounter=0;get _scratchDeclarationScopes(){return this._configurationLifecycle.scratchDeclarationScopes}_checkpointWindow=void 0;_checkpointStack=[];_checkpointPoisoned=!1;_nextCheckpointId=1;_invalidateCheckpointsOnFrameDiscard(n){c6(this,n)}_inFlightAsyncEvaluations=0;_evaluationDepth=0;_objectStoreEpoch=0;_applicationMemo=void 0;checkpoint(n){return l6(this,n)}restore(n){f6(this,n)}discard(n){d6(this,n)}_noteStateEvent(n){dL&&this._checkpointWindow?.noteEvent(n.kind),this._configurationLifecycle.noteStateEvent(n)}_inferenceTxDepth=0;_hasAsyncOnlyOperator=!1;_boxingEpoch=0;_debugBindings=uL();_freshlyInferred=null;_inferenceCause=null;_noteInferenceWrite(n){let t=this._inferenceCause;if(t&&t.expr===void 0&&(t.expr=this._fn(t.operator,t.ops.map(r=>this.expr(r,{form:"raw"})),{canonical:!1})),Ls(this,n.target,{type:n.to,kind:n.kind,axis:"type",cause:t?.expr,epoch:Bs(this)}),n.valueDef!==void 0&&n.from.isUnknown&&this._inferenceTxDepth>0){let r=this._freshlyInferred??=new Set,i=Lt(this);if(i!==void 0&&!r.has(n.valueDef)){let o=n.valueDef;i.record({undo:()=>r.delete(o)})}r.add(n.valueDef)}this._narrowingSink?._recordNarrowing(n.name,n.binding,n.from,n.to)}strict;get jit(){return this._jit}set jit(n){n!==this._jit&&(this._jit=n,this._noteStateEvent({kind:"config"}))}_jit="auto";static getStandardLibrary(n){return ew(n)}constructor(n){if(n!==void 0&&typeof n!="object")throw Error("Unexpected argument");this.strict=!0,this.jit="auto",this._numericConfiguration=new OC({precision:n?.precision,tolerance:n?.tolerance??"auto",angularUnit:"rad"});let t=new FC(this),r=t.initializeCommonNumbers();this.Zero=r.Zero,this.One=r.One,this.Half=r.Half,this.NegativeOne=r.NegativeOne,this.Two=r.Two,this.NaN=r.NaN,this.PositiveInfinity=r.PositiveInfinity,this.NegativeInfinity=r.NegativeInfinity,this.I=r.I,this.ComplexInfinity=r.ComplexInfinity,this._reset(),this.pushScope(void 0,"system"),this.declareType("limits","expression<Limits>"),this.declareType("distribution","expression<NormalDistribution> | expression<BinomialDistribution> | expression<PoissonDistribution> | expression<UniformDistribution> | expression<ExponentialDistribution>",{alias:!0}),t.bootstrapLibraries(n?.libraries);let i=t.initializeCommonSymbolBindings(this._commonSymbols);this.True=i.True,this.False=i.False,this.Pi=i.Pi,this.E=i.E,this.Nothing=i.Nothing,this.Missing=i.Missing,this.pushScope(void 0,"global"),this._compilationTargets.registerDefaults(),n?.latexSyntax&&(this._latexSyntax=n.latexSyntax),n?.latexOptions&&(t2(n.latexOptions),this._latexOptions={...n.latexOptions}),z5(this)}toJSON(){return"[ComputeEngine]"}[Symbol.toStringTag]="ComputeEngine";_reset(){this._configurationLifecycle.reset({refreshNumericConstants:()=>{},resetCommonSymbols:()=>KJ(this._commonSymbols),purgeCaches:()=>this._cacheStore.purgeValues()})}_listenToConfigurationChange(n){return this._configurationLifecycle.listen(n)}_compile(n,t){return BC(n,t)}_getCompilationTarget(n){return this._compilationTargets.get(n)}_listCompilationTargets(){return this._compilationTargets.list()}_registerCompilationTarget(n,t){this._compilationTargets.register(n,t)}_unregisterCompilationTarget(n){this._compilationTargets.unregister(n)}get precision(){return this._numericConfiguration.precision}set precision(n){this._numericConfiguration.setPrecision(n)&&this._reset()}get angularUnit(){return this._numericConfiguration.angularUnit}set angularUnit(n){this._numericConfiguration.setAngularUnit(n)&&this._reset()}withTimeLimit(n,t){let r=typeof n=="number"?n:n.ms,i=typeof n=="number"?void 0:n.label,o=this._runtimeState.deadlineFrame,s=Date.now()+r,u=[...o?.spans??[],...i!==void 0?[i]:[]],a=o!==void 0&&o.at<=s?{at:o.at,owner:o.owner,spans:u}:{at:s,owner:i,spans:u};this._runtimeState.deadlineFrame=a;try{return t()}finally{this._runtimeState.deadlineFrame=o}}get _deadline(){return this._runtimeState.deadline}set _deadline(n){this._runtimeState.deadline=n}get _deadlineFrame(){return this._runtimeState.deadlineFrame}set _deadlineFrame(n){this._runtimeState.deadlineFrame=n}get _timeRemaining(){return this._runtimeState.timeRemaining}get _mapAutoCompileStats(){return ni}get iterationLimit(){return this._runtimeState.iterationLimit}set iterationLimit(n){n!==this._runtimeState.iterationLimit&&(this._runtimeState.iterationLimit=n,this._noteStateEvent({kind:"config"}))}get recursionLimit(){return this._runtimeState.recursionLimit}set recursionLimit(n){this._runtimeState.recursionLimit=n}_enterRecursion(){this._runtimeState.enterRecursion()}_exitRecursion(){this._runtimeState.exitRecursion()}get maxCollectionSize(){return this._runtimeState.maxCollectionSize}set maxCollectionSize(n){this._runtimeState.maxCollectionSize=n}get _isVerifying(){return this._runtimeState.isVerifying}set _isVerifying(n){this._runtimeState.isVerifying=n}get isVerifying(){return this._runtimeState.isVerifying}get tolerance(){return this._numericConfiguration.tolerance}set tolerance(n){this._numericConfiguration.setTolerance(n)&&this._noteStateEvent({kind:"config"})}get _randomFrame(){return this._runtimeState.randomFrame}set _randomFrame(n){this._runtimeState.randomFrame=n}_random(){let n=this._runtimeState.randomFrame;if(n!==void 0){let t=n.next>>>0;return n.next=n.next+1>>>0,hL(n.seedLo,n.seedHi,t)}return Math.random()}_substream(n){return yL(this._runtimeState.randomFrame,n)}chop(n){let t=this._numericConfiguration.tolerance;return typeof n=="number"?Math.abs(n)<=t?0:n:n instanceof D?n.isPositive()&&n.lte(this._numericConfiguration.bignumTolerance)||n.isNegative()&&n.gte(this._numericConfiguration.negBignumTolerance)||n.isZero()?0:n:n instanceof W&&Math.abs(n.re)<=t&&Math.abs(n.im)<=t?0:n}bignum(n){return this._numericConfiguration.bignum(n)}complex(n,t){return n instanceof D&&(n=n.toNumber()),t instanceof D&&(t=t.toNumber()),new W(n,t)}_numericValue(n){if(n instanceof Sr)return n.asExact??n;let t=this._numericConfiguration.precision>Ud?r=>new k5(r):r=>new _5(r);if(typeof n=="number")return Number.isInteger(n)?new pn(n,t):t(n);if(typeof n=="bigint")return new pn(n,t);if(fl(n))return new pn({rational:n},t);if(n instanceof D){if(n.isInteger()){let r=Qf(n.toString());if(r!==null)return new pn(r,t)}return t(n)}if(n instanceof W)return n.im===0?this._numericValue(n.re):t({re:n.re,im:n.im});if("im"in n||"re"in n)return n.im!==void 0&&n.im!==0?t(n):n.re instanceof D&&n.re.isInteger()?new pn({rational:[Qf(n.re.toString()),BigInt(1)]},t):typeof n.re=="number"&&Number.isInteger(n.re)?new pn({rational:[n.re,1]},t):t(n);if("radical"in n||"rational"in n){let r=n;if(r.radical!==void 0&&r.radical!==1){if(!Number.isInteger(r.radical)||r.radical<1)return t({re:h2(r.rational??[1,1])*Math.sqrt(r.radical)});if(r.radical>=On){let[i,o]=qg(r.radical,2);if(o>=On)return t({re:h2(r.rational??[1,1])*Math.sqrt(r.radical)});r={...r,radical:o,rational:CL(r.rational??[1,1],[i,1])}}}return r.rational&&hv(r.rational)&&(!Number.isInteger(r.rational[0])||!Number.isInteger(r.rational[1]))?t(r):new pn(r,t)}throw Error(`Unexpected value: ${typeof n=="object"?JSON.stringify(n):String(n)}`)}get costFunction(){return this._cost??oZ}set costFunction(n){this._cost=typeof n=="function"?n:void 0}get simplificationRules(){return this._simplificationRules.rules}set simplificationRules(n){this._simplificationRules.rules=n,this._cacheStore.invalidate("standard-simplification-rules")}get solveRules(){return this._solveRules.rules}set solveRules(n){this._solveRules.rules=n,this._cacheStore.invalidate("univariate-roots-rules")}get harmonizationRules(){return this._harmonizationRules.rules}set harmonizationRules(n){this._harmonizationRules.rules=n,this._cacheStore.invalidate("harmonization-rules")}lookupDefinition(n){return IG(this,n)}normalizeIdentifier(n){if(!n)return"";if(Ji(n))return n;this.pushScope();try{let t=this.parse(n);if(C(t))return t.symbol}finally{this.popScope()}return""}operatorInfo(n){let t=this.lookupDefinition(n);if(!t||!Q(t))return;let r=t.operator,i=!!(r.evaluate||r.collection);return{kind:i?"function":"opaque",signature:r.signature,canEvaluate:i}}symbolInfo(n){let t=this.lookupDefinition(n);if(!t||!J(t))return;let r=t.value;return{kind:r.isConstant?"constant":"variable",type:r.type}}searchDefinitions(n,t){return kG(this,n,t)}suggestOperatorName(n){return MG(this,n)}functionProperties(n){return Xc(this,n)}_declareSymbolValue(n,t,r){return OG(this,n,t,r)}_declareSymbolOperator(n,t,r){return PG(this,n,t,r)}pushScope(n,t){fJ(this,n,t)}popScope(){cJ(this)}createScope(n,t){return hJ(this,n,t)}_narrowingSink=void 0;_pushEvalContext(n,t,r){d$(this,n,t,r)}_popEvalContext(){p$(this)}_removeEvalContext(n){dJ(this,n)}_inScope(n,t){return mJ(this,n,t)}_resolveOnlyDepth=0;_resolveOnly(n){this._resolveOnlyDepth+=1;try{return n()}finally{this._resolveOnlyDepth-=1}}_printStack(n){gJ(this,n)}_bindingSymbol(n,t){return Wte(this,n,t)}_shadowedParameterStack=[];_pushShadowedParameters(n,t){this._shadowedParameterStack.push({names:new Set(n),types:t,defs:new Map,boundary:this.context.lexicalScope})}_popShadowedParameters(){this._shadowedParameterStack.pop()}_isShadowedParameter(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return!0;return!1}_shadowedParameterType(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].types?.get(n)}_shadowedParameterBoundary(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].boundary}_shadowedParameterDef(n){let t=this._shadowedParameterStack;for(let r=t.length-1;r>=0;r--)if(t[r].names.has(n))return t[r].defs.get(n)}_setShadowedParameterDef(n,t){let r=this._shadowedParameterStack;for(let i=r.length-1;i>=0;i--)if(r[i].names.has(n)){r[i].defs.set(n,t);return}}_currentShadowedParameterDefs(){let n=this._shadowedParameterStack;return n.length>0?n[n.length-1].defs:new Map}_getSymbolValue(n){return DG(this,n)}_setSymbolValue(n,t){FG(this,n,t)}declare(n,t,r){return VG(this,n,t,r)}declareSequence(n,t){return LJ(this,n,t)}getSequenceStatus(n){return BJ(this,n)}getSequence(n){return VJ(this,n)}listSequences(){return jJ(this)}isSequence(n){return qJ(this,n)}clearSequenceCache(n){zJ(this,n)}getSequenceCache(n){return UJ(this,n)}getSequenceTerms(n,t,r,i){return HJ(this,n,t,r,i)}lookupOEIS(n,t){return GJ(this,n,t)}checkSequenceOEIS(n,t,r){return WJ(this,n,t,r)}interpret(n,t){return YJ(this,n,t)}assign(n,t){return jG(this,n,t)}_shouldContinueExecution(){return this._runtimeState.shouldContinueExecution()}_checkContinueExecution(){if(!this._shouldContinueExecution())throw new Error("timeout")}_cache(n,t,r){return this._cacheStore.getOrBuild(n,()=>{let i=this._runtimeState.deadlineFrame;if(i===void 0)return t();this._runtimeState.deadlineFrame=void 0;try{return t()}finally{this._runtimeState.deadlineFrame=i}},r)}expr(n,t){let{canonical:r,structural:i}=Jb(t);return cw(this,t?.scope,()=>Ot(this,n,{canonical:r,structural:i,scope:t?.scope}))}box(n,t){return this.expr(n,t)}rebind(n,t){return cw(this,t?.scope,()=>IZ(this,n,t))}_latexSyntax;get latexSyntax(){return!this._latexSyntax&&e._latexSyntaxFactory&&(this._latexSyntax=e._latexSyntaxFactory()),this._latexSyntax}_requireLatexSyntax(){if(!this._latexSyntax&&e._latexSyntaxFactory&&(this._latexSyntax=e._latexSyntaxFactory()),!this._latexSyntax)throw new Error("LatexSyntax not available. Pass a LatexSyntax instance to the ComputeEngine constructor.");return this._latexSyntax}_latexOptions={};get latexOptions(){return this._latexOptions}set latexOptions(n){t2(n),this._latexOptions={...n}}parse(n,t){if(n==null)return null;if(typeof n!="string")throw Error("ce.parse(): expected a LaTeX string");if(t?.speculative){if(t.scope!==void 0)throw Error("ce.parse(): the `speculative` and `scope` options are mutually exclusive \u2014 `speculative` discards the parse's writes, `scope` harvests them");let{speculative:b,...v}=t,E=this.parse(n,{...v,form:"raw"});this.pushScope(void 0,"speculative-parse");try{let x=this.context.lexicalScope;if(E!==null)for(let S of new Set(E.symbols)){let w=this.lookupDefinition(S);w!==void 0&&"value"in w&&!w.value.isConstant&&(w.value.inferredType||w.value.type.isUnknown)&&this.declare(S,{inferred:!0,type:w.value.type.type,...w.value.subscriptEvaluate?{subscriptEvaluate:w.value.subscriptEvaluate}:{}},x)}return this.parse(n,v)}finally{this.popScope()}}if(t?.scope)return cw(this,t.scope,()=>this.parse(n,{...t,scope:void 0}));let r=this._requireLatexSyntax(),{form:i,canonical:o,structural:s,scope:u,speculative:a,...l}=t??{},f=l.diagnostics??this._latexOptions?.diagnostics??!1,c,d,p,m=new Set;if(f){c=[],p=v=>m.add(v);let b=new Set;d=v=>{let E=`${v.code} ${v.start} ${v.end} ${v.detail?JSON.stringify(v.detail):""}`;b.has(E)||(b.add(E),c.push(v))}}let h=l.resolveSymbol??this._latexOptions?.resolveSymbol,y=h?b=>h(b)??this._resolveSymbolFromScope(b):b=>this._resolveSymbolFromScope(b);uw(this);try{let b=r.parse(n,{tolerance:this.tolerance,...this._latexOptions,...l,resolveSymbol:y,diagnostics:f,onDiagnostic:d,onBoundVariable:p});if(b===null)return null;let v=Ot(this,b,Jb({form:i,canonical:o,structural:s}));if(c!==void 0){if(v=v._unshared(),v.isCanonical)try{let E=new Set(v.symbols),x=new Set(v.freeVariables);for(let S of c){if(S.code!=="undeclared-symbol")continue;let w=S.detail?.name;typeof w=="string"&&(m.has(w)||E.has(w)&&!x.has(w)&&`${w}`)}}catch{}for(let E of c)E.detail&&Object.freeze(E.detail),Object.freeze(E);v.parseDiagnostics=Object.freeze(c)}return v}finally{aw(this)}}_resolveSymbolFromScope(n){let t=this.lookupDefinition(n);if(t)return Q(t)?{type:t.operator.signature}:J(t)?{type:t.value.type,subscriptEvaluate:!!t.value.subscriptEvaluate}:{type:k.unknown}}appliedNonFunctions(n){let t=this.latexSyntax;if(!t)return[];let r=this._latexOptions?.resolveSymbol,i=t.parse(n,{...this._latexOptions,resolveSymbol:r?s=>r(s)??this._resolveSymbolFromScope(s):s=>this._resolveSymbolFromScope(s)}),o=new Set;return i!==null&&RF(i,o),Array.from(o).sort()}function(n,t,r){let{canonical:i,structural:o}=Jb(r);return Yb(this,n,t,{metadata:r?.metadata,canonical:i,structural:o,scope:r?.scope})}error(n,t){return LC(this,n,t)}typeError(n,t,r){return ere(this,n,t,r)}hold(n){return this._fn("Hold",[this.expr(n,{form:"raw"})])}tuple(...n){return new Ze(this,"Tuple",n.map(t=>typeof t=="number"?this.number(t):t.canonical).filter(t=>!C(t,"Nothing")),{canonical:!0})}list(n){let t=n.length;if(typeof t!="number"||!Number.isSafeInteger(t)||t<0)throw new TypeError(`list(): the length must be a non-negative safe integer, not ${String(t)}`);if(t===0)return this.function("List",[]);let r=new Array(t);for(let i=0;i<t;i++){let o=n[i];if(typeof o!="number")throw new TypeError(`list(): element ${i} is ${o===void 0?"undefined":typeof o}, not a number`);r[i]=o===0?0:o}return new Ze(this,"List",void 0,{canonical:!0,numericStore:Object.freeze(r)})}type(n){if(n instanceof k)return n;if(typeof n=="string"&&Z0(n)){let t=this._commonTypes.get(n);return t===void 0&&(t=new k(n,this._typeResolver),this._commonTypes.set(n,t)),t}return new k(n,this._typeResolver)}string(n,t){return new Nl(this,n,t)}character(n,t){if(!bp(n))throw new Error(`ce.character(): "${n}" is not exactly one grapheme cluster. A character is exactly one user-perceived character (one UAX #29 extended grapheme cluster); use ce.string() for arbitrary text, or CharacterFrom() to get a diagnostic instead of a throw.`);return new xE(this,n,t)}symbol(n,t){return Gte(this,this._commonSymbols,n,t)}number(n,t){return Yte(this,this._commonNumbers,n,t)}rules(n,t){return qy(this,n,t)}getRuleSet(n){if(n??="standard-simplification",n==="standard-simplification"){this._simplificationRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("standard-simplification-rules");let t=this._cache("standard-simplification-rules",()=>{let i=qy(this,this._simplificationRules.rules,{canonical:!0}).rules.filter(o=>o.purpose!=="expand");return{rules:Dj(i)}});return this._simplificationRules.markCached(),t}if(n==="solve-univariate"){this._solveRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("univariate-roots-rules");let t=this._cache("univariate-roots-rules",()=>qy(this,this._solveRules.rules));return this._solveRules.markCached(),t}if(n==="harmonization"){this._harmonizationRules.hasMutatedSinceLastCache()&&this._cacheStore.invalidate("harmonization-rules");let t=this._cache("harmonization-rules",()=>qy(this,this._harmonizationRules.rules));return this._harmonizationRules.markCached(),t}}_fn(n,t,r){let i=r?.canonical??!0;return ll(t,this)?this.error("object-foreign-engine"):new Ze(this,n,t,{...r,canonical:i})}_object(n,t,r,i){return FZ(this,n,t,r,i)}ask(n){return v$(this,n)}verify(n){return E$(this,n)}assume(n){return OJ(this,n)}forget(n){x$(this,n)}};VC(()=>new zf);var nXe="0.129.1",rXe=zf;zf._latexSyntaxFactory=()=>new ch;VC(()=>new zf({latexSyntax:new ch}));globalThis[Symbol.for("io.cortexjs.compute-engine")]={ComputeEngine:zf,version:"0.129.1",LatexSyntax:ch,LATEX_DICTIONARY:fh,isExpression:qo,isNumber:T,isSymbol:C,isFunction:g,isString:j,isCharacter:Ye,isTensor:al,isDictionary:Qe,isObject:Vn,isCollection:c2,isIndexedCollection:d2,numericValue:er,sym:P,compile:jC};export{sN as a,Y5 as b,uN as c,bp as d,TN as e,Ea as f,qb as g,Vje as h,jje as i,Fze as j,Lze as k,R as l,rg as m,Fd as n,cg as o,k0 as p,mg as q,wg as r,Vf as s,tre as t,rre as u,ire as v,ore as w,sre as x,ure as y,are as z,lre as A,fre as B,cre as C,dre as D,jC as E,nXe as F,rXe as G};
|