solve-engine 2.25.0 → 2.26.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/dist/CalendarBackend-MdS3Bb4P.d.cts +181 -0
- package/dist/CalendarBackend-MdS3Bb4P.d.ts +181 -0
- package/dist/{Configuration-DnzYPmoK.d.cts → Configuration-BxriK9Kw.d.cts} +63 -4
- package/dist/{Configuration-DnzYPmoK.d.ts → Configuration-BxriK9Kw.d.ts} +63 -4
- package/dist/DateCalendar-B85t6Vk6.d.ts +90 -0
- package/dist/DateCalendar-CUGI1fT4.d.cts +90 -0
- package/dist/{EngineError-fR1K1rvx.d.cts → EngineError-C-kBwYlN.d.cts} +31 -4
- package/dist/{EngineError-fR1K1rvx.d.ts → EngineError-C-kBwYlN.d.ts} +31 -4
- package/dist/{FormattingSettings-bRKjU7wI.d.ts → FormattingSettings-ByO-4wiM.d.cts} +14 -0
- package/dist/{FormattingSettings-bRKjU7wI.d.cts → FormattingSettings-CvCzAfsz.d.ts} +14 -0
- package/dist/{Lexer-aB95pjoX.d.cts → Lexer-DhGhoAa2.d.cts} +13 -3
- package/dist/{Lexer-Bmctxl0n.d.ts → Lexer-DqtnZMC5.d.ts} +13 -3
- package/dist/{PackageCompatibility-CUVg8tmt.d.cts → PackageCompatibility-CNiTtC6S.d.cts} +1 -1
- package/dist/{PackageCompatibility-BludTs7v.d.ts → PackageCompatibility-fj_f7uqC.d.ts} +1 -1
- package/dist/{PackageRegistry-Dvn4i2QK.d.cts → PackageRegistry-BHBCFswo.d.cts} +328 -14
- package/dist/{PackageRegistry-DT-x32OM.d.ts → PackageRegistry-CNZUwWHJ.d.ts} +328 -14
- package/dist/{Parselet-BawfGuTF.d.cts → Parselet-DF3864la.d.cts} +19 -3
- package/dist/{Parselet-DqTbbtWA.d.ts → Parselet-Dgymjxzd.d.ts} +19 -3
- package/dist/{Token-CbP_OutD.d.cts → Token-D8f7yaz1.d.cts} +17 -0
- package/dist/{Token-CbP_OutD.d.ts → Token-D8f7yaz1.d.ts} +17 -0
- package/dist/{TokenNormalizer-CLBtiE8M.d.ts → TokenNormalizer-IF7nPRMp.d.ts} +1 -1
- package/dist/{TokenNormalizer-CjTDmHgB.d.cts → TokenNormalizer-Pe3_390t.d.cts} +1 -1
- package/dist/{ScopeManager-B636am7Y.d.ts → VMBuiltins-CZiZRKn-.d.ts} +91 -9
- package/dist/{ScopeManager-CdwX0VTw.d.cts → VMBuiltins-kv4rr0y5.d.cts} +91 -9
- package/dist/{VMCheckpoints-DDlxNssY.d.ts → VMCheckpoints-DXze6ypg.d.ts} +2 -2
- package/dist/{VMCheckpoints-CYqeq8IV.d.cts → VMCheckpoints-yun4ocSv.d.cts} +2 -2
- package/dist/{Value-Ds3Gy07C.d.cts → Value-BYHw-x7q.d.cts} +57 -1
- package/dist/{Value-Ds3Gy07C.d.ts → Value-BYHw-x7q.d.ts} +57 -1
- package/dist/{WorkerError-B1dF3VYT.d.cts → WorkerError-BLZyNq6M.d.cts} +1 -1
- package/dist/{WorkerError-dneODN-u.d.ts → WorkerError-CfBJYueR.d.ts} +1 -1
- package/dist/chunk-2SYYKQ4Q.cjs +2 -0
- package/dist/chunk-2SYYKQ4Q.cjs.map +1 -0
- package/dist/chunk-6EYKVQT3.cjs +2 -0
- package/dist/chunk-6EYKVQT3.cjs.map +1 -0
- package/dist/chunk-7RC6RBS6.cjs +2 -0
- package/dist/chunk-7RC6RBS6.cjs.map +1 -0
- package/dist/chunk-AZX4NTYN.cjs +3 -0
- package/dist/chunk-AZX4NTYN.cjs.map +1 -0
- package/dist/{chunk-JFZ5SLF7.js → chunk-BCR53EIL.js} +2 -2
- package/dist/{chunk-JFZ5SLF7.js.map → chunk-BCR53EIL.js.map} +1 -1
- package/dist/chunk-BLJ6E577.js +2 -0
- package/dist/chunk-BLJ6E577.js.map +1 -0
- package/dist/{chunk-4BAUQE6A.cjs → chunk-C5GEMKUY.cjs} +3 -3
- package/dist/{chunk-4BAUQE6A.cjs.map → chunk-C5GEMKUY.cjs.map} +1 -1
- package/dist/chunk-CL7DM2FX.js +2 -0
- package/dist/chunk-CL7DM2FX.js.map +1 -0
- package/dist/{chunk-BMXYR5LI.cjs → chunk-CQLCTKMX.cjs} +2 -2
- package/dist/{chunk-BMXYR5LI.cjs.map → chunk-CQLCTKMX.cjs.map} +1 -1
- package/dist/chunk-CQY23OF5.cjs +5 -0
- package/dist/chunk-CQY23OF5.cjs.map +1 -0
- package/dist/chunk-D4VBWPWN.js +2 -0
- package/dist/chunk-D4VBWPWN.js.map +1 -0
- package/dist/chunk-E4HAKNBQ.cjs +2 -0
- package/dist/chunk-E4HAKNBQ.cjs.map +1 -0
- package/dist/{chunk-XHQYHXRE.js → chunk-ESZNJQ2C.js} +3 -3
- package/dist/{chunk-XHQYHXRE.js.map → chunk-ESZNJQ2C.js.map} +1 -1
- package/dist/{chunk-IJMNVBIS.js → chunk-FAO6DQ74.js} +2 -2
- package/dist/chunk-FAO6DQ74.js.map +1 -0
- package/dist/{chunk-WGP4UUO5.cjs → chunk-FDKTESBC.cjs} +2 -2
- package/dist/{chunk-WGP4UUO5.cjs.map → chunk-FDKTESBC.cjs.map} +1 -1
- package/dist/{chunk-NEGZZB7F.cjs → chunk-G2V33LFM.cjs} +2 -2
- package/dist/{chunk-NEGZZB7F.cjs.map → chunk-G2V33LFM.cjs.map} +1 -1
- package/dist/chunk-GJZIJK2Q.cjs +2 -0
- package/dist/chunk-GJZIJK2Q.cjs.map +1 -0
- package/dist/chunk-GQM6ICDM.js +2 -0
- package/dist/chunk-GQM6ICDM.js.map +1 -0
- package/dist/chunk-GVL3ZMS7.cjs +2 -0
- package/dist/chunk-GVL3ZMS7.cjs.map +1 -0
- package/dist/{chunk-YBQPEWT7.cjs → chunk-GXO7TSXQ.cjs} +3 -3
- package/dist/chunk-GXO7TSXQ.cjs.map +1 -0
- package/dist/{chunk-OONQ3V3I.js → chunk-HANGBVEE.js} +2 -2
- package/dist/{chunk-OONQ3V3I.js.map → chunk-HANGBVEE.js.map} +1 -1
- package/dist/chunk-J4K72CQN.js +2 -0
- package/dist/chunk-J4K72CQN.js.map +1 -0
- package/dist/{chunk-72PYPENZ.js → chunk-LE6WZLJ4.js} +2 -2
- package/dist/{chunk-72PYPENZ.js.map → chunk-LE6WZLJ4.js.map} +1 -1
- package/dist/chunk-LMZDTQS5.js +3 -0
- package/dist/chunk-LMZDTQS5.js.map +1 -0
- package/dist/chunk-LQIRBP4Q.js +2 -0
- package/dist/chunk-LQIRBP4Q.js.map +1 -0
- package/dist/{chunk-RDYXH7ML.js → chunk-LTUYWJGO.js} +2 -2
- package/dist/{chunk-RDYXH7ML.js.map → chunk-LTUYWJGO.js.map} +1 -1
- package/dist/chunk-MCU7UYKG.js +3 -0
- package/dist/{chunk-ZDCZ5IDD.js.map → chunk-MCU7UYKG.js.map} +1 -1
- package/dist/chunk-MTN53APQ.js +5 -0
- package/dist/chunk-MTN53APQ.js.map +1 -0
- package/dist/chunk-OPKJ2WWB.cjs +3 -0
- package/dist/chunk-OPKJ2WWB.cjs.map +1 -0
- package/dist/chunk-QQHHZPEW.cjs +2 -0
- package/dist/chunk-QQHHZPEW.cjs.map +1 -0
- package/dist/chunk-RRUGQ6DM.js +2 -0
- package/dist/chunk-RRUGQ6DM.js.map +1 -0
- package/dist/chunk-S3ODNMJS.js +2 -0
- package/dist/chunk-S3ODNMJS.js.map +1 -0
- package/dist/{chunk-SAF3B3AX.cjs → chunk-SE6ZCGZ5.cjs} +2 -2
- package/dist/{chunk-SAF3B3AX.cjs.map → chunk-SE6ZCGZ5.cjs.map} +1 -1
- package/dist/chunk-TC23XEAV.js +2 -0
- package/dist/chunk-TC23XEAV.js.map +1 -0
- package/dist/{chunk-FYAMQFZZ.cjs → chunk-TMQ37JQY.cjs} +3 -3
- package/dist/{chunk-FYAMQFZZ.cjs.map → chunk-TMQ37JQY.cjs.map} +1 -1
- package/dist/chunk-TPPM4QSS.cjs +2 -0
- package/dist/chunk-TPPM4QSS.cjs.map +1 -0
- package/dist/{chunk-57PSJQQW.js → chunk-VB6QMU2W.js} +3 -3
- package/dist/chunk-VB6QMU2W.js.map +1 -0
- package/dist/chunk-VQO54ZMA.js +2 -0
- package/dist/chunk-VQO54ZMA.js.map +1 -0
- package/dist/{chunk-7DP57BA7.js → chunk-Y7XRA2EV.js} +2 -2
- package/dist/{chunk-7DP57BA7.js.map → chunk-Y7XRA2EV.js.map} +1 -1
- package/dist/{chunk-5IJD5L3O.cjs → chunk-YBQOQTVL.cjs} +2 -2
- package/dist/chunk-YBQOQTVL.cjs.map +1 -0
- package/dist/{chunk-EL2XUOWX.js → chunk-YG7UWQFV.js} +2 -2
- package/dist/{chunk-EL2XUOWX.js.map → chunk-YG7UWQFV.js.map} +1 -1
- package/dist/chunk-YS2OW75C.cjs +2 -0
- package/dist/chunk-YS2OW75C.cjs.map +1 -0
- package/dist/chunk-ZC2NPRLO.js +3 -0
- package/dist/chunk-ZC2NPRLO.js.map +1 -0
- package/dist/{chunk-FYTB7SDP.cjs → chunk-ZDJTDFTR.cjs} +2 -2
- package/dist/{chunk-FYTB7SDP.cjs.map → chunk-ZDJTDFTR.cjs.map} +1 -1
- package/dist/chunk-ZE5KKMBV.cjs +2 -0
- package/dist/chunk-ZE5KKMBV.cjs.map +1 -0
- package/dist/{chunk-GBCN7FNV.cjs → chunk-ZSLVLMO5.cjs} +2 -2
- package/dist/{chunk-GBCN7FNV.cjs.map → chunk-ZSLVLMO5.cjs.map} +1 -1
- 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 +14 -12
- package/dist/engine.d.ts +14 -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 +4 -3
- package/dist/format.d.ts +4 -3
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +12 -11
- package/dist/language.d.ts +12 -11
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.d.cts +4 -4
- package/dist/lexer.d.ts +4 -4
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +11 -10
- package/dist/packages.d.ts +11 -10
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +5 -4
- package/dist/parser.d.ts +5 -4
- package/dist/parser.js +1 -1
- package/dist/{pipeline-69q2tsLE.d.cts → pipeline-BYkKNpql.d.cts} +1 -1
- package/dist/{pipeline-DTqGLPsV.d.ts → pipeline-Cl7KW8CB.d.ts} +1 -1
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/temporal.cjs +2 -0
- package/dist/temporal.cjs.map +1 -0
- package/dist/temporal.d.cts +201 -0
- package/dist/temporal.d.ts +201 -0
- package/dist/temporal.js +2 -0
- package/dist/temporal.js.map +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -11
- package/dist/testing.d.ts +12 -11
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +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.cjs.map +1 -1
- package/dist/vm.d.cts +8 -56
- package/dist/vm.d.ts +8 -56
- package/dist/vm.js +1 -1
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +35 -13
- package/dist/worker.d.ts +35 -13
- package/dist/worker.js +2 -2
- package/dist/worker.js.map +1 -1
- package/package.json +12 -1
- package/dist/chunk-4BRTUFTH.js +0 -2
- package/dist/chunk-4BRTUFTH.js.map +0 -1
- package/dist/chunk-4NZXCHQL.cjs +0 -2
- package/dist/chunk-4NZXCHQL.cjs.map +0 -1
- package/dist/chunk-57PSJQQW.js.map +0 -1
- package/dist/chunk-5IJD5L3O.cjs.map +0 -1
- package/dist/chunk-634ILVMP.cjs +0 -2
- package/dist/chunk-634ILVMP.cjs.map +0 -1
- package/dist/chunk-63ZOOUOL.js +0 -2
- package/dist/chunk-63ZOOUOL.js.map +0 -1
- package/dist/chunk-77KI7AKJ.cjs +0 -2
- package/dist/chunk-77KI7AKJ.cjs.map +0 -1
- package/dist/chunk-7N3IJSWF.js +0 -5
- package/dist/chunk-7N3IJSWF.js.map +0 -1
- package/dist/chunk-DUYTXLO2.js +0 -2
- package/dist/chunk-DUYTXLO2.js.map +0 -1
- package/dist/chunk-IJMNVBIS.js.map +0 -1
- package/dist/chunk-JSM3O7EM.cjs +0 -2
- package/dist/chunk-JSM3O7EM.cjs.map +0 -1
- package/dist/chunk-MZMA32NE.js +0 -3
- package/dist/chunk-MZMA32NE.js.map +0 -1
- package/dist/chunk-N4SSR7Q6.js +0 -2
- package/dist/chunk-N4SSR7Q6.js.map +0 -1
- package/dist/chunk-NMU5E7W7.js +0 -2
- package/dist/chunk-NMU5E7W7.js.map +0 -1
- package/dist/chunk-OB2VX4IL.js +0 -2
- package/dist/chunk-OB2VX4IL.js.map +0 -1
- package/dist/chunk-RAPEZR5L.cjs +0 -2
- package/dist/chunk-RAPEZR5L.cjs.map +0 -1
- package/dist/chunk-SPOVFRZO.cjs +0 -5
- package/dist/chunk-SPOVFRZO.cjs.map +0 -1
- package/dist/chunk-SQHBOWES.cjs +0 -2
- package/dist/chunk-SQHBOWES.cjs.map +0 -1
- package/dist/chunk-UF5XMZTT.js +0 -2
- package/dist/chunk-UF5XMZTT.js.map +0 -1
- package/dist/chunk-UV3EUIBT.cjs +0 -3
- package/dist/chunk-UV3EUIBT.cjs.map +0 -1
- package/dist/chunk-VMSCRVNX.cjs +0 -2
- package/dist/chunk-VMSCRVNX.cjs.map +0 -1
- package/dist/chunk-XBGK3TTU.cjs +0 -3
- package/dist/chunk-XBGK3TTU.cjs.map +0 -1
- package/dist/chunk-XX55RR4Q.js +0 -3
- package/dist/chunk-XX55RR4Q.js.map +0 -1
- package/dist/chunk-YBQPEWT7.cjs.map +0 -1
- package/dist/chunk-ZDCZ5IDD.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parser/BindingPower.ts","../src/parser/BytecodeBuilder.ts","../src/parser/BigIntLiteral.ts"],"names":["BindingPower","BUILTIN_INFIX_BP","TokenTypes","_bpTable","buildBindingPowerTable","maxId","name","id","tokenTypeId","table","bp","invalidateBindingPowerTable","MAX_CONSTANT_POOL_INDEX","NEGATIVE_ZERO_KEY","checkedOperand","value","what","ErrorFactory","EMPTY_STRINGS","EMPTY_NUMBERS","BytecodeBuilder","pluginFunctionIndex","argCount","index","op","n","key","idx","s","b","params","program","position","target","buf","opLen","numLen","reuseOpcodes","reuseNumbers","opcodes","numbers","i","CHAINED_DOT_THOUSANDS_GROUPS","DIGITS_ONLY","bigIntLiteralDigits","raw","localeCode","withoutSuffix","digits","stripLocaleGrouping","separator","text","thousandsSeparator","getLocale"],"mappings":"uKAWO,IAAMA,CAAAA,CAAe,CAC1B,MAAA,CAAQ,CAAA,CACR,UAAA,CAAY,EAAA,CACZ,SAAA,CAAW,EAAA,CACX,UAAA,CAAY,EAAA,CAaZ,WAAA,CAAa,EAAA,CAab,SAAA,CAAW,EAAA,CACX,UAAA,CAAY,EAAA,CACZ,UAAA,CAAY,EAAA,CACZ,WAAA,CAAa,EAAA,CACb,KAAA,CAAO,EAAA,CACP,GAAA,CAAK,EA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CAAAA,CAE5C,IAAMC,CAAAA,CAASN,CAAAA,CAA6B,IAAA,CAAKK,CAAa,CAAA,CAC3DA,CAAAA,CAAc,KAAA,CAAM,GAAG,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,CAChCE,CAAAA,CAAoBF,CAAAA,CAAeD,CAAU,CAAA,CAEhD,GAAI,CAACH,CAAAA,CAAY,IAAA,CAAKK,CAAM,CAAA,CAAG,CAC9B,IAAME,CAAAA,CAAYH,CAAAA,CAAc,QAAA,CAAS,GAAG,CAAA,CAAI,GAAA,CAAMA,CAAAA,CAAc,QAAA,CAAS,GAAG,CAAA,CAAI,GAAA,CAAMA,CAAAA,CAC1F,MAAM9B,mBAAAA,CAAa,OAAA,CAClB,wBAAA,CACA,CAAA,CAAA,EAAI4B,CAAG,CAAA,0BAAA,EAA6BK,CAAS,CAAA,4BAAA,EAA+BJ,CAAU,CAAA,0DAAA,CAAA,CACtF,CAAE,GAAA,CAAAD,CAAAA,CAAK,UAAA,CAAAC,CAAAA,CAAY,SAAA,CAAAI,CAAU,CAC9B,CACD,CACA,OAAOF,CACR,CASA,SAASC,CAAAA,CAAoBE,CAAAA,CAAcL,CAAAA,CAA4B,CACtE,IAAMM,CAAAA,CAAqBC,mBAAAA,CAAUP,CAAU,CAAA,CAAE,OAAA,CAAQ,kBAAA,CACzD,OAAOM,CAAAA,CAAqBD,CAAAA,CAAK,KAAA,CAAMC,CAAkB,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,CAAID,CACvE","file":"chunk-FYTB7SDP.cjs","sourcesContent":["/**\n * Named precedence levels for the Pratt parser, from loosest (`Lowest`) to\n * tightest (`Call`) binding. A custom infix parselet compares its own\n * binding power against the current expression's to decide whether to\n * consume the next operator (higher power binds tighter, e.g. `*` over `+`).\n *\n * Package authors reference these when declaring an infix parselet in a\n * package's `infixParselets`. See the built-in packages for examples of\n * picking an appropriate level (e.g. arithmetic `+`/`-` use `Sum`, `*`/`/`\n * use `Product`).\n */\nexport const BindingPower = {\n Lowest: 0,\n Assignment: 10,\n LogicalOr: 12, // `or`, `||` — loosest of the boolean-logic operators\n LogicalAnd: 14, // `&&` — binds tighter than `or` (\"a or b and c\" = \"a or (b and c)\")\n // The word \"and\" (`AND_CONJ`), which is both arithmetic addition (\"5 and 3\"\n // is 8) and boolean conjunction (\"true and false\"). A phrase parselet\n // collecting a list (\"average of X, Y and Z\") parses each argument at this\n // level, and an argument stops at any operator whose power is <= the level it\n // was parsed at, so putting \"and\" here is what makes it end an argument\n // rather than be consumed as the addition it also is. Everything an argument\n // should keep binds tighter, including a genuine \"+\" (`Sum`).\n //\n // It sits BELOW `Conditional` because the boolean reading needs comparisons\n // to be its operands: at 28, \"5 > 3 and 2 > 1\" parsed as \"5 > (3 and 2) > 1\"\n // and answered false. Above `LogicalAnd` so that \"and\" is still the tighter\n // of the two conjunctions, and two steps off each neighbour to leave room.\n Conjunction: 16,\n // The bitwise trio and the shifts, ordered exactly as C and JavaScript order\n // them, which is the order every language that borrowed these operators from\n // C uses: `|` looser than `xor`, `xor` looser than `&`, all three looser than\n // comparison, and the shifts tighter than comparison but looser than `+`.\n // They used to share one level (35) between `Sum` and `Product`, so\n // \"1 + 2 << 3\" answered 17 where JavaScript answers 24 and \"4 & 3 + 1\"\n // answered 1 where JavaScript answers 4. Each has its own level now because\n // a shared level makes \"4 | 6 & 3\" group left instead of letting `&` win.\n //\n // They stay TIGHTER than `Conjunction` so that a phrase argument parsed at\n // that level (\"average of 5 | 3, 2 and 4\") keeps its bitwise operators\n // instead of stopping at the first one.\n BitwiseOr: 18, // `|`\n BitwiseXor: 20, // the `xor` keyword (`BIT_XOR`), not the `^` exponent token\n BitwiseAnd: 22, // `&`\n Conditional: 24, // comparisons (`==`, `<`, `>=`, ...), tighter than the bitwise trio, looser than the shifts\n Shift: 27, // `<<`, `>>`, `>>>`\n Sum: 30,\n Product: 40,\n // `±` (the uncertainty operator), tighter than `+ - * /` and looser than `^`,\n // so the tolerance attaches to its adjacent values: `12.3 ± 0.5 * 4` reads as\n // `(12.3 ± 0.5) * 4` (the parenthesised headline case), and `2 + 3 ± 0.5` as\n // `2 + (3 ± 0.5)`. A Tier-2 parselet (packages/uncertainty/), so this level is\n // read off the parselet rather than the Tier-1 BUILTIN_INFIX_BP table below.\n Uncertainty: 45,\n // `^`, RIGHT-associative: \"2 ^ 3 ^ 2\" is 2^(3^2) = 512, as in mathematics,\n // Python, Ruby and JavaScript's `**`. See PrecedenceParser.parseExpression\n // and BinaryOpParselet for the two places that associativity is implemented.\n Exponent: 50,\n Prefix: 60,\n Postfix: 70,\n Call: 80,\n} as const;\n\n/**\n * Set the binding power of a named operator.\n *\n * Binding power is what decides precedence in the Pratt parser: a higher number\n * binds tighter, so `*` outranks `+`. Changing one changes how every existing\n * expression using that operator parses, which is why packages should allocate\n * a new name rather than adjust a built-in.\n *\n * @param name - Operator name.\n * @param power - Higher binds tighter.\n */\nexport function setBindingPower(name: string, power: number): void {\n (BindingPower as Record<string, number>)[name] = power;\n}\n\n/**\n * Read the binding power of a named operator.\n *\n * @param name - Operator name.\n * @returns Its binding power, or 0 when the name is unknown, which makes an\n * unregistered operator terminate an expression rather than swallow the rest\n * of it.\n */\nexport function getBindingPower(name: string): number {\n return (BindingPower as Record<string, number>)[name] ?? 0;\n}\n\n// ── Built-in Infix Operator Binding Power Table ──────────────────────────────\n// Pre-computed Uint8Array lookup indexed by token typeId.\n// value > 0 → built-in infix operator with that binding power\n// value = 0 → not a built-in infix, fall through to Tier 2 parselet registry\n//\n// Built at module load via buildBindingPowerTable(). The table is sparse\n// most entries are 0 since only ~15 of 80+ token types are infix operators.\n//\n// Performance: Uint8Array[typeId] is a single typed array load, no Map.get()\n// no string hashing, no property chain. V8 eliminates bounds checks when typeId\n// is known to be within array length.\n\nimport { TokenTypes } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\n\n/**\n * Mapping of token type names → binding powers for built-in infix operators.\n * Only operators listed here get the Tier 1 fast path in PrecedenceParser.\n * All other infix tokens use the Tier 2 parselet registry fallback.\n */\nexport const BUILTIN_INFIX_BP: Record<string, number> = {\n // Arithmetic (infix, left-associative)\n [TokenTypes.PLUS]: BindingPower.Sum,\n [TokenTypes.MINUS]: BindingPower.Sum,\n [TokenTypes.STAR]: BindingPower.Product,\n [TokenTypes.SLASH]: BindingPower.Product,\n [TokenTypes.MOD]: BindingPower.Product,\n\n // Arithmetic (infix, RIGHT-associative, PrecedenceParser handles this specially)\n [TokenTypes.CARET]: BindingPower.Exponent,\n\n // Bitwise and shift (infix, left-associative), one level each, ordered as C\n // and JavaScript order them. `>>>` used to be missing from this table\n // entirely, which left it running at its Tier 2 parselet level while `>>`\n // ran at the Tier 1 one, so \"16 >> 3 & 1\" and \"16 >>> 3 & 1\" grouped\n // differently and answered 0 and 8.\n [TokenTypes.BIT_OR]: BindingPower.BitwiseOr,\n [TokenTypes.BIT_XOR]: BindingPower.BitwiseXor,\n [TokenTypes.BIT_AND]: BindingPower.BitwiseAnd,\n [TokenTypes.LSHIFT]: BindingPower.Shift,\n [TokenTypes.RSHIFT]: BindingPower.Shift,\n [TokenTypes.URSHIFT]: BindingPower.Shift,\n\n // Postfix (no right operand, PrecedenceParser handles this specially)\n [TokenTypes.PERCENT]: BindingPower.Postfix,\n\n // Percentage keyword (infix, left-associative: \"50% of 200\" → MUL)\n [TokenTypes.OF]: BindingPower.Product,\n};\n\n// Note: These token types are intentionally NOT in the BP_TABLE, they stay in\n// the Tier 2 parselet registry because they require complex handling:\n// IN, TO → UoM conversion parselets (peek at target unit token, complex logic)\n// DOT → Property access (chained OBJ_GET, needs left-token tracking)\n// EQUALS → Assignment (VariableParselet handles :var = expr pattern)\n// EQUALITY, NEQ, GTE, LTE → Comparison ops (need dedicated VM opcodes, task 2.15a)\n// COMMA → Argument separator (function calls, array/object literals)\n\n/** Cached BP_TABLE, built once at module load, immutable thereafter. */\nlet _bpTable: Uint8Array | null = null;\n\n/**\n * Build the Uint8Array binding power table indexed by token typeId.\n * Idempotent, returns cached table on subsequent calls.\n *\n * Must be called after all token types are registered (via registerAllTokenTypes())\n * and after plugin providers have registered their token types.\n */\nexport function buildBindingPowerTable(): Uint8Array {\n if (_bpTable) return _bpTable;\n\n // Size to the largest registered typeId + 1\n let maxId = 0;\n for (const name of Object.keys(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n // Also scan all TokenTypes to ensure table covers all registered IDs\n for (const name of Object.values(TokenTypes)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n\n const table = new Uint8Array(maxId + 1);\n for (const [name, bp] of Object.entries(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n table[id] = bp;\n }\n\n _bpTable = table;\n return table;\n}\n\n/**\n * Drop the cached table, so the next {@link buildBindingPowerTable} call builds\n * a fresh one sized to the token types registered by then.\n *\n * It does NOT add a plugin's operator to the Tier 1 fast path, which is what\n * this comment used to promise. The values in the table come from\n * `BUILTIN_INFIX_BP`, which is module-private and has no registration path, so\n * a rebuilt table holds the same binding powers and a plugin token still reads\n * 0. `PrecedenceParser.BP_TABLE` is a static initialized once at class\n * definition time and never re-read, so it would not see a rebuild anyway.\n *\n * A plugin's infix operator takes the Tier 2 parselet-registry route instead,\n * which is where an operator whose binding power the engine does not already\n * know is meant to live.\n */\nexport function invalidateBindingPowerTable(): void {\n _bpTable = null;\n}\n","import { OpCode } from \"@solve-js/parser/OpCode\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * `BytecodeProgram.opcodes` is a `Uint8Array`, every operand written into\n * it (including constant-pool indices from {@link BytecodeBuilder.emitNumber}/\n * {@link BytecodeBuilder.emitString}) is truncated to a single byte on\n * `build()`. Exceeding this silently wraps the index (e.g. entry 300 reads\n * back as entry 44), producing a wrong result with no error. See\n * {@link BytecodeBuilder.emitNumber} for the guard that turns this into a\n * thrown error instead.\n */\nconst MAX_CONSTANT_POOL_INDEX = 255;\n\n/** The `numberIndex` key for negative zero, which `Map` would otherwise fold into positive zero. */\nconst NEGATIVE_ZERO_KEY = \"-0\";\n\n/**\n * An operand that fits the byte the opcode stream stores it in, or a\n * structured refusal. `build()` copies the stream into a `Uint8Array`, which\n * keeps the low eight bits of whatever it is given: an operand of 300 used to\n * become 44 with no error, and the program then read a different constant,\n * plugin function or argument count from the one the parselet emitted. Every\n * raw operand goes through here, so a package author's mistake is reported at\n * compile time as a fault in the package rather than answered with a wrong\n * number.\n */\nfunction checkedOperand(value: number, what: string): number {\n\tif (!Number.isInteger(value) || value < 0 || value > 255) {\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"BYTECODE_OPERAND_OUT_OF_RANGE\",\n\t\t\t`A bytecode ${what} must be an integer from 0 to 255, but ${value} was emitted; the opcode stream stores one byte per operand.`,\n\t\t\t{ value, what }\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * Compiled bytecode program produced by {@link BytecodeBuilder}.\n * Ready for consumption by {@link executeBytecode} without further processing.\n */\nexport interface BytecodeProgram {\n\topcodes: Uint8Array;\n\tnumbers: Float64Array;\n\tstrings: string[];\n\t/**\n\t * Numeric constants by opcode position, restored from a snapshot.\n\t *\n\t * Nothing in the compile path writes this: numbers are emitted inline into\n\t * {@link numbers} instead. `build()` used to attach an empty Map to every\n\t * program anyway, which was one allocation per compiled expression, around a\n\t * tenth of parse-and-compile time, for a collection that was never read.\n\t * It is left off now, and only {@link EngineSnapshot} sets it when restoring\n\t * a program that carried one; every reader already guards on its absence.\n\t */\n\tconstants?: Map<number, number>;\n\t/**\n\t * Whether the program contains any async opcodes (CALL_PLUGIN, etc.).\n\t * Set during compilation by the BytecodeBuilder. Allows the engine\n\t * to skip the O(n) resolver preflight check in O(1) for purely\n\t * synchronous expressions like `2 + 2`.\n\t */\n\thasAsync: boolean;\n\t/**\n\t * User-defined-function bodies compiled alongside this program (one\n\t * entry per `name(params) = body` definition on this line). See\n\t * {@link BytecodeBuilder.emitUserFunctionBody}. `OpCode.DEFINE_USER_FUNCTION`'s\n\t * operand is an index into this array, resolved at VM-execution time\n\t * (not parse time) so a diagnostic/lookahead parse that never actually\n\t * executes the definition line has no side effect on `vm.userFunctions`.\n\t */\n\tuserFunctionBodies?: UserFunctionDef[];\n\t/**\n\t * Anonymous function bodies compiled alongside this program, one entry\n\t * per `map`/`reduce` inline transform expression (e.g. the `10*x` in\n\t * `map(10*x, [0,1,500])`). See {@link BytecodeBuilder.emitAnonymousBody}.\n\t * Deliberately a SEPARATE side-table from `userFunctionBodies`, not\n\t * routed through `vm.userFunctions` at all: an inline body has no name\n\t * and must never leak into the persistent name-keyed registry the way\n\t * a real `f(x) = ...` definition does.\n\t */\n\tanonymousBodies?: AnonymousBodyDef[];\n}\n\n/**\n * An anonymous transform body for `map`/`reduce`'s inline-expression form\n * (e.g. `10*x` in `map(10*x, [0,1,500])`, or `acc+x` in `reduce(acc+x,\n * [1,2,3])`). Structurally identical to {@link UserFunctionDef} minus the\n * `name`. See `OpCode.MAP_INVOKE`/`REDUCE_INVOKE` and\n * `vm/VM.ts`'s handlers, which build a call frame from `params`/`args`\n * exactly like `CALL_USER_FUNCTION` does, just without ever registering\n * the body in `vm.userFunctions`.\n */\nexport interface AnonymousBodyDef {\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * A user-defined, parameterized, reusable function's compiled form\n * (`f(x) = 2*x + 1`). See `OpCode.DEFINE_USER_FUNCTION`/`CALL_USER_FUNCTION`\n * and `vm/VM.ts`'s `VM.defineUserFunction`/`getUserFunction`.\n *\n * `program` is the body compiled to its OWN independent `BytecodeProgram`,\n * not a fragment of the definition line's own bytecode. Parameter names\n * inside the body compile to ORDINARY `LOAD_VAR <name>` opcodes, no\n * parse-time rewriting, because parameter resolution happens dynamically\n * at the VM level: `CALL_USER_FUNCTION` pushes a name-keyed call frame\n * (`Map<string, Value>`) before re-executing `program`, and `VM.getVar()`\n * checks the innermost call frame before falling back to the flat\n * document-variable store. This is why a `UNIT`-collision parameter name\n * (e.g. `h` in `area(w, h) = w * h`, which lexes as the \"hour\" unit) needs\n * no special handling anywhere, it's just another `LOAD_VAR \"h\"`, resolved\n * the same way as any other name.\n */\nexport interface UserFunctionDef {\n\tname: string;\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * Shared empty collections for programs that emit none.\n *\n * `build()` runs once per compiled expression, so an empty array allocated\n * there is an allocation per line of every document. Most programs emit no\n * strings at all (only the unit and datetime parselets do), and one that emits\n * no numbers is common too, so both were routinely allocating an empty\n * container that nothing would ever read.\n *\n * Sharing them is safe because a built program is read-only downstream: the VM\n * and the snapshot writer only index and iterate these, and nothing in the\n * engine pushes to `program.strings` or `program.numbers`. They are frozen so\n * that a future writer fails loudly here rather than silently corrupting every\n * other program that shares the instance.\n */\nconst EMPTY_STRINGS: readonly string[] = Object.freeze([]);\nconst EMPTY_NUMBERS = new Float64Array(0);\n\n/**\n * Direct-to-bytecode compiler for the Pratt parser.\n *\n * Accumulates opcodes, numeric constants, and string references during parsing,\n * then produces a {@link BytecodeProgram} for VM execution. Supports:\n * - Standard build via {@link build}\n * - Zero-copy build into pre-allocated buffers via {@link buildInto}\n * - In-place reset for reuse without reallocation\n */\nexport class BytecodeBuilder {\n\tprivate opcodes: number[] = [];\n\tprivate numbers: number[] = [];\n\tprivate strings: string[] = [];\n\tprivate stringIndex = new Map<string, number>();\n\t/** Value (or {@link NEGATIVE_ZERO_KEY}) to its slot in `numbers`, so a repeated literal is emitted once. */\n\tprivate numberIndex = new Map<number | string, number>();\n\tprivate _hasAsync = false;\n\tprivate userFunctionBodies: UserFunctionDef[] = [];\n\tprivate anonymousBodies: AnonymousBodyDef[] = [];\n\n\t/**\n\t * The per-engine `plugin function name -> registry index` map, wired in by\n\t * the engine so {@link emitPluginCall} can resolve a name at emit time. The\n\t * same object reference is shared with every builder in an engine (the pool\n\t * and each ad-hoc nested-body builder), and the engine populates it as\n\t * packages register, so a parselet never sees the numeric index.\n\t */\n\tconstructor(private readonly pluginFunctionIndex?: ReadonlyMap<string, number>) {}\n\n\t/** The name->index map, so a nested-body builder inherits the same resolution. */\n\tget pluginIndexMap(): ReadonlyMap<string, number> | undefined {\n\t\treturn this.pluginFunctionIndex;\n\t}\n\n\t/**\n\t * Emit a plugin-function call by NAME. The engine assigns each registered\n\t * `pluginFunctions` entry an index at registration; this resolves the name to\n\t * that index and emits `CALL_PLUGIN` + index + argCount. Package authors emit\n\t * through this rather than a hand-allocated index.\n\t */\n\temitPluginCall(name: string, argCount: number): void {\n\t\tconst index = this.pluginFunctionIndex?.get(name);\n\t\tif (index === undefined) {\n\t\t\tthrow ErrorFactory.execution(\n\t\t\t\t\"UNKNOWN_PLUGIN_FUNCTION\",\n\t\t\t\t`No registered plugin function named \"${name}\". A package must declare it in its pluginFunctions record and be registered before an expression using it is parsed.`,\n\t\t\t\t{ functionName: name },\n\t\t\t);\n\t\t}\n\t\t// One byte covers the first 256 plugin functions; beyond that, the\n\t\t// wide opcode carries a two-byte little-endian index. Emitting the\n\t\t// narrow form whenever it fits keeps existing bytecode and snapshots\n\t\t// byte-for-byte unchanged. The index cannot exceed 65535 because the\n\t\t// allocator (allocatePluginFunctionIndex) caps it, but guard anyway so\n\t\t// a stray index is a clear error rather than a silently truncated byte.\n\t\tif (index > 0xffff) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"PLUGIN_FUNCTION_INDEX_TOO_LARGE\",\n\t\t\t\t`Plugin-function index ${index} exceeds the two-byte bytecode limit (65535).`,\n\t\t\t\t{ index },\n\t\t\t);\n\t\t}\n\t\tif (index <= 0xff) {\n\t\t\tthis.emitOpcode(OpCode.CALL_PLUGIN);\n\t\t\tthis.emitIndex(index);\n\t\t} else {\n\t\t\tthis.emitOpcode(OpCode.CALL_PLUGIN_WIDE);\n\t\t\tthis.emitIndex(index & 0xff); // low byte\n\t\t\tthis.emitIndex((index >> 8) & 0xff); // high byte\n\t\t}\n\t\tthis.emitIndex(argCount);\n\t}\n\n\t/** Emit an {@link OpCode} instruction. */\n\temitOpcode(op: OpCode): void {\n\t\tthis.opcodes.push(op);\n\t\tif (op === OpCode.CALL_PLUGIN || op === OpCode.CALL_PLUGIN_WIDE) {\n\t\t\tthis._hasAsync = true;\n\t\t}\n\t}\n\n\t/**\n\t * Emit a numeric literal: interns `n` into the program's constant pool\n\t * (deduplicated, like {@link emitString}) and writes its index into the\n\t * opcode stream (read back by the VM as e.g. `PUSH_NUMBER <idx>`).\n\t *\n\t * Deduplicated so that the 256-entry pool counts distinct values rather\n\t * than occurrences: a long line of repeated literals used to exhaust it\n\t * long before it held 256 different numbers. Negative zero keeps its own\n\t * slot, because `1 / -0` is not `1 / 0`; NaN shares one, since every NaN\n\t * reads the same.\n\t *\n\t * @throws If the pool would exceed 256 distinct entries.\n\t */\n\temitNumber(n: number): void {\n\t\tconst key = Object.is(n, -0) ? NEGATIVE_ZERO_KEY : n;\n\t\tlet idx = this.numberIndex.get(key);\n\t\tif (idx === undefined) {\n\t\t\tidx = this.numbers.length;\n\t\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\t\"TOO_MANY_NUMERIC_CONSTANTS\",\n\t\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} distinct numeric literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.numbers.push(n);\n\t\t\tthis.numberIndex.set(key, idx);\n\t\t}\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a string literal: interns `s` into the program's string pool\n\t * (deduplicated via `stringIndex`) and writes its index into the opcode\n\t * stream. Subject to the same constant-pool bound as {@link emitNumber},\n\t * but since strings ARE deduplicated, only distinct string values count\n\t * against the limit.\n\t *\n\t * @throws If the string pool would exceed 256 distinct entries.\n\t */\n\temitString(s: string): void {\n\t\tlet idx = this.stringIndex.get(s);\n\t\tif (idx === undefined) {\n\t\t\tidx = this.strings.length;\n\t\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\t\"TOO_MANY_STRING_CONSTANTS\",\n\t\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} distinct string literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.strings.push(s);\n\t\t\tthis.stringIndex.set(s, idx);\n\t\t}\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a raw numeric operand (0-255) following an opcode, e.g. a\n\t * plugin-function index for `CALL_PLUGIN`, or an argument count. Unlike\n\t * {@link emitOpcode}, this does not go through the `OpCode` enum, so\n\t * package authors use this (not an unsafe cast to `OpCode`) to push\n\t * operands their own opcode handler expects to read positionally.\n\t */\n\temitIndex(idx: number): void {\n\t\tthis.opcodes.push(checkedOperand(idx, \"index\"));\n\t}\n\n\t/** Emit a raw byte (0-255), used for fixed small operands like argument counts. */\n\temitByte(b: number): void {\n\t\tthis.opcodes.push(checkedOperand(b, \"byte\"));\n\t}\n\n\t/** Number of opcodes/operands emitted so far, used to compute jump targets before {@link patchJump}. */\n\tget currentLength(): number {\n\t\treturn this.opcodes.length;\n\t}\n\n\t/**\n\t * Register a compiled user-defined-function body, returning its index\n\t * into this program's `userFunctionBodies` side-table, the caller emits\n\t * that index as `DEFINE_USER_FUNCTION`'s operand via {@link emitIndex}.\n\t * Subject to the same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitNumber}/{@link emitString} (the index itself is a single\n\t * opcode-stream byte), in practice a single line defines at most a\n\t * handful of functions, so this limit is never realistically reached.\n\t *\n\t * @throws If more than 256 function bodies are registered on one program.\n\t */\n\temitUserFunctionBody(name: string, params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.userFunctionBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_FUNCTION_DEFINITIONS\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} function definitions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.userFunctionBodies.push({ name, params, program });\n\t\treturn idx;\n\t}\n\n\t/**\n\t * Register a compiled `map`/`reduce` anonymous transform body, returning\n\t * its index into this program's `anonymousBodies` side-table, the\n\t * caller emits that index as `MAP_INVOKE`/`REDUCE_INVOKE`'s operand via\n\t * {@link emitIndex}. Same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitUserFunctionBody}.\n\t *\n\t * @throws If more than 256 anonymous bodies are registered on one program.\n\t */\n\temitAnonymousBody(params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.anonymousBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_ANONYMOUS_BODIES\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} map/reduce transform expressions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.anonymousBodies.push({ params, program });\n\t\treturn idx;\n\t}\n\n\t/** Overwrite a previously-emitted placeholder operand at `position` with the real jump `target`, once known. */\n\tpatchJump(position: number, target: number): void {\n\t\tif (position < 0 || position >= this.opcodes.length) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"BYTECODE_OPERAND_OUT_OF_RANGE\",\n\t\t\t\t`patchJump was asked to write at position ${position}, outside the ${this.opcodes.length} bytes emitted so far.`,\n\t\t\t\t{ position, length: this.opcodes.length }\n\t\t\t);\n\t\t}\n\t\tthis.opcodes[position] = checkedOperand(target, \"jump target\");\n\t}\n\n\t/**\n\t * Build the accumulated opcodes/numbers/strings into a BytecodeProgram.\n\t * Creates new TypedArrays, the builder can be reused after this call.\n\t */\n\tbuild(): BytecodeProgram {\n\t\treturn {\n\t\t\topcodes: new Uint8Array(this.opcodes),\n\t\t\tnumbers: this.numbers.length > 0 ? new Float64Array(this.numbers) : EMPTY_NUMBERS,\n\t\t\t// Defensive copy when there is anything to copy: reset()'s\n\t\t\t// `.length = 0` would otherwise clear a reference the program still\n\t\t\t// holds. An empty one needs no copy, so it shares the frozen\n\t\t\t// singleton instead of allocating per program.\n\t\t\tstrings: this.strings.length > 0 ? [...this.strings] : (EMPTY_STRINGS as string[]),\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Build directly into a pre-allocated buffer for zero-copy VM consumption.\n\t *\n\t * When `buf` is provided and large enough, writes into it and returns\n\t * subarray **views** (not copies), the returned TypedArrays share the\n\t * buffer's underlying ArrayBuffer. The caller MUST NOT mutate the buffer\n\t * until the returned BytecodeProgram is no longer needed.\n\t *\n\t * If the caller intends to cache the result, they must copy the TypedArrays\n\t * (e.g. `new Uint8Array(program.opcodes)`) before reusing the buffer pool.\n\t *\n\t * When `buf` is omitted or too small, allocates fresh TypedArrays.\n\t */\n\tbuildInto(buf?: { opcodes: Uint8Array; numbers: Float64Array }): BytecodeProgram {\n\t\tconst opLen = this.opcodes.length;\n\t\tconst numLen = this.numbers.length;\n\n\t\tconst reuseOpcodes = buf && buf.opcodes.length >= opLen;\n\t\tconst reuseNumbers = buf && buf.numbers.length >= numLen;\n\n\t\t// Subarray views that share the buffer's ArrayBuffer (zero-copy)\n\t\tconst opcodes = reuseOpcodes\n\t\t\t? new Uint8Array(buf!.opcodes.buffer, buf!.opcodes.byteOffset, opLen)\n\t\t\t: new Uint8Array(opLen);\n\t\tconst numbers = reuseNumbers\n\t\t\t? new Float64Array(buf!.numbers.buffer, buf!.numbers.byteOffset, numLen)\n\t\t\t: new Float64Array(numLen);\n\n\t\t// Write data into the views\n\t\tfor (let i = 0; i < opLen; i++) opcodes[i] = this.opcodes[i];\n\t\tfor (let i = 0; i < numLen; i++) numbers[i] = this.numbers[i];\n\n\t\treturn {\n\t\t\topcodes,\n\t\t\tnumbers,\n\t\t\tstrings: [...this.strings],\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\treset(): void {\n\t\t// Retain backing stores with .length = 0 to avoid reallocation on growth.\n\t\t// = [] discards the ArrayBuffer, forcing V8 to reallocate on every push()\n\t\t// threshold (4→8→16→32...). For a 50-opcode expression, that's 3-4 copies.\n\t\tthis.opcodes.length = 0;\n\t\tif (this.numbers.length > 0) {\n\t\t\tthis.numbers.length = 0;\n\t\t\tthis.numberIndex.clear();\n\t\t}\n\t\t// Guarded on being non-empty. reset() runs once per compiled expression\n\t\t// and a CPU profile put it at over a tenth of parse-and-compile, which\n\t\t// is a lot for clearing collections that are usually already empty:\n\t\t// most expressions emit no strings, and user function bodies are rarer\n\t\t// still. Emptying an empty Map is not free, and neither is the write\n\t\t// barrier on a length assignment.\n\t\tif (this.strings.length > 0) {\n\t\t\tthis.strings.length = 0;\n\t\t\tthis.stringIndex.clear();\n\t\t}\n\t\tthis._hasAsync = false;\n\t\tif (this.userFunctionBodies.length > 0) this.userFunctionBodies.length = 0;\n\t\tif (this.anonymousBodies.length > 0) this.anonymousBodies.length = 0;\n\t}\n}\n","/**\n * Turning a `123n` literal's source text into the digits `PUSH_BIGINT` stores.\n *\n * The lexer coalesces thousands groups into the number token it is building,\n * accepting both `,` and `.` as the separator regardless of locale (see\n * `lexer/ExpressionLexer.ts`'s \"Thousands separators\" block). For a NUMBER that\n * is fine, because the separators are stripped again when the text is turned\n * into a double. For a BIGINT nothing stripped them: both consumers took the\n * token text, removed the trailing `n`, and handed the rest straight to\n * `BigInt()`.\n *\n * So `1.000n` reached `BigInt(\"1.000\")`, which throws a raw `SyntaxError` that\n * arrived at the host as UNEXPECTED_ERROR/INTERNAL: the engine reporting its\n * own bug for six characters a user typed. `1.01n` and `1.1n` were fine, which\n * is the tell that the `n` suffix was never the problem, the three-digit\n * thousands group was: a dot followed by exactly three digits is what the lexer\n * swallows, and one followed by one or two digits it leaves alone.\n *\n * Written once here rather than inline at both call sites. There are two\n * (`parser/PrecedenceParser.ts`'s Tier-1 switch and\n * `packages/biginteger/parselets/BigIntNumberParselet.ts`), they already held\n * identical copies of the `n`-stripping, and the two tiers disagreeing about a\n * literal is a bug shape this codebase has had before.\n *\n * @module BigIntLiteral\n */\n\nimport { getLocale } from \"@solve-js/constants/locales\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Two or more dot-separated groups of three, e.g. `1.234.567`.\n *\n * Unambiguous in any locale, since no locale writes two decimal points, so this\n * is stripped without consulting one. Same regex and same reasoning as\n * `NumberParselet.ts`'s copy for the NUMBER path.\n */\nconst CHAINED_DOT_THOUSANDS_GROUPS = /^\\d{1,3}(\\.\\d{3}){2,}$/;\n\n/** Digits and nothing else, which is what `BigInt()` can be handed safely. */\nconst DIGITS_ONLY = /^\\d+$/;\n\n/**\n * The digit string behind a bigint literal.\n *\n * A bigint literal has no fractional part by construction: the lexer only emits\n * BIGINT when it saw no decimal point of its own and no exponent, so any `.` or\n * `,` still in the text got there as a thousands group. Which of the two the\n * writer meant is a locale question, and answering it wrongly would silently\n * change the value by three orders of magnitude, so only the separator this\n * locale actually uses for grouping is removed. Anything left over is refused\n * rather than guessed at.\n *\n * @param raw - The token's text, with or without the trailing `n`.\n * @param localeCode - The engine's active locale.\n * @returns A string of digits, ready for `BigInt()`.\n * @throws An `INVALID_NUMBER_LITERAL` parsing error when what is left is not a\n * whole number, e.g. `1.000n` in a locale that writes decimals with a dot.\n */\nexport function bigIntLiteralDigits(raw: string, localeCode: string): string {\n\tconst withoutSuffix = raw.endsWith(\"n\") ? raw.slice(0, -1) : raw;\n\n\t// The common case first: nothing was grouped, so there is nothing to decide.\n\tif (DIGITS_ONLY.test(withoutSuffix)) return withoutSuffix;\n\n\tconst digits = CHAINED_DOT_THOUSANDS_GROUPS.test(withoutSuffix)\n\t\t? withoutSuffix.split(\".\").join(\"\")\n\t\t: stripLocaleGrouping(withoutSuffix, localeCode);\n\n\tif (!DIGITS_ONLY.test(digits)) {\n\t\tconst separator = withoutSuffix.includes(\".\") ? \".\" : withoutSuffix.includes(\",\") ? \",\" : withoutSuffix;\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"INVALID_NUMBER_LITERAL\",\n\t\t\t`\"${raw}\" is not a whole number: \"${separator}\" separates decimals in the ${localeCode} locale, and a whole number cannot have a fractional part.`,\n\t\t\t{ raw, localeCode, separator },\n\t\t);\n\t}\n\treturn digits;\n}\n\n/**\n * Removes the active locale's own thousands separator and nothing else.\n *\n * @param text - The literal without its `n`.\n * @param localeCode - The engine's active locale.\n * @returns The text with grouping removed, which the caller then re-checks.\n */\nfunction stripLocaleGrouping(text: string, localeCode: string): string {\n\tconst thousandsSeparator = getLocale(localeCode).display.thousandsSeparator;\n\treturn thousandsSeparator ? text.split(thousandsSeparator).join(\"\") : text;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/parser/BindingPower.ts","../src/parser/BytecodeBuilder.ts","../src/parser/BigIntLiteral.ts"],"names":["BindingPower","BUILTIN_INFIX_BP","TokenTypes","_bpTable","buildBindingPowerTable","maxId","name","id","tokenTypeId","table","bp","invalidateBindingPowerTable","MAX_CONSTANT_POOL_INDEX","NEGATIVE_ZERO_KEY","checkedOperand","value","what","ErrorFactory","EMPTY_STRINGS","EMPTY_NUMBERS","BytecodeBuilder","pluginFunctionIndex","argCount","index","op","n","key","idx","s","b","params","program","position","target","buf","opLen","numLen","reuseOpcodes","reuseNumbers","opcodes","numbers","i","CHAINED_DOT_THOUSANDS_GROUPS","DIGITS_ONLY","bigIntLiteralDigits","raw","localeCode","withoutSuffix","digits","stripLocaleGrouping","separator","text","thousandsSeparator","getLocale"],"mappings":"uKAWO,IAAMA,CAAAA,CAAe,CAC1B,MAAA,CAAQ,CAAA,CACR,UAAA,CAAY,EAAA,CACZ,SAAA,CAAW,EAAA,CACX,UAAA,CAAY,EAAA,CAaZ,WAAA,CAAa,EAAA,CAab,SAAA,CAAW,EAAA,CACX,UAAA,CAAY,EAAA,CACZ,UAAA,CAAY,EAAA,CACZ,WAAA,CAAa,EAAA,CACb,KAAA,CAAO,EAAA,CACP,GAAA,CAAK,EAAA,CACL,OAAA,CAAS,EAAA,CAMT,WAAA,CAAa,EAAA,CAIb,QAAA,CAAU,GACV,MAAA,CAAQ,EAAA,CACR,OAAA,CAAS,EAAA,CACT,IAAA,CAAM,EACR,EAiDO,IAAMC,CAAAA,CAA2C,CAEtD,CAACC,mBAAAA,CAAW,IAAI,EAAOF,CAAAA,CAAa,GAAA,CACpC,CAACE,mBAAAA,CAAW,KAAK,EAAMF,CAAAA,CAAa,GAAA,CACpC,CAACE,mBAAAA,CAAW,IAAI,EAAOF,CAAAA,CAAa,OAAA,CACpC,CAACE,mBAAAA,CAAW,KAAK,EAAMF,CAAAA,CAAa,OAAA,CACpC,CAACE,mBAAAA,CAAW,GAAG,EAAQF,CAAAA,CAAa,OAAA,CAGpC,CAACE,mBAAAA,CAAW,KAAK,EAAMF,CAAAA,CAAa,QAAA,CAOpC,CAACE,mBAAAA,CAAW,MAAM,EAAKF,CAAAA,CAAa,SAAA,CACpC,CAACE,mBAAAA,CAAW,OAAO,EAAIF,CAAAA,CAAa,UAAA,CACpC,CAACE,mBAAAA,CAAW,OAAO,EAAIF,CAAAA,CAAa,UAAA,CACpC,CAACE,mBAA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AcL,CAAAA,CAA4B,CACtE,IAAMM,CAAAA,CAAqBC,mBAAAA,CAAUP,CAAU,CAAA,CAAE,OAAA,CAAQ,kBAAA,CACzD,OAAOM,CAAAA,CAAqBD,CAAAA,CAAK,KAAA,CAAMC,CAAkB,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA,CAAID,CACvE","file":"chunk-ZDJTDFTR.cjs","sourcesContent":["/**\n * Named precedence levels for the Pratt parser, from loosest (`Lowest`) to\n * tightest (`Call`) binding. A custom infix parselet compares its own\n * binding power against the current expression's to decide whether to\n * consume the next operator (higher power binds tighter, e.g. `*` over `+`).\n *\n * Package authors reference these when declaring an infix parselet in a\n * package's `infixParselets`. See the built-in packages for examples of\n * picking an appropriate level (e.g. arithmetic `+`/`-` use `Sum`, `*`/`/`\n * use `Product`).\n */\nexport const BindingPower = {\n Lowest: 0,\n Assignment: 10,\n LogicalOr: 12, // `or`, `||` — loosest of the boolean-logic operators\n LogicalAnd: 14, // `&&` — binds tighter than `or` (\"a or b and c\" = \"a or (b and c)\")\n // The word \"and\" (`AND_CONJ`), which is both arithmetic addition (\"5 and 3\"\n // is 8) and boolean conjunction (\"true and false\"). A phrase parselet\n // collecting a list (\"average of X, Y and Z\") parses each argument at this\n // level, and an argument stops at any operator whose power is <= the level it\n // was parsed at, so putting \"and\" here is what makes it end an argument\n // rather than be consumed as the addition it also is. Everything an argument\n // should keep binds tighter, including a genuine \"+\" (`Sum`).\n //\n // It sits BELOW `Conditional` because the boolean reading needs comparisons\n // to be its operands: at 28, \"5 > 3 and 2 > 1\" parsed as \"5 > (3 and 2) > 1\"\n // and answered false. Above `LogicalAnd` so that \"and\" is still the tighter\n // of the two conjunctions, and two steps off each neighbour to leave room.\n Conjunction: 16,\n // The bitwise trio and the shifts, ordered exactly as C and JavaScript order\n // them, which is the order every language that borrowed these operators from\n // C uses: `|` looser than `xor`, `xor` looser than `&`, all three looser than\n // comparison, and the shifts tighter than comparison but looser than `+`.\n // They used to share one level (35) between `Sum` and `Product`, so\n // \"1 + 2 << 3\" answered 17 where JavaScript answers 24 and \"4 & 3 + 1\"\n // answered 1 where JavaScript answers 4. Each has its own level now because\n // a shared level makes \"4 | 6 & 3\" group left instead of letting `&` win.\n //\n // They stay TIGHTER than `Conjunction` so that a phrase argument parsed at\n // that level (\"average of 5 | 3, 2 and 4\") keeps its bitwise operators\n // instead of stopping at the first one.\n BitwiseOr: 18, // `|`\n BitwiseXor: 20, // the `xor` keyword (`BIT_XOR`), not the `^` exponent token\n BitwiseAnd: 22, // `&`\n Conditional: 24, // comparisons (`==`, `<`, `>=`, ...), tighter than the bitwise trio, looser than the shifts\n Shift: 27, // `<<`, `>>`, `>>>`\n Sum: 30,\n Product: 40,\n // `±` (the uncertainty operator), tighter than `+ - * /` and looser than `^`,\n // so the tolerance attaches to its adjacent values: `12.3 ± 0.5 * 4` reads as\n // `(12.3 ± 0.5) * 4` (the parenthesised headline case), and `2 + 3 ± 0.5` as\n // `2 + (3 ± 0.5)`. A Tier-2 parselet (packages/uncertainty/), so this level is\n // read off the parselet rather than the Tier-1 BUILTIN_INFIX_BP table below.\n Uncertainty: 45,\n // `^`, RIGHT-associative: \"2 ^ 3 ^ 2\" is 2^(3^2) = 512, as in mathematics,\n // Python, Ruby and JavaScript's `**`. See PrecedenceParser.parseExpression\n // and BinaryOpParselet for the two places that associativity is implemented.\n Exponent: 50,\n Prefix: 60,\n Postfix: 70,\n Call: 80,\n} as const;\n\n/**\n * Set the binding power of a named operator.\n *\n * Binding power is what decides precedence in the Pratt parser: a higher number\n * binds tighter, so `*` outranks `+`. Changing one changes how every existing\n * expression using that operator parses, which is why packages should allocate\n * a new name rather than adjust a built-in.\n *\n * @param name - Operator name.\n * @param power - Higher binds tighter.\n */\nexport function setBindingPower(name: string, power: number): void {\n (BindingPower as Record<string, number>)[name] = power;\n}\n\n/**\n * Read the binding power of a named operator.\n *\n * @param name - Operator name.\n * @returns Its binding power, or 0 when the name is unknown, which makes an\n * unregistered operator terminate an expression rather than swallow the rest\n * of it.\n */\nexport function getBindingPower(name: string): number {\n return (BindingPower as Record<string, number>)[name] ?? 0;\n}\n\n// ── Built-in Infix Operator Binding Power Table ──────────────────────────────\n// Pre-computed Uint8Array lookup indexed by token typeId.\n// value > 0 → built-in infix operator with that binding power\n// value = 0 → not a built-in infix, fall through to Tier 2 parselet registry\n//\n// Built at module load via buildBindingPowerTable(). The table is sparse\n// most entries are 0 since only ~15 of 80+ token types are infix operators.\n//\n// Performance: Uint8Array[typeId] is a single typed array load, no Map.get()\n// no string hashing, no property chain. V8 eliminates bounds checks when typeId\n// is known to be within array length.\n\nimport { TokenTypes } from \"@solve-js/lexer/Token\";\nimport { tokenTypeId } from \"@solve-js/lexer/Token\";\n\n/**\n * Mapping of token type names → binding powers for built-in infix operators.\n * Only operators listed here get the Tier 1 fast path in PrecedenceParser.\n * All other infix tokens use the Tier 2 parselet registry fallback.\n */\nexport const BUILTIN_INFIX_BP: Record<string, number> = {\n // Arithmetic (infix, left-associative)\n [TokenTypes.PLUS]: BindingPower.Sum,\n [TokenTypes.MINUS]: BindingPower.Sum,\n [TokenTypes.STAR]: BindingPower.Product,\n [TokenTypes.SLASH]: BindingPower.Product,\n [TokenTypes.MOD]: BindingPower.Product,\n\n // Arithmetic (infix, RIGHT-associative, PrecedenceParser handles this specially)\n [TokenTypes.CARET]: BindingPower.Exponent,\n\n // Bitwise and shift (infix, left-associative), one level each, ordered as C\n // and JavaScript order them. `>>>` used to be missing from this table\n // entirely, which left it running at its Tier 2 parselet level while `>>`\n // ran at the Tier 1 one, so \"16 >> 3 & 1\" and \"16 >>> 3 & 1\" grouped\n // differently and answered 0 and 8.\n [TokenTypes.BIT_OR]: BindingPower.BitwiseOr,\n [TokenTypes.BIT_XOR]: BindingPower.BitwiseXor,\n [TokenTypes.BIT_AND]: BindingPower.BitwiseAnd,\n [TokenTypes.LSHIFT]: BindingPower.Shift,\n [TokenTypes.RSHIFT]: BindingPower.Shift,\n [TokenTypes.URSHIFT]: BindingPower.Shift,\n\n // Postfix (no right operand, PrecedenceParser handles this specially)\n [TokenTypes.PERCENT]: BindingPower.Postfix,\n\n // Percentage keyword (infix, left-associative: \"50% of 200\" → MUL)\n [TokenTypes.OF]: BindingPower.Product,\n};\n\n// Note: These token types are intentionally NOT in the BP_TABLE, they stay in\n// the Tier 2 parselet registry because they require complex handling:\n// IN, TO → UoM conversion parselets (peek at target unit token, complex logic)\n// DOT → Property access (chained OBJ_GET, needs left-token tracking)\n// EQUALS → Assignment (VariableParselet handles :var = expr pattern)\n// EQUALITY, NEQ, GTE, LTE → Comparison ops (need dedicated VM opcodes, task 2.15a)\n// COMMA → Argument separator (function calls, array/object literals)\n\n/** Cached BP_TABLE, built once at module load, immutable thereafter. */\nlet _bpTable: Uint8Array | null = null;\n\n/**\n * Build the Uint8Array binding power table indexed by token typeId.\n * Idempotent, returns cached table on subsequent calls.\n *\n * Must be called after all token types are registered (via registerAllTokenTypes())\n * and after plugin providers have registered their token types.\n */\nexport function buildBindingPowerTable(): Uint8Array {\n if (_bpTable) return _bpTable;\n\n // Size to the largest registered typeId + 1\n let maxId = 0;\n for (const name of Object.keys(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n // Also scan all TokenTypes to ensure table covers all registered IDs\n for (const name of Object.values(TokenTypes)) {\n const id = tokenTypeId(name);\n if (id > maxId) maxId = id;\n }\n\n const table = new Uint8Array(maxId + 1);\n for (const [name, bp] of Object.entries(BUILTIN_INFIX_BP)) {\n const id = tokenTypeId(name);\n table[id] = bp;\n }\n\n _bpTable = table;\n return table;\n}\n\n/**\n * Drop the cached table, so the next {@link buildBindingPowerTable} call builds\n * a fresh one sized to the token types registered by then.\n *\n * It does NOT add a plugin's operator to the Tier 1 fast path, which is what\n * this comment used to promise. The values in the table come from\n * `BUILTIN_INFIX_BP`, which is module-private and has no registration path, so\n * a rebuilt table holds the same binding powers and a plugin token still reads\n * 0. `PrecedenceParser.BP_TABLE` is a static initialized once at class\n * definition time and never re-read, so it would not see a rebuild anyway.\n *\n * A plugin's infix operator takes the Tier 2 parselet-registry route instead,\n * which is where an operator whose binding power the engine does not already\n * know is meant to live.\n */\nexport function invalidateBindingPowerTable(): void {\n _bpTable = null;\n}\n","import { OpCode } from \"@solve-js/parser/OpCode\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * `BytecodeProgram.opcodes` is a `Uint8Array`, every operand written into\n * it (including constant-pool indices from {@link BytecodeBuilder.emitNumber}/\n * {@link BytecodeBuilder.emitString}) is truncated to a single byte on\n * `build()`. Exceeding this silently wraps the index (e.g. entry 300 reads\n * back as entry 44), producing a wrong result with no error. See\n * {@link BytecodeBuilder.emitNumber} for the guard that turns this into a\n * thrown error instead.\n */\nconst MAX_CONSTANT_POOL_INDEX = 255;\n\n/** The `numberIndex` key for negative zero, which `Map` would otherwise fold into positive zero. */\nconst NEGATIVE_ZERO_KEY = \"-0\";\n\n/**\n * An operand that fits the byte the opcode stream stores it in, or a\n * structured refusal. `build()` copies the stream into a `Uint8Array`, which\n * keeps the low eight bits of whatever it is given: an operand of 300 used to\n * become 44 with no error, and the program then read a different constant,\n * plugin function or argument count from the one the parselet emitted. Every\n * raw operand goes through here, so a package author's mistake is reported at\n * compile time as a fault in the package rather than answered with a wrong\n * number.\n */\nfunction checkedOperand(value: number, what: string): number {\n\tif (!Number.isInteger(value) || value < 0 || value > 255) {\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"BYTECODE_OPERAND_OUT_OF_RANGE\",\n\t\t\t`A bytecode ${what} must be an integer from 0 to 255, but ${value} was emitted; the opcode stream stores one byte per operand.`,\n\t\t\t{ value, what }\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * Compiled bytecode program produced by {@link BytecodeBuilder}.\n * Ready for consumption by {@link executeBytecode} without further processing.\n */\nexport interface BytecodeProgram {\n\topcodes: Uint8Array;\n\tnumbers: Float64Array;\n\tstrings: string[];\n\t/**\n\t * Numeric constants by opcode position, restored from a snapshot.\n\t *\n\t * Nothing in the compile path writes this: numbers are emitted inline into\n\t * {@link numbers} instead. `build()` used to attach an empty Map to every\n\t * program anyway, which was one allocation per compiled expression, around a\n\t * tenth of parse-and-compile time, for a collection that was never read.\n\t * It is left off now, and only {@link EngineSnapshot} sets it when restoring\n\t * a program that carried one; every reader already guards on its absence.\n\t */\n\tconstants?: Map<number, number>;\n\t/**\n\t * Whether the program contains any async opcodes (CALL_PLUGIN, etc.).\n\t * Set during compilation by the BytecodeBuilder. Allows the engine\n\t * to skip the O(n) resolver preflight check in O(1) for purely\n\t * synchronous expressions like `2 + 2`.\n\t */\n\thasAsync: boolean;\n\t/**\n\t * User-defined-function bodies compiled alongside this program (one\n\t * entry per `name(params) = body` definition on this line). See\n\t * {@link BytecodeBuilder.emitUserFunctionBody}. `OpCode.DEFINE_USER_FUNCTION`'s\n\t * operand is an index into this array, resolved at VM-execution time\n\t * (not parse time) so a diagnostic/lookahead parse that never actually\n\t * executes the definition line has no side effect on `vm.userFunctions`.\n\t */\n\tuserFunctionBodies?: UserFunctionDef[];\n\t/**\n\t * Anonymous function bodies compiled alongside this program, one entry\n\t * per `map`/`reduce` inline transform expression (e.g. the `10*x` in\n\t * `map(10*x, [0,1,500])`). See {@link BytecodeBuilder.emitAnonymousBody}.\n\t * Deliberately a SEPARATE side-table from `userFunctionBodies`, not\n\t * routed through `vm.userFunctions` at all: an inline body has no name\n\t * and must never leak into the persistent name-keyed registry the way\n\t * a real `f(x) = ...` definition does.\n\t */\n\tanonymousBodies?: AnonymousBodyDef[];\n}\n\n/**\n * An anonymous transform body for `map`/`reduce`'s inline-expression form\n * (e.g. `10*x` in `map(10*x, [0,1,500])`, or `acc+x` in `reduce(acc+x,\n * [1,2,3])`). Structurally identical to {@link UserFunctionDef} minus the\n * `name`. See `OpCode.MAP_INVOKE`/`REDUCE_INVOKE` and\n * `vm/VM.ts`'s handlers, which build a call frame from `params`/`args`\n * exactly like `CALL_USER_FUNCTION` does, just without ever registering\n * the body in `vm.userFunctions`.\n */\nexport interface AnonymousBodyDef {\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * A user-defined, parameterized, reusable function's compiled form\n * (`f(x) = 2*x + 1`). See `OpCode.DEFINE_USER_FUNCTION`/`CALL_USER_FUNCTION`\n * and `vm/VM.ts`'s `VM.defineUserFunction`/`getUserFunction`.\n *\n * `program` is the body compiled to its OWN independent `BytecodeProgram`,\n * not a fragment of the definition line's own bytecode. Parameter names\n * inside the body compile to ORDINARY `LOAD_VAR <name>` opcodes, no\n * parse-time rewriting, because parameter resolution happens dynamically\n * at the VM level: `CALL_USER_FUNCTION` pushes a name-keyed call frame\n * (`Map<string, Value>`) before re-executing `program`, and `VM.getVar()`\n * checks the innermost call frame before falling back to the flat\n * document-variable store. This is why a `UNIT`-collision parameter name\n * (e.g. `h` in `area(w, h) = w * h`, which lexes as the \"hour\" unit) needs\n * no special handling anywhere, it's just another `LOAD_VAR \"h\"`, resolved\n * the same way as any other name.\n */\nexport interface UserFunctionDef {\n\tname: string;\n\tparams: string[];\n\tprogram: BytecodeProgram;\n}\n\n/**\n * Shared empty collections for programs that emit none.\n *\n * `build()` runs once per compiled expression, so an empty array allocated\n * there is an allocation per line of every document. Most programs emit no\n * strings at all (only the unit and datetime parselets do), and one that emits\n * no numbers is common too, so both were routinely allocating an empty\n * container that nothing would ever read.\n *\n * Sharing them is safe because a built program is read-only downstream: the VM\n * and the snapshot writer only index and iterate these, and nothing in the\n * engine pushes to `program.strings` or `program.numbers`. They are frozen so\n * that a future writer fails loudly here rather than silently corrupting every\n * other program that shares the instance.\n */\nconst EMPTY_STRINGS: readonly string[] = Object.freeze([]);\nconst EMPTY_NUMBERS = new Float64Array(0);\n\n/**\n * Direct-to-bytecode compiler for the Pratt parser.\n *\n * Accumulates opcodes, numeric constants, and string references during parsing,\n * then produces a {@link BytecodeProgram} for VM execution. Supports:\n * - Standard build via {@link build}\n * - Zero-copy build into pre-allocated buffers via {@link buildInto}\n * - In-place reset for reuse without reallocation\n */\nexport class BytecodeBuilder {\n\tprivate opcodes: number[] = [];\n\tprivate numbers: number[] = [];\n\tprivate strings: string[] = [];\n\tprivate stringIndex = new Map<string, number>();\n\t/** Value (or {@link NEGATIVE_ZERO_KEY}) to its slot in `numbers`, so a repeated literal is emitted once. */\n\tprivate numberIndex = new Map<number | string, number>();\n\tprivate _hasAsync = false;\n\tprivate userFunctionBodies: UserFunctionDef[] = [];\n\tprivate anonymousBodies: AnonymousBodyDef[] = [];\n\n\t/**\n\t * The per-engine `plugin function name -> registry index` map, wired in by\n\t * the engine so {@link emitPluginCall} can resolve a name at emit time. The\n\t * same object reference is shared with every builder in an engine (the pool\n\t * and each ad-hoc nested-body builder), and the engine populates it as\n\t * packages register, so a parselet never sees the numeric index.\n\t */\n\tconstructor(private readonly pluginFunctionIndex?: ReadonlyMap<string, number>) {}\n\n\t/** The name->index map, so a nested-body builder inherits the same resolution. */\n\tget pluginIndexMap(): ReadonlyMap<string, number> | undefined {\n\t\treturn this.pluginFunctionIndex;\n\t}\n\n\t/**\n\t * Emit a plugin-function call by NAME. The engine assigns each registered\n\t * `pluginFunctions` entry an index at registration; this resolves the name to\n\t * that index and emits `CALL_PLUGIN` + index + argCount. Package authors emit\n\t * through this rather than a hand-allocated index.\n\t */\n\temitPluginCall(name: string, argCount: number): void {\n\t\tconst index = this.pluginFunctionIndex?.get(name);\n\t\tif (index === undefined) {\n\t\t\tthrow ErrorFactory.execution(\n\t\t\t\t\"UNKNOWN_PLUGIN_FUNCTION\",\n\t\t\t\t`No registered plugin function named \"${name}\". A package must declare it in its pluginFunctions record and be registered before an expression using it is parsed.`,\n\t\t\t\t{ functionName: name },\n\t\t\t);\n\t\t}\n\t\t// One byte covers the first 256 plugin functions; beyond that, the\n\t\t// wide opcode carries a two-byte little-endian index. Emitting the\n\t\t// narrow form whenever it fits keeps existing bytecode and snapshots\n\t\t// byte-for-byte unchanged. The index cannot exceed 65535 because the\n\t\t// allocator (allocatePluginFunctionIndex) caps it, but guard anyway so\n\t\t// a stray index is a clear error rather than a silently truncated byte.\n\t\tif (index > 0xffff) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"PLUGIN_FUNCTION_INDEX_TOO_LARGE\",\n\t\t\t\t`Plugin-function index ${index} exceeds the two-byte bytecode limit (65535).`,\n\t\t\t\t{ index },\n\t\t\t);\n\t\t}\n\t\tif (index <= 0xff) {\n\t\t\tthis.emitOpcode(OpCode.CALL_PLUGIN);\n\t\t\tthis.emitIndex(index);\n\t\t} else {\n\t\t\tthis.emitOpcode(OpCode.CALL_PLUGIN_WIDE);\n\t\t\tthis.emitIndex(index & 0xff); // low byte\n\t\t\tthis.emitIndex((index >> 8) & 0xff); // high byte\n\t\t}\n\t\tthis.emitIndex(argCount);\n\t}\n\n\t/** Emit an {@link OpCode} instruction. */\n\temitOpcode(op: OpCode): void {\n\t\tthis.opcodes.push(op);\n\t\tif (op === OpCode.CALL_PLUGIN || op === OpCode.CALL_PLUGIN_WIDE) {\n\t\t\tthis._hasAsync = true;\n\t\t}\n\t}\n\n\t/**\n\t * Emit a numeric literal: interns `n` into the program's constant pool\n\t * (deduplicated, like {@link emitString}) and writes its index into the\n\t * opcode stream (read back by the VM as e.g. `PUSH_NUMBER <idx>`).\n\t *\n\t * Deduplicated so that the 256-entry pool counts distinct values rather\n\t * than occurrences: a long line of repeated literals used to exhaust it\n\t * long before it held 256 different numbers. Negative zero keeps its own\n\t * slot, because `1 / -0` is not `1 / 0`; NaN shares one, since every NaN\n\t * reads the same.\n\t *\n\t * @throws If the pool would exceed 256 distinct entries.\n\t */\n\temitNumber(n: number): void {\n\t\tconst key = Object.is(n, -0) ? NEGATIVE_ZERO_KEY : n;\n\t\tlet idx = this.numberIndex.get(key);\n\t\tif (idx === undefined) {\n\t\t\tidx = this.numbers.length;\n\t\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\t\"TOO_MANY_NUMERIC_CONSTANTS\",\n\t\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} distinct numeric literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.numbers.push(n);\n\t\t\tthis.numberIndex.set(key, idx);\n\t\t}\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a string literal: interns `s` into the program's string pool\n\t * (deduplicated via `stringIndex`) and writes its index into the opcode\n\t * stream. Subject to the same constant-pool bound as {@link emitNumber},\n\t * but since strings ARE deduplicated, only distinct string values count\n\t * against the limit.\n\t *\n\t * @throws If the string pool would exceed 256 distinct entries.\n\t */\n\temitString(s: string): void {\n\t\tlet idx = this.stringIndex.get(s);\n\t\tif (idx === undefined) {\n\t\t\tidx = this.strings.length;\n\t\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\t\"TOO_MANY_STRING_CONSTANTS\",\n\t\t\t\t\t`Expression has more than ${MAX_CONSTANT_POOL_INDEX + 1} distinct string literals, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.strings.push(s);\n\t\t\tthis.stringIndex.set(s, idx);\n\t\t}\n\t\tthis.opcodes.push(idx);\n\t}\n\n\t/**\n\t * Emit a raw numeric operand (0-255) following an opcode, e.g. a\n\t * plugin-function index for `CALL_PLUGIN`, or an argument count. Unlike\n\t * {@link emitOpcode}, this does not go through the `OpCode` enum, so\n\t * package authors use this (not an unsafe cast to `OpCode`) to push\n\t * operands their own opcode handler expects to read positionally.\n\t */\n\temitIndex(idx: number): void {\n\t\tthis.opcodes.push(checkedOperand(idx, \"index\"));\n\t}\n\n\t/** Emit a raw byte (0-255), used for fixed small operands like argument counts. */\n\temitByte(b: number): void {\n\t\tthis.opcodes.push(checkedOperand(b, \"byte\"));\n\t}\n\n\t/** Number of opcodes/operands emitted so far, used to compute jump targets before {@link patchJump}. */\n\tget currentLength(): number {\n\t\treturn this.opcodes.length;\n\t}\n\n\t/**\n\t * Register a compiled user-defined-function body, returning its index\n\t * into this program's `userFunctionBodies` side-table, the caller emits\n\t * that index as `DEFINE_USER_FUNCTION`'s operand via {@link emitIndex}.\n\t * Subject to the same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitNumber}/{@link emitString} (the index itself is a single\n\t * opcode-stream byte), in practice a single line defines at most a\n\t * handful of functions, so this limit is never realistically reached.\n\t *\n\t * @throws If more than 256 function bodies are registered on one program.\n\t */\n\temitUserFunctionBody(name: string, params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.userFunctionBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_FUNCTION_DEFINITIONS\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} function definitions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.userFunctionBodies.push({ name, params, program });\n\t\treturn idx;\n\t}\n\n\t/**\n\t * Register a compiled `map`/`reduce` anonymous transform body, returning\n\t * its index into this program's `anonymousBodies` side-table, the\n\t * caller emits that index as `MAP_INVOKE`/`REDUCE_INVOKE`'s operand via\n\t * {@link emitIndex}. Same {@link MAX_CONSTANT_POOL_INDEX} bound as\n\t * {@link emitUserFunctionBody}.\n\t *\n\t * @throws If more than 256 anonymous bodies are registered on one program.\n\t */\n\temitAnonymousBody(params: string[], program: BytecodeProgram): number {\n\t\tconst idx = this.anonymousBodies.length;\n\t\tif (idx > MAX_CONSTANT_POOL_INDEX) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"TOO_MANY_ANONYMOUS_BODIES\",\n\t\t\t\t`More than ${MAX_CONSTANT_POOL_INDEX + 1} map/reduce transform expressions on one line, exceeding the bytecode constant pool's limit.`,\n\t\t\t\t{ limit: MAX_CONSTANT_POOL_INDEX + 1 }\n\t\t\t);\n\t\t}\n\t\tthis.anonymousBodies.push({ params, program });\n\t\treturn idx;\n\t}\n\n\t/** Overwrite a previously-emitted placeholder operand at `position` with the real jump `target`, once known. */\n\tpatchJump(position: number, target: number): void {\n\t\tif (position < 0 || position >= this.opcodes.length) {\n\t\t\tthrow ErrorFactory.parsing(\n\t\t\t\t\"BYTECODE_OPERAND_OUT_OF_RANGE\",\n\t\t\t\t`patchJump was asked to write at position ${position}, outside the ${this.opcodes.length} bytes emitted so far.`,\n\t\t\t\t{ position, length: this.opcodes.length }\n\t\t\t);\n\t\t}\n\t\tthis.opcodes[position] = checkedOperand(target, \"jump target\");\n\t}\n\n\t/**\n\t * Build the accumulated opcodes/numbers/strings into a BytecodeProgram.\n\t * Creates new TypedArrays, the builder can be reused after this call.\n\t */\n\tbuild(): BytecodeProgram {\n\t\treturn {\n\t\t\topcodes: new Uint8Array(this.opcodes),\n\t\t\tnumbers: this.numbers.length > 0 ? new Float64Array(this.numbers) : EMPTY_NUMBERS,\n\t\t\t// Defensive copy when there is anything to copy: reset()'s\n\t\t\t// `.length = 0` would otherwise clear a reference the program still\n\t\t\t// holds. An empty one needs no copy, so it shares the frozen\n\t\t\t// singleton instead of allocating per program.\n\t\t\tstrings: this.strings.length > 0 ? [...this.strings] : (EMPTY_STRINGS as string[]),\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Build directly into a pre-allocated buffer for zero-copy VM consumption.\n\t *\n\t * When `buf` is provided and large enough, writes into it and returns\n\t * subarray **views** (not copies), the returned TypedArrays share the\n\t * buffer's underlying ArrayBuffer. The caller MUST NOT mutate the buffer\n\t * until the returned BytecodeProgram is no longer needed.\n\t *\n\t * If the caller intends to cache the result, they must copy the TypedArrays\n\t * (e.g. `new Uint8Array(program.opcodes)`) before reusing the buffer pool.\n\t *\n\t * When `buf` is omitted or too small, allocates fresh TypedArrays.\n\t */\n\tbuildInto(buf?: { opcodes: Uint8Array; numbers: Float64Array }): BytecodeProgram {\n\t\tconst opLen = this.opcodes.length;\n\t\tconst numLen = this.numbers.length;\n\n\t\tconst reuseOpcodes = buf && buf.opcodes.length >= opLen;\n\t\tconst reuseNumbers = buf && buf.numbers.length >= numLen;\n\n\t\t// Subarray views that share the buffer's ArrayBuffer (zero-copy)\n\t\tconst opcodes = reuseOpcodes\n\t\t\t? new Uint8Array(buf!.opcodes.buffer, buf!.opcodes.byteOffset, opLen)\n\t\t\t: new Uint8Array(opLen);\n\t\tconst numbers = reuseNumbers\n\t\t\t? new Float64Array(buf!.numbers.buffer, buf!.numbers.byteOffset, numLen)\n\t\t\t: new Float64Array(numLen);\n\n\t\t// Write data into the views\n\t\tfor (let i = 0; i < opLen; i++) opcodes[i] = this.opcodes[i];\n\t\tfor (let i = 0; i < numLen; i++) numbers[i] = this.numbers[i];\n\n\t\treturn {\n\t\t\topcodes,\n\t\t\tnumbers,\n\t\t\tstrings: [...this.strings],\n\t\t\thasAsync: this._hasAsync,\n\t\t\tuserFunctionBodies: this.userFunctionBodies.length > 0 ? [...this.userFunctionBodies] : undefined,\n\t\t\tanonymousBodies: this.anonymousBodies.length > 0 ? [...this.anonymousBodies] : undefined,\n\t\t};\n\t}\n\n\treset(): void {\n\t\t// Retain backing stores with .length = 0 to avoid reallocation on growth.\n\t\t// = [] discards the ArrayBuffer, forcing V8 to reallocate on every push()\n\t\t// threshold (4→8→16→32...). For a 50-opcode expression, that's 3-4 copies.\n\t\tthis.opcodes.length = 0;\n\t\tif (this.numbers.length > 0) {\n\t\t\tthis.numbers.length = 0;\n\t\t\tthis.numberIndex.clear();\n\t\t}\n\t\t// Guarded on being non-empty. reset() runs once per compiled expression\n\t\t// and a CPU profile put it at over a tenth of parse-and-compile, which\n\t\t// is a lot for clearing collections that are usually already empty:\n\t\t// most expressions emit no strings, and user function bodies are rarer\n\t\t// still. Emptying an empty Map is not free, and neither is the write\n\t\t// barrier on a length assignment.\n\t\tif (this.strings.length > 0) {\n\t\t\tthis.strings.length = 0;\n\t\t\tthis.stringIndex.clear();\n\t\t}\n\t\tthis._hasAsync = false;\n\t\tif (this.userFunctionBodies.length > 0) this.userFunctionBodies.length = 0;\n\t\tif (this.anonymousBodies.length > 0) this.anonymousBodies.length = 0;\n\t}\n}\n","/**\n * Turning a `123n` literal's source text into the digits `PUSH_BIGINT` stores.\n *\n * The lexer coalesces thousands groups into the number token it is building,\n * accepting both `,` and `.` as the separator regardless of locale (see\n * `lexer/ExpressionLexer.ts`'s \"Thousands separators\" block). For a NUMBER that\n * is fine, because the separators are stripped again when the text is turned\n * into a double. For a BIGINT nothing stripped them: both consumers took the\n * token text, removed the trailing `n`, and handed the rest straight to\n * `BigInt()`.\n *\n * So `1.000n` reached `BigInt(\"1.000\")`, which throws a raw `SyntaxError` that\n * arrived at the host as UNEXPECTED_ERROR/INTERNAL: the engine reporting its\n * own bug for six characters a user typed. `1.01n` and `1.1n` were fine, which\n * is the tell that the `n` suffix was never the problem, the three-digit\n * thousands group was: a dot followed by exactly three digits is what the lexer\n * swallows, and one followed by one or two digits it leaves alone.\n *\n * Written once here rather than inline at both call sites. There are two\n * (`parser/PrecedenceParser.ts`'s Tier-1 switch and\n * `packages/biginteger/parselets/BigIntNumberParselet.ts`), they already held\n * identical copies of the `n`-stripping, and the two tiers disagreeing about a\n * literal is a bug shape this codebase has had before.\n *\n * @module BigIntLiteral\n */\n\nimport { getLocale } from \"@solve-js/constants/locales\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Two or more dot-separated groups of three, e.g. `1.234.567`.\n *\n * Unambiguous in any locale, since no locale writes two decimal points, so this\n * is stripped without consulting one. Same regex and same reasoning as\n * `NumberParselet.ts`'s copy for the NUMBER path.\n */\nconst CHAINED_DOT_THOUSANDS_GROUPS = /^\\d{1,3}(\\.\\d{3}){2,}$/;\n\n/** Digits and nothing else, which is what `BigInt()` can be handed safely. */\nconst DIGITS_ONLY = /^\\d+$/;\n\n/**\n * The digit string behind a bigint literal.\n *\n * A bigint literal has no fractional part by construction: the lexer only emits\n * BIGINT when it saw no decimal point of its own and no exponent, so any `.` or\n * `,` still in the text got there as a thousands group. Which of the two the\n * writer meant is a locale question, and answering it wrongly would silently\n * change the value by three orders of magnitude, so only the separator this\n * locale actually uses for grouping is removed. Anything left over is refused\n * rather than guessed at.\n *\n * @param raw - The token's text, with or without the trailing `n`.\n * @param localeCode - The engine's active locale.\n * @returns A string of digits, ready for `BigInt()`.\n * @throws An `INVALID_NUMBER_LITERAL` parsing error when what is left is not a\n * whole number, e.g. `1.000n` in a locale that writes decimals with a dot.\n */\nexport function bigIntLiteralDigits(raw: string, localeCode: string): string {\n\tconst withoutSuffix = raw.endsWith(\"n\") ? raw.slice(0, -1) : raw;\n\n\t// The common case first: nothing was grouped, so there is nothing to decide.\n\tif (DIGITS_ONLY.test(withoutSuffix)) return withoutSuffix;\n\n\tconst digits = CHAINED_DOT_THOUSANDS_GROUPS.test(withoutSuffix)\n\t\t? withoutSuffix.split(\".\").join(\"\")\n\t\t: stripLocaleGrouping(withoutSuffix, localeCode);\n\n\tif (!DIGITS_ONLY.test(digits)) {\n\t\tconst separator = withoutSuffix.includes(\".\") ? \".\" : withoutSuffix.includes(\",\") ? \",\" : withoutSuffix;\n\t\tthrow ErrorFactory.parsing(\n\t\t\t\"INVALID_NUMBER_LITERAL\",\n\t\t\t`\"${raw}\" is not a whole number: \"${separator}\" separates decimals in the ${localeCode} locale, and a whole number cannot have a fractional part.`,\n\t\t\t{ raw, localeCode, separator },\n\t\t);\n\t}\n\treturn digits;\n}\n\n/**\n * Removes the active locale's own thousands separator and nothing else.\n *\n * @param text - The literal without its `n`.\n * @param localeCode - The engine's active locale.\n * @returns The text with grouping removed, which the caller then re-checks.\n */\nfunction stripLocaleGrouping(text: string, localeCode: string): string {\n\tconst thousandsSeparator = getLocale(localeCode).display.thousandsSeparator;\n\treturn thousandsSeparator ? text.split(thousandsSeparator).join(\"\") : text;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),chunkGXO7TSXQ_cjs=require('./chunk-GXO7TSXQ.cjs');function x(m,n,e){let r=Math.trunc(m),o=Math.trunc(n),a=Math.trunc(e);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(a))return Number.NaN;let t=r+Math.floor(o/12),i=(o%12+12)%12+1,s=t-(i<=2?1:0),l=Math.floor(s/400),u=s-l*400,N=Math.floor((153*(i+(i>2?-3:9))+2)/5),c=u*365+Math.floor(u/4)-Math.floor(u/100)+N;return l*146097+c-719468+(a-1)}function F(m){if(!Number.isFinite(m))return {year:Number.NaN,month0:Number.NaN,day:Number.NaN};let n=Math.trunc(m)+719468,e=Math.floor(n/146097),r=n-e*146097,o=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),a=r-(365*o+Math.floor(o/4)-Math.floor(o/100)),t=Math.floor((5*a+2)/153),i=a-Math.floor((153*t+2)/5)+1,s=t<10?t+3:t-9;return {year:o+e*400+(s<=2?1:0),month0:s-1,day:i}}var P=Object.freeze({year:Number.NaN,month0:Number.NaN,day:Number.NaN,weekday:Number.NaN,hour:Number.NaN,minute:Number.NaN,second:Number.NaN,millisecond:Number.NaN}),Z=864e13,d=864e5;function D(m){return !Number.isFinite(m)||Math.abs(m)>Z?Number.NaN:Math.trunc(m)}function z(m,n,e,r,o,a,t){let i=Math.trunc(r)*36e5+Math.trunc(o)*6e4+Math.trunc(a)*1e3+Math.trunc(t);return {dayNumber:x(m,n,e)+Math.floor(i/d),timeOfDay:(i%d+d)%d}}var S=/^([+-]\d{6}|\d{4})(?:-(\d{2})(?:-(\d{2}))?)?(?:[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?([Zz]|[+-]\d{2}:?\d{2})?$/,k=class{constructor(n,e={}){A(n),this.temporal=n;let r=e.timeZone??n.Now.timeZoneId(),o;try{o=n.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(r);}catch(a){throw chunkGXO7TSXQ_cjs.c.config(chunkGXO7TSXQ_cjs.r.TEMPORAL_TIME_ZONE_UNKNOWN,`The Temporal implementation does not know the time zone "${r}"`,{timeZone:r,cause:a instanceof Error?a.message:String(a)})}this.timeZone=o.timeZoneId,this.clock=e.now??(()=>n.Now.instant().epochMilliseconds);}now(){return this.clock()}fields(n){let e=this.zoned(n,this.timeZone);return e===null?P:{year:e.year,month0:e.month-1,day:e.day,weekday:e.dayOfWeek%7,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond}}localMidnight(n,e,r){return this.wallClock(n,e,r,0,0,0,0)}localWallClock(n,e,r,o){let a=this.localMidnight(n,e,r),t=this.fields(a);return Number.isNaN(t.year)?Number.NaN:this.wallClock(t.year,t.month0,t.day,t.hour,o,t.second,t.millisecond)}addDays(n,e){let r=this.fields(n);return Number.isNaN(r.year)?Number.NaN:this.wallClock(r.year,r.month0,r.day+e,r.hour,r.minute,r.second,r.millisecond)}addMonths(n,e){let r=this.fields(n);if(Number.isNaN(r.year))return Number.NaN;let o=r.day,a=this.fields(this.wallClock(r.year,r.month0,1,r.hour,r.minute,r.second,r.millisecond));if(Number.isNaN(a.year))return Number.NaN;let t=this.fields(this.wallClock(a.year,a.month0+e,a.day,a.hour,a.minute,a.second,a.millisecond));if(Number.isNaN(t.year))return Number.NaN;let i=Math.min(o,chunkE4HAKNBQ_cjs.b(t.year,t.month0));return this.wallClock(t.year,t.month0,i,t.hour,t.minute,t.second,t.millisecond)}utcOffsetMinutes(n){let e=this.zoned(n,this.timeZone);return e===null?Number.NaN:Math.trunc(e.offsetNanoseconds/6e10)||0}parseIso8601(n){let e=S.exec(n);if(e===null)return Number.NaN;let[,r,o,a,t,i,s,l,u]=e;if(r==="-000000")return Number.NaN;let N=Number(r),c=o===void 0?1:Number(o),f=a===void 0?1:Number(a),b=t===void 0?0:Number(t),h=i===void 0?0:Number(i),y=s===void 0?0:Number(s),I=l===void 0?0:Number(l.slice(0,3).padEnd(3,"0"));if(c<1||c>12||f<1||f>31||b>24||h>59||y>59||b===24&&(h!==0||y!==0||I!==0))return Number.NaN;let p=z(N,c-1,f,b,h,y,I);if(u===void 0&&t!==void 0)return this.resolve(p);let g=0;if(u!==void 0&&u!=="Z"&&u!=="z"){let _=u.slice(1).replace(":",""),w=Number(_.slice(0,2)),C=Number(_.slice(2,4));if(w>23||C>59)return Number.NaN;g=(u[0]==="-"?-1:1)*(w*60+C);}let O=p.dayNumber*d+p.timeOfDay-g*6e4;return Math.abs(O)>Z?Number.NaN:O}formatLongDate(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(r)}formatTimeOfDay(n,e){let r=D(n);return Number.isNaN(r)?"Invalid Date":new Intl.DateTimeFormat(e,{timeZone:this.timeZone,hour:"numeric",minute:"numeric",second:"numeric"}).format(r)}zoneOffsetMinutes(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n),a=Math.floor((r+o.offsetNanoseconds/1e6)/1e3)*1e3;return Math.round((a-e)/6e4)||0}fieldsInZone(n,e){let r=Number.isFinite(e)?Math.trunc(e):e,o=this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(n);return {year:o.year,month0:o.month-1,day:o.day,hour:o.hour,minute:o.minute,second:o.second}}zone(){return this.timeZone}formatTimeInZone(n,e){return chunkE4HAKNBQ_cjs.m(n,e)}formatDateInZone(n,e){return chunkE4HAKNBQ_cjs.n(n,e)}zoned(n,e){let r=D(n);if(Number.isNaN(r))return null;try{return this.temporal.Instant.fromEpochMilliseconds(r).toZonedDateTimeISO(e)}catch{return null}}wallClock(n,e,r,o,a,t,i){let s=n>=0&&n<=99?1900+Math.trunc(n):n;return this.resolve(z(s,e,r,o,a,t,i))}resolve(n){let e=F(n.dayNumber);if(Number.isNaN(e.year))return Number.NaN;let r=Math.floor(n.timeOfDay/36e5),o=Math.floor(n.timeOfDay/6e4)%60,a=Math.floor(n.timeOfDay/1e3)%60,t=n.timeOfDay%1e3;try{let s=this.temporal.PlainDateTime.from({year:e.year,month:e.month0+1,day:e.day,hour:r,minute:o,second:a,millisecond:t},{overflow:"reject"}).toZonedDateTime(this.timeZone,{disambiguation:"compatible"}).epochMilliseconds;return Math.abs(s)>Z?Number.NaN:s}catch{return Number.NaN}}};function A(m){let n=m,e=typeof n?.Now?.instant!="function"?"Now.instant":typeof n?.Now?.timeZoneId!="function"?"Now.timeZoneId":typeof n?.Instant?.fromEpochMilliseconds!="function"?"Instant.fromEpochMilliseconds":typeof n?.PlainDateTime?.from!="function"?"PlainDateTime.from":null;if(e!==null)throw chunkGXO7TSXQ_cjs.c.config(chunkGXO7TSXQ_cjs.r.TEMPORAL_IMPLEMENTATION_INVALID,`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${e}`,{missing:e})}function q(m,n={}){return new k(m,n)}exports.a=k;exports.b=q;//# sourceMappingURL=chunk-ZE5KKMBV.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-ZE5KKMBV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/temporal/CivilDays.ts","../src/temporal/TemporalCalendar.ts"],"names":["civilDayNumber","year","month0","day","y0","m0","d","y","m","shiftedYear","era","yearOfEra","dayOfYear","dayOfEra","civilFromDayNumber","days","z","monthFromMarch","month","NAN_FIELDS","MAX_INSTANT","MS_PER_DAY","clip","epochMs","normaliseWallClock","hour","minute","second","millisecond","time","ISO_DATE_TIME","TemporalCalendar","temporal","options","assertTemporalLike","requested","probe","error","ErrorFactory","CoreErrorCodes","minutesPastMidnight","anchored","a","f","months","f0","dayOfMonth","f1","f2","daysInMonth","text","yearText","monthText","dayText","hourText","minuteText","secondText","fractionText","zoneText","wall","offsetMinutes","digits","offsetHours","offsetMinutesPart","instant","locale","t","zone","wallSecond","timeInZone","dateInZone","windowed","civil","candidate","missing","createTemporalCalendar"],"mappings":"qHAkDO,SAASA,EAAeC,CAAAA,CAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CACjF,IAAMC,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAI,EACpBI,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMH,CAAM,EACtBI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMH,CAAG,EACxB,GAAI,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,MAAA,CAAO,QAAA,CAASC,CAAE,CAAA,EAAK,CAAC,OAAO,QAAA,CAASC,CAAC,EAAG,OAAO,MAAA,CAAO,GAAA,CAGvF,IAAMC,EAAIH,CAAAA,CAAK,IAAA,CAAK,KAAA,CAAMC,CAAAA,CAAK,EAAE,CAAA,CAC3BG,CAAAA,CAAAA,CAAMH,CAAAA,CAAK,EAAA,CAAM,IAAM,EAAA,CAAK,CAAA,CAG5BI,EAAcF,CAAAA,EAAKC,CAAAA,EAAK,EAAI,CAAA,CAAI,CAAA,CAAA,CAChCE,CAAAA,CAAM,IAAA,CAAK,MAAMD,CAAAA,CAAc,GAAG,CAAA,CAClCE,CAAAA,CAAYF,EAAcC,CAAAA,CAAM,GAAA,CAChCE,CAAAA,CAAY,IAAA,CAAK,OAAO,GAAA,EAAOJ,CAAAA,EAAKA,EAAI,CAAA,CAAI,EAAA,CAAK,IAAM,CAAA,EAAK,CAAC,CAAA,CAC7DK,CAAAA,CAAWF,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,OAAO,GACf,CACD,CACD,EAGA,SAAS9B,CAAAA,CAAmBF,CAAAA,CAAqD,CAChF,IAAMyC,CAAAA,CAAYzC,CAAAA,CACZ0C,CAAAA,CACL,OAAOD,CAAAA,EAAW,GAAA,EAAK,OAAA,EAAY,UAAA,CAAa,cAChD,OAAOA,CAAAA,EAAW,KAAK,UAAA,EAAe,UAAA,CAAa,iBACnD,OAAOA,CAAAA,EAAW,OAAA,EAAS,qBAAA,EAA0B,WAAa,+BAAA,CAClE,OAAOA,CAAAA,EAAW,aAAA,EAAe,MAAS,UAAA,CAAa,oBAAA,CACvD,IAAA,CACD,GAAIC,IAAY,IAAA,CACf,MAAMpC,oBAAa,MAAA,CAClBC,mBAAAA,CAAe,gCACf,CAAA,wJAAA,EAA2JmC,CAAO,CAAA,CAAA,CAClK,CAAE,QAAAA,CAAQ,CACX,CAEF,CAoBO,SAASC,CAAAA,CAAuB3C,CAAAA,CAAwBC,CAAAA,CAAmC,GAAsB,CACvH,OAAO,IAAIF,CAAAA,CAAiBC,CAAAA,CAAUC,CAAO,CAC9C","file":"chunk-ZE5KKMBV.cjs","sourcesContent":["/**\n * The day arithmetic behind `Date`'s field normalisation, for the `Temporal`\n * backend.\n *\n * `Date` normalises a set of wall-clock fields before it resolves them in a\n * zone: month 13 rolls into the next year, day 0 into the month before, a\n * time past midnight into the next day, and only the final instant is\n * clipped to the range `Date` represents. That is the `MakeDay` and\n * `MakeTime` order of the ECMAScript specification, and a backend built on\n * another library has to follow it to answer what `Date` answers on the last\n * representable day and for a rolled-over literal. `Date` does this\n * arithmetic inside its own setters, where a second backend cannot reach it,\n * so it is written out here with nothing clipped.\n *\n * Under `temporal/` rather than `calendar/Gregorian.ts` because only the\n * `Temporal` backend needs it: the `Date` backend gets the same arithmetic\n * from `Date` itself, and keeping it here keeps it out of the root entry's\n * bundle. The unit spec measures it against `Date.UTC` and `setUTCFullYear`\n * wherever `Date` can represent the date.\n *\n * @module CivilDays\n */\n\n/** A calendar date as year, zero-based month and day, the shape the civil-day arithmetic exchanges. */\nexport interface CivilDate {\n\treadonly year: number;\n\t/** Zero-based month: 0 is January, 11 is December. */\n\treadonly month0: number;\n\t/** Day of the month, from 1. */\n\treadonly day: number;\n}\n\n/**\n * The day number of a calendar date, counted from 1 January 1970, by\n * arithmetic alone: no `Date`, so no clip to the range `Date` represents.\n *\n * This is the `MakeDay` step of the ECMAScript specification, which a\n * backend needs unclipped: `Date` normalises a set of fields (month 13, day\n * 0, a time past midnight) before it resolves them in a zone and clips the\n * result, so a wall-clock time on the last representable day is an instant,\n * not `NaN`, and a backend built on another library must follow the same\n * order. An overflowing month or day rolls into the adjacent year or month,\n * as {@link utcMs}'s do, and a fractional field is truncated, as `Date`\n * truncates it.\n *\n * @param year - The calendar year, read as written.\n * @param month0 - Zero-based month; overflow rolls into the adjacent year.\n * @param day - Day of the month; overflow rolls into the adjacent month.\n * @returns Whole days since 1 January 1970, negative before it, or `NaN` when a field is not finite.\n */\nexport function civilDayNumber(year: number, month0: number, day: number): number {\n\tconst y0 = Math.trunc(year);\n\tconst m0 = Math.trunc(month0);\n\tconst d = Math.trunc(day);\n\tif (!Number.isFinite(y0) || !Number.isFinite(m0) || !Number.isFinite(d)) return Number.NaN;\n\t// Normalise the month into the year first, then count from the first of\n\t// that month, so a day of 0 or 40 is a plain offset from a real month.\n\tconst y = y0 + Math.floor(m0 / 12);\n\tconst m = ((m0 % 12) + 12) % 12 + 1;\n\t// The days-from-civil arithmetic, with the year taken to start in March\n\t// so a leap day is the last day of the cycle rather than an exception.\n\tconst shiftedYear = y - (m <= 2 ? 1 : 0);\n\tconst era = Math.floor(shiftedYear / 400);\n\tconst yearOfEra = shiftedYear - era * 400;\n\tconst dayOfYear = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5);\n\tconst dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\treturn era * 146_097 + dayOfEra - 719_468 + (d - 1);\n}\n\n/**\n * The calendar date of a day number, the inverse of {@link civilDayNumber}.\n *\n * @param days - Whole days since 1 January 1970, negative before it.\n * @returns The date, or `NaN` in every field when `days` is not finite.\n */\nexport function civilFromDayNumber(days: number): CivilDate {\n\tif (!Number.isFinite(days)) return { year: Number.NaN, month0: Number.NaN, day: Number.NaN };\n\tconst z = Math.trunc(days) + 719_468;\n\tconst era = Math.floor(z / 146_097);\n\tconst dayOfEra = z - era * 146_097;\n\tconst yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36_524) - Math.floor(dayOfEra / 146_096)) / 365);\n\tconst dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst monthFromMarch = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * monthFromMarch + 2) / 5) + 1;\n\tconst month = monthFromMarch < 10 ? monthFromMarch + 3 : monthFromMarch - 9;\n\tconst year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\treturn { year, month0: month - 1, day };\n}\n","/**\n * The `Temporal` calendar backend: the engine's date questions answered\n * through a `Temporal` implementation the host supplies, in a time zone the\n * host chooses.\n *\n * `Temporal` is the JavaScript standard library's replacement for `Date`. It\n * ships unflagged in Node 26 and in current Chrome, Firefox and Deno, but not\n * in Safari nor in Node 22 and 24, and the smallest polyfill adds about twenty\n * kilobytes gzipped to a bundle. The engine therefore imports no `Temporal`\n * and no polyfill: this module is reached only through the\n * `solve-engine/temporal` entry, and the host hands it the implementation to\n * use, `globalThis.Temporal` on a runtime that has one or a polyfill's export.\n * A host that never imports the entry pays nothing for it.\n *\n * The backend answers exactly what the `Date` backend answers. That is a\n * design constraint rather than a hope: `Temporal` and `Date` differ in what\n * they do with an out-of-range instant (`RangeError` against `NaN`), a\n * fractional millisecond (a throw against truncation), a day past the end of\n * a month (a clamp or a throw against a roll into the next month) and a year\n * from 0 to 99 (read literally against read as the 1900s), and every one of\n * those is reproduced here the way `Date` does it, because the engine's\n * results are measured against `Date` and a host switching backends must see\n * no result move. The differential suite under `__tests__/temporal/` is what\n * holds that line.\n *\n * The one thing that does change is the zone. `Date` reads the process's own\n * zone and nothing else; this backend reads the zone it was constructed with,\n * so a document can be computed in Tokyo from a server in London, or in a\n * zone the reader picks. That is the capability the backend adds, and the\n * only observable difference.\n *\n * The named-zone display strings go through the same `Intl.DateTimeFormat`\n * helpers the `Date` backend uses (`calendar/IntlZone.ts`), and the zone-free\n * arithmetic through `calendar/Gregorian.ts`, so the two backends share one\n * implementation wherever an answer does not depend on which backend is in\n * use. The one piece of arithmetic `Date` keeps inside its own setters, the\n * normalisation of overflowing fields, is written out in `CivilDays.ts`.\n *\n * @module TemporalCalendar\n */\n\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"@solve-js/calendar/CalendarBackend\";\nimport { daysInMonth } from \"@solve-js/calendar/Gregorian\";\nimport { civilDayNumber, civilFromDayNumber } from \"./CivilDays\";\nimport { dateInZone, timeInZone } from \"@solve-js/calendar/IntlZone\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { CoreErrorCodes } from \"@solve-js/errors/ErrorCode\";\n\n/**\n * The part of a `Temporal.Instant` the backend reads: its epoch milliseconds,\n * and the zoned date-time it shows in a named zone.\n */\nexport interface TemporalInstantLike {\n\treadonly epochMilliseconds: number;\n\ttoZonedDateTimeISO(timeZone: string): TemporalZonedDateTimeLike;\n}\n\n/**\n * The part of a `Temporal.ZonedDateTime` the backend reads: the calendar\n * fields (a one-based month and an ISO weekday, Monday 1 to Sunday 7, both\n * translated at the boundary), the offset, and the instant.\n */\nexport interface TemporalZonedDateTimeLike {\n\treadonly year: number;\n\t/** One-based month, 1 is January, as `Temporal` counts. */\n\treadonly month: number;\n\treadonly day: number;\n\t/** ISO weekday: Monday is 1, Sunday is 7. */\n\treadonly dayOfWeek: number;\n\treadonly hour: number;\n\treadonly minute: number;\n\treadonly second: number;\n\treadonly millisecond: number;\n\t/** The zone's offset from UTC at this instant, in nanoseconds, positive when ahead. */\n\treadonly offsetNanoseconds: number;\n\treadonly epochMilliseconds: number;\n\t/** The zone's canonical IANA identifier. */\n\treadonly timeZoneId: string;\n}\n\n/** The part of a `Temporal.PlainDateTime` the backend uses: resolving a wall-clock time to an instant in a zone. */\nexport interface TemporalPlainDateTimeLike {\n\ttoZonedDateTime(\n\t\ttimeZone: string,\n\t\toptions?: { disambiguation?: \"compatible\" | \"earlier\" | \"later\" | \"reject\" },\n\t): TemporalZonedDateTimeLike;\n}\n\n/** The wall-clock fields a `Temporal.PlainDateTime` is built from, with a one-based month. */\nexport interface TemporalDateTimeFields {\n\tyear: number;\n\t/** One-based month, 1 is January. */\n\tmonth: number;\n\tday: number;\n\thour: number;\n\tminute: number;\n\tsecond: number;\n\tmillisecond: number;\n}\n\n/**\n * The subset of the `Temporal` namespace the backend uses, as a structural\n * type, so the engine compiles and ships with no `Temporal` type installed\n * and a host passes whichever implementation it has: `globalThis.Temporal`\n * on Node 26 or a current browser, or the export of a polyfill such as\n * `temporal-polyfill`. Both satisfy this shape as they are.\n */\nexport interface TemporalLike {\n\treadonly Now: {\n\t\tinstant(): TemporalInstantLike;\n\t\ttimeZoneId(): string;\n\t};\n\treadonly Instant: {\n\t\tfromEpochMilliseconds(epochMilliseconds: number): TemporalInstantLike;\n\t};\n\treadonly PlainDateTime: {\n\t\tfrom(fields: TemporalDateTimeFields, options?: { overflow?: \"constrain\" | \"reject\" }): TemporalPlainDateTimeLike;\n\t};\n}\n\n/** What {@link createTemporalCalendar} takes beside the implementation. */\nexport interface TemporalCalendarOptions {\n\t/**\n\t * The IANA time zone the engine computes dates in (`\"Asia/Tokyo\"`,\n\t * `\"UTC\"`). Defaults to the runtime's own zone, `Temporal.Now.timeZoneId()`,\n\t * which is what the `Date` backend reads. A zone the implementation does\n\t * not know is refused at construction with `TEMPORAL_TIME_ZONE_UNKNOWN`.\n\t */\n\ttimeZone?: string;\n\t/**\n\t * The clock `now()` reads, in epoch milliseconds. Defaults to\n\t * `Temporal.Now.instant()`. A test pins a date with this: a fake-timer\n\t * library replaces `Date.now`, which the `Date` backend reads, but not\n\t * `Temporal.Now`, so this backend needs telling separately.\n\t */\n\tnow?: () => number;\n}\n\n/** The fields the `Date` backend answers for an instant it cannot represent. */\nconst NAN_FIELDS: CalendarFields = Object.freeze({\n\tyear: Number.NaN, month0: Number.NaN, day: Number.NaN, weekday: Number.NaN,\n\thour: Number.NaN, minute: Number.NaN, second: Number.NaN, millisecond: Number.NaN,\n});\n\n/** The largest magnitude `Date` represents, in milliseconds either side of the epoch. */\nconst MAX_INSTANT = 8.64e15;\n\n/** Milliseconds in a day of wall-clock fields, before any zone is consulted. */\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * An instant as `Date` would hold it: truncated to a whole millisecond, or\n * `NaN` when it is not finite or lies past the range `Date` represents. This\n * is `Date`'s own clip (its `TimeClip`), applied before an instant reaches\n * `Temporal`, which throws for both cases where `Date` answers `NaN`.\n */\nfunction clip(epochMs: number): number {\n\tif (!Number.isFinite(epochMs) || Math.abs(epochMs) > MAX_INSTANT) return Number.NaN;\n\treturn Math.trunc(epochMs);\n}\n\n/**\n * Wall-clock fields normalised the way `Date`'s `MakeDay` and `MakeTime`\n * normalise them, with nothing clipped: the day number of the date the\n * fields land on after any overflow rolls, and the time within that day.\n * Each field is truncated to an integer first, as `Date` truncates it.\n */\ninterface WallClock {\n\treadonly dayNumber: number;\n\treadonly timeOfDay: number;\n}\n\n/** `MakeDay` and `MakeTime`, then `MakeDate`, with a time past midnight carried into the day. */\nfunction normaliseWallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): WallClock {\n\tconst time = Math.trunc(hour) * 3_600_000 + Math.trunc(minute) * 60_000 + Math.trunc(second) * 1_000 + Math.trunc(millisecond);\n\tconst dayNumber = civilDayNumber(year, month0, day) + Math.floor(time / MS_PER_DAY);\n\treturn { dayNumber, timeOfDay: ((time % MS_PER_DAY) + MS_PER_DAY) % MS_PER_DAY };\n}\n\n/**\n * The ECMAScript date-time string format, as the `Date` constructor reads it:\n * a four-digit or six-digit signed year, an optional month and day, an\n * optional time to the millisecond (longer fractions are truncated), and an\n * optional `Z` or offset. The `T` and `Z` may be lower case, and an offset\n * may omit its colon; both are what the runtime's parser accepts.\n */\nconst ISO_DATE_TIME =\n\t/^([+-]\\d{6}|\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:[Tt](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?)?([Zz]|[+-]\\d{2}:?\\d{2})?$/;\n\n/**\n * A {@link CalendarBackend} over a `Temporal` implementation, computing in\n * one named time zone. Build one with {@link createTemporalCalendar}.\n *\n * Every method answers what the `Date` backend answers for the same inputs\n * when the zone is the process's own; see the module comment for the\n * differences between `Temporal` and `Date` that are reproduced deliberately.\n * The local methods answer `NaN` for an instant or a date the backend cannot\n * represent and never throw; the four named-zone methods throw the runtime's\n * `RangeError` for a zone it does not know or an instant it cannot represent,\n * which is the contract the interface states.\n */\nexport class TemporalCalendar implements CalendarBackend {\n\t/** The IANA zone every local answer is computed in, in its canonical spelling. */\n\treadonly timeZone: string;\n\n\tprivate readonly temporal: TemporalLike;\n\tprivate readonly clock: () => number;\n\n\tconstructor(temporal: TemporalLike, options: TemporalCalendarOptions = {}) {\n\t\tassertTemporalLike(temporal);\n\t\tthis.temporal = temporal;\n\t\tconst requested = options.timeZone ?? temporal.Now.timeZoneId();\n\t\tlet probe: TemporalZonedDateTimeLike;\n\t\ttry {\n\t\t\tprobe = temporal.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(requested);\n\t\t} catch (error) {\n\t\t\tthrow ErrorFactory.config(\n\t\t\t\tCoreErrorCodes.TEMPORAL_TIME_ZONE_UNKNOWN,\n\t\t\t\t`The Temporal implementation does not know the time zone \"${requested}\"`,\n\t\t\t\t{ timeZone: requested, cause: error instanceof Error ? error.message : String(error) },\n\t\t\t);\n\t\t}\n\t\t// The canonical spelling, so a zone given as `asia/tokyo` reads back as\n\t\t// the identifier the implementation itself uses.\n\t\tthis.timeZone = probe.timeZoneId;\n\t\tthis.clock = options.now ?? (() => temporal.Now.instant().epochMilliseconds);\n\t}\n\n\tnow(): number {\n\t\treturn this.clock();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return NAN_FIELDS;\n\t\treturn {\n\t\t\tyear: z.year,\n\t\t\tmonth0: z.month - 1,\n\t\t\tday: z.day,\n\t\t\t// ISO's Monday 1 to Sunday 7 becomes Date's Sunday 0 to Saturday 6.\n\t\t\tweekday: z.dayOfWeek % 7,\n\t\t\thour: z.hour,\n\t\t\tminute: z.minute,\n\t\t\tsecond: z.second,\n\t\t\tmillisecond: z.millisecond,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn this.wallClock(year, month0, day, 0, 0, 0, 0);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// `Date`'s sequence exactly: anchor at midnight, then set the minutes\n\t\t// FIELD, which reads the hour, second and millisecond back from the\n\t\t// anchored local time. On a day whose midnight falls in a\n\t\t// daylight-saving gap the anchor resolves to 1 am, and the hour it\n\t\t// reads back is 1, which is what makes the two backends agree there.\n\t\tconst anchored = this.localMidnight(year, month0, day);\n\t\tconst a = this.fields(anchored);\n\t\tif (Number.isNaN(a.year)) return Number.NaN;\n\t\treturn this.wallClock(a.year, a.month0, a.day, a.hour, minutesPastMidnight, a.second, a.millisecond);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\t// `setDate()`: the day field moves and the local time of day is held.\n\t\tconst f = this.fields(epochMs);\n\t\tif (Number.isNaN(f.year)) return Number.NaN;\n\t\treturn this.wallClock(f.year, f.month0, f.day + days, f.hour, f.minute, f.second, f.millisecond);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\t// The `Date` backend's three field writes, each resolved to an instant\n\t\t// and read back before the next, so that a wall-clock time landing in\n\t\t// a transition on an intermediate date shifts the same way it does\n\t\t// there: park on the 1st, move the month, then clamp the day.\n\t\tconst f0 = this.fields(epochMs);\n\t\tif (Number.isNaN(f0.year)) return Number.NaN;\n\t\tconst dayOfMonth = f0.day;\n\t\tconst f1 = this.fields(this.wallClock(f0.year, f0.month0, 1, f0.hour, f0.minute, f0.second, f0.millisecond));\n\t\tif (Number.isNaN(f1.year)) return Number.NaN;\n\t\tconst f2 = this.fields(this.wallClock(f1.year, f1.month0 + months, f1.day, f1.hour, f1.minute, f1.second, f1.millisecond));\n\t\tif (Number.isNaN(f2.year)) return Number.NaN;\n\t\tconst day = Math.min(dayOfMonth, daysInMonth(f2.year, f2.month0));\n\t\treturn this.wallClock(f2.year, f2.month0, day, f2.hour, f2.minute, f2.second, f2.millisecond);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\tconst z = this.zoned(epochMs, this.timeZone);\n\t\tif (z === null) return Number.NaN;\n\t\t// `getTimezoneOffset()` answers whole minutes, truncated toward zero,\n\t\t// which only shows for the local-mean-time offsets in force before a\n\t\t// zone adopted standard time (London's was -00:01:15 until 1847).\n\t\t// `|| 0` folds the -0 a small negative offset truncates to.\n\t\treturn Math.trunc(z.offsetNanoseconds / 60_000_000_000) || 0;\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// Only the format itself. The `Date` constructor falls back to a\n\t\t// legacy parser for a string the format rejects (one with a space\n\t\t// around it, say) and may guess an instant from it; the engine's own\n\t\t// gate admits only the format, so the two backends cannot disagree\n\t\t// through it, and outside it this backend answers NaN rather than guess.\n\t\tconst m = ISO_DATE_TIME.exec(text);\n\t\tif (m === null) return Number.NaN;\n\t\tconst [, yearText, monthText, dayText, hourText, minuteText, secondText, fractionText, zoneText] = m;\n\t\t// An expanded year of `-000000` names no year, by the format's own rule.\n\t\tif (yearText === \"-000000\") return Number.NaN;\n\t\tconst year = Number(yearText);\n\t\tconst month = monthText === undefined ? 1 : Number(monthText);\n\t\tconst day = dayText === undefined ? 1 : Number(dayText);\n\t\tconst hour = hourText === undefined ? 0 : Number(hourText);\n\t\tconst minute = minuteText === undefined ? 0 : Number(minuteText);\n\t\tconst second = secondText === undefined ? 0 : Number(secondText);\n\t\t// Only the first three digits of a fraction are milliseconds; the rest\n\t\t// are dropped rather than rounded, as the runtime's parser does.\n\t\tconst millisecond = fractionText === undefined ? 0 : Number(fractionText.slice(0, 3).padEnd(3, \"0\"));\n\t\t// The runtime checks a day against 31, not against the month, and lets\n\t\t// 30 February roll into March; 24:00 is the end of the day and nothing\n\t\t// past it is a time.\n\t\tif (month < 1 || month > 12 || day < 1 || day > 31) return Number.NaN;\n\t\tif (hour > 24 || minute > 59 || second > 59) return Number.NaN;\n\t\tif (hour === 24 && (minute !== 0 || second !== 0 || millisecond !== 0)) return Number.NaN;\n\n\t\t// The year is taken literally: the format has no 1900s window for a\n\t\t// year from 0 to 99, unlike the constructor.\n\t\tconst wall = normaliseWallClock(year, month - 1, day, hour, minute, second, millisecond);\n\t\tif (zoneText === undefined && hourText !== undefined) {\n\t\t\t// A date-time with no offset is local time, by the format's own rule.\n\t\t\treturn this.resolve(wall);\n\t\t}\n\t\t// A date-only string is UTC midnight, and an offset is subtracted.\n\t\tlet offsetMinutes = 0;\n\t\tif (zoneText !== undefined && zoneText !== \"Z\" && zoneText !== \"z\") {\n\t\t\tconst digits = zoneText.slice(1).replace(\":\", \"\");\n\t\t\tconst offsetHours = Number(digits.slice(0, 2));\n\t\t\tconst offsetMinutesPart = Number(digits.slice(2, 4));\n\t\t\tif (offsetHours > 23 || offsetMinutesPart > 59) return Number.NaN;\n\t\t\toffsetMinutes = (zoneText[0] === \"-\" ? -1 : 1) * (offsetHours * 60 + offsetMinutesPart);\n\t\t}\n\t\tconst instant = wall.dayNumber * MS_PER_DAY + wall.timeOfDay - offsetMinutes * 60_000;\n\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\t// `toLocaleDateString()` on an invalid date, rather than the throw\n\t\t// `Intl` would raise.\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return \"Invalid Date\";\n\t\t// `toLocaleTimeString()` with no options is the hour, minute and second\n\t\t// in the locale's own style.\n\t\treturn new Intl.DateTimeFormat(locale, {\n\t\t\ttimeZone: this.timeZone, hour: \"numeric\", minute: \"numeric\", second: \"numeric\",\n\t\t}).format(t);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// A fault here is the caller's to see, as the contract states, so no\n\t\t// clip: a non-finite instant reaches `Temporal` and throws its\n\t\t// RangeError, as an unknown zone does.\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t// The `Date` backend reads the zone's wall clock to the second and\n\t\t// rounds the difference from the instant to whole minutes; the same\n\t\t// arithmetic on the exact offset keeps the two answers identical for\n\t\t// the pre-standard-time offsets that are not whole minutes.\n\t\tconst wallSecond = Math.floor((t + z.offsetNanoseconds / 1e6) / 1000) * 1000;\n\t\treturn Math.round((wallSecond - epochMs) / 60_000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\tconst t = Number.isFinite(epochMs) ? Math.trunc(epochMs) : epochMs;\n\t\tconst z = this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\treturn { year: z.year, month0: z.month - 1, day: z.day, hour: z.hour, minute: z.minute, second: z.second };\n\t}\n\n\t/** The IANA zone this backend computes in, which is what `CalendarBackend.zone` documents. */\n\tzone(): string {\n\t\treturn this.timeZone;\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n\n\t/** The zoned date-time of an instant, or `null` where `Date` would answer `NaN`. */\n\tprivate zoned(epochMs: number, zone: string): TemporalZonedDateTimeLike | null {\n\t\tconst t = clip(epochMs);\n\t\tif (Number.isNaN(t)) return null;\n\t\ttry {\n\t\t\treturn this.temporal.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(zone);\n\t\t} catch {\n\t\t\t// Past the range the implementation represents in this zone.\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * The instant a set of local wall-clock fields names, with the fields\n\t * normalised the way `Date`'s constructor and setters normalise them\n\t * (month 12 is next January, day 0 the last of the month before, a year\n\t * from 0 to 99 the 1900s) before the zone is consulted.\n\t */\n\tprivate wallClock(year: number, month0: number, day: number, hour: number, minute: number, second: number, millisecond: number): number {\n\t\t// The constructor's two-digit-year window, applied to the year as\n\t\t// written and before any overflow, as `Date` applies it.\n\t\tconst windowed = year >= 0 && year <= 99 ? 1900 + Math.trunc(year) : year;\n\t\treturn this.resolve(normaliseWallClock(windowed, month0, day, hour, minute, second, millisecond));\n\t}\n\n\t/**\n\t * Normalised wall-clock fields resolved to an instant in the backend's\n\t * zone, clipped to the range `Date` represents only then, as `Date` clips\n\t * last. `compatible` disambiguation is `Date`'s rule: a time in a\n\t * spring-forward gap moves later by the gap, and a time that occurs twice\n\t * on a fall-back day is its first occurrence.\n\t */\n\tprivate resolve(wall: WallClock): number {\n\t\tconst civil = civilFromDayNumber(wall.dayNumber);\n\t\tif (Number.isNaN(civil.year)) return Number.NaN;\n\t\tconst hour = Math.floor(wall.timeOfDay / 3_600_000);\n\t\tconst minute = Math.floor(wall.timeOfDay / 60_000) % 60;\n\t\tconst second = Math.floor(wall.timeOfDay / 1_000) % 60;\n\t\tconst millisecond = wall.timeOfDay % 1_000;\n\t\ttry {\n\t\t\tconst plain = this.temporal.PlainDateTime.from(\n\t\t\t\t{ year: civil.year, month: civil.month0 + 1, day: civil.day, hour, minute, second, millisecond },\n\t\t\t\t{ overflow: \"reject\" },\n\t\t\t);\n\t\t\tconst instant = plain.toZonedDateTime(this.timeZone, { disambiguation: \"compatible\" }).epochMilliseconds;\n\t\t\treturn Math.abs(instant) > MAX_INSTANT ? Number.NaN : instant;\n\t\t} catch {\n\t\t\t// Past the range the implementation represents: `Date` answers NaN.\n\t\t\treturn Number.NaN;\n\t\t}\n\t}\n}\n\n/** Refuse anything that is not a usable `Temporal` before a method can fail on it obscurely. */\nfunction assertTemporalLike(temporal: unknown): asserts temporal is TemporalLike {\n\tconst candidate = temporal as Partial<TemporalLike> | null | undefined;\n\tconst missing =\n\t\ttypeof candidate?.Now?.instant !== \"function\" ? \"Now.instant\" :\n\t\ttypeof candidate?.Now?.timeZoneId !== \"function\" ? \"Now.timeZoneId\" :\n\t\ttypeof candidate?.Instant?.fromEpochMilliseconds !== \"function\" ? \"Instant.fromEpochMilliseconds\" :\n\t\ttypeof candidate?.PlainDateTime?.from !== \"function\" ? \"PlainDateTime.from\" :\n\t\tnull;\n\tif (missing !== null) {\n\t\tthrow ErrorFactory.config(\n\t\t\tCoreErrorCodes.TEMPORAL_IMPLEMENTATION_INVALID,\n\t\t\t`createTemporalCalendar needs a Temporal implementation (globalThis.Temporal on a runtime that ships it, or a polyfill's export); the value given has no ${missing}`,\n\t\t\t{ missing },\n\t\t);\n\t}\n}\n\n/**\n * A calendar backend over the host's `Temporal`, for the engine's `calendar`\n * option.\n *\n * ```ts\n * import { createEngine } from \"solve-engine\";\n * import { createTemporalCalendar } from \"solve-engine/temporal\";\n *\n * const calendar = createTemporalCalendar(globalThis.Temporal, { timeZone: \"Asia/Tokyo\" });\n * const engine = createEngine({ calendar });\n * ```\n *\n * @param temporal - The `Temporal` implementation: `globalThis.Temporal` where the runtime ships one, or a polyfill's export.\n * @param options - The zone to compute in and, for a test, the clock to read; see {@link TemporalCalendarOptions}.\n * @returns A backend that computes every date in that zone and answers what the `Date` backend would in it.\n * @throws `TEMPORAL_IMPLEMENTATION_INVALID` when `temporal` lacks the members the backend uses, and\n * `TEMPORAL_TIME_ZONE_UNKNOWN` when the implementation does not know the zone asked for.\n */\nexport function createTemporalCalendar(temporal: TemporalLike, options: TemporalCalendarOptions = {}): TemporalCalendar {\n\treturn new TemporalCalendar(temporal, options);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunk77KI7AKJ_cjs=require('./chunk-77KI7AKJ.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkYBQPEWT7_cjs=require('./chunk-YBQPEWT7.cjs');var N=32,L=2;function v(a){return a.shape!==void 0?a.shape:a.startTokenTypes!==void 0?[{types:a.startTokenTypes}]:[]}var x=class{constructor(e){this.rules=e;let r=e.length,t=Math.max(1,Math.ceil(r/N));this.words=t,this.scratch=new Uint32Array(t);let s=e.map(v),n=0;for(let l of s)for(let c of l)for(let f of c.types??[])n=Math.max(n,chunk5IJD5L3O_cjs.c(f));this.typeRows=n+1;let i=0;for(let l of s)i=Math.max(i,l.length);i=Math.min(i,L),this.allRules=new Uint32Array(t);for(let l=0;l<r;l++)this.allRules[l/N|0]|=1<<l%N;let u=[];for(let l=0;l<i;l++)u.push(this.buildPlane(s,l,t));this.planes=u;}buildPlane(e,r,t){let s={byType:new Uint32Array(this.typeRows*t),typeAny:new Uint32Array(t),atEnd:new Uint32Array(t),typeHasValues:new Uint8Array(this.typeRows),byValue:new Map,valueAny:new Uint32Array(t)};for(let n=0;n<e.length;n++){let i=e[n][r],u=n/N|0,l=1<<n%N,c=i?.types;if(c===void 0)s.typeAny[u]|=l,s.atEnd[u]|=l;else for(let p of c)s.byType[chunk5IJD5L3O_cjs.c(p)*t+u]|=l;let f=i?.values;if(f===void 0)s.valueAny[u]|=l;else {for(let p of f){let h=p.toLowerCase(),o=s.byValue.get(h);o===void 0&&(o=new Uint32Array(t),s.byValue.set(h,o)),o[u]|=l;}if(c===void 0)s.typeHasValues.fill(1);else for(let p of c){let h=chunk5IJD5L3O_cjs.c(p);h<this.typeRows&&(s.typeHasValues[h]=1);}}}return s}get size(){return this.rules.length}get depth(){return this.planes.length}candidates(e,r){let t=this.words,s=this.scratch,n=this.planes,i=e.length;if(n.length===0)return s.set(this.allRules),s;for(let u=0;u<n.length;u++){let l=n[u],c=r+u;if(c>=i){if(u===0)s.set(l.atEnd);else for(let o=0;o<t;o++)s[o]&=l.atEnd[o];continue}let f=e[c],p=f.typeId,h=p>=0&&p<this.typeRows?p*t:-1;if(u===0)if(h>=0)for(let o=0;o<t;o++)s[o]=l.byType[h+o]|l.typeAny[o];else s.set(l.typeAny);else if(h>=0)for(let o=0;o<t;o++)s[o]&=l.byType[h+o]|l.typeAny[o];else for(let o=0;o<t;o++)s[o]&=l.typeAny[o];if(h>=0&&l.typeHasValues[p]===1){let o=f.value,R=O(o)?o.toLowerCase():o,g=l.byValue.get(R);for(let T=0;T<t;T++)s[T]&=(g===void 0?0:g[T])|l.valueAny[T];}if(S(s))return s}return s}};function S(a){for(let e=0;e<a.length;e++)if(a[e]!==0)return false;return true}function O(a){for(let e=0;e<a.length;e++){let r=a.charCodeAt(e);if(r>=65&&r<=90)return true}return false}var B={maxPasses:100,maxTokens:1e4,onFusion:()=>{},ignoreRuleIndex:false};function C(a,e,r){let t=r[0],s=r[r.length-1],n=new chunk77KI7AKJ_cjs.a(a,chunk5IJD5L3O_cjs.c(a),e,e,t.offset,t.lineBreaks??0,t.line,t.col);return n.sourceEnd=s.sourceEnd??s.offset+s.text.length,n}function z(a,e){let r=e[e.length-1];r&&(a.sourceEnd=r.sourceEnd??r.offset+r.text.length);}var _=["NUMBER","HEX","BIGINT","FLOAT","LSHIFT","RSHIFT","BIT_AND","BIT_OR","BIT_XOR","LPAREN","RPAREN","LBRACKET","RBRACKET","COMMA","COLON","EQUALS","THEREFORE","PIPE","AMPERSAND","AT","SEMICOLON","QUESTION","EXCLAMATION","EOF","WS","NEWLINE"],M=(()=>{let a=_.map(t=>chunk5IJD5L3O_cjs.c(t)),e=Math.max(...a)+1,r=new Uint8Array(e);for(let t of a)r[t]=1;return r})(),P=new Set;function D(a){a.shape!==void 0&&a.shape.length>0||a.startTokenTypes===void 0&&a.unshapedReason===void 0&&(P.has(a.name)||(P.add(a.name),console.warn(`[TokenNormalizer] Rule "${a.name}" declares no \`shape\`, so it is tried at every token of every line and slows down documents that never use it. Declare the tokens it can start at, e.g. shape: [{ types: ["IDENT"], values: ["myword"] }, { types: ["LPAREN"] }]. If it genuinely cannot be described that way, set \`unshapedReason\` to say why and this warning will stop.`)));}var U=class{constructor(e={}){this.rules=[];this.sortedRulesCache=null;this.rulesByTokenType=new Map;this.ruleIndexCache=null;this.candidateBuffer=[];this.normalizeCalls=0;this.phraseTrie=new w;this.ruleShapesCache=null;this.options={...B,...e};}register(e){D(e),this.rules.push(e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}unregister(e){this.rules=this.rules.filter(r=>r.name!==e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}clear(){this.rules=[],this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null,this.phraseTrie=new w;}getSortedRules(){return this.sortedRulesCache===null&&(this.sortedRulesCache=[...this.rules].sort((e,r)=>r.priority-e.priority)),this.sortedRulesCache}getRuleIndex(){return this.ruleIndexCache===null&&(this.ruleIndexCache=new x(this.getSortedRules())),this.ruleIndexCache}rulesAt(e,r){if(e===null)return this.options.ignoreRuleIndex?this.getSortedRules():this.rulesForTokenType(r);let t=this.candidateBuffer;t.length=0;let s=this.getRuleIndex().rules;for(let n=0;n<e.length;n++){let i=e[n]>>>0,u=n*32;for(;i!==0;)(i&1)!==0&&t.push(s[u]),i>>>=1,u++;}return t}rulesForTokenType(e){let r=this.rulesByTokenType.get(e);return r===void 0&&(r=this.getSortedRules().filter(t=>{let s=v(t)[0];return s?.types===void 0||s.types.includes(e)}),this.rulesByTokenType.set(e,r)),r}get ruleCount(){return this.rules.length}getRuleShapes(){if(this.ruleShapesCache!==null)return this.ruleShapesCache;let e=this.getRuleIndex();return this.ruleShapesCache=this.getSortedRules().map(r=>{let t=v(r);return {name:r.name,priority:r.priority,shape:t,unshapedReason:r.unshapedReason,indexedSlots:Math.min(t.length,e.depth)}}),this.ruleShapesCache}getCandidateCounts(e){let r=this.getRuleIndex(),t=[];for(let s=0;s<e.length;s++){let n=r.candidates(e,s),i=0;for(let u=0;u<n.length;u++){let l=n[u]>>>0;for(;l!==0;)i+=l&1,l>>>=1;}t.push(i);}return t}addPhrase(e,r){this.phraseTrie.addPhrase(e,r);}getPhrases(){return this.phraseTrie.getAllPhrases()}canStartPhrase(e){return this.phraseTrie.canStart(e)}normalize(e,r){if(e.length===0)return e;let t=r??this.options.onFusion,s=this.options.maxPasses,n=this.options.maxTokens,i=this.normalizeCalls>0;i||(this.normalizeCalls=1);let u=i&&!this.options.ignoreRuleIndex,l=u?this.getRuleIndex():null,c=e,f=true,p=0;for(;f&&p<s;){f=false,p++;let h=null,o=0;for(;o<c.length;){let g=false,T=c[o].typeId;if(T>=M.length||M[T]===0){let m=this.phraseTrie.matchAt(c,o);if(m){let d=c.slice(o,o+m.consumed);h===null&&(h=c.slice(0,o));for(let A of m.replacement)h.push(A);m.consumed>1&&m.replacement.length===1&&(z(m.replacement[0],d),t({rule:m.ruleName??"phrase-trie",sourceTokens:d,fusedToken:m.replacement[0]})),o+=m.consumed,f=true;continue}}let I=u?l.candidates(c,o):null;if(I!==null&&S(I)){h!==null&&h.push(c[o]),o++;continue}for(let m of this.rulesAt(I,c[o].type)){let d=m.match(c,o);if(d){let A=c.slice(o,o+d.consumed);h===null&&(h=c.slice(0,o));for(let b of d.replacement)h.push(b);if(d.consumed>1&&d.replacement.length===1)z(d.replacement[0],A),t({rule:m.name,sourceTokens:A,fusedToken:d.replacement[0]});else if(d.consumed>1&&d.replacement.length<d.consumed)for(let b of d.replacement)t({rule:m.name,sourceTokens:A,fusedToken:b});o+=d.consumed,f=true,g=true;break}}g||(h!==null&&h.push(c[o]),o++);}if(h===null)break;let R=h;if(R.length>n)throw chunkYBQPEWT7_cjs.c.validation("NORMALIZED_TOKEN_LIMIT_EXCEEDED",`Normalized token count (${R.length}) exceeds safety limit (${n})`,{tokenCount:R.length,maxTokens:n});c=R;}return c}};var w=class{constructor(){this.startWords=new Set;this.root=new Map;}addPhrase(e,r){let t=e.toLowerCase().trim().split(/\s+/);if(t.length===0||t[0]==="")return;this.startWords.add(t[0]);let s=t[0],n;if(this.root.has(s)?n=this.root.get(s):(n={children:new Map,terminal:null},this.root.set(s,n)),t.length===1){n.terminal={tokenType:r,phrase:e,consumed:1};return}for(let i=1;i<t.length;i++){let u=t[i];n.children.has(u)||n.children.set(u,{children:new Map,terminal:null}),n=n.children.get(u);}n.terminal={tokenType:r,phrase:e,consumed:t.length};}matchAt(e,r){if(r>=e.length)return null;let t=e[r].type;if(t==="TAG"||t.startsWith("TAG_"))return null;let s=e[r].value.toLowerCase();if(!this.startWords.has(s))return null;let n=this.root.get(s);if(!n)return null;let i=null,u=1;if(n.terminal){let l=e.slice(r,r+1);i={consumed:1,replacement:[C(n.terminal.tokenType,n.terminal.phrase,l)],ruleName:n.terminal.phrase};}for(let l=r+1;l<e.length&&n?.children;l++){let c=e[l].type;if(c==="TAG"||c.startsWith("TAG_"))break;let f=e[l].value.toLowerCase();if(n=n.children.get(f),!n)break;if(u++,n.terminal){let p=e.slice(r,r+u);i={consumed:u,replacement:[C(n.terminal.tokenType,n.terminal.phrase,p)],ruleName:n.terminal.phrase};}}return i}get size(){return this.root.size}getAllPhrases(){let e={},r=(t,s)=>{t.terminal&&(e[s.join(" ")]=t.terminal.tokenType);for(let[n,i]of t.children)r(i,[...s,n]);};for(let[t,s]of this.root)r(s,[t]);return e}canStart(e){return this.startWords.has(e.toLowerCase())}};var F=new Set(["per","a","an","each","every"]),W=new Set(["to","power","increase","decrease","times","multiply","divide","by"]);function H(a=50,e){let r=e??(t=>W.has(t.toLowerCase()));return {name:"implicit:multiply",priority:a,shape:[{types:["NUMBER","RPAREN"]},{types:["IDENT","LPAREN","PI","E"]}],match(t,s){if(s+1>=t.length)return null;let n=t[s],i=t[s+1];if(!((n.type==="NUMBER"||n.type==="RPAREN")&&(i.type==="IDENT"||i.type==="LPAREN"||i.type==="PI"||i.type==="E")))return null;let l=i.value.toLowerCase();if(r(l)||F.has(l)&&t[s+2]?.type==="UNIT")return null;let c=new chunk77KI7AKJ_cjs.a("STAR",chunk5IJD5L3O_cjs.c("STAR"),"*","*",i.offset,0,i.line,i.col);return {consumed:1,replacement:[n,c]}}}}function ne(a,e){let r=[];for(let t=0;t<e;t++){let s=a[t];if(s.type==="LBRACKET")r.push(true);else if(s.type==="LPAREN"){let n=a[t-1],i=!!n&&(n.type==="MAP"||n.type==="REDUCE"||n.type==="SUM_FN"||n.type==="PROD_FN"||n.type==="IDENT"&&(n.value.toLowerCase()==="map"||n.value.toLowerCase()==="reduce"||n.value.toLowerCase()==="sum"||n.value.toLowerCase()==="prod"));r.push(i);}else (s.type==="RBRACKET"||s.type==="RPAREN")&&r.pop();}return r.length>0&&r[r.length-1]}function re(){return [H()]}exports.a=w;exports.b=C;exports.c=U;exports.d=H;exports.e=ne;exports.f=re;//# sourceMappingURL=chunk-GBCN7FNV.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunk6EYKVQT3_cjs=require('./chunk-6EYKVQT3.cjs'),chunkYBQOQTVL_cjs=require('./chunk-YBQOQTVL.cjs'),chunkGXO7TSXQ_cjs=require('./chunk-GXO7TSXQ.cjs');var N=32,L=2;function v(a){return a.shape!==void 0?a.shape:a.startTokenTypes!==void 0?[{types:a.startTokenTypes}]:[]}var x=class{constructor(e){this.rules=e;let r=e.length,t=Math.max(1,Math.ceil(r/N));this.words=t,this.scratch=new Uint32Array(t);let s=e.map(v),n=0;for(let l of s)for(let c of l)for(let f of c.types??[])n=Math.max(n,chunkYBQOQTVL_cjs.c(f));this.typeRows=n+1;let i=0;for(let l of s)i=Math.max(i,l.length);i=Math.min(i,L),this.allRules=new Uint32Array(t);for(let l=0;l<r;l++)this.allRules[l/N|0]|=1<<l%N;let u=[];for(let l=0;l<i;l++)u.push(this.buildPlane(s,l,t));this.planes=u;}buildPlane(e,r,t){let s={byType:new Uint32Array(this.typeRows*t),typeAny:new Uint32Array(t),atEnd:new Uint32Array(t),typeHasValues:new Uint8Array(this.typeRows),byValue:new Map,valueAny:new Uint32Array(t)};for(let n=0;n<e.length;n++){let i=e[n][r],u=n/N|0,l=1<<n%N,c=i?.types;if(c===void 0)s.typeAny[u]|=l,s.atEnd[u]|=l;else for(let p of c)s.byType[chunkYBQOQTVL_cjs.c(p)*t+u]|=l;let f=i?.values;if(f===void 0)s.valueAny[u]|=l;else {for(let p of f){let h=p.toLowerCase(),o=s.byValue.get(h);o===void 0&&(o=new Uint32Array(t),s.byValue.set(h,o)),o[u]|=l;}if(c===void 0)s.typeHasValues.fill(1);else for(let p of c){let h=chunkYBQOQTVL_cjs.c(p);h<this.typeRows&&(s.typeHasValues[h]=1);}}}return s}get size(){return this.rules.length}get depth(){return this.planes.length}candidates(e,r){let t=this.words,s=this.scratch,n=this.planes,i=e.length;if(n.length===0)return s.set(this.allRules),s;for(let u=0;u<n.length;u++){let l=n[u],c=r+u;if(c>=i){if(u===0)s.set(l.atEnd);else for(let o=0;o<t;o++)s[o]&=l.atEnd[o];continue}let f=e[c],p=f.typeId,h=p>=0&&p<this.typeRows?p*t:-1;if(u===0)if(h>=0)for(let o=0;o<t;o++)s[o]=l.byType[h+o]|l.typeAny[o];else s.set(l.typeAny);else if(h>=0)for(let o=0;o<t;o++)s[o]&=l.byType[h+o]|l.typeAny[o];else for(let o=0;o<t;o++)s[o]&=l.typeAny[o];if(h>=0&&l.typeHasValues[p]===1){let o=f.value,R=O(o)?o.toLowerCase():o,g=l.byValue.get(R);for(let T=0;T<t;T++)s[T]&=(g===void 0?0:g[T])|l.valueAny[T];}if(S(s))return s}return s}};function S(a){for(let e=0;e<a.length;e++)if(a[e]!==0)return false;return true}function O(a){for(let e=0;e<a.length;e++){let r=a.charCodeAt(e);if(r>=65&&r<=90)return true}return false}var B={maxPasses:100,maxTokens:1e4,onFusion:()=>{},ignoreRuleIndex:false};function C(a,e,r){let t=r[0],s=r[r.length-1],n=new chunk6EYKVQT3_cjs.a(a,chunkYBQOQTVL_cjs.c(a),e,e,t.offset,t.lineBreaks??0,t.line,t.col);return n.sourceEnd=s.sourceEnd??s.offset+s.text.length,n}function z(a,e){let r=e[e.length-1];r&&(a.sourceEnd=r.sourceEnd??r.offset+r.text.length);}var _=["NUMBER","HEX","BIGINT","FLOAT","LSHIFT","RSHIFT","BIT_AND","BIT_OR","BIT_XOR","LPAREN","RPAREN","LBRACKET","RBRACKET","COMMA","COLON","EQUALS","THEREFORE","PIPE","AMPERSAND","AT","SEMICOLON","QUESTION","EXCLAMATION","EOF","WS","NEWLINE"],M=(()=>{let a=_.map(t=>chunkYBQOQTVL_cjs.c(t)),e=Math.max(...a)+1,r=new Uint8Array(e);for(let t of a)r[t]=1;return r})(),P=new Set;function D(a){a.shape!==void 0&&a.shape.length>0||a.startTokenTypes===void 0&&a.unshapedReason===void 0&&(P.has(a.name)||(P.add(a.name),console.warn(`[TokenNormalizer] Rule "${a.name}" declares no \`shape\`, so it is tried at every token of every line and slows down documents that never use it. Declare the tokens it can start at, e.g. shape: [{ types: ["IDENT"], values: ["myword"] }, { types: ["LPAREN"] }]. If it genuinely cannot be described that way, set \`unshapedReason\` to say why and this warning will stop.`)));}var U=class{constructor(e={}){this.rules=[];this.sortedRulesCache=null;this.rulesByTokenType=new Map;this.ruleIndexCache=null;this.candidateBuffer=[];this.normalizeCalls=0;this.phraseTrie=new w;this.ruleShapesCache=null;this.options={...B,...e};}register(e){D(e),this.rules.push(e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}unregister(e){this.rules=this.rules.filter(r=>r.name!==e),this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null;}clear(){this.rules=[],this.sortedRulesCache=null,this.rulesByTokenType.clear(),this.ruleIndexCache=null,this.ruleShapesCache=null,this.phraseTrie=new w;}getSortedRules(){return this.sortedRulesCache===null&&(this.sortedRulesCache=[...this.rules].sort((e,r)=>r.priority-e.priority)),this.sortedRulesCache}getRuleIndex(){return this.ruleIndexCache===null&&(this.ruleIndexCache=new x(this.getSortedRules())),this.ruleIndexCache}rulesAt(e,r){if(e===null)return this.options.ignoreRuleIndex?this.getSortedRules():this.rulesForTokenType(r);let t=this.candidateBuffer;t.length=0;let s=this.getRuleIndex().rules;for(let n=0;n<e.length;n++){let i=e[n]>>>0,u=n*32;for(;i!==0;)(i&1)!==0&&t.push(s[u]),i>>>=1,u++;}return t}rulesForTokenType(e){let r=this.rulesByTokenType.get(e);return r===void 0&&(r=this.getSortedRules().filter(t=>{let s=v(t)[0];return s?.types===void 0||s.types.includes(e)}),this.rulesByTokenType.set(e,r)),r}get ruleCount(){return this.rules.length}getRuleShapes(){if(this.ruleShapesCache!==null)return this.ruleShapesCache;let e=this.getRuleIndex();return this.ruleShapesCache=this.getSortedRules().map(r=>{let t=v(r);return {name:r.name,priority:r.priority,shape:t,unshapedReason:r.unshapedReason,indexedSlots:Math.min(t.length,e.depth)}}),this.ruleShapesCache}getCandidateCounts(e){let r=this.getRuleIndex(),t=[];for(let s=0;s<e.length;s++){let n=r.candidates(e,s),i=0;for(let u=0;u<n.length;u++){let l=n[u]>>>0;for(;l!==0;)i+=l&1,l>>>=1;}t.push(i);}return t}addPhrase(e,r){this.phraseTrie.addPhrase(e,r);}getPhrases(){return this.phraseTrie.getAllPhrases()}canStartPhrase(e){return this.phraseTrie.canStart(e)}normalize(e,r){if(e.length===0)return e;let t=r??this.options.onFusion,s=this.options.maxPasses,n=this.options.maxTokens,i=this.normalizeCalls>0;i||(this.normalizeCalls=1);let u=i&&!this.options.ignoreRuleIndex,l=u?this.getRuleIndex():null,c=e,f=true,p=0;for(;f&&p<s;){f=false,p++;let h=null,o=0;for(;o<c.length;){let g=false,T=c[o].typeId;if(T>=M.length||M[T]===0){let m=this.phraseTrie.matchAt(c,o);if(m){let d=c.slice(o,o+m.consumed);h===null&&(h=c.slice(0,o));for(let A of m.replacement)h.push(A);m.consumed>1&&m.replacement.length===1&&(z(m.replacement[0],d),t({rule:m.ruleName??"phrase-trie",sourceTokens:d,fusedToken:m.replacement[0]})),o+=m.consumed,f=true;continue}}let I=u?l.candidates(c,o):null;if(I!==null&&S(I)){h!==null&&h.push(c[o]),o++;continue}for(let m of this.rulesAt(I,c[o].type)){let d=m.match(c,o);if(d){let A=c.slice(o,o+d.consumed);h===null&&(h=c.slice(0,o));for(let b of d.replacement)h.push(b);if(d.consumed>1&&d.replacement.length===1)z(d.replacement[0],A),t({rule:m.name,sourceTokens:A,fusedToken:d.replacement[0]});else if(d.consumed>1&&d.replacement.length<d.consumed)for(let b of d.replacement)t({rule:m.name,sourceTokens:A,fusedToken:b});o+=d.consumed,f=true,g=true;break}}g||(h!==null&&h.push(c[o]),o++);}if(h===null)break;let R=h;if(R.length>n)throw chunkGXO7TSXQ_cjs.c.validation("NORMALIZED_TOKEN_LIMIT_EXCEEDED",`Normalized token count (${R.length}) exceeds safety limit (${n})`,{tokenCount:R.length,maxTokens:n});c=R;}return c}};var w=class{constructor(){this.startWords=new Set;this.root=new Map;}addPhrase(e,r){let t=e.toLowerCase().trim().split(/\s+/);if(t.length===0||t[0]==="")return;this.startWords.add(t[0]);let s=t[0],n;if(this.root.has(s)?n=this.root.get(s):(n={children:new Map,terminal:null},this.root.set(s,n)),t.length===1){n.terminal={tokenType:r,phrase:e,consumed:1};return}for(let i=1;i<t.length;i++){let u=t[i];n.children.has(u)||n.children.set(u,{children:new Map,terminal:null}),n=n.children.get(u);}n.terminal={tokenType:r,phrase:e,consumed:t.length};}matchAt(e,r){if(r>=e.length)return null;let t=e[r].type;if(t==="TAG"||t.startsWith("TAG_"))return null;let s=e[r].value.toLowerCase();if(!this.startWords.has(s))return null;let n=this.root.get(s);if(!n)return null;let i=null,u=1;if(n.terminal){let l=e.slice(r,r+1);i={consumed:1,replacement:[C(n.terminal.tokenType,n.terminal.phrase,l)],ruleName:n.terminal.phrase};}for(let l=r+1;l<e.length&&n?.children;l++){let c=e[l].type;if(c==="TAG"||c.startsWith("TAG_"))break;let f=e[l].value.toLowerCase();if(n=n.children.get(f),!n)break;if(u++,n.terminal){let p=e.slice(r,r+u);i={consumed:u,replacement:[C(n.terminal.tokenType,n.terminal.phrase,p)],ruleName:n.terminal.phrase};}}return i}get size(){return this.root.size}getAllPhrases(){let e={},r=(t,s)=>{t.terminal&&(e[s.join(" ")]=t.terminal.tokenType);for(let[n,i]of t.children)r(i,[...s,n]);};for(let[t,s]of this.root)r(s,[t]);return e}canStart(e){return this.startWords.has(e.toLowerCase())}};var F=new Set(["per","a","an","each","every"]),W=new Set(["to","power","increase","decrease","times","multiply","divide","by"]);function H(a=50,e){let r=e??(t=>W.has(t.toLowerCase()));return {name:"implicit:multiply",priority:a,shape:[{types:["NUMBER","RPAREN"]},{types:["IDENT","LPAREN","PI","E"]}],match(t,s){if(s+1>=t.length)return null;let n=t[s],i=t[s+1];if(!((n.type==="NUMBER"||n.type==="RPAREN")&&(i.type==="IDENT"||i.type==="LPAREN"||i.type==="PI"||i.type==="E")))return null;let l=i.value.toLowerCase();if(r(l)||F.has(l)&&t[s+2]?.type==="UNIT")return null;let c=new chunk6EYKVQT3_cjs.a("STAR",chunkYBQOQTVL_cjs.c("STAR"),"*","*",i.offset,0,i.line,i.col);return {consumed:1,replacement:[n,c]}}}}function ne(a,e){let r=[];for(let t=0;t<e;t++){let s=a[t];if(s.type==="LBRACKET")r.push(true);else if(s.type==="LPAREN"){let n=a[t-1],i=!!n&&(n.type==="MAP"||n.type==="REDUCE"||n.type==="SUM_FN"||n.type==="PROD_FN"||n.type==="IDENT"&&(n.value.toLowerCase()==="map"||n.value.toLowerCase()==="reduce"||n.value.toLowerCase()==="sum"||n.value.toLowerCase()==="prod"));r.push(i);}else (s.type==="RBRACKET"||s.type==="RPAREN")&&r.pop();}return r.length>0&&r[r.length-1]}function re(){return [H()]}exports.a=w;exports.b=C;exports.c=U;exports.d=H;exports.e=ne;exports.f=re;//# sourceMappingURL=chunk-ZSLVLMO5.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-ZSLVLMO5.cjs.map
|