solve-engine 2.2.0 → 2.4.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 (95) hide show
  1. package/dist/{Configuration-B6W0-T67.d.cts → Configuration-BGQn-cJ8.d.cts} +38 -0
  2. package/dist/{Configuration-B6W0-T67.d.ts → Configuration-BGQn-cJ8.d.ts} +38 -0
  3. package/dist/FormattingSettings-bRKjU7wI.d.cts +47 -0
  4. package/dist/FormattingSettings-bRKjU7wI.d.ts +47 -0
  5. package/dist/{PackageCompatibility-DBsZ0l2a.d.ts → PackageCompatibility-UsSZIfHs.d.ts} +1 -1
  6. package/dist/{PackageCompatibility-Cv7zjqSV.d.cts → PackageCompatibility-cEClSSkz.d.cts} +1 -1
  7. package/dist/{PackageRegistry-DRbqNJfI.d.ts → PackageRegistry-B3yJHSxX.d.ts} +24 -1
  8. package/dist/{PackageRegistry-BSGQ6saH.d.cts → PackageRegistry-BsLmAVZJ.d.cts} +24 -1
  9. package/dist/{chunk-7NXAZJDB.js → chunk-5R7S5KJJ.js} +3 -3
  10. package/dist/{chunk-7NXAZJDB.js.map → chunk-5R7S5KJJ.js.map} +1 -1
  11. package/dist/chunk-6ZNNPXXE.cjs +3 -0
  12. package/dist/chunk-6ZNNPXXE.cjs.map +1 -0
  13. package/dist/{chunk-7GK3XEZF.js → chunk-7E7NXKQ5.js} +2 -2
  14. package/dist/chunk-7E7NXKQ5.js.map +1 -0
  15. package/dist/chunk-AR7L5OJ2.js +2 -0
  16. package/dist/chunk-AR7L5OJ2.js.map +1 -0
  17. package/dist/chunk-B5NBFGNP.js +3 -0
  18. package/dist/chunk-B5NBFGNP.js.map +1 -0
  19. package/dist/{chunk-6C6IPUBH.cjs → chunk-E2ZSMJEL.cjs} +3 -3
  20. package/dist/{chunk-6C6IPUBH.cjs.map → chunk-E2ZSMJEL.cjs.map} +1 -1
  21. package/dist/chunk-GALZNKW7.js +3 -0
  22. package/dist/chunk-GALZNKW7.js.map +1 -0
  23. package/dist/{chunk-ZCNBT44X.cjs → chunk-LNZNJSRW.cjs} +2 -2
  24. package/dist/chunk-LNZNJSRW.cjs.map +1 -0
  25. package/dist/chunk-MMT2LS5I.cjs +2 -0
  26. package/dist/chunk-MMT2LS5I.cjs.map +1 -0
  27. package/dist/chunk-NAMMTJBE.cjs +3 -0
  28. package/dist/chunk-NAMMTJBE.cjs.map +1 -0
  29. package/dist/chunk-NXIMGB4S.cjs +2 -0
  30. package/dist/chunk-NXIMGB4S.cjs.map +1 -0
  31. package/dist/chunk-UA3BGOYT.js +5 -0
  32. package/dist/chunk-UA3BGOYT.js.map +1 -0
  33. package/dist/chunk-UGQM6ZXU.js +2 -0
  34. package/dist/chunk-UGQM6ZXU.js.map +1 -0
  35. package/dist/chunk-WYAY6WPQ.cjs +5 -0
  36. package/dist/chunk-WYAY6WPQ.cjs.map +1 -0
  37. package/dist/constants.cjs +1 -1
  38. package/dist/constants.d.cts +1 -1
  39. package/dist/constants.d.ts +1 -1
  40. package/dist/constants.js +1 -1
  41. package/dist/engine.cjs +1 -1
  42. package/dist/engine.d.cts +5 -5
  43. package/dist/engine.d.ts +5 -5
  44. package/dist/engine.js +1 -1
  45. package/dist/format.cjs +1 -1
  46. package/dist/format.d.cts +2 -2
  47. package/dist/format.d.ts +2 -2
  48. package/dist/format.js +1 -1
  49. package/dist/index.cjs +1 -1
  50. package/dist/index.d.cts +4 -4
  51. package/dist/index.d.ts +4 -4
  52. package/dist/index.js +1 -1
  53. package/dist/language.d.cts +3 -3
  54. package/dist/language.d.ts +3 -3
  55. package/dist/packages.cjs +1 -1
  56. package/dist/packages.d.cts +11 -2
  57. package/dist/packages.d.ts +11 -2
  58. package/dist/packages.js +1 -1
  59. package/dist/resolvers.cjs +1 -1
  60. package/dist/resolvers.d.cts +14 -0
  61. package/dist/resolvers.d.ts +14 -0
  62. package/dist/resolvers.js +1 -1
  63. package/dist/testing.cjs +2 -2
  64. package/dist/testing.d.cts +3 -3
  65. package/dist/testing.d.ts +3 -3
  66. package/dist/testing.js +1 -1
  67. package/dist/worker.cjs +2 -2
  68. package/dist/worker.d.cts +3 -3
  69. package/dist/worker.d.ts +3 -3
  70. package/dist/worker.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/FormattingSettings-CJHyxcYu.d.cts +0 -27
  73. package/dist/FormattingSettings-CJHyxcYu.d.ts +0 -27
  74. package/dist/chunk-7BXPCWKM.cjs +0 -2
  75. package/dist/chunk-7BXPCWKM.cjs.map +0 -1
  76. package/dist/chunk-7GK3XEZF.js.map +0 -1
  77. package/dist/chunk-E2Q3PQ2G.js +0 -3
  78. package/dist/chunk-E2Q3PQ2G.js.map +0 -1
  79. package/dist/chunk-HLBYHXQD.cjs +0 -3
  80. package/dist/chunk-HLBYHXQD.cjs.map +0 -1
  81. package/dist/chunk-J4LZD4ZY.js +0 -3
  82. package/dist/chunk-J4LZD4ZY.js.map +0 -1
  83. package/dist/chunk-KVTOV3TZ.js +0 -2
  84. package/dist/chunk-KVTOV3TZ.js.map +0 -1
  85. package/dist/chunk-OVKDDTXO.cjs +0 -3
  86. package/dist/chunk-OVKDDTXO.cjs.map +0 -1
  87. package/dist/chunk-TN5E6JU6.js +0 -2
  88. package/dist/chunk-TN5E6JU6.js.map +0 -1
  89. package/dist/chunk-U2UZJX5W.cjs +0 -5
  90. package/dist/chunk-U2UZJX5W.cjs.map +0 -1
  91. package/dist/chunk-X3R7B7XM.cjs +0 -2
  92. package/dist/chunk-X3R7B7XM.cjs.map +0 -1
  93. package/dist/chunk-YU3PACLE.js +0 -5
  94. package/dist/chunk-YU3PACLE.js.map +0 -1
  95. package/dist/chunk-ZCNBT44X.cjs.map +0 -1
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunkR2SZFJTT_cjs=require('./chunk-R2SZFJTT.cjs'),chunkESUN2THE_cjs=require('./chunk-ESUN2THE.cjs'),chunkN7N7MPMK_cjs=require('./chunk-N7N7MPMK.cjs'),chunkPS272DZJ_cjs=require('./chunk-PS272DZJ.cjs'),chunkMSYX32PF_cjs=require('./chunk-MSYX32PF.cjs');var b={floatResult:{decimalPlaces:2,enableSeperator:true},numberResult:{decimalSeparatorLocale:"en-US"},hexResult:{enablePadding:false,paddingZeros:0},unitOfMeasurementResult:{decimalPlaces:2},percentageResult:{decimalPlaces:2},dateResult:{format:"long"}};function D(t,r,o,n){let e=o.floatResult.enableSeperator,a=o.numberResult.decimalSeparatorLocale;if(n!==void 0&&Number.isFinite(t)){let c=t.toLocaleString(a||"en-US",{minimumFractionDigits:n,maximumFractionDigits:n,useGrouping:e});return `${r.display.resultPrefix}${c}`}let i=o.floatResult.decimalPlaces,s=chunkR2SZFJTT_cjs.a(t,i,e,a);return `${r.display.resultPrefix}${s}`}function F(t,r,o,n){let e=n.floatResult.decimalPlaces,a=n.floatResult.enableSeperator,i=n.numberResult.decimalSeparatorLocale||"en-US",s=Math.max(e,1),c=t.toLocaleString(i,{useGrouping:a,minimumFractionDigits:0,maximumFractionDigits:e}),u=Math.abs(r).toLocaleString(i,{useGrouping:a,minimumFractionDigits:1,maximumFractionDigits:s});return `${o.display.resultPrefix}${c} \xB1 ${u}`}function R(t,r,o){if(typeof t=="number"&&!Number.isFinite(t))return `= ${t}`;let n=typeof t=="bigint"?t<0n:t<0,e=n?"-":"",a=c=>typeof t=="bigint"?(n?-t:t).toString(c):Math.abs(Math.trunc(t)).toString(c);if(o==="bin")return `= ${e}0b${a(2)}`;if(o==="oct")return `= ${e}0o${a(8)}`;let i=r.hexResult.enablePadding?r.hexResult.paddingZeros:0,s=a(16).toUpperCase().padStart(i,"0");return `= ${e}0x${s}`}var L=2e4;function P(t){let r=t<0n?-t:t;if(Number.isFinite(Number(r)))return `= ${t}`;let o=r.toString(16).length*4;if(o*Math.LN2/Math.LN10<=L)return `= ${t}`;let n=o*Math.LN2/Math.LN10,e=Math.floor(n),a=Math.pow(10,n-e);return `= ${t<0n?"-":""}~${a.toFixed(3)}e+${e} (an exact integer of about ${(e+1).toLocaleString("en-US")} digits, too large to print)`}function T(t){return `= ${t}`}function I(t){return `= ${t}`}function w(t,r,o){let n=new Date(t),e=o.dateResult?.format??"long",a=n.getHours()===0&&n.getMinutes()===0&&n.getSeconds()===0&&n.getMilliseconds()===0;if(e==="long"){let g=n.toLocaleDateString(r.code,{weekday:"long",year:"numeric",month:"long",day:"numeric"});return a?`= ${g}`:`= ${g}, ${n.toLocaleTimeString(r.code)}`}let i=g=>String(g).padStart(2,"0"),s=n.getFullYear(),c=i(n.getMonth()+1),u=i(n.getDate()),m;if(e==="iso"?m=`${s}-${c}-${u}`:e==="dmy"?m=`${u}/${c}/${s}`:m=`${c}/${u}/${s}`,a)return `= ${m}`;let l=`${i(n.getHours())}:${i(n.getMinutes())}:${i(n.getSeconds())}`;return e==="iso"?`= ${m}T${l}`:`= ${m} ${l}`}function N(t){let r=t<0?"-":"",o=Math.round(Math.abs(t)/1e3),n=Math.floor(o/3600),e=Math.floor(o%3600/60),a=o%60,i=String(e).padStart(2,"0");if(a===0)return `${r}${n}:${i}`;let s=String(a).padStart(2,"0");return `${r}${n}:${i}:${s}`}function U(t,r,o,n,e){if(r==="ms")return `= ${N(t)}`;let a=n.unitOfMeasurementResult.decimalPlaces,s=r&&["days","weeks","months","years","hours","minutes","seconds","day","week","month","year","hour","minute","second"].includes(r),c;s&&t===Math.floor(t)?c=t.toString():c=t.toFixed(a);let u=r?chunkN7N7MPMK_cjs.ua[r.toUpperCase()]:void 0;if(u){let l=e?chunkN7N7MPMK_cjs.sa(e,a):c,g=u.spaced?" ":"";return `= ${u.position==="prefix"?`${u.symbol}${g}${l}`:`${l}${g}${u.symbol}`}`}return `= ${e?chunkN7N7MPMK_cjs.sa(e,a):c} ${r||""}`.trim()}function M(t,r){if(typeof t=="boolean")return t?"true":"false";if(typeof t=="object"&&t!==null)return chunkN7N7MPMK_cjs.R(t);let o=r.floatResult.decimalPlaces,n=r.floatResult.enableSeperator,e=r.numberResult.decimalSeparatorLocale;return chunkR2SZFJTT_cjs.a(t,o,n,e)}function E(t,r,o){let n=chunkN7N7MPMK_cjs.Z(t),e=[];for(let a=0;a<t.rows;a++){let i=[];for(let s=0;s<t.cols;s++)i.push(M(n[a*t.cols+s],o));e.push(i.join(", "));}return `${r.display.resultPrefix}[${e.join("; ")}]`}function Q(t,r){let o=r||b,n=chunkN7N7MPMK_cjs.Z(t),e=[];for(let i=0;i<t.rows;i++){let s=[];for(let c=0;c<t.cols;c++)s.push(M(n[i*t.cols+c],o));e.push(s);}let a=[];for(let i=0;i<t.cols;i++){let s=0;for(let c=0;c<t.rows;c++)s=Math.max(s,e[c][i].length);a.push(s);}return e.map(i=>`[ ${i.map((s,c)=>s.padStart(a[c])).join(" ")} ]`).join(`
2
+ `)}function j(t,r,o){return `${o.display.resultPrefix}${t}:${r}`}function C(t,r,o){let n=o.percentageResult.decimalPlaces;return `= ${(t*100).toFixed(n)}${r.display.percentageSuffix}`}function A(t,r){return `= ${t} ${r||""}`.trim()}function G(t,r,o){let n=r.display.resultPrefix,e=u=>{let m=t.unit!==void 0?new chunkPS272DZJ_cjs.m(6,u.value,t.unit):new chunkPS272DZJ_cjs.m(0,u.value);m.exact=u.exact;let l=O(m,o);return l.startsWith(n)?l.slice(n.length):l},[a,i]=t.shares,s=`${e(a)} each`;if(i===void 0)return `${n}${s}`;let c=i.count===1?"share":"shares";return `${n}${s}, with ${i.count} ${c} paying ${e(i)}`}function O(t,r){let o=r||b,n=o.numberResult.decimalSeparatorLocale||"en",e=chunkMSYX32PF_cjs.a(n);switch(t.type){case 0:return t.uncertainty!==void 0?F(t.value,t.uncertainty,e,o):D(t.value,e,o,t.decimalPlaces);case 1:return R(t.value,o,t.unit);case 2:return P(t.value);case 3:return T(t.value);case 10:return I(t.value);case 4:return w(t.value,e,o);case 6:return U(t.value,t.unit,e,o,t.exact);case 7:return E(t.value,e,o);case 8:{let a=t.value;return j(a.min,a.max,e)}case 14:return `${e.display.resultPrefix}${chunkESUN2THE_cjs.g(t.value)}`;case 15:return G(t.value,e,o);case 9:return chunkN7N7MPMK_cjs.R(t.value);case 5:return C(t.value,e,o);case 11:return A(t.value,t.unit);case 13:return t.unit??String(t.value);default:return `= ${String(t.value)}`}}exports.a=b;exports.b=Q;exports.c=O;//# sourceMappingURL=chunk-6ZNNPXXE.cjs.map
3
+ //# sourceMappingURL=chunk-6ZNNPXXE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","autoFormatIntegerOrFloat","formatUncertain","center","uncertainty","useGrouping","spreadMax","centerText","spreadText","formatHex","base","negative","sign","digits","radix","padding","hex","MAX_DISPLAYED_BIGINT_DIGITS","formatBigInt","magnitude","bits","log10","exponent","mantissa","formatString","formatBoolean","formatDatetime","d","format","isMidnight","dateStr","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","formatUom","unit","exact","isTimeSpan","currencyDisplay","CURRENCY_DISPLAY","moneyText","decimalToFixed","formatMatrixEntry","entry","formatSymbolic","formatMatrix","m","rowMajor","columnMajorToRowMajor","rows","r","cells","c","formatMatrixAligned","us","row","colWidth","width","cell","formatRange","min","max","formatPercentage","formatUnit","formatSplit","data","prefix","render","share","v","Value","text","formatValue","high","each","shareWord","localeCode","getLocale","formatColour"],"mappings":"2QA8CO,IAAMA,CAAAA,CAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,CAAA,CACf,eAAA,CAAiB,IACnB,CAAA,CACA,YAAA,CAAc,CACZ,sBAAA,CAAwB,OAC1B,EACA,SAAA,CAAW,CACT,aAAA,CAAe,KAAA,CACf,YAAA,CAAc,CAChB,CAAA,CACA,uBAAA,CAAyB,CACvB,aAAA,CAAe,CACjB,CAAA,CACA,gBAAA,CAAkB,CAChB,cAAe,CACjB,CAAA,CACA,UAAA,CAAY,CACV,MAAA,CAAQ,MACV,CACF,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,CAAajG,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,QACE,OAAOmF,CAAAA,CAAYnF,EAAM,KAAA,CAAoBC,CAAAA,CAAQwE,CAAE,CAAA,CACzD,OACE,OAAOV,mBAAAA,CAAe/D,CAAAA,CAAM,KAAqB,EACnD,KAAA,CAAA,CACE,OAAOiF,CAAAA,CAAiBjF,CAAAA,CAAM,MAAiBC,CAAAA,CAAQwE,CAAE,EAC3D,KAAA,EAAA,CACE,OAAOS,EAAWlF,CAAAA,CAAM,KAAA,CAAiBA,CAAAA,CAAM,IAAI,EACrD,KAAA,EAAA,CAKE,OAAOA,CAAAA,CAAM,IAAA,EAAQ,OAAOA,CAAAA,CAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,MAAA,CAAOA,EAAM,KAAK,CAAC,EACnC,CACF","file":"chunk-6ZNNPXXE.cjs","sourcesContent":["/**\n * How a Datetime value is rendered.\n *\n * - `'long'`: the spelled-out form, \"Tuesday, March 10, 2026\" (the default).\n * - `'iso'`: \"2026-03-10\" (ISO 8601, with a `T`-separated time when present).\n * - `'dmy'`: \"10/03/2026\" (day first).\n * - `'mdy'`: \"03/10/2026\" (month first).\n *\n * The weekday and long month name in `'long'` are localised through the same\n * locale the number separators come from; the numeric forms are locale-neutral.\n */\nexport type DateOutputFormat = \"long\" | \"iso\" | \"dmy\" | \"mdy\";\n\n/**\n * Minimal formatting settings interface for the engine\n * This allows the engine to format values without depending on app-specific settings\n */\nexport interface FormattingSettings {\n floatResult: {\n decimalPlaces: number;\n enableSeperator: boolean;\n };\n numberResult: {\n decimalSeparatorLocale: string;\n };\n hexResult: {\n enablePadding: boolean;\n paddingZeros: number;\n };\n unitOfMeasurementResult: {\n decimalPlaces: number;\n };\n percentageResult: {\n decimalPlaces: number;\n };\n /**\n * Optional so a host that built a `FormattingSettings` before this field\n * existed still compiles; a missing `dateResult` reads as `'long'`, the\n * historic output.\n */\n dateResult?: {\n format: DateOutputFormat;\n };\n}\n\n/** Formatting used when a host supplies none. */\nexport const DEFAULT_FORMATTING_SETTINGS: FormattingSettings = {\n floatResult: {\n decimalPlaces: 2,\n enableSeperator: true,\n },\n numberResult: {\n decimalSeparatorLocale: \"en-US\",\n },\n hexResult: {\n enablePadding: false,\n paddingZeros: 0,\n },\n unitOfMeasurementResult: {\n decimalPlaces: 2,\n },\n percentageResult: {\n decimalPlaces: 2,\n },\n dateResult: {\n format: \"long\",\n },\n};\n","import { Value, ValueType, type MatrixData, type MatrixEntry, type RangeData, type ColourData, type SplitData, type SplitShare } from \"@solve-js/vm/Value\";\nimport { formatColour } from \"@solve-js/packages/colour/ColourMath\";\nimport { decimalToFixed, type DecimalData } from \"@solve-js/decimal\";\nimport { getLocale, type ILocale } from \"@solve-js/constants/locales\";\nimport { autoFormatIntegerOrFloat } from \"@solve-js/utilities/Number\";\nimport { FormattingSettings, DEFAULT_FORMATTING_SETTINGS } from \"./FormattingSettings\";\nimport { CURRENCY_DISPLAY } from \"@solve-js/uom/CurrencyAliases\";\nimport { columnMajorToRowMajor } from \"@solve-js/vm/MatrixOps\";\nimport { formatSymbolic, type SymbolicNode } from \"@solve-js/symbolic\";\n\nfunction formatNumber(value: number, locale: ILocale, settings: FormattingSettings, decimalPlaces?: number): string {\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n // An explicit precision (`3.14159 to 4 dp`, `round(1.5, 2)`) shows EXACTLY that\n // many places with trailing zeros kept, where the default trims them and shows\n // an integer with none. The value was already rounded to this precision when\n // it was set (see VMBuiltins' roundToPlaces, exact where an exact decimal was\n // there), so rendering it to the same place count reproduces that rounding.\n if (decimalPlaces !== undefined && Number.isFinite(value)) {\n const formatted = value.toLocaleString(loc || \"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n useGrouping: sep,\n });\n return `${locale.display.resultPrefix}${formatted}`;\n }\n const dp = settings.floatResult.decimalPlaces;\n const formatted = autoFormatIntegerOrFloat(value, dp, sep, loc);\n return `${locale.display.resultPrefix}${formatted}`;\n}\n\n/**\n * Renders a measurement that carries a one-sigma uncertainty as\n * `center ± spread`, e.g. `49.2 ± 2.0`.\n *\n * The center is shown the way any number is, whole numbers as integers and\n * trailing zeros trimmed, so a tolerance-free-looking center still reads\n * cleanly (\"30 ± 2.24\", not \"30.00 ± 2.24\"). The spread is shown to the same\n * decimal-place budget but always keeps at least one fractional digit, which is\n * what distinguishes it as a tolerance and gives \"± 2.0\" rather than \"± 2\".\n * Both use `Intl` with `maximumFractionDigits`, so the trailing-zero trimming is\n * locale-correct (a comma-decimal locale is not string-sliced on \".\").\n *\n * The symbol is always the `±` glyph on output, even when the input was the\n * ASCII `+/-`, since the glyph is the conventional notation and unambiguous to\n * read back.\n */\nfunction formatUncertain(center: number, uncertainty: number, locale: ILocale, settings: FormattingSettings): string {\n const dp = settings.floatResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\n // The spread needs room for at least one fractional digit, so a zero-decimal\n // budget cannot leave minimumFractionDigits above maximumFractionDigits.\n const spreadMax = Math.max(dp, 1);\n const centerText = center.toLocaleString(loc, { useGrouping, minimumFractionDigits: 0, maximumFractionDigits: dp });\n const spreadText = Math.abs(uncertainty).toLocaleString(loc, { useGrouping, minimumFractionDigits: 1, maximumFractionDigits: spreadMax });\n return `${locale.display.resultPrefix}${centerText} ± ${spreadText}`;\n}\n\n/**\n * Renders a number in whichever base it is tagged with.\n *\n * The zero padding is a hexadecimal setting and stays one. Applying it to a\n * binary rendering would pad `0b101` out to the same digit count as a hex\n * value, which is a different quantity of zeros and not what the setting asks\n * for.\n */\nfunction formatHex(value: number | bigint, settings: FormattingSettings, base?: string): string {\n // An infinity or a NaN has no digits in any base, and asking for them\n // produced `0xINFINITY`, a literal that reads back as nothing at all. Render\n // the value itself, which is what every other non-finite result shows.\n if (typeof value === \"number\" && !Number.isFinite(value)) return `= ${value}`;\n\n // Truncate and take the sign off before converting. `Number.toString(radix)`\n // does neither: it renders -255 as \"-ff\", which lands the minus inside the\n // literal as `0x-FF`, and it renders 255.7 as \"ff.b3333333333\", inventing\n // fractional hex digits for a notation that has no use for them. Both were\n // visible on `as hex` until the builtins started sharing this path.\n //\n // A bigint needs neither truncation nor a Math call, and must not be routed\n // through one: passing it to Math.trunc() throws, and converting it to a\n // double first is exactly the precision loss it is carried as a bigint to\n // avoid.\n const negative = typeof value === \"bigint\" ? value < 0n : value < 0;\n const sign = negative ? \"-\" : \"\";\n const digits = (radix: number): string =>\n typeof value === \"bigint\"\n ? (negative ? -value : value).toString(radix)\n : Math.abs(Math.trunc(value)).toString(radix);\n\n if (base === \"bin\") return `= ${sign}0b${digits(2)}`;\n if (base === \"oct\") return `= ${sign}0o${digits(8)}`;\n const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;\n const hex = digits(16).toUpperCase().padStart(padding, \"0\");\n return `= ${sign}0x${hex}`;\n}\n\n/**\n * How many decimal digits of an exact integer this will render in full.\n *\n * A little above the ~19,729 digits of the largest bigint the VM will build\n * (`vm/VM.ts`'s MAX_EXACT_POW_BITS / MAX_EXACT_SHIFT_BITS, 65,536 bits), so\n * every value the engine can produce through `^` or `<<` still prints exactly\n * and this ceiling only ever meets a value that came from somewhere else.\n */\nconst MAX_DISPLAYED_BIGINT_DIGITS = 20000;\n\n/**\n * Renders an exact integer, or describes it when writing it out is itself the\n * expensive operation.\n *\n * This used to be a bare `= ${value}` template, which renders whatever it is\n * handed: `1n << 100000000` took 8.5 seconds here turning a 12.5MB integer\n * into a thirty-million-character string, and a host has no way to opt out,\n * since displaying the answer is what it asked the engine for. The VM's own\n * ceiling on `<<` and `^` now stops that value existing, so this is the\n * backstop for every other way a large bigint can arrive (repeated `x * x`,\n * a Value a host built itself), and it costs one comparison for every value\n * that is not absurd.\n *\n * The digit count is estimated from the bit length rather than measured, since\n * measuring means doing the conversion this exists to avoid. Bit length comes\n * off the hexadecimal form, which is linear in the size of the value where the\n * decimal form is not.\n */\nfunction formatBigInt(value: bigint): string {\n const magnitude = value < 0n ? -value : value;\n // Every bigint a person actually reads takes this line and nothing else:\n // anything a double can hold is at most 309 digits, so it is printable\n // without measuring it at all.\n if (Number.isFinite(Number(magnitude))) return `= ${value}`;\n const bits = magnitude.toString(16).length * 4;\n if (bits * Math.LN2 / Math.LN10 <= MAX_DISPLAYED_BIGINT_DIGITS) return `= ${value}`;\n const log10 = bits * Math.LN2 / Math.LN10;\n const exponent = Math.floor(log10);\n const mantissa = Math.pow(10, log10 - exponent);\n const sign = value < 0n ? \"-\" : \"\";\n return `= ${sign}~${mantissa.toFixed(3)}e+${exponent} (an exact integer of about ${(exponent + 1).toLocaleString(\"en-US\")} digits, too large to print)`;\n}\n\nfunction formatString(value: string): string {\n return `= ${value}`;\n}\n\nfunction formatBoolean(value: boolean): string {\n return `= ${value}`;\n}\n\n/**\n * Renders a Datetime value locale-aware, the previous implementation\n * called `d.toLocaleString()` with no arguments, which always uses the JS\n * runtime's own default locale and never actually consulted `locale.code`\n * despite receiving it as a parameter (both branches of its old\n * `dateFormat === \"default\"` check were byte-for-byte identical, dead\n * groundwork for a distinction that was never implemented). Concretely,\n * this meant every configured locale (including the shipped German one)\n * always displayed weekday/month names in English. See GitHub issue #77.\n *\n * Uses `weekday`/`month`: \"long\" for a spelled-out date (\"Monday,\n * November 17, 2025\" / \"lundi 17 novembre 2025\") since that's what a\n * literal weekday name is for; a bare numeric date doesn't need\n * localizing beyond the decimal/thousands separators `formatNumber()`\n * already handles. The time-of-day portion is only appended when it's\n * not exactly local midnight, bare date literals (\"today\", \"17/11/2025\")\n * always anchor to local midnight, and showing \"00:00:00\" on every one of\n * those would be noise, not information.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings): string {\n const d = new Date(value);\n const format = settings.dateResult?.format ?? \"long\";\n const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = d.toLocaleDateString(locale.code, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n if (isMidnight) return `= ${dateStr}`;\n return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;\n }\n\n // The numeric forms, built from the local calendar fields so they read the\n // same regardless of the JS runtime's own default locale.\n const p2 = (n: number) => String(n).padStart(2, \"0\");\n const year = d.getFullYear();\n const month = p2(d.getMonth() + 1);\n const day = p2(d.getDate());\n let datePart: string;\n if (format === \"iso\") datePart = `${year}-${month}-${day}`;\n else if (format === \"dmy\") datePart = `${day}/${month}/${year}`;\n else datePart = `${month}/${day}/${year}`; // mdy\n\n if (isMidnight) return `= ${datePart}`;\n const time = `${p2(d.getHours())}:${p2(d.getMinutes())}:${p2(d.getSeconds())}`;\n // ISO joins date and time with `T`; the slash forms with a space.\n return format === \"iso\" ? `= ${datePart}T${time}` : `= ${datePart} ${time}`;\n}\n\n/**\n * Renders a millisecond duration as clock-style `H:MM` (or `H:MM:SS` when\n * there's a non-zero seconds component). `ms` is never a user-typeable\n * unit (confirmed: it appears nowhere in `lexer/units.ts`), it's only\n * ever produced by subtracting two clock times/datetimes (`9:30 - 8:30`,\n * `VM.ts`'s Datetime SUB case), so this is a safe, narrow special case,\n * not a general change to how durations display.\n */\nfunction formatMsDuration(ms: number): string {\n const sign = ms < 0 ? \"-\" : \"\";\n const totalSeconds = Math.round(Math.abs(ms) / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n const mm = String(minutes).padStart(2, \"0\");\n if (seconds === 0) return `${sign}${hours}:${mm}`;\n const ss = String(seconds).padStart(2, \"0\");\n return `${sign}${hours}:${mm}:${ss}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData): string {\n if (unit === \"ms\") return `= ${formatMsDuration(value)}`;\n\n const dp = settings.unitOfMeasurementResult.decimalPlaces;\n\n // For TimeSpan values (days, weeks, hours, etc.), format as integer if the value is a whole number\n const timeSpanUnits = [\"days\", \"weeks\", \"months\", \"years\", \"hours\", \"minutes\", \"seconds\", \"day\", \"week\", \"month\", \"year\", \"hour\", \"minute\", \"second\"];\n const isTimeSpan = unit && timeSpanUnits.includes(unit);\n\n let formatted: string;\n if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = value.toString();\n } else {\n // For other values, use the configured decimal places\n formatted = value.toFixed(dp);\n }\n\n // Currency display: symbol + culturally-conventional placement (e.g.\n // \"$100.00\" prefix vs \"100.00 kr\" suffix) instead of the generic\n // \"amount CODE\" fallback below. See uom/CurrencyAliases.ts's\n // CURRENCY_DISPLAY table for the exact set covered and the reasoning\n // behind each placement choice. Any currency code NOT in that table\n // (most of the ~150 `CurrencyExchange.isCurrency()` recognizes) falls\n // through to the unchanged \"amount CODE\" format below.\n const currencyDisplay = unit ? CURRENCY_DISPLAY[unit.toUpperCase()] : undefined;\n if (currencyDisplay) {\n // An exact money amount rounds from its decimal, not from the double: a\n // half-cent like \"$1.005\" reads as \"$1.01\" here, where \"(1.005).toFixed(2)\"\n // answers \"1.00\" because the double it is handed already sits below the\n // value the user typed. Amounts with no exact decimal (a currency\n // conversion, whose rate is a double) keep the toFixed rendering above.\n const moneyText = exact ? decimalToFixed(exact, dp) : formatted;\n const sep = currencyDisplay.spaced ? \" \" : \"\";\n const withSymbol = currencyDisplay.position === \"prefix\"\n ? `${currencyDisplay.symbol}${sep}${moneyText}`\n : `${moneyText}${sep}${currencyDisplay.symbol}`;\n return `= ${withSymbol}`;\n }\n\n // The unit is written as the symbol the value carries. There used to be a\n // `unitOfMeasurementResult.unitNames` setting here whose two branches were\n // the same expression, so it never changed anything, and it was removed\n // rather than implemented: the engine has no unit-name data to render from.\n // The generated unit table maps a spelling to [measure, ratio] only, and\n // names cannot be recovered from it, because units that differ by an OFFSET\n // share a ratio, so \"20 C\" would come back as \"20 kelvins\". A real\n // implementation needs a hand-authored name per unit plus pluralization and\n // per-locale spelling (metre against meter), which is a feature rather than\n // the repair of a dead ternary.\n //\n // An exact currency with no symbol in the display table above (one of the\n // less common ISO codes) still rounds from its decimal here, so \"1.005 UYW\"\n // reads the same way \"$1.005\" does. Non-currency Uoms never carry an exact,\n // so this leaves \"1.50 kg\" exactly as it was.\n const genericText = exact ? decimalToFixed(exact, dp) : formatted;\n return `= ${genericText} ${unit || \"\"}`.trim();\n}\n\nfunction formatMatrixEntry(entry: MatrixEntry, settings: FormattingSettings): string {\n if (typeof entry === \"boolean\") return entry ? \"true\" : \"false\";\n if (typeof entry === \"object\" && entry !== null) return formatSymbolic(entry);\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n return autoFormatIntegerOrFloat(entry, dp, sep, loc);\n}\n\n/**\n * Renders a Matrix matching its own literal syntax: a single row (1xN,\n * including plain vectors) as `[a, b, c]`, a single column (Nx1) as\n * `[a; b; c]`, and a general shape as `[r0c0, r0c1; r1c0, r1c1]`, row-major\n * textual output read back out of the column-major storage\n * (`columnMajorToRowMajor()`), matching how `[1,2;3,4]` is written.\n */\nfunction formatMatrix(m: MatrixData, locale: ILocale, settings: FormattingSettings): string {\n const rowMajor = columnMajorToRowMajor(m);\n const rows: string[] = [];\n for (let r = 0; r < m.rows; r++) {\n const cells: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));\n }\n rows.push(cells.join(\", \"));\n }\n return `${locale.display.resultPrefix}[${rows.join(\"; \")}]`;\n}\n\n/**\n * Render a matrix as a multi-line, column-aligned block: one row per line (the\n * newline is where {@link formatValue}'s compact form writes `;`), each column\n * right-padded to its widest cell, and every row wrapped in `[ ... ]`. For\n * display where a grid reads better than a line, e.g. a docs notepad or a REPL:\n *\n * ```text\n * [ 1 2 ]\n * [ 30 4 ]\n * ```\n *\n * This is deliberately separate from {@link formatValue}, whose single-line\n * matrix form stays the stable, assertable text the API and the worker DTO use.\n * A 1xN row vector is one line; an Nx1 column vector is N lines.\n */\nexport function formatMatrixAligned(m: MatrixData, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const rowMajor = columnMajorToRowMajor(m);\n const cells: string[][] = [];\n for (let r = 0; r < m.rows; r++) {\n const row: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n row.push(formatMatrixEntry(rowMajor[r * m.cols + c], us));\n }\n cells.push(row);\n }\n const colWidth: number[] = [];\n for (let c = 0; c < m.cols; c++) {\n let width = 0;\n for (let r = 0; r < m.rows; r++) width = Math.max(width, cells[r][c].length);\n colWidth.push(width);\n }\n return cells\n .map((row) => `[ ${row.map((cell, c) => cell.padStart(colWidth[c])).join(\" \")} ]`)\n .join(\"\\n\");\n}\n\nfunction formatRange(min: number, max: number, locale: ILocale): string {\n return `${locale.display.resultPrefix}${min}:${max}`;\n}\n\nfunction formatPercentage(value: number, locale: ILocale, settings: FormattingSettings): string {\n // ValueType.Percentage stores a fraction (0.25 for 25%). See Value.ts's\n // documented contract and the sole producer, VM.ts's TO_PERCENTAGE opcode\n // (`right/left - 1`, e.g. 0.25 for \"800 to 1000\"). Multiply by 100 before\n // formatting; without this every percentage-change result displayed as\n // e.g. \"0.25%\" instead of \"25.00%\".\n const dp = settings.percentageResult.decimalPlaces;\n const formatted = (value * 100).toFixed(dp);\n return `= ${formatted}${locale.display.percentageSuffix}`;\n}\n\nfunction formatUnit(value: number, unit: string | undefined): string {\n return `= ${value} ${unit || \"\"}`.trim();\n}\n\n/**\n * Renders a per-person bill split: \"= $45.00 each\", or, when the division is\n * uneven, \"= $33.33 each, with 1 share paying $33.34\". Each share's amount is\n * rendered through the ordinary value formatter (a throwaway {@link Value}), so\n * a currency share honours the same symbol placement, decimal places and locale\n * as any other money and a bare share trims trailing zeros the way a plain\n * number does; the \"= \" prefix is added once, around the whole sentence, not\n * per share.\n */\nfunction formatSplit(data: SplitData, locale: ILocale, settings: FormattingSettings): string {\n const prefix = locale.display.resultPrefix;\n const render = (share: SplitShare): string => {\n const v = data.unit !== undefined\n ? new Value(ValueType.Uom, share.value, data.unit)\n : new Value(ValueType.Number, share.value);\n v.exact = share.exact;\n const text = formatValue(v, settings);\n return text.startsWith(prefix) ? text.slice(prefix.length) : text;\n };\n\n const [base, high] = data.shares;\n const each = `${render(base)} each`;\n if (high === undefined) return `${prefix}${each}`;\n const shareWord = high.count === 1 ? \"share\" : \"shares\";\n return `${prefix}${each}, with ${high.count} ${shareWord} paying ${render(high)}`;\n}\n\n/**\n * Render an evaluated {@link Value} as a display string, dispatching on\n * `value.type` to the type-specific formatter (number, hex, datetime, unit\n * of measurement, matrix, range, percentage, ...).\n *\n * Most branches produce a `\"= \"`-prefixed result string (matching the\n * plugin's inline-result convention); `ValueType.Error` is the one\n * exception, it returns the human-readable error message directly\n * (stored in `value.unit`), not an `\"= \"`-prefixed string.\n *\n * @param value - The evaluated value to format.\n * @param settings - Locale/precision/separator options; defaults to\n * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.\n * @example\n * ```typescript\n * const value = engine.evaluateExpression(\"10 USD to GBP\");\n * formatValue(value); // \"= £7.85\" (exact output depends on live exchange rates)\n * ```\n */\nexport function formatValue(value: Value, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const localeCode = us.numberResult.decimalSeparatorLocale || \"en\";\n const locale = getLocale(localeCode);\n\n switch (value.type) {\n case ValueType.Number:\n // A measurement with a tolerance renders as \"center ± spread\"; every\n // other number is unchanged, so a plain value is byte-for-byte what it was.\n if (value.uncertainty !== undefined) {\n return formatUncertain(value.value as number, value.uncertainty, locale, us);\n }\n return formatNumber(value.value as number, locale, us, value.decimalPlaces);\n case ValueType.Hex:\n return formatHex(value.value as number | bigint, us, value.unit);\n case ValueType.BigInt:\n return formatBigInt(value.value as bigint);\n case ValueType.String:\n return formatString(value.value as string);\n case ValueType.Boolean:\n return formatBoolean(value.value as boolean);\n case ValueType.Datetime:\n return formatDatetime(value.value as number, locale, us);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact);\n case ValueType.Matrix:\n return formatMatrix(value.value as MatrixData, locale, us);\n case ValueType.Range: {\n const r = value.value as RangeData;\n return formatRange(r.min, r.max, locale);\n }\n case ValueType.Colour:\n return `${locale.display.resultPrefix}${formatColour(value.value as ColourData)}`;\n case ValueType.Split:\n return formatSplit(value.value as SplitData, locale, us);\n case ValueType.Symbolic:\n return formatSymbolic(value.value as SymbolicNode);\n case ValueType.Percentage:\n return formatPercentage(value.value as number, locale, us);\n case ValueType.Unit:\n return formatUnit(value.value as number, value.unit);\n case ValueType.Error:\n // errorValue(code, message) stores the human-readable message in\n // `.unit` (code goes in `.value`), falling through to the default\n // case here previously displayed the raw code (e.g.\n // \"CURRENCY_RATE_UNAVAILABLE\") instead of the actual message.\n return value.unit ?? String(value.value);\n default:\n return `= ${String(value.value)}`;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- var n=class{constructor(){this.resolvers=new Map;}register(e){this.resolvers.has(e.namespace)&&(console.warn(`[ResolverRegistry] Namespace "${e.namespace}" already registered. Destroying old resolver and overwriting. Use distinct namespaces (e.g., "${e.namespace}:sub1", "${e.namespace}:sub2") to avoid collisions when a package needs multiple async resolvers.`),this.resolvers.get(e.namespace).destroy()),this.resolvers.set(e.namespace,e);}unregister(e,r){let s=this.resolvers.get(e);s&&(s.destroy(),this.resolvers.delete(e)),r&&r.removeQueries({queryKey:[e]});}preflightAll(e,r,s,i,l){for(let t of this.resolvers.values()){if(!t.preflight)continue;let o=t.preflight(e,r,s,i,l);if(o)return o}return null}get(e){return this.resolvers.get(e)}get size(){return this.resolvers.size}has(e){return this.resolvers.has(e)}clear(){for(let e of this.resolvers.values())e.destroy();this.resolvers.clear();}};export{n as a};//# sourceMappingURL=chunk-7GK3XEZF.js.map
2
- //# sourceMappingURL=chunk-7GK3XEZF.js.map
1
+ var n=class{constructor(){this.resolvers=new Map;}register(e){this.resolvers.has(e.namespace)&&(console.warn(`[ResolverRegistry] Namespace "${e.namespace}" already registered. Destroying old resolver and overwriting. Use distinct namespaces (e.g., "${e.namespace}:sub1", "${e.namespace}:sub2") to avoid collisions when a package needs multiple async resolvers.`),this.resolvers.get(e.namespace).destroy()),this.resolvers.set(e.namespace,e);}unregister(e,r){let s=this.resolvers.get(e);s&&(s.destroy(),this.resolvers.delete(e)),r&&r.removeQueries({queryKey:[e]});}preflightAll(e,r,s,i,l){for(let t of this.resolvers.values()){if(!t.preflight)continue;let o=t.preflight(e,r,s,i,l);if(o)return o}return null}get(e){return this.resolvers.get(e)}get size(){return this.resolvers.size}has(e){return this.resolvers.has(e)}clear(){for(let e of this.resolvers.values())e.destroy();this.resolvers.clear();}};export{n as a};//# sourceMappingURL=chunk-7E7NXKQ5.js.map
2
+ //# sourceMappingURL=chunk-7E7NXKQ5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resolvers/ResolverRegistry.ts"],"names":["ResolverRegistry","resolver","namespace","queryClient","tokens","bytecode","packageId","signal","result"],"mappings":"AAqFO,IAAMA,EAAN,KAAuB,CAAvB,WAAA,EAAA,CACN,IAAA,CAAQ,UAAY,IAAI,IAAA,CAWxB,QAAA,CAASC,CAAAA,CAAgC,CAEpC,IAAA,CAAK,SAAA,CAAU,GAAA,CAAIA,CAAAA,CAAS,SAAS,CAAA,GACxC,OAAA,CAAQ,IAAA,CACP,CAAA,8BAAA,EAAiCA,EAAS,SAAS,CAAA,+FAAA,EAExCA,CAAAA,CAAS,SAAS,YAAYA,CAAAA,CAAS,SAAS,CAAA,0EAAA,CAE5D,CAAA,CACA,KAAK,SAAA,CAAU,GAAA,CAAIA,CAAAA,CAAS,SAAS,EAAG,OAAA,EAAQ,CAAA,CAEjD,IAAA,CAAK,SAAA,CAAU,IAAIA,CAAAA,CAAS,SAAA,CAAWA,CAAQ,EAChD,CAMA,UAAA,CAAWC,CAAAA,CAAmBC,CAAAA,CAAiC,CAC9D,IAAMF,CAAAA,CAAW,IAAA,CAAK,SAAA,CAAU,GAAA,CAAIC,CAAS,CAAA,CACzCD,CAAAA,GACHA,CAAAA,CAAS,OAAA,GACT,IAAA,CAAK,SAAA,CAAU,MAAA,CAAOC,CAAS,GAI5BC,CAAAA,EACHA,CAAAA,CAAY,aAAA,CAAc,CAAE,SAAU,CAACD,CAAS,CAAE,CAAC,EAErD,CASA,YAAA,CAAaE,CAAAA,CAAiBC,CAAAA,CAA2BC,EAAmBC,CAAAA,CAAqBJ,CAAAA,CAAmD,CACnJ,IAAA,IAAWF,KAAY,IAAA,CAAK,SAAA,CAAU,MAAA,EAAO,CAAG,CAC/C,GAAI,CAACA,CAAAA,CAAS,SAAA,CAAW,SACzB,IAAMO,CAAAA,CAASP,CAAAA,CAAS,SAAA,CAAUG,EAAQC,CAAAA,CAAUC,CAAAA,CAAWC,CAAAA,CAAQJ,CAAW,EAClF,GAAIK,CAAAA,CAAQ,OAAOA,CACpB,CACA,OAAO,IACR,CAMA,GAAA,CAAIN,EAA+C,CAClD,OAAO,IAAA,CAAK,SAAA,CAAU,IAAIA,CAAS,CACpC,CAGA,IAAI,MAAe,CAClB,OAAO,IAAA,CAAK,SAAA,CAAU,IACvB,CAKA,GAAA,CAAIA,CAAAA,CAA4B,CAC/B,OAAO,IAAA,CAAK,SAAA,CAAU,GAAA,CAAIA,CAAS,CACpC,CAMA,KAAA,EAAc,CACb,IAAA,IAAWD,KAAY,IAAA,CAAK,SAAA,CAAU,MAAA,EAAO,CAC5CA,EAAS,OAAA,EAAQ,CAElB,KAAK,SAAA,CAAU,KAAA,GAChB,CACD","file":"chunk-7E7NXKQ5.js","sourcesContent":["import type { QueryClient } from \"@tanstack/query-core\";\nimport type { Token } from \"@solve-js/lexer\";\nimport type { BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport type { Value } from \"@solve-js/vm/Value\";\n\n/**\n * Result from a resolver's preflight() check.\n * Returned when async data is needed, the orchestrator uses this\n * to subscribe to the resolver and return a Pending value immediately.\n */\nexport interface AsyncCheckResult {\n\t/** Unique cache key for deduplication (e.g., \"{packageId}:rates:USD:GBP\") */\n\tqueryKey: string;\n\t/** Promise that resolves to the final Value */\n\tresolver: Promise<Value>;\n\t/** Package owning this resolver */\n\tpackageId: string;\n\t/** AbortSignal for stale-data prevention */\n\tsignal: AbortSignal;\n\t/** Optional metadata for diagnostics */\n\tmetadata?: Record<string, unknown>;\n\t/**\n\t * Cadence, in ms, at which this value wants proactive background refresh\n\t * (a live quote every minute, an FX rate every few minutes). Absent, or\n\t * paired with no {@link refetch}, means pull-only: the value refreshes on\n\t * re-evaluation, never on its own. Only acted on when the host has enabled\n\t * background refresh; see {@link BackgroundRefreshConfig}.\n\t */\n\trefetchIntervalMs?: number;\n\t/**\n\t * Force a fresh fetch of this exact query, bypassing `staleTime`, and return\n\t * the new value. Supplied alongside {@link refetchIntervalMs} so the engine\n\t * can drive the background refresh without re-scanning bytecode.\n\t */\n\trefetch?: () => Promise<Value>;\n}\n\n/**\n * Interface for async resolvers registered by packages/plugins.\n *\n * Each resolver handles a domain of async data (currency rates,\n * weather, stock prices, etc.). The preflight() method is called\n * BEFORE VM execution to check if all data is cached. If not,\n * it returns an AsyncCheckResult and the engine skips the VM,\n * returning a Pending value instead.\n */\nexport interface IAsyncResolver {\n\t/** Unique namespace for cache key scoping (e.g., \"currency\", \"weather\") */\n\treadonly namespace: string;\n\n\t/**\n\t * Pre-flight check: called BEFORE VM execution.\n\t *\n\t * Returns null if all data for this expression is cached and ready.\n\t * Returns an AsyncCheckResult if async work is needed.\n\t *\n\t * This method is synchronous, it only checks caches, never fetches.\n\t * If data is missing, it creates a Promise and returns immediately.\n\t *\n\t * @param tokens - The lexed tokens for the expression\n\t * @param bytecode - The compiled bytecode program\n\t * @param pluginId - The plugin ID (for cache key scoping)\n\t * @param signal - AbortSignal for the current evaluation\n\t */\n\tpreflight?(tokens: Token[], bytecode: BytecodeProgram, packageId: string, signal: AbortSignal, queryClient: QueryClient): AsyncCheckResult | null;\n\n\t/**\n\t * Called when the resolver's namespace is being unregistered.\n\t * Clean up any in-flight promises, clear caches, unsubscribe.\n\t */\n\tdestroy(): void;\n}\n\n/**\n * Registry of async resolvers, keyed by namespace.\n *\n * Plugins/packages register resolvers alongside their parselets\n * and opcode handlers. The engine calls preflightAll() before\n * VM execution to short-circuit async expressions.\n *\n * Lifecycle:\n * - register(), when a package is loaded\n * - unregister(), when a package is unloaded (clears cache entries)\n * - clear(), on document switch (clears all resolvers)\n */\nexport class ResolverRegistry {\n\tprivate resolvers = new Map<string, IAsyncResolver>();\n\n\t/**\n\t * Register an async resolver.\n\t *\n\t * Each resolver must have a unique `namespace`. If a resolver with the\n\t * same namespace is already registered, the old one is destroyed and\n\t * replaced (with a console warning). Packages that need multiple async\n\t * operations should use `asyncResolvers: [...]` with distinct namespaces\n\t * (e.g., `\"weather:current\"`, `\"weather:forecast\"`).\n\t */\n\tregister(resolver: IAsyncResolver): void {\n\t\t// Clean up previous resolver with same namespace if any\n\t\tif (this.resolvers.has(resolver.namespace)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[ResolverRegistry] Namespace \"${resolver.namespace}\" already registered. ` +\n\t\t\t\t`Destroying old resolver and overwriting. Use distinct namespaces ` +\n\t\t\t\t`(e.g., \"${resolver.namespace}:sub1\", \"${resolver.namespace}:sub2\") ` +\n\t\t\t\t`to avoid collisions when a package needs multiple async resolvers.`,\n\t\t\t);\n\t\t\tthis.resolvers.get(resolver.namespace)!.destroy();\n\t\t}\n\t\tthis.resolvers.set(resolver.namespace, resolver);\n\t}\n\n\t/**\n\t * Unregister a resolver by namespace.\n\t * Calls destroy() and clears all cache entries with that namespace prefix.\n\t */\n\tunregister(namespace: string, queryClient?: QueryClient): void {\n\t\tconst resolver = this.resolvers.get(namespace);\n\t\tif (resolver) {\n\t\t\tresolver.destroy();\n\t\t\tthis.resolvers.delete(namespace);\n\t\t}\n\t\t// Clear all cache entries for this namespace via TanStack Query\n\t\t// Hierarchical keys: [\"osrs\"] clears all [\"osrs\", ...] queries\n\t\tif (queryClient) {\n\t\t\tqueryClient.removeQueries({ queryKey: [namespace] });\n\t\t}\n\t}\n\n\t/**\n\t * Run all registered resolvers' preflight checks against compiled bytecode.\n\t *\n\t * Returns the first AsyncCheckResult found, or null if all data is ready.\n\t * Short-circuits on first pending, subsequent pending ops will be\n\t * discovered on re-evaluation when the first resolves.\n\t */\n\tpreflightAll(tokens: Token[], bytecode: BytecodeProgram, packageId: string, signal: AbortSignal, queryClient: QueryClient): AsyncCheckResult | null {\n\t\tfor (const resolver of this.resolvers.values()) {\n\t\t\tif (!resolver.preflight) continue;\n\t\t\tconst result = resolver.preflight(tokens, bytecode, packageId, signal, queryClient);\n\t\t\tif (result) return result;\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get a resolver by namespace.\n\t * Returns undefined if no resolver is registered for that namespace.\n\t */\n\tget(namespace: string): IAsyncResolver | undefined {\n\t\treturn this.resolvers.get(namespace);\n\t}\n\n\t/** Number of registered resolvers. */\n\tget size(): number {\n\t\treturn this.resolvers.size;\n\t}\n\n\t/**\n\t * Check if a resolver is registered for the given namespace.\n\t */\n\thas(namespace: string): boolean {\n\t\treturn this.resolvers.has(namespace);\n\t}\n\n\t/**\n\t * Clear all resolvers (document switch, engine reset).\n\t * Calls destroy() on each resolver and clears the map.\n\t */\n\tclear(): void {\n\t\tfor (const resolver of this.resolvers.values()) {\n\t\t\tresolver.destroy();\n\t\t}\n\t\tthis.resolvers.clear();\n\t}\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import {a,d as d$1}from'./chunk-YVKHEAFT.js';import {a as a$1}from'./chunk-G7TBEQRQ.js';import {c}from'./chunk-IJMNVBIS.js';import {c as c$1}from'./chunk-MPB7KUN5.js';var A=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(67),e.emitIndex(1);}};var O=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(68),e.emitIndex(1);}};function L(t,o){let r=t.peek();if(!r||r.type!=="IDENT"&&r.type!=="UNIT")throw c$1.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${o} needs the name of an unknown here, as in ${o}(x^2, x).`,{found:r?.type??"end of input"});return t.consume(),r.value}function x(t,o){t.emitOpcode(13),t.emitString(o);}function N(t,o,r){let e=new d$1(o.pluginIndexMap);t.parseExpression(a.Lowest,e),t.setBuilder(o);let n=e.build();if(n.hasAsync)throw c$1.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${r}'s expression must be synchronous (no weather/stocks/currency calls).`);return n}function I(t,o,r){let e=t.emitAnonymousBody([r],o);t.emitOpcode(159),t.emitIndex(e);}var R=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN");let n=N(o,e,"solve"),m=o.match("EQUALS")?N(o,e,"solve"):null;o.consume("COMMA");let l=o.peek();if(!l||l.type!=="IDENT"&&l.type!=="UNIT")throw c$1.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:l?.type??"end of input"});o.consume(),I(e,n,l.value),m?I(e,m,l.value):(e.emitOpcode(10),e.emitNumber(0)),x(e,l.value),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(69),e.emitIndex(3);}};var g=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN");let n=N(o,e,"der");o.consume("COMMA");let m=L(o,"der");I(e,n,m),x(e,m),o.match("COMMA")?o.parseExpression(a.Lowest,e):(e.emitOpcode(10),e.emitNumber(1)),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(70),e.emitIndex(3);}};var C=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN");let n=N(o,e,"integral");o.consume("COMMA");let m=L(o,"integral");I(e,n,m),x(e,m),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(71),e.emitIndex(2);}};var M=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN");let n=N(o,e,"taylor");o.consume("COMMA");let m=L(o,"taylor");I(e,n,m),x(e,m),o.consume("EQUALS"),o.parseExpression(a.Lowest,e),o.consume("COMMA"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(72),e.emitIndex(4);}};var S=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN");let n=0;do o.parseExpression(a.Lowest,e),n++;while(o.match("COMMA"));o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(73),e.emitIndex(n);}};var k=class{constructor(){this.category="Symbolic";}parse(o,r,e){e.emitOpcode(10),e.emitNumber(Number(r.value)),e.emitOpcode(51),e.emitIndex(74),e.emitIndex(1);}};var v=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(75),e.emitIndex(1);}};var w=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(76),e.emitIndex(1);}};var U=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(77),e.emitIndex(1);}};var F=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(78),e.emitIndex(1);}};var h=class{constructor(){this.category="Symbolic";}parse(o,r,e){o.consume("LPAREN"),o.parseExpression(a.Lowest,e),o.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(79),e.emitIndex(1);}};function G(t=75){return {name:"symbolic:imaginary-literal",priority:t,match(o,r){let e=o[r];if(!e||e.type!=="NUMBER")return null;let n=o[r+1];return !n||n.type!=="IDENT"||n.value!=="i"||n.offset!==e.offset+e.value.length||o[r+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new a$1("IMAGINARY",c("IMAGINARY"),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:imaginary-literal"}}}}var ie={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function $(t=80){return {name:"symbolic:call",priority:t,match(o,r){let e=o[r];if(!e||e.type!=="IDENT")return null;let n=ie[e.value.toLowerCase()];return !n||o[r+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new a$1(n,c(n),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:call"}}}}var j=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"algebra.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"algebra.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"algebra.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"algebra.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"algebra.md"}],le={name:"solve-symbolic",normalizerRules:[$(),G()],prefixParselets:{EXPAND_FN:new A,FACTOR_FN:new O,SOLVE_FN:new R,DER_FN:new g,INTEGRAL_FN:new C,TAYLOR_FN:new M,JACOBIAN_FN:new S,IMAGINARY:new k,CONJ_FN:new v,RE_FN:new w,IM_FN:new U,CANCEL_FN:new F,APART_FN:new h},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},ae=new Set(j.map(t=>t.tokenType));function se(t){return t.some(o=>ae.has(o.type))}var ce=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function H(t){let o=t.trim();if(o.length>=2&&o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),!ce.test(o))return null;let r=new Date(o).getTime();return Number.isNaN(r)?null:r}function Eo(t){let o=new Date(t),r=E=>String(E).padStart(2,"0"),e=o.getFullYear(),n=r(o.getMonth()+1),m=r(o.getDate()),l=r(o.getHours()),s=r(o.getMinutes()),c=r(o.getSeconds()),p=-o.getTimezoneOffset(),y=p>=0?"+":"-",a=Math.abs(p),f=r(Math.floor(a/60)),u=r(a%60);return `${e}-${n}-${m}T${l}:${s}:${c}${y}${f}:${u}`}var pe=1e12;function Ao(t){return Math.abs(t)>=pe?t:t*1e3}var D="DATETIME_LITERAL",J=c(D),Y=/^\d+$/,ue=/^\d{1,2}\.\d{1,2}$/,de=/^\.(\d{2}|\d{4})$/,d=/^\d{1,2}$/;function fe(t){for(let o=0;o<t.length-1;o++){let r=t[o];if((r.sourceEnd??r.offset+r.text.length)!==t[o+1].offset)return false}return true}function b(t){if(t.length===4)return Number(t);if(t.length===2){let o=Number(t);return o<=68?2e3+o:1900+o}return null}function P(t,o,r,e,n){if(o<1||o>12||t<1||t>31)return null;let m=new Date(r,o-1,t);if(m.getFullYear()!==r||m.getMonth()!==o-1||m.getDate()!==t)return null;let l=e[0],s=e.map(p=>p.value).join(""),c=new a$1(D,J,String(m.getTime()),s,l.offset,0,l.line,l.col);return {consumed:e.length,replacement:[c],ruleName:n}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?/,Ie=new Set(["NUMBER","MINUS","PLUS","COLON","IDENT"]),xe=16;function ye(t,o,r){let e=t[o];if(e.sourceEnd!==void 0)return null;let n=e.text,m=e.offset+e.text.length,l=[e];for(let f=o+1;f<t.length&&l.length<xe;f++){let u=t[f];if(u.sourceEnd!==void 0||u.offset!==m||!Ie.has(u.type))break;n+=u.text,m=u.offset+u.text.length,l.push(u);}let s=Ne.exec(n);if(s===null)return null;let c=0,p=0;for(let f of l)if(p+=f.text.length,c++,p>=s[0].length)break;if(p!==s[0].length)return null;let y=H(s[0]);if(y===null)return null;let a=new a$1(D,J,String(y),s[0],e.offset,0,e.line,e.col,e.offset+s[0].length);return {consumed:c,replacement:[a],ruleName:r}}function Te(t,o,r,e){if(e==="YMD")return t.length!==4||!d.test(o)||!d.test(r)?null:{year:Number(t),month:Number(o),day:Number(r)};if(!d.test(t)||!d.test(o))return null;let n=b(r);return n===null?null:e==="DMY"?{day:Number(t),month:Number(o),year:n}:{day:Number(o),month:Number(t),year:n}}function Mo(t=()=>"auto"){return {name:"datetime:date-literal",priority:70,match(o,r){let e=o[r];if(e.type!=="NUMBER")return null;if(ue.test(e.value)){let a=o[r+1];if(a&&a.type==="NUMBER"&&de.test(a.value)){let[f,u]=e.value.split("."),E=b(a.value.slice(1));if(E!==null){let z=P(Number(f),Number(u),E,[e,a],"datetime:date-literal:dot");if(z)return z}}return null}if(e.value.length===4&&Y.test(e.value)){let a=ye(o,r,"datetime:date-literal:iso-timestamp");if(a)return a}if(!Y.test(e.value))return null;let n=o[r+1];if(!n||n.type!=="SLASH"&&n.type!=="MINUS")return null;let m=o[r+2],l=o[r+3],s=o[r+4];if(!m||m.type!=="NUMBER"||!Y.test(m.value)||!l||l.type!==n.type||!s||s.type!=="NUMBER"||!Y.test(s.value))return null;let c=[e,n,m,l,s];if(!fe(c))return null;let p=t();if(p!=="auto"){let a=Te(e.value,m.value,s.value,p);return a===null?null:P(a.day,a.month,a.year,c,`datetime:date-literal:${p.toLowerCase()}`)}if(n.type==="SLASH"){if(!d.test(e.value)||!d.test(m.value))return null;let a=b(s.value);return a===null?null:P(Number(e.value),Number(m.value),a,c,"datetime:date-literal:european")}if(e.value.length===4)return !d.test(m.value)||!d.test(s.value)?null:P(Number(s.value),Number(m.value),Number(e.value),c,"datetime:date-literal:iso");if(!d.test(e.value)||!d.test(m.value))return null;let y=b(s.value);return y===null?null:P(Number(m.value),Number(e.value),y,c,"datetime:date-literal:us")}}}export{le as a,se as b,H as c,Eo as d,Ao as e,D as f,P as g,Mo as h};//# sourceMappingURL=chunk-AR7L5OJ2.js.map
2
+ //# sourceMappingURL=chunk-AR7L5OJ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/packages/symbolic/parselets/ExpandParselet.ts","../src/packages/symbolic/parselets/FactorParselet.ts","../src/packages/symbolic/parselets/VariableArgument.ts","../src/packages/symbolic/parselets/SolveParselet.ts","../src/packages/symbolic/parselets/DerParselet.ts","../src/packages/symbolic/parselets/IntegralParselet.ts","../src/packages/symbolic/parselets/TaylorParselet.ts","../src/packages/symbolic/parselets/JacobianParselet.ts","../src/packages/symbolic/parselets/ImaginaryParselet.ts","../src/packages/symbolic/parselets/ConjParselet.ts","../src/packages/symbolic/parselets/ReParselet.ts","../src/packages/symbolic/parselets/ImParselet.ts","../src/packages/symbolic/parselets/CancelParselet.ts","../src/packages/symbolic/parselets/ApartParselet.ts","../src/packages/symbolic/normalizer/ImaginaryLiteralNormalizerRule.ts","../src/packages/symbolic/normalizer/SymbolicCallNormalizerRule.ts","../src/packages/symbolic/SymbolicPackage.ts","../src/packages/datetime/Iso8601.ts","../src/packages/datetime/normalizer/DateLiteralNormalizerRule.ts"],"names":["ExpandParselet","parser","_token","builder","BindingPower","FactorParselet","readVariableName","verb","token","ErrorFactory","emitVariableName","name","parseBoundExpression","inner","BytecodeBuilder","program","emitBoundExpression","index","SolveParselet","left","right","variable","DerParselet","expression","IntegralParselet","TaylorParselet","JacobianParselet","count","ImaginaryParselet","_parser","ConjParselet","ReParselet","ImParselet","CancelParselet","ApartParselet","imaginaryLiteralNormalizerRule","priority","tokens","pos","number","suffix","LexerToken","tokenTypeId","SYMBOLIC_WORD_TO_TOKEN_TYPE","symbolicCallNormalizerRule","tokenType","SYMBOLIC_FUNCTIONS","SYMBOLIC_PACKAGE","SYMBOLIC_TOKEN_TYPES","fn","containsSymbolicCall","ISO8601_PATTERN","parseIso8601","s","trimmed","ms","formatIso8601Local","epochMs","d","pad","n","year","month","day","hours","minutes","seconds","offsetMinutesTotal","sign","absOffset","offsetHours","offsetMinutes","MS_TIMESTAMP_THRESHOLD","unixTimestampToEpochMs","DATETIME_LITERAL_TYPE","DATETIME_LITERAL_TYPE_ID","PLAIN_INTEGER","DOT_DAY_MONTH","DOT_LEADING_YEAR","DAY_OR_MONTH","writtenAsOneRun","i","resolveYear","digits","yy","buildDateToken","sourceTokens","ruleName","date","first","text","t","fusedToken","ISO_TIMESTAMP","ISO_TOKEN_TYPES","ISO_MAX_TOKENS","fuseIsoTimestamp","runEnd","window","next","matched","consumed","covered","resolveOrderedGroups","g0","g1","g2","order","dateLiteralNormalizerRule","getInputOrder","t0","t1","dayText","monthText","match","timestamp","sep1","sep2","t2","resolved"],"mappings":"uKAoBO,IAAMA,CAAAA,CAAN,KAA+C,CAA/C,WAAA,EAAA,CACN,IAAA,CAAS,QAAA,CAAW,WAAA,CAEpB,KAAA,CAAMC,CAAAA,CAAgBC,CAAAA,CAAeC,CAAAA,CAAgC,CACpEF,EAAO,OAAA,CAAQ,QAAQ,CAAA,CACvBA,CAAAA,CAAO,eAAA,CAAgBG,CAAAA,CAAa,MAAA,CAAQD,CAAO,EACnDF,CAAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAEvBE,CAAAA,CAAQ,UAAA,CAAA,EAA8B,CAAA,CACtCA,CAAAA,CAAQ,UAAU,EAAuB,CAAA,CACzCA,CAAAA,CAAQ,SAAA,CAAU,CAAC,EACpB,CACD,CAAA,CCZO,IAAME,CAAAA,CAAN,KAA+C,CAA/C,WAAA,EAAA,CACN,IAAA,CAAS,QAAA,CAAW,WAAA,CAEpB,KAAA,CAAMJ,EAAgBC,CAAAA,CAAeC,CAAAA,CAAgC,CACpEF,CAAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CACvBA,CAAAA,CAAO,gBAAgBG,CAAAA,CAAa,MAAA,CAAQD,CAAO,CAAA,CACnDF,CAAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,CAEvBE,EAAQ,UAAA,CAAA,EAA8B,CAAA,CACtCA,CAAAA,CAAQ,SAAA,CAAU,EAAuB,CAAA,CACzCA,CAAAA,CAAQ,SAAA,CAAU,CAAC,EACpB,CACD,CAAA,CCRO,SAAS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,CAAA,CAAG,OAAO,IAAA,CACzE,IAAMlD,CAAAA,CAAOqB,CAAAA,CAAYoC,CAAAA,CAAG,KAAK,EACjC,OAAIzD,CAAAA,GAAS,IAAA,CAAa,IAAA,CAEnBwB,CAAAA,CAAe,MAAA,CAAO0B,CAAAA,CAAG,KAAK,EAAG,MAAA,CAAOD,CAAAA,CAAG,KAAK,CAAA,CAAGjD,CAAAA,CAAMyB,CAAAA,CAAc,0BAA0B,CAC1G,CACF,CACF","file":"chunk-AR7L5OJ2.js","sourcesContent":["import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_EXPAND } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `expand(expr)`, multiplying out every product and power.\n *\n * A dedicated parselet rather than a `builtinNameToIndex` entry reached through\n * the ordinary `FunctionCallParselet`, because that route needs the lexer to\n * emit `FUNC` for the word, which means a `keywordMap` entry, which would stop\n * `expand` working as an ordinary variable name. See\n * `normalizer/SymbolicCallNormalizerRule.ts`.\n *\n * The emitted bytecode is an ordinary `CALL_BUILTIN`, so no new opcode and no\n * new VM dispatch arm is involved.\n */\nexport class ExpandParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_EXPAND);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_FACTOR } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `factor(expr)`, writing a polynomial as a product of irreducible factors over the rationals.\n *\n * A dedicated parselet rather than a `builtinNameToIndex` entry reached through\n * the ordinary `FunctionCallParselet`, because that route needs the lexer to\n * emit `FUNC` for the word, which means a `keywordMap` entry, which would stop\n * `expand` working as an ordinary variable name. See\n * `normalizer/SymbolicCallNormalizerRule.ts`.\n *\n * The emitted bytecode is an ordinary `CALL_BUILTIN`, so no new opcode and no\n * new VM dispatch arm is involved.\n */\nexport class FactorParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_FACTOR);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { Parser } from \"@solve-js/parser/Parser\";\nimport { BytecodeBuilder, type BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Reads a bare variable name argument and returns it, consuming the token.\n *\n * Shared by every algebra verb that takes \"which unknown\" as an argument.\n * Compiling the name as an ordinary variable read would require it to already\n * have a value, which is precisely what differentiating or solving with respect\n * to it says it does not.\n *\n * Requiring `IDENT` or `UNIT` here gives the same reserved-word protection\n * `VariableParselet` relies on: a keyword always lexes as its own token type,\n * so it can never reach this position and be taken for a variable name.\n *\n * @param parser - The parser, positioned at the name.\n * @param verb - The calling verb's name, for the error message.\n * @returns The name as written.\n * @throws {EngineError} `SYMBOLIC_REQUIRES_VARIABLE_NAME` when the next token is\n * not a bare name.\n */\nexport function readVariableName(parser: Parser, verb: string): string {\n\tconst token = parser.peek();\n\tif (!token || (token.type !== \"IDENT\" && token.type !== \"UNIT\")) {\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"SYMBOLIC_REQUIRES_VARIABLE_NAME\",\n\t\t\t`${verb} needs the name of an unknown here, as in ${verb}(x^2, x).`,\n\t\t\t{ found: token?.type ?? \"end of input\" },\n\t\t);\n\t}\n\tparser.consume();\n\treturn token.value;\n}\n\n/**\n * Reads a bare variable name argument and emits it as a string constant.\n *\n * Pushing the name as a String means the builtin receives it directly and the\n * VM needs no special case.\n *\n * @param parser - The parser, positioned at the name.\n * @param builder - The bytecode builder to emit into.\n * @param verb - The calling verb's name, for the error message.\n */\nexport function consumeVariableName(parser: Parser, builder: BytecodeBuilder, verb: string): void {\n\temitVariableName(builder, readVariableName(parser, verb));\n}\n\n/** Emits an already-read unknown's name as the String argument the algebra builtins read it as. */\nexport function emitVariableName(builder: BytecodeBuilder, name: string): void {\n\tbuilder.emitOpcode(OpCode.PUSH_STRING);\n\tbuilder.emitString(name);\n}\n\n/**\n * Parses an algebra verb's expression argument into its own independent\n * program, rather than emitting it inline.\n *\n * The verb names its unknown AFTER the expression (`der(x^2, x)`), so the\n * expression has to be held rather than emitted: only once the name is known\n * can it be paired with {@link emitBoundExpression}, which is what makes the\n * name shadow any document value it happens to share. Compiled into an\n * isolated builder exactly like a user-defined function body or a map/reduce\n * transform, and `parseExpression` leaves `parser.builder` pointing at the\n * isolated one with no automatic restore, so the caller's builder is put back\n * before returning.\n *\n * @param parser - The parser, positioned at the start of the expression.\n * @param builder - The builder to restore afterwards.\n * @param verb - The calling verb's name, for the error message.\n * @returns The compiled expression, to be handed to {@link emitBoundExpression}.\n */\nexport function parseBoundExpression(parser: Parser, builder: BytecodeBuilder, verb: string): BytecodeProgram {\n\tconst inner = new BytecodeBuilder(builder.pluginIndexMap);\n\tparser.parseExpression(BindingPower.Lowest, inner);\n\tparser.setBuilder(builder);\n\tconst program = inner.build();\n\tif (program.hasAsync) {\n\t\t// Same v1 restriction every other deferred body carries (user-defined\n\t\t// functions, map/reduce transforms): a reentrant execution cannot\n\t\t// suspend and resume the outer expression around an async result.\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS\",\n\t\t\t`${verb}'s expression must be synchronous (no weather/stocks/currency calls).`,\n\t\t);\n\t}\n\treturn program;\n}\n\n/**\n * Emits a held expression so that it evaluates with `name` bound to itself.\n *\n * This is what makes `der(x^2, x)` mean the derivative of a square rather than\n * the derivative of a constant on a page that also says `:x = 5`. Naming `x` as\n * the verb's argument declares it bound, so within the expression it is an\n * unknown and nothing else, exactly the way a function's parameter shadows a\n * document variable of the same name inside its body. Before this, the\n * expression was compiled inline and its `x` was an ordinary variable read, so\n * the verb received 25 and answered 0 with no indication that it had not been\n * asked the question the user wrote.\n *\n * @param builder - The builder to emit into.\n * @param program - The expression, from {@link parseBoundExpression}.\n * @param name - The unknown the verb named, bound for the expression's evaluation.\n */\nexport function emitBoundExpression(builder: BytecodeBuilder, program: BytecodeProgram, name: string): void {\n\tconst index = builder.emitAnonymousBody([name], program);\n\tbuilder.emitOpcode(OpCode.BIND_UNKNOWN);\n\tbuilder.emitIndex(index);\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { SYMBOLIC_BUILTIN_SOLVE } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\nimport { emitVariableName, parseBoundExpression, emitBoundExpression } from \"@solve-js/packages/symbolic/parselets/VariableArgument\";\n\n/**\n * `solve(equation, variable)`, for example `solve(x^2-4=0, x)`.\n *\n * Two things here cannot go through the ordinary function-call grammar, which\n * is why this is a hand-written parselet.\n *\n * The first argument contains a bare `=`, which no infix parselet consumes, so\n * an ordinary argument list would fail to parse it. This reads the two sides\n * separately and lets a missing right-hand side default to zero, so\n * `solve(x^2-4, x)` means the same as `solve(x^2-4=0, x)`.\n *\n * The second argument is a *name*, not a value. Compiling it as a `LOAD_VAR`\n * would demand that the variable already exist, which is exactly what solving\n * for it says it does not. Emitting it as a `PUSH_STRING` instead means the\n * builtin receives a plain String value and the VM needs no change at all.\n *\n * Both sides of the equation are held until that name has been read, so each\n * evaluates with the unknown bound to itself rather than to whatever value the\n * document may already have given it. See {@link emitBoundExpression}: with\n * `:x = 5` above it, `solve(x^2-4=0, x)` was solving `21 = 0` and reporting,\n * accurately for the question it was asked and uselessly for the one written,\n * that there is no solution.\n */\nexport class SolveParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tconst left = parseBoundExpression(parser, builder, \"solve\");\n\t\tconst right = parser.match(\"EQUALS\") ? parseBoundExpression(parser, builder, \"solve\") : null;\n\n\t\tparser.consume(\"COMMA\");\n\t\t// Requiring IDENT or UNIT here is the same protection VariableParselet\n\t\t// relies on: a reserved word always lexes as its own token type, so it\n\t\t// can never reach this position and be mistaken for a variable name.\n\t\tconst variable = parser.peek();\n\t\tif (!variable || (variable.type !== \"IDENT\" && variable.type !== \"UNIT\")) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"SOLVE_REQUIRES_VARIABLE_NAME\",\n\t\t\t\t`solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).`,\n\t\t\t\t{ found: variable?.type ?? \"end of input\" },\n\t\t\t);\n\t\t}\n\t\tparser.consume();\n\n\t\temitBoundExpression(builder, left, variable.value);\n\t\tif (right) {\n\t\t\temitBoundExpression(builder, right, variable.value);\n\t\t} else {\n\t\t\t// No `=` written, so the equation is \"this expression equals zero\".\n\t\t\tbuilder.emitOpcode(OpCode.PUSH_NUMBER);\n\t\t\tbuilder.emitNumber(0);\n\t\t}\n\t\temitVariableName(builder, variable.value);\n\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_SOLVE);\n\t\tbuilder.emitIndex(3);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_DER } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\nimport { readVariableName, emitVariableName, parseBoundExpression, emitBoundExpression } from \"@solve-js/packages/symbolic/parselets/VariableArgument\";\n\n/**\n * `der(expr, variable)` and `der(expr, variable, order)`, the symbolic\n * derivative. `derivative` is accepted as the same thing.\n *\n * The variable is emitted as a string rather than compiled as a variable read,\n * for the reason given in {@link readVariableName}, and `expr` is held until\n * that name is known so it can be evaluated with the name bound. See\n * {@link emitBoundExpression}.\n */\nexport class DerParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tconst expression = parseBoundExpression(parser, builder, \"der\");\n\t\tparser.consume(\"COMMA\");\n\t\tconst variable = readVariableName(parser, \"der\");\n\t\temitBoundExpression(builder, expression, variable);\n\t\temitVariableName(builder, variable);\n\n\t\t// The order is optional and defaults to a first derivative.\n\t\tif (parser.match(\"COMMA\")) {\n\t\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\t} else {\n\t\t\tbuilder.emitOpcode(OpCode.PUSH_NUMBER);\n\t\t\tbuilder.emitNumber(1);\n\t\t}\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_DER);\n\t\tbuilder.emitIndex(3);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { SYMBOLIC_BUILTIN_INTEGRAL } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\nimport { readVariableName, emitVariableName, parseBoundExpression, emitBoundExpression } from \"@solve-js/packages/symbolic/parselets/VariableArgument\";\n\n/**\n * `integral(expr, variable)`, the indefinite integral, without a constant of\n * integration. `expr` is held until the variable is read so that the named\n * unknown shadows any document value of the same name, see\n * {@link emitBoundExpression}.\n */\nexport class IntegralParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tconst expression = parseBoundExpression(parser, builder, \"integral\");\n\t\tparser.consume(\"COMMA\");\n\t\tconst variable = readVariableName(parser, \"integral\");\n\t\temitBoundExpression(builder, expression, variable);\n\t\temitVariableName(builder, variable);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_INTEGRAL);\n\t\tbuilder.emitIndex(2);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_TAYLOR } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\nimport { readVariableName, emitVariableName, parseBoundExpression, emitBoundExpression } from \"@solve-js/packages/symbolic/parselets/VariableArgument\";\n\n/**\n * `taylor(expr, variable = point, degree)`, matching Calca's own spelling.\n *\n * The `variable = point` argument is why this needs a hand-written parselet:\n * `EQUALS` has no infix parselet, so an ordinary argument list cannot parse it.\n * Reading the name and the point separately also means the name never has to\n * exist as a variable, and `expr` is held until the name is known so that the\n * name shadows any document value it shares (see {@link emitBoundExpression}).\n * The expansion point is an ordinary value expression and is not shadowed: it\n * is a number, not the unknown.\n */\nexport class TaylorParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tconst expression = parseBoundExpression(parser, builder, \"taylor\");\n\t\tparser.consume(\"COMMA\");\n\t\tconst variable = readVariableName(parser, \"taylor\");\n\t\temitBoundExpression(builder, expression, variable);\n\t\temitVariableName(builder, variable);\n\t\tparser.consume(\"EQUALS\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"COMMA\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_TAYLOR);\n\t\tbuilder.emitIndex(4);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_JACOBIAN } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `jacobian(f1, f2, ...)`, the matrix of partial derivatives.\n *\n * Variadic, and the variables are not named: they are taken from the union of\n * the functions' own unknowns, sorted, which is what Calca does. Row `i` is the\n * gradient of the `i`-th function.\n */\nexport class JacobianParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tlet count = 0;\n\t\tdo {\n\t\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\t\tcount++;\n\t\t} while (parser.match(\"COMMA\"));\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_JACOBIAN);\n\t\tbuilder.emitIndex(count);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { SYMBOLIC_BUILTIN_IMAGINARY } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * An imaginary literal, `3i`, fused by\n * `normalizer/ImaginaryLiteralNormalizerRule.ts`.\n *\n * The token carries the numeric part as its value; this pushes that number and\n * lets the builtin turn it into an exact imaginary value. Going through a\n * builtin rather than a dedicated opcode keeps the VM dispatch table untouched,\n * the same choice every other algebra verb made.\n */\nexport class ImaginaryParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(_parser: Parser, token: Token, builder: BytecodeBuilder): void {\n\t\tbuilder.emitOpcode(OpCode.PUSH_NUMBER);\n\t\tbuilder.emitNumber(Number(token.value));\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_IMAGINARY);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_CONJ } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `conj(z)`, the complex conjugate.\n *\n * A dedicated parselet rather than a keywordMap entry, for the reason given in\n * `normalizer/SymbolicCallNormalizerRule.ts`: `re` and `im` are short words a\n * person may well use as variable names.\n */\nexport class ConjParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_CONJ);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_RE } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `re(z)`, the real part of a complex value.\n *\n * A dedicated parselet rather than a keywordMap entry, for the reason given in\n * `normalizer/SymbolicCallNormalizerRule.ts`: `re` and `im` are short words a\n * person may well use as variable names.\n */\nexport class ReParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_RE);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_IM } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `im(z)`, the imaginary part of a complex value.\n *\n * A dedicated parselet rather than a keywordMap entry, for the reason given in\n * `normalizer/SymbolicCallNormalizerRule.ts`: `re` and `im` are short words a\n * person may well use as variable names.\n */\nexport class ImParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_IM);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_CANCEL } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `cancel(expr)`, reducing a quotient of polynomials to lowest terms.\n *\n * The simplifier already cancels a common factor automatically; this is the\n * explicit form, for when the intent is to reduce a fraction rather than to\n * evaluate something that happens to contain one.\n */\nexport class CancelParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_CANCEL);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import { PrefixParselet } from \"@solve-js/parser/Parselet\";\nimport { Parser } from \"@solve-js/parser/Parser\";\nimport { Token } from \"@solve-js/lexer/Token\";\nimport { BytecodeBuilder } from \"@solve-js/parser/BytecodeBuilder\";\nimport { OpCode } from \"@solve-js/parser/OpCode\";\nimport { BindingPower } from \"@solve-js/parser/BindingPower\";\nimport { SYMBOLIC_BUILTIN_APART } from \"@solve-js/packages/symbolic/SymbolicBuiltinIndex\";\n\n/**\n * `apart(expr)`, splitting a rational function into partial fractions.\n *\n * The inverse of putting a sum of fractions over a common denominator, and the\n * step that makes a rational function integrable.\n */\nexport class ApartParselet implements PrefixParselet {\n\treadonly category = \"Symbolic\";\n\n\tparse(parser: Parser, _token: Token, builder: BytecodeBuilder): void {\n\t\tparser.consume(\"LPAREN\");\n\t\tparser.parseExpression(BindingPower.Lowest, builder);\n\t\tparser.consume(\"RPAREN\");\n\n\t\tbuilder.emitOpcode(OpCode.CALL_BUILTIN);\n\t\tbuilder.emitIndex(SYMBOLIC_BUILTIN_APART);\n\t\tbuilder.emitIndex(1);\n\t}\n}\n","import type { Token } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\nimport { LexerToken } from \"@solve-js/lexer/ExpressionLexer\";\nimport type { NormalizerRule, NormalizerMatch } from \"@solve-js/normalizer/NormalizerRule\";\n\n/**\n * Fuses `3i` into a single imaginary literal, but only when the `i` is written\n * flush against the number.\n *\n * `i` is not claimed as a keyword, and deliberately so. It is one of the most\n * common variable names there is, and this engine's whole trigger-word policy\n * exists to avoid taking words a person would reasonably assign to. `:i = 5`\n * has to keep working, and after this rule it does: the rule only fires on a\n * number immediately followed by the letter, which is the same shape the\n * magnitude suffixes use, and `2.5k` set that precedent.\n *\n * Adjacency is checked by source offset rather than by token order, so `3i` is\n * an imaginary literal while `3 i` and `3 * i` are a number multiplied by a\n * variable named `i`. That is the distinction that keeps both readings\n * available, and it is the reason a bare `i` on its own is still a variable.\n * Write `1i` for the imaginary unit alone.\n */\nexport function imaginaryLiteralNormalizerRule(priority = 75): NormalizerRule {\n\treturn {\n\t\tname: \"symbolic:imaginary-literal\",\n\t\tpriority,\n\t\tmatch(tokens: Token[], pos: number): NormalizerMatch | null {\n\t\t\tconst number = tokens[pos];\n\t\t\tif (!number || number.type !== \"NUMBER\") return null;\n\n\t\t\tconst suffix = tokens[pos + 1];\n\t\t\tif (!suffix || suffix.type !== \"IDENT\" || suffix.value !== \"i\") return null;\n\n\t\t\t// Flush against the number, with no space between them.\n\t\t\tif (suffix.offset !== number.offset + number.value.length) return null;\n\n\t\t\t// A following `(` would make this a call, as in `3i(x)`, which is not a\n\t\t\t// shape this claims.\n\t\t\tif (tokens[pos + 2]?.type === \"LPAREN\") return null;\n\n\t\t\treturn {\n\t\t\t\tconsumed: 2,\n\t\t\t\treplacement: [\n\t\t\t\t\tnew LexerToken(\n\t\t\t\t\t\t\"IMAGINARY\",\n\t\t\t\t\t\ttokenTypeId(\"IMAGINARY\"),\n\t\t\t\t\t\tnumber.value,\n\t\t\t\t\t\tnumber.value,\n\t\t\t\t\t\tnumber.offset,\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tnumber.line,\n\t\t\t\t\t\tnumber.col,\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\truleName: \"symbolic:imaginary-literal\",\n\t\t\t};\n\t\t},\n\t};\n}\n","import type { Token } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\nimport { LexerToken } from \"@solve-js/lexer/ExpressionLexer\";\nimport type { NormalizerRule, NormalizerMatch } from \"@solve-js/normalizer/NormalizerRule\";\n\n/**\n * The algebra verbs, mapped to the token type each becomes when it is being\n * called.\n *\n * Kept in one place so {@link SYMBOLIC_FUNCTIONS} in `SymbolicPackage.ts` and\n * this rule cannot disagree about which words the package claims.\n */\nexport const SYMBOLIC_WORD_TO_TOKEN_TYPE: Readonly<Record<string, string>> = {\n\texpand: \"EXPAND_FN\",\n\tfactor: \"FACTOR_FN\",\n\tsolve: \"SOLVE_FN\",\n\tder: \"DER_FN\",\n\tderivative: \"DER_FN\",\n\tintegral: \"INTEGRAL_FN\",\n\ttaylor: \"TAYLOR_FN\",\n\tjacobian: \"JACOBIAN_FN\",\n\tconj: \"CONJ_FN\",\n\tre: \"RE_FN\",\n\tim: \"IM_FN\",\n\tcancel: \"CANCEL_FN\",\n\tapart: \"APART_FN\",\n};\n\n/**\n * Fuses an algebra verb into its own token type, but only when the bare word is\n * immediately followed by `(`.\n *\n * None of these words may be a plain `keywordMap` entry, and the reason is\n * concrete rather than stylistic. A `keywordMap` entry makes the lexer emit a\n * reserved token type everywhere the word appears, which would break\n * `:factor = 1.5` and `:solve = 2` as ordinary variable names. `solve` is also\n * the product's own name and `factor` is an everyday English noun, so both are\n * words a user will reasonably assign to.\n *\n * Mirrors `packages/mapreduce/normalizer/MapReduceCallNormalizerRule.ts`, which\n * exists for exactly this reason for `map`/`reduce`/`sum`/`prod`.\n *\n * @param priority - Rule ordering within the normalizer, defaulting to the same\n * band the map/reduce call rule uses.\n * @returns The normalizer rule.\n */\nexport function symbolicCallNormalizerRule(priority = 80): NormalizerRule {\n\treturn {\n\t\tname: \"symbolic:call\",\n\t\tpriority,\n\t\tmatch(tokens: Token[], pos: number): NormalizerMatch | null {\n\t\t\tconst token = tokens[pos];\n\t\t\tif (!token || token.type !== \"IDENT\") return null;\n\t\t\tconst tokenType = SYMBOLIC_WORD_TO_TOKEN_TYPE[token.value.toLowerCase()];\n\t\t\tif (!tokenType) return null;\n\t\t\tif (tokens[pos + 1]?.type !== \"LPAREN\") return null;\n\n\t\t\treturn {\n\t\t\t\tconsumed: 1,\n\t\t\t\treplacement: [\n\t\t\t\t\tnew LexerToken(tokenType, tokenTypeId(tokenType), token.value, token.value, token.offset, 0, token.line, token.col),\n\t\t\t\t],\n\t\t\t\truleName: \"symbolic:call\",\n\t\t\t};\n\t\t},\n\t};\n}\n","import type { IEnginePackage } from \"@solve-js/api/PackageRegistry\";\nimport { ExpandParselet } from \"./parselets/ExpandParselet\";\nimport { FactorParselet } from \"./parselets/FactorParselet\";\nimport { SolveParselet } from \"./parselets/SolveParselet\";\nimport { DerParselet } from \"./parselets/DerParselet\";\nimport { IntegralParselet } from \"./parselets/IntegralParselet\";\nimport { TaylorParselet } from \"./parselets/TaylorParselet\";\nimport { JacobianParselet } from \"./parselets/JacobianParselet\";\nimport { ImaginaryParselet } from \"./parselets/ImaginaryParselet\";\nimport { ConjParselet } from \"./parselets/ConjParselet\";\nimport { ReParselet } from \"./parselets/ReParselet\";\nimport { ImParselet } from \"./parselets/ImParselet\";\nimport { CancelParselet } from \"./parselets/CancelParselet\";\nimport { ApartParselet } from \"./parselets/ApartParselet\";\nimport { imaginaryLiteralNormalizerRule } from \"./normalizer/ImaginaryLiteralNormalizerRule\";\nimport { symbolicCallNormalizerRule } from \"./normalizer/SymbolicCallNormalizerRule\";\nimport {\n\tSYMBOLIC_BUILTIN_EXPAND,\n\tSYMBOLIC_BUILTIN_FACTOR,\n\tSYMBOLIC_BUILTIN_SOLVE,\n\tSYMBOLIC_BUILTIN_DER,\n\tSYMBOLIC_BUILTIN_INTEGRAL,\n\tSYMBOLIC_BUILTIN_TAYLOR,\n\tSYMBOLIC_BUILTIN_JACOBIAN,\n\tSYMBOLIC_BUILTIN_CONJ,\n\tSYMBOLIC_BUILTIN_RE,\n\tSYMBOLIC_BUILTIN_IM,\n\tSYMBOLIC_BUILTIN_CANCEL,\n\tSYMBOLIC_BUILTIN_APART,\n} from \"./SymbolicBuiltinIndex\";\n\n/**\n * One algebra verb's whole surface, in a single row.\n *\n * Everything a verb needs in order to work is listed here rather than being\n * spread across the normalizer, the parselet registry, the builtin table and\n * the docs, so `__tests__/engine/SymbolicSurfaceParity.spec.ts` can check the\n * pieces actually agree. Shipping a verb whose index has no implementation, or\n * whose parselet is registered under a token type the normalizer never mints,\n * then becomes a failing test rather than a silent dead feature.\n */\nexport interface SymbolicFunctionSurface {\n\t/** The bare word a user types. */\n\treadonly word: string;\n\t/** The token type the normalizer fuses it into when it is followed by `(`. */\n\treadonly tokenType: string;\n\t/** The `CALL_BUILTIN` index its parselet emits. */\n\treadonly builtinIndex: number;\n\t/** A working example, executed by the parity spec through every public entry point. */\n\treadonly example: string;\n\t/** That example's expected formatted result. */\n\treadonly expected: string;\n\t/** The documentation page under `docs/src/content/docs/syntax/` that must show it. */\n\treadonly docPage: string;\n}\n\n/** Every algebra verb this package registers. */\nexport const SYMBOLIC_FUNCTIONS: readonly SymbolicFunctionSurface[] = [\n\t{\n\t\tword: \"expand\",\n\t\ttokenType: \"EXPAND_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_EXPAND,\n\t\texample: \"expand((x+1)*(x+2))\",\n\t\texpected: \"x^2+3x+2\",\n\t\tdocPage: \"algebra.md\",\n\t},\n\t{\n\t\tword: \"factor\",\n\t\ttokenType: \"FACTOR_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_FACTOR,\n\t\texample: \"factor(x^2-4)\",\n\t\texpected: \"(x-2)*(x+2)\",\n\t\tdocPage: \"algebra.md\",\n\t},\n\t{\n\t\tword: \"solve\",\n\t\ttokenType: \"SOLVE_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_SOLVE,\n\t\texample: \"solve(x^2-4=0, x)\",\n\t\texpected: \"= [-2, 2]\",\n\t\tdocPage: \"algebra.md\",\n\t},\n\t{\n\t\tword: \"der\",\n\t\ttokenType: \"DER_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_DER,\n\t\texample: \"der(x^3, x)\",\n\t\texpected: \"3x^2\",\n\t\tdocPage: \"calculus.md\",\n\t},\n\t{\n\t\tword: \"integral\",\n\t\ttokenType: \"INTEGRAL_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_INTEGRAL,\n\t\texample: \"integral(x^2, x)\",\n\t\texpected: \"1/3x^3\",\n\t\tdocPage: \"calculus.md\",\n\t},\n\t{\n\t\tword: \"taylor\",\n\t\ttokenType: \"TAYLOR_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_TAYLOR,\n\t\texample: \"taylor(exp(x), x=0, 3)\",\n\t\texpected: \"1/6x^3+0.5x^2+x+1\",\n\t\tdocPage: \"calculus.md\",\n\t},\n\t{\n\t\tword: \"jacobian\",\n\t\ttokenType: \"JACOBIAN_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_JACOBIAN,\n\t\texample: \"jacobian(x*y, x+y)\",\n\t\texpected: \"= [y, x; 1, 1]\",\n\t\tdocPage: \"calculus.md\",\n\t},\n\t{\n\t\tword: \"conj\",\n\t\ttokenType: \"CONJ_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_CONJ,\n\t\texample: \"conj(2+3i)\",\n\t\texpected: \"2-3i\",\n\t\tdocPage: \"complex.md\",\n\t},\n\t{\n\t\tword: \"re\",\n\t\ttokenType: \"RE_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_RE,\n\t\texample: \"re(2+3i)\",\n\t\texpected: \"= 2\",\n\t\tdocPage: \"complex.md\",\n\t},\n\t{\n\t\tword: \"im\",\n\t\ttokenType: \"IM_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_IM,\n\t\texample: \"im(2+3i)\",\n\t\texpected: \"= 3\",\n\t\tdocPage: \"complex.md\",\n\t},\n\t{\n\t\tword: \"cancel\",\n\t\ttokenType: \"CANCEL_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_CANCEL,\n\t\texample: \"cancel((x^2-1)/(x-1))\",\n\t\texpected: \"x+1\",\n\t\tdocPage: \"algebra.md\",\n\t},\n\t{\n\t\tword: \"apart\",\n\t\ttokenType: \"APART_FN\",\n\t\tbuiltinIndex: SYMBOLIC_BUILTIN_APART,\n\t\texample: \"apart((3x+5)/(x^2-1))\",\n\t\texpected: \"4/(x-1)-1/(x+1)\",\n\t\tdocPage: \"algebra.md\",\n\t},\n];\n\n/**\n * Symbolic algebra verbs: multiplying out, and (in later phases) factoring,\n * solving and calculus.\n *\n * The algebra itself lives in `symbolic/`, which is pure mathematics over the\n * expression tree. This package is only the grammar surface: which words become\n * which tokens, and which parselet emits which builtin call.\n *\n * None of these words is a bare `keywordMap` entry. See\n * `normalizer/SymbolicCallNormalizerRule.ts` for why that matters.\n */\nexport const SYMBOLIC_PACKAGE: IEnginePackage = {\n\tname: \"solve-symbolic\",\n\tnormalizerRules: [symbolicCallNormalizerRule(), imaginaryLiteralNormalizerRule()],\n\tprefixParselets: {\n\t\tEXPAND_FN: new ExpandParselet(),\n\t\tFACTOR_FN: new FactorParselet(),\n\t\tSOLVE_FN: new SolveParselet(),\n\t\tDER_FN: new DerParselet(),\n\t\tINTEGRAL_FN: new IntegralParselet(),\n\t\tTAYLOR_FN: new TaylorParselet(),\n\t\tJACOBIAN_FN: new JacobianParselet(),\n\t\tIMAGINARY: new ImaginaryParselet(),\n\t\tCONJ_FN: new ConjParselet(),\n\t\tRE_FN: new ReParselet(),\n\t\tIM_FN: new ImParselet(),\n\t\tCANCEL_FN: new CancelParselet(),\n\t\tAPART_FN: new ApartParselet(),\n\t},\n\ttokenCategories: {\n\t\tEXPAND_FN: \"keyword\",\n\t\tFACTOR_FN: \"keyword\",\n\t\tSOLVE_FN: \"keyword\",\n\t\tDER_FN: \"keyword\",\n\t\tINTEGRAL_FN: \"keyword\",\n\t\tTAYLOR_FN: \"keyword\",\n\t\tJACOBIAN_FN: \"keyword\",\n\t\tIMAGINARY: \"number\",\n\t\tCONJ_FN: \"keyword\",\n\t\tRE_FN: \"keyword\",\n\t\tIM_FN: \"keyword\",\n\t\tCANCEL_FN: \"keyword\",\n\t\tAPART_FN: \"keyword\",\n\t},\n};\n\n/** The token types the algebra verbs fuse into, for the engine's own \"is this line symbolic\" check. */\nconst SYMBOLIC_TOKEN_TYPES: ReadonlySet<string> = new Set(SYMBOLIC_FUNCTIONS.map(fn => fn.tokenType));\n\n/**\n * Whether a normalized token list calls an algebra verb.\n *\n * `engine/ExpressionEngine.ts` uses this to evaluate such a line in\n * symbolic-tolerant mode without requiring a trailing `=>`, since asking to\n * expand or factor something is already a statement that its unknowns are meant\n * to stay unknown.\n *\n * @param tokens - The normalized tokens for one line.\n * @returns True when any token is an algebra verb.\n */\nexport function containsSymbolicCall(tokens: readonly { type: string }[]): boolean {\n\treturn tokens.some(token => SYMBOLIC_TOKEN_TYPES.has(token.type));\n}\n","/**\n * ISO8601 string <-> epoch-ms helpers backing the datetime package's\n * `<ISO8601 string> to date` and `<date/time> as iso8601` features.\n *\n * SCOPE, revised in 1.0.0: {@link parseIso8601} is now reached by BOTH input\n * shapes. A quoted string literal (`\"2019-04-01T15:30:00+11:00\" to date`)\n * always came here; the bare, unquoted form now does too, fused into one\n * DATETIME_LITERAL by `normalizer/DateLiteralNormalizerRule.ts` before the\n * parser sees it.\n *\n * This file used to record that the bare form was out of scope because it is\n * ambiguous with arithmetic (`2019 - 04 - 01` reads as two subtractions) and\n * would need a dedicated lexer change. The date half of that ambiguity was\n * already settled by the normalizer rule, and the differential run against\n * 1.0.0-beta.6 showed what leaving the other half cost: a bare\n * `2019-04-01T15:30:00+11:00` read its `+11:00` as a clock time being ADDED to\n * the date, and answered TODAY at 11:00. Not the instant, not an error, and\n * formatted as a date, which is the most convincing way to be wrong. The two\n * spellings now answer identically, which is the only defensible arrangement\n * when one of them was always right.\n */\n\n/**\n * Matches a (reasonably) well-formed ISO8601 date or date-time string:\n * `YYYY-MM-DD` optionally followed by `THH:MM[:SS[.fff]][Z|+HH:MM|-HH:MM]`.\n * Deliberately stricter than the native `Date` constructor's very lenient\n * parsing (which also accepts things like `\"April 1, 2019\"`), only a\n * string actually ISO8601-shaped is accepted here, so `\"not a date\" to\n * date` fails loudly instead of silently parsing as `Invalid Date` (or,\n * worse, something the native parser guesses at).\n */\nconst ISO8601_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\n/**\n * Parse an ISO8601-shaped string into epoch milliseconds.\n *\n * Delegates the actual parsing to the native `Date` constructor, which\n * fully implements the ISO8601 extended format (including \"Z\"/\"+HH:MM\"\n * offsets and a fractional-seconds component) per the ECMA-262 Date Time\n * String Format spec, no custom parsing logic needed, just a stricter\n * shape gate in front of it (see {@link ISO8601_PATTERN}'s doc comment).\n *\n * A date-only string (`\"2019-04-01\"`) parses as UTC midnight; a date-time\n * with no offset and no \"Z\" (`\"2019-04-01T15:30:00\"`) parses in the HOST\n * SYSTEM's local timezone, both are the native `Date` constructor's own\n * spec-mandated behavior, not something this function adds.\n *\n * @returns epoch ms, or `null` if `s` isn't ISO8601-shaped or doesn't\n * parse to a valid instant.\n */\nexport function parseIso8601(s: string): number | null {\n // A `ValueType.String` Value's `.value` used to retain its original\n // surrounding double-quotes, because `tokenizeString()` set the token's\n // value to the raw source slice and `OpCode.PUSH_STRING` pushed that\n // verbatim. It no longer does: the token's `value` is the payload and its\n // `text` is the quoted slice. The strip below stays because this function\n // is also reachable with text that came from somewhere other than a\n // literal, and stripping a pair that is not there is a no-op.\n let trimmed = s.trim();\n if (trimmed.length >= 2 && trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n trimmed = trimmed.slice(1, -1);\n }\n if (!ISO8601_PATTERN.test(trimmed)) return null;\n const ms = new Date(trimmed).getTime();\n return Number.isNaN(ms) ? null : ms;\n}\n\n/**\n * Format epoch milliseconds as an ISO8601 string with an explicit\n * `+HH:MM`/`-HH:MM` offset, e.g. `\"2019-04-01T15:30:00+11:00\"`.\n *\n * DESIGN NOTE: uses the HOST SYSTEM's local timezone offset for the\n * offset component. This engine's `Datetime` representation is a bare\n * epoch-ms number with no zone tag (see `packages/time/TimePackage.ts`'s\n * doc comment for the same limitation affecting timezone conversion), so\n * there is no per-expression timezone context to draw on otherwise, the\n * process's own local offset (`Date.getTimezoneOffset()`) is the only\n * notion of \"local\" available. No milliseconds component is emitted,\n * matching the precision of the task's own worked example.\n */\nexport function formatIso8601Local(epochMs: number): string {\n const d = new Date(epochMs);\n const pad = (n: number) => String(n).padStart(2, \"0\");\n\n const year = d.getFullYear();\n const month = pad(d.getMonth() + 1);\n const day = pad(d.getDate());\n const hours = pad(d.getHours());\n const minutes = pad(d.getMinutes());\n const seconds = pad(d.getSeconds());\n\n // getTimezoneOffset() is (UTC - local) in minutes, i.e. the SIGN is\n // inverted relative to a \"+HH:MM ahead of UTC\" display offset.\n const offsetMinutesTotal = -d.getTimezoneOffset();\n const sign = offsetMinutesTotal >= 0 ? \"+\" : \"-\";\n const absOffset = Math.abs(offsetMinutesTotal);\n const offsetHours = pad(Math.floor(absOffset / 60));\n const offsetMinutes = pad(absOffset % 60);\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${sign}${offsetHours}:${offsetMinutes}`;\n}\n\n/**\n * Magnitude threshold distinguishing a millisecond Unix timestamp from a\n * second Unix timestamp: values at or above this are treated as\n * milliseconds, below it as seconds.\n *\n * Chosen so that \"now\" in EITHER unit sits comfortably on its own side:\n * seconds-since-epoch for the foreseeable future stays in the ~1.7-2.5\n * billion range (1e9-1e10-ish), nowhere near 1e12, while the SAME\n * instant in milliseconds is ~1000x larger, comfortably past 1e12\n * (e.g. \"2024-12-10\" is ~1.73e9 seconds or ~1.73e12 ms). 1e12 sits well\n * clear of both real-world ranges for at least the next few centuries of\n * second-timestamps, so this is a safe, simple magnitude gate rather than\n * a fragile exact boundary.\n */\nconst MS_TIMESTAMP_THRESHOLD = 1e12;\n\n/**\n * Interpret a bare numeric Unix timestamp as epoch milliseconds, applying\n * the magnitude-based seconds-vs-milliseconds disambiguation described by\n * {@link MS_TIMESTAMP_THRESHOLD}.\n */\nexport function unixTimestampToEpochMs(n: number): number {\n return Math.abs(n) >= MS_TIMESTAMP_THRESHOLD ? n : n * 1000;\n}\n","import type { Token } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\nimport { LexerToken } from \"@solve-js/lexer/ExpressionLexer\";\nimport type { NormalizerRule, NormalizerMatch } from \"@solve-js/normalizer/NormalizerRule\";\nimport { parseIso8601 } from \"@solve-js/packages/datetime/Iso8601\";\nimport type { DateInputOrder } from \"@solve-js/constants/Configuration\";\n\n/**\n * Token type a fused date literal is rewritten to.\n *\n * One type covers every supported ordering, so the parselet handles the shape\n * rather than the locale.\n */\nexport const DATETIME_LITERAL_TYPE = \"DATETIME_LITERAL\";\nconst DATETIME_LITERAL_TYPE_ID = tokenTypeId(DATETIME_LITERAL_TYPE);\n\n/** A pure digit string, guards against fusing hex/scientific/bigint-suffixed NUMBER tokens. */\nconst PLAIN_INTEGER = /^\\d+$/;\n\n/** First NUMBER token of a dot-separated literal: the lexer's decimal scanner\n * merges \"DD.MM\" into one float-shaped token (see module doc below). */\nconst DOT_DAY_MONTH = /^\\d{1,2}\\.\\d{1,2}$/;\n\n/** Second NUMBER token of a dot-separated literal: the lexer re-enters\n * tokenizeNumber() AT the second dot, so the year keeps its leading dot. */\nconst DOT_LEADING_YEAR = /^\\.(\\d{2}|\\d{4})$/;\n\n/**\n * Day and month groups of a separator-separated literal, in any of the three\n * orderings below: one or two digits, padded or not.\n *\n * Deliberately NOT two digits exactly. Zero-padding is what ISO 8601 requires\n * of a serialized date, but it is not what people type: \"2024-5-3\" is an\n * ordinary way to write a date and has to keep working. The digit count is\n * still bounded because a group of three or more digits is not a date group at\n * all, and the calendar check in {@link buildDateToken} would not catch it on\n * its own (\"030\" reads back as day 30).\n *\n * What actually separates a date from the arithmetic it is spelled like is\n * adjacency, not padding. See {@link writtenAsOneRun}.\n */\nconst DAY_OR_MONTH = /^\\d{1,2}$/;\n\n/**\n * Whether every token in a run touches the next one in the source text, with\n * no whitespace anywhere between the first character and the last.\n *\n * This is the whole basis for telling a date literal apart from the\n * arithmetic it is spelled identically to. A date is written as one\n * uninterrupted run (\"2024-5-3\"); a subtraction chain is written with spaces\n * around its operators (\"2024 - 5 - 3\"). The lexer records that difference in\n * the token offsets and nowhere else, since the tokens themselves are the same\n * five either way:\n *\n * 2024-5-3 NUMBER@0 MINUS@4 NUMBER@5 MINUS@6 NUMBER@7\n * 2024 - 5 - 3 NUMBER@0 MINUS@5 NUMBER@7 MINUS@9 NUMBER@11\n *\n * The same technique, for the same reason, is what tells \"5k\" from \"5 k\" in\n * `arithmetic/normalizer/LargeNumberSuffixNormalizerRule.ts`.\n *\n * ## Why this replaced a zero-padding requirement on the ISO branch\n * The ISO branch briefly required its month and day groups to be padded to two\n * digits, which did stop \"2024 - 5 - 3\" being answered as \"Friday, May 3,\n * 2024\" but also stopped \"2024-5-3\" being a date at all. Padding was never the\n * real distinction, and the rule's own US branch is the proof: it has always\n * accepted unpadded groups, so \"1-1-2020\" and \"12-25-2023\" are both dates\n * today. Requiring padding on one branch of the two was therefore an\n * inconsistency between two spellings of one rule rather than a policy.\n *\n * The US branch's own guard is a 2-or-4-digit trailing year plus the calendar\n * check, and it is NOT safe against spaced arithmetic on its own: before this\n * check existed, \"12 - 25 - 2023\" answered Christmas 2023 instead of -2036,\n * and \"1 - 1 - 2020\" answered New Year's Day instead of -2020. Applying\n * adjacency to the whole run rather than to one branch fixes that at the same\n * time and leaves both branches resting on the same reason.\n *\n * ## Padded but spaced\n * \"2024 - 05 - 03\" is subtraction under this check, and that is the intended\n * reading. Nobody types the spaces when they mean the date, so the spacing is\n * the clearest signal available about which was meant, and the padding is not:\n * a person subtracting may well write \"05\" for the same reason they write\n * \"05\" anywhere else. Choosing the date there would mean no spelling of that\n * subtraction existed.\n *\n * `sourceEnd` is preferred over `text.length` where it is set, because a token\n * an earlier rule fused carries replacement text rather than source text and\n * only `sourceEnd` still describes the span it covers (see\n * `normalizer/TokenNormalizer.ts`'s `createFusedToken`).\n */\nfunction writtenAsOneRun(tokens: Token[]): boolean {\n for (let i = 0; i < tokens.length - 1; i++) {\n const token = tokens[i];\n const end = token.sourceEnd ?? token.offset + token.text.length;\n if (end !== tokens[i + 1].offset) return false;\n }\n return true;\n}\n\n/**\n * Resolves a year token's raw digit text to a 4-digit year.\n *\n * Accepts exactly 2 or 4 digits (matching the wiki's documented formats).\n * A 2-digit year is windowed using the common glibc `strptime(\"%y\")`\n * convention: 00-68 -> 2000-2068, 69-99 -> 1969-1999. Any other digit\n * count (1 or 3 digits) is not a valid year shape and returns null so the\n * caller can decline the match and fall back to ordinary arithmetic.\n */\nfunction resolveYear(digits: string): number | null {\n if (digits.length === 4) return Number(digits);\n if (digits.length === 2) {\n const yy = Number(digits);\n return yy <= 68 ? 2000 + yy : 1900 + yy;\n }\n return null;\n}\n\n/**\n * Converts a validated day/month/year triple into a fused DATETIME_LITERAL\n * token, or null if the triple isn't a real calendar date (e.g. \"30\" for\n * February), letting the caller fall back to treating the source tokens\n * as ordinary arithmetic instead of a date.\n */\nexport function buildDateToken(\n day: number,\n month: number,\n year: number,\n sourceTokens: Token[],\n ruleName: string,\n): NormalizerMatch | null {\n if (month < 1 || month > 12 || day < 1 || day > 31) return null;\n\n // Local midnight, consistent with formatDatetime()'s toLocaleString()\n // display and DATE_NOW's Date.now() epoch, both of which are local-time.\n const date = new Date(year, month - 1, day);\n // Reject calendar rollover (e.g. day=30 in February) rather than silently\n // normalizing to March 2, a rollover almost always means the tokens were\n // never a date to begin with (e.g. \"2-30-5\" as chained subtraction).\n if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {\n return null;\n }\n\n const first = sourceTokens[0];\n const text = sourceTokens.map((t) => t.value).join(\"\");\n const fusedToken = new LexerToken(\n DATETIME_LITERAL_TYPE,\n DATETIME_LITERAL_TYPE_ID,\n String(date.getTime()),\n text,\n first.offset,\n 0,\n first.line,\n first.col,\n );\n\n return { consumed: sourceTokens.length, replacement: [fusedToken], ruleName };\n}\n\n/**\n * A full ISO 8601 timestamp: an ISO date with a time of day, optionally\n * carrying a UTC offset or the `Z` that means one of zero.\n *\n * Anchored at the start and deliberately greedy about the offset, so\n * `...T15:30:00+11:00` matches through the offset rather than stopping at the\n * seconds and leaving `+11:00` behind as an addition. That is what the bare\n * form used to do: `2019-04-01T15:30:00+11:00` read the offset as a clock time\n * being ADDED to the date on its left, and answered today at 11:00. Both\n * halves of that were wrong and neither was visible, which is worse than the\n * bare form simply not being supported.\n *\n * The time of day is required. Without it this would match what the date-only\n * branches below already handle, and they carry the ambiguity rules\n * (adjacency, group shapes) that keep a subtraction chain a subtraction.\n *\n * Matched against reconstructed source text rather than token by token. The\n * lexer has no idea this is one literal, so it emits nine to fourteen tokens\n * for it with the shape depending on the spelling (`T15` arrives as an\n * identifier, `Z` as another, an offset as a PLUS or MINUS with two more\n * numbers), and enumerating those permutations in token patterns is how a\n * spelling gets missed.\n *\n * `T` and `Z` are uppercase only, matching `Iso8601.ts`'s own pattern, which is\n * what actually parses the match. Accepting a spelling here that the parser\n * then refuses would mean the bare form supported more shapes than the quoted\n * one, for no reason a reader could infer.\n */\nconst ISO_TIMESTAMP = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?/;\n\n/**\n * Token types a run of ISO 8601 timestamp text can lex into. Anything else\n * ends the run, so the reconstruction below can never reach across an operator\n * or a word that is not part of the literal.\n */\nconst ISO_TOKEN_TYPES = new Set([\"NUMBER\", \"MINUS\", \"PLUS\", \"COLON\", \"IDENT\"]);\n\n/**\n * How many tokens the longest supported spelling occupies. `2019-04-01T15:30:00.123+11:00`\n * is fourteen; the cap only bounds the walk, since the match itself decides\n * where the literal ends.\n */\nconst ISO_MAX_TOKENS = 16;\n\n/**\n * Fuses a bare (unquoted) ISO 8601 timestamp into one DATETIME_LITERAL.\n *\n * `Iso8601.ts` could always parse this shape, and still does the parsing here;\n * what it said could not be done without \"a much larger, dedicated lexer\n * change\" was recognising the bare form, on the grounds that it is ambiguous\n * with arithmetic. The date half of that ambiguity was settled by the rule this\n * helper sits inside (a date is written as one uninterrupted run, so\n * `2024 - 5 - 3` stays arithmetic), and the time half is not ambiguous at all:\n * no chain of subtractions contains a `T15:30`.\n *\n * Contiguity in the SOURCE is what makes that true, the same test\n * {@link writtenAsOneRun} applies to the date-only orderings. Every token has\n * to begin exactly where the previous one ended, so `2019-04-01 T15:30` with a\n * space in it, or `2019-04-01 + 11:00` with the offset written as an addition,\n * are left alone: the user who typed a space typed two things.\n *\n * A token an earlier normalizer rule already fused ends the run rather than\n * joining it. Its `text` is replacement text rather than source text (see\n * `normalizer/TokenNormalizer.ts`'s `createFusedToken`), so concatenating it\n * would reconstruct something the user never typed, and nothing that has\n * already been fused into a phrase is part of a timestamp anyway.\n *\n * @returns The fused match, or null when the tokens at `pos` are not a\n * timestamp, when the match would end mid-token, or when the shape is\n * ISO-like but names no real instant (`2019-04-01T25:00:00`).\n */\nfunction fuseIsoTimestamp(tokens: Token[], pos: number, ruleName: string): NormalizerMatch | null {\n const first = tokens[pos];\n if (first.sourceEnd !== undefined) return null;\n let text = first.text;\n let runEnd = first.offset + first.text.length;\n const window: Token[] = [first];\n for (let i = pos + 1; i < tokens.length && window.length < ISO_MAX_TOKENS; i++) {\n const next = tokens[i];\n if (next.sourceEnd !== undefined) break;\n if (next.offset !== runEnd || !ISO_TOKEN_TYPES.has(next.type)) break;\n text += next.text;\n runEnd = next.offset + next.text.length;\n window.push(next);\n }\n\n const matched = ISO_TIMESTAMP.exec(text);\n if (matched === null) return null;\n\n // The literal has to end where a token ends. A match that stopped halfway\n // through one would leave the parser holding a token whose text has already\n // been consumed, so decline and let the ordinary rules have it.\n let consumed = 0;\n let covered = 0;\n for (const token of window) {\n covered += token.text.length;\n consumed++;\n if (covered >= matched[0].length) break;\n }\n if (covered !== matched[0].length) return null;\n\n // The instant comes from the same parser the quoted form uses, so the two\n // spellings cannot drift apart: an offset means what it means there, and a\n // timestamp with no offset is local time, exactly as a bare date literal is\n // local midnight.\n const epochMs = parseIso8601(matched[0]);\n if (epochMs === null) return null;\n\n const fusedToken = new LexerToken(\n DATETIME_LITERAL_TYPE,\n DATETIME_LITERAL_TYPE_ID,\n String(epochMs),\n matched[0],\n first.offset,\n 0,\n first.line,\n first.col,\n first.offset + matched[0].length,\n );\n return { consumed, replacement: [fusedToken], ruleName };\n}\n\n/**\n * Maps the three numeric groups of a slash- or hyphen-separated literal to a\n * (day, month, year) triple under an explicit {@link DateInputOrder}, or null\n * when a group is the wrong shape for its role (a non-4-digit year in `YMD`, a\n * year group that is neither two nor four digits in `DMY`/`MDY`).\n *\n * Only reached when the host has fixed an order; `'auto'` keeps the historic\n * per-separator reading in the rule below and never calls this.\n */\nfunction resolveOrderedGroups(\n g0: string, g1: string, g2: string, order: Exclude<DateInputOrder, \"auto\">,\n): { day: number; month: number; year: number } | null {\n if (order === \"YMD\") {\n if (g0.length !== 4) return null;\n if (!DAY_OR_MONTH.test(g1) || !DAY_OR_MONTH.test(g2)) return null;\n return { year: Number(g0), month: Number(g1), day: Number(g2) };\n }\n // DMY and MDY: two 1-2 digit groups and a trailing 2- or 4-digit year.\n if (!DAY_OR_MONTH.test(g0) || !DAY_OR_MONTH.test(g1)) return null;\n const year = resolveYear(g2);\n if (year === null) return null;\n return order === \"DMY\"\n ? { day: Number(g0), month: Number(g1), year }\n : { day: Number(g1), month: Number(g0), year };\n}\n\n/**\n * NormalizerRule that fuses numeric date literals into a single\n * DATETIME_LITERAL token, per the documented \"Datetime Formats\":\n * - European: DD/MM/YYYY (5 tokens: NUMBER SLASH NUMBER SLASH NUMBER)\n * - US: MM-DD-YYYY (5 tokens: NUMBER MINUS NUMBER MINUS NUMBER)\n * - ISO 8601: YYYY-MM-DD (same 5-token shape as US, disambiguated by the\n * first group being exactly 4 digits)\n * - Dot: DD.MM.YYYY (2 tokens. See below)\n *\n * ## Why the dot format is a 2-token window, not 5\n * ExpressionLexer's tokenizeNumber() treats \".\" adjacent to digits on both\n * sides as a decimal point, not a separator. For \"25.12.2023\" the lexer\n * itself emits only two NUMBER tokens: \"25.12\" (day+month merged into one\n * float-shaped literal) and \".2023\" (the lexer re-enters number scanning\n * AT the second dot, so the year keeps a leading dot). There is no 5-token\n * NUMBER-DOT-NUMBER-DOT-NUMBER shape to match against, the fusion has to\n * happen post-hoc from that 2-token shape instead. This only works for the\n * literal typed with no internal whitespace (e.g. \"25.12.2023\"); a spaced\n * variant (\"25 .12 .2023\") produces three separate leading-dot tokens and\n * is intentionally not supported, out of scope for the documented format.\n *\n * ## Ambiguity with existing arithmetic\n * A date-shaped SLASH or MINUS chain (e.g. \"25/12/2023\" or \"12-25-2023\")\n * previously parsed as chained division/subtraction. This rule\n * deliberately reinterprets any such chain that resolves to a real\n * calendar date as a date literal instead, matching the documented\n * behavior. Chains that aren't valid dates (out-of-range day/month, a\n * February 30, a non-2/4-digit year) fall through unchanged.\n *\n * That reinterpretation only ever claims a chain written as one\n * uninterrupted run of characters. \"25/12/2023\" and \"12-25-2023\" are dates;\n * \"25 / 12 / 2023\" and \"12 - 25 - 2023\", written with the spaces an operator\n * normally gets, stay division and subtraction. {@link writtenAsOneRun}\n * carries the full reasoning, including why this is checked instead of\n * requiring an ISO date's zero-padding.\n *\n * ## Relationship to Iso8601.ts / DatePhrase.ts\n * This is the general-purpose \"bare numeric date literal\" implementation\n * those two files' doc comments referenced as landing on a sibling branch\n * (`feat/safety-limits-datetime-literals`), now ported here. It's\n * intentionally independent of both: `Iso8601.ts` only parses QUOTED\n * STRING literals (`\"2019-04-01...\" to date`), and the Stocks package's\n * `DatePhrase.ts` is a narrower, deliberately-diverging grammar (US-style\n * bare SLASH dates, 4-digit-year-only) scoped to stock-history queries\n * neither of those needed to change for this to land.\n */\nexport function dateLiteralNormalizerRule(\n getInputOrder: () => DateInputOrder = () => \"auto\",\n): NormalizerRule {\n return {\n name: \"datetime:date-literal\",\n priority: 70,\n match(tokens: Token[], pos: number): NormalizerMatch | null {\n const t0 = tokens[pos];\n if (t0.type !== \"NUMBER\") return null;\n\n // ── Dot format: 2-token window (see module doc) ──────────────────\n if (DOT_DAY_MONTH.test(t0.value)) {\n const t1 = tokens[pos + 1];\n if (t1 && t1.type === \"NUMBER\" && DOT_LEADING_YEAR.test(t1.value)) {\n const [dayText, monthText] = t0.value.split(\".\");\n const year = resolveYear(t1.value.slice(1));\n if (year !== null) {\n const match = buildDateToken(\n Number(dayText), Number(monthText), year,\n [t0, t1], \"datetime:date-literal:dot\",\n );\n if (match) return match;\n }\n }\n return null;\n }\n\n // ── ISO 8601 timestamp: as many tokens as the spelling takes ─────\n // Tried before the date-only windows below, which would otherwise fuse\n // the date half of a timestamp and leave the time half to be read as\n // arithmetic. See fuseIsoTimestamp().\n if (t0.value.length === 4 && PLAIN_INTEGER.test(t0.value)) {\n const timestamp = fuseIsoTimestamp(tokens, pos, \"datetime:date-literal:iso-timestamp\");\n if (timestamp) return timestamp;\n }\n\n // ── Slash / minus format: 5-token window ─────────────────────────\n if (!PLAIN_INTEGER.test(t0.value)) return null;\n const sep1 = tokens[pos + 1];\n if (!sep1 || (sep1.type !== \"SLASH\" && sep1.type !== \"MINUS\")) return null;\n const t1 = tokens[pos + 2];\n const sep2 = tokens[pos + 3];\n const t2 = tokens[pos + 4];\n if (!t1 || t1.type !== \"NUMBER\" || !PLAIN_INTEGER.test(t1.value)) return null;\n if (!sep2 || sep2.type !== sep1.type) return null;\n if (!t2 || t2.type !== \"NUMBER\" || !PLAIN_INTEGER.test(t2.value)) return null;\n\n const sourceTokens = [t0, sep1, t1, sep2, t2];\n // The one check that separates every ordering below from the arithmetic\n // it is spelled identically to, and the only one that applies to all\n // three equally. See writtenAsOneRun.\n if (!writtenAsOneRun(sourceTokens)) return null;\n\n // A host-fixed order (DMY/MDY/YMD) reads slash and hyphen dates the same\n // way, so a US reader's `12/25/2023` and an ISO `2023/12/25` both parse.\n // `'auto'` falls through to the historic per-separator reading below.\n const order = getInputOrder();\n if (order !== \"auto\") {\n const resolved = resolveOrderedGroups(t0.value, t1.value, t2.value, order);\n if (resolved === null) return null;\n return buildDateToken(\n resolved.day, resolved.month, resolved.year, sourceTokens,\n `datetime:date-literal:${order.toLowerCase()}`,\n );\n }\n\n if (sep1.type === \"SLASH\") {\n // European: DD/MM/YYYY (always, no ISO-slash variant is documented)\n if (!DAY_OR_MONTH.test(t0.value) || !DAY_OR_MONTH.test(t1.value)) return null;\n const year = resolveYear(t2.value);\n if (year === null) return null;\n return buildDateToken(Number(t0.value), Number(t1.value), year, sourceTokens, \"datetime:date-literal:european\");\n }\n\n // MINUS: ISO (YYYY-MM-DD) if the first group is exactly 4 digits, else US (MM-DD-YYYY)\n if (t0.value.length === 4) {\n if (!DAY_OR_MONTH.test(t1.value) || !DAY_OR_MONTH.test(t2.value)) return null;\n // year=t0, month=t1, day=t2, buildDateToken takes (day, month, year)\n return buildDateToken(Number(t2.value), Number(t1.value), Number(t0.value), sourceTokens, \"datetime:date-literal:iso\");\n }\n if (!DAY_OR_MONTH.test(t0.value) || !DAY_OR_MONTH.test(t1.value)) return null;\n const year = resolveYear(t2.value);\n if (year === null) return null;\n // month=t0, day=t1, year=t2, buildDateToken takes (day, month, year)\n return buildDateToken(Number(t1.value), Number(t0.value), year, sourceTokens, \"datetime:date-literal:us\");\n },\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import {a as a$1}from'./chunk-XEIDV5JP.js';import {g}from'./chunk-R2ENWQ76.js';import {Z,R as R$1,ua,sa}from'./chunk-RSF25YSJ.js';import {m}from'./chunk-EVAOPEO4.js';import {a}from'./chunk-62LMTO4F.js';var b={floatResult:{decimalPlaces:2,enableSeperator:true},numberResult:{decimalSeparatorLocale:"en-US"},hexResult:{enablePadding:false,paddingZeros:0},unitOfMeasurementResult:{decimalPlaces:2},percentageResult:{decimalPlaces:2},dateResult:{format:"long"}};function D(t,r,o,n){let e=o.floatResult.enableSeperator,a=o.numberResult.decimalSeparatorLocale;if(n!==void 0&&Number.isFinite(t)){let c=t.toLocaleString(a||"en-US",{minimumFractionDigits:n,maximumFractionDigits:n,useGrouping:e});return `${r.display.resultPrefix}${c}`}let i=o.floatResult.decimalPlaces,s=a$1(t,i,e,a);return `${r.display.resultPrefix}${s}`}function F(t,r,o,n){let e=n.floatResult.decimalPlaces,a=n.floatResult.enableSeperator,i=n.numberResult.decimalSeparatorLocale||"en-US",s=Math.max(e,1),c=t.toLocaleString(i,{useGrouping:a,minimumFractionDigits:0,maximumFractionDigits:e}),u=Math.abs(r).toLocaleString(i,{useGrouping:a,minimumFractionDigits:1,maximumFractionDigits:s});return `${o.display.resultPrefix}${c} \xB1 ${u}`}function R(t,r,o){if(typeof t=="number"&&!Number.isFinite(t))return `= ${t}`;let n=typeof t=="bigint"?t<0n:t<0,e=n?"-":"",a=c=>typeof t=="bigint"?(n?-t:t).toString(c):Math.abs(Math.trunc(t)).toString(c);if(o==="bin")return `= ${e}0b${a(2)}`;if(o==="oct")return `= ${e}0o${a(8)}`;let i=r.hexResult.enablePadding?r.hexResult.paddingZeros:0,s=a(16).toUpperCase().padStart(i,"0");return `= ${e}0x${s}`}var L=2e4;function P(t){let r=t<0n?-t:t;if(Number.isFinite(Number(r)))return `= ${t}`;let o=r.toString(16).length*4;if(o*Math.LN2/Math.LN10<=L)return `= ${t}`;let n=o*Math.LN2/Math.LN10,e=Math.floor(n),a=Math.pow(10,n-e);return `= ${t<0n?"-":""}~${a.toFixed(3)}e+${e} (an exact integer of about ${(e+1).toLocaleString("en-US")} digits, too large to print)`}function T(t){return `= ${t}`}function I(t){return `= ${t}`}function w(t,r,o){let n=new Date(t),e=o.dateResult?.format??"long",a=n.getHours()===0&&n.getMinutes()===0&&n.getSeconds()===0&&n.getMilliseconds()===0;if(e==="long"){let g=n.toLocaleDateString(r.code,{weekday:"long",year:"numeric",month:"long",day:"numeric"});return a?`= ${g}`:`= ${g}, ${n.toLocaleTimeString(r.code)}`}let i=g=>String(g).padStart(2,"0"),s=n.getFullYear(),c=i(n.getMonth()+1),u=i(n.getDate()),m;if(e==="iso"?m=`${s}-${c}-${u}`:e==="dmy"?m=`${u}/${c}/${s}`:m=`${c}/${u}/${s}`,a)return `= ${m}`;let l=`${i(n.getHours())}:${i(n.getMinutes())}:${i(n.getSeconds())}`;return e==="iso"?`= ${m}T${l}`:`= ${m} ${l}`}function N(t){let r=t<0?"-":"",o=Math.round(Math.abs(t)/1e3),n=Math.floor(o/3600),e=Math.floor(o%3600/60),a=o%60,i=String(e).padStart(2,"0");if(a===0)return `${r}${n}:${i}`;let s=String(a).padStart(2,"0");return `${r}${n}:${i}:${s}`}function U(t,r,o,n,e){if(r==="ms")return `= ${N(t)}`;let a=n.unitOfMeasurementResult.decimalPlaces,s=r&&["days","weeks","months","years","hours","minutes","seconds","day","week","month","year","hour","minute","second"].includes(r),c;s&&t===Math.floor(t)?c=t.toString():c=t.toFixed(a);let u=r?ua[r.toUpperCase()]:void 0;if(u){let l=e?sa(e,a):c,g=u.spaced?" ":"";return `= ${u.position==="prefix"?`${u.symbol}${g}${l}`:`${l}${g}${u.symbol}`}`}return `= ${e?sa(e,a):c} ${r||""}`.trim()}function M(t,r){if(typeof t=="boolean")return t?"true":"false";if(typeof t=="object"&&t!==null)return R$1(t);let o=r.floatResult.decimalPlaces,n=r.floatResult.enableSeperator,e=r.numberResult.decimalSeparatorLocale;return a$1(t,o,n,e)}function E(t,r,o){let n=Z(t),e=[];for(let a=0;a<t.rows;a++){let i=[];for(let s=0;s<t.cols;s++)i.push(M(n[a*t.cols+s],o));e.push(i.join(", "));}return `${r.display.resultPrefix}[${e.join("; ")}]`}function Q(t,r){let o=r||b,n=Z(t),e=[];for(let i=0;i<t.rows;i++){let s=[];for(let c=0;c<t.cols;c++)s.push(M(n[i*t.cols+c],o));e.push(s);}let a=[];for(let i=0;i<t.cols;i++){let s=0;for(let c=0;c<t.rows;c++)s=Math.max(s,e[c][i].length);a.push(s);}return e.map(i=>`[ ${i.map((s,c)=>s.padStart(a[c])).join(" ")} ]`).join(`
2
+ `)}function j(t,r,o){return `${o.display.resultPrefix}${t}:${r}`}function C(t,r,o){let n=o.percentageResult.decimalPlaces;return `= ${(t*100).toFixed(n)}${r.display.percentageSuffix}`}function A(t,r){return `= ${t} ${r||""}`.trim()}function G(t,r,o){let n=r.display.resultPrefix,e=u=>{let m$1=t.unit!==void 0?new m(6,u.value,t.unit):new m(0,u.value);m$1.exact=u.exact;let l=O(m$1,o);return l.startsWith(n)?l.slice(n.length):l},[a,i]=t.shares,s=`${e(a)} each`;if(i===void 0)return `${n}${s}`;let c=i.count===1?"share":"shares";return `${n}${s}, with ${i.count} ${c} paying ${e(i)}`}function O(t,r){let o=r||b,n=o.numberResult.decimalSeparatorLocale||"en",e=a(n);switch(t.type){case 0:return t.uncertainty!==void 0?F(t.value,t.uncertainty,e,o):D(t.value,e,o,t.decimalPlaces);case 1:return R(t.value,o,t.unit);case 2:return P(t.value);case 3:return T(t.value);case 10:return I(t.value);case 4:return w(t.value,e,o);case 6:return U(t.value,t.unit,e,o,t.exact);case 7:return E(t.value,e,o);case 8:{let a=t.value;return j(a.min,a.max,e)}case 14:return `${e.display.resultPrefix}${g(t.value)}`;case 15:return G(t.value,e,o);case 9:return R$1(t.value);case 5:return C(t.value,e,o);case 11:return A(t.value,t.unit);case 13:return t.unit??String(t.value);default:return `= ${String(t.value)}`}}export{b as a,Q as b,O as c};//# sourceMappingURL=chunk-B5NBFGNP.js.map
3
+ //# sourceMappingURL=chunk-B5NBFGNP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","autoFormatIntegerOrFloat","formatUncertain","center","uncertainty","useGrouping","spreadMax","centerText","spreadText","formatHex","base","negative","sign","digits","radix","padding","hex","MAX_DISPLAYED_BIGINT_DIGITS","formatBigInt","magnitude","bits","log10","exponent","mantissa","formatString","formatBoolean","formatDatetime","d","format","isMidnight","dateStr","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","formatUom","unit","exact","isTimeSpan","currencyDisplay","CURRENCY_DISPLAY","moneyText","decimalToFixed","formatMatrixEntry","entry","formatSymbolic","formatMatrix","m","rowMajor","columnMajorToRowMajor","rows","r","cells","c","formatMatrixAligned","us","row","colWidth","width","cell","formatRange","min","max","formatPercentage","formatUnit","formatSplit","data","prefix","render","share","v","Value","text","formatValue","high","each","shareWord","localeCode","getLocale","formatColour"],"mappings":"0MA8CO,IAAMA,CAAAA,CAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,CAAA,CACf,eAAA,CAAiB,IACnB,CAAA,CACA,YAAA,CAAc,CACZ,sBAAA,CAAwB,OAC1B,EACA,SAAA,CAAW,CACT,aAAA,CAAe,KAAA,CACf,YAAA,CAAc,CAChB,CAAA,CACA,uBAAA,CAAyB,CACvB,aAAA,CAAe,CACjB,CAAA,CACA,gBAAA,CAAkB,CAChB,cAAe,CACjB,CAAA,CACA,UAAA,CAAY,CACV,MAAA,CAAQ,MACV,CACF,ECzDA,SAASC,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAA8BC,CAAAA,CAAgC,CAClH,IAA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AQwE,CAAE,CAAA,CACzD,OACE,OAAOV,GAAAA,CAAe/D,CAAAA,CAAM,KAAqB,EACnD,KAAA,CAAA,CACE,OAAOiF,CAAAA,CAAiBjF,CAAAA,CAAM,MAAiBC,CAAAA,CAAQwE,CAAE,EAC3D,KAAA,EAAA,CACE,OAAOS,EAAWlF,CAAAA,CAAM,KAAA,CAAiBA,CAAAA,CAAM,IAAI,EACrD,KAAA,EAAA,CAKE,OAAOA,CAAAA,CAAM,IAAA,EAAQ,OAAOA,CAAAA,CAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,MAAA,CAAOA,EAAM,KAAK,CAAC,EACnC,CACF","file":"chunk-B5NBFGNP.js","sourcesContent":["/**\n * How a Datetime value is rendered.\n *\n * - `'long'`: the spelled-out form, \"Tuesday, March 10, 2026\" (the default).\n * - `'iso'`: \"2026-03-10\" (ISO 8601, with a `T`-separated time when present).\n * - `'dmy'`: \"10/03/2026\" (day first).\n * - `'mdy'`: \"03/10/2026\" (month first).\n *\n * The weekday and long month name in `'long'` are localised through the same\n * locale the number separators come from; the numeric forms are locale-neutral.\n */\nexport type DateOutputFormat = \"long\" | \"iso\" | \"dmy\" | \"mdy\";\n\n/**\n * Minimal formatting settings interface for the engine\n * This allows the engine to format values without depending on app-specific settings\n */\nexport interface FormattingSettings {\n floatResult: {\n decimalPlaces: number;\n enableSeperator: boolean;\n };\n numberResult: {\n decimalSeparatorLocale: string;\n };\n hexResult: {\n enablePadding: boolean;\n paddingZeros: number;\n };\n unitOfMeasurementResult: {\n decimalPlaces: number;\n };\n percentageResult: {\n decimalPlaces: number;\n };\n /**\n * Optional so a host that built a `FormattingSettings` before this field\n * existed still compiles; a missing `dateResult` reads as `'long'`, the\n * historic output.\n */\n dateResult?: {\n format: DateOutputFormat;\n };\n}\n\n/** Formatting used when a host supplies none. */\nexport const DEFAULT_FORMATTING_SETTINGS: FormattingSettings = {\n floatResult: {\n decimalPlaces: 2,\n enableSeperator: true,\n },\n numberResult: {\n decimalSeparatorLocale: \"en-US\",\n },\n hexResult: {\n enablePadding: false,\n paddingZeros: 0,\n },\n unitOfMeasurementResult: {\n decimalPlaces: 2,\n },\n percentageResult: {\n decimalPlaces: 2,\n },\n dateResult: {\n format: \"long\",\n },\n};\n","import { Value, ValueType, type MatrixData, type MatrixEntry, type RangeData, type ColourData, type SplitData, type SplitShare } from \"@solve-js/vm/Value\";\nimport { formatColour } from \"@solve-js/packages/colour/ColourMath\";\nimport { decimalToFixed, type DecimalData } from \"@solve-js/decimal\";\nimport { getLocale, type ILocale } from \"@solve-js/constants/locales\";\nimport { autoFormatIntegerOrFloat } from \"@solve-js/utilities/Number\";\nimport { FormattingSettings, DEFAULT_FORMATTING_SETTINGS } from \"./FormattingSettings\";\nimport { CURRENCY_DISPLAY } from \"@solve-js/uom/CurrencyAliases\";\nimport { columnMajorToRowMajor } from \"@solve-js/vm/MatrixOps\";\nimport { formatSymbolic, type SymbolicNode } from \"@solve-js/symbolic\";\n\nfunction formatNumber(value: number, locale: ILocale, settings: FormattingSettings, decimalPlaces?: number): string {\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n // An explicit precision (`3.14159 to 4 dp`, `round(1.5, 2)`) shows EXACTLY that\n // many places with trailing zeros kept, where the default trims them and shows\n // an integer with none. The value was already rounded to this precision when\n // it was set (see VMBuiltins' roundToPlaces, exact where an exact decimal was\n // there), so rendering it to the same place count reproduces that rounding.\n if (decimalPlaces !== undefined && Number.isFinite(value)) {\n const formatted = value.toLocaleString(loc || \"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n useGrouping: sep,\n });\n return `${locale.display.resultPrefix}${formatted}`;\n }\n const dp = settings.floatResult.decimalPlaces;\n const formatted = autoFormatIntegerOrFloat(value, dp, sep, loc);\n return `${locale.display.resultPrefix}${formatted}`;\n}\n\n/**\n * Renders a measurement that carries a one-sigma uncertainty as\n * `center ± spread`, e.g. `49.2 ± 2.0`.\n *\n * The center is shown the way any number is, whole numbers as integers and\n * trailing zeros trimmed, so a tolerance-free-looking center still reads\n * cleanly (\"30 ± 2.24\", not \"30.00 ± 2.24\"). The spread is shown to the same\n * decimal-place budget but always keeps at least one fractional digit, which is\n * what distinguishes it as a tolerance and gives \"± 2.0\" rather than \"± 2\".\n * Both use `Intl` with `maximumFractionDigits`, so the trailing-zero trimming is\n * locale-correct (a comma-decimal locale is not string-sliced on \".\").\n *\n * The symbol is always the `±` glyph on output, even when the input was the\n * ASCII `+/-`, since the glyph is the conventional notation and unambiguous to\n * read back.\n */\nfunction formatUncertain(center: number, uncertainty: number, locale: ILocale, settings: FormattingSettings): string {\n const dp = settings.floatResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\n // The spread needs room for at least one fractional digit, so a zero-decimal\n // budget cannot leave minimumFractionDigits above maximumFractionDigits.\n const spreadMax = Math.max(dp, 1);\n const centerText = center.toLocaleString(loc, { useGrouping, minimumFractionDigits: 0, maximumFractionDigits: dp });\n const spreadText = Math.abs(uncertainty).toLocaleString(loc, { useGrouping, minimumFractionDigits: 1, maximumFractionDigits: spreadMax });\n return `${locale.display.resultPrefix}${centerText} ± ${spreadText}`;\n}\n\n/**\n * Renders a number in whichever base it is tagged with.\n *\n * The zero padding is a hexadecimal setting and stays one. Applying it to a\n * binary rendering would pad `0b101` out to the same digit count as a hex\n * value, which is a different quantity of zeros and not what the setting asks\n * for.\n */\nfunction formatHex(value: number | bigint, settings: FormattingSettings, base?: string): string {\n // An infinity or a NaN has no digits in any base, and asking for them\n // produced `0xINFINITY`, a literal that reads back as nothing at all. Render\n // the value itself, which is what every other non-finite result shows.\n if (typeof value === \"number\" && !Number.isFinite(value)) return `= ${value}`;\n\n // Truncate and take the sign off before converting. `Number.toString(radix)`\n // does neither: it renders -255 as \"-ff\", which lands the minus inside the\n // literal as `0x-FF`, and it renders 255.7 as \"ff.b3333333333\", inventing\n // fractional hex digits for a notation that has no use for them. Both were\n // visible on `as hex` until the builtins started sharing this path.\n //\n // A bigint needs neither truncation nor a Math call, and must not be routed\n // through one: passing it to Math.trunc() throws, and converting it to a\n // double first is exactly the precision loss it is carried as a bigint to\n // avoid.\n const negative = typeof value === \"bigint\" ? value < 0n : value < 0;\n const sign = negative ? \"-\" : \"\";\n const digits = (radix: number): string =>\n typeof value === \"bigint\"\n ? (negative ? -value : value).toString(radix)\n : Math.abs(Math.trunc(value)).toString(radix);\n\n if (base === \"bin\") return `= ${sign}0b${digits(2)}`;\n if (base === \"oct\") return `= ${sign}0o${digits(8)}`;\n const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;\n const hex = digits(16).toUpperCase().padStart(padding, \"0\");\n return `= ${sign}0x${hex}`;\n}\n\n/**\n * How many decimal digits of an exact integer this will render in full.\n *\n * A little above the ~19,729 digits of the largest bigint the VM will build\n * (`vm/VM.ts`'s MAX_EXACT_POW_BITS / MAX_EXACT_SHIFT_BITS, 65,536 bits), so\n * every value the engine can produce through `^` or `<<` still prints exactly\n * and this ceiling only ever meets a value that came from somewhere else.\n */\nconst MAX_DISPLAYED_BIGINT_DIGITS = 20000;\n\n/**\n * Renders an exact integer, or describes it when writing it out is itself the\n * expensive operation.\n *\n * This used to be a bare `= ${value}` template, which renders whatever it is\n * handed: `1n << 100000000` took 8.5 seconds here turning a 12.5MB integer\n * into a thirty-million-character string, and a host has no way to opt out,\n * since displaying the answer is what it asked the engine for. The VM's own\n * ceiling on `<<` and `^` now stops that value existing, so this is the\n * backstop for every other way a large bigint can arrive (repeated `x * x`,\n * a Value a host built itself), and it costs one comparison for every value\n * that is not absurd.\n *\n * The digit count is estimated from the bit length rather than measured, since\n * measuring means doing the conversion this exists to avoid. Bit length comes\n * off the hexadecimal form, which is linear in the size of the value where the\n * decimal form is not.\n */\nfunction formatBigInt(value: bigint): string {\n const magnitude = value < 0n ? -value : value;\n // Every bigint a person actually reads takes this line and nothing else:\n // anything a double can hold is at most 309 digits, so it is printable\n // without measuring it at all.\n if (Number.isFinite(Number(magnitude))) return `= ${value}`;\n const bits = magnitude.toString(16).length * 4;\n if (bits * Math.LN2 / Math.LN10 <= MAX_DISPLAYED_BIGINT_DIGITS) return `= ${value}`;\n const log10 = bits * Math.LN2 / Math.LN10;\n const exponent = Math.floor(log10);\n const mantissa = Math.pow(10, log10 - exponent);\n const sign = value < 0n ? \"-\" : \"\";\n return `= ${sign}~${mantissa.toFixed(3)}e+${exponent} (an exact integer of about ${(exponent + 1).toLocaleString(\"en-US\")} digits, too large to print)`;\n}\n\nfunction formatString(value: string): string {\n return `= ${value}`;\n}\n\nfunction formatBoolean(value: boolean): string {\n return `= ${value}`;\n}\n\n/**\n * Renders a Datetime value locale-aware, the previous implementation\n * called `d.toLocaleString()` with no arguments, which always uses the JS\n * runtime's own default locale and never actually consulted `locale.code`\n * despite receiving it as a parameter (both branches of its old\n * `dateFormat === \"default\"` check were byte-for-byte identical, dead\n * groundwork for a distinction that was never implemented). Concretely,\n * this meant every configured locale (including the shipped German one)\n * always displayed weekday/month names in English. See GitHub issue #77.\n *\n * Uses `weekday`/`month`: \"long\" for a spelled-out date (\"Monday,\n * November 17, 2025\" / \"lundi 17 novembre 2025\") since that's what a\n * literal weekday name is for; a bare numeric date doesn't need\n * localizing beyond the decimal/thousands separators `formatNumber()`\n * already handles. The time-of-day portion is only appended when it's\n * not exactly local midnight, bare date literals (\"today\", \"17/11/2025\")\n * always anchor to local midnight, and showing \"00:00:00\" on every one of\n * those would be noise, not information.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings): string {\n const d = new Date(value);\n const format = settings.dateResult?.format ?? \"long\";\n const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = d.toLocaleDateString(locale.code, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n if (isMidnight) return `= ${dateStr}`;\n return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;\n }\n\n // The numeric forms, built from the local calendar fields so they read the\n // same regardless of the JS runtime's own default locale.\n const p2 = (n: number) => String(n).padStart(2, \"0\");\n const year = d.getFullYear();\n const month = p2(d.getMonth() + 1);\n const day = p2(d.getDate());\n let datePart: string;\n if (format === \"iso\") datePart = `${year}-${month}-${day}`;\n else if (format === \"dmy\") datePart = `${day}/${month}/${year}`;\n else datePart = `${month}/${day}/${year}`; // mdy\n\n if (isMidnight) return `= ${datePart}`;\n const time = `${p2(d.getHours())}:${p2(d.getMinutes())}:${p2(d.getSeconds())}`;\n // ISO joins date and time with `T`; the slash forms with a space.\n return format === \"iso\" ? `= ${datePart}T${time}` : `= ${datePart} ${time}`;\n}\n\n/**\n * Renders a millisecond duration as clock-style `H:MM` (or `H:MM:SS` when\n * there's a non-zero seconds component). `ms` is never a user-typeable\n * unit (confirmed: it appears nowhere in `lexer/units.ts`), it's only\n * ever produced by subtracting two clock times/datetimes (`9:30 - 8:30`,\n * `VM.ts`'s Datetime SUB case), so this is a safe, narrow special case,\n * not a general change to how durations display.\n */\nfunction formatMsDuration(ms: number): string {\n const sign = ms < 0 ? \"-\" : \"\";\n const totalSeconds = Math.round(Math.abs(ms) / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n const mm = String(minutes).padStart(2, \"0\");\n if (seconds === 0) return `${sign}${hours}:${mm}`;\n const ss = String(seconds).padStart(2, \"0\");\n return `${sign}${hours}:${mm}:${ss}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData): string {\n if (unit === \"ms\") return `= ${formatMsDuration(value)}`;\n\n const dp = settings.unitOfMeasurementResult.decimalPlaces;\n\n // For TimeSpan values (days, weeks, hours, etc.), format as integer if the value is a whole number\n const timeSpanUnits = [\"days\", \"weeks\", \"months\", \"years\", \"hours\", \"minutes\", \"seconds\", \"day\", \"week\", \"month\", \"year\", \"hour\", \"minute\", \"second\"];\n const isTimeSpan = unit && timeSpanUnits.includes(unit);\n\n let formatted: string;\n if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = value.toString();\n } else {\n // For other values, use the configured decimal places\n formatted = value.toFixed(dp);\n }\n\n // Currency display: symbol + culturally-conventional placement (e.g.\n // \"$100.00\" prefix vs \"100.00 kr\" suffix) instead of the generic\n // \"amount CODE\" fallback below. See uom/CurrencyAliases.ts's\n // CURRENCY_DISPLAY table for the exact set covered and the reasoning\n // behind each placement choice. Any currency code NOT in that table\n // (most of the ~150 `CurrencyExchange.isCurrency()` recognizes) falls\n // through to the unchanged \"amount CODE\" format below.\n const currencyDisplay = unit ? CURRENCY_DISPLAY[unit.toUpperCase()] : undefined;\n if (currencyDisplay) {\n // An exact money amount rounds from its decimal, not from the double: a\n // half-cent like \"$1.005\" reads as \"$1.01\" here, where \"(1.005).toFixed(2)\"\n // answers \"1.00\" because the double it is handed already sits below the\n // value the user typed. Amounts with no exact decimal (a currency\n // conversion, whose rate is a double) keep the toFixed rendering above.\n const moneyText = exact ? decimalToFixed(exact, dp) : formatted;\n const sep = currencyDisplay.spaced ? \" \" : \"\";\n const withSymbol = currencyDisplay.position === \"prefix\"\n ? `${currencyDisplay.symbol}${sep}${moneyText}`\n : `${moneyText}${sep}${currencyDisplay.symbol}`;\n return `= ${withSymbol}`;\n }\n\n // The unit is written as the symbol the value carries. There used to be a\n // `unitOfMeasurementResult.unitNames` setting here whose two branches were\n // the same expression, so it never changed anything, and it was removed\n // rather than implemented: the engine has no unit-name data to render from.\n // The generated unit table maps a spelling to [measure, ratio] only, and\n // names cannot be recovered from it, because units that differ by an OFFSET\n // share a ratio, so \"20 C\" would come back as \"20 kelvins\". A real\n // implementation needs a hand-authored name per unit plus pluralization and\n // per-locale spelling (metre against meter), which is a feature rather than\n // the repair of a dead ternary.\n //\n // An exact currency with no symbol in the display table above (one of the\n // less common ISO codes) still rounds from its decimal here, so \"1.005 UYW\"\n // reads the same way \"$1.005\" does. Non-currency Uoms never carry an exact,\n // so this leaves \"1.50 kg\" exactly as it was.\n const genericText = exact ? decimalToFixed(exact, dp) : formatted;\n return `= ${genericText} ${unit || \"\"}`.trim();\n}\n\nfunction formatMatrixEntry(entry: MatrixEntry, settings: FormattingSettings): string {\n if (typeof entry === \"boolean\") return entry ? \"true\" : \"false\";\n if (typeof entry === \"object\" && entry !== null) return formatSymbolic(entry);\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n return autoFormatIntegerOrFloat(entry, dp, sep, loc);\n}\n\n/**\n * Renders a Matrix matching its own literal syntax: a single row (1xN,\n * including plain vectors) as `[a, b, c]`, a single column (Nx1) as\n * `[a; b; c]`, and a general shape as `[r0c0, r0c1; r1c0, r1c1]`, row-major\n * textual output read back out of the column-major storage\n * (`columnMajorToRowMajor()`), matching how `[1,2;3,4]` is written.\n */\nfunction formatMatrix(m: MatrixData, locale: ILocale, settings: FormattingSettings): string {\n const rowMajor = columnMajorToRowMajor(m);\n const rows: string[] = [];\n for (let r = 0; r < m.rows; r++) {\n const cells: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));\n }\n rows.push(cells.join(\", \"));\n }\n return `${locale.display.resultPrefix}[${rows.join(\"; \")}]`;\n}\n\n/**\n * Render a matrix as a multi-line, column-aligned block: one row per line (the\n * newline is where {@link formatValue}'s compact form writes `;`), each column\n * right-padded to its widest cell, and every row wrapped in `[ ... ]`. For\n * display where a grid reads better than a line, e.g. a docs notepad or a REPL:\n *\n * ```text\n * [ 1 2 ]\n * [ 30 4 ]\n * ```\n *\n * This is deliberately separate from {@link formatValue}, whose single-line\n * matrix form stays the stable, assertable text the API and the worker DTO use.\n * A 1xN row vector is one line; an Nx1 column vector is N lines.\n */\nexport function formatMatrixAligned(m: MatrixData, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const rowMajor = columnMajorToRowMajor(m);\n const cells: string[][] = [];\n for (let r = 0; r < m.rows; r++) {\n const row: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n row.push(formatMatrixEntry(rowMajor[r * m.cols + c], us));\n }\n cells.push(row);\n }\n const colWidth: number[] = [];\n for (let c = 0; c < m.cols; c++) {\n let width = 0;\n for (let r = 0; r < m.rows; r++) width = Math.max(width, cells[r][c].length);\n colWidth.push(width);\n }\n return cells\n .map((row) => `[ ${row.map((cell, c) => cell.padStart(colWidth[c])).join(\" \")} ]`)\n .join(\"\\n\");\n}\n\nfunction formatRange(min: number, max: number, locale: ILocale): string {\n return `${locale.display.resultPrefix}${min}:${max}`;\n}\n\nfunction formatPercentage(value: number, locale: ILocale, settings: FormattingSettings): string {\n // ValueType.Percentage stores a fraction (0.25 for 25%). See Value.ts's\n // documented contract and the sole producer, VM.ts's TO_PERCENTAGE opcode\n // (`right/left - 1`, e.g. 0.25 for \"800 to 1000\"). Multiply by 100 before\n // formatting; without this every percentage-change result displayed as\n // e.g. \"0.25%\" instead of \"25.00%\".\n const dp = settings.percentageResult.decimalPlaces;\n const formatted = (value * 100).toFixed(dp);\n return `= ${formatted}${locale.display.percentageSuffix}`;\n}\n\nfunction formatUnit(value: number, unit: string | undefined): string {\n return `= ${value} ${unit || \"\"}`.trim();\n}\n\n/**\n * Renders a per-person bill split: \"= $45.00 each\", or, when the division is\n * uneven, \"= $33.33 each, with 1 share paying $33.34\". Each share's amount is\n * rendered through the ordinary value formatter (a throwaway {@link Value}), so\n * a currency share honours the same symbol placement, decimal places and locale\n * as any other money and a bare share trims trailing zeros the way a plain\n * number does; the \"= \" prefix is added once, around the whole sentence, not\n * per share.\n */\nfunction formatSplit(data: SplitData, locale: ILocale, settings: FormattingSettings): string {\n const prefix = locale.display.resultPrefix;\n const render = (share: SplitShare): string => {\n const v = data.unit !== undefined\n ? new Value(ValueType.Uom, share.value, data.unit)\n : new Value(ValueType.Number, share.value);\n v.exact = share.exact;\n const text = formatValue(v, settings);\n return text.startsWith(prefix) ? text.slice(prefix.length) : text;\n };\n\n const [base, high] = data.shares;\n const each = `${render(base)} each`;\n if (high === undefined) return `${prefix}${each}`;\n const shareWord = high.count === 1 ? \"share\" : \"shares\";\n return `${prefix}${each}, with ${high.count} ${shareWord} paying ${render(high)}`;\n}\n\n/**\n * Render an evaluated {@link Value} as a display string, dispatching on\n * `value.type` to the type-specific formatter (number, hex, datetime, unit\n * of measurement, matrix, range, percentage, ...).\n *\n * Most branches produce a `\"= \"`-prefixed result string (matching the\n * plugin's inline-result convention); `ValueType.Error` is the one\n * exception, it returns the human-readable error message directly\n * (stored in `value.unit`), not an `\"= \"`-prefixed string.\n *\n * @param value - The evaluated value to format.\n * @param settings - Locale/precision/separator options; defaults to\n * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.\n * @example\n * ```typescript\n * const value = engine.evaluateExpression(\"10 USD to GBP\");\n * formatValue(value); // \"= £7.85\" (exact output depends on live exchange rates)\n * ```\n */\nexport function formatValue(value: Value, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const localeCode = us.numberResult.decimalSeparatorLocale || \"en\";\n const locale = getLocale(localeCode);\n\n switch (value.type) {\n case ValueType.Number:\n // A measurement with a tolerance renders as \"center ± spread\"; every\n // other number is unchanged, so a plain value is byte-for-byte what it was.\n if (value.uncertainty !== undefined) {\n return formatUncertain(value.value as number, value.uncertainty, locale, us);\n }\n return formatNumber(value.value as number, locale, us, value.decimalPlaces);\n case ValueType.Hex:\n return formatHex(value.value as number | bigint, us, value.unit);\n case ValueType.BigInt:\n return formatBigInt(value.value as bigint);\n case ValueType.String:\n return formatString(value.value as string);\n case ValueType.Boolean:\n return formatBoolean(value.value as boolean);\n case ValueType.Datetime:\n return formatDatetime(value.value as number, locale, us);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact);\n case ValueType.Matrix:\n return formatMatrix(value.value as MatrixData, locale, us);\n case ValueType.Range: {\n const r = value.value as RangeData;\n return formatRange(r.min, r.max, locale);\n }\n case ValueType.Colour:\n return `${locale.display.resultPrefix}${formatColour(value.value as ColourData)}`;\n case ValueType.Split:\n return formatSplit(value.value as SplitData, locale, us);\n case ValueType.Symbolic:\n return formatSymbolic(value.value as SymbolicNode);\n case ValueType.Percentage:\n return formatPercentage(value.value as number, locale, us);\n case ValueType.Unit:\n return formatUnit(value.value as number, value.unit);\n case ValueType.Error:\n // errorValue(code, message) stores the human-readable message in\n // `.unit` (code goes in `.value`), falling through to the default\n // case here previously displayed the raw code (e.g.\n // \"CURRENCY_RATE_UNAVAILABLE\") instead of the actual message.\n return value.unit ?? String(value.value);\n default:\n return `= ${String(value.value)}`;\n }\n}\n"]}