solve-engine 2.32.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/{EngineError-CqGtaT_v.d.cts → EngineError-Bm4OYmw8.d.cts} +6 -0
  2. package/dist/{EngineError-CqGtaT_v.d.ts → EngineError-Bm4OYmw8.d.ts} +6 -0
  3. package/dist/{Lexer-CqFjYoRA.d.ts → Lexer-DPn5dfCH.d.ts} +1 -13
  4. package/dist/{Lexer-sCI05tqO.d.cts → Lexer-DaWkCu84.d.cts} +1 -13
  5. package/dist/{PackageCompatibility-phvSFP4f.d.ts → PackageCompatibility-CkzZfoJ3.d.ts} +1 -1
  6. package/dist/{PackageCompatibility-Bn-T_xKW.d.cts → PackageCompatibility-E_5GtcQW.d.cts} +1 -1
  7. package/dist/{PackageRegistry-C78jVkI9.d.ts → PackageRegistry-DSqic8kz.d.ts} +132 -23
  8. package/dist/{PackageRegistry-B-C1duZw.d.cts → PackageRegistry-js47hr28.d.cts} +132 -23
  9. package/dist/{Parselet-Dgymjxzd.d.ts → Parselet-CQjcHOKw.d.ts} +13 -6
  10. package/dist/{Parselet-DF3864la.d.cts → Parselet-s1sRRn8H.d.cts} +13 -6
  11. package/dist/{TokenNormalizer-Pe3_390t.d.cts → TokenNormalizer-D382VSYh.d.cts} +4 -1
  12. package/dist/{TokenNormalizer-IF7nPRMp.d.ts → TokenNormalizer-DAzPp-j1.d.ts} +4 -1
  13. package/dist/{VMBuiltins-BkKzhj6C.d.cts → VMBuiltins-JCavlQUj.d.cts} +53 -18
  14. package/dist/{VMBuiltins-Du9y8sEo.d.ts → VMBuiltins-qgzA6qGi.d.ts} +53 -18
  15. package/dist/{VMCheckpoints-WdUQrdc9.d.cts → VMCheckpoints-BxPzmdu0.d.cts} +2 -2
  16. package/dist/{VMCheckpoints-gvy_yxYh.d.ts → VMCheckpoints-DjjE92mf.d.ts} +2 -2
  17. package/dist/{Value-BYHw-x7q.d.cts → Value-2TIKi-YL.d.cts} +19 -0
  18. package/dist/{Value-BYHw-x7q.d.ts → Value-2TIKi-YL.d.ts} +19 -0
  19. package/dist/{WorkerError-DTrl3Jag.d.ts → WorkerError-BaN8_eok.d.ts} +1 -1
  20. package/dist/{WorkerError-CRoM8Ju1.d.cts → WorkerError-CexHHmbb.d.cts} +1 -1
  21. package/dist/{chunk-IJE4AEDX.js → chunk-24OW3AAU.js} +3 -3
  22. package/dist/{chunk-IJE4AEDX.js.map → chunk-24OW3AAU.js.map} +1 -1
  23. package/dist/{chunk-CAJTDZ5B.cjs → chunk-2XOLAHW6.cjs} +2 -2
  24. package/dist/{chunk-CAJTDZ5B.cjs.map → chunk-2XOLAHW6.cjs.map} +1 -1
  25. package/dist/{chunk-AGCNMEP2.cjs → chunk-3MG7VIPL.cjs} +2 -2
  26. package/dist/{chunk-AGCNMEP2.cjs.map → chunk-3MG7VIPL.cjs.map} +1 -1
  27. package/dist/chunk-4ASM522I.js +2 -0
  28. package/dist/chunk-4ASM522I.js.map +1 -0
  29. package/dist/{chunk-KH4QXKLT.js → chunk-4MD5L23F.js} +2 -2
  30. package/dist/{chunk-KH4QXKLT.js.map → chunk-4MD5L23F.js.map} +1 -1
  31. package/dist/{chunk-IQVSCL2R.js → chunk-4XWZXP6I.js} +3 -3
  32. package/dist/{chunk-IQVSCL2R.js.map → chunk-4XWZXP6I.js.map} +1 -1
  33. package/dist/{chunk-RELMEWY6.js → chunk-6G2NES2I.js} +2 -2
  34. package/dist/chunk-6G2NES2I.js.map +1 -0
  35. package/dist/{chunk-CDE2ZUGG.js → chunk-6NL7RBAG.js} +2 -2
  36. package/dist/{chunk-CDE2ZUGG.js.map → chunk-6NL7RBAG.js.map} +1 -1
  37. package/dist/{chunk-SUAGBRQ7.cjs → chunk-6SYU4MH7.cjs} +2 -2
  38. package/dist/chunk-6SYU4MH7.cjs.map +1 -0
  39. package/dist/chunk-72J5V7SN.cjs +2 -0
  40. package/dist/chunk-72J5V7SN.cjs.map +1 -0
  41. package/dist/{chunk-TSJ4RQLZ.js → chunk-AENL3Z66.js} +2 -2
  42. package/dist/{chunk-TSJ4RQLZ.js.map → chunk-AENL3Z66.js.map} +1 -1
  43. package/dist/chunk-APYRNAU2.js +2 -0
  44. package/dist/chunk-APYRNAU2.js.map +1 -0
  45. package/dist/{chunk-AXTYQFIV.cjs → chunk-D7URPV5Z.cjs} +3 -3
  46. package/dist/{chunk-AXTYQFIV.cjs.map → chunk-D7URPV5Z.cjs.map} +1 -1
  47. package/dist/chunk-DB5ISONG.js +2 -0
  48. package/dist/chunk-DB5ISONG.js.map +1 -0
  49. package/dist/chunk-DGDVY6XI.js +3 -0
  50. package/dist/chunk-DGDVY6XI.js.map +1 -0
  51. package/dist/chunk-EOKHRS2T.js +2 -0
  52. package/dist/chunk-EOKHRS2T.js.map +1 -0
  53. package/dist/{chunk-NQFCXLEF.js → chunk-EOO6M65F.js} +2 -2
  54. package/dist/{chunk-NQFCXLEF.js.map → chunk-EOO6M65F.js.map} +1 -1
  55. package/dist/{chunk-A764BY7L.cjs → chunk-EQNKDTMX.cjs} +2 -2
  56. package/dist/{chunk-A764BY7L.cjs.map → chunk-EQNKDTMX.cjs.map} +1 -1
  57. package/dist/chunk-FESR6PZI.cjs +2 -0
  58. package/dist/chunk-FESR6PZI.cjs.map +1 -0
  59. package/dist/chunk-G2LCDR52.cjs +3 -0
  60. package/dist/chunk-G2LCDR52.cjs.map +1 -0
  61. package/dist/chunk-G5TZ6TDA.js +2 -0
  62. package/dist/chunk-G5TZ6TDA.js.map +1 -0
  63. package/dist/chunk-GDLYXRMA.cjs +2 -0
  64. package/dist/chunk-GDLYXRMA.cjs.map +1 -0
  65. package/dist/{chunk-7DJYS5PO.cjs → chunk-HSTGWWU2.cjs} +2 -2
  66. package/dist/{chunk-7DJYS5PO.cjs.map → chunk-HSTGWWU2.cjs.map} +1 -1
  67. package/dist/{chunk-OE2DBN4K.js → chunk-INMJ7ZXL.js} +2 -2
  68. package/dist/chunk-INMJ7ZXL.js.map +1 -0
  69. package/dist/chunk-ITH2RLRG.js +5 -0
  70. package/dist/chunk-ITH2RLRG.js.map +1 -0
  71. package/dist/{chunk-5AKT36UK.cjs → chunk-K3PZ66XR.cjs} +2 -2
  72. package/dist/{chunk-5AKT36UK.cjs.map → chunk-K3PZ66XR.cjs.map} +1 -1
  73. package/dist/chunk-LI6LYJDA.cjs +2 -0
  74. package/dist/chunk-LI6LYJDA.cjs.map +1 -0
  75. package/dist/{chunk-WQGHJAW2.cjs → chunk-M4UC2PB6.cjs} +2 -2
  76. package/dist/{chunk-WQGHJAW2.cjs.map → chunk-M4UC2PB6.cjs.map} +1 -1
  77. package/dist/chunk-O7HF345B.js +2 -0
  78. package/dist/chunk-O7HF345B.js.map +1 -0
  79. package/dist/{chunk-CM2WM5CM.cjs → chunk-OBZJKZ2F.cjs} +2 -2
  80. package/dist/{chunk-CM2WM5CM.cjs.map → chunk-OBZJKZ2F.cjs.map} +1 -1
  81. package/dist/{chunk-Q7TBBV62.cjs → chunk-P5YWBIIU.cjs} +2 -2
  82. package/dist/chunk-P5YWBIIU.cjs.map +1 -0
  83. package/dist/chunk-PICFFFJV.js +3 -0
  84. package/dist/chunk-PICFFFJV.js.map +1 -0
  85. package/dist/{chunk-P43SV4NJ.cjs → chunk-QOOTRUY7.cjs} +3 -3
  86. package/dist/{chunk-P43SV4NJ.cjs.map → chunk-QOOTRUY7.cjs.map} +1 -1
  87. package/dist/chunk-R3W53ZMP.cjs +2 -0
  88. package/dist/chunk-R3W53ZMP.cjs.map +1 -0
  89. package/dist/chunk-RMDCGYZM.js +2 -0
  90. package/dist/chunk-RMDCGYZM.js.map +1 -0
  91. package/dist/{chunk-CB3EXUM2.js → chunk-RU3KGJRA.js} +2 -2
  92. package/dist/chunk-RU3KGJRA.js.map +1 -0
  93. package/dist/chunk-S3SPDK6N.cjs +2 -0
  94. package/dist/chunk-S3SPDK6N.cjs.map +1 -0
  95. package/dist/chunk-SF5QVUEI.cjs +3 -0
  96. package/dist/chunk-SF5QVUEI.cjs.map +1 -0
  97. package/dist/{chunk-FXB5GCBT.js → chunk-TJKN466F.js} +2 -2
  98. package/dist/{chunk-FXB5GCBT.js.map → chunk-TJKN466F.js.map} +1 -1
  99. package/dist/{chunk-VLX7ZVK4.js → chunk-U5MESNRT.js} +2 -2
  100. package/dist/{chunk-VLX7ZVK4.js.map → chunk-U5MESNRT.js.map} +1 -1
  101. package/dist/chunk-WCVPXBCW.cjs +5 -0
  102. package/dist/chunk-WCVPXBCW.cjs.map +1 -0
  103. package/dist/{chunk-YWF6C2IO.cjs → chunk-WFT3XUSH.cjs} +2 -2
  104. package/dist/{chunk-YWF6C2IO.cjs.map → chunk-WFT3XUSH.cjs.map} +1 -1
  105. package/dist/{chunk-3ZGFAE3Q.js → chunk-X2GQAKL2.js} +2 -2
  106. package/dist/{chunk-3ZGFAE3Q.js.map → chunk-X2GQAKL2.js.map} +1 -1
  107. package/dist/{chunk-G3POUURF.js → chunk-YID47OPR.js} +2 -2
  108. package/dist/{chunk-G3POUURF.js.map → chunk-YID47OPR.js.map} +1 -1
  109. package/dist/chunk-YV4GDW5A.cjs +2 -0
  110. package/dist/chunk-YV4GDW5A.cjs.map +1 -0
  111. package/dist/chunk-ZSXQP7PD.cjs +2 -0
  112. package/dist/chunk-ZSXQP7PD.cjs.map +1 -0
  113. package/dist/constants.cjs +1 -1
  114. package/dist/constants.js +1 -1
  115. package/dist/engine.cjs +1 -1
  116. package/dist/engine.d.cts +10 -10
  117. package/dist/engine.d.ts +10 -10
  118. package/dist/engine.js +1 -1
  119. package/dist/engine.worker.cjs +1 -1
  120. package/dist/engine.worker.cjs.map +1 -1
  121. package/dist/engine.worker.js +1 -1
  122. package/dist/engine.worker.js.map +1 -1
  123. package/dist/errors.cjs +1 -1
  124. package/dist/errors.d.cts +3 -3
  125. package/dist/errors.d.ts +3 -3
  126. package/dist/errors.js +1 -1
  127. package/dist/format.cjs +1 -1
  128. package/dist/format.d.cts +1 -1
  129. package/dist/format.d.ts +1 -1
  130. package/dist/format.js +1 -1
  131. package/dist/index.cjs +1 -1
  132. package/dist/index.cjs.map +1 -1
  133. package/dist/index.d.cts +10 -10
  134. package/dist/index.d.ts +10 -10
  135. package/dist/index.js +1 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/language.d.cts +9 -9
  138. package/dist/language.d.ts +9 -9
  139. package/dist/lexer.cjs +1 -1
  140. package/dist/lexer.d.cts +3 -3
  141. package/dist/lexer.d.ts +3 -3
  142. package/dist/lexer.js +1 -1
  143. package/dist/normalizer.cjs +1 -1
  144. package/dist/normalizer.d.cts +2 -2
  145. package/dist/normalizer.d.ts +2 -2
  146. package/dist/normalizer.js +1 -1
  147. package/dist/packages.cjs +1 -1
  148. package/dist/packages.d.cts +8 -8
  149. package/dist/packages.d.ts +8 -8
  150. package/dist/packages.js +1 -1
  151. package/dist/parser.cjs +1 -1
  152. package/dist/parser.d.cts +3 -3
  153. package/dist/parser.d.ts +3 -3
  154. package/dist/parser.js +1 -1
  155. package/dist/{pipeline-BYkKNpql.d.cts → pipeline-Bum6y1B9.d.cts} +1 -1
  156. package/dist/{pipeline-Cl7KW8CB.d.ts → pipeline-DOo3KHaq.d.ts} +1 -1
  157. package/dist/resolvers.cjs +1 -1
  158. package/dist/resolvers.d.cts +69 -3
  159. package/dist/resolvers.d.ts +69 -3
  160. package/dist/resolvers.js +1 -1
  161. package/dist/temporal.cjs +1 -1
  162. package/dist/temporal.js +1 -1
  163. package/dist/testing.cjs +2 -2
  164. package/dist/testing.cjs.map +1 -1
  165. package/dist/testing.d.cts +9 -9
  166. package/dist/testing.d.ts +9 -9
  167. package/dist/testing.js +1 -1
  168. package/dist/testing.js.map +1 -1
  169. package/dist/uom.cjs +1 -1
  170. package/dist/uom.d.cts +35 -2
  171. package/dist/uom.d.ts +35 -2
  172. package/dist/uom.js +1 -1
  173. package/dist/vm.cjs +1 -1
  174. package/dist/vm.d.cts +6 -6
  175. package/dist/vm.d.ts +6 -6
  176. package/dist/vm.js +1 -1
  177. package/dist/worker.cjs +2 -2
  178. package/dist/worker.cjs.map +1 -1
  179. package/dist/worker.d.cts +9 -9
  180. package/dist/worker.d.ts +9 -9
  181. package/dist/worker.js +1 -1
  182. package/dist/worker.js.map +1 -1
  183. package/package.json +1 -1
  184. package/dist/chunk-4DR5RBHQ.cjs +0 -2
  185. package/dist/chunk-4DR5RBHQ.cjs.map +0 -1
  186. package/dist/chunk-4IC5OARK.js +0 -3
  187. package/dist/chunk-4IC5OARK.js.map +0 -1
  188. package/dist/chunk-7ODHPWQC.js +0 -5
  189. package/dist/chunk-7ODHPWQC.js.map +0 -1
  190. package/dist/chunk-A755LVPT.cjs +0 -2
  191. package/dist/chunk-A755LVPT.cjs.map +0 -1
  192. package/dist/chunk-AF6NDOIE.js +0 -2
  193. package/dist/chunk-AF6NDOIE.js.map +0 -1
  194. package/dist/chunk-B2NL65FI.js +0 -2
  195. package/dist/chunk-B2NL65FI.js.map +0 -1
  196. package/dist/chunk-CB3EXUM2.js.map +0 -1
  197. package/dist/chunk-DUFEONVN.cjs +0 -3
  198. package/dist/chunk-DUFEONVN.cjs.map +0 -1
  199. package/dist/chunk-IJHL3LMH.js +0 -2
  200. package/dist/chunk-IJHL3LMH.js.map +0 -1
  201. package/dist/chunk-LCYQQFUH.cjs +0 -2
  202. package/dist/chunk-LCYQQFUH.cjs.map +0 -1
  203. package/dist/chunk-LP3JYC3A.js +0 -2
  204. package/dist/chunk-LP3JYC3A.js.map +0 -1
  205. package/dist/chunk-OE2DBN4K.js.map +0 -1
  206. package/dist/chunk-OKKGPINQ.cjs +0 -5
  207. package/dist/chunk-OKKGPINQ.cjs.map +0 -1
  208. package/dist/chunk-OM7NOHJF.cjs +0 -2
  209. package/dist/chunk-OM7NOHJF.cjs.map +0 -1
  210. package/dist/chunk-PTXUWGRR.js +0 -3
  211. package/dist/chunk-PTXUWGRR.js.map +0 -1
  212. package/dist/chunk-Q7TBBV62.cjs.map +0 -1
  213. package/dist/chunk-RELMEWY6.js.map +0 -1
  214. package/dist/chunk-SFM4XFGJ.js +0 -2
  215. package/dist/chunk-SFM4XFGJ.js.map +0 -1
  216. package/dist/chunk-SRAU3BLV.cjs +0 -3
  217. package/dist/chunk-SRAU3BLV.cjs.map +0 -1
  218. package/dist/chunk-SUAGBRQ7.cjs.map +0 -1
  219. package/dist/chunk-UNKZ5XRC.cjs +0 -2
  220. package/dist/chunk-UNKZ5XRC.cjs.map +0 -1
  221. package/dist/chunk-WU7SBKVU.cjs +0 -2
  222. package/dist/chunk-WU7SBKVU.cjs.map +0 -1
  223. package/dist/chunk-X5K72MBV.js +0 -2
  224. package/dist/chunk-X5K72MBV.js.map +0 -1
  225. package/dist/chunk-ZVPZQ66D.cjs +0 -2
  226. package/dist/chunk-ZVPZQ66D.cjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-EOKHRS2T.js';import {b}from'./chunk-PICFFFJV.js';import {n}from'./chunk-O7HF345B.js';var g="currency",h=class{constructor(a){this.namespace=g;this.watchedOpcodes=[13];this.exchange=a??b;}preflight(a$1,C,d,f,p){let{opcodes:o,strings:y}=C,x=o.length,r=0,s=-1,c=-1;for(;r<x;){let e=o[r];if(e===13&&(c=s,s=o[r+1]),(e===84||e===81||e===20||e===21||e===22||e===23)&&c>=0&&s>=0){let t=y[c],n$1=y[s];if(this.exchange.isCurrency(t)&&this.exchange.isCurrency(n$1)&&t.toUpperCase()!==n$1.toUpperCase()&&this.exchange.getRateSync(t,n$1)===null){let R=t.toUpperCase(),U=n$1.toUpperCase(),i=[g,R,U];if(p.getQueryData(i)!==void 0){r++;continue}let v=p.fetchQuery({queryKey:i,queryFn:({signal:S})=>this.exchange.getRate(t,n$1,S).then(O=>n(O)),staleTime:300*1e3});return {queryKey:i.join(":"),resolver:v,packageId:d,signal:f,metadata:{fromUnit:t,toUnit:n$1}}}}r=a(o,r);}return null}destroy(){}};export{h as a};//# sourceMappingURL=chunk-G5TZ6TDA.js.map
2
+ //# sourceMappingURL=chunk-G5TZ6TDA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/uom/CurrencyResolver.ts"],"names":["CURRENCY_NS","CurrencyAsyncResolver","exchange","currencyExchangeService","_tokens","bytecode","packageId","signal","queryClient","opcodes","strings","len","i","lastStrIdx","prevStrIdx","op","fromUnit","toUnit","fromUpper","toUpper","cacheKey","resolver","qSignal","rate","numberValue","nextInstruction"],"mappings":"4GAkBA,IAAMA,CAAAA,CAAc,WAQPC,CAAAA,CAAN,KAAsD,CAc5D,WAAA,CAAYC,CAAAA,CAAoC,CAbhD,IAAA,CAAS,SAAA,CAAYF,CAAAA,CASrB,KAAS,cAAA,CAAoC,CAAA,EAAmB,EAK/D,IAAA,CAAK,QAAA,CAAWE,GAAYC,EAC7B,CAEA,SAAA,CAAUC,GAAAA,CAAkBC,CAAAA,CAA2BC,CAAAA,CAAmBC,EAAqBC,CAAAA,CAAmD,CACjJ,GAAM,CAAE,OAAA,CAAAC,EAAS,OAAA,CAAAC,CAAQ,CAAA,CAAIL,CAAAA,CACvBM,CAAAA,CAAMF,CAAAA,CAAQ,OAChBG,CAAAA,CAAI,CAAA,CAEJC,EAAa,EAAA,CACbC,CAAAA,CAAa,GAEjB,KAAOF,CAAAA,CAAID,CAAAA,EAAK,CACf,IAAMI,CAAAA,CAAKN,EAAQG,CAAC,CAAA,CAkBpB,GAhBIG,CAAAA,GAAO,EAAA,GACVD,EAAaD,CAAAA,CACbA,CAAAA,CAAaJ,CAAAA,CAAQG,CAAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAY1BG,IAAO,EAAA,EAAyBA,CAAAA,GAAO,IACvCA,CAAAA,GAAO,EAAA,EAAcA,IAAO,EAAA,EAAcA,CAAAA,GAAO,EAAA,EAAcA,CAAAA,GAAO,EAAA,GAElED,CAAAA,EAAc,GAAKD,CAAAA,EAAc,CAAA,CAAG,CACvC,IAAMG,CAAAA,CAAWN,EAAQI,CAAU,CAAA,CAC7BG,GAAAA,CAASP,CAAAA,CAAQG,CAAU,CAAA,CAEjC,GACC,IAAA,CAAK,QAAA,CAAS,WAAWG,CAAQ,CAAA,EACjC,KAAK,QAAA,CAAS,UAAA,CAAWC,GAAM,CAAA,EAC/BD,CAAAA,CAAS,WAAA,KAAkBC,GAAAA,CAAO,WAAA,IAEjB,IAAA,CAAK,QAAA,CAAS,YAAYD,CAAAA,CAAUC,GAAM,CAAA,GAC1C,IAAA,CAAM,CACtB,IAAMC,EAAYF,CAAAA,CAAS,WAAA,GACrBG,CAAAA,CAAUF,GAAAA,CAAO,aAAY,CAG7BG,CAAAA,CAAW,CAACpB,CAAAA,CAAakB,CAAAA,CAAWC,CAAO,EACjD,GAAIX,CAAAA,CAAY,aAAaY,CAAQ,CAAA,GAAM,OAAW,CACrDR,CAAAA,EAAAA,CACA,QACD,CAGA,IAAMS,CAAAA,CAAWb,EAAY,UAAA,CAAW,CACvC,SAAUY,CAAAA,CACV,OAAA,CAAS,CAAC,CAAE,MAAA,CAAQE,CAAQ,CAAA,GACpB,IAAA,CAAK,QAAA,CAAS,QAAQN,CAAAA,CAAUC,GAAAA,CAAQK,CAAO,CAAA,CAAE,IAAA,CAAMC,GAASC,CAAAA,CAAYD,CAAI,CAAC,CAAA,CAEzF,SAAA,CAAW,GAAA,CAAS,GACrB,CAAC,CAAA,CAED,OAAO,CAAE,QAAA,CAAUH,EAAS,IAAA,CAAK,GAAG,CAAA,CAAG,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAf,EAAW,MAAA,CAAAC,CAAAA,CAAQ,SAAU,CAAE,QAAA,CAAAS,EAAU,MAAA,CAAAC,GAAO,CAAE,CACpG,CAEF,CAKDL,EAAIa,CAAAA,CAAgBhB,CAAAA,CAASG,CAAC,EAC/B,CAEA,OAAO,IACR,CAEA,OAAA,EAAgB,CAEhB,CACD","file":"chunk-G5TZ6TDA.js","sourcesContent":["/**\n * Currency async resolver, bridges CurrencyExchangeService to the\n * IAsyncResolver interface for the Suspense architecture.\n *\n * Uses TanStack Query (injected via queryClient) as the single cache layer.\n */\nimport type { QueryClient } from \"@tanstack/query-core\";\nimport type { Token } from \"@solve-js/lexer\";\nimport type { BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { numberValue } from \"@solve-js/vm/Value\";\nimport {\n\tcurrencyExchangeService,\n\tCurrencyExchangeService,\n} from \"@solve-js/uom/CurrencyExchange\";\nimport type { IAsyncResolver, AsyncCheckResult } from \"@solve-js/resolvers/ResolverRegistry\";\nimport { nextInstruction } from \"@solve-js/parser/OperandWidth\";\n\nconst CURRENCY_NS = \"currency\";\n\n/**\n * Fetches exchange rates before the VM runs, so a conversion has real numbers.\n *\n * Until rates arrive the line evaluates to a pending value rather than a\n * guessed one, and re-evaluates when they land.\n */\nexport class CurrencyAsyncResolver implements IAsyncResolver {\n\treadonly namespace = CURRENCY_NS;\n\n\t/**\n\t * Every unit the scan below reads arrives as a `PUSH_STRING` operand, so a\n\t * program with no string constant cannot name a currency and the engine\n\t * need not ask. Deliberately not the arithmetic opcodes the scan also\n\t * checks: `ADD` is in nearly every line, and declaring it would spare\n\t * nothing. See {@link IAsyncResolver.watchedOpcodes}.\n\t */\n\treadonly watchedOpcodes: readonly OpCode[] = [OpCode.PUSH_STRING];\n\n\tprivate exchange: CurrencyExchangeService;\n\n\tconstructor(exchange?: CurrencyExchangeService) {\n\t\tthis.exchange = exchange ?? currencyExchangeService;\n\t}\n\n\tpreflight(_tokens: Token[], bytecode: BytecodeProgram, packageId: string, signal: AbortSignal, queryClient: QueryClient): AsyncCheckResult | null {\n\t\tconst { opcodes, strings } = bytecode;\n\t\tconst len = opcodes.length;\n\t\tlet i = 0;\n\n\t\tlet lastStrIdx = -1;\n\t\tlet prevStrIdx = -1;\n\n\t\twhile (i < len) {\n\t\t\tconst op = opcodes[i] as OpCode;\n\n\t\t\tif (op === OpCode.PUSH_STRING) {\n\t\t\t\tprevStrIdx = lastStrIdx;\n\t\t\t\tlastStrIdx = opcodes[i + 1];\n\t\t\t}\n\n\t\t\t// Explicit \"X to Y\"/\"X in Y\" conversions (UOM_CONVERT_IN/_TO) are\n\t\t\t// the obvious case, but arithmetic directly on two differently-\n\t\t\t// denominated currency literals, \"0.01 BTC + 1 ETH\", needs the\n\t\t\t// exact same preflight fetch and previously never got it: this\n\t\t\t// scanner only looked for the CONVERT opcodes, so ADD/SUB/MUL/DIV\n\t\t\t// between two currency UOMs skipped preflight entirely, ran with\n\t\t\t// no cached rate, and fell through to the VM's silent-wrong-math\n\t\t\t// fallback instead of ever reaching a network fetch.\n\t\t\tconst isCurrencyCombiningOp =\n\t\t\t\top === OpCode.UOM_CONVERT_IN || op === OpCode.UOM_CONVERT_TO ||\n\t\t\t\top === OpCode.ADD || op === OpCode.SUB || op === OpCode.MUL || op === OpCode.DIV;\n\t\t\tif (isCurrencyCombiningOp) {\n\t\t\t\tif (prevStrIdx >= 0 && lastStrIdx >= 0) {\n\t\t\t\t\tconst fromUnit = strings[prevStrIdx];\n\t\t\t\t\tconst toUnit = strings[lastStrIdx];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.exchange.isCurrency(fromUnit) &&\n\t\t\t\t\t\tthis.exchange.isCurrency(toUnit) &&\n\t\t\t\t\t\tfromUnit.toUpperCase() !== toUnit.toUpperCase()\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst syncRate = this.exchange.getRateSync(fromUnit, toUnit);\n\t\t\t\t\t\tif (syncRate === null) {\n\t\t\t\t\t\t\tconst fromUpper = fromUnit.toUpperCase();\n\t\t\t\t\t\t\tconst toUpper = toUnit.toUpperCase();\n\n\t\t\t\t\t\t\t// Check TanStack Query cache\n\t\t\t\t\t\t\tconst cacheKey = [CURRENCY_NS, fromUpper, toUpper];\n\t\t\t\t\t\t\tif (queryClient.getQueryData(cacheKey) !== undefined) {\n\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Fetch via TanStack Query (dedup + retry automatic)\n\t\t\t\t\t\t\tconst resolver = queryClient.fetchQuery({\n\t\t\t\t\t\t\t\tqueryKey: cacheKey,\n\t\t\t\t\t\t\t\tqueryFn: ({ signal: qSignal }) => {\n\t\t\t\t\t\t\t\t\treturn this.exchange.getRate(fromUnit, toUnit, qSignal).then((rate) => numberValue(rate));\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tstaleTime: 5 * 60 * 1000,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn { queryKey: cacheKey.join(\":\"), resolver, packageId, signal, metadata: { fromUnit, toUnit } };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step over this instruction and its operands. Shared table, because\n\t\t\t// three hand-copied versions of this had already drifted.\n\t\t\ti = nextInstruction(opcodes, i);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tdestroy(): void {\n\t\t// Cache cleared by ResolverRegistry.unregister() via removeQueries({ queryKey: [\"currency\"] })\n\t}\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var E=[10,11,12,13,14,16,60,61,62,63,150,159,95,96],O=[50,51,151,152,160],A=[157,158,161],n=(()=>{let _=new Array(256).fill(0);for(let o of E)_[o]=1;for(let o of O)_[o]=2;for(let o of A)_[o]=3;return _})();[...E,...O,...A];function N(_,o){return o+1+(n[_[o]]??0)}exports.a=N;//# sourceMappingURL=chunk-GDLYXRMA.cjs.map
2
+ //# sourceMappingURL=chunk-GDLYXRMA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/parser/OperandWidth.ts"],"names":["ONE_OPERAND","TWO_OPERANDS","THREE_OPERANDS","OPERAND_BYTES","widths","op","nextInstruction","opcodes","index"],"mappings":"aAwBA,IAAMA,CAAAA,CAAiC,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,GAAA,CAAA,GAAA,CAAA,EAAA,CAAA,EAwBvC,CAAA,CAOMC,CAAAA,CAAkC,kBAOxC,CAAA,CASMC,CAAAA,CAAoC,CAAA,GAAA,CAAA,GAAA,CAAA,GAAiE,CAAA,CAQ9FC,CAAAA,CAAAA,CAAoC,IAAM,CACtD,IAAMC,EAAS,IAAI,KAAA,CAAc,GAAG,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,CAC5C,IAAA,IAAWC,KAAML,CAAAA,CAAaI,CAAAA,CAAOC,CAAE,CAAA,CAAI,CAAA,CAC3C,IAAA,IAAWA,CAAAA,IAAMJ,CAAAA,CAAcG,EAAOC,CAAE,CAAA,CAAI,CAAA,CAC5C,IAAA,IAAWA,CAAAA,IAAMH,CAAAA,CAAgBE,CAAAA,CAAOC,CAAE,EAAI,CAAA,CAC9C,OAAOD,CACR,CAAA,GAAG,CAOqD,CACvD,GAAGJ,EACH,GAAGC,CAAAA,CACH,GAAGC,CACJ,EAaO,SAASI,CAAAA,CAAgBC,CAAAA,CAAqBC,EAAuB,CAC3E,OAAOA,CAAAA,CAAQ,CAAA,EAAKL,CAAAA,CAAcI,CAAAA,CAAQC,CAAK,CAAC,GAAK,CAAA,CACtD","file":"chunk-GDLYXRMA.cjs","sourcesContent":["/**\n * How many operand bytes follow each opcode, and how to step over one.\n *\n * Anything walking a bytecode stream without executing it needs this: the\n * resolver preflight scanners look for specific opcodes and must skip past\n * everything else without mistaking an operand byte for an instruction.\n *\n * It used to be a hand-copied switch in each of those scanners. They had\n * already drifted: two counted `CALL_PLUGIN` as three bytes wide and the third\n * omitted it from that arm, so a stream containing one desynchronised there and\n * every opcode after it was read at the wrong offset. Adding an opcode meant\n * remembering every copy, and nothing checked that you had.\n *\n * `__tests__/parser/OperandWidth.spec.ts` asserts every opcode has a width, so\n * a new one fails a test rather than silently defaulting to zero operands.\n */\n\nimport { OpCode } from \"@solve-js/parser/OpCode\";\n\n/**\n * Opcodes taking one operand byte.\n *\n * A constant-pool index, or a variable-name index.\n */\nconst ONE_OPERAND: readonly OpCode[] = [\n\tOpCode.PUSH_NUMBER,\n\tOpCode.PUSH_BIGINT,\n\tOpCode.PUSH_HEX,\n\tOpCode.PUSH_STRING,\n\tOpCode.PUSH_BOOLEAN,\n\t// Its operand is a string-pool index holding the exact decimal text, so a\n\t// scanner must step over one byte exactly as it does for PUSH_STRING.\n\tOpCode.PUSH_DECIMAL,\n\tOpCode.LOAD_VAR,\n\tOpCode.STORE_VAR,\n\tOpCode.LOAD_GLOBAL_VAR,\n\tOpCode.STORE_GLOBAL_VAR,\n\tOpCode.DEFINE_USER_FUNCTION,\n\tOpCode.BIND_UNKNOWN,\n\t// Its operand is a constant-pool index, like PUSH_NUMBER's: the epoch-ms\n\t// was resolved at parse time and stored in `numbers`. Omitting it made\n\t// every scanner read that index byte as an opcode, so an ordinary date\n\t// literal desynchronised the whole preflight walk.\n\tOpCode.DATE_LITERAL,\n\t// One byte, the offset direction (0 forward, 1 backward) for \"N working\n\t// days after/before/from <date>\". See WorkdayOffsetParselet. DATE_WORKDAYS_BETWEEN\n\t// takes no operand and so is not listed here.\n\tOpCode.DATE_WORKDAY_OFFSET,\n];\n\n/**\n * Opcodes taking two operand bytes.\n *\n * A callable index plus an argument count, or a matrix's row and column counts.\n */\nconst TWO_OPERANDS: readonly OpCode[] = [\n\tOpCode.CALL_PLUGIN,\n\tOpCode.CALL_BUILTIN,\n\tOpCode.CALL_USER_FUNCTION,\n\tOpCode.MAT_NEW,\n\t// A body index plus the pooled source-expression string.\n\tOpCode.PLOT_INVOKE,\n];\n\n/**\n * Opcodes taking three operand bytes.\n *\n * The map and reduce invocations, which carry a body index alongside their\n * other operands.\n */\n// CALL_PLUGIN_WIDE: a two-byte plugin index plus the one-byte argument count.\nconst THREE_OPERANDS: readonly OpCode[] = [OpCode.MAP_INVOKE, OpCode.REDUCE_INVOKE, OpCode.CALL_PLUGIN_WIDE];\n\n/**\n * Operand byte count for every opcode, indexed by opcode value.\n *\n * A dense array rather than a map, because the preflight scanners run on every\n * keystroke and this is read once per instruction.\n */\nexport const OPERAND_BYTES: readonly number[] = (() => {\n\tconst widths = new Array<number>(256).fill(0);\n\tfor (const op of ONE_OPERAND) widths[op] = 1;\n\tfor (const op of TWO_OPERANDS) widths[op] = 2;\n\tfor (const op of THREE_OPERANDS) widths[op] = 3;\n\treturn widths;\n})();\n\n/**\n * Every opcode that takes at least one operand.\n *\n * Exported so a test can assert the table stays complete as opcodes are added.\n */\nexport const OPCODES_WITH_OPERANDS: readonly OpCode[] = [\n\t...ONE_OPERAND,\n\t...TWO_OPERANDS,\n\t...THREE_OPERANDS,\n];\n\n/**\n * Offset of the instruction after the one at `index`.\n *\n * @param opcodes - The bytecode stream.\n * @param index - Offset of an opcode, not of an operand byte. Passing an\n * operand offset yields nonsense, which is the failure mode this exists to\n * prevent: a caller stepping by hand and getting one width wrong reads the rest\n * of the stream misaligned.\n * @returns Offset of the next opcode. May be past the end when the instruction\n * at `index` is the last one, so callers loop while it is under `opcodes.length`.\n */\nexport function nextInstruction(opcodes: Uint8Array, index: number): number {\n\treturn index + 1 + (OPERAND_BYTES[opcodes[index]] ?? 0);\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkSUAGBRQ7_cjs=require('./chunk-SUAGBRQ7.cjs');var o={WORKER_CANCELLED:"WORKER_CANCELLED",WORKER_TERMINATED:"WORKER_TERMINATED",WORKER_TRANSPORT_FAILED:"WORKER_TRANSPORT_FAILED",WORKER_UNKNOWN_METHOD:"WORKER_UNKNOWN_METHOD",WORKER_NOT_INITIALISED:"WORKER_NOT_INITIALISED",WORKER_UNKNOWN_PACKAGE:"WORKER_UNKNOWN_PACKAGE"};function t(r){let e={name:r.name,category:r.category,code:r.code,message:r.message,recoverable:r.recoverable};return r.expected!==void 0&&(e.expected=r.expected),r.found!==void 0&&(e.found=r.found),r.suggestion!==void 0&&(e.suggestion=r.suggestion),r.span!==void 0&&(e.span=r.span),e}function a(r){let e=Object.values(chunkSUAGBRQ7_cjs.a).includes(r.category)?r.category:"INTERNAL";return new chunkSUAGBRQ7_cjs.b(e,{code:r.code,message:r.message,expected:r.expected,found:r.found,suggestion:r.suggestion,recoverable:r.recoverable,span:r.span})}function s(r){return chunkSUAGBRQ7_cjs.c.execution(o.WORKER_CANCELLED,r?`The worker request "${r}" was cancelled`:"The worker request was cancelled",r?{method:r}:void 0)}function c(){return chunkSUAGBRQ7_cjs.c.execution(o.WORKER_TERMINATED,"The worker engine was terminated before this request completed")}function g(r){return chunkSUAGBRQ7_cjs.c.external(o.WORKER_TRANSPORT_FAILED,`The worker transport failed: ${r}`,{detail:r})}exports.a=o;exports.b=t;exports.c=a;exports.d=s;exports.e=c;exports.f=g;//# sourceMappingURL=chunk-7DJYS5PO.cjs.map
2
- //# sourceMappingURL=chunk-7DJYS5PO.cjs.map
1
+ 'use strict';var chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var o={WORKER_CANCELLED:"WORKER_CANCELLED",WORKER_TERMINATED:"WORKER_TERMINATED",WORKER_TRANSPORT_FAILED:"WORKER_TRANSPORT_FAILED",WORKER_UNKNOWN_METHOD:"WORKER_UNKNOWN_METHOD",WORKER_NOT_INITIALISED:"WORKER_NOT_INITIALISED",WORKER_UNKNOWN_PACKAGE:"WORKER_UNKNOWN_PACKAGE"};function t(r){let e={name:r.name,category:r.category,code:r.code,message:r.message,recoverable:r.recoverable};return r.expected!==void 0&&(e.expected=r.expected),r.found!==void 0&&(e.found=r.found),r.suggestion!==void 0&&(e.suggestion=r.suggestion),r.span!==void 0&&(e.span=r.span),e}function a(r){let e=Object.values(chunk6SYU4MH7_cjs.a).includes(r.category)?r.category:"INTERNAL";return new chunk6SYU4MH7_cjs.b(e,{code:r.code,message:r.message,expected:r.expected,found:r.found,suggestion:r.suggestion,recoverable:r.recoverable,span:r.span})}function s(r){return chunk6SYU4MH7_cjs.c.execution(o.WORKER_CANCELLED,r?`The worker request "${r}" was cancelled`:"The worker request was cancelled",r?{method:r}:void 0)}function c(){return chunk6SYU4MH7_cjs.c.execution(o.WORKER_TERMINATED,"The worker engine was terminated before this request completed")}function g(r){return chunk6SYU4MH7_cjs.c.external(o.WORKER_TRANSPORT_FAILED,`The worker transport failed: ${r}`,{detail:r})}exports.a=o;exports.b=t;exports.c=a;exports.d=s;exports.e=c;exports.f=g;//# sourceMappingURL=chunk-HSTGWWU2.cjs.map
2
+ //# sourceMappingURL=chunk-HSTGWWU2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors/WorkerError.ts"],"names":["WorkerErrorCodes","serializeEngineError","error","dto","deserializeEngineError","category","ErrorCategory","EngineError","workerCancelledError","method","ErrorFactory","workerTerminatedError","workerTransportError","detail"],"mappings":"mEAoBO,IAAMA,EAAmB,CAE/B,gBAAA,CAAkB,kBAAA,CAElB,iBAAA,CAAmB,oBAEnB,uBAAA,CAAyB,yBAAA,CAEzB,qBAAA,CAAuB,uBAAA,CAEvB,uBAAwB,wBAAA,CAExB,sBAAA,CAAwB,wBACzB,EAyBO,SAASC,CAAAA,CAAqBC,CAAAA,CAA2C,CAC/E,IAAMC,EAA6B,CAClC,IAAA,CAAMD,CAAAA,CAAM,IAAA,CACZ,SAAUA,CAAAA,CAAM,QAAA,CAChB,IAAA,CAAMA,CAAAA,CAAM,KACZ,OAAA,CAASA,CAAAA,CAAM,QACf,WAAA,CAAaA,CAAAA,CAAM,WACpB,CAAA,CAIA,OAAIA,CAAAA,CAAM,QAAA,GAAa,SAAWC,CAAAA,CAAI,QAAA,CAAWD,CAAAA,CAAM,QAAA,CAAA,CACnDA,EAAM,KAAA,GAAU,MAAA,GAAWC,CAAAA,CAAI,KAAA,CAAQD,EAAM,KAAA,CAAA,CAC7CA,CAAAA,CAAM,aAAe,MAAA,GAAWC,CAAAA,CAAI,WAAaD,CAAAA,CAAM,UAAA,CAAA,CAGvDA,CAAAA,CAAM,IAAA,GAAS,SAAWC,CAAAA,CAAI,IAAA,CAAOD,CAAAA,CAAM,IAAA,CAAA,CACxCC,CACR,CAWO,SAASC,CAAAA,CAAuBD,CAAAA,CAAyC,CAC/E,IAAME,CAAAA,CAAW,OAAO,MAAA,CAAOC,mBAAa,EAAE,QAAA,CAASH,CAAAA,CAAI,QAAQ,CAAA,CAChEA,EAAI,QAAA,CAAA,UAAA,CAEP,OAAO,IAAII,mBAAAA,CAAYF,EAAU,CAChC,IAAA,CAAMF,CAAAA,CAAI,IAAA,CACV,QAASA,CAAAA,CAAI,OAAA,CACb,SAAUA,CAAAA,CAAI,QAAA,CACd,MAAOA,CAAAA,CAAI,KAAA,CACX,UAAA,CAAYA,CAAAA,CAAI,WAChB,WAAA,CAAaA,CAAAA,CAAI,WAAA,CACjB,IAAA,CAAMA,EAAI,IACX,CAAC,CACF,CAGO,SAASK,CAAAA,CAAqBC,CAAAA,CAA8B,CAClE,OAAOC,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,gBAAA,CACjBS,CAAAA,CACG,CAAA,oBAAA,EAAuBA,CAAM,CAAA,eAAA,CAAA,CAC7B,kCAAA,CACHA,CAAAA,CAAS,CAAE,OAAAA,CAAO,CAAA,CAAI,MACvB,CACD,CAGO,SAASE,CAAAA,EAAqC,CACpD,OAAOD,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,iBAAA,CACjB,gEACD,CACD,CAGO,SAASY,CAAAA,CAAqBC,CAAAA,CAA6B,CACjE,OAAOH,mBAAAA,CAAa,QAAA,CACnBV,CAAAA,CAAiB,uBAAA,CACjB,gCAAgCa,CAAM,CAAA,CAAA,CACtC,CAAE,MAAA,CAAAA,CAAO,CACV,CACD","file":"chunk-7DJYS5PO.cjs","sourcesContent":["/**\n * Structured errors for the off-main-thread worker harness, and the pair of\n * functions that carry an {@link EngineError} across a `postMessage` boundary.\n *\n * A worker runs in another thread, so a failure there cannot be `throw`n back\n * into the caller's stack. It has to be encoded, posted, and rebuilt on the\n * main side, and it must arrive as a real structured error rather than a lost\n * promise or an opaque string. {@link serializeEngineError} projects an\n * `EngineError` onto a plain, clone-safe object; {@link deserializeEngineError}\n * rebuilds one from that object so the main-side `catch` sees the same\n * `code`/`category`/`message` it would have seen in-process.\n */\n\nimport { EngineError, ErrorCategory, ErrorFactory, type SourceSpan } from \"./EngineError\";\n\n/**\n * Codes the worker harness owns, co-located here rather than unioned into the\n * core catalog, matching the convention `errors/ErrorCode.ts` documents for a\n * domain that keeps its own small code object.\n */\nexport const WorkerErrorCodes = {\n\t/** The caller aborted the request through its `AbortSignal`. */\n\tWORKER_CANCELLED: \"WORKER_CANCELLED\",\n\t/** The worker engine was torn down while a request was still in flight. */\n\tWORKER_TERMINATED: \"WORKER_TERMINATED\",\n\t/** The transport failed or the worker exited before answering. */\n\tWORKER_TRANSPORT_FAILED: \"WORKER_TRANSPORT_FAILED\",\n\t/** A request named a method the runtime does not expose. */\n\tWORKER_UNKNOWN_METHOD: \"WORKER_UNKNOWN_METHOD\",\n\t/** A request arrived before the runtime finished building its engine. */\n\tWORKER_NOT_INITIALISED: \"WORKER_NOT_INITIALISED\",\n\t/** An init named a package the runtime could not resolve. */\n\tWORKER_UNKNOWN_PACKAGE: \"WORKER_UNKNOWN_PACKAGE\",\n} as const;\n\n/**\n * A structured error flattened for transport.\n *\n * Every field is a string, a boolean, or an object of numbers, so the whole\n * thing survives both `structuredClone` (what `postMessage` uses) and\n * `JSON.stringify` (what a host may log). `context`, `cause` and `timestamp`\n * are deliberately dropped rather than posted: a context can hold a value that\n * is not clone-safe, and none of the three is part of what a main-side handler\n * branches on.\n */\nexport interface SerializedEngineError {\n\tname: string;\n\tcategory: ErrorCategory;\n\tcode: string;\n\tmessage: string;\n\texpected?: string;\n\tfound?: string;\n\tsuggestion?: string;\n\trecoverable: boolean;\n\tspan?: SourceSpan;\n}\n\n/** Flatten an {@link EngineError} into a clone-safe {@link SerializedEngineError}. */\nexport function serializeEngineError(error: EngineError): SerializedEngineError {\n\tconst dto: SerializedEngineError = {\n\t\tname: error.name,\n\t\tcategory: error.category,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\trecoverable: error.recoverable,\n\t};\n\t// Only the optional string fields that were actually set cross the wire, so\n\t// a rebuilt error has `undefined` exactly where the original did rather than\n\t// an explicit `undefined` property a deep-equal would trip on.\n\tif (error.expected !== undefined) dto.expected = error.expected;\n\tif (error.found !== undefined) dto.found = error.found;\n\tif (error.suggestion !== undefined) dto.suggestion = error.suggestion;\n\t// A span is character offsets (plain numbers), so it is safe to carry and\n\t// useful for a host that highlights the failing range.\n\tif (error.span !== undefined) dto.span = error.span;\n\treturn dto;\n}\n\n/**\n * Rebuild an {@link EngineError} from its transported form.\n *\n * The category string round-trips straight back into the `ErrorCategory` enum\n * (its members ARE their own string values), so a main-side `catch` reads the\n * same category the worker raised. A malformed category (a message that was not\n * produced by {@link serializeEngineError}) falls back to `INTERNAL` rather than\n * constructing an error with an invalid category.\n */\nexport function deserializeEngineError(dto: SerializedEngineError): EngineError {\n\tconst category = Object.values(ErrorCategory).includes(dto.category)\n\t\t? dto.category\n\t\t: ErrorCategory.INTERNAL;\n\treturn new EngineError(category, {\n\t\tcode: dto.code,\n\t\tmessage: dto.message,\n\t\texpected: dto.expected,\n\t\tfound: dto.found,\n\t\tsuggestion: dto.suggestion,\n\t\trecoverable: dto.recoverable,\n\t\tspan: dto.span,\n\t});\n}\n\n/** The error a request rejects with when its caller aborts through an `AbortSignal`. */\nexport function workerCancelledError(method?: string): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_CANCELLED,\n\t\tmethod\n\t\t\t? `The worker request \"${method}\" was cancelled`\n\t\t\t: \"The worker request was cancelled\",\n\t\tmethod ? { method } : undefined,\n\t);\n}\n\n/** The error every pending request rejects with when the worker engine is terminated. */\nexport function workerTerminatedError(): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_TERMINATED,\n\t\t\"The worker engine was terminated before this request completed\",\n\t);\n}\n\n/** The error a request rejects with when the transport fails or the worker exits early. */\nexport function workerTransportError(detail: string): EngineError {\n\treturn ErrorFactory.external(\n\t\tWorkerErrorCodes.WORKER_TRANSPORT_FAILED,\n\t\t`The worker transport failed: ${detail}`,\n\t\t{ detail },\n\t);\n}\n"]}
1
+ {"version":3,"sources":["../src/errors/WorkerError.ts"],"names":["WorkerErrorCodes","serializeEngineError","error","dto","deserializeEngineError","category","ErrorCategory","EngineError","workerCancelledError","method","ErrorFactory","workerTerminatedError","workerTransportError","detail"],"mappings":"mEAoBO,IAAMA,EAAmB,CAE/B,gBAAA,CAAkB,kBAAA,CAElB,iBAAA,CAAmB,oBAEnB,uBAAA,CAAyB,yBAAA,CAEzB,qBAAA,CAAuB,uBAAA,CAEvB,uBAAwB,wBAAA,CAExB,sBAAA,CAAwB,wBACzB,EAyBO,SAASC,CAAAA,CAAqBC,CAAAA,CAA2C,CAC/E,IAAMC,EAA6B,CAClC,IAAA,CAAMD,CAAAA,CAAM,IAAA,CACZ,SAAUA,CAAAA,CAAM,QAAA,CAChB,IAAA,CAAMA,CAAAA,CAAM,KACZ,OAAA,CAASA,CAAAA,CAAM,QACf,WAAA,CAAaA,CAAAA,CAAM,WACpB,CAAA,CAIA,OAAIA,CAAAA,CAAM,QAAA,GAAa,SAAWC,CAAAA,CAAI,QAAA,CAAWD,CAAAA,CAAM,QAAA,CAAA,CACnDA,EAAM,KAAA,GAAU,MAAA,GAAWC,CAAAA,CAAI,KAAA,CAAQD,EAAM,KAAA,CAAA,CAC7CA,CAAAA,CAAM,aAAe,MAAA,GAAWC,CAAAA,CAAI,WAAaD,CAAAA,CAAM,UAAA,CAAA,CAGvDA,CAAAA,CAAM,IAAA,GAAS,SAAWC,CAAAA,CAAI,IAAA,CAAOD,CAAAA,CAAM,IAAA,CAAA,CACxCC,CACR,CAWO,SAASC,CAAAA,CAAuBD,CAAAA,CAAyC,CAC/E,IAAME,CAAAA,CAAW,OAAO,MAAA,CAAOC,mBAAa,EAAE,QAAA,CAASH,CAAAA,CAAI,QAAQ,CAAA,CAChEA,EAAI,QAAA,CAAA,UAAA,CAEP,OAAO,IAAII,mBAAAA,CAAYF,EAAU,CAChC,IAAA,CAAMF,CAAAA,CAAI,IAAA,CACV,QAASA,CAAAA,CAAI,OAAA,CACb,SAAUA,CAAAA,CAAI,QAAA,CACd,MAAOA,CAAAA,CAAI,KAAA,CACX,UAAA,CAAYA,CAAAA,CAAI,WAChB,WAAA,CAAaA,CAAAA,CAAI,WAAA,CACjB,IAAA,CAAMA,EAAI,IACX,CAAC,CACF,CAGO,SAASK,CAAAA,CAAqBC,CAAAA,CAA8B,CAClE,OAAOC,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,gBAAA,CACjBS,CAAAA,CACG,CAAA,oBAAA,EAAuBA,CAAM,CAAA,eAAA,CAAA,CAC7B,kCAAA,CACHA,CAAAA,CAAS,CAAE,OAAAA,CAAO,CAAA,CAAI,MACvB,CACD,CAGO,SAASE,CAAAA,EAAqC,CACpD,OAAOD,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,iBAAA,CACjB,gEACD,CACD,CAGO,SAASY,CAAAA,CAAqBC,CAAAA,CAA6B,CACjE,OAAOH,mBAAAA,CAAa,QAAA,CACnBV,CAAAA,CAAiB,uBAAA,CACjB,gCAAgCa,CAAM,CAAA,CAAA,CACtC,CAAE,MAAA,CAAAA,CAAO,CACV,CACD","file":"chunk-HSTGWWU2.cjs","sourcesContent":["/**\n * Structured errors for the off-main-thread worker harness, and the pair of\n * functions that carry an {@link EngineError} across a `postMessage` boundary.\n *\n * A worker runs in another thread, so a failure there cannot be `throw`n back\n * into the caller's stack. It has to be encoded, posted, and rebuilt on the\n * main side, and it must arrive as a real structured error rather than a lost\n * promise or an opaque string. {@link serializeEngineError} projects an\n * `EngineError` onto a plain, clone-safe object; {@link deserializeEngineError}\n * rebuilds one from that object so the main-side `catch` sees the same\n * `code`/`category`/`message` it would have seen in-process.\n */\n\nimport { EngineError, ErrorCategory, ErrorFactory, type SourceSpan } from \"./EngineError\";\n\n/**\n * Codes the worker harness owns, co-located here rather than unioned into the\n * core catalog, matching the convention `errors/ErrorCode.ts` documents for a\n * domain that keeps its own small code object.\n */\nexport const WorkerErrorCodes = {\n\t/** The caller aborted the request through its `AbortSignal`. */\n\tWORKER_CANCELLED: \"WORKER_CANCELLED\",\n\t/** The worker engine was torn down while a request was still in flight. */\n\tWORKER_TERMINATED: \"WORKER_TERMINATED\",\n\t/** The transport failed or the worker exited before answering. */\n\tWORKER_TRANSPORT_FAILED: \"WORKER_TRANSPORT_FAILED\",\n\t/** A request named a method the runtime does not expose. */\n\tWORKER_UNKNOWN_METHOD: \"WORKER_UNKNOWN_METHOD\",\n\t/** A request arrived before the runtime finished building its engine. */\n\tWORKER_NOT_INITIALISED: \"WORKER_NOT_INITIALISED\",\n\t/** An init named a package the runtime could not resolve. */\n\tWORKER_UNKNOWN_PACKAGE: \"WORKER_UNKNOWN_PACKAGE\",\n} as const;\n\n/**\n * A structured error flattened for transport.\n *\n * Every field is a string, a boolean, or an object of numbers, so the whole\n * thing survives both `structuredClone` (what `postMessage` uses) and\n * `JSON.stringify` (what a host may log). `context`, `cause` and `timestamp`\n * are deliberately dropped rather than posted: a context can hold a value that\n * is not clone-safe, and none of the three is part of what a main-side handler\n * branches on.\n */\nexport interface SerializedEngineError {\n\tname: string;\n\tcategory: ErrorCategory;\n\tcode: string;\n\tmessage: string;\n\texpected?: string;\n\tfound?: string;\n\tsuggestion?: string;\n\trecoverable: boolean;\n\tspan?: SourceSpan;\n}\n\n/** Flatten an {@link EngineError} into a clone-safe {@link SerializedEngineError}. */\nexport function serializeEngineError(error: EngineError): SerializedEngineError {\n\tconst dto: SerializedEngineError = {\n\t\tname: error.name,\n\t\tcategory: error.category,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\trecoverable: error.recoverable,\n\t};\n\t// Only the optional string fields that were actually set cross the wire, so\n\t// a rebuilt error has `undefined` exactly where the original did rather than\n\t// an explicit `undefined` property a deep-equal would trip on.\n\tif (error.expected !== undefined) dto.expected = error.expected;\n\tif (error.found !== undefined) dto.found = error.found;\n\tif (error.suggestion !== undefined) dto.suggestion = error.suggestion;\n\t// A span is character offsets (plain numbers), so it is safe to carry and\n\t// useful for a host that highlights the failing range.\n\tif (error.span !== undefined) dto.span = error.span;\n\treturn dto;\n}\n\n/**\n * Rebuild an {@link EngineError} from its transported form.\n *\n * The category string round-trips straight back into the `ErrorCategory` enum\n * (its members ARE their own string values), so a main-side `catch` reads the\n * same category the worker raised. A malformed category (a message that was not\n * produced by {@link serializeEngineError}) falls back to `INTERNAL` rather than\n * constructing an error with an invalid category.\n */\nexport function deserializeEngineError(dto: SerializedEngineError): EngineError {\n\tconst category = Object.values(ErrorCategory).includes(dto.category)\n\t\t? dto.category\n\t\t: ErrorCategory.INTERNAL;\n\treturn new EngineError(category, {\n\t\tcode: dto.code,\n\t\tmessage: dto.message,\n\t\texpected: dto.expected,\n\t\tfound: dto.found,\n\t\tsuggestion: dto.suggestion,\n\t\trecoverable: dto.recoverable,\n\t\tspan: dto.span,\n\t});\n}\n\n/** The error a request rejects with when its caller aborts through an `AbortSignal`. */\nexport function workerCancelledError(method?: string): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_CANCELLED,\n\t\tmethod\n\t\t\t? `The worker request \"${method}\" was cancelled`\n\t\t\t: \"The worker request was cancelled\",\n\t\tmethod ? { method } : undefined,\n\t);\n}\n\n/** The error every pending request rejects with when the worker engine is terminated. */\nexport function workerTerminatedError(): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_TERMINATED,\n\t\t\"The worker engine was terminated before this request completed\",\n\t);\n}\n\n/** The error a request rejects with when the transport fails or the worker exits early. */\nexport function workerTransportError(detail: string): EngineError {\n\treturn ErrorFactory.external(\n\t\tWorkerErrorCodes.WORKER_TRANSPORT_FAILED,\n\t\t`The worker transport failed: ${detail}`,\n\t\t{ detail },\n\t);\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {b as b$1}from'./chunk-3ZGFAE3Q.js';import {c as c$2}from'./chunk-PTXUWGRR.js';import {ga,C,z,B as B$1,E,p,i,j,r,s,qa,l,h,g,f,e as e$1,k,Q as Q$2,V as V$1,ha,la,ra,ja,ma,J,w as w$1,o,a as a$1,d,u as u$1,W,Y,F,_ as _$1,da,ca,ba,$,L,O,c as c$3,na,pa,ka,ia,oa,v as v$1,q as q$1,m,b as b$2,A,n as n$1,K as K$2,fa,I,H as H$1,G,N as N$1,t as t$1,D,P as P$2,y,x,M}from'./chunk-KH4QXKLT.js';import {b}from'./chunk-NQFCXLEF.js';import {Q as Q$1,P as P$1,p as p$1,q,K as K$1,n,s as s$1,u,C as C$1,v,H,N,t,r as r$1}from'./chunk-X5K72MBV.js';import {c as c$1,e,i as i$1,j as j$1}from'./chunk-BWTVJD5L.js';import {a}from'./chunk-PRSXXDTA.js';import {c}from'./chunk-RELMEWY6.js';function Xt(e,t){let n=t===2?L:M,o=n(e.n),r=n(e.d);return o===null||r===null?null:{n:o,d:r}}function Zt(e,t){let n=y(e),o=new Map;for(let[r,i]of n){if(i%t!==0)return null;o.set(r,i/t);}return x(o)}function Wn(e,t){let n=y(e);for(let[o,r]of y(t))n.set(o,(n.get(o)??0)+r);return x(n)}function Ht(e,t){let n=y(e);for(let[o,r]of y(t)){let i=(n.get(o)??0)-r;i<=0?n.delete(o):n.set(o,i);}return x(n)}function Qn(e,t){let n=y(e),o=new Map;for(let[r,i]of y(t)){let a=n.get(r);a!==void 0&&o.set(r,Math.min(a,i));}return x(o)}function zn(e){let t=new Set;for(let n of e)for(let o of 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 E({terms:t,vars:zn(e.map(n=>n.key))})}function We(e){let t=e[0];for(let n=1;n<e.length;n++)t={kind:"mul",left:t,right:e[n]};return t}function Jn(e){return [...e.terms].map(([n,o])=>({key:n,coefficient:o})).sort((n,o)=>D(n.key,o.key,e.vars))}function zt(e){if(e.vars.length<2)return null;let t=Jn(e);return t.length===2?eo(t[0],t[1]):t.length===3?to(t):t.length===4?no(t):null}function eo(e,t){let n=e.coefficient.n>0n,o=t.coefficient.n>0n;if(!n)return null;let r=Qe(e,t,2);if(r!==null&&!o)return We([Q([r.a,Te(r.b)]),Q([r.a,r.b])]);let i=Qe(e,t,3);if(i===null)return null;let a=Q(o?[i.a,i.b]:[i.a,Te(i.b)]),u=o?Te(Ve(i.a,i.b)):Ve(i.a,i.b);return We([a,Q([Wt(i.a),u,Wt(i.b)])])}function Qe(e,t,n){let o=t.coefficient.n<0n?j(t.coefficient):t.coefficient,r=Xt(e.coefficient,n),i=Xt(o,n);if(r===null||i===null)return null;let a=Zt(e.key,n),u=Zt(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:j(e.coefficient)}}function Ve(e,t){return {key:Wn(e.key,t.key),coefficient:h(e.coefficient,t.coefficient)}}function Wt(e){return Ve(e,e)}function to(e){let[t,n,o]=e;if(t.coefficient.n<0n||o.coefficient.n<0n)return null;let r=Qe(t,o,2);if(r===null)return null;let i$1=Ve(r.a,r.b);if(i$1.key!==n.key)return null;let a=h(i$1.coefficient,{n:2n,d:1n}),u=n.coefficient.n<0n,l=u?j(n.coefficient):n.coefficient;return m(i(l,a))?{kind:"pow",base:Q([r.a,u?Te(r.b):r.b]),exponent:p(2)}:null}function no(e){let t=[[[0,1],[2,3]],[[0,2],[1,3]],[[0,3],[1,2]]];for(let n of t){let o=Qt(e[n[0][0]],e[n[0][1]]),r=Qt(e[n[1][0]],e[n[1][1]]);if(!(o===null||r===null)&&oo(o.cofactor,r.cofactor))return We([Q([o.common,r.common]),Q(o.cofactor)])}return null}function Qt(e,t){let n=Qn(e.key,t.key),o={key:n,coefficient:e.coefficient},r=[{key:Ht(e.key,n),coefficient:{n:1n,d:1n}},{key:Ht(t.key,n),coefficient:i(t.coefficient,e.coefficient)}];return r[0].key===r[1].key?null:{common:o,cofactor:r}}function oo(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 ro=12,we=4096;function Oe(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 en(e,t){return e===0n||t===0n?0n:e/Oe(e,t)*t}function Jt(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>we)return null}return n}function tn(e,t){let n=a$1;for(let o of e)n=f(h(n,t),o);return n}function io(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(f(e[o],h(n[o-1],t)));return n}function ue(e){if(e.length<2)return [];let t=1n;for(let s of e)t=en(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=Jt(r),a=Jt(o);if(i===null||a===null)throw c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial's coefficients have too many divisors to search for rational roots.",{limit:we});if(i.length*a.length>we)throw c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial has too many candidate rational roots to test.",{limit:we});let u=[],l$1=new Set;for(let s of i)for(let p of a)for(let h of [1n,-1n]){let x={n:h*s/Oe(s,p),d:p/Oe(s,p)},T=`${x.n}/${x.d}`;l$1.has(T)||(l$1.add(T),l(tn(e,x))&&u.push(x));}return u}function ao(e,t){return l(t)?q$1(e):t.n>0n?{kind:"sub",left:q$1(e),right:p(t)}:{kind:"add",left:q$1(e),right:p(j(t))}}function uo(e,t){let n=e.length-1,o=new Map;return e.forEach((r,i)=>{if(l(r))return;let a=n-i;o.set(a===0?"":a===1?t:`${t}^${a}`,r);}),E({terms:o,vars:o.size>0?[t]:[]})}function Je(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&&l(tn(o,a));)o=io(o,a),u++;u>0&&n.push({base:ao(t,a),power:u});}r=o.length>2?ue(o):[];}return o.length-1>=1?(n.push({base:uo(o,t),power:1}),{content:b$2,factors:n}):{content:o.length===1?o[0]:b$2,factors:n}}function lo(e){let t=[];m(e.content)||t.push(p(e.content));for(let o of e.factors)t.push(o.power===1?o.base:r(o.base,p({n:BigInt(o.power),d:1n})));if(t.length===0)return p(b$2);let n=t[0];for(let o=1;o<t.length;o++)n={kind:"mul",left:n,right:t[o]};return n}function so(e){let t=0n,n=1n;for(let o of e.terms.values())t=Oe(t,o.n),n=en(n,o.d);return t===0n?b$2:{n:t,d:n}}function co(e){let t=new Map;for(let r of e.vars){let i=1/0;for(let a of e.terms.keys()){let u=mo(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=ze(r);for(let[u,l]of t)a.set(u,(a.get(u)??0)-l);n.set(fo(a),i);}let o=new Set;for(let r of n.keys())for(let i of ze(r).keys())o.add(i);return {monomial:t,reduced:{terms:n,vars:[...o].sort()}}}function mo(e,t){return ze(e).get(t)??0}function ze(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 fo(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 po(e){let t=[...e.keys()].sort(),n=null;for(let o of t){let r$1=e.get(o),i=r$1===1?q$1(o):r(q$1(o),p({n:BigInt(r$1),d:1n}));n=n===null?i:{kind:"mul",left:n,right:i};}return n}function nn(e){let t=C(e);if(t===null||t.terms.size===0||z(t)>ro||t.vars.length===0)return e;let n=so(t),o=m(n)?t:bo(t,i(b$2,n)),{monomial:r,reduced:i$1}=co(o),a=po(r),u=A(i$1);if(u===null){let te=zt(i$1);return te!==null?yo(n,a,te):ho(n,a,i$1)??e}let l=[...B$1(i$1,u)].reverse(),s=Je(l,u),p$1=h(n,s.content);if(s.factors.length<=1&&(s.factors[0]?.power??1)===1&&a===null&&m(p$1))return e;let x=[];m(p$1)||x.push(p(p$1)),a!==null&&x.push(a),x.push(lo({content:b$2,factors:s.factors}));let T=x[0];for(let te=1;te<x.length;te++)T={kind:"mul",left:T,right:x[te]};return T}function bo(e,t){let n=new Map;for(let[o,r]of e.terms)n.set(o,h(r,t));return {terms:n,vars:e.vars}}function yo(e,t,n){let o=[];m(e)||o.push(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 ho(e,t,n){if(t===null&&m(e))return null;let o=[];m(e)||o.push(p(e)),t!==null&&o.push(t),o.push(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 _={n:2n,d:1n},B={n:3n,d:1n},be={n:4n,d:1n};function No(e,t,n,o){let r=j(i(t,h(B,e))),i$1=i(g(h(B,h(e,n)),h(t,t)),h(B,h(e,e))),a=h(_,h(t,h(t,t))),u=h({n:9n,d:1n},h(e,h(t,n))),l=h({n:27n,d:1n},h(h(e,e),o)),s=i(f(g(a,u),l),h({n:27n,d:1n},h(e,h(e,e))));return {p:i$1,q:s,shift:r}}function rn(e,t,n,o){let{p:r,q:i,shift:a}=No(e,t,n,o),u=j(f(h(be,h(r,h(r,r))),h({n:27n,d:1n},h(i,i))));return k(u,a$1)>0?{exact:[],approximate:Ao(r,i,a)}:l(u)?{exact:go(r,i,a),approximate:[]}:{exact:Ro(r,i,a),approximate:[]}}function go(e,t,n){if(l(e))return [p(n)];let o=f(i(h(B,t),e),n),r=f(j(i(h(B,t),h(_,e))),n);return [o,r].sort(k).map(p)}function Ro(e,t,n){let o=j(i(t,_)),r=f(h(i(t,_),i(t,_)),h(i(e,B),h(i(e,B),i(e,B)))),i$1=O(r),a={kind:"call",name:"cbrt",args:[{kind:"add",left:p(o),right:i$1}]},u={kind:"call",name:"cbrt",args:[{kind:"sub",left:p(o),right:i$1}]},l={kind:"add",left:a,right:u},s={kind:"sub",left:a,right:u},p$1={kind:"add",left:p(n),right:{kind:"div",left:{kind:"neg",operand:l},right:p(_)}},h$1={kind:"mul",left:{kind:"div",left:{kind:"mul",left:s,right:O(B)},right:p(_)},right:w$1(n$1)};return [{kind:"add",left:p(n),right:l},{kind:"sub",left:p$1,right:h$1},{kind:"add",left:p$1,right:h$1}]}function Ao(e,t,n){let o=e$1(e),r=e$1(t),i=e$1(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 xo(e,t,n,o){let r=j(i(e,be)),i$1=h(e,e),a=g(t,i(h(B,i$1),{n:8n,d:1n})),u=f(g(n,i(h(e,t),_)),i(h(i$1,e),{n:8n,d:1n})),l=g(f(g(o,i(h(e,n),be)),i(h(i$1,t),{n:16n,d:1n})),i(h(B,h(i$1,i$1)),{n:256n,d:1n}));return {p:a,q:u,r:l,shift:r}}function an(e,t,n,o,r,i$1){let a=T=>i(T,e),{p:u,q:l$1,r:s,shift:p$1}=xo(a(t),a(n),a(o),a(r)),h=l(l$1)?Mo(u,s):ko(u,l$1,s,i$1);if(h===null)return null;let x=l(p$1)?h:h.map(T=>({kind:"add",left:p(p$1),right:T}));return {exact:vo(x),approximate:[]}}function vo(e){let t=new Set,n=[];for(let o of e){let r=t$1(Q$2(o));t.has(r)||(t.add(r),n.push(o));}return n}function Mo(e,t){let n=g(h(e,e),h(be,t));if(k(n,a$1)<0)return So(e,t);let o=N$1(n);return o!==null?Io(j(e),o,l(n)):Eo(e,t,n)}function Io(e,t,n){let o=n?[i(e,_)]:[i(f(e,t),_),i(g(e,t),_)],r=[];for(let i of o){if(l(i)){r.push(p(a$1));continue}let a=P$2(i);r.push({kind:"neg",operand:a},a);}return r}function Eo(e,t,n){let o=p(j(e)),r=O(n),i=k(e,a$1)<=0,a=[{node:et({kind:"add",left:o,right:r}),positive:i||k(t,a$1)<=0},{node:et({kind:"sub",left:o,right:r}),positive:i&&k(t,a$1)>=0}],u=[];for(let{node:l,positive:s}of a){let h={kind:"call",name:"sqrt",args:[s?l:{kind:"neg",operand:l}]},x=s?h:{kind:"mul",left:h,right:w$1(n$1)};u.push({kind:"neg",operand:x},x);}return u}function et(e){return {kind:"div",left:e,right:p(_)}}function So(e,t){let n=i(j(e),_),o=N$1(t),r=o===null?on(O(t),n):O(i(f(o,n),_)),a={kind:"mul",left:o===null?on(O(t),j(n)):O(i(g(o,n),_)),right:w$1(n$1)},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 on(e,t){let n=t.n>=0n?{kind:"add",left:e,right:p(t)}:{kind:"sub",left:e,right:p(j(t))};return {kind:"call",name:"sqrt",args:[et(n)]}}function ko(e,t,n,o){let r=[{n:1n,d:1n},h(_,e),g(h(e,e),h(be,n)),j(h(t,t))];for(let i$1 of ue(r)){if(k(i$1,a$1)<=0)continue;let a=N$1(i$1);if(a===null)continue;let u=f(e,i$1),l=i(t,a),s=i(g(u,l),_),p=i(f(u,l),_),h={n:1n,d:1n};return [...o(h,a,s),...o(h,j(a),p)]}return null}var _o=200,To=1e-14,Vo=1e-10,wo=1e-10,un=1e-9,Oo=1e-8,Co=4;function ye(e,t){return {re:e.re-t.re,im:e.im-t.im}}function Do(e,t){return {re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function sn(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 Ce(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 Po(e,t){let n=K(t),o=0;for(let r of e)o=o*n+Math.abs(r);return o}function Lo(e){let t=e.length-1,n=[];for(let o=0;o<t;o++)n.push(e[o]*(t-o));return n}function Fo(e){let t=[...e].reverse(),o=[...K$2(t)].reverse().map(e$1);return o.some(r=>!Number.isFinite(r))?null:o}function Uo(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 $o(e){let t=e.length-1,n=Uo(e);for(let o=0;o<_o;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=Do(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=sn(Ce(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<=To*i)return n}return null}function ln(e,t,n){let o=n;for(let r=0;r<Co;r++){let i=Ce(t,o);if(i.re===0&&i.im===0)break;let a=ye(o,sn(Ce(e,o),i));if(!Number.isFinite(a.re)||!Number.isFinite(a.im))break;o=a;}return o}function Bo(e,t,n){let o=Math.max(1,K(n));if(n.im!==0&&Math.abs(n.im)<=un*o){let r=ln(e,t,{re:n.re,im:0});if(tt(e,r))return {re:r.re,im:0}}if(n.re!==0&&Math.abs(n.re)<=un*o){let r=ln(e,t,{re:0,im:n.im});if(tt(e,r))return {re:0,im:r.im}}return n}function tt(e,t){return !Number.isFinite(t.re)||!Number.isFinite(t.im)?false:K(Ce(e,t))<=Vo*Po(e,t)}function qo(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>Oo*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 Yo(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]))<=wo*o)return false}return true}function cn(e){let t=Fo(e);if(t===null)return null;if(t.length<2)return [];let n=$o(t);if(n===null)return null;let o=Lo(t),r=qo(n).map(i=>Bo(t,o,i));for(let i of r)if(!tt(t,i))return null;return Yo(r)?[...r].sort((i,a)=>i.re-a.re||i.im-a.im):null}var mn=8;function Go(e,t){let n=a$1;for(let o of e)n=f(h(n,t),o);return n}function jo(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(f(e[o],h(n[o-1],t)));return n}function fn(e,t,n){let o=g(h(t,t),h(Zo(),h(e,n))),r=h(Xo(),e);if(k(o,a$1)<0)return Ko(j(t),o,r);if(l(o))return [p(i(j(t),r))];let i$1=L(o.n),a=L(o.d);if(i$1!==null&&a!==null){let h={n:i$1,d:a},x=i(f(j(t),h),r),T=i(g(j(t),h),r);return k(T,x)<=0?[p(T),p(x)]:[p(x),p(T)]}let u=O(o),l$1=k(r,a$1)>0,s={kind:"div",left:{kind:"sub",left:p(j(t)),right:u},right:p(r)},p$1={kind:"div",left:{kind:"add",left:p(j(t)),right:u},right:p(r)};return l$1?[s,p$1]:[p$1,s]}function Ko(e,t,n){let o$1=j(t),r=L(o$1.n),i$1=L(o$1.d);if(r!==null&&i$1!==null){let s=i({n:r,d:i$1},n),p=i(e,n);return [w$1(o(p,j(s))),w$1(o(p,s))]}let a=i(e,n),u=i(o$1,h(n,n)),l$1={kind:"mul",left:O(u),right:w$1(n$1)};return l(a)?[{kind:"neg",operand:l$1},l$1]:[{kind:"sub",left:p(a),right:l$1},{kind:"add",left:p(a),right:l$1}]}function Xo(){return {n:2n,d:1n}}function Zo(){return {n:4n,d:1n}}function Ho(e){return {re:e,im:0}}function dn(e,t,n){let o=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=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`}:Wo(o,n);if(i===0)return o.terms.size===0?{kind:"identity"}:{kind:"contradiction"};if(i>mn)return {kind:"unsupported",reason:`degree ${i} is above the supported maximum of ${mn}`};let a=[...B$1(o,n)].reverse();return Jo(a)}function Wo(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=E({terms:n,vars:r(n)});return {kind:"roots",exact:[{kind:"div",left:{kind:"neg",operand:E({terms:o,vars:r(o)})},right:i}],approximate:[]}}function Qo(e){return e.length===4?rn(e[0],e[1],e[2],e[3]):e.length===5?an(e[0],e[1],e[2],e[3],e[4],fn):null}function zo(e){let t=[],n=[...e],o=0;for(;n.length>1&&l(n[n.length-1]);)n=n.slice(0,-1),o++;for(o>0&&t.push(a$1);n.length>1;){let r=ue(n);if(r.length===0)break;for(let i of r){let a=0;for(;n.length>1&&l(Go(n,i));)n=jo(n,i),a++;a>0&&t.push(i);}}return {roots:t.sort(k),remaining:n}}function Jo(e){let{roots:t,remaining:n}=zo(e),o=t.map(p),r=[],i$1=n.length-1,a=e.length-n.length;if(i$1<=0)return le(o,r,a,0,"");if(i$1===1)return o.push(p(i(j(n[1]),n[0]))),le(o,r,a+1,0,"");if(i$1===2)return o.push(...fn(n[0],n[1],n[2])),le(o,r,a+2,0,"");let u=Qo(n);if(u!==null)return o.push(...u.exact),r.push(...u.approximate.map(Ho)),le(o,r,a+i$1,0,"");let l=cn(n);return l!==null?(r.push(...l),le(o,r,a+i$1,0,"")):le(o,r,a,i$1,`a degree-${i$1} 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 pn={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"},er=31,ki=new Set([67,68,69,70,71,72,73,74,75,76,77,78,79]);function V(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)?p(d(t)):null}function w(e){let t=Q$2(e);return t.kind==="const"?n(e$1(t.value)):K$1(t)}function De(e){return P$1("SYMBOLIC_UNSUPPORTED_FUNCTION",`"${e}" cannot be applied to an expression that still contains an unknown.`)}function _i(e,t){let n=V(e),o=V(t);return n===null||o===null?De("^"):w(r(n,o))}function Ti(e){let t=V(e);return t===null?De("-"):w({kind:"neg",operand:t})}function Vi(e,t){let n=[];for(let r of t){let i=Q$1(r);if(i)return i;let a=V(r);if(a===null)return De(pn[e]??`builtin ${e}`);n.push(a);}if(e===er&&n.length===2)return w(r(n[0],n[1]));let o=pn[e];return o===void 0?De(`builtin ${e}`):w(s(o,n))}function tr(e){let t=w(e);return t.type===0&&!Number.isInteger(t.toNumber())?K$1(e):t}function nr(e){return e.im===0?n(e.re):K$1(w$1(o(d(e.re),d(e.im))))}function or(e){switch(e.kind){case "identity":return t("true for every value");case "contradiction":return t("no solution");case "unsupported":return P$1("SYMBOLIC_SOLVE_UNSUPPORTED",`Cannot solve this equation: ${e.reason}.`);case "incomplete":{let t=e.exact.length+e.approximate.length;return P$1("SYMBOLIC_SOLVE_INCOMPLETE",`Only ${t} of this equation's ${t+e.missing} roots could be found: ${e.reason}.`)}case "roots":{let t$1=e.exact.map(tr);for(let n of e.approximate)t$1.push(nr(n));return t$1.length===0?t("no solution"):t$1.length===1?t$1[0]:C$1(1,t$1.length,t$1.map(n=>n.type===9?n.value:n.toNumber()))}}}function yn(e,t,n){let o=V(e),r=V(t);return o===null||r===null?P$1("SYMBOLIC_NONFINITE_OPERAND","An equation side has no exact value to solve with."):or(dn(o,r,n))}function he(e$1,t){if(e$1.type===6&&t.type===6){if(e$1.unit===t.unit)return {lv:e$1.toNumber(),rv:t.toNumber(),unit:e$1.unit,sameMeasure:true};let n=c$1(e$1.unit),o=c$1(t.unit),r=c$2.isCurrency(e$1.unit)&&c$2.isCurrency(t.unit);if(n&&n===o){let i=e(t.toNumber(),t.unit,e$1.unit);return {lv:e$1.toNumber(),rv:i,unit:e$1.unit,sameMeasure:true}}if(r){let i=c$2.convertSync(t.toNumber(),t.unit,e$1.unit);if(i!==null)return {lv:e$1.toNumber(),rv:i,unit:e$1.unit,sameMeasure:true}}return {lv:e$1.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:false}}return e$1.type===6?{lv:e$1.toNumber(),rv:t.toNumber(),unit:e$1.unit,sameMeasure:true}:t.type===6?{lv:e$1.toNumber(),rv:t.toNumber(),unit:t.unit,sameMeasure:true}:{lv:e$1.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:true}}var rr=1e-12;function ir(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 qi(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&&c$2.isCurrency(e.unit))return {lv:n,rv:o,equal: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=ir(n,o,t.toNumber());return {lv:n,rv:o,equal:Math.abs(n-o)<=i*rr,sameMeasure:true}}var ar={time:"duration",luminousIntensity:"luminous intensity"},ur=new Set(["money","data"]),lr={add:"added",sub:"subtracted",mul:"multiplied",div:"divided"};function Pe(e){if(c$2.isCurrency(e))return "money";let t=c$1(e);if(t!==void 0)return ar[t]??t}function hn(e){return ur.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 sr(e){return e!==void 0?lr[e]??"combined":"combined"}function Yi(e,t){let n=Pe(e),o=Pe(t);if(n!==void 0&&o!==void 0&&n!==o)return `${hn(n)} cannot be converted to ${hn(o)}`}function Gi(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 P$1("INCOMPATIBLE_UNITS",r??`Cannot compare incompatible units: ${n??"?"} and ${o??"?"}`)}function Nn(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 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 ji(){return 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 Ki(e,t){let n=gn(e),o=gn(t);return n===null||o===null?null:n<o?-1:n>o?1:0}function gn(e){if(e.type===2)return e.value;let t=e.toNumber();return Number.isInteger(t)?BigInt(t):null}function nt(e,t){return Number.isFinite(t)?Math.pow(e,t):e===1||e===-1&&!Number.isNaN(t)?1:Math.pow(e,t)}function Rn(e){return e.exact!==void 0?e.exact:ha(e.toNumber())}function cr(e,t,n){let o=e.type===6&&e.unit!==void 0&&e.exact!==void 0&&c$2.isCurrency(e.unit),r=t.type===6&&t.unit!==void 0&&t.exact!==void 0&&c$2.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=Rn(t);else if(r&&e.type!==6)a=t.exact,u=t.unit,i=Rn(e);else return null;if(i===null||a===null)return null;let l;switch(n){case "add":l=ja(i,a);break;case "sub":l=ka(i,a);break;case "mul":l=la(i,a);break;case "div":if(na(a))return null;l=pa(i,a);break}return v(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)?c$3(BigInt(e.value)):null}function Xi(e,t,n){let o=Le(e);if(o===null)return null;let r=Le(t);if(r===null||n==="div"&&l(r))return null;let i$1;try{switch(n){case "add":i$1=f(o,r);break;case "sub":i$1=g(o,r);break;case "mul":i$1=h(o,r);break;case "div":i$1=i(o,r);break}}catch{return null}return p$1(e$1(i$1),i$1)}function Zi(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 q(u,l)}function Hi(e,t){let n=Le(e);if(n===null)return null;let o=Le(t);return o===null?null:k(n,o)}function Wi(e,t,n$1,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=V(e),a=V(t);return i===null||a===null?P$1("SYMBOLIC_NONFINITE_OPERAND","A symbolic expression cannot combine with a value that has no exact number (NaN or infinity)."):K$1(Q$2({kind:r,left:i,right:a}))}if(e.type===0&&t.type===0)return n(n$1(e.value,t.value));if(e.type===2||t.type===2){let i=Nn(e),a=Nn(t);return o?s$1(o(i,a)):s$1(i+a)}if(e.type===6||t.type===6){if(r){let s=cr(e,t,r);if(s)return s}let{lv:i,rv:a,unit:u$1,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,sr(r));return P$1("INCOMPATIBLE_UNITS",h??`Cannot combine incompatible units: ${s??"?"} and ${p??"?"}`)}return u(n$1(i,a),u$1)}if(e.type===7&&t.type===7){let i=e.value,a=t.value;if(!V$1(i,a))return P$1("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$1(i.data[l],a.data[l]);return C$1(i.rows,i.cols,u)}if(e.type===7){let i=e.value,a=t.toNumber(),u=i.data.map(l=>n$1(l,a));return C$1(i.rows,i.cols,u)}if(t.type===7){let i=t.value,a=e.toNumber(),u=i.data.map(l=>n$1(a,l));return C$1(i.rows,i.cols,u)}return n(n$1(e.toNumber(),t.toNumber()))}var An=254,xn=200,Ne=class{constructor(){this.handlers=new Map;this.nextOpcode=xn+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>An)throw c.config("OPCODE_POOL_EXHAUSTED",`OpRegistry: dynamic opcode pool exhausted (max ${An-xn} allocations).`);return this.nextOpcode++}},Ji=new Ne;var Mn=ga(1);function ge(e,t){return c$2.isCurrency(t)?e.exact??ha(e.toNumber()):null}function ot(e){if(!Number.isFinite(e))return null;if(Number.isInteger(e))return ga(BigInt(e));let t=String(e);return /^-?\d+\.\d+$/.test(t)?ia(t):null}function In(e,t,n){let o=ge(e,n),r=ot(t);if(o!==null&&r!==null){let i=la(o,r);return v(ra(i),n,i)}return u(e.toNumber()*t,n)}function En(e,t,n,o){let r=ge(e,t),i=ot(n);if(r!==null&&i!==null){let a=ja(Mn,o===1?i:ma(i)),u=la(r,a);return v(ra(u),t,u)}return u(e.toNumber()*(1+o*n),t)}function Sn(e){let t=ot(e);return t===null?null:ja(Mn,t)}function kn(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||na(r))return null;let i=pa(o,r);return v(ra(i),t,i)}function _n(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||na(r))return null;let i=ka(o,pa(o,r));return v(ra(i),t,i)}function Tn(e,t){let n=e.unit,o=n!==void 0&&c$2.isCurrency(n)?mr(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=vn(i,t-u);return u===0?{unit:n,shares:[s]}:{unit:n,shares:[s,vn(i+l,u)]}}function vn(e,t){let n=fa(e,2);return {value:ra(n),exact:n,count:t}}function mr(e,t){let n=ge(e,t);return n===null?null:oa(n,2).coef}var fr=12;function Vn(e,t){if(e.length===0||t.length===0)return [];let n=new Array(e.length+t.length-1).fill(a$1);return e.forEach((o,r)=>{t.forEach((i,a)=>{n[r+a]=f(n[r+a],h(o,i));});}),n}function dr(e,t){let n=[b$2];for(let o=0;o<t;o++)n=Vn(n,e);return n}function rt(e,t){return e.map(n=>i(n,t))}function pr(e,t){let n=[],o=0;for(;o<e.length&&l(e[o]);)o++;o>0&&n.push({base:[a$1,b$2],power:o});let r=e.slice(o);if(r.length>1){let i=Je([...r].reverse(),t);for(let a of i.factors){let u=C(a.base);if(u===null)return null;n.push({base:[...B$1(u,t)],power:a.power});}}return n.length>0?n:null}function br(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 yr(e,t,n){let o=dr(t[e.factor].base,e.power),{quotient:r,remainder:i}=H$1(n,o);if(!G(i))return null;let a=new Array(e.degree).fill(a$1);return a.push(b$2),Vn(r,a)}function hr(e,t){let n=t.length;for(let o=0;o<n;o++){let r=-1;for(let i=o;i<n;i++)if(!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$1=0;i$1<n;i$1++){if(i$1===o||l(e[i$1][o]))continue;let a=i(e[i$1][o],e[o][o]);for(let u=o;u<n;u++)e[i$1][u]=g(e[i$1][u],h(a,e[o][u]));t[i$1]=g(t[i$1],h(a,t[o]));}}return t.map((o,r)=>i(o,e[r][r]))}function it(e,t,n){if(t.length<2||t.length-1>fr)return null;let o=I(e,t),r=o.length>1?H$1(e,o).quotient:[...e],i=o.length>1?H$1(t,o).quotient:[...t];if(i.length===1)return {polynomial:rt(r,i[0]),terms:[]};if(i.length===0)return null;let a=i[i.length-1],u=rt(i,a),l=rt(r,a),{quotient:s,remainder:p}=H$1(l,u);if(G(p))return {polynomial:s,terms:[]};let h=pr(u,n);if(h===null)return null;let x=Nr(h,u,p);return x===null?null:{polynomial:s,terms:x}}function Nr(e,t,n){let o=br(e),r=t.length-1;if(o.length!==r)return null;let i=[];for(let s of o){let p=yr(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]??a$1));let u=[];for(let s=0;s<r;s++)u.push(n[s]??a$1);let l=hr(a,u);return l===null?null:gr(o,l,e)}function gr(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$1]=i.split(":").map(Number),s=[...a].map(p=>p??a$1);s.every(l)||r.push({numerator:s,base:n[u].base,power:l$1});}return r}function Re(e,t){let n=new Map;return e.forEach((o,r)=>{l(o)||n.set(r===0?"":r===1?t:`${t}^${r}`,o);}),n.size===0?p(a$1):E({terms:n,vars:e.length>1?[t]:[]})}function wn(e){let t=at(e);if(t===null)return e;let n=it(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$1 of n.terms){let i=Re(r$1.base,t.variable),a=r$1.power===1?i:r(i,p({n:BigInt(r$1.power),d:1n})),u=Rr(r$1.numerator),l=u?r$1.numerator.map(p=>j(p)):r$1.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:Q$2(o)}function Rr(e){return e.some(t=>t.n<0n)&&e.every(t=>t.n<=0n)}function at(e){if(e.kind!=="div")return null;let t=C(e.left),n=C(e.right);if(t===null||n===null)return null;let o=A(n);return o===null||t.vars.some(r=>r!==o)?null:{numerator:B$1(t,o),denominator:B$1(n,o),variable:o}}var ut=16;function On(){return p(a$1)}function X(){return p(b$2)}function Ar(e,t){switch(e){case "sin":return s("cos",[t]);case "cos":return {kind:"neg",operand:s("sin",[t])};case "tan":return {kind:"div",left:X(),right:r(s("cos",[t]),p(2))};case "exp":return s("exp",[t]);case "log":return {kind:"div",left:X(),right:t};case "sqrt":return {kind:"div",left:X(),right:{kind:"mul",left:p(2),right:s("sqrt",[t])}};case "asin":return {kind:"div",left:X(),right:s("sqrt",[Cn(t)])};case "acos":return {kind:"neg",operand:{kind:"div",left:X(),right:s("sqrt",[Cn(t)])}};case "atan":return {kind:"div",left:X(),right:xr(t)};case "sinh":return s("cosh",[t]);case "cosh":return s("sinh",[t]);case "tanh":return {kind:"div",left:X(),right:r(s("cosh",[t]),p(2))};case "abs":return s("sign",[t]);default:return null}}function Cn(e){return {kind:"sub",left:X(),right:r(e,p(2))}}function xr(e){return {kind:"add",left:X(),right:r(e,p(2))}}function Ae(e,t,n=1){if(n<0||!Number.isInteger(n))throw c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT","A derivative order must be a whole number, at least zero.");if(n>ut)throw c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT",`A derivative order above ${ut} is not supported.`,{limit:ut});let o=Q$2(e);for(let r=0;r<n;r++)o=Q$2(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:r(e.right,p(2))};case "pow":return vr(e,t);case "call":{if(e.args.length!==1)return lt(e,t);let n=Ar(e.name,e.args[0]);return n===null?lt(e,t):{kind:"mul",left:n,right:P(e.args[0],t)}}}}function vr(e,t){if(e.exponent.kind==="const"){let n=p(g(e.exponent.value,b$2));return {kind:"mul",left:{kind:"mul",left:e.exponent,right: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:s("log",[e.base])},right:P(e.exponent,t)}:lt(e,t)}function lt(e,t){return s("der",[e,q$1(t)])}function Dn(e,t){let n=C(e);if(n===null||n.vars.filter(u=>u!==t).length>0||z(n,t)>1)return null;let r=B$1(n,t),i=r[0]??{n:0n,d:1n},a=r[1]??{n:0n,d:1n};return l(a)?null:{slope:a,intercept:i}}function Mr(e,t){let n=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$1=B$1(n,t),i$1=p(0);return r$1.forEach((a,u)=>{if(l(a))return;let l$1=u+1,s=i(a,{n:BigInt(l$1),d:1n}),p$1={kind:"mul",left:p(s),right:l$1===1?q$1(t):r(q$1(t),p(l$1))};i$1={kind:"add",left:i$1,right:p$1};}),{ok:true,value:Q$2(i$1)}}function Ir(e,t){if(e.kind!=="call"||e.args.length!==1)return null;let n=Dn(e.args[0],t);if(n===null)return null;let o=e.args[0],r=i=>Q$2({kind:"div",left:i,right:p(n.slope)});switch(e.name){case "exp":return {ok:true,value:r(s("exp",[o]))};case "sin":return {ok:true,value:r({kind:"neg",operand:s("cos",[o])})};case "cos":return {ok:true,value:r(s("sin",[o]))};case "log":return {ok:true,value:r({kind:"sub",left:{kind:"mul",left:o,right:s("log",[o])},right:o})};default:return null}}function Er(e,t){if(e.kind!=="div"||e.left.kind!=="const"||!st(e.left.value))return null;let n=Dn(e.right,t);if(n!==null)return {ok:true,value:Q$2({kind:"div",left:s("log",[e.right]),right:p(n.slope)})};let o=C(e.right);if(o!==null&&o.vars.length===1&&o.vars[0]===t){let r=B$1(o,t);if(r.length===3&&st(r[0])&&l(r[1])&&st(r[2]))return {ok:true,value:s("atan",[q$1(t)])}}return null}function st(e){return e.n===1n&&e.d===1n}function Sr(e,t){let n=at(e);if(n===null||n.variable!==t)return null;let o=it(n.numerator,n.denominator,t);if(o===null)return null;let r=o.polynomial.length>0?Tr(o.polynomial,t):p(0);for(let i of o.terms){let a=kr(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:Q$2(r)}}function kr(e,t){let n=e.base.length-1,o=Re(e.base,t);if(n===1){let r$1=e.numerator[0]??a$1;if(e.power===1)return {kind:"mul",left:p(r$1),right:s("log",[o])};let i$1=e.power-1,a=i(r$1,{n:BigInt(-i$1),d:1n});return {kind:"div",left:p(a),right:r(o,p({n:BigInt(i$1),d:1n}))}}return n!==2||e.power!==1?null:_r(e,t,o)}function _r(e,t,n){let o=e.numerator[0]??a$1,r=e.numerator[1]??a$1,[i,a]=e.base,u={n:1n,d:2n},l$1=h(a,u),s$1={kind:"mul",left:p(h(r,u)),right:s("log",[n])},p$1=g(o,h(r,l$1));if(l(p$1))return s$1;let h$1=O(g(i,h(l$1,l$1))),x={kind:"add",left:q$1(t),right:p(l$1)},T={kind:"mul",left:{kind:"div",left:p(p$1),right:h$1},right:s("atan",[{kind:"div",left:x,right:h$1}])};return l(r)?T:{kind:"add",left:s$1,right:T}}function Tr(e,t){let n=p(0);return e.forEach((o,r$1)=>{if(l(o))return;let i$1=r$1+1,a=i(o,{n:BigInt(i$1),d:1n}),u={kind:"mul",left:p(a),right:i$1===1?q$1(t):r(q$1(t),p(i$1))};n={kind:"add",left:n,right:u};}),n}function xe(e,t){let n=Q$2(e);if(!u$1(n).has(t))return {ok:true,value:Q$2({kind:"mul",left:n,right:q$1(t)})};let o=Mr(n,t);if(o!==null)return o;let r=Ir(n,t);if(r!==null)return r;let i=Er(n,t);if(i!==null)return i;let a=Sr(n,t);if(a!==null)return a;if(n.kind==="add"||n.kind==="sub"){let u=xe(n.left,t);if(!u.ok)return u;let l=xe(n.right,t);return l.ok?{ok:true,value:Q$2({kind:n.kind,left:u.value,right:l.value})}:l}if(n.kind==="mul"&&n.left.kind==="const"){let u=xe(n.right,t);return u.ok?{ok:true,value:Q$2({kind:"mul",left:n.left,right:u.value})}:u}return {ok:false,reason:"no elementary antiderivative is known for this expression"}}var ct=16;function Pn(e,t,n,o){if(o<0||!Number.isInteger(o)||o>ct)throw c.execution("SYMBOLIC_TAYLOR_DEGREE_LIMIT",`A Taylor degree must be a whole number from 0 to ${ct}.`,{limit:ct});let r$1=p(n),i$1=1n,a=p(a$1);for(let u=0;u<=o;u++){u>0&&(i$1*=BigInt(u));let l$1=Ae(e,t,u),s=Q$2(v$1(l$1,t,r$1));if(s.kind!=="const")throw 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$1=i(s.value,{n:i$1,d:1n});if(l(p$1))continue;let h=l(n)?q$1(t):{kind:"sub",left:q$1(t),right:r$1},x=u===0?p(1):u===1?h:r(h,p(u));a={kind:"add",left:a,right:{kind:"mul",left:p(p$1),right:x}};}return Q$2(a)}function Ln(e,t){return e.map(n=>t.map(o=>Ae(n,o)))}function Vr(){let e=globalThis.Temporal;return e??void 0}function Fn(e){if(e!==void 0&&typeof e!="string")return e;if(e==="date")return b;let t=Vr();if(e==="temporal"){if(t===void 0)throw c.config("CALENDAR_TEMPORAL_UNAVAILABLE",'calendar: "temporal" was asked for, but this runtime has no Temporal. Node ships it from 26 (24 behind --harmony-temporal), and Chrome, Edge, Firefox and Opera ship it; Safari does not. Pass a polyfill-backed backend from "solve-engine/temporal", or use calendar: "auto" to compute on Date where Temporal is absent.');return b$1(t)}return t===void 0?b:b$1(t)}function wr(e={}){return {pluginFunctions:{},opRegistry:new Ne,pluginFunctionOwners:{},networkEnabled:e.networkEnabled??true,calendar:Fn(e.calendar)}}var Un=wr();var Or={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},Bn=1970,qn=2026;function $n(e){return Or[Math.trunc(e)]}function mt(e,t){let n=$n(e),o=$n(t);if(!(n===void 0||o===void 0||n===0))return o/n}function Fa(e,t,n){let o=mt(t,n);if(o!==void 0)return e*o}function Cr(e){let t=Math.abs(e);return t<60?u(e,"s"):t<3600?u(e/60,"min"):t<86400?u(e/3600,"h"):u(e/86400,"d")}var Dr=0;function ft(e){if(e.type===6&&e.unit!==void 0){let t=a[e.unit.toLowerCase()];if(t!==void 0&&t[0]===Dr)return e.toNumber()*t[1]}return e.toNumber()}function Pr(e,t){if(t===1)return e;let n=`${e}s`;return a[n.toLowerCase()]===void 0?e:n}function Yn(e,t){let n$1,o=false;for(let r of e){if(Number.isNaN(r.toNumber())){o=true;continue}if(n$1===void 0){n$1=r;continue}let{lv:i,rv:a,sameMeasure:u}=he(n$1,r);if(!u){let l=n$1.type===6?n$1.unit:void 0,s=r.type===6?r.unit:void 0,p=Fe(l,s,"compared");return P$1("INCOMPATIBLE_UNITS",p??`Cannot compare incompatible units: ${l??"?"} and ${s??"?"}`)}(t?a>i:a<i)&&(n$1=r);}return o?n(NaN):n$1===void 0?n(t?-1/0:1/0):n$1.type===6?n$1:n(n$1.toNumber())}function Ue(e,t){return e.type===6&&e.unit!==void 0?u(t,e.unit):n(t)}function Gn(e,t){let n=Number.isFinite(t)?Math.min(100,Math.max(0,Math.trunc(t))):0;if(e.exact!==void 0){let a=oa(e.exact,n);return $e(e,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$1,o){let r=e.type===6&&e.unit!==void 0?u(t,e.unit):n(t);return r.decimalPlaces=n$1,o!==void 0&&(r.exact=o),r}function jn(e,t,n){if(Number.isFinite(e)&&Number.isFinite(t))return null;let o=Number.isFinite(e)?t:e;return P$1("INVALID_INTEGER_OPERAND",`${n} needs two whole numbers, and ${Number.isNaN(o)?"one of them has no value":"one of them is infinite"}`)}function Kn(e,t){let n=e,o=t;for(;o!==0;){let r=o;o=n%o,n=r;}return n}function Lr(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:Lr(e)/o}var uu={0:e=>{let t=e[0].toNumber();return t>=0?n(Math.sqrt(t)):w(s("sqrt",[p(t)]))},1:e=>e[0].type===7?ca(e[0].value):Ue(e[0],Math.abs(e[0].toNumber())),2:e=>n(Math.sin(ft(e[0]))),3:e=>n(Math.cos(ft(e[0]))),4:e=>n(Math.tan(ft(e[0]))),5:e=>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?Gn(e[0],e[1].toNumber()):Ue(e[0],Math.round(e[0].toNumber())),9:e=>Yn(e,false),10:e=>Yn(e,true),11:e=>n(Math.asin(e[0].toNumber())),12:e=>n(Math.acos(e[0].toNumber())),13:e=>n(Math.atan(e[0].toNumber())),14:e=>n(Math.atan2(e[0].toNumber(),e[1].toNumber())),15:e=>n(Math.sinh(e[0].toNumber())),16:e=>n(Math.cosh(e[0].toNumber())),17:e=>n(Math.tanh(e[0].toNumber())),18:e=>n(Math.asinh(e[0].toNumber())),19:e=>n(Math.acosh(e[0].toNumber())),20:e=>n(Math.atanh(e[0].toNumber())),21:e=>n(Math.cbrt(e[0].toNumber())),22:e=>n(Math.clz32(e[0].toNumber())),23:e=>n(Math.expm1(e[0].toNumber())),24:e=>n(Math.exp(e[0].toNumber())),25:e=>n(Math.fround(e[0].toNumber())),26:e=>n(Math.hypot(...e.map(t=>t.toNumber()))),27:e=>n(Math.imul(e[0].toNumber(),e[1].toNumber())),28:e=>n(Math.log10(e[0].toNumber())),29:e=>n(Math.log1p(e[0].toNumber())),30:e=>n(Math.log2(e[0].toNumber())),31:e=>e[0].type===7?e[1].type!==0?P$1("MATRIX_POWER_UNSUPPORTED",`pow: a matrix's exponent must be a whole number, as in "pow([1,2;3,4], 2)".`):$(e[0].value,e[1].value):e[1].type===7?P$1("MATRIX_POWER_UNSUPPORTED",'pow: a matrix may only be the base, as in "pow([1,2;3,4], 2)".'):n(nt(e[0].toNumber(),e[1].toNumber())),32:()=>n(Math.random()),33:e=>n(Math.sign(e[0].toNumber())),34:e=>n(Math.trunc(e[0].toNumber())),35:e=>n(e[0].toNumber()*Math.PI/180),36:e=>n(e[0].toNumber()*180/Math.PI),37:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return t>n$1?P$1("INVALID_RANGE",`roll: invalid range, ${t} is greater than ${n$1}`):n(Math.floor(Math.random()*(n$1-t+1))+t)},38:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n$1=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n$1,"gcd");return o||n(Kn(t,n$1))},39:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n$1=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n$1,"lcm");return o||(t===0||n$1===0?n(0):n(t/Kn(t,n$1)*n$1))},40:e=>{let t=Math.trunc(e[0].toNumber()),n$1=Math.trunc(e[1].toNumber());if(t<0||n$1<0||n$1>t)return P$1("INVALID_RANGE",`permutation: invalid n=${t}, r=${n$1} (require 0 <= r <= n)`);let o=1;for(let r=0;r<n$1;r++)if(o*=t-r,!Number.isFinite(o))return P$1("PERMUTATION_OVERFLOW",`permutation: P(${t}, ${n$1}) exceeds the maximum representable double (it passed it after ${r+1} of ${n$1} factors)`);return n(o)},41:e=>{let t=Math.trunc(e[0].toNumber()),n$1=Math.trunc(e[1].toNumber());if(t<0||n$1<0||n$1>t)return P$1("INVALID_RANGE",`combination: invalid n=${t}, r=${n$1} (require 0 <= r <= n)`);let o=Math.min(n$1,t-n$1),r=1;for(let i=0;i<o;i++)if(r=r*(t-i)/(i+1),!Number.isFinite(r))return P$1("COMBINATION_OVERFLOW",`combination: C(${t}, ${n$1}) exceeds the maximum representable double (it passed it after ${i+1} of ${o} steps)`);return n(Math.round(r))},42:e=>{if(e.length===0)return n(0);let t=e.reduce((n,o)=>n+o.toNumber(),0);return n(t/e.length)},43:e=>{if(e.length===0)return n(0);let t=e.map(o=>o.toNumber()).sort((o,r)=>o-r),n$1=Math.floor(t.length/2);return n(t.length%2===0?(t[n$1-1]+t[n$1])/2:t[n$1])},44:e=>n(e.reduce((t,n)=>t+n.toNumber(),0)),45:e=>n(e.length),46:e=>{let[t,n$1,o]=e,{lv:r,rv:i}=he(t,n$1);if(r===0)return P$1("PROPORTION_DIVIDE_BY_ZERO",`Cannot compute proportion: "${t.value}" is zero`);let a=o.toNumber()*(i/r);return o.type===6?u(a,o.unit):n(a)},47:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return n$1>o?P$1("INVALID_RANGE",`clamp: invalid range, ${n$1} is greater than ${o}`):n(Math.min(Math.max(t,n$1),o))},48:e=>r$1(e[0].toNumber()),49:e=>r$1(e[0].toNumber(),"bin"),50:e=>n(Math.trunc(e[0].toNumber())),51:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`compoundInterest: rate ${n$1} makes (1 + rate) non-positive`);let r=t*Math.pow(1+n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},52:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`interestEarned: rate ${n$1} makes (1 + rate) non-positive`);let r=t*(Math.pow(1+n$1,o)-1);return e[0].type===6?u(r,e[0].unit):n(r)},53:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return t<=0||n$1<=0?P$1("INVALID_RANGE","compoundInterestRate: principal and futureValue must both be positive"):o<=0?P$1("INVALID_RANGE","compoundInterestRate: years must be greater than 0"):n(Math.pow(n$1/t,1/o)-1)},54:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return t<=0||n$1<=0?P$1("INVALID_RANGE","compoundInterestYears: principal and futureValue must both be positive"):1+o<=0||o===0?P$1("INVALID_RATE",`compoundInterestYears: rate ${o} is not usable (must be > -1 and not 0)`):n(Math.log(n$1/t)/Math.log(1+o))},55:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return P$1("INVALID_RANGE","loanRepayment: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","loanRepayment: years must be positive");if(n$1<0)return P$1("INVALID_RATE","loanRepayment: rate must not be negative");if(r<0)return P$1("INVALID_RANGE","loanRepayment: periodsPerYear must not be negative");let{totalRepayment:i}=bt(t,n$1,o),a=r===0?i:i/(o*r);return e[0].type===6?u(a,e[0].unit):n(a)},56:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return P$1("INVALID_RANGE","loanInterest: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","loanInterest: years must be positive");if(n$1<0)return P$1("INVALID_RATE","loanInterest: rate must not be negative");if(r<0)return P$1("INVALID_RANGE","loanInterest: periodsPerYear must not be negative");let{totalInterest:i}=bt(t,n$1,o),a=r===0?i:i/(o*r);return e[0].type===6?u(a,e[0].unit):n(a)},57:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(t<=0)return P$1("INVALID_RANGE","monthlyPayment: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","monthlyPayment: years must be positive");if(n$1<0)return P$1("INVALID_RATE","monthlyPayment: rate must not be negative");let{monthlyPayment:r}=bt(t,n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},58:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return e[0].type===6?En(e[0],e[0].unit,n$1,1):n(t*(1+n$1))},59:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return 1+n$1<=0?P$1("INVALID_RATE",`taxRemove: rate ${n$1} makes (1 + rate) non-positive`):e[0].type===6?kn(e[0],e[0].unit,n$1)??u(t/(1+n$1),e[0].unit):n(t/(1+n$1))},60:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=mt(n$1,o);if(r===void 0)return P$1("INFLATION_YEAR_OUT_OF_RANGE",`inflationAdjust: fromYear ${n$1} or toYear ${o} is outside the bundled CPI table's range (${Bn}-${qn})`);let i=t*r;return e[0].type===6?u(i,e[0].unit):n(i)},61:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return n(nt(n$1,1/t))},62:e=>{let t=e[0].toNumber();if(!Number.isInteger(t)||t<0)return P$1("INVALID_FACTORIAL_INPUT",`fact: ${t} is not a non-negative integer`);if(t>170)return P$1("FACTORIAL_OVERFLOW",`fact: ${t}! exceeds the maximum representable double (170! is the largest finite factorial)`);let n$1=1;for(let o=2;o<=t;o++)n$1*=o;return n(n$1)},63:e=>e[0].type===7?ba(e[0].value):e[0],64:e=>e[0].type===7?ca(e[0].value):n(e[0].toNumber()),65:e=>e[0].type===7?da(e[0].value):n(1/e[0].toNumber()),66:e=>{let[t,n$1]=e;if(t.type===0&&n$1.type===0)return n(t.toNumber()*n$1.toNumber());let o=r=>r.type===7?r.value:{rows:1,cols:1,data:[r.toNumber()],hasSymbolic:false};return _$1(o(t),o(n$1))},67:e=>{let[t]=e;return t.type!==9?t:w(F(t.value))},68:e=>{let[t]=e;return t.type!==9?t:w(nn(t.value))},69:e=>{let[t,n,o]=e;return o?.type!==3?P$1("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown."):yn(t,n,o.value)},70:e=>{let[t,n,o]=e,r=pt(n,"der");if(typeof r!="string")return r;let i=V(t);return i===null?P$1("SYMBOLIC_NONFINITE_OPERAND","der needs an expression with an exact value."):w(Ae(i,r,o?.toNumber()??1))},71:e=>{let[t,n]=e,o=pt(n,"integral");if(typeof o!="string")return o;let r=V(t);if(r===null)return P$1("SYMBOLIC_NONFINITE_OPERAND","integral needs an expression with an exact value.");let i=xe(r,o);return i.ok?w(i.value):P$1("SYMBOLIC_INTEGRAL_UNSUPPORTED",`Cannot integrate this: ${i.reason}.`)},72:e=>{let[t,n,o,r]=e,i=pt(n,"taylor");if(typeof i!="string")return i;let a=V(t),u=V(o);return a===null||u===null||u.kind!=="const"?P$1("SYMBOLIC_NONFINITE_OPERAND","taylor needs an expression and an exact expansion point."):w(Pn(a,i,u.value,r.toNumber()))},73:e=>{let t=[];for(let a of e){let u=V(a);if(u===null)return P$1("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 u$1(a))n.add(u);let o=[...n].sort();if(o.length===0)return P$1("SYMBOLIC_JACOBIAN_NO_VARIABLES","jacobian needs at least one unknown to differentiate against.");let r=Ln(t,o),i=[];for(let a of r)for(let u of a)i.push(W(u));return C$1(r.length,o.length,Y(r.length,o.length,i))},74:e=>w(w$1(o(a$1,d(e[0].toNumber())))),75:e=>dt("conj",e[0]),76:e=>dt("re",e[0]),77:e=>dt("im",e[0]),78:e=>{let t=e[0];return t.type!==9?t:w(J(t.value))},79:e=>{let t=e[0];return t.type!==9?t:w(wn(t.value))},85:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`taxIn: rate ${n$1} makes (1 + rate) non-positive`);let o=t-t/(1+n$1);return e[0].type===6?_n(e[0],e[0].unit,n$1)??u(o,e[0].unit):n(o)},86:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return e[0].type===6?In(e[0],n$1,e[0].unit):n(t*n$1)},87:e=>n(Math.sin(e[0].toNumber()*Math.PI/180)),88:e=>n(Math.cos(e[0].toNumber()*Math.PI/180)),89:e=>n(Math.tan(e[0].toNumber()*Math.PI/180)),90:e=>n(Math.asin(e[0].toNumber())*180/Math.PI),91:e=>n(Math.acos(e[0].toNumber())*180/Math.PI),92:e=>n(Math.atan(e[0].toNumber())*180/Math.PI),93:e=>u(e[0].toNumber(),"days"),94:e=>{let t$1=typeof e[1]?.value=="string"?e[1].value:void 0,n=typeof e[2]?.value=="string"?e[2].value:void 0;if(t$1===void 0||n===void 0)return P$1("UNKNOWN_UNIT",'both units have to be named, as in "12.5 minutes in minutes and seconds"');let o=a[t$1.toLowerCase()],r=a[n.toLowerCase()];if(o===void 0||r===void 0)return P$1("UNKNOWN_UNIT",`${t$1} and ${n}: one of these is not a unit`);if(o[0]!==r[0])return P$1("INCOMPATIBLE_UNITS",`${t$1} and ${n} measure different things`);if(r[1]>=o[1])return P$1("INCOMPATIBLE_UNITS",`${t$1} and ${n}: name the larger unit first`);let i=e[0],a$1=i.type===6&&i.unit!==void 0?a[i.unit.toLowerCase()]:void 0,u=i.toNumber()*(a$1?.[1]??o[1]),l=Math.floor(u/o[1]),s=Math.round((u-l*o[1])/r[1]*1e3)/1e3;return t(`${l} ${t$1} ${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("/")?P$1("INVALID_RATE_UNIT",`${o}/${n}: that is already a rate`):u(t.toNumber(),`${o}/${n}`)},96:e=>{let t=e[0],n$1=e[1];if(n$1.type===6&&t.type===6&&i$1(n$1.unit)){let s=j$1(t.toNumber(),t.unit,n$1.toNumber(),n$1.unit);if(s!==null)return Cr(s)}if(n$1.type!==6||n$1.unit===void 0||!n$1.unit.includes("/"))return P$1("INVALID_RATE",'at: the right-hand side has to be a rate, as in "$30/hour"');let o=n$1.unit.indexOf("/"),r=n$1.unit.slice(0,o),i=n$1.unit.slice(o+1),a$1=t.type===6?t.unit:void 0,u$1=a[i.toLowerCase()],l=a$1===void 0?void 0:a[a$1.toLowerCase()];if(l!==void 0&&u$1!==void 0&&l[0]===u$1[0]){let p=t.toNumber()*l[1]/u$1[1]*n$1.toNumber();return r===""?n(p):u(p,r)}if(a$1!==void 0&&a$1===r){let s=t.toNumber()/n$1.toNumber();return u(s,Pr(i,s))}if(a$1===void 0){let s=t.toNumber()*n$1.toNumber();return r===""?n(s):u(s,r)}return P$1("INCOMPATIBLE_UNITS",`at: ${a$1} matches neither side of ${n$1.unit}`)},80:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0)return P$1("INVALID_RATE",`compounding: ${r} periods per year is not a period`);if(1+n$1/r<=0)return P$1("INVALID_RATE",`compounding: rate ${n$1} makes each period non-positive`);let i=t*Math.pow(1+n$1/r,r*o);return e[0].type===6?u(i,e[0].unit):n(i)},81:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0||1+n$1/r<=0)return P$1("INVALID_RATE",`compounding: rate ${n$1} over ${r} periods per year is not usable`);let i=t*(Math.pow(1+n$1/r,r*o)-1);return e[0].type===6?u(i,e[0].unit):n(i)},82:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`presentValue: rate ${n$1} makes (1 + rate) non-positive`);let r=t/Math.pow(1+n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},83:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return t===0?P$1("INVALID_RATE","roi: nothing was invested, so there is no return on it"):n((n$1-t)/t)},84:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0?P$1("INVALID_RATE","annual return: the amount invested must be positive"):o<=0?P$1("INVALID_RATE","annual return: the period must be longer than zero"):n<=0?P$1("INVALID_RATE","annual return: nothing was returned, so there is no annual rate"):N(Math.pow(n/t,1/o)-1)},97:e=>Gn(e[0],e[1].toNumber()),98:e=>{let t=e[1].toNumber();return !Number.isInteger(t)||t<1?P$1("INVALID_RANGE",`split: the number of shares must be a whole number of at least 1, not ${e[1].toNumber()}.`):H(Tn(e[0],t))},99:e=>{let t=e[0].toNumber(),n$1=Fr(e[1]),o=e[2].toNumber();if(n$1===null)return P$1("INVALID_RANGE",'savings goal: the duration must be in months or years, e.g. "in 2 years".');if(t<=0)return P$1("INVALID_RANGE","savings goal: the target must be positive.");if(n$1<=0)return P$1("INVALID_RANGE","savings goal: the duration must be positive.");if(o<0)return P$1("INVALID_RATE","savings goal: the rate must not be negative.");let r=Ur(t,o/12,n$1);return e[0].type===6?u(r,e[0].unit):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 P$1("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return P$1("INVALID_RANGE","savings goal: the contribution must be positive.");if(r<0)return P$1("INVALID_RATE","savings goal: the rate must not be negative.");let a=$r(t,n,r/o);return u(a,i)},101:e=>n(Math.sqrt(Be(e.map(t=>t.toNumber()),false))),102:e=>n(Math.sqrt(Be(e.map(t=>t.toNumber()),true))),103:e=>n(Be(e.map(t=>t.toNumber()),false)),104:e=>n(Be(e.map(t=>t.toNumber()),true)),105:e=>{if(e.length===0)return n(0);let t=e.map(n=>n.toNumber());return n(Math.max(...t)-Math.min(...t))},106:e=>{if(e.length===0)return n(0);let t=new Map,n$1=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$1=i);}return n(n$1)},107:e=>{let t=0,n$1=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$1+=i;}return n$1===0?P$1("WEIGHTED_AVERAGE_ZERO_WEIGHT","weighted average: the weights sum to zero, so there is nothing to divide by"):n(t/n$1)}};function Fr(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 Ur(e,t,n){return t===0?e/n:e*t/(Math.pow(1+t,n)-1)}function $r(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 dt(e,t){let n=V(t);return n===null?P$1("SYMBOLIC_NONFINITE_OPERAND",e+" needs a value with an exact number."):w(s(e,[n]))}function pt(e,t){return e?.type!==3?P$1("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown.`):e.value}function bt(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 lu=Un.pluginFunctions,Xn=65535,Zn=0;function Br(){if(Zn>Xn)throw c.config("PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED",`allocatePluginFunctionIndex: pool exhausted (max ${Xn+1} allocations).`);return Zn++}var Hn=new Map;function su(e){let t=Hn.get(e);return t===void 0&&(t=Br(),Hn.set(e,t)),t}var yt=new Map;function cu(e,t){let n=e.toLowerCase(),o=yt.get(n);o&&o!==t&&console.warn(`[asConverterRegistry] Converter name "${n}" is already registered \u2014 overwriting.`),yt.set(n,t);}function mu(e){yt.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&&qr(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 ht=qe;function qr(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 du=new ht;function pu(e){return `global:${e}`}var Yr={sydney:"Australia/Sydney",melbourne:"Australia/Melbourne",brisbane:"Australia/Brisbane",perth:"Australia/Perth",adelaide:"Australia/Adelaide",canberra:"Australia/Sydney",auckland:"Pacific/Auckland",wellington:"Pacific/Auckland",fiji:"Pacific/Fiji",chicago:"America/Chicago",seattle:"America/Los_Angeles",denver:"America/Denver",phoenix:"America/Phoenix",toronto:"America/Toronto",montreal:"America/Toronto",vancouver:"America/Vancouver",ottawa:"America/Toronto",honolulu:"Pacific/Honolulu",anchorage:"America/Anchorage",miami:"America/New_York",boston:"America/New_York",atlanta:"America/New_York",dallas:"America/Chicago",houston:"America/Chicago",lima:"America/Lima",bogota:"America/Bogota",caracas:"America/Caracas",santiago:"America/Santiago",montevideo:"America/Montevideo",quito:"America/Guayaquil",london:"Europe/London",paris:"Europe/Paris",berlin:"Europe/Berlin",madrid:"Europe/Madrid",rome:"Europe/Rome",amsterdam:"Europe/Amsterdam",dublin:"Europe/Dublin",lisbon:"Europe/Lisbon",vienna:"Europe/Vienna",zurich:"Europe/Zurich",geneva:"Europe/Zurich",moscow:"Europe/Moscow",istanbul:"Europe/Istanbul",athens:"Europe/Athens",stockholm:"Europe/Stockholm",oslo:"Europe/Oslo",helsinki:"Europe/Helsinki",warsaw:"Europe/Warsaw",prague:"Europe/Prague",budapest:"Europe/Budapest",brussels:"Europe/Brussels",copenhagen:"Europe/Copenhagen",reykjavik:"Atlantic/Reykjavik",kiev:"Europe/Kyiv",kyiv:"Europe/Kyiv",tokyo:"Asia/Tokyo",osaka:"Asia/Tokyo",beijing:"Asia/Shanghai",shanghai:"Asia/Shanghai",seoul:"Asia/Seoul",singapore:"Asia/Singapore",bangkok:"Asia/Bangkok",jakarta:"Asia/Jakarta",manila:"Asia/Manila",mumbai:"Asia/Kolkata",delhi:"Asia/Kolkata",bangalore:"Asia/Kolkata",dubai:"Asia/Dubai",abudhabi:"Asia/Dubai",karachi:"Asia/Karachi",dhaka:"Asia/Dhaka",hanoi:"Asia/Ho_Chi_Minh",taipei:"Asia/Taipei",islamabad:"Asia/Karachi",riyadh:"Asia/Riyadh",telaviv:"Asia/Jerusalem",jerusalem:"Asia/Jerusalem",cairo:"Africa/Cairo",lagos:"Africa/Lagos",nairobi:"Africa/Nairobi",johannesburg:"Africa/Johannesburg",casablanca:"Africa/Casablanca",accra:"Africa/Accra",tunis:"Africa/Tunis",addisababa:"Africa/Addis_Ababa",france:"Europe/Paris",germany:"Europe/Berlin",spain:"Europe/Madrid",italy:"Europe/Rome",japan:"Asia/Tokyo",china:"Asia/Shanghai",india:"Asia/Kolkata",brazil:"America/Sao_Paulo",russia:"Europe/Moscow",australia:"Australia/Sydney",canada:"America/Toronto",mexico:"America/Mexico_City",uk:"Europe/London",usa:"America/New_York",ireland:"Europe/Dublin",netherlands:"Europe/Amsterdam",sweden:"Europe/Stockholm",norway:"Europe/Oslo",poland:"Europe/Warsaw",turkey:"Europe/Istanbul",egypt:"Africa/Cairo",nigeria:"Africa/Lagos"},Gr={"new york":"America/New_York","los angeles":"America/Los_Angeles","san francisco":"America/Los_Angeles","las vegas":"America/Los_Angeles","mexico city":"America/Mexico_City","hong kong":"Asia/Hong_Kong","kuala lumpur":"Asia/Kuala_Lumpur","sao paulo":"America/Sao_Paulo","buenos aires":"America/Argentina/Buenos_Aires","rio de janeiro":"America/Sao_Paulo","cape town":"Africa/Johannesburg","new delhi":"Asia/Kolkata","united kingdom":"Europe/London","united states":"America/New_York","south africa":"Africa/Johannesburg"},jr={pst:"America/Los_Angeles",pdt:"America/Los_Angeles",est:"America/New_York",edt:"America/New_York",cst:"America/Chicago",cdt:"America/Chicago",mst:"America/Denver",mdt:"America/Denver",hst:"Pacific/Honolulu",bst:"Europe/London",cet:"Europe/Paris",cest:"Europe/Paris",jst:"Asia/Tokyo",ist:"Asia/Kolkata",aest:"Australia/Sydney",aedt:"Australia/Sydney"},Kr={...Yr,...Gr,...jr};function yu(e){let t=e.trim().toLowerCase();return t==="utc"||t==="gmt"?"UTC":Kr[t]??null}export{qn as A,Fa as B,uu as C,lu as D,Br as E,su as F,yt as G,cu as H,mu as I,du as J,pu as K,Gr as L,Kr as M,yu as N,ge as a,In as b,En as c,dn as d,ki as e,_i as f,Ti as g,Vi as h,yn as i,he as j,qi as k,Yi as l,Gi as m,Nn as n,ji as o,Ki as p,nt as q,Xi as r,Zi as s,Hi as t,Wi as u,Ne as v,Ji as w,wr as x,Un as y,Bn as z};//# sourceMappingURL=chunk-OE2DBN4K.js.map
2
- //# sourceMappingURL=chunk-OE2DBN4K.js.map
1
+ import {b as b$1}from'./chunk-X2GQAKL2.js';import {c as c$2}from'./chunk-PICFFFJV.js';import {ga,C,z,B as B$1,E,p,i,j,r,s,qa,l,h,g,f,e as e$1,k,Q as Q$2,V as V$1,ha,la,ra,ja,ma,J,w as w$1,o,a as a$1,d,u as u$1,W,Y,F,_ as _$1,da,ca,ba,$,L,O,c as c$3,na,pa,ka,ia,oa,v as v$1,q as q$1,m,b as b$2,A,n as n$1,K as K$2,fa,I,H as H$1,G,N as N$1,t as t$1,D,P as P$2,y,x,M}from'./chunk-4MD5L23F.js';import {b}from'./chunk-EOO6M65F.js';import {Q as Q$1,P as P$1,p as p$1,q,K as K$1,n,s as s$1,u,C as C$1,v,H,N,t,r as r$1}from'./chunk-O7HF345B.js';import {c as c$1,e,i as i$1,j as j$1}from'./chunk-BWTVJD5L.js';import {a}from'./chunk-PRSXXDTA.js';import {c}from'./chunk-6G2NES2I.js';function Xt(e,t){let n=t===2?L:M,o=n(e.n),r=n(e.d);return o===null||r===null?null:{n:o,d:r}}function Zt(e,t){let n=y(e),o=new Map;for(let[r,i]of n){if(i%t!==0)return null;o.set(r,i/t);}return x(o)}function Wn(e,t){let n=y(e);for(let[o,r]of y(t))n.set(o,(n.get(o)??0)+r);return x(n)}function Ht(e,t){let n=y(e);for(let[o,r]of y(t)){let i=(n.get(o)??0)-r;i<=0?n.delete(o):n.set(o,i);}return x(n)}function Qn(e,t){let n=y(e),o=new Map;for(let[r,i]of y(t)){let a=n.get(r);a!==void 0&&o.set(r,Math.min(a,i));}return x(o)}function zn(e){let t=new Set;for(let n of e)for(let o of 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 E({terms:t,vars:zn(e.map(n=>n.key))})}function We(e){let t=e[0];for(let n=1;n<e.length;n++)t={kind:"mul",left:t,right:e[n]};return t}function Jn(e){return [...e.terms].map(([n,o])=>({key:n,coefficient:o})).sort((n,o)=>D(n.key,o.key,e.vars))}function zt(e){if(e.vars.length<2)return null;let t=Jn(e);return t.length===2?eo(t[0],t[1]):t.length===3?to(t):t.length===4?no(t):null}function eo(e,t){let n=e.coefficient.n>0n,o=t.coefficient.n>0n;if(!n)return null;let r=Qe(e,t,2);if(r!==null&&!o)return We([Q([r.a,Te(r.b)]),Q([r.a,r.b])]);let i=Qe(e,t,3);if(i===null)return null;let a=Q(o?[i.a,i.b]:[i.a,Te(i.b)]),u=o?Te(Ve(i.a,i.b)):Ve(i.a,i.b);return We([a,Q([Wt(i.a),u,Wt(i.b)])])}function Qe(e,t,n){let o=t.coefficient.n<0n?j(t.coefficient):t.coefficient,r=Xt(e.coefficient,n),i=Xt(o,n);if(r===null||i===null)return null;let a=Zt(e.key,n),u=Zt(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:j(e.coefficient)}}function Ve(e,t){return {key:Wn(e.key,t.key),coefficient:h(e.coefficient,t.coefficient)}}function Wt(e){return Ve(e,e)}function to(e){let[t,n,o]=e;if(t.coefficient.n<0n||o.coefficient.n<0n)return null;let r=Qe(t,o,2);if(r===null)return null;let i$1=Ve(r.a,r.b);if(i$1.key!==n.key)return null;let a=h(i$1.coefficient,{n:2n,d:1n}),u=n.coefficient.n<0n,l=u?j(n.coefficient):n.coefficient;return m(i(l,a))?{kind:"pow",base:Q([r.a,u?Te(r.b):r.b]),exponent:p(2)}:null}function no(e){let t=[[[0,1],[2,3]],[[0,2],[1,3]],[[0,3],[1,2]]];for(let n of t){let o=Qt(e[n[0][0]],e[n[0][1]]),r=Qt(e[n[1][0]],e[n[1][1]]);if(!(o===null||r===null)&&oo(o.cofactor,r.cofactor))return We([Q([o.common,r.common]),Q(o.cofactor)])}return null}function Qt(e,t){let n=Qn(e.key,t.key),o={key:n,coefficient:e.coefficient},r=[{key:Ht(e.key,n),coefficient:{n:1n,d:1n}},{key:Ht(t.key,n),coefficient:i(t.coefficient,e.coefficient)}];return r[0].key===r[1].key?null:{common:o,cofactor:r}}function oo(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 ro=12,we=4096;function Oe(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 en(e,t){return e===0n||t===0n?0n:e/Oe(e,t)*t}function Jt(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>we)return null}return n}function tn(e,t){let n=a$1;for(let o of e)n=f(h(n,t),o);return n}function io(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(f(e[o],h(n[o-1],t)));return n}function ue(e){if(e.length<2)return [];let t=1n;for(let s of e)t=en(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=Jt(r),a=Jt(o);if(i===null||a===null)throw c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial's coefficients have too many divisors to search for rational roots.",{limit:we});if(i.length*a.length>we)throw c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial has too many candidate rational roots to test.",{limit:we});let u=[],l$1=new Set;for(let s of i)for(let p of a)for(let h of [1n,-1n]){let x={n:h*s/Oe(s,p),d:p/Oe(s,p)},T=`${x.n}/${x.d}`;l$1.has(T)||(l$1.add(T),l(tn(e,x))&&u.push(x));}return u}function ao(e,t){return l(t)?q$1(e):t.n>0n?{kind:"sub",left:q$1(e),right:p(t)}:{kind:"add",left:q$1(e),right:p(j(t))}}function uo(e,t){let n=e.length-1,o=new Map;return e.forEach((r,i)=>{if(l(r))return;let a=n-i;o.set(a===0?"":a===1?t:`${t}^${a}`,r);}),E({terms:o,vars:o.size>0?[t]:[]})}function Je(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&&l(tn(o,a));)o=io(o,a),u++;u>0&&n.push({base:ao(t,a),power:u});}r=o.length>2?ue(o):[];}return o.length-1>=1?(n.push({base:uo(o,t),power:1}),{content:b$2,factors:n}):{content:o.length===1?o[0]:b$2,factors:n}}function lo(e){let t=[];m(e.content)||t.push(p(e.content));for(let o of e.factors)t.push(o.power===1?o.base:r(o.base,p({n:BigInt(o.power),d:1n})));if(t.length===0)return p(b$2);let n=t[0];for(let o=1;o<t.length;o++)n={kind:"mul",left:n,right:t[o]};return n}function so(e){let t=0n,n=1n;for(let o of e.terms.values())t=Oe(t,o.n),n=en(n,o.d);return t===0n?b$2:{n:t,d:n}}function co(e){let t=new Map;for(let r of e.vars){let i=1/0;for(let a of e.terms.keys()){let u=mo(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=ze(r);for(let[u,l]of t)a.set(u,(a.get(u)??0)-l);n.set(fo(a),i);}let o=new Set;for(let r of n.keys())for(let i of ze(r).keys())o.add(i);return {monomial:t,reduced:{terms:n,vars:[...o].sort()}}}function mo(e,t){return ze(e).get(t)??0}function ze(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 fo(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 po(e){let t=[...e.keys()].sort(),n=null;for(let o of t){let r$1=e.get(o),i=r$1===1?q$1(o):r(q$1(o),p({n:BigInt(r$1),d:1n}));n=n===null?i:{kind:"mul",left:n,right:i};}return n}function nn(e){let t=C(e);if(t===null||t.terms.size===0||z(t)>ro||t.vars.length===0)return e;let n=so(t),o=m(n)?t:bo(t,i(b$2,n)),{monomial:r,reduced:i$1}=co(o),a=po(r),u=A(i$1);if(u===null){let te=zt(i$1);return te!==null?yo(n,a,te):ho(n,a,i$1)??e}let l=[...B$1(i$1,u)].reverse(),s=Je(l,u),p$1=h(n,s.content);if(s.factors.length<=1&&(s.factors[0]?.power??1)===1&&a===null&&m(p$1))return e;let x=[];m(p$1)||x.push(p(p$1)),a!==null&&x.push(a),x.push(lo({content:b$2,factors:s.factors}));let T=x[0];for(let te=1;te<x.length;te++)T={kind:"mul",left:T,right:x[te]};return T}function bo(e,t){let n=new Map;for(let[o,r]of e.terms)n.set(o,h(r,t));return {terms:n,vars:e.vars}}function yo(e,t,n){let o=[];m(e)||o.push(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 ho(e,t,n){if(t===null&&m(e))return null;let o=[];m(e)||o.push(p(e)),t!==null&&o.push(t),o.push(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 _={n:2n,d:1n},B={n:3n,d:1n},be={n:4n,d:1n};function No(e,t,n,o){let r=j(i(t,h(B,e))),i$1=i(g(h(B,h(e,n)),h(t,t)),h(B,h(e,e))),a=h(_,h(t,h(t,t))),u=h({n:9n,d:1n},h(e,h(t,n))),l=h({n:27n,d:1n},h(h(e,e),o)),s=i(f(g(a,u),l),h({n:27n,d:1n},h(e,h(e,e))));return {p:i$1,q:s,shift:r}}function rn(e,t,n,o){let{p:r,q:i,shift:a}=No(e,t,n,o),u=j(f(h(be,h(r,h(r,r))),h({n:27n,d:1n},h(i,i))));return k(u,a$1)>0?{exact:[],approximate:Ao(r,i,a)}:l(u)?{exact:go(r,i,a),approximate:[]}:{exact:Ro(r,i,a),approximate:[]}}function go(e,t,n){if(l(e))return [p(n)];let o=f(i(h(B,t),e),n),r=f(j(i(h(B,t),h(_,e))),n);return [o,r].sort(k).map(p)}function Ro(e,t,n){let o=j(i(t,_)),r=f(h(i(t,_),i(t,_)),h(i(e,B),h(i(e,B),i(e,B)))),i$1=O(r),a={kind:"call",name:"cbrt",args:[{kind:"add",left:p(o),right:i$1}]},u={kind:"call",name:"cbrt",args:[{kind:"sub",left:p(o),right:i$1}]},l={kind:"add",left:a,right:u},s={kind:"sub",left:a,right:u},p$1={kind:"add",left:p(n),right:{kind:"div",left:{kind:"neg",operand:l},right:p(_)}},h$1={kind:"mul",left:{kind:"div",left:{kind:"mul",left:s,right:O(B)},right:p(_)},right:w$1(n$1)};return [{kind:"add",left:p(n),right:l},{kind:"sub",left:p$1,right:h$1},{kind:"add",left:p$1,right:h$1}]}function Ao(e,t,n){let o=e$1(e),r=e$1(t),i=e$1(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 xo(e,t,n,o){let r=j(i(e,be)),i$1=h(e,e),a=g(t,i(h(B,i$1),{n:8n,d:1n})),u=f(g(n,i(h(e,t),_)),i(h(i$1,e),{n:8n,d:1n})),l=g(f(g(o,i(h(e,n),be)),i(h(i$1,t),{n:16n,d:1n})),i(h(B,h(i$1,i$1)),{n:256n,d:1n}));return {p:a,q:u,r:l,shift:r}}function an(e,t,n,o,r,i$1){let a=T=>i(T,e),{p:u,q:l$1,r:s,shift:p$1}=xo(a(t),a(n),a(o),a(r)),h=l(l$1)?Mo(u,s):ko(u,l$1,s,i$1);if(h===null)return null;let x=l(p$1)?h:h.map(T=>({kind:"add",left:p(p$1),right:T}));return {exact:vo(x),approximate:[]}}function vo(e){let t=new Set,n=[];for(let o of e){let r=t$1(Q$2(o));t.has(r)||(t.add(r),n.push(o));}return n}function Mo(e,t){let n=g(h(e,e),h(be,t));if(k(n,a$1)<0)return So(e,t);let o=N$1(n);return o!==null?Io(j(e),o,l(n)):Eo(e,t,n)}function Io(e,t,n){let o=n?[i(e,_)]:[i(f(e,t),_),i(g(e,t),_)],r=[];for(let i of o){if(l(i)){r.push(p(a$1));continue}let a=P$2(i);r.push({kind:"neg",operand:a},a);}return r}function Eo(e,t,n){let o=p(j(e)),r=O(n),i=k(e,a$1)<=0,a=[{node:et({kind:"add",left:o,right:r}),positive:i||k(t,a$1)<=0},{node:et({kind:"sub",left:o,right:r}),positive:i&&k(t,a$1)>=0}],u=[];for(let{node:l,positive:s}of a){let h={kind:"call",name:"sqrt",args:[s?l:{kind:"neg",operand:l}]},x=s?h:{kind:"mul",left:h,right:w$1(n$1)};u.push({kind:"neg",operand:x},x);}return u}function et(e){return {kind:"div",left:e,right:p(_)}}function So(e,t){let n=i(j(e),_),o=N$1(t),r=o===null?on(O(t),n):O(i(f(o,n),_)),a={kind:"mul",left:o===null?on(O(t),j(n)):O(i(g(o,n),_)),right:w$1(n$1)},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 on(e,t){let n=t.n>=0n?{kind:"add",left:e,right:p(t)}:{kind:"sub",left:e,right:p(j(t))};return {kind:"call",name:"sqrt",args:[et(n)]}}function ko(e,t,n,o){let r=[{n:1n,d:1n},h(_,e),g(h(e,e),h(be,n)),j(h(t,t))];for(let i$1 of ue(r)){if(k(i$1,a$1)<=0)continue;let a=N$1(i$1);if(a===null)continue;let u=f(e,i$1),l=i(t,a),s=i(g(u,l),_),p=i(f(u,l),_),h={n:1n,d:1n};return [...o(h,a,s),...o(h,j(a),p)]}return null}var _o=200,To=1e-14,Vo=1e-10,wo=1e-10,un=1e-9,Oo=1e-8,Co=4;function ye(e,t){return {re:e.re-t.re,im:e.im-t.im}}function Do(e,t){return {re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function sn(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 Ce(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 Po(e,t){let n=K(t),o=0;for(let r of e)o=o*n+Math.abs(r);return o}function Lo(e){let t=e.length-1,n=[];for(let o=0;o<t;o++)n.push(e[o]*(t-o));return n}function Fo(e){let t=[...e].reverse(),o=[...K$2(t)].reverse().map(e$1);return o.some(r=>!Number.isFinite(r))?null:o}function Uo(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 $o(e){let t=e.length-1,n=Uo(e);for(let o=0;o<_o;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=Do(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=sn(Ce(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<=To*i)return n}return null}function ln(e,t,n){let o=n;for(let r=0;r<Co;r++){let i=Ce(t,o);if(i.re===0&&i.im===0)break;let a=ye(o,sn(Ce(e,o),i));if(!Number.isFinite(a.re)||!Number.isFinite(a.im))break;o=a;}return o}function Bo(e,t,n){let o=Math.max(1,K(n));if(n.im!==0&&Math.abs(n.im)<=un*o){let r=ln(e,t,{re:n.re,im:0});if(tt(e,r))return {re:r.re,im:0}}if(n.re!==0&&Math.abs(n.re)<=un*o){let r=ln(e,t,{re:0,im:n.im});if(tt(e,r))return {re:0,im:r.im}}return n}function tt(e,t){return !Number.isFinite(t.re)||!Number.isFinite(t.im)?false:K(Ce(e,t))<=Vo*Po(e,t)}function qo(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>Oo*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 Yo(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]))<=wo*o)return false}return true}function cn(e){let t=Fo(e);if(t===null)return null;if(t.length<2)return [];let n=$o(t);if(n===null)return null;let o=Lo(t),r=qo(n).map(i=>Bo(t,o,i));for(let i of r)if(!tt(t,i))return null;return Yo(r)?[...r].sort((i,a)=>i.re-a.re||i.im-a.im):null}var mn=8;function Go(e,t){let n=a$1;for(let o of e)n=f(h(n,t),o);return n}function jo(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(f(e[o],h(n[o-1],t)));return n}function fn(e,t,n){let o=g(h(t,t),h(Zo(),h(e,n))),r=h(Xo(),e);if(k(o,a$1)<0)return Ko(j(t),o,r);if(l(o))return [p(i(j(t),r))];let i$1=L(o.n),a=L(o.d);if(i$1!==null&&a!==null){let h={n:i$1,d:a},x=i(f(j(t),h),r),T=i(g(j(t),h),r);return k(T,x)<=0?[p(T),p(x)]:[p(x),p(T)]}let u=O(o),l$1=k(r,a$1)>0,s={kind:"div",left:{kind:"sub",left:p(j(t)),right:u},right:p(r)},p$1={kind:"div",left:{kind:"add",left:p(j(t)),right:u},right:p(r)};return l$1?[s,p$1]:[p$1,s]}function Ko(e,t,n){let o$1=j(t),r=L(o$1.n),i$1=L(o$1.d);if(r!==null&&i$1!==null){let s=i({n:r,d:i$1},n),p=i(e,n);return [w$1(o(p,j(s))),w$1(o(p,s))]}let a=i(e,n),u=i(o$1,h(n,n)),l$1={kind:"mul",left:O(u),right:w$1(n$1)};return l(a)?[{kind:"neg",operand:l$1},l$1]:[{kind:"sub",left:p(a),right:l$1},{kind:"add",left:p(a),right:l$1}]}function Xo(){return {n:2n,d:1n}}function Zo(){return {n:4n,d:1n}}function Ho(e){return {re:e,im:0}}function dn(e,t,n){let o=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=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`}:Wo(o,n);if(i===0)return o.terms.size===0?{kind:"identity"}:{kind:"contradiction"};if(i>mn)return {kind:"unsupported",reason:`degree ${i} is above the supported maximum of ${mn}`};let a=[...B$1(o,n)].reverse();return Jo(a)}function Wo(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=E({terms:n,vars:r(n)});return {kind:"roots",exact:[{kind:"div",left:{kind:"neg",operand:E({terms:o,vars:r(o)})},right:i}],approximate:[]}}function Qo(e){return e.length===4?rn(e[0],e[1],e[2],e[3]):e.length===5?an(e[0],e[1],e[2],e[3],e[4],fn):null}function zo(e){let t=[],n=[...e],o=0;for(;n.length>1&&l(n[n.length-1]);)n=n.slice(0,-1),o++;for(o>0&&t.push(a$1);n.length>1;){let r=ue(n);if(r.length===0)break;for(let i of r){let a=0;for(;n.length>1&&l(Go(n,i));)n=jo(n,i),a++;a>0&&t.push(i);}}return {roots:t.sort(k),remaining:n}}function Jo(e){let{roots:t,remaining:n}=zo(e),o=t.map(p),r=[],i$1=n.length-1,a=e.length-n.length;if(i$1<=0)return le(o,r,a,0,"");if(i$1===1)return o.push(p(i(j(n[1]),n[0]))),le(o,r,a+1,0,"");if(i$1===2)return o.push(...fn(n[0],n[1],n[2])),le(o,r,a+2,0,"");let u=Qo(n);if(u!==null)return o.push(...u.exact),r.push(...u.approximate.map(Ho)),le(o,r,a+i$1,0,"");let l=cn(n);return l!==null?(r.push(...l),le(o,r,a+i$1,0,"")):le(o,r,a,i$1,`a degree-${i$1} 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 pn={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"},er=31,ki=new Set([67,68,69,70,71,72,73,74,75,76,77,78,79]);function V(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)?p(d(t)):null}function w(e){let t=Q$2(e);return t.kind==="const"?n(e$1(t.value)):K$1(t)}function De(e){return P$1("SYMBOLIC_UNSUPPORTED_FUNCTION",`"${e}" cannot be applied to an expression that still contains an unknown.`)}function _i(e,t){let n=V(e),o=V(t);return n===null||o===null?De("^"):w(r(n,o))}function Ti(e){let t=V(e);return t===null?De("-"):w({kind:"neg",operand:t})}function Vi(e,t){let n=[];for(let r of t){let i=Q$1(r);if(i)return i;let a=V(r);if(a===null)return De(pn[e]??`builtin ${e}`);n.push(a);}if(e===er&&n.length===2)return w(r(n[0],n[1]));let o=pn[e];return o===void 0?De(`builtin ${e}`):w(s(o,n))}function tr(e){let t=w(e);return t.type===0&&!Number.isInteger(t.toNumber())?K$1(e):t}function nr(e){return e.im===0?n(e.re):K$1(w$1(o(d(e.re),d(e.im))))}function or(e){switch(e.kind){case "identity":return t("true for every value");case "contradiction":return t("no solution");case "unsupported":return P$1("SYMBOLIC_SOLVE_UNSUPPORTED",`Cannot solve this equation: ${e.reason}.`);case "incomplete":{let t=e.exact.length+e.approximate.length;return P$1("SYMBOLIC_SOLVE_INCOMPLETE",`Only ${t} of this equation's ${t+e.missing} roots could be found: ${e.reason}.`)}case "roots":{let t$1=e.exact.map(tr);for(let n of e.approximate)t$1.push(nr(n));return t$1.length===0?t("no solution"):t$1.length===1?t$1[0]:C$1(1,t$1.length,t$1.map(n=>n.type===9?n.value:n.toNumber()))}}}function yn(e,t,n){let o=V(e),r=V(t);return o===null||r===null?P$1("SYMBOLIC_NONFINITE_OPERAND","An equation side has no exact value to solve with."):or(dn(o,r,n))}function he(e$1,t){if(e$1.type===6&&t.type===6){if(e$1.unit===t.unit)return {lv:e$1.toNumber(),rv:t.toNumber(),unit:e$1.unit,sameMeasure:true};let n=c$1(e$1.unit),o=c$1(t.unit),r=c$2.isCurrency(e$1.unit)&&c$2.isCurrency(t.unit);if(n&&n===o){let i=e(t.toNumber(),t.unit,e$1.unit);return {lv:e$1.toNumber(),rv:i,unit:e$1.unit,sameMeasure:true}}if(r){let i=c$2.convertSync(t.toNumber(),t.unit,e$1.unit);if(i!==null)return {lv:e$1.toNumber(),rv:i,unit:e$1.unit,sameMeasure:true}}return {lv:e$1.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:false}}return e$1.type===6?{lv:e$1.toNumber(),rv:t.toNumber(),unit:e$1.unit,sameMeasure:true}:t.type===6?{lv:e$1.toNumber(),rv:t.toNumber(),unit:t.unit,sameMeasure:true}:{lv:e$1.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:true}}var rr=1e-12;function ir(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 qi(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&&c$2.isCurrency(e.unit))return {lv:n,rv:o,equal: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=ir(n,o,t.toNumber());return {lv:n,rv:o,equal:Math.abs(n-o)<=i*rr,sameMeasure:true}}var ar={time:"duration",luminousIntensity:"luminous intensity"},ur=new Set(["money","data"]),lr={add:"added",sub:"subtracted",mul:"multiplied",div:"divided"};function Pe(e){if(c$2.isCurrency(e))return "money";let t=c$1(e);if(t!==void 0)return ar[t]??t}function hn(e){return ur.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 sr(e){return e!==void 0?lr[e]??"combined":"combined"}function Yi(e,t){let n=Pe(e),o=Pe(t);if(n!==void 0&&o!==void 0&&n!==o)return `${hn(n)} cannot be converted to ${hn(o)}`}function Gi(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 P$1("INCOMPATIBLE_UNITS",r??`Cannot compare incompatible units: ${n??"?"} and ${o??"?"}`)}function Nn(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 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 ji(){return 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 Ki(e,t){let n=gn(e),o=gn(t);return n===null||o===null?null:n<o?-1:n>o?1:0}function gn(e){if(e.type===2)return e.value;let t=e.toNumber();return Number.isInteger(t)?BigInt(t):null}function nt(e,t){return Number.isFinite(t)?Math.pow(e,t):e===1||e===-1&&!Number.isNaN(t)?1:Math.pow(e,t)}function Rn(e){return e.exact!==void 0?e.exact:ha(e.toNumber())}function cr(e,t,n){let o=e.type===6&&e.unit!==void 0&&e.exact!==void 0&&c$2.isCurrency(e.unit),r=t.type===6&&t.unit!==void 0&&t.exact!==void 0&&c$2.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=Rn(t);else if(r&&e.type!==6)a=t.exact,u=t.unit,i=Rn(e);else return null;if(i===null||a===null)return null;let l;switch(n){case "add":l=ja(i,a);break;case "sub":l=ka(i,a);break;case "mul":l=la(i,a);break;case "div":if(na(a))return null;l=pa(i,a);break}return v(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)?c$3(BigInt(e.value)):null}function Xi(e,t,n){let o=Le(e);if(o===null)return null;let r=Le(t);if(r===null||n==="div"&&l(r))return null;let i$1;try{switch(n){case "add":i$1=f(o,r);break;case "sub":i$1=g(o,r);break;case "mul":i$1=h(o,r);break;case "div":i$1=i(o,r);break}}catch{return null}return p$1(e$1(i$1),i$1)}function Zi(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 q(u,l)}function Hi(e,t){let n=Le(e);if(n===null)return null;let o=Le(t);return o===null?null:k(n,o)}function Wi(e,t,n$1,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=V(e),a=V(t);return i===null||a===null?P$1("SYMBOLIC_NONFINITE_OPERAND","A symbolic expression cannot combine with a value that has no exact number (NaN or infinity)."):K$1(Q$2({kind:r,left:i,right:a}))}if(e.type===0&&t.type===0)return n(n$1(e.value,t.value));if(e.type===2||t.type===2){let i=Nn(e),a=Nn(t);return o?s$1(o(i,a)):s$1(i+a)}if(e.type===6||t.type===6){if(r){let s=cr(e,t,r);if(s)return s}let{lv:i,rv:a,unit:u$1,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,sr(r));return P$1("INCOMPATIBLE_UNITS",h??`Cannot combine incompatible units: ${s??"?"} and ${p??"?"}`)}return u(n$1(i,a),u$1)}if(e.type===7&&t.type===7){let i=e.value,a=t.value;if(!V$1(i,a))return P$1("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$1(i.data[l],a.data[l]);return C$1(i.rows,i.cols,u)}if(e.type===7){let i=e.value,a=t.toNumber(),u=i.data.map(l=>n$1(l,a));return C$1(i.rows,i.cols,u)}if(t.type===7){let i=t.value,a=e.toNumber(),u=i.data.map(l=>n$1(a,l));return C$1(i.rows,i.cols,u)}return n(n$1(e.toNumber(),t.toNumber()))}var An=254,xn=200,Ne=class{constructor(){this.handlers=new Map;this.nextOpcode=xn+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>An)throw c.config("OPCODE_POOL_EXHAUSTED",`OpRegistry: dynamic opcode pool exhausted (max ${An-xn} allocations).`);return this.nextOpcode++}},Ji=new Ne;var Mn=ga(1);function ge(e,t){return c$2.isCurrency(t)?e.exact??ha(e.toNumber()):null}function ot(e){if(!Number.isFinite(e))return null;if(Number.isInteger(e))return ga(BigInt(e));let t=String(e);return /^-?\d+\.\d+$/.test(t)?ia(t):null}function In(e,t,n){let o=ge(e,n),r=ot(t);if(o!==null&&r!==null){let i=la(o,r);return v(ra(i),n,i)}return u(e.toNumber()*t,n)}function En(e,t,n,o){let r=ge(e,t),i=ot(n);if(r!==null&&i!==null){let a=ja(Mn,o===1?i:ma(i)),u=la(r,a);return v(ra(u),t,u)}return u(e.toNumber()*(1+o*n),t)}function Sn(e){let t=ot(e);return t===null?null:ja(Mn,t)}function kn(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||na(r))return null;let i=pa(o,r);return v(ra(i),t,i)}function _n(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||na(r))return null;let i=ka(o,pa(o,r));return v(ra(i),t,i)}function Tn(e,t){let n=e.unit,o=n!==void 0&&c$2.isCurrency(n)?mr(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=vn(i,t-u);return u===0?{unit:n,shares:[s]}:{unit:n,shares:[s,vn(i+l,u)]}}function vn(e,t){let n=fa(e,2);return {value:ra(n),exact:n,count:t}}function mr(e,t){let n=ge(e,t);return n===null?null:oa(n,2).coef}var fr=12;function Vn(e,t){if(e.length===0||t.length===0)return [];let n=new Array(e.length+t.length-1).fill(a$1);return e.forEach((o,r)=>{t.forEach((i,a)=>{n[r+a]=f(n[r+a],h(o,i));});}),n}function dr(e,t){let n=[b$2];for(let o=0;o<t;o++)n=Vn(n,e);return n}function rt(e,t){return e.map(n=>i(n,t))}function pr(e,t){let n=[],o=0;for(;o<e.length&&l(e[o]);)o++;o>0&&n.push({base:[a$1,b$2],power:o});let r=e.slice(o);if(r.length>1){let i=Je([...r].reverse(),t);for(let a of i.factors){let u=C(a.base);if(u===null)return null;n.push({base:[...B$1(u,t)],power:a.power});}}return n.length>0?n:null}function br(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 yr(e,t,n){let o=dr(t[e.factor].base,e.power),{quotient:r,remainder:i}=H$1(n,o);if(!G(i))return null;let a=new Array(e.degree).fill(a$1);return a.push(b$2),Vn(r,a)}function hr(e,t){let n=t.length;for(let o=0;o<n;o++){let r=-1;for(let i=o;i<n;i++)if(!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$1=0;i$1<n;i$1++){if(i$1===o||l(e[i$1][o]))continue;let a=i(e[i$1][o],e[o][o]);for(let u=o;u<n;u++)e[i$1][u]=g(e[i$1][u],h(a,e[o][u]));t[i$1]=g(t[i$1],h(a,t[o]));}}return t.map((o,r)=>i(o,e[r][r]))}function it(e,t,n){if(t.length<2||t.length-1>fr)return null;let o=I(e,t),r=o.length>1?H$1(e,o).quotient:[...e],i=o.length>1?H$1(t,o).quotient:[...t];if(i.length===1)return {polynomial:rt(r,i[0]),terms:[]};if(i.length===0)return null;let a=i[i.length-1],u=rt(i,a),l=rt(r,a),{quotient:s,remainder:p}=H$1(l,u);if(G(p))return {polynomial:s,terms:[]};let h=pr(u,n);if(h===null)return null;let x=Nr(h,u,p);return x===null?null:{polynomial:s,terms:x}}function Nr(e,t,n){let o=br(e),r=t.length-1;if(o.length!==r)return null;let i=[];for(let s of o){let p=yr(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]??a$1));let u=[];for(let s=0;s<r;s++)u.push(n[s]??a$1);let l=hr(a,u);return l===null?null:gr(o,l,e)}function gr(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$1]=i.split(":").map(Number),s=[...a].map(p=>p??a$1);s.every(l)||r.push({numerator:s,base:n[u].base,power:l$1});}return r}function Re(e,t){let n=new Map;return e.forEach((o,r)=>{l(o)||n.set(r===0?"":r===1?t:`${t}^${r}`,o);}),n.size===0?p(a$1):E({terms:n,vars:e.length>1?[t]:[]})}function wn(e){let t=at(e);if(t===null)return e;let n=it(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$1 of n.terms){let i=Re(r$1.base,t.variable),a=r$1.power===1?i:r(i,p({n:BigInt(r$1.power),d:1n})),u=Rr(r$1.numerator),l=u?r$1.numerator.map(p=>j(p)):r$1.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:Q$2(o)}function Rr(e){return e.some(t=>t.n<0n)&&e.every(t=>t.n<=0n)}function at(e){if(e.kind!=="div")return null;let t=C(e.left),n=C(e.right);if(t===null||n===null)return null;let o=A(n);return o===null||t.vars.some(r=>r!==o)?null:{numerator:B$1(t,o),denominator:B$1(n,o),variable:o}}var ut=16;function On(){return p(a$1)}function X(){return p(b$2)}function Ar(e,t){switch(e){case "sin":return s("cos",[t]);case "cos":return {kind:"neg",operand:s("sin",[t])};case "tan":return {kind:"div",left:X(),right:r(s("cos",[t]),p(2))};case "exp":return s("exp",[t]);case "log":return {kind:"div",left:X(),right:t};case "sqrt":return {kind:"div",left:X(),right:{kind:"mul",left:p(2),right:s("sqrt",[t])}};case "asin":return {kind:"div",left:X(),right:s("sqrt",[Cn(t)])};case "acos":return {kind:"neg",operand:{kind:"div",left:X(),right:s("sqrt",[Cn(t)])}};case "atan":return {kind:"div",left:X(),right:xr(t)};case "sinh":return s("cosh",[t]);case "cosh":return s("sinh",[t]);case "tanh":return {kind:"div",left:X(),right:r(s("cosh",[t]),p(2))};case "abs":return s("sign",[t]);default:return null}}function Cn(e){return {kind:"sub",left:X(),right:r(e,p(2))}}function xr(e){return {kind:"add",left:X(),right:r(e,p(2))}}function Ae(e,t,n=1){if(n<0||!Number.isInteger(n))throw c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT","A derivative order must be a whole number, at least zero.");if(n>ut)throw c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT",`A derivative order above ${ut} is not supported.`,{limit:ut});let o=Q$2(e);for(let r=0;r<n;r++)o=Q$2(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:r(e.right,p(2))};case "pow":return vr(e,t);case "call":{if(e.args.length!==1)return lt(e,t);let n=Ar(e.name,e.args[0]);return n===null?lt(e,t):{kind:"mul",left:n,right:P(e.args[0],t)}}}}function vr(e,t){if(e.exponent.kind==="const"){let n=p(g(e.exponent.value,b$2));return {kind:"mul",left:{kind:"mul",left:e.exponent,right: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:s("log",[e.base])},right:P(e.exponent,t)}:lt(e,t)}function lt(e,t){return s("der",[e,q$1(t)])}function Dn(e,t){let n=C(e);if(n===null||n.vars.filter(u=>u!==t).length>0||z(n,t)>1)return null;let r=B$1(n,t),i=r[0]??{n:0n,d:1n},a=r[1]??{n:0n,d:1n};return l(a)?null:{slope:a,intercept:i}}function Mr(e,t){let n=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$1=B$1(n,t),i$1=p(0);return r$1.forEach((a,u)=>{if(l(a))return;let l$1=u+1,s=i(a,{n:BigInt(l$1),d:1n}),p$1={kind:"mul",left:p(s),right:l$1===1?q$1(t):r(q$1(t),p(l$1))};i$1={kind:"add",left:i$1,right:p$1};}),{ok:true,value:Q$2(i$1)}}function Ir(e,t){if(e.kind!=="call"||e.args.length!==1)return null;let n=Dn(e.args[0],t);if(n===null)return null;let o=e.args[0],r=i=>Q$2({kind:"div",left:i,right:p(n.slope)});switch(e.name){case "exp":return {ok:true,value:r(s("exp",[o]))};case "sin":return {ok:true,value:r({kind:"neg",operand:s("cos",[o])})};case "cos":return {ok:true,value:r(s("sin",[o]))};case "log":return {ok:true,value:r({kind:"sub",left:{kind:"mul",left:o,right:s("log",[o])},right:o})};default:return null}}function Er(e,t){if(e.kind!=="div"||e.left.kind!=="const"||!st(e.left.value))return null;let n=Dn(e.right,t);if(n!==null)return {ok:true,value:Q$2({kind:"div",left:s("log",[e.right]),right:p(n.slope)})};let o=C(e.right);if(o!==null&&o.vars.length===1&&o.vars[0]===t){let r=B$1(o,t);if(r.length===3&&st(r[0])&&l(r[1])&&st(r[2]))return {ok:true,value:s("atan",[q$1(t)])}}return null}function st(e){return e.n===1n&&e.d===1n}function Sr(e,t){let n=at(e);if(n===null||n.variable!==t)return null;let o=it(n.numerator,n.denominator,t);if(o===null)return null;let r=o.polynomial.length>0?Tr(o.polynomial,t):p(0);for(let i of o.terms){let a=kr(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:Q$2(r)}}function kr(e,t){let n=e.base.length-1,o=Re(e.base,t);if(n===1){let r$1=e.numerator[0]??a$1;if(e.power===1)return {kind:"mul",left:p(r$1),right:s("log",[o])};let i$1=e.power-1,a=i(r$1,{n:BigInt(-i$1),d:1n});return {kind:"div",left:p(a),right:r(o,p({n:BigInt(i$1),d:1n}))}}return n!==2||e.power!==1?null:_r(e,t,o)}function _r(e,t,n){let o=e.numerator[0]??a$1,r=e.numerator[1]??a$1,[i,a]=e.base,u={n:1n,d:2n},l$1=h(a,u),s$1={kind:"mul",left:p(h(r,u)),right:s("log",[n])},p$1=g(o,h(r,l$1));if(l(p$1))return s$1;let h$1=O(g(i,h(l$1,l$1))),x={kind:"add",left:q$1(t),right:p(l$1)},T={kind:"mul",left:{kind:"div",left:p(p$1),right:h$1},right:s("atan",[{kind:"div",left:x,right:h$1}])};return l(r)?T:{kind:"add",left:s$1,right:T}}function Tr(e,t){let n=p(0);return e.forEach((o,r$1)=>{if(l(o))return;let i$1=r$1+1,a=i(o,{n:BigInt(i$1),d:1n}),u={kind:"mul",left:p(a),right:i$1===1?q$1(t):r(q$1(t),p(i$1))};n={kind:"add",left:n,right:u};}),n}function xe(e,t){let n=Q$2(e);if(!u$1(n).has(t))return {ok:true,value:Q$2({kind:"mul",left:n,right:q$1(t)})};let o=Mr(n,t);if(o!==null)return o;let r=Ir(n,t);if(r!==null)return r;let i=Er(n,t);if(i!==null)return i;let a=Sr(n,t);if(a!==null)return a;if(n.kind==="add"||n.kind==="sub"){let u=xe(n.left,t);if(!u.ok)return u;let l=xe(n.right,t);return l.ok?{ok:true,value:Q$2({kind:n.kind,left:u.value,right:l.value})}:l}if(n.kind==="mul"&&n.left.kind==="const"){let u=xe(n.right,t);return u.ok?{ok:true,value:Q$2({kind:"mul",left:n.left,right:u.value})}:u}return {ok:false,reason:"no elementary antiderivative is known for this expression"}}var ct=16;function Pn(e,t,n,o){if(o<0||!Number.isInteger(o)||o>ct)throw c.execution("SYMBOLIC_TAYLOR_DEGREE_LIMIT",`A Taylor degree must be a whole number from 0 to ${ct}.`,{limit:ct});let r$1=p(n),i$1=1n,a=p(a$1);for(let u=0;u<=o;u++){u>0&&(i$1*=BigInt(u));let l$1=Ae(e,t,u),s=Q$2(v$1(l$1,t,r$1));if(s.kind!=="const")throw 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$1=i(s.value,{n:i$1,d:1n});if(l(p$1))continue;let h=l(n)?q$1(t):{kind:"sub",left:q$1(t),right:r$1},x=u===0?p(1):u===1?h:r(h,p(u));a={kind:"add",left:a,right:{kind:"mul",left:p(p$1),right:x}};}return Q$2(a)}function Ln(e,t){return e.map(n=>t.map(o=>Ae(n,o)))}function Vr(){let e=globalThis.Temporal;return e??void 0}function Fn(e){if(e!==void 0&&typeof e!="string")return e;if(e==="date")return b;let t=Vr();if(e==="temporal"){if(t===void 0)throw c.config("CALENDAR_TEMPORAL_UNAVAILABLE",'calendar: "temporal" was asked for, but this runtime has no Temporal. Node ships it from 26 (24 behind --harmony-temporal), and Chrome, Edge, Firefox and Opera ship it; Safari does not. Pass a polyfill-backed backend from "solve-engine/temporal", or use calendar: "auto" to compute on Date where Temporal is absent.');return b$1(t)}return t===void 0?b:b$1(t)}function wr(e={}){return {pluginFunctions:{},opRegistry:new Ne,pluginFunctionOwners:{},networkEnabled:e.networkEnabled??true,calendar:Fn(e.calendar)}}var Un=wr();var Or={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},Bn=1970,qn=2026;function $n(e){return Or[Math.trunc(e)]}function mt(e,t){let n=$n(e),o=$n(t);if(!(n===void 0||o===void 0||n===0))return o/n}function Fa(e,t,n){let o=mt(t,n);if(o!==void 0)return e*o}function Cr(e){let t=Math.abs(e);return t<60?u(e,"s"):t<3600?u(e/60,"min"):t<86400?u(e/3600,"h"):u(e/86400,"d")}var Dr=0;function ft(e){if(e.type===6&&e.unit!==void 0){let t=a[e.unit.toLowerCase()];if(t!==void 0&&t[0]===Dr)return e.toNumber()*t[1]}return e.toNumber()}function Pr(e,t){if(t===1)return e;let n=`${e}s`;return a[n.toLowerCase()]===void 0?e:n}function Yn(e,t){let n$1,o=false;for(let r of e){if(Number.isNaN(r.toNumber())){o=true;continue}if(n$1===void 0){n$1=r;continue}let{lv:i,rv:a,sameMeasure:u}=he(n$1,r);if(!u){let l=n$1.type===6?n$1.unit:void 0,s=r.type===6?r.unit:void 0,p=Fe(l,s,"compared");return P$1("INCOMPATIBLE_UNITS",p??`Cannot compare incompatible units: ${l??"?"} and ${s??"?"}`)}(t?a>i:a<i)&&(n$1=r);}return o?n(NaN):n$1===void 0?n(t?-1/0:1/0):n$1.type===6?n$1:n(n$1.toNumber())}function Ue(e,t){return e.type===6&&e.unit!==void 0?u(t,e.unit):n(t)}function Gn(e,t){let n=Number.isFinite(t)?Math.min(100,Math.max(0,Math.trunc(t))):0;if(e.exact!==void 0){let a=oa(e.exact,n);return $e(e,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$1,o){let r=e.type===6&&e.unit!==void 0?u(t,e.unit):n(t);return r.decimalPlaces=n$1,o!==void 0&&(r.exact=o),r}function jn(e,t,n){if(Number.isFinite(e)&&Number.isFinite(t))return null;let o=Number.isFinite(e)?t:e;return P$1("INVALID_INTEGER_OPERAND",`${n} needs two whole numbers, and ${Number.isNaN(o)?"one of them has no value":"one of them is infinite"}`)}function Kn(e,t){let n=e,o=t;for(;o!==0;){let r=o;o=n%o,n=r;}return n}function Lr(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:Lr(e)/o}var uu={0:e=>{let t=e[0].toNumber();return t>=0?n(Math.sqrt(t)):w(s("sqrt",[p(t)]))},1:e=>e[0].type===7?ca(e[0].value):Ue(e[0],Math.abs(e[0].toNumber())),2:e=>n(Math.sin(ft(e[0]))),3:e=>n(Math.cos(ft(e[0]))),4:e=>n(Math.tan(ft(e[0]))),5:e=>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?Gn(e[0],e[1].toNumber()):Ue(e[0],Math.round(e[0].toNumber())),9:e=>Yn(e,false),10:e=>Yn(e,true),11:e=>n(Math.asin(e[0].toNumber())),12:e=>n(Math.acos(e[0].toNumber())),13:e=>n(Math.atan(e[0].toNumber())),14:e=>n(Math.atan2(e[0].toNumber(),e[1].toNumber())),15:e=>n(Math.sinh(e[0].toNumber())),16:e=>n(Math.cosh(e[0].toNumber())),17:e=>n(Math.tanh(e[0].toNumber())),18:e=>n(Math.asinh(e[0].toNumber())),19:e=>n(Math.acosh(e[0].toNumber())),20:e=>n(Math.atanh(e[0].toNumber())),21:e=>n(Math.cbrt(e[0].toNumber())),22:e=>n(Math.clz32(e[0].toNumber())),23:e=>n(Math.expm1(e[0].toNumber())),24:e=>n(Math.exp(e[0].toNumber())),25:e=>n(Math.fround(e[0].toNumber())),26:e=>n(Math.hypot(...e.map(t=>t.toNumber()))),27:e=>n(Math.imul(e[0].toNumber(),e[1].toNumber())),28:e=>n(Math.log10(e[0].toNumber())),29:e=>n(Math.log1p(e[0].toNumber())),30:e=>n(Math.log2(e[0].toNumber())),31:e=>e[0].type===7?e[1].type!==0?P$1("MATRIX_POWER_UNSUPPORTED",`pow: a matrix's exponent must be a whole number, as in "pow([1,2;3,4], 2)".`):$(e[0].value,e[1].value):e[1].type===7?P$1("MATRIX_POWER_UNSUPPORTED",'pow: a matrix may only be the base, as in "pow([1,2;3,4], 2)".'):n(nt(e[0].toNumber(),e[1].toNumber())),32:()=>n(Math.random()),33:e=>n(Math.sign(e[0].toNumber())),34:e=>n(Math.trunc(e[0].toNumber())),35:e=>n(e[0].toNumber()*Math.PI/180),36:e=>n(e[0].toNumber()*180/Math.PI),37:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return t>n$1?P$1("INVALID_RANGE",`roll: invalid range, ${t} is greater than ${n$1}`):n(Math.floor(Math.random()*(n$1-t+1))+t)},38:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n$1=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n$1,"gcd");return o||n(Kn(t,n$1))},39:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n$1=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n$1,"lcm");return o||(t===0||n$1===0?n(0):n(t/Kn(t,n$1)*n$1))},40:e=>{let t=Math.trunc(e[0].toNumber()),n$1=Math.trunc(e[1].toNumber());if(t<0||n$1<0||n$1>t)return P$1("INVALID_RANGE",`permutation: invalid n=${t}, r=${n$1} (require 0 <= r <= n)`);let o=1;for(let r=0;r<n$1;r++)if(o*=t-r,!Number.isFinite(o))return P$1("PERMUTATION_OVERFLOW",`permutation: P(${t}, ${n$1}) exceeds the maximum representable double (it passed it after ${r+1} of ${n$1} factors)`);return n(o)},41:e=>{let t=Math.trunc(e[0].toNumber()),n$1=Math.trunc(e[1].toNumber());if(t<0||n$1<0||n$1>t)return P$1("INVALID_RANGE",`combination: invalid n=${t}, r=${n$1} (require 0 <= r <= n)`);let o=Math.min(n$1,t-n$1),r=1;for(let i=0;i<o;i++)if(r=r*(t-i)/(i+1),!Number.isFinite(r))return P$1("COMBINATION_OVERFLOW",`combination: C(${t}, ${n$1}) exceeds the maximum representable double (it passed it after ${i+1} of ${o} steps)`);return n(Math.round(r))},42:e=>{if(e.length===0)return n(0);let t=e.reduce((n,o)=>n+o.toNumber(),0);return n(t/e.length)},43:e=>{if(e.length===0)return n(0);let t=e.map(o=>o.toNumber()).sort((o,r)=>o-r),n$1=Math.floor(t.length/2);return n(t.length%2===0?(t[n$1-1]+t[n$1])/2:t[n$1])},44:e=>n(e.reduce((t,n)=>t+n.toNumber(),0)),45:e=>n(e.length),46:e=>{let[t,n$1,o]=e,{lv:r,rv:i}=he(t,n$1);if(r===0)return P$1("PROPORTION_DIVIDE_BY_ZERO",`Cannot compute proportion: "${t.value}" is zero`);let a=o.toNumber()*(i/r);return o.type===6?u(a,o.unit):n(a)},47:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return n$1>o?P$1("INVALID_RANGE",`clamp: invalid range, ${n$1} is greater than ${o}`):n(Math.min(Math.max(t,n$1),o))},48:e=>r$1(e[0].toNumber()),49:e=>r$1(e[0].toNumber(),"bin"),50:e=>n(Math.trunc(e[0].toNumber())),51:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`compoundInterest: rate ${n$1} makes (1 + rate) non-positive`);let r=t*Math.pow(1+n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},52:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`interestEarned: rate ${n$1} makes (1 + rate) non-positive`);let r=t*(Math.pow(1+n$1,o)-1);return e[0].type===6?u(r,e[0].unit):n(r)},53:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return t<=0||n$1<=0?P$1("INVALID_RANGE","compoundInterestRate: principal and futureValue must both be positive"):o<=0?P$1("INVALID_RANGE","compoundInterestRate: years must be greater than 0"):n(Math.pow(n$1/t,1/o)-1)},54:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();return t<=0||n$1<=0?P$1("INVALID_RANGE","compoundInterestYears: principal and futureValue must both be positive"):1+o<=0||o===0?P$1("INVALID_RATE",`compoundInterestYears: rate ${o} is not usable (must be > -1 and not 0)`):n(Math.log(n$1/t)/Math.log(1+o))},55:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return P$1("INVALID_RANGE","loanRepayment: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","loanRepayment: years must be positive");if(n$1<0)return P$1("INVALID_RATE","loanRepayment: rate must not be negative");if(r<0)return P$1("INVALID_RANGE","loanRepayment: periodsPerYear must not be negative");let{totalRepayment:i}=bt(t,n$1,o),a=r===0?i:i/(o*r);return e[0].type===6?u(a,e[0].unit):n(a)},56:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return P$1("INVALID_RANGE","loanInterest: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","loanInterest: years must be positive");if(n$1<0)return P$1("INVALID_RATE","loanInterest: rate must not be negative");if(r<0)return P$1("INVALID_RANGE","loanInterest: periodsPerYear must not be negative");let{totalInterest:i}=bt(t,n$1,o),a=r===0?i:i/(o*r);return e[0].type===6?u(a,e[0].unit):n(a)},57:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(t<=0)return P$1("INVALID_RANGE","monthlyPayment: principal must be positive");if(o<=0)return P$1("INVALID_RANGE","monthlyPayment: years must be positive");if(n$1<0)return P$1("INVALID_RATE","monthlyPayment: rate must not be negative");let{monthlyPayment:r}=bt(t,n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},58:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return e[0].type===6?En(e[0],e[0].unit,n$1,1):n(t*(1+n$1))},59:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return 1+n$1<=0?P$1("INVALID_RATE",`taxRemove: rate ${n$1} makes (1 + rate) non-positive`):e[0].type===6?kn(e[0],e[0].unit,n$1)??u(t/(1+n$1),e[0].unit):n(t/(1+n$1))},60:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=mt(n$1,o);if(r===void 0)return P$1("INFLATION_YEAR_OUT_OF_RANGE",`inflationAdjust: fromYear ${n$1} or toYear ${o} is outside the bundled CPI table's range (${Bn}-${qn})`);let i=t*r;return e[0].type===6?u(i,e[0].unit):n(i)},61:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return n(nt(n$1,1/t))},62:e=>{let t=e[0].toNumber();if(!Number.isInteger(t)||t<0)return P$1("INVALID_FACTORIAL_INPUT",`fact: ${t} is not a non-negative integer`);if(t>170)return P$1("FACTORIAL_OVERFLOW",`fact: ${t}! exceeds the maximum representable double (170! is the largest finite factorial)`);let n$1=1;for(let o=2;o<=t;o++)n$1*=o;return n(n$1)},63:e=>e[0].type===7?ba(e[0].value):e[0],64:e=>e[0].type===7?ca(e[0].value):n(e[0].toNumber()),65:e=>e[0].type===7?da(e[0].value):n(1/e[0].toNumber()),66:e=>{let[t,n$1]=e;if(t.type===0&&n$1.type===0)return n(t.toNumber()*n$1.toNumber());let o=r=>r.type===7?r.value:{rows:1,cols:1,data:[r.toNumber()],hasSymbolic:false};return _$1(o(t),o(n$1))},67:e=>{let[t]=e;return t.type!==9?t:w(F(t.value))},68:e=>{let[t]=e;return t.type!==9?t:w(nn(t.value))},69:e=>{let[t,n,o]=e;return o?.type!==3?P$1("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown."):yn(t,n,o.value)},70:e=>{let[t,n,o]=e,r=pt(n,"der");if(typeof r!="string")return r;let i=V(t);return i===null?P$1("SYMBOLIC_NONFINITE_OPERAND","der needs an expression with an exact value."):w(Ae(i,r,o?.toNumber()??1))},71:e=>{let[t,n]=e,o=pt(n,"integral");if(typeof o!="string")return o;let r=V(t);if(r===null)return P$1("SYMBOLIC_NONFINITE_OPERAND","integral needs an expression with an exact value.");let i=xe(r,o);return i.ok?w(i.value):P$1("SYMBOLIC_INTEGRAL_UNSUPPORTED",`Cannot integrate this: ${i.reason}.`)},72:e=>{let[t,n,o,r]=e,i=pt(n,"taylor");if(typeof i!="string")return i;let a=V(t),u=V(o);return a===null||u===null||u.kind!=="const"?P$1("SYMBOLIC_NONFINITE_OPERAND","taylor needs an expression and an exact expansion point."):w(Pn(a,i,u.value,r.toNumber()))},73:e=>{let t=[];for(let a of e){let u=V(a);if(u===null)return P$1("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 u$1(a))n.add(u);let o=[...n].sort();if(o.length===0)return P$1("SYMBOLIC_JACOBIAN_NO_VARIABLES","jacobian needs at least one unknown to differentiate against.");let r=Ln(t,o),i=[];for(let a of r)for(let u of a)i.push(W(u));return C$1(r.length,o.length,Y(r.length,o.length,i))},74:e=>w(w$1(o(a$1,d(e[0].toNumber())))),75:e=>dt("conj",e[0]),76:e=>dt("re",e[0]),77:e=>dt("im",e[0]),78:e=>{let t=e[0];return t.type!==9?t:w(J(t.value))},79:e=>{let t=e[0];return t.type!==9?t:w(wn(t.value))},85:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`taxIn: rate ${n$1} makes (1 + rate) non-positive`);let o=t-t/(1+n$1);return e[0].type===6?_n(e[0],e[0].unit,n$1)??u(o,e[0].unit):n(o)},86:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return e[0].type===6?In(e[0],n$1,e[0].unit):n(t*n$1)},87:e=>n(Math.sin(e[0].toNumber()*Math.PI/180)),88:e=>n(Math.cos(e[0].toNumber()*Math.PI/180)),89:e=>n(Math.tan(e[0].toNumber()*Math.PI/180)),90:e=>n(Math.asin(e[0].toNumber())*180/Math.PI),91:e=>n(Math.acos(e[0].toNumber())*180/Math.PI),92:e=>n(Math.atan(e[0].toNumber())*180/Math.PI),93:e=>u(e[0].toNumber(),"days"),94:e=>{let t$1=typeof e[1]?.value=="string"?e[1].value:void 0,n=typeof e[2]?.value=="string"?e[2].value:void 0;if(t$1===void 0||n===void 0)return P$1("UNKNOWN_UNIT",'both units have to be named, as in "12.5 minutes in minutes and seconds"');let o=a[t$1.toLowerCase()],r=a[n.toLowerCase()];if(o===void 0||r===void 0)return P$1("UNKNOWN_UNIT",`${t$1} and ${n}: one of these is not a unit`);if(o[0]!==r[0])return P$1("INCOMPATIBLE_UNITS",`${t$1} and ${n} measure different things`);if(r[1]>=o[1])return P$1("INCOMPATIBLE_UNITS",`${t$1} and ${n}: name the larger unit first`);let i=e[0],a$1=i.type===6&&i.unit!==void 0?a[i.unit.toLowerCase()]:void 0,u=i.toNumber()*(a$1?.[1]??o[1]),l=Math.floor(u/o[1]),s=Math.round((u-l*o[1])/r[1]*1e3)/1e3;return t(`${l} ${t$1} ${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("/")?P$1("INVALID_RATE_UNIT",`${o}/${n}: that is already a rate`):u(t.toNumber(),`${o}/${n}`)},96:e=>{let t=e[0],n$1=e[1];if(n$1.type===6&&t.type===6&&i$1(n$1.unit)){let s=j$1(t.toNumber(),t.unit,n$1.toNumber(),n$1.unit);if(s!==null)return Cr(s)}if(n$1.type!==6||n$1.unit===void 0||!n$1.unit.includes("/"))return P$1("INVALID_RATE",'at: the right-hand side has to be a rate, as in "$30/hour"');let o=n$1.unit.indexOf("/"),r=n$1.unit.slice(0,o),i=n$1.unit.slice(o+1),a$1=t.type===6?t.unit:void 0,u$1=a[i.toLowerCase()],l=a$1===void 0?void 0:a[a$1.toLowerCase()];if(l!==void 0&&u$1!==void 0&&l[0]===u$1[0]){let p=t.toNumber()*l[1]/u$1[1]*n$1.toNumber();return r===""?n(p):u(p,r)}if(a$1!==void 0&&a$1===r){let s=t.toNumber()/n$1.toNumber();return u(s,Pr(i,s))}if(a$1===void 0){let s=t.toNumber()*n$1.toNumber();return r===""?n(s):u(s,r)}return P$1("INCOMPATIBLE_UNITS",`at: ${a$1} matches neither side of ${n$1.unit}`)},80:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0)return P$1("INVALID_RATE",`compounding: ${r} periods per year is not a period`);if(1+n$1/r<=0)return P$1("INVALID_RATE",`compounding: rate ${n$1} makes each period non-positive`);let i=t*Math.pow(1+n$1/r,r*o);return e[0].type===6?u(i,e[0].unit):n(i)},81:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0||1+n$1/r<=0)return P$1("INVALID_RATE",`compounding: rate ${n$1} over ${r} periods per year is not usable`);let i=t*(Math.pow(1+n$1/r,r*o)-1);return e[0].type===6?u(i,e[0].unit):n(i)},82:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber(),o=e[2].toNumber();if(1+n$1<=0)return P$1("INVALID_RATE",`presentValue: rate ${n$1} makes (1 + rate) non-positive`);let r=t/Math.pow(1+n$1,o);return e[0].type===6?u(r,e[0].unit):n(r)},83:e=>{let t=e[0].toNumber(),n$1=e[1].toNumber();return t===0?P$1("INVALID_RATE","roi: nothing was invested, so there is no return on it"):n((n$1-t)/t)},84:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0?P$1("INVALID_RATE","annual return: the amount invested must be positive"):o<=0?P$1("INVALID_RATE","annual return: the period must be longer than zero"):n<=0?P$1("INVALID_RATE","annual return: nothing was returned, so there is no annual rate"):N(Math.pow(n/t,1/o)-1)},97:e=>Gn(e[0],e[1].toNumber()),98:e=>{let t=e[1].toNumber();return !Number.isInteger(t)||t<1?P$1("INVALID_RANGE",`split: the number of shares must be a whole number of at least 1, not ${e[1].toNumber()}.`):H(Tn(e[0],t))},99:e=>{let t=e[0].toNumber(),n$1=Fr(e[1]),o=e[2].toNumber();if(n$1===null)return P$1("INVALID_RANGE",'savings goal: the duration must be in months or years, e.g. "in 2 years".');if(t<=0)return P$1("INVALID_RANGE","savings goal: the target must be positive.");if(n$1<=0)return P$1("INVALID_RANGE","savings goal: the duration must be positive.");if(o<0)return P$1("INVALID_RATE","savings goal: the rate must not be negative.");let r=Ur(t,o/12,n$1);return e[0].type===6?u(r,e[0].unit):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 P$1("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return P$1("INVALID_RANGE","savings goal: the contribution must be positive.");if(r<0)return P$1("INVALID_RATE","savings goal: the rate must not be negative.");let a=$r(t,n,r/o);return u(a,i)},101:e=>n(Math.sqrt(Be(e.map(t=>t.toNumber()),false))),102:e=>n(Math.sqrt(Be(e.map(t=>t.toNumber()),true))),103:e=>n(Be(e.map(t=>t.toNumber()),false)),104:e=>n(Be(e.map(t=>t.toNumber()),true)),105:e=>{if(e.length===0)return n(0);let t=e.map(n=>n.toNumber());return n(Math.max(...t)-Math.min(...t))},106:e=>{if(e.length===0)return n(0);let t=new Map,n$1=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$1=i);}return n(n$1)},107:e=>{let t=0,n$1=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$1+=i;}return n$1===0?P$1("WEIGHTED_AVERAGE_ZERO_WEIGHT","weighted average: the weights sum to zero, so there is nothing to divide by"):n(t/n$1)}};function Fr(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 Ur(e,t,n){return t===0?e/n:e*t/(Math.pow(1+t,n)-1)}function $r(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 dt(e,t){let n=V(t);return n===null?P$1("SYMBOLIC_NONFINITE_OPERAND",e+" needs a value with an exact number."):w(s(e,[n]))}function pt(e,t){return e?.type!==3?P$1("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown.`):e.value}function bt(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 lu=Un.pluginFunctions,Xn=65535,Zn=0;function Br(){if(Zn>Xn)throw c.config("PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED",`allocatePluginFunctionIndex: pool exhausted (max ${Xn+1} allocations).`);return Zn++}var Hn=new Map;function su(e){let t=Hn.get(e);return t===void 0&&(t=Br(),Hn.set(e,t)),t}var yt=new Map;function cu(e,t){let n=e.toLowerCase(),o=yt.get(n);o&&o!==t&&console.warn(`[asConverterRegistry] Converter name "${n}" is already registered \u2014 overwriting.`),yt.set(n,t);}function mu(e){yt.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&&qr(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 ht=qe;function qr(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 du=new ht;function pu(e){return `global:${e}`}var Yr={sydney:"Australia/Sydney",melbourne:"Australia/Melbourne",brisbane:"Australia/Brisbane",perth:"Australia/Perth",adelaide:"Australia/Adelaide",canberra:"Australia/Sydney",auckland:"Pacific/Auckland",wellington:"Pacific/Auckland",fiji:"Pacific/Fiji",chicago:"America/Chicago",seattle:"America/Los_Angeles",denver:"America/Denver",phoenix:"America/Phoenix",toronto:"America/Toronto",montreal:"America/Toronto",vancouver:"America/Vancouver",ottawa:"America/Toronto",honolulu:"Pacific/Honolulu",anchorage:"America/Anchorage",miami:"America/New_York",boston:"America/New_York",atlanta:"America/New_York",dallas:"America/Chicago",houston:"America/Chicago",lima:"America/Lima",bogota:"America/Bogota",caracas:"America/Caracas",santiago:"America/Santiago",montevideo:"America/Montevideo",quito:"America/Guayaquil",london:"Europe/London",paris:"Europe/Paris",berlin:"Europe/Berlin",madrid:"Europe/Madrid",rome:"Europe/Rome",amsterdam:"Europe/Amsterdam",dublin:"Europe/Dublin",lisbon:"Europe/Lisbon",vienna:"Europe/Vienna",zurich:"Europe/Zurich",geneva:"Europe/Zurich",moscow:"Europe/Moscow",istanbul:"Europe/Istanbul",athens:"Europe/Athens",stockholm:"Europe/Stockholm",oslo:"Europe/Oslo",helsinki:"Europe/Helsinki",warsaw:"Europe/Warsaw",prague:"Europe/Prague",budapest:"Europe/Budapest",brussels:"Europe/Brussels",copenhagen:"Europe/Copenhagen",reykjavik:"Atlantic/Reykjavik",kiev:"Europe/Kyiv",kyiv:"Europe/Kyiv",tokyo:"Asia/Tokyo",osaka:"Asia/Tokyo",beijing:"Asia/Shanghai",shanghai:"Asia/Shanghai",seoul:"Asia/Seoul",singapore:"Asia/Singapore",bangkok:"Asia/Bangkok",jakarta:"Asia/Jakarta",manila:"Asia/Manila",mumbai:"Asia/Kolkata",delhi:"Asia/Kolkata",bangalore:"Asia/Kolkata",dubai:"Asia/Dubai",abudhabi:"Asia/Dubai",karachi:"Asia/Karachi",dhaka:"Asia/Dhaka",hanoi:"Asia/Ho_Chi_Minh",taipei:"Asia/Taipei",islamabad:"Asia/Karachi",riyadh:"Asia/Riyadh",telaviv:"Asia/Jerusalem",jerusalem:"Asia/Jerusalem",cairo:"Africa/Cairo",lagos:"Africa/Lagos",nairobi:"Africa/Nairobi",johannesburg:"Africa/Johannesburg",casablanca:"Africa/Casablanca",accra:"Africa/Accra",tunis:"Africa/Tunis",addisababa:"Africa/Addis_Ababa",france:"Europe/Paris",germany:"Europe/Berlin",spain:"Europe/Madrid",italy:"Europe/Rome",japan:"Asia/Tokyo",china:"Asia/Shanghai",india:"Asia/Kolkata",brazil:"America/Sao_Paulo",russia:"Europe/Moscow",australia:"Australia/Sydney",canada:"America/Toronto",mexico:"America/Mexico_City",uk:"Europe/London",usa:"America/New_York",ireland:"Europe/Dublin",netherlands:"Europe/Amsterdam",sweden:"Europe/Stockholm",norway:"Europe/Oslo",poland:"Europe/Warsaw",turkey:"Europe/Istanbul",egypt:"Africa/Cairo",nigeria:"Africa/Lagos"},Gr={"new york":"America/New_York","los angeles":"America/Los_Angeles","san francisco":"America/Los_Angeles","las vegas":"America/Los_Angeles","mexico city":"America/Mexico_City","hong kong":"Asia/Hong_Kong","kuala lumpur":"Asia/Kuala_Lumpur","sao paulo":"America/Sao_Paulo","buenos aires":"America/Argentina/Buenos_Aires","rio de janeiro":"America/Sao_Paulo","cape town":"Africa/Johannesburg","new delhi":"Asia/Kolkata","united kingdom":"Europe/London","united states":"America/New_York","south africa":"Africa/Johannesburg"},jr={pst:"America/Los_Angeles",pdt:"America/Los_Angeles",est:"America/New_York",edt:"America/New_York",cst:"America/Chicago",cdt:"America/Chicago",mst:"America/Denver",mdt:"America/Denver",hst:"Pacific/Honolulu",bst:"Europe/London",cet:"Europe/Paris",cest:"Europe/Paris",jst:"Asia/Tokyo",ist:"Asia/Kolkata",aest:"Australia/Sydney",aedt:"Australia/Sydney"},Kr={...Yr,...Gr,...jr};function yu(e){let t=e.trim().toLowerCase();return t==="utc"||t==="gmt"?"UTC":Kr[t]??null}export{qn as A,Fa as B,uu as C,lu as D,Br as E,su as F,yt as G,cu as H,mu as I,du as J,pu as K,Gr as L,Kr as M,yu as N,ge as a,In as b,En as c,dn as d,ki as e,_i as f,Ti as g,Vi as h,yn as i,he as j,qi as k,Yi as l,Gi as m,Nn as n,ji as o,Ki as p,nt as q,Xi as r,Zi as s,Hi as t,Wi as u,Ne as v,Ji as w,wr as x,Un as y,Bn as z};//# sourceMappingURL=chunk-INMJ7ZXL.js.map
2
+ //# sourceMappingURL=chunk-INMJ7ZXL.js.map