solve-engine 1.1.1 → 1.2.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 (188) hide show
  1. package/dist/{EngineError-B61GS1jp.d.cts → EngineError-CNA_rHY-.d.cts} +6 -0
  2. package/dist/{EngineError-B61GS1jp.d.ts → EngineError-CNA_rHY-.d.ts} +6 -0
  3. package/dist/{Lexer-BOs7euZe.d.cts → Lexer-B4C1qHXu.d.cts} +1 -1
  4. package/dist/{Lexer-CSI_lwbW.d.ts → Lexer-DKMlj7Sy.d.ts} +1 -1
  5. package/dist/{PackageCompatibility-B-7rK1TD.d.cts → PackageCompatibility-B6NX9IaN.d.cts} +1 -1
  6. package/dist/{PackageCompatibility-Dh59eF-X.d.ts → PackageCompatibility-Ceg5XdAp.d.ts} +1 -1
  7. package/dist/{PackageRegistry-BHWJP83F.d.cts → PackageRegistry-DnJYVw9G.d.cts} +55 -8
  8. package/dist/{PackageRegistry-_8rDlvxI.d.ts → PackageRegistry-DrCPQNyy.d.ts} +55 -8
  9. package/dist/{Parselet-BBT8riYh.d.ts → Parselet-Bhf7d0_W.d.ts} +2 -2
  10. package/dist/{Parselet-BHcgK9S7.d.cts → Parselet-Cv7S7KRt.d.cts} +2 -2
  11. package/dist/{ScopeManager-CxA24W5n.d.ts → ScopeManager-Bzq87GfA.d.ts} +10 -3
  12. package/dist/{ScopeManager-8vf02dwj.d.cts → ScopeManager-DRDBVfan.d.cts} +10 -3
  13. package/dist/{Token-B1hdkedD.d.cts → Token-CbP_OutD.d.cts} +9 -0
  14. package/dist/{Token-B1hdkedD.d.ts → Token-CbP_OutD.d.ts} +9 -0
  15. package/dist/{TokenNormalizer-C6VzZgHa.d.ts → TokenNormalizer-DCWdZjGz.d.ts} +1 -1
  16. package/dist/{TokenNormalizer-DRc1Js1V.d.cts → TokenNormalizer-DnlL7_8c.d.cts} +1 -1
  17. package/dist/{VMCheckpoints-MK--EBH2.d.ts → VMCheckpoints-C6c17Hbo.d.ts} +2 -2
  18. package/dist/{VMCheckpoints-ELYqITdF.d.cts → VMCheckpoints-dZxSMGHG.d.cts} +2 -2
  19. package/dist/{Value-BUi1RA3S.d.cts → Value-DZNQ_PU7.d.cts} +32 -5
  20. package/dist/{Value-BUi1RA3S.d.ts → Value-DZNQ_PU7.d.ts} +32 -5
  21. package/dist/{WorkerError-_-RkoQ5P.d.ts → WorkerError-B7t7R2-m.d.ts} +1 -1
  22. package/dist/{WorkerError-gzmaopj2.d.cts → WorkerError-Djd7GGGa.d.cts} +1 -1
  23. package/dist/{chunk-SSV46KFA.cjs → chunk-4K5W7EH2.cjs} +6 -6
  24. package/dist/{chunk-SSV46KFA.cjs.map → chunk-4K5W7EH2.cjs.map} +1 -1
  25. package/dist/{chunk-267JPOTF.js → chunk-5EFKSKMA.js} +11 -4
  26. package/dist/chunk-5EFKSKMA.js.map +1 -0
  27. package/dist/{chunk-536WPM2V.cjs → chunk-7AXJNQMF.cjs} +17 -3
  28. package/dist/chunk-7AXJNQMF.cjs.map +1 -0
  29. package/dist/{chunk-LHZ6VOA7.js → chunk-7JM3F4KL.js} +39 -8
  30. package/dist/chunk-7JM3F4KL.js.map +1 -0
  31. package/dist/{chunk-N5NNW4VG.cjs → chunk-7USV76HV.cjs} +6 -6
  32. package/dist/{chunk-N5NNW4VG.cjs.map → chunk-7USV76HV.cjs.map} +1 -1
  33. package/dist/{chunk-HIQ5HSZL.cjs → chunk-A2DZ5BEJ.cjs} +53 -46
  34. package/dist/{chunk-HIQ5HSZL.cjs.map → chunk-A2DZ5BEJ.cjs.map} +1 -1
  35. package/dist/{chunk-CKQMXMHR.cjs → chunk-AKNGX4TZ.cjs} +28 -11
  36. package/dist/chunk-AKNGX4TZ.cjs.map +1 -0
  37. package/dist/{chunk-I4GAWIPW.js → chunk-AOH6UR2L.js} +6 -6
  38. package/dist/{chunk-I4GAWIPW.js.map → chunk-AOH6UR2L.js.map} +1 -1
  39. package/dist/{chunk-T6ZYQJ63.cjs → chunk-BESTLPRK.cjs} +326 -214
  40. package/dist/chunk-BESTLPRK.cjs.map +1 -0
  41. package/dist/{chunk-Z7XGGLI2.js → chunk-BSPXMGIS.js} +3 -3
  42. package/dist/{chunk-Z7XGGLI2.js.map → chunk-BSPXMGIS.js.map} +1 -1
  43. package/dist/{chunk-SRGQ72IR.cjs → chunk-C2OMO3WN.cjs} +376 -370
  44. package/dist/chunk-C2OMO3WN.cjs.map +1 -0
  45. package/dist/{chunk-GLA4JXBO.js → chunk-CSDQMDU2.js} +4 -4
  46. package/dist/{chunk-GLA4JXBO.js.map → chunk-CSDQMDU2.js.map} +1 -1
  47. package/dist/{chunk-7KYSUDQO.js → chunk-F4UB4XIL.js} +4 -4
  48. package/dist/{chunk-7KYSUDQO.js.map → chunk-F4UB4XIL.js.map} +1 -1
  49. package/dist/{chunk-WXEHD6TT.js → chunk-FE4RC37D.js} +15 -9
  50. package/dist/chunk-FE4RC37D.js.map +1 -0
  51. package/dist/{chunk-7ZX6B7SY.cjs → chunk-FR7RNOPT.cjs} +637 -556
  52. package/dist/chunk-FR7RNOPT.cjs.map +1 -0
  53. package/dist/{chunk-QFTDTX6K.cjs → chunk-G2YPPLGX.cjs} +29 -2
  54. package/dist/chunk-G2YPPLGX.cjs.map +1 -0
  55. package/dist/{chunk-HVRVSI2Z.cjs → chunk-GDEU72RG.cjs} +86 -86
  56. package/dist/{chunk-HVRVSI2Z.cjs.map → chunk-GDEU72RG.cjs.map} +1 -1
  57. package/dist/{chunk-MN3LHRGV.cjs → chunk-HKTQCQ4Z.cjs} +860 -489
  58. package/dist/chunk-HKTQCQ4Z.cjs.map +1 -0
  59. package/dist/{chunk-XA4CKRML.cjs → chunk-HWHU642X.cjs} +2 -2
  60. package/dist/{chunk-XA4CKRML.cjs.map → chunk-HWHU642X.cjs.map} +1 -1
  61. package/dist/{chunk-CUR2WLI4.cjs → chunk-ICEKS6YC.cjs} +11 -11
  62. package/dist/{chunk-CUR2WLI4.cjs.map → chunk-ICEKS6YC.cjs.map} +1 -1
  63. package/dist/{chunk-NNZAEUDW.js → chunk-IJGOFP2J.js} +138 -26
  64. package/dist/chunk-IJGOFP2J.js.map +1 -0
  65. package/dist/{chunk-ENKKJYD3.js → chunk-IQJGDZOP.js} +4 -4
  66. package/dist/{chunk-ENKKJYD3.js.map → chunk-IQJGDZOP.js.map} +1 -1
  67. package/dist/{chunk-2TZKENDH.cjs → chunk-IT74O4BE.cjs} +15 -7
  68. package/dist/chunk-IT74O4BE.cjs.map +1 -0
  69. package/dist/{chunk-ZVTWQLK4.cjs → chunk-KXDQKVNX.cjs} +10 -10
  70. package/dist/{chunk-ZVTWQLK4.cjs.map → chunk-KXDQKVNX.cjs.map} +1 -1
  71. package/dist/{chunk-BYJBUL7U.js → chunk-L5YHV6BQ.js} +5 -5
  72. package/dist/{chunk-BYJBUL7U.js.map → chunk-L5YHV6BQ.js.map} +1 -1
  73. package/dist/{chunk-E23GZEWL.cjs → chunk-LO7HU5WB.cjs} +8 -8
  74. package/dist/{chunk-E23GZEWL.cjs.map → chunk-LO7HU5WB.cjs.map} +1 -1
  75. package/dist/{chunk-UO6BUV6K.js → chunk-LSALB3IN.js} +17 -3
  76. package/dist/chunk-LSALB3IN.js.map +1 -0
  77. package/dist/{chunk-J45BCEZ4.cjs → chunk-MI7OTUHL.cjs} +27 -27
  78. package/dist/{chunk-J45BCEZ4.cjs.map → chunk-MI7OTUHL.cjs.map} +1 -1
  79. package/dist/{chunk-B4HBEFTB.cjs → chunk-MIGXCBXT.cjs} +8 -2
  80. package/dist/chunk-MIGXCBXT.cjs.map +1 -0
  81. package/dist/{chunk-ERCOHGXD.js → chunk-N7OA4WPJ.js} +8 -2
  82. package/dist/chunk-N7OA4WPJ.js.map +1 -0
  83. package/dist/{chunk-4D6NIHE2.js → chunk-NAWZATKT.js} +29 -2
  84. package/dist/chunk-NAWZATKT.js.map +1 -0
  85. package/dist/{chunk-JG6ZJ2WU.js → chunk-ORM7CHYZ.js} +23 -5
  86. package/dist/chunk-ORM7CHYZ.js.map +1 -0
  87. package/dist/{chunk-B7NLZMQ3.cjs → chunk-PCZVMMWU.cjs} +8 -8
  88. package/dist/{chunk-B7NLZMQ3.cjs.map → chunk-PCZVMMWU.cjs.map} +1 -1
  89. package/dist/{chunk-DLEBSLF4.js → chunk-RNKDIXDV.js} +4 -4
  90. package/dist/{chunk-DLEBSLF4.js.map → chunk-RNKDIXDV.js.map} +1 -1
  91. package/dist/{chunk-YRIKITGF.cjs → chunk-TC6BTUSU.cjs} +55 -24
  92. package/dist/chunk-TC6BTUSU.cjs.map +1 -0
  93. package/dist/{chunk-4HQKTMWG.js → chunk-TPOK3UNI.js} +387 -17
  94. package/dist/chunk-TPOK3UNI.js.map +1 -0
  95. package/dist/{chunk-CCBZZQAE.js → chunk-UF6JG5SG.js} +2 -2
  96. package/dist/{chunk-CCBZZQAE.js.map → chunk-UF6JG5SG.js.map} +1 -1
  97. package/dist/{chunk-NKW7LKYU.js → chunk-WMQRJTAO.js} +88 -7
  98. package/dist/chunk-WMQRJTAO.js.map +1 -0
  99. package/dist/{chunk-ZMW6NU2K.cjs → chunk-YJHY7CMN.cjs} +95 -77
  100. package/dist/chunk-YJHY7CMN.cjs.map +1 -0
  101. package/dist/{chunk-3OWCDIPN.js → chunk-YNIWOYW6.js} +21 -4
  102. package/dist/chunk-YNIWOYW6.js.map +1 -0
  103. package/dist/{chunk-WWQEY7BV.js → chunk-ZN6YYPIW.js} +3 -3
  104. package/dist/{chunk-WWQEY7BV.js.map → chunk-ZN6YYPIW.js.map} +1 -1
  105. package/dist/{chunk-NNQ2TYDF.js → chunk-ZNFFTYWH.js} +11 -5
  106. package/dist/chunk-ZNFFTYWH.js.map +1 -0
  107. package/dist/constants.cjs +5 -5
  108. package/dist/constants.js +2 -2
  109. package/dist/engine.cjs +33 -33
  110. package/dist/engine.d.cts +27 -11
  111. package/dist/engine.d.ts +27 -11
  112. package/dist/engine.js +20 -20
  113. package/dist/errors.cjs +26 -26
  114. package/dist/errors.d.cts +3 -3
  115. package/dist/errors.d.ts +3 -3
  116. package/dist/errors.js +2 -2
  117. package/dist/format.cjs +7 -7
  118. package/dist/format.d.cts +1 -1
  119. package/dist/format.d.ts +1 -1
  120. package/dist/format.js +4 -4
  121. package/dist/index.cjs +48 -48
  122. package/dist/index.d.cts +11 -11
  123. package/dist/index.d.ts +11 -11
  124. package/dist/index.js +21 -21
  125. package/dist/language.cjs +7 -7
  126. package/dist/language.d.cts +10 -10
  127. package/dist/language.d.ts +10 -10
  128. package/dist/language.js +2 -2
  129. package/dist/lexer.cjs +16 -16
  130. package/dist/lexer.d.cts +3 -3
  131. package/dist/lexer.d.ts +3 -3
  132. package/dist/lexer.js +5 -5
  133. package/dist/normalizer.cjs +10 -10
  134. package/dist/normalizer.d.cts +3 -3
  135. package/dist/normalizer.d.ts +3 -3
  136. package/dist/normalizer.js +4 -4
  137. package/dist/packages.cjs +40 -36
  138. package/dist/packages.d.cts +37 -11
  139. package/dist/packages.d.ts +37 -11
  140. package/dist/packages.js +11 -11
  141. package/dist/parser.cjs +13 -13
  142. package/dist/parser.d.cts +4 -4
  143. package/dist/parser.d.ts +4 -4
  144. package/dist/parser.js +5 -5
  145. package/dist/{pipeline-DCd5M6Gk.d.ts → pipeline-D-PS9gVw.d.ts} +3 -3
  146. package/dist/{pipeline-CtfJtPQc.d.cts → pipeline-DtSBJ8TS.d.cts} +3 -3
  147. package/dist/resolvers.d.cts +2 -2
  148. package/dist/resolvers.d.ts +2 -2
  149. package/dist/testing.cjs +26 -26
  150. package/dist/testing.d.cts +10 -10
  151. package/dist/testing.d.ts +10 -10
  152. package/dist/testing.js +19 -19
  153. package/dist/uom.cjs +8 -8
  154. package/dist/uom.d.cts +2 -2
  155. package/dist/uom.d.ts +2 -2
  156. package/dist/uom.js +4 -4
  157. package/dist/vm.cjs +32 -32
  158. package/dist/vm.d.cts +7 -7
  159. package/dist/vm.d.ts +7 -7
  160. package/dist/vm.js +7 -7
  161. package/dist/worker.cjs +38 -38
  162. package/dist/worker.d.cts +10 -10
  163. package/dist/worker.d.ts +10 -10
  164. package/dist/worker.js +20 -20
  165. package/package.json +1 -1
  166. package/dist/chunk-267JPOTF.js.map +0 -1
  167. package/dist/chunk-2TZKENDH.cjs.map +0 -1
  168. package/dist/chunk-3OWCDIPN.js.map +0 -1
  169. package/dist/chunk-4D6NIHE2.js.map +0 -1
  170. package/dist/chunk-4HQKTMWG.js.map +0 -1
  171. package/dist/chunk-536WPM2V.cjs.map +0 -1
  172. package/dist/chunk-7ZX6B7SY.cjs.map +0 -1
  173. package/dist/chunk-B4HBEFTB.cjs.map +0 -1
  174. package/dist/chunk-CKQMXMHR.cjs.map +0 -1
  175. package/dist/chunk-ERCOHGXD.js.map +0 -1
  176. package/dist/chunk-JG6ZJ2WU.js.map +0 -1
  177. package/dist/chunk-LHZ6VOA7.js.map +0 -1
  178. package/dist/chunk-MN3LHRGV.cjs.map +0 -1
  179. package/dist/chunk-NKW7LKYU.js.map +0 -1
  180. package/dist/chunk-NNQ2TYDF.js.map +0 -1
  181. package/dist/chunk-NNZAEUDW.js.map +0 -1
  182. package/dist/chunk-QFTDTX6K.cjs.map +0 -1
  183. package/dist/chunk-SRGQ72IR.cjs.map +0 -1
  184. package/dist/chunk-T6ZYQJ63.cjs.map +0 -1
  185. package/dist/chunk-UO6BUV6K.js.map +0 -1
  186. package/dist/chunk-WXEHD6TT.js.map +0 -1
  187. package/dist/chunk-YRIKITGF.cjs.map +0 -1
  188. package/dist/chunk-ZMW6NU2K.cjs.map +0 -1
@@ -1,26 +1,26 @@
1
1
  'use strict';
2
2
 
3
- var chunkHVRVSI2Z_cjs = require('./chunk-HVRVSI2Z.cjs');
3
+ var chunkGDEU72RG_cjs = require('./chunk-GDEU72RG.cjs');
4
4
  var chunkX6K3HUOY_cjs = require('./chunk-X6K3HUOY.cjs');
5
5
  var chunkENRIK36Q_cjs = require('./chunk-ENRIK36Q.cjs');
6
- var chunkSRGQ72IR_cjs = require('./chunk-SRGQ72IR.cjs');
7
- var chunkXA4CKRML_cjs = require('./chunk-XA4CKRML.cjs');
8
- var chunkCKQMXMHR_cjs = require('./chunk-CKQMXMHR.cjs');
9
- var chunkMN3LHRGV_cjs = require('./chunk-MN3LHRGV.cjs');
10
- var chunkJ45BCEZ4_cjs = require('./chunk-J45BCEZ4.cjs');
11
- var chunkCUR2WLI4_cjs = require('./chunk-CUR2WLI4.cjs');
6
+ var chunkC2OMO3WN_cjs = require('./chunk-C2OMO3WN.cjs');
7
+ var chunkHWHU642X_cjs = require('./chunk-HWHU642X.cjs');
8
+ var chunkAKNGX4TZ_cjs = require('./chunk-AKNGX4TZ.cjs');
9
+ var chunkHKTQCQ4Z_cjs = require('./chunk-HKTQCQ4Z.cjs');
10
+ var chunkMI7OTUHL_cjs = require('./chunk-MI7OTUHL.cjs');
11
+ var chunkICEKS6YC_cjs = require('./chunk-ICEKS6YC.cjs');
12
12
  var chunkADBA3XBE_cjs = require('./chunk-ADBA3XBE.cjs');
13
13
  var chunkZ2XP767T_cjs = require('./chunk-Z2XP767T.cjs');
14
- var chunk7ZX6B7SY_cjs = require('./chunk-7ZX6B7SY.cjs');
15
- var chunkHIQ5HSZL_cjs = require('./chunk-HIQ5HSZL.cjs');
16
- var chunk2TZKENDH_cjs = require('./chunk-2TZKENDH.cjs');
17
- var chunkE23GZEWL_cjs = require('./chunk-E23GZEWL.cjs');
18
- var chunkN5NNW4VG_cjs = require('./chunk-N5NNW4VG.cjs');
19
- var chunk536WPM2V_cjs = require('./chunk-536WPM2V.cjs');
20
- var chunkZMW6NU2K_cjs = require('./chunk-ZMW6NU2K.cjs');
21
- var chunkQFTDTX6K_cjs = require('./chunk-QFTDTX6K.cjs');
14
+ var chunkFR7RNOPT_cjs = require('./chunk-FR7RNOPT.cjs');
15
+ var chunkA2DZ5BEJ_cjs = require('./chunk-A2DZ5BEJ.cjs');
16
+ var chunkIT74O4BE_cjs = require('./chunk-IT74O4BE.cjs');
17
+ var chunkLO7HU5WB_cjs = require('./chunk-LO7HU5WB.cjs');
18
+ var chunk7USV76HV_cjs = require('./chunk-7USV76HV.cjs');
19
+ var chunk7AXJNQMF_cjs = require('./chunk-7AXJNQMF.cjs');
20
+ var chunkYJHY7CMN_cjs = require('./chunk-YJHY7CMN.cjs');
21
+ var chunkG2YPPLGX_cjs = require('./chunk-G2YPPLGX.cjs');
22
22
  var chunkOUHT5Z36_cjs = require('./chunk-OUHT5Z36.cjs');
23
- var chunkB4HBEFTB_cjs = require('./chunk-B4HBEFTB.cjs');
23
+ var chunkMIGXCBXT_cjs = require('./chunk-MIGXCBXT.cjs');
24
24
  var chunkB7LXJ6LC_cjs = require('./chunk-B7LXJ6LC.cjs');
25
25
 
26
26
  // node_modules/semver/internal/constants.js
@@ -1973,7 +1973,7 @@ var require_semver2 = chunkB7LXJ6LC_cjs.__commonJS({
1973
1973
 
1974
1974
  // src/api/EngineVersionCompatibility.ts
1975
1975
  var import_semver = chunkB7LXJ6LC_cjs.__toESM(require_semver2(), 1);
1976
- function checkEngineVersionCompatibility(pkg, engineVersion = chunkE23GZEWL_cjs.ENGINE_VERSION) {
1976
+ function checkEngineVersionCompatibility(pkg, engineVersion = chunkLO7HU5WB_cjs.ENGINE_VERSION) {
1977
1977
  if (!pkg.engineVersion) return { compatible: true };
1978
1978
  if ((0, import_semver.validRange)(pkg.engineVersion) === null) {
1979
1979
  return { compatible: false, reason: "invalid-range", declaredRange: pkg.engineVersion, engineVersion };
@@ -1984,11 +1984,11 @@ function checkEngineVersionCompatibility(pkg, engineVersion = chunkE23GZEWL_cjs.
1984
1984
  }
1985
1985
  return { compatible: true };
1986
1986
  }
1987
- function assertEngineVersionCompatible(pkg, engineVersion = chunkE23GZEWL_cjs.ENGINE_VERSION) {
1987
+ function assertEngineVersionCompatible(pkg, engineVersion = chunkLO7HU5WB_cjs.ENGINE_VERSION) {
1988
1988
  const result = checkEngineVersionCompatibility(pkg, engineVersion);
1989
1989
  if (result.compatible) return;
1990
1990
  if (result.reason === "invalid-range") {
1991
- throw chunkB4HBEFTB_cjs.ErrorFactory.config({
1991
+ throw chunkMIGXCBXT_cjs.ErrorFactory.config({
1992
1992
  code: "PACKAGE_ENGINE_VERSION_INVALID_RANGE",
1993
1993
  message: `Package "${pkg.name}" declares an invalid engineVersion range: "${result.declaredRange}" is not a valid semver range.`,
1994
1994
  expected: `a valid semver range string (e.g. "^0.1.0", ">=0.2.0 <1.0.0")`,
@@ -1997,7 +1997,7 @@ function assertEngineVersionCompatible(pkg, engineVersion = chunkE23GZEWL_cjs.EN
1997
1997
  context: { packageName: pkg.name, declaredRange: result.declaredRange }
1998
1998
  });
1999
1999
  }
2000
- throw chunkB4HBEFTB_cjs.ErrorFactory.config({
2000
+ throw chunkMIGXCBXT_cjs.ErrorFactory.config({
2001
2001
  code: "PACKAGE_ENGINE_VERSION_MISMATCH",
2002
2002
  message: `Package "${pkg.name}" declares engineVersion "${result.declaredRange}", which is not satisfied by the running engine version "${result.engineVersion}".`,
2003
2003
  expected: `an engine version satisfying "${result.declaredRange}"`,
@@ -2154,7 +2154,7 @@ function decodeNumber(n) {
2154
2154
  if (n === "NaN") return NaN;
2155
2155
  if (n === "Infinity") return Infinity;
2156
2156
  if (n === "-Infinity") return -Infinity;
2157
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2157
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2158
2158
  code: SnapshotErrorCodes.SNAPSHOT_MALFORMED,
2159
2159
  message: `Snapshot holds an unrecognised number sentinel: ${JSON.stringify(n)}`,
2160
2160
  expected: `a JSON number, or one of "NaN", "Infinity", "-Infinity"`,
@@ -2182,10 +2182,10 @@ function deserializeRational(r) {
2182
2182
  return { n: BigInt(r.n), d: BigInt(r.d) };
2183
2183
  }
2184
2184
  function valueTypeName(type) {
2185
- return chunk2TZKENDH_cjs.ValueType[type] ?? String(type);
2185
+ return chunkIT74O4BE_cjs.ValueType[type] ?? String(type);
2186
2186
  }
2187
2187
  function unsupportedValue(type, where) {
2188
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2188
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2189
2189
  code: SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE,
2190
2190
  message: `A ${valueTypeName(type)} value (${where}) cannot be included in a snapshot yet.`,
2191
2191
  expected: "a concrete number, string, boolean, unit, range, matrix, bigint, or money value",
@@ -2248,41 +2248,41 @@ function serializeMatrixCell(cell, where) {
2248
2248
  function deserializeValue(sv) {
2249
2249
  switch (sv.t) {
2250
2250
  case 0 /* Number */: {
2251
- const v = new chunk2TZKENDH_cjs.Value(0 /* Number */, decodeNumber(sv.v));
2251
+ const v = new chunkIT74O4BE_cjs.Value(0 /* Number */, decodeNumber(sv.v));
2252
2252
  if (sv.exact !== void 0) v.exact = deserializeDecimal(sv.exact);
2253
2253
  if (sv.rational !== void 0) v.rational = deserializeRational(sv.rational);
2254
2254
  return v;
2255
2255
  }
2256
2256
  case 1 /* Hex */: {
2257
2257
  const value = sv.big ? BigInt(sv.v) : decodeNumber(sv.v);
2258
- return new chunk2TZKENDH_cjs.Value(1 /* Hex */, value, sv.base);
2258
+ return new chunkIT74O4BE_cjs.Value(1 /* Hex */, value, sv.base);
2259
2259
  }
2260
2260
  case 2 /* BigInt */:
2261
- return new chunk2TZKENDH_cjs.Value(2 /* BigInt */, BigInt(sv.v));
2261
+ return new chunkIT74O4BE_cjs.Value(2 /* BigInt */, BigInt(sv.v));
2262
2262
  case 3 /* String */:
2263
- return new chunk2TZKENDH_cjs.Value(3 /* String */, sv.v);
2263
+ return new chunkIT74O4BE_cjs.Value(3 /* String */, sv.v);
2264
2264
  case 4 /* Datetime */:
2265
- return new chunk2TZKENDH_cjs.Value(4 /* Datetime */, decodeNumber(sv.v));
2265
+ return new chunkIT74O4BE_cjs.Value(4 /* Datetime */, decodeNumber(sv.v));
2266
2266
  case 5 /* Percentage */:
2267
- return new chunk2TZKENDH_cjs.Value(5 /* Percentage */, decodeNumber(sv.v));
2267
+ return new chunkIT74O4BE_cjs.Value(5 /* Percentage */, decodeNumber(sv.v));
2268
2268
  case 6 /* Uom */: {
2269
- const v = new chunk2TZKENDH_cjs.Value(6 /* Uom */, decodeNumber(sv.v), sv.unit);
2269
+ const v = new chunkIT74O4BE_cjs.Value(6 /* Uom */, decodeNumber(sv.v), sv.unit);
2270
2270
  if (sv.exact !== void 0) v.exact = deserializeDecimal(sv.exact);
2271
2271
  return v;
2272
2272
  }
2273
2273
  case 7 /* Matrix */: {
2274
2274
  const data = sv.data.map((cell) => typeof cell === "boolean" ? cell : decodeNumber(cell));
2275
2275
  const m = { rows: sv.rows, cols: sv.cols, data, hasSymbolic: false };
2276
- return new chunk2TZKENDH_cjs.Value(7 /* Matrix */, m);
2276
+ return new chunkIT74O4BE_cjs.Value(7 /* Matrix */, m);
2277
2277
  }
2278
2278
  case 8 /* Range */:
2279
- return new chunk2TZKENDH_cjs.Value(8 /* Range */, { min: decodeNumber(sv.min), max: decodeNumber(sv.max) });
2279
+ return new chunkIT74O4BE_cjs.Value(8 /* Range */, { min: decodeNumber(sv.min), max: decodeNumber(sv.max) });
2280
2280
  case 10 /* Boolean */:
2281
- return new chunk2TZKENDH_cjs.Value(10 /* Boolean */, sv.v);
2281
+ return new chunkIT74O4BE_cjs.Value(10 /* Boolean */, sv.v);
2282
2282
  case 13 /* Error */:
2283
- return new chunk2TZKENDH_cjs.Value(13 /* Error */, sv.code, sv.message);
2283
+ return new chunkIT74O4BE_cjs.Value(13 /* Error */, sv.code, sv.message);
2284
2284
  default:
2285
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2285
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2286
2286
  code: SnapshotErrorCodes.SNAPSHOT_MALFORMED,
2287
2287
  message: `Snapshot holds a value with an unknown type tag: ${JSON.stringify(sv.t)}`,
2288
2288
  expected: "a known SerializedValue type tag",
@@ -2326,7 +2326,7 @@ function deserializeUserFunction(fn) {
2326
2326
  }
2327
2327
  function assertRestorable(snapshot) {
2328
2328
  if (typeof snapshot !== "object" || snapshot === null) {
2329
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2329
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2330
2330
  code: SnapshotErrorCodes.SNAPSHOT_VERSION_MISMATCH,
2331
2331
  message: "fromJSON was given something that is not a snapshot object.",
2332
2332
  expected: `an object produced by ExpressionEngine.toJSON() with format "${SNAPSHOT_FORMAT}"`,
@@ -2335,7 +2335,7 @@ function assertRestorable(snapshot) {
2335
2335
  }
2336
2336
  const candidate = snapshot;
2337
2337
  if (candidate.format !== SNAPSHOT_FORMAT) {
2338
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2338
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2339
2339
  code: SnapshotErrorCodes.SNAPSHOT_VERSION_MISMATCH,
2340
2340
  message: `This object is not a solve-engine snapshot (its "format" is ${JSON.stringify(candidate.format)}).`,
2341
2341
  expected: `format "${SNAPSHOT_FORMAT}"`,
@@ -2343,7 +2343,7 @@ function assertRestorable(snapshot) {
2343
2343
  });
2344
2344
  }
2345
2345
  if (candidate.version !== SNAPSHOT_VERSION) {
2346
- throw chunkB4HBEFTB_cjs.ErrorFactory.validation({
2346
+ throw chunkMIGXCBXT_cjs.ErrorFactory.validation({
2347
2347
  code: SnapshotErrorCodes.SNAPSHOT_VERSION_MISMATCH,
2348
2348
  message: `This snapshot was written for format version ${candidate.version}, but this engine restores version ${SNAPSHOT_VERSION}.`,
2349
2349
  expected: `snapshot version ${SNAPSHOT_VERSION}`,
@@ -2659,7 +2659,7 @@ function percentile(sorted, p) {
2659
2659
  // src/engine/ExpressionEngineSafety.ts
2660
2660
  function checkExpressionLength(expression, config) {
2661
2661
  if (expression.length > config.maxExpressionLength) {
2662
- const err = chunkB4HBEFTB_cjs.ErrorFactory.validation(
2662
+ const err = chunkMIGXCBXT_cjs.ErrorFactory.validation(
2663
2663
  "EXPRESSION_TOO_LONG",
2664
2664
  `Expression exceeds max length of ${config.maxExpressionLength} characters (got ${expression.length})`,
2665
2665
  { expressionLength: expression.length, maxLength: config.maxExpressionLength }
@@ -2667,7 +2667,7 @@ function checkExpressionLength(expression, config) {
2667
2667
  return {
2668
2668
  passed: false,
2669
2669
  error: {
2670
- value: chunk2TZKENDH_cjs.numberValue(0),
2670
+ value: chunkIT74O4BE_cjs.numberValue(0),
2671
2671
  tokens: [],
2672
2672
  program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
2673
2673
  error: err.message,
@@ -2691,7 +2691,7 @@ function checkExpressionComplexity(tokens, config) {
2691
2691
  }
2692
2692
  const complexityScore = tokens.length + functionCallCount * 5 + maxParens * 10;
2693
2693
  if (complexityScore > config.maxComplexity) {
2694
- const err = chunkB4HBEFTB_cjs.ErrorFactory.validation(
2694
+ const err = chunkMIGXCBXT_cjs.ErrorFactory.validation(
2695
2695
  "EXPRESSION_TOO_COMPLEX",
2696
2696
  `Expression complexity score ${complexityScore} exceeds maximum of ${config.maxComplexity}`,
2697
2697
  { complexity: complexityScore, maxComplexity: config.maxComplexity }
@@ -2740,7 +2740,7 @@ function extractReadsAndWrites(tokens) {
2740
2740
  const t = tokens[i];
2741
2741
  if (t.type === "GLOBAL") {
2742
2742
  if (i + 2 < tokens.length && tokens[i + 1].type === "COLON" && isVarName(tokens[i + 2])) {
2743
- const key = chunk7ZX6B7SY_cjs.globalDagKey(tokens[i + 2].value);
2743
+ const key = chunkFR7RNOPT_cjs.globalDagKey(tokens[i + 2].value);
2744
2744
  reads.push(key);
2745
2745
  if (i + 3 < tokens.length && tokens[i + 3].type === "EQUALS") {
2746
2746
  writes.push(key);
@@ -2771,7 +2771,8 @@ function extractReadsAndWrites(tokens) {
2771
2771
  }
2772
2772
  }
2773
2773
  reads.push(t.value);
2774
- if (i + 1 < tokens.length && tokens[i + 1].type === "EQUALS") {
2774
+ const next = tokens[i + 1]?.type;
2775
+ if (next === "EQUALS" || next === "PLUS_EQUALS" || next === "MINUS_EQUALS") {
2775
2776
  writes.push(t.value);
2776
2777
  }
2777
2778
  }
@@ -2779,11 +2780,11 @@ function extractReadsAndWrites(tokens) {
2779
2780
  return { reads, writes };
2780
2781
  }
2781
2782
  function isEmptyLine(lineText) {
2782
- const classification = chunkN5NNW4VG_cjs.sharedLexer.classifyLine(lineText);
2783
+ const classification = chunk7USV76HV_cjs.sharedLexer.classifyLine(lineText);
2783
2784
  return classification.skip;
2784
2785
  }
2785
2786
  function findInlineSolvesInLine(lineText, lineNumber) {
2786
- const spans = chunkN5NNW4VG_cjs.sharedLexer.findInlineSolves(lineText);
2787
+ const spans = chunk7USV76HV_cjs.sharedLexer.findInlineSolves(lineText);
2787
2788
  return spans.map((s) => ({
2788
2789
  start: s.start,
2789
2790
  end: s.end,
@@ -2867,9 +2868,9 @@ function userUnitExpansionRule(table, priority = 82) {
2867
2868
  const after = tokens[pos + 1 + matched.wordCount];
2868
2869
  if (after?.type === "EQUALS") return null;
2869
2870
  const { ratioText, baseUnit } = matched.definition;
2870
- const star = new chunkZMW6NU2K_cjs.LexerToken("STAR", chunkQFTDTX6K_cjs.tokenTypeId("STAR"), "*", "*", value.offset, 0, value.line, value.col);
2871
- const ratio = new chunkZMW6NU2K_cjs.LexerToken("NUMBER", chunkQFTDTX6K_cjs.tokenTypeId("NUMBER"), ratioText, ratioText, value.offset, 0, value.line, value.col);
2872
- const unit = new chunkZMW6NU2K_cjs.LexerToken("UNIT", chunkQFTDTX6K_cjs.tokenTypeId("UNIT"), baseUnit, baseUnit, value.offset, 0, value.line, value.col);
2871
+ const star = new chunkYJHY7CMN_cjs.LexerToken("STAR", chunkG2YPPLGX_cjs.tokenTypeId("STAR"), "*", "*", value.offset, 0, value.line, value.col);
2872
+ const ratio = new chunkYJHY7CMN_cjs.LexerToken("NUMBER", chunkG2YPPLGX_cjs.tokenTypeId("NUMBER"), ratioText, ratioText, value.offset, 0, value.line, value.col);
2873
+ const unit = new chunkYJHY7CMN_cjs.LexerToken("UNIT", chunkG2YPPLGX_cjs.tokenTypeId("UNIT"), baseUnit, baseUnit, value.offset, 0, value.line, value.col);
2873
2874
  return {
2874
2875
  consumed: 1 + matched.wordCount,
2875
2876
  replacement: [value, star, ratio, unit],
@@ -2886,18 +2887,18 @@ var EXPONENT = 50;
2886
2887
  var ON_OFF = 24;
2887
2888
  function infixBindingPower(type) {
2888
2889
  switch (type) {
2889
- case chunkQFTDTX6K_cjs.TokenTypes.PLUS:
2890
- case chunkQFTDTX6K_cjs.TokenTypes.MINUS:
2890
+ case chunkG2YPPLGX_cjs.TokenTypes.PLUS:
2891
+ case chunkG2YPPLGX_cjs.TokenTypes.MINUS:
2891
2892
  return SUM;
2892
- case chunkQFTDTX6K_cjs.TokenTypes.STAR:
2893
- case chunkQFTDTX6K_cjs.TokenTypes.SLASH:
2894
- case chunkQFTDTX6K_cjs.TokenTypes.MOD:
2895
- case chunkQFTDTX6K_cjs.TokenTypes.OF:
2893
+ case chunkG2YPPLGX_cjs.TokenTypes.STAR:
2894
+ case chunkG2YPPLGX_cjs.TokenTypes.SLASH:
2895
+ case chunkG2YPPLGX_cjs.TokenTypes.MOD:
2896
+ case chunkG2YPPLGX_cjs.TokenTypes.OF:
2896
2897
  return PRODUCT;
2897
- case chunkQFTDTX6K_cjs.TokenTypes.CARET:
2898
+ case chunkG2YPPLGX_cjs.TokenTypes.CARET:
2898
2899
  return EXPONENT;
2899
- case chunkQFTDTX6K_cjs.TokenTypes.PCT_ON:
2900
- case chunkQFTDTX6K_cjs.TokenTypes.PCT_OFF:
2900
+ case chunkG2YPPLGX_cjs.TokenTypes.PCT_ON:
2901
+ case chunkG2YPPLGX_cjs.TokenTypes.PCT_OFF:
2901
2902
  return ON_OFF;
2902
2903
  default:
2903
2904
  return 0;
@@ -2905,23 +2906,23 @@ function infixBindingPower(type) {
2905
2906
  }
2906
2907
  function connective(type) {
2907
2908
  switch (type) {
2908
- case chunkQFTDTX6K_cjs.TokenTypes.PLUS:
2909
+ case chunkG2YPPLGX_cjs.TokenTypes.PLUS:
2909
2910
  return "plus";
2910
- case chunkQFTDTX6K_cjs.TokenTypes.MINUS:
2911
+ case chunkG2YPPLGX_cjs.TokenTypes.MINUS:
2911
2912
  return "minus";
2912
- case chunkQFTDTX6K_cjs.TokenTypes.STAR:
2913
+ case chunkG2YPPLGX_cjs.TokenTypes.STAR:
2913
2914
  return "times";
2914
- case chunkQFTDTX6K_cjs.TokenTypes.SLASH:
2915
+ case chunkG2YPPLGX_cjs.TokenTypes.SLASH:
2915
2916
  return "divided by";
2916
- case chunkQFTDTX6K_cjs.TokenTypes.MOD:
2917
+ case chunkG2YPPLGX_cjs.TokenTypes.MOD:
2917
2918
  return "mod";
2918
- case chunkQFTDTX6K_cjs.TokenTypes.CARET:
2919
+ case chunkG2YPPLGX_cjs.TokenTypes.CARET:
2919
2920
  return "to the power of";
2920
- case chunkQFTDTX6K_cjs.TokenTypes.OF:
2921
+ case chunkG2YPPLGX_cjs.TokenTypes.OF:
2921
2922
  return "of";
2922
- case chunkQFTDTX6K_cjs.TokenTypes.PCT_ON:
2923
+ case chunkG2YPPLGX_cjs.TokenTypes.PCT_ON:
2923
2924
  return "plus";
2924
- case chunkQFTDTX6K_cjs.TokenTypes.PCT_OFF:
2925
+ case chunkG2YPPLGX_cjs.TokenTypes.PCT_OFF:
2925
2926
  return "less";
2926
2927
  default:
2927
2928
  return type.toLowerCase();
@@ -2931,22 +2932,22 @@ function tokenEnd(t) {
2931
2932
  return t.sourceEnd ?? t.offset + t.value.length;
2932
2933
  }
2933
2934
  var OPERAND_TOKEN_TYPES = /* @__PURE__ */ new Set([
2934
- chunkQFTDTX6K_cjs.TokenTypes.NUMBER,
2935
- chunkQFTDTX6K_cjs.TokenTypes.BIGINT,
2936
- chunkQFTDTX6K_cjs.TokenTypes.IDENT,
2937
- chunkQFTDTX6K_cjs.TokenTypes.UNIT,
2938
- chunkQFTDTX6K_cjs.TokenTypes.PERCENT,
2939
- chunkQFTDTX6K_cjs.TokenTypes.PI,
2940
- chunkQFTDTX6K_cjs.TokenTypes.E,
2941
- chunkQFTDTX6K_cjs.TokenTypes.TRUE,
2942
- chunkQFTDTX6K_cjs.TokenTypes.FALSE,
2943
- chunkQFTDTX6K_cjs.TokenTypes.DOLLAR,
2944
- chunkQFTDTX6K_cjs.TokenTypes.POUND,
2945
- chunkQFTDTX6K_cjs.TokenTypes.EURO,
2946
- chunkQFTDTX6K_cjs.TokenTypes.YEN,
2947
- chunkQFTDTX6K_cjs.TokenTypes.RUBLE,
2948
- chunkQFTDTX6K_cjs.TokenTypes.WON,
2949
- chunkQFTDTX6K_cjs.TokenTypes.CURRENCY_SYMBOL
2935
+ chunkG2YPPLGX_cjs.TokenTypes.NUMBER,
2936
+ chunkG2YPPLGX_cjs.TokenTypes.BIGINT,
2937
+ chunkG2YPPLGX_cjs.TokenTypes.IDENT,
2938
+ chunkG2YPPLGX_cjs.TokenTypes.UNIT,
2939
+ chunkG2YPPLGX_cjs.TokenTypes.PERCENT,
2940
+ chunkG2YPPLGX_cjs.TokenTypes.PI,
2941
+ chunkG2YPPLGX_cjs.TokenTypes.E,
2942
+ chunkG2YPPLGX_cjs.TokenTypes.TRUE,
2943
+ chunkG2YPPLGX_cjs.TokenTypes.FALSE,
2944
+ chunkG2YPPLGX_cjs.TokenTypes.DOLLAR,
2945
+ chunkG2YPPLGX_cjs.TokenTypes.POUND,
2946
+ chunkG2YPPLGX_cjs.TokenTypes.EURO,
2947
+ chunkG2YPPLGX_cjs.TokenTypes.YEN,
2948
+ chunkG2YPPLGX_cjs.TokenTypes.RUBLE,
2949
+ chunkG2YPPLGX_cjs.TokenTypes.WON,
2950
+ chunkG2YPPLGX_cjs.TokenTypes.CURRENCY_SYMBOL
2950
2951
  ]);
2951
2952
  function isBoundary(type) {
2952
2953
  return !OPERAND_TOKEN_TYPES.has(type);
@@ -2978,7 +2979,7 @@ var Parser = class {
2978
2979
  const bindingPower = infixBindingPower(t.type);
2979
2980
  if (bindingPower === 0 || bindingPower <= minBindingPower) break;
2980
2981
  this.next();
2981
- const rightBindingPower = t.type === chunkQFTDTX6K_cjs.TokenTypes.CARET ? bindingPower - 1 : bindingPower;
2982
+ const rightBindingPower = t.type === chunkG2YPPLGX_cjs.TokenTypes.CARET ? bindingPower - 1 : bindingPower;
2982
2983
  const right = this.parseExpression(rightBindingPower);
2983
2984
  left = {
2984
2985
  kind: "binary",
@@ -2995,16 +2996,16 @@ var Parser = class {
2995
2996
  parseOperand() {
2996
2997
  const first = this.peek();
2997
2998
  if (!first) throw new Error("explain: expected an operand");
2998
- if (first.type === chunkQFTDTX6K_cjs.TokenTypes.LPAREN) {
2999
+ if (first.type === chunkG2YPPLGX_cjs.TokenTypes.LPAREN) {
2999
3000
  return this.parseGroup();
3000
3001
  }
3001
3002
  const signStart = first.offset;
3002
3003
  let sawSign = false;
3003
- while (this.peek() && (this.peek().type === chunkQFTDTX6K_cjs.TokenTypes.PLUS || this.peek().type === chunkQFTDTX6K_cjs.TokenTypes.MINUS)) {
3004
+ while (this.peek() && (this.peek().type === chunkG2YPPLGX_cjs.TokenTypes.PLUS || this.peek().type === chunkG2YPPLGX_cjs.TokenTypes.MINUS)) {
3004
3005
  this.next();
3005
3006
  sawSign = true;
3006
3007
  }
3007
- if (sawSign && this.peek() && this.peek().type === chunkQFTDTX6K_cjs.TokenTypes.LPAREN) {
3008
+ if (sawSign && this.peek() && this.peek().type === chunkG2YPPLGX_cjs.TokenTypes.LPAREN) {
3008
3009
  const group = this.parseGroup();
3009
3010
  return { kind: "wrap", child: group, start: signStart, end: group.end };
3010
3011
  }
@@ -3021,7 +3022,7 @@ var Parser = class {
3021
3022
  const open = this.next();
3022
3023
  const inner = this.parseExpression(0);
3023
3024
  const close = this.peek();
3024
- if (!close || close.type !== chunkQFTDTX6K_cjs.TokenTypes.RPAREN) {
3025
+ if (!close || close.type !== chunkG2YPPLGX_cjs.TokenTypes.RPAREN) {
3025
3026
  throw new Error("explain: unbalanced parentheses");
3026
3027
  }
3027
3028
  this.next();
@@ -3056,7 +3057,7 @@ var Builder = class {
3056
3057
  }
3057
3058
  describe(node) {
3058
3059
  const word = connective(node.op);
3059
- if (node.op === chunkQFTDTX6K_cjs.TokenTypes.PCT_ON || node.op === chunkQFTDTX6K_cjs.TokenTypes.PCT_OFF) {
3060
+ if (node.op === chunkG2YPPLGX_cjs.TokenTypes.PCT_ON || node.op === chunkG2YPPLGX_cjs.TokenTypes.PCT_OFF) {
3060
3061
  return `${this.operand(node.right)} ${word} ${this.operand(node.left)}`;
3061
3062
  }
3062
3063
  return `${this.operand(node.left)} ${word} ${this.operand(node.right)}`;
@@ -3078,7 +3079,7 @@ var Builder = class {
3078
3079
  }
3079
3080
  /** Format a value for inline display, without the result prefix ("= "). */
3080
3081
  render(value) {
3081
- const formatted = chunkCKQMXMHR_cjs.formatValue(value, chunkCKQMXMHR_cjs.DEFAULT_FORMATTING_SETTINGS);
3082
+ const formatted = chunkAKNGX4TZ_cjs.formatValue(value, chunkAKNGX4TZ_cjs.DEFAULT_FORMATTING_SETTINGS);
3082
3083
  return formatted.startsWith(this.resultPrefix) ? formatted.slice(this.resultPrefix.length) : formatted;
3083
3084
  }
3084
3085
  };
@@ -3109,9 +3110,17 @@ var _ExpressionEngine = class _ExpressionEngine {
3109
3110
  //#region Constructor
3110
3111
  constructor(localeCode = "en", diagnosticMode = false, config, diagnosticPipeline, packages) {
3111
3112
  //#region Private Properties
3112
- this.dag = new chunkSRGQ72IR_cjs.DependencyGraph();
3113
+ this.dag = new chunkC2OMO3WN_cjs.DependencyGraph();
3113
3114
  this.lineCache = new LineCache();
3114
- this.scopeManager = new chunkSRGQ72IR_cjs.ScopeManager();
3115
+ /**
3116
+ * Names ever used as a running-total target (`total += 5`). A document is
3117
+ * re-parsed top-to-bottom on every keystroke, so each accumulator is reset
3118
+ * to undefined at the start of a batch pass and re-seeds from its opening
3119
+ * `+=`/`-=` this pass, rather than reading its own previous pass's value
3120
+ * (which grew the total without bound). See {@link tryCompoundAssignment}.
3121
+ */
3122
+ this.accumulatorNames = /* @__PURE__ */ new Set();
3123
+ this.scopeManager = new chunkC2OMO3WN_cjs.ScopeManager();
3115
3124
  /** Registry of async resolvers from registered packages. */
3116
3125
  this.resolverRegistry = new chunkX6K3HUOY_cjs.ResolverRegistry();
3117
3126
  /**
@@ -3194,51 +3203,51 @@ var _ExpressionEngine = class _ExpressionEngine {
3194
3203
  this.bytecodeCache = /* @__PURE__ */ new Map();
3195
3204
  // Pre-allocated BytecodeBuilder pool
3196
3205
  this.builderPool = [
3197
- new chunkJ45BCEZ4_cjs.BytecodeBuilder(),
3198
- new chunkJ45BCEZ4_cjs.BytecodeBuilder(),
3199
- new chunkJ45BCEZ4_cjs.BytecodeBuilder(),
3200
- new chunkJ45BCEZ4_cjs.BytecodeBuilder()
3206
+ new chunkMI7OTUHL_cjs.BytecodeBuilder(),
3207
+ new chunkMI7OTUHL_cjs.BytecodeBuilder(),
3208
+ new chunkMI7OTUHL_cjs.BytecodeBuilder(),
3209
+ new chunkMI7OTUHL_cjs.BytecodeBuilder()
3201
3210
  ];
3202
3211
  // Index into the builder pool, incremented modulo pool size.
3203
3212
  this.builderPoolIndex = 0;
3204
3213
  // Most recent pipeline telemetry, populated when AllocationTracker.isEnabled().
3205
3214
  this.lastTelemetry = null;
3206
3215
  this.localeCode = localeCode;
3207
- this.config = chunkE23GZEWL_cjs.mergeEngineConfig(chunkE23GZEWL_cjs.DEFAULT_CONFIG, config ?? {});
3208
- this.lexer = new chunkN5NNW4VG_cjs.Lexer(localeCode, chunkN5NNW4VG_cjs.buildTokenLookup(localeCode));
3209
- this.registry = new chunkHVRVSI2Z_cjs.ParseletRegistry();
3210
- this.context = chunk7ZX6B7SY_cjs.createEngineContext();
3216
+ this.config = chunkLO7HU5WB_cjs.mergeEngineConfig(chunkLO7HU5WB_cjs.DEFAULT_CONFIG, config ?? {});
3217
+ this.lexer = new chunk7USV76HV_cjs.Lexer(localeCode, chunk7USV76HV_cjs.buildTokenLookup(localeCode));
3218
+ this.registry = new chunkGDEU72RG_cjs.ParseletRegistry();
3219
+ this.context = chunkFR7RNOPT_cjs.createEngineContext();
3211
3220
  if (diagnosticPipeline) {
3212
3221
  this.diagnosticPipeline = diagnosticPipeline;
3213
3222
  } else if (diagnosticMode) {
3214
- this.diagnosticPipeline = new chunkXA4CKRML_cjs.DiagnosticPipeline();
3215
- this.timelineCollector = new chunkXA4CKRML_cjs.TimelineDiagnosticCollector();
3223
+ this.diagnosticPipeline = new chunkHWHU642X_cjs.DiagnosticPipeline();
3224
+ this.timelineCollector = new chunkHWHU642X_cjs.TimelineDiagnosticCollector();
3216
3225
  this.diagnosticPipeline.register(this.timelineCollector);
3217
3226
  } else {
3218
- this.diagnosticPipeline = new chunkXA4CKRML_cjs.DiagnosticPipeline();
3227
+ this.diagnosticPipeline = new chunkHWHU642X_cjs.DiagnosticPipeline();
3219
3228
  }
3220
- this.normalizer = new chunkCUR2WLI4_cjs.TokenNormalizer();
3221
- for (const [phrase, tokenType] of Object.entries(chunkCUR2WLI4_cjs.BUILTIN_PHRASES)) {
3229
+ this.normalizer = new chunkICEKS6YC_cjs.TokenNormalizer();
3230
+ for (const [phrase, tokenType] of Object.entries(chunkICEKS6YC_cjs.BUILTIN_PHRASES)) {
3222
3231
  this.normalizer.addPhrase(phrase, tokenType);
3223
3232
  }
3224
- this.normalizer.register(chunkCUR2WLI4_cjs.implicitMultiplyRule(
3233
+ this.normalizer.register(chunkICEKS6YC_cjs.implicitMultiplyRule(
3225
3234
  50,
3226
3235
  (word) => this.normalizer.canStartPhrase(word)
3227
3236
  ));
3228
3237
  this.normalizer.register(userUnitExpansionRule(this.userUnits));
3229
- const pkgList = packages ?? chunkMN3LHRGV_cjs.BUILTIN_PACKAGES;
3238
+ const pkgList = packages ?? chunkHKTQCQ4Z_cjs.BUILTIN_PACKAGES;
3230
3239
  for (const pkg of pkgList) {
3231
3240
  try {
3232
3241
  this.registerPackage(pkg);
3233
3242
  } catch (e) {
3234
- const engineError = chunkB4HBEFTB_cjs.normalizeUnknownError(e);
3243
+ const engineError = chunkMIGXCBXT_cjs.normalizeUnknownError(e);
3235
3244
  console.error(
3236
3245
  `[ExpressionEngine] Failed to register package "${pkg.name}" \u2014 skipping it and continuing construction with the remaining packages: ${engineError.format()}`
3237
3246
  );
3238
3247
  }
3239
3248
  }
3240
- this.parser = new chunkHVRVSI2Z_cjs.PrecedenceParser(this.registry, this.config.validation.maxNestingDepth, localeCode);
3241
- this.vm = chunkSRGQ72IR_cjs.createVM(
3249
+ this.parser = new chunkGDEU72RG_cjs.PrecedenceParser(this.registry, this.config.validation.maxNestingDepth, localeCode);
3250
+ this.vm = chunkC2OMO3WN_cjs.createVM(
3242
3251
  this.context.opRegistry,
3243
3252
  this.config.vm.maxStackDepth,
3244
3253
  this.config.vm.maxInstructions,
@@ -3328,17 +3337,17 @@ var _ExpressionEngine = class _ExpressionEngine {
3328
3337
  evaluateLineWithBinding(targetLine, variable, bound, symbolicTolerant) {
3329
3338
  const doc = this.documentModel;
3330
3339
  if (!doc) {
3331
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_NO_DOCUMENT", "Goal seek needs a document to solve against, which the single-expression entry point does not have.");
3340
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_NO_DOCUMENT", "Goal seek needs a document to solve against, which the single-expression entry point does not have.");
3332
3341
  }
3333
3342
  if (this.goalSeekDepth >= _ExpressionEngine.GOAL_SEEK_MAX_NESTING_DEPTH) {
3334
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_NESTED", `A goal-seek line cannot target another goal-seek line, since each already re-runs its target many times.`);
3343
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_NESTED", `A goal-seek line cannot target another goal-seek line, since each already re-runs its target many times.`);
3335
3344
  }
3336
3345
  const state = doc.getLineAt(targetLine);
3337
3346
  if (!state || state.bytecodes.length === 0) {
3338
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_LINE_NOT_READY", `Line ${targetLine} has no evaluated expression to solve (forward reference, out of range, or not an expression).`);
3347
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_LINE_NOT_READY", `Line ${targetLine} has no evaluated expression to solve (forward reference, out of range, or not an expression).`);
3339
3348
  }
3340
3349
  if (state.isVariableDef) {
3341
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_TARGET_IS_DEFINITION", `Line ${targetLine} defines a variable, so re-running it would overwrite that variable. Target the line that uses ${variable}, not the one that sets a value.`);
3350
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_TARGET_IS_DEFINITION", `Line ${targetLine} defines a variable, so re-running it would overwrite that variable. Target the line that uses ${variable}, not the one that sets a value.`);
3342
3351
  }
3343
3352
  const program = state.bytecodes[0];
3344
3353
  this.goalSeekDepth++;
@@ -3347,12 +3356,12 @@ var _ExpressionEngine = class _ExpressionEngine {
3347
3356
  const stackBefore = this.vm.getStack().length;
3348
3357
  this.vm.pushCallFrame(frame);
3349
3358
  try {
3350
- const result = chunkSRGQ72IR_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(targetLine), symbolicTolerant);
3359
+ const result = chunkC2OMO3WN_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(targetLine), symbolicTolerant);
3351
3360
  if (result.type === "pending") {
3352
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_ASYNC_UNSUPPORTED", `Line ${targetLine} depends on an async value (weather, stocks, currency, ...), which goal seek cannot re-run.`);
3361
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_ASYNC_UNSUPPORTED", `Line ${targetLine} depends on an async value (weather, stocks, currency, ...), which goal seek cannot re-run.`);
3353
3362
  }
3354
3363
  if (result.type === "error") {
3355
- return chunk2TZKENDH_cjs.errorValue(result.error.code ?? "GOAL_SEEK_TARGET_ERROR", result.error.message);
3364
+ return chunkIT74O4BE_cjs.errorValue(result.error.code ?? "GOAL_SEEK_TARGET_ERROR", result.error.message);
3356
3365
  }
3357
3366
  return result.value;
3358
3367
  } finally {
@@ -3360,7 +3369,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3360
3369
  while (this.vm.getStack().length > stackBefore) this.vm.pop();
3361
3370
  }
3362
3371
  } catch (e) {
3363
- return chunk2TZKENDH_cjs.errorValue("GOAL_SEEK_TARGET_ERROR", chunkB4HBEFTB_cjs.normalizeUnknownError(e).message);
3372
+ return chunkIT74O4BE_cjs.errorValue("GOAL_SEEK_TARGET_ERROR", chunkMIGXCBXT_cjs.normalizeUnknownError(e).message);
3364
3373
  } finally {
3365
3374
  this.goalSeekDepth--;
3366
3375
  }
@@ -3500,7 +3509,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3500
3509
  }
3501
3510
  if (pkg.tokenCategories) {
3502
3511
  for (const [tokenType, category] of Object.entries(pkg.tokenCategories)) {
3503
- chunk536WPM2V_cjs.registerTokenCategory(tokenType, category);
3512
+ chunk7AXJNQMF_cjs.registerTokenCategory(tokenType, category);
3504
3513
  contribution.tokenCategories.push(tokenType);
3505
3514
  }
3506
3515
  }
@@ -3509,7 +3518,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3509
3518
  }
3510
3519
  if (pkg.asConverters) {
3511
3520
  for (const [name, handler] of Object.entries(pkg.asConverters)) {
3512
- chunk7ZX6B7SY_cjs.registerAsConverter(name, handler);
3521
+ chunkFR7RNOPT_cjs.registerAsConverter(name, handler);
3513
3522
  contribution.asConverterNames.push(name);
3514
3523
  }
3515
3524
  }
@@ -3561,13 +3570,13 @@ var _ExpressionEngine = class _ExpressionEngine {
3561
3570
  this.resolverRegistry.unregister(namespace);
3562
3571
  }
3563
3572
  for (const tokenType of contribution.tokenCategories) {
3564
- chunk536WPM2V_cjs.unregisterTokenCategory(tokenType);
3573
+ chunk7AXJNQMF_cjs.unregisterTokenCategory(tokenType);
3565
3574
  }
3566
3575
  if (contribution.lexerVocabulary) {
3567
3576
  this.lexer.unregisterVocabulary(contribution.lexerVocabulary);
3568
3577
  }
3569
3578
  for (const name of contribution.asConverterNames) {
3570
- chunk7ZX6B7SY_cjs.unregisterAsConverter(name);
3579
+ chunkFR7RNOPT_cjs.unregisterAsConverter(name);
3571
3580
  }
3572
3581
  for (const ruleName of contribution.normalizerRuleNames) {
3573
3582
  this.normalizer.unregister(ruleName);
@@ -3642,7 +3651,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3642
3651
  controller.abort();
3643
3652
  };
3644
3653
  chunkZ2XP767T_cjs.setActiveQueryClient(this.queryClient);
3645
- const result = chunkSRGQ72IR_cjs.executeBytecode(program, this.vm, tracePipeline, traceExpression, this.makeLineContext(lineNumber));
3654
+ const result = chunkC2OMO3WN_cjs.executeBytecode(program, this.vm, tracePipeline, traceExpression, this.makeLineContext(lineNumber));
3646
3655
  while (this.vm.getStack().length > stackBefore) {
3647
3656
  this.vm.pop();
3648
3657
  }
@@ -3653,7 +3662,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3653
3662
  result.packageId || packageId,
3654
3663
  [result.queryKey]
3655
3664
  );
3656
- const pending = chunk2TZKENDH_cjs.pendingValue(result.queryKey);
3665
+ const pending = chunkIT74O4BE_cjs.pendingValue(result.queryKey);
3657
3666
  this.storeLineResult(lineNumber, pending, program, reads, writes, expression);
3658
3667
  return pending;
3659
3668
  }
@@ -3693,7 +3702,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3693
3702
  controller.abort();
3694
3703
  };
3695
3704
  chunkZ2XP767T_cjs.setActiveQueryClient(this.queryClient);
3696
- const result = chunkSRGQ72IR_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber));
3705
+ const result = chunkC2OMO3WN_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber));
3697
3706
  while (this.vm.getStack().length > stackBefore) {
3698
3707
  this.vm.pop();
3699
3708
  }
@@ -3751,7 +3760,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3751
3760
  parseDocument(input, options = { inputType: "markdown" }) {
3752
3761
  const maxLines = this.config.performance.maxDocumentLines;
3753
3762
  if (chunkADBA3XBE_cjs.countLines(input, maxLines) > maxLines) {
3754
- throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
3763
+ throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
3755
3764
  "DOCUMENT_TOO_LARGE",
3756
3765
  `This document has more than ${maxLines.toLocaleString("en-US")} lines, which is the most the engine will process in one pass`,
3757
3766
  { maxLines }
@@ -3759,6 +3768,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3759
3768
  }
3760
3769
  if (!this.userUnits.isEmpty) this.bytecodeCache.clear();
3761
3770
  this.userUnits.clear();
3771
+ this.resetAccumulators();
3762
3772
  const scanResults = this.lexer.scanDocument(input);
3763
3773
  const processedLines = this.processScanResults(scanResults);
3764
3774
  const result = {
@@ -3806,6 +3816,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3806
3816
  evaluateLines(lines) {
3807
3817
  if (!this.userUnits.isEmpty) this.bytecodeCache.clear();
3808
3818
  this.userUnits.clear();
3819
+ this.resetAccumulators();
3809
3820
  const documentText = lines.join("\n");
3810
3821
  const scanResults = this.lexer.scanDocument(documentText);
3811
3822
  return this.processScanResults(scanResults);
@@ -3949,7 +3960,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3949
3960
  }
3950
3961
  if (labelIsAllNumeric) {
3951
3962
  const literal = tokens.slice(0, i + 2).map((t) => t.value).join("");
3952
- throw chunkB4HBEFTB_cjs.ErrorFactory.parsing(
3963
+ throw chunkMIGXCBXT_cjs.ErrorFactory.parsing(
3953
3964
  "INVALID_TIME_LITERAL",
3954
3965
  `"${literal}" is not a valid time`,
3955
3966
  { tokenType: tokens[i].type, tokenValue: literal }
@@ -3962,7 +3973,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3962
3973
  } catch {
3963
3974
  }
3964
3975
  }
3965
- throw chunkB4HBEFTB_cjs.ErrorFactory.parsing(
3976
+ throw chunkMIGXCBXT_cjs.ErrorFactory.parsing(
3966
3977
  "UNEXPECTED_TRAILING_TOKEN",
3967
3978
  `Unexpected token after expression: "${leftover.value}"`,
3968
3979
  { tokenType: leftover.type, tokenValue: leftover.value }
@@ -3980,7 +3991,7 @@ var _ExpressionEngine = class _ExpressionEngine {
3980
3991
  * (this grammar is rare, a per-call allocation here is a non-issue).
3981
3992
  */
3982
3993
  compileAdHoc(tokens) {
3983
- const builder = new chunkJ45BCEZ4_cjs.BytecodeBuilder();
3994
+ const builder = new chunkMI7OTUHL_cjs.BytecodeBuilder();
3984
3995
  this.parseExpression(builder, tokens);
3985
3996
  return builder.build();
3986
3997
  }
@@ -4003,10 +4014,10 @@ var _ExpressionEngine = class _ExpressionEngine {
4003
4014
  * `LINE_REF_NO_DOCUMENT` a single-expression eval already returns.
4004
4015
  */
4005
4016
  executeSymbolicTolerant(program, lineNumber = -1) {
4006
- const result = chunkSRGQ72IR_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber), true);
4017
+ const result = chunkC2OMO3WN_cjs.executeBytecode(program, this.vm, void 0, void 0, this.makeLineContext(lineNumber), true);
4007
4018
  if (result.type === "error") throw result.error;
4008
4019
  if (result.type === "pending") {
4009
- throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
4020
+ throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
4010
4021
  "THEREFORE_ASYNC_UNSUPPORTED",
4011
4022
  `"=>" doesn't support expressions that call an async operation (weather/stocks/currency).`
4012
4023
  );
@@ -4065,13 +4076,13 @@ var _ExpressionEngine = class _ExpressionEngine {
4065
4076
  for (const name of equation.factorNames) {
4066
4077
  const v = this.vm.getVar(name);
4067
4078
  if (v === void 0) {
4068
- return chunk2TZKENDH_cjs.errorValue(
4079
+ return chunkIT74O4BE_cjs.errorValue(
4069
4080
  "EQUATION_FACTOR_UNDEFINED",
4070
4081
  `Cannot solve for "${equation.variable}": "${name}" is not yet defined.`
4071
4082
  );
4072
4083
  }
4073
4084
  if (v.type !== 7 /* Matrix */) {
4074
- return chunk2TZKENDH_cjs.errorValue(
4085
+ return chunkIT74O4BE_cjs.errorValue(
4075
4086
  "EQUATION_FACTOR_NOT_MATRIX",
4076
4087
  `Cannot solve for "${equation.variable}": "${name}" must be a Matrix (got a different value type).`
4077
4088
  );
@@ -4080,20 +4091,20 @@ var _ExpressionEngine = class _ExpressionEngine {
4080
4091
  }
4081
4092
  let combined = factorValues[0].value;
4082
4093
  for (let i = 1; i < factorValues.length; i++) {
4083
- const product = chunkHIQ5HSZL_cjs.matrixMultiply(combined, factorValues[i].value);
4094
+ const product = chunkA2DZ5BEJ_cjs.matrixMultiply(combined, factorValues[i].value);
4084
4095
  if (product.type === 13 /* Error */) return product;
4085
4096
  combined = product.value;
4086
4097
  }
4087
- const inv = chunkHIQ5HSZL_cjs.inverse(combined);
4098
+ const inv = chunkA2DZ5BEJ_cjs.inverse(combined);
4088
4099
  if (inv.type === 13 /* Error */) return inv;
4089
4100
  const rhsValue = this.executeSymbolicTolerant(equation.rhsProgram, lineNumber);
4090
4101
  if (rhsValue.type !== 7 /* Matrix */) {
4091
- return chunk2TZKENDH_cjs.errorValue(
4102
+ return chunkIT74O4BE_cjs.errorValue(
4092
4103
  "EQUATION_RHS_NOT_MATRIX",
4093
4104
  `Cannot solve for "${equation.variable}": the right-hand side must be a Matrix.`
4094
4105
  );
4095
4106
  }
4096
- return chunkHIQ5HSZL_cjs.matrixMultiply(inv.value, rhsValue.value);
4107
+ return chunkA2DZ5BEJ_cjs.matrixMultiply(inv.value, rhsValue.value);
4097
4108
  }
4098
4109
  /**
4099
4110
  * Detects and handles this session's two new symbolic-algebra grammar
@@ -4172,7 +4183,91 @@ var _ExpressionEngine = class _ExpressionEngine {
4172
4183
  if (i !== tokens.length) return null;
4173
4184
  this.userUnits.define(nameWords, ratioToken.value, baseToken.value);
4174
4185
  this.bytecodeCache.clear();
4175
- return chunk2TZKENDH_cjs.stringValue(`${nameWords.join(" ")} defined`);
4186
+ return chunkIT74O4BE_cjs.stringValue(`${nameWords.join(" ")} defined`);
4187
+ }
4188
+ /**
4189
+ * `name += expr` / `name -= expr`, a running total. The accumulator reads
4190
+ * its current value, adds or subtracts the right-hand side, stores the
4191
+ * result, and answers with the new value, so a note becomes a live ledger
4192
+ * where each line adjusts a balance in place. Returns null to decline
4193
+ * anything that is not the compound shape.
4194
+ *
4195
+ * Handled here, in the same effectful, cache-bypassing channel as
4196
+ * {@link tryDefineUserUnit} and the bare `count = 10` assignment (see
4197
+ * {@link trySymbolicGrammar}), rather than as a parselet: a bare identifier
4198
+ * is a Tier-1 prefix that emits `LOAD_VAR name` before any infix parselet on
4199
+ * `+=` could run, and that pre-emitted load throws UNDEFINED_VARIABLE for a
4200
+ * first-use accumulator. Seeding 0 for a first `+=`/`-=` is a one-line
4201
+ * `getVar`/`setVar` here where it cannot be from a parselet, a deliberate
4202
+ * departure from a plain reference, which still reports the undefined name.
4203
+ *
4204
+ * The right-hand side is parenthesised and run through the ORDINARY (not
4205
+ * symbolic-tolerant) path, so `bal += 3 * 4` is `bal + 12`, a genuine typo in
4206
+ * it (`total += nope`) is a real UNDEFINED_VARIABLE, and the accumulation
4207
+ * goes through the VM's own ADD/SUB: money stays money, a unit stays its
4208
+ * unit, and the seed 0 added to a typed right-hand side takes that type on
4209
+ * first use. The colon (`:name`) and `global :name` grammars are untouched:
4210
+ * they lex their own leading token, never IDENT/UNIT, so they decline here.
4211
+ */
4212
+ tryCompoundAssignment(tokens, lineNumber = -1) {
4213
+ if (tokens.length < 2) return null;
4214
+ const nameTok = tokens[0];
4215
+ const opTok = tokens[1];
4216
+ const isName = nameTok.type === "IDENT" || nameTok.type === "UNIT";
4217
+ const isCompound = opTok.type === "PLUS_EQUALS" || opTok.type === "MINUS_EQUALS";
4218
+ if (!isName || !isCompound) return null;
4219
+ const rhs = tokens.slice(2);
4220
+ if (rhs.length === 0) {
4221
+ throw chunkMIGXCBXT_cjs.ErrorFactory.parsing(
4222
+ "COMPOUND_ASSIGN_REQUIRES_EXPRESSION",
4223
+ `"${nameTok.value} ${opTok.value}" needs an expression on the right, e.g. "${nameTok.value} ${opTok.value} 10".`
4224
+ );
4225
+ }
4226
+ const name = nameTok.value;
4227
+ this.accumulatorNames.add(name);
4228
+ if (this.vm.getVar(name) === void 0) this.vm.setVar(name, chunkIT74O4BE_cjs.numberValue(0));
4229
+ const op = opTok.type === "PLUS_EQUALS" ? { type: "PLUS", text: "+" } : { type: "MINUS", text: "-" };
4230
+ const accTokens = [
4231
+ chunkICEKS6YC_cjs.createFusedToken("IDENT", name, [nameTok]),
4232
+ chunkICEKS6YC_cjs.createFusedToken(op.type, op.text, [opTok]),
4233
+ chunkICEKS6YC_cjs.createFusedToken("LPAREN", "(", [opTok]),
4234
+ ...rhs,
4235
+ chunkICEKS6YC_cjs.createFusedToken("RPAREN", ")", [opTok])
4236
+ ];
4237
+ const result = chunkC2OMO3WN_cjs.executeBytecode(
4238
+ this.compileAdHoc(accTokens),
4239
+ this.vm,
4240
+ void 0,
4241
+ void 0,
4242
+ this.makeLineContext(lineNumber),
4243
+ false
4244
+ );
4245
+ if (result.type === "error") throw result.error;
4246
+ if (result.type === "pending") {
4247
+ throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
4248
+ "COMPOUND_ASSIGN_ASYNC_UNSUPPORTED",
4249
+ `A running total (+= / -=) cannot use an async operation (weather/stocks/currency) on its right-hand side.`
4250
+ );
4251
+ }
4252
+ this.vm.setVar(name, result.value);
4253
+ return result.value;
4254
+ }
4255
+ /**
4256
+ * Reset every running-total accumulator (`total += 5`) to undefined, and
4257
+ * return their names.
4258
+ *
4259
+ * An accumulator seeds 0 only while its name is undefined, then reads that
4260
+ * value on each `+=`/`-=`. A document is re-evaluated top-to-bottom on
4261
+ * every keystroke, so unless the name is cleared first the total reads its
4262
+ * own previous evaluation's value and grows without bound. The batch
4263
+ * document pass (`parseDocument`/`evaluateLines`) calls this at the start
4264
+ * of each pass; the incremental {@link ThreeTierEvaluator} calls it and
4265
+ * then marks the lines that touch each name dirty, since it re-runs lines
4266
+ * selectively rather than replaying the whole document.
4267
+ */
4268
+ resetAccumulators() {
4269
+ for (const name of this.accumulatorNames) this.vm.deleteVar(name);
4270
+ return this.accumulatorNames;
4176
4271
  }
4177
4272
  trySymbolicGrammar(normalizedTokens, lineNumber = -1) {
4178
4273
  if (normalizedTokens.length === 0) return null;
@@ -4180,7 +4275,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4180
4275
  if (last.type === "THEREFORE") {
4181
4276
  const beforeTokens = normalizedTokens.slice(0, -1);
4182
4277
  if (beforeTokens.length === 0) {
4183
- throw chunkB4HBEFTB_cjs.ErrorFactory.parsing("THEREFORE_REQUIRES_EXPRESSION", `"=>" needs an expression or variable name before it.`);
4278
+ throw chunkMIGXCBXT_cjs.ErrorFactory.parsing("THEREFORE_REQUIRES_EXPRESSION", `"=>" needs an expression or variable name before it.`);
4184
4279
  }
4185
4280
  if (beforeTokens.length === 1 && (beforeTokens[0].type === "IDENT" || beforeTokens[0].type === "UNIT")) {
4186
4281
  const name = beforeTokens[0].value;
@@ -4197,7 +4292,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4197
4292
  }
4198
4293
  return this.simplifySymbolically(beforeTokens, lineNumber);
4199
4294
  }
4200
- if (chunkMN3LHRGV_cjs.containsSymbolicCall(normalizedTokens)) {
4295
+ if (chunkHKTQCQ4Z_cjs.containsSymbolicCall(normalizedTokens)) {
4201
4296
  return this.simplifySymbolically(normalizedTokens, lineNumber);
4202
4297
  }
4203
4298
  if (normalizedTokens[0].type === "COLON" || normalizedTokens[0].type === "GLOBAL") return null;
@@ -4218,7 +4313,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4218
4313
  const factorNames = names.slice(0, -1);
4219
4314
  this.vm.defineEquation(freeVar, factorNames, this.compileAdHoc(rhsTokens));
4220
4315
  this.vm.defineScalarEquation(freeVar, this.compileAdHoc(normalizedTokens.slice(0, eqIdx)), this.compileAdHoc(rhsTokens));
4221
- return chunk2TZKENDH_cjs.stringValue(`${freeVar} stored as an equation \u2014 solve with "${freeVar} =>"`);
4316
+ return chunkIT74O4BE_cjs.stringValue(`${freeVar} stored as an equation \u2014 solve with "${freeVar} =>"`);
4222
4317
  }
4223
4318
  /**
4224
4319
  * Stores a general scalar equation (`x^2 - 4 = 0`) keyed by its unknown, or
@@ -4260,7 +4355,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4260
4355
  if (unknowns.length !== 1) return null;
4261
4356
  const variable = unknowns[0];
4262
4357
  this.vm.defineScalarEquation(variable, this.compileAdHoc(lhsTokens), this.compileAdHoc(rhsTokens));
4263
- return chunk2TZKENDH_cjs.stringValue(`${variable} stored as an equation \u2014 solve with "${variable} =>"`);
4358
+ return chunkIT74O4BE_cjs.stringValue(`${variable} stored as an equation \u2014 solve with "${variable} =>"`);
4264
4359
  }
4265
4360
  /**
4266
4361
  * The names in an equation that have no value yet, which is what makes them
@@ -4299,7 +4394,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4299
4394
  solveScalarEquation(equation, lineNumber = -1) {
4300
4395
  const lhs = this.executeSymbolicTolerant(equation.lhsProgram, lineNumber);
4301
4396
  const rhs = this.executeSymbolicTolerant(equation.rhsProgram, lineNumber);
4302
- return chunk7ZX6B7SY_cjs.solveEquationValues(lhs, rhs, equation.variable);
4397
+ return chunkFR7RNOPT_cjs.solveEquationValues(lhs, rhs, equation.variable);
4303
4398
  }
4304
4399
  //#endregion
4305
4400
  /**
@@ -4391,14 +4486,25 @@ var _ExpressionEngine = class _ExpressionEngine {
4391
4486
  return { kind: "error", stage: "complexity", error: complexityCheck.engineError, normalizedTokens };
4392
4487
  }
4393
4488
  let symbolicResult;
4489
+ let compoundReadsWrites = null;
4394
4490
  try {
4395
- symbolicResult = this.tryDefineUserUnit(normalizedTokens) ?? this.trySymbolicGrammar(normalizedTokens, lineNumber);
4491
+ symbolicResult = this.tryDefineUserUnit(normalizedTokens);
4492
+ if (symbolicResult === null) {
4493
+ const compound = this.tryCompoundAssignment(normalizedTokens, lineNumber);
4494
+ if (compound !== null) {
4495
+ symbolicResult = compound;
4496
+ compoundReadsWrites = extractReadsAndWrites(normalizedTokens);
4497
+ }
4498
+ }
4499
+ if (symbolicResult === null) {
4500
+ symbolicResult = this.trySymbolicGrammar(normalizedTokens, lineNumber);
4501
+ }
4396
4502
  } catch (e) {
4397
4503
  const { reads: reads2, writes: writes2 } = extractReadsAndWrites(normalizedTokens);
4398
- return { kind: "error", stage: "parse", error: chunkB4HBEFTB_cjs.normalizeUnknownError(e), reads: reads2, writes: writes2, normalizedTokens };
4504
+ return { kind: "error", stage: "parse", error: chunkMIGXCBXT_cjs.normalizeUnknownError(e), reads: reads2, writes: writes2, normalizedTokens };
4399
4505
  }
4400
4506
  if (symbolicResult !== null) {
4401
- return { kind: "symbolic-solve", normalizedTokens, value: symbolicResult };
4507
+ return { kind: "symbolic-solve", normalizedTokens, value: symbolicResult, reads: compoundReadsWrites?.reads, writes: compoundReadsWrites?.writes };
4402
4508
  }
4403
4509
  const { reads, writes } = extractReadsAndWrites(normalizedTokens);
4404
4510
  const cachedProgram = this.bytecodeCache.get(expression);
@@ -4417,7 +4523,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4417
4523
  program = parseResult.result;
4418
4524
  parserAlloc = parseResult.alloc;
4419
4525
  } catch (e) {
4420
- return { kind: "error", stage: "parse", error: chunkB4HBEFTB_cjs.normalizeUnknownError(e), reads, writes, normalizedTokens };
4526
+ return { kind: "error", stage: "parse", error: chunkMIGXCBXT_cjs.normalizeUnknownError(e), reads, writes, normalizedTokens };
4421
4527
  }
4422
4528
  this.cacheBytecode(expression, program);
4423
4529
  return { kind: "ready", normalizedTokens, reads, writes, program, cached: false, parserAlloc };
@@ -4479,7 +4585,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4479
4585
  asyncCheck.packageId || "_engine",
4480
4586
  [asyncCheck.queryKey]
4481
4587
  );
4482
- const pending = chunk2TZKENDH_cjs.pendingValue(asyncCheck.queryKey);
4588
+ const pending = chunkIT74O4BE_cjs.pendingValue(asyncCheck.queryKey);
4483
4589
  this.storeLineResult(lineNumber, pending, program, reads, writes, expression);
4484
4590
  return { kind: "pending", value: pending };
4485
4591
  }
@@ -4505,7 +4611,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4505
4611
  evaluateWithTokens(lineNumber, expression, tokens, hasParens) {
4506
4612
  const prep = this.prepareExpression(expression, tokens, hasParens, void 0, lineNumber);
4507
4613
  if (prep.kind === "empty") {
4508
- const v = chunk2TZKENDH_cjs.numberValue(0);
4614
+ const v = chunkIT74O4BE_cjs.numberValue(0);
4509
4615
  this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
4510
4616
  return v;
4511
4617
  }
@@ -4513,7 +4619,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4513
4619
  throw prep.error;
4514
4620
  }
4515
4621
  if (prep.kind === "symbolic-solve") {
4516
- this.storeLineResult(lineNumber, prep.value, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], [], expression);
4622
+ this.storeLineResult(lineNumber, prep.value, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, prep.reads ?? [], prep.writes ?? [], expression);
4517
4623
  return prep.value;
4518
4624
  }
4519
4625
  const { normalizedTokens, reads, writes, program } = prep;
@@ -4548,13 +4654,13 @@ var _ExpressionEngine = class _ExpressionEngine {
4548
4654
  if (result.engineError) {
4549
4655
  throw result.engineError;
4550
4656
  }
4551
- throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
4657
+ throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
4552
4658
  "EVALUATION_ERROR",
4553
4659
  result.error,
4554
4660
  { lineNumber }
4555
4661
  );
4556
4662
  }
4557
- return { values: [chunk2TZKENDH_cjs.freezeIfDev(result.value)] };
4663
+ return { values: [chunkIT74O4BE_cjs.freezeIfDev(result.value)] };
4558
4664
  }
4559
4665
  /**
4560
4666
  * Evaluate a line with diagnostic information, supporting both regular expressions and inline solves.
@@ -4707,7 +4813,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4707
4813
  }
4708
4814
  if (hasCollectors) {
4709
4815
  pipeline.firePipelineStart({
4710
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineStart,
4816
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineStart,
4711
4817
  elapsedNs: 0,
4712
4818
  expression,
4713
4819
  inputType
@@ -4726,7 +4832,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4726
4832
  }
4727
4833
  const onToken = hasCollectors ? (t) => {
4728
4834
  pipeline.fireTokenEmitted({
4729
- type: chunkXA4CKRML_cjs.DiagnosticEventType.TokenEmitted,
4835
+ type: chunkHWHU642X_cjs.DiagnosticEventType.TokenEmitted,
4730
4836
  elapsedNs: 0,
4731
4837
  // zero-cost placeholder (timeline collector overrides)
4732
4838
  expression,
@@ -4789,11 +4895,11 @@ var _ExpressionEngine = class _ExpressionEngine {
4789
4895
  });
4790
4896
  }
4791
4897
  if (tokens.length === 0) {
4792
- const v = chunk2TZKENDH_cjs.numberValue(0);
4898
+ const v = chunkIT74O4BE_cjs.numberValue(0);
4793
4899
  this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
4794
4900
  if (hasCollectors) {
4795
4901
  pipeline.firePipelineEnd({
4796
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
4902
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
4797
4903
  elapsedNs: 0,
4798
4904
  expression,
4799
4905
  success: true,
@@ -4811,7 +4917,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4811
4917
  normalizerFusions.push(fusion);
4812
4918
  normalizerRuleCounts.set(fusion.rule, (normalizerRuleCounts.get(fusion.rule) || 0) + 1);
4813
4919
  pipeline.fireTokenFused({
4814
- type: chunkXA4CKRML_cjs.DiagnosticEventType.TokenFused,
4920
+ type: chunkHWHU642X_cjs.DiagnosticEventType.TokenFused,
4815
4921
  elapsedNs: 0,
4816
4922
  expression,
4817
4923
  ruleName: fusion.rule,
@@ -4822,7 +4928,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4822
4928
  } : void 0;
4823
4929
  if (hasCollectors && this.normalizer.ruleCount > 0) {
4824
4930
  pipeline.fireNormalizerStart({
4825
- type: chunkXA4CKRML_cjs.DiagnosticEventType.NormalizerStart,
4931
+ type: chunkHWHU642X_cjs.DiagnosticEventType.NormalizerStart,
4826
4932
  elapsedNs: 0,
4827
4933
  expression,
4828
4934
  inputTokenCount: tokens.length
@@ -4843,7 +4949,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4843
4949
  if (hasCollectors) {
4844
4950
  if (this.normalizer.ruleCount > 0) {
4845
4951
  pipeline.fireNormalizerEnd({
4846
- type: chunkXA4CKRML_cjs.DiagnosticEventType.NormalizerEnd,
4952
+ type: chunkHWHU642X_cjs.DiagnosticEventType.NormalizerEnd,
4847
4953
  elapsedNs: 0,
4848
4954
  expression,
4849
4955
  outputTokenCount: normalizedTokens.length,
@@ -4873,7 +4979,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4873
4979
  if (prep.kind === "empty" || prep.kind === "error" && prep.stage === "length") {
4874
4980
  if (hasCollectors) {
4875
4981
  pipeline.firePipelineEnd({
4876
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
4982
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
4877
4983
  elapsedNs: 0,
4878
4984
  expression,
4879
4985
  success: prep.kind === "empty",
@@ -4882,12 +4988,12 @@ var _ExpressionEngine = class _ExpressionEngine {
4882
4988
  });
4883
4989
  }
4884
4990
  if (prep.kind === "empty") {
4885
- const v = chunk2TZKENDH_cjs.numberValue(0);
4991
+ const v = chunkIT74O4BE_cjs.numberValue(0);
4886
4992
  this.lineCache.set(lineNumber, new LineCacheEntry(v, { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, [], null), expression);
4887
4993
  return { value: v, tokens, program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false }, debug: void 0, diagnostic: void 0 };
4888
4994
  }
4889
4995
  return {
4890
- value: chunk2TZKENDH_cjs.numberValue(0),
4996
+ value: chunkIT74O4BE_cjs.numberValue(0),
4891
4997
  tokens: [],
4892
4998
  program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
4893
4999
  error: prep.error.message,
@@ -4912,7 +5018,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4912
5018
  errorMessage: complexityCheck.errorMessage
4913
5019
  });
4914
5020
  pipeline.firePipelineEnd({
4915
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5021
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
4916
5022
  elapsedNs: 0,
4917
5023
  expression,
4918
5024
  success: false,
@@ -4921,7 +5027,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4921
5027
  });
4922
5028
  }
4923
5029
  return {
4924
- value: chunk2TZKENDH_cjs.numberValue(0),
5030
+ value: chunkIT74O4BE_cjs.numberValue(0),
4925
5031
  tokens: [],
4926
5032
  program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
4927
5033
  error: complexityCheck.errorMessage,
@@ -4946,7 +5052,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4946
5052
  if (prep.kind === "symbolic-solve") {
4947
5053
  if (hasCollectors) {
4948
5054
  pipeline.firePipelineEnd({
4949
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5055
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
4950
5056
  elapsedNs: 0,
4951
5057
  expression,
4952
5058
  success: true,
@@ -4955,7 +5061,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4955
5061
  });
4956
5062
  }
4957
5063
  const emptyProgram = { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false };
4958
- this.storeLineResult(lineNumber, prep.value, emptyProgram, [], [], expression);
5064
+ this.storeLineResult(lineNumber, prep.value, emptyProgram, prep.reads ?? [], prep.writes ?? [], expression);
4959
5065
  return {
4960
5066
  value: prep.value,
4961
5067
  tokens: normalizedTokens,
@@ -4980,15 +5086,15 @@ var _ExpressionEngine = class _ExpressionEngine {
4980
5086
  cacheKey: expression
4981
5087
  });
4982
5088
  if (cachedBefore) {
4983
- pipeline.fireCacheHit({ type: chunkXA4CKRML_cjs.DiagnosticEventType.CacheHit, elapsedNs: 0, expression, cache: "bytecode", key: expression });
5089
+ pipeline.fireCacheHit({ type: chunkHWHU642X_cjs.DiagnosticEventType.CacheHit, elapsedNs: 0, expression, cache: "bytecode", key: expression });
4984
5090
  } else {
4985
- pipeline.fireCacheMiss({ type: chunkXA4CKRML_cjs.DiagnosticEventType.CacheMiss, elapsedNs: 0, expression, cache: "bytecode", key: expression });
5091
+ pipeline.fireCacheMiss({ type: chunkHWHU642X_cjs.DiagnosticEventType.CacheMiss, elapsedNs: 0, expression, cache: "bytecode", key: expression });
4986
5092
  }
4987
5093
  }
4988
5094
  if (prep.kind === "error" && prep.stage === "parse") {
4989
5095
  if (hasCollectors) {
4990
5096
  pipeline.firePipelineEnd({
4991
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5097
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
4992
5098
  elapsedNs: 0,
4993
5099
  expression,
4994
5100
  success: false,
@@ -4997,7 +5103,7 @@ var _ExpressionEngine = class _ExpressionEngine {
4997
5103
  });
4998
5104
  }
4999
5105
  return {
5000
- value: chunk2TZKENDH_cjs.numberValue(0),
5106
+ value: chunkIT74O4BE_cjs.numberValue(0),
5001
5107
  tokens: normalizedTokens,
5002
5108
  program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
5003
5109
  error: prep.error.message,
@@ -5007,7 +5113,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5007
5113
  };
5008
5114
  }
5009
5115
  if (prep.kind !== "ready") {
5010
- throw chunkB4HBEFTB_cjs.ErrorFactory.internal({
5116
+ throw chunkMIGXCBXT_cjs.ErrorFactory.internal({
5011
5117
  code: "UNEXPECTED_ERROR",
5012
5118
  message: "Internal error: prepareExpression() returned an unexpected variant after all other cases were handled"
5013
5119
  });
@@ -5029,7 +5135,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5029
5135
  cached: !!cachedBefore
5030
5136
  });
5031
5137
  pipeline.fireBytecodeBuilt({
5032
- type: chunkXA4CKRML_cjs.DiagnosticEventType.BytecodeBuilt,
5138
+ type: chunkHWHU642X_cjs.DiagnosticEventType.BytecodeBuilt,
5033
5139
  elapsedNs: 0,
5034
5140
  expression,
5035
5141
  opcodesLength: program.opcodes.length,
@@ -5068,7 +5174,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5068
5174
  if (preflight.kind === "pending") {
5069
5175
  if (hasCollectors) {
5070
5176
  pipeline.firePipelineEnd({
5071
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5177
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
5072
5178
  elapsedNs: 0,
5073
5179
  expression,
5074
5180
  success: true,
@@ -5093,10 +5199,10 @@ var _ExpressionEngine = class _ExpressionEngine {
5093
5199
  result = vmResult.result;
5094
5200
  if (trackEnabled && vmResult.alloc) stageAllocs.push(vmResult.alloc);
5095
5201
  } catch (e) {
5096
- const engineError = chunkB4HBEFTB_cjs.normalizeUnknownError(e);
5202
+ const engineError = chunkMIGXCBXT_cjs.normalizeUnknownError(e);
5097
5203
  if (hasCollectors) {
5098
5204
  pipeline.firePipelineEnd({
5099
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5205
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
5100
5206
  elapsedNs: 0,
5101
5207
  expression,
5102
5208
  success: false,
@@ -5105,7 +5211,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5105
5211
  });
5106
5212
  }
5107
5213
  return {
5108
- value: chunk2TZKENDH_cjs.numberValue(0),
5214
+ value: chunkIT74O4BE_cjs.numberValue(0),
5109
5215
  tokens: normalizedTokens,
5110
5216
  program,
5111
5217
  error: engineError.message,
@@ -5130,7 +5236,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5130
5236
  if (isPending) {
5131
5237
  if (hasCollectors) {
5132
5238
  pipeline.firePipelineEnd({
5133
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5239
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
5134
5240
  elapsedNs: 0,
5135
5241
  expression,
5136
5242
  success: true,
@@ -5174,7 +5280,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5174
5280
  unit: result.unit
5175
5281
  });
5176
5282
  pipeline.fireVmHalt({
5177
- type: chunkXA4CKRML_cjs.DiagnosticEventType.VmHalt,
5283
+ type: chunkHWHU642X_cjs.DiagnosticEventType.VmHalt,
5178
5284
  elapsedNs: 0,
5179
5285
  expression,
5180
5286
  result: result ? {
@@ -5191,7 +5297,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5191
5297
  cacheHit: !!cachedBefore
5192
5298
  });
5193
5299
  pipeline.firePipelineEnd({
5194
- type: chunkXA4CKRML_cjs.DiagnosticEventType.PipelineEnd,
5300
+ type: chunkHWHU642X_cjs.DiagnosticEventType.PipelineEnd,
5195
5301
  elapsedNs: 0,
5196
5302
  expression,
5197
5303
  success: true,
@@ -5299,14 +5405,14 @@ var _ExpressionEngine = class _ExpressionEngine {
5299
5405
  packageId: asyncCheck.packageId || "_engine",
5300
5406
  signal: asyncCheck.signal
5301
5407
  });
5302
- return chunk2TZKENDH_cjs.pendingValue(asyncCheck.queryKey);
5408
+ return chunkIT74O4BE_cjs.pendingValue(asyncCheck.queryKey);
5303
5409
  }
5304
5410
  this.keystrokeSignal?.removeEventListener("abort", abortPreflight);
5305
5411
  }
5306
5412
  const evalResult = this.executeRaw(program, lineNumber);
5307
5413
  if (evalResult.type === "pending") {
5308
5414
  void this.resolveAsync(evalResult);
5309
- return chunk2TZKENDH_cjs.pendingValue(evalResult.queryKey);
5415
+ return chunkIT74O4BE_cjs.pendingValue(evalResult.queryKey);
5310
5416
  }
5311
5417
  if (evalResult.type === "error") {
5312
5418
  throw evalResult.error;
@@ -5595,13 +5701,13 @@ var _ExpressionEngine = class _ExpressionEngine {
5595
5701
  evaluateIsolated(expression) {
5596
5702
  const { tokens, hasParens } = this.lexToTokens(expression);
5597
5703
  const prep = this.prepareExpression(expression, tokens, hasParens, void 0, -1);
5598
- if (prep.kind === "empty") return chunk2TZKENDH_cjs.numberValue(0);
5704
+ if (prep.kind === "empty") return chunkIT74O4BE_cjs.numberValue(0);
5599
5705
  if (prep.kind === "error") throw prep.error;
5600
5706
  if (prep.kind === "symbolic-solve") return prep.value;
5601
5707
  const result = this.executeRaw(prep.program, -1);
5602
5708
  if (result.type === "error") throw result.error;
5603
5709
  if (result.type === "pending") {
5604
- throw chunkB4HBEFTB_cjs.ErrorFactory.execution(
5710
+ throw chunkMIGXCBXT_cjs.ErrorFactory.execution(
5605
5711
  "EXPLAIN_ASYNC_UNSUPPORTED",
5606
5712
  `A derivation cannot be built for a line that resolves data asynchronously: "${expression}"`,
5607
5713
  { expression }
@@ -5637,7 +5743,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5637
5743
  }
5638
5744
  if (prep.kind === "error") {
5639
5745
  if (prep.stage === "parse" && (prep.reads?.length || prep.writes?.length)) {
5640
- throw new chunkB4HBEFTB_cjs.EngineError(prep.error.category, {
5746
+ throw new chunkMIGXCBXT_cjs.EngineError(prep.error.category, {
5641
5747
  code: prep.error.code,
5642
5748
  message: prep.error.message,
5643
5749
  expected: prep.error.expected,
@@ -5655,8 +5761,8 @@ var _ExpressionEngine = class _ExpressionEngine {
5655
5761
  return {
5656
5762
  program: { opcodes: new Uint8Array(0), numbers: new Float64Array(0), strings: [], hasAsync: false },
5657
5763
  tokens: prep.normalizedTokens,
5658
- reads: [],
5659
- writes: []
5764
+ reads: prep.reads ?? [],
5765
+ writes: prep.writes ?? []
5660
5766
  };
5661
5767
  }
5662
5768
  return { program: prep.program, tokens, reads: prep.reads, writes: prep.writes };
@@ -5728,12 +5834,12 @@ var _ExpressionEngine = class _ExpressionEngine {
5728
5834
  */
5729
5835
  executeCached(program, lineNumber = -1) {
5730
5836
  if (program.opcodes.length === 0) {
5731
- return chunk2TZKENDH_cjs.numberValue(0);
5837
+ return chunkIT74O4BE_cjs.numberValue(0);
5732
5838
  }
5733
5839
  const evalResult = this.executeRaw(program, lineNumber);
5734
5840
  if (evalResult.type === "pending") {
5735
5841
  void this.resolveAsync(evalResult);
5736
- return chunk2TZKENDH_cjs.pendingValue(evalResult.queryKey);
5842
+ return chunkIT74O4BE_cjs.pendingValue(evalResult.queryKey);
5737
5843
  }
5738
5844
  if (evalResult.type === "error") {
5739
5845
  throw evalResult.error;
@@ -5780,6 +5886,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5780
5886
  this.bytecodeCache.clear();
5781
5887
  this.vm.reset();
5782
5888
  this.userUnits.clear();
5889
+ this.accumulatorNames.clear();
5783
5890
  this.lastTelemetry = null;
5784
5891
  }
5785
5892
  //#endregion
@@ -5838,7 +5945,12 @@ var _ExpressionEngine = class _ExpressionEngine {
5838
5945
  for (const [name, value] of this.vm.getVariableEntries()) {
5839
5946
  if (value.type === 12 /* Pending */) continue;
5840
5947
  if (latestWriter.get(name)?.async) continue;
5841
- variables[name] = serializeValue(value, `variable "${name}"`);
5948
+ try {
5949
+ variables[name] = serializeValue(value, `variable "${name}"`);
5950
+ } catch (e) {
5951
+ if (e instanceof chunkMIGXCBXT_cjs.EngineError && e.code === SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE) continue;
5952
+ throw e;
5953
+ }
5842
5954
  }
5843
5955
  const userFunctions = this.vm.getUserFunctionDefs().map(serializeUserFunction);
5844
5956
  const lineCache = [];
@@ -5849,7 +5961,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5849
5961
  try {
5850
5962
  result = serializeValue(entry.result, `line ${line}`);
5851
5963
  } catch (e) {
5852
- if (e instanceof chunkB4HBEFTB_cjs.EngineError && e.code === SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE) continue;
5964
+ if (e instanceof chunkMIGXCBXT_cjs.EngineError && e.code === SnapshotErrorCodes.SNAPSHOT_UNSUPPORTED_VALUE) continue;
5853
5965
  throw e;
5854
5966
  }
5855
5967
  lineCache.push({
@@ -5868,7 +5980,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5868
5980
  return {
5869
5981
  format: SNAPSHOT_FORMAT,
5870
5982
  version: SNAPSHOT_VERSION,
5871
- engineVersion: chunkE23GZEWL_cjs.ENGINE_VERSION,
5983
+ engineVersion: chunkLO7HU5WB_cjs.ENGINE_VERSION,
5872
5984
  locale: this.localeCode,
5873
5985
  variables,
5874
5986
  userFunctions,
@@ -5944,7 +6056,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5944
6056
  */
5945
6057
  evaluateIncremental(variable, newValue) {
5946
6058
  const affectedLines = this.dag.getAffectedLinesInOrder(variable);
5947
- this.vm.setVar(variable, chunk2TZKENDH_cjs.numberValue(newValue));
6059
+ this.vm.setVar(variable, chunkIT74O4BE_cjs.numberValue(newValue));
5948
6060
  const updated = /* @__PURE__ */ new Map();
5949
6061
  for (const lineNumber of affectedLines) {
5950
6062
  const entry = this.lineCache.getEntryForLine(lineNumber);
@@ -5955,7 +6067,7 @@ var _ExpressionEngine = class _ExpressionEngine {
5955
6067
  continue;
5956
6068
  }
5957
6069
  if (evalResult.type === "error") {
5958
- const value = chunk2TZKENDH_cjs.errorValue(evalResult.error.code, evalResult.error.message);
6070
+ const value = chunkIT74O4BE_cjs.errorValue(evalResult.error.code, evalResult.error.message);
5959
6071
  updated.set(lineNumber, value);
5960
6072
  entry.result = value;
5961
6073
  continue;
@@ -5986,7 +6098,7 @@ function getCompileEngine() {
5986
6098
  var executeVm = null;
5987
6099
  function getExecuteVm() {
5988
6100
  if (!executeVm) {
5989
- executeVm = chunkSRGQ72IR_cjs.createVM(chunk7ZX6B7SY_cjs.sharedOpRegistry, 200, 5e4);
6101
+ executeVm = chunkC2OMO3WN_cjs.createVM(chunkFR7RNOPT_cjs.sharedOpRegistry, 200, 5e4);
5990
6102
  }
5991
6103
  return executeVm;
5992
6104
  }
@@ -6058,7 +6170,7 @@ function executeOne(item) {
6058
6170
  const numbers = new Float64Array(item.numbersBuffer, 0, item.numbersLength);
6059
6171
  const bytecode = { opcodes, numbers, strings: item.strings };
6060
6172
  try {
6061
- const result = chunkSRGQ72IR_cjs.executeBytecode(bytecode, vmm);
6173
+ const result = chunkC2OMO3WN_cjs.executeBytecode(bytecode, vmm);
6062
6174
  if (result.type === "pending") {
6063
6175
  return {
6064
6176
  lineNumber: item.lineNumber,
@@ -6312,29 +6424,29 @@ var ExecutionPool = class {
6312
6424
  function reconstructValue(result) {
6313
6425
  switch (result.valueType) {
6314
6426
  case 0 /* Number */:
6315
- return chunk2TZKENDH_cjs.numberValue(result.value);
6427
+ return chunkIT74O4BE_cjs.numberValue(result.value);
6316
6428
  case 1 /* Hex */:
6317
- return chunk2TZKENDH_cjs.hexValue(result.value);
6429
+ return chunkIT74O4BE_cjs.hexValue(result.value);
6318
6430
  case 2 /* BigInt */:
6319
- return chunk2TZKENDH_cjs.bigIntValue(BigInt(result.value));
6431
+ return chunkIT74O4BE_cjs.bigIntValue(BigInt(result.value));
6320
6432
  case 3 /* String */:
6321
- return chunk2TZKENDH_cjs.stringValue(String(result.value));
6433
+ return chunkIT74O4BE_cjs.stringValue(String(result.value));
6322
6434
  case 4 /* Datetime */:
6323
- return chunk2TZKENDH_cjs.datetimeValue(result.value);
6435
+ return chunkIT74O4BE_cjs.datetimeValue(result.value);
6324
6436
  case 5 /* Percentage */:
6325
- return chunk2TZKENDH_cjs.percentageValue(result.value);
6437
+ return chunkIT74O4BE_cjs.percentageValue(result.value);
6326
6438
  case 6 /* Uom */:
6327
- return chunk2TZKENDH_cjs.uomValue(result.value, result.unit ?? "");
6439
+ return chunkIT74O4BE_cjs.uomValue(result.value, result.unit ?? "");
6328
6440
  case 7 /* Matrix */:
6329
- return chunk2TZKENDH_cjs.numberValue(result.value);
6441
+ return chunkIT74O4BE_cjs.numberValue(result.value);
6330
6442
  case 10 /* Boolean */:
6331
- return chunk2TZKENDH_cjs.boolValue(result.value !== 0);
6443
+ return chunkIT74O4BE_cjs.boolValue(result.value !== 0);
6332
6444
  case 12 /* Pending */:
6333
- return chunk2TZKENDH_cjs.pendingValue(result.queryKey ?? "");
6445
+ return chunkIT74O4BE_cjs.pendingValue(result.queryKey ?? "");
6334
6446
  case 13 /* Error */:
6335
- return chunk2TZKENDH_cjs.errorValue("WORKER_EXECUTION_ERROR", result.unit ?? "Unknown worker error");
6447
+ return chunkIT74O4BE_cjs.errorValue("WORKER_EXECUTION_ERROR", result.unit ?? "Unknown worker error");
6336
6448
  default:
6337
- return chunk2TZKENDH_cjs.numberValue(result.value);
6449
+ return chunkIT74O4BE_cjs.numberValue(result.value);
6338
6450
  }
6339
6451
  }
6340
6452
 
@@ -6450,7 +6562,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
6450
6562
  try {
6451
6563
  this.flush();
6452
6564
  } catch (e) {
6453
- const engineError = chunkB4HBEFTB_cjs.normalizeUnknownError(e);
6565
+ const engineError = chunkMIGXCBXT_cjs.normalizeUnknownError(e);
6454
6566
  console.error(`[AsyncResolutionBatcher] flush() failed unexpectedly \u2014 this should never happen; please report: ${engineError.format()}`);
6455
6567
  }
6456
6568
  });
@@ -6575,7 +6687,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
6575
6687
  entryMap.set(lineNumber, this.lineCache.getEntryForLine(lineNumber));
6576
6688
  }
6577
6689
  void this.reExecuteViaWorkerPool(ordered, entryMap, allQueryKeys).catch((e) => {
6578
- const engineError = chunkB4HBEFTB_cjs.normalizeUnknownError(e);
6690
+ const engineError = chunkMIGXCBXT_cjs.normalizeUnknownError(e);
6579
6691
  console.error(`[AsyncResolutionBatcher] reExecuteViaWorkerPool() failed unexpectedly: ${engineError.format()}`);
6580
6692
  });
6581
6693
  return;
@@ -6723,7 +6835,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
6723
6835
  if (!entry || entry.bytecode.opcodes.length === 0) continue;
6724
6836
  const stackBefore = this.vm.getStack().length;
6725
6837
  try {
6726
- const result = chunkSRGQ72IR_cjs.executeBytecode(entry.bytecode, this.vm);
6838
+ const result = chunkC2OMO3WN_cjs.executeBytecode(entry.bytecode, this.vm);
6727
6839
  while (this.vm.getStack().length > stackBefore) {
6728
6840
  this.vm.pop();
6729
6841
  }
@@ -6733,7 +6845,7 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
6733
6845
  this.onLineResult?.(lineNumber, result.value);
6734
6846
  updatedLineNumbers.push(lineNumber);
6735
6847
  } else if (result.type === "error") {
6736
- const value = chunk2TZKENDH_cjs.errorValue(result.error.code, result.error.message);
6848
+ const value = chunkIT74O4BE_cjs.errorValue(result.error.code, result.error.message);
6737
6849
  entry.result = value;
6738
6850
  this.warnIfUnwired();
6739
6851
  this.warnIfUnwired();
@@ -6744,8 +6856,8 @@ var _AsyncResolutionBatcher = class _AsyncResolutionBatcher {
6744
6856
  while (this.vm.getStack().length > stackBefore) {
6745
6857
  this.vm.pop();
6746
6858
  }
6747
- const engineError = chunkB4HBEFTB_cjs.normalizeUnknownError(e);
6748
- const value = chunk2TZKENDH_cjs.errorValue(engineError.code, engineError.message);
6859
+ const engineError = chunkMIGXCBXT_cjs.normalizeUnknownError(e);
6860
+ const value = chunkIT74O4BE_cjs.errorValue(engineError.code, engineError.message);
6749
6861
  entry.result = value;
6750
6862
  this.warnIfUnwired();
6751
6863
  this.onLineResult?.(lineNumber, value);
@@ -6803,5 +6915,5 @@ exports.engine_worker_default = engine_worker_default;
6803
6915
  exports.extractReadsAndWrites = extractReadsAndWrites;
6804
6916
  exports.findInlineSolvesInLine = findInlineSolvesInLine;
6805
6917
  exports.isEmptyLine = isEmptyLine;
6806
- //# sourceMappingURL=chunk-T6ZYQJ63.cjs.map
6807
- //# sourceMappingURL=chunk-T6ZYQJ63.cjs.map
6918
+ //# sourceMappingURL=chunk-BESTLPRK.cjs.map
6919
+ //# sourceMappingURL=chunk-BESTLPRK.cjs.map