solve-engine 1.0.0-beta.7 → 1.0.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 (205) hide show
  1. package/dist/{BytecodeBuilder-3egMyuDi.d.cts → BytecodeBuilder-B0xskcv5.d.cts} +2 -1
  2. package/dist/{BytecodeBuilder-3egMyuDi.d.ts → BytecodeBuilder-B0xskcv5.d.ts} +2 -1
  3. package/dist/{Configuration-fVpd-HC-.d.cts → Configuration-B-G5gTRn.d.cts} +107 -29
  4. package/dist/{Configuration-fVpd-HC-.d.ts → Configuration-B-G5gTRn.d.ts} +107 -29
  5. package/dist/{EngineError-DvPSnhZi.d.cts → EngineError-LU7W7AgI.d.cts} +96 -16
  6. package/dist/{EngineError-DvPSnhZi.d.ts → EngineError-LU7W7AgI.d.ts} +96 -16
  7. package/dist/{Lexer-W9MBOP0V.d.ts → Lexer-BN5mt30n.d.ts} +16 -0
  8. package/dist/{Lexer-Cfm79Dak.d.cts → Lexer-D78E2yDW.d.cts} +16 -0
  9. package/dist/{PackageRegistry-CjDt-Jy_.d.ts → PackageRegistry-DFeINv2O.d.ts} +54 -13
  10. package/dist/{PackageRegistry-pHtKythi.d.cts → PackageRegistry-u2zdfFaj.d.cts} +54 -13
  11. package/dist/{Parselet-DEdF9I7n.d.ts → Parselet-BaySkMV3.d.ts} +37 -5
  12. package/dist/{Parselet-Cu0bLSis.d.cts → Parselet-DuI1Pjiq.d.cts} +37 -5
  13. package/dist/{ScopeManager-CKfQtl7l.d.cts → ScopeManager-B6GzdhVG.d.cts} +75 -6
  14. package/dist/{ScopeManager-B5k0nk05.d.ts → ScopeManager-udv4Twwq.d.ts} +75 -6
  15. package/dist/{VMCheckpoints-BmDwIXgK.d.ts → VMCheckpoints-BiaIlOOY.d.ts} +4 -4
  16. package/dist/{VMCheckpoints-CqFuLwrT.d.cts → VMCheckpoints-DwLjivM7.d.cts} +4 -4
  17. package/dist/{Value-KtAQNHur.d.cts → Value-CXJqDH9J.d.cts} +5 -2
  18. package/dist/{Value-KtAQNHur.d.ts → Value-CXJqDH9J.d.ts} +5 -2
  19. package/dist/{chunk-CSG5XVNJ.cjs → chunk-3AFRJYP4.cjs} +556 -414
  20. package/dist/chunk-3AFRJYP4.cjs.map +1 -0
  21. package/dist/chunk-3BOK2LDK.js +17 -0
  22. package/dist/chunk-3BOK2LDK.js.map +1 -0
  23. package/dist/{chunk-6RDSQURE.js → chunk-3D7V24DG.js} +57 -6
  24. package/dist/chunk-3D7V24DG.js.map +1 -0
  25. package/dist/{chunk-MEOHSQEH.js → chunk-3LAEG75D.js} +47 -15
  26. package/dist/chunk-3LAEG75D.js.map +1 -0
  27. package/dist/{chunk-P75775WC.js → chunk-3VNGREMU.js} +118 -41
  28. package/dist/chunk-3VNGREMU.js.map +1 -0
  29. package/dist/{chunk-4AVD7NZW.cjs → chunk-4B2CNWQU.cjs} +13 -7
  30. package/dist/chunk-4B2CNWQU.cjs.map +1 -0
  31. package/dist/{chunk-6GCKCWLB.js → chunk-526PMQOA.js} +126 -69
  32. package/dist/chunk-526PMQOA.js.map +1 -0
  33. package/dist/{chunk-2CS6OMZK.js → chunk-5F4C26RU.js} +8 -5
  34. package/dist/chunk-5F4C26RU.js.map +1 -0
  35. package/dist/{chunk-M4N5GA5Z.cjs → chunk-5KMIY374.cjs} +57 -6
  36. package/dist/chunk-5KMIY374.cjs.map +1 -0
  37. package/dist/{chunk-R24DI24X.cjs → chunk-5LI5EPGJ.cjs} +6 -5
  38. package/dist/chunk-5LI5EPGJ.cjs.map +1 -0
  39. package/dist/{chunk-BAMZT3GL.js → chunk-5WVP4YHP.js} +939 -134
  40. package/dist/chunk-5WVP4YHP.js.map +1 -0
  41. package/dist/{chunk-MZOVP3WI.cjs → chunk-6KFYJ6TD.cjs} +3 -2
  42. package/dist/chunk-6KFYJ6TD.cjs.map +1 -0
  43. package/dist/{chunk-BXKJLM5R.cjs → chunk-6WFMPTGB.cjs} +972 -636
  44. package/dist/chunk-6WFMPTGB.cjs.map +1 -0
  45. package/dist/{chunk-2MV4HBKC.cjs → chunk-A2N2GFCG.cjs} +10 -10
  46. package/dist/{chunk-2MV4HBKC.cjs.map → chunk-A2N2GFCG.cjs.map} +1 -1
  47. package/dist/chunk-ADBA3XBE.cjs +20 -0
  48. package/dist/chunk-ADBA3XBE.cjs.map +1 -0
  49. package/dist/{chunk-MBNQVDVC.cjs → chunk-AMOJYLG2.cjs} +16 -10
  50. package/dist/chunk-AMOJYLG2.cjs.map +1 -0
  51. package/dist/{chunk-CLVQBF5C.cjs → chunk-AQNHHJMJ.cjs} +5 -5
  52. package/dist/{chunk-CLVQBF5C.cjs.map → chunk-AQNHHJMJ.cjs.map} +1 -1
  53. package/dist/{chunk-AHCLWAM5.cjs → chunk-BHTNFEGZ.cjs} +13 -13
  54. package/dist/chunk-BHTNFEGZ.cjs.map +1 -0
  55. package/dist/{chunk-35IWNZPJ.cjs → chunk-E4NUZXVK.cjs} +58 -27
  56. package/dist/chunk-E4NUZXVK.cjs.map +1 -0
  57. package/dist/{chunk-P33SBYGG.js → chunk-GLG5ZMX7.js} +54 -23
  58. package/dist/chunk-GLG5ZMX7.js.map +1 -0
  59. package/dist/{chunk-BVAR5J2F.js → chunk-GQCOSXMG.js} +117 -6
  60. package/dist/chunk-GQCOSXMG.js.map +1 -0
  61. package/dist/{chunk-QDMPOAI7.cjs → chunk-HDP7VK3C.cjs} +1118 -313
  62. package/dist/chunk-HDP7VK3C.cjs.map +1 -0
  63. package/dist/{chunk-GVWHCL2N.js → chunk-HMOISHXR.js} +217 -75
  64. package/dist/chunk-HMOISHXR.js.map +1 -0
  65. package/dist/{chunk-MTX2KVU7.cjs → chunk-HVQFNJKE.cjs} +122 -90
  66. package/dist/chunk-HVQFNJKE.cjs.map +1 -0
  67. package/dist/{chunk-OC6LTXYS.cjs → chunk-JMXUNXQS.cjs} +126 -7
  68. package/dist/chunk-JMXUNXQS.cjs.map +1 -0
  69. package/dist/{chunk-WWOLFXTX.cjs → chunk-KBSXGXPM.cjs} +10 -7
  70. package/dist/chunk-KBSXGXPM.cjs.map +1 -0
  71. package/dist/{chunk-YU2CUNFO.js → chunk-KV7UW6T6.js} +11 -5
  72. package/dist/chunk-KV7UW6T6.js.map +1 -0
  73. package/dist/{chunk-CCJPSHGI.cjs → chunk-N7FNVFXW.cjs} +4 -12
  74. package/dist/chunk-N7FNVFXW.cjs.map +1 -0
  75. package/dist/{chunk-CYFK5SY2.js → chunk-O3ANBHSA.js} +169 -39
  76. package/dist/chunk-O3ANBHSA.js.map +1 -0
  77. package/dist/{chunk-NZFKROS7.cjs → chunk-PA4VC73I.cjs} +130 -72
  78. package/dist/chunk-PA4VC73I.cjs.map +1 -0
  79. package/dist/{chunk-NJTXJ5AG.cjs → chunk-PFUESQTW.cjs} +18 -18
  80. package/dist/{chunk-NJTXJ5AG.cjs.map → chunk-PFUESQTW.cjs.map} +1 -1
  81. package/dist/{chunk-SFQWJMKT.js → chunk-QY25VWBF.js} +51 -12
  82. package/dist/chunk-QY25VWBF.js.map +1 -0
  83. package/dist/{chunk-WC5FFSHB.js → chunk-R3PY4G7J.js} +3 -3
  84. package/dist/{chunk-WC5FFSHB.js.map → chunk-R3PY4G7J.js.map} +1 -1
  85. package/dist/{chunk-M5E34VG5.js → chunk-SBUFNJVE.js} +3 -3
  86. package/dist/{chunk-M5E34VG5.js.map → chunk-SBUFNJVE.js.map} +1 -1
  87. package/dist/{chunk-UKPGSAZW.js → chunk-TMA4RCEN.js} +3 -3
  88. package/dist/{chunk-UKPGSAZW.js.map → chunk-TMA4RCEN.js.map} +1 -1
  89. package/dist/{chunk-V6HA6JJZ.cjs → chunk-U5VAY32K.cjs} +215 -138
  90. package/dist/chunk-U5VAY32K.cjs.map +1 -0
  91. package/dist/{chunk-DUEZFTK2.js → chunk-UKQHXPGW.js} +4 -12
  92. package/dist/chunk-UKQHXPGW.js.map +1 -0
  93. package/dist/{chunk-4CVLFLOB.cjs → chunk-UM6BVY2S.cjs} +201 -69
  94. package/dist/chunk-UM6BVY2S.cjs.map +1 -0
  95. package/dist/{chunk-75JP4BZX.js → chunk-UQ3UIZJC.js} +3 -2
  96. package/dist/chunk-UQ3UIZJC.js.map +1 -0
  97. package/dist/{chunk-PCPX42KL.js → chunk-V4XG5QF6.js} +16 -10
  98. package/dist/chunk-V4XG5QF6.js.map +1 -0
  99. package/dist/{chunk-GPPLSM2Z.js → chunk-VB37OC6I.js} +6 -5
  100. package/dist/chunk-VB37OC6I.js.map +1 -0
  101. package/dist/{chunk-MVBEL57Q.js → chunk-Y7FT4IQT.js} +500 -170
  102. package/dist/chunk-Y7FT4IQT.js.map +1 -0
  103. package/dist/{chunk-OFXOTECC.js → chunk-YPPPYLSR.js} +7 -7
  104. package/dist/chunk-YPPPYLSR.js.map +1 -0
  105. package/dist/{chunk-M4F66R4O.cjs → chunk-YWQ6V4ZN.cjs} +121 -82
  106. package/dist/chunk-YWQ6V4ZN.cjs.map +1 -0
  107. package/dist/constants.cjs +5 -5
  108. package/dist/constants.d.cts +1 -1
  109. package/dist/constants.d.ts +1 -1
  110. package/dist/constants.js +2 -2
  111. package/dist/engine.cjs +31 -31
  112. package/dist/engine.d.cts +11 -11
  113. package/dist/engine.d.ts +11 -11
  114. package/dist/engine.js +21 -21
  115. package/dist/errors.cjs +19 -19
  116. package/dist/errors.d.cts +2 -2
  117. package/dist/errors.d.ts +2 -2
  118. package/dist/errors.js +1 -1
  119. package/dist/format.cjs +29 -22
  120. package/dist/format.cjs.map +1 -1
  121. package/dist/format.d.cts +1 -2
  122. package/dist/format.d.ts +1 -2
  123. package/dist/format.js +23 -16
  124. package/dist/format.js.map +1 -1
  125. package/dist/index.cjs +31 -31
  126. package/dist/index.d.cts +10 -10
  127. package/dist/index.d.ts +10 -10
  128. package/dist/index.js +22 -22
  129. package/dist/language.cjs +8 -8
  130. package/dist/language.cjs.map +1 -1
  131. package/dist/language.d.cts +10 -10
  132. package/dist/language.d.ts +10 -10
  133. package/dist/language.js +6 -6
  134. package/dist/language.js.map +1 -1
  135. package/dist/lexer.cjs +18 -18
  136. package/dist/lexer.d.cts +2 -2
  137. package/dist/lexer.d.ts +2 -2
  138. package/dist/lexer.js +6 -6
  139. package/dist/normalizer.cjs +12 -12
  140. package/dist/normalizer.js +6 -6
  141. package/dist/packages.cjs +39 -39
  142. package/dist/packages.d.cts +9 -9
  143. package/dist/packages.d.ts +9 -9
  144. package/dist/packages.js +16 -16
  145. package/dist/parser.cjs +15 -15
  146. package/dist/parser.d.cts +23 -9
  147. package/dist/parser.d.ts +23 -9
  148. package/dist/parser.js +5 -5
  149. package/dist/{pipeline-CrsRPmsv.d.ts → pipeline-B6k5lCB7.d.ts} +1 -1
  150. package/dist/{pipeline-DPUQt7yL.d.cts → pipeline-BEb3hujr.d.cts} +1 -1
  151. package/dist/resolvers.d.cts +2 -2
  152. package/dist/resolvers.d.ts +2 -2
  153. package/dist/uom.cjs +17 -17
  154. package/dist/uom.d.cts +2 -2
  155. package/dist/uom.d.ts +2 -2
  156. package/dist/uom.js +7 -7
  157. package/dist/utilities.cjs +8 -4
  158. package/dist/utilities.d.cts +19 -3
  159. package/dist/utilities.d.ts +19 -3
  160. package/dist/utilities.js +2 -2
  161. package/dist/vm.cjs +43 -31
  162. package/dist/vm.d.cts +105 -9
  163. package/dist/vm.d.ts +105 -9
  164. package/dist/vm.js +9 -9
  165. package/package.json +1 -1
  166. package/dist/chunk-2CS6OMZK.js.map +0 -1
  167. package/dist/chunk-35IWNZPJ.cjs.map +0 -1
  168. package/dist/chunk-4AVD7NZW.cjs.map +0 -1
  169. package/dist/chunk-4CVLFLOB.cjs.map +0 -1
  170. package/dist/chunk-6GCKCWLB.js.map +0 -1
  171. package/dist/chunk-6RDSQURE.js.map +0 -1
  172. package/dist/chunk-75JP4BZX.js.map +0 -1
  173. package/dist/chunk-AHCLWAM5.cjs.map +0 -1
  174. package/dist/chunk-BAMZT3GL.js.map +0 -1
  175. package/dist/chunk-BVAR5J2F.js.map +0 -1
  176. package/dist/chunk-BXKJLM5R.cjs.map +0 -1
  177. package/dist/chunk-CCJPSHGI.cjs.map +0 -1
  178. package/dist/chunk-CSG5XVNJ.cjs.map +0 -1
  179. package/dist/chunk-CYFK5SY2.js.map +0 -1
  180. package/dist/chunk-DUEZFTK2.js.map +0 -1
  181. package/dist/chunk-GPPLSM2Z.js.map +0 -1
  182. package/dist/chunk-GVWHCL2N.js.map +0 -1
  183. package/dist/chunk-M4F66R4O.cjs.map +0 -1
  184. package/dist/chunk-M4N5GA5Z.cjs.map +0 -1
  185. package/dist/chunk-MBNQVDVC.cjs.map +0 -1
  186. package/dist/chunk-MEOHSQEH.js.map +0 -1
  187. package/dist/chunk-MTX2KVU7.cjs.map +0 -1
  188. package/dist/chunk-MVBEL57Q.js.map +0 -1
  189. package/dist/chunk-MZOVP3WI.cjs.map +0 -1
  190. package/dist/chunk-N5YFR4UP.cjs +0 -10
  191. package/dist/chunk-N5YFR4UP.cjs.map +0 -1
  192. package/dist/chunk-NZFKROS7.cjs.map +0 -1
  193. package/dist/chunk-OC6LTXYS.cjs.map +0 -1
  194. package/dist/chunk-OFXOTECC.js.map +0 -1
  195. package/dist/chunk-P33SBYGG.js.map +0 -1
  196. package/dist/chunk-P75775WC.js.map +0 -1
  197. package/dist/chunk-PCPX42KL.js.map +0 -1
  198. package/dist/chunk-PFSDGGYL.js +0 -8
  199. package/dist/chunk-PFSDGGYL.js.map +0 -1
  200. package/dist/chunk-QDMPOAI7.cjs.map +0 -1
  201. package/dist/chunk-R24DI24X.cjs.map +0 -1
  202. package/dist/chunk-SFQWJMKT.js.map +0 -1
  203. package/dist/chunk-V6HA6JJZ.cjs.map +0 -1
  204. package/dist/chunk-WWOLFXTX.cjs.map +0 -1
  205. package/dist/chunk-YU2CUNFO.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { registerAllTokenTypes, tokenTypeId } from './chunk-GPPLSM2Z.js';
1
+ import { registerAllTokenTypes, tokenTypeId } from './chunk-VB37OC6I.js';
2
2
  import { getLocale } from './chunk-XBTEO4OB.js';
3
- import { knownUnits } from './chunk-M5E34VG5.js';
4
- import { ErrorFactory } from './chunk-6RDSQURE.js';
3
+ import { knownUnits } from './chunk-SBUFNJVE.js';
4
+ import { ErrorFactory } from './chunk-3D7V24DG.js';
5
5
 
6
6
  // src/lexer/ExpressionLexer.ts
7
7
  registerAllTokenTypes();
@@ -46,6 +46,19 @@ function buildCharClassTable() {
46
46
  table[96] = 11 /* BACKTICK */;
47
47
  return table;
48
48
  }
49
+ function isUnicodeSpace(cc) {
50
+ return cc === 133 || // NEL, next line
51
+ cc === 160 || // no-break space
52
+ cc === 5760 || // ogham space mark
53
+ cc >= 8192 && cc <= 8202 || // en quad through hair space, incl. figure/thin space
54
+ cc === 8203 || // zero-width space
55
+ cc === 8232 || // line separator
56
+ cc === 8233 || // paragraph separator
57
+ cc === 8239 || // narrow no-break space
58
+ cc === 8287 || // medium mathematical space
59
+ cc === 12288 || // ideographic space
60
+ cc === 65279;
61
+ }
49
62
  var LexerToken = class {
50
63
  constructor(type, typeId, value, text, offset, lineBreaks, line, col, sourceEnd) {
51
64
  this.type = type;
@@ -571,7 +584,7 @@ var _ExpressionLexer = class _ExpressionLexer {
571
584
  tokenIndex++;
572
585
  break;
573
586
  default: {
574
- if (c0 === 215) {
587
+ if (isUnicodeSpace(c0)) ; else if (c0 === 215) {
575
588
  yield new LexerToken("STAR", tokenTypeId("STAR"), "\xD7", "\xD7", 0, 0, 1, 1);
576
589
  tokenIndex++;
577
590
  } else if (c0 === 247) {
@@ -728,7 +741,13 @@ var _ExpressionLexer = class _ExpressionLexer {
728
741
  // ── Non-ASCII characters ─────────────────────────────────────
729
742
  default: {
730
743
  const col = this.pos - this.lineStartPos + 1;
731
- if (c0 === 215) {
744
+ if (isUnicodeSpace(c0)) {
745
+ this.pos++;
746
+ if (c0 === 8232 || c0 === 8233 || c0 === 133) {
747
+ this.line++;
748
+ this.lineStartPos = this.pos;
749
+ }
750
+ } else if (c0 === 215) {
732
751
  yield new LexerToken("STAR", tokenTypeId("STAR"), "\xD7", "\xD7", this.pos, 0, this.line, col);
733
752
  this.pos++;
734
753
  tokenIndex++;
@@ -930,7 +949,7 @@ var _ExpressionLexer = class _ExpressionLexer {
930
949
  cc >= 65 && cc <= 90 || // A-Z
931
950
  cc >= 97 && cc <= 122 || // a-z
932
951
  cc === 95 || // _
933
- cc >= 128)) {
952
+ cc >= 128 && !isUnicodeSpace(cc))) {
934
953
  pos++;
935
954
  }
936
955
  const identText = input.slice(start, pos);
@@ -1037,6 +1056,22 @@ var _ExpressionLexer = class _ExpressionLexer {
1037
1056
  // ── String literal tokenizer ──────────────────────────────────────────
1038
1057
  /**
1039
1058
  * Reads a double-quoted string literal. Supports backslash escapes.
1059
+ *
1060
+ * `text` is the raw source slice, quotes included, because that is what
1061
+ * `offset` + `text.length` has to span for a host to underline the literal.
1062
+ * `value` is the PAYLOAD, quotes excluded, because that is what
1063
+ * `PUSH_STRING` puts into the Value.
1064
+ *
1065
+ * The two used to be the same string. `"abc"` carried the five characters
1066
+ * `"abc"` as its value, which was invisible on screen (the formatter prints
1067
+ * the payload raw and the retained quotes landed where a display would have
1068
+ * put them back) and not invisible anywhere else: `parseFloat('"5"')` is NaN
1069
+ * whatever the digits say, so `"5" + 5` answered 5.
1070
+ *
1071
+ * An unterminated literal is an error rather than a string that happens to
1072
+ * reach the end of the line. It used to return what it had, so `"abc` and
1073
+ * `"abc"` were indistinguishable by payload once the quotes were stripped,
1074
+ * which is the other half of why they are stripped here rather than later.
1040
1075
  */
1041
1076
  tokenizeString() {
1042
1077
  const input = this.input;
@@ -1049,9 +1084,10 @@ var _ExpressionLexer = class _ExpressionLexer {
1049
1084
  const c0 = input.charCodeAt(pos);
1050
1085
  if (c0 === 34) {
1051
1086
  pos++;
1052
- const text2 = input.slice(start, pos);
1087
+ const text = input.slice(start, pos);
1088
+ const value = input.slice(start + 1, pos - 1);
1053
1089
  this.pos = pos;
1054
- return new LexerToken("STRING", tokenTypeId("STRING"), text2, text2, start, lineBreaks, this.line, startCol);
1090
+ return new LexerToken("STRING", tokenTypeId("STRING"), value, text, start, lineBreaks, this.line, startCol);
1055
1091
  }
1056
1092
  if (c0 === 92 && pos + 1 < len) {
1057
1093
  pos += 2;
@@ -1064,9 +1100,12 @@ var _ExpressionLexer = class _ExpressionLexer {
1064
1100
  }
1065
1101
  pos++;
1066
1102
  }
1067
- const text = input.slice(start, pos);
1068
1103
  this.pos = pos;
1069
- return new LexerToken("STRING", tokenTypeId("STRING"), text, text, start, lineBreaks, this.line, startCol);
1104
+ throw ErrorFactory.parsing(
1105
+ "UNTERMINATED_STRING",
1106
+ `Unterminated string literal: ${input.slice(start, pos)}`,
1107
+ { literal: input.slice(start, pos), offset: start }
1108
+ );
1070
1109
  }
1071
1110
  // ── Markdown line scanner (Phase B) ───────────────────────────────────
1072
1111
  /**
@@ -1321,5 +1360,5 @@ _ExpressionLexer.CHAR_CLASS = buildCharClassTable();
1321
1360
  var ExpressionLexer = _ExpressionLexer;
1322
1361
 
1323
1362
  export { ExpressionLexer, LexerToken };
1324
- //# sourceMappingURL=chunk-SFQWJMKT.js.map
1325
- //# sourceMappingURL=chunk-SFQWJMKT.js.map
1363
+ //# sourceMappingURL=chunk-QY25VWBF.js.map
1364
+ //# sourceMappingURL=chunk-QY25VWBF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lexer/ExpressionLexer.ts"],"names":["input","text"],"mappings":";;;;;;AAOA,qBAAA,EAAsB;AA8FtB,SAAS,mBAAA,GAAkC;AACzC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,GAAG,CAAA;AAGhC,EAAA,KAAA,IAAS,IAAI,EAAA,EAAI,CAAA,IAAK,IAAI,CAAA,EAAA,EAAK,KAAA,CAAM,CAAC,CAAA,GAAI,CAAA;AAG1C,EAAA,KAAA,IAAS,IAAI,EAAA,EAAI,CAAA,IAAK,IAAI,CAAA,EAAA,EAAK,KAAA,CAAM,CAAC,CAAA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,IAAM,EAAA,KAAO,EAAA,EAAI;AAC5B,MAAA,GAAA,EAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,CAAM,KAAA,EAAO,GAAG,CAAA;AACnC,IAAA,IAAA,CAAK,GAAA,GAAM,GAAA;AACX,IAAA,OAAO,IAAI,UAAA,CAAW,SAAA,EAAW,WAAA,CAAY,SAAS,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,QAAQ,CAAA;AAAA,EACpG;AACF,CAAA;AA77Ca,gBAAA,CACa,aAAa,mBAAA,EAAoB;AADpD,IAAM,eAAA,GAAN","file":"chunk-QY25VWBF.js","sourcesContent":["import { Token, tokenTypeId, registerAllTokenTypes } from '@solve-js/lexer/Token';\nimport { knownUnits } from '@solve-js/lexer/units';\nimport { getLocale, type ILocale } from '@solve-js/constants/locales';\nimport { ErrorFactory } from '@solve-js/errors/UnifiedErrorFramework';\nimport type { TokenLookup } from '@solve-js/lexer/TokenClassRegistry';\n\n// Bootstrap all token types at module load\nregisterAllTokenTypes();\n\n// ── Markdown line classification (Phase B) ──────────────────────────────\n\n/** What a line is, structurally, before anything tries to evaluate it. */\nexport type MarkdownLineType =\n | 'expression'\n | 'prose'\n | 'heading'\n | 'blockquote'\n | 'list'\n | 'code_fence'\n | 'math_fence'\n | 'table'\n | 'table_separator'\n | 'hr'\n | 'wikilink'\n | 'comment'\n | 'empty';\n\n/**\n * What a line is and whether it holds anything to evaluate.\n *\n * Produced by a character-level scan that never consults the keyword, unit or\n * operator tables, so any lexer gives the same answer for the same line. See\n * `__tests__/lexer/LineClassificationIsVocabularyIndependent.spec.ts`.\n */\nexport interface LineClassification {\n /** The type of this markdown line */\n type: MarkdownLineType;\n /** Whether this line should be skipped (no expression evaluation) */\n skip: boolean;\n /** Whether the line contains inline solve markers (`s`...``) */\n hasInlineSolve: boolean;\n}\n\n/** Inline solve position with precise coordinates */\nexport interface InlineSolveSpan {\n /** Character offset of the `s`` marker */\n start: number;\n /** Character offset past the closing `` ` `` */\n end: number;\n /** The expression text between the backticks */\n expression: string;\n /** 1-based column of the `s`` marker */\n columnNumber: number;\n /** Token index of INLINE_SOLVE_START in the line's token array (set during tokenization). */\n startTokenIndex?: number;\n /** Token index of closing BACKTICK_OPEN in the line's token array (set during tokenization). */\n endTokenIndex?: number;\n}\n\n/**\n * Result from a single line processed by scanDocument().\n * Combines line classification, tokenized tokens, and inline solve spans\n * into a single structure, eliminating the need for separate classifyLine()\n * findInlineSolves(), and per-line Lexer.reset() calls.\n */\nexport interface ScanLineResult {\n /** The raw line text (without trailing newline). */\n text: string;\n /** 1-based line number within the document. */\n lineNumber: number;\n /** Character offset of the line start within the document. */\n startOffset: number;\n /** Character offset of the line end (before newline). */\n endOffset: number;\n /** The line classification. */\n classification: LineClassification;\n /** Tokenized tokens (empty array if line is skipped). */\n tokens: Token[];\n /** Inline solve spans found in this line (empty if none). */\n inlineSolves: InlineSolveSpan[];\n}\n\n// ── Character class constants ─────────────────────────────────────────────\n// Used as the result of the CHAR_CLASS lookup table. V8 compiles the\n// outer switch on these small integer constants into a jump table.\nconst enum CharClass {\n SKIP = 0, // Invalid / control / unicode fallback\n WHITESPACE = 1, // space, tab, \\n, \\r\n DIGIT = 2, // 0-9\n ALPHA = 3, // a-z, A-Z, _\n DOT = 4, // . (could be decimal point or DOT token)\n OPERATOR = 5, // + - * / ^ % ( ) [ ] { } , : ; = ? & | ~ ! < >\n QUOTE = 6, // \"\n HASH = 7, // # (comment)\n DOLLAR = 8, // $\n POUND = 9, // £ (U+00A3)\n EURO = 10, // € (U+20AC)\n BACKTICK = 11, // `\n}\n\n// ── Static character class table (built once at module load) ──────────────\nfunction buildCharClassTable(): Uint8Array {\n const table = new Uint8Array(128);\n\n // Digits 0-9\n for (let i = 48; i <= 57; i++) table[i] = CharClass.DIGIT;\n\n // Uppercase A-Z\n for (let i = 65; i <= 90; i++) table[i] = CharClass.ALPHA;\n\n // Lowercase a-z\n for (let i = 97; i <= 122; i++) table[i] = CharClass.ALPHA;\n\n // Underscore\n table[95] = CharClass.ALPHA;\n\n // Dot\n table[46] = CharClass.DOT;\n\n // Whitespace\n table[32] = CharClass.WHITESPACE; // space\n table[9] = CharClass.WHITESPACE; // tab\n table[10] = CharClass.WHITESPACE; // \\n\n table[13] = CharClass.WHITESPACE; // \\r\n\n // Operators / punctuation\n table[33] = CharClass.OPERATOR; // !\n table[37] = CharClass.OPERATOR; // %\n table[38] = CharClass.OPERATOR; // &\n table[40] = CharClass.OPERATOR; // (\n table[41] = CharClass.OPERATOR; // )\n table[42] = CharClass.OPERATOR; // *\n table[43] = CharClass.OPERATOR; // +\n table[44] = CharClass.OPERATOR; // ,\n table[45] = CharClass.OPERATOR; // -\n table[47] = CharClass.OPERATOR; // /\n table[58] = CharClass.OPERATOR; // :\n table[59] = CharClass.OPERATOR; // ;\n table[60] = CharClass.OPERATOR; // <\n table[61] = CharClass.OPERATOR; // =\n table[62] = CharClass.OPERATOR; // >\n table[63] = CharClass.OPERATOR; // ?\n table[91] = CharClass.OPERATOR; // [\n table[93] = CharClass.OPERATOR; // ]\n table[94] = CharClass.OPERATOR; // ^\n table[123] = CharClass.OPERATOR; // {\n table[124] = CharClass.OPERATOR; // |\n table[125] = CharClass.OPERATOR; // }\n table[126] = CharClass.OPERATOR; // ~\n // \"@\" was previously unclassified (defaulted to CharClass.SKIP, silently\n // dropped before ever reaching OP_MAP). See OP_MAP's own \"@\" entry doc\n // comment for why this is being activated now.\n table[64] = CharClass.OPERATOR; // @\n\n // Other\n table[34] = CharClass.QUOTE; // \"\n table[35] = CharClass.HASH; // #\n table[36] = CharClass.DOLLAR; // $\n table[96] = CharClass.BACKTICK; // `\n\n return table;\n}\n\n/**\n * Whether a non-ASCII code point separates tokens rather than joining them.\n *\n * The CHAR_CLASS table above is 128 entries wide, so every code point past\n * ASCII falls through to one branch that reads it as part of an identifier.\n * That is right for `café`, `日本語` and emoji, and wrong for the dozen or so\n * code points that are whitespace without being ASCII whitespace. Without this,\n * a no-break space between two operands JOINED them: `1<NBSP>+<NBSP>1` lexed as\n * one identifier and reported \"Undefined variable: 1 + 1\", and a byte-order\n * mark at the head of a file did the same to its first line. Both arrive\n * constantly in pasted text, from a web page, a word processor, a spreadsheet\n * export, or a Windows editor that writes a BOM.\n *\n * The zero-width JOINERS are deliberately absent. U+200D is what holds a family\n * emoji together as one grapheme, and U+200C is its non-joining partner; both\n * bind their neighbours rather than separating them, so they stay identifier\n * characters. U+200B, the zero-width SPACE, is a separator despite being\n * invisible, which is exactly why it is worth handling: it is unreadable on\n * screen and would otherwise silently break the line it lands in.\n *\n * @param cc - A UTF-16 code unit, only meaningful for values >= 128.\n * @returns True when the character should be skipped like a space.\n */\nfunction isUnicodeSpace(cc: number): boolean {\n return (\n cc === 0x0085 || // NEL, next line\n cc === 0x00A0 || // no-break space\n cc === 0x1680 || // ogham space mark\n (cc >= 0x2000 && cc <= 0x200A) || // en quad through hair space, incl. figure/thin space\n cc === 0x200B || // zero-width space\n cc === 0x2028 || // line separator\n cc === 0x2029 || // paragraph separator\n cc === 0x202F || // narrow no-break space\n cc === 0x205F || // medium mathematical space\n cc === 0x3000 || // ideographic space\n cc === 0xFEFF // byte-order mark / zero-width no-break space\n );\n}\n\n// ── Monomorphic Token class ───────────────────────────────────────────────\n// V8 assigns a single stable HiddenClass because all properties are\n// initialized in the constructor and never added/removed afterwards.\n// This enables fast property access (inline cache hits) and allows\n// allocation in V8's nursery (cheap GC).\n// All 9 fields are always set, no optional fields, no different shapes.\n/**\n * A token, as the lexer produces it.\n *\n * A class rather than an object literal because tokens are created on every\n * keystroke and a shared hidden class keeps that path predictable for the\n * engine running it.\n */\nexport class LexerToken implements Token {\n constructor(\n public type: string,\n public typeId: number,\n public value: string,\n public text: string,\n public offset: number,\n public lineBreaks: number,\n public line: number,\n public col: number,\n /** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */\n public sourceEnd?: number,\n ) {}\n}\n\n// ── Two-character operator lookup ─────────────────────────────────────────\n// Maps first-char → (second-char → token type). Used for operators like\n// ==, !=, >=, <=, **, <<, >>.\ninterface TwoCharOpMap {\n [firstChar: number]: { [secondChar: number]: string };\n}\nconst TWO_CHAR_OPS: TwoCharOpMap = {\n 61: { 61: 'EQUALITY', 62: 'THEREFORE' }, // ==, => (opposite char order from >='s GTE below — no collision)\n 33: { 61: 'NEQ' }, // !=\n 62: { 61: 'GTE' }, // >=\n 60: { 61: 'LTE' }, // <=\n 38: { 38: 'LOGICAL_AND' }, // &&\n 124: { 124: 'LOGICAL_OR' }, // ||\n // Note: ** is NOT a single token, the existing moo lexer emits two\n // separate STAR tokens, and the parser consumes them that way.\n // 42: { 42: 'EXPONENT' }, // **, disabled for moo compatibility\n};\n// Note: LSHIFT (<<) and RSHIFT (>>) are handled separately because\n// 60 is also used for LTE, so we check LTE first then LSHIFT.\n\n// ── Single-character operator lookup ──────────────────────────────────────\nconst OP_MAP: Record<number, string> = {\n 43: 'PLUS', // +\n 45: 'MINUS', // -\n 42: 'STAR', // *\n 47: 'SLASH', // /\n 94: 'CARET', // ^\n 37: 'PERCENT', // %\n 40: 'LPAREN', // (\n 41: 'RPAREN', // )\n 91: 'LBRACKET', // [\n 93: 'RBRACKET', // ]\n 123: 'LBRACE', // {\n 125: 'RBRACE', // }\n 44: 'COMMA', // ,\n 58: 'COLON', // :\n 59: 'SEMICOLON',// ;\n 61: 'EQUALS', // =\n 63: 'QUESTION', // ?\n 33: 'BANG', // !\n 38: 'BIT_AND', // &\n 124: 'BIT_OR', // |\n 60: 'LT', // <\n 62: 'GT', // >\n 126: 'BIT_NOT', // ~\n // \"@\", activates the token type name already dormant-reserved for this\n // exact purpose (see Token.ts's OVER/RATE_AT doc comment and\n // normalizer/TokenNormalizer.ts's NON_WORD_NAMES, both of which already\n // anticipated \"AT\" as a future \"@\" symbol token before this addition).\n // Backs the time package's video-timecode literal's alternate fps\n // separator (`01:02:03:04 @ 30fps`, equivalent to `... at 30fps`). See\n // packages/time/parselets/VideoTimecodeParselet.ts.\n 64: 'AT', // @\n};\n\n/**\n * Plugin interface for extending the ExpressionLexer with custom tokens.\n *\n * Plugins can register:\n * - `keywords`: Map identifier strings to custom token types (checked after locale keywords).\n * - `operators`: Map multi-character operator sequences to custom token types.\n * - `units`: Register additional unit identifiers (checked alongside built-in units).\n *\n * Multi-word phrase matching has been moved to the TokenNormalizer post-lexer\n * stage. To register phrase patterns, use `IEnginePackage.normalizerRules` instead.\n *\n * All registrations are additive, built-in patterns still work.\n */\nexport interface LexerVocabulary {\n /**\n * Keyword → tokenType mappings. Each key is a lowercase identifier that,\n * when encountered, will emit the specified token type instead of IDENT.\n * These are checked AFTER the locale's built-in keywordMap, so locale\n * keywords take priority.\n */\n keywords?: Record<string, string>;\n\n /**\n * Multi-character operator → tokenType mappings. Each key is the exact\n * character sequence (e.g., \"::\", \"->\", \"=>\") and the value is the token\n * type to emit. Two-character operators take priority during matching.\n * Built-in operators (==, !=, >=, <=, <<, >>) always take priority.\n */\n operators?: Record<string, string>;\n\n /**\n * Additional unit identifiers to recognize (e.g., \"gp\", \"osrs\", \"tile\").\n * These are checked alongside the built-in `knownUnits` set.\n */\n units?: string[];\n\n /**\n * Whole-line patterns matched against the RAW line text, BEFORE any\n * per-character tokenization begins.\n *\n * Every other extension point in this file (`keywords`/`operators`/\n * `units`, plus `IEnginePackage.phrases`/`normalizerRules`) transforms\n * a token STREAM -- they all assume the line is, at some granularity,\n * valid Solve syntax. This hook exists for the one shape that isn't:\n * a package whose grammar captures arbitrary free-form text terminated\n * by a fixed marker (e.g. a natural-language query ending in `= ?`),\n * where the text itself (\"distance to the moon\") would never tokenize\n * or parse as a normal expression and must be captured verbatim\n * instead -- see `packages/knowledge/` for the reference use.\n *\n * Each entry's `pattern` is tested (via `RegExp.exec`) against the\n * full, untrimmed line text. If it matches AND capture group 1 is\n * non-empty after trimming, the ENTIRE line becomes a single\n * synthetic token of `tokenType` whose `value`/`text` is the trimmed\n * capture group -- the character-by-character scanner never runs for\n * that line. Patterns are tried in registration order; the first\n * match wins. A package registering a rule here still needs a\n * `prefixParselets` entry for `tokenType` to actually consume the\n * resulting token.\n *\n * Because this bypasses tokenization entirely, a matching line can\n * contain characters that would otherwise be lexer errors (unmatched\n * quotes, stray symbols, ...) -- by design, since the whole point is\n * to hand the package raw text the normal pipeline was never meant to\n * parse.\n */\n rawLinePatterns?: Array<{ pattern: RegExp; tokenType: string }>;\n}\n\n// ── Expression gating (L1) ──────────────────────────────────────────────\n// Pre-computed Set of character codes that indicate an expression might\n// be present. Used by hasExpressionIndicators() to gate prose lines\n// before full tokenization.\n//\n// NOTE: Currently unused, L1 prose gating was removed from classifyFromPositions()\n// because it incorrectly skipped keyword-only lines (\"pi\"), single identifiers\n// (\"hello\"), and short alpha lines. Retained for future re-implementation with\n// keyword-awareness and proper test coverage.\nconst EXPRESSION_INDICATOR_CODES = (() => {\n const set = new Set<number>();\n // Digits 0-9\n for (let i = 48; i <= 57; i++) set.add(i);\n // Operators / punctuation\n // Note: colon (58) is intentionally excluded, it's common in prose\n // (e.g., \"Subject: Hello world\") and would cause false-positive\n // expression classification. Variable assignment lines like\n // \":myVar = 5\" are still caught by '=' and digit indicators.\n const opCodes = [43, 45, 42, 47, 94, 37, 40, 41, 91, 93, 123, 125, 61, 60, 62, 33, 38, 124, 126, 59, 63];\n for (const c of opCodes) set.add(c);\n // Currency\n set.add(36); // $\n set.add(0x00A3); // £\n set.add(0x20AC); // €\n set.add(0x00A5); // ¥\n set.add(0x20BD); // ₽\n set.add(0x20A9); // ₩\n // Backtick (inline solve)\n set.add(96); // `\n // Dot (could be decimal)\n set.add(46); // .\n // Hash (comment, still an expression indicator)\n set.add(35); // #\n return set;\n})();\n\n// ── ExpressionLexer ───────────────────────────────────────────────────────\n/**\n * Character-by-character tokenizer for expression text.\n *\n * Scans a raw line/expression string into a stream of typed tokens\n * (numbers, identifiers, operators, units, keywords, ...), handling\n * markdown-line classification (`classifyLine`), inline `` s`...` `` solve\n * spans, and package-contributed vocabulary (registered via\n * {@link registerVocabulary}/{@link unregisterVocabulary}, keywords\n * operators, and units a package wants recognized as their own token\n * types rather than falling through to generic identifiers).\n *\n * Most consumers should use the higher-level {@link Lexer} wrapper, which\n * adds streaming `next()`/`peek()` access over this class's scan results.\n */\nexport class ExpressionLexer {\n private static readonly CHAR_CLASS = buildCharClassTable();\n /**\n * Configured TokenLookup from TokenClassRegistry. When set, replaces\n * the internal keyword map and unit set with registry-built equivalents.\n * Enables data-driven keyword/unit registration across locale keywords,\n * provider keywords, and plugins.\n *\n * Set at construction time via the constructor parameter. Plugin-registered\n * keywords/units (via registerVocabulary()) are checked alongside\n * the configuredLookup, neither source is bypassed.\n */\tprivate configuredLookup: TokenLookup | null = null;\n\n\t// Instance state\n private input: string = '';\n private pos: number = 0;\n private len: number = 0;\n\n // Line / column tracking (1-indexed)\n private line: number = 1;\n private lineStartPos: number = 0;\n\n // Keyword map: lowercase identifier → token type (locale keywords only)\n private keywordMap: Map<string, string>;\n\n // ── Merged lookup collections (keywordMap + pluginKeywordMap, knownUnits + pluginUnits)\n private mergedKeywords: Map<string, string>;\n private mergedUnits: Set<string>;\n\n // Plugin-extensible keyword map (merged with locale keywordMap)\n private pluginKeywordMap: Map<string, string> = new Map();\n\n // Plugin-extensible two-char operators: firstChar → (secondChar → tokenType)\n private pluginOperators: Map<number, Map<number, string>> = new Map();\n\n // Plugin-extensible units (merged with knownUnits)\n private pluginUnits: Set<string> = new Set();\t// Fast-path guards: skip plugin lookups entirely when no plugins registered\n\tprivate hasPluginOps = false;\n\n // Locale for function-identifier lookups\n private localeCode: string;\n private locale: ILocale;\n\n /**\n * Inline solve spans collected during the most recent tokenization pass.\n * Populated by [Symbol.iterator]() and consumed by scanDocument().\n */\n _inlineSolveSpans: InlineSolveSpan[] = [];\n\n // Plugin-extensible raw-line patterns. See LexerVocabulary.rawLinePatterns.\n private pluginRawLinePatterns: Array<{ pattern: RegExp; tokenType: string }> = [];\n\n /**\n * If a `rawLinePatterns` rule matches the FULL text most recently passed\n * to {@link reset}, this holds the single synthetic token that\n * {@link tokenizeAll} should return instead of running the\n * character-by-character scanner. Cleared (re-evaluated) on every\n * {@link reset} call. `null` when no plugin registered any raw-line\n * patterns, or none matched, the overwhelmingly common case, checked\n * with a `length === 0` guard before ever touching this field so a\n * plugin-free lexer pays zero cost for the feature.\n */\n private pendingRawLineToken: Token | null = null;\n\n /**\n * Test `text` against every registered `rawLinePatterns` rule, in\n * registration order. Returns a synthetic token for the first rule\n * whose `pattern` matches AND whose capture group 1 is non-empty after\n * trimming; returns `null` if no rule matches (the normal\n * character-by-character scanner should run instead).\n */\n private matchRawLine(text: string): Token | null {\n for (const rule of this.pluginRawLinePatterns) {\n const m = rule.pattern.exec(text);\n if (m && typeof m[1] === 'string') {\n const value = m[1].trim();\n if (value.length > 0) {\n return new LexerToken(rule.tokenType, tokenTypeId(rule.tokenType), value, value, 0, 0, this.line, 1);\n }\n }\n }\n return null;\n }\n\n /** Rebuild merged keyword and unit collections after plugin registration. */\n private rebuildMergedCollections(): void {\n this.mergedKeywords = new Map([...this.keywordMap, ...this.pluginKeywordMap]);\n this.mergedUnits = new Set([...knownUnits, ...this.pluginUnits]);\n }\n\n constructor(localeCode = 'en', lookup?: TokenLookup) {\n this.localeCode = localeCode;\n this.locale = getLocale(localeCode);\n this.configuredLookup = lookup ?? null;\n this.keywordMap = new Map<string, string>();\n for (const [k, v] of Object.entries(this.locale.keywordMap)) {\n this.keywordMap.set(k.toLowerCase(), v);\n }\n this.mergedKeywords = new Map(this.keywordMap);\n this.mergedUnits = new Set(knownUnits);\n }\n\n /**\n * Register a plugin to extend the lexer with custom tokens.\n *\n * All registrations are additive, built-in patterns still work.\n * Keywords, operators, and units from the plugin are merged\n * with existing ones. Calling multiple times adds more entries.\n *\n * Note: multi-word phrases are now handled by the TokenNormalizer\n * (see `IEnginePackage.normalizerRules`), not the lexer.\n *\n * Built-in tokens CANNOT be overridden. Throws a EngineError if the\n * plugin attempts to register a keyword, operator, or unit\n * that conflicts with a built-in one.\n */\n registerVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const [keyword, tokenType] of Object.entries(plugin.keywords)) {\n const lower = keyword.toLowerCase();\n // Guard: prevent overriding built-in locale keywords\n if (this.keywordMap.has(lower)) {\n throw ErrorFactory.config(\n 'PLUGIN_KEYWORD_COLLISION',\n `Plugin keyword \"${keyword}\" conflicts with built-in keyword ` +\n `(type: ${this.keywordMap.get(lower)}). Built-in keywords cannot be overridden.`,\n { keyword, builtinType: this.keywordMap.get(lower) }\n );\n }\n this.pluginKeywordMap.set(lower, tokenType);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n this.hasPluginOps = true;\n for (const [chars, tokenType] of Object.entries(plugin.operators)) {\n // Only support 2-char operators for the fast path\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n\n // Guard: prevent overriding built-in two-char operators (==, !=, >=, <=)\n const builtInSecondMap = TWO_CHAR_OPS[first];\n if (builtInSecondMap && builtInSecondMap[second] !== undefined) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: ${builtInSecondMap[second]}). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: builtInSecondMap[second] }\n );\n }\n // Guard: prevent overriding LSHIFT (<<) and RSHIFT (>>)\n if (first === 60 && second === 60) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: LSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'LSHIFT' }\n );\n }\n if (first === 62 && second === 62) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in operator ` +\n `(type: RSHIFT). Built-in operators cannot be overridden.`,\n { operator: chars, builtinType: 'RSHIFT' }\n );\n }\n // Guard: prevent overriding comment sequences (//)\n if (first === 47 && second === 47) {\n throw ErrorFactory.config(\n 'PLUGIN_OPERATOR_COLLISION',\n `Plugin operator \"${chars}\" conflicts with built-in comment sequence. ` +\n `Comment sequences cannot be overridden.`,\n { operator: chars, builtinType: 'COMMENT' }\n );\n }\n\n let inner = this.pluginOperators.get(first);\n if (!inner) {\n inner = new Map();\n this.pluginOperators.set(first, inner);\n }\n inner.set(second, tokenType);\n }\n }\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n // Guard: prevent overriding built-in units\n if (knownUnits.has(unit)) {\n throw ErrorFactory.config(\n 'PLUGIN_UNIT_COLLISION',\n `Plugin unit \"${unit}\" conflicts with a built-in unit. ` +\n `Built-in units cannot be overridden.`,\n { unit }\n );\n }\n this.pluginUnits.add(unit);\n }\n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n this.pluginRawLinePatterns.push(...plugin.rawLinePatterns);\n }\n }\n\n /**\n * Unregister a plugin, removing its custom tokens from the lexer.\n *\n * This is the inverse of registerVocabulary(). All keywords, operators,\n * and units registered by the plugin are removed. After\n * unregistration, those tokens will revert to their default behavior\n * (e.g., keywords become IDENT, operators become ERROR).\n *\n * Calling unregisterVocabulary with a plugin that was never registered\n * is safe, it simply has no effect.\n */\n unregisterVocabulary(plugin: LexerVocabulary): void {\n if (plugin.keywords) {\n for (const keyword of Object.keys(plugin.keywords)) {\n this.pluginKeywordMap.delete(keyword.toLowerCase());\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.operators) {\n for (const chars of Object.keys(plugin.operators)) {\n if (chars.length === 2) {\n const first = chars.charCodeAt(0);\n const second = chars.charCodeAt(1);\n const inner = this.pluginOperators.get(first);\n if (inner) {\n inner.delete(second);\n if (inner.size === 0) {\n this.pluginOperators.delete(first);\n }\n }\n }\n }\n this.hasPluginOps = this.pluginOperators.size > 0;\n }\n\n if (plugin.units) {\n for (const unit of plugin.units) {\n this.pluginUnits.delete(unit);\n }\n \n this.rebuildMergedCollections();\n }\n\n if (plugin.rawLinePatterns) {\n const toRemove = new Set(plugin.rawLinePatterns);\n this.pluginRawLinePatterns = this.pluginRawLinePatterns.filter((r) => !toRemove.has(r));\n }\n }\n\n reset(input: string): void {\n this.input = input;\n this.pos = 0;\n this.len = input.length;\n this.line = 1;\n this.lineStartPos = 0;\n this.pendingRawLineToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(input) : null;\n }\n\n /**\n * Scan a full document text in a single pass, classifying each line and\n * tokenizing non-skipped lines.\n *\n * Replaces the separate classifyLine() + findInlineSolves() + per-line\n * reset() + tokenizeAll() pattern with a single character-by-character\n * walk through the entire document. Key benefits:\n *\n * - **Single reset()**: `this.pos`, `this.len`, `this.line`, and\n * `this.lineStartPos` are set once for the whole document, not per-line.\n * - **Single classification**: classifyLine() runs once per line inline;\n * skipped lines are jumped over without tokenization.\n * - **Shared tokenization**: Non-skipped lines are tokenized using the\n * existing state machine, yielding Token[] without per-line reset().\n * - **Inline solve detection**: findInlineSolves() is called only for\n * lines that classifyLine() marks as having inline solves.\n *\n * Tokenization is scoped to each line by temporarily restricting\n * `this.len` to the line end position, so the [Symbol.iterator]\n * generator naturally stops at the line boundary. After tokenization,\n * `this.len` is restored and `this.pos` advances past the newline.\n *\n * @param text The full document text (with newlines).\n * @returns Array of ScanLineResult, one per line, in document order.\n */\n scanDocument(text: string): ScanLineResult[] {\n this.input = text;\n this.pos = 0;\n this.len = text.length;\n this.line = 1;\n this.lineStartPos = 0;\n\n const results: ScanLineResult[] = [];\n const input = this.input;\n const docLen = this.len;\n\n while (this.pos < docLen) {\n const lineStart = this.pos;\n\n // ── Find end of current line (newline boundary) ───────────────\n let lineEnd = this.pos;\n while (lineEnd < docLen) {\n const cc = input.charCodeAt(lineEnd);\n if (cc === 10 || cc === 13) break; // \\n or \\r\n lineEnd++;\n }\n\n const lineNumber = this.line;\n\n // ── Classify the line ─────────────────────────────────────────\n // Uses classifyFromPositions() to read from this.input directly\n // avoids allocating a substring and keeps classification reads\n // within the same memory region as tokenization.\n const classification = this.classifyFromPositions(lineStart, lineEnd);\n\n // ── Slice line text for ScanLineResult.text ────────────────\n // Hoisted above tokenization (rather than after, as originally) so the\n // raw-line-pattern check below can test the exact substring a plugin\n // registered via `LexerVocabulary.rawLinePatterns`. See reset()/\n // tokenizeAll() for the single-expression-string equivalent of this\n // same check.\n const lineText = input.slice(lineStart, lineEnd);\n\n // ── Tokenize non-skipped lines ────────────────────────────────\n let tokens: Token[] = [];\n if (!classification.skip) {\n const rawToken = this.pluginRawLinePatterns.length > 0 ? this.matchRawLine(lineText) : null;\n if (rawToken) {\n tokens = [rawToken];\n } else {\n // Scope tokenization to just this line by temporarily restricting len.\n // The [Symbol.iterator]() generator captures `this.len` at call time,\n // so creating the iterator AFTER setting this.len = lineEnd ensures\n // tokenization stops at the line boundary. After tokenization,\n // this.pos will be at lineEnd (the newline position).\n const savedLen = this.len;\n this.len = lineEnd;\n tokens = Array.from(this);\n this.len = savedLen;\n // this.pos is now at lineEnd, advance past newline below\n }\n }\n\n // ── Detect inline solves ──────────────────────────────────────\n // Two data sources are merged:\n // 1. _inlineSolveSpans, token indices collected inline during\n // [Symbol.iterator](). Provides correct startTokenIndex /\n // endTokenIndex. Also handles \\` escape (skips the pair\n // instead of closing the span early).\n // 2. findInlineSolves(), character-level string scan for\n // expression text. Still needed because token-based\n // reconstruction loses whitespace (the lexer skips spaces),\n // which breaks multi-word expressions like\n // \"2 weeks in days\" → \"2weeksindays\" (wrong tokenization).\n let inlineSolves: InlineSolveSpan[] = [];\n if (classification.hasInlineSolve) {\n if (!classification.skip && tokens.length > 0) {\n const charSpans = this.findInlineSolves(lineText);\n inlineSolves = this._inlineSolveSpans.map((span, i) => ({\n start: charSpans[i]?.start ?? 0,\n end: charSpans[i]?.end ?? 0,\n expression: charSpans[i]?.expression ?? '',\n columnNumber: charSpans[i]?.columnNumber ?? span.columnNumber,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: span.endTokenIndex,\n }));\n } else {\n // Skipped lines weren't tokenized, fall back to string scan\n inlineSolves = this.findInlineSolves(lineText);\n }\n }\n\n results.push({\n text: lineText,\n lineNumber,\n startOffset: lineStart,\n endOffset: lineEnd,\n classification,\n tokens,\n inlineSolves,\n });\n\n // ── Advance past newline ─────────────────────────────────────\n this.pos = lineEnd;\n if (this.pos < docLen) {\n const nlChar = input.charCodeAt(this.pos);\n if (nlChar === 13) { // \\r\n this.pos++;\n if (this.pos < docLen && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n } else if (nlChar === 10) { // \\n\n this.pos++;\n }\n }\n this.line++;\n this.lineStartPos = this.pos;\n }\n\n return results;\n }\n\n /**\n * Tokenize an expression string into an array of Tokens.\n *\n * Delegates to the lazy [Symbol.iterator]() generator and collects all\n * yielded tokens via Array.from(). For memory-sensitive use cases, prefer\n * iterating the lexer directly with for...of to avoid array allocation.\n *\n * Optimizations:\n * - CHAR_CLASS jump table (Uint8Array) → switch on small integers\n * - Direct character-code dispatch (c0 cached pattern)\n * - Mathematical digit parsing (integer math, not slice+parseFloat)\n * - Inline operator tokenizer with two-char peek-ahead\n * - Whitespace eliminated in-lexer (never emitted)\n * - 0-char and 1-char fast paths\n */\n tokenizeAll(): Token[] {\n if (this.pendingRawLineToken) {\n this._inlineSolveSpans = [];\n return [this.pendingRawLineToken];\n }\n return Array.from(this);\n }\n\n // ── Lazy iterator ─────────────────────────────────────────────────────\n /**\n * Lazy token-by-token generator. Yields each token without allocating an\n * intermediate Token[] array. Supports for...of and spread usage.\n *\n * Usage:\n * for (const t of lexer) { ... } // lazy, no array allocation\n * const tokens = [...lexer]; // materializes via spread\n * const tokens = lexer.tokenizeAll(); // materializes via Array.from()\n *\n * IMPORTANT: This generator captures `this.len` ONCE at creation time\n * (const len = this.len). `scanDocument()` relies on this behavior to\n * scope tokenization to a single line by temporarily restricting\n * `this.len` to the line end position before creating the iterator.\n * Do NOT refactor to re-read `this.len` mid-loop without also updating\n * `scanDocument()`.\n */\n *[Symbol.iterator](): Generator<Token, void, undefined> {\n const len = this.len;\n\n // ── 0-char fast path ────────────────────────────────────────────────\n if (len === 0) { this._inlineSolveSpans = []; return; }\n\n // Inline solve tracking state, collected inline during tokenization\n let tokenIndex = 0;\n let openSpan: { startTokenIndex: number; startColumn: number } | null = null;\n const collectedSpans: InlineSolveSpan[] = [];\n\n // ── 1-char fast path ────────────────────────────────────────────────\n if (len === 1) {\n const c0 = this.input.charCodeAt(0);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n switch (cc) {\n case CharClass.DIGIT:\n case CharClass.DOT:\n yield new LexerToken('NUMBER', tokenTypeId('NUMBER'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.ALPHA: {\n const input = this.input;\n const identLower = input.toLowerCase();\n // Use pre-merged collections (built-in + plugin), single lookup each\n if (this.mergedUnits.has(input)) {\n yield new LexerToken('UNIT', tokenTypeId('UNIT'), input, input, 0, 0, 1, 1);\n } else {\n const kwType = this.mergedKeywords.get(identLower);\n if (kwType) {\n yield new LexerToken(kwType, tokenTypeId(kwType), input, input, 0, 0, 1, 1);\n } else {\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), input, input, 0, 0, 1, 1);\n }\n }\n tokenIndex++;\n break;\n }\n\n case CharClass.OPERATOR: {\n const opType = OP_MAP[c0];\n if (opType) {\n yield new LexerToken(opType, tokenTypeId(opType), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n\n case CharClass.QUOTE:\n // Delegate to tokenizeString for correctness (handles unterminated)\n this.pos = 0;\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n case CharClass.HASH:\n // Delegate to tokenizeComment for correctness\n this.pos = 0;\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n case CharClass.DOLLAR:\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n case CharClass.BACKTICK:\n // s` is 2 chars, openSpan can never be set in the 1-char fast path\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', 0, 0, 1, 1);\n tokenIndex++;\n break;\n\n default: {\n // CharClass.SKIP, includes non-ASCII characters (code >= 128)\n if (isUnicodeSpace(c0)) {\n // A line holding nothing but a no-break space or a byte-order mark\n // holds no expression, exactly as a line holding one space does.\n // Yielding an IDENT for it made it an undefined variable instead.\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', 0, 0, 1, 1);\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility\n yield new LexerToken('IDENT', tokenTypeId('IDENT'), this.input, this.input, 0, 0, 1, 1);\n tokenIndex++;\n }\n break;\n }\n }\n this._inlineSolveSpans = collectedSpans;\n return;\n }\n\n const input = this.input;\n\n // ── Main tokenization loop ──────────────────────────────────────────\n while (this.pos < len) {\n const c0 = input.charCodeAt(this.pos);\n const cc = ExpressionLexer.CHAR_CLASS[c0] ?? CharClass.SKIP;\n\n // ── Escaped backtick inside inline solve ────────────────────────\n // \\` is treated as an escaped backtick, skip both characters\n // without closing the inline solve span. Without this, the\n // backtick would close the span early, producing wrong expression\n // text for expressions like s`hello \\` world`.\n if (openSpan && c0 === 92 && this.pos + 1 < len && input.charCodeAt(this.pos + 1) === 96) {\n this.pos += 2; // skip \\ and `\n continue;\n }\n\n switch (cc) {\n // ── Whitespace, skip entirely, track newlines ────────────────\n case CharClass.WHITESPACE:\n this.pos++;\n if (c0 === 10) { // \\n\n this.line++;\n this.lineStartPos = this.pos;\n } else if (c0 === 13) { // \\r\n this.line++;\n if (this.pos < len && input.charCodeAt(this.pos) === 10) {\n this.pos++; // skip \\n in \\r\\n\n }\n this.lineStartPos = this.pos;\n }\n break;\n\n // ── Digit, inline number tokenizer ───────────────────────────\n case CharClass.DIGIT:\n yield this.tokenizeNumber();\n tokenIndex++;\n break;\n\n // ── Alpha / underscore, identifier or keyword ────────────────\n case CharClass.ALPHA: {\n const token = this.tokenizeIdentifier();\n if (token.type === 'INLINE_SOLVE_START') {\n openSpan = { startTokenIndex: tokenIndex, startColumn: token.col };\n }\n yield token;\n tokenIndex++;\n break;\n }\n\n // ── Dot, could be decimal (.5) or DOT token ─────────────────\n case CharClass.DOT:\n if (this.pos + 1 < len) {\n const nextCc = ExpressionLexer.CHAR_CLASS[input.charCodeAt(this.pos + 1)] ?? CharClass.SKIP;\n if (nextCc === CharClass.DIGIT) {\n yield this.tokenizeNumber();\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n } else {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOT', tokenTypeId('DOT'), '.', '.', this.pos, 0, this.line, col);\n this.pos++;\n }\n tokenIndex++;\n break;\n\n // ── Operator / punctuation ────────────────────────────────────\n case CharClass.OPERATOR:\n yield this.tokenizeOperator();\n tokenIndex++;\n break;\n\n // ── String literal ────────────────────────────────────────────\n case CharClass.QUOTE:\n yield this.tokenizeString();\n tokenIndex++;\n break;\n\n // ── Comment (# or //) ─────────────────────────────────────────\n case CharClass.HASH:\n yield this.tokenizeComment();\n tokenIndex++;\n break;\n\n // ── Dollar sign $ ─────────────────────────────────────────────\n case CharClass.DOLLAR: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('DOLLAR', tokenTypeId('DOLLAR'), '$', '$', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n break;\n }\n\n // ── Backtick ` ───────────────────────────────────────────────\n case CharClass.BACKTICK: {\n const col = this.pos - this.lineStartPos + 1;\n yield new LexerToken('BACKTICK_OPEN', tokenTypeId('BACKTICK_OPEN'), '`', '`', this.pos, 0, this.line, col);\n this.pos++;\n if (openSpan) {\n const span = openSpan; // narrow for TS\n collectedSpans.push({\n start: 0, end: 0, expression: '',\n columnNumber: span.startColumn,\n startTokenIndex: span.startTokenIndex,\n endTokenIndex: tokenIndex,\n });\n openSpan = null;\n }\n tokenIndex++;\n break;\n }\n\n // ── Non-ASCII characters ─────────────────────────────────────\n default: {\n const col = this.pos - this.lineStartPos + 1;\n if (isUnicodeSpace(c0)) {\n // Separates its neighbours instead of joining them. See\n // isUnicodeSpace()'s doc comment: this branch is why a sum pasted\n // out of a web page or a spreadsheet evaluates at all.\n this.pos++;\n if (c0 === 0x2028 || c0 === 0x2029 || c0 === 0x0085) {\n // The three that are line breaks rather than spaces, tracked the\n // same way \"\\n\" is above so a later token reports its own line.\n this.line++;\n this.lineStartPos = this.pos;\n }\n } else if (c0 === 0x00D7) { // × → STAR\n yield new LexerToken('STAR', tokenTypeId('STAR'), '\\u00D7', '\\u00D7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00F7) { // ÷ → SLASH\n yield new LexerToken('SLASH', tokenTypeId('SLASH'), '\\u00F7', '\\u00F7', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x2260) { // ≠ → NEQ\n yield new LexerToken('NEQ', tokenTypeId('NEQ'), '\\u2260', '\\u2260', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A3) { // £\n yield new LexerToken('POUND', tokenTypeId('POUND'), '\\u00A3', '\\u00A3', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AC) { // €\n yield new LexerToken('EURO', tokenTypeId('EURO'), '\\u20AC', '\\u20AC', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x00A5) { // ¥\n yield new LexerToken('YEN', tokenTypeId('YEN'), '¥', '¥', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BD) { // ₽\n yield new LexerToken('RUBLE', tokenTypeId('RUBLE'), '₽', '₽', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A9) { // ₩\n yield new LexerToken('WON', tokenTypeId('WON'), '₩', '₩', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B9) { // ₹ (Indian rupee) — see uom/CurrencyAliases.ts\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₹', '₹', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20BA) { // ₺ (Turkish lira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₺', '₺', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B4) { // ₴ (Ukrainian hryvnia)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₴', '₴', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AA) { // ₪ (Israeli new shekel)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₪', '₪', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20AB) { // ₫ (Vietnamese dong)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₫', '₫', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20A6) { // ₦ (Nigerian naira)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₦', '₦', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 === 0x20B1) { // ₱ (Philippine peso)\n yield new LexerToken('CURRENCY_SYMBOL', tokenTypeId('CURRENCY_SYMBOL'), '₱', '₱', this.pos, 0, this.line, col);\n this.pos++;\n tokenIndex++;\n } else if (c0 >= 128) {\n // Unknown unicode, treat as IDENT for forward compatibility.\n // tokenizeIdentifier() now includes cc >= 128 in its reading loop,\n // so this properly advances past all consecutive Unicode chars.\n yield this.tokenizeIdentifier();\n tokenIndex++;\n } else {\n // Unknown ASCII, silently skip\n this.pos++;\n }\n break;\n }\n }\n }\n this._inlineSolveSpans = collectedSpans;\n }\n\n // ── Inline number tokenizer ────────────────────────────────────────────\n /**\n * Character-by-character number parsing.\n *\n * Supports: integers, floats, scientific notation (1.5e10, 1.5e-10),\n * hex (0xFF), binary (0b1010), octal (0o17), BigInt suffix (123n),\n * thousands separators (1,234 or 1.234.567).\n *\n * Returns a LexerToken and advances `this.pos` past the number.\n */\n private tokenizeNumber(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // ── Hex literal: 0x / 0X ───────────────────────────────────────────\n if (input.charCodeAt(pos) === 48 && pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (next === 0x78 || next === 0x58) { // 'x' or 'X'\n pos += 2;\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || (cc >= 65 && cc <= 70) || (cc >= 97 && cc <= 102))\n ) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Binary literal: 0b / 0B ─────────────────────────────────────\n if (next === 0x62 || next === 0x42) { // 'b' or 'B'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc === 48 || cc === 49)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n // ── Octal literal: 0o / 0O ───────────────────────────────────────\n if (next === 0x6F || next === 0x4F) { // 'o' or 'O'\n pos += 2;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 55)) {\n pos++;\n }\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n }\n\n let hasIntPart = false;\n\n // ── Integer part ───────────────────────────────────────────────────\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n hasIntPart = true;\n pos++;\n }\n\n // ── Thousands separators, coalesce with digits ────────────────────\n while (hasIntPart && pos < len && (input.charCodeAt(pos) === 44 || input.charCodeAt(pos) === 46)) {\n if (pos + 4 <= len) {\n const d1 = input.charCodeAt(pos + 1);\n const d2 = input.charCodeAt(pos + 2);\n const d3 = input.charCodeAt(pos + 3);\n // A genuine thousands group is always exactly 3 digits, followed\n // by either another separator, or a non-digit (end of number,\n // operator, unit, EOF), never a 4th consecutive digit. Without\n // this check, a plain decimal fraction with 4+ digits after the\n // point, e.g. \"0.0001\", had its first 3 fractional digits\n // misread as a \".\" thousands-group, silently truncating the\n // number to \"0.000\" and leaving the remaining digit(s) as a\n // separate, unrelated NUMBER token right after it (so\n // \"0.0001 BTC to USD\" tokenized as \"0.000\", \"1\", \"BTC\", \"to\",\n // \"USD\", two number literals instead of one, and evaluated to\n // a bare 0 instead of a real BTC quantity).\n const d4 = pos + 4 < len ? input.charCodeAt(pos + 4) : -1;\n const isGroupOfExactlyThree = !(d4 >= 48 && d4 <= 57);\n if (\n d1 >= 48 && d1 <= 57 &&\n d2 >= 48 && d2 <= 57 &&\n d3 >= 48 && d3 <= 57 &&\n isGroupOfExactlyThree\n ) {\n pos += 4;\n hasIntPart = true;\n continue;\n }\n }\n break;\n }\n\n // ── Decimal part (.xxx) ───────────────────────────────────────────\n let hasDecimal = false;\n if (pos < len && input.charCodeAt(pos) === 46) {\n if (pos + 1 < len) {\n const nextCc = input.charCodeAt(pos + 1);\n if (nextCc >= 48 && nextCc <= 57) {\n hasDecimal = true;\n pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n\n // ── Exponent (e / E [+-]? \\n+) ────────────────────────────────────\n let hasExponent = false;\n if (pos < len) {\n const ec = input.charCodeAt(pos);\n if (ec === 0x65 || ec === 0x45) { // 'e' or 'E'\n if (pos + 1 < len) {\n const next = input.charCodeAt(pos + 1);\n if (\n (next >= 48 && next <= 57) ||\n next === 43 || next === 45 // + or -\n ) {\n hasExponent = true;\n pos++;\n if (next === 43 || next === 45) pos++;\n while (pos < len && ((cc = input.charCodeAt(pos)), cc >= 48 && cc <= 57)) {\n pos++;\n }\n }\n }\n }\n }\n\n // ── BigInt suffix check ────────────────────────────────────────────\n if (pos < len && input.charCodeAt(pos) === 110) { // 'n'\n if (hasIntPart && !hasDecimal && !hasExponent) {\n pos++;\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('BIGINT', tokenTypeId('BIGINT'), text, text, start, 0, this.line, startCol);\n }\n }\n\n // ── Emit NUMBER token ──────────────────────────────────────────────\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('NUMBER', tokenTypeId('NUMBER'), text, text, start, 0, this.line, startCol);\n }\n\n // ── Inline identifier / keyword tokenizer ──────────────────────────────\n /**\n * Reads [a-zA-Z_][a-zA-Z0-9_]* and resolves to:\n * - A unit type (via knownUnits, case-sensitive)\n * - A keyword type (via locale keywordMap, case-insensitive)\n * - IDENT if none of the above\n *\n * Multi-word phrases (e.g., \"to the power of\") are handled by the\n * TokenNormalizer post-lexer pass, not the lexer.\n */\n private tokenizeIdentifier(): Token {\n const input = this.input;\n const len = this.len;\n let pos = this.pos;\n const start = pos;\n const startCol = pos - this.lineStartPos + 1;\n let cc: number;\n\n // Read [a-zA-Z0-9_]* plus any Unicode (>= 128) including emoji surrogate pairs.\n // Without this, non-ASCII characters cause an infinite loop: the default case\n // calls tokenizeIdentifier(), the while loop doesn't match the Unicode char,\n // pos never advances, and the outer loop re-reads the same char forever.\n while (\n pos < len &&\n ((cc = input.charCodeAt(pos)),\n (cc >= 48 && cc <= 57) || // 0-9\n (cc >= 65 && cc <= 90) || // A-Z\n (cc >= 97 && cc <= 122) || // a-z\n cc === 95 || // _\n (cc >= 128 && !isUnicodeSpace(cc))) // Unicode (accented chars, emoji, etc.), but not Unicode whitespace\n ) {\n pos++;\n }\n\n const identText = input.slice(start, pos);\n const identLower = identText.toLowerCase();\n\n // ── Inline solve marker: s` (lowercase 's' followed by backtick) ──\n if (identLower === 's' && pos < len && input.charCodeAt(pos) === 96) {\n pos++;\n this.pos = pos;\n const fullText = input.slice(start, pos);\n return new LexerToken('INLINE_SOLVE_START', tokenTypeId('INLINE_SOLVE_START'), fullText, fullText, start, 0, this.line, startCol);\n }\n\n // ── Unit lookup (case-sensitive)\n const isKnownUnit = this.mergedUnits.has(identText);\n if (isKnownUnit) {\n if (!this.isFollowedByLParen(pos)) {\n this.pos = pos;\n return new LexerToken('UNIT', tokenTypeId('UNIT'), identText, identText, start, 0, this.line, startCol);\n }\n }\n\n // ── Keyword lookup (case-insensitive)\n const localeKwType = this.mergedKeywords.get(identLower);\n if (localeKwType) {\n this.pos = pos;\n return new LexerToken(localeKwType, tokenTypeId(localeKwType), identText, identText, start, 0, this.line, startCol);\n }\n\n // ── Fall through: emit IDENT\n // Multi-word phrases are now handled by the TokenNormalizer post-lexer pass,\n // which keeps the lexer slim and focused on single-token production.\n this.pos = pos;\n return new LexerToken('IDENT', tokenTypeId('IDENT'), identText, identText, start, 0, this.line, startCol);\n }\n\n /**\n * Peek past in-expression whitespace (space, tab) from `pos` to check\n * if the next significant character is '('.\n */\n private isFollowedByLParen(pos: number): boolean {\n const len = this.len;\n let lookPos = pos;\n while (lookPos < len) {\n const cc = this.input.charCodeAt(lookPos);\n if (cc === 40) return true;\n if (cc !== 32 && cc !== 9) break;\n lookPos++;\n }\n return false;\n }\n\n // ── Inline operator tokenizer ─────────────────────────────────────────\n /**\n * Reads an operator/punctuation token.\n * Handles two-char operators (==, !=, >=, <=, **) and the special\n * cases << (LSHIFT) and >> (RSHIFT).\n */\n private tokenizeOperator(): Token {\n const input = this.input;\n const pos = this.pos;\n const col = pos - this.lineStartPos + 1;\n const c0 = input.charCodeAt(pos);\n const len = this.len;\n\n // ── Two-character operators ────────────────────────────────────────\n if (pos + 1 < len) {\n const c1 = input.charCodeAt(pos + 1);\n\n // ==, !=, >=, <=\n const secondMap = TWO_CHAR_OPS[c0];\n if (secondMap) {\n const twoCharType = secondMap[c1];\n if (twoCharType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(twoCharType, tokenTypeId(twoCharType), text, text, pos, 0, this.line, col);\n }\n }\n\n // // comment\n if (c0 === 47 && c1 === 47) {\n let commentPos = pos + 2;\n while (commentPos < len) {\n const cc = input.charCodeAt(commentPos);\n if (cc === 10 || cc === 13) break;\n commentPos++;\n }\n const text = input.slice(pos, commentPos);\n this.pos = commentPos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, pos, 0, this.line, col);\n }\n\n // << (LSHIFT), >> (RSHIFT) and >>> (URSHIFT).\n //\n // >>> is tested before >>, or the two-char match would consume the first\n // two angle brackets and leave a stray > for the parser to choke on.\n if (c0 === 60 && c1 === 60) {\n this.pos = pos + 2;\n return new LexerToken('LSHIFT', tokenTypeId('LSHIFT'), '<<', '<<', pos, 0, this.line, col);\n }\n if (c0 === 62 && c1 === 62) {\n if (input.charCodeAt(pos + 2) === 62) {\n this.pos = pos + 3;\n return new LexerToken('URSHIFT', tokenTypeId('URSHIFT'), '>>>', '>>>', pos, 0, this.line, col);\n }\n this.pos = pos + 2;\n return new LexerToken('RSHIFT', tokenTypeId('RSHIFT'), '>>', '>>', pos, 0, this.line, col);\n }\n\n // ── Plugin-registered two-char operators ──────────────────────\n if (this.hasPluginOps) {\n const pluginInner = this.pluginOperators.get(c0);\n if (pluginInner) {\n const pluginType = pluginInner.get(c1);\n if (pluginType) {\n const text = input.slice(pos, pos + 2);\n this.pos = pos + 2;\n return new LexerToken(pluginType, tokenTypeId(pluginType), text, text, pos, 0, this.line, col);\n }\n }\n }\n }\n\n // ── Single-character operator ──────────────────────────────────────\n this.pos = pos + 1;\n const opType = OP_MAP[c0];\n const text = input.charAt(pos);\n return new LexerToken(opType || 'ERROR', tokenTypeId(opType || 'ERROR'), text, text, pos, 0, this.line, col);\n }\n\n // ── String literal tokenizer ──────────────────────────────────────────\n /**\n * Reads a double-quoted string literal. Supports backslash escapes.\n *\n * `text` is the raw source slice, quotes included, because that is what\n * `offset` + `text.length` has to span for a host to underline the literal.\n * `value` is the PAYLOAD, quotes excluded, because that is what\n * `PUSH_STRING` puts into the Value.\n *\n * The two used to be the same string. `\"abc\"` carried the five characters\n * `\"abc\"` as its value, which was invisible on screen (the formatter prints\n * the payload raw and the retained quotes landed where a display would have\n * put them back) and not invisible anywhere else: `parseFloat('\"5\"')` is NaN\n * whatever the digits say, so `\"5\" + 5` answered 5.\n *\n * An unterminated literal is an error rather than a string that happens to\n * reach the end of the line. It used to return what it had, so `\"abc` and\n * `\"abc\"` were indistinguishable by payload once the quotes were stripped,\n * which is the other half of why they are stripped here rather than later.\n */\n private tokenizeString(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n let pos = start + 1;\n let lineBreaks = 0;\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 34) {\n pos++;\n const text = input.slice(start, pos);\n const value = input.slice(start + 1, pos - 1);\n this.pos = pos;\n return new LexerToken('STRING', tokenTypeId('STRING'), value, text, start, lineBreaks, this.line, startCol);\n }\n if (c0 === 92 && pos + 1 < len) {\n pos += 2;\n continue;\n }\n if (c0 === 10) {\n this.line++;\n this.lineStartPos = pos + 1;\n lineBreaks++;\n }\n pos++;\n }\n\n this.pos = pos;\n throw ErrorFactory.parsing(\n \"UNTERMINATED_STRING\",\n `Unterminated string literal: ${input.slice(start, pos)}`,\n { literal: input.slice(start, pos), offset: start },\n );\n }\n\n // ── Markdown line scanner (Phase B) ───────────────────────────────────\n\n /**\n * L1 expression gating: quickly determine if a line contains any\n * characters that indicate an expression (digits, operators, currency,\n * backticks, parentheses, etc.).\n *\n * Pure prose lines (e.g., \"The quick brown fox jumps over the lazy dog\")\n * return false and can be skipped without full tokenization (L2).\n *\n * This is a fast character-by-character scan that stops at the first\n * expression indicator. Called once per line in classifyFromPositions().\n */\n static hasExpressionIndicators(input: string, start: number, end: number): boolean {\n const indicatorCodes = EXPRESSION_INDICATOR_CODES;\n for (let i = start; i < end; i++) {\n const cc = input.charCodeAt(i);\n // Check digits and operators via pre-computed Set (O(1) lookup)\n if (indicatorCodes.has(cc)) return true;\n // Unicode math/currency symbols (≥ 128, not in the 128-byte table)\n if (cc >= 128) {\n // ×, ÷, ≠, £, €, ¥, ₽, ₩, common expression symbols\n if (cc === 0x00D7 || cc === 0x00F7 || cc === 0x2260 ||\n cc === 0x00A3 || cc === 0x20AC ||\n cc === 0x00A5 || cc === 0x20BD || cc === 0x20A9) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Classify a line by its character positions within this.input.\n * Reads directly from this.input using start/end boundaries.\n * DOES NOT modify this.pos, purely a read-only classifier.\n */\n private classifyFromPositions(start: number, end: number): LineClassification {\n const len = end;\n\n if (start >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const input = this.input;\n let pos = start;\n\n while (pos < len) {\n const cc = input.charCodeAt(pos);\n if (cc !== 32 && cc !== 9) break;\n pos++;\n }\n\n if (pos >= len) {\n return { type: 'empty', skip: true, hasInlineSolve: false };\n }\n\n const c0 = input.charCodeAt(pos);\n let hasInline: boolean | undefined;\n\n // ── Heading: #{1,6} ' ' ──────────────────────────────────────────\n if (c0 === 35) {\n let hashCount = 1;\n while (pos + hashCount < len && input.charCodeAt(pos + hashCount) === 35) {\n hashCount++;\n }\n if (hashCount <= 6 && pos + hashCount < len && input.charCodeAt(pos + hashCount) === 32) {\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n return { type: 'heading', skip: true, hasInlineSolve: false };\n }\n\n // ── Blockquote: > ' ' ────────────────────────────────────────────\n if (c0 === 62) {\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Code fence: ``` or ~~~ ────────────────────────────────────────\n if (c0 === 96 && pos + 2 < len && input.charCodeAt(pos + 1) === 96 && input.charCodeAt(pos + 2) === 96) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n if (c0 === 126 && pos + 2 < len && input.charCodeAt(pos + 1) === 126 && input.charCodeAt(pos + 2) === 126) {\n return { type: 'code_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Math fence: $$ ────────────────────────────────────────────────\n if (c0 === 36 && pos + 1 < len && input.charCodeAt(pos + 1) === 36) {\n return { type: 'math_fence', skip: true, hasInlineSolve: false };\n }\n\n // ── Horizontal rule: ---, ***, ___ (3+ same char, then only whitespace)\n if (c0 === 45 || c0 === 42 || c0 === 95) {\n let count = 1;\n while (pos + count < len && input.charCodeAt(pos + count) === c0) {\n count++;\n }\n if (count >= 3) {\n let trailPos = pos + count;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'hr', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Unordered list: - ' ', * ' ', + ' ' ──────────────────────────\n if ((c0 === 45 || c0 === 42 || c0 === 43) && pos + 1 < len && input.charCodeAt(pos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n return { type: 'list', skip: false, hasInlineSolve: hasInline };\n }\n\n // ── Ordered list: \\n+ '. ' ────────────────────────────────────────\n if (c0 >= 48 && c0 <= 57) {\n let digitPos = pos;\n while (digitPos < len && input.charCodeAt(digitPos) >= 48 && input.charCodeAt(digitPos) <= 57) {\n digitPos++;\n }\n if (digitPos < len && input.charCodeAt(digitPos) === 46) {\n if (digitPos + 1 < len && input.charCodeAt(digitPos + 1) === 32) {\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n return { type: 'list', skip: false, hasInlineSolve: hasInline };\n }\n }\n }\n\n // ── Table / table separator: | ────────────────────────────────────\n if (c0 === 124) {\n let tPos = pos + 1;\n while (tPos < len) {\n const tc = input.charCodeAt(tPos);\n if (tc !== 45 && tc !== 58 && tc !== 124 && tc !== 32 && tc !== 9 && tc !== 13) break;\n tPos++;\n }\n if (tPos >= len) {\n return { type: 'table_separator', skip: true, hasInlineSolve: false };\n }\n }\n\n // ── Wikilink / embed: [[ or ![[ ───────────────────────────────────\n if (c0 === 91 && pos + 1 < len && input.charCodeAt(pos + 1) === 91) {\n const closePos = input.indexOf(']]', pos + 2);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n if (c0 === 33 && pos + 2 < len && input.charCodeAt(pos + 1) === 91 && input.charCodeAt(pos + 2) === 91) {\n const closePos = input.indexOf(']]', pos + 3);\n if (closePos !== -1 && closePos < len) {\n let trailPos = closePos + 2;\n while (trailPos < len && (input.charCodeAt(trailPos) === 32 || input.charCodeAt(trailPos) === 9)) {\n trailPos++;\n }\n if (trailPos >= len) {\n return { type: 'wikilink', skip: true, hasInlineSolve: false };\n }\n }\n }\n\n // ── Comment: // ──────────────────────────────────────────────────\n if (c0 === 47 && pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n return { type: 'comment', skip: true, hasInlineSolve: false };\n }\n\n // ── Default: expression or prose line ─────────────────────────────\n if (c0 === 62) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'blockquote', skip: true, hasInlineSolve: false };\n }\n if (c0 === 45 || c0 === 42 || c0 === 43) {\n let trail = pos + 1;\n while (trail < len && (input.charCodeAt(trail) === 32 || input.charCodeAt(trail) === 9)) trail++;\n if (trail >= len) return { type: 'list', skip: false, hasInlineSolve: false };\n }\n if (hasInline === undefined) {\n const idx = input.indexOf('s`', pos);\n hasInline = idx !== -1 && idx < len;\n }\n\n // Return expression, all non-markdown-structure lines are tokenized.\n // (L1 prose gating removed: it incorrectly skipped keyword-only lines\n // like \"pi\", single identifiers like \"hello\", and any line without\n // digits/operators/currency. Can be re-added with keyword-awareness\n // and proper test coverage.)\n return { type: 'expression', skip: false, hasInlineSolve: hasInline };\n }\n\n /**\n * Classify a single line of markdown text.\n */\n classifyLine(lineText: string): LineClassification {\n const savedInput = this.input;\n const savedLen = this.len;\n const savedPos = this.pos;\n this.input = lineText;\n this.len = lineText.length;\n this.pos = 0;\n const result = this.classifyFromPositions(0, lineText.length);\n this.input = savedInput;\n this.len = savedLen;\n this.pos = savedPos;\n return result;\n }\n\n /**\n * Every keyword this lexer currently recognizes, locale keywords\n * (`pi`, `sqrt`, `convert`, ...) merged with any plugin-contributed ones\n * from `registerVocabulary()` (e.g. a package's custom keywords), mapped to\n * the token type they lex to. A snapshot copy, not a live reference\n * mutating the return value has no effect on the lexer.\n */\n getKeywords(): Record<string, string> {\n return Object.fromEntries(this.mergedKeywords);\n }\n\n /**\n * Find all inline solve markers in a line with precise coordinate mapping.\n */\n findInlineSolves(lineText: string): InlineSolveSpan[] {\n const results: InlineSolveSpan[] = [];\n const len = lineText.length;\n let pos = 0;\n\n while (pos < len) {\n const sPos = lineText.indexOf('s`', pos);\n if (sPos === -1) break;\n\n const exprStart = sPos + 2;\n\n let exprEnd = exprStart;\n while (exprEnd < len) {\n const cc = lineText.charCodeAt(exprEnd);\n if (cc === 92 && exprEnd + 1 < len) {\n exprEnd += 2;\n continue;\n }\n if (cc === 96) break;\n exprEnd++;\n }\n\n if (exprEnd >= len) {\n exprEnd = len;\n }\n\n const expression = lineText.slice(exprStart, exprEnd);\n const end = exprEnd < len ? exprEnd + 1 : exprEnd;\n\n results.push({\n start: sPos,\n end,\n expression,\n columnNumber: sPos + 1,\n });\n\n pos = end;\n }\n\n return results;\n }\n\n // ── Comment tokenizer ─────────────────────────────────────────────────\n /**\n * Reads a comment: # to end of line, or // to end of line.\n */\n private tokenizeComment(): Token {\n const input = this.input;\n const len = this.len;\n const start = this.pos;\n const startCol = start - this.lineStartPos + 1;\n let pos = this.pos;\n\n if (pos + 1 < len && input.charCodeAt(pos + 1) === 47) {\n pos += 2;\n } else {\n pos++;\n }\n\n while (pos < len) {\n const c0 = input.charCodeAt(pos);\n if (c0 === 10 || c0 === 13) break;\n pos++;\n }\n\n const text = input.slice(start, pos);\n this.pos = pos;\n return new LexerToken('COMMENT', tokenTypeId('COMMENT'), text, text, start, 0, this.line, startCol);\n }\n}"]}
@@ -1,4 +1,4 @@
1
- import { UNIT_TABLE, UNIT_DIFFERENCES, EXTENDED_UNITS, MEASURE_KIND_NAMES, MEASURE_SYMBOLS, BEST_UNITS_METRIC } from './chunk-PCPX42KL.js';
1
+ import { UNIT_TABLE, UNIT_DIFFERENCES, EXTENDED_UNITS, MEASURE_KIND_NAMES, MEASURE_SYMBOLS, BEST_UNITS_METRIC } from './chunk-V4XG5QF6.js';
2
2
 
3
3
  // src/uom/UnitConversion.ts
4
4
  var UNIT_LOOKUP = new Map(Object.entries(UNIT_TABLE));
@@ -164,5 +164,5 @@ function getBestUnit(value, unit) {
164
164
  }
165
165
 
166
166
  export { canConvert, convertUnit, getBestUnit, getConvertiblePossibilities, getMeasure, isConvertibleUnit, isWorkdayUnit, resolveUnit };
167
- //# sourceMappingURL=chunk-WC5FFSHB.js.map
168
- //# sourceMappingURL=chunk-WC5FFSHB.js.map
167
+ //# sourceMappingURL=chunk-R3PY4G7J.js.map
168
+ //# sourceMappingURL=chunk-R3PY4G7J.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":[],"mappings":";;;AAmCA,IAAM,cAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAC,CAAA;AAStF,IAAM,oBAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAC,CAAA;AAgBxF,SAAS,WAAW,IAAA,EAAqC;AAC9D,EAAA,OAAO,WAAA,CAAY,IAAI,IAAI,CAAA;AAC7B;AAWO,SAAS,UAAA,CAAW,QAAA,EAAkB,IAAA,EAAc,EAAA,EAAoB;AAC7E,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,GAAA,CAAI,IAAI,CAAA;AACvC,EAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,EAAG,IAAI,CAAA,oBAAA,CAAsB,CAAA;AAAA,EACpD;AAEA,EAAA,MAAM,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,EAAE,CAAA;AACnC,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,EAAG,EAAE,CAAA,oBAAA,CAAsB,CAAA;AAAA,EAClD;AAEA,EAAA,OAAO,eAAA,CAAgB,QAAA,EAAU,IAAA,EAAM,EAAA,EAAI,YAAY,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C,EAAA,MAAM,OAAA,GAAU,eAAA,CAAgB,KAAA,CAAM,CAAC,CAAC,CAAA;AACxC,EAAA,IAAI,CAAC,OAAA,EAAS,OAAO,EAAC;AACtB,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,KAAM,MAAM,QAAQ,CAAA;AAC7C;AAGO,SAAS,kBAAkB,IAAA,EAAuB;AACvD,EAAA,IAAI,aAAA,CAAc,IAAI,CAAA,EAAG,OAAO,IAAA;AAChC,EAAA,IAAI,cAAA,CAAe,IAAI,CAAA,EAAG,OAAO,IAAA;AACjC,EAAA,OAAO,UAAA,CAAW,WAAA,CAAY,IAAI,CAAC,CAAA,KAAM,MAAA;AAC3C;AAWO,SAAS,WAAA,CAAY,OAAe,IAAA,EAA+C;AACxF,EAAA,MAAM,CAAA,GAAI,YAAY,IAAI,CAAA;AAC1B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,mBAAA,CAAoB,KAAA,EAAO,CAAC,CAAA;AAC3C,IAAA,OAAO,EAAE,KAAA,EAAO,MAAA,CAAO,QAAA,EAAU,IAAA,EAAM,OAAO,IAAA,EAAK;AAAA,EACrD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1B;AACF","file":"chunk-WC5FFSHB.js","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":[],"mappings":";;;AAmCA,IAAM,cAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,UAAU,CAAC,CAAA;AAStF,IAAM,oBAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQ,gBAAgB,CAAC,CAAA;AAgBxF,SAAS,WAAW,IAAA,EAAqC;AAC9D,EAAA,OAAO,WAAA,CAAY,IAAI,IAAI,CAAA;AAC7B;AAWO,SAAS,UAAA,CAAW,QAAA,EAAkB,IAAA,EAAc,EAAA,EAAoB;AAC7E,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,GAAA,CAAI,IAAI,CAAA;AACvC,EAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,EAAG,IAAI,CAAA,oBAAA,CAAsB,CAAA;AAAA,EACpD;AAEA,EAAA,MAAM,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,EAAE,CAAA;AACnC,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,EAAG,EAAE,CAAA,oBAAA,CAAsB,CAAA;AAAA,EAClD;AAEA,EAAA,OAAO,eAAA,CAAgB,QAAA,EAAU,IAAA,EAAM,EAAA,EAAI,YAAY,QAAQ,CAAA;AACjE;AAWO,SAAS,eAAA,CACd,QAAA,EACA,IAAA,EACA,EAAA,EACA,WACA,OAAA,EACQ;AACR,EAAA,MAAM,UAAA,GAAa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ACtB,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,KAAM,MAAM,QAAQ,CAAA;AAC7C;AAGO,SAAS,kBAAkB,IAAA,EAAuB;AACvD,EAAA,IAAI,aAAA,CAAc,IAAI,CAAA,EAAG,OAAO,IAAA;AAChC,EAAA,IAAI,cAAA,CAAe,IAAI,CAAA,EAAG,OAAO,IAAA;AACjC,EAAA,OAAO,UAAA,CAAW,WAAA,CAAY,IAAI,CAAC,CAAA,KAAM,MAAA;AAC3C;AAWO,SAAS,WAAA,CAAY,OAAe,IAAA,EAA+C;AACxF,EAAA,MAAM,CAAA,GAAI,YAAY,IAAI,CAAA;AAC1B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,mBAAA,CAAoB,KAAA,EAAO,CAAC,CAAA;AAC3C,IAAA,OAAO,EAAE,KAAA,EAAO,MAAA,CAAO,QAAA,EAAU,IAAA,EAAM,OAAO,IAAA,EAAK;AAAA,EACrD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,CAAA,EAAE;AAAA,EAC1B;AACF","file":"chunk-R3PY4G7J.js","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { UNIT_TABLE, EXTENDED_UNITS } from './chunk-PCPX42KL.js';
1
+ import { UNIT_TABLE, EXTENDED_UNITS } from './chunk-V4XG5QF6.js';
2
2
 
3
3
  // src/lexer/units.ts
4
4
  var EXCLUDED_UNIT_SPELLINGS = /* @__PURE__ */ new Map([
@@ -254,5 +254,5 @@ function isKnownUnit(text) {
254
254
  }
255
255
 
256
256
  export { isKnownUnit, knownUnits };
257
- //# sourceMappingURL=chunk-M5E34VG5.js.map
258
- //# sourceMappingURL=chunk-M5E34VG5.js.map
257
+ //# sourceMappingURL=chunk-SBUFNJVE.js.map
258
+ //# sourceMappingURL=chunk-SBUFNJVE.js.map