solve-engine 2.23.0 → 2.25.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.
- package/README.md +82 -32
- package/dist/{BytecodeBuilder-aqVa7Plx.d.cts → BytecodeBuilder-DSWKZi4f.d.cts} +11 -9
- package/dist/{BytecodeBuilder-aqVa7Plx.d.ts → BytecodeBuilder-DSWKZi4f.d.ts} +11 -9
- package/dist/{Configuration-BGQn-cJ8.d.cts → Configuration-DnzYPmoK.d.cts} +33 -0
- package/dist/{Configuration-BGQn-cJ8.d.ts → Configuration-DnzYPmoK.d.ts} +33 -0
- package/dist/{EngineError-DTk7I7hZ.d.cts → EngineError-fR1K1rvx.d.cts} +6 -0
- package/dist/{EngineError-DTk7I7hZ.d.ts → EngineError-fR1K1rvx.d.ts} +6 -0
- package/dist/{Lexer-CqagTewQ.d.ts → Lexer-Bmctxl0n.d.ts} +84 -35
- package/dist/{Lexer-CCHFDcgP.d.cts → Lexer-aB95pjoX.d.cts} +84 -35
- package/dist/{PackageCompatibility-BGXSFuL9.d.ts → PackageCompatibility-BludTs7v.d.ts} +1 -1
- package/dist/{PackageCompatibility-BZCqaTOO.d.cts → PackageCompatibility-CUVg8tmt.d.cts} +1 -1
- package/dist/{PackageRegistry-BRoVOYzg.d.ts → PackageRegistry-DT-x32OM.d.ts} +67 -14
- package/dist/{PackageRegistry-rMGnTh7W.d.cts → PackageRegistry-Dvn4i2QK.d.cts} +67 -14
- package/dist/{Parselet-Bkbp9CKD.d.cts → Parselet-BawfGuTF.d.cts} +8 -2
- package/dist/{Parselet-B-WyUtX4.d.ts → Parselet-DqTbbtWA.d.ts} +8 -2
- package/dist/{ScopeManager-gB9UengK.d.ts → ScopeManager-B636am7Y.d.ts} +39 -8
- package/dist/{ScopeManager-bCYewWVt.d.cts → ScopeManager-CdwX0VTw.d.cts} +39 -8
- package/dist/{TokenNormalizer-OTPS0Otq.d.ts → TokenNormalizer-CLBtiE8M.d.ts} +45 -26
- package/dist/{TokenNormalizer-MXaKLJ_m.d.cts → TokenNormalizer-CjTDmHgB.d.cts} +45 -26
- package/dist/{VMCheckpoints-DGar9Yg8.d.cts → VMCheckpoints-CYqeq8IV.d.cts} +3 -3
- package/dist/{VMCheckpoints-BDRY1Kx8.d.ts → VMCheckpoints-DDlxNssY.d.ts} +3 -3
- package/dist/{Value-DCTqTSeP.d.cts → Value-Ds3Gy07C.d.cts} +1 -1
- package/dist/{Value-DCTqTSeP.d.ts → Value-Ds3Gy07C.d.ts} +1 -1
- package/dist/{WorkerError-DGBNM3gA.d.cts → WorkerError-B1dF3VYT.d.cts} +1 -1
- package/dist/{WorkerError-DpZgKRks.d.ts → WorkerError-dneODN-u.d.ts} +1 -1
- package/dist/{chunk-YAONCEAW.cjs → chunk-4BAUQE6A.cjs} +3 -3
- package/dist/{chunk-YAONCEAW.cjs.map → chunk-4BAUQE6A.cjs.map} +1 -1
- package/dist/chunk-4BRTUFTH.js +2 -0
- package/dist/chunk-4BRTUFTH.js.map +1 -0
- package/dist/chunk-4NZXCHQL.cjs +2 -0
- package/dist/chunk-4NZXCHQL.cjs.map +1 -0
- package/dist/chunk-57PSJQQW.js +3 -0
- package/dist/chunk-57PSJQQW.js.map +1 -0
- package/dist/chunk-634ILVMP.cjs +2 -0
- package/dist/chunk-634ILVMP.cjs.map +1 -0
- package/dist/{chunk-HMC7FJO7.js → chunk-63ZOOUOL.js} +2 -2
- package/dist/{chunk-HMC7FJO7.js.map → chunk-63ZOOUOL.js.map} +1 -1
- package/dist/chunk-72PYPENZ.js +2 -0
- package/dist/chunk-72PYPENZ.js.map +1 -0
- package/dist/chunk-77KI7AKJ.cjs +2 -0
- package/dist/chunk-77KI7AKJ.cjs.map +1 -0
- package/dist/chunk-7DP57BA7.js +2 -0
- package/dist/chunk-7DP57BA7.js.map +1 -0
- package/dist/chunk-7N3IJSWF.js +5 -0
- package/dist/chunk-7N3IJSWF.js.map +1 -0
- package/dist/chunk-BMXYR5LI.cjs +2 -0
- package/dist/chunk-BMXYR5LI.cjs.map +1 -0
- package/dist/chunk-DUYTXLO2.js +2 -0
- package/dist/chunk-DUYTXLO2.js.map +1 -0
- package/dist/chunk-EL2XUOWX.js +2 -0
- package/dist/chunk-EL2XUOWX.js.map +1 -0
- package/dist/chunk-FYAMQFZZ.cjs +3 -0
- package/dist/chunk-FYAMQFZZ.cjs.map +1 -0
- package/dist/chunk-FYTB7SDP.cjs +2 -0
- package/dist/chunk-FYTB7SDP.cjs.map +1 -0
- package/dist/chunk-GBCN7FNV.cjs +2 -0
- package/dist/chunk-GBCN7FNV.cjs.map +1 -0
- package/dist/{chunk-7E7NXKQ5.js → chunk-IJHL3LMH.js} +2 -2
- package/dist/chunk-IJHL3LMH.js.map +1 -0
- package/dist/{chunk-4ETS224G.js → chunk-JFZ5SLF7.js} +2 -2
- package/dist/{chunk-4ETS224G.js.map → chunk-JFZ5SLF7.js.map} +1 -1
- package/dist/chunk-JSM3O7EM.cjs +2 -0
- package/dist/chunk-JSM3O7EM.cjs.map +1 -0
- package/dist/chunk-MZMA32NE.js +3 -0
- package/dist/chunk-MZMA32NE.js.map +1 -0
- package/dist/chunk-N4SSR7Q6.js +2 -0
- package/dist/chunk-N4SSR7Q6.js.map +1 -0
- package/dist/{chunk-TL545PXW.cjs → chunk-NEGZZB7F.cjs} +2 -2
- package/dist/{chunk-TL545PXW.cjs.map → chunk-NEGZZB7F.cjs.map} +1 -1
- package/dist/{chunk-3GR46UOX.js → chunk-NMU5E7W7.js} +2 -2
- package/dist/{chunk-3GR46UOX.js.map → chunk-NMU5E7W7.js.map} +1 -1
- package/dist/chunk-OB2VX4IL.js +2 -0
- package/dist/chunk-OB2VX4IL.js.map +1 -0
- package/dist/{chunk-MRRMIBHE.js → chunk-OONQ3V3I.js} +2 -2
- package/dist/{chunk-MRRMIBHE.js.map → chunk-OONQ3V3I.js.map} +1 -1
- package/dist/{chunk-N37PUZJR.cjs → chunk-RAPEZR5L.cjs} +2 -2
- package/dist/{chunk-N37PUZJR.cjs.map → chunk-RAPEZR5L.cjs.map} +1 -1
- package/dist/{chunk-KEA5HRL3.js → chunk-RDYXH7ML.js} +2 -2
- package/dist/{chunk-KEA5HRL3.js.map → chunk-RDYXH7ML.js.map} +1 -1
- package/dist/{chunk-3SSMOVWB.cjs → chunk-SAF3B3AX.cjs} +2 -2
- package/dist/{chunk-3SSMOVWB.cjs.map → chunk-SAF3B3AX.cjs.map} +1 -1
- package/dist/chunk-SPOVFRZO.cjs +5 -0
- package/dist/chunk-SPOVFRZO.cjs.map +1 -0
- package/dist/{chunk-75JLWK4L.cjs → chunk-SQHBOWES.cjs} +2 -2
- package/dist/{chunk-75JLWK4L.cjs.map → chunk-SQHBOWES.cjs.map} +1 -1
- package/dist/chunk-UF5XMZTT.js +2 -0
- package/dist/chunk-UF5XMZTT.js.map +1 -0
- package/dist/chunk-UV3EUIBT.cjs +3 -0
- package/dist/chunk-UV3EUIBT.cjs.map +1 -0
- package/dist/chunk-VMSCRVNX.cjs +2 -0
- package/dist/chunk-VMSCRVNX.cjs.map +1 -0
- package/dist/{chunk-J7ABVGZH.cjs → chunk-WGP4UUO5.cjs} +2 -2
- package/dist/{chunk-J7ABVGZH.cjs.map → chunk-WGP4UUO5.cjs.map} +1 -1
- package/dist/chunk-XBGK3TTU.cjs +3 -0
- package/dist/chunk-XBGK3TTU.cjs.map +1 -0
- package/dist/chunk-XHQYHXRE.js +3 -0
- package/dist/chunk-XHQYHXRE.js.map +1 -0
- package/dist/chunk-XX55RR4Q.js +3 -0
- package/dist/chunk-XX55RR4Q.js.map +1 -0
- package/dist/chunk-YBQPEWT7.cjs +3 -0
- package/dist/chunk-YBQPEWT7.cjs.map +1 -0
- package/dist/{chunk-CHSO3DCS.js → chunk-ZDCZ5IDD.js} +3 -3
- package/dist/{chunk-CHSO3DCS.js.map → chunk-ZDCZ5IDD.js.map} +1 -1
- package/dist/{chunk-LNZNJSRW.cjs → chunk-ZVPZQ66D.cjs} +2 -2
- package/dist/chunk-ZVPZQ66D.cjs.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +12 -12
- package/dist/engine.d.ts +12 -12
- package/dist/engine.js +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +11 -11
- package/dist/language.d.ts +11 -11
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.cjs.map +1 -1
- package/dist/lexer.d.cts +8 -7
- package/dist/lexer.d.ts +8 -7
- package/dist/lexer.js +1 -1
- package/dist/lexer.js.map +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +16 -10
- package/dist/normalizer.d.ts +16 -10
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +10 -10
- package/dist/packages.d.ts +10 -10
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +4 -4
- package/dist/parser.d.ts +4 -4
- package/dist/parser.js +1 -1
- package/dist/{pipeline-B4wf3M1h.d.cts → pipeline-69q2tsLE.d.cts} +1 -1
- package/dist/{pipeline-QIT4iD8f.d.ts → pipeline-DTqGLPsV.d.ts} +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +19 -3
- package/dist/resolvers.d.ts +19 -3
- package/dist/resolvers.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +11 -11
- package/dist/testing.d.ts +11 -11
- package/dist/testing.js +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +8 -8
- package/dist/vm.d.ts +8 -8
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +34 -25
- package/dist/worker.d.ts +34 -25
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-42JXN3BH.js +0 -5
- package/dist/chunk-42JXN3BH.js.map +0 -1
- package/dist/chunk-4DJJIUQF.js +0 -2
- package/dist/chunk-4DJJIUQF.js.map +0 -1
- package/dist/chunk-6YM67DWH.cjs +0 -3
- package/dist/chunk-6YM67DWH.cjs.map +0 -1
- package/dist/chunk-7E7NXKQ5.js.map +0 -1
- package/dist/chunk-7SZBEE5R.cjs +0 -2
- package/dist/chunk-7SZBEE5R.cjs.map +0 -1
- package/dist/chunk-A5M4QZIK.js +0 -2
- package/dist/chunk-A5M4QZIK.js.map +0 -1
- package/dist/chunk-AF7HQN6I.js +0 -2
- package/dist/chunk-AF7HQN6I.js.map +0 -1
- package/dist/chunk-ALY4ZMYO.js +0 -2
- package/dist/chunk-ALY4ZMYO.js.map +0 -1
- package/dist/chunk-BRJ4RT5U.js +0 -2
- package/dist/chunk-BRJ4RT5U.js.map +0 -1
- package/dist/chunk-CO2BI6WL.cjs +0 -3
- package/dist/chunk-CO2BI6WL.cjs.map +0 -1
- package/dist/chunk-EN3CDYOS.cjs +0 -2
- package/dist/chunk-EN3CDYOS.cjs.map +0 -1
- package/dist/chunk-EQDT42JG.js +0 -3
- package/dist/chunk-EQDT42JG.js.map +0 -1
- package/dist/chunk-FMMT5C5H.cjs +0 -3
- package/dist/chunk-FMMT5C5H.cjs.map +0 -1
- package/dist/chunk-FP6Z6PYR.js +0 -2
- package/dist/chunk-FP6Z6PYR.js.map +0 -1
- package/dist/chunk-H3JXNH7X.cjs +0 -3
- package/dist/chunk-H3JXNH7X.cjs.map +0 -1
- package/dist/chunk-HZOLIL5T.js +0 -3
- package/dist/chunk-HZOLIL5T.js.map +0 -1
- package/dist/chunk-JVMINMAB.js +0 -2
- package/dist/chunk-JVMINMAB.js.map +0 -1
- package/dist/chunk-JYLNQOPU.cjs +0 -2
- package/dist/chunk-JYLNQOPU.cjs.map +0 -1
- package/dist/chunk-KRXO3MOW.cjs +0 -2
- package/dist/chunk-KRXO3MOW.cjs.map +0 -1
- package/dist/chunk-KVLJDOZ7.cjs +0 -5
- package/dist/chunk-KVLJDOZ7.cjs.map +0 -1
- package/dist/chunk-LNZNJSRW.cjs.map +0 -1
- package/dist/chunk-O3BDXOQJ.js +0 -2
- package/dist/chunk-O3BDXOQJ.js.map +0 -1
- package/dist/chunk-PIZQIQVM.js +0 -3
- package/dist/chunk-PIZQIQVM.js.map +0 -1
- package/dist/chunk-QTSDIDAS.js +0 -3
- package/dist/chunk-QTSDIDAS.js.map +0 -1
- package/dist/chunk-SGIDBZ4T.cjs +0 -2
- package/dist/chunk-SGIDBZ4T.cjs.map +0 -1
- package/dist/chunk-UNKSCVIL.cjs +0 -2
- package/dist/chunk-UNKSCVIL.cjs.map +0 -1
- package/dist/chunk-USQ4KL6S.cjs +0 -2
- package/dist/chunk-USQ4KL6S.cjs.map +0 -1
- package/dist/chunk-XDXIPVZB.cjs +0 -2
- package/dist/chunk-XDXIPVZB.cjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunkYBQPEWT7_cjs=require('./chunk-YBQPEWT7.cjs');var o={WORKER_CANCELLED:"WORKER_CANCELLED",WORKER_TERMINATED:"WORKER_TERMINATED",WORKER_TRANSPORT_FAILED:"WORKER_TRANSPORT_FAILED",WORKER_UNKNOWN_METHOD:"WORKER_UNKNOWN_METHOD",WORKER_NOT_INITIALISED:"WORKER_NOT_INITIALISED",WORKER_UNKNOWN_PACKAGE:"WORKER_UNKNOWN_PACKAGE"};function t(r){let e={name:r.name,category:r.category,code:r.code,message:r.message,recoverable:r.recoverable};return r.expected!==void 0&&(e.expected=r.expected),r.found!==void 0&&(e.found=r.found),r.suggestion!==void 0&&(e.suggestion=r.suggestion),r.span!==void 0&&(e.span=r.span),e}function a(r){let e=Object.values(chunkYBQPEWT7_cjs.a).includes(r.category)?r.category:"INTERNAL";return new chunkYBQPEWT7_cjs.b(e,{code:r.code,message:r.message,expected:r.expected,found:r.found,suggestion:r.suggestion,recoverable:r.recoverable,span:r.span})}function s(r){return chunkYBQPEWT7_cjs.c.execution(o.WORKER_CANCELLED,r?`The worker request "${r}" was cancelled`:"The worker request was cancelled",r?{method:r}:void 0)}function c(){return chunkYBQPEWT7_cjs.c.execution(o.WORKER_TERMINATED,"The worker engine was terminated before this request completed")}function g(r){return chunkYBQPEWT7_cjs.c.external(o.WORKER_TRANSPORT_FAILED,`The worker transport failed: ${r}`,{detail:r})}exports.a=o;exports.b=t;exports.c=a;exports.d=s;exports.e=c;exports.f=g;//# sourceMappingURL=chunk-SAF3B3AX.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-SAF3B3AX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/WorkerError.ts"],"names":["WorkerErrorCodes","serializeEngineError","error","dto","deserializeEngineError","category","ErrorCategory","EngineError","workerCancelledError","method","ErrorFactory","workerTerminatedError","workerTransportError","detail"],"mappings":"mEAoBO,IAAMA,EAAmB,CAE/B,gBAAA,CAAkB,kBAAA,CAElB,iBAAA,CAAmB,oBAEnB,uBAAA,CAAyB,yBAAA,CAEzB,qBAAA,CAAuB,uBAAA,CAEvB,uBAAwB,wBAAA,CAExB,sBAAA,CAAwB,wBACzB,EAyBO,SAASC,CAAAA,CAAqBC,CAAAA,CAA2C,CAC/E,IAAMC,EAA6B,CAClC,IAAA,CAAMD,CAAAA,CAAM,IAAA,CACZ,SAAUA,CAAAA,CAAM,QAAA,CAChB,IAAA,CAAMA,CAAAA,CAAM,KACZ,OAAA,CAASA,CAAAA,CAAM,QACf,WAAA,CAAaA,CAAAA,CAAM,WACpB,CAAA,CAIA,OAAIA,CAAAA,CAAM,QAAA,GAAa,SAAWC,CAAAA,CAAI,QAAA,CAAWD,CAAAA,CAAM,QAAA,CAAA,CACnDA,EAAM,KAAA,GAAU,MAAA,GAAWC,CAAAA,CAAI,KAAA,CAAQD,EAAM,KAAA,CAAA,CAC7CA,CAAAA,CAAM,aAAe,MAAA,GAAWC,CAAAA,CAAI,WAAaD,CAAAA,CAAM,UAAA,CAAA,CAGvDA,CAAAA,CAAM,IAAA,GAAS,SAAWC,CAAAA,CAAI,IAAA,CAAOD,CAAAA,CAAM,IAAA,CAAA,CACxCC,CACR,CAWO,SAASC,CAAAA,CAAuBD,CAAAA,CAAyC,CAC/E,IAAME,CAAAA,CAAW,OAAO,MAAA,CAAOC,mBAAa,EAAE,QAAA,CAASH,CAAAA,CAAI,QAAQ,CAAA,CAChEA,EAAI,QAAA,CAAA,UAAA,CAEP,OAAO,IAAII,mBAAAA,CAAYF,EAAU,CAChC,IAAA,CAAMF,CAAAA,CAAI,IAAA,CACV,QAASA,CAAAA,CAAI,OAAA,CACb,SAAUA,CAAAA,CAAI,QAAA,CACd,MAAOA,CAAAA,CAAI,KAAA,CACX,UAAA,CAAYA,CAAAA,CAAI,WAChB,WAAA,CAAaA,CAAAA,CAAI,WAAA,CACjB,IAAA,CAAMA,EAAI,IACX,CAAC,CACF,CAGO,SAASK,CAAAA,CAAqBC,CAAAA,CAA8B,CAClE,OAAOC,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,gBAAA,CACjBS,CAAAA,CACG,CAAA,oBAAA,EAAuBA,CAAM,CAAA,eAAA,CAAA,CAC7B,kCAAA,CACHA,CAAAA,CAAS,CAAE,OAAAA,CAAO,CAAA,CAAI,MACvB,CACD,CAGO,SAASE,CAAAA,EAAqC,CACpD,OAAOD,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,iBAAA,CACjB,gEACD,CACD,CAGO,SAASY,CAAAA,CAAqBC,CAAAA,CAA6B,CACjE,OAAOH,mBAAAA,CAAa,QAAA,CACnBV,CAAAA,CAAiB,uBAAA,CACjB,gCAAgCa,CAAM,CAAA,CAAA,CACtC,CAAE,MAAA,CAAAA,CAAO,CACV,CACD","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/errors/WorkerError.ts"],"names":["WorkerErrorCodes","serializeEngineError","error","dto","deserializeEngineError","category","ErrorCategory","EngineError","workerCancelledError","method","ErrorFactory","workerTerminatedError","workerTransportError","detail"],"mappings":"mEAoBO,IAAMA,EAAmB,CAE/B,gBAAA,CAAkB,kBAAA,CAElB,iBAAA,CAAmB,oBAEnB,uBAAA,CAAyB,yBAAA,CAEzB,qBAAA,CAAuB,uBAAA,CAEvB,uBAAwB,wBAAA,CAExB,sBAAA,CAAwB,wBACzB,EAyBO,SAASC,CAAAA,CAAqBC,CAAAA,CAA2C,CAC/E,IAAMC,EAA6B,CAClC,IAAA,CAAMD,CAAAA,CAAM,IAAA,CACZ,SAAUA,CAAAA,CAAM,QAAA,CAChB,IAAA,CAAMA,CAAAA,CAAM,KACZ,OAAA,CAASA,CAAAA,CAAM,QACf,WAAA,CAAaA,CAAAA,CAAM,WACpB,CAAA,CAIA,OAAIA,CAAAA,CAAM,QAAA,GAAa,SAAWC,CAAAA,CAAI,QAAA,CAAWD,CAAAA,CAAM,QAAA,CAAA,CACnDA,EAAM,KAAA,GAAU,MAAA,GAAWC,CAAAA,CAAI,KAAA,CAAQD,EAAM,KAAA,CAAA,CAC7CA,CAAAA,CAAM,aAAe,MAAA,GAAWC,CAAAA,CAAI,WAAaD,CAAAA,CAAM,UAAA,CAAA,CAGvDA,CAAAA,CAAM,IAAA,GAAS,SAAWC,CAAAA,CAAI,IAAA,CAAOD,CAAAA,CAAM,IAAA,CAAA,CACxCC,CACR,CAWO,SAASC,CAAAA,CAAuBD,CAAAA,CAAyC,CAC/E,IAAME,CAAAA,CAAW,OAAO,MAAA,CAAOC,mBAAa,EAAE,QAAA,CAASH,CAAAA,CAAI,QAAQ,CAAA,CAChEA,EAAI,QAAA,CAAA,UAAA,CAEP,OAAO,IAAII,mBAAAA,CAAYF,EAAU,CAChC,IAAA,CAAMF,CAAAA,CAAI,IAAA,CACV,QAASA,CAAAA,CAAI,OAAA,CACb,SAAUA,CAAAA,CAAI,QAAA,CACd,MAAOA,CAAAA,CAAI,KAAA,CACX,UAAA,CAAYA,CAAAA,CAAI,WAChB,WAAA,CAAaA,CAAAA,CAAI,WAAA,CACjB,IAAA,CAAMA,EAAI,IACX,CAAC,CACF,CAGO,SAASK,CAAAA,CAAqBC,CAAAA,CAA8B,CAClE,OAAOC,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,gBAAA,CACjBS,CAAAA,CACG,CAAA,oBAAA,EAAuBA,CAAM,CAAA,eAAA,CAAA,CAC7B,kCAAA,CACHA,CAAAA,CAAS,CAAE,OAAAA,CAAO,CAAA,CAAI,MACvB,CACD,CAGO,SAASE,CAAAA,EAAqC,CACpD,OAAOD,mBAAAA,CAAa,UACnBV,CAAAA,CAAiB,iBAAA,CACjB,gEACD,CACD,CAGO,SAASY,CAAAA,CAAqBC,CAAAA,CAA6B,CACjE,OAAOH,mBAAAA,CAAa,QAAA,CACnBV,CAAAA,CAAiB,uBAAA,CACjB,gCAAgCa,CAAM,CAAA,CAAA,CACtC,CAAE,MAAA,CAAAA,CAAO,CACV,CACD","file":"chunk-SAF3B3AX.cjs","sourcesContent":["/**\n * Structured errors for the off-main-thread worker harness, and the pair of\n * functions that carry an {@link EngineError} across a `postMessage` boundary.\n *\n * A worker runs in another thread, so a failure there cannot be `throw`n back\n * into the caller's stack. It has to be encoded, posted, and rebuilt on the\n * main side, and it must arrive as a real structured error rather than a lost\n * promise or an opaque string. {@link serializeEngineError} projects an\n * `EngineError` onto a plain, clone-safe object; {@link deserializeEngineError}\n * rebuilds one from that object so the main-side `catch` sees the same\n * `code`/`category`/`message` it would have seen in-process.\n */\n\nimport { EngineError, ErrorCategory, ErrorFactory, type SourceSpan } from \"./EngineError\";\n\n/**\n * Codes the worker harness owns, co-located here rather than unioned into the\n * core catalog, matching the convention `errors/ErrorCode.ts` documents for a\n * domain that keeps its own small code object.\n */\nexport const WorkerErrorCodes = {\n\t/** The caller aborted the request through its `AbortSignal`. */\n\tWORKER_CANCELLED: \"WORKER_CANCELLED\",\n\t/** The worker engine was torn down while a request was still in flight. */\n\tWORKER_TERMINATED: \"WORKER_TERMINATED\",\n\t/** The transport failed or the worker exited before answering. */\n\tWORKER_TRANSPORT_FAILED: \"WORKER_TRANSPORT_FAILED\",\n\t/** A request named a method the runtime does not expose. */\n\tWORKER_UNKNOWN_METHOD: \"WORKER_UNKNOWN_METHOD\",\n\t/** A request arrived before the runtime finished building its engine. */\n\tWORKER_NOT_INITIALISED: \"WORKER_NOT_INITIALISED\",\n\t/** An init named a package the runtime could not resolve. */\n\tWORKER_UNKNOWN_PACKAGE: \"WORKER_UNKNOWN_PACKAGE\",\n} as const;\n\n/**\n * A structured error flattened for transport.\n *\n * Every field is a string, a boolean, or an object of numbers, so the whole\n * thing survives both `structuredClone` (what `postMessage` uses) and\n * `JSON.stringify` (what a host may log). `context`, `cause` and `timestamp`\n * are deliberately dropped rather than posted: a context can hold a value that\n * is not clone-safe, and none of the three is part of what a main-side handler\n * branches on.\n */\nexport interface SerializedEngineError {\n\tname: string;\n\tcategory: ErrorCategory;\n\tcode: string;\n\tmessage: string;\n\texpected?: string;\n\tfound?: string;\n\tsuggestion?: string;\n\trecoverable: boolean;\n\tspan?: SourceSpan;\n}\n\n/** Flatten an {@link EngineError} into a clone-safe {@link SerializedEngineError}. */\nexport function serializeEngineError(error: EngineError): SerializedEngineError {\n\tconst dto: SerializedEngineError = {\n\t\tname: error.name,\n\t\tcategory: error.category,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\trecoverable: error.recoverable,\n\t};\n\t// Only the optional string fields that were actually set cross the wire, so\n\t// a rebuilt error has `undefined` exactly where the original did rather than\n\t// an explicit `undefined` property a deep-equal would trip on.\n\tif (error.expected !== undefined) dto.expected = error.expected;\n\tif (error.found !== undefined) dto.found = error.found;\n\tif (error.suggestion !== undefined) dto.suggestion = error.suggestion;\n\t// A span is character offsets (plain numbers), so it is safe to carry and\n\t// useful for a host that highlights the failing range.\n\tif (error.span !== undefined) dto.span = error.span;\n\treturn dto;\n}\n\n/**\n * Rebuild an {@link EngineError} from its transported form.\n *\n * The category string round-trips straight back into the `ErrorCategory` enum\n * (its members ARE their own string values), so a main-side `catch` reads the\n * same category the worker raised. A malformed category (a message that was not\n * produced by {@link serializeEngineError}) falls back to `INTERNAL` rather than\n * constructing an error with an invalid category.\n */\nexport function deserializeEngineError(dto: SerializedEngineError): EngineError {\n\tconst category = Object.values(ErrorCategory).includes(dto.category)\n\t\t? dto.category\n\t\t: ErrorCategory.INTERNAL;\n\treturn new EngineError(category, {\n\t\tcode: dto.code,\n\t\tmessage: dto.message,\n\t\texpected: dto.expected,\n\t\tfound: dto.found,\n\t\tsuggestion: dto.suggestion,\n\t\trecoverable: dto.recoverable,\n\t\tspan: dto.span,\n\t});\n}\n\n/** The error a request rejects with when its caller aborts through an `AbortSignal`. */\nexport function workerCancelledError(method?: string): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_CANCELLED,\n\t\tmethod\n\t\t\t? `The worker request \"${method}\" was cancelled`\n\t\t\t: \"The worker request was cancelled\",\n\t\tmethod ? { method } : undefined,\n\t);\n}\n\n/** The error every pending request rejects with when the worker engine is terminated. */\nexport function workerTerminatedError(): EngineError {\n\treturn ErrorFactory.execution(\n\t\tWorkerErrorCodes.WORKER_TERMINATED,\n\t\t\"The worker engine was terminated before this request completed\",\n\t);\n}\n\n/** The error a request rejects with when the transport fails or the worker exits early. */\nexport function workerTransportError(detail: string): EngineError {\n\treturn ErrorFactory.external(\n\t\tWorkerErrorCodes.WORKER_TRANSPORT_FAILED,\n\t\t`The worker transport failed: ${detail}`,\n\t\t{ detail },\n\t);\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';var chunkVMSCRVNX_cjs=require('./chunk-VMSCRVNX.cjs'),chunkZVPZQ66D_cjs=require('./chunk-ZVPZQ66D.cjs'),chunkTTFO4YDP_cjs=require('./chunk-TTFO4YDP.cjs'),chunkJSM3O7EM_cjs=require('./chunk-JSM3O7EM.cjs'),chunkHG4NPDN5_cjs=require('./chunk-HG4NPDN5.cjs'),chunkXBGK3TTU_cjs=require('./chunk-XBGK3TTU.cjs'),chunkRAPEZR5L_cjs=require('./chunk-RAPEZR5L.cjs'),chunkFYTB7SDP_cjs=require('./chunk-FYTB7SDP.cjs'),chunkGBCN7FNV_cjs=require('./chunk-GBCN7FNV.cjs'),chunkUURM7P3P_cjs=require('./chunk-UURM7P3P.cjs'),chunkZLRJ7TDP_cjs=require('./chunk-ZLRJ7TDP.cjs'),chunk634ILVMP_cjs=require('./chunk-634ILVMP.cjs'),chunkWGP4UUO5_cjs=require('./chunk-WGP4UUO5.cjs'),chunkSQHBOWES_cjs=require('./chunk-SQHBOWES.cjs'),chunk4NZXCHQL_cjs=require('./chunk-4NZXCHQL.cjs'),chunkBMXYR5LI_cjs=require('./chunk-BMXYR5LI.cjs'),chunkY7O4D3BJ_cjs=require('./chunk-Y7O4D3BJ.cjs'),chunk77KI7AKJ_cjs=require('./chunk-77KI7AKJ.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkYBQPEWT7_cjs=require('./chunk-YBQPEWT7.cjs');function Pt(r,e,t,n,i){let s=t[e],o=n[e];if(!s||!o)return;let a=new Set(Object.keys(s));for(let l of Object.keys(o))a.has(l)&&i.push({kind:r,severity:"warning",detail:`Both "${t.name}" and "${n.name}" register a ${e==="prefixParselets"?"prefix":"infix"} parselet for token type "${l}" \u2014 the later-registered one silently wins.`,packages:[t.name,n.name]});}function Ot(r,e){let t=[];if(Pt("prefixParseletTokenType","prefixParselets",r,e,t),Pt("infixParseletTokenType","infixParselets",r,e,t),r.phrases&&e.phrases)for(let[s,o]of Object.entries(e.phrases)){let a=r.phrases[s];a!==void 0&&a!==o&&t.push({kind:"phrase",severity:"warning",detail:`Both "${r.name}" (-> "${a}") and "${e.name}" (-> "${o}") fuse the phrase "${s}" to DIFFERENT token types \u2014 PhraseTrie has no collision detection of its own, so the later-registered mapping silently wins with no other signal.`,packages:[r.name,e.name]});}if(r.asConverters&&e.asConverters)for(let s of Object.keys(e.asConverters)){let o=s.toLowerCase();Object.keys(r.asConverters).some(a=>a.toLowerCase()===o)&&t.push({kind:"converterName",severity:"warning",detail:`Both "${r.name}" and "${e.name}" register an "as ${s}" converter \u2014 the later-registered handler silently wins.`,packages:[r.name,e.name]});}if(r.pluginFunctions&&e.pluginFunctions){let s=new Set(Object.keys(r.pluginFunctions));for(let o of Object.keys(e.pluginFunctions))s.has(o)&&t.push({kind:"pluginFunctionName",severity:"warning",detail:`Both "${r.name}" and "${e.name}" register a plugin function named "${o}" \u2014 the later registration wins in the engine's name-to-index map. Give each package's functions package-unique names.`,packages:[r.name,e.name]});}if(r.normalizerRules&&e.normalizerRules){let s=new Set(r.normalizerRules.map(o=>o.name));for(let o of e.normalizerRules)s.has(o.name)&&t.push({kind:"normalizerRuleName",severity:"warning",detail:`Both "${r.name}" and "${e.name}" register a normalizer rule named "${o.name}" \u2014 the normalizer unregisters rules by name, so removing either package would drop both rules. Give each package's rules a package-unique name.`,packages:[r.name,e.name]});}let n=r.lexerVocabulary,i=e.lexerVocabulary;if(n?.keywords&&i?.keywords)for(let[s,o]of Object.entries(i.keywords)){let a=n.keywords[s];a!==void 0&&a!==o&&t.push({kind:"lexerKeyword",severity:"error",detail:`Both "${r.name}" (-> "${a}") and "${e.name}" (-> "${o}") register the lexer keyword "${s}" for DIFFERENT token types \u2014 whichever package registers second wins, and the loser's grammar becomes silently unreachable for that word.`,packages:[r.name,e.name]});}if(n?.operators&&i?.operators)for(let[s,o]of Object.entries(i.operators)){let a=n.operators[s];a!==void 0&&a!==o&&t.push({kind:"lexerOperator",severity:"error",detail:`Both "${r.name}" (-> "${a}") and "${e.name}" (-> "${o}") register the lexer operator "${s}" for DIFFERENT token types.`,packages:[r.name,e.name]});}if(r.asyncResolvers&&e.asyncResolvers){let s=new Set(r.asyncResolvers.map(o=>o.namespace));for(let o of e.asyncResolvers)s.has(o.namespace)&&t.push({kind:"asyncResolverNamespace",severity:"error",detail:`Both "${r.name}" and "${e.name}" register an async resolver under the namespace "${o.namespace}" \u2014 ResolverRegistry is keyed by namespace, so one resolver's cache/preflight state will silently clobber the other's.`,packages:[r.name,e.name]});}if(r.tokenCategories&&e.tokenCategories)for(let[s,o]of Object.entries(e.tokenCategories)){let a=r.tokenCategories[s];a!==void 0&&a!==o&&t.push({kind:"tokenCategory",severity:"info",detail:`Both "${r.name}" (-> "${a}") and "${e.name}" (-> "${o}") declare a highlight category for token type "${s}" \u2014 cosmetic only, but the later registration wins.`,packages:[r.name,e.name]});}return t}function $r(r,e){let t=[];for(let n of e)n===r||n.name===r.name||t.push(...Ot(n,r));return {compatible:!t.some(n=>n.severity==="error"),conflicts:t}}var be=class{constructor(){this.prefixOwners=new Map;this.infixOwners=new Map;this.phraseOwners=new Map;this.converterOwners=new Map;this.pluginFnOwners=new Map;this.ruleOwners=new Map;this.keywordOwners=new Map;this.operatorOwners=new Map;this.resolverOwners=new Map;this.categoryOwners=new Map;}check(e){let t=new Set,n=(s,o)=>{let a=s.get(o);a&&a!==e&&a.name!==e.name&&t.add(a);};if(e.prefixParselets)for(let s of Object.keys(e.prefixParselets))n(this.prefixOwners,s);if(e.infixParselets)for(let s of Object.keys(e.infixParselets))n(this.infixOwners,s);if(e.phrases)for(let s of Object.keys(e.phrases))n(this.phraseOwners,s);if(e.asConverters)for(let s of Object.keys(e.asConverters))n(this.converterOwners,s.toLowerCase());if(e.pluginFunctions)for(let s of Object.keys(e.pluginFunctions))n(this.pluginFnOwners,s);if(e.normalizerRules)for(let s of e.normalizerRules)n(this.ruleOwners,s.name);if(e.lexerVocabulary?.keywords)for(let s of Object.keys(e.lexerVocabulary.keywords))n(this.keywordOwners,s);if(e.lexerVocabulary?.operators)for(let s of Object.keys(e.lexerVocabulary.operators))n(this.operatorOwners,s);if(e.asyncResolvers)for(let s of e.asyncResolvers)n(this.resolverOwners,s.namespace);if(e.tokenCategories)for(let s of Object.keys(e.tokenCategories))n(this.categoryOwners,s);let i=[];for(let s of t)i.push(...Ot(s,e));return i}add(e){let t=(n,i)=>{n.has(i)||n.set(i,e);};if(e.prefixParselets)for(let n of Object.keys(e.prefixParselets))t(this.prefixOwners,n);if(e.infixParselets)for(let n of Object.keys(e.infixParselets))t(this.infixOwners,n);if(e.phrases)for(let n of Object.keys(e.phrases))t(this.phraseOwners,n);if(e.asConverters)for(let n of Object.keys(e.asConverters))t(this.converterOwners,n.toLowerCase());if(e.pluginFunctions)for(let n of Object.keys(e.pluginFunctions))t(this.pluginFnOwners,n);if(e.normalizerRules)for(let n of e.normalizerRules)t(this.ruleOwners,n.name);if(e.lexerVocabulary?.keywords)for(let n of Object.keys(e.lexerVocabulary.keywords))t(this.keywordOwners,n);if(e.lexerVocabulary?.operators)for(let n of Object.keys(e.lexerVocabulary.operators))t(this.operatorOwners,n);if(e.asyncResolvers)for(let n of e.asyncResolvers)t(this.resolverOwners,n.namespace);if(e.tokenCategories)for(let n of Object.keys(e.tokenCategories))t(this.categoryOwners,n);}rebuild(e){for(let t of [this.prefixOwners,this.infixOwners,this.phraseOwners,this.converterOwners,this.pluginFnOwners,this.ruleOwners,this.keywordOwners,this.operatorOwners,this.resolverOwners,this.categoryOwners])t.clear();for(let t of e)this.add(t);}};var or=/(\d+)\.(\d+)\.(\d+)/,ar=/^\d+$/;function Lt(r){let e=or.exec(r.trim());return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null}function lr(r,e){return r[0]-e[0]||r[1]-e[1]||r[2]-e[2]}function Ie(r){let e=r.split(".");if(e.length===0||e.length>3)return null;let t=[0,0,0];for(let n=0;n<e.length;n++){if(!ar.test(e[n]))return null;t[n]=Number(e[n]);}return [t[0],t[1],t[2]]}function cr([r,e,t]){let n=r>0?[r+1,0,0]:e>0?[0,e+1,0]:[0,0,t+1];return [{op:">=",v:[r,e,t]},{op:"<",v:n}]}function ur([r,e,t]){return [{op:">=",v:[r,e,t]},{op:"<",v:[r,e+1,0]}]}function pr(r){if(r===""||r==="*"||r==="x"||r==="X")return [];if(r[0]==="^"){let i=Ie(r.slice(1));return i&&cr(i)}if(r[0]==="~"){let i=Ie(r.slice(1));return i&&ur(i)}let e=/^(>=|<=|>|<|=)/.exec(r),t=e?e[1]:"=",n=Ie(e?r.slice(e[1].length):r);return n&&[{op:t,v:n}]}function It(r){let e=[];for(let t of r.split("||")){let n=t.trim().split(/\s+/).filter(s=>s!==""),i=[];for(let s of n){let o=pr(s);if(o===null)return null;i.push(...o);}e.push(i);}return e}function Vt(r){return It(r.trim())!==null}function fr(r,e){let t=lr(r,e.v);switch(e.op){case "<":return t<0;case "<=":return t<=0;case ">":return t>0;case ">=":return t>=0;case "=":return t===0}}function Mt(r,e){let t=It(e.trim());return t===null?false:t.some(n=>n.every(i=>fr(r,i)))}function gr(r,e=chunk4NZXCHQL_cjs.a){if(!r.engineVersion)return {compatible:true};if(!Vt(r.engineVersion))return {compatible:false,reason:"invalid-range",declaredRange:r.engineVersion,engineVersion:e};let t=Lt(e);return t===null||!Mt(t,r.engineVersion)?{compatible:false,reason:"range-not-satisfied",declaredRange:r.engineVersion,engineVersion:e}:{compatible:true}}function Bt(r,e=chunk4NZXCHQL_cjs.a){let t=gr(r,e);if(!t.compatible)throw t.reason==="invalid-range"?chunkYBQPEWT7_cjs.c.config({code:"PACKAGE_ENGINE_VERSION_INVALID_RANGE",message:`Package "${r.name}" declares an invalid engineVersion range: "${t.declaredRange}" is not a valid semver range.`,expected:'a valid semver range string (e.g. "^0.1.0", ">=0.2.0 <1.0.0")',found:`"${t.declaredRange}"`,suggestion:`This is a range-syntax typo in "${r.name}"'s own descriptor, not a version mismatch with the running engine \u2014 check for a stray character.`,context:{packageName:r.name,declaredRange:t.declaredRange}}):chunkYBQPEWT7_cjs.c.config({code:"PACKAGE_ENGINE_VERSION_MISMATCH",message:`Package "${r.name}" declares engineVersion "${t.declaredRange}", which is not satisfied by the running engine version "${t.engineVersion}".`,expected:`an engine version satisfying "${t.declaredRange}"`,found:`engine version "${t.engineVersion}"`,suggestion:`Update "${r.name}" to a version built against solve-engine ${t.engineVersion}, or pin solve-engine to a version satisfying "${t.declaredRange}".`,context:{packageName:r.name,declaredRange:t.declaredRange,engineVersion:t.engineVersion}})}var ee="solve-engine/snapshot",Q=1;function $(r){return Number.isFinite(r)?r:Number.isNaN(r)?"NaN":r>0?"Infinity":"-Infinity"}function _(r){if(typeof r=="number")return r;if(r==="NaN")return NaN;if(r==="Infinity")return 1/0;if(r==="-Infinity")return -1/0;throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_MALFORMED,message:`Snapshot holds an unrecognised number sentinel: ${JSON.stringify(r)}`,expected:'a JSON number, or one of "NaN", "Infinity", "-Infinity"',found:JSON.stringify(r)})}var B={SNAPSHOT_VERSION_MISMATCH:"SNAPSHOT_VERSION_MISMATCH",SNAPSHOT_MALFORMED:"SNAPSHOT_MALFORMED",SNAPSHOT_UNSUPPORTED_VALUE:"SNAPSHOT_UNSUPPORTED_VALUE"};function Dt(r){return {coef:r.coef.toString(),scale:r.scale}}function Ut(r){return {coef:BigInt(r.coef),scale:r.scale}}function dr(r){return {n:r.n.toString(),d:r.d.toString()}}function hr(r){return {n:BigInt(r.n),d:BigInt(r.d)}}function Ft(r){return chunkSQHBOWES_cjs.g[r]??String(r)}function Ve(r,e){throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_UNSUPPORTED_VALUE,message:`A ${Ft(r)} value (${e}) cannot be included in a snapshot yet.`,expected:"a concrete number, string, boolean, unit, range, matrix, bigint, or money value",found:`${Ft(r)} value`,suggestion:"Symbolic (algebra) values are deferred to a follow-up. Evaluate the document without the symbolic line, or re-derive it after restoring.",context:{valueType:r,location:e}})}function Me(r,e){switch(r.type){case 0:{let t={t:0,v:$(r.value)};return r.exact!==void 0&&(t.exact=Dt(r.exact)),r.rational!==void 0&&(t.rational=dr(r.rational)),t}case 1:{let t=r.value;return typeof t=="bigint"?{t:1,v:t.toString(),big:true,base:r.unit}:{t:1,v:$(t),base:r.unit}}case 2:return {t:2,v:r.value.toString()};case 3:return {t:3,v:r.value};case 4:return {t:4,v:$(r.value)};case 5:return {t:5,v:$(r.value)};case 6:{let t={t:6,v:$(r.value),unit:r.unit??""};return r.exact!==void 0&&(t.exact=Dt(r.exact)),t}case 7:{let t=r.value;t.hasSymbolic&&Ve(9,`${e} (symbolic matrix cell)`);let n=t.data.map(i=>mr(i,e));return {t:7,rows:t.rows,cols:t.cols,data:n}}case 8:{let t=r.value;return {t:8,min:$(t.min),max:$(t.max)}}case 10:return {t:10,v:r.value};case 13:return {t:13,code:r.value,message:r.unit??""};default:return Ve(r.type,e)}}function mr(r,e){return typeof r=="boolean"?r:typeof r=="number"?$(r):Ve(9,`${e} (symbolic matrix cell)`)}function Be(r){switch(r.t){case 0:{let e=new chunkSQHBOWES_cjs.m(0,_(r.v));return r.exact!==void 0&&(e.exact=Ut(r.exact)),r.rational!==void 0&&(e.rational=hr(r.rational)),e}case 1:{let e=r.big?BigInt(r.v):_(r.v);return new chunkSQHBOWES_cjs.m(1,e,r.base)}case 2:return new chunkSQHBOWES_cjs.m(2,BigInt(r.v));case 3:return new chunkSQHBOWES_cjs.m(3,r.v);case 4:return new chunkSQHBOWES_cjs.m(4,_(r.v));case 5:return new chunkSQHBOWES_cjs.m(5,_(r.v));case 6:{let e=new chunkSQHBOWES_cjs.m(6,_(r.v),r.unit);return r.exact!==void 0&&(e.exact=Ut(r.exact)),e}case 7:{let e=r.data.map(n=>typeof n=="boolean"?n:_(n)),t={rows:r.rows,cols:r.cols,data:e,hasSymbolic:false};return new chunkSQHBOWES_cjs.m(7,t)}case 8:return new chunkSQHBOWES_cjs.m(8,{min:_(r.min),max:_(r.max)});case 10:return new chunkSQHBOWES_cjs.m(10,r.v);case 13:return new chunkSQHBOWES_cjs.m(13,r.code,r.message);default:throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_MALFORMED,message:`Snapshot holds a value with an unknown type tag: ${JSON.stringify(r.t)}`,expected:"a known SerializedValue type tag",found:JSON.stringify(r.t)})}}function ue(r){let e={opcodes:Array.from(r.opcodes),numbers:Array.from(r.numbers,$),strings:r.strings.slice(),hasAsync:r.hasAsync};return r.constants&&(e.constants=Array.from(r.constants.entries())),r.userFunctionBodies&&(e.userFunctionBodies=r.userFunctionBodies.map(De)),r.anonymousBodies&&(e.anonymousBodies=r.anonymousBodies.map(t=>({params:t.params.slice(),program:ue(t.program)}))),e}function pe(r){let e={opcodes:Uint8Array.from(r.opcodes),numbers:Float64Array.from(r.numbers,_),strings:r.strings.slice(),hasAsync:r.hasAsync};return r.constants&&(e.constants=new Map(r.constants)),r.userFunctionBodies&&(e.userFunctionBodies=r.userFunctionBodies.map(Ue)),r.anonymousBodies&&(e.anonymousBodies=r.anonymousBodies.map(t=>({params:t.params.slice(),program:pe(t.program)}))),e}function De(r){return {name:r.name,params:r.params.slice(),program:ue(r.program)}}function Ue(r){return {name:r.name,params:r.params.slice(),program:pe(r.program)}}function jt(r){if(typeof r!="object"||r===null)throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_VERSION_MISMATCH,message:"fromJSON was given something that is not a snapshot object.",expected:`an object produced by ExpressionEngine.toJSON() with format "${ee}"`,found:r===null?"null":typeof r});let e=r;if(e.format!==ee)throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_VERSION_MISMATCH,message:`This object is not a solve-engine snapshot (its "format" is ${JSON.stringify(e.format)}).`,expected:`format "${ee}"`,found:JSON.stringify(e.format)});if(e.version!==Q)throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_VERSION_MISMATCH,message:`This snapshot was written for format version ${e.version}, but this engine restores version ${Q}.`,expected:`snapshot version ${Q}`,found:`version ${e.version}`,suggestion:"Regenerate the snapshot with a matching engine version, or re-evaluate the document from source.",context:{snapshotVersion:e.version,readerVersion:Q,engineVersion:e.engineVersion}});vr(r);}var _t=32;function yr(r){return r===null?"null":Array.isArray(r)?`an array of ${r.length}`:typeof r=="object"?"an object":`${typeof r} ${JSON.stringify(r)}`.slice(0,80)}function d(r,e,t){throw chunkYBQPEWT7_cjs.c.validation({code:B.SNAPSHOT_MALFORMED,message:`Snapshot is malformed at ${r}: expected ${e}.`,expected:e,found:yr(t),suggestion:"Regenerate the snapshot with ExpressionEngine.toJSON(), or re-evaluate the document from source.",context:{location:r}})}function z(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function W(r){return typeof r=="number"||r==="NaN"||r==="Infinity"||r==="-Infinity"}function ce(r){return typeof r=="string"&&/^-?\d+$/.test(r)}function ve(r,e){(!Array.isArray(r)||!r.every(t=>typeof t=="string"))&&d(e,"an array of strings",r);}function $t(r,e){(!z(r)||!ce(r.coef)||typeof r.scale!="number")&&d(e,"a decimal as { coef: digits, scale: number }",r);}function br(r,e){(!z(r)||!ce(r.n)||!ce(r.d))&&d(e,"a rational as { n: digits, d: digits }",r);}function zt(r,e){switch(z(r)||d(e,"a serialised value object",r),r.t){case 0:W(r.v)||d(`${e}.v`,"a number",r.v),r.exact!==void 0&&$t(r.exact,`${e}.exact`),r.rational!==void 0&&br(r.rational,`${e}.rational`);return;case 1:(r.big?!ce(r.v):!W(r.v))&&d(`${e}.v`,r.big?"an integer string":"a number",r.v),r.base!==void 0&&typeof r.base!="string"&&d(`${e}.base`,"a base name",r.base);return;case 2:ce(r.v)||d(`${e}.v`,"an integer string",r.v);return;case 3:typeof r.v!="string"&&d(`${e}.v`,"a string",r.v);return;case 4:case 5:W(r.v)||d(`${e}.v`,"a number",r.v);return;case 6:W(r.v)||d(`${e}.v`,"a number",r.v),typeof r.unit!="string"&&d(`${e}.unit`,"a unit name",r.unit),r.exact!==void 0&&$t(r.exact,`${e}.exact`);return;case 7:{let{rows:t,cols:n,data:i}=r;(!Number.isInteger(t)||t<0)&&d(`${e}.rows`,"a non-negative integer",t),(!Number.isInteger(n)||n<0)&&d(`${e}.cols`,"a non-negative integer",n),(!Array.isArray(i)||i.length!==t*n)&&d(`${e}.data`,`an array of ${t} \xD7 ${n} cells`,i),i.every(s=>typeof s=="boolean"||W(s))||d(`${e}.data`,"numeric or boolean cells",i);return}case 8:(!W(r.min)||!W(r.max))&&d(e,"a range with numeric min and max",r);return;case 10:typeof r.v!="boolean"&&d(`${e}.v`,"a boolean",r.v);return;case 13:(typeof r.code!="string"||typeof r.message!="string")&&d(e,"an error with a string code and message",r);return;default:return}}function Ee(r,e,t){if(t>_t&&d(e,`function bodies nested at most ${_t} deep`,"deeper nesting"),z(r)||d(e,"a serialised program object",r),(!Array.isArray(r.opcodes)||!r.opcodes.every(n=>Number.isInteger(n)&&n>=0&&n<=255))&&d(`${e}.opcodes`,"an array of bytes (integers 0 to 255)",r.opcodes),(!Array.isArray(r.numbers)||!r.numbers.every(W))&&d(`${e}.numbers`,"an array of numbers",r.numbers),ve(r.strings,`${e}.strings`),typeof r.hasAsync!="boolean"&&d(`${e}.hasAsync`,"a boolean",r.hasAsync),r.constants!==void 0){let n=i=>Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number";(!Array.isArray(r.constants)||!r.constants.every(n))&&d(`${e}.constants`,"an array of [number, number] pairs",r.constants);}r.userFunctionBodies!==void 0&&(Array.isArray(r.userFunctionBodies)||d(`${e}.userFunctionBodies`,"an array of functions",r.userFunctionBodies),r.userFunctionBodies.forEach((n,i)=>Ht(n,`${e}.userFunctionBodies[${i}]`,t+1))),r.anonymousBodies!==void 0&&(Array.isArray(r.anonymousBodies)||d(`${e}.anonymousBodies`,"an array of bodies",r.anonymousBodies),r.anonymousBodies.forEach((n,i)=>{let s=`${e}.anonymousBodies[${i}]`;z(n)||d(s,"a body object",n),ve(n.params,`${s}.params`),Ee(n.program,`${s}.program`,t+1);}));}function Ht(r,e,t){z(r)||d(e,"a function object",r),typeof r.name!="string"&&d(`${e}.name`,"a function name",r.name),ve(r.params,`${e}.params`),Ee(r.program,`${e}.program`,t);}function vr(r){r.locale!==void 0&&typeof r.locale!="string"&&d("locale","a locale code",r.locale),z(r.variables)||d("variables","an object of values by name",r.variables);for(let[e,t]of Object.entries(r.variables))zt(t,`variables.${e}`);Array.isArray(r.userFunctions)||d("userFunctions","an array of functions",r.userFunctions),r.userFunctions.forEach((e,t)=>Ht(e,`userFunctions[${t}]`,1)),Array.isArray(r.lineCache)||d("lineCache","an array of cached lines",r.lineCache),r.lineCache.forEach((e,t)=>{let n=`lineCache[${t}]`;z(e)||d(n,"a cached line",e),Number.isInteger(e.line)||d(`${n}.line`,"a line number",e.line),typeof e.expression!="string"&&d(`${n}.expression`,"the line's expression text",e.expression),zt(e.result,`${n}.result`),Ee(e.bytecode,`${n}.bytecode`,1),ve(e.reads,`${n}.reads`),e.writeVar!==null&&typeof e.writeVar!="string"&&d(`${n}.writeVar`,"a variable name or null",e.writeVar);}),Array.isArray(r.bytecodeCache)||d("bytecodeCache","an array of compiled expressions",r.bytecodeCache),r.bytecodeCache.forEach((e,t)=>{let n=`bytecodeCache[${t}]`;(!z(e)||typeof e.expression!="string")&&d(n,"an { expression, program } pair",e),Ee(e.program,`${n}.program`,1);});}var K=class{constructor(e,t,n,i){this.result=e;this.bytecode=t;this.readVariables=n;this.writeVariable=i;}},ke=class r{constructor(){this.byLine=new Map;this.count=0;}static exprKey(e){return e??""}static displayKey(e,t){return t===""?`${e}`:`${e}:${t}`}get(e,t){return this.byLine.get(e)?.get(r.exprKey(t))}getEntryForLine(e){let t=this.byLine.get(e);if(t)for(let n of t.values())return n}set(e,t,n){let i=this.byLine.get(e);i||(i=new Map,this.byLine.set(e,i));let s=r.exprKey(n);i.size>0&&!i.has(s)&&(this.count-=i.size,i.clear()),i.has(s)||this.count++,i.set(s,t);}has(e,t){return this.byLine.get(e)?.has(r.exprKey(t))??false}remove(e,t){let n=this.byLine.get(e);n&&n.delete(r.exprKey(t))&&(this.count--,n.size===0&&this.byLine.delete(e));}removeAllForLine(e){let t=this.byLine.get(e);t&&(this.count-=t.size,this.byLine.delete(e));}clearLine(e){this.removeAllForLine(e);}get size(){return this.count}clear(){this.byLine.clear(),this.count=0;}forEach(e){for(let[t,n]of this.byLine)for(let[i,s]of n)e(r.displayKey(t,i),s);}snapshotEntries(){let e=[];for(let[t,n]of this.byLine)for(let[i,s]of n)e.push({line:t,expression:i,entry:s});return e}keys(){let e=[];for(let[t,n]of this.byLine)for(let i of n.keys())e.push(r.displayKey(t,i));return e}};function Fe(r){let e=new Date(r),t=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return `${e.getFullYear()}-${t}-${n}`}function Er(r){if(r instanceof Date)return Fe(r.getTime());if(typeof r=="number")return Number.isFinite(r)?Fe(r):null;let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(r.trim());return e?`${e[1]}-${e[2]}-${e[3]}`:null}function Wt(r){if(r===void 0)return;if(typeof r=="function")return t=>r(new Date(t));let e=new Set;for(let t of r){let n=Er(t);n!==null&&e.add(n);}return t=>e.has(Fe(t))}function kr(r,e){if(!r||r.type!==e.type||r.value!==e.value)return true;let t=r.unit,n=e.unit;return t!==n}var xe=class r{constructor(e,t){this.dag=e;this.enqueue=t;this.entries=new Map;}get size(){return this.entries.size}static idOf(e,t){return JSON.stringify([e,t])}register(e){if(!(e.intervalMs>0))return;let t=r.idOf(e.packageId,e.queryKey);if(this.entries.has(t))return;let n=setInterval(()=>{this.tick(t);},e.intervalMs);n.unref?.(),this.entries.set(t,{...e,timer:n,lastValue:null,inFlight:false});}async tick(e){let t=this.entries.get(e);if(t&&!t.inFlight){if(this.isDead(t)){this.stop(e);return}t.inFlight=true;try{let n=await t.refetch(),i=this.entries.get(e);if(!i)return;n&&kr(i.lastValue,n)&&(i.lastValue=n,this.enqueue(i.packageId,i.queryKey));}catch{}finally{let n=this.entries.get(e);n&&(n.inFlight=false);}}}isDead(e){return this.dag.getAffectedLinesByDataSource(e.packageId,[e.queryKey]).size===0}reconcile(){for(let[e,t]of this.entries)this.isDead(t)&&this.stop(e);}stop(e){let t=this.entries.get(e);t&&(clearInterval(t.timer),this.entries.delete(e));}clearAll(){for(let e of this.entries.values())clearInterval(e.timer);this.entries.clear();}};var F=class{static enable(){this.enabled=true;}static disable(){this.enabled=false;}static isEnabled(){return this.enabled}static track(e,t,n){if(!this.enabled)return {result:t(),alloc:null};let i=typeof process<"u"&&process.memoryUsage?process.memoryUsage():null,s=typeof process<"u"&&process.hrtime?process.hrtime():performance.now(),o=t(),a=typeof process<"u"&&process.hrtime?process.hrtime(s):void 0,l=typeof process<"u"&&process.memoryUsage?process.memoryUsage():null,c=a?a[0]*1e9+a[1]:(performance.now()-s)*1e6,u=i&&l?l.heapUsed-i.heapUsed:0,p={stage:e,allocCount:0,allocBytes:u,objectCounts:{},wallTimeNs:c,...n};return {result:o,alloc:p}}static generateReport(e,t){let n=[];n.push(t?`## ${t}`:"## Pipeline Allocation Report"),n.push(""),n.push(`**Runs:** ${e.length} | **Generated:** ${new Date().toISOString()}`),n.push("");let i=this.aggregate(e);if(i.length===0)return n.push("_No telemetry data._"),n.join(`
|
|
2
|
+
`);n.push("### Per-Stage Breakdown"),n.push(""),n.push("| Stage | Count | Mean Wall (\xB5s) | Mean Alloc (bytes) | Min (\xB5s) | Max (\xB5s) | p50 (\xB5s) | p95 (\xB5s) | p99 (\xB5s) |"),n.push("|-------|:-----:|:--------------:|:------------------:|:--------:|:--------:|:--------:|:--------:|:--------:|");for(let l of i)n.push(`| ${l.stage} | ${l.count} | ${(l.meanWallTimeNs/1e3).toFixed(2)} | ${l.meanAllocBytes.toFixed(0)} | ${(l.minWallTimeNs/1e3).toFixed(2)} | ${(l.maxWallTimeNs/1e3).toFixed(2)} | ${(l.p50WallTimeNs/1e3).toFixed(2)} | ${(l.p95WallTimeNs/1e3).toFixed(2)} | ${(l.p99WallTimeNs/1e3).toFixed(2)} |`);let s=e.reduce((l,c)=>l+c.totalAllocBytes,0),o=e.reduce((l,c)=>l+c.totalWallTimeNs,0),a=e.filter(l=>l.fastPath).length;return n.push(""),n.push("### Totals"),n.push(""),n.push(`- **Total wall time:** ${(o/1e6).toFixed(2)} ms (${e.length} runs)`),n.push(`- **Total heap allocated:** ${s.toLocaleString()} bytes`),n.push(`- **Fast-path runs:** ${a}/${e.length} (${(a/e.length*100).toFixed(0)}%)`),n.push(`- **Mean per-run:** ${(o/e.length/1e3).toFixed(2)} \xB5s, ${(s/e.length).toFixed(0)} bytes`),n.join(`
|
|
3
|
+
`)}static aggregate(e){let t=new Map;for(let i of e)for(let s of i.stages)t.has(s.stage)||t.set(s.stage,[]),t.get(s.stage).push(s);let n=[];for(let[i,s]of t){let o=s.map(c=>c.wallTimeNs).sort((c,u)=>c-u),a=s.map(c=>c.allocBytes),l=s.length;n.push({stage:i,count:l,meanAllocBytes:a.reduce((c,u)=>c+u,0)/l,meanWallTimeNs:o.reduce((c,u)=>c+u,0)/l,minWallTimeNs:o[0],maxWallTimeNs:o[o.length-1],p50WallTimeNs:_e(o,50),p95WallTimeNs:_e(o,95),p99WallTimeNs:_e(o,99)});}return n.sort((i,s)=>i.stage.localeCompare(s.stage)),n}static createTelemetry(e,t,n=false){let i=t.reduce((o,a)=>o+a.allocBytes,0),s=t.reduce((o,a)=>o+a.wallTimeNs,0);return {expression:e,stages:t,totalAllocBytes:i,totalWallTimeNs:s,fastPath:n}}};F.enabled=false;function _e(r,e){if(r.length===0)return 0;if(r.length===1)return r[0];let t=e/100*(r.length-1),n=Math.floor(t),i=Math.ceil(t);if(n===i)return r[n];let s=t-n;return r[n]*(1-s)+r[i]*s}function $e(r,e){if(r.length>e.maxExpressionLength){let t=chunkYBQPEWT7_cjs.c.validation("EXPRESSION_TOO_LONG",`Expression exceeds max length of ${e.maxExpressionLength} characters (got ${r.length})`,{expressionLength:r.length,maxLength:e.maxExpressionLength});return {passed:false,error:{value:chunkSQHBOWES_cjs.n(0),tokens:[],program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},error:t.message,engineError:t}}}return {passed:true}}function ze(r,e){let t=0,n=0,i=0;for(let o of r)o.type==="FUNC"&&t++,(o.value==="("||o.type==="LPAREN")&&(n++,i=Math.max(i,n)),(o.value===")"||o.type==="RPAREN")&&n--;let s=r.length+t*5+i*10;if(s>e.maxComplexity){let o=chunkYBQPEWT7_cjs.c.validation("EXPRESSION_TOO_COMPLEX",`Expression complexity score ${s} exceeds maximum of ${e.maxComplexity}`,{complexity:s,maxComplexity:e.maxComplexity});return {passed:false,complexityScore:s,errorMessage:o.message,engineError:o}}return {passed:true,complexityScore:s}}function fe(r){return r.type==="IDENT"||r.type==="UNIT"}function xr(r){return r.type==="NUMBER"||r.type==="TO"||r.type==="IN"||r.type==="RPAREN"}function Kt(r,e){let t=0;for(let n=e;n<r.length;n++)if(r[n].type==="LPAREN")t++;else if(r[n].type==="RPAREN"&&(t--,t===0))return n;return null}function Sr(r){let e=new Set;for(let t=0;t<r.length;t++){if(!fe(r[t])||t>0&&r[t-1].type==="COLON"||r[t+1]?.type!=="LPAREN")continue;let n=Kt(r,t+1);if(n!==null&&r[n+1]?.type==="EQUALS")for(let i=t+2;i<n;i++)fe(r[i])&&e.add(r[i].value);}return e}function Se(r){let e=[],t=[],n=Sr(r);for(let i=0;i<r.length;i++){let s=r[i];if(s.type==="GLOBAL"){if(i+2<r.length&&r[i+1].type==="COLON"&&fe(r[i+2])){let o=chunk634ILVMP_cjs.K(r[i+2].value);e.push(o),i+3<r.length&&r[i+3].type==="EQUALS"&&t.push(o);}continue}if(s.type==="COLON"){if(i>0&&r[i-1].type==="GLOBAL")continue;if(i+1<r.length&&fe(r[i+1])){let o=r[i+1].value;e.push(o),i+2<r.length&&r[i+2].type==="EQUALS"&&t.push(o);}}if(fe(s)){if(i>0&&r[i-1].type==="COLON"||s.type==="UNIT"&&i>0&&xr(r[i-1])||n.has(s.value))continue;if(r[i+1]?.type==="LPAREN"){let a=Kt(r,i+1);if(a!==null&&r[a+1]?.type==="EQUALS"){e.push(s.value),t.push(s.value);continue}}e.push(s.value);let o=r[i+1]?.type;(o==="EQUALS"||o==="PLUS_EQUALS"||o==="MINUS_EQUALS")&&t.push(s.value);}}return {reads:e,writes:t}}function cn(r){return chunkBMXYR5LI_cjs.c.classifyLine(r).skip}function un(r,e){return chunkBMXYR5LI_cjs.c.findInlineSolves(r).map(n=>({start:n.start,end:n.end,expression:n.expression,lineNumber:e,columnNumber:n.columnNumber}))}function qt(r){let e=r[r.length-1],t=e.length>1&&e.endsWith("s")?e.slice(0,-1):e;return [...r.slice(0,-1),t].join(" ")}var Ce=class{constructor(){this.byKey=new Map;this.longestName=0;}get isEmpty(){return this.byKey.size===0}get maxWordCount(){return this.longestName}define(e,t,n){let i=qt(e);this.byKey.set(i,{displayName:e.join(" "),ratioText:t,baseUnit:n}),e.length>this.longestName&&(this.longestName=e.length);}match(e){let t=Math.min(e.length,this.longestName);for(let n=t;n>=1;n--){let i=this.byKey.get(qt(e.slice(0,n)));if(i!==void 0)return {definition:i,wordCount:n}}return null}clear(){this.byKey.clear(),this.longestName=0;}};function Gt(r,e=82){return {name:"uom:user-unit",priority:e,shape:[{types:["NUMBER","RPAREN"]},{types:["IDENT"]}],match(t,n){if(r.isEmpty)return null;let i=t[n];if(i.type!=="NUMBER"&&i.type!=="RPAREN")return null;let s=[],o=r.maxWordCount;for(let f=n+1;f<t.length&&s.length<o&&t[f].type==="IDENT";f++)s.push(t[f].value);if(s.length===0)return null;let a=r.match(s);if(a===null||t[n+1+a.wordCount]?.type==="EQUALS")return null;let{ratioText:c,baseUnit:u}=a.definition,p=new chunk77KI7AKJ_cjs.a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"*","*",i.offset,0,i.line,i.col),m=new chunk77KI7AKJ_cjs.a("NUMBER",chunk5IJD5L3O_cjs.c("NUMBER"),c,c,i.offset,0,i.line,i.col),y=new chunk77KI7AKJ_cjs.a("UNIT",chunk5IJD5L3O_cjs.c("UNIT"),u,u,i.offset,0,i.line,i.col);return {consumed:1+a.wordCount,replacement:[i,p,m,y],ruleName:"uom:user-unit"}}}}var Qt="engine:call-fusion";function Xt(r,e=80){return {name:Qt,priority:e,shape:[{types:["IDENT"]},{types:["LPAREN"]}],match(t,n){let i=t[n];if(!i||i.type!=="IDENT"||t[n+1]?.type!=="LPAREN"||t[n-1]?.type==="COLON")return null;let s=(i.value??"").toLowerCase(),o=r.get(s);return o===void 0?null:{consumed:1,replacement:[new chunk77KI7AKJ_cjs.a(o,chunk5IJD5L3O_cjs.c(o),s,i.value,i.offset,0,i.line,i.col)],ruleName:Qt}}}}var Cr=30,wr=40,Tr=50,Nr=24;function Rr(r){switch(r){case chunk5IJD5L3O_cjs.a.PLUS:case chunk5IJD5L3O_cjs.a.MINUS:return Cr;case chunk5IJD5L3O_cjs.a.STAR:case chunk5IJD5L3O_cjs.a.SLASH:case chunk5IJD5L3O_cjs.a.MOD:case chunk5IJD5L3O_cjs.a.OF:return wr;case chunk5IJD5L3O_cjs.a.CARET:return Tr;case chunk5IJD5L3O_cjs.a.PCT_ON:case chunk5IJD5L3O_cjs.a.PCT_OFF:return Nr;default:return 0}}function Ar(r){switch(r){case chunk5IJD5L3O_cjs.a.PLUS:return "plus";case chunk5IJD5L3O_cjs.a.MINUS:return "minus";case chunk5IJD5L3O_cjs.a.STAR:return "times";case chunk5IJD5L3O_cjs.a.SLASH:return "divided by";case chunk5IJD5L3O_cjs.a.MOD:return "mod";case chunk5IJD5L3O_cjs.a.CARET:return "to the power of";case chunk5IJD5L3O_cjs.a.OF:return "of";case chunk5IJD5L3O_cjs.a.PCT_ON:return "plus";case chunk5IJD5L3O_cjs.a.PCT_OFF:return "less";default:return r.toLowerCase()}}function Jt(r){return r.sourceEnd??r.offset+r.value.length}var Pr=new Set([chunk5IJD5L3O_cjs.a.NUMBER,chunk5IJD5L3O_cjs.a.BIGINT,chunk5IJD5L3O_cjs.a.IDENT,chunk5IJD5L3O_cjs.a.UNIT,chunk5IJD5L3O_cjs.a.PERCENT,chunk5IJD5L3O_cjs.a.PI,chunk5IJD5L3O_cjs.a.E,chunk5IJD5L3O_cjs.a.TRUE,chunk5IJD5L3O_cjs.a.FALSE,chunk5IJD5L3O_cjs.a.DOLLAR,chunk5IJD5L3O_cjs.a.POUND,chunk5IJD5L3O_cjs.a.EURO,chunk5IJD5L3O_cjs.a.YEN,chunk5IJD5L3O_cjs.a.RUBLE,chunk5IJD5L3O_cjs.a.WON,chunk5IJD5L3O_cjs.a.CURRENCY_SYMBOL]);function Or(r){return !Pr.has(r)}var je=class{constructor(e){this.tokens=e;this.pos=0;}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}parseAll(){let e=this.parseExpression(0);if(this.pos!==this.tokens.length)throw new Error("explain: unconsumed tokens");return e}parseExpression(e){let t=this.parseOperand();for(;;){let n=this.peek();if(!n)break;let i=Rr(n.type);if(i===0||i<=e)break;this.next();let s=n.type===chunk5IJD5L3O_cjs.a.CARET?i-1:i,o=this.parseExpression(s);t={kind:"binary",op:n.type,left:t,right:o,start:t.start,end:o.end};}return t}parseOperand(){let e=this.peek();if(!e)throw new Error("explain: expected an operand");if(e.type===chunk5IJD5L3O_cjs.a.LPAREN)return this.parseGroup();let t=e.offset,n=false;for(;this.peek()&&(this.peek().type===chunk5IJD5L3O_cjs.a.PLUS||this.peek().type===chunk5IJD5L3O_cjs.a.MINUS);)this.next(),n=true;if(n&&this.peek()&&this.peek().type===chunk5IJD5L3O_cjs.a.LPAREN){let s=this.parseGroup();return {kind:"wrap",child:s,start:t,end:s.end}}let i=-1;for(;this.peek()&&!Or(this.peek().type);)i=Jt(this.next());if(i===-1)throw new Error("explain: expected an operand");return {kind:"leaf",start:t,end:i}}parseGroup(){let e=this.next(),t=this.parseExpression(0),n=this.peek();if(!n||n.type!==chunk5IJD5L3O_cjs.a.RPAREN)throw new Error("explain: unbalanced parentheses");return this.next(),{kind:"wrap",child:t,start:e.offset,end:Jt(n)}}},He=class{constructor(e,t,n){this.source=e;this.evaluate=t;this.steps=[];this.cache=new Map;this.resultPrefix=chunkS3DFU33X_cjs.a(n).display.resultPrefix;}build(e){return this.emit(e),{steps:this.steps,result:this.valueOf(e)}}emit(e){if(e.kind!=="leaf"){if(e.kind==="wrap"){this.emit(e.child);return}this.emit(e.left),this.emit(e.right),this.steps.push({description:this.describe(e),value:this.valueOf(e)});}}describe(e){let t=Ar(e.op);return e.op===chunk5IJD5L3O_cjs.a.PCT_ON||e.op===chunk5IJD5L3O_cjs.a.PCT_OFF?`${this.operand(e.right)} ${t} ${this.operand(e.left)}`:`${this.operand(e.left)} ${t} ${this.operand(e.right)}`}operand(e){return e.kind==="leaf"?this.source.slice(e.start,e.end).trim():this.render(this.valueOf(e))}valueOf(e){let t=this.cache.get(e);if(t)return t;let n=this.evaluate(this.source.slice(e.start,e.end));return this.cache.set(e,n),n}render(e){let t=chunkXBGK3TTU_cjs.c(e,chunkXBGK3TTU_cjs.a);return t.startsWith(this.resultPrefix)?t.slice(this.resultPrefix.length):t}};function We(r){let{expression:e,tokens:t,evaluate:n,locale:i}=r,s=()=>({expression:e,steps:[],result:n(e)}),o;try{o=new je(t).parseAll();}catch{return s()}try{let{steps:a,result:l}=new He(e,n,i).build(o);return {expression:e,steps:a,result:l}}catch{return s()}}var X=class X{constructor(e={}){this.dag=new chunkJSM3O7EM_cjs.a;this.lineCache=new ke;this.accumulatorNames=new Set;this.scopeManager=new chunkJSM3O7EM_cjs.b;this.resolverRegistry=new chunkZVPZQ66D_cjs.a;this.packageContributions=new Map;this.registeredPackages=new Map;this.callFusions=new Map;this.callFusionOwners=new Map;this.compatIndex=new be;this.documentModel=null;this.goalSeekDepth=0;this.batchScanResults=null;this.batchParsedLines=null;this.packageCompletionItems=new Map;this.keystrokeSignal=null;this.backgroundRefreshSignal=new AbortController().signal;this.userUnits=new Ce;this.bytecodeCache=new Map;this.compiledFrontHalf=new Map;this.failedParses=new Map;this.pluginFunctionIndexByName=new Map;this.builderPool=[new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName),new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName),new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName),new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName)];this.builderPoolIndex=0;this.lastTelemetry=null;let{locale:t="en",diagnostics:n=false,config:i,packages:s}=e;this.localeCode=t,this.config=chunk4NZXCHQL_cjs.c(chunk4NZXCHQL_cjs.b,i??{}),this.lexer=new chunkBMXYR5LI_cjs.b(t),this.registry=new chunkVMSCRVNX_cjs.b,this.context=chunk634ILVMP_cjs.x({networkEnabled:this.config.network.enabled}),n?(this.diagnosticPipeline=new chunkHG4NPDN5_cjs.a,this.timelineCollector=new chunkHG4NPDN5_cjs.b,this.diagnosticPipeline.register(this.timelineCollector)):this.diagnosticPipeline=new chunkHG4NPDN5_cjs.a,this.normalizer=new chunkGBCN7FNV_cjs.c;for(let[a,l]of Object.entries(chunk77KI7AKJ_cjs.c))this.normalizer.addPhrase(a,l);this.normalizer.register(chunkGBCN7FNV_cjs.d(50,a=>this.normalizer.canStartPhrase(a))),this.normalizer.register(Gt(this.userUnits)),this.normalizer.register(Xt(this.callFusions));let o=s??[];for(let a of o)try{this.registerPackage(a);}catch(l){let c=chunkYBQPEWT7_cjs.d(l);console.error(`[ExpressionEngine] Failed to register package "${a.name}" \u2014 skipping it and continuing construction with the remaining packages: ${c.format()}`);}this.registry.hasPrefix("DATETIME_LITERAL")&&this.normalizer.register(chunkRAPEZR5L_cjs.h(()=>this.config.date.inputOrder)),this.parser=new chunkVMSCRVNX_cjs.a(this.registry,this.config.validation.maxNestingDepth,t,this.pluginFunctionIndexByName),this.vm=chunkJSM3O7EM_cjs.c(this.context.opRegistry,this.config.vm.maxStackDepth,this.config.vm.maxInstructions,void 0,this.config.vm.maxCollectionSize,this.config.vm.maxAllocatedElements,this.config.vm.maxFunctionCalls,this.config.date.maxOffsetYears,this.config.date.minOffsetYears,this.context,Wt(this.config.date.holidays)),this.queryClient=chunkZLRJ7TDP_cjs.c(),this.batcher=new Te(this.dag,this.lineCache,this.vm),this.backgroundRefresh=this.config.backgroundRefresh.enabled?new xe(this.dag,(a,l)=>this.batcher.add({queryKey:l,packageId:a,signal:this.backgroundRefreshSignal,isError:false})):null,e.warmup===true&&this.warmUp();}setDocumentModel(e){this.documentModel=e;}getDocumentModel(){return this.documentModel}warmUp(){let e=new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName);for(let t of X.WARMUP_EXPRESSIONS)try{this.lexer.resetExpression(t);let n=[];for(let o of this.lexer)o.type!=="COMMENT"&&n.push(o);let i=this.normalizer.normalize(n);e.reset(),this.parser.load(i),this.parser.parseExpression(0,e);let s=e.build();this.vm.reset(),chunkJSM3O7EM_cjs.d(s,this.vm);}catch{}this.vm.reset();}makeLineContext(e){let t=this.documentModel,n=t?null:this.batchScanResults,i=t?null:this.batchParsedLines;return {lineIndex:e,getLineResult:t?s=>t.getLineAt(s)?.result??void 0:i?s=>i[s-1]?.result??void 0:void 0,isLineBoundary:t?s=>{let o=t.getLineAt(s);return o?o.isEmpty||/^\s*#/.test(o.text):true}:n?s=>{let o=n[s-1];return o?o.classification.skip||/^\s*#/.test(o.text):true}:void 0,getLineReads:t?s=>{let o=t.getLineAt(s);if(!(!o||o.bytecodes.length===0))return o.reads}:void 0,evaluateLineWithBinding:t?(s,o,a,l)=>this.evaluateLineWithBinding(s,o,a,l):void 0,goalSeekMaxIterations:this.config.vm.maxGoalSeekIterations,networkEnabled:this.config.network.enabled,getLineText:t?s=>t.getLineAt(s)?.text:n?s=>n[s-1]?.text:void 0}}evaluateLineWithBinding(e,t,n,i){let s=this.documentModel;if(!s)return chunkSQHBOWES_cjs.P("GOAL_SEEK_NO_DOCUMENT","Goal seek needs a document to solve against, which the single-expression entry point does not have.");if(this.goalSeekDepth>=X.GOAL_SEEK_MAX_NESTING_DEPTH)return chunkSQHBOWES_cjs.P("GOAL_SEEK_NESTED","A goal-seek line cannot target another goal-seek line, since each already re-runs its target many times.");let o=s.getLineAt(e);if(!o||o.bytecodes.length===0)return chunkSQHBOWES_cjs.P("GOAL_SEEK_LINE_NOT_READY",`Line ${e} has no evaluated expression to solve (forward reference, out of range, or not an expression).`);if(o.isVariableDef)return chunkSQHBOWES_cjs.P("GOAL_SEEK_TARGET_IS_DEFINITION",`Line ${e} defines a variable, so re-running it would overwrite that variable. Target the line that uses ${t}, not the one that sets a value.`);let a=o.bytecodes[0];this.goalSeekDepth++;try{let l=new Map([[t,n]]),c=this.vm.getStack().length;this.vm.pushCallFrame(l);try{let u=chunkJSM3O7EM_cjs.d(a,this.vm,void 0,void 0,this.makeLineContext(e),i);return u.type==="pending"?chunkSQHBOWES_cjs.P("GOAL_SEEK_ASYNC_UNSUPPORTED",`Line ${e} depends on an async value (weather, stocks, currency, ...), which goal seek cannot re-run.`):u.type==="error"?chunkSQHBOWES_cjs.P(u.error.code??"GOAL_SEEK_TARGET_ERROR",u.error.message):u.value}finally{for(this.vm.popCallFrame();this.vm.getStack().length>c;)this.vm.pop();}}catch(l){return chunkSQHBOWES_cjs.P("GOAL_SEEK_TARGET_ERROR",chunkYBQPEWT7_cjs.d(l).message)}finally{this.goalSeekDepth--;}}frontHalfCached(e){return this.compiledFrontHalf.has(e)&&this.bytecodeCache.has(e)||this.failedParses.has(e)}clearCompiledCache(){this.bytecodeCache.clear(),this.compiledFrontHalf.clear(),this.failedParses.clear();}cacheBytecode(e,t,n){let i=this.config.performance.defaultCacheSize;if(this.bytecodeCache.size>=i){let s=this.bytecodeCache.keys().next().value;s!==void 0&&(this.bytecodeCache.delete(s),this.compiledFrontHalf.delete(s));}this.bytecodeCache.set(e,t),this.compiledFrontHalf.set(e,n);}rememberFailedParse(e,t){if(this.failedParses.size>=this.config.performance.defaultCacheSize){let n=this.failedParses.keys().next().value;n!==void 0&&this.failedParses.delete(n);}this.failedParses.set(e,t);}getEventStream(){return this.batcher.getEventStream()}getBatcher(){return this.batcher}registerPackage(e){Bt(e),this.packageContributions.has(e.name)&&(console.warn(`[ExpressionEngine] Package "${e.name}" is already registered. Unregistering the previous registration before re-registering.`),this.unregisterPackage(e.name));let t=this.compatIndex.check(e);for(let i of t)(i.severity==="error"?console.error:console.warn)(`[ExpressionEngine] Package compatibility ${i.severity} (${i.kind}): ${i.detail}`);let n={pluginFunctionIndices:[],pluginFunctionNames:[],resolverNamespaces:[],tokenCategories:[],lexerVocabulary:e.lexerVocabulary,asConverterNames:[],normalizerRuleNames:[],callFusionNames:[]};if(e.lexerVocabulary&&this.lexer.registerVocabulary(e.lexerVocabulary),e.prefixParselets)for(let[i,s]of Object.entries(e.prefixParselets))this.registry.registerPrefix(i,s);if(e.infixParselets)for(let[i,s]of Object.entries(e.infixParselets))this.registry.registerInfix(i,s);if(e.pluginFunctions)for(let[i,s]of Object.entries(e.pluginFunctions)){let o=chunk634ILVMP_cjs.F(`${e.name}:${i}`);this.context.pluginFunctions[o]=s,this.context.pluginFunctionOwners[o]=e.name,this.pluginFunctionIndexByName.set(i,o),n.pluginFunctionIndices.push(o),n.pluginFunctionNames.push(i);}if(e.asyncResolvers)for(let i of e.asyncResolvers)this.resolverRegistry.register(i),n.resolverNamespaces.push(i.namespace);if(e.phrases)for(let[i,s]of Object.entries(e.phrases))this.normalizer.addPhrase(i,s);if(e.normalizerRules)for(let i of e.normalizerRules)this.normalizer.register(i),n.normalizerRuleNames.push(i.name);if(e.callFusions)for(let[i,s]of Object.entries(e.callFusions)){let o=i.toLowerCase(),a=this.callFusionOwners.get(o);a?a.push({pkg:e.name,tokenType:s}):this.callFusionOwners.set(o,[{pkg:e.name,tokenType:s}]),this.callFusions.set(o,s),n.callFusionNames.push(o);}if(e.tokenCategories)for(let[i,s]of Object.entries(e.tokenCategories))chunkY7O4D3BJ_cjs.b(i,s),n.tokenCategories.push(i);if(e.completionItems&&this.packageCompletionItems.set(e.name,e.completionItems),e.asConverters)for(let[i,s]of Object.entries(e.asConverters))chunk634ILVMP_cjs.H(i,s),n.asConverterNames.push(i);this.packageContributions.set(e.name,n),this.registeredPackages.set(e.name,e),this.compatIndex.add(e),this.clearCompiledCache();}unregisterPackage(e){let t=this.packageContributions.get(e);if(!t)return false;for(let n of t.pluginFunctionIndices)delete this.context.pluginFunctions[n],delete this.context.pluginFunctionOwners[n];for(let n of t.pluginFunctionNames)this.pluginFunctionIndexByName.delete(n);for(let n of t.resolverNamespaces)this.resolverRegistry.unregister(n);for(let n of t.tokenCategories)chunkY7O4D3BJ_cjs.c(n);t.lexerVocabulary&&this.lexer.unregisterVocabulary(t.lexerVocabulary);for(let n of t.asConverterNames)chunk634ILVMP_cjs.I(n);for(let n of t.normalizerRuleNames)this.normalizer.unregister(n);for(let n of t.callFusionNames){let i=(this.callFusionOwners.get(n)??[]).filter(s=>s.pkg!==e);i.length===0?(this.callFusionOwners.delete(n),this.callFusions.delete(n)):(this.callFusionOwners.set(n,i),this.callFusions.set(n,i[i.length-1].tokenType));}return this.packageCompletionItems.delete(e),this.packageContributions.delete(e),this.registeredPackages.delete(e),this.compatIndex.rebuild(this.registeredPackages.values()),this.clearCompiledCache(),true}getConfig(){return {...this.config}}getDiagnosticPipeline(){return this.diagnosticPipeline}storeLineResult(e,t,n,i,s,o){this.lineCache.set(e,new K(t,n,i,s.length>0?s[0]:null),o);}executeAndStore(e,t,n,i,s,o,a,l){let c=this.vm.getStack().length,u=new AbortController,p=()=>u.abort();this.keystrokeSignal?.addEventListener("abort",p,{once:true}),chunkTTFO4YDP_cjs.a.localControllerCreated("executeAndStore"),this.keystrokeSignal&&chunkTTFO4YDP_cjs.a.signalLinked("executeAndStore"),this.vm.activeSignal=u.signal,this.vm.abortCurrent=()=>{chunkTTFO4YDP_cjs.a.signalUnlinked("executeAndStore"),this.keystrokeSignal?.removeEventListener("abort",p),u.abort();},chunkZLRJ7TDP_cjs.a(this.queryClient);let m=chunkJSM3O7EM_cjs.d(e,this.vm,a,l,this.makeLineContext(t));for(;this.vm.getStack().length>c;)this.vm.pop();if(m.type==="pending"){this.resolveAsync(m),this.dag.registerLineDataSourceDependency(t,m.packageId||o,[m.queryKey]);let y=chunkSQHBOWES_cjs.O(m.queryKey);return this.storeLineResult(t,y,e,i,s,n),y}if(m.type==="error")throw this.keystrokeSignal?.removeEventListener("abort",p),m.error;return this.keystrokeSignal?.removeEventListener("abort",p),this.dag.registerLine(t,i,s),this.storeLineResult(t,m.value,e,i,s,n),m.value}executeRaw(e,t=-1){let n=this.vm.getStack().length,i=new AbortController,s=()=>i.abort();this.keystrokeSignal?.addEventListener("abort",s,{once:true}),chunkTTFO4YDP_cjs.a.localControllerCreated("executeRaw"),this.keystrokeSignal&&chunkTTFO4YDP_cjs.a.signalLinked("executeRaw"),this.vm.activeSignal=i.signal,this.vm.abortCurrent=()=>{chunkTTFO4YDP_cjs.a.signalUnlinked("executeRaw"),this.keystrokeSignal?.removeEventListener("abort",s),i.abort();},chunkZLRJ7TDP_cjs.a(this.queryClient);let o=chunkJSM3O7EM_cjs.d(e,this.vm,void 0,void 0,this.makeLineContext(t));for(;this.vm.getStack().length>n;)this.vm.pop();return o.type!=="pending"&&this.keystrokeSignal?.removeEventListener("abort",s),o}async resolveAsync(e){let{queryKey:t,resolver:n,packageId:i,signal:s}=e,o=i||"_engine";try{if(await n,s.aborted){chunkTTFO4YDP_cjs.a.staleDataDiscarded(t,"signal aborted after resolve");return}this.batcher.add({queryKey:t,packageId:o,signal:s,isError:!1});}catch(a){if(s.aborted){chunkTTFO4YDP_cjs.a.staleDataDiscarded(t,"signal aborted after error");return}let l=a instanceof Error?a:new Error(String(a));this.batcher.add({queryKey:t,packageId:o,signal:s,isError:true,error:l});}}registerBackgroundRefresh(e){this.backgroundRefresh&&(e.refetchIntervalMs===void 0||!e.refetch||this.backgroundRefresh.register({packageId:e.packageId||"_engine",queryKey:e.queryKey,intervalMs:e.refetchIntervalMs,refetch:e.refetch}));}getBackgroundRefreshCount(){return this.backgroundRefresh?.size??0}parseDocument(e,t={inputType:"markdown"}){let n=this.config.performance.maxDocumentLines;if(chunkUURM7P3P_cjs.b(e,n)>n)throw chunkYBQPEWT7_cjs.c.execution("DOCUMENT_TOO_LARGE",`This document has more than ${n.toLocaleString("en-US")} lines, which is the most the engine will process in one pass`,{maxLines:n});this.userUnits.isEmpty||this.clearCompiledCache(),this.userUnits.clear(),this.resetAccumulators();let i=this.lexer.scanDocument(e),s=this.processScanResults(i),o={lines:s,totalLines:s.length,errors:[]};for(let l of s){l.error&&o.errors.push(`Line ${l.lineNumber}: ${l.error}`);for(let c of l.inlineSolves)c.error&&o.errors.push(`Line ${l.lineNumber}: ${c.error}`);}if(t.includeDiagnostics??false){let l=this.diagnosticPipeline.collectReports();l.length>0&&(o.diagnostics=l[0].toJSON());}return o}evaluateLines(e){this.userUnits.isEmpty||this.clearCompiledCache(),this.userUnits.clear(),this.resetAccumulators();let t=e.join(`
|
|
4
|
+
`),n=this.lexer.scanDocument(t);return this.processScanResults(n)}processScanResults(e){let t=[],n=this.batchScanResults,i=this.batchParsedLines;this.batchScanResults=e,this.batchParsedLines=t;try{for(let s of e){let o=s.text,a=s.lineNumber,l=s.startOffset,c=s.endOffset,u=s.classification.skip,p=s.inlineSolves.map(f=>({start:f.start,end:f.end,expression:f.expression,lineNumber:a,columnNumber:f.columnNumber})),m=p.length>0,y={lineNumber:a,text:o,startPosition:l,endPosition:c,isEmpty:u,hasInlineSolves:m,inlineSolves:p,expression:null,result:null,error:null};if(s.error)y.error=s.error.message;else if(!u){let f=o.trim().startsWith(":");if(m&&!f)for(let L of p)try{L.result=this.evaluateLine(a,L.expression);}catch(v){let N=v instanceof Error?v.message:String(v);L.error=N;}else {let L=s.classification.contentOffset,N=(L===void 0?o:o.slice(L-l)).trim();if(N)try{let O=this.evaluateLineWithPreTokenized(a,N,s.tokens);y.expression=N,y.result=O[0];}catch(O){let q=O instanceof Error?O.message:String(O);y.error=q;}}}t.push(y);}}finally{this.batchScanResults=n,this.batchParsedLines=i;}return t}evaluateLineWithPreTokenized(e,t,n){let i=[],s=false;for(let o of n)(o.type==="LPAREN"||o.type==="RPAREN")&&(s=true),i.push(o);return [this.evaluateWithTokens(e,t,i,s)]}parseExpression(e,t,n,i=true){this.parser.setBuilder(e),this.parser.load(t,this.config.validation.autoBalanceParens?n:false),this.parser.parseExpression(0);let s=this.parser.peek();if(s){if(s.type==="EQUALS"&&!this.parser.peekAt(1))return;for(let o=i?t.length-1:0;o>=1;o--){if(t[o].type!=="COLON"||o+1>=t.length)continue;let a=true;for(let l=0;l<o;l++){let c=t[l].type;if(c!=="NUMBER"&&c!=="COLON"){a=false;break}}if(a){let l=t.slice(0,o+2).map(c=>c.value).join("");throw chunkYBQPEWT7_cjs.c.parsing("INVALID_TIME_LITERAL",`"${l}" is not a valid time`,{tokenType:t[o].type,tokenValue:l})}e.reset();try{this.parseExpression(e,t.slice(o+1),n,!1);return}catch{}}throw chunkYBQPEWT7_cjs.c.parsing({code:"UNEXPECTED_TRAILING_TOKEN",message:`Unexpected token after expression: "${s.value}"`,context:{tokenType:s.type,tokenValue:s.value},span:{start:s.offset,end:s.sourceEnd??s.offset+s.text.length,line:s.line,col:s.col}})}}compileAdHoc(e){let t=new chunkFYTB7SDP_cjs.d(this.pluginFunctionIndexByName);return this.parseExpression(t,e),t.build()}executeSymbolicTolerant(e,t=-1){let n=chunkJSM3O7EM_cjs.d(e,this.vm,void 0,void 0,this.makeLineContext(t),true);if(n.type==="error")throw n.error;if(n.type==="pending")throw chunkYBQPEWT7_cjs.c.execution("THEREFORE_ASYNC_UNSUPPORTED",`"=>" doesn't support expressions that call an async operation (weather/stocks/currency).`);return n.value}simplifySymbolically(e,t=-1){return this.executeSymbolicTolerant(this.compileAdHoc(e),t)}parseFactorChain(e){if(e.length===0||e.length%2===0)return null;let t=[];for(let n=0;n<e.length;n++)if(n%2===0){if(e[n].type!=="IDENT"&&e[n].type!=="UNIT")return null;t.push(e[n].value);}else if(e[n].type!=="STAR")return null;return t}solveEquation(e,t=-1){let n=[];for(let a of e.factorNames){let l=this.vm.getVar(a);if(l===void 0)return chunkSQHBOWES_cjs.P("EQUATION_FACTOR_UNDEFINED",`Cannot solve for "${e.variable}": "${a}" is not yet defined.`);if(l.type!==7)return chunkSQHBOWES_cjs.P("EQUATION_FACTOR_NOT_MATRIX",`Cannot solve for "${e.variable}": "${a}" must be a Matrix (got a different value type).`);n.push(l);}let i=n[0].value;for(let a=1;a<n.length;a++){let l=chunkWGP4UUO5_cjs._(i,n[a].value);if(l.type===13)return l;i=l.value;}let s=chunkWGP4UUO5_cjs.da(i);if(s.type===13)return s;let o=this.executeSymbolicTolerant(e.rhsProgram,t);return o.type!==7?chunkSQHBOWES_cjs.P("EQUATION_RHS_NOT_MATRIX",`Cannot solve for "${e.variable}": the right-hand side must be a Matrix.`):chunkWGP4UUO5_cjs._(s.value,o.value)}tryDefineUserUnit(e){if(e.length<5||e[0].type!=="NUMBER"||Number(e[0].value)!==1)return null;let t=1;e[t].type==="STAR"&&t++;let n=[];for(;t<e.length&&e[t].type==="IDENT";)n.push(e[t].value),t++;if(n.length===0||e[t]?.type!=="EQUALS"||(t++,e[t]?.type!=="NUMBER"))return null;let i=e[t];if(t++,e[t]?.type!=="UNIT")return null;let s=e[t];return t++,t!==e.length?null:(this.userUnits.define(n,i.value,s.value),this.clearCompiledCache(),chunkSQHBOWES_cjs.t(`${n.join(" ")} defined`))}tryCompoundAssignment(e,t=-1){if(e.length<2)return null;let n=e[0],i=e[1],s=n.type==="IDENT"||n.type==="UNIT",o=i.type==="PLUS_EQUALS"||i.type==="MINUS_EQUALS";if(!s||!o)return null;let a=e.slice(2);if(a.length===0)throw chunkYBQPEWT7_cjs.c.parsing("COMPOUND_ASSIGN_REQUIRES_EXPRESSION",`"${n.value} ${i.value}" needs an expression on the right, e.g. "${n.value} ${i.value} 10".`);let l=n.value;this.accumulatorNames.add(l),this.vm.getVar(l)===void 0&&this.vm.setVar(l,chunkSQHBOWES_cjs.n(0));let c=i.type==="PLUS_EQUALS"?{type:"PLUS",text:"+"}:{type:"MINUS",text:"-"},u=[chunkGBCN7FNV_cjs.b("IDENT",l,[n]),chunkGBCN7FNV_cjs.b(c.type,c.text,[i]),chunkGBCN7FNV_cjs.b("LPAREN","(",[i]),...a,chunkGBCN7FNV_cjs.b("RPAREN",")",[i])],p=chunkJSM3O7EM_cjs.d(this.compileAdHoc(u),this.vm,void 0,void 0,this.makeLineContext(t),false);if(p.type==="error")throw p.error;if(p.type==="pending")throw chunkYBQPEWT7_cjs.c.execution("COMPOUND_ASSIGN_ASYNC_UNSUPPORTED","A running total (+= / -=) cannot use an async operation (weather/stocks/currency) on its right-hand side.");return this.vm.setVar(l,p.value),p.value}resetAccumulators(){for(let e of this.accumulatorNames)this.vm.deleteVar(e);return this.accumulatorNames}trySymbolicGrammar(e,t=-1){if(e.length===0)return null;if(e[e.length-1].type==="THEREFORE"){let c=e.slice(0,-1);if(c.length===0)throw chunkYBQPEWT7_cjs.c.parsing("THEREFORE_REQUIRES_EXPRESSION",'"=>" needs an expression or variable name before it.');if(c.length===1&&(c[0].type==="IDENT"||c[0].type==="UNIT")){let u=c[0].value,p=this.vm.getEquation(u),m=this.vm.getScalarEquation(u);if(p){let y=this.solveEquation(p,t);if(!(y.type===13&&y.value==="EQUATION_FACTOR_NOT_MATRIX")||!m)return y}if(m)return this.solveScalarEquation(m,t)}return this.simplifySymbolically(c,t)}if(chunkRAPEZR5L_cjs.b(e))return this.simplifySymbolically(e,t);if(e[0].type==="COLON"||e[0].type==="GLOBAL"||e[0].type==="GOAL_SEEK")return null;let i=e.findIndex(c=>c.type==="EQUALS");if(i===-1)return null;let s=this.parseFactorChain(e.slice(0,i));if(s===null)return this.tryStoreScalarEquation(e,i);let o=e.slice(i+1);if(s.length===1){let c=this.simplifySymbolically(o,t);return this.vm.setVar(s[0],c),c}let a=s[s.length-1],l=s.slice(0,-1);return this.vm.defineEquation(a,l,this.compileAdHoc(o)),this.vm.defineScalarEquation(a,this.compileAdHoc(e.slice(0,i)),this.compileAdHoc(o)),chunkSQHBOWES_cjs.t(`${a} stored as an equation \u2014 solve with "${a} =>"`)}tryStoreScalarEquation(e,t){if(e[1]?.type==="LPAREN"||t===0||t===e.length-1)return null;let n=e.slice(0,t),i=e.slice(t+1);if(i.some(a=>a.type==="EQUALS"))return null;let s=this.equationUnknowns(n,i);if(s.length!==1)return null;let o=s[0];return this.vm.defineScalarEquation(o,this.compileAdHoc(n),this.compileAdHoc(i)),chunkSQHBOWES_cjs.t(`${o} stored as an equation \u2014 solve with "${o} =>"`)}equationUnknowns(e,t){let n=[];for(let i of [...e,...t])i.type!=="IDENT"&&i.type!=="UNIT"||this.vm.getVar(i.value)===void 0&&(this.vm.hasUserFunction(i.value)||n.includes(i.value)||n.push(i.value));return n}solveScalarEquation(e,t=-1){let n=this.executeSymbolicTolerant(e.lhsProgram,t),i=this.executeSymbolicTolerant(e.rhsProgram,t);return chunk634ILVMP_cjs.i(n,i,e.variable)}lexToTokens(e,t,n=true){let i=[],s=false;if(n&&!t&&this.frontHalfCached(e))return {tokens:i,hasParens:s,compiled:true};this.lexer.resetExpression(e);for(let o of this.lexer)o.type!=="COMMENT"&&((o.type==="LPAREN"||o.type==="RPAREN")&&(s=true),i.push(o),t?.(o));return {tokens:i,hasParens:s,compiled:false}}prepareExpression(e,t,n,i,s=-1){let o=this.bytecodeCache.get(e);if(o&&!i){let v=this.compiledFrontHalf.get(e);if(v)return {kind:"ready",normalizedTokens:v.normalizedTokens,reads:v.reads,writes:v.writes,program:o,cached:true}}let a=i?void 0:this.failedParses.get(e),l;if(a)l=a.normalizedTokens;else {let v=$e(e,this.config.validation);if(!v.passed)return {kind:"error",stage:"length",error:v.error.engineError};let N=t.filter(q=>q.type!=="COMMENT");if(N.length===0)return {kind:"empty"};l=this.normalizer.normalize(N,i);let O=ze(l,this.config.validation);if(!O.passed)return {kind:"error",stage:"complexity",error:O.engineError,normalizedTokens:l}}let c,u=null;try{if(c=this.tryDefineUserUnit(l),c===null){let v=this.tryCompoundAssignment(l,s);v!==null&&(c=v,u=Se(l));}c===null&&(c=this.trySymbolicGrammar(l,s));}catch(v){let{reads:N,writes:O}=Se(l);return {kind:"error",stage:"parse",error:chunkYBQPEWT7_cjs.d(v),reads:N,writes:O,normalizedTokens:l}}if(c!==null)return {kind:"symbolic-solve",normalizedTokens:l,value:c,reads:u?.reads,writes:u?.writes};if(a)return {kind:"error",stage:"parse",error:a.error,reads:a.reads,writes:a.writes,normalizedTokens:l};let{reads:p,writes:m}=Se(l);if(o)return this.compiledFrontHalf.set(e,{normalizedTokens:l,reads:p,writes:m}),{kind:"ready",normalizedTokens:l,reads:p,writes:m,program:o,cached:true};let y=this.builderPool[this.builderPoolIndex++%this.builderPool.length];y.reset();let f,L=null;try{let v=F.track("parser",()=>(this.parseExpression(y,l,n),y.build()));f=v.result,L=v.alloc;}catch(v){let N=chunkYBQPEWT7_cjs.d(v);return this.rememberFailedParse(e,{error:N,normalizedTokens:l,reads:p,writes:m}),{kind:"error",stage:"parse",error:N,reads:p,writes:m,normalizedTokens:l}}return this.cacheBytecode(e,f,{normalizedTokens:l,reads:p,writes:m}),{kind:"ready",normalizedTokens:l,reads:p,writes:m,program:f,cached:false,parserAlloc:L}}preflightAsync(e,t,n,i,s,o){if(!(t.hasAsync||this.resolverRegistry.size>0))return {kind:"proceed"};let a=new AbortController,l=()=>a.abort();this.keystrokeSignal?.addEventListener("abort",l,{once:true}),chunkTTFO4YDP_cjs.a.localControllerCreated("preflightAsync"),this.keystrokeSignal&&chunkTTFO4YDP_cjs.a.signalLinked("preflightAsync");let c=a.signal,u=this.resolverRegistry.preflightAll(e,t,"_engine",c,this.queryClient,this.config.network.enabled);if(u){this.resolveAsync({type:"pending",queryKey:u.queryKey,resolver:u.resolver,packageId:u.packageId||"_engine",signal:u.signal}),this.dag.registerLineDataSourceDependency(n,u.packageId||"_engine",[u.queryKey]),this.registerBackgroundRefresh(u);let p=chunkSQHBOWES_cjs.O(u.queryKey);return this.storeLineResult(n,p,t,s,o,i),{kind:"pending",value:p}}return this.keystrokeSignal?.removeEventListener("abort",l),{kind:"proceed"}}evaluateWithTokens(e,t,n,i){let s=this.prepareExpression(t,n,i,void 0,e);if(s.kind==="empty"){let p=chunkSQHBOWES_cjs.n(0);return this.lineCache.set(e,new K(p,{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},[],null),t),p}if(s.kind==="error")throw s.error;if(s.kind==="symbolic-solve")return this.storeLineResult(e,s.value,{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},s.reads??[],s.writes??[],t),s.value;let{normalizedTokens:o,reads:a,writes:l,program:c}=s,u=this.preflightAsync(o,c,e,t,a,l);return u.kind==="pending"?u.value:this.executeAndStore(c,e,t,a,l,"_engine")}evaluateLine(e,t){let n=this.evaluateLineWithDebug(e,t);if(n.error)throw n.engineError?n.engineError:chunkYBQPEWT7_cjs.c.execution("EVALUATION_ERROR",n.error,{lineNumber:e});return chunkSQHBOWES_cjs.l(n.value)}evaluateLineWithDebug(e,t,n="expression"){let i=t.match(/^s`([^`]*)`$/);if(i){let s=i[1];return {...this.evaluateExpressionWithDiagnostic(s,e,n),inlineSolve:{start:0,end:t.length,expression:s,lineNumber:e,columnNumber:1}}}return this.evaluateExpressionWithDiagnostic(t,e,n)}addDiagnosticStage(e,t,n,i,s,o,a,l,c){e.push({stage:t,label:n,icon:i,colorClass:s,stepNumber:o,elapsedNs:a,skipped:l,output:c});}evaluateExpressionWithDiagnostic(e,t,n="expression"){let i=this.diagnosticPipeline,s=i.hasCollectors,o=this.timelineCollector?.parseletMatchCount??0,a=F.isEnabled(),l=[],c=[],u=0,p=$e(e,this.config.validation);if(!p.passed)return s&&this.addDiagnosticStage(c,"safety_length","Safety: Length","\u{1F6E1}\uFE0F","validate",2,u,false,{type:"safety_length",passed:false,expressionLength:e.length,maxLength:this.config.validation.maxExpressionLength,errorMessage:p.error.error}),{...p.error,debug:void 0,diagnostic:void 0};s&&(i.firePipelineStart({type:chunkHG4NPDN5_cjs.c.PipelineStart,elapsedNs:0,expression:e,inputType:n}),this.addDiagnosticStage(c,"pipeline_start","Pipeline Start","\u25B6","pipeline",1,u,false,{type:"pipeline_start",expression:e,inputType:n}),this.addDiagnosticStage(c,"safety_length","Safety: Length","\u{1F6E1}\uFE0F","validate",2,u,false,{type:"safety_length",passed:true,expressionLength:e.length,maxLength:this.config.validation.maxExpressionLength}));let m=s?h=>{i.fireTokenEmitted({type:chunkHG4NPDN5_cjs.c.TokenEmitted,elapsedNs:0,expression:e,token:{type:h.type,value:h.value,offset:h.offset||0,line:h.line||t,col:h.col||0}});}:void 0,y=F.track("lexer",()=>this.lexToTokens(e,m)),f=y.result.tokens,L=y.result.hasParens,v=y.result.compiled;if(a&&y.alloc&&l.push(y.alloc),s){let h={};for(let P of f)h[P.type]=(h[P.type]||0)+1;this.addDiagnosticStage(c,"lexer","Lexer","\u{1F524}","lexer",3,u,false,{type:"lexer",tokenCount:f.length,tokenTypes:h,hasParens:L,locale:this.localeCode,tokens:[...f]});let R=[];for(let P=0;P<f.length;P++){let oe=f[P];if(oe.type==="INLINE_SOLVE_START"){let D=-1;for(let j=P+1;j<f.length;j++)if(f[j].type==="BACKTICK_OPEN"){D=j;break}if(D>P){let ir=f.slice(P+1,D).map(sr=>sr.value).join("");R.push({startTokenIndex:P,endTokenIndex:D,expression:ir,columnNumber:oe.col||1}),P=D;}}}this.addDiagnosticStage(c,"line_classification","Line Classification","\u{1F4CB}","classify",3.5,u,false,{type:"line_classification",classification:"expression",skip:false,hasInlineSolve:R.length>0,inlineSolveSpans:R});}if(!v&&f.length===0){let h=chunkSQHBOWES_cjs.n(0);return this.lineCache.set(t,new K(h,{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},[],null),e),s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:true,totalTokens:0,totalOpcodes:0}),{value:h,tokens:f,program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},debug:void 0,diagnostic:void 0}}let N=0,O=[],q=new Map,tr=s?h=>{N++,O.push(h),q.set(h.rule,(q.get(h.rule)||0)+1),i.fireTokenFused({type:chunkHG4NPDN5_cjs.c.TokenFused,elapsedNs:0,expression:e,ruleName:h.rule,sourceTokenCount:h.sourceTokens.length,fusedTokenType:h.fusedToken.type,fusedTokenValue:h.fusedToken.value});}:void 0;s&&this.normalizer.ruleCount>0&&i.fireNormalizerStart({type:chunkHG4NPDN5_cjs.c.NormalizerStart,elapsedNs:0,expression:e,inputTokenCount:f.length});let V=this.bytecodeCache.get(e);s&&!V&&this.parser.setDiagnosticPipeline(i,e);let b=this.prepareExpression(e,f,L,tr,t);v&&b.kind==="ready"&&(f=b.normalizedTokens),a&&b.kind==="ready"&&b.parserAlloc&&l.push(b.parserAlloc),s&&!V&&this.parser.setDiagnosticPipeline(void 0,"");let x=b.kind==="empty"?f:b.normalizedTokens??f;if(s&&(this.normalizer.ruleCount>0?(i.fireNormalizerEnd({type:chunkHG4NPDN5_cjs.c.NormalizerEnd,elapsedNs:0,expression:e,outputTokenCount:x.length,fusionsCount:N}),this.addDiagnosticStage(c,"normalizer","Normalizer","\u{1F504}","normalizer",4,u,false,{type:"normalizer",inputTokenCount:f.length,outputTokenCount:x.length,fusions:O,rulesApplied:[...q.entries()].map(([h,R])=>({rule:h,count:R})),tokens:[...x],phrases:this.normalizer.getPhrases(),ruleShapes:this.normalizer.getRuleShapes(),candidatesPerPosition:this.normalizer.getCandidateCounts(x)})):this.addDiagnosticStage(c,"normalizer","Normalizer","\u{1F504}","normalizer",4,u,true,{type:"normalizer",inputTokenCount:f.length,outputTokenCount:f.length,fusions:[],rulesApplied:[],tokens:[...f],phrases:this.normalizer.getPhrases(),ruleShapes:this.normalizer.getRuleShapes(),candidatesPerPosition:this.normalizer.getCandidateCounts(f)})),b.kind==="empty"||b.kind==="error"&&b.stage==="length"){if(s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:b.kind==="empty",totalTokens:f.length,totalOpcodes:0}),b.kind==="empty"){let h=chunkSQHBOWES_cjs.n(0);return this.lineCache.set(t,new K(h,{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},[],null),e),{value:h,tokens:f,program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},debug:void 0,diagnostic:void 0}}return {value:chunkSQHBOWES_cjs.n(0),tokens:[],program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},error:b.error.message,engineError:b.error,debug:void 0,diagnostic:void 0}}let ne=ze(x,this.config.validation);if(b.kind==="error"&&b.stage==="complexity")return s&&(this.addDiagnosticStage(c,"safety_complexity","Safety: Complexity","\u{1F6E1}\uFE0F","validate",5,u,false,{type:"safety_complexity",passed:false,complexityScore:ne.complexityScore??0,maxComplexity:this.config.validation.maxComplexity,breakdown:{tokenCount:x.length,functionCalls:0,nestingDepth:0},errorMessage:ne.errorMessage}),i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:false,totalTokens:f.length,totalOpcodes:0})),{value:chunkSQHBOWES_cjs.n(0),tokens:[],program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},error:ne.errorMessage,engineError:ne.engineError,debug:void 0,diagnostic:void 0};if(s&&this.addDiagnosticStage(c,"safety_complexity","Safety: Complexity","\u{1F6E1}\uFE0F","validate",5,u,false,{type:"safety_complexity",passed:true,complexityScore:ne.complexityScore??x.length,maxComplexity:this.config.validation.maxComplexity,breakdown:{tokenCount:x.length,functionCalls:0,nestingDepth:0}}),b.kind==="symbolic-solve"){s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:true,totalTokens:f.length,totalOpcodes:0});let h={opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false};return this.storeLineResult(t,b.value,h,b.reads??[],b.writes??[],e),{value:b.value,tokens:x,program:h,debug:void 0,diagnostic:void 0}}let ge=b.reads??[],ie=b.writes??[];if(s&&(this.addDiagnosticStage(c,"readwrite","Read/Write","\u{1F4CB}","readwrite",6,u,false,{type:"readwrite",reads:ge,writes:ie,isAssignment:ie.length>0}),this.addDiagnosticStage(c,"cache_check","Cache Check","\u{1F4BE}","cache",7,u,false,{type:"cache_check",hit:!!V,cacheSize:this.bytecodeCache.size,cacheKey:e}),V?i.fireCacheHit({type:chunkHG4NPDN5_cjs.c.CacheHit,elapsedNs:0,expression:e,cache:"bytecode",key:e}):i.fireCacheMiss({type:chunkHG4NPDN5_cjs.c.CacheMiss,elapsedNs:0,expression:e,cache:"bytecode",key:e})),b.kind==="error"&&b.stage==="parse")return s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:false,totalTokens:f.length,totalOpcodes:0}),{value:chunkSQHBOWES_cjs.n(0),tokens:x,program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},error:b.error.message,engineError:b.error,debug:void 0,diagnostic:void 0};if(b.kind!=="ready")throw chunkYBQPEWT7_cjs.c.internal({code:"UNEXPECTED_ERROR",message:"Internal error: prepareExpression() returned an unexpected variant after all other cases were handled"});let k=b.program;s&&(this.addDiagnosticStage(c,"parser","Parser","\u{1F333}","parser",8,u,!!V,{type:"parser",parselets:[],uniqueParseletTypes:[],astDepth:0}),this.addDiagnosticStage(c,"compiler","Compiler","\u2699\uFE0F","compiler",9,u,!!V,{type:"compiler",opcodeCount:k.opcodes.length,numberConstants:k.numbers.length,stringConstants:k.strings.length,hasAsync:k.hasAsync,cached:!!V}),i.fireBytecodeBuilt({type:chunkHG4NPDN5_cjs.c.BytecodeBuilt,elapsedNs:0,expression:e,opcodesLength:k.opcodes.length,numbersLength:k.numbers.length,stringsLength:k.strings.length,isCached:!!V}));let rr=k.hasAsync||this.resolverRegistry.size>0,se=this.preflightAsync(x,k,t,e,ge,ie);if(s&&(se.kind==="pending"?this.addDiagnosticStage(c,"async_preflight","Async Preflight","\u{1F52E}","async",10,u,false,{type:"async_preflight",path:"pending",pendingQueryKey:se.value.value,resolverCount:this.resolverRegistry.size,skippedGuard:true}):rr?this.addDiagnosticStage(c,"async_preflight","Async Preflight","\u{1F52E}","async",10,u,false,{type:"async_preflight",path:"sync",resolverCount:this.resolverRegistry.size,skippedGuard:false}):this.addDiagnosticStage(c,"async_preflight","Async Preflight","\u{1F52E}","async",10,u,true,{type:"async_preflight",path:"sync",resolverCount:0,skippedGuard:true})),se.kind==="pending")return s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:true,totalTokens:f.length,totalOpcodes:k.opcodes.length}),{value:se.value,tokens:x,program:k,debug:void 0,diagnostic:s?this.buildDiagnosticResult(c,se.value,x,k,null):void 0};let nr=s&&this.config.diagnostic.vmTraceEnabled===true,w;try{let h=F.track("vm",()=>this.executeAndStore(k,t,e,ge,ie,"_engine",nr?i:void 0,e),{cacheHit:!!V});w=h.result,a&&h.alloc&&l.push(h.alloc);}catch(h){let R=chunkYBQPEWT7_cjs.d(h);return s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:false,totalTokens:f.length,totalOpcodes:k.opcodes.length}),{value:chunkSQHBOWES_cjs.n(0),tokens:x,program:k,error:R.message,engineError:R,debug:void 0,diagnostic:void 0}}let de=w.type===12;if(s){let h=de?"pending":String(w.value??""),R=de?"Pending":w.unit?"Uom":"Number";this.addDiagnosticStage(c,"vm_execute","VM Execute","\u26A1","vm",11,u,false,{type:"vm_execute",totalInstructions:k.opcodes.length,stackDepth:this.vm.getStack().length,resultType:R,resultValue:h,isPending:de});}if(de)return s&&i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:true,totalTokens:f.length,totalOpcodes:k.opcodes.length}),{value:w,tokens:x,program:k,debug:void 0,diagnostic:s?this.buildDiagnosticResult(c,w,x,k,null):void 0};if(a&&l.length>0&&(this.lastTelemetry=F.createTelemetry(e,l,!!V)),s&&(this.addDiagnosticStage(c,"dag_registration","DAG Registration","\u{1F517}","dag",12,u,false,{type:"dag_registration",readsRegistered:ge,writesRegistered:ie,dataSourcesRegistered:[]}),this.addDiagnosticStage(c,"linecache","Line Cache","\u{1F4E6}","cache",13,u,false,{type:"linecache",lineNumber:t,expression:e,stored:true}),this.addDiagnosticStage(c,"result","Result","\u2713","result",14,u,false,{type:"result",rawValue:String(w.value),formattedValue:String(w.value),valueType:w.type===0?"Number":"Value",unit:w.unit}),i.fireVmHalt({type:chunkHG4NPDN5_cjs.c.VmHalt,elapsedNs:0,expression:e,result:w?{type:w.type,value:w.value,unit:w.unit}:void 0}),this.addDiagnosticStage(c,"pipeline_end","Pipeline End","\u23F9","pipeline",15,u,false,{type:"pipeline_end",success:true,totalTokens:f.length,totalOpcodes:k.opcodes.length,cacheHit:!!V}),i.firePipelineEnd({type:chunkHG4NPDN5_cjs.c.PipelineEnd,elapsedNs:0,expression:e,success:true,totalTokens:f.length,totalOpcodes:k.opcodes.length})),s){let R=i.collectReports()[0]?.toJSON(),P=R;if(R){let oe=R.parselets.slice(o),D={};for(let j of oe)D[j.parseletCategory]=(D[j.parseletCategory]??0)+1;P={...R,parselets:oe,summary:{...R.summary,totalParselets:Object.keys(D).length,parseCategories:D}};}return {value:w,tokens:x,program:k,debug:P,diagnostic:this.buildDiagnosticResult(c,w,x,k,null)}}return {value:w,tokens:x,program:k}}buildDiagnosticResult(e,t,n,i,s){return {stages:e,value:t,tokens:n,program:i,error:s,dagSnapshot:this.dag.getSnapshot(),cacheSnapshot:this.getCacheSnapshot(),batcherMetrics:this.getBatcherMetrics(),checkpoints:this.getCheckpoints()}}reEvaluateLine(e,t){let n=this.lineCache.get(e,t);if(!n)return;let i=this.bytecodeCache.get(t);if(!i)return;if(n.bytecode.hasAsync||this.resolverRegistry.size>0){let a=new AbortController,l=()=>a.abort();this.keystrokeSignal?.addEventListener("abort",l,{once:true}),chunkTTFO4YDP_cjs.a.localControllerCreated("reEvaluateLine preflight"),this.keystrokeSignal&&chunkTTFO4YDP_cjs.a.signalLinked("reEvaluateLine preflight");let c=a.signal,u=this.resolverRegistry.preflightAll([],n.bytecode,"_engine",c,this.queryClient,this.config.network.enabled);if(u)return this.resolveAsync({type:"pending",queryKey:u.queryKey,resolver:u.resolver,packageId:u.packageId||"_engine",signal:u.signal}),this.registerBackgroundRefresh(u),chunkSQHBOWES_cjs.O(u.queryKey);this.keystrokeSignal?.removeEventListener("abort",l);}let s=this.executeRaw(i,e);if(s.type==="pending")return this.resolveAsync(s),chunkSQHBOWES_cjs.O(s.queryKey);if(s.type==="error")throw s.error;let o=s.value;return n.result=o,o}getDag(){return this.dag}getLineCache(){return this.lineCache}getBytecodeCache(){return this.bytecodeCache}getVM(){return this.vm}getContext(){return this.context}getScopeManager(){return this.scopeManager}getLexer(){return this.lexer}getNormalizer(){return this.normalizer}getPackageCompletionItems(){let e=[];for(let t of this.packageCompletionItems.values())e.push(...t);return e}getParseletRegistry(){return {prefix:this.registry.getAllPrefix(),infix:this.registry.getAllInfix()}}tokenizeForClassification(e){this.lexer.resetExpression(e);let n=Array.from(this.lexer).filter(i=>i.type!=="COMMENT");return n.length===0?[]:this.normalizer.normalize(n)}getParser(){return this.parser}isDiagnosticMode(){return this.diagnosticPipeline.hasCollectors}setKeystrokeSignal(e){e?chunkTTFO4YDP_cjs.a.keystrokeSignalSet(e.aborted):chunkTTFO4YDP_cjs.a.keystrokeSignalCleared(),this.keystrokeSignal=e;}getCacheSnapshot(){let e=[];for(let[o,a]of this.bytecodeCache)e.push({expression:o,opcodesLength:a.opcodes.length,numbersLength:a.numbers.length,stringsLength:a.strings.length,hasAsync:a.hasAsync});let t=[];for(let o of this.lineCache.keys()){let a=o.indexOf(":"),l=a>0?parseInt(o.slice(0,a),10)||0:parseInt(o,10)||0,c=a>0?o.slice(a+1):void 0,u=c!==void 0?this.lineCache.get(l,c):this.lineCache.getEntryForLine(l);u&&t.push({key:o,lineNumber:l,resultType:String(u.result?.type??""),resultValue:String(u.result?.value??""),reads:u.readVariables??[],writeVar:u.writeVariable??null});}let s=this.queryClient.getQueryCache().getAll().map(o=>{let a=o.state.status==="success"?"resolved":o.state.status==="error"?"error":"in_flight";return {packageId:o.queryKey[0]??"unknown",resolvedCount:o.state.status==="success"?1:0,inFlightCount:o.state.status!=="success"&&o.state.status!=="error"?1:0,errorCount:o.state.status==="error"?1:0,entries:[{key:o.queryKey.join(":"),status:a}]}});return {bytecode:e,lineCache:t,asyncCache:s}}getBatcherMetrics(){return {pendingCount:this.batcher.pendingCount,dedupCount:this.batcher.dedupCount,workerOffloadCount:this.batcher.workerOffloadCount,listenerCount:this.batcher.listenerCount}}getCheckpoints(){let t=this.vm.checkpointer;return t?t.getAllCheckpoints().map(i=>({lineNumber:i.lineNumber,variables:Object.keys(i.variables),variableCount:Object.keys(i.variables).length})):[]}getLastTelemetry(){return this.lastTelemetry}evaluateExpression(e){return this.evaluateLine(-1,e)}explainLine(e){let{tokens:t}=this.lexToTokens(e,void 0,false),n=t.filter(s=>s.type!=="COMMENT"),i=this.normalizer.normalize(n);return We({expression:e,tokens:i,evaluate:s=>this.evaluateIsolated(s),locale:this.localeCode})}evaluateIsolated(e){let{tokens:t,hasParens:n}=this.lexToTokens(e),i=this.prepareExpression(e,t,n,void 0,-1);if(i.kind==="empty")return chunkSQHBOWES_cjs.n(0);if(i.kind==="error")throw i.error;if(i.kind==="symbolic-solve")return i.value;let s=this.executeRaw(i.program,-1);if(s.type==="error")throw s.error;if(s.type==="pending")throw chunkYBQPEWT7_cjs.c.execution("EXPLAIN_ASYNC_UNSUPPORTED",`A derivation cannot be built for a line that resolves data asynchronously: "${e}"`,{expression:e});return s.value}compileExpression(e){let t=this.lexToTokens(e),{hasParens:n}=t,i=this.prepareExpression(e,t.tokens,n),s=t.compiled&&i.kind==="ready"?i.normalizedTokens:t.tokens;if(i.kind==="empty")return {program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},tokens:[],reads:[],writes:[]};if(i.kind==="error")throw i.stage==="parse"&&(i.reads?.length||i.writes?.length)?new chunkYBQPEWT7_cjs.b(i.error.category,{code:i.error.code,message:i.error.message,expected:i.error.expected,found:i.error.found,suggestion:i.error.suggestion,recoverable:i.error.recoverable,span:i.error.span,cause:i.error.cause,context:{...i.error.context,reads:i.reads??[],writes:i.writes??[]}}):i.error;return i.kind==="symbolic-solve"?{program:{opcodes:new Uint8Array(0),numbers:new Float64Array(0),strings:[],hasAsync:false},tokens:i.normalizedTokens,reads:i.reads??[],writes:i.writes??[]}:{program:i.program,tokens:s,reads:i.reads,writes:i.writes}}tryCompileExpression(e){try{return this.tryCompileExpressionUnguarded(e)}catch{return false}}tryCompileExpressionUnguarded(e){let{tokens:t,hasParens:n}=this.lexToTokens(e);return this.prepareExpression(e,t,n).kind!=="error"}executeCached(e,t=-1){if(e.opcodes.length===0)return chunkSQHBOWES_cjs.n(0);let n=this.executeRaw(e,t);if(n.type==="pending")return this.resolveAsync(n),chunkSQHBOWES_cjs.O(n.queryKey);if(n.type==="error")throw n.error;return n.value}evaluateNumber(e){let t=e.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&this.vm.getVar(t)===void 0)return NaN;try{let n=this.evaluateLine(-1,e);return n.isFault()?NaN:n.toNumber()}catch{return NaN}}clear(){this.batcher.clearAll(),this.backgroundRefresh?.clearAll(),this.queryClient.clear(),chunkZLRJ7TDP_cjs.b()===this.queryClient&&chunkZLRJ7TDP_cjs.a(null),this.dag.clear(),this.lineCache.clear(),this.scopeManager.clear(),this.clearCompiledCache(),this.vm.reset(),this.userUnits.clear(),this.accumulatorNames.clear(),this.lastTelemetry=null;}toJSON(){let e=this.dag.getSnapshot(),t=new Set;for(let c of Object.keys(e.dataSourceDeps)){let u=Number(c);Number.isNaN(u)||t.add(u);}let n=this.lineCache.snapshotEntries(),i=new Map;for(let{line:c,entry:u}of n){let p=t.has(c)||u.bytecode.hasAsync;p&&t.add(c);let m=u.writeVariable;if(m){let y=i.get(m);(!y||c>=y.line)&&i.set(m,{line:c,async:p});}}let s={};for(let[c,u]of this.vm.getVariableEntries())if(u.type!==12&&!i.get(c)?.async)try{s[c]=Me(u,`variable "${c}"`);}catch(p){if(p instanceof chunkYBQPEWT7_cjs.b&&p.code===B.SNAPSHOT_UNSUPPORTED_VALUE)continue;throw p}let o=this.vm.getUserFunctionDefs().map(De),a=[];for(let{line:c,expression:u,entry:p}of n){if(t.has(c)||p.result.type===12)continue;let m;try{m=Me(p.result,`line ${c}`);}catch(y){if(y instanceof chunkYBQPEWT7_cjs.b&&y.code===B.SNAPSHOT_UNSUPPORTED_VALUE)continue;throw y}a.push({line:c,expression:u,result:m,bytecode:ue(p.bytecode),reads:p.readVariables.slice(),writeVar:p.writeVariable});}let l=Array.from(this.bytecodeCache.entries()).map(([c,u])=>({expression:c,program:ue(u)}));return {format:ee,version:Q,engineVersion:chunk4NZXCHQL_cjs.a,locale:this.localeCode,variables:s,userFunctions:o,lineCache:a,bytecodeCache:l}}static fromJSON(e,t={}){jt(e);let n=t.locale??e.locale??"en",i=new X({locale:n,diagnostics:t.diagnostics??false,config:t.config,packages:t.packages});return i.restoreSnapshot(e),i}restoreSnapshot(e){for(let[t,n]of Object.entries(e.variables))this.vm.setVar(t,Be(n));for(let t of e.userFunctions){let n=Ue(t);this.vm.defineUserFunction(n.name,n.params,n.program);}for(let t of e.lineCache){let n=new K(Be(t.result),pe(t.bytecode),t.reads.slice(),t.writeVar);this.lineCache.set(t.line,n,t.expression),this.dag.registerLine(t.line,t.reads,t.writeVar?[t.writeVar]:[]);}for(let{expression:t,program:n}of e.bytecodeCache)this.bytecodeCache.set(t,pe(n));}evaluateIncremental(e,t){let n=this.dag.getAffectedLinesInOrder(e);this.vm.setVar(e,chunkSQHBOWES_cjs.n(t));let i=new Map;for(let s of n){let o=this.lineCache.getEntryForLine(s);if(!o||o.bytecode.opcodes.length===0)continue;let a=this.executeRaw(o.bytecode,s);if(a.type==="pending"){this.resolveAsync(a);continue}if(a.type==="error"){let c=chunkSQHBOWES_cjs.P(a.error.code,a.error.message);i.set(s,c),o.result=c;continue}let l=a.value;i.set(s,l),o.result=l;}return i}};X.GOAL_SEEK_MAX_NESTING_DEPTH=1,X.WARMUP_EXPRESSIONS=["1 + 2 * 3","10.5 / 2 - 0.25","50% of 200","3 kg + 400 g","sqrt(144) + max(1, 2)","1 < 2 && 3 >= 3","half of 250",'"text" + "joined"'];var we=X;var Ke=(()=>{throw new Error("engine.worker.ts was not processed by esbuild-plugin-inline-worker, so worker offload is unavailable")}),te=null;function Lr(){return te||(te=new we),te}var re=null;function Ir(){return re||(re=chunkJSM3O7EM_cjs.c(chunk634ILVMP_cjs.w,200,5e4)),re}function Vr(r){let e={lineId:r.lineId,expression:r.expression,compiledAgainstHash:r.textHash,strings:[],reads:[],writes:[],isVariableDef:false,error:null};try{let t=Lr(),{program:n,reads:i,writes:s}=t.compileExpression(r.expression),o=s.length>0,a=n.opcodes,l=n.numbers,c=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),u=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength);return {...e,opcodesBuffer:c,numbersBuffer:u,opcodesLength:a.length,numbersLength:l.length,strings:[...n.strings],reads:i,writes:s,isVariableDef:o}}catch(t){return {...e,opcodesBuffer:new ArrayBuffer(0),numbersBuffer:new ArrayBuffer(0),opcodesLength:0,numbersLength:0,error:t instanceof Error?t.message:String(t)}}}function Mr(r){let e=[],t=[];for(let n of r.items){let i=Vr(n);e.push(i),i.opcodesBuffer.byteLength>0&&t.push(i.opcodesBuffer),i.numbersBuffer.byteLength>0&&t.push(i.numbersBuffer);}self.postMessage({id:r.id,type:"COMPILE_RESULT",results:e},t);}function Br(r){let e=Ir();e.reset();let t=new Uint8Array(r.opcodesBuffer,0,r.opcodesLength),n=new Float64Array(r.numbersBuffer,0,r.numbersLength),i={opcodes:t,numbers:n,strings:r.strings};try{let s=chunkJSM3O7EM_cjs.d(i,e);if(s.type==="pending")return {lineNumber:r.lineNumber,valueType:12,value:0,isPending:!0,queryKey:s.queryKey};if(s.type==="error")return {lineNumber:r.lineNumber,valueType:13,value:0,isPending:!1,unit:s.error.message};let o=s.value;return {lineNumber:r.lineNumber,valueType:o.type,value:typeof o.value=="number"?o.value:typeof o.value=="bigint"?Number(o.value):0,unit:o.unit,isPending:!1}}catch{return {lineNumber:r.lineNumber,valueType:13,value:0,isPending:false,unit:"Worker execution failed"}}}function Dr(r){let e=[];for(let t of r.items)e.push(Br(t));self.postMessage({id:r.id,type:"EXECUTE_RESULT",results:e});}var Ur=typeof self<"u"&&typeof window>"u",Fr=r=>{if(r.origin&&self.location&&r.origin!==self.location.origin)return;let e=r.data;switch(e.type){case "COMPILE_BATCH":Mr(e);break;case "EXECUTE_BATCH":Dr(e);break;case "TERMINATE":{te&&(te.clear(),te=null),re&&(re.reset(),re=null),self.postMessage({id:e.id,type:"COMPILE_RESULT",results:[]});break}default:self.postMessage({id:-1,type:"COMPILE_RESULT",results:[],error:`Unknown message type: ${e.type}`});}};Ur&&(self.onmessage=Fr);var Yt=3e4,Zt=50,Ne=class{constructor(e){this.workers=[];this.nextWorker=0;this.nextId=1;this.pendingBatches=new Map;this.terminated=false;this._available=null;this.poolSize=Math.min(e??this.defaultPoolSize(),4);}defaultPoolSize(){return typeof navigator<"u"&&navigator.hardwareConcurrency?Math.min(navigator.hardwareConcurrency,4):2}isAvailable(){if(this.terminated)return false;if(this._available!==null)return this._available;if(typeof Worker>"u")return this._available=false,false;try{return Ke().terminate(),this._available=!0,!0}catch{return this._available=false,false}}executeBatch(e,t){if(!this.isAvailable())return;if(e.length===0)return Promise.resolve([]);this.ensureWorkers();let n=[];for(let l of e){let c=t.get(l);if(!c||c.bytecode.opcodes.length===0)continue;let u=c.bytecode.opcodes,p=c.bytecode.numbers,m=u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength),y=p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength);n.push({lineNumber:l,opcodesBuffer:m,numbersBuffer:y,opcodesLength:u.length,numbersLength:p.length,strings:[...c.bytecode.strings]});}if(n.length===0)return Promise.resolve([]);let i=[];for(let l of n)l.opcodesBuffer.byteLength>0&&i.push(l.opcodesBuffer),l.numbersBuffer.byteLength>0&&i.push(l.numbersBuffer);let s=this.nextId++,o=this.nextWorkerIndex(),a=this.workers[o];return new Promise(l=>{let c=setTimeout(()=>{this.pendingBatches.has(s)&&this.failWorker(o,"WORKER_TIMEOUT",`Evaluation did not finish within ${Yt/1e3} seconds; the worker was replaced`);},Yt);this.pendingBatches.set(s,{id:s,lineNumbers:n.map(u=>u.lineNumber),workerIndex:o,resolve:u=>{clearTimeout(c),l(u);}}),a.postMessage({type:"EXECUTE_BATCH",id:s,items:n},i);})}clear(){for(let[,e]of this.pendingBatches)e.resolve([]);this.pendingBatches.clear();for(let e of this.workers)e.terminate();this.workers=[],this.nextWorker=0;}destroy(){this.terminated=true,this.clear();}ensureWorkers(){if(!(this.workers.length>0))for(let e=0;e<this.poolSize;e++)this.spawnWorker(e);}spawnWorker(e){let t=Ke();t.onmessage=n=>{this.handleWorkerMessage(n.data);},t.onerror=n=>{console.error(`[ExecutionPool] Worker ${e} error:`,n.message),this.failWorker(e,"WORKER_EXECUTION_ERROR",`Worker failed: ${n.message}`);},this.workers[e]=t;}failWorker(e,t,n){if(this.workers.length!==0){this.workers[e]?.terminate(),this.terminated||this.spawnWorker(e);for(let[i,s]of this.pendingBatches)s.workerIndex===e&&(this.pendingBatches.delete(i),s.resolve(_r(s.lineNumbers,t,n)));}}nextWorkerIndex(){let e=this.nextWorker;return this.nextWorker=(this.nextWorker+1)%this.workers.length,e}handleWorkerMessage(e){if(e.type!=="EXECUTE_RESULT")return;let t=this.pendingBatches.get(e.id);t&&(this.pendingBatches.delete(e.id),t.resolve(e.results));}};function _r(r,e,t){return r.map(n=>({lineNumber:n,valueType:13,value:0,unit:t,isPending:false,errorCode:e}))}function er(r){switch(r.valueType){case 0:return chunkSQHBOWES_cjs.n(r.value);case 1:return chunkSQHBOWES_cjs.r(r.value);case 2:return chunkSQHBOWES_cjs.s(BigInt(r.value));case 3:return chunkSQHBOWES_cjs.t(String(r.value));case 4:return chunkSQHBOWES_cjs.M(r.value);case 5:return chunkSQHBOWES_cjs.N(r.value);case 6:return chunkSQHBOWES_cjs.u(r.value,r.unit??"");case 7:return chunkSQHBOWES_cjs.n(r.value);case 10:return chunkSQHBOWES_cjs.L(r.value!==0);case 12:return chunkSQHBOWES_cjs.O(r.queryKey??"");case 13:return chunkSQHBOWES_cjs.P(r.errorCode??"WORKER_EXECUTION_ERROR",r.unit??"Unknown worker error");default:return chunkSQHBOWES_cjs.n(r.value)}}var Re=class Re{constructor(e,t,n,i=Re.DEFAULT_HIGH_WATER_MARK){this.pending=[];this.scheduled=false;this.cleared=false;this.executionPool=null;this.workerOffloadDispatchCount=0;this._streamController=null;this._testCaptures=null;this.onLineResult=null;this.warnedAboutMissingHook=false;this.dag=e,this.lineCache=t,this.vm=n,this.highWaterMark=i,this._eventStream=this.createEventStream();}warnIfUnwired(){this.onLineResult||this.listenerCount>0||this.warnedAboutMissingHook||(this.warnedAboutMissingHook=true,console.warn("[solve-engine] An async result resolved, but nothing is listening for it: no reader is attached to engine.getEventStream() and AsyncResolutionBatcher.onLineResult is not set. The value is in the cache; without one of those the line keeps showing as pending. Read the event stream and re-evaluate the lines it names (see the async guide), or set onLineResult to mirror resolved values into your own state. This warning appears once per batcher."));}createEventStream(){return new ReadableStream({start:e=>{this._streamController=e;},cancel:()=>{this._streamController=null;}},new CountQueuingStrategy({highWaterMark:this.highWaterMark}))}add(e){this.cleared=false;for(let t of this.pending)if(t.packageId===e.packageId&&t.queryKey===e.queryKey)return;this.pending.push(e),this.scheduled||(this.scheduled=true,queueMicrotask(()=>{try{this.flush();}catch(t){let n=chunkYBQPEWT7_cjs.d(t);console.error(`[AsyncResolutionBatcher] flush() failed unexpectedly \u2014 this should never happen; please report: ${n.format()}`);}}));}getEventStream(){return this._eventStream}get pendingCount(){return this.pending.length}get dedupCount(){let e=new Set;for(let t of this.pending)e.add(`${t.packageId}:${t.queryKey}`);return Math.max(0,this.pending.length-e.size)}get listenerCount(){return this._eventStream.locked?1:0}get workerOffloadCount(){return this.workerOffloadDispatchCount}clearAll(){this.pending=[],this.scheduled=false,this.cleared=true,this._testCaptures=null,this.onLineResult=null;try{this._streamController?.close();}catch{}this._streamController=null,this._eventStream=this.createEventStream(),this.executionPool&&(this.executionPool.clear(),this.executionPool=null),this.workerOffloadDispatchCount=0;}flush(){if(this.scheduled=false,this.cleared||this.pending.length===0)return;let e=this.pending;this.pending=[];let t=new Map;for(let c of e){let u=`${c.packageId}:${c.queryKey}`;t.set(u,c);}let n=[],i=[];for(let c of t.values())c.isError?n.push(c):i.push(c);for(let c of n)c.signal.aborted||this.notifyListeners({type:"error",queryKey:c.queryKey,packageId:c.packageId,error:c.error??new Error("Unknown async resolution error")});let s=new Set,o=[],a=[...i,...n];for(let c of a){if(c.signal.aborted)continue;o.push(c.queryKey);let u=this.dag.getAffectedLinesByDataSource(c.packageId,[c.queryKey]);for(let p of u)s.add(p);}if(s.size===0){this.notifyListeners({type:"lines-updated",lineNumbers:[],affectedQueryKeys:o});return}let l=this.topologicalSort(Array.from(s));if(l.length>Zt){let c=new Map;for(let u of l)c.set(u,this.lineCache.getEntryForLine(u));this.reExecuteViaWorkerPool(l,c,o).catch(u=>{let p=chunkYBQPEWT7_cjs.d(u);console.error(`[AsyncResolutionBatcher] reExecuteViaWorkerPool() failed unexpectedly: ${p.format()}`);});return}this.reExecuteMainThread(l,o);}topologicalSort(e){if(e.length<=1)return e;let t=new Map,n=new Map,i=new Map;for(let a of e)t.set(a,0),n.set(a,[]);for(let a of e){let l=this.dag.getWrites(a);for(let c of l)i.set(c,a);}for(let a of e){let l=this.dag.getDependencies(a);for(let c of l){let u=i.get(c);u!==void 0&&u!==a&&(n.get(u).push(a),t.set(a,(t.get(a)??0)+1));}}let s=[];for(let[a,l]of t)l===0&&s.push(a);if(s.length===0&&e.length>0)return [...e].sort((a,l)=>a-l);let o=[];for(;s.length>0;){let a=s.shift();o.push(a);for(let l of n.get(a)??[]){let c=(t.get(l)??1)-1;t.set(l,c),c===0&&s.push(l);}}if(o.length<e.length){let a=e.filter(l=>!o.includes(l)).sort((l,c)=>l-c);o.push(...a);}return o}async reExecuteViaWorkerPool(e,t,n){this.executionPool||(this.executionPool=new Ne);let i=this.executionPool.executeBatch(e,t);if(!i){this.reExecuteMainThread(e,n,t);return}this.workerOffloadDispatchCount++;let s=await i;if(this.cleared)return;let o=[];for(let a of s){let l=t.get(a.lineNumber);if(!l||a.isPending)continue;let c=er(a);l.result=c,this.warnIfUnwired(),this.onLineResult?.(a.lineNumber,c),o.push(a.lineNumber);}this.cleared||(o.length>0||n.length>0)&&this.notifyListeners({type:"lines-updated",lineNumbers:o,affectedQueryKeys:n});}reExecuteMainThread(e,t,n){let i=[];for(let s of e){let o=n?n.get(s):this.lineCache.getEntryForLine(s);if(!o||o.bytecode.opcodes.length===0)continue;let a=this.vm.getStack().length;try{let l=chunkJSM3O7EM_cjs.d(o.bytecode,this.vm);for(;this.vm.getStack().length>a;)this.vm.pop();if(l.type==="value")o.result=l.value,this.warnIfUnwired(),this.onLineResult?.(s,l.value),i.push(s);else if(l.type==="error"){let c=chunkSQHBOWES_cjs.P(l.error.code,l.error.message);o.result=c,this.warnIfUnwired(),this.warnIfUnwired(),this.onLineResult?.(s,c),i.push(s);}}catch(l){for(;this.vm.getStack().length>a;)this.vm.pop();let c=chunkYBQPEWT7_cjs.d(l),u=chunkSQHBOWES_cjs.P(c.code,c.message);o.result=u,this.warnIfUnwired(),this.onLineResult?.(s,u),i.push(s);}}return (i.length>0||t.length>0)&&this.notifyListeners({type:"lines-updated",lineNumbers:i,affectedQueryKeys:t}),i}notifyListeners(e){if(this._testCaptures&&this._testCaptures.push(e),this._streamController)try{this._streamController.enqueue(e);}catch{}}};Re.DEFAULT_HIGH_WATER_MARK=64;var Te=Re;exports.a=$r;exports.b=gr;exports.c=Bt;exports.d=ee;exports.e=Q;exports.f=B;exports.g=Ke;exports.h=Te;exports.i=$e;exports.j=ze;exports.k=Se;exports.l=cn;exports.m=un;exports.n=we;//# sourceMappingURL=chunk-SPOVFRZO.cjs.map
|
|
5
|
+
//# sourceMappingURL=chunk-SPOVFRZO.cjs.map
|