solve-engine 2.7.0 → 2.9.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 (102) hide show
  1. package/dist/{chunk-5FO4PDIG.js → chunk-3GAWAMT4.js} +2 -2
  2. package/dist/{chunk-5FO4PDIG.js.map → chunk-3GAWAMT4.js.map} +1 -1
  3. package/dist/{chunk-32GC2FHC.cjs → chunk-3HYO3QYW.cjs} +2 -2
  4. package/dist/{chunk-32GC2FHC.cjs.map → chunk-3HYO3QYW.cjs.map} +1 -1
  5. package/dist/{chunk-2JMFUQZH.js → chunk-44EOEWGP.js} +2 -2
  6. package/dist/chunk-44EOEWGP.js.map +1 -0
  7. package/dist/chunk-556Q7VZC.cjs +2 -0
  8. package/dist/chunk-556Q7VZC.cjs.map +1 -0
  9. package/dist/{chunk-B7J24Q5T.cjs → chunk-6ILXAGWX.cjs} +2 -2
  10. package/dist/{chunk-B7J24Q5T.cjs.map → chunk-6ILXAGWX.cjs.map} +1 -1
  11. package/dist/{chunk-CIQOK7Q4.cjs → chunk-6QRHN3I6.cjs} +2 -2
  12. package/dist/chunk-6QRHN3I6.cjs.map +1 -0
  13. package/dist/{chunk-IHZBKT7L.cjs → chunk-6TPXH6Y5.cjs} +3 -3
  14. package/dist/chunk-6TPXH6Y5.cjs.map +1 -0
  15. package/dist/{chunk-W7VOTR2J.cjs → chunk-7VJN65QP.cjs} +3 -3
  16. package/dist/{chunk-W7VOTR2J.cjs.map → chunk-7VJN65QP.cjs.map} +1 -1
  17. package/dist/{chunk-GYX6S6OS.cjs → chunk-AEPS7W3D.cjs} +3 -3
  18. package/dist/chunk-AEPS7W3D.cjs.map +1 -0
  19. package/dist/chunk-BKSKZA4W.cjs +2 -0
  20. package/dist/chunk-BKSKZA4W.cjs.map +1 -0
  21. package/dist/{chunk-VAGS5JS7.cjs → chunk-C65UDMWH.cjs} +2 -2
  22. package/dist/{chunk-VAGS5JS7.cjs.map → chunk-C65UDMWH.cjs.map} +1 -1
  23. package/dist/chunk-DLAKPF5T.js +2 -0
  24. package/dist/chunk-DLAKPF5T.js.map +1 -0
  25. package/dist/{chunk-AQWNEO7M.cjs → chunk-EURCQMZK.cjs} +2 -2
  26. package/dist/{chunk-AQWNEO7M.cjs.map → chunk-EURCQMZK.cjs.map} +1 -1
  27. package/dist/{chunk-G7TBEQRQ.js → chunk-GMSBBLUQ.js} +2 -2
  28. package/dist/{chunk-G7TBEQRQ.js.map → chunk-GMSBBLUQ.js.map} +1 -1
  29. package/dist/chunk-HE7E6M5O.js +3 -0
  30. package/dist/chunk-HE7E6M5O.js.map +1 -0
  31. package/dist/chunk-K4MME6ZT.js +2 -0
  32. package/dist/chunk-K4MME6ZT.js.map +1 -0
  33. package/dist/{chunk-5AMJNF7J.js → chunk-LH7URJZT.js} +3 -3
  34. package/dist/chunk-LH7URJZT.js.map +1 -0
  35. package/dist/{chunk-KXM7EY27.js → chunk-N46DFZLZ.js} +3 -3
  36. package/dist/{chunk-KXM7EY27.js.map → chunk-N46DFZLZ.js.map} +1 -1
  37. package/dist/{chunk-CVY2A3TP.js → chunk-OVNB7MI5.js} +2 -2
  38. package/dist/{chunk-CVY2A3TP.js.map → chunk-OVNB7MI5.js.map} +1 -1
  39. package/dist/{chunk-ZRFUD2LX.cjs → chunk-OWQF6ZOK.cjs} +4 -4
  40. package/dist/{chunk-ZRFUD2LX.cjs.map → chunk-OWQF6ZOK.cjs.map} +1 -1
  41. package/dist/{chunk-HF4H7LYA.js → chunk-P7XWFT45.js} +3 -3
  42. package/dist/{chunk-HF4H7LYA.js.map → chunk-P7XWFT45.js.map} +1 -1
  43. package/dist/{chunk-YAHGSBMC.js → chunk-QYO7IEPR.js} +2 -2
  44. package/dist/{chunk-YAHGSBMC.js.map → chunk-QYO7IEPR.js.map} +1 -1
  45. package/dist/{chunk-2LFLR3VZ.cjs → chunk-SNVPM27Q.cjs} +2 -2
  46. package/dist/{chunk-2LFLR3VZ.cjs.map → chunk-SNVPM27Q.cjs.map} +1 -1
  47. package/dist/{chunk-AR7L5OJ2.js → chunk-T3FBAFRR.js} +2 -2
  48. package/dist/{chunk-AR7L5OJ2.js.map → chunk-T3FBAFRR.js.map} +1 -1
  49. package/dist/chunk-UWAXJX5G.js +2 -0
  50. package/dist/chunk-UWAXJX5G.js.map +1 -0
  51. package/dist/chunk-WEAKI5V5.cjs +2 -0
  52. package/dist/chunk-WEAKI5V5.cjs.map +1 -0
  53. package/dist/{chunk-NXIMGB4S.cjs → chunk-WYIOXAFW.cjs} +2 -2
  54. package/dist/{chunk-NXIMGB4S.cjs.map → chunk-WYIOXAFW.cjs.map} +1 -1
  55. package/dist/{chunk-HTJPV42D.js → chunk-YTCTUBR2.js} +2 -2
  56. package/dist/{chunk-HTJPV42D.js.map → chunk-YTCTUBR2.js.map} +1 -1
  57. package/dist/constants.cjs +1 -1
  58. package/dist/constants.js +1 -1
  59. package/dist/engine.cjs +1 -1
  60. package/dist/engine.js +1 -1
  61. package/dist/format.cjs +1 -1
  62. package/dist/format.js +1 -1
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.js +1 -1
  65. package/dist/language.cjs +1 -1
  66. package/dist/language.js +1 -1
  67. package/dist/lexer.cjs +1 -1
  68. package/dist/lexer.js +1 -1
  69. package/dist/normalizer.cjs +1 -1
  70. package/dist/normalizer.js +1 -1
  71. package/dist/packages.cjs +1 -1
  72. package/dist/packages.d.cts +1 -1
  73. package/dist/packages.d.ts +1 -1
  74. package/dist/packages.js +1 -1
  75. package/dist/testing.cjs +2 -2
  76. package/dist/testing.js +1 -1
  77. package/dist/uom.cjs +1 -1
  78. package/dist/uom.js +1 -1
  79. package/dist/vm.cjs +1 -1
  80. package/dist/vm.js +1 -1
  81. package/dist/worker.cjs +2 -2
  82. package/dist/worker.js +1 -1
  83. package/package.json +1 -1
  84. package/dist/chunk-2JMFUQZH.js.map +0 -1
  85. package/dist/chunk-5AMJNF7J.js.map +0 -1
  86. package/dist/chunk-CIQOK7Q4.cjs.map +0 -1
  87. package/dist/chunk-FWW3M36J.cjs +0 -2
  88. package/dist/chunk-FWW3M36J.cjs.map +0 -1
  89. package/dist/chunk-GYX6S6OS.cjs.map +0 -1
  90. package/dist/chunk-HAEOMJE3.cjs +0 -2
  91. package/dist/chunk-HAEOMJE3.cjs.map +0 -1
  92. package/dist/chunk-IANAMBJQ.cjs +0 -2
  93. package/dist/chunk-IANAMBJQ.cjs.map +0 -1
  94. package/dist/chunk-IHZBKT7L.cjs.map +0 -1
  95. package/dist/chunk-N4HJTHZR.js +0 -2
  96. package/dist/chunk-N4HJTHZR.js.map +0 -1
  97. package/dist/chunk-P5EMTVMJ.js +0 -3
  98. package/dist/chunk-P5EMTVMJ.js.map +0 -1
  99. package/dist/chunk-TRBXW6HW.js +0 -2
  100. package/dist/chunk-TRBXW6HW.js.map +0 -1
  101. package/dist/chunk-WGZ3FNHI.js +0 -2
  102. package/dist/chunk-WGZ3FNHI.js.map +0 -1
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkCIQOK7Q4_cjs=require('./chunk-CIQOK7Q4.cjs');var p=new Map(Object.entries(chunkCIQOK7Q4_cjs.a)),_=new Map(Object.entries(chunkCIQOK7Q4_cjs.b));function a(n){return p.get(n)}function b(n,e,t){let r=p.get(e);if(r===void 0)throw new RangeError(`${e} is not a valid unit`);let i=p.get(t);if(i===void 0)throw new RangeError(`${t} is not a valid unit`);return x(n,e,t,r,i)}function x(n,e,t,r,i){let s=r,u=i;if(s[0]!==u[0])throw new RangeError(`Cannot convert between different measures: ${e} and ${t}`);let o=s[1],d=u[1],f=_.get(e),l=_.get(t);return f!==void 0?l!==void 0?(n+f)*(o/d)-l:(n+f)*(o/d):l!==void 0?n*(o/d)-l:n*(o/d)}function B(n,e){let t=p.get(e);if(t===void 0)throw new RangeError(`${e} is not a valid unit`);let r=chunkCIQOK7Q4_cjs.c[t[0]],i=r[0][0],s=i,u=b(n,e,i),o=u<0?-u:u;for(let d=0;d<r.length;d++){let f=r[d];if(o>=f[1])s=f[0];else break}return {quantity:b(n,e,s),unit:s}}var v=new Set(["workday","workdays"]),F=7/5;function g(n){return typeof n=="string"&&v.has(n)}function k(n){return n}function m(n){if(g(n))return m("day");let e=chunkCIQOK7Q4_cjs.f[n];if(e)return e.measure;let t=a(n);if(t!==void 0)return chunkCIQOK7Q4_cjs.e[t[0]]}function K(n,e){if(n===e)return true;if(g(n)||g(e)){let u=m(n),o=m(e);return !!u&&u===o}let t=a(n),r=a(e);if(t!==void 0&&r!==void 0)return t[0]===r[0];let i=chunkCIQOK7Q4_cjs.f[n],s=chunkCIQOK7Q4_cjs.f[e];return i!==void 0&&s!==void 0?i.measure===s.measure:y(n,e)||y(e,n)}function y(n,e){let t=chunkCIQOK7Q4_cjs.f[n];if(t===void 0)return false;let r=a(e);return r===void 0?false:chunkCIQOK7Q4_cjs.e[r[0]]===t.measure}function R(n,e,t){if(e===t)return n;let r=a(e),i=a(t);if(r!==void 0&&i!==void 0)return x(n,e,t,r,i);if(g(e)&&g(t))return n;if(g(e)){let o=n*F;return t==="day"?o:R(o,"day",t)}if(g(t))return (e==="day"?n:R(n,e,"day"))/F;let s=chunkCIQOK7Q4_cjs.f[e],u=chunkCIQOK7Q4_cjs.f[t];return s!==void 0&&u!==void 0?n*(s.toBase/u.toBase):s!==void 0&&y(e,t)?b(n*s.toBase,N(t),t):u!==void 0&&y(t,e)?b(n,e,N(e))/u.toBase:b(n,e,t)}function N(n){let e=a(n);if(e===void 0)return n;for(let t of Object.keys(chunkCIQOK7Q4_cjs.a)){let r=chunkCIQOK7Q4_cjs.a[t];if(r[0]===e[0]&&r[1]===1)return t}return n}function L(n){let e=n,t=a(e);if(t===void 0)return [];let r=chunkCIQOK7Q4_cjs.d[t[0]];return r?r.filter(i=>i!==e):[]}function $(n){return g(n)||chunkCIQOK7Q4_cjs.f[n]?true:a(n)!==void 0}function Y(n,e){let t=e;try{let r=B(n,t);return {value:r.quantity,unit:r.unit}}catch{return {value:n,unit:t}}}function S(n,e){let t=e.indexOf("/");if(t>=0)return {value:n,numerator:e.slice(0,t),denominator:e.slice(t+1)};let r=chunkCIQOK7Q4_cjs.f[e];return r!==void 0&&r.measure==="speed"?{value:n*r.toBase,numerator:"m",denominator:"s"}:null}function O(n,e){if(n===e)return 1;if(n===""||e==="")return null;let t=m(n),r=m(e);return t===void 0||r===void 0||t!==r?null:R(1,n,e)}function j(n,e,t){let r=S(n,e);if(r===null)return null;let i,s,u,o=t.indexOf("/");if(o>=0)i=t.slice(0,o),s=t.slice(o+1),u=1;else {let l=chunkCIQOK7Q4_cjs.f[t];if(l===void 0||l.measure!=="speed")return null;i="m",s="s",u=l.toBase;}let d=O(r.numerator,i);if(d===null)return null;let f=O(r.denominator,s);return f===null?null:r.value*d/f/u}exports.a=g;exports.b=k;exports.c=m;exports.d=K;exports.e=R;exports.f=L;exports.g=$;exports.h=Y;exports.i=j;//# sourceMappingURL=chunk-IANAMBJQ.cjs.map
2
- //# sourceMappingURL=chunk-IANAMBJQ.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":["UNIT_LOOKUP","UNIT_TABLE","DIFFERENCE_LOOKUP","UNIT_DIFFERENCES","lookupUnit","unit","convertRaw","quantity","from","to","parsedFrom","parsedTo","convertResolved","fromEntry","toEntry","fromRatio","toRatio","fromDifference","toDifference","convertToBestMetric","best","BEST_UNITS_METRIC","smallestUnit","bestUnit","baseQuantity","absQuantity","i","bestEntry","WORKDAY_UNIT_NAMES","WORKDAY_TO_DAY_FACTOR","isWorkdayUnit","resolveUnit","getMeasure","extended","EXTENDED_UNITS","entry","MEASURE_KIND_NAMES","canConvert","fromMeasure","toMeasure","fromExtended","toExtended","bridgesToBaseMeasure","extendedUnit","baseUnit","base","convertUnit","value","days","fExt","tExt","baseUnitFor","symbol","candidate","getConvertiblePossibilities","resolved","symbols","MEASURE_SYMBOLS","s","isConvertibleUnit","getBestUnit","u","result","expandUnitToRate","slash","ext","rateAx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AAA,KACT,CACL,IAAMN,CAAAA,CAAM/B,oBAAezB,CAAE,CAAA,CAC7B,GAAIwD,CAAAA,GAAQ,MAAA,EAAaA,CAAAA,CAAI,UAAY,OAAA,CAAS,OAAO,IAAA,CACzDI,CAAAA,CAAkB,GAAA,CAClBC,CAAAA,CAAoB,IACpBC,CAAAA,CAAcN,CAAAA,CAAI,OACpB,CAEA,IAAMO,CAAAA,CAAkBN,EAAeE,CAAAA,CAAO,SAAA,CAAWC,CAAe,CAAA,CACxE,GAAIG,IAAoB,IAAA,CAAM,OAAO,IAAA,CACrC,IAAMC,CAAAA,CAAoBP,CAAAA,CAAeE,EAAO,WAAA,CAAaE,CAAiB,CAAA,CAC9E,OAAIG,CAAAA,GAAsB,IAAA,CAAa,KAE/BL,CAAAA,CAAO,KAAA,CAAQI,CAAAA,CAAmBC,CAAAA,CAAoBF,CAChE","file":"chunk-IANAMBJQ.cjs","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n\n// ── Rate and derived-unit conversion ───────────────────────────────────────\n//\n// A rate value carries a compound unit spelled \"numerator/denominator\" (e.g.\n// \"km/h\", \"m/s\"), see vm/Value.ts's rateValue(). Plain convertUnit() cannot\n// touch one, because neither half is the whole unit and getMeasure(\"km/h\") is\n// undefined. This section converts a rate to another rate, and bridges a rate\n// to the single-token speed spellings (mph, kph, mps, ...) that ExtendedUnits.ts\n// already carries, so \"100 km/h in mph\" and \"60 mph in km/h\" resolve instead of\n// reporting incompatible units.\n\n/** A rate reduced to a numerator unit over a denominator unit. */\ninterface RateForm {\n /** Magnitude, scaled so `value numerator/denominator` is the physical quantity. */\n value: number;\n /** Numerator unit spelling, or `\"\"` for a countless rate such as `30/week`. */\n numerator: string;\n /** Denominator unit spelling. */\n denominator: string;\n}\n\n/**\n * Express `value unit` as a numerator/denominator rate, or `null` when `unit`\n * is neither a compound rate spelling nor a single-token speed alias.\n *\n * A speed alias (mph, kph, ...) is one unit standing for a length/time rate, so\n * it expands to the base pair `m`/`s` with its value scaled by the alias's\n * metres-per-second factor. That collapses both inputs to one shape, so a\n * single routine handles rate/rate and rate/alias without a second code path.\n */\nfunction expandUnitToRate(value: number, unit: string): RateForm | null {\n const slash = unit.indexOf(\"/\");\n if (slash >= 0) {\n return { value, numerator: unit.slice(0, slash), denominator: unit.slice(slash + 1) };\n }\n const ext = EXTENDED_UNITS[unit];\n if (ext !== undefined && ext.measure === \"speed\") {\n // 1 alias == ext.toBase m/s, so `value alias` is `value * toBase` m/s.\n return { value: value * ext.toBase, numerator: \"m\", denominator: \"s\" };\n }\n return null;\n}\n\n/**\n * The factor that turns one `from` into `to` along a single rate axis, or\n * `null` when the two cannot line up.\n *\n * Same spelling needs no conversion. A countless axis (`\"\"`) only lines up with\n * another countless one, never with a real unit. Otherwise both sides must name\n * the same measure, which is what keeps a length numerator from pairing with a\n * mass one.\n */\nfunction rateAxisFactor(from: string, to: string): number | null {\n if (from === to) return 1;\n if (from === \"\" || to === \"\") return null;\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n if (fromMeasure === undefined || toMeasure === undefined || fromMeasure !== toMeasure) {\n return null;\n }\n return convertUnit(1, from, to);\n}\n\n/**\n * Convert `value` from a rate/speed unit `from` to a rate/speed unit `to`,\n * returning the converted magnitude, or `null` when the pair is not\n * rate-convertible (so the caller falls back to its own incompatible-units\n * handling).\n *\n * Handles rate to rate (`10 m/s in km/h`), rate to speed alias\n * (`100 km/h in mph`) and speed alias to rate (`60 mph in km/h`). Plain\n * same-measure pairs (`kph in mph`, `km in miles`) never reach here, they are\n * resolved by {@link convertUnit} first.\n *\n * The rule is the ordinary one for a quotient of quantities: convert the\n * numerator and the denominator each on their own, so `A/B -> C/D` scales by\n * `(A->C) / (B->D)`.\n */\nexport function convertRate(value: number, from: string, to: string): number | null {\n const source = expandUnitToRate(value, from);\n if (source === null) return null;\n\n // The target is either a rate spelling or a single-token speed alias. An\n // alias expands to the base m/s pair, and `targetScale` is what the base-form\n // magnitude is divided by to read out in the alias itself.\n let targetNumerator: string;\n let targetDenominator: string;\n let targetScale: number;\n const slash = to.indexOf(\"/\");\n if (slash >= 0) {\n targetNumerator = to.slice(0, slash);\n targetDenominator = to.slice(slash + 1);\n targetScale = 1;\n } else {\n const ext = EXTENDED_UNITS[to];\n if (ext === undefined || ext.measure !== \"speed\") return null;\n targetNumerator = \"m\";\n targetDenominator = \"s\";\n targetScale = ext.toBase;\n }\n\n const numeratorFactor = rateAxisFactor(source.numerator, targetNumerator);\n if (numeratorFactor === null) return null;\n const denominatorFactor = rateAxisFactor(source.denominator, targetDenominator);\n if (denominatorFactor === null) return null;\n\n return (source.value * numeratorFactor) / denominatorFactor / targetScale;\n}\n"]}
@@ -1 +0,0 @@
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","formatIpCidr","data","dotted","formatIp","formatSplit","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,ECxDA,SAASC,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAA8BC,CAAAA,CAAgC,CAClH,IAAMC,CAAAA,CAAMF,CAAAA,CAAS,WAAA,CAAY,eAAA,CAC3BG,CAAAA,CAAMH,CAAAA,CAAS,YAAA,CAAa,sBAAA,CAMlC,GAAIC,CAAAA,GAAkB,MAAA,EAAa,MAAA,CAAO,QAAA,CAASH,CAAK,CAAA,CAAG,CACzD,IAAMM,CAAAA,CAAYN,CAAAA,CAAM,cAAA,CAAeK,CAAAA,EAAO,OAAA,CAAS,CACrD,qBAAA,CAAuBF,CAAAA,CACvB,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AGkF,EAAanF,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,KAAA,CAAA,CACE,OAAO+D,mBAAAA,CAAe/D,CAAAA,CAAM,KAAqB,CAAA,CACnD,KAAA,CAAA,CACE,OAAOiF,CAAAA,CAAiBjF,CAAAA,CAAM,MAAiBC,CAAAA,CAAQwE,CAAE,EAC3D,KAAA,EAAA,CACE,OAAOS,EAAWlF,CAAAA,CAAM,KAAA,CAAiBA,EAAM,IAAI,CAAA,CACrD,QAKE,OAAOA,CAAAA,CAAM,MAAQ,MAAA,CAAOA,CAAAA,CAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,MAAA,CAAOA,EAAM,KAAK,CAAC,EACnC,CACF","file":"chunk-IHZBKT7L.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, type ChartData, type IpCidrData } from \"@solve-js/vm/Value\";\nimport { formatColour } from \"@solve-js/packages/colour/ColourMath\";\nimport { formatIp } from \"@solve-js/packages/ip/IpMath\";\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 */\n/**\n * An IP/CIDR as text: the dotted quad, plus `/prefix` when present, or a bare\n * `/prefix` when there is no address (`netmask of /24` before it resolves).\n */\nfunction formatIpCidr(data: IpCidrData): string {\n\tif (data.addr === undefined) return `/${data.prefix}`;\n\tconst dotted = formatIp(data.addr);\n\treturn data.prefix === undefined ? dotted : `${dotted}/${data.prefix}`;\n}\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.Chart:\n // A chart is drawn from its data by the host; the text answer is its label\n // (`sin(x) over [0, 6.28]`, or the series a sparkline came from).\n return `${locale.display.resultPrefix}${(value.value as ChartData).label}`;\n case ValueType.IpCidr:\n return `${locale.display.resultPrefix}${formatIpCidr(value.value as IpCidrData)}`;\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 +0,0 @@
1
- import {c as c$2}from'./chunk-KHCNMNZZ.js';import {y,C,a as a$1,G,J,e as e$2,h as h$1,t as t$1,p,k as k$1,m,n as n$1,g as g$1,q as q$3,f as f$2,u as u$1,o as o$1,s as s$1,j as j$2,r as r$2,l,b as b$2,c as c$6}from'./chunk-HTJPV42D.js';import {c as c$5}from'./chunk-YAYBVVG2.js';import {b}from'./chunk-YNMMRH44.js';import {ea,T,U as U$1,X,S,Y,q as q$1,aa,ma,j as j$1,$,_,ia,ra,ua}from'./chunk-WTEXBPBR.js';import {n,g,j,a,P,c as c$3,Q,I,e,C as C$1,F,M,x,y as y$1,w,u,t,v,r as r$1,N,G as G$1,k,K,f as f$1,R,L,s,q as q$2,p as p$1,o,d,A,b as b$1,B}from'./chunk-A33K7NY4.js';import {c as c$4,e as e$1,i,h,f,a as a$2}from'./chunk-WGZ3FNHI.js';import {a as a$3}from'./chunk-2JMFUQZH.js';import {c as c$1,r,d as d$1}from'./chunk-MPB7KUN5.js';var Ct=class{constructor(){this.consumers=new Map;this.dependencies=new Map;this.writes=new Map;this.lineReads=new Map;this.dataSourceDependencies=new Map;this.dataSourceConsumers=new Map;}registerLine(a,o,u){let m=this.lineReads.get(a);if(m)for(let b of m){let h=this.consumers.get(b);h&&h.delete(a);}this.lineReads.set(a,new Set(o));for(let b of o)this.consumers.has(b)||this.consumers.set(b,new Set),this.consumers.get(b).add(a);if(u.length>0){this.dependencies.set(a,new Set(o)),this.writes.set(a,new Set(u));for(let b of u){let h=this.consumers.get(b);h&&h.delete(a);}}}registerLineDataSourceDependency(a,o,u){let m=JSON.stringify(u),b=`${o}:${m}`;this.dataSourceDependencies.has(a)||this.dataSourceDependencies.set(a,new Set),this.dataSourceDependencies.get(a).add(b),this.dataSourceConsumers.has(b)||this.dataSourceConsumers.set(b,new Set),this.dataSourceConsumers.get(b).add(a);}getAffectedLines(a){let o=new Set,u=[a];for(;u.length>0;){let m=u.pop(),b=this.consumers.get(m);if(b)for(let h of b){if(o.has(h))continue;o.add(h);let d=this.writes.get(h);if(d)for(let y of d)u.push(y);}}return o}getAffectedLinesInOrder(a){let o=this.getAffectedLines(a);if(o.size===0)return [];let u=new Map,m=new Map;for(let y of o)u.has(y)||u.set(y,0),m.has(y)||m.set(y,[]);let b=new Map;for(let y of o){let x=this.writes.get(y);if(x)for(let A of x)b.set(A,y);}for(let y of o){let x=this.lineReads.get(y);if(x)for(let A of x){let w=b.get(A);w!==void 0&&w!==y&&(m.get(w).push(y),u.set(y,(u.get(y)??0)+1));}}let h=[];for(let[y,x]of u)x===0&&h.push(y);if(h.length===0&&o.size>0){let y=Array.from(o).sort((x,A)=>x-A);h.push(y[0]);}let d=[];for(;h.length>0;){let y=h.shift();d.push(y);for(let x of m.get(y)??[]){let A=(u.get(x)??1)-1;u.set(x,A),A===0&&h.push(x);}}if(d.length<o.size){let y=new Set(d),x=Array.from(o).filter(A=>!y.has(A)).sort((A,w)=>A-w);d.push(...x);}return d}getAffectedLinesByDataSource(a,o){let u=JSON.stringify(o),m=`${a}:${u}`;return this.dataSourceConsumers.get(m)??new Set}removeLine(a){let o=this.lineReads.get(a);if(o){for(let m of o){let b=this.consumers.get(m);b&&b.delete(a);}this.lineReads.delete(a);}this.dependencies.delete(a),this.writes.delete(a);let u=this.dataSourceDependencies.get(a);if(u){for(let m of u)this.dataSourceConsumers.get(m)?.delete(a);this.dataSourceDependencies.delete(a);}}getConsumers(a){return this.consumers.get(a)??new Set}getDependencies(a){return this.dependencies.get(a)??new Set}getWrites(a){return this.writes.get(a)??new Set}getSnapshot(){let a={};for(let[h,d]of this.consumers)a[h]=Array.from(d);let o={};for(let[h,d]of this.writes)o[h]=Array.from(d);let u={};for(let[h,d]of this.lineReads)u[h]=Array.from(d);let m={};for(let[h,d]of this.dataSourceDependencies)m[h]=Array.from(d);let b={};for(let[h,d]of this.dataSourceConsumers)b[h]=Array.from(d);return {consumers:a,writes:o,reads:u,dataSourceDeps:m,dataSourceConsumers:b}}clear(){this.consumers.clear(),this.dependencies.clear(),this.writes.clear(),this.lineReads.clear(),this.dataSourceDependencies.clear(),this.dataSourceConsumers.clear();}};var Ot=class{constructor(){this.definitions=new Map;}write(a,o,u){this.definitions.has(a)||this.definitions.set(a,[]);let m=this.definitions.get(a);m.push({line:o,expr:u}),m.sort((b,h)=>b.line-h.line);}read(a,o){let u=this.definitions.get(a);if(u){for(let m=u.length-1;m>=0;m--)if(u[m].line<=o)return u[m].expr.lastResult}}invalidateDownstream(a,o){let u=this.definitions.get(a);if(!u)return;let m=u.findIndex(b=>b.line===o);m!==-1&&u.splice(m+1);}clear(){this.definitions.clear();}};function Jt(r){let a=new Date(r).getDay();return a===0||a===6}function vt(r,a){return Jt(r)?false:a?!a(r):true}function Ut(r){let a=new Date(r);return new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime()}function Rt(r,a,o,u){let m=Math.trunc(Math.abs(a)),b=a>=0?1:-1,h=new Date(r),d=0;for(;m>0;){if(h.setDate(h.getDate()+b),d++,d>u)return null;vt(h.getTime(),o)&&m--;}return h.getTime()}function Vt(r,a,o,u){let m=Ut(Math.min(r,a)),b=Ut(Math.max(r,a)),h=Math.round((b-m)/864e5);if(h>u)return null;let d=0,y=new Date(m);for(let x=0;x<=h;x++)vt(y.getTime(),o)&&d++,y.setDate(y.getDate()+1);return d}var Zt={0:{name:"sqrt",min:1,max:1},1:{name:"abs",min:1,max:1},2:{name:"sin",min:1,max:1},3:{name:"cos",min:1,max:1},4:{name:"tan",min:1,max:1},5:{name:"log",min:1,max:1},6:{name:"ceil",min:1,max:1},7:{name:"floor",min:1,max:1},8:{name:"round",min:1,max:2},9:{name:"min",min:1,max:1/0},10:{name:"max",min:1,max:1/0},11:{name:"asin",min:1,max:1},12:{name:"acos",min:1,max:1},13:{name:"atan",min:1,max:1},14:{name:"atan2",min:2,max:2},15:{name:"sinh",min:1,max:1},16:{name:"cosh",min:1,max:1},17:{name:"tanh",min:1,max:1},18:{name:"asinh",min:1,max:1},19:{name:"acosh",min:1,max:1},20:{name:"atanh",min:1,max:1},21:{name:"cbrt",min:1,max:1},22:{name:"clz32",min:1,max:1},23:{name:"expm1",min:1,max:1},24:{name:"exp",min:1,max:1},25:{name:"fround",min:1,max:1},26:{name:"hypot",min:1,max:1/0},27:{name:"imul",min:2,max:2},28:{name:"log10",min:1,max:1},29:{name:"log1p",min:1,max:1},30:{name:"log2",min:1,max:1},31:{name:"pow",min:2,max:2},32:{name:"random",min:0,max:0},33:{name:"sign",min:1,max:1},34:{name:"trunc",min:1,max:1},35:{name:"degtorad",min:1,max:1},36:{name:"radtodeg",min:1,max:1},37:{name:"roll",min:2,max:2},38:{name:"gcd",min:2,max:2},39:{name:"lcm",min:2,max:2},40:{name:"permutation",min:2,max:2},41:{name:"combination",min:2,max:2},42:{name:"average",min:0,max:1/0},43:{name:"median",min:0,max:1/0},44:{name:"total",min:0,max:1/0},45:{name:"count",min:0,max:1/0},46:{name:"proportion",min:3,max:3},47:{name:"clamp",min:3,max:3},48:{name:"hex",min:1,max:1},49:{name:"bin",min:1,max:1},50:{name:"int",min:1,max:1},51:{name:"compoundInterest",min:3,max:3},52:{name:"interestEarned",min:3,max:3},53:{name:"compoundInterestRate",min:3,max:3},54:{name:"compoundInterestYears",min:3,max:3},55:{name:"loanRepayment",min:4,max:4},56:{name:"loanInterest",min:4,max:4},57:{name:"monthlyPayment",min:3,max:3},58:{name:"taxAdd",min:2,max:2},59:{name:"taxRemove",min:2,max:2},60:{name:"inflationAdjust",min:3,max:3},61:{name:"root",min:2,max:2},62:{name:"fact",min:1,max:1},63:{name:"transpose",min:1,max:1},64:{name:"det",min:1,max:1},65:{name:"inv",min:1,max:1},66:{name:"dot",min:2,max:2},67:{name:"expand",min:1,max:1},68:{name:"factor",min:1,max:1},69:{name:"solve",min:3,max:3},70:{name:"der",min:2,max:3},71:{name:"integral",min:2,max:2},72:{name:"taylor",min:4,max:4},73:{name:"jacobian",min:1,max:1/0},74:{name:"imaginary",min:1,max:1},75:{name:"conj",min:1,max:1},76:{name:"re",min:1,max:1},77:{name:"im",min:1,max:1},78:{name:"cancel",min:1,max:1},79:{name:"apart",min:1,max:1},80:{name:"compoundInterestEvery",min:4,max:4},81:{name:"compoundInterestEarnedEvery",min:4,max:4},82:{name:"presentValue",min:3,max:3},83:{name:"roi",min:2,max:2},84:{name:"annualisedReturn",min:3,max:3},85:{name:"taxIn",min:2,max:2},86:{name:"taxOn",min:2,max:2},87:{name:"sind",min:1,max:1},88:{name:"cosd",min:1,max:1},89:{name:"tand",min:1,max:1},90:{name:"asind",min:1,max:1},91:{name:"acosd",min:1,max:1},92:{name:"atand",min:1,max:1},93:{name:"daysCount",min:1,max:1},94:{name:"asTwoUnits",min:3,max:3},95:{name:"makeRate",min:2,max:2},96:{name:"atRate",min:2,max:2},97:{name:"roundToPlaces",min:2,max:2},98:{name:"splitEach",min:2,max:2},99:{name:"savingsGoalPayment",min:3,max:3},100:{name:"savingsGoalPeriods",min:5,max:5},101:{name:"standardDeviation",min:0,max:1/0},102:{name:"sampleStandardDeviation",min:0,max:1/0},103:{name:"variance",min:0,max:1/0},104:{name:"sampleVariance",min:0,max:1/0},105:{name:"spread",min:0,max:1/0},106:{name:"mode",min:0,max:1/0},107:{name:"weightedAverage",min:2,max:1/0}};function ke(r){return r===1?"1 argument":`${r} arguments`}function en(r){return r.max===1/0?`at least ${ke(r.min)}`:r.min===r.max?ke(r.min):`${r.min} to ${ke(r.max)}`}function Bt(r,a){let o=Zt[r];if(o!==void 0&&!(a>=o.min&&a<=o.max))return c$1.execution("BUILTIN_ARITY_MISMATCH",`${o.name}() takes ${en(o)}, but was given ${a===0?"none":ke(a)}`,{functionName:o.name,expectedMin:o.min,expectedMax:o.max,actual:a})}function jn(r,a=200,o=5e4,u=50,m=1e5,b=2e6,h=1e4,d=100,y$1=-100,x=y,A){let w=[],I=new Map,L=0,j,$,n$1=[],Q=new Map,W=new Map,K=new Map;return {push(f){w.length<a&&w.push(f);},getMaxStackDepth(){return a},getMaxCollectionSize(){return m},getMaxAllocatedElements(){return b},getMaxFunctionCalls(){return h},getMaxDateOffsetYears(){return d},getMinDateOffsetYears(){return y$1},isHoliday(f){return A?A(f):false},pop(){return w.length===0?n(0):w.pop()},popNumber(){return c(w).toNumber()},popString(){return q(c(w),"VM.popString()")},peek(){return w[w.length-1]},getStack(){return w},registry:r,getVar(f){if(n$1.length>0){let e=n$1[n$1.length-1].get(f);if(e!==void 0)return e}return I.get(f)},setVar(f,e){I.set(f,e);},deleteVar(f){I.delete(f);},pushCallFrame(f){if(n$1.length>=u)throw c$1.execution("FUNCTION_RECURSION_LIMIT_EXCEEDED",`Function call nesting exceeded maximum depth of ${u} (possible infinite recursion, e.g. f(x) = f(x))`,{maxFunctionRecursionDepth:u});n$1.push(f);},popCallFrame(){n$1.pop();},getCallFrame(){return n$1.length>0?n$1[n$1.length-1]:void 0},defineUserFunction(f,e,t){Q.set(f,{name:f,params:e,program:t});},getUserFunction(f){return Q.get(f)},hasUserFunction(f){return Q.has(f)},getVariableEntries(){return Array.from(I.entries())},getUserFunctionDefs(){return Array.from(Q.values())},defineEquation(f,e,t){W.set(f,{variable:f,factorNames:e,rhsProgram:t});},getEquation(f){return W.get(f)},hasEquation(f){return W.has(f)},defineScalarEquation(f,e,t){K.set(f,{variable:f,lhsProgram:e,rhsProgram:t});},getScalarEquation(f){return K.get(f)},hasScalarEquation(f){return K.has(f)},reset(){w.length=0,I.clear(),n$1.length=0,Q.clear(),W.clear(),K.clear(),L=0,$&&($(),$=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(f){j=f;},get abortCurrent(){return $},set abortCurrent(f){$=f;},context:x,getMaxInstructions(){return o},getInstructionCount(){return L},incrementInstructions(f){if(L+=f,L>o)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${o} instructions`)}}}function tn(r,a){return r.rows===1&&r.cols===1?a.data.length:a.rows===1&&a.cols===1?r.data.length:r.cols!==a.rows?0:r.rows*a.cols}function nn(r,a){return !Number.isInteger(a)||a<0?0:r.rows*r.cols*(1+(a<2?1:2*Math.floor(Math.log2(a))))}function c(r){if(r.length===0)throw c$1.internal({code:"STACK_UNDERFLOW",message:"Stack underflow: an opcode expected a value on the stack but it was empty",expected:"at least one value on the VM stack",found:"an empty stack",suggestion:"this indicates corrupted bytecode or a bug in a package's parselet (mismatched push/pop counts), not a user-input error"});return r.pop()}var jt="bytecode is caller input on this entry point: rebuild the program with the engine's compiler, or fix the hand-assembled stream";function an(r){return typeof r=="number"?b(r):r}function se(r,a,o,u,m,b={}){let h=an(a);return c$1.validation({code:r,message:`Malformed bytecode: ${h} ${o}`,expected:u,found:m,suggestion:jt,context:typeof a=="number"?{opcode:a,opcodeName:h,...b}:{site:h,...b}})}function U(r,a,o,u){if(a>=r.length)throw se("MALFORMED_BYTECODE_TRUNCATED",o,`is missing its ${u}: the program ends mid-instruction`,`an operand byte at offset ${a}`,`a program only ${r.length} byte(s) long`,{offset:a,length:r.length,role:u});return r[a]}function je(r,a,o,u,m,b){let h=U(r,a,o,u);if(h>=m)throw se("MALFORMED_BYTECODE_CONSTANT_INDEX",o,`reads ${b} entry ${h}, which does not exist`,`an index below ${m}`,`${h}`,{index:h,poolSize:m,pool:b});return h}function z(r,a,o,u,m){return Se(o,U(r,a,u,m),u)}function Se(r,a,o){let u=r[a];if(typeof u!="string")throw se("MALFORMED_BYTECODE_CONSTANT_INDEX",o,`reads string-pool entry ${a}, which is ${a>=r.length?"past the end of the pool":"not a string"}`,`an index below ${r.length}, holding a string`,a>=r.length?`${a}`:typeof u,{index:a,poolSize:r.length,pool:"string-pool"});return u}function q(r,a,o){if(typeof r.value!="string")throw se("MALFORMED_BYTECODE_OPERAND_TYPE",a,`expected a ${o??"string"} on the stack`,o?`a string value holding the ${o}`:"a string value",`a ${g[r.type]??"unknown"} value`,o?{role:o,valueType:r.type}:{valueType:r.type});return r.value}function Ft(r,a,o){if(r!==0&&r!==1&&r!==2)throw se("MALFORMED_BYTECODE_BODY_KIND",o,`has body kind ${r}, which is not one this VM knows`,"0 (inline body), 1 (builtin function) or 2 (user-defined function)",`${r}`,{kind:r,ref:a})}function rn(r,a){try{return BigInt(r)}catch{throw se("MALFORMED_BYTECODE_BIGINT_LITERAL",a,`cannot read "${r}" as a whole number`,"a string holding an integer, with no decimal point or separators",`"${r}"`,{literal:r})}}function on(r){if(r===null||typeof r!="object")return `expected a bytecode program, got ${r===null?"null":typeof r}`;let a=r;return typeof a.opcodes?.length!="number"?"the program has no `opcodes` array":typeof a.numbers?.length!="number"?"the program has no `numbers` pool":typeof a.strings?.length!="number"?"the program has no `strings` pool":null}var Lt=64;function ze(r,a,o,u,m,b,h,d){let y=new Map;for(let A=0;A<r.length;A++)y.set(r[A],o[A]);u.pushCallFrame(y);let x;try{x=Ze(a,u,m,b,h,d);}finally{u.popCallFrame();}if(x.type==="pending")throw c$1.execution("MAP_REDUCE_ASYNC_UNSUPPORTED","map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported");if(x.type==="error")throw x.error;return x.value}function sn(r,a,o,u,m,b,h){let d=new Map(o.getCallFrame());d.set(r,K(q$1(r))),o.pushCallFrame(d);let y;try{y=Ze(a,o,u,m,b,h);}finally{o.popCallFrame();}if(y.type==="pending")throw c$1.execution("SYMBOLIC_ASYNC_UNSUPPORTED","an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)");if(y.type==="error")throw y.error;return y.value}function $t(r,a){if(r.type!==6||a.type!==6)return null;let o=r.unit,u=a.unit;if(o===void 0||u===void 0)return null;let m=o.indexOf("/"),b=u.indexOf("/");if(m<0||b<0||o.slice(0,m)!==u.slice(0,b))return null;let h=a$3[o.slice(m+1).toLowerCase()],d=a$3[u.slice(b+1).toLowerCase()];return h===void 0||d===void 0||h[0]!==d[0]?null:r.toNumber()*(d[1]/h[1])}function Pt(r,a){if(r.type!==6||a.type!==6)return null;let o=r.unit,u$1=a.unit;if(o===void 0||u$1===void 0||o.includes("/")||u$1.includes("/"))return null;let m=ua[o.toUpperCase()]!==void 0,b=ua[u$1.toUpperCase()]!==void 0;return m===b?null:u(r.toNumber()*a.toNumber(),m?o:u$1)}function Yt(r,a,o){if(r.type===5)return a.type===6&&a.unit!==void 0?c$6(a,a.unit,r.toNumber(),o):a.type!==5&&a.type!==0?null:N(r.toNumber()+o*a.toNumber());if(a.type!==5)return null;let u=1+o*a.toNumber();if(r.type===0){let m=r.toNumber()*u;return r.uncertainty!==void 0?q$2(m,Math.abs(r.uncertainty*u)):n(m)}return r.type===6&&r.unit!==void 0?c$6(r,r.unit,a.toNumber(),o):null}function un(r,a){let o=r.type===5?r:a.type===5?a:null;if(o===null)return null;let u=o===r?a:r;if(u.type!==0||u.uncertainty===void 0)return null;let m=o.toNumber();return q$2(u.toNumber()*m,Math.abs(u.uncertainty*m))}function ln(r,a){let o=r.type===6?r:a,u=r.type===6?a:r;return o.type!==6||o.unit===void 0||!c$5.isCurrency(o.unit)||u.type!==0&&u.type!==5||u.rational!==void 0?null:b$2(o,u.toNumber(),o.unit)}function cn(r,a){if(a.type===5&&r.type===0&&r.uncertainty!==void 0){let o=a.toNumber();return o===0?null:q$2(r.toNumber()/o,Math.abs(r.uncertainty/o))}if(r.type===5&&a.type===0&&a.uncertainty!==void 0){let o=a.toNumber();return o===0?null:q$2(r.toNumber()/o,Math.abs(r.toNumber()*a.uncertainty/(o*o)))}return null}function mn(r){if(r.type===6){let a=r.unit;if(a&&c$4(a)==="time")try{return e$1(r.toNumber(),a,"ms")}catch{}return 0}return r.toNumber()}var Xt=260;function zt(r,a,o){let u=Math.trunc(Math.abs(a)),b=(a>=0?1:-1)>0?o.getMaxDateOffsetYears():-o.getMinDateOffsetYears(),h=Math.floor(b*Xt);if(u>h)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/Xt).toLocaleString("en-US")} years, past the limit of ${b} years for a workday offset`,{requestedWorkdays:u,limitYears:b,limitWorkdays:h});let d=h*7+7,y=Rt(r,a,x=>o.isHoliday(x),d);if(y===null)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A working-day offset of ${u.toLocaleString("en-US")} could not be reached within the ${b}-year limit; the configured holiday calendar leaves too few working days`,{requestedWorkdays:u,limitYears:b,maxCalendarSteps:d});return y}var Gt=864e5,pn={month:1,months:1,mo:1,year:12,years:12,yr:12,y:12,a:12,decade:120,decades:120,dec:120,century:1200,centuries:1200,millennium:12e3,millennia:12e3};function fn(r,a){return new Date(r,a+1,0).getDate()}function Qt(r,a){let o=Math.trunc(a),u=new Date(r);u.setDate(u.getDate()+o);let m=u.getTime();return Number.isNaN(m)?r+a*Gt:m+(a-o)*Gt}function dn(r,a){let o=Math.trunc(a),u=new Date(r),m=u.getDate();u.setDate(1),u.setMonth(u.getMonth()+o),u.setDate(Math.min(m,fn(u.getFullYear(),u.getMonth())));let b=u.getTime(),h=e$1(1,"month","ms");return Number.isNaN(b)?r+a*h:b+(a-o)*h}function he(r,a,o,u){if(a.type===6&&a.unit!==void 0){let m=a.unit,b=o*a.toNumber();if(a$2(m))return zt(r,b,u);let h=pn[m];if(h!==void 0)return dn(r,b*h);if(c$4(m)==="time"){let d=0;try{d=e$1(1,m,"day");}catch{}if(Number.isInteger(d)&&d>=1)return Qt(r,b*d)}}return r+o*mn(a)}function Wt(r,a,o){let u$1=B(r.unit);if(a.type===6&&A(a.unit)){let m=B(a.unit);return m!==u$1?P("TIMECODE_FPS_MISMATCH",`Cannot combine timecodes at different frame rates (${u$1} fps vs ${m} fps)`):o===1?u(r.toNumber()+a.toNumber(),r.unit):u(r.toNumber()-a.toNumber(),"frames")}if(a.type===6&&a.unit==="frames")return u(r.toNumber()+o*a.toNumber(),r.unit);if(a.type===6&&a.unit&&c$4(a.unit)==="time"){let m=e$1(a.toNumber(),a.unit,"s");return u(r.toNumber()+o*m*u$1,r.unit)}return u(r.toNumber()+o*a.toNumber(),r.unit)}function ge(r){return r.type===10?r.value:r.toNumber()!==0}function Kt(r,a){let o=l(r,a);return P("INCOMPATIBLE_UNITS",o??`Cannot convert ${r} to ${a}: they do not measure the same thing`)}var Te=65536;function bn(r,a){if(!Number.isInteger(a)||a<0)return null;if(a===0)return 1;let o=Math.abs(r.toNumber());return o<=1?1:(o<=2?1:Math.log2(o))*a}function hn(r,a){let o=1n,u=r,m=a;for(;m>0n;)m%2n===1n&&(o*=u),m/=2n,m>0n&&(u*=u);return o}var Qe=Te;function Ht(r){let a=r<0n?-r:r;if(a===0n)return 0;let o=Number(a);return Number.isFinite(o)?Math.floor(Math.log2(o))+1:a.toString(16).length*4}function qt(r,a,o){let u=n$1(r),m=n$1(a);if(u===0n)return s(0n);let b=o*Number(m);if(b<=0||Ht(u)+b<=Qe)return s(o===1?u<<m:u>>m);throw c$1.execution("BIGINT_SHIFT_LIMIT_EXCEEDED",`Shifting by ${m} would build an exact integer of about ${(Ht(u)+b).toLocaleString("en-US")} bits, past the limit of ${Qe.toLocaleString("en-US")} bits`,{shift:String(m),limitBits:Qe})}function Je(r,a){let{numerator:o,denominator:u$1}=y$1(r.unit),m=c$4(u$1),b=c$4(a.unit);if(!m||m!==b)return P("RATE_MUL_MEASURE_MISMATCH",`Cannot multiply a "${u$1}"-denominated rate by "${a.unit}" \u2014 different measures`);let h=e$1(a.toNumber(),a.unit,u$1),d=r.toNumber()*h;return o?u(d,o):n(d)}function gn(r){if(Number.isNaN(r))return "NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let a=r<0,o=Math.abs(r),u=Math.floor(o),m=o-u;if(m<1e-9)return `${a?"-":""}${u}`;let b=0,h=1,d=1,y=0,x=m,A=1e6;for(let I=0;I<30;I++){let L=Math.floor(x+1e-9),j=L*h+b,$=L*y+d;if($>A||(b=h,h=j,d=y,y=$,Math.abs(m-h/y)<1e-9))break;let n=x-L;if(n<1e-9)break;x=1/n;}let w=u*y+h;return `${a?"-":""}${w}/${y}`}function yn(r){return r.d===1n?String(r.n):`${r.n}/${r.d}`}function Nn(r){let a=r.toNumber(),o=r.type===5?1+a:a;return `${Math.round(o*1e6)/1e6}x`}function xn(r){if(!Number.isFinite(r))return String(r);if(r===0)return "0e+0";let[a,o]=r.toExponential().split("e");return `${a.includes(".")?a.replace(/0+$/,"").replace(/\.$/,""):a}e${o}`}function Ze(r$3,a$2,o$2,u$2,m$1,b$2){let h$2=on(r$3);if(h$2)return {type:"error",error:c$1.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${h$2}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:h$2,suggestion:jt})};let{opcodes:d$2,numbers:y,strings:x$1,userFunctionBodies:A$1,anonymousBodies:w$1}=r$3,I$1=0,L$1=0,j$3=a$2.getMaxInstructions(),$$1=a$2.getMaxStackDepth(),n$2=a$2.getStack(),Q$1=o$2?.hasCollectors??false,W=j();if(d$2.length===0)return {type:"value",value:n(0)};a(a$2);try{for(;I$1<d$2.length;){if(++L$1>j$3)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${j$3} instructions`);if(n$2.length>$$1)throw c$1.execution("STACK_LIMIT_EXCEEDED",`Execution exceeded maximum stack depth of ${$$1}`);let f$3=d$2[I$1++];if(Q$1){let e=n$2.map(t=>({type:t.type,value:t.value,unit:t.unit}));o$2.fireVmStep({type:c$2.VmStep,elapsedNs:0,expression:u$2??"",opcode:f$3,opcodeName:b(f$3),ip:I$1-1,stackDepth:n$2.length,instructionNumber:L$1,stack:e});}switch(f$3){case 0:break;case 1:{let e=c(n$2);return {type:"value",value:W?k(e):e}}case 3:{let e=c(n$2);n$2.push(e),n$2.push(e);break}case 2:{let e=c(n$2),t=c(n$2);n$2.push(e),n$2.push(t);break}case 10:n$2.push(n(y[je(d$2,I$1++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 11:n$2.push(s(rn(z(d$2,I$1++,x$1,f$3,"constant-pool index"),f$3)));break;case 16:{let e=ia(z(d$2,I$1++,x$1,f$3,"constant-pool index"));n$2.push(o(ra(e),e));break}case 12:n$2.push(r$1(y[je(d$2,I$1++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 13:n$2.push(t(z(d$2,I$1++,x$1,f$3,"constant-pool index")));break;case 14:n$2.push(L(U(d$2,I$1++,f$3,"boolean operand")===1));break;case 20:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"add");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"add");if(p){n$2.push(p);break}}let i=Yt(t,e,1),l=i===null?$t(t,e):null;i!==null?n$2.push(i):l!==null?n$2.push(u(l+e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value+e.value)):t.type===10&&e.type===10?n$2.push(L(t.value&&e.value)):t.type===4?e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot add two datetimes together")):n$2.push(M(he(t.toNumber(),e,1,a$2))):t.type===6&&A(t.unit)?n$2.push(Wt(t,e,1)):e.type===4?n$2.push(M(he(e.toNumber(),t,1,a$2))):n$2.push(u$1(t,e,(p,g)=>p+g,(p,g)=>p+g,"add"));break}case 21:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"sub");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"sub");if(p){n$2.push(p);break}}let i=Yt(t,e,-1),l=i===null?$t(t,e):null;i!==null?n$2.push(i):l!==null?n$2.push(u(l-e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value-e.value)):t.type===4?e.type===4?n$2.push(u(t.toNumber()-e.toNumber(),"ms")):n$2.push(M(he(t.toNumber(),e,-1,a$2))):t.type===6&&A(t.unit)?n$2.push(Wt(t,e,-1)):e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot subtract a datetime from a value that is not a datetime")):n$2.push(u$1(t,e,(p,g)=>p-g,(p,g)=>p-g,"sub"));break}case 22:{let e=c(n$2),t=c(n$2),s=un(t,e);if(s){n$2.push(s);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let l=s$1(t,e,"mul");if(l){n$2.push(l);break}}if(t.rational!==void 0||e.rational!==void 0){let l=r$2(t,e,"mul");if(l){n$2.push(l);break}}let i=ln(t,e);if(i){n$2.push(i);break}t.type===0&&e.type===0?n$2.push(n(t.value*e.value)):t.type===7&&e.type===7?(d(tn(t.value,e.value),"matrix cells"),n$2.push(_(t.value,e.value))):t.type===6&&x(t.unit)&&e.type===6&&e.unit?n$2.push(Je(t,e)):e.type===6&&x(e.unit)&&t.type===6&&t.unit?n$2.push(Je(e,t)):Pt(t,e)!==null?n$2.push(Pt(t,e)):n$2.push(u$1(t,e,(l,p)=>l*p,(l,p)=>l*p,"mul"));break}case 23:{let e=c(n$2),t=c(n$2),s=cn(t,e);if(s){n$2.push(s);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let i=s$1(t,e,"div");if(i){n$2.push(i);break}}if(t.type===6&&e.type===6){let{lv:i,rv:l,sameMeasure:p}=j$2(t,e);p?n$2.push(n(i/l)):c$5.isCurrency(t.unit)&&c$5.isCurrency(e.unit)?n$2.push(P("INCOMPATIBLE_UNITS",`Cannot combine incompatible units: ${t.unit} and ${e.unit}`)):n$2.push(w(i/l,t.unit,e.unit));}else {let i=r$2(t,e,"div");if(i){n$2.push(i);break}n$2.push(u$1(t,e,(l,p)=>l/p,(l,p)=>{if(p===0n)throw o$1();return l/p},"div"));}break}case 24:{let e=c(n$2),t=c(n$2);n$2.push(u$1(t,e,(s,i)=>s%i,(s,i)=>{if(i===0n)throw o$1();return s%i}));break}case 25:{let e=c(n$2),t=c(n$2);if(t.type===13){n$2.push(t);break}if(e.type===13){n$2.push(e);break}if(t.type===12){n$2.push(t);break}if(e.type===12){n$2.push(e);break}if(t.type===0&&e.type===0){n$2.push(n(q$3(t.value,e.value)));break}if(t.type===7||e.type===7){if(t.type!==7||e.type!==0){n$2.push(P("MATRIX_POWER_UNSUPPORTED",`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${g[t.type]} ^ ${g[e.type]}" has no matrix reading.`));break}d(nn(t.value,e.value),"matrix cells"),n$2.push($(t.value,e.value));break}if(t.type===9||e.type===9){n$2.push(f$2(t,e));break}if(t.type===2||e.type===2){let s$1=bn(t,e.toNumber());if(s$1!==null){if(s$1>Te)throw c$1.execution("BIGINT_POW_LIMIT_EXCEEDED",`That power would build an exact integer of about ${Math.round(s$1).toLocaleString("en-US")} bits, past the limit of ${Te.toLocaleString("en-US")} bits`,{limitBits:Te});n$2.push(s(hn(n$1(t),n$1(e))));break}}n$2.push(n(q$3(t.toNumber(),e.toNumber())));break}case 26:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(-e.value)):e.type===6&&e.exact!==void 0?n$2.push(v(-e.toNumber(),e.unit,ma(e.exact))):e.type===6?n$2.push(u(-e.toNumber(),e.unit)):e.type===5?n$2.push(N(-e.toNumber())):e.type===9?n$2.push(g$1(e)):e.type===0&&e.rational!==void 0?n$2.push(p$1(-e.toNumber(),j$1(e.rational))):e.type===0&&e.exact!==void 0?n$2.push(o(-e.toNumber(),ma(e.exact))):n$2.push(n(-e.toNumber()));break}case 27:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===6&&e.exact!==void 0?n$2.push(v(e.toNumber(),e.unit,e.exact)):e.type===6?n$2.push(u(e.toNumber(),e.unit)):e.type===5?n$2.push(N(e.toNumber())):e.type===0&&e.rational!==void 0?n$2.push(p$1(e.toNumber(),e.rational)):e.type===0&&e.exact!==void 0?n$2.push(o(e.toNumber(),e.exact)):n$2.push(n(e.toNumber()));break}case 28:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(q$2(t.toNumber(),Math.abs(e.toNumber())));break}case 30:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}t.type===2||e.type===2?n$2.push(qt(t,e,1)):n$2.push(n(t.toNumber()<<e.toNumber()));break}case 31:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}t.type===2||e.type===2?n$2.push(qt(t,e,-1)):n$2.push(n(t.toNumber()>>e.toNumber()));break}case 32:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(n(t.toNumber()>>>e.toNumber()));break}case 33:{let e=c(n$2),t=c(n$2),s$1=Q(t,e);if(s$1){n$2.push(s$1);break}t.type===2||e.type===2?n$2.push(s(n$1(t)&n$1(e))):n$2.push(n(t.toNumber()&e.toNumber()));break}case 34:{let e=c(n$2),t=c(n$2),s$1=Q(t,e);if(s$1){n$2.push(s$1);break}t.type===2||e.type===2?n$2.push(s(n$1(t)|n$1(e))):n$2.push(n(t.toNumber()|e.toNumber()));break}case 35:{let e=c(n$2),t=c(n$2),s$1=Q(t,e);if(s$1){n$2.push(s$1);break}t.type===2||e.type===2?n$2.push(s(n$1(t)^n$1(e))):n$2.push(n(t.toNumber()^e.toNumber()));break}case 36:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(~e.value)):n$2.push(n(~e.toNumber()));break}case 40:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i===0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value===e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()===e.toNumber():i===0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value===e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:l}=k$1(t,e);n$2.push(L(l&&i));}else if(t.type===7&&e.type===7)n$2.push(aa(t.value,e.value,(i,l)=>i===l));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,l=e.value;n$2.push(L(i.r===l.r&&i.g===l.g&&i.b===l.b&&i.a===l.a));}else n$2.push(L(!1));else n$2.push(L(t.toNumber()===e.toNumber()));break}case 41:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i!==0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value!==e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()!==e.toNumber():i!==0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value!==e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:l}=k$1(t,e);n$2.push(L(!l||!i));}else if(t.type===7&&e.type===7)n$2.push(aa(t.value,e.value,(i,l)=>i!==l));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,l=e.value;n$2.push(L(!(i.r===l.r&&i.g===l.g&&i.b===l.b&&i.a===l.a)));}else n$2.push(L(!0));else n$2.push(L(t.toNumber()!==e.toNumber()));break}case 42:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<e.toNumber():i<0));}else if(t.type===6&&e.type===6){let{lv:i,rv:l,equal:p,sameMeasure:g}=k$1(t,e);n$2.push(g?L(!p&&i<l):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa(t.value,e.value,(i,l)=>i<l)):n$2.push(L(t.toNumber()<e.toNumber()));break}case 43:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<=e.toNumber():i<=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:l,equal:p,sameMeasure:g}=k$1(t,e);n$2.push(g?L(p||i<=l):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa(t.value,e.value,(i,l)=>i<=l)):n$2.push(L(t.toNumber()<=e.toNumber()));break}case 44:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>e.toNumber():i>0));}else if(t.type===6&&e.type===6){let{lv:i,rv:l,equal:p,sameMeasure:g}=k$1(t,e);n$2.push(g?L(!p&&i>l):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa(t.value,e.value,(i,l)=>i>l)):n$2.push(L(t.toNumber()>e.toNumber()));break}case 45:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>=e.toNumber():i>=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:l,equal:p,sameMeasure:g}=k$1(t,e);n$2.push(g?L(p||i>=l):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa(t.value,e.value,(i,l)=>i>=l)):n$2.push(L(t.toNumber()>=e.toNumber()));break}case 130:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(L(ge(t)&&ge(e)));break}case 131:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(L(ge(t)||ge(e)));break}case 132:{let e=c(n$2),t=c(n$2),s=c(n$2),i=Q(s);if(i){n$2.push(i);break}n$2.push(ge(s)?t:e);break}case 50:{let e=U(d$2,I$1++,f$3,"plugin-function index"),t=U(d$2,I$1++,f$3,"argument count"),s=[];for(let p=0;p<t;p++)s.push(c(n$2));s.reverse();let i=a$2.context.pluginFunctions[e],l=R(s);if(l)n$2.push(l);else if(!i)n$2.push(n(0));else {let p=i(s,m$1);if(p instanceof Promise){let g=`plugin:${e}:${s.map(B=>String(B.value??"")).join("|")}`,E=a$2.activeSignal,C=a$2.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:g,resolver:p,packageId:C,signal:E}}n$2.push(p);}break}case 51:{let e=U(d$2,I$1++,f$3,"builtin-function index"),t=U(d$2,I$1++,f$3,"argument count"),s=Bt(e,t);if(s)throw s;let i=[],l=!1;for(let E=0;E<t;E++){let C=c(n$2);C.type===9&&(l=!0),i.push(C);}let p=R(i);if(p){n$2.push(p);break}let g=C[e];if(g){let E=i.reverse(),C=l&&!e$2.has(e);n$2.push(C?h$1(e,E):g(E));}break}case 150:{let e=U(d$2,I$1++,f$3,"function-body index"),t=A$1?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_FUNCTION_BODY",`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${e}`,{bodyIdx:e});a$2.defineUserFunction(t.name,t.params,t.program);break}case 151:{let e=z(d$2,I$1++,x$1,f$3,"function-name index"),t=U(d$2,I$1++,f$3,"argument count"),s=[];for(let g=0;g<t;g++)s.push(c(n$2));s.reverse();let i=a$2.getUserFunction(e);if(!i)throw c$1.execution("UNDEFINED_FUNCTION",`Undefined function: ${e}`,{name:e});if(t!==i.params.length)throw c$1.execution("FUNCTION_ARITY_MISMATCH",`${e} expects ${i.params.length} argument(s) but got ${t}`,{name:e,expected:i.params.length,actual:t});let l=new Map;for(let g=0;g<i.params.length;g++)l.set(i.params[g],s[g]);f$1(),a$2.pushCallFrame(l);let p;try{p=Ze(i.program,a$2,o$2,u$2,m$1);}finally{a$2.popCallFrame();}if(p.type==="pending")throw c$1.execution("USER_FUNCTION_ASYNC_UNSUPPORTED",`${e}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,{name:e});if(p.type==="error")throw p.error;n$2.push(p.value);break}case 60:{let e=z(d$2,I$1++,x$1,f$3,"variable-name index"),t=a$2.getVar(e);if(t!==void 0)n$2.push(t);else if(b$2)n$2.push(K(q$1(e)));else throw c$1.execution("UNDEFINED_VARIABLE",`Undefined variable: ${e}`,{varName:e});break}case 61:{let e=c(n$2),t=z(d$2,I$1++,x$1,f$3,"variable-name index");a$2.setVar(t,W?k(e):e),n$2.push(e);break}case 62:{let e=z(d$2,I$1++,x$1,f$3,"variable-name index"),t=J.get(e);if(t===void 0)throw c$1.internal({code:"GLOBAL_VARIABLE_NOT_RESOLVED",message:`Global variable "${e}" was read before it resolved`,expected:`global variable "${e}" to already be resolved (async preflight should guarantee this)`,found:"no value in the global variable store",context:{varName:e}});n$2.push(t);break}case 63:{let e=c(n$2),t=z(d$2,I$1++,x$1,f$3,"variable-name index");J.set(t,W?k(e):e),n$2.push(e);break}case 70:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 71:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}if(e.type===14){let s=e.value;n$2.push(G$1({r:s.r,g:s.g,b:s.b,a:s.a,format:"hex"}));break}n$2.push(r$1(e.type===2?e.value:e.toNumber()));break}case 74:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(N(e.toNumber()));break}case 140:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(e.rational!==void 0?yn(e.rational):gn(e.toNumber())));break}case 141:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(Nn(e)));break}case 142:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(xn(e.toNumber())));break}case 143:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"bin"));break}case 144:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"oct"));break}case 145:{let e=q(c(n$2),f$3,"converter name").toLowerCase(),t=c(n$2),s=Q(t);if(s){n$2.push(s);break}let i=G.get(e);i?n$2.push(i(t)):n$2.push(P("UNKNOWN_AS_CONVERTER",`Unknown converter "as ${e}"`));break}case 80:{let e=q(c(n$2),f$3,"unit name"),t=c(n$2),s=Q(t);if(s){n$2.push(s);break}let i=a$1(t,e);i?n$2.push(v(t.toNumber(),e,i)):n$2.push(u(t.toNumber(),e));break}case 81:{let e=q(c(n$2),f$3,"target unit name"),t=q(c(n$2),f$3,"source unit name"),s=c(n$2),i$1=Q(s);if(i$1){n$2.push(i$1);break}let l=s.toNumber(),p=c$4(t),g=c$5.isCurrency(t)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(l,t,e),e));else if(g){let E=c$5.convertSync(l,t,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${t} to ${e}`));}else {let E=i(l,t,e);E!==null?n$2.push(u(E,e)):n$2.push(Kt(t,e));}break}case 85:{let e=q(c(n$2),f$3,"unit name"),t$1=f(e);n$2.push(t(t$1.length>0?t$1.join(", "):`No known units for "${e}"`));break}case 83:{let e=q(c(n$2),f$3,"unit name"),t=c(n$2),s=Q(t);if(s){n$2.push(s);break}let{value:i,unit:l}=h(t.toNumber(),e);n$2.push(u(i,l));break}case 84:{let e=q(c(n$2),f$3,"target unit name"),t=c(n$2),s=Q(t);if(s){n$2.push(s);break}if(t.type===6){let i$1=t.unit,l=t.toNumber(),p=c$4(i$1),g=c$5.isCurrency(i$1)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(l,i$1,e),e));else if(g){let E=c$5.convertSync(l,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${i$1} to ${e}`));}else {let E=i(l,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(Kt(i$1,e));}}else n$2.push(u(t.toNumber(),e));break}case 82:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 110:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MISSING_DENOMINATOR_UNIT",'Cannot build a rate: the right-hand side of "/" has no unit'));break}let i=t.type===6?t.unit??"":"";n$2.push(w(t.toNumber()/e.toNumber(),i,e.unit));break}case 111:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_MUL_LEFT_NOT_A_RATE",'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MUL_RIGHT_MISSING_UNIT","Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));break}n$2.push(Je(t,e));break}case 112:{let e=q(c(n$2),f$3,"denominator unit name"),t=c(n$2),s=Q(t);if(s){n$2.push(s);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_CONVERT_NOT_A_RATE","Cannot convert a non-rate value's denominator"));break}let{numerator:i,denominator:l}=y$1(t.unit),p=c$4(l),g=c$4(e);if(!p||p!==g){n$2.push(P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${l}"-denominated rate to "${e}" \u2014 different measures`));break}let E=e$1(1,e,l);n$2.push(w(t.toNumber()*E,i,e));break}case 120:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}let s=e.toNumber(),i=new Date,l=new Date(i.getFullYear(),i.getMonth(),i.getDate(),0,0,0,0);l.setMinutes(s),n$2.push(M(l.getTime()));break}case 90:n$2.push(M(Date.now()));break;case 95:n$2.push(M(y[je(d$2,I$1++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 91:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(M(he(t.toNumber(),e,1,a$2)));break}case 92:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}n$2.push(M(he(t.toNumber(),e,-1,a$2)));break}case 96:{let e=U(d$2,I$1++,f$3,"workday offset direction")===1?-1:1,t=c(n$2),s=c(n$2),i=Q(s,t);if(i){n$2.push(i);break}if(t.type!==4){n$2.push(P(r.WORKDAY_OFFSET_EXPECTED_DATE,`"working days after/before/from" expects a date to count from, got ${g[t.type]??"an unsupported value"}`));break}n$2.push(M(zt(t.toNumber(),e*s.toNumber(),a$2)));break}case 97:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.type!==4||e.type!==4){n$2.push(P(r.WORKDAYS_BETWEEN_EXPECTED_DATES,`"working days between" expects two dates, got ${g[t.type]??"an unsupported value"} and ${g[e.type]??"an unsupported value"}`));break}let i=Math.ceil((a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears())*366),l=Vt(t.toNumber(),e.toNumber(),p=>a$2.isHoliday(p),i);if(l===null){n$2.push(P(r.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,`The two dates are more than ${a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears()} years apart, past the working-day count's limit`));break}n$2.push(n(l));break}case 93:case 94:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}let i=e.toNumber(),l=t.toNumber(),p=new Date(l).getDay(),g=f$3===93?(i-p+7)%7:(p-i+7)%7;g===0&&(g=7),n$2.push(M(Qt(l,f$3===93?g:-g)));break}case 152:{let e$1=U(d$2,I$1++,f$3,"row count"),t=U(d$2,I$1++,f$3,"column count"),s=e$1*t,i=e(s,"matrix cells"),l=null;for(let p=s-1;p>=0;p--){let g=c(n$2);l===null&&(l=Q(g)),i[p]=g.type===10||g.type===9?g.value:g.toNumber();}if(l){n$2.push(l);break}n$2.push(C$1(e$1,t,Y(e$1,t,i)));break}case 153:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let i=t.value,l=Math.trunc(e.toNumber());if(l<0||l>=i.data.length){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Index ${l} is out of bounds for a ${i.rows}x${i.cols} matrix (valid range: 0-${i.data.length-1}).`));break}let p=S(i,l);n$2.push(X(p));break}case 154:{let e=c(n$2),t=c(n$2),s=c(n$2),i=Q(s,t,e);if(i){n$2.push(i);break}if(s.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let l=s.value,p=Math.trunc(t.toNumber()),g=Math.trunc(e.toNumber());if(!U$1(l,p,g)){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${p}, ${g}] is out of bounds for a ${l.rows}x${l.cols} matrix.`));break}let E=T(l,p,g);n$2.push(X(E));break}case 156:{let e=c(n$2),t=c(n$2),s=Q(t,e);if(s){n$2.push(s);break}if(t.type!==0||e.type!==0){n$2.push(P("INVALID_RANGE_BOUND",`A range's bounds must be plain numbers (e.g. "0:3").`));break}let i=t.value,l=e.value;if(!Number.isInteger(i)||!Number.isInteger(l)){n$2.push(P("NON_INTEGER_RANGE_BOUND",`A range's bounds must be whole numbers, got "${i}:${l}".`));break}if(i>l){n$2.push(P("DESCENDING_RANGE",`A range's min (${i}) cannot be greater than its max (${l}) \u2014 did you mean "${l}:${i}"?`));break}n$2.push(F(i,l));break}case 155:{let e$1=c(n$2),t=c(n$2),s=c(n$2),i=Q(s,t,e$1);if(i){n$2.push(i);break}if(s.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot slice a non-matrix value with "[...]".'));break}if(t.type!==8||e$1.type!==8){n$2.push(P("INVALID_MATRIX_SLICE_BOUND",'Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").'));break}let l=s.value,p=t.value,g=e$1.value;if(p.min<0||p.max>=l.rows||g.min<0||g.max>=l.cols){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${p.min}:${p.max}, ${g.min}:${g.max}] is out of bounds for a ${l.rows}x${l.cols} matrix.`));break}let E=p.max-p.min+1,C=g.max-g.min+1,B=e(E*C,"matrix cells");for(let V=0;V<E;V++)for(let D=0;D<C;D++)B[V+D*E]=T(l,p.min+V,g.min+D);n$2.push(C$1(E,C,B));break}case 157:{let e$1=U(d$2,I$1++,f$3,"body kind"),t=U(d$2,I$1++,f$3,"body reference"),s=U(d$2,I$1++,f$3,"collection count");Ft(e$1,t,f$3);let i=new Array(s);for(let k=s-1;k>=0;k--)i[k]=c(n$2);let l=[],p;if(e$1===0){let k=w$1?.[t];if(!k)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: MAP_INVOKE referenced missing anonymous body index ${t}`,{ref:t});l=k.params,p=k.program;}else if(e$1===2){let k=Se(x$1,t,f$3),v=a$2.getUserFunction(k);if(!v){n$2.push(P("UNDEFINED_FUNCTION",`map: undefined function "${k}"`));break}if(v.params.length!==s){n$2.push(P("FUNCTION_ARITY_MISMATCH",`map: "${k}" expects ${v.params.length} argument(s) but ${s} collection(s) were given`));break}l=v.params,p=v.program;}let g=-1,E=new Array(s),C$2;for(let k=0;k<s;k++){let v=ea(i[k],a$2.getMaxCollectionSize());if(!Array.isArray(v)){C$2=v;break}if(c$3(v.length,"collection elements"),g===-1)g=v.length;else if(v.length!==g){C$2=P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${g} and ${v.length}).`);break}E[k]=v;}if(C$2){n$2.push(C$2);break}let B=e(g,"matrix cells"),V;for(let k=0;k<g;k++){let v=new Array(s);for(let ye=0;ye<s;ye++)v[ye]=E[ye][k];let ae=e$1===1?C[t]?.(v)??P("UNKNOWN_BUILTIN_FUNCTION",`map: unknown builtin function index ${t}`):ze(l,p,v,a$2,o$2,u$2,m$1,!!b$2),et=Q(ae);if(et){V=et;break}B[k]=ae.type===10||ae.type===9?ae.value:ae.toNumber();}if(V){n$2.push(V);break}let D=i[0],R=D?.type===7?D.value:void 0;R&&R.rows*R.cols===g?n$2.push(C$1(R.rows,R.cols,B)):n$2.push(C$1(1,g,B));break}case 160:{let e=U(d$2,I$1++,f$3,"plot body reference"),t=U(d$2,I$1++,f$3,"plot expression"),s=Se(x$1,t,f$3),i=c(n$2).toNumber(),l=c(n$2).toNumber(),p=w$1?.[e];if(!p)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: PLOT_INVOKE referenced missing anonymous body index ${e}`,{ref:e});if(!Number.isFinite(l)||!Number.isFinite(i)){n$2.push(P("PLOT_INVALID_RANGE",`plot: the range bounds must be finite numbers (got ${l} to ${i})`));break}let g=[];for(let D=0;D<Lt;D++){let R=l+D/(Lt-1)*(i-l),k;try{k=ze(p.params,p.program,[n(R)],a$2,o$2,u$2,m$1,!!b$2).toNumber();}catch{continue}Number.isFinite(k)&&g.push([R,k]);}let E=g.map(D=>D[1]),C=E.length?Math.min(...E):0,B=E.length?Math.max(...E):0,V=D=>Number.isInteger(D)?String(D):String(Number(D.toFixed(2)));n$2.push(I({kind:"plot",points:g,label:`${s} over [${V(l)}, ${V(i)}]`,domain:[l,i],range:[C,B],expr:s}));break}case 158:{let e=U(d$2,I$1++,f$3,"body kind"),t=U(d$2,I$1++,f$3,"body reference"),s=U(d$2,I$1++,f$3,"initial-value flag");Ft(e,t,f$3);let i=s?c(n$2):void 0,l=c(n$2),p=[],g;if(e===0){let D=w$1?.[t];if(!D)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${t}`,{ref:t});p=D.params,g=D.program;}else if(e===2){let D=Se(x$1,t,f$3),R=a$2.getUserFunction(D);if(!R){n$2.push(P("UNDEFINED_FUNCTION",`reduce: undefined function "${D}"`));break}if(R.params.length!==2){n$2.push(P("FUNCTION_ARITY_MISMATCH",`reduce: "${D}" must take exactly 2 arguments (accumulator, element), got ${R.params.length}`));break}p=R.params,g=R.program;}let E=ea(l,a$2.getMaxCollectionSize());if(!Array.isArray(E)){n$2.push(E);break}c$3(E.length,"collection elements");let C$1,B;if(i!==void 0){let D=Q(i);if(D){n$2.push(D);break}C$1=i,B=0;}else {if(E.length===0){n$2.push(P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}C$1=E[0],B=1;}let V;for(let D=B;D<E.length;D++){let R=[C$1,E[D]],k=e===1?C[t]?.(R)??P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${t}`):ze(p,g,R,a$2,o$2,u$2,m$1,!!b$2),v=Q(k);if(v){V=v;break}C$1=k;}if(V){n$2.push(V);break}n$2.push(C$1);break}case 159:{let e=U(d$2,I$1++,f$3,"body reference"),t=w$1?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${e}`,{ref:e});n$2.push(sn(t.params[0],t.program,a$2,o$2,u$2,m$1,!!b$2));break}}}let K$1=c(n$2);return {type:"value",value:W?k(K$1):K$1}}catch(K){return {type:"error",error:d$1(K)}}finally{b$1();}}export{Ct as a,Ot as b,jn as c,Ze as d};//# sourceMappingURL=chunk-N4HJTHZR.js.map
2
- //# sourceMappingURL=chunk-N4HJTHZR.js.map