solve-engine 2.25.0 → 2.27.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 (240) hide show
  1. package/dist/CalendarBackend-MdS3Bb4P.d.cts +181 -0
  2. package/dist/CalendarBackend-MdS3Bb4P.d.ts +181 -0
  3. package/dist/{Configuration-DnzYPmoK.d.cts → Configuration-BxriK9Kw.d.cts} +63 -4
  4. package/dist/{Configuration-DnzYPmoK.d.ts → Configuration-BxriK9Kw.d.ts} +63 -4
  5. package/dist/DateCalendar-B85t6Vk6.d.ts +90 -0
  6. package/dist/DateCalendar-CUGI1fT4.d.cts +90 -0
  7. package/dist/{EngineError-fR1K1rvx.d.cts → EngineError-C-kBwYlN.d.cts} +31 -4
  8. package/dist/{EngineError-fR1K1rvx.d.ts → EngineError-C-kBwYlN.d.ts} +31 -4
  9. package/dist/{FormattingSettings-bRKjU7wI.d.ts → FormattingSettings-ByO-4wiM.d.cts} +14 -0
  10. package/dist/{FormattingSettings-bRKjU7wI.d.cts → FormattingSettings-CvCzAfsz.d.ts} +14 -0
  11. package/dist/{Lexer-aB95pjoX.d.cts → Lexer-DhGhoAa2.d.cts} +13 -3
  12. package/dist/{Lexer-Bmctxl0n.d.ts → Lexer-DqtnZMC5.d.ts} +13 -3
  13. package/dist/{PackageCompatibility-CUVg8tmt.d.cts → PackageCompatibility-CNiTtC6S.d.cts} +1 -1
  14. package/dist/{PackageCompatibility-BludTs7v.d.ts → PackageCompatibility-fj_f7uqC.d.ts} +1 -1
  15. package/dist/{PackageRegistry-Dvn4i2QK.d.cts → PackageRegistry-BHBCFswo.d.cts} +328 -14
  16. package/dist/{PackageRegistry-DT-x32OM.d.ts → PackageRegistry-CNZUwWHJ.d.ts} +328 -14
  17. package/dist/{Parselet-BawfGuTF.d.cts → Parselet-DF3864la.d.cts} +19 -3
  18. package/dist/{Parselet-DqTbbtWA.d.ts → Parselet-Dgymjxzd.d.ts} +19 -3
  19. package/dist/{Token-CbP_OutD.d.cts → Token-D8f7yaz1.d.cts} +17 -0
  20. package/dist/{Token-CbP_OutD.d.ts → Token-D8f7yaz1.d.ts} +17 -0
  21. package/dist/{TokenNormalizer-CLBtiE8M.d.ts → TokenNormalizer-IF7nPRMp.d.ts} +1 -1
  22. package/dist/{TokenNormalizer-CjTDmHgB.d.cts → TokenNormalizer-Pe3_390t.d.cts} +1 -1
  23. package/dist/{ScopeManager-B636am7Y.d.ts → VMBuiltins-CZiZRKn-.d.ts} +91 -9
  24. package/dist/{ScopeManager-CdwX0VTw.d.cts → VMBuiltins-kv4rr0y5.d.cts} +91 -9
  25. package/dist/{VMCheckpoints-DDlxNssY.d.ts → VMCheckpoints-DXze6ypg.d.ts} +2 -2
  26. package/dist/{VMCheckpoints-CYqeq8IV.d.cts → VMCheckpoints-yun4ocSv.d.cts} +2 -2
  27. package/dist/{Value-Ds3Gy07C.d.cts → Value-BYHw-x7q.d.cts} +57 -1
  28. package/dist/{Value-Ds3Gy07C.d.ts → Value-BYHw-x7q.d.ts} +57 -1
  29. package/dist/{WorkerError-B1dF3VYT.d.cts → WorkerError-BLZyNq6M.d.cts} +1 -1
  30. package/dist/{WorkerError-dneODN-u.d.ts → WorkerError-CfBJYueR.d.ts} +1 -1
  31. package/dist/chunk-2SYYKQ4Q.cjs +2 -0
  32. package/dist/chunk-2SYYKQ4Q.cjs.map +1 -0
  33. package/dist/chunk-6EYKVQT3.cjs +2 -0
  34. package/dist/chunk-6EYKVQT3.cjs.map +1 -0
  35. package/dist/chunk-7RC6RBS6.cjs +2 -0
  36. package/dist/chunk-7RC6RBS6.cjs.map +1 -0
  37. package/dist/chunk-AZX4NTYN.cjs +3 -0
  38. package/dist/chunk-AZX4NTYN.cjs.map +1 -0
  39. package/dist/{chunk-JFZ5SLF7.js → chunk-BCR53EIL.js} +2 -2
  40. package/dist/{chunk-JFZ5SLF7.js.map → chunk-BCR53EIL.js.map} +1 -1
  41. package/dist/chunk-BCY2WY5P.js +5 -0
  42. package/dist/chunk-BCY2WY5P.js.map +1 -0
  43. package/dist/chunk-BLJ6E577.js +2 -0
  44. package/dist/chunk-BLJ6E577.js.map +1 -0
  45. package/dist/chunk-CL7DM2FX.js +2 -0
  46. package/dist/chunk-CL7DM2FX.js.map +1 -0
  47. package/dist/{chunk-BMXYR5LI.cjs → chunk-CQLCTKMX.cjs} +2 -2
  48. package/dist/{chunk-BMXYR5LI.cjs.map → chunk-CQLCTKMX.cjs.map} +1 -1
  49. package/dist/chunk-D4VBWPWN.js +2 -0
  50. package/dist/chunk-D4VBWPWN.js.map +1 -0
  51. package/dist/chunk-DFMAZ6XM.cjs +3 -0
  52. package/dist/chunk-DFMAZ6XM.cjs.map +1 -0
  53. package/dist/chunk-E4HAKNBQ.cjs +2 -0
  54. package/dist/chunk-E4HAKNBQ.cjs.map +1 -0
  55. package/dist/{chunk-XHQYHXRE.js → chunk-ESZNJQ2C.js} +3 -3
  56. package/dist/{chunk-XHQYHXRE.js.map → chunk-ESZNJQ2C.js.map} +1 -1
  57. package/dist/{chunk-IJMNVBIS.js → chunk-FAO6DQ74.js} +2 -2
  58. package/dist/chunk-FAO6DQ74.js.map +1 -0
  59. package/dist/{chunk-WGP4UUO5.cjs → chunk-FDKTESBC.cjs} +2 -2
  60. package/dist/{chunk-WGP4UUO5.cjs.map → chunk-FDKTESBC.cjs.map} +1 -1
  61. package/dist/{chunk-NEGZZB7F.cjs → chunk-G2V33LFM.cjs} +2 -2
  62. package/dist/{chunk-NEGZZB7F.cjs.map → chunk-G2V33LFM.cjs.map} +1 -1
  63. package/dist/chunk-GJZIJK2Q.cjs +2 -0
  64. package/dist/chunk-GJZIJK2Q.cjs.map +1 -0
  65. package/dist/chunk-GVL3ZMS7.cjs +2 -0
  66. package/dist/chunk-GVL3ZMS7.cjs.map +1 -0
  67. package/dist/{chunk-YBQPEWT7.cjs → chunk-GXO7TSXQ.cjs} +3 -3
  68. package/dist/chunk-GXO7TSXQ.cjs.map +1 -0
  69. package/dist/{chunk-OONQ3V3I.js → chunk-HANGBVEE.js} +2 -2
  70. package/dist/{chunk-OONQ3V3I.js.map → chunk-HANGBVEE.js.map} +1 -1
  71. package/dist/chunk-J4K72CQN.js +2 -0
  72. package/dist/chunk-J4K72CQN.js.map +1 -0
  73. package/dist/{chunk-72PYPENZ.js → chunk-LE6WZLJ4.js} +2 -2
  74. package/dist/{chunk-72PYPENZ.js.map → chunk-LE6WZLJ4.js.map} +1 -1
  75. package/dist/chunk-LQIRBP4Q.js +2 -0
  76. package/dist/chunk-LQIRBP4Q.js.map +1 -0
  77. package/dist/{chunk-RDYXH7ML.js → chunk-LTUYWJGO.js} +2 -2
  78. package/dist/{chunk-RDYXH7ML.js.map → chunk-LTUYWJGO.js.map} +1 -1
  79. package/dist/chunk-O5PO4D2A.cjs +2 -0
  80. package/dist/chunk-O5PO4D2A.cjs.map +1 -0
  81. package/dist/chunk-PQFI55AC.js +3 -0
  82. package/dist/chunk-PQFI55AC.js.map +1 -0
  83. package/dist/chunk-QQHHZPEW.cjs +2 -0
  84. package/dist/chunk-QQHHZPEW.cjs.map +1 -0
  85. package/dist/chunk-REZQFPVX.js +2 -0
  86. package/dist/chunk-REZQFPVX.js.map +1 -0
  87. package/dist/chunk-RRUGQ6DM.js +2 -0
  88. package/dist/chunk-RRUGQ6DM.js.map +1 -0
  89. package/dist/chunk-S3ODNMJS.js +2 -0
  90. package/dist/chunk-S3ODNMJS.js.map +1 -0
  91. package/dist/{chunk-SAF3B3AX.cjs → chunk-SE6ZCGZ5.cjs} +2 -2
  92. package/dist/{chunk-SAF3B3AX.cjs.map → chunk-SE6ZCGZ5.cjs.map} +1 -1
  93. package/dist/chunk-TC23XEAV.js +2 -0
  94. package/dist/chunk-TC23XEAV.js.map +1 -0
  95. package/dist/{chunk-FYAMQFZZ.cjs → chunk-TMQ37JQY.cjs} +3 -3
  96. package/dist/{chunk-FYAMQFZZ.cjs.map → chunk-TMQ37JQY.cjs.map} +1 -1
  97. package/dist/chunk-TPPM4QSS.cjs +2 -0
  98. package/dist/chunk-TPPM4QSS.cjs.map +1 -0
  99. package/dist/chunk-UVHD7BBC.js +3 -0
  100. package/dist/{chunk-ZDCZ5IDD.js.map → chunk-UVHD7BBC.js.map} +1 -1
  101. package/dist/{chunk-57PSJQQW.js → chunk-VB6QMU2W.js} +3 -3
  102. package/dist/chunk-VB6QMU2W.js.map +1 -0
  103. package/dist/chunk-VQO54ZMA.js +2 -0
  104. package/dist/chunk-VQO54ZMA.js.map +1 -0
  105. package/dist/{chunk-7DP57BA7.js → chunk-Y7XRA2EV.js} +2 -2
  106. package/dist/{chunk-7DP57BA7.js.map → chunk-Y7XRA2EV.js.map} +1 -1
  107. package/dist/{chunk-5IJD5L3O.cjs → chunk-YBQOQTVL.cjs} +2 -2
  108. package/dist/chunk-YBQOQTVL.cjs.map +1 -0
  109. package/dist/{chunk-EL2XUOWX.js → chunk-YG7UWQFV.js} +2 -2
  110. package/dist/{chunk-EL2XUOWX.js.map → chunk-YG7UWQFV.js.map} +1 -1
  111. package/dist/chunk-YSHWNCDH.cjs +5 -0
  112. package/dist/chunk-YSHWNCDH.cjs.map +1 -0
  113. package/dist/chunk-ZC2NPRLO.js +3 -0
  114. package/dist/chunk-ZC2NPRLO.js.map +1 -0
  115. package/dist/{chunk-FYTB7SDP.cjs → chunk-ZDJTDFTR.cjs} +2 -2
  116. package/dist/{chunk-FYTB7SDP.cjs.map → chunk-ZDJTDFTR.cjs.map} +1 -1
  117. package/dist/chunk-ZE5KKMBV.cjs +2 -0
  118. package/dist/chunk-ZE5KKMBV.cjs.map +1 -0
  119. package/dist/{chunk-4BAUQE6A.cjs → chunk-ZPHUTCJ5.cjs} +3 -3
  120. package/dist/{chunk-4BAUQE6A.cjs.map → chunk-ZPHUTCJ5.cjs.map} +1 -1
  121. package/dist/{chunk-GBCN7FNV.cjs → chunk-ZSLVLMO5.cjs} +2 -2
  122. package/dist/{chunk-GBCN7FNV.cjs.map → chunk-ZSLVLMO5.cjs.map} +1 -1
  123. package/dist/constants.cjs +1 -1
  124. package/dist/constants.d.cts +1 -1
  125. package/dist/constants.d.ts +1 -1
  126. package/dist/constants.js +1 -1
  127. package/dist/engine.cjs +1 -1
  128. package/dist/engine.d.cts +14 -12
  129. package/dist/engine.d.ts +14 -12
  130. package/dist/engine.js +1 -1
  131. package/dist/errors.cjs +1 -1
  132. package/dist/errors.d.cts +3 -3
  133. package/dist/errors.d.ts +3 -3
  134. package/dist/errors.js +1 -1
  135. package/dist/format.cjs +1 -1
  136. package/dist/format.d.cts +4 -3
  137. package/dist/format.d.ts +4 -3
  138. package/dist/format.js +1 -1
  139. package/dist/index.cjs +1 -1
  140. package/dist/index.cjs.map +1 -1
  141. package/dist/index.d.cts +15 -13
  142. package/dist/index.d.ts +15 -13
  143. package/dist/index.js +1 -1
  144. package/dist/index.js.map +1 -1
  145. package/dist/language.d.cts +12 -11
  146. package/dist/language.d.ts +12 -11
  147. package/dist/lexer.cjs +1 -1
  148. package/dist/lexer.d.cts +4 -4
  149. package/dist/lexer.d.ts +4 -4
  150. package/dist/lexer.js +1 -1
  151. package/dist/normalizer.cjs +1 -1
  152. package/dist/normalizer.d.cts +3 -3
  153. package/dist/normalizer.d.ts +3 -3
  154. package/dist/normalizer.js +1 -1
  155. package/dist/packages.cjs +1 -1
  156. package/dist/packages.d.cts +11 -10
  157. package/dist/packages.d.ts +11 -10
  158. package/dist/packages.js +1 -1
  159. package/dist/parser.cjs +1 -1
  160. package/dist/parser.d.cts +5 -4
  161. package/dist/parser.d.ts +5 -4
  162. package/dist/parser.js +1 -1
  163. package/dist/{pipeline-69q2tsLE.d.cts → pipeline-BYkKNpql.d.cts} +1 -1
  164. package/dist/{pipeline-DTqGLPsV.d.ts → pipeline-Cl7KW8CB.d.ts} +1 -1
  165. package/dist/resolvers.d.cts +2 -2
  166. package/dist/resolvers.d.ts +2 -2
  167. package/dist/temporal.cjs +2 -0
  168. package/dist/temporal.cjs.map +1 -0
  169. package/dist/temporal.d.cts +201 -0
  170. package/dist/temporal.d.ts +201 -0
  171. package/dist/temporal.js +2 -0
  172. package/dist/temporal.js.map +1 -0
  173. package/dist/testing.cjs +2 -2
  174. package/dist/testing.cjs.map +1 -1
  175. package/dist/testing.d.cts +12 -11
  176. package/dist/testing.d.ts +12 -11
  177. package/dist/testing.js +1 -1
  178. package/dist/testing.js.map +1 -1
  179. package/dist/uom.cjs +1 -1
  180. package/dist/uom.d.cts +2 -2
  181. package/dist/uom.d.ts +2 -2
  182. package/dist/uom.js +1 -1
  183. package/dist/vm.cjs +1 -1
  184. package/dist/vm.cjs.map +1 -1
  185. package/dist/vm.d.cts +8 -56
  186. package/dist/vm.d.ts +8 -56
  187. package/dist/vm.js +1 -1
  188. package/dist/vm.js.map +1 -1
  189. package/dist/worker.cjs +2 -2
  190. package/dist/worker.cjs.map +1 -1
  191. package/dist/worker.d.cts +35 -13
  192. package/dist/worker.d.ts +35 -13
  193. package/dist/worker.js +2 -2
  194. package/dist/worker.js.map +1 -1
  195. package/package.json +12 -1
  196. package/dist/chunk-4BRTUFTH.js +0 -2
  197. package/dist/chunk-4BRTUFTH.js.map +0 -1
  198. package/dist/chunk-4NZXCHQL.cjs +0 -2
  199. package/dist/chunk-4NZXCHQL.cjs.map +0 -1
  200. package/dist/chunk-57PSJQQW.js.map +0 -1
  201. package/dist/chunk-5IJD5L3O.cjs.map +0 -1
  202. package/dist/chunk-634ILVMP.cjs +0 -2
  203. package/dist/chunk-634ILVMP.cjs.map +0 -1
  204. package/dist/chunk-63ZOOUOL.js +0 -2
  205. package/dist/chunk-63ZOOUOL.js.map +0 -1
  206. package/dist/chunk-77KI7AKJ.cjs +0 -2
  207. package/dist/chunk-77KI7AKJ.cjs.map +0 -1
  208. package/dist/chunk-7N3IJSWF.js +0 -5
  209. package/dist/chunk-7N3IJSWF.js.map +0 -1
  210. package/dist/chunk-DUYTXLO2.js +0 -2
  211. package/dist/chunk-DUYTXLO2.js.map +0 -1
  212. package/dist/chunk-IJMNVBIS.js.map +0 -1
  213. package/dist/chunk-JSM3O7EM.cjs +0 -2
  214. package/dist/chunk-JSM3O7EM.cjs.map +0 -1
  215. package/dist/chunk-MZMA32NE.js +0 -3
  216. package/dist/chunk-MZMA32NE.js.map +0 -1
  217. package/dist/chunk-N4SSR7Q6.js +0 -2
  218. package/dist/chunk-N4SSR7Q6.js.map +0 -1
  219. package/dist/chunk-NMU5E7W7.js +0 -2
  220. package/dist/chunk-NMU5E7W7.js.map +0 -1
  221. package/dist/chunk-OB2VX4IL.js +0 -2
  222. package/dist/chunk-OB2VX4IL.js.map +0 -1
  223. package/dist/chunk-RAPEZR5L.cjs +0 -2
  224. package/dist/chunk-RAPEZR5L.cjs.map +0 -1
  225. package/dist/chunk-SPOVFRZO.cjs +0 -5
  226. package/dist/chunk-SPOVFRZO.cjs.map +0 -1
  227. package/dist/chunk-SQHBOWES.cjs +0 -2
  228. package/dist/chunk-SQHBOWES.cjs.map +0 -1
  229. package/dist/chunk-UF5XMZTT.js +0 -2
  230. package/dist/chunk-UF5XMZTT.js.map +0 -1
  231. package/dist/chunk-UV3EUIBT.cjs +0 -3
  232. package/dist/chunk-UV3EUIBT.cjs.map +0 -1
  233. package/dist/chunk-VMSCRVNX.cjs +0 -2
  234. package/dist/chunk-VMSCRVNX.cjs.map +0 -1
  235. package/dist/chunk-XBGK3TTU.cjs +0 -3
  236. package/dist/chunk-XBGK3TTU.cjs.map +0 -1
  237. package/dist/chunk-XX55RR4Q.js +0 -3
  238. package/dist/chunk-XX55RR4Q.js.map +0 -1
  239. package/dist/chunk-YBQPEWT7.cjs.map +0 -1
  240. package/dist/chunk-ZDCZ5IDD.js +0 -3
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json","../src/constants/version.ts","../src/constants/Configuration.ts"],"names":["version","ENGINE_VERSION","DEFAULT_CONFIG","mergeEngineConfig","base","override","ConfigManager","config","path","keys","current","key","ErrorFactory","value","section","property","sectionConfig","errors"],"mappings":"mEAEE,IAAAA,EAAW,QAAA,CCcN,IAAMC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AAA,iCAAA,EAAoCE,CAAO,CAAA,CAAA,CAC3C,CAAE,QAAAA,CAAAA,CAAS,IAAA,CAAAN,CAAK,CAClB,CAAA,CAGF,IAAMQ,CAAAA,CAAgB,IAAA,CAAK,OAAOF,CAA6B,CAAA,CAC/D,GAAIE,CAAAA,EAAiB,OAAOA,CAAAA,EAAkB,QAAA,CAC3CA,EAAqDD,CAAQ,CAAA,CAAIF,OAElE,MAAMD,mBAAAA,CAAa,OACjB,2BAAA,CACA,CAAA,kCAAA,EAAqCJ,CAAI,CAAA,CAAA,CACzC,CAAE,KAAAA,CAAK,CACT,CAEJ,CAUA,SAAA,EAA0B,CACxB,OAAOL,CAAAA,CAAkB,KAAK,MAAA,CAAQ,EAAE,CAC1C,CAKA,OAAOI,CAAAA,CAAqC,CAC1C,KAAK,MAAA,CAASJ,CAAAA,CAAkB,KAAK,MAAA,CAAQI,CAAM,EACrD,CAcA,KAAA,EAAc,CACZ,IAAA,CAAK,MAAA,CAASJ,CAAAA,CAAkBD,CAAAA,CAAgB,EAAE,EACpD,CAKA,QAAA,EAA6B,CAC3B,IAAMe,CAAAA,CAAmB,GAGzB,OAAI,IAAA,CAAK,OAAO,WAAA,CAAY,gBAAA,CAAmB,KAC7CA,CAAAA,CAAO,IAAA,CAAK,wCAAwC,CAAA,CAIlD,IAAA,CAAK,OAAO,IAAA,CAAK,cAAA,CAAiB,KACpCA,CAAAA,CAAO,IAAA,CAAK,mCAAmC,CAAA,CAG1C,CACL,MAAOA,CAAAA,CAAO,MAAA,GAAW,EACzB,KAAA,CAAOA,CAAAA,CAAO,KAAK,IAAI,CAAA,CACvB,SAAU,EACZ,CACF,CACF","file":"chunk-4NZXCHQL.cjs","sourcesContent":["{\n \"name\": \"solve-engine\",\n \"version\": \"2.25.0\",\n \"description\": \"An embeddable expression engine for natural-language calculations: units, currencies, percentages, dates and matrices, with the parsing and evaluation plumbing already built.\",\n \"keywords\": [\n \"expression-evaluator\",\n \"calculator\",\n \"bytecode-vm\",\n \"parser\",\n \"lexer\",\n \"dsl\",\n \"markdown\",\n \"obsidian\"\n ],\n \"license\": \"MIT\",\n \"author\": \"Liam Riddell\",\n \"homepage\": \"https://liamriddell.github.io/solve-engine/\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/LiamRiddell/solve-engine.git\",\n \"directory\": \"packages/engine\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/LiamRiddell/solve-engine/issues\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"engines\": {\n \"node\": \">=22\"\n },\n \"files\": [\n \"dist\",\n \"LICENSE\"\n ],\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./engine\": {\n \"import\": {\n \"types\": \"./dist/engine.d.ts\",\n \"default\": \"./dist/engine.js\"\n },\n \"require\": {\n \"types\": \"./dist/engine.d.cts\",\n \"default\": \"./dist/engine.cjs\"\n }\n },\n \"./vm\": {\n \"import\": {\n \"types\": \"./dist/vm.d.ts\",\n \"default\": \"./dist/vm.js\"\n },\n \"require\": {\n \"types\": \"./dist/vm.d.cts\",\n \"default\": \"./dist/vm.cjs\"\n }\n },\n \"./format\": {\n \"import\": {\n \"types\": \"./dist/format.d.ts\",\n \"default\": \"./dist/format.js\"\n },\n \"require\": {\n \"types\": \"./dist/format.d.cts\",\n \"default\": \"./dist/format.cjs\"\n }\n },\n \"./language\": {\n \"import\": {\n \"types\": \"./dist/language.d.ts\",\n \"default\": \"./dist/language.js\"\n },\n \"require\": {\n \"types\": \"./dist/language.d.cts\",\n \"default\": \"./dist/language.cjs\"\n }\n },\n \"./packages\": {\n \"import\": {\n \"types\": \"./dist/packages.d.ts\",\n \"default\": \"./dist/packages.js\"\n },\n \"require\": {\n \"types\": \"./dist/packages.d.cts\",\n \"default\": \"./dist/packages.cjs\"\n }\n },\n \"./constants\": {\n \"import\": {\n \"types\": \"./dist/constants.d.ts\",\n \"default\": \"./dist/constants.js\"\n },\n \"require\": {\n \"types\": \"./dist/constants.d.cts\",\n \"default\": \"./dist/constants.cjs\"\n }\n },\n \"./lexer\": {\n \"import\": {\n \"types\": \"./dist/lexer.d.ts\",\n \"default\": \"./dist/lexer.js\"\n },\n \"require\": {\n \"types\": \"./dist/lexer.d.cts\",\n \"default\": \"./dist/lexer.cjs\"\n }\n },\n \"./parser\": {\n \"import\": {\n \"types\": \"./dist/parser.d.ts\",\n \"default\": \"./dist/parser.js\"\n },\n \"require\": {\n \"types\": \"./dist/parser.d.cts\",\n \"default\": \"./dist/parser.cjs\"\n }\n },\n \"./normalizer\": {\n \"import\": {\n \"types\": \"./dist/normalizer.d.ts\",\n \"default\": \"./dist/normalizer.js\"\n },\n \"require\": {\n \"types\": \"./dist/normalizer.d.cts\",\n \"default\": \"./dist/normalizer.cjs\"\n }\n },\n \"./resolvers\": {\n \"import\": {\n \"types\": \"./dist/resolvers.d.ts\",\n \"default\": \"./dist/resolvers.js\"\n },\n \"require\": {\n \"types\": \"./dist/resolvers.d.cts\",\n \"default\": \"./dist/resolvers.cjs\"\n }\n },\n \"./errors\": {\n \"import\": {\n \"types\": \"./dist/errors.d.ts\",\n \"default\": \"./dist/errors.js\"\n },\n \"require\": {\n \"types\": \"./dist/errors.d.cts\",\n \"default\": \"./dist/errors.cjs\"\n }\n },\n \"./utilities\": {\n \"import\": {\n \"types\": \"./dist/utilities.d.ts\",\n \"default\": \"./dist/utilities.js\"\n },\n \"require\": {\n \"types\": \"./dist/utilities.d.cts\",\n \"default\": \"./dist/utilities.cjs\"\n }\n },\n \"./uom\": {\n \"import\": {\n \"types\": \"./dist/uom.d.ts\",\n \"default\": \"./dist/uom.js\"\n },\n \"require\": {\n \"types\": \"./dist/uom.d.cts\",\n \"default\": \"./dist/uom.cjs\"\n }\n },\n \"./services\": {\n \"import\": {\n \"types\": \"./dist/services.d.ts\",\n \"default\": \"./dist/services.js\"\n },\n \"require\": {\n \"types\": \"./dist/services.d.cts\",\n \"default\": \"./dist/services.cjs\"\n }\n },\n \"./worker\": {\n \"import\": {\n \"types\": \"./dist/worker.d.ts\",\n \"default\": \"./dist/worker.js\"\n },\n \"require\": {\n \"types\": \"./dist/worker.d.cts\",\n \"default\": \"./dist/worker.cjs\"\n }\n },\n \"./testing\": {\n \"import\": {\n \"types\": \"./dist/testing.d.ts\",\n \"default\": \"./dist/testing.js\"\n },\n \"require\": {\n \"types\": \"./dist/testing.d.cts\",\n \"default\": \"./dist/testing.cjs\"\n }\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"prepublishOnly\": \"npm run build && node ../../scripts/assert-publishable.mjs .\",\n \"dev\": \"tsup --watch\",\n \"test\": \"jest --config jest.config.cjs --no-coverage\",\n \"typecheck\": \"tsgo --noEmit --skipLibCheck\",\n \"typecheck:tsc\": \"tsc --noEmit --skipLibCheck\"\n },\n \"dependencies\": {\n \"@tanstack/query-core\": \"^5.102.8\"\n },\n \"devDependencies\": {\n \"@jest/globals\": \"^30.5.0\",\n \"@types/node\": \"^26.4.0\",\n \"convert\": \"^7.0.0\",\n \"jest\": \"^30.5.0\",\n \"ts-jest\": \"^29.4.12\",\n \"tsup\": \"8.5.1\",\n \"typescript\": \"5.9.3\"\n },\n \"//sideEffects\": \"Load-bearing claim, not boilerplate. tsup's splitting emits bare chunk imports at the top of dist/index.js, and this field tells Rollup, webpack and Vite they may delete them, which esbuild reports as [ignored-bare-import] once per import during `npm run size`. The engine does have module-level work to lose: registerAllTokenTypes(), _PrecedenceParser.BP_TABLE and its cached token ids, and several process-wide registries. It is safe because every chunk doing that work is also imported for its bindings somewhere, so no bundler can drop it. That is a property of how tsup currently splits the code rather than a design guarantee, so `npm run smoke:bundled` (scripts/check-tree-shaking.mjs) proves it on every run of `npm run verify` instead of assuming it, and its header explains the two fixes if it ever stops holding.\",\n \"sideEffects\": false\n}\n","/**\n * The running engine's own semver version, sourced directly from this\n * package's package.json so it can never drift from what's actually\n * published. Exists so IEnginePackage.engineVersion range checks\n * (api/EngineVersionCompatibility.ts) have something real to check\n * against.\n */\nimport { version } from \"../../package.json\";\n\n/**\n * The running engine's version, taken from package.json.\n *\n * What a package's `engineVersion` range is checked against at registration.\n * A prerelease is compared by its coerced release version, so a 1.0.0 beta\n * satisfies `^1.0.0`. See `api/EngineVersionCompatibility.ts`.\n */\nexport const ENGINE_VERSION: string = version;\n","/**\n * Configuration Module for solve-js Engine\n * \n * This module provides the **single source of truth** for all engine configuration.\n * Every configurable aspect of the engine, from safety limits and performance\n * budgets to VM constraints and worker pool sizing, is defined here.\n * \n * ### Design principles\n * \n * 1. **Engine owns its config.** The engine defines its own config shape and defaults.\n * Consumers (e.g., the Obsidian plugin) pass partial overrides; all unspecified\n * fields fall back to `DEFAULT_CONFIG`.\n * \n * 2. **Self-documenting.** Every interface and field has descriptive JSDoc so the\n * config is understandable at a glance, whether you're using the engine as an\n * npm package or reading the source.\n * \n * 3. **Minimal consumer knowledge.** Consumers only need to pass `Partial<EngineConfig>`.\n * They don't need to replicate the full config shape, just the fields they\n * want to override.\n * \n * @module Configuration\n */\n\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * A host's test for whether a calendar date is a public holiday, given the\n * `Date` for that day at local midnight. Return `true` to exclude it from\n * working-day arithmetic.\n */\nexport type HolidayPredicate = (date: Date) => boolean;\n\n/**\n * The host-supplied public-holiday calendar, in the same \"bring your own data\"\n * shape the stocks and weather packages already use for a host callback (see\n * `packages/stocks/StocksPackage.ts`): weekends are decidable from the date\n * alone, holidays are not, so they come from the host or not at all.\n *\n * Either a {@link HolidayPredicate}, for a host that computes holidays itself\n * (an existing library, a region rule), or an iterable of specific dates as\n * `YYYY-MM-DD` strings, epoch-millisecond numbers or `Date` objects, for a host\n * that just has a list. Resolved to one internal predicate by\n * `vm/HolidayCalendar.ts`'s `resolveHolidayPredicate()`.\n *\n * Left unset, working-day arithmetic skips weekends only, which is the honest\n * default: the engine excludes exactly the days it can prove are non-working.\n */\nexport type HolidayCalendar = HolidayPredicate | Iterable<string | number | Date>;\n\n/**\n * Date-related configuration.\n * Controls the bounds and formatting for date/time expression evaluation\n * (e.g., `today + 20 days`, `last monday`).\n */\n/**\n * How an ambiguous all-numeric date literal is read.\n *\n * - `'auto'`: by separator, the historic behaviour. A slash date is\n * day-first (`25/12/2023`), a hyphen date is month-first (`12-25-2023`)\n * unless its first group is four digits, which makes it ISO (`2023-12-25`).\n * - `'DMY'` / `'MDY'` / `'YMD'`: a fixed order for every numeric separator, so\n * a host can match its readers' locale. `'MDY'` is what lets a US reader's\n * `12/25/2023` parse, which `'auto'` refuses because the slash defaults to\n * day-first.\n *\n * Only the all-numeric literals are affected. A spelled-out month (`March 9,\n * 2024`) is never ambiguous, and an ISO timestamp is always read as ISO.\n */\nexport type DateInputOrder = 'auto' | 'DMY' | 'MDY' | 'YMD';\n\n/** Date-related engine configuration: offset limits, input order, holidays. */\nexport interface DateConfig {\n /**\n * The order an ambiguous all-numeric date literal is read in. Defaults to\n * `'auto'` (by separator, the historic behaviour). See {@link DateInputOrder}.\n */\n readonly inputOrder: DateInputOrder;\n /**\n * How far forward a date offset whose COST grows with the offset may reach,\n * in years. Enforced by `vm/VM.ts`'s `addBusinessDays()`.\n *\n * Bounds the walk, not the calendar. Every other date offset in the engine\n * is arithmetic on a Date field, so `today + 100000 days` costs exactly what\n * one day costs and needs no ceiling; workdays are the one offset that has\n * to step day by day, because which days are skipped depends on where each\n * step lands. `today + 100000000 workdays` therefore froze the host for\n * thirteen seconds inside a single ADD opcode (where `vm.maxInstructions`\n * cannot see it) and then answered \"Invalid Date\", and a trillion never\n * returned at all.\n *\n * Release hardening: this field was declared, documented as a \"safety\n * limit\", and read nowhere, so it bounded nothing. A limit a host can\n * configure and the engine ignores is worse than no limit, because it reads\n * as protection that is not there.\n */\n readonly maxOffsetYears: number;\n /** How far BACK the same walk may reach, in years, as a negative number. See {@link maxOffsetYears}. */\n readonly minOffsetYears: number;\n /** Default date string format for display (moment.js format string) */\n readonly defaultFormat: string;\n /**\n * Public-holiday calendar for working-day arithmetic (`N working days after\n * <date>`, `working days between <date> and <date>`, `<date> + N workdays`).\n * See {@link HolidayCalendar}.\n *\n * Optional and unset by default: with no calendar, working-day arithmetic\n * skips weekends only. A host that wants holidays excluded too supplies one\n * here (`new ExpressionEngine({ config: { date: { holidays } } })`), the\n * same way stocks and weather take a host data source. Threaded into the VM\n * by `engine/ExpressionEngine.ts` exactly as {@link maxOffsetYears} is,\n * because working-day math is a VM operation several grammar forms share, so\n * the calendar has to be one source the VM owns rather than per-package state\n * the VM cannot see.\n */\n readonly holidays?: HolidayCalendar;\n}\n\n/**\n * Performance-related configuration.\n * Controls caching, timeouts, and processing limits to prevent runaway\n * resource consumption on large documents.\n */\nexport interface PerformanceConfig {\n /**\n * Maximum number of entries in {@link ExpressionEngine}'s bytecode cache\n * (per-instance, keyed by expression text) before the oldest entry is\n * evicted. Raise this for documents with many distinct expressions if\n * repeated re-evaluation (e.g. scrolling) is re-parsing instead of\n * hitting cache, bug fix (release hardening pass): this field used to\n * be read nowhere; the cache size was a hardcoded, unconfigurable\n * constant. Note this does NOT bound {@link LineCache}, which has no\n * size limit of its own.\n */\n readonly defaultCacheSize: number;\n /**\n * Maximum lines a document may have for the engine to process it in one\n * pass. Enforced by `ExpressionEngine.parseDocument()` and by\n * `engine/DocumentModel.ts`'s `setDocument()`, the two entry points that\n * take a whole document.\n *\n * A document costs memory per line whatever each line says: a parsed line\n * record, a cache entry, a dependency-graph node. Two hundred thousand\n * lines of `1 + 1` therefore exhausted the heap and aborted the process\n * before any per-line limit had anything to object to, which is the same\n * shape of hole as an unbounded expression and needs the same kind of\n * ceiling. Refusing the document names the limit; a host that genuinely has\n * a larger one raises this field.\n *\n * Release hardening: declared and read nowhere until now.\n */\n readonly maxDocumentLines: number;\n}\n\n/**\n * Validation / safety-limit configuration.\n * Protects against runaway expressions that could cause excessive memory use\n * or stack overflow. These limits are checked during lexing and parsing.\n */\n/** Bounds on untrusted input: expression length and nesting depth. */\nexport interface ValidationConfig {\n /** Maximum expression length in characters. Prevents excessively long strings from entering the pipeline. */\n readonly maxExpressionLength: number;\n /** Maximum expression complexity score (`tokens + functionCalls×5 + nestingDepth×10`). Protects against deeply nested or combinatorially complex expressions. */\n readonly maxComplexity: number;\n /** Maximum parentheses nesting depth. Prevents stack overflow in the recursive-descent parser. */\n readonly maxNestingDepth: number;\n /**\n * Auto-balance unmatched parentheses by appending missing closing parens\n * or prepending missing opening parens. When disabled, unbalanced expressions\n * cause parse errors instead of being silently corrected.\n *\n * Disabled by default for strict parsing. Enable for forgiving user input\n * (e.g., chat-style calculators where users often omit closing parens).\n * Has zero overhead when disabled, the O(n) paren-count scan is skipped.\n */\n readonly autoBalanceParens: boolean;\n}\n\n/**\n * Worker pool configuration.\n * Controls the parallel execution workers used for batch evaluation.\n */\nexport interface WorkerConfig {\n /** Maximum number of concurrent Web Workers allowed */\n readonly maxConcurrentWorkers: number;\n /** Time (ms) a worker stays alive while idle before being terminated */\n readonly idleTimeoutMs: number;\n /** Maximum retry attempts for a failed worker operation */\n readonly maxRetries: number;\n /** Base backoff delay (ms) between retries (exponential backoff applied on top) */\n readonly baseBackoffMs: number;\n} /**\n * Diagnostic / telemetry configuration.\n * Controls the diagnostic event pipeline for profiling and debugging.\n * All diagnostics are disabled by default for maximum production performance.\n */\n export interface DiagnosticConfig {\n /** Master switch: enable the diagnostic pipeline (collectors receive events for all pipeline stages) */\n readonly enabled: boolean;\n /** Enable VM trace mode, emits per-opcode execution events (very verbose; disables some optimizations) */\n readonly vmTraceEnabled: boolean;\n }\n\n /**\n * Proactive background refresh of live async values.\n *\n * Off by default. When a live value (a stock quote, an FX rate) has gone\n * stale, today it only refetches on the next re-evaluation (a keystroke), so a\n * note left open silently ages. With this enabled, the engine drives a refetch\n * on each such value's own cadence (the resolver's `refetchIntervalMs`) for the\n * values currently on screen, and pushes the fresh result to the host through\n * the same event stream the pull path uses. It needs timers and a live editor\n * consuming that stream, so a headless or batch host leaves it off.\n */\n export interface BackgroundRefreshConfig {\n /** Master switch. When false, no timers run and every value refreshes only on re-evaluation. */\n readonly enabled: boolean;\n }\n\n /**\n * Whether the engine may reach the network at all.\n *\n * On by default, which is the historic behaviour: a city name or a currency\n * pair in a line fetches live data from a public endpoint as soon as the\n * line evaluates. A host embedding the engine somewhere that must not make\n * outbound requests (an offline document, a sandboxed evaluation, a tenant\n * with egress rules) switches it off here and gets the same engine with no\n * egress: every live-data form answers with a `NETWORK_DISABLED` error\n * naming the setting, instead of a request.\n *\n * The gate closes before any request is made. It stops every async\n * resolver a package registers (weather, currency, stocks, crypto,\n * knowledge, and any host-supplied one) unless the resolver declares\n * itself `local` (it reads engine state, never a network; the engine's own\n * global-variable resolver is the one built-in case). It also refuses the\n * result of a plugin function that returns a promise. That last case is a\n * boundary rather than a guarantee: such a function has already run by the\n * time the engine sees the promise, so a package that fetches inside a\n * plugin function rather than through an async resolver may still have\n * started its request. The documented shape for live data is the resolver\n * (`createQueryResolver`), which this gate stops cold.\n *\n * Rates a host primes by hand (`currencyExchangeService.primeRates`) keep\n * working with the network off, which is what an offline host with its own\n * rate table wants.\n */\n export interface NetworkConfig {\n /** Master switch. When false, no async resolver runs and no live value is fetched. */\n readonly enabled: boolean;\n }\n\n /**\n * Virtual Machine configuration.\n * Controls the internal bytecode VM that executes compiled expressions.\n */\n export interface VMConfig {\n /** Maximum stack depth (value slots) for VM execution, prevents stack overflow in recursive/pratt-parser generated bytecode */\n readonly maxStackDepth: number;\n /** Maximum opcodes executed per expression, halts runaway infinite loops */\n readonly maxInstructions: number;\n /**\n * Maximum elements a collection may be expanded to before `map`/`reduce`/\n * `sum`/`prod` will iterate it.\n *\n * A Range is stored as its two bounds and costs nothing until something\n * materializes it, at which point it becomes one Value per element. Twenty\n * characters (`sum(x, 1:100000000)`) therefore asked for a hundred million\n * of them, and neither `maxInstructions` nor `maxStackDepth` could see it:\n * the expansion happens inside a single opcode, so the instruction counter\n * is never consulted while it runs, and the elements never reach the value\n * stack. V8 aborted the whole process with \"Reached heap limit\", which a\n * host embedding the engine cannot catch.\n */\n readonly maxCollectionSize: number;\n /**\n * Maximum elements (collection Values, matrix cells) one evaluation may\n * materialize in total.\n *\n * `maxCollectionSize` above bounds a single collection. This bounds the sum\n * of everything an expression asks for, which is a different question and\n * the one that actually protects the host: two collections that are\n * individually legal are legal together, and an operation whose result is\n * the PRODUCT of two legal operands is bounded by neither of them. A matrix\n * multiply is exactly that shape, so three lines within every other limit\n * (`:a = map(1*x, 0:20000)`, `:b = transpose(a)`, `b * a`) asked for four\n * hundred million cells and aborted the process.\n *\n * Counted in elements rather than bytes, because a count is what a call\n * site has before it allocates. An element is 8 bytes as a numeric matrix\n * cell and closer to a hundred as a full Value, so the default is worth\n * roughly 16 MB of matrix or 200 MB of expanded collection: far past any\n * document and far short of what an editor cannot survive.\n */\n readonly maxAllocatedElements: number;\n /**\n * Maximum user-defined-function calls one evaluation may make in TOTAL,\n * however deeply or widely they nest.\n *\n * `maxFunctionRecursionDepth` bounds how DEEP calls nest and cannot see\n * how MANY there are, and those are different numbers. Twenty-two lines of\n * `f(n)(v) = f(n-1)(v) + f(n-1)(v)` reach a depth of only 22 against a\n * limit of 50, and make 2,097,152 calls doing it: a fatal heap abort in\n * under a second. `maxInstructions` cannot bound it either, because\n * `executeBytecode()` re-enters itself per call and each reentrant call\n * gets its OWN instruction count, so recursion refreshes its allowance on\n * the way in. This is the tally that does not refresh; see\n * `vm/AllocationBudget.ts`, which holds it for the same reason it holds\n * the element tally.\n *\n * Counted in calls rather than in the instructions they run, because the\n * call is the thing that multiplies: every call allocates a frame, its\n * arguments and its result whatever its body says.\n */\n readonly maxFunctionCalls: number;\n /**\n * Hard ceiling on how many bisection steps goal seek (`solve line N for\n * <var> = <target>`, see `packages/goalseek/`) may take before it gives up\n * with a structured error rather than continuing.\n *\n * Goal seek re-evaluates the target line's expression once per step while\n * narrowing an interval, and an untrusted document must never be able to\n * make that loop spin. `maxInstructions` bounds each individual\n * re-evaluation, but not how many of them the search performs, so this is\n * the tally that bounds the search itself, the same reason `maxFunctionCalls`\n * exists alongside `maxInstructions`. Bisection halves the interval every\n * step, so a hundred steps resolves an input to roughly one part in 2^100:\n * far past any precision a document needs, and a definite stop either way.\n */\n readonly maxGoalSeekIterations: number;\n }\n\n/**\n * Complete engine configuration.\n *\n * Every field has a default in `DEFAULT_CONFIG`. To customize, pass a\n * `Partial<EngineConfig>` when constructing `ExpressionEngine`. Only the\n * sections/fields you supply are overridden; all others use their defaults.\n *\n * @example\n * ```typescript\n * import { ExpressionEngine } from \"solve-js\";\n *\n * const engine = new ExpressionEngine({ config: {\n * validation: {\n * maxExpressionLength: 1000,\n * maxComplexity: 200,\n * },\n * // date, performance, vm, worker, diagnostic all use defaults\n * } });\n * ```\n */\nexport interface EngineConfig {\n /** Date/time expression evaluation bounds and formatting */\n readonly date: DateConfig;\n /** Performance budgets and cache sizing */\n readonly performance: PerformanceConfig;\n /** Safety limits for expression complexity */\n readonly validation: ValidationConfig;\n /** Internal bytecode VM configuration */\n readonly vm: VMConfig;\n /** Parallel worker pool configuration */\n readonly worker: WorkerConfig;\n /** Diagnostic pipeline configuration */\n readonly diagnostic: DiagnosticConfig;\n /** Proactive background refresh of live async values */\n readonly backgroundRefresh: BackgroundRefreshConfig;\n /** Whether live data may be fetched at all. See {@link NetworkConfig}. */\n readonly network: NetworkConfig;\n }\n\n/**\n * A partial {@link EngineConfig} override, one section at a time.\n *\n * Overrides are merged per section over {@link DEFAULT_CONFIG}, so you can set a\n * single field of one section (`{ validation: { maxExpressionLength: 1000 } }`)\n * and keep every other default in that section. A plain `Partial<EngineConfig>`\n * cannot express that, it demands a whole section object, which is why the\n * documented overrides never typechecked against it. This is the type the\n * constructor and {@link createEngine} accept.\n */\nexport type EngineConfigOverride = {\n readonly [K in keyof EngineConfig]?: Partial<EngineConfig[K]>;\n};\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONFIG: EngineConfig = {\n date: {\n // A century of workdays is about 26,000 steps, which is microseconds,\n // and past any offset a person means. The walk is what these bound; see\n // DateConfig above for why no other date offset needs a ceiling.\n maxOffsetYears: 100,\n minOffsetYears: -100,\n defaultFormat: 'YYYY-MM-DD',\n inputOrder: 'auto',\n },\n performance: {\n // Preserves the effective cache size the hardcoded (now-removed)\n // BYTECODE_CACHE_MAX_ENTRIES constant had, so wiring this field up\n // doesn't silently shrink the default cache for existing consumers.\n defaultCacheSize: 2000,\n // Raised from the 10,000 this field was declared with, which was never\n // enforced and turned out to be under what this engine already supports:\n // its paging design is tested against a 20,000-line document\n // (`engine/PageManager.ts` and its spec) and its throughput benchmark\n // parses a 50,000-line one. Twice the largest of those, and the same\n // number `ConfigManager.validate()` already refuses to go above.\n //\n // Measured under a 256MB heap: setting a 100,000-line document costs\n // 64MB, evaluating every line of a 20,000-line one costs 106MB, and\n // 200,000 lines aborts the process before a single expression is looked\n // at. A host with a small heap should lower this; the ceiling is here to\n // stop the size that cannot work anywhere.\n maxDocumentLines: 100000,\n },\n validation: {\n maxExpressionLength: 2000,\n maxComplexity: 500,\n maxNestingDepth: 50,\n autoBalanceParens: false,\n },\n vm: {\n maxStackDepth: 200,\n maxInstructions: 50000,\n // Two orders of magnitude above anything a person types by hand (the\n // longest range in the test suite is 1000 elements) and small enough\n // that expanding it is measured in milliseconds rather than in whether\n // the host survives.\n maxCollectionSize: 100000,\n // Twenty times the single-collection ceiling above, so an expression may\n // legitimately handle a number of large collections, and two hundred\n // times below the allocation that took the process down.\n maxAllocatedElements: 2000000,\n // Six hundred times the largest call count any test or example makes\n // (five levels of composition is sixteen calls), and small enough that\n // the calls it does allow cost single-digit megabytes rather than the\n // heap. A document that needs more than ten thousand calls on one line\n // is doing something a calculator was not built for.\n maxFunctionCalls: 10000,\n // A hundred bisection steps resolve an input to one part in 2^100, far\n // finer than any document needs and a firm stop for an untrusted one. A\n // continuous, monotonic relationship converges in tens of steps, well\n // under this; hitting it means the target is unreachable or the\n // relationship is not the smooth one goal seek assumes.\n maxGoalSeekIterations: 100,\n },\n worker: {\n maxConcurrentWorkers: 4,\n idleTimeoutMs: 30000,\n maxRetries: 3,\n baseBackoffMs: 1000,\n },\n diagnostic: {\n enabled: false,\n vmTraceEnabled: false,\n },\n backgroundRefresh: {\n enabled: false,\n },\n network: {\n // On, because it is what every existing consumer gets today. A host that\n // must not make outbound requests turns it off; see NetworkConfig.\n enabled: true,\n },\n };\n\n/**\n * Merge a partial config override onto a base `EngineConfig`, section by\n * section, `{ ...base.section, ...override.section }` for each of the 8\n * top-level sections, not a single top-level spread.\n *\n * A shallow `{ ...base, ...override }` at the TOP level replaces an entire\n * section wholesale the moment a caller overrides even one field in it\n * (e.g. `{ performance: { defaultCacheSize: 500 } }` would silently drop\n * every other `performance.*` field back to `undefined`, not to its\n * default). This function exists specifically so every config consumer\n * shares one correct merge instead of each hand-rolling (and risking) its\n * own. `ConfigManager` and `ExpressionEngine` both call this rather than\n * either duplicating the section list or instantiating a whole\n * `ConfigManager` just to reuse its private merge logic.\n */\nexport function mergeEngineConfig(\n base: EngineConfig,\n override: EngineConfigOverride\n): EngineConfig {\n return {\n date: { ...base.date, ...override.date },\n performance: { ...base.performance, ...override.performance },\n validation: { ...base.validation, ...override.validation },\n vm: { ...base.vm, ...override.vm },\n worker: { ...base.worker, ...override.worker },\n diagnostic: { ...base.diagnostic, ...override.diagnostic },\n backgroundRefresh: { ...base.backgroundRefresh, ...override.backgroundRefresh },\n network: { ...base.network, ...override.network },\n };\n}\n\n/**\n * Configuration manager for engine settings\n *\n * @example\n * ```typescript\n * const configManager = new ConfigManager();\n * configManager.set('performance.defaultCacheSize', 2000);\n * const cacheSize = configManager.get('performance.defaultCacheSize');\n * ```\n */\nexport class ConfigManager {\n private config: EngineConfig;\n\n constructor(config: Partial<EngineConfig> = {}) {\n this.config = mergeEngineConfig(DEFAULT_CONFIG, config);\n }\n\n /**\n * Get configuration value by path\n * \n * @param path - Dot-notation path to config value\n * @returns Configuration value\n */\n get<T>(path: string): T {\n const keys = path.split('.');\n let current: unknown = this.config;\n\n for (const key of keys) {\n if (current && typeof current === 'object' && key in current) {\n current = (current as Record<string, unknown>)[key];\n } else {\n throw ErrorFactory.config(\n \"CONFIG_PATH_NOT_FOUND\",\n `Configuration path not found: ${path}`,\n { path }\n );\n }\n }\n\n return current as T;\n }\n\n /**\n * Set configuration value by path\n * \n * @param path - Dot-notation path to config value\n * @param value - New value\n */\n set<T>(path: string, value: T): void {\n const keys = path.split('.');\n if (keys.length < 2) {\n throw ErrorFactory.config(\n \"INVALID_CONFIG_PATH\",\n `Invalid path: ${path}. Must be in format 'section.property'`,\n { path }\n );\n }\n \n const section = keys[0];\n const property = keys[1];\n \n if (!(section in this.config)) {\n throw ErrorFactory.config(\n \"CONFIG_SECTION_NOT_FOUND\",\n `Configuration section not found: ${section}`,\n { section, path }\n );\n }\n \n const sectionConfig = this.config[section as keyof EngineConfig];\n if (sectionConfig && typeof sectionConfig === 'object') {\n (sectionConfig as unknown as Record<string, unknown>)[property] = value;\n } else {\n throw ErrorFactory.config(\n \"CONFIG_PROPERTY_NOT_FOUND\",\n `Configuration property not found: ${path}`,\n { path }\n );\n }\n }\n\n /**\n * Get complete configuration.\n *\n * A detached copy, section objects included. A top-level spread would hand\n * the caller this manager's own section objects, so `getConfig().vm.x = 1`\n * would be an undeclared back door into {@link set}, bypassing its path\n * validation and reaching every later {@link get}.\n */\n getConfig(): EngineConfig {\n return mergeEngineConfig(this.config, {});\n }\n\n /**\n * Update multiple configuration values\n */\n update(config: Partial<EngineConfig>): void {\n this.config = mergeEngineConfig(this.config, config);\n }\n\n /**\n * Reset to default configuration.\n *\n * Goes through {@link mergeEngineConfig} for the same reason the constructor\n * does. A top-level `{ ...DEFAULT_CONFIG }` copies the six section\n * references, not the sections, so after a reset this manager's\n * `performance` object WAS `DEFAULT_CONFIG.performance` and the next\n * `set('performance.x', ...)` wrote into the module constant. That constant\n * is what every `ExpressionEngine` is built from, so one manager's reset\n * could change the cache size, instruction ceiling or allocation budget of\n * every engine constructed later in the process.\n */\n reset(): void {\n this.config = mergeEngineConfig(DEFAULT_CONFIG, {});\n }\n\n /**\n * Validate configuration values\n */\n validate(): ValidationResult {\n const errors: string[] = [];\n\n // Validate performance config\n if (this.config.performance.maxDocumentLines > 100000) {\n errors.push('maxDocumentLines cannot exceed 100,000');\n }\n\n // Validate date config\n if (this.config.date.maxOffsetYears > 1000) {\n errors.push('maxOffsetYears cannot exceed 1000');\n }\n\n return {\n valid: errors.length === 0,\n error: errors.join('; '),\n warnings: []\n };\n }\n}\n\n/**\n * Result type for {@link ConfigManager.validate}.\n */\nexport interface ValidationResult {\n valid: boolean;\n error?: string;\n warnings?: string[];\n}\n\n"]}
@@ -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"],"mappings":"AA6BO,IAAKA,OAEVA,CAAAA,CAAA,OAAA,CAAU,UAEVA,CAAAA,CAAA,SAAA,CAAY,YAEZA,CAAAA,CAAA,UAAA,CAAa,aAEbA,CAAAA,CAAA,QAAA,CAAW,WAEXA,CAAAA,CAAA,QAAA,CAAW,WAEXA,CAAAA,CAAA,MAAA,CAAS,SAZCA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA,CAAA,CAmECC,CAAAA,CAAN,MAAMA,UAAoB,KAAM,CA+CrC,YAAYC,CAAAA,CAAyBC,CAA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AAgC,gCAAA,CAEhC,0BAAA,CAA4B,6BAE5B,yBAAA,CAA2B,2BAAA,CAE3B,4BAAA,CAA8B,8BAAA,CAE9B,gCAAiC,iCAAA,CAEjC,6BAAA,CAA+B,+BAAA,CAE/B,4BAAA,CAA8B,+BAE9B,uBAAA,CAAyB,yBAAA,CAEzB,+BAAA,CAAiC,iCAAA,CAEjC,+BAAgC,gCAAA,CAEhC,uBAAA,CAAyB,yBAAA,CAGzB,mBAAA,CAAqB,sBACrB,sBAAA,CAAwB,wBAAA,CAExB,kBAAA,CAAoB,oBAAA,CACpB,gCAAiC,iCAAA,CAEjC,6BAAA,CAA+B,+BAAA,CAE/B,2BAAA,CAA6B,8BAE7B,mCAAA,CAAqC,qCAAA,CAErC,kCAAmC,mCAAA,CAEnC,sBAAA,CAAwB,yBAExB,oBAAA,CAAsB,sBAAA,CAEtB,gBAAA,CAAkB,kBAAA,CAIlB,0BAA2B,2BAAA,CAE3B,kBAAA,CAAoB,oBAAA,CAEpB,0BAAA,CAA4B,6BAG5B,qBAAA,CAAuB,uBAAA,CACvB,mBAAA,CAAqB,qBAAA,CACrB,yBAA0B,0BAAA,CAC1B,yBAAA,CAA2B,2BAAA,CAG3B,yBAAA,CAA2B,4BAC3B,wBAAA,CAA0B,0BAAA,CAC1B,qBAAA,CAAuB,uBAAA,CAEvB,gCAAiC,iCAAA,CAEjC,oCAAA,CAAsC,sCAAA,CAEtC,qBAAA,CAAuB,wBAEvB,oCAAA,CAAsC,sCAAA,CAEtC,+BAAA,CAAiC,iCAAA,CAGjC,kBAAmB,mBAAA,CACnB,qBAAA,CAAuB,wBAGvB,gBAAA,CAAkB,kBAAA,CAClB,cAAe,eACjB","file":"chunk-57PSJQQW.js","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 // ── 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 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 * The aggregated catalog type. Currently just `CoreErrorCode`, union in\n * each package's own code-object type here as Phase 5 converts it, e.g.\n * `CoreErrorCode | WeatherErrorCode | StocksErrorCode | ...`.\n */\nexport type ErrorCode = CoreErrorCode;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lexer/Token.ts"],"names":["TokenTypes","_nextTokenTypeId","_tokenTypeNameToId","_tokenTypeIdToName","registerTokenType","name","existing","id","tokenTypeId","tokenTypeName","registerAllTokenTypes"],"mappings":"aA0CO,IAAMA,CAAAA,CAAa,CACxB,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,CACR,KAAA,CAAO,OAAA,CACP,IAAA,CAAM,MAAA,CACN,KAAA,CAAO,OAAA,CAGP,WAAA,CAAa,aAAA,CACb,YAAA,CAAc,cAAA,CACd,IAAA,CAAM,MAAA,CACN,KAAA,CAAO,OAAA,CAMP,UAAA,CAAY,YAAA,CACZ,KAAA,CAAO,OAAA,CACP,OAAA,CAAS,SAAA,CACT,OAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,CACR,OAAA,CAAS,SAAA,CACT,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,CACR,QAAA,CAAU,UAAA,CACV,QAAA,CAAU,UAAA,CACV,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,SACR,KAAA,CAAO,OAAA,CACP,GAAA,CAAK,KAAA,CACL,KAAA,CAAO,OAAA,CACP,SAAA,CAAW,WAAA,CACX,MAAA,CAAQ,QAAA,CACR,MAAA,CAAQ,QAAA,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,CAAmB,GAAA,CAAIG,CAAI,CAAA,CAC5C,GAAIC,CAAAA,GAAa,OAAW,OAAOA,CAAAA,CACnC,IAAMC,CAAAA,CAAKN,CAAAA,EAAAA,CACX,OAAAC,CAAAA,CAAmB,GAAA,CAAIG,CAAAA,CAAME,CAAE,CAAA,CAC/BJ,CAAAA,CAAmB,GAAA,CAAII,CAAAA,CAAIF,CAAI,CAAA,CACxBE,CACR,CAQO,SAASC,CAAAA,CAAYH,CAAAA,CAAsB,CACjD,OAAOD,CAAAA,CAAkBC,CAAI,CAC9B,CAMO,SAASI,CAAAA,CAAcF,CAAAA,CAAoB,CACjD,OAAOJ,CAAAA,CAAmB,IAAII,CAAE,CAAA,EAAK,CAAA,QAAA,EAAWA,CAAE,CAAA,CACnD,CAMO,SAASG,CAAAA,EAA8B,CAC7C,IAAA,IAAWL,CAAAA,IAAQ,MAAA,CAAO,MAAA,CAAOL,CAAU,CAAA,CAC1CI,CAAAA,CAAkBC,CAAI,EAExB","file":"chunk-5IJD5L3O.cjs","sourcesContent":["/**\n * Lexer token produced by {@link ExpressionLexer} and consumed by parsers.\n *\n * Each token carries:\n * - `type`: string name (e.g. \"NUMBER\", \"PLUS\") for diagnostics and parselet lookup\n * - `typeId`: integer ID for O(1) comparison in parser hot paths\n * - `value`/`text`: the token's semantic value and raw source text\n * - `offset`/`line`/`col`: source position for error messages and highlighting\n */\nexport interface Token {\n\t/** String token type (e.g., \"NUMBER\", \"PLUS\", \"IDENT\"). Used by ParseletRegistry string-keyed maps and error messages. */\n\ttype: string;\n\t/** Integer token type ID for fast comparison in Parser hot path.\n\t * Populated by the Lexer via registerTokenType(). Use tokenTypeId(type) to get a type's ID. */\n\ttypeId: number;\n\tvalue: string;\n\ttext: string;\n\toffset: number;\n\tlineBreaks: number;\n\tline: number;\n\tcol: number;\n\t/**\n\t * End offset of the source text this token was fused from, exclusive.\n\t *\n\t * Only set on tokens the normalizer built by fusing several lexer tokens\n\t * into one, and only there because those are the tokens whose `value` no\n\t * longer describes the text they came from. `10 frames` fuses into a\n\t * FRAME_COUNT whose value is `10`, so `offset + value.length` would cover\n\t * two characters of a nine-character phrase.\n\t *\n\t * Evaluation never reads this. It exists so that a consumer painting a line\n\t * (see `LanguageService.getSemanticTokens`) can highlight a fused phrase as\n\t * the one thing the parser will see rather than as its parts.\n\t */\n\tsourceEnd?: number;\n}\n\n/**\n * Canonical token type name constants.\n * All token types used by the lexer, parser, and VM are defined here.\n * Custom/plugin token types should be registered via {@link registerTokenType}.\n */\nexport const TokenTypes = {\n NUMBER: \"NUMBER\",\n BIGINT: \"BIGINT\",\n STRING: \"STRING\",\n IDENT: \"IDENT\",\n PLUS: \"PLUS\",\n MINUS: \"MINUS\",\n // Compound assignment for running totals: `total += 100`, `total -= 40`.\n // Handled by the engine's compound-assignment interception, not a parselet.\n PLUS_EQUALS: \"PLUS_EQUALS\",\n MINUS_EQUALS: \"MINUS_EQUALS\",\n STAR: \"STAR\",\n SLASH: \"SLASH\",\n // The uncertainty operator, `±` (U+00B1) or the ASCII `+/-`. The symbol is\n // lexed directly (ExpressionLexer.ts, alongside `×`/`÷`), and the ASCII\n // spelling is fused from PLUS SLASH MINUS by a normalizer rule (see\n // packages/uncertainty/). Registered here rather than left to be lazily\n // minted so its id is stable, the same reasoning as the algebra verbs below.\n PLUS_MINUS: \"PLUS_MINUS\",\n CARET: \"CARET\",\n PERCENT: \"PERCENT\",\n LSHIFT: \"LSHIFT\",\n RSHIFT: \"RSHIFT\",\n URSHIFT: \"URSHIFT\",\n LPAREN: \"LPAREN\",\n RPAREN: \"RPAREN\",\n LBRACKET: \"LBRACKET\",\n RBRACKET: \"RBRACKET\",\n LBRACE: \"LBRACE\",\n RBRACE: \"RBRACE\",\n COMMA: \"COMMA\",\n DOT: \"DOT\",\n COLON: \"COLON\",\n SEMICOLON: \"SEMICOLON\",\n EQUALS: \"EQUALS\",\n DOLLAR: \"DOLLAR\",\n POUND: \"POUND\",\n EURO: \"EURO\",\n YEN: \"YEN\",\n RUBLE: \"RUBLE\",\n WON: \"WON\",\n QUESTION: \"QUESTION\",\n BANG: \"BANG\",\n BIT_AND: \"BIT_AND\",\n BIT_OR: \"BIT_OR\",\n BIT_NOT: \"BIT_NOT\",\n KEYWORD: \"KEYWORD\",\n EOF: \"EOF\",\n ERROR: \"ERROR\",\n WS: \"WS\",\n NEWLINE: \"NEWLINE\",\n DATETIME_LITERAL: \"DATETIME_LITERAL\",\n DURATION: \"DURATION\",\n UNIT: \"UNIT\",\n ROLL: \"ROLL\",\n PI: \"PI\",\n E: \"E\",\n MOD: \"MOD\",\n // The English word \"and\", which is NOT the same thing as \"+\" even though it\n // adds. It used to map straight onto PLUS in the locale keyword map, which\n // made \"3 and 4\" evaluate to 7 correctly and then quietly broke every phrase\n // that uses \"and\" as a list separator: \"average of 36, 42, 19 and 81\" parsed\n // its last argument as \"19 + 81\" and returned 178/3 rather than 178/4.\n //\n // Giving it its own type lets a parselet tell the two apart. It is still an\n // infix addition (see ArithmeticPackage.ts) so \"3 and 4\" is unchanged, but it\n // binds at BindingPower.Conjunction, looser than both Sum and Conditional, so\n // a phrase parselet can parse an argument at Conjunction and get \"1 + 2\"\n // whole while still stopping at \"and\", and so \"5 > 3 and 2 > 1\" reads as the\n // conjunction of two comparisons rather than \"5 > (3 and 2) > 1\".\n AND_CONJ: \"AND_CONJ\",\n OF: \"OF\",\n INCREASE_BY: \"INCREASE_BY\",\n DECREASE_BY: \"DECREASE_BY\",\n // Percentage solve-for-unknown (packages/percentage/), \"N% of what is\n // X\" solves N% * base = X for base. Fused as a full 3-word phrase (see\n // PercentagePackage.ts's `phrases` field) rather than a bare \"what\"\n // keyword, \"what\" is common enough as a variable name to be worth the\n // same phrase-fusion treatment this codebase gives \"total\"/\"average\"/etc.\n OF_WHAT_IS: \"OF_WHAT_IS\",\n // Sibling solve-for-unknown forms accounting for a +/-1 offset, \"N% on\n // what is X\" (increase) / \"N% off what is X\" (decrease). Same\n // phrase-fusion reasoning as OF_WHAT_IS above.\n ON_WHAT_IS: \"ON_WHAT_IS\",\n OFF_WHAT_IS: \"OFF_WHAT_IS\",\n NOW: \"NOW\",\n TODAY: \"TODAY\",\n TOMORROW: \"TOMORROW\",\n YESTERDAY: \"YESTERDAY\",\n DURATION_DAY: \"DURATION_DAY\",\n DURATION_WEEK: \"DURATION_WEEK\",\n DURATION_MONTH: \"DURATION_MONTH\",\n DURATION_YEAR: \"DURATION_YEAR\",\n DURATION_HOUR: \"DURATION_HOUR\",\n DURATION_MINUTE: \"DURATION_MINUTE\",\n DURATION_SECOND: \"DURATION_SECOND\",\n FUNC: \"FUNC\",\n CONVERT: \"CONVERT\",\n TO: \"TO\",\n BEST: \"BEST\",\n NEXT: \"NEXT\",\n LAST: \"LAST\",\n UNTIL: \"UNTIL\",\n SINCE: \"SINCE\",\n BETWEEN: \"BETWEEN\",\n // Bill split (finance package). Retyped from the ordinary words \"split\",\n // \"ways\" and \"people\" by BillSplitNormalizerRule, but only inside the full\n // split shape, so those words stay usable as variable names and prose\n // everywhere else (the same contextual-claim discipline as the recurring\n // schedule and at-rate rules).\n // The verb-first `split <amount> between N` form (prefix).\n SPLIT: \"SPLIT\",\n // The amount-first `<amount> split N ways` form (infix). A separate,\n // infix-only token so implicit multiplication does not read it as the start\n // of a new value and insert a `*` before it, which the dual-role SPLIT would.\n SPLIT_WAYS: \"SPLIT_WAYS\",\n WAYS: \"WAYS\",\n PEOPLE: \"PEOPLE\",\n FROM: \"FROM\",\n INCREASE: \"INCREASE\",\n DECREASE: \"DECREASE\",\n UNICODE_MATH: \"UNICODE_MATH\",\n TIMES_BY: \"TIMES_BY\",\n MULTIPLY_BY: \"MULTIPLY_BY\",\n DIVIDE_BY: \"DIVIDE_BY\",\n NEQ: \"NEQ\",\n IN: \"IN\",\n BIT_XOR: \"BIT_XOR\",\n EQUALITY: \"EQUALITY\",\n GTE: \"GTE\",\n LTE: \"LTE\",\n LT: \"LT\",\n GT: \"GT\",\n LOGICAL_AND: \"LOGICAL_AND\",\n LOGICAL_OR: \"LOGICAL_OR\",\n OR: \"OR\",\n TRUE: \"TRUE\",\n FALSE: \"FALSE\",\n IF: \"IF\",\n THEN: \"THEN\",\n ELSE: \"ELSE\",\n AS: \"AS\",\n CONVERTER_NAME: \"CONVERTER_NAME\",\n // Rounding (packages/converters/). \"rounded\" is a bare keyword: it is a\n // past participle with no plausible use as a :variableName, the same\n // accepted-risk category as \"between\"/\"from\". TO_NEAREST and\n // DECIMAL_PLACES are fused, since \"to\" already means percentage change.\n ROUNDED: \"ROUNDED\",\n TO_NEAREST: \"TO_NEAREST\",\n DECIMAL_PLACES: \"DECIMAL_PLACES\",\n // Fused two-word phrase tokens (see MathPhrasesPackage.ts's `phrases`\n // field), deliberately NOT bare single-word keywords: \"average\"\n // \"total\", \"count\", etc. are common variable names, and this codebase\n // has a tested policy that colon-prefixed variable names can't be\n // keyword-shaped words (see VariableParselet.ts's doc comment). Fusing\n // the full \"<word> of\"/\"<word> between\" phrase means the bare word\n // itself never becomes its own token type, so \":total = ...\" keeps\n // working exactly as before.\n AVERAGE_OF: \"AVERAGE_OF\",\n MEDIAN_OF: \"MEDIAN_OF\",\n TOTAL_OF: \"TOTAL_OF\",\n COUNT_OF: \"COUNT_OF\",\n LARGER_OF: \"LARGER_OF\",\n SMALLER_OF: \"SMALLER_OF\",\n HALF_OF: \"HALF_OF\",\n MIDPOINT_BETWEEN: \"MIDPOINT_BETWEEN\",\n REMAINDER_OF: \"REMAINDER_OF\",\n NTH_ROOT: \"NTH_ROOT\",\n LOG_PHRASE: \"LOG_PHRASE\",\n LOG_BASE: \"LOG_BASE\",\n GCD_OF: \"GCD_OF\",\n LCM_OF: \"LCM_OF\",\n SQUARE_ROOT_OF: \"SQUARE_ROOT_OF\",\n CUBE_ROOT_OF: \"CUBE_ROOT_OF\",\n RANDOM_NUMBER: \"RANDOM_NUMBER\",\n IS_TO: \"IS_TO\",\n // Bare \"is\", the trigger for the solve-for-the-unknown percentage family\n // (packages/percentage/IsWhatParselet.ts). Safe as a bare keyword: it is a\n // verb, not a plausible :variableName, and the \"is to\" proportion phrase is\n // fused earlier so it still wins.\n IS: \"IS\",\n PCT_ON: \"PCT_ON\",\n PCT_OFF: \"PCT_OFF\",\n // Successive percentage change (packages/percentage/UpDownParselet.ts):\n // `X up N%` grows, `X down N%` shrinks, chainable with `then` and\n // repeatable with `N times`. Retyped from a bare `up`/`down` IDENT only\n // when a percentage immediately follows (PercentUpDownNormalizerRule), so\n // prose that merely mentions the words is untouched. Declared here rather\n // than minted lazily for the same reason as the algebra verbs below: a\n // normalizer rule and its parselet must agree on the id.\n PCT_UP: \"PCT_UP\",\n PCT_DOWN: \"PCT_DOWN\",\n OF_WHAT: \"OF_WHAT\",\n OFF_WHAT: \"OFF_WHAT\",\n ON_WHAT: \"ON_WHAT\",\n // CLAMP stays a bare single-word keyword: \"clamp X between Y and Z\" has\n // the value X between the trigger and \"between\", so it can't be\n // phrase-fused like the others above (same structural reason\n // ClampParselet.ts is hand-written instead of PhrasePattern-based).\n // Matches this codebase's existing accepted risk for \"between\"/\"from\"/\n // \"next\"/\"last\"/\"best\", also bare, also can't be used as `:name`.\n CLAMP: \"CLAMP\",\n // map/reduce/sum/prod (packages/mapreduce/), bare single-word keywords\n // each with its own dedicated parselet (custom argument grammar: a bare\n // builtin/user-function name, an inline transform expression, or\n // `name=collection` zipped pairs, none of which fit the ordinary\n // FunctionCallParselet path, so these can't just reuse the generic FUNC\n // token type the way sqrt/abs/... do).\n MAP: \"MAP\",\n REDUCE: \"REDUCE\",\n SUM_FN: \"SUM_FN\",\n PROD_FN: \"PROD_FN\",\n // The algebra verbs (packages/symbolic/), fused from an ordinary IDENT only\n // when immediately followed by `(`, so `factor`/`solve`/`expand` stay usable\n // as variable names. Declared here rather than left to be minted on first use\n // by `tokenTypeId()`, which is what {@link registerAllTokenTypes} exists for:\n // a lazily-minted id depends on what else happened to be minted before it, so\n // in a single-process run the id a normalizer rule produces can stop matching\n // the id the parselet was registered under. Every token type a built-in\n // package relies on belongs in this table.\n EXPAND_FN: \"EXPAND_FN\",\n FACTOR_FN: \"FACTOR_FN\",\n SOLVE_FN: \"SOLVE_FN\",\n DER_FN: \"DER_FN\",\n INTEGRAL_FN: \"INTEGRAL_FN\",\n TAYLOR_FN: \"TAYLOR_FN\",\n JACOBIAN_FN: \"JACOBIAN_FN\",\n CONJ_FN: \"CONJ_FN\",\n RE_FN: \"RE_FN\",\n IM_FN: \"IM_FN\",\n CANCEL_FN: \"CANCEL_FN\",\n APART_FN: \"APART_FN\",\n // The imaginary-literal suffix, fused from a number followed immediately by\n // `i`. Same registration reasoning as the verbs above.\n IMAGINARY: \"IMAGINARY\",\n // `=>`, \"therefore\"/solve operator. The algebra itself lives in symbolic/;\n // packages/symbolic/ carries the grammar surface for the named operations.\n // A genuine 2-char lexer token (ExpressionLexer.ts's TWO_CHAR_OPS table),\n // same mechanism as ==/!=/>=/<=, not a normalizer-level fusion, \"=\" then\n // \">\" is the opposite char order from GTE's \">=\", so there's no collision.\n THEREFORE: \"THEREFORE\",\n // Timezone query phrases (see TimePackage.ts's `phrases` field). Same\n // phrase-fusion reasoning as above: \"time\"/\"date\"/\"difference\" are\n // common variable names, so the fused trigger is the full phrase.\n // CITY_NAME is the fused-token type for multi-word city/country names\n // (e.g. \"new york\"). See timezones/CityZones.ts's MULTI_WORD_CITY_ZONES.\n TIME_IN: \"TIME_IN\",\n DATE_IN: \"DATE_IN\",\n TIME_DIFFERENCE_BETWEEN: \"TIME_DIFFERENCE_BETWEEN\",\n CITY_NAME: \"CITY_NAME\",\n BACKTICK_OPEN: \"BACKTICK_OPEN\",\n INLINE_SOLVE_START: \"INLINE_SOLVE_START\",\n // Comment marker, `#` or `//` to end of line. Emitted by\n // ExpressionLexer.tokenizeComment()/tokenizeOperator() but never reaches\n // a parselet: ExpressionEngine.prepareExpression() filters COMMENT\n // tokens out of the stream before normalization/parsing (see\n // ExpressionEngine.ts's \"Filter COMMENT tokens\" comments). Listed here\n // for discoverability even though tokenTypeId() would lazily register\n // it anyway on first use.\n COMMENT: \"COMMENT\",\n // A `#hex` colour literal (`#ff0000`), recognised by the lexer where `#`\n // would otherwise be a heading/comment; the colour package's parselet turns\n // it into a colour value. See ExpressionLexer.matchHexColourEnd().\n HEX_COLOUR: \"HEX_COLOUR\",\n // A bounded mid-line `#tag` annotation (`1200 #housing`). Stripped from\n // evaluation by the tags package's strip rule, or consumed by its aggregate\n // rule (`total of #housing`). A line-start `#` is a heading, and `# ` (space)\n // or `//` is still a free-text comment.\n TAG: \"TAG\",\n // A colour function call fused by the colour package's normalizer, e.g.\n // `rgb(`/`lighten(`. Carries the function name; see ColourCallParselet.\n COLOUR_CALL: \"COLOUR_CALL\",\n // Vector types (referenced in locale keywordMap as vec2→VEC2, etc.)\n VEC2: \"VEC2\",\n VEC3: \"VEC3\",\n VEC4: \"VEC4\",\n FLOAT: \"FLOAT\",\n GLOBAL: \"GLOBAL\",\n // ── Finance (packages/finance/) ──\n // OVER/RATE_AT are bare single-word keywords (not phrase-fused): both are\n // prepositions with near-zero plausibility as a variable name (nobody\n // writes \":over = 5\" or \":at = 3\"), the same accepted-risk category as\n // this codebase's existing bare \"between\"/\"from\"/\"next\"/\"last\"/\"best\"\n // keywords (see VariableParselet.ts's doc comment). RATE_AT is deliberately\n // NOT named \"AT\", that name is already reserved (dormant) for a future\n // \"@\" symbol token in TokenNormalizer.NON_WORD_NAMES; reusing it here would\n // create an unintended coupling if \"@\" is ever wired up.\n OVER: \"OVER\",\n RATE_AT: \"RATE_AT\",\n // The investment grammar's connectives (packages/finance/), same\n // accepted-risk category as OVER/RATE_AT above. \"after\"/\"for\" are\n // prepositions; \"compounding\", \"invested\" and \"returned\" are participles,\n // and none is a plausible `:variableName`.\n //\n // \"after\" and \"for\" are the pivots Soulver's own documented syntax uses,\n // `$1,000 after 3 years at 7%` and `$1,000 for 3 years at 7% compounding\n // monthly`. This package originally substituted \"over\" for both and said so\n // in CompoundInterestParselet.ts's doc comment; the documented spellings now\n // work as well, and \"over\" is kept so nothing that already parsed stops.\n AFTER: \"AFTER\",\n PRESENT_VALUE_OF: \"PRESENT_VALUE_OF\",\n ANNUAL_RETURN_ON: \"ANNUAL_RETURN_ON\",\n FOR_DURATION: \"FOR_DURATION\",\n COMPOUNDING: \"COMPOUNDING\",\n INVESTED: \"INVESTED\",\n RETURNED: \"RETURNED\",\n // Fused phrase tokens (see FinancePackage.ts's `phrases` field)\n // deliberately NOT bare single-word keywords: \"interest\", \"tax\", \"vat\",\n // \"repayment\", \"principal\" etc. are all common, plausible variable names\n // (a shipped playground example uses \":total = :subtotal + :tax\". See\n // MathPhrasesPackage.ts's doc comment for the regression this caused\n // once already). Fusing the full \"<word> on\"/\"<word> off\" phrase means\n // the bare leading word itself never becomes its own token type, so\n // \":tax = ...\" keeps working exactly as before.\n COMPOUND_INTEREST_ON: \"COMPOUND_INTEREST_ON\",\n INTEREST_ON: \"INTEREST_ON\",\n DAILY_REPAYMENT_ON: \"DAILY_REPAYMENT_ON\",\n MONTHLY_REPAYMENT_ON: \"MONTHLY_REPAYMENT_ON\",\n ANNUAL_REPAYMENT_ON: \"ANNUAL_REPAYMENT_ON\",\n TOTAL_REPAYMENT_ON: \"TOTAL_REPAYMENT_ON\",\n DAILY_LOAN_INTEREST_ON: \"DAILY_LOAN_INTEREST_ON\",\n MONTHLY_LOAN_INTEREST_ON: \"MONTHLY_LOAN_INTEREST_ON\",\n ANNUAL_LOAN_INTEREST_ON: \"ANNUAL_LOAN_INTEREST_ON\",\n TOTAL_LOAN_INTEREST_ON: \"TOTAL_LOAN_INTEREST_ON\",\n TAX_ON: \"TAX_ON\",\n TAX_OFF: \"TAX_OFF\",\n TAX_IN_PHRASE: \"TAX_IN_PHRASE\",\n // Inflation-adjusted value (packages/finance/) -- fused phrase\n // tokens (see FinancePackage.ts's `phrases` field), same reasoning\n // as the tax/interest phrases above: \"what\"/\"was\"/\"value\"/\"worth\"\n // are all plausible variable names, so only the full phrases are\n // ever claimed as keywords, never the bare leading word.\n WHAT_IS: \"WHAT_IS\",\n WHAT_WAS: \"WHAT_WAS\",\n VALUE_OF: \"VALUE_OF\",\n WORTH_IN: \"WORTH_IN\",\n // Savings goals (finance). Fused whole-phrase triggers, so \"how\", \"much\",\n // \"save\" and \"reach\" stay ordinary variable names, the same reason as the\n // other finance phrases above.\n SAVINGS_HOW_LONG: \"SAVINGS_HOW_LONG\",\n SAVINGS_HOW_MUCH: \"SAVINGS_HOW_MUCH\",\n // Bare single-word keyword (not phrase-fused) -- \"assuming\" has\n // near-zero plausibility as a variable name, the same accepted-risk\n // category as this codebase's existing bare \"over\"/\"at\" keywords\n // (see the OVER/RATE_AT comment above). Registered so its bare word\n // is a recognized phrase-starter (`canStartPhrase`), which suppresses\n // implicit-multiply insertion between the futureYear NUMBER and this\n // word in \"value of $X in <year> assuming N% inflation\" -- without\n // this, \"<year> assuming\" was silently rewritten to \"<year> *\n // assuming\" before parsing ever ran.\n ASSUMING: \"ASSUMING\",\n // Fused by a custom NormalizerRule (not `phrases`), carrying the\n // year as its value -- see\n // finance/normalizer/InYearDollarsNormalizerRule.ts.\n IN_YEAR_DOLLARS: \"IN_YEAR_DOLLARS\",\n // Cooking/UoM (packages/uom/) -- fused ingredient name (single- or\n // multi-word, e.g. \"butter\"/\"olive oil\") carrying the matched name\n // as its value. NOT a bare-word phrase-trie keyword -- see\n // uom/normalizer/IngredientNameNormalizerRule.ts's doc comment for\n // why this is a context-sensitive NormalizerRule instead (so a bare\n // `:butter = 5` variable definition is completely unaffected).\n INGREDIENT_NAME: \"INGREDIENT_NAME\",\n // ── Datetime, workdays/weekdays/timestamps (packages/datetime/) ──\n // Fused phrase tokens (see DatetimePackage.ts's `phrases` field)\n // deliberately NOT bare single-word keywords: \"workdays\"/\"weekday\"/\n // \"timestamp\"/\"date\" are all plausible variable names, same\n // reasoning/regression risk as MathPhrasesPackage.ts's \"total\" note and\n // FinancePackage.ts's \"tax\" note above. Fusing the full phrase means the\n // bare leading word itself never becomes its own token type, so e.g.\n // \":timestamp = 5\" keeps working.\n WORKDAYS_IN: \"WORKDAYS_IN\",\n WEEKDAY_ON: \"WEEKDAY_ON\",\n CURRENT_TIMESTAMP: \"CURRENT_TIMESTAMP\",\n TO_DATE: \"TO_DATE\",\n TO_TIMESTAMP: \"TO_TIMESTAMP\",\n // Natural-question forms over the same date fields, \"what day is it in\n // 30 days\", \"what month is it on 25/12/2026\", \"what week is it\". Each is\n // a fully-fused phrase for the same reason as WEEKDAY_ON above: claiming\n // bare \"day\"/\"month\"/\"week\" as keywords would break \":day = 5\" and\n // collide with the UNIT tokens of the same name.\n WEEKDAY_IN: \"WEEKDAY_IN\",\n MONTH_ON: \"MONTH_ON\",\n MONTH_IN: \"MONTH_IN\",\n WEEK_ON: \"WEEK_ON\",\n DAYS_IN_PERIOD: \"DAYS_IN_PERIOD\",\n IN_TWO_UNITS: \"IN_TWO_UNITS\",\n PER_UNIT: \"PER_UNIT\",\n AT_RATE: \"AT_RATE\",\n WEEK_IN: \"WEEK_IN\",\n // `<unit> between <date> and <date>`, fused UNIT+BETWEEN, exactly like\n // UNTIL_UNIT/SINCE_UNIT above.\n BETWEEN_UNIT: \"BETWEEN_UNIT\",\n // Business-day arithmetic in words, \"N working/business days after|from|\n // before <date>\" (infix, the count is the left operand) and \"working/\n // business days between <date> and <date>\" (prefix). Full phrases for the\n // same reason as WORKDAYS_IN above: \"working\"/\"business\" are ordinary words,\n // so only the complete phrase is claimed, never the bare leading word. See\n // WorkdayOffsetParselet.ts / WorkdaysBetweenParselet.ts.\n WORKDAYS_AFTER: \"WORKDAYS_AFTER\",\n WORKDAYS_BEFORE: \"WORKDAYS_BEFORE\",\n WORKDAYS_BETWEEN: \"WORKDAYS_BETWEEN\",\n // Postfix day-type predicates, \"<date> is a weekend\" / \"is a workday\".\n IS_WEEKEND: \"IS_WEEKEND\",\n IS_WORKDAY: \"IS_WORKDAY\",\n // ── Time, video timecode (packages/time/) ──\n // Fused from a raw `HH:MM:SS:FF` token sequence (see\n // packages/time/normalizer/VideoTimecodeNormalizerRule.ts) and from\n // `NUMBER frames` (see FrameCountNormalizerRule.ts), not a bare-keyword\n // collision risk the way the datetime tokens above are, since neither\n // fusion claims a plain English word as its own token type.\n VIDEO_TIMECODE: \"VIDEO_TIMECODE\",\n FRAME_COUNT: \"FRAME_COUNT\",\n // \"@\". See ExpressionLexer.ts's OP_MAP entry for why this was\n // previously dormant/unproduced despite being anticipated by name here\n // and in TokenNormalizer.ts's NON_WORD_NAMES.\n AT: \"AT\",\n // Generic token for every currency symbol added AFTER the original\n // DOLLAR/POUND/EURO/YEN/RUBLE/WON set (each of which kept its own\n // specific token type for backward compatibility). See\n // uom/CurrencyAliases.ts's CURRENCY_SYMBOL_ALIASES and\n // ExpressionLexer.ts's dispatch for the full symbol list. One shared\n // type avoids needing a new TokenTypes entry + TokenCategoryMap entry +\n // CurrencyPackage.ts prefixParselets entry per additional symbol.\n CURRENCY_SYMBOL: \"CURRENCY_SYMBOL\",\n // ── Cross-line data access (packages/lines/) ──\n // \"prev\" -- bare keyword (nothing to phrase-fuse against, same shape as\n // CLAMP -- accepted collision risk per that package's own precedent).\n PREV: \"PREV\",\n // \"line1\" / \"line 1\" / \"l1\" -- fused by LineRefNormalizerRule (never a\n // bare lexer keyword, so \":line = 5\"/\":l = 5\" stay untouched). Carries\n // the parsed line number as its .value.\n LINE_REF: \"LINE_REF\",\n // \"sum(\" / \"total(\" -- fused ONLY when immediately followed by LPAREN\n // (see LineRefNormalizerRule's lookahead guard), so \":sum = 100\" and\n // MathPhrases' \"total of X, Y\" (no paren after \"of\") are unaffected.\n SUM_RANGE_CALL: \"SUM_RANGE_CALL\",\n AVERAGE_RANGE_CALL: \"AVERAGE_RANGE_CALL\",\n // \"total above\" / \"sum above\" / \"average above\" -- phrase-fused (see\n // LinesPackage.ts's `phrases` field), a deliberate departure from\n // Numi/Numbr's bare \"total\"/\"sum\" wording to avoid the exact bare-\n // keyword collision this codebase already regressed on once.\n TOTAL_ABOVE: \"TOTAL_ABOVE\",\n SUM_ABOVE: \"SUM_ABOVE\",\n AVERAGE_ABOVE: \"AVERAGE_ABOVE\",\n // ── Goal seek (packages/goalseek/) ──\n // \"solve line 4 for rate = 900\" -- fused by GoalSeekNormalizerRule when the\n // bare word \"solve\" is immediately followed by a LINE_REF (never a bare\n // lexer keyword, so \":solve = 2\" and the existing \"solve(...)\" call form\n // both stay untouched, since neither is \"solve\" directly before a LINE_REF).\n GOAL_SEEK: \"GOAL_SEEK\",\n} as const;\n\n/**\n * A token's kind, as a string.\n *\n * Deliberately open rather than an enum: a package registers its own token\n * types at runtime, and a closed set would make that impossible.\n */\nexport type TokenType = (typeof TokenTypes)[keyof typeof TokenTypes];\n\n// ── Integer Token Type ID System ──────────────────────────────────────────────\n// Enables O(1) integer comparison in Parser hot path instead of string hashing.\n\n/** Auto-incrementing integer ID for each token type. */\nlet _nextTokenTypeId = 0;\n\n/** String → integer ID lookup. Populated lazily via registerTokenType(). */\nconst _tokenTypeNameToId = new Map<string, number>();\n\n/** Integer ID → string lookup. For debug/error messages. */\nconst _tokenTypeIdToName = new Map<number, string>();\n\n/**\n * Register a token type name and get back its integer ID.\n * Idempotent, returns existing ID if already registered.\n * Call once per token type at module initialization time.\n */\nexport function registerTokenType(name: string): number {\n\tconst existing = _tokenTypeNameToId.get(name);\n\tif (existing !== undefined) return existing;\n\tconst id = _nextTokenTypeId++;\n\t_tokenTypeNameToId.set(name, id);\n\t_tokenTypeIdToName.set(id, name);\n\treturn id;\n}\n\n/**\n * Get the integer ID for a token type name.\n * Lazily registers unknown token types on first access, enabling plugin providers\n * to define custom token types (VEC2, VEC3, etc.) without pre-registration.\n * All built-in TokenTypes are pre-registered via registerAllTokenTypes().\n */\nexport function tokenTypeId(name: string): number {\n\treturn registerTokenType(name); // registerTokenType is idempotent\n}\n\n/**\n * Get the string name for a token type ID (for error messages and debugging).\n * Returns `UNKNOWN_${id}` if the ID is not registered.\n */\nexport function tokenTypeName(id: number): string {\n\treturn _tokenTypeIdToName.get(id) ?? `UNKNOWN_${id}`;\n}\n\n/**\n * Bootstrap all known token types from TokenTypes at module load.\n * Call this once after TokenTypes is defined.\n */\nexport function registerAllTokenTypes(): void {\n\tfor (const name of Object.values(TokenTypes)) {\n\t\tregisterTokenType(name);\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkFYAMQFZZ_cjs=require('./chunk-FYAMQFZZ.cjs'),chunkWGP4UUO5_cjs=require('./chunk-WGP4UUO5.cjs'),chunkSQHBOWES_cjs=require('./chunk-SQHBOWES.cjs'),chunkZKFCKAIX_cjs=require('./chunk-ZKFCKAIX.cjs'),chunkEZKR44MA_cjs=require('./chunk-EZKR44MA.cjs'),chunkYBQPEWT7_cjs=require('./chunk-YBQPEWT7.cjs');function jt(e,t){let n=t===2?chunkWGP4UUO5_cjs.L:chunkWGP4UUO5_cjs.M,o=n(e.n),r=n(e.d);return o===null||r===null?null:{n:o,d:r}}function Kt(e,t){let n=chunkWGP4UUO5_cjs.y(e),o=new Map;for(let[r,i]of n){if(i%t!==0)return null;o.set(r,i/t);}return chunkWGP4UUO5_cjs.x(o)}function Xn(e,t){let n=chunkWGP4UUO5_cjs.y(e);for(let[o,r]of chunkWGP4UUO5_cjs.y(t))n.set(o,(n.get(o)??0)+r);return chunkWGP4UUO5_cjs.x(n)}function Xt(e,t){let n=chunkWGP4UUO5_cjs.y(e);for(let[o,r]of chunkWGP4UUO5_cjs.y(t)){let i=(n.get(o)??0)-r;i<=0?n.delete(o):n.set(o,i);}return chunkWGP4UUO5_cjs.x(n)}function Zn(e,t){let n=chunkWGP4UUO5_cjs.y(e),o=new Map;for(let[r,i]of chunkWGP4UUO5_cjs.y(t)){let a=n.get(r);a!==void 0&&o.set(r,Math.min(a,i));}return chunkWGP4UUO5_cjs.x(o)}function Hn(e){let t=new Set;for(let n of e)for(let o of chunkWGP4UUO5_cjs.y(n).keys())t.add(o);return [...t].sort()}function Q(e){let t=new Map;for(let n of e)t.set(n.key,n.coefficient);return chunkWGP4UUO5_cjs.E({terms:t,vars:Hn(e.map(n=>n.key))})}function Ze(e){let t=e[0];for(let n=1;n<e.length;n++)t={kind:"mul",left:t,right:e[n]};return t}function Wn(e){return [...e.terms].map(([n,o])=>({key:n,coefficient:o})).sort((n,o)=>chunkWGP4UUO5_cjs.D(n.key,o.key,e.vars))}function Wt(e){if(e.vars.length<2)return null;let t=Wn(e);return t.length===2?Qn(t[0],t[1]):t.length===3?zn(t):t.length===4?Jn(t):null}function Qn(e,t){let n=e.coefficient.n>0n,o=t.coefficient.n>0n;if(!n)return null;let r=He(e,t,2);if(r!==null&&!o)return Ze([Q([r.a,Te(r.b)]),Q([r.a,r.b])]);let i=He(e,t,3);if(i===null)return null;let a=Q(o?[i.a,i.b]:[i.a,Te(i.b)]),u=o?Te(Oe(i.a,i.b)):Oe(i.a,i.b);return Ze([a,Q([Zt(i.a),u,Zt(i.b)])])}function He(e,t,n){let o=t.coefficient.n<0n?chunkWGP4UUO5_cjs.j(t.coefficient):t.coefficient,r=jt(e.coefficient,n),i=jt(o,n);if(r===null||i===null)return null;let a=Kt(e.key,n),u=Kt(t.key,n);return a===null||u===null?null:{a:{key:a,coefficient:r},b:{key:u,coefficient:i}}}function Te(e){return {key:e.key,coefficient:chunkWGP4UUO5_cjs.j(e.coefficient)}}function Oe(e,t){return {key:Xn(e.key,t.key),coefficient:chunkWGP4UUO5_cjs.h(e.coefficient,t.coefficient)}}function Zt(e){return Oe(e,e)}function zn(e){let[t,n,o]=e;if(t.coefficient.n<0n||o.coefficient.n<0n)return null;let r=He(t,o,2);if(r===null)return null;let i=Oe(r.a,r.b);if(i.key!==n.key)return null;let a=chunkWGP4UUO5_cjs.h(i.coefficient,{n:2n,d:1n}),u=n.coefficient.n<0n,l=u?chunkWGP4UUO5_cjs.j(n.coefficient):n.coefficient;return chunkWGP4UUO5_cjs.m(chunkWGP4UUO5_cjs.i(l,a))?{kind:"pow",base:Q([r.a,u?Te(r.b):r.b]),exponent:chunkWGP4UUO5_cjs.p(2)}:null}function Jn(e){let t=[[[0,1],[2,3]],[[0,2],[1,3]],[[0,3],[1,2]]];for(let n of t){let o=Ht(e[n[0][0]],e[n[0][1]]),r=Ht(e[n[1][0]],e[n[1][1]]);if(!(o===null||r===null)&&eo(o.cofactor,r.cofactor))return Ze([Q([o.common,r.common]),Q(o.cofactor)])}return null}function Ht(e,t){let n=Zn(e.key,t.key),o={key:n,coefficient:e.coefficient},r=[{key:Xt(e.key,n),coefficient:{n:1n,d:1n}},{key:Xt(t.key,n),coefficient:chunkWGP4UUO5_cjs.i(t.coefficient,e.coefficient)}];return r[0].key===r[1].key?null:{common:o,cofactor:r}}function eo(e,t){return e.length!==t.length?false:e.every((n,o)=>n.key===t[o].key&&n.coefficient.n===t[o].coefficient.n&&n.coefficient.d===t[o].coefficient.d)}var to=12,_e=4096;function we(e,t){let n=e<0n?-e:e,o=t<0n?-t:t;for(;o!==0n;){let r=n%o;n=o,o=r;}return n}function zt(e,t){return e===0n||t===0n?0n:e/we(e,t)*t}function Qt(e){let t=e<0n?-e:e;if(t===0n)return null;let n=[];for(let o=1n;o*o<=t;o++){if(t%o!==0n)continue;n.push(o);let r=t/o;if(r!==o&&n.push(r),n.length>_e)return null}return n}function Jt(e,t){let n=chunkWGP4UUO5_cjs.a;for(let o of e)n=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.h(n,t),o);return n}function no(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(chunkWGP4UUO5_cjs.f(e[o],chunkWGP4UUO5_cjs.h(n[o-1],t)));return n}function ue(e){if(e.length<2)return [];let t=1n;for(let s of e)t=zt(t,s.d);let n=e.map(s=>s.n*t/s.d),o=n[0],r=n[n.length-1];if(r===0n)return [];let i=Qt(r),a=Qt(o);if(i===null||a===null)throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial's coefficients have too many divisors to search for rational roots.",{limit:_e});if(i.length*a.length>_e)throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial has too many candidate rational roots to test.",{limit:_e});let u=[],l=new Set;for(let s of i)for(let p of a)for(let h of [1n,-1n]){let v={n:h*s/we(s,p),d:p/we(s,p)},V=`${v.n}/${v.d}`;l.has(V)||(l.add(V),chunkWGP4UUO5_cjs.l(Jt(e,v))&&u.push(v));}return u}function oo(e,t){return chunkWGP4UUO5_cjs.l(t)?chunkWGP4UUO5_cjs.q(e):t.n>0n?{kind:"sub",left:chunkWGP4UUO5_cjs.q(e),right:chunkWGP4UUO5_cjs.p(t)}:{kind:"add",left:chunkWGP4UUO5_cjs.q(e),right:chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.j(t))}}function ro(e,t){let n=e.length-1,o=new Map;return e.forEach((r,i)=>{if(chunkWGP4UUO5_cjs.l(r))return;let a=n-i;o.set(a===0?"":a===1?t:`${t}^${a}`,r);}),chunkWGP4UUO5_cjs.E({terms:o,vars:o.size>0?[t]:[]})}function Qe(e,t){let n=[],o=[...e],r=ue(o);for(;r.length>0&&o.length>2;){for(let a of r){let u=0;for(;o.length>1&&chunkWGP4UUO5_cjs.l(Jt(o,a));)o=no(o,a),u++;u>0&&n.push({base:oo(t,a),power:u});}r=o.length>2?ue(o):[];}return o.length-1>=1?(n.push({base:ro(o,t),power:1}),{content:chunkWGP4UUO5_cjs.b,factors:n}):{content:o.length===1?o[0]:chunkWGP4UUO5_cjs.b,factors:n}}function io(e){let t=[];chunkWGP4UUO5_cjs.m(e.content)||t.push(chunkWGP4UUO5_cjs.p(e.content));for(let o of e.factors)t.push(o.power===1?o.base:chunkWGP4UUO5_cjs.r(o.base,chunkWGP4UUO5_cjs.p({n:BigInt(o.power),d:1n})));if(t.length===0)return chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.b);let n=t[0];for(let o=1;o<t.length;o++)n={kind:"mul",left:n,right:t[o]};return n}function ao(e){let t=0n,n=1n;for(let o of e.terms.values())t=we(t,o.n),n=zt(n,o.d);return t===0n?chunkWGP4UUO5_cjs.b:{n:t,d:n}}function uo(e){let t=new Map;for(let r of e.vars){let i=1/0;for(let a of e.terms.keys()){let u=lo(a,r);u<i&&(i=u);}i>0&&i!==1/0&&t.set(r,i);}if(t.size===0)return {monomial:t,reduced:e};let n=new Map;for(let[r,i]of e.terms){let a=We(r);for(let[u,l]of t)a.set(u,(a.get(u)??0)-l);n.set(so(a),i);}let o=new Set;for(let r of n.keys())for(let i of We(r).keys())o.add(i);return {monomial:t,reduced:{terms:n,vars:[...o].sort()}}}function lo(e,t){return We(e).get(t)??0}function We(e){let t=new Map;if(e==="")return t;for(let n of e.split("*")){let o=n.indexOf("^");o===-1?t.set(n,1):t.set(n.slice(0,o),Number(n.slice(o+1)));}return t}function so(e){return [...e.keys()].filter(n=>(e.get(n)??0)>0).sort().map(n=>e.get(n)===1?n:`${n}^${e.get(n)}`).join("*")}function co(e){let t=[...e.keys()].sort(),n=null;for(let o of t){let r=e.get(o),i=r===1?chunkWGP4UUO5_cjs.q(o):chunkWGP4UUO5_cjs.r(chunkWGP4UUO5_cjs.q(o),chunkWGP4UUO5_cjs.p({n:BigInt(r),d:1n}));n=n===null?i:{kind:"mul",left:n,right:i};}return n}function en(e){let t=chunkWGP4UUO5_cjs.C(e);if(t===null||t.terms.size===0||chunkWGP4UUO5_cjs.z(t)>to||t.vars.length===0)return e;let n=ao(t),o=chunkWGP4UUO5_cjs.m(n)?t:mo(t,chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.b,n)),{monomial:r,reduced:i}=uo(o),a=co(r),u=chunkWGP4UUO5_cjs.A(i);if(u===null){let te=Wt(i);return te!==null?fo(n,a,te):po(n,a,i)??e}let l=[...chunkWGP4UUO5_cjs.B(i,u)].reverse(),s=Qe(l,u),p=chunkWGP4UUO5_cjs.h(n,s.content);if(s.factors.length<=1&&(s.factors[0]?.power??1)===1&&a===null&&chunkWGP4UUO5_cjs.m(p))return e;let v=[];chunkWGP4UUO5_cjs.m(p)||v.push(chunkWGP4UUO5_cjs.p(p)),a!==null&&v.push(a),v.push(io({content:chunkWGP4UUO5_cjs.b,factors:s.factors}));let V=v[0];for(let te=1;te<v.length;te++)V={kind:"mul",left:V,right:v[te]};return V}function mo(e,t){let n=new Map;for(let[o,r]of e.terms)n.set(o,chunkWGP4UUO5_cjs.h(r,t));return {terms:n,vars:e.vars}}function fo(e,t,n){let o=[];chunkWGP4UUO5_cjs.m(e)||o.push(chunkWGP4UUO5_cjs.p(e)),t!==null&&o.push(t),o.push(n);let r=o[0];for(let i=1;i<o.length;i++)r={kind:"mul",left:r,right:o[i]};return r}function po(e,t,n){if(t===null&&chunkWGP4UUO5_cjs.m(e))return null;let o=[];chunkWGP4UUO5_cjs.m(e)||o.push(chunkWGP4UUO5_cjs.p(e)),t!==null&&o.push(t),o.push(chunkWGP4UUO5_cjs.E(n));let r=o[0];for(let i=1;i<o.length;i++)r={kind:"mul",left:r,right:o[i]};return r}var k={n:2n,d:1n},B={n:3n,d:1n},be={n:4n,d:1n};function bo(e,t,n,o){let r=chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.i(t,chunkWGP4UUO5_cjs.h(B,e))),i=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.h(B,chunkWGP4UUO5_cjs.h(e,n)),chunkWGP4UUO5_cjs.h(t,t)),chunkWGP4UUO5_cjs.h(B,chunkWGP4UUO5_cjs.h(e,e))),a=chunkWGP4UUO5_cjs.h(k,chunkWGP4UUO5_cjs.h(t,chunkWGP4UUO5_cjs.h(t,t))),u=chunkWGP4UUO5_cjs.h({n:9n,d:1n},chunkWGP4UUO5_cjs.h(e,chunkWGP4UUO5_cjs.h(t,n))),l=chunkWGP4UUO5_cjs.h({n:27n,d:1n},chunkWGP4UUO5_cjs.h(chunkWGP4UUO5_cjs.h(e,e),o)),s=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.g(a,u),l),chunkWGP4UUO5_cjs.h({n:27n,d:1n},chunkWGP4UUO5_cjs.h(e,chunkWGP4UUO5_cjs.h(e,e))));return {p:i,q:s,shift:r}}function nn(e,t,n,o){let{p:r,q:i,shift:a}=bo(e,t,n,o),u=chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.h(be,chunkWGP4UUO5_cjs.h(r,chunkWGP4UUO5_cjs.h(r,r))),chunkWGP4UUO5_cjs.h({n:27n,d:1n},chunkWGP4UUO5_cjs.h(i,i))));return chunkWGP4UUO5_cjs.k(u,chunkWGP4UUO5_cjs.a)>0?{exact:[],approximate:No(r,i,a)}:chunkWGP4UUO5_cjs.l(u)?{exact:yo(r,i,a),approximate:[]}:{exact:ho(r,i,a),approximate:[]}}function yo(e,t,n){if(chunkWGP4UUO5_cjs.l(e))return [chunkWGP4UUO5_cjs.p(n)];let o=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(B,t),e),n),r=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(B,t),chunkWGP4UUO5_cjs.h(k,e))),n);return [o,r].sort(chunkWGP4UUO5_cjs.k).map(chunkWGP4UUO5_cjs.p)}function ho(e,t,n){let o=chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.i(t,k)),r=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.h(chunkWGP4UUO5_cjs.i(t,k),chunkWGP4UUO5_cjs.i(t,k)),chunkWGP4UUO5_cjs.h(chunkWGP4UUO5_cjs.i(e,B),chunkWGP4UUO5_cjs.h(chunkWGP4UUO5_cjs.i(e,B),chunkWGP4UUO5_cjs.i(e,B)))),i=chunkWGP4UUO5_cjs.O(r),a={kind:"call",name:"cbrt",args:[{kind:"add",left:chunkWGP4UUO5_cjs.p(o),right:i}]},u={kind:"call",name:"cbrt",args:[{kind:"sub",left:chunkWGP4UUO5_cjs.p(o),right:i}]},l={kind:"add",left:a,right:u},s={kind:"sub",left:a,right:u},p={kind:"add",left:chunkWGP4UUO5_cjs.p(n),right:{kind:"div",left:{kind:"neg",operand:l},right:chunkWGP4UUO5_cjs.p(k)}},h={kind:"mul",left:{kind:"div",left:{kind:"mul",left:s,right:chunkWGP4UUO5_cjs.O(B)},right:chunkWGP4UUO5_cjs.p(k)},right:chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.n)};return [{kind:"add",left:chunkWGP4UUO5_cjs.p(n),right:l},{kind:"sub",left:p,right:h},{kind:"add",left:p,right:h}]}function No(e,t,n){let o=chunkWGP4UUO5_cjs.e(e),r=chunkWGP4UUO5_cjs.e(t),i=chunkWGP4UUO5_cjs.e(n),a=2*Math.sqrt(-o/3),u=3*r/(2*o)*Math.sqrt(-3/o),l=Math.acos(Math.min(1,Math.max(-1,u)))/3;return [0,1,2].map(s=>a*Math.cos(l-2*Math.PI*s/3)+i).sort((s,p)=>s-p)}function go(e,t,n,o){let r=chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.i(e,be)),i=chunkWGP4UUO5_cjs.h(e,e),a=chunkWGP4UUO5_cjs.g(t,chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(B,i),{n:8n,d:1n})),u=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.g(n,chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(e,t),k)),chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(i,e),{n:8n,d:1n})),l=chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.g(o,chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(e,n),be)),chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(i,t),{n:16n,d:1n})),chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.h(B,chunkWGP4UUO5_cjs.h(i,i)),{n:256n,d:1n}));return {p:a,q:u,r:l,shift:r}}function on(e,t,n,o,r,i){let a=V=>chunkWGP4UUO5_cjs.i(V,e),{p:u,q:l,r:s,shift:p}=go(a(t),a(n),a(o),a(r)),h=chunkWGP4UUO5_cjs.l(l)?xo(u,s):So(u,l,s,i);if(h===null)return null;let v=chunkWGP4UUO5_cjs.l(p)?h:h.map(V=>({kind:"add",left:chunkWGP4UUO5_cjs.p(p),right:V}));return {exact:Ro(v),approximate:[]}}function Ro(e){let t=new Set,n=[];for(let o of e){let r=chunkWGP4UUO5_cjs.t(chunkWGP4UUO5_cjs.Q(o));t.has(r)||(t.add(r),n.push(o));}return n}function xo(e,t){let n=chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.h(e,e),chunkWGP4UUO5_cjs.h(be,t));if(chunkWGP4UUO5_cjs.k(n,chunkWGP4UUO5_cjs.a)<0)return Mo(e,t);let o=chunkWGP4UUO5_cjs.N(n);return o!==null?vo(chunkWGP4UUO5_cjs.j(e),o,chunkWGP4UUO5_cjs.l(n)):Io(e,t,n)}function vo(e,t,n){let o=n?[chunkWGP4UUO5_cjs.i(e,k)]:[chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.f(e,t),k),chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.g(e,t),k)],r=[];for(let i of o){if(chunkWGP4UUO5_cjs.l(i)){r.push(chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.a));continue}let a=chunkWGP4UUO5_cjs.P(i);r.push({kind:"neg",operand:a},a);}return r}function Io(e,t,n){let o=chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.j(e)),r=chunkWGP4UUO5_cjs.O(n),i=chunkWGP4UUO5_cjs.k(e,chunkWGP4UUO5_cjs.a)<=0,a=[{node:ze({kind:"add",left:o,right:r}),positive:i||chunkWGP4UUO5_cjs.k(t,chunkWGP4UUO5_cjs.a)<=0},{node:ze({kind:"sub",left:o,right:r}),positive:i&&chunkWGP4UUO5_cjs.k(t,chunkWGP4UUO5_cjs.a)>=0}],u=[];for(let{node:l,positive:s}of a){let h={kind:"call",name:"sqrt",args:[s?l:{kind:"neg",operand:l}]},v=s?h:{kind:"mul",left:h,right:chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.n)};u.push({kind:"neg",operand:v},v);}return u}function ze(e){return {kind:"div",left:e,right:chunkWGP4UUO5_cjs.p(k)}}function Mo(e,t){let n=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.j(e),k),o=chunkWGP4UUO5_cjs.N(t),r=o===null?tn(chunkWGP4UUO5_cjs.O(t),n):chunkWGP4UUO5_cjs.O(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.f(o,n),k)),a={kind:"mul",left:o===null?tn(chunkWGP4UUO5_cjs.O(t),chunkWGP4UUO5_cjs.j(n)):chunkWGP4UUO5_cjs.O(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.g(o,n),k)),right:chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.n)},u={kind:"add",left:r,right:a},l={kind:"sub",left:r,right:a};return [{kind:"neg",operand:u},{kind:"neg",operand:l},l,u]}function tn(e,t){let n=t.n>=0n?{kind:"add",left:e,right:chunkWGP4UUO5_cjs.p(t)}:{kind:"sub",left:e,right:chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.j(t))};return {kind:"call",name:"sqrt",args:[ze(n)]}}function So(e,t,n,o){let r=[{n:1n,d:1n},chunkWGP4UUO5_cjs.h(k,e),chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.h(e,e),chunkWGP4UUO5_cjs.h(be,n)),chunkWGP4UUO5_cjs.j(chunkWGP4UUO5_cjs.h(t,t))];for(let i of ue(r)){if(chunkWGP4UUO5_cjs.k(i,chunkWGP4UUO5_cjs.a)<=0)continue;let a=chunkWGP4UUO5_cjs.N(i);if(a===null)continue;let u=chunkWGP4UUO5_cjs.f(e,i),l=chunkWGP4UUO5_cjs.i(t,a),s=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.g(u,l),k),p=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.f(u,l),k),h={n:1n,d:1n};return [...o(h,a,s),...o(h,chunkWGP4UUO5_cjs.j(a),p)]}return null}var Eo=200,Ao=1e-14,ko=1e-10,Vo=1e-10,rn=1e-9,To=1e-8,Oo=4;function ye(e,t){return {re:e.re-t.re,im:e.im-t.im}}function _o(e,t){return {re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function un(e,t){if(Math.abs(t.re)>=Math.abs(t.im)){let r=t.im/t.re,i=t.re+t.im*r;return {re:(e.re+e.im*r)/i,im:(e.im-e.re*r)/i}}let n=t.re/t.im,o=t.re*n+t.im;return {re:(e.re*n+e.im)/o,im:(e.im*n-e.re)/o}}function K(e){return Math.hypot(e.re,e.im)}function De(e,t){let n=0,o=0;for(let r of e){let i=n*t.re-o*t.im+r;o=n*t.im+o*t.re,n=i;}return {re:n,im:o}}function wo(e,t){let n=K(t),o=0;for(let r of e)o=o*n+Math.abs(r);return o}function Do(e){let t=e.length-1,n=[];for(let o=0;o<t;o++)n.push(e[o]*(t-o));return n}function Co(e){let t=[...e].reverse(),o=[...chunkWGP4UUO5_cjs.K(t)].reverse().map(chunkWGP4UUO5_cjs.e);return o.some(r=>!Number.isFinite(r))?null:o}function Po(e){let t=e.length-1,n=0;for(let a=1;a<e.length;a++)n=Math.max(n,Math.abs(e[a]));let o=1+n,r=-e[1]/t,i=[];for(let a=0;a<t;a++){let u=2*Math.PI*a/t+Math.PI/(2*t);i.push({re:r+o*Math.cos(u),im:o*Math.sin(u)});}return i}function Lo(e){let t=e.length-1,n=Po(e);for(let o=0;o<Eo;o++){let r=0,i=1;for(let a=0;a<t;a++){let u={re:1,im:0};for(let s=0;s<t;s++)a!==s&&(u=_o(u,ye(n[a],n[s])));if(u.re===0&&u.im===0){n[a]={re:n[a].re+1e-6*(a+1),im:n[a].im+1e-6};continue}let l=un(De(e,n[a]),u);if(!Number.isFinite(l.re)||!Number.isFinite(l.im))return null;n[a]=ye(n[a],l),r=Math.max(r,K(l)),i=Math.max(i,K(n[a]));}if(r<=Ao*i)return n}return null}function an(e,t,n){let o=n;for(let r=0;r<Oo;r++){let i=De(t,o);if(i.re===0&&i.im===0)break;let a=ye(o,un(De(e,o),i));if(!Number.isFinite(a.re)||!Number.isFinite(a.im))break;o=a;}return o}function Fo(e,t,n){let o=Math.max(1,K(n));if(n.im!==0&&Math.abs(n.im)<=rn*o){let r=an(e,t,{re:n.re,im:0});if(Je(e,r))return {re:r.re,im:0}}if(n.re!==0&&Math.abs(n.re)<=rn*o){let r=an(e,t,{re:0,im:n.im});if(Je(e,r))return {re:0,im:r.im}}return n}function Je(e,t){return !Number.isFinite(t.re)||!Number.isFinite(t.im)?false:K(De(e,t))<=ko*wo(e,t)}function Uo(e){let t=[...e],n=t.map(o=>o.im===0);for(let o=0;o<t.length;o++){if(n[o])continue;let r={re:t[o].re,im:-t[o].im},i=-1,a=Number.POSITIVE_INFINITY;for(let p=o+1;p<t.length;p++){if(n[p])continue;let h=K(ye(t[p],r));h<a&&(a=h,i=p);}if(i===-1||a>To*Math.max(1,K(t[o])))continue;let u=(t[o].re+t[i].re)/2,l=(Math.abs(t[o].im)+Math.abs(t[i].im))/2,s=t[o].im<0?-1:1;t[o]={re:u,im:s*l},t[i]={re:u,im:-s*l},n[o]=true,n[i]=true;}return t}function $o(e){for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let o=Math.max(1,K(e[t]),K(e[n]));if(K(ye(e[t],e[n]))<=Vo*o)return false}return true}function ln(e){let t=Co(e);if(t===null)return null;if(t.length<2)return [];let n=Lo(t);if(n===null)return null;let o=Do(t),r=Uo(n).map(i=>Fo(t,o,i));for(let i of r)if(!Je(t,i))return null;return $o(r)?[...r].sort((i,a)=>i.re-a.re||i.im-a.im):null}var sn=8;function Bo(e,t){let n=chunkWGP4UUO5_cjs.a;for(let o of e)n=chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.h(n,t),o);return n}function qo(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(chunkWGP4UUO5_cjs.f(e[o],chunkWGP4UUO5_cjs.h(n[o-1],t)));return n}function cn(e,t,n){let o=chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.h(t,t),chunkWGP4UUO5_cjs.h(jo(),chunkWGP4UUO5_cjs.h(e,n))),r=chunkWGP4UUO5_cjs.h(Go(),e);if(chunkWGP4UUO5_cjs.k(o,chunkWGP4UUO5_cjs.a)<0)return Yo(chunkWGP4UUO5_cjs.j(t),o,r);if(chunkWGP4UUO5_cjs.l(o))return [chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.j(t),r))];let i=chunkWGP4UUO5_cjs.L(o.n),a=chunkWGP4UUO5_cjs.L(o.d);if(i!==null&&a!==null){let h={n:i,d:a},v=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.f(chunkWGP4UUO5_cjs.j(t),h),r),V=chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.g(chunkWGP4UUO5_cjs.j(t),h),r);return chunkWGP4UUO5_cjs.k(V,v)<=0?[chunkWGP4UUO5_cjs.p(V),chunkWGP4UUO5_cjs.p(v)]:[chunkWGP4UUO5_cjs.p(v),chunkWGP4UUO5_cjs.p(V)]}let u=chunkWGP4UUO5_cjs.O(o),l=chunkWGP4UUO5_cjs.k(r,chunkWGP4UUO5_cjs.a)>0,s={kind:"div",left:{kind:"sub",left:chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.j(t)),right:u},right:chunkWGP4UUO5_cjs.p(r)},p={kind:"div",left:{kind:"add",left:chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.j(t)),right:u},right:chunkWGP4UUO5_cjs.p(r)};return l?[s,p]:[p,s]}function Yo(e,t,n){let o=chunkWGP4UUO5_cjs.j(t),r=chunkWGP4UUO5_cjs.L(o.n),i=chunkWGP4UUO5_cjs.L(o.d);if(r!==null&&i!==null){let s=chunkWGP4UUO5_cjs.i({n:r,d:i},n),p=chunkWGP4UUO5_cjs.i(e,n);return [chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.o(p,chunkWGP4UUO5_cjs.j(s))),chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.o(p,s))]}let a=chunkWGP4UUO5_cjs.i(e,n),u=chunkWGP4UUO5_cjs.i(o,chunkWGP4UUO5_cjs.h(n,n)),l={kind:"mul",left:chunkWGP4UUO5_cjs.O(u),right:chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.n)};return chunkWGP4UUO5_cjs.l(a)?[{kind:"neg",operand:l},l]:[{kind:"sub",left:chunkWGP4UUO5_cjs.p(a),right:l},{kind:"add",left:chunkWGP4UUO5_cjs.p(a),right:l}]}function Go(){return {n:2n,d:1n}}function jo(){return {n:4n,d:1n}}function Ko(e){return {re:e,im:0}}function mn(e,t,n){let o=chunkWGP4UUO5_cjs.C({kind:"sub",left:e,right:t});if(o===null)return {kind:"unsupported",reason:"this is not a polynomial equation (it divides by an unknown, or calls a function of one)"};let r=o.vars.filter(u=>u!==n),i=chunkWGP4UUO5_cjs.z(o,n);if(r.length>0)return i!==1?{kind:"unsupported",reason:`solving for "${n}" needs the equation to be linear in it when other unknowns (${r.join(", ")}) are present`}:Xo(o,n);if(i===0)return o.terms.size===0?{kind:"identity"}:{kind:"contradiction"};if(i>sn)return {kind:"unsupported",reason:`degree ${i} is above the supported maximum of ${sn}`};let a=[...chunkWGP4UUO5_cjs.B(o,n)].reverse();return Wo(a)}function Xo(e,t){let n=new Map,o=new Map;for(let[u,l]of e.terms){let s=u.split("*").filter(h=>h.length>0),p=s.indexOf(t);p===-1?o.set(u,l):(s.splice(p,1),n.set(s.join("*"),l));}let r=u=>{let l=new Set;for(let s of u.keys())for(let p of s.split("*"))p.length>0&&l.add(p.split("^")[0]);return [...l].sort()},i=chunkWGP4UUO5_cjs.E({terms:n,vars:r(n)});return {kind:"roots",exact:[{kind:"div",left:{kind:"neg",operand:chunkWGP4UUO5_cjs.E({terms:o,vars:r(o)})},right:i}],approximate:[]}}function Zo(e){return e.length===4?nn(e[0],e[1],e[2],e[3]):e.length===5?on(e[0],e[1],e[2],e[3],e[4],cn):null}function Ho(e){let t=[],n=[...e],o=0;for(;n.length>1&&chunkWGP4UUO5_cjs.l(n[n.length-1]);)n=n.slice(0,-1),o++;for(o>0&&t.push(chunkWGP4UUO5_cjs.a);n.length>1;){let r=ue(n);if(r.length===0)break;for(let i of r){let a=0;for(;n.length>1&&chunkWGP4UUO5_cjs.l(Bo(n,i));)n=qo(n,i),a++;a>0&&t.push(i);}}return {roots:t.sort(chunkWGP4UUO5_cjs.k),remaining:n}}function Wo(e){let{roots:t,remaining:n}=Ho(e),o=t.map(chunkWGP4UUO5_cjs.p),r=[],i=n.length-1,a=e.length-n.length;if(i<=0)return le(o,r,a,0,"");if(i===1)return o.push(chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.i(chunkWGP4UUO5_cjs.j(n[1]),n[0]))),le(o,r,a+1,0,"");if(i===2)return o.push(...cn(n[0],n[1],n[2])),le(o,r,a+2,0,"");let u=Zo(n);if(u!==null)return o.push(...u.exact),r.push(...u.approximate.map(Ko)),le(o,r,a+i,0,"");let l=ln(n);return l!==null?(r.push(...l),le(o,r,a+i,0,"")):le(o,r,a,i,`a degree-${i} factor of it has no exact solution here and the numerical method did not converge on that factor`)}function le(e,t,n,o,r){let i=e.length+t.length,a=n>=1&&(i<1||i>n);return o>0||a?{kind:"incomplete",exact:e,approximate:t,missing:a?Math.max(1,n+o-i):o,reason:a?`${i} root${i===1?"":"s"} were produced for a degree-${n+o} equation, which does not add up`:r}:{kind:"roots",exact:e,approximate:t}}var fn={0:"sqrt",1:"abs",2:"sin",3:"cos",4:"tan",5:"log",6:"ceil",7:"floor",8:"round",11:"asin",12:"acos",13:"atan",14:"atan2",15:"sinh",16:"cosh",17:"tanh",18:"asinh",19:"acosh",20:"atanh",21:"cbrt",23:"expm1",24:"exp",26:"hypot",28:"log10",29:"log1p",30:"log2",33:"sign",34:"trunc",35:"degtorad",36:"radtodeg",61:"root",62:"fact"},Qo=31,Ri=new Set([67,68,69,70,71,72,73,74,75,76,77,78,79]);function O(e){if(e.type===9)return e.value;if(e.type===13||e.type===12)return null;let t=e.toNumber();return Number.isFinite(t)?chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.d(t)):null}function _(e){let t=chunkWGP4UUO5_cjs.Q(e);return t.kind==="const"?chunkSQHBOWES_cjs.n(chunkWGP4UUO5_cjs.e(t.value)):chunkSQHBOWES_cjs.K(t)}function Ce(e){return chunkSQHBOWES_cjs.P("SYMBOLIC_UNSUPPORTED_FUNCTION",`"${e}" cannot be applied to an expression that still contains an unknown.`)}function xi(e,t){let n=O(e),o=O(t);return n===null||o===null?Ce("^"):_(chunkWGP4UUO5_cjs.r(n,o))}function vi(e){let t=O(e);return t===null?Ce("-"):_({kind:"neg",operand:t})}function Ii(e,t){let n=[];for(let r of t){let i=chunkSQHBOWES_cjs.Q(r);if(i)return i;let a=O(r);if(a===null)return Ce(fn[e]??`builtin ${e}`);n.push(a);}if(e===Qo&&n.length===2)return _(chunkWGP4UUO5_cjs.r(n[0],n[1]));let o=fn[e];return o===void 0?Ce(`builtin ${e}`):_(chunkWGP4UUO5_cjs.s(o,n))}function zo(e){let t=_(e);return t.type===0&&!Number.isInteger(t.toNumber())?chunkSQHBOWES_cjs.K(e):t}function Jo(e){return e.im===0?chunkSQHBOWES_cjs.n(e.re):chunkSQHBOWES_cjs.K(chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.o(chunkWGP4UUO5_cjs.d(e.re),chunkWGP4UUO5_cjs.d(e.im))))}function er(e){switch(e.kind){case "identity":return chunkSQHBOWES_cjs.t("true for every value");case "contradiction":return chunkSQHBOWES_cjs.t("no solution");case "unsupported":return chunkSQHBOWES_cjs.P("SYMBOLIC_SOLVE_UNSUPPORTED",`Cannot solve this equation: ${e.reason}.`);case "incomplete":{let t=e.exact.length+e.approximate.length;return chunkSQHBOWES_cjs.P("SYMBOLIC_SOLVE_INCOMPLETE",`Only ${t} of this equation's ${t+e.missing} roots could be found: ${e.reason}.`)}case "roots":{let t=e.exact.map(zo);for(let n of e.approximate)t.push(Jo(n));return t.length===0?chunkSQHBOWES_cjs.t("no solution"):t.length===1?t[0]:chunkSQHBOWES_cjs.C(1,t.length,t.map(n=>n.type===9?n.value:n.toNumber()))}}}function pn(e,t,n){let o=O(e),r=O(t);return o===null||r===null?chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","An equation side has no exact value to solve with."):er(mn(o,r,n))}function he(e,t){if(e.type===6&&t.type===6){if(e.unit===t.unit)return {lv:e.toNumber(),rv:t.toNumber(),unit:e.unit,sameMeasure:true};let n=chunkZKFCKAIX_cjs.c(e.unit),o=chunkZKFCKAIX_cjs.c(t.unit),r=chunkFYAMQFZZ_cjs.c.isCurrency(e.unit)&&chunkFYAMQFZZ_cjs.c.isCurrency(t.unit);if(n&&n===o){let i=chunkZKFCKAIX_cjs.e(t.toNumber(),t.unit,e.unit);return {lv:e.toNumber(),rv:i,unit:e.unit,sameMeasure:true}}if(r){let i=chunkFYAMQFZZ_cjs.c.convertSync(t.toNumber(),t.unit,e.unit);if(i!==null)return {lv:e.toNumber(),rv:i,unit:e.unit,sameMeasure:true}}return {lv:e.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:false}}return e.type===6?{lv:e.toNumber(),rv:t.toNumber(),unit:e.unit,sameMeasure:true}:t.type===6?{lv:e.toNumber(),rv:t.toNumber(),unit:t.unit,sameMeasure:true}:{lv:e.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:true}}var tr=1e-12;function nr(e,t,n){let o=0;return Number.isFinite(e)&&Math.abs(e)>o&&(o=Math.abs(e)),Number.isFinite(t)&&Math.abs(t)>o&&(o=Math.abs(t)),Number.isFinite(n)&&Math.abs(n)>o&&(o=Math.abs(n)),o}function Di(e,t){let{lv:n,rv:o,sameMeasure:r}=he(e,t);if(!r)return {lv:n,rv:o,equal:false,sameMeasure:false};if(e.type===6&&t.type===6&&e.unit!==void 0&&e.unit===t.unit&&e.exact!==void 0&&t.exact!==void 0&&chunkFYAMQFZZ_cjs.c.isCurrency(e.unit))return {lv:n,rv:o,equal:chunkWGP4UUO5_cjs.qa(e.exact,t.exact)===0,sameMeasure:true};if(n===o)return {lv:n,rv:o,equal:true,sameMeasure:true};if(!Number.isFinite(n)||!Number.isFinite(o))return {lv:n,rv:o,equal:false,sameMeasure:true};let i=nr(n,o,t.toNumber());return {lv:n,rv:o,equal:Math.abs(n-o)<=i*tr,sameMeasure:true}}var or={time:"duration",luminousIntensity:"luminous intensity"},rr=new Set(["money","data"]),ir={add:"added",sub:"subtracted",mul:"multiplied",div:"divided"};function Pe(e){if(chunkFYAMQFZZ_cjs.c.isCurrency(e))return "money";let t=chunkZKFCKAIX_cjs.c(e);if(t!==void 0)return or[t]??t}function bn(e){return rr.has(e)?e:/^[aeiou]/.test(e)?`an ${e}`:`a ${e}`}function Fe(e,t,n){let o=e===void 0?void 0:Pe(e),r=t===void 0?void 0:Pe(t);if(o!==void 0&&r!==void 0&&o!==r)return `${o} and ${r} cannot be ${n}`}function ar(e){return e!==void 0?ir[e]??"combined":"combined"}function Ci(e,t){let n=Pe(e),o=Pe(t);if(n!==void 0&&o!==void 0&&n!==o)return `${bn(n)} cannot be converted to ${bn(o)}`}function Pi(e,t){let n=e.type===6?e.unit:void 0,o=t.type===6?t.unit:void 0,r=Fe(n,o,"compared");return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",r??`Cannot compare incompatible units: ${n??"?"} and ${o??"?"}`)}function yn(e){if(e.type===2)return e.value;let t=e.toNumber();if(!Number.isInteger(t)){let n=Number.isNaN(t)?"NaN":String(t);throw chunkYBQPEWT7_cjs.c.execution("BIGINT_INEXACT_OPERAND",`A whole-number (n) value can only be combined with another whole number, and ${n} is not one`,{operand:n})}return BigInt(t)}function Li(){return chunkYBQPEWT7_cjs.c.execution("BIGINT_DIVISION_BY_ZERO","Division by zero: a whole-number (n) division is exact integer division, which has no answer at zero, unlike 1 / 0 which is Infinity")}function Fi(e,t){let n=hn(e),o=hn(t);return n===null||o===null?null:n<o?-1:n>o?1:0}function hn(e){if(e.type===2)return e.value;let t=e.toNumber();return Number.isInteger(t)?BigInt(t):null}function et(e,t){return Number.isFinite(t)?Math.pow(e,t):e===1||e===-1&&!Number.isNaN(t)?1:Math.pow(e,t)}function Nn(e){return e.exact!==void 0?e.exact:chunkWGP4UUO5_cjs.ha(e.toNumber())}function ur(e,t,n){let o=e.type===6&&e.unit!==void 0&&e.exact!==void 0&&chunkFYAMQFZZ_cjs.c.isCurrency(e.unit),r=t.type===6&&t.unit!==void 0&&t.exact!==void 0&&chunkFYAMQFZZ_cjs.c.isCurrency(t.unit);if(!o&&!r)return null;let i,a,u;if(o&&r){if(e.unit!==t.unit||n==="div")return null;i=e.exact,a=t.exact,u=e.unit;}else if(o&&t.type!==6)i=e.exact,u=e.unit,a=Nn(t);else if(r&&e.type!==6)a=t.exact,u=t.unit,i=Nn(e);else return null;if(i===null||a===null)return null;let l;switch(n){case "add":l=chunkWGP4UUO5_cjs.ja(i,a);break;case "sub":l=chunkWGP4UUO5_cjs.ka(i,a);break;case "mul":l=chunkWGP4UUO5_cjs.la(i,a);break;case "div":if(chunkWGP4UUO5_cjs.na(a))return null;l=chunkWGP4UUO5_cjs.pa(i,a);break}return chunkSQHBOWES_cjs.v(chunkWGP4UUO5_cjs.ra(l),u,l)}function Le(e){return e.rational!==void 0?e.rational:(e.type===0||e.type===1)&&typeof e.value=="number"&&Number.isInteger(e.value)?chunkWGP4UUO5_cjs.c(BigInt(e.value)):null}function Ui(e,t,n){let o=Le(e);if(o===null)return null;let r=Le(t);if(r===null||n==="div"&&chunkWGP4UUO5_cjs.l(r))return null;let i;try{switch(n){case "add":i=chunkWGP4UUO5_cjs.f(o,r);break;case "sub":i=chunkWGP4UUO5_cjs.g(o,r);break;case "mul":i=chunkWGP4UUO5_cjs.h(o,r);break;case "div":i=chunkWGP4UUO5_cjs.i(o,r);break}}catch{return null}return chunkSQHBOWES_cjs.p(chunkWGP4UUO5_cjs.e(i),i)}function $i(e,t,n){if(e.type!==0||t.type!==0)return null;let o=e.value,r=t.value,i=e.uncertainty??0,a=t.uncertainty??0,u,l;switch(n){case "add":u=o+r,l=Math.hypot(i,a);break;case "sub":u=o-r,l=Math.hypot(i,a);break;case "mul":u=o*r,l=Math.hypot(r*i,o*a);break;case "div":u=o/r,l=Math.hypot(i/r,o*a/(r*r));break}return chunkSQHBOWES_cjs.q(u,l)}function Bi(e,t){let n=Le(e);if(n===null)return null;let o=Le(t);return o===null?null:chunkWGP4UUO5_cjs.k(n,o)}function qi(e,t,n,o,r){if(e.type===13)return e;if(t.type===13)return t;if(e.type===12)return e;if(t.type===12)return t;if(r&&(e.type===9||t.type===9)){let i=O(e),a=O(t);return i===null||a===null?chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","A symbolic expression cannot combine with a value that has no exact number (NaN or infinity)."):chunkSQHBOWES_cjs.K(chunkWGP4UUO5_cjs.Q({kind:r,left:i,right:a}))}if(e.type===0&&t.type===0)return chunkSQHBOWES_cjs.n(n(e.value,t.value));if(e.type===2||t.type===2){let i=yn(e),a=yn(t);return o?chunkSQHBOWES_cjs.s(o(i,a)):chunkSQHBOWES_cjs.s(i+a)}if(e.type===6||t.type===6){if(r){let s=ur(e,t,r);if(s)return s}let{lv:i,rv:a,unit:u,sameMeasure:l}=he(e,t);if(!l){let s=e.type===6?e.unit:void 0,p=t.type===6?t.unit:void 0,h=Fe(s,p,ar(r));return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",h??`Cannot combine incompatible units: ${s??"?"} and ${p??"?"}`)}return chunkSQHBOWES_cjs.u(n(i,a),u)}if(e.type===7&&t.type===7){let i=e.value,a=t.value;if(!chunkWGP4UUO5_cjs.V(i,a))return chunkSQHBOWES_cjs.P("DIMENSION_MISMATCH",`Cannot combine matrices of different shapes: ${i.rows}x${i.cols} and ${a.rows}x${a.cols}`);let u=new Array(i.data.length);for(let l=0;l<i.data.length;l++)u[l]=n(i.data[l],a.data[l]);return chunkSQHBOWES_cjs.C(i.rows,i.cols,u)}if(e.type===7){let i=e.value,a=t.toNumber(),u=i.data.map(l=>n(l,a));return chunkSQHBOWES_cjs.C(i.rows,i.cols,u)}if(t.type===7){let i=t.value,a=e.toNumber(),u=i.data.map(l=>n(a,l));return chunkSQHBOWES_cjs.C(i.rows,i.cols,u)}return chunkSQHBOWES_cjs.n(n(e.toNumber(),t.toNumber()))}var gn=254,Rn=200,Ne=class{constructor(){this.handlers=new Map;this.nextOpcode=Rn+1;}register(t){this.handlers.set(t.opcode,t.handler);}unregister(t){this.handlers.delete(t);}get(t){return this.handlers.get(t)}has(t){return this.handlers.has(t)}allocateOpcode(){if(this.nextOpcode>gn)throw chunkYBQPEWT7_cjs.c.config("OPCODE_POOL_EXHAUSTED",`OpRegistry: dynamic opcode pool exhausted (max ${gn-Rn} allocations).`);return this.nextOpcode++}},ji=new Ne;var vn=chunkWGP4UUO5_cjs.ga(1);function ge(e,t){return chunkFYAMQFZZ_cjs.c.isCurrency(t)?e.exact??chunkWGP4UUO5_cjs.ha(e.toNumber()):null}function tt(e){if(!Number.isFinite(e))return null;if(Number.isInteger(e))return chunkWGP4UUO5_cjs.ga(BigInt(e));let t=String(e);return /^-?\d+\.\d+$/.test(t)?chunkWGP4UUO5_cjs.ia(t):null}function In(e,t,n){let o=ge(e,n),r=tt(t);if(o!==null&&r!==null){let i=chunkWGP4UUO5_cjs.la(o,r);return chunkSQHBOWES_cjs.v(chunkWGP4UUO5_cjs.ra(i),n,i)}return chunkSQHBOWES_cjs.u(e.toNumber()*t,n)}function Mn(e,t,n,o){let r=ge(e,t),i=tt(n);if(r!==null&&i!==null){let a=chunkWGP4UUO5_cjs.ja(vn,o===1?i:chunkWGP4UUO5_cjs.ma(i)),u=chunkWGP4UUO5_cjs.la(r,a);return chunkSQHBOWES_cjs.v(chunkWGP4UUO5_cjs.ra(u),t,u)}return chunkSQHBOWES_cjs.u(e.toNumber()*(1+o*n),t)}function Sn(e){let t=tt(e);return t===null?null:chunkWGP4UUO5_cjs.ja(vn,t)}function En(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||chunkWGP4UUO5_cjs.na(r))return null;let i=chunkWGP4UUO5_cjs.pa(o,r);return chunkSQHBOWES_cjs.v(chunkWGP4UUO5_cjs.ra(i),t,i)}function An(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||chunkWGP4UUO5_cjs.na(r))return null;let i=chunkWGP4UUO5_cjs.ka(o,chunkWGP4UUO5_cjs.pa(o,r));return chunkSQHBOWES_cjs.v(chunkWGP4UUO5_cjs.ra(i),t,i)}function kn(e,t){let n=e.unit,o=n!==void 0&&chunkFYAMQFZZ_cjs.c.isCurrency(n)?lr(e,n):null;if(o===null)return {unit:n,shares:[{value:e.toNumber()/t,count:t}]};let r=BigInt(t),i=o/r,a=o-i*r,u=Number(a<0n?-a:a),l=o<0n?-1n:1n,s=xn(i,t-u);return u===0?{unit:n,shares:[s]}:{unit:n,shares:[s,xn(i+l,u)]}}function xn(e,t){let n=chunkWGP4UUO5_cjs.fa(e,2);return {value:chunkWGP4UUO5_cjs.ra(n),exact:n,count:t}}function lr(e,t){let n=ge(e,t);return n===null?null:chunkWGP4UUO5_cjs.oa(n,2).coef}var sr=12;function Vn(e,t){if(e.length===0||t.length===0)return [];let n=new Array(e.length+t.length-1).fill(chunkWGP4UUO5_cjs.a);return e.forEach((o,r)=>{t.forEach((i,a)=>{n[r+a]=chunkWGP4UUO5_cjs.f(n[r+a],chunkWGP4UUO5_cjs.h(o,i));});}),n}function cr(e,t){let n=[chunkWGP4UUO5_cjs.b];for(let o=0;o<t;o++)n=Vn(n,e);return n}function nt(e,t){return e.map(n=>chunkWGP4UUO5_cjs.i(n,t))}function mr(e,t){let n=[],o=0;for(;o<e.length&&chunkWGP4UUO5_cjs.l(e[o]);)o++;o>0&&n.push({base:[chunkWGP4UUO5_cjs.a,chunkWGP4UUO5_cjs.b],power:o});let r=e.slice(o);if(r.length>1){let i=Qe([...r].reverse(),t);for(let a of i.factors){let u=chunkWGP4UUO5_cjs.C(a.base);if(u===null)return null;n.push({base:[...chunkWGP4UUO5_cjs.B(u,t)],power:a.power});}}return n.length>0?n:null}function fr(e){let t=[];return e.forEach((n,o)=>{let r=n.base.length-1;for(let i=1;i<=n.power;i++)for(let a=0;a<r;a++)t.push({factor:o,power:i,degree:a});}),t}function dr(e,t,n){let o=cr(t[e.factor].base,e.power),{quotient:r,remainder:i}=chunkWGP4UUO5_cjs.H(n,o);if(!chunkWGP4UUO5_cjs.G(i))return null;let a=new Array(e.degree).fill(chunkWGP4UUO5_cjs.a);return a.push(chunkWGP4UUO5_cjs.b),Vn(r,a)}function pr(e,t){let n=t.length;for(let o=0;o<n;o++){let r=-1;for(let i=o;i<n;i++)if(!chunkWGP4UUO5_cjs.l(e[i][o])){r=i;break}if(r===-1)return null;[e[o],e[r]]=[e[r],e[o]],[t[o],t[r]]=[t[r],t[o]];for(let i=0;i<n;i++){if(i===o||chunkWGP4UUO5_cjs.l(e[i][o]))continue;let a=chunkWGP4UUO5_cjs.i(e[i][o],e[o][o]);for(let u=o;u<n;u++)e[i][u]=chunkWGP4UUO5_cjs.g(e[i][u],chunkWGP4UUO5_cjs.h(a,e[o][u]));t[i]=chunkWGP4UUO5_cjs.g(t[i],chunkWGP4UUO5_cjs.h(a,t[o]));}}return t.map((o,r)=>chunkWGP4UUO5_cjs.i(o,e[r][r]))}function ot(e,t,n){if(t.length<2||t.length-1>sr)return null;let o=chunkWGP4UUO5_cjs.I(e,t),r=o.length>1?chunkWGP4UUO5_cjs.H(e,o).quotient:[...e],i=o.length>1?chunkWGP4UUO5_cjs.H(t,o).quotient:[...t];if(i.length===1)return {polynomial:nt(r,i[0]),terms:[]};if(i.length===0)return null;let a=i[i.length-1],u=nt(i,a),l=nt(r,a),{quotient:s,remainder:p}=chunkWGP4UUO5_cjs.H(l,u);if(chunkWGP4UUO5_cjs.G(p))return {polynomial:s,terms:[]};let h=mr(u,n);if(h===null)return null;let v=br(h,u,p);return v===null?null:{polynomial:s,terms:v}}function br(e,t,n){let o=fr(e),r=t.length-1;if(o.length!==r)return null;let i=[];for(let s of o){let p=dr(s,e,t);if(p===null)return null;i.push(p);}let a=[];for(let s=0;s<r;s++)a.push(i.map(p=>p[s]??chunkWGP4UUO5_cjs.a));let u=[];for(let s=0;s<r;s++)u.push(n[s]??chunkWGP4UUO5_cjs.a);let l=pr(a,u);return l===null?null:yr(o,l,e)}function yr(e,t,n){let o=new Map;e.forEach((i,a)=>{let u=`${i.factor}:${i.power}`,l=o.get(u)??[];l[i.degree]=t[a],o.set(u,l);});let r=[];for(let[i,a]of o){let[u,l]=i.split(":").map(Number),s=[...a].map(p=>p??chunkWGP4UUO5_cjs.a);s.every(chunkWGP4UUO5_cjs.l)||r.push({numerator:s,base:n[u].base,power:l});}return r}function Re(e,t){let n=new Map;return e.forEach((o,r)=>{chunkWGP4UUO5_cjs.l(o)||n.set(r===0?"":r===1?t:`${t}^${r}`,o);}),n.size===0?chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.a):chunkWGP4UUO5_cjs.E({terms:n,vars:e.length>1?[t]:[]})}function Tn(e){let t=rt(e);if(t===null)return e;let n=ot(t.numerator,t.denominator,t.variable);if(n===null||n.terms.length===0)return e;let o=n.polynomial.length>0?Re(n.polynomial,t.variable):null;for(let r of n.terms){let i=Re(r.base,t.variable),a=r.power===1?i:chunkWGP4UUO5_cjs.r(i,chunkWGP4UUO5_cjs.p({n:BigInt(r.power),d:1n})),u=hr(r.numerator),l=u?r.numerator.map(p=>chunkWGP4UUO5_cjs.j(p)):r.numerator,s={kind:"div",left:Re(l,t.variable),right:a};o===null?o=u?{kind:"neg",operand:s}:s:o={kind:u?"sub":"add",left:o,right:s};}return o===null?e:chunkWGP4UUO5_cjs.Q(o)}function hr(e){return e.some(t=>t.n<0n)&&e.every(t=>t.n<=0n)}function rt(e){if(e.kind!=="div")return null;let t=chunkWGP4UUO5_cjs.C(e.left),n=chunkWGP4UUO5_cjs.C(e.right);if(t===null||n===null)return null;let o=chunkWGP4UUO5_cjs.A(n);return o===null||t.vars.some(r=>r!==o)?null:{numerator:chunkWGP4UUO5_cjs.B(t,o),denominator:chunkWGP4UUO5_cjs.B(n,o),variable:o}}var it=16;function On(){return chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.a)}function X(){return chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.b)}function Nr(e,t){switch(e){case "sin":return chunkWGP4UUO5_cjs.s("cos",[t]);case "cos":return {kind:"neg",operand:chunkWGP4UUO5_cjs.s("sin",[t])};case "tan":return {kind:"div",left:X(),right:chunkWGP4UUO5_cjs.r(chunkWGP4UUO5_cjs.s("cos",[t]),chunkWGP4UUO5_cjs.p(2))};case "exp":return chunkWGP4UUO5_cjs.s("exp",[t]);case "log":return {kind:"div",left:X(),right:t};case "sqrt":return {kind:"div",left:X(),right:{kind:"mul",left:chunkWGP4UUO5_cjs.p(2),right:chunkWGP4UUO5_cjs.s("sqrt",[t])}};case "asin":return {kind:"div",left:X(),right:chunkWGP4UUO5_cjs.s("sqrt",[_n(t)])};case "acos":return {kind:"neg",operand:{kind:"div",left:X(),right:chunkWGP4UUO5_cjs.s("sqrt",[_n(t)])}};case "atan":return {kind:"div",left:X(),right:gr(t)};case "sinh":return chunkWGP4UUO5_cjs.s("cosh",[t]);case "cosh":return chunkWGP4UUO5_cjs.s("sinh",[t]);case "tanh":return {kind:"div",left:X(),right:chunkWGP4UUO5_cjs.r(chunkWGP4UUO5_cjs.s("cosh",[t]),chunkWGP4UUO5_cjs.p(2))};case "abs":return chunkWGP4UUO5_cjs.s("sign",[t]);default:return null}}function _n(e){return {kind:"sub",left:X(),right:chunkWGP4UUO5_cjs.r(e,chunkWGP4UUO5_cjs.p(2))}}function gr(e){return {kind:"add",left:X(),right:chunkWGP4UUO5_cjs.r(e,chunkWGP4UUO5_cjs.p(2))}}function xe(e,t,n=1){if(n<0||!Number.isInteger(n))throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT","A derivative order must be a whole number, at least zero.");if(n>it)throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT",`A derivative order above ${it} is not supported.`,{limit:it});let o=chunkWGP4UUO5_cjs.Q(e);for(let r=0;r<n;r++)o=chunkWGP4UUO5_cjs.Q(P(o,t));return o}function P(e,t){switch(e.kind){case "const":case "complex":return On();case "var":return e.name===t?X():On();case "add":return {kind:"add",left:P(e.left,t),right:P(e.right,t)};case "sub":return {kind:"sub",left:P(e.left,t),right:P(e.right,t)};case "neg":return {kind:"neg",operand:P(e.operand,t)};case "mul":return {kind:"add",left:{kind:"mul",left:P(e.left,t),right:e.right},right:{kind:"mul",left:e.left,right:P(e.right,t)}};case "div":return {kind:"div",left:{kind:"sub",left:{kind:"mul",left:P(e.left,t),right:e.right},right:{kind:"mul",left:e.left,right:P(e.right,t)}},right:chunkWGP4UUO5_cjs.r(e.right,chunkWGP4UUO5_cjs.p(2))};case "pow":return Rr(e,t);case "call":{if(e.args.length!==1)return at(e,t);let n=Nr(e.name,e.args[0]);return n===null?at(e,t):{kind:"mul",left:n,right:P(e.args[0],t)}}}}function Rr(e,t){if(e.exponent.kind==="const"){let n=chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.g(e.exponent.value,chunkWGP4UUO5_cjs.b));return {kind:"mul",left:{kind:"mul",left:e.exponent,right:chunkWGP4UUO5_cjs.r(e.base,n)},right:P(e.base,t)}}return e.base.kind==="const"&&e.base.value.n>0n?{kind:"mul",left:{kind:"mul",left:e,right:chunkWGP4UUO5_cjs.s("log",[e.base])},right:P(e.exponent,t)}:at(e,t)}function at(e,t){return chunkWGP4UUO5_cjs.s("der",[e,chunkWGP4UUO5_cjs.q(t)])}function wn(e,t){let n=chunkWGP4UUO5_cjs.C(e);if(n===null||n.vars.filter(u=>u!==t).length>0||chunkWGP4UUO5_cjs.z(n,t)>1)return null;let r=chunkWGP4UUO5_cjs.B(n,t),i=r[0]??{n:0n,d:1n},a=r[1]??{n:0n,d:1n};return chunkWGP4UUO5_cjs.l(a)?null:{slope:a,intercept:i}}function xr(e,t){let n=chunkWGP4UUO5_cjs.C(e);if(n===null)return null;let o=n.vars.filter(a=>a!==t);if(o.length>0)return {ok:false,reason:`it involves more than one unknown (${o.join(", ")})`};let r=chunkWGP4UUO5_cjs.B(n,t),i=chunkWGP4UUO5_cjs.p(0);return r.forEach((a,u)=>{if(chunkWGP4UUO5_cjs.l(a))return;let l=u+1,s=chunkWGP4UUO5_cjs.i(a,{n:BigInt(l),d:1n}),p={kind:"mul",left:chunkWGP4UUO5_cjs.p(s),right:l===1?chunkWGP4UUO5_cjs.q(t):chunkWGP4UUO5_cjs.r(chunkWGP4UUO5_cjs.q(t),chunkWGP4UUO5_cjs.p(l))};i={kind:"add",left:i,right:p};}),{ok:true,value:chunkWGP4UUO5_cjs.Q(i)}}function vr(e,t){if(e.kind!=="call"||e.args.length!==1)return null;let n=wn(e.args[0],t);if(n===null)return null;let o=e.args[0],r=i=>chunkWGP4UUO5_cjs.Q({kind:"div",left:i,right:chunkWGP4UUO5_cjs.p(n.slope)});switch(e.name){case "exp":return {ok:true,value:r(chunkWGP4UUO5_cjs.s("exp",[o]))};case "sin":return {ok:true,value:r({kind:"neg",operand:chunkWGP4UUO5_cjs.s("cos",[o])})};case "cos":return {ok:true,value:r(chunkWGP4UUO5_cjs.s("sin",[o]))};case "log":return {ok:true,value:r({kind:"sub",left:{kind:"mul",left:o,right:chunkWGP4UUO5_cjs.s("log",[o])},right:o})};default:return null}}function Ir(e,t){if(e.kind!=="div"||e.left.kind!=="const"||!ut(e.left.value))return null;let n=wn(e.right,t);if(n!==null)return {ok:true,value:chunkWGP4UUO5_cjs.Q({kind:"div",left:chunkWGP4UUO5_cjs.s("log",[e.right]),right:chunkWGP4UUO5_cjs.p(n.slope)})};let o=chunkWGP4UUO5_cjs.C(e.right);if(o!==null&&o.vars.length===1&&o.vars[0]===t){let r=chunkWGP4UUO5_cjs.B(o,t);if(r.length===3&&ut(r[0])&&chunkWGP4UUO5_cjs.l(r[1])&&ut(r[2]))return {ok:true,value:chunkWGP4UUO5_cjs.s("atan",[chunkWGP4UUO5_cjs.q(t)])}}return null}function ut(e){return e.n===1n&&e.d===1n}function Mr(e,t){let n=rt(e);if(n===null||n.variable!==t)return null;let o=ot(n.numerator,n.denominator,t);if(o===null)return null;let r=o.polynomial.length>0?Ar(o.polynomial,t):chunkWGP4UUO5_cjs.p(0);for(let i of o.terms){let a=Sr(i,t);if(a===null)return {ok:false,reason:"its denominator has a repeated irreducible quadratic factor, which needs a reduction formula this does not have"};r={kind:"add",left:r,right:a};}return {ok:true,value:chunkWGP4UUO5_cjs.Q(r)}}function Sr(e,t){let n=e.base.length-1,o=Re(e.base,t);if(n===1){let r=e.numerator[0]??chunkWGP4UUO5_cjs.a;if(e.power===1)return {kind:"mul",left:chunkWGP4UUO5_cjs.p(r),right:chunkWGP4UUO5_cjs.s("log",[o])};let i=e.power-1,a=chunkWGP4UUO5_cjs.i(r,{n:BigInt(-i),d:1n});return {kind:"div",left:chunkWGP4UUO5_cjs.p(a),right:chunkWGP4UUO5_cjs.r(o,chunkWGP4UUO5_cjs.p({n:BigInt(i),d:1n}))}}return n!==2||e.power!==1?null:Er(e,t,o)}function Er(e,t,n){let o=e.numerator[0]??chunkWGP4UUO5_cjs.a,r=e.numerator[1]??chunkWGP4UUO5_cjs.a,[i,a]=e.base,u={n:1n,d:2n},l=chunkWGP4UUO5_cjs.h(a,u),s={kind:"mul",left:chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.h(r,u)),right:chunkWGP4UUO5_cjs.s("log",[n])},p=chunkWGP4UUO5_cjs.g(o,chunkWGP4UUO5_cjs.h(r,l));if(chunkWGP4UUO5_cjs.l(p))return s;let h=chunkWGP4UUO5_cjs.O(chunkWGP4UUO5_cjs.g(i,chunkWGP4UUO5_cjs.h(l,l))),v={kind:"add",left:chunkWGP4UUO5_cjs.q(t),right:chunkWGP4UUO5_cjs.p(l)},V={kind:"mul",left:{kind:"div",left:chunkWGP4UUO5_cjs.p(p),right:h},right:chunkWGP4UUO5_cjs.s("atan",[{kind:"div",left:v,right:h}])};return chunkWGP4UUO5_cjs.l(r)?V:{kind:"add",left:s,right:V}}function Ar(e,t){let n=chunkWGP4UUO5_cjs.p(0);return e.forEach((o,r)=>{if(chunkWGP4UUO5_cjs.l(o))return;let i=r+1,a=chunkWGP4UUO5_cjs.i(o,{n:BigInt(i),d:1n}),u={kind:"mul",left:chunkWGP4UUO5_cjs.p(a),right:i===1?chunkWGP4UUO5_cjs.q(t):chunkWGP4UUO5_cjs.r(chunkWGP4UUO5_cjs.q(t),chunkWGP4UUO5_cjs.p(i))};n={kind:"add",left:n,right:u};}),n}function ve(e,t){let n=chunkWGP4UUO5_cjs.Q(e);if(!chunkWGP4UUO5_cjs.u(n).has(t))return {ok:true,value:chunkWGP4UUO5_cjs.Q({kind:"mul",left:n,right:chunkWGP4UUO5_cjs.q(t)})};let o=xr(n,t);if(o!==null)return o;let r=vr(n,t);if(r!==null)return r;let i=Ir(n,t);if(i!==null)return i;let a=Mr(n,t);if(a!==null)return a;if(n.kind==="add"||n.kind==="sub"){let u=ve(n.left,t);if(!u.ok)return u;let l=ve(n.right,t);return l.ok?{ok:true,value:chunkWGP4UUO5_cjs.Q({kind:n.kind,left:u.value,right:l.value})}:l}if(n.kind==="mul"&&n.left.kind==="const"){let u=ve(n.right,t);return u.ok?{ok:true,value:chunkWGP4UUO5_cjs.Q({kind:"mul",left:n.left,right:u.value})}:u}return {ok:false,reason:"no elementary antiderivative is known for this expression"}}var lt=16;function Dn(e,t,n,o){if(o<0||!Number.isInteger(o)||o>lt)throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_TAYLOR_DEGREE_LIMIT",`A Taylor degree must be a whole number from 0 to ${lt}.`,{limit:lt});let r=chunkWGP4UUO5_cjs.p(n),i=1n,a=chunkWGP4UUO5_cjs.p(chunkWGP4UUO5_cjs.a);for(let u=0;u<=o;u++){u>0&&(i*=BigInt(u));let l=xe(e,t,u),s=chunkWGP4UUO5_cjs.Q(chunkWGP4UUO5_cjs.v(l,t,r));if(s.kind!=="const")throw chunkYBQPEWT7_cjs.c.execution("SYMBOLIC_TAYLOR_INEXACT",`The derivative of order ${u} does not reduce to an exact number at the expansion point, so this series cannot be computed exactly.`,{order:u});let p=chunkWGP4UUO5_cjs.i(s.value,{n:i,d:1n});if(chunkWGP4UUO5_cjs.l(p))continue;let h=chunkWGP4UUO5_cjs.l(n)?chunkWGP4UUO5_cjs.q(t):{kind:"sub",left:chunkWGP4UUO5_cjs.q(t),right:r},v=u===0?chunkWGP4UUO5_cjs.p(1):u===1?h:chunkWGP4UUO5_cjs.r(h,chunkWGP4UUO5_cjs.p(u));a={kind:"add",left:a,right:{kind:"mul",left:chunkWGP4UUO5_cjs.p(p),right:v}};}return chunkWGP4UUO5_cjs.Q(a)}function Cn(e,t){return e.map(n=>t.map(o=>xe(n,o)))}function kr(e={}){return {pluginFunctions:{},opRegistry:new Ne,pluginFunctionOwners:{},networkEnabled:e.networkEnabled??true}}var Pn=kr();var Vr={1970:38.8,1971:40.5,1972:41.8,1973:44.4,1974:49.3,1975:53.8,1976:56.9,1977:60.6,1978:65.2,1979:72.6,1980:82.4,1981:90.9,1982:96.5,1983:99.6,1984:103.9,1985:107.6,1986:109.6,1987:113.6,1988:118.3,1989:124,1990:130.7,1991:136.2,1992:140.3,1993:144.5,1994:148.2,1995:152.4,1996:156.9,1997:160.5,1998:163,1999:166.6,2e3:172.2,2001:177.1,2002:179.9,2003:184,2004:188.9,2005:195.3,2006:201.6,2007:207.3,2008:215.3,2009:214.5,2010:218.1,2011:224.9,2012:229.6,2013:233,2014:236.7,2015:237,2016:240,2017:245.1,2018:251.1,2019:255.7,2020:258.8,2021:271,2022:292.7,2023:304.7,2024:313.7,2025:322.2,2026:332.7},Fn=1970,Un=2026;function Ln(e){return Vr[Math.trunc(e)]}function st(e,t){let n=Ln(e),o=Ln(t);if(!(n===void 0||o===void 0||n===0))return o/n}function Sa(e,t,n){let o=st(t,n);if(o!==void 0)return e*o}function Tr(e){let t=Math.abs(e);return t<60?chunkSQHBOWES_cjs.u(e,"s"):t<3600?chunkSQHBOWES_cjs.u(e/60,"min"):t<86400?chunkSQHBOWES_cjs.u(e/3600,"h"):chunkSQHBOWES_cjs.u(e/86400,"d")}var Or=0;function ct(e){if(e.type===6&&e.unit!==void 0){let t=chunkEZKR44MA_cjs.a[e.unit.toLowerCase()];if(t!==void 0&&t[0]===Or)return e.toNumber()*t[1]}return e.toNumber()}function _r(e,t){if(t===1)return e;let n=`${e}s`;return chunkEZKR44MA_cjs.a[n.toLowerCase()]===void 0?e:n}function $n(e,t){let n,o=false;for(let r of e){if(Number.isNaN(r.toNumber())){o=true;continue}if(n===void 0){n=r;continue}let{lv:i,rv:a,sameMeasure:u}=he(n,r);if(!u){let l=n.type===6?n.unit:void 0,s=r.type===6?r.unit:void 0,p=Fe(l,s,"compared");return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",p??`Cannot compare incompatible units: ${l??"?"} and ${s??"?"}`)}(t?a>i:a<i)&&(n=r);}return o?chunkSQHBOWES_cjs.n(NaN):n===void 0?chunkSQHBOWES_cjs.n(t?-1/0:1/0):n.type===6?n:chunkSQHBOWES_cjs.n(n.toNumber())}function Ue(e,t){return e.type===6&&e.unit!==void 0?chunkSQHBOWES_cjs.u(t,e.unit):chunkSQHBOWES_cjs.n(t)}function Bn(e,t){let n=Number.isFinite(t)?Math.min(100,Math.max(0,Math.trunc(t))):0;if(e.exact!==void 0){let a=chunkWGP4UUO5_cjs.oa(e.exact,n);return $e(e,chunkWGP4UUO5_cjs.ra(a),n,a)}let o=e.toNumber();if(!Number.isFinite(o))return $e(e,o,n);let r=Math.pow(10,n),i=o*r;return !Number.isFinite(i)||Math.abs(i)>Number.MAX_SAFE_INTEGER?$e(e,o,n):$e(e,Math.round(i)/r,n)}function $e(e,t,n,o){let r=e.type===6&&e.unit!==void 0?chunkSQHBOWES_cjs.u(t,e.unit):chunkSQHBOWES_cjs.n(t);return r.decimalPlaces=n,o!==void 0&&(r.exact=o),r}function qn(e,t,n){if(Number.isFinite(e)&&Number.isFinite(t))return null;let o=Number.isFinite(e)?t:e;return chunkSQHBOWES_cjs.P("INVALID_INTEGER_OPERAND",`${n} needs two whole numbers, and ${Number.isNaN(o)?"one of them has no value":"one of them is infinite"}`)}function Yn(e,t){let n=e,o=t;for(;o!==0;){let r=o;o=n%o,n=r;}return n}function wr(e){let t=e.length;if(t===0)return 0;let n=e.reduce((o,r)=>o+r,0)/t;return e.reduce((o,r)=>o+(r-n)*(r-n),0)}function Be(e,t){let n=e.length;if(n===0)return 0;let o=t?n-1:n;return o<=0?0:wr(e)/o}var Za={0:e=>{let t=e[0].toNumber();return t>=0?chunkSQHBOWES_cjs.n(Math.sqrt(t)):_(chunkWGP4UUO5_cjs.s("sqrt",[chunkWGP4UUO5_cjs.p(t)]))},1:e=>e[0].type===7?chunkWGP4UUO5_cjs.ca(e[0].value):Ue(e[0],Math.abs(e[0].toNumber())),2:e=>chunkSQHBOWES_cjs.n(Math.sin(ct(e[0]))),3:e=>chunkSQHBOWES_cjs.n(Math.cos(ct(e[0]))),4:e=>chunkSQHBOWES_cjs.n(Math.tan(ct(e[0]))),5:e=>chunkSQHBOWES_cjs.n(Math.log(e[0].toNumber())),6:e=>Ue(e[0],Math.ceil(e[0].toNumber())),7:e=>Ue(e[0],Math.floor(e[0].toNumber())),8:e=>e.length>=2?Bn(e[0],e[1].toNumber()):Ue(e[0],Math.round(e[0].toNumber())),9:e=>$n(e,false),10:e=>$n(e,true),11:e=>chunkSQHBOWES_cjs.n(Math.asin(e[0].toNumber())),12:e=>chunkSQHBOWES_cjs.n(Math.acos(e[0].toNumber())),13:e=>chunkSQHBOWES_cjs.n(Math.atan(e[0].toNumber())),14:e=>chunkSQHBOWES_cjs.n(Math.atan2(e[0].toNumber(),e[1].toNumber())),15:e=>chunkSQHBOWES_cjs.n(Math.sinh(e[0].toNumber())),16:e=>chunkSQHBOWES_cjs.n(Math.cosh(e[0].toNumber())),17:e=>chunkSQHBOWES_cjs.n(Math.tanh(e[0].toNumber())),18:e=>chunkSQHBOWES_cjs.n(Math.asinh(e[0].toNumber())),19:e=>chunkSQHBOWES_cjs.n(Math.acosh(e[0].toNumber())),20:e=>chunkSQHBOWES_cjs.n(Math.atanh(e[0].toNumber())),21:e=>chunkSQHBOWES_cjs.n(Math.cbrt(e[0].toNumber())),22:e=>chunkSQHBOWES_cjs.n(Math.clz32(e[0].toNumber())),23:e=>chunkSQHBOWES_cjs.n(Math.expm1(e[0].toNumber())),24:e=>chunkSQHBOWES_cjs.n(Math.exp(e[0].toNumber())),25:e=>chunkSQHBOWES_cjs.n(Math.fround(e[0].toNumber())),26:e=>chunkSQHBOWES_cjs.n(Math.hypot(...e.map(t=>t.toNumber()))),27:e=>chunkSQHBOWES_cjs.n(Math.imul(e[0].toNumber(),e[1].toNumber())),28:e=>chunkSQHBOWES_cjs.n(Math.log10(e[0].toNumber())),29:e=>chunkSQHBOWES_cjs.n(Math.log1p(e[0].toNumber())),30:e=>chunkSQHBOWES_cjs.n(Math.log2(e[0].toNumber())),31:e=>e[0].type===7?e[1].type!==0?chunkSQHBOWES_cjs.P("MATRIX_POWER_UNSUPPORTED",`pow: a matrix's exponent must be a whole number, as in "pow([1,2;3,4], 2)".`):chunkWGP4UUO5_cjs.$(e[0].value,e[1].value):e[1].type===7?chunkSQHBOWES_cjs.P("MATRIX_POWER_UNSUPPORTED",'pow: a matrix may only be the base, as in "pow([1,2;3,4], 2)".'):chunkSQHBOWES_cjs.n(et(e[0].toNumber(),e[1].toNumber())),32:()=>chunkSQHBOWES_cjs.n(Math.random()),33:e=>chunkSQHBOWES_cjs.n(Math.sign(e[0].toNumber())),34:e=>chunkSQHBOWES_cjs.n(Math.trunc(e[0].toNumber())),35:e=>chunkSQHBOWES_cjs.n(e[0].toNumber()*Math.PI/180),36:e=>chunkSQHBOWES_cjs.n(e[0].toNumber()*180/Math.PI),37:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return t>n?chunkSQHBOWES_cjs.P("INVALID_RANGE",`roll: invalid range, ${t} is greater than ${n}`):chunkSQHBOWES_cjs.n(Math.floor(Math.random()*(n-t+1))+t)},38:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n=Math.trunc(Math.abs(e[1].toNumber())),o=qn(t,n,"gcd");return o||chunkSQHBOWES_cjs.n(Yn(t,n))},39:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n=Math.trunc(Math.abs(e[1].toNumber())),o=qn(t,n,"lcm");return o||(t===0||n===0?chunkSQHBOWES_cjs.n(0):chunkSQHBOWES_cjs.n(t/Yn(t,n)*n))},40:e=>{let t=Math.trunc(e[0].toNumber()),n=Math.trunc(e[1].toNumber());if(t<0||n<0||n>t)return chunkSQHBOWES_cjs.P("INVALID_RANGE",`permutation: invalid n=${t}, r=${n} (require 0 <= r <= n)`);let o=1;for(let r=0;r<n;r++)if(o*=t-r,!Number.isFinite(o))return chunkSQHBOWES_cjs.P("PERMUTATION_OVERFLOW",`permutation: P(${t}, ${n}) exceeds the maximum representable double (it passed it after ${r+1} of ${n} factors)`);return chunkSQHBOWES_cjs.n(o)},41:e=>{let t=Math.trunc(e[0].toNumber()),n=Math.trunc(e[1].toNumber());if(t<0||n<0||n>t)return chunkSQHBOWES_cjs.P("INVALID_RANGE",`combination: invalid n=${t}, r=${n} (require 0 <= r <= n)`);let o=Math.min(n,t-n),r=1;for(let i=0;i<o;i++)if(r=r*(t-i)/(i+1),!Number.isFinite(r))return chunkSQHBOWES_cjs.P("COMBINATION_OVERFLOW",`combination: C(${t}, ${n}) exceeds the maximum representable double (it passed it after ${i+1} of ${o} steps)`);return chunkSQHBOWES_cjs.n(Math.round(r))},42:e=>{if(e.length===0)return chunkSQHBOWES_cjs.n(0);let t=e.reduce((n,o)=>n+o.toNumber(),0);return chunkSQHBOWES_cjs.n(t/e.length)},43:e=>{if(e.length===0)return chunkSQHBOWES_cjs.n(0);let t=e.map(o=>o.toNumber()).sort((o,r)=>o-r),n=Math.floor(t.length/2);return chunkSQHBOWES_cjs.n(t.length%2===0?(t[n-1]+t[n])/2:t[n])},44:e=>chunkSQHBOWES_cjs.n(e.reduce((t,n)=>t+n.toNumber(),0)),45:e=>chunkSQHBOWES_cjs.n(e.length),46:e=>{let[t,n,o]=e,{lv:r,rv:i}=he(t,n);if(r===0)return chunkSQHBOWES_cjs.P("PROPORTION_DIVIDE_BY_ZERO",`Cannot compute proportion: "${t.value}" is zero`);let a=o.toNumber()*(i/r);return o.type===6?chunkSQHBOWES_cjs.u(a,o.unit):chunkSQHBOWES_cjs.n(a)},47:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return n>o?chunkSQHBOWES_cjs.P("INVALID_RANGE",`clamp: invalid range, ${n} is greater than ${o}`):chunkSQHBOWES_cjs.n(Math.min(Math.max(t,n),o))},48:e=>chunkSQHBOWES_cjs.r(e[0].toNumber()),49:e=>chunkSQHBOWES_cjs.r(e[0].toNumber(),"bin"),50:e=>chunkSQHBOWES_cjs.n(Math.trunc(e[0].toNumber())),51:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`compoundInterest: rate ${n} makes (1 + rate) non-positive`);let r=t*Math.pow(1+n,o);return e[0].type===6?chunkSQHBOWES_cjs.u(r,e[0].unit):chunkSQHBOWES_cjs.n(r)},52:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`interestEarned: rate ${n} makes (1 + rate) non-positive`);let r=t*(Math.pow(1+n,o)-1);return e[0].type===6?chunkSQHBOWES_cjs.u(r,e[0].unit):chunkSQHBOWES_cjs.n(r)},53:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0||n<=0?chunkSQHBOWES_cjs.P("INVALID_RANGE","compoundInterestRate: principal and futureValue must both be positive"):o<=0?chunkSQHBOWES_cjs.P("INVALID_RANGE","compoundInterestRate: years must be greater than 0"):chunkSQHBOWES_cjs.n(Math.pow(n/t,1/o)-1)},54:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0||n<=0?chunkSQHBOWES_cjs.P("INVALID_RANGE","compoundInterestYears: principal and futureValue must both be positive"):1+o<=0||o===0?chunkSQHBOWES_cjs.P("INVALID_RATE",`compoundInterestYears: rate ${o} is not usable (must be > -1 and not 0)`):chunkSQHBOWES_cjs.n(Math.log(n/t)/Math.log(1+o))},55:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanRepayment: principal must be positive");if(o<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanRepayment: years must be positive");if(n<0)return chunkSQHBOWES_cjs.P("INVALID_RATE","loanRepayment: rate must not be negative");if(r<0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanRepayment: periodsPerYear must not be negative");let{totalRepayment:i}=dt(t,n,o),a=r===0?i:i/(o*r);return e[0].type===6?chunkSQHBOWES_cjs.u(a,e[0].unit):chunkSQHBOWES_cjs.n(a)},56:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanInterest: principal must be positive");if(o<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanInterest: years must be positive");if(n<0)return chunkSQHBOWES_cjs.P("INVALID_RATE","loanInterest: rate must not be negative");if(r<0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","loanInterest: periodsPerYear must not be negative");let{totalInterest:i}=dt(t,n,o),a=r===0?i:i/(o*r);return e[0].type===6?chunkSQHBOWES_cjs.u(a,e[0].unit):chunkSQHBOWES_cjs.n(a)},57:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(t<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","monthlyPayment: principal must be positive");if(o<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","monthlyPayment: years must be positive");if(n<0)return chunkSQHBOWES_cjs.P("INVALID_RATE","monthlyPayment: rate must not be negative");let{monthlyPayment:r}=dt(t,n,o);return e[0].type===6?chunkSQHBOWES_cjs.u(r,e[0].unit):chunkSQHBOWES_cjs.n(r)},58:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return e[0].type===6?Mn(e[0],e[0].unit,n,1):chunkSQHBOWES_cjs.n(t*(1+n))},59:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return 1+n<=0?chunkSQHBOWES_cjs.P("INVALID_RATE",`taxRemove: rate ${n} makes (1 + rate) non-positive`):e[0].type===6?En(e[0],e[0].unit,n)??chunkSQHBOWES_cjs.u(t/(1+n),e[0].unit):chunkSQHBOWES_cjs.n(t/(1+n))},60:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=st(n,o);if(r===void 0)return chunkSQHBOWES_cjs.P("INFLATION_YEAR_OUT_OF_RANGE",`inflationAdjust: fromYear ${n} or toYear ${o} is outside the bundled CPI table's range (${Fn}-${Un})`);let i=t*r;return e[0].type===6?chunkSQHBOWES_cjs.u(i,e[0].unit):chunkSQHBOWES_cjs.n(i)},61:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return chunkSQHBOWES_cjs.n(et(n,1/t))},62:e=>{let t=e[0].toNumber();if(!Number.isInteger(t)||t<0)return chunkSQHBOWES_cjs.P("INVALID_FACTORIAL_INPUT",`fact: ${t} is not a non-negative integer`);if(t>170)return chunkSQHBOWES_cjs.P("FACTORIAL_OVERFLOW",`fact: ${t}! exceeds the maximum representable double (170! is the largest finite factorial)`);let n=1;for(let o=2;o<=t;o++)n*=o;return chunkSQHBOWES_cjs.n(n)},63:e=>e[0].type===7?chunkWGP4UUO5_cjs.ba(e[0].value):e[0],64:e=>e[0].type===7?chunkWGP4UUO5_cjs.ca(e[0].value):chunkSQHBOWES_cjs.n(e[0].toNumber()),65:e=>e[0].type===7?chunkWGP4UUO5_cjs.da(e[0].value):chunkSQHBOWES_cjs.n(1/e[0].toNumber()),66:e=>{let[t,n]=e;if(t.type===0&&n.type===0)return chunkSQHBOWES_cjs.n(t.toNumber()*n.toNumber());let o=r=>r.type===7?r.value:{rows:1,cols:1,data:[r.toNumber()],hasSymbolic:false};return chunkWGP4UUO5_cjs._(o(t),o(n))},67:e=>{let[t]=e;return t.type!==9?t:_(chunkWGP4UUO5_cjs.F(t.value))},68:e=>{let[t]=e;return t.type!==9?t:_(en(t.value))},69:e=>{let[t,n,o]=e;return o?.type!==3?chunkSQHBOWES_cjs.P("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown."):pn(t,n,o.value)},70:e=>{let[t,n,o]=e,r=ft(n,"der");if(typeof r!="string")return r;let i=O(t);return i===null?chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","der needs an expression with an exact value."):_(xe(i,r,o?.toNumber()??1))},71:e=>{let[t,n]=e,o=ft(n,"integral");if(typeof o!="string")return o;let r=O(t);if(r===null)return chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","integral needs an expression with an exact value.");let i=ve(r,o);return i.ok?_(i.value):chunkSQHBOWES_cjs.P("SYMBOLIC_INTEGRAL_UNSUPPORTED",`Cannot integrate this: ${i.reason}.`)},72:e=>{let[t,n,o,r]=e,i=ft(n,"taylor");if(typeof i!="string")return i;let a=O(t),u=O(o);return a===null||u===null||u.kind!=="const"?chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","taylor needs an expression and an exact expansion point."):_(Dn(a,i,u.value,r.toNumber()))},73:e=>{let t=[];for(let a of e){let u=O(a);if(u===null)return chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND","jacobian needs expressions with exact values.");t.push(u);}let n=new Set;for(let a of t)for(let u of chunkWGP4UUO5_cjs.u(a))n.add(u);let o=[...n].sort();if(o.length===0)return chunkSQHBOWES_cjs.P("SYMBOLIC_JACOBIAN_NO_VARIABLES","jacobian needs at least one unknown to differentiate against.");let r=Cn(t,o),i=[];for(let a of r)for(let u of a)i.push(chunkWGP4UUO5_cjs.W(u));return chunkSQHBOWES_cjs.C(r.length,o.length,chunkWGP4UUO5_cjs.Y(r.length,o.length,i))},74:e=>_(chunkWGP4UUO5_cjs.w(chunkWGP4UUO5_cjs.o(chunkWGP4UUO5_cjs.a,chunkWGP4UUO5_cjs.d(e[0].toNumber())))),75:e=>mt("conj",e[0]),76:e=>mt("re",e[0]),77:e=>mt("im",e[0]),78:e=>{let t=e[0];return t.type!==9?t:_(chunkWGP4UUO5_cjs.J(t.value))},79:e=>{let t=e[0];return t.type!==9?t:_(Tn(t.value))},85:e=>{let t=e[0].toNumber(),n=e[1].toNumber();if(1+n<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`taxIn: rate ${n} makes (1 + rate) non-positive`);let o=t-t/(1+n);return e[0].type===6?An(e[0],e[0].unit,n)??chunkSQHBOWES_cjs.u(o,e[0].unit):chunkSQHBOWES_cjs.n(o)},86:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return e[0].type===6?In(e[0],n,e[0].unit):chunkSQHBOWES_cjs.n(t*n)},87:e=>chunkSQHBOWES_cjs.n(Math.sin(e[0].toNumber()*Math.PI/180)),88:e=>chunkSQHBOWES_cjs.n(Math.cos(e[0].toNumber()*Math.PI/180)),89:e=>chunkSQHBOWES_cjs.n(Math.tan(e[0].toNumber()*Math.PI/180)),90:e=>chunkSQHBOWES_cjs.n(Math.asin(e[0].toNumber())*180/Math.PI),91:e=>chunkSQHBOWES_cjs.n(Math.acos(e[0].toNumber())*180/Math.PI),92:e=>chunkSQHBOWES_cjs.n(Math.atan(e[0].toNumber())*180/Math.PI),93:e=>chunkSQHBOWES_cjs.u(e[0].toNumber(),"days"),94:e=>{let t=typeof e[1]?.value=="string"?e[1].value:void 0,n=typeof e[2]?.value=="string"?e[2].value:void 0;if(t===void 0||n===void 0)return chunkSQHBOWES_cjs.P("UNKNOWN_UNIT",'both units have to be named, as in "12.5 minutes in minutes and seconds"');let o=chunkEZKR44MA_cjs.a[t.toLowerCase()],r=chunkEZKR44MA_cjs.a[n.toLowerCase()];if(o===void 0||r===void 0)return chunkSQHBOWES_cjs.P("UNKNOWN_UNIT",`${t} and ${n}: one of these is not a unit`);if(o[0]!==r[0])return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",`${t} and ${n} measure different things`);if(r[1]>=o[1])return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",`${t} and ${n}: name the larger unit first`);let i=e[0],a=i.type===6&&i.unit!==void 0?chunkEZKR44MA_cjs.a[i.unit.toLowerCase()]:void 0,u=i.toNumber()*(a?.[1]??o[1]),l=Math.floor(u/o[1]),s=Math.round((u-l*o[1])/r[1]*1e3)/1e3;return chunkSQHBOWES_cjs.t(`${l} ${t} ${s} ${n}`)},95:e=>{let t=e[0],n=String(e[1].value),o=t.type===6&&t.unit!==void 0?t.unit:"";return o.includes("/")?chunkSQHBOWES_cjs.P("INVALID_RATE_UNIT",`${o}/${n}: that is already a rate`):chunkSQHBOWES_cjs.u(t.toNumber(),`${o}/${n}`)},96:e=>{let t=e[0],n=e[1];if(n.type===6&&t.type===6&&chunkZKFCKAIX_cjs.i(n.unit)){let s=chunkZKFCKAIX_cjs.j(t.toNumber(),t.unit,n.toNumber(),n.unit);if(s!==null)return Tr(s)}if(n.type!==6||n.unit===void 0||!n.unit.includes("/"))return chunkSQHBOWES_cjs.P("INVALID_RATE",'at: the right-hand side has to be a rate, as in "$30/hour"');let o=n.unit.indexOf("/"),r=n.unit.slice(0,o),i=n.unit.slice(o+1),a=t.type===6?t.unit:void 0,u=chunkEZKR44MA_cjs.a[i.toLowerCase()],l=a===void 0?void 0:chunkEZKR44MA_cjs.a[a.toLowerCase()];if(l!==void 0&&u!==void 0&&l[0]===u[0]){let p=t.toNumber()*l[1]/u[1]*n.toNumber();return r===""?chunkSQHBOWES_cjs.n(p):chunkSQHBOWES_cjs.u(p,r)}if(a!==void 0&&a===r){let s=t.toNumber()/n.toNumber();return chunkSQHBOWES_cjs.u(s,_r(i,s))}if(a===void 0){let s=t.toNumber()*n.toNumber();return r===""?chunkSQHBOWES_cjs.n(s):chunkSQHBOWES_cjs.u(s,r)}return chunkSQHBOWES_cjs.P("INCOMPATIBLE_UNITS",`at: ${a} matches neither side of ${n.unit}`)},80:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`compounding: ${r} periods per year is not a period`);if(1+n/r<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`compounding: rate ${n} makes each period non-positive`);let i=t*Math.pow(1+n/r,r*o);return e[0].type===6?chunkSQHBOWES_cjs.u(i,e[0].unit):chunkSQHBOWES_cjs.n(i)},81:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0||1+n/r<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`compounding: rate ${n} over ${r} periods per year is not usable`);let i=t*(Math.pow(1+n/r,r*o)-1);return e[0].type===6?chunkSQHBOWES_cjs.u(i,e[0].unit):chunkSQHBOWES_cjs.n(i)},82:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkSQHBOWES_cjs.P("INVALID_RATE",`presentValue: rate ${n} makes (1 + rate) non-positive`);let r=t/Math.pow(1+n,o);return e[0].type===6?chunkSQHBOWES_cjs.u(r,e[0].unit):chunkSQHBOWES_cjs.n(r)},83:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return t===0?chunkSQHBOWES_cjs.P("INVALID_RATE","roi: nothing was invested, so there is no return on it"):chunkSQHBOWES_cjs.n((n-t)/t)},84:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0?chunkSQHBOWES_cjs.P("INVALID_RATE","annual return: the amount invested must be positive"):o<=0?chunkSQHBOWES_cjs.P("INVALID_RATE","annual return: the period must be longer than zero"):n<=0?chunkSQHBOWES_cjs.P("INVALID_RATE","annual return: nothing was returned, so there is no annual rate"):chunkSQHBOWES_cjs.N(Math.pow(n/t,1/o)-1)},97:e=>Bn(e[0],e[1].toNumber()),98:e=>{let t=e[1].toNumber();return !Number.isInteger(t)||t<1?chunkSQHBOWES_cjs.P("INVALID_RANGE",`split: the number of shares must be a whole number of at least 1, not ${e[1].toNumber()}.`):chunkSQHBOWES_cjs.H(kn(e[0],t))},99:e=>{let t=e[0].toNumber(),n=Dr(e[1]),o=e[2].toNumber();if(n===null)return chunkSQHBOWES_cjs.P("INVALID_RANGE",'savings goal: the duration must be in months or years, e.g. "in 2 years".');if(t<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","savings goal: the duration must be positive.");if(o<0)return chunkSQHBOWES_cjs.P("INVALID_RATE","savings goal: the rate must not be negative.");let r=Cr(t,o/12,n);return e[0].type===6?chunkSQHBOWES_cjs.u(r,e[0].unit):chunkSQHBOWES_cjs.n(r)},100:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber(),i=typeof e[4]?.value=="string"?e[4].value:"periods";if(t<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return chunkSQHBOWES_cjs.P("INVALID_RANGE","savings goal: the contribution must be positive.");if(r<0)return chunkSQHBOWES_cjs.P("INVALID_RATE","savings goal: the rate must not be negative.");let a=Pr(t,n,r/o);return chunkSQHBOWES_cjs.u(a,i)},101:e=>chunkSQHBOWES_cjs.n(Math.sqrt(Be(e.map(t=>t.toNumber()),false))),102:e=>chunkSQHBOWES_cjs.n(Math.sqrt(Be(e.map(t=>t.toNumber()),true))),103:e=>chunkSQHBOWES_cjs.n(Be(e.map(t=>t.toNumber()),false)),104:e=>chunkSQHBOWES_cjs.n(Be(e.map(t=>t.toNumber()),true)),105:e=>{if(e.length===0)return chunkSQHBOWES_cjs.n(0);let t=e.map(n=>n.toNumber());return chunkSQHBOWES_cjs.n(Math.max(...t)-Math.min(...t))},106:e=>{if(e.length===0)return chunkSQHBOWES_cjs.n(0);let t=new Map,n=e[0].toNumber(),o=0;for(let r of e){let i=r.toNumber(),a=(t.get(i)??0)+1;t.set(i,a),a>o&&(o=a,n=i);}return chunkSQHBOWES_cjs.n(n)},107:e=>{let t=0,n=0;for(let o=0;o+1<e.length;o+=2){let r=e[o].toNumber(),i=e[o+1].toNumber();t+=r*i,n+=i;}return n===0?chunkSQHBOWES_cjs.P("WEIGHTED_AVERAGE_ZERO_WEIGHT","weighted average: the weights sum to zero, so there is nothing to divide by"):chunkSQHBOWES_cjs.n(t/n)}};function Dr(e){if(e.type!==6)return null;let t=e.unit;return t==="months"||t==="month"?e.toNumber():t==="years"||t==="year"?e.toNumber()*12:null}function Cr(e,t,n){return t===0?e/n:e*t/(Math.pow(1+t,n)-1)}function Pr(e,t,n){let o=n===0?e/t:Math.log(1+e*n/t)/Math.log(1+n);return Math.ceil(o-1e-9)}function mt(e,t){let n=O(t);return n===null?chunkSQHBOWES_cjs.P("SYMBOLIC_NONFINITE_OPERAND",e+" needs a value with an exact number."):_(chunkWGP4UUO5_cjs.s(e,[n]))}function ft(e,t){return e?.type!==3?chunkSQHBOWES_cjs.P("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown.`):e.value}function dt(e,t,n){let o=n*12,r=t/12,i=r===0?e/o:e*r/(1-Math.pow(1+r,-o)),a=i*o,u=a-e;return {monthlyPayment:i,totalRepayment:a,totalInterest:u}}var Ha=Pn.pluginFunctions,Gn=65535,jn=0;function Lr(){if(jn>Gn)throw chunkYBQPEWT7_cjs.c.config("PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED",`allocatePluginFunctionIndex: pool exhausted (max ${Gn+1} allocations).`);return jn++}var Kn=new Map;function Wa(e){let t=Kn.get(e);return t===void 0&&(t=Lr(),Kn.set(e,t)),t}var pt=new Map;function Qa(e,t){let n=e.toLowerCase(),o=pt.get(n);o&&o!==t&&console.warn(`[asConverterRegistry] Converter name "${n}" is already registered \u2014 overwriting.`),pt.set(n,t);}function za(e){pt.delete(e.toLowerCase());}var qe=class qe{constructor(){this.values=new Map;this.listeners=new Set;this.notifyDepth=0;}get(t){return this.values.get(t)}has(t){return this.values.has(t)}set(t,n){let o=this.values.get(t);this.values.set(t,n),!(o!==void 0&&Fr(o,n))&&this.notify(t,n);}notify(t,n){if(!(this.notifyDepth>=qe.MAX_NOTIFY_DEPTH)){this.notifyDepth++;try{for(let o of this.listeners)o(t,n);}finally{this.notifyDepth--;}}}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}clear(){this.values.clear(),this.listeners.clear(),this.notifyDepth=0;}};qe.MAX_NOTIFY_DEPTH=64;var bt=qe;function Fr(e,t){if(e.type!==t.type||e.unit!==t.unit||(e.timedOut??false)!==(t.timedOut??false))return false;let n=e.value,o=t.value;if(Array.isArray(n)||Array.isArray(o)){if(!Array.isArray(n)||!Array.isArray(o)||n.length!==o.length)return false;for(let r=0;r<n.length;r++)if(!Object.is(n[r],o[r]))return false;return true}return Object.is(n,o)}var eu=new bt;function tu(e){return `global:${e}`}function ou(e,t){return new Date(e,t+1,0).getDate()}exports.A=Un;exports.B=Sa;exports.C=Za;exports.D=Ha;exports.E=Lr;exports.F=Wa;exports.G=pt;exports.H=Qa;exports.I=za;exports.J=eu;exports.K=tu;exports.L=ou;exports.a=ge;exports.b=In;exports.c=Mn;exports.d=mn;exports.e=Ri;exports.f=xi;exports.g=vi;exports.h=Ii;exports.i=pn;exports.j=he;exports.k=Di;exports.l=Ci;exports.m=Pi;exports.n=yn;exports.o=Li;exports.p=Fi;exports.q=et;exports.r=Ui;exports.s=$i;exports.t=Bi;exports.u=qi;exports.v=Ne;exports.w=ji;exports.x=kr;exports.y=Pn;exports.z=Fn;//# sourceMappingURL=chunk-634ILVMP.cjs.map
2
- //# sourceMappingURL=chunk-634ILVMP.cjs.map