solve-engine 2.32.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/{EngineError-CqGtaT_v.d.cts → EngineError-Bm4OYmw8.d.cts} +6 -0
  2. package/dist/{EngineError-CqGtaT_v.d.ts → EngineError-Bm4OYmw8.d.ts} +6 -0
  3. package/dist/{Lexer-CqFjYoRA.d.ts → Lexer-DPn5dfCH.d.ts} +1 -13
  4. package/dist/{Lexer-sCI05tqO.d.cts → Lexer-DaWkCu84.d.cts} +1 -13
  5. package/dist/{PackageCompatibility-phvSFP4f.d.ts → PackageCompatibility-CkzZfoJ3.d.ts} +1 -1
  6. package/dist/{PackageCompatibility-Bn-T_xKW.d.cts → PackageCompatibility-E_5GtcQW.d.cts} +1 -1
  7. package/dist/{PackageRegistry-C78jVkI9.d.ts → PackageRegistry-DSqic8kz.d.ts} +132 -23
  8. package/dist/{PackageRegistry-B-C1duZw.d.cts → PackageRegistry-js47hr28.d.cts} +132 -23
  9. package/dist/{Parselet-Dgymjxzd.d.ts → Parselet-CQjcHOKw.d.ts} +13 -6
  10. package/dist/{Parselet-DF3864la.d.cts → Parselet-s1sRRn8H.d.cts} +13 -6
  11. package/dist/{TokenNormalizer-Pe3_390t.d.cts → TokenNormalizer-D382VSYh.d.cts} +4 -1
  12. package/dist/{TokenNormalizer-IF7nPRMp.d.ts → TokenNormalizer-DAzPp-j1.d.ts} +4 -1
  13. package/dist/{VMBuiltins-BkKzhj6C.d.cts → VMBuiltins-JCavlQUj.d.cts} +53 -18
  14. package/dist/{VMBuiltins-Du9y8sEo.d.ts → VMBuiltins-qgzA6qGi.d.ts} +53 -18
  15. package/dist/{VMCheckpoints-WdUQrdc9.d.cts → VMCheckpoints-BxPzmdu0.d.cts} +2 -2
  16. package/dist/{VMCheckpoints-gvy_yxYh.d.ts → VMCheckpoints-DjjE92mf.d.ts} +2 -2
  17. package/dist/{Value-BYHw-x7q.d.cts → Value-2TIKi-YL.d.cts} +19 -0
  18. package/dist/{Value-BYHw-x7q.d.ts → Value-2TIKi-YL.d.ts} +19 -0
  19. package/dist/{WorkerError-DTrl3Jag.d.ts → WorkerError-BaN8_eok.d.ts} +1 -1
  20. package/dist/{WorkerError-CRoM8Ju1.d.cts → WorkerError-CexHHmbb.d.cts} +1 -1
  21. package/dist/{chunk-IJE4AEDX.js → chunk-24OW3AAU.js} +3 -3
  22. package/dist/{chunk-IJE4AEDX.js.map → chunk-24OW3AAU.js.map} +1 -1
  23. package/dist/{chunk-CAJTDZ5B.cjs → chunk-2XOLAHW6.cjs} +2 -2
  24. package/dist/{chunk-CAJTDZ5B.cjs.map → chunk-2XOLAHW6.cjs.map} +1 -1
  25. package/dist/{chunk-AGCNMEP2.cjs → chunk-3MG7VIPL.cjs} +2 -2
  26. package/dist/{chunk-AGCNMEP2.cjs.map → chunk-3MG7VIPL.cjs.map} +1 -1
  27. package/dist/chunk-4ASM522I.js +2 -0
  28. package/dist/chunk-4ASM522I.js.map +1 -0
  29. package/dist/{chunk-KH4QXKLT.js → chunk-4MD5L23F.js} +2 -2
  30. package/dist/{chunk-KH4QXKLT.js.map → chunk-4MD5L23F.js.map} +1 -1
  31. package/dist/{chunk-IQVSCL2R.js → chunk-4XWZXP6I.js} +3 -3
  32. package/dist/{chunk-IQVSCL2R.js.map → chunk-4XWZXP6I.js.map} +1 -1
  33. package/dist/{chunk-RELMEWY6.js → chunk-6G2NES2I.js} +2 -2
  34. package/dist/chunk-6G2NES2I.js.map +1 -0
  35. package/dist/{chunk-CDE2ZUGG.js → chunk-6NL7RBAG.js} +2 -2
  36. package/dist/{chunk-CDE2ZUGG.js.map → chunk-6NL7RBAG.js.map} +1 -1
  37. package/dist/{chunk-SUAGBRQ7.cjs → chunk-6SYU4MH7.cjs} +2 -2
  38. package/dist/chunk-6SYU4MH7.cjs.map +1 -0
  39. package/dist/chunk-72J5V7SN.cjs +2 -0
  40. package/dist/chunk-72J5V7SN.cjs.map +1 -0
  41. package/dist/{chunk-TSJ4RQLZ.js → chunk-AENL3Z66.js} +2 -2
  42. package/dist/{chunk-TSJ4RQLZ.js.map → chunk-AENL3Z66.js.map} +1 -1
  43. package/dist/chunk-APYRNAU2.js +2 -0
  44. package/dist/chunk-APYRNAU2.js.map +1 -0
  45. package/dist/{chunk-AXTYQFIV.cjs → chunk-D7URPV5Z.cjs} +3 -3
  46. package/dist/{chunk-AXTYQFIV.cjs.map → chunk-D7URPV5Z.cjs.map} +1 -1
  47. package/dist/chunk-DB5ISONG.js +2 -0
  48. package/dist/chunk-DB5ISONG.js.map +1 -0
  49. package/dist/chunk-DGDVY6XI.js +3 -0
  50. package/dist/chunk-DGDVY6XI.js.map +1 -0
  51. package/dist/chunk-EOKHRS2T.js +2 -0
  52. package/dist/chunk-EOKHRS2T.js.map +1 -0
  53. package/dist/{chunk-NQFCXLEF.js → chunk-EOO6M65F.js} +2 -2
  54. package/dist/{chunk-NQFCXLEF.js.map → chunk-EOO6M65F.js.map} +1 -1
  55. package/dist/{chunk-A764BY7L.cjs → chunk-EQNKDTMX.cjs} +2 -2
  56. package/dist/{chunk-A764BY7L.cjs.map → chunk-EQNKDTMX.cjs.map} +1 -1
  57. package/dist/chunk-FESR6PZI.cjs +2 -0
  58. package/dist/chunk-FESR6PZI.cjs.map +1 -0
  59. package/dist/chunk-G2LCDR52.cjs +3 -0
  60. package/dist/chunk-G2LCDR52.cjs.map +1 -0
  61. package/dist/chunk-G5TZ6TDA.js +2 -0
  62. package/dist/chunk-G5TZ6TDA.js.map +1 -0
  63. package/dist/chunk-GDLYXRMA.cjs +2 -0
  64. package/dist/chunk-GDLYXRMA.cjs.map +1 -0
  65. package/dist/{chunk-7DJYS5PO.cjs → chunk-HSTGWWU2.cjs} +2 -2
  66. package/dist/{chunk-7DJYS5PO.cjs.map → chunk-HSTGWWU2.cjs.map} +1 -1
  67. package/dist/{chunk-OE2DBN4K.js → chunk-INMJ7ZXL.js} +2 -2
  68. package/dist/chunk-INMJ7ZXL.js.map +1 -0
  69. package/dist/chunk-ITH2RLRG.js +5 -0
  70. package/dist/chunk-ITH2RLRG.js.map +1 -0
  71. package/dist/{chunk-5AKT36UK.cjs → chunk-K3PZ66XR.cjs} +2 -2
  72. package/dist/{chunk-5AKT36UK.cjs.map → chunk-K3PZ66XR.cjs.map} +1 -1
  73. package/dist/chunk-LI6LYJDA.cjs +2 -0
  74. package/dist/chunk-LI6LYJDA.cjs.map +1 -0
  75. package/dist/{chunk-WQGHJAW2.cjs → chunk-M4UC2PB6.cjs} +2 -2
  76. package/dist/{chunk-WQGHJAW2.cjs.map → chunk-M4UC2PB6.cjs.map} +1 -1
  77. package/dist/chunk-O7HF345B.js +2 -0
  78. package/dist/chunk-O7HF345B.js.map +1 -0
  79. package/dist/{chunk-CM2WM5CM.cjs → chunk-OBZJKZ2F.cjs} +2 -2
  80. package/dist/{chunk-CM2WM5CM.cjs.map → chunk-OBZJKZ2F.cjs.map} +1 -1
  81. package/dist/{chunk-Q7TBBV62.cjs → chunk-P5YWBIIU.cjs} +2 -2
  82. package/dist/chunk-P5YWBIIU.cjs.map +1 -0
  83. package/dist/chunk-PICFFFJV.js +3 -0
  84. package/dist/chunk-PICFFFJV.js.map +1 -0
  85. package/dist/{chunk-P43SV4NJ.cjs → chunk-QOOTRUY7.cjs} +3 -3
  86. package/dist/{chunk-P43SV4NJ.cjs.map → chunk-QOOTRUY7.cjs.map} +1 -1
  87. package/dist/chunk-R3W53ZMP.cjs +2 -0
  88. package/dist/chunk-R3W53ZMP.cjs.map +1 -0
  89. package/dist/chunk-RMDCGYZM.js +2 -0
  90. package/dist/chunk-RMDCGYZM.js.map +1 -0
  91. package/dist/{chunk-CB3EXUM2.js → chunk-RU3KGJRA.js} +2 -2
  92. package/dist/chunk-RU3KGJRA.js.map +1 -0
  93. package/dist/chunk-S3SPDK6N.cjs +2 -0
  94. package/dist/chunk-S3SPDK6N.cjs.map +1 -0
  95. package/dist/chunk-SF5QVUEI.cjs +3 -0
  96. package/dist/chunk-SF5QVUEI.cjs.map +1 -0
  97. package/dist/{chunk-FXB5GCBT.js → chunk-TJKN466F.js} +2 -2
  98. package/dist/{chunk-FXB5GCBT.js.map → chunk-TJKN466F.js.map} +1 -1
  99. package/dist/{chunk-VLX7ZVK4.js → chunk-U5MESNRT.js} +2 -2
  100. package/dist/{chunk-VLX7ZVK4.js.map → chunk-U5MESNRT.js.map} +1 -1
  101. package/dist/chunk-WCVPXBCW.cjs +5 -0
  102. package/dist/chunk-WCVPXBCW.cjs.map +1 -0
  103. package/dist/{chunk-YWF6C2IO.cjs → chunk-WFT3XUSH.cjs} +2 -2
  104. package/dist/{chunk-YWF6C2IO.cjs.map → chunk-WFT3XUSH.cjs.map} +1 -1
  105. package/dist/{chunk-3ZGFAE3Q.js → chunk-X2GQAKL2.js} +2 -2
  106. package/dist/{chunk-3ZGFAE3Q.js.map → chunk-X2GQAKL2.js.map} +1 -1
  107. package/dist/{chunk-G3POUURF.js → chunk-YID47OPR.js} +2 -2
  108. package/dist/{chunk-G3POUURF.js.map → chunk-YID47OPR.js.map} +1 -1
  109. package/dist/chunk-YV4GDW5A.cjs +2 -0
  110. package/dist/chunk-YV4GDW5A.cjs.map +1 -0
  111. package/dist/chunk-ZSXQP7PD.cjs +2 -0
  112. package/dist/chunk-ZSXQP7PD.cjs.map +1 -0
  113. package/dist/constants.cjs +1 -1
  114. package/dist/constants.js +1 -1
  115. package/dist/engine.cjs +1 -1
  116. package/dist/engine.d.cts +10 -10
  117. package/dist/engine.d.ts +10 -10
  118. package/dist/engine.js +1 -1
  119. package/dist/engine.worker.cjs +1 -1
  120. package/dist/engine.worker.cjs.map +1 -1
  121. package/dist/engine.worker.js +1 -1
  122. package/dist/engine.worker.js.map +1 -1
  123. package/dist/errors.cjs +1 -1
  124. package/dist/errors.d.cts +3 -3
  125. package/dist/errors.d.ts +3 -3
  126. package/dist/errors.js +1 -1
  127. package/dist/format.cjs +1 -1
  128. package/dist/format.d.cts +1 -1
  129. package/dist/format.d.ts +1 -1
  130. package/dist/format.js +1 -1
  131. package/dist/index.cjs +1 -1
  132. package/dist/index.cjs.map +1 -1
  133. package/dist/index.d.cts +10 -10
  134. package/dist/index.d.ts +10 -10
  135. package/dist/index.js +1 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/language.d.cts +9 -9
  138. package/dist/language.d.ts +9 -9
  139. package/dist/lexer.cjs +1 -1
  140. package/dist/lexer.d.cts +3 -3
  141. package/dist/lexer.d.ts +3 -3
  142. package/dist/lexer.js +1 -1
  143. package/dist/normalizer.cjs +1 -1
  144. package/dist/normalizer.d.cts +2 -2
  145. package/dist/normalizer.d.ts +2 -2
  146. package/dist/normalizer.js +1 -1
  147. package/dist/packages.cjs +1 -1
  148. package/dist/packages.d.cts +8 -8
  149. package/dist/packages.d.ts +8 -8
  150. package/dist/packages.js +1 -1
  151. package/dist/parser.cjs +1 -1
  152. package/dist/parser.d.cts +3 -3
  153. package/dist/parser.d.ts +3 -3
  154. package/dist/parser.js +1 -1
  155. package/dist/{pipeline-BYkKNpql.d.cts → pipeline-Bum6y1B9.d.cts} +1 -1
  156. package/dist/{pipeline-Cl7KW8CB.d.ts → pipeline-DOo3KHaq.d.ts} +1 -1
  157. package/dist/resolvers.cjs +1 -1
  158. package/dist/resolvers.d.cts +69 -3
  159. package/dist/resolvers.d.ts +69 -3
  160. package/dist/resolvers.js +1 -1
  161. package/dist/temporal.cjs +1 -1
  162. package/dist/temporal.js +1 -1
  163. package/dist/testing.cjs +2 -2
  164. package/dist/testing.cjs.map +1 -1
  165. package/dist/testing.d.cts +9 -9
  166. package/dist/testing.d.ts +9 -9
  167. package/dist/testing.js +1 -1
  168. package/dist/testing.js.map +1 -1
  169. package/dist/uom.cjs +1 -1
  170. package/dist/uom.d.cts +35 -2
  171. package/dist/uom.d.ts +35 -2
  172. package/dist/uom.js +1 -1
  173. package/dist/vm.cjs +1 -1
  174. package/dist/vm.d.cts +6 -6
  175. package/dist/vm.d.ts +6 -6
  176. package/dist/vm.js +1 -1
  177. package/dist/worker.cjs +2 -2
  178. package/dist/worker.cjs.map +1 -1
  179. package/dist/worker.d.cts +9 -9
  180. package/dist/worker.d.ts +9 -9
  181. package/dist/worker.js +1 -1
  182. package/dist/worker.js.map +1 -1
  183. package/package.json +1 -1
  184. package/dist/chunk-4DR5RBHQ.cjs +0 -2
  185. package/dist/chunk-4DR5RBHQ.cjs.map +0 -1
  186. package/dist/chunk-4IC5OARK.js +0 -3
  187. package/dist/chunk-4IC5OARK.js.map +0 -1
  188. package/dist/chunk-7ODHPWQC.js +0 -5
  189. package/dist/chunk-7ODHPWQC.js.map +0 -1
  190. package/dist/chunk-A755LVPT.cjs +0 -2
  191. package/dist/chunk-A755LVPT.cjs.map +0 -1
  192. package/dist/chunk-AF6NDOIE.js +0 -2
  193. package/dist/chunk-AF6NDOIE.js.map +0 -1
  194. package/dist/chunk-B2NL65FI.js +0 -2
  195. package/dist/chunk-B2NL65FI.js.map +0 -1
  196. package/dist/chunk-CB3EXUM2.js.map +0 -1
  197. package/dist/chunk-DUFEONVN.cjs +0 -3
  198. package/dist/chunk-DUFEONVN.cjs.map +0 -1
  199. package/dist/chunk-IJHL3LMH.js +0 -2
  200. package/dist/chunk-IJHL3LMH.js.map +0 -1
  201. package/dist/chunk-LCYQQFUH.cjs +0 -2
  202. package/dist/chunk-LCYQQFUH.cjs.map +0 -1
  203. package/dist/chunk-LP3JYC3A.js +0 -2
  204. package/dist/chunk-LP3JYC3A.js.map +0 -1
  205. package/dist/chunk-OE2DBN4K.js.map +0 -1
  206. package/dist/chunk-OKKGPINQ.cjs +0 -5
  207. package/dist/chunk-OKKGPINQ.cjs.map +0 -1
  208. package/dist/chunk-OM7NOHJF.cjs +0 -2
  209. package/dist/chunk-OM7NOHJF.cjs.map +0 -1
  210. package/dist/chunk-PTXUWGRR.js +0 -3
  211. package/dist/chunk-PTXUWGRR.js.map +0 -1
  212. package/dist/chunk-Q7TBBV62.cjs.map +0 -1
  213. package/dist/chunk-RELMEWY6.js.map +0 -1
  214. package/dist/chunk-SFM4XFGJ.js +0 -2
  215. package/dist/chunk-SFM4XFGJ.js.map +0 -1
  216. package/dist/chunk-SRAU3BLV.cjs +0 -3
  217. package/dist/chunk-SRAU3BLV.cjs.map +0 -1
  218. package/dist/chunk-SUAGBRQ7.cjs.map +0 -1
  219. package/dist/chunk-UNKZ5XRC.cjs +0 -2
  220. package/dist/chunk-UNKZ5XRC.cjs.map +0 -1
  221. package/dist/chunk-WU7SBKVU.cjs +0 -2
  222. package/dist/chunk-WU7SBKVU.cjs.map +0 -1
  223. package/dist/chunk-X5K72MBV.js +0 -2
  224. package/dist/chunk-X5K72MBV.js.map +0 -1
  225. package/dist/chunk-ZVPZQ66D.cjs +0 -2
  226. package/dist/chunk-ZVPZQ66D.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors/EngineError.ts","../src/errors/Result.ts","../src/errors/ErrorCode.ts"],"names":["ErrorCategory","_EngineError","category","init","recoverable","skipStack","errorCtor","previousLimit","chain","current","lines","EngineError","ErrorFactory","_ErrorFactory","defaultRecoverable","codeOrInit","message","context","normalizeUnknownError","error","ok","value","err","isOk","r","isErr","map","fn","mapErr","andThen","unwrapOr","fallback","match","arms","combine","results","values","throwIfErr","tryCatch","normalize","e","tryCatchAsync","CoreErrorCodes","DatetimeErrorCodes"],"mappings":"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","file":"chunk-SUAGBRQ7.cjs","sourcesContent":["/**\n * The engine's structured error type, the \"Rust/Go-style, verbose, easy to\n * tell the issue\" half of the error-handling redesign (the other half is\n * `Result.ts`).\n *\n * Historical note: an earlier version of this class (`UnifiedErrorFramework.ts`,\n * still the import path most of the codebase uses. See that file, now a\n * pure re-export barrel) had a much larger field set (`severity`,\n * `recovery`, a 5-value enum, `ErrorRecoveryManager`) that was almost\n * entirely dead: nothing downstream ever read `.severity`/`.recovery`,\n * only `.message` reliably survived to a caller. This version is smaller\n * and deliberately keeps only fields something actually consumes.\n */\n\nimport type { ErrorCode } from \"@solve-js/errors/ErrorCode\";\n\n/** A character-offset (and optional line/col) span into the original expression text, for a future \"underline the offending token\" UI, not yet wired to one. */\nexport interface SourceSpan {\n start: number;\n end: number;\n line?: number;\n col?: number;\n}\n\n/**\n * Error classification, kept from the original framework, now actually\n * consulted: it's the `format()` header and lets host code group errors\n * by pipeline stage without string-matching `.code`.\n */\nexport enum ErrorCategory {\n /** Errors during expression parsing. */\n PARSING = \"PARSING\",\n /** Errors during bytecode execution. */\n EXECUTION = \"EXECUTION\",\n /** Errors from input validation (safety limits, config). */\n VALIDATION = \"VALIDATION\",\n /** Errors from external services/APIs (currency rates, weather, stocks). */\n EXTERNAL = \"EXTERNAL\",\n /** Internal engine invariant violations. See `recoverable`'s doc comment. */\n INTERNAL = \"INTERNAL\",\n /** Configuration errors. */\n CONFIG = \"CONFIG\",\n}\n\n/** Fields accepted when constructing an {@link EngineError}. */\nexport interface EngineErrorInit {\n /** Catalog code. See `errors/ErrorCode.ts`. Not a free string: every code used by a BUILT-IN package should be registered there so `ErrorCodeCatalog.spec.ts` can catch collisions/typos. Third-party packages may still use any string here, `EngineError.code`'s runtime type is `string`. */\n code: ErrorCode | (string & {});\n /** Short, single-line, `Error.message`-compatible. Existing `.toThrow(/pattern/)`/`.message` assertions keep working against this field, richer detail goes in `expected`/`found`/`suggestion`, not crammed into this string. */\n message: string;\n /** What the parser/validator/VM expected to see, in plain words, e.g. \"a city name\", \"a 4-digit year\", \"end of expression\". */\n expected?: string;\n /** What was actually found instead, e.g. \"end of expression\", `NUMBER \"5\"`, the offending token's literal text. */\n found?: string;\n /** An actionable, worked-example fix, e.g. `e.g. \"weather in London\"`. Mirrors this codebase's best existing messages (`WEATHER_EXPECTED_CITY`, `AS_CONVERTER_EXPECTED_NAME`). */\n suggestion?: string;\n /**\n * Whether this engine instance is still usable. `true` for everything that\n * went wrong on ONE line, whether the line's fault (bad syntax, an unknown\n * variable, a safety limit exceeded), the environment's (an external API\n * down), or the engine's own (corrupted bytecode, a stack underflow from a\n * buggy plugin). `false` is for the far rarer case where there is no working\n * engine to go on with: a configuration or package-registration failure,\n * which is what `ErrorFactory.config()` is for and the only factory method\n * that still defaults to it.\n *\n * The category answers a different question, and the two used to be answered\n * as one. Category INTERNAL says whose fault this is, the engine's, worth\n * reporting as a bug. `recoverable` says whether the host may carry on, and\n * after an internal slip on one line it may:\n * `__tests__/hardening/RobustnessEngineLifecycle.spec.ts` alternates a\n * throwing line with a good one five hundred times and every answer stays\n * correct. Reporting that as `isFatal()` told a host the opposite, and a host\n * that honours the name would tear a document down over one bad line.\n *\n * This has never gated \"does evaluation of the rest of the document\n * continue\"; with this engine's per-line containment it always does, even for\n * a `recoverable: false` error (see `ARCHITECTURE.md`'s async-batcher/Tier-2\n * hardening notes). It gates what a host is TOLD. See\n * {@link EngineError.isFatal}.\n */\n recoverable?: boolean;\n /** Character-offset span into the source expression, when available. Not yet threaded through every call site, populate opportunistically, don't block on retrofitting every existing throw site. */\n span?: SourceSpan;\n /** Free-form structured context. The one field the pre-existing framework's real consumer (`ThreeTierEvaluator.ts`'s DAG-preservation-on-compile-error path) actually reads, kept name- and shape-compatible on purpose. */\n context?: Record<string, unknown>;\n /** The underlying error this one wraps, if any, passed straight through to native `Error.cause` (ES2022), so Node's default printer, most loggers, and `instanceof Error` tooling understand the chain for free. */\n cause?: unknown;\n}\n\n/**\n * The engine's structured error type. Still a real `Error` subclass (so\n * `throw`/`catch`/`instanceof Error` all keep working exactly as before),\n * but now every field except the removed `severity`/`recovery` pair is\n * something real code reads.\n */\nexport class EngineError extends Error {\n readonly category: ErrorCategory;\n readonly code: string;\n readonly expected?: string;\n readonly found?: string;\n readonly suggestion?: string;\n readonly recoverable: boolean;\n readonly span?: SourceSpan;\n readonly context?: Record<string, unknown>;\n readonly timestamp: Date;\n /**\n * Set explicitly (not via `super(message, {cause})`). This repo's\n * `tsconfig.json` targets ES6/ES5-ES7 lib, which predates TypeScript's\n * ES2022 `Error` constructor `cause`-option overload. `Error.prototype.cause`\n * is still a real runtime feature in every target this engine actually\n * runs in (Node 16.9+, all evergreen browsers, Electron/Obsidian's\n * bundled Chromium) regardless of the TS lib target used to type-check\n * against it, assigning it directly gets the same Node-printer/logger\n * interop with no build-config change needed.\n */\n readonly cause?: unknown;\n\n /**\n * Whether a recoverable error captures a JavaScript stack trace.\n *\n * Off, because a recoverable EngineError is a value rather than a fault. A\n * line of prose in a notepad is not an expression, so parsing it fails, and\n * that failure is the answer for that line rather than a bug to debug. The\n * engine builds one such error per non-expression line.\n *\n * Capturing a stack is not cheap, and its cost grows with how deep the stack\n * is when it happens. Measured through `parseDocument`, where the throw site\n * sits about a dozen frames down, each capture cost around 62 microseconds\n * and a 250-line document built 74 of them: a CPU profile put the\n * constructor at 46% of the whole pipeline, more than lexing, normalising,\n * parsing and executing put together.\n *\n * Turn it on to debug where a recoverable error is raised from. Errors that\n * are NOT recoverable always capture, since those are the genuine faults.\n *\n * @example\n * ```ts\n * EngineError.captureRecoverableStacks = true;\n * ```\n */\n static captureRecoverableStacks = false;\n\n constructor(category: ErrorCategory, init: EngineErrorInit) {\n // Before super(), which is legal as long as `this` is untouched. V8 reads\n // `Error.stackTraceLimit` while constructing the Error, so zeroing it\n // across the super() call is what actually skips the capture; there is no\n // per-instance switch for it.\n const recoverable = init.recoverable ?? true;\n const skipStack = recoverable && !EngineError.captureRecoverableStacks;\n // `stackTraceLimit` is a V8 extension, present in Node and every\n // Chromium-based browser but absent from the DOM lib, so it is reached\n // through a narrow local view rather than by widening the global type.\n // Where it does not exist, reading and writing it are both harmless and\n // the stack is captured as before.\n const errorCtor = Error as unknown as { stackTraceLimit?: number };\n const previousLimit = errorCtor.stackTraceLimit;\n if (skipStack) errorCtor.stackTraceLimit = 0;\n super(init.message);\n if (skipStack) errorCtor.stackTraceLimit = previousLimit;\n\n this.name = \"EngineError\";\n this.category = category;\n this.code = init.code;\n this.expected = init.expected;\n this.found = init.found;\n this.suggestion = init.suggestion;\n this.recoverable = recoverable;\n this.span = init.span;\n this.context = init.context;\n this.cause = init.cause;\n this.timestamp = new Date();\n // Only for the faults. super() has already captured a stack for those, and\n // this second call recaptures it purely to drop this constructor's own\n // frame; doing that for every error meant paying the whole cost twice.\n if (!skipStack && Error.captureStackTrace) {\n Error.captureStackTrace(this, EngineError);\n }\n }\n\n /** `!recoverable`. See `EngineErrorInit.recoverable`'s doc comment for what this actually gates (message framing/telemetry, not whether evaluation continues). */\n isFatal(): boolean {\n return !this.recoverable;\n }\n\n /** Walk `.cause` repeatedly, collecting the full chain (this error first). */\n causeChain(): unknown[] {\n const chain: unknown[] = [this];\n let current: unknown = this.cause;\n while (current !== undefined && current !== null) {\n chain.push(current);\n current = current instanceof Error ? (current as Error & { cause?: unknown }).cause : undefined;\n }\n return chain;\n }\n\n /**\n * Rust/Go-style multi-line renderer, the NEW thing a host/CLI/test\n * reaches for when it wants the full, verbose picture, as distinct from\n * `.message` (kept short and stable for existing assertions). Example:\n *\n * ```\n * error[WEATHER_EXPECTED_CITY]: Expected a city name after \"weather in\"\n * expected: a city name\n * found: end of expression\n * suggestion: e.g. \"weather in London\"\n * ```\n */\n format(): string {\n const lines = [`error[${this.code}]: ${this.message}`];\n if (this.expected) lines.push(` expected: ${this.expected}`);\n if (this.found) lines.push(` found: ${this.found}`);\n if (this.suggestion) lines.push(` suggestion: ${this.suggestion}`);\n return lines.join(\"\\n\");\n }\n\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n category: this.category,\n code: this.code,\n message: this.message,\n expected: this.expected,\n found: this.found,\n suggestion: this.suggestion,\n recoverable: this.recoverable,\n span: this.span,\n context: this.context,\n timestamp: this.timestamp.toISOString(),\n };\n }\n}\n\n/**\n * Factory for creating classified `EngineError`s. Every method accepts\n * EITHER the original, minimal 3-arg shape (`code, message, context?`\n * every existing call site across the codebase keeps compiling unchanged)\n * OR the richer `EngineErrorInit` object (for `expected`/`found`/\n * `suggestion`/`recoverable`/`span`/`cause`), upgrade a call site to the\n * richer form only when you're already touching it, no separate churn\n * pass required.\n */\nexport class ErrorFactory {\n private static build(\n category: ErrorCategory,\n defaultRecoverable: boolean,\n codeOrInit: string | EngineErrorInit,\n message?: string,\n context?: Record<string, unknown>,\n ): EngineError {\n const init: EngineErrorInit =\n typeof codeOrInit === \"string\"\n ? { code: codeOrInit, message: message!, context }\n : codeOrInit;\n return new EngineError(category, { recoverable: defaultRecoverable, ...init });\n }\n\n static validation(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static validation(init: EngineErrorInit): EngineError;\n static validation(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.VALIDATION, true, codeOrInit, message, context);\n }\n\n static parsing(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static parsing(init: EngineErrorInit): EngineError;\n static parsing(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.PARSING, true, codeOrInit, message, context);\n }\n\n static execution(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static execution(init: EngineErrorInit): EngineError;\n static execution(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXECUTION, true, codeOrInit, message, context);\n }\n\n static external(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static external(init: EngineErrorInit): EngineError;\n static external(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.EXTERNAL, true, codeOrInit, message, context);\n }\n\n /**\n * Reserve for genuine engine-internal invariant violations (corrupted\n * bytecode, a stack underflow from a buggy plugin, an \"impossible\" state),\n * not for user-input errors: the category is a bug report.\n *\n * Defaults `recoverable: true` all the same, because every one of these sites\n * is an invariant that failed on ONE line and none of them leaves the engine\n * unusable. This used to default to `false`, which conflated \"the engine's\n * fault\" with \"the engine is finished\" and told a host to tear a document\n * down over a line it could simply have shown an error against. A site that\n * has looked at its own case and concluded the instance really is gone can\n * still pass `recoverable: false` explicitly. See {@link\n * EngineErrorInit.recoverable}.\n */\n static internal(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static internal(init: EngineErrorInit): EngineError;\n static internal(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.INTERNAL, true, codeOrInit, message, context);\n }\n\n /** Defaults `recoverable: false`, and is now the only method that does: a configuration or package-registration failure is the one class that leaves no working engine to carry on with, rather than one bad line in a document. */\n static config(code: string, message: string, context?: Record<string, unknown>): EngineError;\n static config(init: EngineErrorInit): EngineError;\n static config(codeOrInit: string | EngineErrorInit, message?: string, context?: Record<string, unknown>): EngineError {\n return ErrorFactory.build(ErrorCategory.CONFIG, false, codeOrInit, message, context);\n }\n}\n\n/**\n * Normalize any thrown value into an `EngineError`, an `EngineError`\n * passes through as-is; a plain `Error` gets wrapped (message preserved,\n * original attached via `cause`); anything else becomes a generic\n * \"unknown error\" wrapping the stringified value. Used at every\n * throw-space/Result-space boundary (`Result.tryCatch`'s default\n * `normalize`, the VM's outer execution try/catch, `AsyncResolutionBatcher`'s\n * per-line containment) so a raw `TypeError` from a genuine engine bug\n * still surfaces as a structured, catalogued error instead of an opaque\n * uncaught exception.\n *\n * Both branches state RECOVERABLE explicitly, while keeping the INTERNAL\n * category. The two fields answer different questions and were previously\n * answering the same one:\n *\n * category INTERNAL whose fault is this? The engine's. Worth reporting.\n * recoverable is this engine instance still usable? Yes.\n *\n * Everything reaching here is by definition something the engine did not\n * anticipate on ONE line, and per-line containment means the next line\n * evaluates normally, which `__tests__/hardening/RobustnessEngineLifecycle`\n * demonstrates over hundreds of alternating failure/success pairs. Reporting\n * that as `isFatal()` told a host the opposite, and a host that honours the\n * name would tear a document down over a single bad line. The \"this is an\n * engine bug rather than your syntax\" signal a caller wants for telemetry is\n * the CATEGORY, which is unchanged.\n *\n * The flag is written out here rather than inherited from\n * `ErrorFactory.internal()`, which now defaults the same way, so that this\n * function's contract survives a future change to that default.\n */\nexport function normalizeUnknownError(error: unknown): EngineError {\n if (error instanceof EngineError) return error;\n if (error instanceof Error) {\n return ErrorFactory.internal({\n code: \"UNEXPECTED_ERROR\",\n message: error.message,\n context: { originalErrorName: error.name },\n cause: error,\n recoverable: true,\n });\n }\n return ErrorFactory.internal({\n code: \"UNKNOWN_ERROR\",\n message: \"An unknown error occurred\",\n context: { error: String(error) },\n recoverable: true,\n });\n}\n","import { type EngineError, normalizeUnknownError } from \"@solve-js/errors/EngineError\";\n\n/**\n * A Rust-style `Result<T, E>`, the value half of this engine's error-handling\n * redesign. `E` defaults to `EngineError` (this engine's structured error\n * type) but every combinator here is generic over `E`, so `Result` works\n * equally well for a domain that isn't `EngineError`-shaped.\n *\n * This exact shape used to live in `errors/UnifiedErrorFramework.ts` (kept\n * there as a barrel re-export for backward compatibility), moved here as\n * its own module because it's genuinely generic (no dependency on\n * `EngineError` beyond the default type parameter) and because the engine\n * is migrating callers to it incrementally: parsing/VM/package code that\n * expects \"a failure is a possibility, not an exception\" returns\n * `Result<T, EngineError>` instead of throwing; two explicit adapters\n * {@link throwIfErr} and {@link tryCatch}, are the sanctioned way to cross\n * the boundary between Result-based code and still-throw-based code during\n * the migration (and permanently, at the public API boundary. See\n * `ExpressionEngine.evaluateExpression()`'s documented throw contract).\n */\nexport type Result<T, E = EngineError> =\n | { ok: true; value: T }\n | { ok: false; error: E };\n\n/** Wrap a successful value. */\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/** Wrap a failure. */\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/**\n * Narrow a {@link Result} to its success arm.\n *\n * @param r - The result to test.\n * @returns True when it succeeded, narrowing `r` so `r.value` is reachable.\n */\nexport function isOk<T, E>(r: Result<T, E>): r is { ok: true; value: T } {\n return r.ok;\n}\n\n/**\n * Narrow a {@link Result} to its failure arm.\n *\n * @param r - The result to test.\n * @returns True when it failed, narrowing `r` so `r.error` is reachable.\n */\nexport function isErr<T, E>(r: Result<T, E>): r is { ok: false; error: E } {\n return !r.ok;\n}\n\n/** Transform the success value; a failure passes through untouched. */\nexport function map<T, U, E>(r: Result<T, E>, fn: (value: T) => U): Result<U, E> {\n return r.ok ? ok(fn(r.value)) : r;\n}\n\n/** Transform the error; a success passes through untouched. */\nexport function mapErr<T, E, F>(r: Result<T, E>, fn: (error: E) => F): Result<T, F> {\n return r.ok ? r : err(fn(r.error));\n}\n\n/** Chain a Result-returning operation onto a success (a.k.a. flatMap/bind). */\nexport function andThen<T, U, E>(r: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E> {\n return r.ok ? fn(r.value) : r;\n}\n\n/** Unwrap a success, or return `fallback` for a failure. Never throws. */\nexport function unwrapOr<T, E>(r: Result<T, E>, fallback: T): T {\n return r.ok ? r.value : fallback;\n}\n\n/** Exhaustive pattern-match, the `match`/`switch` a Rust enum gets for free. */\nexport function match<T, E, R>(r: Result<T, E>, arms: { ok: (value: T) => R; err: (error: E) => R }): R {\n return r.ok ? arms.ok(r.value) : arms.err(r.error);\n}\n\n/**\n * Combine several Results into one, succeeds with a tuple of all values\n * iff every input succeeded; otherwise fails with the FIRST error\n * encountered (left-to-right), matching this codebase's existing\n * fail-fast convention elsewhere (e.g. `BytecodeBuilder`'s constant-pool\n * limit checks).\n */\nexport function combine<T extends readonly unknown[], E>(\n results: { [K in keyof T]: Result<T[K], E> },\n): Result<T, E> {\n const values: unknown[] = [];\n for (const r of results as readonly Result<unknown, E>[]) {\n if (!r.ok) return r;\n values.push(r.value);\n }\n return ok(values as unknown as T);\n}\n\n/**\n * Cross from Result-space back to throw-space, the sanctioned boundary\n * adapter for callers (public API surface, older not-yet-migrated code,\n * tests) that still want exception-based control flow. Throws `r.error`\n * as-is (an `EngineError` is already a real `Error` subclass, so this\n * needs no wrapping).\n */\nexport function throwIfErr<T, E>(r: Result<T, E>): T {\n if (r.ok) return r.value;\n throw r.error;\n}\n\n/**\n * Cross from throw-space into Result-space, runs `fn`, converting any\n * thrown value into a Result via `normalize` (defaults to\n * {@link normalizeUnknownError}). The inverse of {@link throwIfErr}; the\n * pairing that lets Result-based and throw-based code interoperate during\n * an incremental migration instead of requiring a single flag-day rewrite.\n */\nexport function tryCatch<T>(\n fn: () => T,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Result<T, EngineError> {\n try {\n return ok(fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n\n/** Async sibling of {@link tryCatch}. */\nexport async function tryCatchAsync<T>(\n fn: () => Promise<T>,\n normalize: (e: unknown) => EngineError = normalizeUnknownError,\n): Promise<Result<T, EngineError>> {\n try {\n return ok(await fn());\n } catch (e) {\n return err(normalize(e));\n }\n}\n","/**\n * The built-in error-code catalog, one typed const object per domain\n * unioned together here for autocomplete/exhaustiveness in core engine\n * code. Deliberately NOT one central enum: `IEnginePackage` is documented\n * public SDK surface for third-party packages (see `api/PackageRegistry.ts`),\n * and a closed enum would block an external package author from defining\n * their own codes without editing this file. `EngineError.code`'s runtime\n * type stays `string` for exactly that reason. This catalog is for the\n * codes THIS repo owns and wants collision/typo checking on (see\n * `__tests__/errors/ErrorCodeCatalog.spec.ts`), not a hard runtime\n * whitelist.\n *\n * As each package migrates to `Result<void, EngineError>` (see this\n * session's error-handling-refactor plan, Phase 5), it should export its\n * own small `XxxErrorCodes` const object co-located with its parselets\n * exactly like `CoreErrorCodes` below, just scoped to one domain, and get\n * unioned into `ErrorCode` here. Until a package migrates, its existing\n * free-string codes keep working (ErrorFactory accepts any string); they\n * just aren't caught by the catalog's uniqueness/orphan checks yet.\n */\n\n/**\n * Codes used directly by the parser/VM/engine/errors layers themselves\n * confirmed against the current source, not aspirational. Grouped by\n * pipeline stage via the comments, not a naming prefix (these predate any\n * naming convention and renaming them is out of scope for introducing the\n * catalog, only NEW codes need to follow a scoped/prefixed style, see\n * `STACK_UNDERFLOW` etc. below).\n */\nexport const CoreErrorCodes = {\n // ── Parser (parser/PrecedenceParser.ts, parser/BytecodeBuilder.ts, parser/PhrasePattern.ts) ──\n INVALID_NUMBER_LITERAL: \"INVALID_NUMBER_LITERAL\",\n /** A `\"` that never meets its closing partner (`lexer/ExpressionLexer.ts`'s `tokenizeString()`). Previously the tokenizer ran off the end of the input and returned what it had, so `\"abc` lexed to an ordinary String and an unterminated literal was indistinguishable from a terminated one. */\n UNTERMINATED_STRING: \"UNTERMINATED_STRING\",\n NO_PREFIX_PARSELET: \"NO_PREFIX_PARSELET\",\n UNEXPECTED_END_OF_INPUT: \"UNEXPECTED_END_OF_INPUT\",\n UNEXPECTED_TOKEN_TYPE: \"UNEXPECTED_TOKEN_TYPE\",\n NESTING_DEPTH_EXCEEDED: \"NESTING_DEPTH_EXCEEDED\",\n UNEXPECTED_END: \"UNEXPECTED_END\",\n UNEXPECTED_TRAILING_TOKEN: \"UNEXPECTED_TRAILING_TOKEN\",\n PARSE_ERROR: \"PARSE_ERROR\",\n TOO_MANY_NUMERIC_CONSTANTS: \"TOO_MANY_NUMERIC_CONSTANTS\",\n /** A raw bytecode operand outside 0 to 255, or a jump patch outside the emitted stream (`parser/BytecodeBuilder.ts`'s `emitIndex`, `emitByte`, `patchJump`). `build()` keeps one byte per operand, so 300 used to become 44 with no error and the program read the wrong constant or plugin function. A package-authoring fault, reported at compile time. */\n BYTECODE_OPERAND_OUT_OF_RANGE: \"BYTECODE_OPERAND_OUT_OF_RANGE\",\n TOO_MANY_STRING_CONSTANTS: \"TOO_MANY_STRING_CONSTANTS\",\n NO_MATCHING_PHRASE_ALTERNATIVE: \"NO_MATCHING_PHRASE_ALTERNATIVE\",\n INVALID_PHRASE_PATTERN: \"INVALID_PHRASE_PATTERN\",\n PHRASE_KEYWORD_MISMATCH: \"PHRASE_KEYWORD_MISMATCH\",\n /** User-defined-function definition parsing (`f(x, y) = ...`), an invalid token where a parameter name was expected. */\n USER_FUNCTION_INVALID_PARAM_NAME: \"USER_FUNCTION_INVALID_PARAM_NAME\",\n /** `f() = ...` with zero parameters, indistinguishable from a plain no-arg function call, so rejected at definition time. */\n USER_FUNCTION_NO_PARAMS: \"USER_FUNCTION_NO_PARAMS\",\n /** A user-defined function body calling an async plugin (weather/stocks/currency/...), rejected at definition time; v1 scope excludes async function bodies. */\n FUNCTION_BODY_MUST_BE_SYNCHRONOUS: \"FUNCTION_BODY_MUST_BE_SYNCHRONOUS\",\n /** `BytecodeBuilder`'s `userFunctionBodies` side-table exceeding its capacity. Same class as `TOO_MANY_NUMERIC_CONSTANTS`/`TOO_MANY_STRING_CONSTANTS` below. */\n TOO_MANY_FUNCTION_DEFINITIONS: \"TOO_MANY_FUNCTION_DEFINITIONS\",\n /** `BytecodeBuilder`'s `anonymousBodies` side-table (map/reduce inline transform bodies) exceeding its capacity. Same class as `TOO_MANY_FUNCTION_DEFINITIONS` above. */\n TOO_MANY_ANONYMOUS_BODIES: \"TOO_MANY_ANONYMOUS_BODIES\",\n /** New with the 2.0 descriptor redesign: a parselet emits a plugin call by NAME (`BytecodeBuilder.emitPluginCall(name, argCount)`) and the engine resolves that name to the index it assigned at registration. This fires when the name is absent from the builder's name->index map: the package used a `pluginFunctions` name it never declared, or the expression was parsed before that package registered. Not a user-input error; a package-authoring/registration fault. See `parser/BytecodeBuilder.ts`'s `emitPluginCall()`. */\n UNKNOWN_PLUGIN_FUNCTION: \"UNKNOWN_PLUGIN_FUNCTION\",\n\n // ── VM (vm/VM.ts, vm/OpRegistry.ts, vm/VMBuiltins.ts) ──\n EVALUATION_ERROR: \"EVALUATION_ERROR\",\n INSTRUCTION_LIMIT_EXCEEDED: \"INSTRUCTION_LIMIT_EXCEEDED\",\n STACK_LIMIT_EXCEEDED: \"STACK_LIMIT_EXCEEDED\",\n /** One evaluation asking for more elements (collection Values, matrix cells) than `vm.maxAllocatedElements` allows. The counter the two limits above cannot be: both are checked between opcodes, so neither can see what a single opcode allocates inside a loop of its own. See `vm/AllocationBudget.ts`. Recoverable, since it describes this expression rather than the engine. */\n ALLOCATION_LIMIT_EXCEEDED: \"ALLOCATION_LIMIT_EXCEEDED\",\n /** New this phase. See `VM.ts`'s `safePop()`: a stack-underflow (corrupted bytecode, a buggy plugin) is now a controlled EngineError instead of a raw TypeError. Category INTERNAL, since it is an engine or plugin fault rather than a typed line, but recoverable: it happened on one line and the engine is still usable. */\n STACK_UNDERFLOW: \"STACK_UNDERFLOW\",\n UNDEFINED_VARIABLE: \"UNDEFINED_VARIABLE\",\n /** New this phase, the Tier-2/`LOAD_GLOBAL_VAR` hardening: a global variable read before its async preflight resolved, surfaced as a controlled error instead of pushing `undefined`. */\n GLOBAL_VARIABLE_NOT_RESOLVED: \"GLOBAL_VARIABLE_NOT_RESOLVED\",\n UNKNOWN_FUNCTION: \"UNKNOWN_FUNCTION\",\n /** `unwrapEvalResult()`'s pending-when-expecting-value case, a caller-contract violation, not user-input. */\n UNEXPECTED_PENDING_RESULT: \"UNEXPECTED_PENDING_RESULT\",\n /** User-defined-function call/definition errors (`CALL_USER_FUNCTION`/`DEFINE_USER_FUNCTION` opcodes), calling a name with no matching definition, calling with the wrong argument count, and the deliberate v1 restriction that a function body can't itself contain async work. */\n UNDEFINED_FUNCTION: \"UNDEFINED_FUNCTION\",\n FUNCTION_ARITY_MISMATCH: \"FUNCTION_ARITY_MISMATCH\",\n /** The same mistake against a BUILT-IN rather than a user-defined function (`sqrt()`, `atan2(1)`, `sqrt(1,2,3)`). Separate from `FUNCTION_ARITY_MISMATCH` above because the two are raised by different opcodes and a host may want to word them differently. Checked at the `CALL_BUILTIN` dispatch against `vm/VMBuiltinArity.ts`; recoverable, since it is a typo in the line, not an engine fault. */\n BUILTIN_ARITY_MISMATCH: \"BUILTIN_ARITY_MISMATCH\",\n USER_FUNCTION_ASYNC_UNSUPPORTED: \"USER_FUNCTION_ASYNC_UNSUPPORTED\",\n /** A map/reduce transform body (inline expression or user-defined function) calling an async plugin. Same v1 scope restriction as `USER_FUNCTION_ASYNC_UNSUPPORTED` above, enforced both at parse time (`MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS`, packages/mapreduce/) and as a defense-in-depth runtime backstop here. */\n MAP_REDUCE_ASYNC_UNSUPPORTED: \"MAP_REDUCE_ASYNC_UNSUPPORTED\",\n /** An algebra verb's expression argument (`BIND_UNKNOWN`'s body) calling an async plugin. Same v1 scope restriction as the two above, and likewise refused at parse time first (`SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS`, packages/symbolic/). */\n SYMBOLIC_ASYNC_UNSUPPORTED: \"SYMBOLIC_ASYNC_UNSUPPORTED\",\n /** `explainLine()` asked to derive a line that resolves data asynchronously (a live-data or async-plugin line). A derivation is a sequence of settled intermediate values, which a pending result has none of, so the line is refused rather than explained with a hole in it. */\n EXPLAIN_ASYNC_UNSUPPORTED: \"EXPLAIN_ASYNC_UNSUPPORTED\",\n /** `pushCallFrame()`'s recursion guard, a nested `CALL_USER_FUNCTION` re-enters `executeBytecode()`, so `maxInstructions` alone can't catch e.g. `f(x) = f(x)`; this is the dedicated backstop. `recoverable: true` (the default for `.execution()`), ordinary user-written infinite recursion, not an engine bug; the guard exists precisely so it surfaces as a clear error instead of overflowing the native call stack uncatchably. */\n FUNCTION_RECURSION_LIMIT_EXCEEDED: \"FUNCTION_RECURSION_LIMIT_EXCEEDED\",\n /** The companion to the code above, and the half it could never see: how MANY user-defined-function calls one evaluation makes, rather than how deeply they nest. A twenty-two-line doubling chain nests twenty-two deep (legal) and makes two million calls (a fatal heap abort). Counted in `vm/AllocationBudget.ts`, because the tally has to survive `executeBytecode()` re-entering itself. Recoverable. */\n FUNCTION_CALL_LIMIT_EXCEEDED: \"FUNCTION_CALL_LIMIT_EXCEEDED\",\n /** A `<date> + N workdays` offset outside `date.maxOffsetYears`/`minOffsetYears`. Workdays are the one date offset that walks the calendar a day at a time, so the one whose cost is the offset; every other one moves a Date field once. Recoverable. */\n DATE_OFFSET_LIMIT_EXCEEDED: \"DATE_OFFSET_LIMIT_EXCEEDED\",\n /** The anchor of `N working days after/before/from <expr>` was not a date (e.g. `5 working days after 3`). The grammar guarantees the count is a number, so this only fires on the anchor. Emitted as a recoverable Error value, not thrown, matching the datetime package's other type guards. See `vm/VM.ts`'s `DATE_WORKDAY_OFFSET` case. */\n WORKDAY_OFFSET_EXPECTED_DATE: \"WORKDAY_OFFSET_EXPECTED_DATE\",\n /** An endpoint of `working days between <expr> and <expr>` was not a date. Recoverable Error value. See `vm/VM.ts`'s `DATE_WORKDAYS_BETWEEN` case. */\n WORKDAYS_BETWEEN_EXPECTED_DATES: \"WORKDAYS_BETWEEN_EXPECTED_DATES\",\n /** The two endpoints of `working days between <expr> and <expr>` are further apart than `date.maxOffsetYears`/`minOffsetYears` allow the count's calendar walk to run. Recoverable Error value, the between-count's equivalent of `DATE_OFFSET_LIMIT_EXCEEDED`. See `vm/VM.ts`'s `DATE_WORKDAYS_BETWEEN` case. */\n WORKDAYS_BETWEEN_RANGE_TOO_LARGE: \"WORKDAYS_BETWEEN_RANGE_TOO_LARGE\",\n /** A `<<`/`>>` with a bigint operand whose exact result would pass `MAX_EXACT_SHIFT_BITS`, whichever operand is the bigint. Both spellings refuse as of 1.0.0: a bigint on the left used to fall through to `x * 2^n` in doubles and report a 19,870-digit integer as Infinity. See `vm/VM.ts`'s `bigIntShift()`. Recoverable. */\n BIGINT_SHIFT_LIMIT_EXCEEDED: \"BIGINT_SHIFT_LIMIT_EXCEEDED\",\n /** The same ceiling for `^`, the operator it was written for: `2n ^ 100000` asks for the same 100,001-bit integer `1n << 100000` does, so the two spellings answer the same way. Also new in 1.0.0, and for the same reason: this used to fall through to the double path and answer Infinity. A fractional or negative exponent (`4n ^ 0.5`, `2n ^ -1`) has no exact answer to bound and still uses the double path. See `vm/VM.ts`'s `MAX_EXACT_POW_BITS`. Recoverable. */\n BIGINT_POW_LIMIT_EXCEEDED: \"BIGINT_POW_LIMIT_EXCEEDED\",\n /** An operand with no whole-number form (a fraction, an infinity, a NaN) meeting a bigint: `1n + 0.5`, `1n & 1.5`, `5n/pi`. `BigInt()` answers those with a raw RangeError, which the VM relabelled UNEXPECTED_ERROR, so a typo in the line was reported as an engine fault. Recoverable; see `vm/VMConversion.ts`'s `toBigIntOperand()`. */\n BIGINT_INEXACT_OPERAND: \"BIGINT_INEXACT_OPERAND\",\n /** `10n / 0n` and `10n mod 0n`. Deliberately NOT what `1 / 0` does, which is Infinity: a bigint division is exact integer division (`7n / 2n` is 3n), and integer division by zero has no answer, exactly as it has none in C, Java, Python or JavaScript's own BigInt. Previously V8's own RangeError, relabelled UNEXPECTED_ERROR. Recoverable; see `vm/VMConversion.ts`'s `bigIntDivisionByZero()`. */\n BIGINT_DIVISION_BY_ZERO: \"BIGINT_DIVISION_BY_ZERO\",\n /** `DEFINE_USER_FUNCTION`'s body-index lookup failing, a compiler/VM invariant violation (the opcode stream referenced a `userFunctionBodies` slot that doesn't exist), never a user-input error. */\n INTERNAL_MISSING_FUNCTION_BODY: \"INTERNAL_MISSING_FUNCTION_BODY\",\n /** `MAP_INVOKE`/`REDUCE_INVOKE`'s anonymous-body-index lookup failing. Same class as `INTERNAL_MISSING_FUNCTION_BODY` above, for the `anonymousBodies` side-table instead of `userFunctionBodies`. */\n INTERNAL_MISSING_ANONYMOUS_BODY: \"INTERNAL_MISSING_ANONYMOUS_BODY\",\n /** `CALL_BUILTIN` naming an index no builtin is registered at. It used to pop its arguments and push nothing, so the opcode after it read a neighbour's operand as its own; now an Error value on the stack, the shape `map`/`reduce` already used for the same fault. Bytecode-level, so unreachable from source without a compiler or snapshot fault. */\n UNKNOWN_BUILTIN_FUNCTION: \"UNKNOWN_BUILTIN_FUNCTION\",\n\n // ── Malformed bytecode on the public `./vm` surface (vm/VM.ts) ──\n //\n // `executeBytecode` is exported, so a bytecode program is caller input in\n // the same sense an expression string is, and these five say so. They are\n // VALIDATION rather than INTERNAL for exactly that reason: before they\n // existed, every one of these cases reached a raw TypeError (`BigInt(undefined)`,\n // `code.toUpperCase()` on a boolean, destructuring a program that was not\n // there), which normalised to UNEXPECTED_ERROR and told the caller the\n // engine was broken when their eleven bytes were. Reachable from ordinary\n // source only through a compiler bug, which is why the messages name the\n // opcode and the operand rather than the user's line.\n /** An operand byte read past the end of the stream: the program ends in the middle of an instruction. */\n MALFORMED_BYTECODE_TRUNCATED: \"MALFORMED_BYTECODE_TRUNCATED\",\n /** A constant-pool operand indexing a `numbers`/`strings` entry that does not exist, or that is not of the pool's type. */\n MALFORMED_BYTECODE_CONSTANT_INDEX: \"MALFORMED_BYTECODE_CONSTANT_INDEX\",\n /** A unit or converter name read off the value stack that is not a string. Distinct from the pool case above: the operand is a Value another opcode pushed, not a pool entry. */\n MALFORMED_BYTECODE_OPERAND_TYPE: \"MALFORMED_BYTECODE_OPERAND_TYPE\",\n /** `MAP_INVOKE`/`REDUCE_INVOKE` carrying a body kind other than 0/1/2. Used to fall through every arm with no body and recurse into `executeBytecode(undefined)`. */\n MALFORMED_BYTECODE_BODY_KIND: \"MALFORMED_BYTECODE_BODY_KIND\",\n /** A `PUSH_BIGINT` pool entry that is not a whole number, e.g. `\"1.000\"`. `BigInt()` answers that with a raw SyntaxError. */\n MALFORMED_BYTECODE_BIGINT_LITERAL: \"MALFORMED_BYTECODE_BIGINT_LITERAL\",\n /** `executeBytecode()` called with something that is not a runnable program at all. Checked before the destructure that used to throw outside the function's own try/catch. */\n MALFORMED_BYTECODE_PROGRAM: \"MALFORMED_BYTECODE_PROGRAM\",\n\n // ── Symbolic algebra (symbolic/, vm/SymbolicOps.ts) ──\n /** A coefficient grew past `RATIONAL_MAX_BITS`, e.g. repeated exact elimination multiplying denominators together. */\n SYMBOLIC_RATIONAL_OVERFLOW: \"SYMBOLIC_RATIONAL_OVERFLOW\",\n /** `NaN` or `±Infinity` reaching a symbolic expression, neither of which has an exact rational value. */\n SYMBOLIC_NONFINITE_OPERAND: \"SYMBOLIC_NONFINITE_OPERAND\",\n /** Division by an exactly-zero rational. Exact, unlike the double comparison it replaced, which could not distinguish a true zero from `5.551e-17`. */\n SYMBOLIC_DIVISION_BY_ZERO: \"SYMBOLIC_DIVISION_BY_ZERO\",\n /** A tree exceeding `SYMBOLIC_MAX_NODES` entering the simplifier. */\n SYMBOLIC_NODE_LIMIT_EXCEEDED: \"SYMBOLIC_NODE_LIMIT_EXCEEDED\",\n /** A builtin with no symbolic reading (`min`, `random`, the finance block, ...) applied to an expression still containing an unknown. Returned rather than computing against `toNumber()`'s placeholder zero. */\n SYMBOLIC_UNSUPPORTED_FUNCTION: \"SYMBOLIC_UNSUPPORTED_FUNCTION\",\n /** The rational-root search exceeding `FACTOR_MAX_ROOT_CANDIDATES`. The candidate set is the product of two divisor sets, so a highly-composite coefficient escapes quickly. */\n SYMBOLIC_FACTOR_LIMIT_EXCEEDED: \"SYMBOLIC_FACTOR_LIMIT_EXCEEDED\",\n /** An equation outside what the solver attempts: not a polynomial, above the degree ceiling, or non-linear in the unknown while another unknown is present. */\n SYMBOLIC_SOLVE_UNSUPPORTED: \"SYMBOLIC_SOLVE_UNSUPPORTED\",\n /** Some but not all of an equation's roots were found. Reported rather than returned, because a partial list of roots looks exactly like a complete one. */\n SYMBOLIC_SOLVE_INCOMPLETE: \"SYMBOLIC_SOLVE_INCOMPLETE\",\n /** `solve`'s second argument not being a bare name. */\n SOLVE_REQUIRES_VARIABLE_NAME: \"SOLVE_REQUIRES_VARIABLE_NAME\",\n /** A derivative order outside 0..`DERIVATIVE_MAX_ORDER`. */\n SYMBOLIC_DERIVATIVE_ORDER_LIMIT: \"SYMBOLIC_DERIVATIVE_ORDER_LIMIT\",\n /** An expression with no known elementary antiderivative. Reported rather than approximated, since a wrong integral is indistinguishable from a right one at the point of use. */\n SYMBOLIC_INTEGRAL_UNSUPPORTED: \"SYMBOLIC_INTEGRAL_UNSUPPORTED\",\n /** A Taylor degree outside 0..`TAYLOR_MAX_DEGREE`. */\n SYMBOLIC_TAYLOR_DEGREE_LIMIT: \"SYMBOLIC_TAYLOR_DEGREE_LIMIT\",\n /** A Taylor coefficient that does not reduce to an exact number at the expansion point. */\n SYMBOLIC_TAYLOR_INEXACT: \"SYMBOLIC_TAYLOR_INEXACT\",\n /** An algebra verb's variable-name argument not being a bare name. */\n SYMBOLIC_REQUIRES_VARIABLE_NAME: \"SYMBOLIC_REQUIRES_VARIABLE_NAME\",\n /** `jacobian` called with expressions containing no unknown to differentiate against. */\n SYMBOLIC_JACOBIAN_NO_VARIABLES: \"SYMBOLIC_JACOBIAN_NO_VARIABLES\",\n /** A finite number whose decimal form could not be read back, which the regex covering every `Number.prototype.toString` output should make unreachable. */\n INTERNAL_RATIONAL_PARSE: \"INTERNAL_RATIONAL_PARSE\",\n\n // ── Engine (engine/ExpressionEngine.ts, engine/ExpressionEngineSafety.ts, engine/AsyncResolutionBatcher.ts) ──\n EXPRESSION_TOO_LONG: \"EXPRESSION_TOO_LONG\",\n EXPRESSION_TOO_COMPLEX: \"EXPRESSION_TOO_COMPLEX\",\n /** A document with more lines than `performance.maxDocumentLines`. The per-line limits above bound what one line may ask for and say nothing about how many lines there are; two hundred thousand of `1 + 1` exhausted the heap on the line records alone. Recoverable. */\n DOCUMENT_TOO_LARGE: \"DOCUMENT_TOO_LARGE\",\n NORMALIZED_TOKEN_LIMIT_EXCEEDED: \"NORMALIZED_TOKEN_LIMIT_EXCEEDED\",\n /** `\"=>\"` with nothing before it, needs an expression or variable name to solve/simplify. */\n THEREFORE_REQUIRES_EXPRESSION: \"THEREFORE_REQUIRES_EXPRESSION\",\n /** A `\"=>\"`-triggered expression called an async plugin (weather/stocks/currency). Same v1 scope restriction as user-function/map-reduce bodies. */\n THEREFORE_ASYNC_UNSUPPORTED: \"THEREFORE_ASYNC_UNSUPPORTED\",\n /** A compound assignment (`name += expr` / `name -= expr`) with nothing on the right, a line half-typed on the way to `total += 5`. */\n COMPOUND_ASSIGN_REQUIRES_EXPRESSION: \"COMPOUND_ASSIGN_REQUIRES_EXPRESSION\",\n /** A running total (`+= / -=`) whose right-hand side calls an async plugin (weather/stocks/currency). The same v1 scope restriction as the `\"=>\"` and user-function bodies. */\n COMPOUND_ASSIGN_ASYNC_UNSUPPORTED: \"COMPOUND_ASSIGN_ASYNC_UNSUPPORTED\",\n /** A savings-goal contribution period that is not one of daily/weekly/monthly/yearly (`how long to save $X at $Y <period>`). Names the accepted set. */\n UNKNOWN_SAVINGS_PERIOD: \"UNKNOWN_SAVINGS_PERIOD\",\n /** Colon-separated numbers that are not a time any clock can show (\"24:00\", \"9:60\", \"100:5\"). Raised by the labeled-line fallback, which used to answer them with whatever stood after the colon. */\n INVALID_TIME_LITERAL: \"INVALID_TIME_LITERAL\",\n /** A live-data form evaluated on an engine whose host switched the network off (`network.enabled: false`, see `constants/Configuration.ts`'s `NetworkConfig`). A recoverable Error value, raised by the VM for a currency conversion with no primed rate and for a plugin function that returned a promise, and by `createQueryResolver`'s plugin function when its preflight was skipped. Names the setting, so the reader knows it is policy rather than an outage. */\n NETWORK_DISABLED: \"NETWORK_DISABLED\",\n\n // ── Temporal calendar backend (temporal/TemporalCalendar.ts) ──\n /** `createTemporalCalendar()` was handed something that is not a usable `Temporal` implementation: no `Now.instant`, `Now.timeZoneId`, `Instant.fromEpochMilliseconds` or `PlainDateTime.from`. Raised at construction, naming the missing member, rather than letting the first date computation fail on it obscurely. */\n TEMPORAL_IMPLEMENTATION_INVALID: \"TEMPORAL_IMPLEMENTATION_INVALID\",\n /** The `timeZone` given to `createTemporalCalendar()` is not one the `Temporal` implementation knows. Raised at construction, so a misspelt zone is a configuration error the host sees once, not a `RangeError` from inside every date the engine computes. */\n TEMPORAL_TIME_ZONE_UNKNOWN: \"TEMPORAL_TIME_ZONE_UNKNOWN\",\n\n // ── Snapshot / restore (engine/EngineSnapshot.ts, engine/ExpressionEngine.ts) ──\n /** `fromJSON()` handed an object that is not a snapshot at all, or whose serialised-shape version does not match this engine's reader. The versioning gate that refuses an incompatible snapshot clearly rather than restoring it wrongly. See `engine/EngineSnapshot.ts`'s `assertRestorable()`. */\n SNAPSHOT_VERSION_MISMATCH: \"SNAPSHOT_VERSION_MISMATCH\",\n /** A snapshot with the right envelope but internally inconsistent contents (an unrecognised number sentinel, an unknown value tag). Distinct from a version mismatch: the format is right, the payload is not. */\n SNAPSHOT_MALFORMED: \"SNAPSHOT_MALFORMED\",\n /** A value the v1 snapshot format cannot yet represent (a symbolic/algebra value, a symbolic matrix cell). Deferred to a follow-up; refused by name rather than dropped silently. */\n SNAPSHOT_UNSUPPORTED_VALUE: \"SNAPSHOT_UNSUPPORTED_VALUE\",\n\n // ── Config (constants/Configuration.ts) ──\n CONFIG_PATH_NOT_FOUND: \"CONFIG_PATH_NOT_FOUND\",\n INVALID_CONFIG_PATH: \"INVALID_CONFIG_PATH\",\n CONFIG_SECTION_NOT_FOUND: \"CONFIG_SECTION_NOT_FOUND\",\n CONFIG_PROPERTY_NOT_FOUND: \"CONFIG_PROPERTY_NOT_FOUND\",\n\n // ── Package/lexer registration-time collisions (lexer/ExpressionLexer.ts) ──\n /** `calendar: \"temporal\"` was asked for on a runtime with no `Temporal`. Refused rather than silently computing on `Date`, because a host that named Temporal did so to be sure what it was computing on. Recoverable. */\n CALENDAR_TEMPORAL_UNAVAILABLE: \"CALENDAR_TEMPORAL_UNAVAILABLE\",\n /** A trip form (`cost to drive ...`) was written without the `at` that separates its parts. Recoverable. */\n TRIP_EXPECTED_AT: \"TRIP_EXPECTED_AT\",\n /** A width and a height were written with nothing asked of the pair (`1920x1080` on its own). Recoverable. */\n DIMENSIONS_EXPECTED_FORM: \"DIMENSIONS_EXPECTED_FORM\",\n /** A `resize` was written without one of its parts: the dimensions, the `to`, the size, or the side it names. Recoverable. */\n RESIZE_EXPECTED_SHAPE: \"RESIZE_EXPECTED_SHAPE\",\n PLUGIN_OPERATOR_COLLISION: \"PLUGIN_OPERATOR_COLLISION\",\n PLUGIN_KEYWORD_COLLISION: \"PLUGIN_KEYWORD_COLLISION\",\n PLUGIN_UNIT_COLLISION: \"PLUGIN_UNIT_COLLISION\",\n /** A package's declared `IEnginePackage.engineVersion` semver range doesn't satisfy the running engine's ENGINE_VERSION. See api/EngineVersionCompatibility.ts. */\n PACKAGE_ENGINE_VERSION_MISMATCH: \"PACKAGE_ENGINE_VERSION_MISMATCH\",\n /** A package's declared `IEnginePackage.engineVersion` isn't a parseable semver range at all (a typo in the package's own descriptor). */\n PACKAGE_ENGINE_VERSION_INVALID_RANGE: \"PACKAGE_ENGINE_VERSION_INVALID_RANGE\",\n /** `OpRegistry.allocateOpcode()`'s dynamic opcode pool (started at 201) exhausted, too many packages calling it. */\n OPCODE_POOL_EXHAUSTED: \"OPCODE_POOL_EXHAUSTED\",\n /** `VMBuiltins.allocatePluginFunctionIndex()`'s index pool (up to 65536, two opcode-stream bytes) exhausted. */\n PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED: \"PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED\",\n /** A plugin-function index exceeds the two-byte (65535) `CALL_PLUGIN_WIDE` bytecode operand. */\n PLUGIN_FUNCTION_INDEX_TOO_LARGE: \"PLUGIN_FUNCTION_INDEX_TOO_LARGE\",\n\n // ── vm/Value.ts caller-contract violations (check isRateUnit()/isTimecodeUnit() first) ──\n INVALID_RATE_UNIT: \"INVALID_RATE_UNIT\",\n INVALID_TIMECODE_UNIT: \"INVALID_TIMECODE_UNIT\",\n\n // ── errors/EngineError.ts's own fallback normalization ──\n UNEXPECTED_ERROR: \"UNEXPECTED_ERROR\",\n UNKNOWN_ERROR: \"UNKNOWN_ERROR\",\n} as const;\n\n/** Every error code the engine's own layers can produce, from {@link CoreErrorCodes}. */\nexport type CoreErrorCode = (typeof CoreErrorCodes)[keyof typeof CoreErrorCodes];\n\n/**\n * Codes for the datetime forms whose failure is raised OUTSIDE the datetime\n * package.\n *\n * These sit here rather than beside the datetime parselets, which is where a\n * package's own code object belongs, because the two sites that raise them are\n * `vm/VM.ts` (the `in <zone>` branch of the unit-conversion opcode) and\n * `calendar/DateCalendar.ts` (the zone-bound backend factory), and neither may\n * import from `packages/`. A code object in the datetime package would put the\n * name a core file needs on the wrong side of that line.\n */\nexport const DatetimeErrorCodes = {\n /** `2026-04-03 in Atlantis`: a Datetime met `in <name>` and the name is neither a zone this engine knows nor a unit. Before this code the epoch-millisecond payload was simply labelled with the name, and the line answered a fourteen-digit quantity in a unit called Atlantis. */\n DATETIME_ZONE_UNKNOWN: \"DATETIME_ZONE_UNKNOWN\",\n /** `2026-04-03 in furlongs`: the same handler, where the name IS a real unit. Separate from `DATETIME_ZONE_UNKNOWN` because the two mistakes have different fixes: one is a misspelt zone, the other is a category error, and a message that suggests checking the spelling of `furlongs` would be no help at all. */\n DATETIME_NOT_CONVERTIBLE: \"DATETIME_NOT_CONVERTIBLE\",\n /** `dateCalendarInZone(\"Europe/Atlantis\")`: the zone-bound `Date` backend factory, given a zone this runtime's `Intl` cannot format with. Raised at construction rather than per line, because a backend that cannot compute in the zone it was asked for must not silently answer in another one. */\n DATE_ZONE_UNKNOWN: \"DATE_ZONE_UNKNOWN\",\n} as const;\n\n/** Every code from {@link DatetimeErrorCodes}. */\nexport type DatetimeErrorCode = (typeof DatetimeErrorCodes)[keyof typeof DatetimeErrorCodes];\n\n/**\n * The aggregated catalog type. Currently `CoreErrorCode` and\n * `DatetimeErrorCode`, union in each package's own code-object type here as\n * Phase 5 converts it, e.g. `CoreErrorCode | WeatherErrorCode | ...`.\n */\nexport type ErrorCode = CoreErrorCode | DatetimeErrorCode;\n"]}
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkHG4NPDN5_cjs=require('./chunk-HG4NPDN5.cjs'),chunkLCYQQFUH_cjs=require('./chunk-LCYQQFUH.cjs'),chunkDUFEONVN_cjs=require('./chunk-DUFEONVN.cjs'),chunkABVDKMNF_cjs=require('./chunk-ABVDKMNF.cjs'),chunkYWF6C2IO_cjs=require('./chunk-YWF6C2IO.cjs'),chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),chunkOM7NOHJF_cjs=require('./chunk-OM7NOHJF.cjs'),chunkPHWIO4P3_cjs=require('./chunk-PHWIO4P3.cjs'),chunkEZKR44MA_cjs=require('./chunk-EZKR44MA.cjs'),chunkSUAGBRQ7_cjs=require('./chunk-SUAGBRQ7.cjs');var Bn=class{constructor(){this.consumers=new Map;this.dependencies=new Map;this.writes=new Map;this.lineReads=new Map;this.dataSourceDependencies=new Map;this.dataSourceConsumers=new Map;}registerLine(a,s,u){let c=this.lineReads.get(a);if(c)for(let b of c){let h=this.consumers.get(b);h&&h.delete(a);}this.lineReads.set(a,new Set(s));for(let b of s)this.consumers.has(b)||this.consumers.set(b,new Set),this.consumers.get(b).add(a);if(u.length>0){this.dependencies.set(a,new Set(s)),this.writes.set(a,new Set(u));for(let b of u){let h=this.consumers.get(b);h&&h.delete(a);}}}registerLineDataSourceDependency(a,s,u){let c=JSON.stringify(u),b=`${s}:${c}`;this.dataSourceDependencies.has(a)||this.dataSourceDependencies.set(a,new Set),this.dataSourceDependencies.get(a).add(b),this.dataSourceConsumers.has(b)||this.dataSourceConsumers.set(b,new Set),this.dataSourceConsumers.get(b).add(a);}getAffectedLines(a){let s=new Set,u=[a];for(;u.length>0;){let c=u.pop(),b=this.consumers.get(c);if(b)for(let h of b){if(s.has(h))continue;s.add(h);let p=this.writes.get(h);if(p)for(let y of p)u.push(y);}}return s}getAffectedLinesInOrder(a){let s=this.getAffectedLines(a);if(s.size===0)return [];let u=new Map,c=new Map;for(let y of s)u.has(y)||u.set(y,0),c.has(y)||c.set(y,[]);let b=new Map;for(let y of s){let x=this.writes.get(y);if(x)for(let T of x)b.set(T,y);}for(let y of s){let x=this.lineReads.get(y);if(x)for(let T of x){let O=b.get(T);O!==void 0&&O!==y&&(c.get(O).push(y),u.set(y,(u.get(y)??0)+1));}}let h=[];for(let[y,x]of u)x===0&&h.push(y);if(h.length===0&&s.size>0){let y=Array.from(s).sort((x,T)=>x-T);h.push(y[0]);}let p=[];for(;h.length>0;){let y=h.shift();p.push(y);for(let x of c.get(y)??[]){let T=(u.get(x)??1)-1;u.set(x,T),T===0&&h.push(x);}}if(p.length<s.size){let y=new Set(p),x=Array.from(s).filter(T=>!y.has(T)).sort((T,O)=>T-O);p.push(...x);}return p}getAffectedLinesByDataSource(a,s){let u=JSON.stringify(s),c=`${a}:${u}`;return this.dataSourceConsumers.get(c)??new Set}removeLine(a){let s=this.lineReads.get(a);if(s){for(let c of s){let b=this.consumers.get(c);b&&b.delete(a);}this.lineReads.delete(a);}this.dependencies.delete(a),this.writes.delete(a);let u=this.dataSourceDependencies.get(a);if(u){for(let c of u)this.dataSourceConsumers.get(c)?.delete(a);this.dataSourceDependencies.delete(a);}}getConsumers(a){return this.consumers.get(a)??new Set}getDependencies(a){return this.dependencies.get(a)??new Set}getWrites(a){return this.writes.get(a)??new Set}getSnapshot(){let a={};for(let[h,p]of this.consumers)a[h]=Array.from(p);let s={};for(let[h,p]of this.writes)s[h]=Array.from(p);let u={};for(let[h,p]of this.lineReads)u[h]=Array.from(p);let c={};for(let[h,p]of this.dataSourceDependencies)c[h]=Array.from(p);let b={};for(let[h,p]of this.dataSourceConsumers)b[h]=Array.from(p);return {consumers:a,writes:s,reads:u,dataSourceDeps:c,dataSourceConsumers:b}}clear(){this.consumers.clear(),this.dependencies.clear(),this.writes.clear(),this.lineReads.clear(),this.dataSourceDependencies.clear(),this.dataSourceConsumers.clear();}};var Ln=class{constructor(){this.definitions=new Map;}write(a,s,u){this.definitions.has(a)||this.definitions.set(a,[]);let c=this.definitions.get(a);c.push({line:s,expr:u}),c.sort((b,h)=>b.line-h.line);}read(a,s){let u=this.definitions.get(a);if(u){for(let c=u.length-1;c>=0;c--)if(u[c].line<=s)return u[c].expr.lastResult}}invalidateDownstream(a,s){let u=this.definitions.get(a);if(!u)return;let c=u.findIndex(b=>b.line===s);c!==-1&&u.splice(c+1);}clear(){this.definitions.clear();}};var Je={kg:{dim:[1,0,0,0],si:1},g:{dim:[1,0,0,0],si:.001},tonne:{dim:[1,0,0,0],si:1e3},t:{dim:[1,0,0,0],si:1e3},m:{dim:[0,1,0,0],si:1},cm:{dim:[0,1,0,0],si:.01},mm:{dim:[0,1,0,0],si:.001},km:{dim:[0,1,0,0],si:1e3},s:{dim:[0,0,1,0],si:1},ms:{dim:[0,0,1,0],si:.001},min:{dim:[0,0,1,0],si:60},minute:{dim:[0,0,1,0],si:60},minutes:{dim:[0,0,1,0],si:60},h:{dim:[0,0,1,0],si:3600},hr:{dim:[0,0,1,0],si:3600},hour:{dim:[0,0,1,0],si:3600},hours:{dim:[0,0,1,0],si:3600},A:{dim:[0,0,0,1],si:1},mA:{dim:[0,0,0,1],si:.001},kA:{dim:[0,0,0,1],si:1e3},ampere:{dim:[0,0,0,1],si:1},amperes:{dim:[0,0,0,1],si:1},mps2:{dim:[0,1,-2,0],si:1},N:{dim:[1,1,-2,0],si:1},kN:{dim:[1,1,-2,0],si:1e3},newton:{dim:[1,1,-2,0],si:1},newtons:{dim:[1,1,-2,0],si:1},J:{dim:[1,2,-2,0],si:1},kJ:{dim:[1,2,-2,0],si:1e3},MJ:{dim:[1,2,-2,0],si:1e6},joule:{dim:[1,2,-2,0],si:1},joules:{dim:[1,2,-2,0],si:1},Wh:{dim:[1,2,-2,0],si:3600},kWh:{dim:[1,2,-2,0],si:36e5},W:{dim:[1,2,-3,0],si:1},kW:{dim:[1,2,-3,0],si:1e3},MW:{dim:[1,2,-3,0],si:1e6},watt:{dim:[1,2,-3,0],si:1},watts:{dim:[1,2,-3,0],si:1},Pa:{dim:[1,-1,-2,0],si:1},kPa:{dim:[1,-1,-2,0],si:1e3},MPa:{dim:[1,-1,-2,0],si:1e6},pascal:{dim:[1,-1,-2,0],si:1},pascals:{dim:[1,-1,-2,0],si:1},V:{dim:[1,2,-3,-1],si:1},mV:{dim:[1,2,-3,-1],si:.001},kV:{dim:[1,2,-3,-1],si:1e3},volt:{dim:[1,2,-3,-1],si:1},volts:{dim:[1,2,-3,-1],si:1}},it={"1,1,-2,0":"N","1,2,-2,0":"J","1,2,-3,0":"W","1,-1,-2,0":"Pa","1,2,-3,-1":"V"},st=r=>r.join(",");function Ze(r,a,s){if(r.type!==6||a.type!==6)return null;let u=r.unit?Je[r.unit]:void 0,c=a.unit?Je[a.unit]:void 0;if(u===void 0||c===void 0)return null;let b=[u.dim[0]+(s?c.dim[0]:-c.dim[0]),u.dim[1]+(s?c.dim[1]:-c.dim[1]),u.dim[2]+(s?c.dim[2]:-c.dim[2]),u.dim[3]+(s?c.dim[3]:-c.dim[3])],h=it[st(b)];if(h===void 0)return null;let p=r.toNumber()*u.si,y=a.toNumber()*c.si,x=s?p*y:p/y;return chunkOM7NOHJF_cjs.u(x/Je[h].si,h)}function ot(r,a){let s=a.fields(r).weekday;return s===0||s===6}function $n(r,a,s){return ot(r,s)?false:a?!a(r):true}function Fn(r,a){let s=a.fields(r);return a.localMidnight(s.year,s.month0,s.day)}function Pn(r,a,s,u,c){let b=Math.trunc(Math.abs(a)),h=a>=0?1:-1,p=r,y=0;for(;b>0;){if(p=c.addDays(p,h),y++,y>u)return null;$n(p,s,c)&&b--;}return p}function Yn(r,a,s,u,c){let b=Fn(Math.min(r,a),c),h=Fn(Math.max(r,a),c),p=Math.round((h-b)/864e5);if(p>u)return null;let y=0,x=b;for(let T=0;T<=p;T++)$n(x,s,c)&&y++,x=c.addDays(x,1);return y}var ut={0:{name:"sqrt",min:1,max:1},1:{name:"abs",min:1,max:1},2:{name:"sin",min:1,max:1},3:{name:"cos",min:1,max:1},4:{name:"tan",min:1,max:1},5:{name:"log",min:1,max:1},6:{name:"ceil",min:1,max:1},7:{name:"floor",min:1,max:1},8:{name:"round",min:1,max:2},9:{name:"min",min:1,max:1/0},10:{name:"max",min:1,max:1/0},11:{name:"asin",min:1,max:1},12:{name:"acos",min:1,max:1},13:{name:"atan",min:1,max:1},14:{name:"atan2",min:2,max:2},15:{name:"sinh",min:1,max:1},16:{name:"cosh",min:1,max:1},17:{name:"tanh",min:1,max:1},18:{name:"asinh",min:1,max:1},19:{name:"acosh",min:1,max:1},20:{name:"atanh",min:1,max:1},21:{name:"cbrt",min:1,max:1},22:{name:"clz32",min:1,max:1},23:{name:"expm1",min:1,max:1},24:{name:"exp",min:1,max:1},25:{name:"fround",min:1,max:1},26:{name:"hypot",min:1,max:1/0},27:{name:"imul",min:2,max:2},28:{name:"log10",min:1,max:1},29:{name:"log1p",min:1,max:1},30:{name:"log2",min:1,max:1},31:{name:"pow",min:2,max:2},32:{name:"random",min:0,max:0},33:{name:"sign",min:1,max:1},34:{name:"trunc",min:1,max:1},35:{name:"degtorad",min:1,max:1},36:{name:"radtodeg",min:1,max:1},37:{name:"roll",min:2,max:2},38:{name:"gcd",min:2,max:2},39:{name:"lcm",min:2,max:2},40:{name:"permutation",min:2,max:2},41:{name:"combination",min:2,max:2},42:{name:"average",min:0,max:1/0},43:{name:"median",min:0,max:1/0},44:{name:"total",min:0,max:1/0},45:{name:"count",min:0,max:1/0},46:{name:"proportion",min:3,max:3},47:{name:"clamp",min:3,max:3},48:{name:"hex",min:1,max:1},49:{name:"bin",min:1,max:1},50:{name:"int",min:1,max:1},51:{name:"compoundInterest",min:3,max:3},52:{name:"interestEarned",min:3,max:3},53:{name:"compoundInterestRate",min:3,max:3},54:{name:"compoundInterestYears",min:3,max:3},55:{name:"loanRepayment",min:4,max:4},56:{name:"loanInterest",min:4,max:4},57:{name:"monthlyPayment",min:3,max:3},58:{name:"taxAdd",min:2,max:2},59:{name:"taxRemove",min:2,max:2},60:{name:"inflationAdjust",min:3,max:3},61:{name:"root",min:2,max:2},62:{name:"fact",min:1,max:1},63:{name:"transpose",min:1,max:1},64:{name:"det",min:1,max:1},65:{name:"inv",min:1,max:1},66:{name:"dot",min:2,max:2},67:{name:"expand",min:1,max:1},68:{name:"factor",min:1,max:1},69:{name:"solve",min:3,max:3},70:{name:"der",min:2,max:3},71:{name:"integral",min:2,max:2},72:{name:"taylor",min:4,max:4},73:{name:"jacobian",min:1,max:1/0},74:{name:"imaginary",min:1,max:1},75:{name:"conj",min:1,max:1},76:{name:"re",min:1,max:1},77:{name:"im",min:1,max:1},78:{name:"cancel",min:1,max:1},79:{name:"apart",min:1,max:1},80:{name:"compoundInterestEvery",min:4,max:4},81:{name:"compoundInterestEarnedEvery",min:4,max:4},82:{name:"presentValue",min:3,max:3},83:{name:"roi",min:2,max:2},84:{name:"annualisedReturn",min:3,max:3},85:{name:"taxIn",min:2,max:2},86:{name:"taxOn",min:2,max:2},87:{name:"sind",min:1,max:1},88:{name:"cosd",min:1,max:1},89:{name:"tand",min:1,max:1},90:{name:"asind",min:1,max:1},91:{name:"acosd",min:1,max:1},92:{name:"atand",min:1,max:1},93:{name:"daysCount",min:1,max:1},94:{name:"asTwoUnits",min:3,max:3},95:{name:"makeRate",min:2,max:2},96:{name:"atRate",min:2,max:2},97:{name:"roundToPlaces",min:2,max:2},98:{name:"splitEach",min:2,max:2},99:{name:"savingsGoalPayment",min:3,max:3},100:{name:"savingsGoalPeriods",min:5,max:5},101:{name:"standardDeviation",min:0,max:1/0},102:{name:"sampleStandardDeviation",min:0,max:1/0},103:{name:"variance",min:0,max:1/0},104:{name:"sampleVariance",min:0,max:1/0},105:{name:"spread",min:0,max:1/0},106:{name:"mode",min:0,max:1/0},107:{name:"weightedAverage",min:2,max:1/0}};function De(r){return r===1?"1 argument":`${r} arguments`}function lt(r){return r.max===1/0?`at least ${De(r.min)}`:r.min===r.max?De(r.min):`${r.min} to ${De(r.max)}`}function Wn(r,a){let s=ut[r];if(s!==void 0&&!(a>=s.min&&a<=s.max))return chunkSUAGBRQ7_cjs.c.execution("BUILTIN_ARITY_MISMATCH",`${s.name}() takes ${lt(s)}, but was given ${a===0?"none":De(a)}`,{functionName:s.name,expectedMin:s.min,expectedMax:s.max,actual:a})}function la(r,a=200,s=5e4,u=50,c=1e5,b=2e6,h=1e4,p=100,y=-100,x=chunkLCYQQFUH_cjs.y,T){let O=[],E=new Map,$=0,j,P,t=[],Z=new Map,X=new Map,K=new Map;return {push(f){if(O.length>=a)throw chunkSUAGBRQ7_cjs.c.execution("STACK_LIMIT_EXCEEDED",`Execution exceeded maximum stack depth of ${a}`);O.push(f);},getMaxStackDepth(){return a},getMaxCollectionSize(){return c},getMaxAllocatedElements(){return b},getMaxFunctionCalls(){return h},getMaxDateOffsetYears(){return p},getMinDateOffsetYears(){return y},isHoliday(f){return T?T(f):false},pop(){return m(O)},popNumber(){return m(O).toNumber()},popString(){return q(m(O),"VM.popString()")},peek(){return O[O.length-1]},getStack(){return O},registry:r,getVar(f){if(t.length>0){let e=t[t.length-1].get(f);if(e!==void 0)return e}return E.get(f)},setVar(f,e){E.set(f,e);},deleteVar(f){E.delete(f);},pushCallFrame(f){if(t.length>=u)throw chunkSUAGBRQ7_cjs.c.execution("FUNCTION_RECURSION_LIMIT_EXCEEDED",`Function call nesting exceeded maximum depth of ${u} (possible infinite recursion, e.g. f(x) = f(x))`,{maxFunctionRecursionDepth:u});t.push(f);},popCallFrame(){t.pop();},getCallFrame(){return t.length>0?t[t.length-1]:void 0},defineUserFunction(f,e,n){Z.set(f,{name:f,params:e,program:n});},getUserFunction(f){return Z.get(f)},hasUserFunction(f){return Z.has(f)},getVariableEntries(){return Array.from(E.entries())},getUserFunctionDefs(){return Array.from(Z.values())},defineEquation(f,e,n){X.set(f,{variable:f,factorNames:e,rhsProgram:n});},getEquation(f){return X.get(f)},hasEquation(f){return X.has(f)},defineScalarEquation(f,e,n){K.set(f,{variable:f,lhsProgram:e,rhsProgram:n});},getScalarEquation(f){return K.get(f)},hasScalarEquation(f){return K.has(f)},reset(){O.length=0,E.clear(),t.length=0,Z.clear(),X.clear(),K.clear(),$=0,P&&(P(),P=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(f){j=f;},get abortCurrent(){return P},set abortCurrent(f){P=f;},context:x,getMaxInstructions(){return s},getInstructionCount(){return $},incrementInstructions(f){if($+=f,$>s)throw chunkSUAGBRQ7_cjs.c.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${s} instructions`)}}}function ct(r,a){return r.rows===1&&r.cols===1?a.data.length:a.rows===1&&a.cols===1?r.data.length:r.cols!==a.rows?0:r.rows*a.cols}function mt(r,a){return !Number.isInteger(a)||a<0?0:r.rows*r.cols*(1+(a<2?1:2*Math.floor(Math.log2(a))))}function Gn(r,a,s){return r.context.networkEnabled?chunkOM7NOHJF_cjs.P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${a} to ${s}`):chunkOM7NOHJF_cjs.P("NETWORK_DISABLED",`No exchange rate for ${a} to ${s}: live data is switched off for this engine (network.enabled is false)`)}function m(r){if(r.length===0)throw chunkSUAGBRQ7_cjs.c.internal({code:"STACK_UNDERFLOW",message:"Stack underflow: an opcode expected a value on the stack but it was empty",expected:"at least one value on the VM stack",found:"an empty stack",suggestion:"this indicates corrupted bytecode or a bug in a package's parselet (mismatched push/pop counts), not a user-input error"});return r.pop()}var tt="bytecode is caller input on this entry point: rebuild the program with the engine's compiler, or fix the hand-assembled stream";function dt(r){return typeof r=="number"?chunkABVDKMNF_cjs.b(r):r}function oe(r,a,s,u,c,b={}){let h=dt(a);return chunkSUAGBRQ7_cjs.c.validation({code:r,message:`Malformed bytecode: ${h} ${s}`,expected:u,found:c,suggestion:tt,context:typeof a=="number"?{opcode:a,opcodeName:h,...b}:{site:h,...b}})}function w(r,a,s,u){if(a>=r.length)throw oe("MALFORMED_BYTECODE_TRUNCATED",s,`is missing its ${u}: the program ends mid-instruction`,`an operand byte at offset ${a}`,`a program only ${r.length} byte(s) long`,{offset:a,length:r.length,role:u});return r[a]}function Qe(r,a,s,u,c,b){let h=w(r,a,s,u);if(h>=c)throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads ${b} entry ${h}, which does not exist`,`an index below ${c}`,`${h}`,{index:h,poolSize:c,pool:b});return h}function J(r,a,s,u,c){return Te(s,w(r,a,u,c),u)}function Te(r,a,s){let u=r[a];if(typeof u!="string")throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads string-pool entry ${a}, which is ${a>=r.length?"past the end of the pool":"not a string"}`,`an index below ${r.length}, holding a string`,a>=r.length?`${a}`:typeof u,{index:a,poolSize:r.length,pool:"string-pool"});return u}function q(r,a,s){if(typeof r.value!="string")throw oe("MALFORMED_BYTECODE_OPERAND_TYPE",a,`expected a ${s??"string"} on the stack`,s?`a string value holding the ${s}`:"a string value",`a ${chunkOM7NOHJF_cjs.g[r.type]??"unknown"} value`,s?{role:s,valueType:r.type}:{valueType:r.type});return r.value}function Xn(r,a,s){if(r!==0&&r!==1&&r!==2)throw oe("MALFORMED_BYTECODE_BODY_KIND",s,`has body kind ${r}, which is not one this VM knows`,"0 (inline body), 1 (builtin function) or 2 (user-defined function)",`${r}`,{kind:r,ref:a})}function pt(r,a){try{return BigInt(r)}catch{throw oe("MALFORMED_BYTECODE_BIGINT_LITERAL",a,`cannot read "${r}" as a whole number`,"a string holding an integer, with no decimal point or separators",`"${r}"`,{literal:r})}}function ft(r){if(r===null||typeof r!="object")return `expected a bytecode program, got ${r===null?"null":typeof r}`;let a=r;return typeof a.opcodes?.length!="number"?"the program has no `opcodes` array":typeof a.numbers?.length!="number"?"the program has no `numbers` pool":typeof a.strings?.length!="number"?"the program has no `strings` pool":null}var Kn=64;function en(r,a,s,u,c,b,h,p){let y=new Map;for(let T=0;T<r.length;T++)y.set(r[T],s[T]);u.pushCallFrame(y);let x;try{x=an(a,u,c,b,h,p);}finally{u.popCallFrame();}if(x.type==="pending")throw chunkSUAGBRQ7_cjs.c.execution("MAP_REDUCE_ASYNC_UNSUPPORTED","map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported");if(x.type==="error")throw x.error;return x.value}function bt(r,a,s,u,c,b,h){let p=new Map(s.getCallFrame());p.set(r,chunkOM7NOHJF_cjs.K(chunkYWF6C2IO_cjs.q(r))),s.pushCallFrame(p);let y;try{y=an(a,s,u,c,b,h);}finally{s.popCallFrame();}if(y.type==="pending")throw chunkSUAGBRQ7_cjs.c.execution("SYMBOLIC_ASYNC_UNSUPPORTED","an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)");if(y.type==="error")throw y.error;return y.value}function Hn(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u=a.unit;if(s===void 0||u===void 0)return null;let c=s.indexOf("/"),b=u.indexOf("/");if(c<0||b<0||s.slice(0,c)!==u.slice(0,b))return null;let h=chunkEZKR44MA_cjs.a[s.slice(c+1).toLowerCase()],p=chunkEZKR44MA_cjs.a[u.slice(b+1).toLowerCase()];return h===void 0||p===void 0||h[0]!==p[0]?null:r.toNumber()*(p[1]/h[1])}function qn(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u=a.unit;if(s===void 0||u===void 0||s.includes("/")||u.includes("/"))return null;let c=chunkYWF6C2IO_cjs.ua[s.toUpperCase()]!==void 0,b=chunkYWF6C2IO_cjs.ua[u.toUpperCase()]!==void 0;return c===b?null:chunkOM7NOHJF_cjs.u(r.toNumber()*a.toNumber(),c?s:u)}function jn(r,a,s){if(r.type===5)return a.type===6&&a.unit!==void 0?chunkLCYQQFUH_cjs.c(a,a.unit,r.toNumber(),s):a.type!==5&&a.type!==0?null:chunkOM7NOHJF_cjs.N(r.toNumber()+s*a.toNumber());if(a.type!==5)return null;let u=1+s*a.toNumber();if(r.type===0){let c=r.toNumber()*u;return r.uncertainty!==void 0?chunkOM7NOHJF_cjs.q(c,Math.abs(r.uncertainty*u)):chunkOM7NOHJF_cjs.n(c)}return r.type===6&&r.unit!==void 0?chunkLCYQQFUH_cjs.c(r,r.unit,a.toNumber(),s):null}function ht(r,a){let s=r.type===5?r:a.type===5?a:null;if(s===null)return null;let u=s===r?a:r;if(u.type!==0||u.uncertainty===void 0)return null;let c=s.toNumber();return chunkOM7NOHJF_cjs.q(u.toNumber()*c,Math.abs(u.uncertainty*c))}function gt(r,a){let s=r.type===6?r:a,u=r.type===6?a:r;return s.type!==6||s.unit===void 0||!chunkDUFEONVN_cjs.c.isCurrency(s.unit)||u.type!==0&&u.type!==5||u.rational!==void 0?null:chunkLCYQQFUH_cjs.b(s,u.toNumber(),s.unit)}function yt(r,a){if(a.type===5&&r.type===0&&r.uncertainty!==void 0){let s=a.toNumber();return s===0?null:chunkOM7NOHJF_cjs.q(r.toNumber()/s,Math.abs(r.uncertainty/s))}if(r.type===5&&a.type===0&&a.uncertainty!==void 0){let s=a.toNumber();return s===0?null:chunkOM7NOHJF_cjs.q(r.toNumber()/s,Math.abs(r.toNumber()*a.uncertainty/(s*s)))}return null}function Nt(r){if(r.type===6){let a=r.unit;if(a&&chunkPHWIO4P3_cjs.c(a)==="time")try{return chunkPHWIO4P3_cjs.e(r.toNumber(),a,"ms")}catch{}return 0}return r.toNumber()}var zn=260;function at(r,a,s){let u=Math.trunc(Math.abs(a)),b=(a>=0?1:-1)>0?s.getMaxDateOffsetYears():-s.getMinDateOffsetYears(),h=Math.floor(b*zn);if(u>h)throw chunkSUAGBRQ7_cjs.c.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/zn).toLocaleString("en-US")} years, past the limit of ${b} years for a workday offset`,{requestedWorkdays:u,limitYears:b,limitWorkdays:h});let p=h*7+7,y=Pn(r,a,x=>s.isHoliday(x),p,s.context.calendar);if(y===null)throw chunkSUAGBRQ7_cjs.c.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A working-day offset of ${u.toLocaleString("en-US")} could not be reached within the ${b}-year limit; the configured holiday calendar leaves too few working days`,{requestedWorkdays:u,limitYears:b,maxCalendarSteps:p});return y}var Jn=864e5,xt={month:1,months:1,mo:1,year:12,years:12,yr:12,y:12,a:12,decade:120,decades:120,dec:120,century:1200,centuries:1200,millennium:12e3,millennia:12e3};function rt(r,a,s){let u=Math.trunc(a),c=s.addDays(r,u);return Number.isNaN(c)?r+a*Jn:c+(a-u)*Jn}function Et(r,a,s){let u=Math.trunc(a),c=s.addMonths(r,u),b=chunkPHWIO4P3_cjs.e(1,"month","ms");return Number.isNaN(c)?r+a*b:c+(a-u)*b}function he(r,a,s,u){if(a.type===6&&a.unit!==void 0){let c=a.unit,b=s*a.toNumber();if(chunkPHWIO4P3_cjs.a(c))return at(r,b,u);let h=xt[c];if(h!==void 0)return Et(r,b*h,u.context.calendar);if(chunkPHWIO4P3_cjs.c(c)==="time"){let p=0;try{p=chunkPHWIO4P3_cjs.e(1,c,"day");}catch{}if(Number.isInteger(p)&&p>=1)return rt(r,b*p,u.context.calendar)}}return r+s*Nt(a)}function Zn(r,a,s){let u=chunkOM7NOHJF_cjs.B(r.unit);if(a.type===6&&chunkOM7NOHJF_cjs.A(a.unit)){let c=chunkOM7NOHJF_cjs.B(a.unit);return c!==u?chunkOM7NOHJF_cjs.P("TIMECODE_FPS_MISMATCH",`Cannot combine timecodes at different frame rates (${u} fps vs ${c} fps)`):s===1?chunkOM7NOHJF_cjs.u(r.toNumber()+a.toNumber(),r.unit):chunkOM7NOHJF_cjs.u(r.toNumber()-a.toNumber(),"frames")}if(a.type===6&&a.unit==="frames")return chunkOM7NOHJF_cjs.u(r.toNumber()+s*a.toNumber(),r.unit);if(a.type===6&&a.unit&&chunkPHWIO4P3_cjs.c(a.unit)==="time"){let c=chunkPHWIO4P3_cjs.e(a.toNumber(),a.unit,"s");return chunkOM7NOHJF_cjs.u(r.toNumber()+s*c*u,r.unit)}return chunkOM7NOHJF_cjs.u(r.toNumber()+s*a.toNumber(),r.unit)}function ge(r){return r.type===10?r.value:r.toNumber()!==0}function It(r,a,s){let u=chunkLCYQQFUH_cjs.N(a);if(u===null)return chunkPHWIO4P3_cjs.c(a)!==void 0||chunkDUFEONVN_cjs.c.isCurrency(a)?chunkOM7NOHJF_cjs.P(chunkSUAGBRQ7_cjs.s.DATETIME_NOT_CONVERTIBLE,`A date cannot be read in "${a}". "in <name>" after a date names a time zone, as in "2026-04-03 in Tokyo"`):chunkOM7NOHJF_cjs.P(chunkSUAGBRQ7_cjs.s.DATETIME_ZONE_UNKNOWN,`"${a}" is not a time zone this engine knows. Name a city ("in Tokyo"), a standard abbreviation ("in JST") or "in UTC"`);let c=r.toNumber();if(r.grain!=="date"&&r.grain!=="datetime")return chunkOM7NOHJF_cjs.M(c,"instant",u);let b=s.context.calendar,h=b.fields(c);if(r.grain==="date")return chunkOM7NOHJF_cjs.M(chunkE4HAKNBQ_cjs.j(h.year,h.month0,h.day,0,0,u,b),"instant",u);let p=chunkE4HAKNBQ_cjs.j(h.year,h.month0,h.day,h.hour,h.minute,u,b);return chunkOM7NOHJF_cjs.M(p+h.second*1e3+h.millisecond,"instant",u)}function Qn(r,a){let s=chunkLCYQQFUH_cjs.l(r,a);return chunkOM7NOHJF_cjs.P("INCOMPATIBLE_UNITS",s??`Cannot convert ${r} to ${a}: they do not measure the same thing`)}var Se=65536;function kt(r,a){if(!Number.isInteger(a)||a<0)return null;if(a===0)return 1;let s=Math.abs(r.toNumber());return s<=1?1:(s<=2?1:Math.log2(s))*a}function _t(r,a){let s=1n,u=r,c=a;for(;c>0n;)c%2n===1n&&(s*=u),c/=2n,c>0n&&(u*=u);return s}var nn=Se;function et(r){let a=r<0n?-r:r;if(a===0n)return 0;let s=Number(a);return Number.isFinite(s)?Math.floor(Math.log2(s))+1:a.toString(16).length*4}function nt(r,a,s){let u=chunkLCYQQFUH_cjs.n(r),c=chunkLCYQQFUH_cjs.n(a);if(u===0n)return chunkOM7NOHJF_cjs.s(0n);let b=s*Number(c);if(b<=0||et(u)+b<=nn)return chunkOM7NOHJF_cjs.s(s===1?u<<c:u>>c);throw chunkSUAGBRQ7_cjs.c.execution("BIGINT_SHIFT_LIMIT_EXCEEDED",`Shifting by ${c} would build an exact integer of about ${(et(u)+b).toLocaleString("en-US")} bits, past the limit of ${nn.toLocaleString("en-US")} bits`,{shift:String(c),limitBits:nn})}function tn(r,a){let{numerator:s,denominator:u}=chunkOM7NOHJF_cjs.y(r.unit),c=chunkPHWIO4P3_cjs.c(u),b=chunkPHWIO4P3_cjs.c(a.unit);if(!c||c!==b)return chunkOM7NOHJF_cjs.P("RATE_MUL_MEASURE_MISMATCH",`Cannot multiply a "${u}"-denominated rate by "${a.unit}" \u2014 different measures`);let h=chunkPHWIO4P3_cjs.e(a.toNumber(),a.unit,u),p=r.toNumber()*h;return s?chunkOM7NOHJF_cjs.u(p,s):chunkOM7NOHJF_cjs.n(p)}function Mt(r){if(Number.isNaN(r))return "NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let a=r<0,s=Math.abs(r),u=Math.floor(s),c=s-u;if(c<1e-9)return `${a?"-":""}${u}`;let b=0,h=1,p=1,y=0,x=c,T=1e6;for(let E=0;E<30;E++){let $=Math.floor(x+1e-9),j=$*h+b,P=$*y+p;if(P>T||(b=h,h=j,p=y,y=P,Math.abs(c-h/y)<1e-9))break;let t=x-$;if(t<1e-9)break;x=1/t;}let O=u*y+h;return `${a?"-":""}${O}/${y}`}function Dt(r){return r.d===1n?String(r.n):`${r.n}/${r.d}`}function Tt(r){let a=r.toNumber(),s=r.type===5?1+a:a;return `${Math.round(s*1e6)/1e6}x`}function St(r){if(!Number.isFinite(r))return String(r);if(r===0)return "0e+0";let[a,s]=r.toExponential().split("e");return `${a.includes(".")?a.replace(/0+$/,"").replace(/\.$/,""):a}e${s}`}function an(r,a,s,u,c,b){let h=ft(r);if(h)return {type:"error",error:chunkSUAGBRQ7_cjs.c.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${h}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:h,suggestion:tt})};let{opcodes:p,numbers:y,strings:x,userFunctionBodies:T,anonymousBodies:O}=r,E=0,$=0,j=a.getMaxInstructions(),P=a.getMaxStackDepth(),t=a.getStack(),Z=s?.hasCollectors??false,X=chunkOM7NOHJF_cjs.j();if(p.length===0)return {type:"value",value:chunkOM7NOHJF_cjs.n(0)};chunkOM7NOHJF_cjs.a(a);try{for(;E<p.length;){if(++$>j)throw chunkSUAGBRQ7_cjs.c.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${j} instructions`);if(t.length>P)throw chunkSUAGBRQ7_cjs.c.execution("STACK_LIMIT_EXCEEDED",`Execution exceeded maximum stack depth of ${P}`);let f=p[E++];if(Z){let e=t.map(n=>({type:n.type,value:n.value,unit:n.unit}));s.fireVmStep({type:chunkHG4NPDN5_cjs.c.VmStep,elapsedNs:0,expression:u??"",opcode:f,opcodeName:chunkABVDKMNF_cjs.b(f),ip:E-1,stackDepth:t.length,instructionNumber:$,stack:e});}switch(f){case 0:break;case 1:{let e=m(t);return {type:"value",value:X?chunkOM7NOHJF_cjs.k(e):e}}case 3:{let e=m(t);t.push(e),t.push(e);break}case 2:{let e=m(t),n=m(t);t.push(e),t.push(n);break}case 10:t.push(chunkOM7NOHJF_cjs.n(y[Qe(p,E++,f,"constant-pool index",y.length,"number-pool")]));break;case 11:t.push(chunkOM7NOHJF_cjs.s(pt(J(p,E++,x,f,"constant-pool index"),f)));break;case 16:{let e=chunkYWF6C2IO_cjs.ia(J(p,E++,x,f,"constant-pool index"));t.push(chunkOM7NOHJF_cjs.o(chunkYWF6C2IO_cjs.ra(e),e));break}case 12:t.push(chunkOM7NOHJF_cjs.r(y[Qe(p,E++,f,"constant-pool index",y.length,"number-pool")]));break;case 13:t.push(chunkOM7NOHJF_cjs.t(J(p,E++,x,f,"constant-pool index")));break;case 14:t.push(chunkOM7NOHJF_cjs.L(w(p,E++,f,"boolean operand")===1));break;case 20:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.uncertainty!==void 0||e.uncertainty!==void 0){let d=chunkLCYQQFUH_cjs.s(n,e,"add");if(d){t.push(d);break}}if(n.rational!==void 0||e.rational!==void 0){let d=chunkLCYQQFUH_cjs.r(n,e,"add");if(d){t.push(d);break}}let i=jn(n,e,1),l=i===null?Hn(n,e):null;i!==null?t.push(i):l!==null?t.push(chunkOM7NOHJF_cjs.u(l+e.toNumber(),e.unit)):n.type===0&&e.type===0?t.push(chunkOM7NOHJF_cjs.n(n.value+e.value)):n.type===10&&e.type===10?t.push(chunkOM7NOHJF_cjs.L(n.value&&e.value)):n.type===4?e.type===4?t.push(chunkOM7NOHJF_cjs.P("INVALID_DATETIME_OP","Cannot add two datetimes together")):t.push(chunkOM7NOHJF_cjs.M(he(n.toNumber(),e,1,a),n.grain,n.zone)):n.type===6&&chunkOM7NOHJF_cjs.A(n.unit)?t.push(Zn(n,e,1)):e.type===4?t.push(chunkOM7NOHJF_cjs.M(he(e.toNumber(),n,1,a),e.grain,e.zone)):n.type===3&&e.type===3?t.push(chunkOM7NOHJF_cjs.t(n.value+e.value)):t.push(chunkLCYQQFUH_cjs.u(n,e,(d,g)=>d+g,(d,g)=>d+g,"add"));break}case 21:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.uncertainty!==void 0||e.uncertainty!==void 0){let d=chunkLCYQQFUH_cjs.s(n,e,"sub");if(d){t.push(d);break}}if(n.rational!==void 0||e.rational!==void 0){let d=chunkLCYQQFUH_cjs.r(n,e,"sub");if(d){t.push(d);break}}let i=jn(n,e,-1),l=i===null?Hn(n,e):null;i!==null?t.push(i):l!==null?t.push(chunkOM7NOHJF_cjs.u(l-e.toNumber(),e.unit)):n.type===0&&e.type===0?t.push(chunkOM7NOHJF_cjs.n(n.value-e.value)):n.type===4?e.type===4?t.push(chunkOM7NOHJF_cjs.u(n.toNumber()-e.toNumber(),"ms")):t.push(chunkOM7NOHJF_cjs.M(he(n.toNumber(),e,-1,a),n.grain,n.zone)):n.type===6&&chunkOM7NOHJF_cjs.A(n.unit)?t.push(Zn(n,e,-1)):e.type===4?t.push(chunkOM7NOHJF_cjs.P("INVALID_DATETIME_OP","Cannot subtract a datetime from a value that is not a datetime")):t.push(chunkLCYQQFUH_cjs.u(n,e,(d,g)=>d-g,(d,g)=>d-g,"sub"));break}case 22:{let e=m(t),n=m(t),o=ht(n,e);if(o){t.push(o);break}if(n.uncertainty!==void 0||e.uncertainty!==void 0){let l=chunkLCYQQFUH_cjs.s(n,e,"mul");if(l){t.push(l);break}}if(n.rational!==void 0||e.rational!==void 0){let l=chunkLCYQQFUH_cjs.r(n,e,"mul");if(l){t.push(l);break}}let i=gt(n,e);if(i){t.push(i);break}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.n(n.value*e.value));else if(n.type===7&&e.type===7)chunkOM7NOHJF_cjs.d(ct(n.value,e.value),"matrix cells"),t.push(chunkYWF6C2IO_cjs._(n.value,e.value));else if(n.type===6&&chunkOM7NOHJF_cjs.x(n.unit)&&e.type===6&&e.unit)t.push(tn(n,e));else if(e.type===6&&chunkOM7NOHJF_cjs.x(e.unit)&&n.type===6&&n.unit)t.push(tn(e,n));else if(qn(n,e)!==null)t.push(qn(n,e));else {let l=Ze(n,e,!0);l?t.push(l):t.push(chunkLCYQQFUH_cjs.u(n,e,(d,g)=>d*g,(d,g)=>d*g,"mul"));}break}case 23:{let e=m(t),n=m(t),o=yt(n,e);if(o){t.push(o);break}if(n.uncertainty!==void 0||e.uncertainty!==void 0){let i=chunkLCYQQFUH_cjs.s(n,e,"div");if(i){t.push(i);break}}if(n.type===6&&e.type===6){let{lv:i,rv:l,sameMeasure:d}=chunkLCYQQFUH_cjs.j(n,e);if(d)t.push(chunkOM7NOHJF_cjs.n(i/l));else if(chunkDUFEONVN_cjs.c.isCurrency(n.unit)&&chunkDUFEONVN_cjs.c.isCurrency(e.unit))t.push(chunkOM7NOHJF_cjs.P("INCOMPATIBLE_UNITS",`Cannot combine incompatible units: ${n.unit} and ${e.unit}`));else {let g=Ze(n,e,!1);if(g){t.push(g);break}t.push(chunkOM7NOHJF_cjs.w(i/l,n.unit,e.unit));}}else {let i=chunkLCYQQFUH_cjs.r(n,e,"div");if(i){t.push(i);break}t.push(chunkLCYQQFUH_cjs.u(n,e,(l,d)=>l/d,(l,d)=>{if(d===0n)throw chunkLCYQQFUH_cjs.o();return l/d},"div"));}break}case 24:{let e=m(t),n=m(t);t.push(chunkLCYQQFUH_cjs.u(n,e,(o,i)=>o%i,(o,i)=>{if(i===0n)throw chunkLCYQQFUH_cjs.o();return o%i}));break}case 25:{let e=m(t),n=m(t);if(n.type===13){t.push(n);break}if(e.type===13){t.push(e);break}if(n.type===12){t.push(n);break}if(e.type===12){t.push(e);break}if(n.type===0&&e.type===0){t.push(chunkOM7NOHJF_cjs.n(chunkLCYQQFUH_cjs.q(n.value,e.value)));break}if(n.type===7||e.type===7){if(n.type!==7||e.type!==0){t.push(chunkOM7NOHJF_cjs.P("MATRIX_POWER_UNSUPPORTED",`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${chunkOM7NOHJF_cjs.g[n.type]} ^ ${chunkOM7NOHJF_cjs.g[e.type]}" has no matrix reading.`));break}chunkOM7NOHJF_cjs.d(mt(n.value,e.value),"matrix cells"),t.push(chunkYWF6C2IO_cjs.$(n.value,e.value));break}if(n.type===9||e.type===9){t.push(chunkLCYQQFUH_cjs.f(n,e));break}if(n.type===2||e.type===2){let o=kt(n,e.toNumber());if(o!==null){if(o>Se)throw chunkSUAGBRQ7_cjs.c.execution("BIGINT_POW_LIMIT_EXCEEDED",`That power would build an exact integer of about ${Math.round(o).toLocaleString("en-US")} bits, past the limit of ${Se.toLocaleString("en-US")} bits`,{limitBits:Se});t.push(chunkOM7NOHJF_cjs.s(_t(chunkLCYQQFUH_cjs.n(n),chunkLCYQQFUH_cjs.n(e))));break}}t.push(chunkOM7NOHJF_cjs.n(chunkLCYQQFUH_cjs.q(n.toNumber(),e.toNumber())));break}case 26:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}e.type===2?t.push(chunkOM7NOHJF_cjs.s(-e.value)):e.type===6&&e.exact!==void 0?t.push(chunkOM7NOHJF_cjs.v(-e.toNumber(),e.unit,chunkYWF6C2IO_cjs.ma(e.exact))):e.type===6?t.push(chunkOM7NOHJF_cjs.u(-e.toNumber(),e.unit)):e.type===5?t.push(chunkOM7NOHJF_cjs.N(-e.toNumber())):e.type===9?t.push(chunkLCYQQFUH_cjs.g(e)):e.type===0&&e.rational!==void 0?t.push(chunkOM7NOHJF_cjs.p(-e.toNumber(),chunkYWF6C2IO_cjs.j(e.rational))):e.type===0&&e.exact!==void 0?t.push(chunkOM7NOHJF_cjs.o(-e.toNumber(),chunkYWF6C2IO_cjs.ma(e.exact))):t.push(chunkOM7NOHJF_cjs.n(-e.toNumber()));break}case 27:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}e.type===6&&e.exact!==void 0?t.push(chunkOM7NOHJF_cjs.v(e.toNumber(),e.unit,e.exact)):e.type===6?t.push(chunkOM7NOHJF_cjs.u(e.toNumber(),e.unit)):e.type===5?t.push(chunkOM7NOHJF_cjs.N(e.toNumber())):e.type===0&&e.rational!==void 0?t.push(chunkOM7NOHJF_cjs.p(e.toNumber(),e.rational)):e.type===0&&e.exact!==void 0?t.push(chunkOM7NOHJF_cjs.o(e.toNumber(),e.exact)):t.push(chunkOM7NOHJF_cjs.n(e.toNumber()));break}case 28:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.q(n.toNumber(),Math.abs(e.toNumber())));break}case 30:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}n.type===2||e.type===2?t.push(nt(n,e,1)):t.push(chunkOM7NOHJF_cjs.n(n.toNumber()<<e.toNumber()));break}case 31:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}n.type===2||e.type===2?t.push(nt(n,e,-1)):t.push(chunkOM7NOHJF_cjs.n(n.toNumber()>>e.toNumber()));break}case 32:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.n(n.toNumber()>>>e.toNumber()));break}case 33:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}n.type===2||e.type===2?t.push(chunkOM7NOHJF_cjs.s(chunkLCYQQFUH_cjs.n(n)&chunkLCYQQFUH_cjs.n(e))):t.push(chunkOM7NOHJF_cjs.n(n.toNumber()&e.toNumber()));break}case 34:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}n.type===2||e.type===2?t.push(chunkOM7NOHJF_cjs.s(chunkLCYQQFUH_cjs.n(n)|chunkLCYQQFUH_cjs.n(e))):t.push(chunkOM7NOHJF_cjs.n(n.toNumber()|e.toNumber()));break}case 35:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}n.type===2||e.type===2?t.push(chunkOM7NOHJF_cjs.s(chunkLCYQQFUH_cjs.n(n)^chunkLCYQQFUH_cjs.n(e))):t.push(chunkOM7NOHJF_cjs.n(n.toNumber()^e.toNumber()));break}case 36:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}e.type===2?t.push(chunkOM7NOHJF_cjs.s(~e.value)):t.push(chunkOM7NOHJF_cjs.n(~e.toNumber()));break}case 40:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i===0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value===e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()===e.toNumber():i===0));}else if(n.type===3&&e.type===3)t.push(chunkOM7NOHJF_cjs.L(n.value===e.value));else if(n.type===6&&e.type===6){let{equal:i,sameMeasure:l}=chunkLCYQQFUH_cjs.k(n,e);t.push(chunkOM7NOHJF_cjs.L(l&&i));}else if(n.type===7&&e.type===7)t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i===l));else if(n.type===14||e.type===14)if(n.type===14&&e.type===14){let i=n.value,l=e.value;t.push(chunkOM7NOHJF_cjs.L(i.r===l.r&&i.g===l.g&&i.b===l.b&&i.a===l.a));}else t.push(chunkOM7NOHJF_cjs.L(!1));else t.push(chunkOM7NOHJF_cjs.L(n.toNumber()===e.toNumber()));break}case 41:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i!==0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value!==e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()!==e.toNumber():i!==0));}else if(n.type===3&&e.type===3)t.push(chunkOM7NOHJF_cjs.L(n.value!==e.value));else if(n.type===6&&e.type===6){let{equal:i,sameMeasure:l}=chunkLCYQQFUH_cjs.k(n,e);t.push(chunkOM7NOHJF_cjs.L(!l||!i));}else if(n.type===7&&e.type===7)t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i!==l));else if(n.type===14||e.type===14)if(n.type===14&&e.type===14){let i=n.value,l=e.value;t.push(chunkOM7NOHJF_cjs.L(!(i.r===l.r&&i.g===l.g&&i.b===l.b&&i.a===l.a)));}else t.push(chunkOM7NOHJF_cjs.L(!0));else t.push(chunkOM7NOHJF_cjs.L(n.toNumber()!==e.toNumber()));break}case 42:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i<0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value<e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()<e.toNumber():i<0));}else if(n.type===6&&e.type===6){let{lv:i,rv:l,equal:d,sameMeasure:g}=chunkLCYQQFUH_cjs.k(n,e);t.push(g?chunkOM7NOHJF_cjs.L(!d&&i<l):chunkLCYQQFUH_cjs.m(n,e));}else n.type===7&&e.type===7?t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i<l)):t.push(chunkOM7NOHJF_cjs.L(n.toNumber()<e.toNumber()));break}case 43:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i<=0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value<=e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()<=e.toNumber():i<=0));}else if(n.type===6&&e.type===6){let{lv:i,rv:l,equal:d,sameMeasure:g}=chunkLCYQQFUH_cjs.k(n,e);t.push(g?chunkOM7NOHJF_cjs.L(d||i<=l):chunkLCYQQFUH_cjs.m(n,e));}else n.type===7&&e.type===7?t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i<=l)):t.push(chunkOM7NOHJF_cjs.L(n.toNumber()<=e.toNumber()));break}case 44:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i>0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value>e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()>e.toNumber():i>0));}else if(n.type===6&&e.type===6){let{lv:i,rv:l,equal:d,sameMeasure:g}=chunkLCYQQFUH_cjs.k(n,e);t.push(g?chunkOM7NOHJF_cjs.L(!d&&i>l):chunkLCYQQFUH_cjs.m(n,e));}else n.type===7&&e.type===7?t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i>l)):t.push(chunkOM7NOHJF_cjs.L(n.toNumber()>e.toNumber()));break}case 45:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.rational!==void 0||e.rational!==void 0){let i=chunkLCYQQFUH_cjs.t(n,e);if(i!==null){t.push(chunkOM7NOHJF_cjs.L(i>=0));break}}if(n.type===0&&e.type===0)t.push(chunkOM7NOHJF_cjs.L(n.value>=e.value));else if(n.type===2||e.type===2){let i=chunkLCYQQFUH_cjs.p(n,e);t.push(chunkOM7NOHJF_cjs.L(i===null?n.toNumber()>=e.toNumber():i>=0));}else if(n.type===6&&e.type===6){let{lv:i,rv:l,equal:d,sameMeasure:g}=chunkLCYQQFUH_cjs.k(n,e);t.push(g?chunkOM7NOHJF_cjs.L(d||i>=l):chunkLCYQQFUH_cjs.m(n,e));}else n.type===7&&e.type===7?t.push(chunkYWF6C2IO_cjs.aa(n.value,e.value,(i,l)=>i>=l)):t.push(chunkOM7NOHJF_cjs.L(n.toNumber()>=e.toNumber()));break}case 130:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.L(ge(n)&&ge(e)));break}case 131:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.L(ge(n)||ge(e)));break}case 132:{let e=m(t),n=m(t),o=m(t),i=chunkOM7NOHJF_cjs.Q(o);if(i){t.push(i);break}t.push(ge(o)?n:e);break}case 50:case 161:{let e;if(f===161){let d=w(p,E++,f,"plugin-function index (low byte)"),g=w(p,E++,f,"plugin-function index (high byte)");e=d|g<<8;}else e=w(p,E++,f,"plugin-function index");let n=w(p,E++,f,"argument count"),o=[];for(let d=0;d<n;d++)o.push(m(t));o.reverse();let i=a.context.pluginFunctions[e],l=chunkOM7NOHJF_cjs.R(o);if(l)t.push(l);else if(!i)t.push(chunkOM7NOHJF_cjs.P("UNKNOWN_PLUGIN_FUNCTION",`Plugin function index ${e} is not registered with this engine`));else {let d=i(o,c);if(d instanceof Promise){if(!a.context.networkEnabled){d.catch(()=>{}),t.push(chunkOM7NOHJF_cjs.P("NETWORK_DISABLED","Live data is switched off for this engine (network.enabled is false), so the result of this call was not awaited"));break}let g=`plugin:${e}:${o.map(v=>`${v.type}:${String(v.value??"")}${v.unit?`:${v.unit}`:""}`).join("|")}`,I=a.activeSignal,U=a.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:g,resolver:d,packageId:U,signal:I}}t.push(d);}break}case 51:{let e=w(p,E++,f,"builtin-function index"),n=w(p,E++,f,"argument count"),o=Wn(e,n);if(o)throw o;let i=[],l=!1;for(let I=0;I<n;I++){let U=m(t);U.type===9&&(l=!0),i.push(U);}let d=chunkOM7NOHJF_cjs.R(i);if(d){t.push(d);break}let g=chunkLCYQQFUH_cjs.C[e];if(g){let I=i.reverse(),U=l&&!chunkLCYQQFUH_cjs.e.has(e);t.push(U?chunkLCYQQFUH_cjs.h(e,I):g(I));}else t.push(chunkOM7NOHJF_cjs.P("UNKNOWN_BUILTIN_FUNCTION",`Builtin function index ${e} is not registered`));break}case 150:{let e=w(p,E++,f,"function-body index"),n=T?.[e];if(!n)throw chunkSUAGBRQ7_cjs.c.internal("INTERNAL_MISSING_FUNCTION_BODY",`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${e}`,{bodyIdx:e});a.defineUserFunction(n.name,n.params,n.program);break}case 151:{let e=J(p,E++,x,f,"function-name index"),n=w(p,E++,f,"argument count"),o=[];for(let g=0;g<n;g++)o.push(m(t));o.reverse();let i=a.getUserFunction(e);if(!i)throw chunkSUAGBRQ7_cjs.c.execution("UNDEFINED_FUNCTION",`Undefined function: ${e}`,{name:e});if(n!==i.params.length)throw chunkSUAGBRQ7_cjs.c.execution("FUNCTION_ARITY_MISMATCH",`${e} expects ${i.params.length} argument(s) but got ${n}`,{name:e,expected:i.params.length,actual:n});let l=new Map;for(let g=0;g<i.params.length;g++)l.set(i.params[g],o[g]);chunkOM7NOHJF_cjs.f(),a.pushCallFrame(l);let d;try{d=an(i.program,a,s,u,c);}finally{a.popCallFrame();}if(d.type==="pending")throw chunkSUAGBRQ7_cjs.c.execution("USER_FUNCTION_ASYNC_UNSUPPORTED",`${e}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,{name:e});if(d.type==="error")throw d.error;t.push(d.value);break}case 60:{let e=J(p,E++,x,f,"variable-name index"),n=a.getVar(e);if(n!==void 0)t.push(n);else if(b)t.push(chunkOM7NOHJF_cjs.K(chunkYWF6C2IO_cjs.q(e)));else throw chunkSUAGBRQ7_cjs.c.execution("UNDEFINED_VARIABLE",`Undefined variable: ${e}`,{varName:e});break}case 61:{let e=m(t),n=J(p,E++,x,f,"variable-name index");a.setVar(n,X?chunkOM7NOHJF_cjs.k(e):e),t.push(e);break}case 62:{let e=J(p,E++,x,f,"variable-name index"),n=chunkLCYQQFUH_cjs.J.get(e);if(n===void 0)throw chunkSUAGBRQ7_cjs.c.internal({code:"GLOBAL_VARIABLE_NOT_RESOLVED",message:`Global variable "${e}" was read before it resolved`,expected:`global variable "${e}" to already be resolved (async preflight should guarantee this)`,found:"no value in the global variable store",context:{varName:e}});t.push(n);break}case 63:{let e=m(t),n=J(p,E++,x,f,"variable-name index");chunkLCYQQFUH_cjs.J.set(n,X?chunkOM7NOHJF_cjs.k(e):e),t.push(e);break}case 70:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.n(e.toNumber()));break}case 71:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}if(e.type===14){let o=e.value;t.push(chunkOM7NOHJF_cjs.G({r:o.r,g:o.g,b:o.b,a:o.a,format:"hex"}));break}t.push(chunkOM7NOHJF_cjs.r(e.type===2?e.value:e.toNumber()));break}case 74:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.N(e.toNumber()));break}case 140:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.t(e.rational!==void 0?Dt(e.rational):Mt(e.toNumber())));break}case 141:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.t(Tt(e)));break}case 142:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.t(St(e.toNumber())));break}case 143:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.r(e.type===2?e.value:e.toNumber(),"bin"));break}case 144:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.r(e.type===2?e.value:e.toNumber(),"oct"));break}case 145:{let e=q(m(t),f,"converter name").toLowerCase(),n=m(t),o=chunkOM7NOHJF_cjs.Q(n);if(o){t.push(o);break}let i=chunkLCYQQFUH_cjs.G.get(e);i?t.push(i(n,c)):t.push(chunkOM7NOHJF_cjs.P("UNKNOWN_AS_CONVERTER",`Unknown converter "as ${e}"`));break}case 80:{let e=q(m(t),f,"unit name"),n=m(t),o=chunkOM7NOHJF_cjs.Q(n);if(o){t.push(o);break}let i=chunkLCYQQFUH_cjs.a(n,e);i?t.push(chunkOM7NOHJF_cjs.v(n.toNumber(),e,i)):t.push(chunkOM7NOHJF_cjs.u(n.toNumber(),e));break}case 81:{let e=q(m(t),f,"target unit name"),n=q(m(t),f,"source unit name"),o=m(t),i=chunkOM7NOHJF_cjs.Q(o);if(i){t.push(i);break}let l=o.toNumber(),d=chunkPHWIO4P3_cjs.c(n),g=chunkDUFEONVN_cjs.c.isCurrency(n)&&chunkDUFEONVN_cjs.c.isCurrency(e);if(d&&chunkPHWIO4P3_cjs.c(e)===d)t.push(chunkOM7NOHJF_cjs.u(chunkPHWIO4P3_cjs.e(l,n,e),e));else if(g){let I=chunkDUFEONVN_cjs.c.convertSync(l,n,e);I!==null?t.push(chunkOM7NOHJF_cjs.u(I,e)):t.push(Gn(a,n,e));}else {let I=chunkPHWIO4P3_cjs.k(l,n,e);I!==null?t.push(chunkOM7NOHJF_cjs.u(I,e)):t.push(Qn(n,e));}break}case 85:{let e=q(m(t),f,"unit name"),n=chunkPHWIO4P3_cjs.f(e);t.push(chunkOM7NOHJF_cjs.t(n.length>0?n.join(", "):`No known units for "${e}"`));break}case 83:{let e=q(m(t),f,"unit name"),n=m(t),o=chunkOM7NOHJF_cjs.Q(n);if(o){t.push(o);break}let{value:i,unit:l}=chunkPHWIO4P3_cjs.h(n.toNumber(),e);t.push(chunkOM7NOHJF_cjs.u(i,l));break}case 84:{let e=q(m(t),f,"target unit name"),n=m(t),o=chunkOM7NOHJF_cjs.Q(n);if(o){t.push(o);break}if(n.type===6){let i=n.unit,l=n.toNumber(),d=chunkPHWIO4P3_cjs.c(i),g=chunkDUFEONVN_cjs.c.isCurrency(i)&&chunkDUFEONVN_cjs.c.isCurrency(e);if(d&&chunkPHWIO4P3_cjs.c(e)===d)t.push(chunkOM7NOHJF_cjs.u(chunkPHWIO4P3_cjs.e(l,i,e),e));else if(g){let I=chunkDUFEONVN_cjs.c.convertSync(l,i,e);I!==null?t.push(chunkOM7NOHJF_cjs.u(I,e)):t.push(Gn(a,i,e));}else {let I=chunkPHWIO4P3_cjs.k(l,i,e);I!==null?t.push(chunkOM7NOHJF_cjs.u(I,e)):t.push(Qn(i,e));}}else n.type===4?t.push(It(n,e,a)):t.push(chunkOM7NOHJF_cjs.u(n.toNumber(),e));break}case 82:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}t.push(chunkOM7NOHJF_cjs.n(e.toNumber()));break}case 110:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(e.type!==6||!e.unit){t.push(chunkOM7NOHJF_cjs.P("RATE_MISSING_DENOMINATOR_UNIT",'Cannot build a rate: the right-hand side of "/" has no unit'));break}let i=n.type===6?n.unit??"":"";t.push(chunkOM7NOHJF_cjs.w(n.toNumber()/e.toNumber(),i,e.unit));break}case 111:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.type!==6||!chunkOM7NOHJF_cjs.x(n.unit)){t.push(chunkOM7NOHJF_cjs.P("RATE_MUL_LEFT_NOT_A_RATE",'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));break}if(e.type!==6||!e.unit){t.push(chunkOM7NOHJF_cjs.P("RATE_MUL_RIGHT_MISSING_UNIT","Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));break}t.push(tn(n,e));break}case 112:{let e=q(m(t),f,"denominator unit name"),n=m(t),o=chunkOM7NOHJF_cjs.Q(n);if(o){t.push(o);break}if(n.type!==6||!chunkOM7NOHJF_cjs.x(n.unit)){t.push(chunkOM7NOHJF_cjs.P("RATE_CONVERT_NOT_A_RATE","Cannot convert a non-rate value's denominator"));break}let{numerator:i,denominator:l}=chunkOM7NOHJF_cjs.y(n.unit),d=chunkPHWIO4P3_cjs.c(l),g=chunkPHWIO4P3_cjs.c(e);if(!d||d!==g){t.push(chunkOM7NOHJF_cjs.P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${l}"-denominated rate to "${e}" \u2014 different measures`));break}let I=chunkPHWIO4P3_cjs.e(1,e,l);t.push(chunkOM7NOHJF_cjs.w(n.toNumber()*I,i,e));break}case 120:{let e=m(t),n=chunkOM7NOHJF_cjs.Q(e);if(n){t.push(n);break}let o=e.toNumber(),i=a.context.calendar,l=i.fields(i.now());t.push(chunkOM7NOHJF_cjs.M(i.localWallClock(l.year,l.month0,l.day,o),"datetime"));break}case 90:t.push(chunkOM7NOHJF_cjs.M(a.context.calendar.now(),"instant"));break;case 95:t.push(chunkOM7NOHJF_cjs.M(y[Qe(p,E++,f,"constant-pool index",y.length,"number-pool")],"date"));break;case 91:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.M(he(n.toNumber(),e,1,a),n.grain,n.zone));break}case 92:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}t.push(chunkOM7NOHJF_cjs.M(he(n.toNumber(),e,-1,a),n.grain,n.zone));break}case 96:{let e=w(p,E++,f,"workday offset direction")===1?-1:1,n=m(t),o=m(t),i=chunkOM7NOHJF_cjs.Q(o,n);if(i){t.push(i);break}if(n.type!==4){t.push(chunkOM7NOHJF_cjs.P(chunkSUAGBRQ7_cjs.r.WORKDAY_OFFSET_EXPECTED_DATE,`"working days after/before/from" expects a date to count from, got ${chunkOM7NOHJF_cjs.g[n.type]??"an unsupported value"}`));break}t.push(chunkOM7NOHJF_cjs.M(at(n.toNumber(),e*o.toNumber(),a)));break}case 97:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.type!==4||e.type!==4){t.push(chunkOM7NOHJF_cjs.P(chunkSUAGBRQ7_cjs.r.WORKDAYS_BETWEEN_EXPECTED_DATES,`"working days between" expects two dates, got ${chunkOM7NOHJF_cjs.g[n.type]??"an unsupported value"} and ${chunkOM7NOHJF_cjs.g[e.type]??"an unsupported value"}`));break}let i=Math.ceil((a.getMaxDateOffsetYears()-a.getMinDateOffsetYears())*366),l=Yn(n.toNumber(),e.toNumber(),d=>a.isHoliday(d),i,a.context.calendar);if(l===null){t.push(chunkOM7NOHJF_cjs.P(chunkSUAGBRQ7_cjs.r.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,`The two dates are more than ${a.getMaxDateOffsetYears()-a.getMinDateOffsetYears()} years apart, past the working-day count's limit`));break}t.push(chunkOM7NOHJF_cjs.n(l));break}case 93:case 94:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}let i=e.toNumber(),l=n.toNumber(),d=a.context.calendar.fields(l).weekday,g=f===93?(i-d+7)%7:(d-i+7)%7;g===0&&(g=7),t.push(chunkOM7NOHJF_cjs.M(rt(l,f===93?g:-g,a.context.calendar)));break}case 152:{let e=w(p,E++,f,"row count"),n=w(p,E++,f,"column count"),o=e*n,i=chunkOM7NOHJF_cjs.e(o,"matrix cells"),l=null;for(let d=o-1;d>=0;d--){let g=m(t);l===null&&(l=chunkOM7NOHJF_cjs.Q(g)),i[d]=g.type===10||g.type===9?g.value:g.toNumber();}if(l){t.push(l);break}t.push(chunkOM7NOHJF_cjs.C(e,n,chunkYWF6C2IO_cjs.Y(e,n,i)));break}case 153:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.type!==7){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let i=n.value,l=Math.trunc(e.toNumber());if(l<0||l>=i.data.length){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_OUT_OF_BOUNDS",`Index ${l} is out of bounds for a ${i.rows}x${i.cols} matrix (valid range: 0-${i.data.length-1}).`));break}let d=chunkYWF6C2IO_cjs.S(i,l);t.push(chunkYWF6C2IO_cjs.X(d));break}case 154:{let e=m(t),n=m(t),o=m(t),i=chunkOM7NOHJF_cjs.Q(o,n,e);if(i){t.push(i);break}if(o.type!==7){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let l=o.value,d=Math.trunc(n.toNumber()),g=Math.trunc(e.toNumber());if(!chunkYWF6C2IO_cjs.U(l,d,g)){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${d}, ${g}] is out of bounds for a ${l.rows}x${l.cols} matrix.`));break}let I=chunkYWF6C2IO_cjs.T(l,d,g);t.push(chunkYWF6C2IO_cjs.X(I));break}case 156:{let e=m(t),n=m(t),o=chunkOM7NOHJF_cjs.Q(n,e);if(o){t.push(o);break}if(n.type!==0||e.type!==0){t.push(chunkOM7NOHJF_cjs.P("INVALID_RANGE_BOUND",`A range's bounds must be plain numbers (e.g. "0:3").`));break}let i=n.value,l=e.value;if(!Number.isInteger(i)||!Number.isInteger(l)){t.push(chunkOM7NOHJF_cjs.P("NON_INTEGER_RANGE_BOUND",`A range's bounds must be whole numbers, got "${i}:${l}".`));break}if(i>l){t.push(chunkOM7NOHJF_cjs.P("DESCENDING_RANGE",`A range's min (${i}) cannot be greater than its max (${l}) \u2014 did you mean "${l}:${i}"?`));break}t.push(chunkOM7NOHJF_cjs.F(i,l));break}case 155:{let e=m(t),n=m(t),o=m(t),i=chunkOM7NOHJF_cjs.Q(o,n,e);if(i){t.push(i);break}if(o.type!==7){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot slice a non-matrix value with "[...]".'));break}if(n.type!==8||e.type!==8){t.push(chunkOM7NOHJF_cjs.P("INVALID_MATRIX_SLICE_BOUND",'Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").'));break}let l=o.value,d=n.value,g=e.value;if(d.min<0||d.max>=l.rows||g.min<0||g.max>=l.cols){t.push(chunkOM7NOHJF_cjs.P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${d.min}:${d.max}, ${g.min}:${g.max}] is out of bounds for a ${l.rows}x${l.cols} matrix.`));break}let I=d.max-d.min+1,U=g.max-g.min+1,v=chunkOM7NOHJF_cjs.e(I*U,"matrix cells");for(let B=0;B<I;B++)for(let M=0;M<U;M++)v[B+M*I]=chunkYWF6C2IO_cjs.T(l,d.min+B,g.min+M);t.push(chunkOM7NOHJF_cjs.C(I,U,v));break}case 157:{let e=w(p,E++,f,"body kind"),n=w(p,E++,f,"body reference"),o=w(p,E++,f,"collection count");Xn(e,n,f);let i=new Array(o);for(let D=o-1;D>=0;D--)i[D]=m(t);let l=[],d;if(e===0){let D=O?.[n];if(!D)throw chunkSUAGBRQ7_cjs.c.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: MAP_INVOKE referenced missing anonymous body index ${n}`,{ref:n});l=D.params,d=D.program;}else if(e===2){let D=Te(x,n,f),R=a.getUserFunction(D);if(!R){t.push(chunkOM7NOHJF_cjs.P("UNDEFINED_FUNCTION",`map: undefined function "${D}"`));break}if(R.params.length!==o){t.push(chunkOM7NOHJF_cjs.P("FUNCTION_ARITY_MISMATCH",`map: "${D}" expects ${R.params.length} argument(s) but ${o} collection(s) were given`));break}l=R.params,d=R.program;}let g=-1,I=new Array(o),U;for(let D=0;D<o;D++){let R=chunkYWF6C2IO_cjs.ea(i[D],a.getMaxCollectionSize());if(!Array.isArray(R)){U=R;break}if(chunkOM7NOHJF_cjs.c(R.length,"collection elements"),g===-1)g=R.length;else if(R.length!==g){U=chunkOM7NOHJF_cjs.P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${g} and ${R.length}).`);break}I[D]=R;}if(U){t.push(U);break}let v=chunkOM7NOHJF_cjs.e(g,"matrix cells"),B;for(let D=0;D<g;D++){let R=new Array(o);for(let ye=0;ye<o;ye++)R[ye]=I[ye][D];let re=e===1?chunkLCYQQFUH_cjs.C[n]?.(R)??chunkOM7NOHJF_cjs.P("UNKNOWN_BUILTIN_FUNCTION",`map: unknown builtin function index ${n}`):en(l,d,R,a,s,u,c,!!b),rn=chunkOM7NOHJF_cjs.Q(re);if(rn){B=rn;break}v[D]=re.type===10||re.type===9?re.value:re.toNumber();}if(B){t.push(B);break}let M=i[0],V=M?.type===7?M.value:void 0;V&&V.rows*V.cols===g?t.push(chunkOM7NOHJF_cjs.C(V.rows,V.cols,v)):t.push(chunkOM7NOHJF_cjs.C(1,g,v));break}case 160:{let e=w(p,E++,f,"plot body reference"),n=w(p,E++,f,"plot expression"),o=Te(x,n,f),i=m(t).toNumber(),l=m(t).toNumber(),d=O?.[e];if(!d)throw chunkSUAGBRQ7_cjs.c.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: PLOT_INVOKE referenced missing anonymous body index ${e}`,{ref:e});if(!Number.isFinite(l)||!Number.isFinite(i)){t.push(chunkOM7NOHJF_cjs.P("PLOT_INVALID_RANGE",`plot: the range bounds must be finite numbers (got ${l} to ${i})`));break}let g=[];for(let M=0;M<Kn;M++){let V=l+M/(Kn-1)*(i-l),D;try{D=en(d.params,d.program,[chunkOM7NOHJF_cjs.n(V)],a,s,u,c,!!b).toNumber();}catch{continue}Number.isFinite(D)&&g.push([V,D]);}let I=g.map(M=>M[1]),U=I.length?Math.min(...I):0,v=I.length?Math.max(...I):0,B=M=>Number.isInteger(M)?String(M):String(Number(M.toFixed(2)));t.push(chunkOM7NOHJF_cjs.I({kind:"plot",points:g,label:`${o} over [${B(l)}, ${B(i)}]`,domain:[l,i],range:[U,v],expr:o}));break}case 158:{let e=w(p,E++,f,"body kind"),n=w(p,E++,f,"body reference"),o=w(p,E++,f,"initial-value flag");Xn(e,n,f);let i=o?m(t):void 0,l=m(t),d=[],g;if(e===0){let M=O?.[n];if(!M)throw chunkSUAGBRQ7_cjs.c.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${n}`,{ref:n});d=M.params,g=M.program;}else if(e===2){let M=Te(x,n,f),V=a.getUserFunction(M);if(!V){t.push(chunkOM7NOHJF_cjs.P("UNDEFINED_FUNCTION",`reduce: undefined function "${M}"`));break}if(V.params.length!==2){t.push(chunkOM7NOHJF_cjs.P("FUNCTION_ARITY_MISMATCH",`reduce: "${M}" must take exactly 2 arguments (accumulator, element), got ${V.params.length}`));break}d=V.params,g=V.program;}let I=chunkYWF6C2IO_cjs.ea(l,a.getMaxCollectionSize());if(!Array.isArray(I)){t.push(I);break}chunkOM7NOHJF_cjs.c(I.length,"collection elements");let U,v;if(i!==void 0){let M=chunkOM7NOHJF_cjs.Q(i);if(M){t.push(M);break}U=i,v=0;}else {if(I.length===0){t.push(chunkOM7NOHJF_cjs.P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}U=I[0],v=1;}let B;for(let M=v;M<I.length;M++){let V=[U,I[M]],D=e===1?chunkLCYQQFUH_cjs.C[n]?.(V)??chunkOM7NOHJF_cjs.P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${n}`):en(d,g,V,a,s,u,c,!!b),R=chunkOM7NOHJF_cjs.Q(D);if(R){B=R;break}U=D;}if(B){t.push(B);break}t.push(U);break}case 159:{let e=w(p,E++,f,"body reference"),n=O?.[e];if(!n)throw chunkSUAGBRQ7_cjs.c.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${e}`,{ref:e});t.push(bt(n.params[0],n.program,a,s,u,c,!!b));break}}}let K=m(t);return {type:"value",value:X?chunkOM7NOHJF_cjs.k(K):K}}catch(K){return {type:"error",error:chunkSUAGBRQ7_cjs.d(K)}}finally{chunkOM7NOHJF_cjs.b();}}exports.a=Bn;exports.b=Ln;exports.c=la;exports.d=an;//# sourceMappingURL=chunk-UNKZ5XRC.cjs.map
2
- //# sourceMappingURL=chunk-UNKZ5XRC.cjs.map