solve-engine 2.38.19 → 2.38.20
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.
- package/dist/{chunk-X2UPN2J3.js → chunk-3JSXJSMT.js} +2 -2
- package/dist/{chunk-X2UPN2J3.js.map → chunk-3JSXJSMT.js.map} +1 -1
- package/dist/{chunk-TVT3SOU5.cjs → chunk-6W3JFXPQ.cjs} +2 -2
- package/dist/{chunk-TVT3SOU5.cjs.map → chunk-6W3JFXPQ.cjs.map} +1 -1
- package/dist/{chunk-5QZQIZTS.cjs → chunk-7PUNL5CJ.cjs} +3 -3
- package/dist/{chunk-5QZQIZTS.cjs.map → chunk-7PUNL5CJ.cjs.map} +1 -1
- package/dist/{chunk-ZYITLCTW.js → chunk-BHHTXIUL.js} +2 -2
- package/dist/{chunk-ZYITLCTW.js.map → chunk-BHHTXIUL.js.map} +1 -1
- package/dist/{chunk-WR5HTFDE.cjs → chunk-EPLOL7WC.cjs} +2 -2
- package/dist/{chunk-WR5HTFDE.cjs.map → chunk-EPLOL7WC.cjs.map} +1 -1
- package/dist/{chunk-JUIHUG4M.cjs → chunk-EZ7R3ZHM.cjs} +3 -3
- package/dist/{chunk-JUIHUG4M.cjs.map → chunk-EZ7R3ZHM.cjs.map} +1 -1
- package/dist/{chunk-45J6ALYU.js → chunk-H4G3UXJV.js} +3 -3
- package/dist/{chunk-45J6ALYU.js.map → chunk-H4G3UXJV.js.map} +1 -1
- package/dist/{chunk-5MFUZDYK.cjs → chunk-HNXV35Q2.cjs} +2 -2
- package/dist/{chunk-5MFUZDYK.cjs.map → chunk-HNXV35Q2.cjs.map} +1 -1
- package/dist/{chunk-XPP5U527.cjs → chunk-I4PKEUMZ.cjs} +2 -2
- package/dist/{chunk-XPP5U527.cjs.map → chunk-I4PKEUMZ.cjs.map} +1 -1
- package/dist/{chunk-4I7XP3KF.js → chunk-JZQRUOO6.js} +2 -2
- package/dist/{chunk-4I7XP3KF.js.map → chunk-JZQRUOO6.js.map} +1 -1
- package/dist/{chunk-NN6Q5S4I.cjs → chunk-KZPA4DUF.cjs} +3 -3
- package/dist/{chunk-NN6Q5S4I.cjs.map → chunk-KZPA4DUF.cjs.map} +1 -1
- package/dist/{chunk-VSYQSSN6.js → chunk-MXMMDSX4.js} +3 -3
- package/dist/{chunk-VSYQSSN6.js.map → chunk-MXMMDSX4.js.map} +1 -1
- package/dist/{chunk-P3ODL6WX.js → chunk-RTEWTZ6I.js} +3 -3
- package/dist/{chunk-P3ODL6WX.js.map → chunk-RTEWTZ6I.js.map} +1 -1
- package/dist/{chunk-XDL542DB.js → chunk-SIUHB77U.js} +2 -2
- package/dist/{chunk-XDL542DB.js.map → chunk-SIUHB77U.js.map} +1 -1
- package/dist/{chunk-SSS3ZMKX.js → chunk-TFZNEEJR.js} +3 -3
- package/dist/{chunk-SSS3ZMKX.js.map → chunk-TFZNEEJR.js.map} +1 -1
- package/dist/{chunk-U45F6L2L.cjs → chunk-UOLCBH37.cjs} +4 -4
- package/dist/{chunk-U45F6L2L.cjs.map → chunk-UOLCBH37.cjs.map} +1 -1
- package/dist/{chunk-5N4XDULO.cjs → chunk-Z4MIX43O.cjs} +2 -2
- package/dist/chunk-Z4MIX43O.cjs.map +1 -0
- package/dist/{chunk-IHPYXJIY.js → chunk-ZSFOIBIH.js} +2 -2
- package/dist/chunk-ZSFOIBIH.js.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.worker.cjs +1 -1
- package/dist/engine.worker.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5N4XDULO.cjs.map +0 -1
- package/dist/chunk-IHPYXJIY.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {b,a as a$1}from'./chunk-HLZRNZEU.js';import {g,D}from'./chunk-5TCSFTZD.js';import {Z as Z$1,R,ua,sa}from'./chunk-
|
|
2
|
-
`)}function z(t,e,r){return `${r.display.resultPrefix}${t}:${e}`}function v(t,e,r){let o=r.percentageResult.decimalPlaces;return `= ${(t*100).toFixed(o)}${e.display.percentageSuffix}`}function tt(t,e){return `= ${t} ${e||""}`.trim()}function et(t){if(t.addr===void 0)return `/${t.prefix}`;let e=D(t.addr);return t.prefix===void 0?e:`${e}/${t.prefix}`}function nt(t,e,r){let o=e.display.resultPrefix,n=m$1=>{let u=t.unit!==void 0?new m(6,m$1.value,t.unit):new m(0,m$1.value);u.exact=m$1.exact;let d=rt(u,r);return d.startsWith(o)?d.slice(o.length):d},[s,a]=t.shares,i=`${n(s)} each`;if(a===void 0)return `${o}${i}`;let c=a.count===1?"share":"shares";return `${o}${i}, with ${a.count} ${c} paying ${n(a)}`}function rt(t,e){let r=e||F,o=r.numberResult.decimalSeparatorLocale||"en",n=a(o);switch(t.type){case 0:return t.uncertainty!==void 0?k(t.value,t.uncertainty,n,r):A(t.value,n,r,t.decimalPlaces);case 1:return j(t.value,r,t.unit);case 2:return G(t.value);case 3:return Z(t.value);case 10:return V(t.value);case 4:return W(t.value,n,r,t.zone);case 6:return J(t.value,t.unit,n,r,t.exact,t.datetimeSpan,t.decimalPlaces);case 7:return Q(t.value,n,r);case 8:{let s=t.value;return z(s.min,s.max,n)}case 14:return `${n.display.resultPrefix}${g(t.value)}`;case 15:return nt(t.value,n,r);case 16:return `${n.display.resultPrefix}${t.value.label}`;case 17:return `${n.display.resultPrefix}${et(t.value)}`;case 9:return R(t.value);case 5:return v(t.value,n,r);case 11:return tt(t.value,t.unit);case 13:return t.unit??String(t.value);default:return `= ${String(t.value)}`}}export{F as a,yt as b,rt as c};//# sourceMappingURL=chunk-
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {b,a as a$1}from'./chunk-HLZRNZEU.js';import {g,D}from'./chunk-5TCSFTZD.js';import {Z as Z$1,R,ua,sa}from'./chunk-ZSFOIBIH.js';import {b as b$1}from'./chunk-EOO6M65F.js';import {g as g$1,o,p}from'./chunk-J4K72CQN.js';import {m}from'./chunk-A34R65WT.js';import {c}from'./chunk-BWTVJD5L.js';import {a}from'./chunk-LHLW7JLS.js';var F={floatResult:{decimalPlaces:2,enableSeperator:true},numberResult:{decimalSeparatorLocale:"en-US"},hexResult:{enablePadding:false,paddingZeros:0},unitOfMeasurementResult:{decimalPlaces:2},percentageResult:{decimalPlaces:2},dateResult:{format:"long"}};function A(t,e,r,o){let n=r.floatResult.enableSeperator,s=r.numberResult.decimalSeparatorLocale;if(o!==void 0&&Number.isFinite(t)){let m=t.toLocaleString(s||"en-US",{minimumFractionDigits:o,maximumFractionDigits:o,useGrouping:n});return `${e.display.resultPrefix}${m}`}let a=r.floatResult.decimalPlaces,c=a$1(t,a,s||"en-US")??b(t,a,n,s);return `${e.display.resultPrefix}${c}`}function k(t,e,r,o){let n=o.floatResult.decimalPlaces,s=o.floatResult.enableSeperator,a=o.numberResult.decimalSeparatorLocale||"en-US",i=Math.max(n,1),c=t.toLocaleString(a,{useGrouping:s,minimumFractionDigits:0,maximumFractionDigits:n}),m=Math.abs(e).toLocaleString(a,{useGrouping:s,minimumFractionDigits:1,maximumFractionDigits:i});return `${r.display.resultPrefix}${c} \xB1 ${m}`}function j(t,e,r){if(typeof t=="number"&&!Number.isFinite(t))return `= ${t}`;let o=typeof t=="bigint"?t<0n:t<0,n=o?"-":"",s=c=>typeof t=="bigint"?(o?-t:t).toString(c):Math.abs(Math.trunc(t)).toString(c);if(r==="bin")return `= ${n}0b${s(2)}`;if(r==="oct")return `= ${n}0o${s(8)}`;let a=e.hexResult.enablePadding?e.hexResult.paddingZeros:0,i=s(16).toUpperCase().padStart(a,"0");return `= ${n}0x${i}`}var B=2e4;function G(t){let e=t<0n?-t:t;if(Number.isFinite(Number(e)))return `= ${t}`;let r=e.toString(16).length*4;if(r*Math.LN2/Math.LN10<=B)return `= ${t}`;let o=r*Math.LN2/Math.LN10,n=Math.floor(o),s=Math.pow(10,o-n);return `= ${t<0n?"-":""}~${s.toFixed(3)}e+${n} (an exact integer of about ${(n+1).toLocaleString("en-US")} digits, too large to print)`}function Z(t){return `= ${t}`}function V(t){return `= ${t}`}function W(t,e,r,o$1){let n=r.calendar??b$1,s=r.dateResult?.format??"long",a=o$1!==void 0&&!g$1(o$1),i=a?n.fieldsInZone(o$1,t):n.fields(t),c=a?0:n.fields(t).millisecond,m=i.hour===0&&i.minute===0&&i.second===0&&c===0;if(s==="long"){let f=a?o(o$1,t,e.code):n.formatLongDate(t,e.code);if(m)return `= ${f}`;let $=a?p(o$1,t,e.code):n.formatTimeOfDay(t,e.code);return `= ${f}, ${$}`}let u=f=>String(f).padStart(2,"0"),d=i.year,p$1=u(i.month0+1),g=u(i.day),l;if(s==="iso"?l=`${d}-${p$1}-${g}`:s==="dmy"?l=`${g}/${p$1}/${d}`:l=`${p$1}/${g}/${d}`,m)return `= ${l}`;let b=`${u(i.hour)}:${u(i.minute)}:${u(i.second)}`;return s==="iso"?`= ${l}T${b}`:`= ${l} ${b}`}function Y(t){let e=t<0?"-":"",r=Math.round(Math.abs(t)/1e3),o=Math.floor(r/3600),n=Math.floor(r%3600/60),s=r%60,a=String(n).padStart(2,"0");if(s===0)return `${e}${o}:${a}`;let i=String(s).padStart(2,"0");return `${e}${o}:${a}:${i}`}var H={s:1,sec:1,secs:1,second:1,seconds:1,min:60,mins:60,minute:60,minutes:60,h:3600,hr:3600,hrs:3600,hour:3600,hours:3600},K=60;function X(t,e){let r=e.indexOf("/");if(r<=0)return;let o=H[e.slice(0,r).toLowerCase()];if(o===void 0)return;let n=e.slice(r+1);if(c(n)!=="length")return;let s=t*o;if(!Number.isFinite(s)||Math.abs(s)<K)return;let a=s<0?"-":"",i=Math.round(Math.abs(s)),c$1=Math.floor(i/3600),m=String(Math.floor(i%3600/60)).padStart(2,"0"),u=String(i%60).padStart(2,"0"),d=c$1===0?`${Math.floor(i/60)}:${u}`:`${c$1}:${m}:${u}`;return `${a}${d} /${n}`}var O=new Map;function q(t){let e=O.get(t);return e===void 0&&(e=new Intl.NumberFormat(t).formatToParts(1.1).find(r=>r.type==="decimal")?.value??".",O.set(t,e)),e}function S(t,e,r){let o=/^(-?)(\d+)(?:\.(\d+))?$/.exec(t);if(!o)return t;let[,n,s,a]=o,i=r?BigInt(s).toLocaleString(e,{useGrouping:true}):s;return a===void 0?`${n}${i}`:`${n}${i}${q(e)}${a}`}function J(t,e,r,o,n,s,a){if(e!==void 0&&a===void 0){let f=X(t,e);if(f!==void 0)return `= ${f}`}if(e==="ms"&&s)return `= ${Y(t)}`;e==="l100km"&&(e="l/100km"),e==="mps2"&&(e="m/s\xB2");let i=a??o.unitOfMeasurementResult.decimalPlaces,c=o.floatResult.enableSeperator,m=o.numberResult.decimalSeparatorLocale||"en-US",d=e&&["days","weeks","months","years","hours","minutes","seconds","day","week","month","year","hour","minute","second"].includes(e),p=a===void 0?a$1(t,i,m):void 0,g;p!==void 0?g=p:d&&t===Math.floor(t)?g=S(t.toString(),m,c):g=S(t.toFixed(i),m,c);let l=e?ua[e.toUpperCase()]:void 0;if(l){let f=n?S(sa(n,i),m,c):g,$=l.spaced?" ":"";return `= ${l.position==="prefix"?`${l.symbol}${$}${f}`:`${f}${$}${l.symbol}`}`}return `= ${n?S(sa(n,i),m,c):g} ${e||""}`.trim()}function _(t,e){if(typeof t=="boolean")return t?"true":"false";if(typeof t=="object"&&t!==null)return R(t);let r=e.floatResult.decimalPlaces,o=e.floatResult.enableSeperator,n=e.numberResult.decimalSeparatorLocale;return b(t,r,o,n)}function Q(t,e,r){let o=Z$1(t),n=[];for(let s=0;s<t.rows;s++){let a=[];for(let i=0;i<t.cols;i++)a.push(_(o[s*t.cols+i],r));n.push(a.join(", "));}return `${e.display.resultPrefix}[${n.join("; ")}]`}function yt(t,e){let r=e||F,o=Z$1(t),n=[];for(let a=0;a<t.rows;a++){let i=[];for(let c=0;c<t.cols;c++)i.push(_(o[a*t.cols+c],r));n.push(i);}let s=[];for(let a=0;a<t.cols;a++){let i=0;for(let c=0;c<t.rows;c++)i=Math.max(i,n[c][a].length);s.push(i);}return n.map(a=>`[ ${a.map((i,c)=>i.padStart(s[c])).join(" ")} ]`).join(`
|
|
2
|
+
`)}function z(t,e,r){return `${r.display.resultPrefix}${t}:${e}`}function v(t,e,r){let o=r.percentageResult.decimalPlaces;return `= ${(t*100).toFixed(o)}${e.display.percentageSuffix}`}function tt(t,e){return `= ${t} ${e||""}`.trim()}function et(t){if(t.addr===void 0)return `/${t.prefix}`;let e=D(t.addr);return t.prefix===void 0?e:`${e}/${t.prefix}`}function nt(t,e,r){let o=e.display.resultPrefix,n=m$1=>{let u=t.unit!==void 0?new m(6,m$1.value,t.unit):new m(0,m$1.value);u.exact=m$1.exact;let d=rt(u,r);return d.startsWith(o)?d.slice(o.length):d},[s,a]=t.shares,i=`${n(s)} each`;if(a===void 0)return `${o}${i}`;let c=a.count===1?"share":"shares";return `${o}${i}, with ${a.count} ${c} paying ${n(a)}`}function rt(t,e){let r=e||F,o=r.numberResult.decimalSeparatorLocale||"en",n=a(o);switch(t.type){case 0:return t.uncertainty!==void 0?k(t.value,t.uncertainty,n,r):A(t.value,n,r,t.decimalPlaces);case 1:return j(t.value,r,t.unit);case 2:return G(t.value);case 3:return Z(t.value);case 10:return V(t.value);case 4:return W(t.value,n,r,t.zone);case 6:return J(t.value,t.unit,n,r,t.exact,t.datetimeSpan,t.decimalPlaces);case 7:return Q(t.value,n,r);case 8:{let s=t.value;return z(s.min,s.max,n)}case 14:return `${n.display.resultPrefix}${g(t.value)}`;case 15:return nt(t.value,n,r);case 16:return `${n.display.resultPrefix}${t.value.label}`;case 17:return `${n.display.resultPrefix}${et(t.value)}`;case 9:return R(t.value);case 5:return v(t.value,n,r);case 11:return tt(t.value,t.unit);case 13:return t.unit??String(t.value);default:return `= ${String(t.value)}`}}export{F as a,yt as b,rt as c};//# sourceMappingURL=chunk-TFZNEEJR.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-TFZNEEJR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","tooSmallToPrintText","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","zone","calendar","DATE_CALENDAR","format","named","isFixedOffset","d","millisecond","isMidnight","dateStr","longDateInZone","timeStr","timeOfDayInZone","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","PACE_TIME_UNITS","PACE_CLOCK_FLOOR_SECONDS","formatPace","unit","slash","perSecond","distance","getMeasure","whole","clock","decimalMarkByLocale","decimalMark","mark","part","localiseFixedDecimal","fixed","match","integer","fraction","integerText","formatUom","exact","isDatetimeSpan","explicitPlaces","pace","isTimeSpan","tooSmall","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":"4UA2DO,IAAMA,EAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,EACf,eAAA,CAAiB,IACnB,C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AAA,EAAA,CAGE,OAAO,CAAA,EAAGzG,CAAAA,CAAO,QAAQ,YAAY,CAAA,EAAID,EAAM,KAAA,CAAoB,KAAK,CAAA,CAAA,CAC1E,KAAA,EAAA,CACE,OAAO,CAAA,EAAGC,EAAO,OAAA,CAAQ,YAAY,GAAGmH,EAAAA,CAAapH,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,OACE,OAAOgG,CAAAA,CAAehG,EAAM,KAAqB,CAAA,CACnD,OACE,OAAOkH,CAAAA,CAAiBlH,EAAM,KAAA,CAAiBC,CAAAA,CAAQyG,CAAE,CAAA,CAC3D,KAAA,EAAA,CACE,OAAOS,EAAAA,CAAWnH,CAAAA,CAAM,MAAiBA,CAAAA,CAAM,IAAI,EACrD,KAAA,EAAA,CAKE,OAAOA,EAAM,IAAA,EAAQ,MAAA,CAAOA,EAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,OAAOA,CAAAA,CAAM,KAAK,CAAC,CAAA,CACnC,CACF","file":"chunk-SSS3ZMKX.js","sourcesContent":["import type { CalendarBackend } from \"@solve-js/calendar/CalendarBackend\";\n/**\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 /**\n * The calendar backend a date is written out through: which local day and\n * wall-clock time an instant shows as. Pass the same backend the engine\n * was given as its `calendar` option, so a date displays in the zone it\n * was computed in. Absent means the built-in `Date` backend, the process's\n * own zone, which is what every engine computes with by default.\n *\n * A backend is an object of functions, so it cannot cross a `postMessage`\n * boundary: a worker runtime takes its backend from `WorkerRuntimeOptions`\n * and applies it to the formatting it receives.\n */\n calendar?: CalendarBackend;\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, tooSmallToPrintText } from \"@solve-js/utilities/Number\";\nimport { getMeasure } from \"@solve-js/uom/UomConverter\";\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\";\nimport { DATE_CALENDAR } from \"@solve-js/calendar/DateCalendar\";\nimport { isFixedOffset, longDateInZone, timeOfDayInZone } from \"@solve-js/calendar/IntlZone\";\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 // A value below the decimal budget is shown to three significant digits\n // rather than as a zero it cannot be told apart from. Only when the budget is\n // the default one: an explicit `to N dp` above asked for those places and is\n // given them, zeros included.\n const tooSmall = tooSmallToPrintText(value, dp, loc || \"en-US\");\n const formatted = tooSmall ?? 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 *\n * Reads the calendar backend on the settings, or the built-in `Date` one\n * when the settings name none: `formatValue` is a free function a host calls\n * with a value and settings, with no engine in hand, so the host passes the\n * backend its engine computes with (`FormattingSettings.calendar`) and a\n * date shows the day it was computed on, in that backend's zone.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings, zone?: string): string {\n const calendar = settings.calendar ?? DATE_CALENDAR;\n const format = settings.dateResult?.format ?? \"long\";\n\n // A date that names a zone is read in it. `3 April 2026 in Tokyo` is Tokyo's\n // 3 April, and rendering the instant behind it in the reader's own zone\n // showed them 2 April: the right moment, answering a question nobody asked.\n //\n // Only a named zone, deliberately. An ISO literal carrying `Z` or an offset\n // records the synthetic fixed-offset form, and how those display is a\n // separate question this does not answer: they keep reading in the zone the\n // engine computes in, as they always have.\n const named = zone !== undefined && !isFixedOffset(zone);\n const d = named ? calendar.fieldsInZone(zone, value) : calendar.fields(value);\n const millisecond = named ? 0 : calendar.fields(value).millisecond;\n const isMidnight = d.hour === 0 && d.minute === 0 && d.second === 0 && millisecond === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = named ? longDateInZone(zone, value, locale.code) : calendar.formatLongDate(value, locale.code);\n if (isMidnight) return `= ${dateStr}`;\n const timeStr = named ? timeOfDayInZone(zone, value, locale.code) : calendar.formatTimeOfDay(value, locale.code);\n return `= ${dateStr}, ${timeStr}`;\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.year;\n const month = p2(d.month0 + 1);\n const day = p2(d.day);\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.hour)}:${p2(d.minute)}:${p2(d.second)}`;\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\n/**\n * The time units a pace can be written in, and what one of each is in seconds.\n *\n * A short list rather than a measure lookup, because a pace is minutes and\n * seconds by convention and nobody writes a pace in weeks.\n */\nconst PACE_TIME_UNITS: Readonly<Record<string, number>> = {\n\ts: 1, sec: 1, secs: 1, second: 1, seconds: 1,\n\tmin: 60, mins: 60, minute: 60, minutes: 60,\n\th: 3600, hr: 3600, hrs: 3600, hour: 3600, hours: 3600,\n};\n\n/**\n * Below this many seconds per unit, a pace keeps its ordinary rendering.\n *\n * A clock shows whole seconds, and rounding to one is immaterial at a runner's\n * pace and a real loss below a minute: `0.90 seconds/m` would read `0:01 /m`,\n * which is a different number. A minute per unit is where the rounding stops\n * mattering.\n */\nconst PACE_CLOCK_FLOOR_SECONDS = 60;\n\n/**\n * A time over a distance, written the way a runner writes it.\n *\n * `4:30/km` is four and a half minutes to cover a kilometre, and `270.00\n * seconds/km` is the same number in a spelling nobody uses. So a quantity whose\n * unit is a time over a length is shown on a clock, matching what the `pace`\n * function has always printed.\n *\n * Returns undefined for everything else, which is every other unit the engine\n * carries: a speed (`90 km/h`) is a length over a time and reads as a number, a\n * rate of pay is money over a time, and a pace faster than a minute per unit\n * keeps its digits. Callers keep the rendering they had.\n */\nfunction formatPace(value: number, unit: string): string | undefined {\n\tconst slash = unit.indexOf(\"/\");\n\tif (slash <= 0) return undefined;\n\tconst perSecond = PACE_TIME_UNITS[unit.slice(0, slash).toLowerCase()];\n\tif (perSecond === undefined) return undefined;\n\tconst distance = unit.slice(slash + 1);\n\tif (getMeasure(distance) !== \"length\") return undefined;\n\n\tconst seconds = value * perSecond;\n\tif (!Number.isFinite(seconds) || Math.abs(seconds) < PACE_CLOCK_FLOOR_SECONDS) return undefined;\n\t// The same shape `formatMsDuration` writes, so a pace and a stretch of time\n\t// read alike, with the hours dropped when there are none.\n\tconst sign = seconds < 0 ? \"-\" : \"\";\n\tconst whole = Math.round(Math.abs(seconds));\n\tconst hours = Math.floor(whole / 3600);\n\tconst mm = String(Math.floor((whole % 3600) / 60)).padStart(2, \"0\");\n\tconst ss = String(whole % 60).padStart(2, \"0\");\n\tconst clock = hours === 0 ? `${Math.floor(whole / 60)}:${ss}` : `${hours}:${mm}:${ss}`;\n\treturn `${sign}${clock} /${distance}`;\n}\n\n/** The decimal mark each locale writes, looked up once per locale rather than on every value. */\nconst decimalMarkByLocale = new Map<string, string>();\n\nfunction decimalMark(loc: string): string {\n let mark = decimalMarkByLocale.get(loc);\n if (mark === undefined) {\n mark = new Intl.NumberFormat(loc).formatToParts(1.1).find((part) => part.type === \"decimal\")?.value ?? \".\";\n decimalMarkByLocale.set(loc, mark);\n }\n return mark;\n}\n\n/**\n * Write a fixed-decimal string (`\"1234567.50\"`) the way `loc` writes numbers:\n * its decimal mark, and its digit grouping when `useGrouping` is on.\n *\n * Every quantity and every money amount used to be rendered with a bare\n * `toFixed`, so a plain `52000` showed as `52,000` while `£52000` showed as\n * `£52000.00`, and the `enableSeperator` setting had no effect on the one\n * value type people most want grouped. The digits are taken from the string\n * rather than re-rendered from the double, because an exact money amount has\n * already been rounded from its decimal (see {@link formatUom}) and\n * re-rendering would undo that. `BigInt` carries the integer part through\n * `Intl` so grouping follows the locale's own rule (Indian lakhs included)\n * rather than a hand-written every-three-digits. Anything that is not plain\n * digits, an `Infinity` or an exponent form, is returned as it came.\n */\nfunction localiseFixedDecimal(fixed: string, loc: string, useGrouping: boolean): string {\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?$/.exec(fixed);\n if (!match) return fixed;\n const [, sign, integer, fraction] = match;\n const integerText = useGrouping ? BigInt(integer).toLocaleString(loc, { useGrouping: true }) : integer;\n if (fraction === undefined) return `${sign}${integerText}`;\n return `${sign}${integerText}${decimalMark(loc)}${fraction}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData, isDatetimeSpan?: boolean, explicitPlaces?: number): string {\n // A time over a distance is a pace, and a runner reads a pace on a clock.\n // Not when the line named its own place count, which asked for digits.\n if (unit !== undefined && explicitPlaces === undefined) {\n const pace = formatPace(value, unit);\n if (pace !== undefined) return `= ${pace}`;\n }\n // A clock only for the gap between two datetimes, which is marked as such.\n // A quantity in milliseconds is a quantity: `40ms + 120ms` is 190 ms, not\n // 0:00, and every neighbouring spelling already agreed (`40 milliseconds`).\n if (unit === \"ms\" && isDatetimeSpan) return `= ${formatMsDuration(value)}`;\n // A fuel-consumption unit is stored slash-free (so it is not read as a rate)\n // but shown the way it is written.\n if (unit === \"l100km\") unit = \"l/100km\";\n if (unit === \"mps2\") unit = \"m/s²\";\n\n // `1.23456 km to 4 dp` asked for four places and used to be given the\n // setting's two, because a quantity's own place count was never read here the\n // way a plain number's already was.\n const dp = explicitPlaces ?? settings.unitOfMeasurementResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\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 // A conversion can land far below the decimal budget, and `1 Hz in MHz`\n // printing `0.00 MHz` is indistinguishable from a real zero. Three\n // significant digits instead, in exponent form once the zeros stop being\n // countable. Not for an explicit `to N dp`, which asked for those places, and\n // not for money below: a currency zero is a real answer, and `$0.001` is\n // `$0.00` because a tenth of a penny is not a payable amount.\n const tooSmall = explicitPlaces === undefined ? tooSmallToPrintText(value, dp, loc) : undefined;\n\n let formatted: string;\n if (tooSmall !== undefined) {\n formatted = tooSmall;\n } else if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = localiseFixedDecimal(value.toString(), loc, useGrouping);\n } else {\n // For other values, use the configured decimal places\n formatted = localiseFixedDecimal(value.toFixed(dp), loc, useGrouping);\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 ? localiseFixedDecimal(decimalToFixed(exact, dp), loc, useGrouping) : 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 ? localiseFixedDecimal(decimalToFixed(exact, dp), loc, useGrouping) : 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, value.zone);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact, value.datetimeSpan, value.decimalPlaces);\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
|
+
{"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","tooSmallToPrintText","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","zone","calendar","DATE_CALENDAR","format","named","isFixedOffset","d","millisecond","isMidnight","dateStr","longDateInZone","timeStr","timeOfDayInZone","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","PACE_TIME_UNITS","PACE_CLOCK_FLOOR_SECONDS","formatPace","unit","slash","perSecond","distance","getMeasure","whole","clock","decimalMarkByLocale","decimalMark","mark","part","localiseFixedDecimal","fixed","match","integer","fraction","integerText","formatUom","exact","isDatetimeSpan","explicitPlaces","pace","isTimeSpan","tooSmall","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":"4UA2DO,IAAMA,EAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,EACf,eAAA,CAAiB,IACnB,CAAA,CACA,YAAA,CAAc,CACZ,sBAAA,CAAwB,OAC1B,CAAA,CACA,SAAA,CAAW,CACT,aAAA,CAAe,KAAA,CACf,YAAA,CAAc,CAChB,EACA,uBAAA,CAAyB,CACvB,aAAA,CAAe,CACjB,EACA,gBAAA,CAAkB,CAChB,aAAA,CAAe,CACjB,EACA,UAAA,CAAY,CACV,OAAQ,MACV,CACF,EClEA,SAASC,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,CAAiBC,EAA8BC,CAAAA,CAAgC,CAClH,IAAMC,CAAAA,CAAMF,EAAS,WAAA,CAAY,eAAA,CAC3BG,CAAAA,CAAMH,CAAAA,CAAS,aAAa,sBAAA,CAMlC,GAAIC,IAAkB,MAAA,EAAa,MAAA,CAAO,SAASH,CAAK,CAAA,CAAG,CACzD,IAAMM,EAAYN,CAAAA,CAAM,cAAA,CAAeK,CAAAA,EAAO,OAAA,CAAS,CACrD,qBAAA,CAAuBF,CAAAA,CACvB,qBAAA,CAAuBA,CAAAA,CACvB,YAAaC,CACf,CAAC,EACD,OAAO,CAAA,EAAGH,EAAO,OAAA,CAAQ,YAAY,CAAA,EAAGK,CAAS,EACnD,CACA,IAAMC,CAAAA,CAAKL,CAAAA,CAAS,YAAY,aAAA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a,CAAA,CACtH,KAAA,CAAA,CACE,OAAOiG,CAAAA,CAAajG,CAAAA,CAAM,KAAA,CAAqBC,CAAAA,CAAQyG,CAAE,CAAA,CAC3D,OAAsB,CACpB,IAAMJ,EAAItG,CAAAA,CAAM,KAAA,CAChB,OAAO+G,CAAAA,CAAYT,CAAAA,CAAE,IAAKA,CAAAA,CAAE,GAAA,CAAKrG,CAAM,CACzC,CACA,QACE,OAAO,CAAA,EAAGA,EAAO,OAAA,CAAQ,YAAY,GAAGoI,CAAAA,CAAarI,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,QACE,OAAOwH,EAAAA,CAAYxH,EAAM,KAAA,CAAoBC,CAAAA,CAAQyG,CAAE,CAAA,CACzD,KAAA,EAAA,CAGE,OAAO,CAAA,EAAGzG,CAAAA,CAAO,QAAQ,YAAY,CAAA,EAAID,EAAM,KAAA,CAAoB,KAAK,CAAA,CAAA,CAC1E,KAAA,EAAA,CACE,OAAO,CAAA,EAAGC,EAAO,OAAA,CAAQ,YAAY,GAAGmH,EAAAA,CAAapH,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,OACE,OAAOgG,CAAAA,CAAehG,EAAM,KAAqB,CAAA,CACnD,OACE,OAAOkH,CAAAA,CAAiBlH,EAAM,KAAA,CAAiBC,CAAAA,CAAQyG,CAAE,CAAA,CAC3D,KAAA,EAAA,CACE,OAAOS,EAAAA,CAAWnH,CAAAA,CAAM,MAAiBA,CAAAA,CAAM,IAAI,EACrD,KAAA,EAAA,CAKE,OAAOA,EAAM,IAAA,EAAQ,MAAA,CAAOA,EAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,OAAOA,CAAAA,CAAM,KAAK,CAAC,CAAA,CACnC,CACF","file":"chunk-TFZNEEJR.js","sourcesContent":["import type { CalendarBackend } from \"@solve-js/calendar/CalendarBackend\";\n/**\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 /**\n * The calendar backend a date is written out through: which local day and\n * wall-clock time an instant shows as. Pass the same backend the engine\n * was given as its `calendar` option, so a date displays in the zone it\n * was computed in. Absent means the built-in `Date` backend, the process's\n * own zone, which is what every engine computes with by default.\n *\n * A backend is an object of functions, so it cannot cross a `postMessage`\n * boundary: a worker runtime takes its backend from `WorkerRuntimeOptions`\n * and applies it to the formatting it receives.\n */\n calendar?: CalendarBackend;\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, tooSmallToPrintText } from \"@solve-js/utilities/Number\";\nimport { getMeasure } from \"@solve-js/uom/UomConverter\";\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\";\nimport { DATE_CALENDAR } from \"@solve-js/calendar/DateCalendar\";\nimport { isFixedOffset, longDateInZone, timeOfDayInZone } from \"@solve-js/calendar/IntlZone\";\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 // A value below the decimal budget is shown to three significant digits\n // rather than as a zero it cannot be told apart from. Only when the budget is\n // the default one: an explicit `to N dp` above asked for those places and is\n // given them, zeros included.\n const tooSmall = tooSmallToPrintText(value, dp, loc || \"en-US\");\n const formatted = tooSmall ?? 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 *\n * Reads the calendar backend on the settings, or the built-in `Date` one\n * when the settings name none: `formatValue` is a free function a host calls\n * with a value and settings, with no engine in hand, so the host passes the\n * backend its engine computes with (`FormattingSettings.calendar`) and a\n * date shows the day it was computed on, in that backend's zone.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings, zone?: string): string {\n const calendar = settings.calendar ?? DATE_CALENDAR;\n const format = settings.dateResult?.format ?? \"long\";\n\n // A date that names a zone is read in it. `3 April 2026 in Tokyo` is Tokyo's\n // 3 April, and rendering the instant behind it in the reader's own zone\n // showed them 2 April: the right moment, answering a question nobody asked.\n //\n // Only a named zone, deliberately. An ISO literal carrying `Z` or an offset\n // records the synthetic fixed-offset form, and how those display is a\n // separate question this does not answer: they keep reading in the zone the\n // engine computes in, as they always have.\n const named = zone !== undefined && !isFixedOffset(zone);\n const d = named ? calendar.fieldsInZone(zone, value) : calendar.fields(value);\n const millisecond = named ? 0 : calendar.fields(value).millisecond;\n const isMidnight = d.hour === 0 && d.minute === 0 && d.second === 0 && millisecond === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = named ? longDateInZone(zone, value, locale.code) : calendar.formatLongDate(value, locale.code);\n if (isMidnight) return `= ${dateStr}`;\n const timeStr = named ? timeOfDayInZone(zone, value, locale.code) : calendar.formatTimeOfDay(value, locale.code);\n return `= ${dateStr}, ${timeStr}`;\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.year;\n const month = p2(d.month0 + 1);\n const day = p2(d.day);\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.hour)}:${p2(d.minute)}:${p2(d.second)}`;\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\n/**\n * The time units a pace can be written in, and what one of each is in seconds.\n *\n * A short list rather than a measure lookup, because a pace is minutes and\n * seconds by convention and nobody writes a pace in weeks.\n */\nconst PACE_TIME_UNITS: Readonly<Record<string, number>> = {\n\ts: 1, sec: 1, secs: 1, second: 1, seconds: 1,\n\tmin: 60, mins: 60, minute: 60, minutes: 60,\n\th: 3600, hr: 3600, hrs: 3600, hour: 3600, hours: 3600,\n};\n\n/**\n * Below this many seconds per unit, a pace keeps its ordinary rendering.\n *\n * A clock shows whole seconds, and rounding to one is immaterial at a runner's\n * pace and a real loss below a minute: `0.90 seconds/m` would read `0:01 /m`,\n * which is a different number. A minute per unit is where the rounding stops\n * mattering.\n */\nconst PACE_CLOCK_FLOOR_SECONDS = 60;\n\n/**\n * A time over a distance, written the way a runner writes it.\n *\n * `4:30/km` is four and a half minutes to cover a kilometre, and `270.00\n * seconds/km` is the same number in a spelling nobody uses. So a quantity whose\n * unit is a time over a length is shown on a clock, matching what the `pace`\n * function has always printed.\n *\n * Returns undefined for everything else, which is every other unit the engine\n * carries: a speed (`90 km/h`) is a length over a time and reads as a number, a\n * rate of pay is money over a time, and a pace faster than a minute per unit\n * keeps its digits. Callers keep the rendering they had.\n */\nfunction formatPace(value: number, unit: string): string | undefined {\n\tconst slash = unit.indexOf(\"/\");\n\tif (slash <= 0) return undefined;\n\tconst perSecond = PACE_TIME_UNITS[unit.slice(0, slash).toLowerCase()];\n\tif (perSecond === undefined) return undefined;\n\tconst distance = unit.slice(slash + 1);\n\tif (getMeasure(distance) !== \"length\") return undefined;\n\n\tconst seconds = value * perSecond;\n\tif (!Number.isFinite(seconds) || Math.abs(seconds) < PACE_CLOCK_FLOOR_SECONDS) return undefined;\n\t// The same shape `formatMsDuration` writes, so a pace and a stretch of time\n\t// read alike, with the hours dropped when there are none.\n\tconst sign = seconds < 0 ? \"-\" : \"\";\n\tconst whole = Math.round(Math.abs(seconds));\n\tconst hours = Math.floor(whole / 3600);\n\tconst mm = String(Math.floor((whole % 3600) / 60)).padStart(2, \"0\");\n\tconst ss = String(whole % 60).padStart(2, \"0\");\n\tconst clock = hours === 0 ? `${Math.floor(whole / 60)}:${ss}` : `${hours}:${mm}:${ss}`;\n\treturn `${sign}${clock} /${distance}`;\n}\n\n/** The decimal mark each locale writes, looked up once per locale rather than on every value. */\nconst decimalMarkByLocale = new Map<string, string>();\n\nfunction decimalMark(loc: string): string {\n let mark = decimalMarkByLocale.get(loc);\n if (mark === undefined) {\n mark = new Intl.NumberFormat(loc).formatToParts(1.1).find((part) => part.type === \"decimal\")?.value ?? \".\";\n decimalMarkByLocale.set(loc, mark);\n }\n return mark;\n}\n\n/**\n * Write a fixed-decimal string (`\"1234567.50\"`) the way `loc` writes numbers:\n * its decimal mark, and its digit grouping when `useGrouping` is on.\n *\n * Every quantity and every money amount used to be rendered with a bare\n * `toFixed`, so a plain `52000` showed as `52,000` while `£52000` showed as\n * `£52000.00`, and the `enableSeperator` setting had no effect on the one\n * value type people most want grouped. The digits are taken from the string\n * rather than re-rendered from the double, because an exact money amount has\n * already been rounded from its decimal (see {@link formatUom}) and\n * re-rendering would undo that. `BigInt` carries the integer part through\n * `Intl` so grouping follows the locale's own rule (Indian lakhs included)\n * rather than a hand-written every-three-digits. Anything that is not plain\n * digits, an `Infinity` or an exponent form, is returned as it came.\n */\nfunction localiseFixedDecimal(fixed: string, loc: string, useGrouping: boolean): string {\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?$/.exec(fixed);\n if (!match) return fixed;\n const [, sign, integer, fraction] = match;\n const integerText = useGrouping ? BigInt(integer).toLocaleString(loc, { useGrouping: true }) : integer;\n if (fraction === undefined) return `${sign}${integerText}`;\n return `${sign}${integerText}${decimalMark(loc)}${fraction}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData, isDatetimeSpan?: boolean, explicitPlaces?: number): string {\n // A time over a distance is a pace, and a runner reads a pace on a clock.\n // Not when the line named its own place count, which asked for digits.\n if (unit !== undefined && explicitPlaces === undefined) {\n const pace = formatPace(value, unit);\n if (pace !== undefined) return `= ${pace}`;\n }\n // A clock only for the gap between two datetimes, which is marked as such.\n // A quantity in milliseconds is a quantity: `40ms + 120ms` is 190 ms, not\n // 0:00, and every neighbouring spelling already agreed (`40 milliseconds`).\n if (unit === \"ms\" && isDatetimeSpan) return `= ${formatMsDuration(value)}`;\n // A fuel-consumption unit is stored slash-free (so it is not read as a rate)\n // but shown the way it is written.\n if (unit === \"l100km\") unit = \"l/100km\";\n if (unit === \"mps2\") unit = \"m/s²\";\n\n // `1.23456 km to 4 dp` asked for four places and used to be given the\n // setting's two, because a quantity's own place count was never read here the\n // way a plain number's already was.\n const dp = explicitPlaces ?? settings.unitOfMeasurementResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\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 // A conversion can land far below the decimal budget, and `1 Hz in MHz`\n // printing `0.00 MHz` is indistinguishable from a real zero. Three\n // significant digits instead, in exponent form once the zeros stop being\n // countable. Not for an explicit `to N dp`, which asked for those places, and\n // not for money below: a currency zero is a real answer, and `$0.001` is\n // `$0.00` because a tenth of a penny is not a payable amount.\n const tooSmall = explicitPlaces === undefined ? tooSmallToPrintText(value, dp, loc) : undefined;\n\n let formatted: string;\n if (tooSmall !== undefined) {\n formatted = tooSmall;\n } else if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = localiseFixedDecimal(value.toString(), loc, useGrouping);\n } else {\n // For other values, use the configured decimal places\n formatted = localiseFixedDecimal(value.toFixed(dp), loc, useGrouping);\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 ? localiseFixedDecimal(decimalToFixed(exact, dp), loc, useGrouping) : 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 ? localiseFixedDecimal(decimalToFixed(exact, dp), loc, useGrouping) : 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, value.zone);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact, value.datetimeSpan, value.decimalPlaces);\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"]}
|