solve-engine 2.14.1 → 2.16.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/{BytecodeBuilder-BGq9ZiO3.d.cts → BytecodeBuilder-CRYfrFfq.d.cts} +2 -1
- package/dist/{BytecodeBuilder-BGq9ZiO3.d.ts → BytecodeBuilder-CRYfrFfq.d.ts} +2 -1
- package/dist/{EngineError-Ce1lPkjZ.d.cts → EngineError-Cv5q4Rbv.d.cts} +3 -1
- package/dist/{EngineError-Ce1lPkjZ.d.ts → EngineError-Cv5q4Rbv.d.ts} +3 -1
- package/dist/{PackageCompatibility-mqlZvt2e.d.cts → PackageCompatibility-BET0iFb9.d.cts} +1 -1
- package/dist/{PackageCompatibility-CXmG2lCU.d.ts → PackageCompatibility-CHQ4kDT8.d.ts} +1 -1
- package/dist/{PackageRegistry-T3MTYZrM.d.cts → PackageRegistry-DzmG-Rvu.d.cts} +35 -6
- package/dist/{PackageRegistry-CdRD2O6r.d.ts → PackageRegistry-YmfowYr1.d.ts} +35 -6
- package/dist/{Parselet-Blq8B0Gj.d.ts → Parselet-CK0bNO1l.d.ts} +2 -2
- package/dist/{Parselet-BSndkWEY.d.cts → Parselet-DOGmj6N6.d.cts} +2 -2
- package/dist/{ScopeManager-D8nLv--u.d.cts → ScopeManager-BtqiTVjG.d.cts} +3 -3
- package/dist/{ScopeManager-CF3cZUqW.d.ts → ScopeManager-C6c1WmJD.d.ts} +3 -3
- package/dist/{TokenNormalizer-DnlL7_8c.d.cts → TokenNormalizer-BfTHg1qt.d.cts} +35 -0
- package/dist/{TokenNormalizer-DCWdZjGz.d.ts → TokenNormalizer-d7F1KQFs.d.ts} +35 -0
- package/dist/{VMCheckpoints-Dy39SVHa.d.cts → VMCheckpoints-BFDlaGse.d.cts} +2 -2
- package/dist/{VMCheckpoints-BsR5_auF.d.ts → VMCheckpoints-DJdvpliw.d.ts} +2 -2
- package/dist/{WorkerError-B4p6PNfx.d.cts → WorkerError-FH7KXX4_.d.cts} +1 -1
- package/dist/{WorkerError-Dhj9BQ_A.d.ts → WorkerError-J3v3ix_z.d.ts} +1 -1
- package/dist/{chunk-75XDS65A.cjs → chunk-2XZCLDHJ.cjs} +2 -2
- package/dist/chunk-2XZCLDHJ.cjs.map +1 -0
- package/dist/chunk-35RNQ2OQ.js +5 -0
- package/dist/chunk-35RNQ2OQ.js.map +1 -0
- package/dist/{chunk-WN7L3ISM.js → chunk-55B4PSPM.js} +2 -2
- package/dist/{chunk-WN7L3ISM.js.map → chunk-55B4PSPM.js.map} +1 -1
- package/dist/chunk-5CWVWMIY.js +2 -0
- package/dist/chunk-5CWVWMIY.js.map +1 -0
- package/dist/{chunk-GKJY7QTV.js → chunk-5EX2FCM3.js} +3 -3
- package/dist/{chunk-GKJY7QTV.js.map → chunk-5EX2FCM3.js.map} +1 -1
- package/dist/{chunk-PNDQRCRQ.cjs → chunk-6U66HQKQ.cjs} +2 -2
- package/dist/chunk-6U66HQKQ.cjs.map +1 -0
- package/dist/chunk-7EMZOBGW.cjs +3 -0
- package/dist/chunk-7EMZOBGW.cjs.map +1 -0
- package/dist/{chunk-VBSMA7WJ.cjs → chunk-ABVDKMNF.cjs} +2 -2
- package/dist/chunk-ABVDKMNF.cjs.map +1 -0
- package/dist/chunk-C5MP74ER.js +2 -0
- package/dist/chunk-C5MP74ER.js.map +1 -0
- package/dist/{chunk-JQBG3LX4.js → chunk-CUDPOWXA.js} +2 -2
- package/dist/{chunk-JQBG3LX4.js.map → chunk-CUDPOWXA.js.map} +1 -1
- package/dist/chunk-EEVUKZ5B.cjs +2 -0
- package/dist/{chunk-EURCQMZK.cjs.map → chunk-EEVUKZ5B.cjs.map} +1 -1
- package/dist/chunk-ERMNQ5QJ.js +2 -0
- package/dist/chunk-ERMNQ5QJ.js.map +1 -0
- package/dist/{chunk-V7UBTBYS.cjs → chunk-EXCFCHAT.cjs} +2 -2
- package/dist/{chunk-V7UBTBYS.cjs.map → chunk-EXCFCHAT.cjs.map} +1 -1
- package/dist/{chunk-N2YOOLUE.cjs → chunk-FAGFPVYK.cjs} +2 -2
- package/dist/{chunk-N2YOOLUE.cjs.map → chunk-FAGFPVYK.cjs.map} +1 -1
- package/dist/chunk-FVQWN5HZ.cjs +2 -0
- package/dist/chunk-FVQWN5HZ.cjs.map +1 -0
- package/dist/{chunk-4BZIYU7S.cjs → chunk-GWCBPITD.cjs} +3 -3
- package/dist/{chunk-4BZIYU7S.cjs.map → chunk-GWCBPITD.cjs.map} +1 -1
- package/dist/{chunk-YAYBVVG2.js → chunk-GWJJRH32.js} +3 -3
- package/dist/{chunk-YAYBVVG2.js.map → chunk-GWJJRH32.js.map} +1 -1
- package/dist/{chunk-MVP2YD4X.cjs → chunk-HG4NPDN5.cjs} +2 -2
- package/dist/{chunk-MVP2YD4X.cjs.map → chunk-HG4NPDN5.cjs.map} +1 -1
- package/dist/{chunk-FNNIAJNY.cjs → chunk-IMXSVHQK.cjs} +2 -2
- package/dist/{chunk-FNNIAJNY.cjs.map → chunk-IMXSVHQK.cjs.map} +1 -1
- package/dist/{chunk-LH7URJZT.js → chunk-IPOU3JTA.js} +3 -3
- package/dist/{chunk-LH7URJZT.js.map → chunk-IPOU3JTA.js.map} +1 -1
- package/dist/{chunk-WTEXBPBR.js → chunk-JOIQFDZQ.js} +2 -2
- package/dist/chunk-JOIQFDZQ.js.map +1 -0
- package/dist/{chunk-KHCNMNZZ.js → chunk-JP4JMQOG.js} +2 -2
- package/dist/{chunk-KHCNMNZZ.js.map → chunk-JP4JMQOG.js.map} +1 -1
- package/dist/{chunk-62LMTO4F.js → chunk-LHLW7JLS.js} +2 -2
- package/dist/{chunk-62LMTO4F.js.map → chunk-LHLW7JLS.js.map} +1 -1
- package/dist/chunk-LZSSAH5D.cjs +2 -0
- package/dist/chunk-LZSSAH5D.cjs.map +1 -0
- package/dist/{chunk-SOMGSIO4.cjs → chunk-NAZ6PGLS.cjs} +2 -2
- package/dist/chunk-NAZ6PGLS.cjs.map +1 -0
- package/dist/{chunk-A33K7NY4.js → chunk-O3ALJLYC.js} +2 -2
- package/dist/chunk-O3ALJLYC.js.map +1 -0
- package/dist/chunk-P4ETODMP.js +2 -0
- package/dist/chunk-P4ETODMP.js.map +1 -0
- package/dist/{chunk-P6WPEUAJ.cjs → chunk-PREIL3IB.cjs} +2 -2
- package/dist/{chunk-P6WPEUAJ.cjs.map → chunk-PREIL3IB.cjs.map} +1 -1
- package/dist/chunk-Q3PSTNSY.js +2 -0
- package/dist/chunk-Q3PSTNSY.js.map +1 -0
- package/dist/{chunk-MSYX32PF.cjs → chunk-S3DFU33X.cjs} +2 -2
- package/dist/{chunk-MSYX32PF.cjs.map → chunk-S3DFU33X.cjs.map} +1 -1
- package/dist/chunk-SPOECHDG.cjs +5 -0
- package/dist/chunk-SPOECHDG.cjs.map +1 -0
- package/dist/{chunk-TEX2VB7U.js → chunk-TVE2DNPU.js} +2 -2
- package/dist/{chunk-TEX2VB7U.js.map → chunk-TVE2DNPU.js.map} +1 -1
- package/dist/{chunk-YNMMRH44.js → chunk-TZYMXNIB.js} +2 -2
- package/dist/chunk-TZYMXNIB.js.map +1 -0
- package/dist/{chunk-6TPXH6Y5.cjs → chunk-UUAFDZK6.cjs} +3 -3
- package/dist/{chunk-6TPXH6Y5.cjs.map → chunk-UUAFDZK6.cjs.map} +1 -1
- package/dist/{chunk-DYPIAHRW.js → chunk-UZSPBFZN.js} +2 -2
- package/dist/{chunk-DYPIAHRW.js.map → chunk-UZSPBFZN.js.map} +1 -1
- package/dist/chunk-VJP4GGCW.cjs +2 -0
- package/dist/chunk-VJP4GGCW.cjs.map +1 -0
- package/dist/{chunk-5DYMAQFI.cjs → chunk-VOTTSM4L.cjs} +3 -3
- package/dist/{chunk-5DYMAQFI.cjs.map → chunk-VOTTSM4L.cjs.map} +1 -1
- package/dist/chunk-W5ELYJ4Z.cjs +2 -0
- package/dist/chunk-W5ELYJ4Z.cjs.map +1 -0
- package/dist/chunk-W64AWQCX.js +3 -0
- package/dist/chunk-W64AWQCX.js.map +1 -0
- package/dist/{chunk-YTCTUBR2.js → chunk-WOIJPV7Z.js} +2 -2
- package/dist/{chunk-YTCTUBR2.js.map → chunk-WOIJPV7Z.js.map} +1 -1
- package/dist/{chunk-MVZUTETT.js → chunk-XK23K3EJ.js} +2 -2
- package/dist/{chunk-MVZUTETT.js.map → chunk-XK23K3EJ.js.map} +1 -1
- package/dist/{chunk-GBQ34WG5.cjs → chunk-XZYZS4BP.cjs} +2 -2
- package/dist/{chunk-GBQ34WG5.cjs.map → chunk-XZYZS4BP.cjs.map} +1 -1
- package/dist/{chunk-MPB7KUN5.js → chunk-YAZ4DUJJ.js} +2 -2
- package/dist/chunk-YAZ4DUJJ.js.map +1 -0
- package/dist/chunk-Z4BXU65Y.cjs +2 -0
- package/dist/chunk-Z4BXU65Y.cjs.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +9 -9
- package/dist/engine.d.ts +9 -9
- 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.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/language.d.cts +8 -8
- package/dist/language.d.ts +8 -8
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +2 -2
- package/dist/normalizer.d.ts +2 -2
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +7 -7
- package/dist/packages.d.ts +7 -7
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +3 -3
- package/dist/parser.d.ts +3 -3
- package/dist/parser.js +1 -1
- package/dist/{pipeline-BM8xc0CZ.d.cts → pipeline-B4wf3M1h.d.cts} +5 -24
- package/dist/{pipeline-J2ehIm7t.d.ts → pipeline-QIT4iD8f.d.ts} +5 -24
- package/dist/resolvers.d.cts +1 -1
- package/dist/resolvers.d.ts +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +8 -8
- package/dist/testing.d.ts +8 -8
- package/dist/testing.js +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +1 -1
- package/dist/uom.d.ts +1 -1
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +8 -7
- package/dist/vm.d.ts +8 -7
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.d.cts +8 -8
- package/dist/worker.d.ts +8 -8
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4QVBSG6B.cjs +0 -2
- package/dist/chunk-4QVBSG6B.cjs.map +0 -1
- package/dist/chunk-556Q7VZC.cjs +0 -2
- package/dist/chunk-556Q7VZC.cjs.map +0 -1
- package/dist/chunk-75XDS65A.cjs.map +0 -1
- package/dist/chunk-A33K7NY4.js.map +0 -1
- package/dist/chunk-BCBKL76C.cjs +0 -3
- package/dist/chunk-BCBKL76C.cjs.map +0 -1
- package/dist/chunk-EGICX6MR.js +0 -5
- package/dist/chunk-EGICX6MR.js.map +0 -1
- package/dist/chunk-EURCQMZK.cjs +0 -2
- package/dist/chunk-FUDVKPB7.cjs +0 -2
- package/dist/chunk-FUDVKPB7.cjs.map +0 -1
- package/dist/chunk-JEFMG6CV.js +0 -2
- package/dist/chunk-JEFMG6CV.js.map +0 -1
- package/dist/chunk-K4MME6ZT.js +0 -2
- package/dist/chunk-K4MME6ZT.js.map +0 -1
- package/dist/chunk-KTXFIJL2.cjs +0 -2
- package/dist/chunk-KTXFIJL2.cjs.map +0 -1
- package/dist/chunk-MPB7KUN5.js.map +0 -1
- package/dist/chunk-MPFPYI6H.cjs +0 -2
- package/dist/chunk-MPFPYI6H.cjs.map +0 -1
- package/dist/chunk-PNDQRCRQ.cjs.map +0 -1
- package/dist/chunk-QCJFGGQS.js +0 -2
- package/dist/chunk-QCJFGGQS.js.map +0 -1
- package/dist/chunk-RVVRIKM7.cjs +0 -5
- package/dist/chunk-RVVRIKM7.cjs.map +0 -1
- package/dist/chunk-SOMGSIO4.cjs.map +0 -1
- package/dist/chunk-VBSMA7WJ.cjs.map +0 -1
- package/dist/chunk-WTEXBPBR.js.map +0 -1
- package/dist/chunk-WX7HYWJ2.js +0 -2
- package/dist/chunk-WX7HYWJ2.js.map +0 -1
- package/dist/chunk-YKVQDYWZ.js +0 -3
- package/dist/chunk-YKVQDYWZ.js.map +0 -1
- package/dist/chunk-YNMMRH44.js.map +0 -1
- package/dist/chunk-YVKHEAFT.js +0 -2
- package/dist/chunk-YVKHEAFT.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkW5ELYJ4Z_cjs=require('./chunk-W5ELYJ4Z.cjs'),chunkZ4BXU65Y_cjs=require('./chunk-Z4BXU65Y.cjs'),chunkFVQWN5HZ_cjs=require('./chunk-FVQWN5HZ.cjs'),chunkLZSSAH5D_cjs=require('./chunk-LZSSAH5D.cjs'),chunkUURM7P3P_cjs=require('./chunk-UURM7P3P.cjs'),chunkZLRJ7TDP_cjs=require('./chunk-ZLRJ7TDP.cjs'),chunkEEVUKZ5B_cjs=require('./chunk-EEVUKZ5B.cjs'),chunkGWCBPITD_cjs=require('./chunk-GWCBPITD.cjs'),chunkTLG7VZRX_cjs=require('./chunk-TLG7VZRX.cjs'),chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunk2XZCLDHJ_cjs=require('./chunk-2XZCLDHJ.cjs'),chunk6U66HQKQ_cjs=require('./chunk-6U66HQKQ.cjs'),chunkBKSKZA4W_cjs=require('./chunk-BKSKZA4W.cjs'),chunkFAGFPVYK_cjs=require('./chunk-FAGFPVYK.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkWEAKI5V5_cjs=require('./chunk-WEAKI5V5.cjs'),chunk6QRHN3I6_cjs=require('./chunk-6QRHN3I6.cjs'),chunkNAZ6PGLS_cjs=require('./chunk-NAZ6PGLS.cjs');var Iu=/^\d{1,3}(\.\d{3}){2,}$/,Cu=/^\d*\.\d*$/,xt=class{constructor(){this.category="Arithmetic";}parse(e,o,r){let n,i=null,a=o.value;if(a.startsWith("0x")||a.startsWith("0X")){if(n=parseInt(a,16),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid hex literal: "${a}"`,{raw:a})}else if(a.startsWith("0b")||a.startsWith("0B")){if(n=parseInt(a.slice(2),2),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid binary literal: "${a}"`,{raw:a})}else if(a.startsWith("0o")||a.startsWith("0O")){if(n=parseInt(a.slice(2),8),Number.isNaN(n))throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid octal literal: "${a}"`,{raw:a})}else if(Iu.test(a))n=parseFloat(a.split(".").join(""));else {let s=chunkS3DFU33X_cjs.a(e.getLocaleCode()),l=s.display.decimalSeparator,u=s.display.thousandsSeparator,c=a;u&&(c=c.split(u).join("")),l&&l!=="."&&(c=c.replace(l,".")),n=parseFloat(c),Cu.test(c)&&(i=c);}if(i!==null){r.emitOpcode(16),r.emitString(i);return}r.emitOpcode(10),r.emitNumber(n);}};var Ie=class{constructor(e){this.opcode=e;this.category="Arithmetic";}parse(e,o,r){e.parseExpression(60,r),r.emitOpcode(this.opcode);}};var k=class{constructor(e,o,r=false){this.opcode=o;this.category="Arithmetic";this.bindingPower=e,this.rightBindingPower=r?e-1:e;}parse(e,o,r,n){e.parseExpression(this.rightBindingPower,n),n.emitOpcode(this.opcode);}};var Ot=class{constructor(){this.category="Arithmetic";}parse(e,o,r){e.parseExpression(0,r);let n=1;for(;e.match("COMMA");)e.parseExpression(0,r),n++;e.consume("RPAREN"),n>1&&(r.emitOpcode(152),r.emitIndex(1),r.emitIndex(n));}};var $e=class{constructor(){this.category="Arithmetic";}parse(e,o,r){let n=o.type==="PI"?Math.PI:Math.E;r.emitOpcode(10),r.emitNumber(n);}};var hu={k:3,M:6,G:9,B:9,T:12},Su={thousand:3,thousands:3,million:6,millions:6,mn:6,billion:9,billions:9,bn:9,trillion:12,trillions:12,tn:12},Lu=/^\d+(\.\d+)?$/;function wu(t,e){let o=t.indexOf("."),r=o===-1?t:t.slice(0,o),n=o===-1?"":t.slice(o+1);n.length<e&&(n=n.padEnd(e,"0"));let i=r+n.slice(0,e),a=n.slice(e);return a?`${i}.${a}`:i}function fa(t=65){return {name:"arithmetic:large-number-suffix",priority:t,startTokenTypes:["NUMBER"],match(e,o){let r=e[o];if(r.type!=="NUMBER"||!Lu.test(r.text))return null;let n=e[o+1];if(!n||n.type!=="IDENT"&&n.type!=="UNIT")return null;let i=r.offset+r.text.length===n.offset,a=n.type==="UNIT"?void 0:Su[n.value.toLowerCase()],s=i?hu[n.value]??a:a;if(s===void 0)return null;let l=wu(r.text,s);return {consumed:2,replacement:[chunkLZSSAH5D_cjs.b("NUMBER",l,e.slice(o,o+2))],ruleName:"arithmetic:large-number-suffix"}}}}var $o={name:"solve-arithmetic",prefixParselets:{NUMBER:new xt,LPAREN:new Ot,PI:new $e,E:new $e,PLUS:new Ie(27),MINUS:new Ie(26),BIT_NOT:new Ie(36)},infixParselets:{PLUS:new k(chunkFVQWN5HZ_cjs.a.Sum,20),AND_CONJ:new k(chunkFVQWN5HZ_cjs.a.Conjunction,20),MINUS:new k(chunkFVQWN5HZ_cjs.a.Sum,21),STAR:new k(chunkFVQWN5HZ_cjs.a.Product,22),SLASH:new k(chunkFVQWN5HZ_cjs.a.Product,23),MOD:new k(chunkFVQWN5HZ_cjs.a.Product,24),CARET:new k(chunkFVQWN5HZ_cjs.a.Exponent,25,true),TIMES_BY:new k(chunkFVQWN5HZ_cjs.a.Product,22),MULTIPLY_BY:new k(chunkFVQWN5HZ_cjs.a.Product,22),DIVIDE_BY:new k(chunkFVQWN5HZ_cjs.a.Product,23),LSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,30),RSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,31),URSHIFT:new k(chunkFVQWN5HZ_cjs.a.Shift,32),BIT_AND:new k(chunkFVQWN5HZ_cjs.a.BitwiseAnd,33),BIT_OR:new k(chunkFVQWN5HZ_cjs.a.BitwiseOr,34),BIT_XOR:new k(chunkFVQWN5HZ_cjs.a.BitwiseXor,35)},normalizerRules:[fa()]};var Rt=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Prefix;}parse(e,o,r,n){n.emitOpcode(10),n.emitNumber(100),n.emitOpcode(23),n.emitOpcode(74);}};var It=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){if(Ta(e,"what")){e.consume(),this.parseWhatRate(e,n);return}this.parseWhatBase(e,n);}parseWhatRate(e,o){if(!e.match("PERCENT"))throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_PERCENT",'Expected "%" after "is what", as in "20 is what % of 200"');let r=vu(e);if(r===null){o.emitOpcode(74);return}e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),o.emitOpcode(23),r==="off"?(o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(2),o.emitOpcode(21)):r==="on"&&(o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(21)),o.emitOpcode(74);}parseWhatBase(e,o){if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),e.match("TO")){Ea(e,"what",'"81 is 9 to what power"'),Ea(e,"power",'"81 is 9 to what power"'),o.emitOpcode(51),o.emitIndex(da),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(51),o.emitIndex(da),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(23);return}let r=e.match("OF_WHAT")?"of":e.match("OFF_WHAT")?"off":e.match("ON_WHAT")?"on":null;if(r===null)throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_PREPOSITION",'Expected "of what", "off what" or "on what", as in "20 is 10% of what"');if(r==="of"){o.emitOpcode(23);return}o.emitOpcode(10),o.emitNumber(1),r==="off"?(o.emitOpcode(2),o.emitOpcode(21)):o.emitOpcode(20),o.emitOpcode(23);}},da=5;function Ta(t,e){return (t.peek()?.text??"").toLowerCase()===e}function Ea(t,e,o){if(!Ta(t,e))throw chunkNAZ6PGLS_cjs.c.parsing("IS_WHAT_EXPECTED_WORD",`Expected "${e}" here, as in ${o}`);t.consume();}function vu(t){if(t.match("OF"))return "of";let e=(t.peek()?.text??"").toLowerCase();return e==="off"||e==="on"?(t.consume(),e):null}var We=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(2),n.emitOpcode(10),n.emitNumber(1),this.sign===1?n.emitOpcode(20):(n.emitOpcode(2),n.emitOpcode(21)),n.emitOpcode(22);}};function Na(t=68){return {name:"percentage:on-off",priority:t,startTokenTypes:["PERCENT"],match(e,o){if(e[o]?.type!=="PERCENT")return null;let r=e[o+1];if(r?.type!=="IDENT")return null;let n=(r.text??r.value??"").toLowerCase();return n!=="on"&&n!=="off"||(e[o+2]?.text??"").toLowerCase()==="what"?null:{consumed:2,replacement:[e[o],chunkLZSSAH5D_cjs.b(n==="on"?"PCT_ON":"PCT_OFF",n,[r])],ruleName:"percentage:on-off"}}}}var Ct=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(22);}};var ht=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23);}};var Ye=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,r,n){n.emitOpcode(10),n.emitNumber(1),this.sign===1?n.emitOpcode(20):(n.emitOpcode(2),n.emitOpcode(21)),e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23);}};var je=class{constructor(e){this.multiplier=e;this.category="Percentage";}parse(e,o,r){e.parseExpression(0,r);let n=e.peek();n&&(n.type==="IDENT"||n.type==="BY")&&e.consume(),r.emitOpcode(10),r.emitNumber(1),e.parseExpression(0,r),e.peek()?.type==="PERCENT"&&e.consume(),r.emitOpcode(this.multiplier>0?20:21),r.emitOpcode(22);}};var Xe=class{constructor(e){this.multiplier=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(10),n.emitNumber(1),n.emitOpcode(2),n.emitOpcode(this.multiplier>0?20:21),n.emitOpcode(22);}};var St=class{constructor(){this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){if(o.type==="UNIT")return;let i=e.peek();if(i&&((i.type==="UNIT"||i.type==="IDENT")&&chunkWEAKI5V5_cjs.b(i.value)||i.type==="IN")){e.consume(),n.emitOpcode(13),n.emitString(i.value),n.emitOpcode(84);return}e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23),n.emitOpcode(10),n.emitNumber(1),n.emitOpcode(21),n.emitOpcode(74);}};var ku={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12};function Bu(t){if(t.type==="NUMBER"){let e=Number(t.value);return Number.isInteger(e)&&e>=0?e:null}return t.type==="IDENT"?ku[t.value.toLowerCase()]??null:null}var Qe=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(10),n.emitNumber(1),n.emitOpcode(2),n.emitOpcode(this.sign>0?20:21);let i=this.tryConsumeRepeat(e);i!==null&&(n.emitOpcode(10),n.emitNumber(i),n.emitOpcode(25)),n.emitOpcode(22),this.consumeChainThen(e);}tryConsumeRepeat(e){let o=e.peek(),r=e.peekAt(1);if(!o||!r||r.type!=="STAR"||r.value.toLowerCase()!=="times")return null;let n=Bu(o);return n===null?null:(e.consume(),e.consume(),n)}consumeChainThen(e){if(e.peek()?.type!=="THEN")return;let o=e.peekAt(1)?.type;(o==="PCT_UP"||o==="PCT_DOWN")&&e.consume();}};function ya(t,e){let o=t[e];if(o?.type!=="IDENT")return null;let r=(o.text??o.value??"").toLowerCase();return r!=="up"&&r!=="down"||t[e+1]?.type!=="NUMBER"||t[e+2]?.type!=="PERCENT"?null:chunkLZSSAH5D_cjs.b(r==="up"?"PCT_UP":"PCT_DOWN",r,[o])}function ga(t=68){return {name:"percentage:up-down",priority:t,match(e,o){let r=e[o];if(r&&(r.type==="NUMBER"||r.type==="RPAREN")){let i=ya(e,o+1);if(i)return {consumed:2,replacement:[r,i],ruleName:"percentage:up-down"}}let n=ya(e,o);return n?{consumed:1,replacement:[n],ruleName:"percentage:up-down"}:null}}}var Wo={name:"solve-percentage",phrases:{"of what is":"OF_WHAT_IS","of what":"OF_WHAT","off what":"OFF_WHAT","on what":"ON_WHAT","on what is":"ON_WHAT_IS","off what is":"OFF_WHAT_IS"},infixParselets:{PERCENT:new Rt,IS:new It,PCT_ON:new We(1),PCT_OFF:new We(-1),OF:new Ct,OF_WHAT_IS:new ht,ON_WHAT_IS:new Ye(1),OFF_WHAT_IS:new Ye(-1),TO:new St,INCREASE_BY:new Xe(1),DECREASE_BY:new Xe(-1),PCT_UP:new Qe(1),PCT_DOWN:new Qe(-1)},prefixParselets:{INCREASE:new je(1),DECREASE:new je(-1)},normalizerRules:[Na(),ga()]};var Yo={sqrt:0,abs:1,sin:2,cos:3,tan:4,log:5,ceil:6,floor:7,round:8,min:9,max:10,asin:11,acos:12,atan:13,atan2:14,arcsin:11,arccos:12,arctan:13,sind:87,cosd:88,tand:89,asind:90,acosd:91,atand:92,sinh:15,cosh:16,tanh:17,asinh:18,acosh:19,atanh:20,cbrt:21,clz32:22,expm1:23,exp:24,fround:25,hypot:26,imul:27,log10:28,log1p:29,log2:30,pow:31,random:32,sign:33,trunc:34,degtorad:35,radtodeg:36,gcd:38,lcm:39,permutation:40,combination:41,hex:48,bin:49,int:50,compoundinterest:51,interestearned:52,compoundinterestrate:53,compoundinterestyears:54,loanrepayment:55,loaninterest:56,monthlypayment:57,taxadd:58,taxremove:59,inflationadjust:60,root:61,fact:62,factorial:62,transpose:63,det:64,inv:65,dot:66},Lt=class{constructor(){this.category="Function";}parse(e,o,r){let n=o.value.toLowerCase(),i=Yo[n];if(i===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown function: ${n}`,{functionName:n});e.consume("LPAREN");let a=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),a++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),a++;e.consume("RPAREN"),r.emitOpcode(51),r.emitIndex(i),r.emitIndex(a);}};var jo={name:"solve-function",prefixParselets:{FUNC:new Lt}};var pe=class{constructor(e=0){this.category="Date/Time";this.dayOffset=e;}parse(e,o,r){r.emitOpcode(90),this.dayOffset!==0&&(r.emitOpcode(10),r.emitNumber(this.dayOffset),r.emitOpcode(13),r.emitString("days"),r.emitOpcode(80),r.emitOpcode(20));}};var Mu={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},qe=class{constructor(e){this.direction=e;this.category="Date/Time";}parse(e,o,r){let n=e.peek(),i=n?Mu[n.type]:void 0;if(i===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("MISSING_WEEKDAY",`"${o.value}" must be followed by a day of the week (e.g. "${o.value} Saturday")`,{keyword:o.value,actualType:n?.type,actualValue:n?.value});e.consume(),r.emitOpcode(90),r.emitOpcode(10),r.emitNumber(i),r.emitOpcode(this.direction==="next"?93:94);}};var Ze=class{constructor(e){this.direction=e;this.category="Date/Time";}parse(e,o,r){let n=o.value;this.direction==="until"?(e.parseExpression(0,r),r.emitOpcode(90)):(r.emitOpcode(90),e.parseExpression(0,r)),r.emitOpcode(21),r.emitOpcode(13),r.emitString(n),r.emitOpcode(84);}};var wt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(0,r),r.emitPluginCall("workdaysInDuration",1);}};var Je=class{constructor(e){this.direction=e;this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Sum,n),n.emitOpcode(96),n.emitByte(this.direction==="backward"?1:0);}};var vt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitOpcode(97);}};var J=class{constructor(e,o){this.functionName=e;this.mode=o;this.category="Date/Time";}parse(e,o,r){this.mode==="in"?(r.emitOpcode(90),e.parseExpression(0,r),r.emitOpcode(20)):e.peek()?e.parseExpression(0,r):r.emitOpcode(90),r.emitPluginCall(this.functionName,1);}};var kt=class{constructor(){this.category="Date/Time";}parse(e,o,r){let n=o.value;e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitPluginCall("spanBetweenDates",2),r.emitOpcode(13),r.emitString(n),r.emitOpcode(84);}};var et=class{constructor(e){this.functionName=e;this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall(this.functionName,1);}};var Bt=class{constructor(){this.category="Date/Time";}parse(e,o,r){r.emitOpcode(90),r.emitPluginCall("toTimestampFromAny",1);}};var Mt=class{constructor(){this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toDateFromAny",1);}};var Ut=class{constructor(){this.category="Date/Time";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toTimestampFromAny",1);}};var Dt=class{constructor(){this.category="Date/Time";}parse(e,o,r){r.emitOpcode(95),r.emitNumber(Number(o.value));}};var bt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.consume("OF"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,r),r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("nthWeekdayOfMonth",2);}};var Ce=class{constructor(e){this.offsetMonths=e;this.category="Date/Time";}parse(e,o,r){r.emitOpcode(90),r.emitOpcode(10),r.emitNumber(this.offsetMonths),r.emitPluginCall("monthAnchorShift",2);}};var Uu=new Set(["year","years","month","months","day","days"]),Vt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,r),this.wordIs(e.peek(),"on")?(e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,r)):r.emitOpcode(90);let n=this.consumeBreakdown(e)?"ymd":"years";r.emitOpcode(13),r.emitString(n),r.emitPluginCall("ageBetween",3);}wordIs(e,o){return e?String(e.value??e.text??"").toLowerCase()===o:false}consumeBreakdown(e){if(e.peek()?.type!=="IN")return false;e.consume();let o=false;for(;;){let r=e.peek();if(!r)break;let n=String(r.value??r.text??"").toLowerCase();if(r.type==="UNIT"&&Uu.has(n))o=true,e.consume();else if(r.type==="COMMA"||r.type==="AND_CONJ"||n==="and")e.consume();else break}return o}};function Du(t){let e=t[0],o;if(e.type===6&&e.unit){if(chunkBKSKZA4W_cjs.c(e.unit)!=="time")return chunk6U66HQKQ_cjs.P("WORKDAYS_IN_EXPECTED_DURATION",`"workdays in" expects a time duration, got unit "${e.unit}"`);o=chunkBKSKZA4W_cjs.e(e.toNumber(),e.unit,"day");}else o=e.toNumber();let r=o<0?-1:1,n=Math.abs(o),i=Math.floor(n/7),a=n-i*7,s=r*(i*5+Math.min(a,5));return chunk6U66HQKQ_cjs.n(s)}var bu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function tt(t,e){return t.type===4?t.toNumber():chunk6U66HQKQ_cjs.P("DATE_FIELD_EXPECTED_DATE",`"${e}" expects a date, got ${chunk6U66HQKQ_cjs.g[t.type]??"an unsupported value"}`)}function Vu(t){let e=tt(t[0],"weekday");return typeof e!="number"?e:chunk6U66HQKQ_cjs.t(bu[new Date(e).getDay()])}var Fu=["January","February","March","April","May","June","July","August","September","October","November","December"];function Hu(t){let e=tt(t[0],"month");return typeof e!="number"?e:chunk6U66HQKQ_cjs.t(Fu[new Date(e).getMonth()])}function Gu(t){let e=tt(t[0],"week");if(typeof e!="number")return e;let o=new Date(e),r=new Date(Date.UTC(o.getFullYear(),o.getMonth(),o.getDate())),n=r.getUTCDay()===0?7:r.getUTCDay();r.setUTCDate(r.getUTCDate()+4-n);let i=Date.UTC(r.getUTCFullYear(),0,1),a=Math.floor((r.getTime()-i)/864e5);return chunk6U66HQKQ_cjs.n(Math.floor(a/7)+1)}function Pa(t){let e=new Date(t).getDay();return e===0||e===6}function zu(t){let e=tt(t[0],"is a weekend");return typeof e!="number"?e:chunk6U66HQKQ_cjs.L(Pa(e))}function Ku(t){let e=tt(t[0],"is a workday");return typeof e!="number"?e:chunk6U66HQKQ_cjs.L(!Pa(e))}function $u(t){return chunk6U66HQKQ_cjs.u(Math.abs(t[0].toNumber()-t[1].toNumber()),"ms")}function Wu(t){let e=t[0];if(e.type===4)return e;if(e.type===3){let o=chunkZ4BXU65Y_cjs.c(e.value);return o===null?chunk6U66HQKQ_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk6U66HQKQ_cjs.M(o)}return chunk6U66HQKQ_cjs.M(chunkZ4BXU65Y_cjs.e(e.toNumber()))}function Yu(t){let e=t[0];if(e.type===3){let o=chunkZ4BXU65Y_cjs.c(e.value);return o===null?chunk6U66HQKQ_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk6U66HQKQ_cjs.n(Math.floor(o/1e3))}return chunk6U66HQKQ_cjs.n(Math.floor(e.toNumber()/1e3))}var _a=Du,Xo=Vu,Qo=Hu,qo=Gu,Aa=zu,xa=Ku,Oa=$u,Ra=Wu,Ia=Yu;function Zo(t,e){return new Date(t,e+1,0).getDate()}function Sa(t,e,o,r){let n=new Date(t,e,1).getDay(),a=1+(o-n+7)%7+(r-1)*7;return a<1||a>Zo(t,e)?null:new Date(t,e,a).getTime()}function La(t,e,o){let r=Zo(t,e),i=(new Date(t,e,r).getDay()-o+7)%7;return new Date(t,e,r-i).getTime()}function wa(t,e){let o=new Date(t),r=new Date(e),n=r.getFullYear()-o.getFullYear();return (r.getMonth()<o.getMonth()||r.getMonth()===o.getMonth()&&r.getDate()<o.getDate())&&n--,n}function Ca(t,e){let o=t.getFullYear(),r=t.getMonth()+e,n=o+Math.floor(r/12),i=(r%12+12)%12,a=Math.min(t.getDate(),Zo(n,i));return new Date(n,i,a)}function ha(t){return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)}function va(t,e){let o=new Date(t),r=new Date(e),n=(r.getFullYear()-o.getFullYear())*12+(r.getMonth()-o.getMonth());Ca(o,n)>r&&n--;let i=Ca(o,n),a=ha(r)-ha(i);return {years:Math.floor(n/12),months:n%12,days:a}}function ka(t,e){let o=new Date(t);return new Date(o.getFullYear(),o.getMonth()+e,1).getTime()}function Ht(t,e){return t.type===4?t.toNumber():chunk6U66HQKQ_cjs.P("DATE_EXPECTED",`"${e}" expects a date, got ${chunk6U66HQKQ_cjs.g[t.type]??"an unsupported value"}`)}function ju(t){let e=Ht(t[0],"nth weekday of month");if(typeof e!="number")return e;let o=String(t[1].value??""),[r,n]=o.split(":"),i=Number(n),a=new Date(e),s=a.getFullYear(),l=a.getMonth();if(r==="last")return chunk6U66HQKQ_cjs.M(La(s,l,i));let u=Number(r),c=Sa(s,l,i,u);return c===null?chunk6U66HQKQ_cjs.P("NTH_WEEKDAY_OUT_OF_RANGE",`there is no ${r}${Xu(u)} occurrence of that weekday in the month`):chunk6U66HQKQ_cjs.M(c)}function Xu(t){let e=t%100;if(e>=11&&e<=13)return "th";switch(t%10){case 1:return "st";case 2:return "nd";case 3:return "rd";default:return "th"}}function Qu(t){let e=Ht(t[0],"month anchor");if(typeof e!="number")return e;let o=t[1].toNumber();return chunk6U66HQKQ_cjs.M(ka(e,o))}var qu="ymd";function Zu(t){let e=Ht(t[0],"age of");if(typeof e!="number")return e;let o=Ht(t[1],"age of");return typeof o!="number"?o:String(t[2].value??"years")===qu?chunk6U66HQKQ_cjs.t(Ju(va(e,o))):chunk6U66HQKQ_cjs.u(wa(e,o),"years")}function Ju(t){let e=[];return t.years!==0&&e.push(Ft(t.years,"year")),t.months!==0&&e.push(Ft(t.months,"month")),t.days!==0&&e.push(Ft(t.days,"day")),e.length===0?Ft(0,"day"):e.join(", ")}function Ft(t,e){return `${t} ${e}${Math.abs(t)===1?"":"s"}`}var Ba=ju,Ma=Qu,Ua=Zu;var ec={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},Da="NTH_WEEKDAY",tc=chunk5IJD5L3O_cjs.c(Da),rc=/^(\d+)(st|nd|rd|th)$/i;function ba(t=66){let e="datetime:nth-weekday";return {name:e,priority:t,match(o,r){let n=o[r];if(!n)return null;let i=null,a=0;if(n.type==="LAST")i="last",a=1;else {let f=o[r+1];if(!f||(n.sourceEnd??n.offset+(n.text?.length??0))!==f.offset)return null;let N=(n.text??"")+(f.text??""),E=rc.exec(N);if(!E)return null;i=String(Number(E[1])),a=2;}let s=o[r+a],l=s?ec[s.type]:void 0;if(l===void 0||o[r+a+1]?.type!=="OF")return null;let u=`${i}:${l}`,c=new chunkFAGFPVYK_cjs.a(Da,tc,u,u,n.offset,0,n.line,n.col);return {consumed:a+1,replacement:[c],ruleName:e}}}}function Va(t=60){return {name:"datetime:until-since",priority:t,startTokenTypes:["UNIT"],match(e,o){if(o+1>=e.length)return null;let r=e[o],n=e[o+1];if(r.type!=="UNIT"||n.type!=="UNTIL"&&n.type!=="SINCE")return null;let i=n.type==="UNTIL"?"UNTIL_UNIT":"SINCE_UNIT";return {consumed:2,replacement:[chunkLZSSAH5D_cjs.b(i,r.value,[r,n])],ruleName:`datetime:${n.type.toLowerCase()}`}}}}function Fa(t=60){return {name:"datetime:between-unit",priority:t,startTokenTypes:["UNIT","IDENT"],match(e,o){let r=o,n=0;e[o]?.value?.toLowerCase()==="how"&&e[o+1]?.value?.toLowerCase()==="many"&&(r=o+2,n=2);let i=e[r],a=e[r+1];if(!i||!a||i.type!=="UNIT")return null;let s=a.type==="BETWEEN",l=a.type==="UNTIL"||a.type==="SINCE";if(!s&&!l||l&&n===0)return null;let u=e.slice(o,r+2);return l?{consumed:n+2,replacement:[i,a],ruleName:"datetime:how-many"}:{consumed:n+2,replacement:[chunkLZSSAH5D_cjs.b("BETWEEN_UNIT",i.value,u)],ruleName:"datetime:between"}}}}function Ha(t=70){return {name:"datetime:workday-rate-denominator",priority:t,startTokenTypes:["SLASH"],match(e,o){let r=e[o];if(r.type!=="SLASH")return null;let n=e[o+1];if(!n||n.type!=="UNIT"||n.value!=="workday"&&n.value!=="workdays")return null;let i={...n,type:"NUMBER",typeId:chunk5IJD5L3O_cjs.c("NUMBER"),value:"1",text:"1"};return {consumed:2,replacement:[r,i,n],ruleName:"datetime:workday-rate-denominator"}}}}var oc={january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,sept:9,october:10,oct:10,november:11,nov:11,december:12,dec:12};function Ga(t){return t===void 0||t.type!=="IDENT"&&t.type!=="UNIT"?0:oc[(t.text??t.value??"").toLowerCase()]??0}var rt=/^\d+$/;function Gt(t){return t.length===4}function za(t=64){return {name:"datetime:month-name-date",priority:t,startTokenTypes:["NUMBER","IDENT","UNIT"],match(e,o){let r="datetime:month-name-date",n=e[o];if(n?.type==="NUMBER"&&rt.test(n.text??"")){let c=Ga(e[o+1]);if(c===0)return null;let f=Number(n.text);if(f<1||f>31)return null;let T=e[o+2];return T?.type==="NUMBER"&&rt.test(T.text??"")&&Gt(T.text??"")?chunkZ4BXU65Y_cjs.g(f,c,Number(T.text),e.slice(o,o+3),r):chunkZ4BXU65Y_cjs.g(f,c,new Date().getFullYear(),e.slice(o,o+2),r)}let i=Ga(n);if(i===0)return null;let a=e[o+1];if(a?.type!=="NUMBER"||!rt.test(a.text??""))return null;if(Gt(a.text??""))return chunkZ4BXU65Y_cjs.g(1,i,Number(a.text),e.slice(o,o+2),r);let s=Number(a.text),l=e[o+2],u=e[o+3];return l?.type==="COMMA"&&u?.type==="NUMBER"&&rt.test(u.text??"")&&Gt(u.text??"")?chunkZ4BXU65Y_cjs.g(s,i,Number(u.text),e.slice(o,o+4),r):l?.type==="NUMBER"&&rt.test(l.text??"")&&Gt(l.text??"")?chunkZ4BXU65Y_cjs.g(s,i,Number(l.text),e.slice(o,o+3),r):chunkZ4BXU65Y_cjs.g(s,i,new Date().getFullYear(),e.slice(o,o+2),r)}}}var nc=93,ic={q1:[1,3],q2:[4,6],q3:[7,9],q4:[10,12]};function Jo(t,e){return new Date(t,e,0).getDate()}function ac(t){return Jo(t,2)===29?366:365}var zt=class{constructor(){this.category="Datetime";}parse(e,o,r){let n=this.readPeriodDays(e);r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(51),r.emitIndex(nc),r.emitIndex(1);}readPeriodDays(e){let o=e.peek(),r=(o?.text??o?.value??"").toLowerCase(),n=ic[r];if(n!==void 0){e.consume();let a=this.readOptionalYear(e)??new Date().getFullYear(),s=0;for(let l=n[0];l<=n[1];l++)s+=Jo(a,l);return s}if(o?.type==="DATETIME_LITERAL"){e.consume();let a=new Date(Number(o.value));return Jo(a.getFullYear(),a.getMonth()+1)}let i=this.readOptionalYear(e);if(i!==null)return ac(i);throw chunkNAZ6PGLS_cjs.c.parsing("DAYS_IN_EXPECTED_PERIOD",'Expected a month, quarter or year, as in "days in February 2020" or "days in Q3"')}readOptionalYear(e){let o=e.peek();if(o?.type!=="NUMBER")return null;let r=o.text??o.value??"";return /^\d{4}$/.test(r)?(e.consume(),Number(r)):null}};var sc=new Set(["q1","q2","q3","q4"]),mc=new Set(["january","jan","february","feb","march","mar","april","apr","may","june","jun","july","jul","august","aug","september","sep","sept","october","oct","november","nov","december","dec"]);function lc(t){if(t===void 0)return false;if(t.type==="DATETIME_LITERAL")return true;let e=(t.text??t.value??"").toLowerCase();return t.type==="IDENT"||t.type==="UNIT"?sc.has(e)||mc.has(e):t.type==="NUMBER"&&/^\d{4}$/.test(t.text??"")}function Ka(t=60){return {name:"datetime:days-in-period",priority:t,startTokenTypes:["UNIT","IDENT"],match(e,o){let r=e[o];return r===void 0||(r.text??r.value??"").toLowerCase()!=="days"||r.type!=="UNIT"&&r.type!=="IDENT"||e[o+1]?.type!=="IN"||!lc(e[o+2])?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b("DAYS_IN_PERIOD","days in",[r,e[o+1]])],ruleName:"datetime:days-in-period"}}}}function $a(){return {name:"datetime:daily-note-link",priority:80,startTokenTypes:["LBRACKET"],match(t,e){return t[e]?.type!=="LBRACKET"||t[e+1]?.type!=="LBRACKET"||t[e+2]?.type!==chunkZ4BXU65Y_cjs.f||t[e+3]?.type!=="RBRACKET"||t[e+4]?.type!=="RBRACKET"?null:{consumed:5,replacement:[t[e+2]],ruleName:"datetime:daily-note-link"}}}}var en={name:"solve-datetime",phrases:{"workdays in":"WORKDAYS_IN","working days after":"WORKDAYS_AFTER","business days after":"WORKDAYS_AFTER","working day after":"WORKDAYS_AFTER","business day after":"WORKDAYS_AFTER","working days from":"WORKDAYS_AFTER","business days from":"WORKDAYS_AFTER","working day from":"WORKDAYS_AFTER","business day from":"WORKDAYS_AFTER","working days before":"WORKDAYS_BEFORE","business days before":"WORKDAYS_BEFORE","working day before":"WORKDAYS_BEFORE","business day before":"WORKDAYS_BEFORE","working days between":"WORKDAYS_BETWEEN","business days between":"WORKDAYS_BETWEEN","day of the week on":"WEEKDAY_ON","weekday on":"WEEKDAY_ON","current timestamp":"CURRENT_TIMESTAMP","to date":"TO_DATE","to timestamp":"TO_TIMESTAMP","what day is it":"WEEKDAY_ON","what day is it on":"WEEKDAY_ON","what day will it be on":"WEEKDAY_ON","what day is it in":"WEEKDAY_IN","what day will it be in":"WEEKDAY_IN","what month is it":"MONTH_ON","what month is it on":"MONTH_ON","month of":"MONTH_ON","what month is it in":"MONTH_IN","what month will it be in":"MONTH_IN","what week is it":"WEEK_ON","what week is it on":"WEEK_ON","week of":"WEEK_ON","week number on":"WEEK_ON","week number of":"WEEK_ON","week number":"WEEK_ON","what week is it in":"WEEK_IN","what week will it be in":"WEEK_IN","is a weekend":"IS_WEEKEND","is on a weekend":"IS_WEEKEND","is a workday":"IS_WORKDAY","is a weekday":"IS_WORKDAY","is a business day":"IS_WORKDAY","age of":"AGE_OF","next month":"MONTH_ANCHOR_NEXT","this month":"MONTH_ANCHOR_THIS","last month":"MONTH_ANCHOR_LAST"},prefixParselets:{DAYS_IN_PERIOD:new zt,NOW:new pe(0),TODAY:new pe(0),TOMORROW:new pe(1),YESTERDAY:new pe(-1),NEXT:new qe("next"),LAST:new qe("last"),UNTIL_UNIT:new Ze("until"),SINCE_UNIT:new Ze("since"),WORKDAYS_IN:new wt,WORKDAYS_BETWEEN:new vt,WEEKDAY_ON:new J("weekdayOnDate","on"),WEEKDAY_IN:new J("weekdayOnDate","in"),MONTH_ON:new J("monthOnDate","on"),MONTH_IN:new J("monthOnDate","in"),WEEK_ON:new J("weekOnDate","on"),WEEK_IN:new J("weekOnDate","in"),BETWEEN_UNIT:new kt,CURRENT_TIMESTAMP:new Bt,DATETIME_LITERAL:new Dt,NTH_WEEKDAY:new bt,AGE_OF:new Vt,MONTH_ANCHOR_NEXT:new Ce(1),MONTH_ANCHOR_THIS:new Ce(0),MONTH_ANCHOR_LAST:new Ce(-1)},infixParselets:{WORKDAYS_AFTER:new Je("forward"),WORKDAYS_BEFORE:new Je("backward"),TO_DATE:new Mt,TO_TIMESTAMP:new Ut,IS_WEEKEND:new et("isWeekendOnDate"),IS_WORKDAY:new et("isWorkdayOnDate")},normalizerRules:[Va(),Fa(),Ha(),za(),ba(),Ka(),$a()],pluginFunctions:{workdaysInDuration:_a,weekdayOnDate:Xo,toDateFromAny:Ra,toTimestampFromAny:Ia,monthOnDate:Qo,weekOnDate:qo,isWeekendOnDate:Aa,isWorkdayOnDate:xa,spanBetweenDates:Oa,nthWeekdayOfMonth:Ba,monthAnchorShift:Ma,ageBetween:Ua},asConverters:{iso8601:t=>chunk6U66HQKQ_cjs.t(chunkZ4BXU65Y_cjs.d(t.toNumber())),weekday:t=>Xo([t]),month:t=>Qo([t]),week:t=>qo([t])},tokenCategories:{NTH_WEEKDAY:"datetime",MONTH_ANCHOR_NEXT:"datetime",MONTH_ANCHOR_THIS:"datetime",MONTH_ANCHOR_LAST:"datetime",AGE_OF:"keyword"}};var uc={sydney:"Australia/Sydney",melbourne:"Australia/Melbourne",brisbane:"Australia/Brisbane",perth:"Australia/Perth",adelaide:"Australia/Adelaide",canberra:"Australia/Sydney",auckland:"Pacific/Auckland",wellington:"Pacific/Auckland",fiji:"Pacific/Fiji",chicago:"America/Chicago",seattle:"America/Los_Angeles",denver:"America/Denver",phoenix:"America/Phoenix",toronto:"America/Toronto",montreal:"America/Toronto",vancouver:"America/Vancouver",ottawa:"America/Toronto",honolulu:"Pacific/Honolulu",anchorage:"America/Anchorage",miami:"America/New_York",boston:"America/New_York",atlanta:"America/New_York",dallas:"America/Chicago",houston:"America/Chicago",lima:"America/Lima",bogota:"America/Bogota",caracas:"America/Caracas",santiago:"America/Santiago",montevideo:"America/Montevideo",quito:"America/Guayaquil",london:"Europe/London",paris:"Europe/Paris",berlin:"Europe/Berlin",madrid:"Europe/Madrid",rome:"Europe/Rome",amsterdam:"Europe/Amsterdam",dublin:"Europe/Dublin",lisbon:"Europe/Lisbon",vienna:"Europe/Vienna",zurich:"Europe/Zurich",geneva:"Europe/Zurich",moscow:"Europe/Moscow",istanbul:"Europe/Istanbul",athens:"Europe/Athens",stockholm:"Europe/Stockholm",oslo:"Europe/Oslo",helsinki:"Europe/Helsinki",warsaw:"Europe/Warsaw",prague:"Europe/Prague",budapest:"Europe/Budapest",brussels:"Europe/Brussels",copenhagen:"Europe/Copenhagen",reykjavik:"Atlantic/Reykjavik",kiev:"Europe/Kyiv",kyiv:"Europe/Kyiv",tokyo:"Asia/Tokyo",osaka:"Asia/Tokyo",beijing:"Asia/Shanghai",shanghai:"Asia/Shanghai",seoul:"Asia/Seoul",singapore:"Asia/Singapore",bangkok:"Asia/Bangkok",jakarta:"Asia/Jakarta",manila:"Asia/Manila",mumbai:"Asia/Kolkata",delhi:"Asia/Kolkata",bangalore:"Asia/Kolkata",dubai:"Asia/Dubai",abudhabi:"Asia/Dubai",karachi:"Asia/Karachi",dhaka:"Asia/Dhaka",hanoi:"Asia/Ho_Chi_Minh",taipei:"Asia/Taipei",islamabad:"Asia/Karachi",riyadh:"Asia/Riyadh",telaviv:"Asia/Jerusalem",jerusalem:"Asia/Jerusalem",cairo:"Africa/Cairo",lagos:"Africa/Lagos",nairobi:"Africa/Nairobi",johannesburg:"Africa/Johannesburg",casablanca:"Africa/Casablanca",accra:"Africa/Accra",tunis:"Africa/Tunis",addisababa:"Africa/Addis_Ababa",france:"Europe/Paris",germany:"Europe/Berlin",spain:"Europe/Madrid",italy:"Europe/Rome",japan:"Asia/Tokyo",china:"Asia/Shanghai",india:"Asia/Kolkata",brazil:"America/Sao_Paulo",russia:"Europe/Moscow",australia:"Australia/Sydney",canada:"America/Toronto",mexico:"America/Mexico_City",uk:"Europe/London",usa:"America/New_York",ireland:"Europe/Dublin",netherlands:"Europe/Amsterdam",sweden:"Europe/Stockholm",norway:"Europe/Oslo",poland:"Europe/Warsaw",turkey:"Europe/Istanbul",egypt:"Africa/Cairo",nigeria:"Africa/Lagos"},tn={"new york":"America/New_York","los angeles":"America/Los_Angeles","san francisco":"America/Los_Angeles","las vegas":"America/Los_Angeles","mexico city":"America/Mexico_City","hong kong":"Asia/Hong_Kong","kuala lumpur":"Asia/Kuala_Lumpur","sao paulo":"America/Sao_Paulo","buenos aires":"America/Argentina/Buenos_Aires","rio de janeiro":"America/Sao_Paulo","cape town":"Africa/Johannesburg","new delhi":"Asia/Kolkata","united kingdom":"Europe/London","united states":"America/New_York","south africa":"Africa/Johannesburg"},cc={pst:"America/Los_Angeles",pdt:"America/Los_Angeles",est:"America/New_York",edt:"America/New_York",cst:"America/Chicago",cdt:"America/Chicago",mst:"America/Denver",mdt:"America/Denver",hst:"Pacific/Honolulu",bst:"Europe/London",cet:"Europe/Paris",cest:"Europe/Paris",jst:"Asia/Tokyo",ist:"Asia/Kolkata",aest:"Australia/Sydney",aedt:"Australia/Sydney"},Wa={...uc,...tn,...cc};var rn="UTCOFFSET:";function on(t){return `${rn}${t}`}function ot(t){return t.startsWith(rn)}function nt(t){return parseInt(t.slice(rn.length),10)}function Kt(t,e){if(ot(t))return nt(t);let o=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),r={};for(let i of o.formatToParts(new Date(e)))r[i.type]=i.value;let n=Date.UTC(+r.year,+r.month-1,+r.day,+r.hour,+r.minute,+r.second);return Math.round((n-e)/6e4)}function ja(t,e,o,r,n,i){let a=Date.UTC(t,e,o,r,n,0),s=Kt(i,a);return a-s*6e4}function nn(t,e){if(ot(e)){let r=nt(e)*6e4;return pc(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:true}).format(new Date(t))}function Xa(t,e){if(ot(e)){let r=nt(e)*6e4;return fc(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"long",day:"numeric"}).format(new Date(t))}function Ya(t,e){if(ot(e)){let n=new Date(t+nt(e)*6e4);return {year:n.getUTCFullYear(),month0:n.getUTCMonth(),day:n.getUTCDate()}}let o=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}),r={};for(let n of o.formatToParts(new Date(t)))r[n.type]=n.value;return {year:+r.year,month0:+r.month-1,day:+r.day}}function Qa(t,e,o){let r=Ya(t,e),n=Ya(t,o),i=Date.UTC(r.year,r.month0,r.day),a=Date.UTC(n.year,n.month0,n.day);return Math.round((i-a)/864e5)}function pc(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",hour:"numeric",minute:"2-digit",hour12:true}).format(t)}function fc(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",year:"numeric",month:"long",day:"numeric"}).format(t)}function an(t){if(ot(t)){let o=nt(t),r=o>=0?"+":"-",n=Math.abs(o),i=Math.floor(n/60),a=n%60;return a===0?`UTC${r}${i}`:`UTC${r}${i}:${String(a).padStart(2,"0")}`}return (t.split("/").pop()??t).replace(/_/g," ")}function ne(t){let e=t.peek();if(!e)return null;let o=e.value,r=o.toLowerCase();if(r==="gmt"||r==="utc"){t.consume();let i=t.peek();if(i?.type==="PLUS"||i?.type==="MINUS"){let s=i.type==="MINUS";t.consume();let l=t.peek(),u;if(l?.type==="CLOCK_TIME")t.consume(),u=parseInt(l.value,10);else {let f=t.consume("NUMBER");if(u=parseInt(f.value,10)*60,t.peek()?.type==="COLON"){t.consume();let T=t.consume("NUMBER");u+=parseInt(T.value,10);}}let c=on(s?-u:u);return {zoneRef:c,displayName:an(c)}}let a=on(0);return {zoneRef:a,displayName:an(a)}}let n=Wa[r];if(n){t.consume();let i=o.replace(/\b\w/g,a=>a.toUpperCase());return {zoneRef:n,displayName:i}}return null}var $t="zoneConvert",sn="timeInZone",mn="dateInZone",Wt="timeDifference";function qa(t){let e=t[0].toNumber(),o=t[1].value,r=t[2].value,n=new Date,i=ja(n.getFullYear(),n.getMonth(),n.getDate(),Math.floor(e/60),e%60,o),a=nn(i,r),s=Qa(i,r,o);if(s===0)return chunk6U66HQKQ_cjs.t(a);let l=s>0?"+":"";return chunk6U66HQKQ_cjs.t(`${a} (${l}${s} day${Math.abs(s)===1?"":"s"})`)}function Za(t){let e=t[0].value;return chunk6U66HQKQ_cjs.t(nn(Date.now(),e))}function Ja(t){let e=t[0].value;return chunk6U66HQKQ_cjs.t(Xa(Date.now(),e))}function es(t){let e=t[0].value,o=t[1].value,r=t[2].value,n=t[3].value,i=Date.now(),a=Kt(e,i),l=Kt(o,i)-a;if(l===0)return chunk6U66HQKQ_cjs.t(`${n} and ${r} currently share the same UTC offset`);let u=l>0?n:r,c=l>0?r:n,f=Math.abs(l),T=Math.floor(f/60),N=f%60,E=[];return T>0&&E.push(`${T} hour${T===1?"":"s"}`),N>0&&E.push(`${N} minute${N===1?"":"s"}`),chunk6U66HQKQ_cjs.t(`${u} is ${E.join(" ")} ahead of ${c}`)}var Yt=class{constructor(){this.category="Time";}parse(e,o,r){let n=parseInt(o.value,10),i=ne(e);if(i!==null){if(e.peek()?.type!=="IN")throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_IN",`Expected "in <city>" after the zone name (e.g. "6pm Sydney in Chicago") but got ${e.peek()?`"${e.peek().value}"`:"end of input"}`);e.consume();let a=ne(e);if(a===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_TARGET",'Expected a city or zone name after "in" (e.g. "6pm Sydney in Chicago")');r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(13),r.emitString(i.zoneRef),r.emitOpcode(13),r.emitString(a.zoneRef),r.emitPluginCall($t,3);return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(120);}};var jt=class{constructor(){this.category="Time";}parse(e,o,r){let[n,i]=o.value.split(":"),a=parseInt(n,10),s=parseInt(i,10),l=s>=a?s-a:1440-a+s;r.emitOpcode(10),r.emitNumber(l),r.emitOpcode(13),r.emitString("minutes"),r.emitOpcode(80);}};var Xt=class{constructor(){this.category="Time";}parse(e,o,r){r.emitOpcode(10),r.emitNumber(parseFloat(o.value)),r.emitOpcode(13),r.emitString("frames/s"),r.emitOpcode(80);}};var Qt=class{constructor(){this.category="Time";}parse(e,o,r){r.emitOpcode(10),r.emitNumber(parseFloat(o.value)),r.emitOpcode(13),r.emitString("s"),r.emitOpcode(80);}};function ln(t){return {category:"Time",parse(e,o,r){let n=ne(e);if(n===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_ZONE_EXPECTED_CITY",`Expected a city or zone name after "${o.value}" (e.g. "time in Paris")`);r.emitOpcode(13),r.emitString(n.zoneRef),r.emitPluginCall(t,1);}}}var qt=class{constructor(){this.category="Time";}parse(e,o,r){let n=ne(e);if(n===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_DIFFERENCE_EXPECTED_CITY",'Expected a city or zone name after "time difference between" (e.g. "time difference between Seattle and Moscow")');e.consume("AND_CONJ");let i=ne(e);if(i===null)throw chunkNAZ6PGLS_cjs.c.parsing("TIME_DIFFERENCE_EXPECTED_SECOND_CITY",'Expected a second city or zone name after "and" (e.g. "time difference between Seattle and Moscow")');r.emitOpcode(13),r.emitString(n.zoneRef),r.emitOpcode(13),r.emitString(i.zoneRef),r.emitOpcode(13),r.emitString(n.displayName),r.emitOpcode(13),r.emitString(i.displayName),r.emitPluginCall(Wt,4);}};var Zt=class{constructor(){this.category="Time";}parse(e,o,r){let[n,i,a,s]=o.value.split(",").map(Number),l=e.peek();if(!l||l.type!=="RATE_AT"&&l.type!=="AT")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`A video timecode must specify a frame rate, e.g. "${o.value.split(",").join(":")} at 30 fps" or "... @ 30 fps"`);e.consume();let u=e.peek();if(!u||u.type!=="FPS_RATE")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`Expected "<number> fps" after "${l.value}" (e.g. "at 30 fps")`);e.consume();let c=parseFloat(u.value),f=Math.round(c);if(s>=f)throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_FRAME_OUT_OF_RANGE",`Frame number ${s} is out of range for ${c} fps (must be 0-${f-1})`);let T=(n*3600+i*60+a)*f+s,N=chunk6U66HQKQ_cjs.z(c);if(e.peek()?.type==="IN"){e.consume();let E=e.peek();if(!E||E.type!=="IDENT"||E.value.toLowerCase()!=="frames")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FRAMES",`Expected "frames" after "in" (e.g. "... in frames") but got ${E?`"${E.value}"`:"end of input"}`);e.consume(),N="frames";}r.emitOpcode(10),r.emitNumber(T),r.emitOpcode(13),r.emitString(N),r.emitOpcode(80);}};function ts(t,e){let o=Math.max(1,Math.round(e)),r=c=>String(c).padStart(2,"0"),n=Math.trunc(t),i=(n%o+o)%o,a=Math.floor(n/o),s=Math.floor(a/3600),l=Math.floor(a%3600/60),u=a%60;return `${r(s)}:${r(l)}:${r(u)}:${r(i)}`}var Jt=class{constructor(){this.category="Time";}parse(e,o,r){let n=parseFloat(o.value),i=e.peek();if(i&&(i.type==="RATE_AT"||i.type==="AT")){e.consume();let a=e.peek();if(!a||a.type!=="FPS_RATE")throw chunkNAZ6PGLS_cjs.c.parsing("TIMECODE_EXPECTED_FPS",`Expected "<number> fps" after "${i.value}" (e.g. "@ 30 fps")`);e.consume();let s=parseFloat(a.value);r.emitOpcode(13),r.emitString(ts(n,s));return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(13),r.emitString("frames"),r.emitOpcode(80);}};function rs(t,e,o){if(e<0||e>59)return null;if(o){if(t<1||t>12)return null;let r=o.toLowerCase()==="pm";return (t%12+(r?12:0))*60+e}return t<0||t>23?null:t*60+e}function os(t){return !!t&&t.type==="IDENT"&&/^(am|pm)$/i.test(t.value)}function ns(t=65){return {name:"time:clock-time",priority:t,startTokenTypes:["NUMBER"],match(e,o){if(chunkLZSSAH5D_cjs.e(e,o))return null;let r=e[o];if(r.type!=="NUMBER")return null;let n=parseInt(r.value,10);if(isNaN(n)||n<0||n>23)return null;let i=e[o+1],a=e[o+2];if(i?.type==="COLON"&&a?.type==="NUMBER"){let l=parseInt(a.value,10),u=e[o+3],c=os(u),f=rs(n,l,c?u.value:void 0);if(f===null)return null;let T=c?4:3;return {consumed:T,replacement:[chunkLZSSAH5D_cjs.b("CLOCK_TIME",String(f),e.slice(o,o+T))],ruleName:"time:clock-time"}}let s=e[o+1];if(os(s)){let l=rs(n,0,s.value);return l===null?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b("CLOCK_TIME",String(l),e.slice(o,o+2))],ruleName:"time:clock-time"}}return null}}}function is(t=66){return {name:"time:clock-time-interval",priority:t,startTokenTypes:["CLOCK_TIME"],match(e,o){let r=e[o],n=e[o+1],i=e[o+2];return r.type!=="CLOCK_TIME"||n?.type!=="TO"||i?.type!=="CLOCK_TIME"?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("CLOCK_TIME_INTERVAL",`${r.value}:${i.value}`,e.slice(o,o+3))],ruleName:"time:clock-time-interval"}}}}function as(t=65){return {name:"time:fps-rate",priority:t,startTokenTypes:["NUMBER"],match(e,o){let r=e[o],n=e[o+1];return r.type!=="NUMBER"||n?.type!=="IDENT"||n.value.toLowerCase()!=="fps"?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b("FPS_RATE",r.value,e.slice(o,o+2))],ruleName:"time:fps-rate"}}}}function ss(t=70){return {name:"time:laptime",priority:t,startTokenTypes:["NUMBER"],match(e,o){if(chunkLZSSAH5D_cjs.e(e,o))return null;let r=e[o],n=e[o+1],i=e[o+2],a=e[o+3],s=e[o+4];if(r.type!=="NUMBER"||n?.type!=="COLON"||i?.type!=="NUMBER"||a?.type!=="COLON"||s?.type!=="NUMBER")return null;let l=parseInt(r.value,10),u=parseInt(i.value,10),c=parseFloat(s.value);if(isNaN(l)||isNaN(u)||isNaN(c)||u<0||u>59||c<0||c>=60)return null;let f=l*3600+u*60+c;return {consumed:5,replacement:[chunkLZSSAH5D_cjs.b("LAPTIME",String(f),e.slice(o,o+5))],ruleName:"time:laptime"}}}}function ms(t=75){return {name:"time:video-timecode",priority:t,startTokenTypes:["NUMBER"],match(e,o){if(chunkLZSSAH5D_cjs.e(e,o))return null;let r=e[o],n=e[o+1],i=e[o+2],a=e[o+3],s=e[o+4],l=e[o+5],u=e[o+6];if(r?.type!=="NUMBER"||n?.type!=="COLON"||i?.type!=="NUMBER"||a?.type!=="COLON"||s?.type!=="NUMBER"||l?.type!=="COLON"||u?.type!=="NUMBER")return null;let c=parseInt(r.value,10),f=parseInt(i.value,10),T=parseInt(s.value,10),N=parseInt(u.value,10);return [c,f,T,N].some(E=>isNaN(E))||f<0||f>59||T<0||T>59||c<0||N<0?null:{consumed:7,replacement:[chunkLZSSAH5D_cjs.b("VIDEO_TIMECODE",`${c},${f},${T},${N}`,e.slice(o,o+7))],ruleName:"time:video-timecode"}}}}function ls(t=65){return {name:"time:frame-count",priority:t,startTokenTypes:["NUMBER"],match(e,o){let r=e[o],n=e[o+1];return r.type!=="NUMBER"||n?.type!=="IDENT"||n.value.toLowerCase()!=="frames"?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b("FRAME_COUNT",r.value,e.slice(o,o+2))],ruleName:"time:frame-count"}}}}var dc=14,Ec=[["week","weeks",604800],["day","days",86400],["hour","hours",3600],["minute","minutes",60],["second","seconds",1]];function us(t){if(t.type===0)return t.toNumber();if(t.type!==6||t.unit===void 0)return null;let e=chunk6QRHN3I6_cjs.a[t.unit.toLowerCase()];return e===void 0||e[0]!==dc?null:t.toNumber()*e[1]}function cs(t){let e=us(t);if(e===null)return chunk6U66HQKQ_cjs.t(`"as timespan" needs a duration, got ${t.unit??"a non-duration"}`);let o=e<0,r=Math.abs(e),n=[];for(let[a,s,l]of Ec){if(l===1)break;let u=Math.floor(r/l);u>0&&(n.push(`${u} ${u===1?a:s}`),r-=u*l);}let i=Math.round(r*1e3)/1e3;return (i>0||n.length===0)&&n.push(`${i} ${i===1?"second":"seconds"}`),chunk6U66HQKQ_cjs.t((o?"-":"")+n.join(" "))}function cn(t){let e=us(t);if(e===null)return chunk6U66HQKQ_cjs.t(`"as laptime" needs a duration, got ${t.unit??"a non-duration"}`);let o=e<0,r=Math.round(Math.abs(e)*1e3)/1e3,n=Math.floor(r/3600),i=Math.floor(r%3600/60),a=r%60,s=Math.floor(a),l=Math.round((a-s)*1e3),u=`${un(n)}:${un(i)}:${un(s)}`;return chunk6U66HQKQ_cjs.t((o?"-":"")+(l>0?`${u}.${String(l).padStart(3,"0")}`:u))}function un(t){return t<10?`0${t}`:String(t)}var pn={name:"solve-time",asConverters:{timespan:cs,laptime:cn,lap:cn},phrases:{"time in":"TIME_IN","date in":"DATE_IN","time difference between":"TIME_DIFFERENCE_BETWEEN",...Object.fromEntries(Object.keys(tn).map(t=>[t,"CITY_NAME"]))},prefixParselets:{CLOCK_TIME:new Yt,CLOCK_TIME_INTERVAL:new jt,FPS_RATE:new Xt,LAPTIME:new Qt,TIME_IN:ln(sn),DATE_IN:ln(mn),TIME_DIFFERENCE_BETWEEN:new qt,VIDEO_TIMECODE:new Zt,FRAME_COUNT:new Jt},normalizerRules:[ns(),is(),as(),ss(),ms(),ls()],pluginFunctions:{[$t]:qa,[sn]:Za,[mn]:Ja,[Wt]:es}};function er(t){for(let e of t.alternatives){let o=e.slots[0];if(!o||o.kind!=="keyword")throw chunkNAZ6PGLS_cjs.c.config("INVALID_PHRASE_PATTERN","Every PhraseAlternative's first slot must be a `keyword` slot \u2014 alternatives are chosen by peeking the next token, which only works if the choice is decidable from one leading keyword.",{category:t.category})}return {category:t.category,parse(e,o,r){let n=e.peek(),i=t.alternatives.find(s=>{let l=s.slots[0];return n!==void 0&&l.tokenTypes.includes(n.type)});if(!i){let s=t.alternatives.map(l=>l.slots[0].tokenTypes.join("|")).join(", ");throw chunkNAZ6PGLS_cjs.c.parsing("NO_MATCHING_PHRASE_ALTERNATIVE",`Expected one of [${s}] but got "${n?.type??"end of input"}" ("${n?.value??""}")`,{category:t.category,expected:s,actualType:n?.type,actualValue:n?.value})}let a=[];for(let s of i.slots)if(s.kind==="keyword"){let l=e.peek();if(!l||!s.tokenTypes.includes(l.type))throw chunkNAZ6PGLS_cjs.c.parsing("PHRASE_KEYWORD_MISMATCH",`Expected one of [${s.tokenTypes.join("|")}] but got "${l?.type??"end of input"}" ("${l?.value??""}")`,{category:t.category,expected:s.tokenTypes,actualType:l?.type,actualValue:l?.value});e.consume(),a.push({type:l.type,value:l.value});}else e.parseExpression(s.bindingPower??0,r);i.emit(r,a);}}}var Tc=37;function tr(t){t.emitOpcode(51),t.emitIndex(Tc),t.emitIndex(2);}var Nc=er({category:"Dice",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:tr},{slots:[{kind:"keyword",tokenTypes:["FROM"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["TO"]},{kind:"expr"}],emit:tr},{slots:[{kind:"keyword",tokenTypes:["LPAREN"]},{kind:"expr"},{kind:"keyword",tokenTypes:["COMMA"]},{kind:"expr"},{kind:"keyword",tokenTypes:["RPAREN"]}],emit:tr}]}),rr=class{constructor(){this.category="Dice";}parse(e,o,r){let n=e.peek();if(n&&n.type==="NUMBER"){let i=e.consume();r.emitOpcode(10),r.emitNumber(parseFloat(i.value)),e.consume("MINUS");let a=e.consume();r.emitOpcode(10),r.emitNumber(parseFloat(a.value)),tr(r);return}Nc.parse(e,o,r);}};var fn={name:"solve-dice",prefixParselets:{ROLL:new rr}};var or=class{constructor(){this.category="Variable";}parse(e,o,r){let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("EXPECTED_IDENTIFIER",`Expected identifier or unit after colon, got ${n.type}`,{tokenType:n.type});let i=n.value;e.peek()?.type==="EQUALS"?(e.consume("EQUALS"),e.parseExpression(0,r),r.emitOpcode(61),r.emitString(i)):(r.emitOpcode(60),r.emitString(i));}};var it=class{constructor(){this.category="Variable";}parse(e,o,r){r.emitOpcode(60),r.emitString(o.value);}};var nr=class{constructor(){this.category="Variable";}parse(e,o,r){e.consume("COLON");let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("EXPECTED_IDENTIFIER",`Expected identifier after 'global :', got ${n.type}`,{tokenType:n.type});let i=n.value;e.peek()?.type==="EQUALS"?(e.consume("EQUALS"),e.parseExpression(0,r),r.emitOpcode(63),r.emitString(i)):(r.emitOpcode(62),r.emitString(i));}};var ir=class{constructor(){this.namespace="global-variables";this.pending=new Map;}preflight(e,o,r,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=0;for(;u<l;){if(a[u]===62){let f=s[a[u+1]];if(!chunkEEVUKZ5B_cjs.J.has(f))return this.pendingResultFor(f,r,n)}u=chunkW5ELYJ4Z_cjs.a(a,u);}return null}pendingResultFor(e,o,r){let n=this.pending.get(e);return n||(n=new Promise(i=>{let a=chunkEEVUKZ5B_cjs.J.subscribe((s,l)=>{s===e&&(a(),this.pending.delete(e),i(l));});}),this.pending.set(e,n)),{queryKey:`global:${e}`,resolver:n,packageId:o,signal:r,metadata:{varName:e}}}destroy(){this.pending.clear();}};var dn={name:"solve-variables",asyncResolvers:[new ir],prefixParselets:{COLON:new or,IDENT:new it,UNIT:new it,GLOBAL:new nr}};var fs="currency-historical",fe="historicalCurrency",yc=`solve-currency:${fe}`,ar={NOT_CONFIGURED:"HISTORICAL_RATES_NOT_CONFIGURED",QUERY_FAILED:"HISTORICAL_RATE_QUERY_FAILED",NOT_PREFLIGHTED:"HISTORICAL_RATE_NOT_PREFLIGHTED",INVALID_OPERAND:"HISTORICAL_CURRENCY_INVALID_OPERAND"},gc=3e4,ds=1/0,Pc=1e4;function En(t,e,o){return [fs,`${t.toUpperCase()}:${e.toUpperCase()}:${o}`]}function ps(t){return t<10?`0${t}`:String(t)}function sr(t,e,o){if(!chunkGWCBPITD_cjs.c.isCurrency(e)||o!==void 0&&!chunkGWCBPITD_cjs.c.isCurrency(o))return null;let r=t.peek();if(!r||r.type!=="IDENT"||r.value.toLowerCase()!=="on")return null;let n=t.peekAt(1);if(!n||n.type!=="DATETIME_LITERAL")return null;t.consume(),t.consume();let i=new Date(Number(n.value));return `${i.getFullYear()}-${ps(i.getMonth()+1)}-${ps(i.getDate())}`}async function Es(t,e,o,r,n,i){let a=e.toUpperCase(),s=o.toUpperCase();if(!t)return chunk6U66HQKQ_cjs.P(ar.NOT_CONFIGURED,`Historical exchange rates are not configured. Supply historicalRateProvider via createCurrencyPackage({ ... }) to convert ${a} to ${s} on ${r}.`);let{signal:l,cleanup:u}=chunkTLG7VZRX_cjs.a(n,Pc,"Historical currency rate fetch");try{let c=await t(a,s,r,l);return chunk6U66HQKQ_cjs.n(c)}catch(c){let f=chunk6U66HQKQ_cjs.P(ar.QUERY_FAILED,`Failed to resolve the historical rate for ${a} to ${s} on ${r}: ${c instanceof Error?c.message:String(c)}`),T=En(e,o,r);return setTimeout(()=>{i.getQueryData(T)===f&&i.removeQueries({queryKey:T,exact:true});},gc).unref?.(),f}finally{u();}}function Tn(t){return e=>{let o=e[0],r=e[1],n=e[2],i=chunk6U66HQKQ_cjs.Q(o);if(i)return i;if(o.type!==6||o.unit===void 0||!chunkGWCBPITD_cjs.c.isCurrency(o.unit))return chunk6U66HQKQ_cjs.P(ar.INVALID_OPERAND,'Historical conversion needs an amount in a currency, for example "100 USD in GBP on 2024-01-15".');let a=o.unit,s=String(r.value),l=String(n.value);if(a.toUpperCase()===s.toUpperCase())return chunk6U66HQKQ_cjs.u(o.toNumber(),s);let u=chunkZLRJ7TDP_cjs.b(),c=En(a,s,l),f=u?.getQueryData(c);if(f===void 0)return u?u.fetchQuery({queryKey:c,queryFn:({signal:N})=>Es(t,a,s,l,N,u),staleTime:ds}):chunk6U66HQKQ_cjs.P(ar.NOT_PREFLIGHTED,`No historical rate resolved for ${a.toUpperCase()} to ${s.toUpperCase()} on ${l}.`);if(f.type===13)return f;let T=f.value;return chunk6U66HQKQ_cjs.u(o.toNumber()*T,s)}}function Ts(t){return {namespace:fs,preflight(e,o,r,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=chunkEEVUKZ5B_cjs.F(yc),c=0,f=[];for(;c<l;){let T=a[c];if(T===13)f.push(a[c+1]);else if(T===50){let N=a[c+1],E=a[c+2];if(N===u&&E===3&&f.length>=3){let _=s[f[f.length-1]],O=s[f[f.length-2]],R=new Set;for(let g=0;g<f.length-2;g++){let P=s[f[g]];chunkGWCBPITD_cjs.c.isCurrency(P)&&R.add(P.toUpperCase());}if(R.size===1){let g=R.values().next().value;if(g!==O.toUpperCase()){let P=En(g,O,_);if(i.getQueryData(P)===void 0){let C=i.fetchQuery({queryKey:P,queryFn:({signal:S})=>Es(t,g,O,_,S,i),staleTime:ds});return {queryKey:P.join(":"),resolver:C,packageId:r,signal:n,metadata:{from:g,to:O,isoDate:_}}}}}}f=[];}c=chunkW5ELYJ4Z_cjs.a(a,c);}return null},destroy(){}}}function Ns(t){return chunk2XZCLDHJ_cjs.ta(t)??t}var mr=class{constructor(){this.category="UoM";this.bindingPower=chunkFVQWN5HZ_cjs.a.Postfix;}parse(e,o,r,n){let i=Ns(r.value);if(n.emitOpcode(13),n.emitString(i),!(e.infixMinBindingPower>=chunkFVQWN5HZ_cjs.a.Product)&&(e.peek()?.type==="TO"||e.peek()?.type==="IN")){e.consume();let s=e.peek();if(s?.type==="UNIT"||s?.type==="IN"){e.consume();let l=Ns(s.value),u=sr(e,l,i);if(u!==null){n.emitOpcode(80),n.emitOpcode(13),n.emitString(l),n.emitOpcode(13),n.emitString(u),n.emitPluginCall(fe,3);return}n.emitOpcode(13),n.emitString(l),n.emitOpcode(81);return}if(s?.type==="QUESTION"){e.consume(),n.emitOpcode(85);return}}if(e.peek()?.type==="BEST"){e.consume(),n.emitOpcode(83);return}n.emitOpcode(80);}};function Nn(t){return chunk2XZCLDHJ_cjs.ta(t)??t}var lr=class{constructor(){this.category="UoM";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Postfix,r);let n=e.peek();if(n&&n.type==="UNIT"){if(e.consume(),r.emitOpcode(13),r.emitString(Nn(n.value)),e.peek()?.type==="TO"){e.consume("TO");let i=e.consume();i?.type==="UNIT"?(r.emitOpcode(13),r.emitString(Nn(i.value)),r.emitOpcode(81)):i?.type==="BEST"&&r.emitOpcode(83);}else r.emitOpcode(80);return}if(n&&(n.type==="TO"||n.type==="IN")){e.consume();let i=e.peek();i?.type==="UNIT"||i?.type==="IN"||i?.type==="DOLLAR"||i?.type==="POUND"||i?.type==="EURO"||i?.type==="YEN"||i?.type==="RUBLE"||i?.type==="WON"||i?.type==="CURRENCY_SYMBOL"||i?.type==="IDENT"?(e.consume(),r.emitOpcode(13),r.emitString(Nn(i.value)),r.emitOpcode(84)):i?.type==="BEST"&&(e.consume(),r.emitOpcode(83));return}}};var ur=class{constructor(){this.category="UoM";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitOpcode(85);}};function ys(t=60){return {name:"uom:possibilities",priority:t,startTokenTypes:["UNIT"],match(e,o){if(o+2>=e.length)return null;let r=e[o],n=e[o+1],i=e[o+2];return r.type!=="UNIT"||n.type!=="TO"||i.type!=="QUESTION"?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("UOM_POSSIBILITIES_QUERY",r.value,[r,n,i])],ruleName:"uom:possibilities"}}}}var gs=14;function Ps(t,e){if(t===void 0||t.type!=="UNIT")return;let o=(t.value??"").toLowerCase();if(o==="m"&&e===gs)return {kind:gs,ratio:60,spelling:"minutes"};let r=chunk6QRHN3I6_cjs.a[o];return r===void 0?void 0:{kind:r[0],ratio:r[1],spelling:o}}var _s=/^\d+(\.\d+)?$/;function As(t=63){return {name:"uom:compound-quantity",priority:t,startTokenTypes:["NUMBER"],match(e,o){let r=e[o];if(r?.type!=="NUMBER"||!_s.test(r.text??""))return null;let n=Ps(e[o+1]);if(n===void 0)return null;let i=n.kind,a=n.ratio,s=Number(r.text)*a,l=n.spelling,u=e[o+1],c=2;for(;;){let N=e[o+c];if(N?.type!=="NUMBER"||!_s.test(N.text??""))break;let E=Ps(e[o+c+1],i);if(E===void 0||E.kind!==i||E.ratio>=a)break;s+=Number(N.text)*E.ratio,a=E.ratio,l=E.spelling,u=e[o+c+1],c+=2;}if(c===2)return null;let f=e.slice(o,o+c),T=s/a;return {consumed:c,replacement:[chunkLZSSAH5D_cjs.b("NUMBER",String(T),f),chunkLZSSAH5D_cjs.b("UNIT",l,[u])],ruleName:"uom:compound-quantity"}}}}function xs(t){return t===void 0||t.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(t.value??"").toLowerCase()]!==void 0}function Os(t=59){return {name:"uom:two-unit-conversion",priority:t,startTokenTypes:["IN","TO"],match(e,o){let r=e[o];if(r?.type!=="IN"&&r?.type!=="TO"||!xs(e[o+1])||e[o+2]?.type!=="AND_CONJ"||!xs(e[o+3]))return null;let n=e[o+1].value,i=e[o+3].value;return {consumed:4,replacement:[chunkLZSSAH5D_cjs.b("IN_TWO_UNITS",`${n} ${i}`,e.slice(o,o+4))],ruleName:"uom:two-unit-conversion"}}}}function Rs(t=74){return {name:"uom:degree-symbol",priority:t,startTokenTypes:["NUMBER"],match(e,o){let r=e[o];if(r?.type!=="NUMBER")return null;let n=e[o+1];return n===void 0||n.type!=="IDENT"||(n.text??n.value??"")!=="\xB0"?null:{consumed:2,replacement:[r,chunkLZSSAH5D_cjs.b("UNIT","degrees",[n])],ruleName:"uom:degree-symbol"}}}}var cr=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){let[i,a]=String(r.value).split(" ");n.emitOpcode(13),n.emitString(i),n.emitOpcode(13),n.emitString(a),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(3);}};function Is(t){return t===void 0||t.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(t.value??"").toLowerCase()]!==void 0}var yn=new Set(["per","a","an","each","every"]);function _c(t){if(t===void 0||t.type!=="IDENT")return false;let e=(t.text??t.value??"").toLowerCase();return yn.has(e)?false:/^[a-z][a-z_]{2,}$/.test(e)&&chunk6QRHN3I6_cjs.a[e]===void 0}function Cs(t=75){return {name:"uom:bare-rate-denominator",priority:t,match(e,o){let r=e[o];if(r===void 0)return null;if(r.type==="NUMBER"&&_c(e[o+1])){let l=e[o+1],u=e[o+2];if((u?.type==="SLASH"||u?.type==="IDENT"&&yn.has((u.text??u.value??"").toLowerCase()))&&Is(e[o+3]))return {consumed:2,replacement:[r,chunkLZSSAH5D_cjs.b("UNIT",l.value,[l])],ruleName:"uom:bare-rate-denominator"}}if(!Is(e[o+1]))return null;let n=r.type==="SLASH",i=(r.text??r.value??"").toLowerCase(),a=r.type==="IDENT"&&yn.has(i);if(!n&&!a)return null;let s=e[o+1];return {consumed:2,replacement:[chunkLZSSAH5D_cjs.b("PER_UNIT",s.value,[r,s])],ruleName:"uom:bare-rate-denominator"}}}}var pr=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,r,n){n.emitOpcode(13),n.emitString(String(r.value)),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};var fr=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkFVQWN5HZ_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};function Ac(t){return t===void 0||t.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(t.value??"").toLowerCase()]!==void 0}var xc=new Set(["per","a","an","each","every"]);function Oc(t,e){for(let o=e;o<t.length&&o<e+5;o++){let r=t[o];if(r.type==="PER_UNIT")return true;if(r.type==="EOF"||r.type==="COMMA"||r.type==="RATE_AT")return false;let n=(r.text??r.value??"").toLowerCase();if((r.type==="SLASH"||r.type==="IDENT"&&xc.has(n))&&Ac(t[o+1]))return true}return false}function hs(t=73){return {name:"uom:at-rate",priority:t,startTokenTypes:["RATE_AT"],match(e,o){return e[o]?.type!=="RATE_AT"||!Oc(e,o+1)?null:{consumed:1,replacement:[chunkLZSSAH5D_cjs.b("AT_RATE","at",[e[o]])],ruleName:"uom:at-rate"}}}}function Rc(t){return t===void 0||t.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Ic=new Set(["a","an"]);function Ss(t=76){return {name:"uom:for-duration",priority:t,startTokenTypes:["FOR_DURATION"],match(e,o){let r=e[o];if(r?.type!=="FOR_DURATION")return null;let n=e[o+1];return n?.type!=="IDENT"||!Ic.has((n.text??n.value??"").toLowerCase())||!Rc(e[o+2])?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("STAR","*",[r]),chunkLZSSAH5D_cjs.b("NUMBER","1",[n]),e[o+2]],ruleName:"uom:for-duration"}}}}function gn(t){return t===void 0||t.type!=="UNIT"?false:chunk6QRHN3I6_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Cc=new Set(["a","an"]);function Ls(t=61){return {name:"uom:reversed-conversion",priority:t,startTokenTypes:["UNIT"],match(e,o){if(o!==0||!gn(e[o])||e[o+1]?.type!=="IN")return null;let r=e[o],n=e[o+2];if(n===void 0)return null;if(n.type==="NUMBER"&&gn(e[o+3]))return {consumed:4,replacement:[n,e[o+3],e[o+1],r],ruleName:"uom:reversed-conversion"};let i=(n.text??n.value??"").toLowerCase();return n.type==="IDENT"&&Cc.has(i)&&gn(e[o+3])?{consumed:4,replacement:[chunkLZSSAH5D_cjs.b("NUMBER","1",[n]),e[o+3],e[o+1],r],ruleName:"uom:reversed-conversion"}:null}}}var hc={water:1,milk:1.03,"whole milk":1.03,"skim milk":1.035,buttermilk:1.03,"heavy cream":1,"whipping cream":1,"sour cream":.96,yogurt:1.03,"greek yogurt":1.05,"cream cheese":1.01,"condensed milk":1.3,"evaporated milk":1.06,"coconut milk":.97,"almond milk":1.03,"soy milk":1.03,butter:.9595,margarine:.96,"vegetable oil":.92,"olive oil":.913,"canola oil":.92,"coconut oil":.92,"sunflower oil":.92,"sesame oil":.92,mayonnaise:.91,sugar:.845,"granulated sugar":.845,"brown sugar":.93,"powdered sugar":.51,"icing sugar":.51,honey:1.42,"maple syrup":1.32,"corn syrup":1.38,molasses:1.4,nutella:1.14,"peanut butter":1.09,flour:.53,"all-purpose flour":.53,"all purpose flour":.53,"bread flour":.54,"cake flour":.47,"whole wheat flour":.55,cornstarch:.53,cornmeal:.65,semolina:.6,rice:.79,"white rice":.79,"brown rice":.8,oats:.34,"rolled oats":.38,breadcrumbs:.43,yeast:.68,"dry yeast":.68,salt:1.2,"table salt":1.2,"kosher salt":.96,"baking powder":.9,"baking soda":.99,"cream of tartar":.68,cinnamon:.56,ginger:.5,"vanilla extract":.88,"lemon juice":1.03,"lime juice":1.02,"orange juice":1.04,vinegar:1.01,cocoa:.41,"cocoa powder":.41,"chocolate chips":.72,"chocolate chunks":.72,coconut:.35,"shredded coconut":.35,raisins:.68,almonds:.55,walnuts:.5,pecans:.5,pistachios:.55,peanuts:.6,"shredded cheese":.4,parmesan:.44,"tomato paste":1.06,"tomato sauce":1.02,ketchup:1.14,broth:1,stock:1,wine:.99,beer:1.01},ws=2;function vs(t){return hc[t.toLowerCase().trim()]}var dr="cookingConvert";function ks(t){let e=t[0],o=t[1].value,r=t[2].value;if(e.type!==6||!e.unit)return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_REQUIRES_UNIT",'Expected a value with a mass or volume unit (e.g. "300g", "10 cups"), got a plain number');let n=e.unit,i=e.toNumber(),a=chunkBKSKZA4W_cjs.c(n),s=chunkBKSKZA4W_cjs.c(r),l=N=>N==="mass"||N==="volume";if(!l(a))return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${n}" is not a recognized mass or volume unit`);if(!l(s))return chunk6U66HQKQ_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${r}" is not a recognized mass or volume unit`);if(a===s)return chunk6U66HQKQ_cjs.u(chunkBKSKZA4W_cjs.e(i,n,r),r);let u=vs(o);if(u===void 0)return chunk6U66HQKQ_cjs.P("COOKING_UNKNOWN_INGREDIENT",`No density data for "${o}" \u2014 cannot convert between mass and volume for this ingredient`);if(a==="mass"){let E=chunkBKSKZA4W_cjs.e(i,n,"g")/u,_=chunkBKSKZA4W_cjs.e(E,"ml",r);return chunk6U66HQKQ_cjs.u(_,r)}let f=chunkBKSKZA4W_cjs.e(i,n,"ml")*u,T=chunkBKSKZA4W_cjs.e(f,"g",r);return chunk6U66HQKQ_cjs.u(T,r)}var Er=class{constructor(){this.category="UoM";this.bindingPower=35;}parse(e,o,r,n){let i=r.value;e.consume("IN");let a=e.consume();n.emitOpcode(13),n.emitString(i),n.emitOpcode(13),n.emitString(a.value),n.emitPluginCall(dr,3);}};function Bs(t=68){return {name:"uom-cooking:ingredient-name",priority:t,match(e,o){let r=e[o-1];if(!r||r.type!=="UNIT")return null;for(let n=ws;n>=1;n--){if(o+n>e.length)continue;let i=e.slice(o,o+n);if(!i.every(c=>c.type==="IDENT"))continue;let a=o+n,s=e[a];if(!s||s.type!=="IN")continue;let l=e[a+1];if(!l||l.type!=="UNIT"&&l.type!=="IDENT")continue;let u=i.map(c=>c.value.toLowerCase()).join(" ");return {consumed:n,replacement:[chunkLZSSAH5D_cjs.b("INGREDIENT_NAME",u,i)],ruleName:"uom-cooking:ingredient-name"}}return null}}}function Ms(t=78){return {name:"uom:multi-word-unit",priority:t,startTokenTypes:["UNIT"],match(e,o){let r=e[o],n=e[o+1];if(r?.type!=="UNIT"||n?.type!=="UNIT"||r.offset+r.text.length+1!==n.offset)return null;let i=`${r.value} ${n.value}`;return chunk6QRHN3I6_cjs.a[i]===void 0?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b("UNIT",i,e.slice(o,o+2))],ruleName:"uom:multi-word-unit"}}}}function Us(t=77){return {name:"uom:compound-unit",priority:t,startTokenTypes:["UNIT"],match(e,o){let r=e[o],n=e[o+1],i=e[o+2];if(r?.type!=="UNIT"||n?.type!=="SLASH"||i?.type!=="UNIT")return null;let a=`${r.value}/${i.value}`;return {consumed:3,replacement:[chunkLZSSAH5D_cjs.b("UNIT",a,[r,n,i])],ruleName:"uom:compound-unit"}}}}var Pn={name:"solve-uom",prefixParselets:{CONVERT:new lr,UOM_POSSIBILITIES_QUERY:new ur},infixParselets:{IN_TWO_UNITS:new cr(94),PER_UNIT:new pr(95),AT_RATE:new fr(96),UNIT:new mr,INGREDIENT_NAME:new Er},normalizerRules:[Ms(),Us(),ys(),As(),Os(),Rs(),hs(),Ss(),Cs(),Ls(),Bs()],pluginFunctions:{[dr]:ks}};var Q=class{constructor(){this.category="UoM";}parse(e,o,r){let n=chunk2XZCLDHJ_cjs.ta(o.value)??o.value.toUpperCase();e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,r),e.peek()?.type==="UNIT"&&e.consume(),r.emitOpcode(13),r.emitString(n),r.emitOpcode(80);}};var Tr=class{constructor(){this.category="UoM";this.bindingPower=35;}parse(e,o,r,n){let i=e.peek();if(i?.type==="IP_CIDR"){e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,n),n.emitPluginCall("ipInCidr",2);return}if(i&&(i.type==="UNIT"||i.type==="DOLLAR"||i.type==="POUND"||i.type==="EURO"||i.type==="YEN"||i.type==="RUBLE"||i.type==="WON"||i.type==="CURRENCY_SYMBOL"||i.type==="IDENT"||i.type==="IN")){e.consume();let a=chunk2XZCLDHJ_cjs.ta(i.value)??i.value,s=sr(e,a);if(s!==null){n.emitOpcode(13),n.emitString(a),n.emitOpcode(13),n.emitString(s),n.emitPluginCall(fe,3);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(84);}}};function _n(t={}){return {name:"solve-currency",asyncResolvers:[new chunkW5ELYJ4Z_cjs.b,Ts(t.historicalRateProvider)],prefixParselets:{DOLLAR:new Q,POUND:new Q,EURO:new Q,YEN:new Q,RUBLE:new Q,WON:new Q,CURRENCY_SYMBOL:new Q},infixParselets:{IN:new Tr},pluginFunctions:{[fe]:Tn(t.historicalRateProvider)}}}var An=_n();var he=class{constructor(e=0){this.category="Vector";this.dimension=e;}parse(e,o,r){e.consume("LPAREN");let n=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(0,r),n++;e.match("COMMA");)e.parseExpression(0,r),n++;e.consume("RPAREN"),r.emitOpcode(152),r.emitIndex(1),r.emitIndex(this.dimension>0?this.dimension:n);}};var Nr=class{constructor(){this.category="Float";}parse(e,o,r){e.consume("LPAREN"),e.parseExpression(0,r),e.consume("RPAREN"),r.emitOpcode(152),r.emitIndex(1),r.emitIndex(1);}};var xn={name:"solve-vector",prefixParselets:{VEC2:new he(2),VEC3:new he(3),VEC4:new he(4),FLOAT:new Nr}};var yr=class{constructor(){this.category="Matrix";}parse(e,o,r){let n=0,i=-1;if(e.peek()?.type==="RBRACKET")throw chunkNAZ6PGLS_cjs.c.parsing("EMPTY_MATRIX_LITERAL","A matrix literal cannot be empty \u2014 `[]` has no valid shape.",{});for(;;){let a=0;for(e.parseExpression(0,r),a++;e.match("COMMA");)e.parseExpression(0,r),a++;if(i===-1)i=a;else if(a!==i)throw chunkNAZ6PGLS_cjs.c.parsing("RAGGED_MATRIX_LITERAL",`Matrix literal rows must all have the same number of columns \u2014 row ${n+1} has ${a}, but a previous row has ${i}.`,{expectedCols:i,actualCols:a,row:n+1});if(n++,!e.match("SEMICOLON"))break}e.consume("RBRACKET"),r.emitOpcode(152),r.emitIndex(n),r.emitIndex(i);}};var gr=class{constructor(){this.category="Matrix";this.bindingPower=chunkFVQWN5HZ_cjs.a.Postfix;}parse(e,o,r,n){let i=this.hasTopLevelColon(e);this.parseIndexArg(e,n,i);let a=1;if(e.match("COMMA")&&(this.parseIndexArg(e,n,i),a=2),e.consume("RBRACKET"),!i){a===1?n.emitOpcode(153):n.emitOpcode(154);return}if(a!==2)throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_MATRIX_SLICE_ARITY",`Range-based matrix slicing needs exactly 2 arguments ("a[rowRange, colRange]"), got ${a}.`,{argCount:a});n.emitOpcode(155);}hasTopLevelColon(e){let o=0;for(let r=0;;r++){let n=e.peekAt(r);if(!n)return false;if(n.type==="LBRACKET"||n.type==="LPAREN")o++;else if(n.type==="RBRACKET"||n.type==="RPAREN"){if(o===0)return false;o--;}else if(n.type==="COLON"&&o===0)return true}}parseIndexArg(e,o,r){e.parseExpression(0,o);let n=false;e.match("COLON")&&(e.parseExpression(0,o),n=true),r&&(n||o.emitOpcode(3),o.emitOpcode(156));}};var On={name:"solve-matrix",prefixParselets:{LBRACKET:new yr},infixParselets:{LBRACKET:new gr}};function Pr(t,e){let o=t.peek(),r=t.peekAt(1);if(o&&(o.type==="IDENT"||o.type==="UNIT"||o.type==="FUNC")&&r?.type==="COMMA"){t.consume();let a=o.value,s=Yo[a.toLowerCase()];return s!==void 0?{kind:1,builtinIdx:s}:{kind:2,name:a}}let n=new chunkFVQWN5HZ_cjs.d(e.pluginIndexMap);t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),t.setBuilder(e);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","map/reduce transform expressions must be synchronous (no weather/stocks/currency calls).");return {kind:0,program:i}}function Ds(t){let e=t.peek(),o=t.peekAt(1);return !!e&&(e.type==="IDENT"||e.type==="UNIT")&&o?.type==="EQUALS"}function bs(t){let e=t.peek();if(e&&(e.type==="IDENT"||e.type==="UNIT"))return t.consume(),e.value;throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_EXPECTED_COLLECTION_NAME",`Expected a collection name (e.g. "x" in "x=[1,2,3]") but got ${e?`"${e.value}"`:"end of input"}.`)}function ee(t,e){t.parseExpression(0,e),t.match("COLON")&&(t.parseExpression(0,e),e.emitOpcode(156));}function ie(t,e,o,r,n){if(t.emitOpcode(e),t.emitIndex(o.kind),o.kind===0){let i=t.emitAnonymousBody(r,o.program);t.emitIndex(i);}else o.kind===1?t.emitIndex(o.builtinIdx):t.emitString(o.name);t.emitIndex(n);}var _r=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=Pr(e,r);e.consume("COMMA");let i=[];if(Ds(e))do{let a=bs(e);e.consume("EQUALS"),ee(e,r),i.push(a);}while(e.match("COMMA"));else ee(e,r),i.push("x");e.consume("RPAREN"),ie(r,157,n,i,i.length);}};var Ar=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=Pr(e,r);e.consume("COMMA"),ee(e,r);let i=0;e.match("COMMA")&&(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i=1),e.consume("RPAREN"),ie(r,158,n,["acc","x"],i);}};var xr=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=new chunkFVQWN5HZ_cjs.d(r.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),e.setBuilder(r),n.emitOpcode(20);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","sum's element expression must be synchronous (no weather/stocks/currency calls).");e.consume("COMMA"),ee(e,r),e.consume("RPAREN"),r.emitOpcode(10),r.emitNumber(0),ie(r,158,{kind:0,program:i},["acc","x"],1);}};var Or=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=new chunkFVQWN5HZ_cjs.d(r.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,n),e.setBuilder(r),n.emitOpcode(22);let i=n.build();if(i.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("MAP_REDUCE_TRANSFORM_MUST_BE_SYNCHRONOUS","prod's element expression must be synchronous (no weather/stocks/currency calls).");e.consume("COMMA"),ee(e,r),e.consume("RPAREN"),r.emitOpcode(10),r.emitNumber(1),ie(r,158,{kind:0,program:i},["acc","x"],1);}};var Sc={map:"MAP",reduce:"REDUCE",sum:"SUM_FN",prod:"PROD_FN"};function Lc(t,e){return t?!!(t.type==="LINE_REF"||t.type==="IDENT"&&(/^line\d+$/i.test(t.value)||/^line$/i.test(t.value)&&e?.type==="NUMBER"&&/^\d+$/.test(e.value))):false}function Vs(t=80){return {name:"mapreduce:call",priority:t,startTokenTypes:["IDENT"],match(e,o){let r=e[o];if(!r||r.type!=="IDENT")return null;let n=r.value.toLowerCase(),i=Sc[n];return !i||e[o+1]?.type!=="LPAREN"||n==="sum"&&Lc(e[o+2],e[o+3])?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(i,chunk5IJD5L3O_cjs.c(i),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"mapreduce:call"}}}}var Rn={name:"solve-mapreduce",normalizerRules:[Vs()],prefixParselets:{MAP:new _r,REDUCE:new Ar,SUM_FN:new xr,PROD_FN:new Or}};var Rr=class{constructor(){this.category="BigInt";}parse(e,o,r){r.emitOpcode(11),r.emitString(chunkFVQWN5HZ_cjs.e(o.value,e.getLocaleCode()));}};var In={name:"solve-bigint",prefixParselets:{BIGINT:new Rr}};var te=class{constructor(e){this.opcode=e;this.category="Conditionals";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(this.opcode);}};var Se=class{constructor(e,o){this.opcode=e;this.bindingPower=o;this.category="Conditionals";}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(this.opcode);}};var at=class{constructor(e){this.value=e;this.category="Conditionals";}parse(e,o,r){r.emitOpcode(14),r.emitByte(this.value?1:0);}};var Ir=class{constructor(){this.category="Conditionals";}parse(e,o,r){e.parseExpression(0,r),e.consume("THEN"),e.parseExpression(0,r),e.consume("ELSE"),e.parseExpression(0,r),r.emitOpcode(132);}};var Cn={name:"solve-conditionals",prefixParselets:{TRUE:new at(true),FALSE:new at(false),IF:new Ir},infixParselets:{EQUALITY:new te(40),NEQ:new te(41),LT:new te(42),GT:new te(44),LTE:new te(43),GTE:new te(45),OR:new Se(131,chunkFVQWN5HZ_cjs.a.LogicalOr),LOGICAL_AND:new Se(130,chunkFVQWN5HZ_cjs.a.LogicalAnd),LOGICAL_OR:new Se(131,chunkFVQWN5HZ_cjs.a.LogicalOr)}};var wc={percent:74,percentage:74,decimal:70,dec:70,number:70,hex:71,fraction:140,multiplier:141,x:141,sci:142,scientific:142,binary:143,bin:143,octal:144,oct:144},Fs={2:143,8:144,16:71},Cr=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){let i=e.peek();if(i?.type==="PERCENT"){e.consume(),n.emitOpcode(74);return}if(!i||i.type!=="CONVERTER_NAME"&&i.type!=="IDENT"&&i.type!=="FUNC"&&i.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("AS_CONVERTER_EXPECTED_NAME",`Expected a converter name after "as" (e.g. "as hex", "as decimal") but got ${i?`"${i.value}"`:"end of input"}`);e.consume();let a=i.value.toLowerCase();if(a==="base"){let l=e.peek(),u=l?.type==="NUMBER"?Number(l.value):NaN,c=Fs[u];if(c===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("AS_CONVERTER_UNSUPPORTED_BASE",`"as base ${l?.value??"?"}": only bases ${Object.keys(Fs).join(", ")} can be written out`);e.consume(),n.emitOpcode(c);return}let s=wc[a];if(s!==void 0){s===141&&e.match("OF")&&(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitOpcode(23)),n.emitOpcode(s);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(145);}};var Hs={ten:10,hundred:100,thousand:1e3,million:1e6,billion:1e9};function Gs(t,e,o){t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(23),zs(t,o),t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(22);}function zs(t,e){let o=e==="up"?kc:e==="down"?Bc:vc;t.emitOpcode(51),t.emitIndex(o),t.emitIndex(1);}var vc=8,kc=6,Bc=7,Mc=97;function Uc(t){let o=(t.peek()?.text??"").toLowerCase();return o==="up"?(t.consume(),"up"):o==="down"?(t.consume(),"down"):"nearest"}var hr=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){let i=Uc(e);if(e.match("TO_NEAREST")){Gs(n,Ks(e),i);return}zs(n,i);}},Sr=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){Gs(n,Ks(e),"nearest");}};function Ks(t){let e=t.peek(),o=(e?.text??"").toLowerCase(),r=Hs[o];if(r!==void 0)return t.consume(),r;if(e?.type==="NUMBER"){t.consume();let n=Number(e.value);if(Number.isFinite(n)&&n>0)return n}throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_ROUNDING_INCREMENT",`"to nearest ${e?.value??"?"}": expected a positive number or one of ${Object.keys(Hs).join(", ")}`)}var Lr=class{constructor(){this.category="Converters";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){let i=Number(r.value);if(!Number.isFinite(i)||i<0||i>100)throw chunkNAZ6PGLS_cjs.c.parsing("INVALID_DECIMAL_PLACES",`"to ${r.value} dp": expected a place count between 0 and 100`);n.emitOpcode(10),n.emitNumber(i),n.emitOpcode(51),n.emitIndex(Mc),n.emitIndex(2);}};var Dc=new Set(["dp","dps","decimals","digits","digit"]),bc=new Set(["decimal"]);function $s(t=66){return {name:"converters:decimal-places",priority:t,startTokenTypes:["TO"],match(e,o){if(e[o]?.type!=="TO")return null;let r=e[o+1];if(r?.type!=="NUMBER")return null;let n=e[o+2];if(!n)return null;let i=(n.text??n.value??"").toLowerCase(),a=3;if(bc.has(i)){let l=(e[o+3]?.text??"").toLowerCase();if(l!=="place"&&l!=="places")return null;a=4;}else if(!Dc.has(i))return null;return {consumed:a,replacement:[chunkLZSSAH5D_cjs.b("DECIMAL_PLACES",r.value,e.slice(o,o+a))],ruleName:"converters:decimal-places"}}}}var Vc=new Set(["hex","bin"]);function Ws(t=67){return {name:"converters:preposition",priority:t,startTokenTypes:["IN","TO"],match(e,o){let r=e[o];if(r?.type!=="IN"&&r?.type!=="TO")return null;let n=e[o+1];return n?.type==="CONVERTER_NAME"||n?.type==="FUNC"&&Vc.has(n.value.toLowerCase())?{consumed:1,replacement:[chunkLZSSAH5D_cjs.b("AS","as",[r])],ruleName:"converters:preposition"}:null}}}var hn={name:"solve-converters",phrases:{"to nearest":"TO_NEAREST","to the nearest":"TO_NEAREST"},infixParselets:{AS:new Cr,ROUNDED:new hr,TO_NEAREST:new Sr,DECIMAL_PLACES:new Lr},normalizerRules:[$s(),Ws()]};var H=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,r){let n=0;for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),n++;e.match("COMMA")||e.match("AND_CONJ");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),n++;r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(n);}};var wr=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,r){let n=0;do{if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),n++,!e.match("RATE_AT")&&!e.match("AT")){let i=e.peek();throw chunkNAZ6PGLS_cjs.c.parsing("WEIGHTED_AVERAGE_MISSING_WEIGHT",'weighted average: each value needs a weight, as in "72 at 30%"',{actualType:i?.type,actualValue:i?.value})}e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),n++,this.skipWeightLabel(e);}while(e.match("COMMA")||e.match("AND_CONJ"));r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(n);}skipWeightLabel(e){for(;;){let o=e.peek();if(!o)return;if(o.type==="STAR"||o.type==="IDENT"||o.type==="UNIT"){e.consume();continue}return}}};function Sn(t){return {category:"MathPhrases",parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(t),r.emitIndex(1);}}}var js={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),!t.match("DIVIDE_BY")&&!t.match("SLASH"))throw chunkNAZ6PGLS_cjs.c.parsing("REMAINDER_EXPECTED_DIVIDED_BY",'Expected "divided by" or "/", as in "remainder of 21 divided by 5"');t.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),o.emitOpcode(24);}},Xs={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkFVQWN5HZ_cjs.a.Product,o),!t.match("OF"))throw chunkNAZ6PGLS_cjs.c.parsing("ROOT_EXPECTED_OF",'Expected "of", as in "root 5 of 100"');t.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),o.emitOpcode(2),o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(2),o.emitOpcode(23),o.emitOpcode(25);}},Qs={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),Ys(o),!t.match("LOG_BASE"))throw chunkNAZ6PGLS_cjs.c.parsing("LOG_EXPECTED_BASE",'Expected "base", as in "log 20 base 4"');t.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,o),Ys(o),o.emitOpcode(23);}},Fc=5;function Ys(t){t.emitOpcode(51),t.emitIndex(Fc),t.emitIndex(1);}function qs(t=69){return {name:"mathphrases:function-phrase",priority:t,startTokenTypes:["FUNC"],match(e,o){let r=e[o];if(r?.type!=="FUNC")return null;let n=(r.value??"").toLowerCase();if(n!=="root"&&n!=="log"||e[o+1]?.type==="LPAREN")return null;if(n==="root")return {consumed:1,replacement:[chunkLZSSAH5D_cjs.b("NTH_ROOT","root",[r])],ruleName:"mathphrases:function-phrase"};let i=Hc(e,o+1);if(i===-1)return null;let a=e.slice(o,i+1).map((s,l)=>l===0?chunkLZSSAH5D_cjs.b("LOG_PHRASE","log",[s]):l===i-o?chunkLZSSAH5D_cjs.b("LOG_BASE","base",[s]):s);return {consumed:i-o+1,replacement:a,ruleName:"mathphrases:function-phrase"}}}}function Hc(t,e){for(let o=e;o<t.length&&o<e+8;o++){let r=t[o];if(r.type==="EOF"||r.type==="COMMA"||r.type==="RPAREN")return -1;if((r.text??r.value??"").toLowerCase()==="base")return o}return -1}function st(t){return {category:"MathPhrases",parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(t),r.emitIndex(2);}}}var Zs={category:"MathPhrases",parse(t,e,o){t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var Js={category:"MathPhrases",parse(t,e,o){t.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,o),t.consume("AND_CONJ"),t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),o.emitOpcode(20),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var em=er({category:"MathPhrases",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkFVQWN5HZ_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:t=>{t.emitOpcode(51),t.emitIndex(37),t.emitIndex(2);}}]});var Gc=47,vr=class{constructor(){this.category="MathPhrases";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);let n=e.peek();if(n?.type==="BETWEEN")e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);else if(n?.type==="FROM")e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("TO"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);else throw chunkNAZ6PGLS_cjs.c.parsing("CLAMP_EXPECTED_BETWEEN_OR_FROM",`Expected "between" or "from" after "clamp <value>" but got ${n?`"${n.value}"`:"end of input"}`);r.emitOpcode(51),r.emitIndex(Gc),r.emitIndex(3);}};var zc=46,kr=class{constructor(){this.category="MathPhrases";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),e.consume("AS"),e.parseExpression(this.bindingPower,n),e.consume("IS_TO");let i=e.consume();if(!i||i.value.toLowerCase()!=="what")throw chunkNAZ6PGLS_cjs.c.parsing("PROPORTION_EXPECTED_WHAT",`Expected "what" but got ${i?`"${i.value}"`:"end of input"}`);n.emitOpcode(51),n.emitIndex(zc),n.emitIndex(3);}};var Kc=42,$c=43,Wc=44,Yc=45,jc=9,Xc=10,Qc=101,qc=102,Zc=103,Jc=104,ep=105,tp=106,rp=107,op=38,np=39,ip=0,ap=21,Ln={name:"solve-mathphrases",phrases:{"average of":"AVERAGE_OF","median of":"MEDIAN_OF","total of":"TOTAL_OF","count of":"COUNT_OF","larger of":"LARGER_OF","greater of":"LARGER_OF","smaller of":"SMALLER_OF","lesser of":"SMALLER_OF","half of":"HALF_OF","midpoint between":"MIDPOINT_BETWEEN","random number":"RANDOM_NUMBER","is to":"IS_TO","remainder of":"REMAINDER_OF","gcd of":"GCD_OF","lcm of":"LCM_OF","square root of":"SQUARE_ROOT_OF","cube root of":"CUBE_ROOT_OF","standard deviation of":"STANDARD_DEVIATION_OF","stdev of":"STANDARD_DEVIATION_OF","sample standard deviation of":"SAMPLE_STANDARD_DEVIATION_OF","sample stdev of":"SAMPLE_STANDARD_DEVIATION_OF","variance of":"VARIANCE_OF","sample variance of":"SAMPLE_VARIANCE_OF","spread of":"SPREAD_OF","mode of":"MODE_OF","weighted average of":"WEIGHTED_AVERAGE_OF","weighted mean of":"WEIGHTED_AVERAGE_OF"},prefixParselets:{AVERAGE_OF:new H(Kc),MEDIAN_OF:new H($c),TOTAL_OF:new H(Wc),COUNT_OF:new H(Yc),LARGER_OF:st(Xc),SMALLER_OF:st(jc),HALF_OF:Zs,MIDPOINT_BETWEEN:Js,RANDOM_NUMBER:em,REMAINDER_OF:js,NTH_ROOT:Xs,LOG_PHRASE:Qs,GCD_OF:st(op),LCM_OF:st(np),SQUARE_ROOT_OF:Sn(ip),CUBE_ROOT_OF:Sn(ap),CLAMP:new vr,STANDARD_DEVIATION_OF:new H(Qc),SAMPLE_STANDARD_DEVIATION_OF:new H(qc),VARIANCE_OF:new H(Zc),SAMPLE_VARIANCE_OF:new H(Jc),SPREAD_OF:new H(ep),MODE_OF:new H(tp),WEIGHTED_AVERAGE_OF:new wr(rp)},infixParselets:{IS_TO:new kr},normalizerRules:[qs()]};var tm={annually:1,yearly:1,"semi-annually":2,quarterly:4,monthly:12,fortnightly:26,weekly:52,daily:365};function wn(t){if(!t.match("COMPOUNDING"))return 1;let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=tm[o];if(r===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("UNKNOWN_COMPOUNDING_INTERVAL",`compounding ${o||"?"}: expected one of ${Object.keys(tm).join(", ")}`);return t.consume(),r}var mt=class{constructor(e,o){this.annualIndex=e;this.intervalIndex=o;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n);let i=wn(e);if(n.emitOpcode(2),i===1){n.emitOpcode(51),n.emitIndex(this.annualIndex),n.emitIndex(3);return}n.emitOpcode(10),n.emitNumber(i),n.emitOpcode(51),n.emitIndex(this.intervalIndex),n.emitIndex(4);}},Br=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),r.emitOpcode(2),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);}},Mr=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.consume("RETURNED"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}},Ur=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.consume("INVESTED"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.consume("RETURNED"),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);}};function Dr(t,e,o){return om(t,o)?(t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),rm(t),t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),{swap:true}):(rm(t),t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),sp(t,o),t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,e),{swap:false})}function om(t,e){for(let o of e)if(t.match(o))return true;return false}function sp(t,e){om(t,e)||t.consume(e[0]);}function rm(t){t.match("RATE_AT")||t.consume("AT");}var lt=class{constructor(e,o){this.builtinIndex=e;this.intervalIndex=o;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r);let{swap:n}=Dr(e,r,["AFTER","FOR_DURATION","OVER"]),i=wn(e);if(n&&r.emitOpcode(2),i===1){r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);return}r.emitOpcode(10),r.emitNumber(i),r.emitOpcode(51),r.emitIndex(this.intervalIndex),r.emitIndex(4);}};var W=class{constructor(e,o){this.builtinIndex=e;this.periodsPerYear=o;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);let{swap:n}=Dr(e,r,["OVER"]);n&&r.emitOpcode(2),r.emitOpcode(10),r.emitNumber(this.periodsPerYear),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(4);}};var br=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("BETWEEN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.match("PEOPLE"),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(2);}},Vr=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),e.consume("WAYS"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};var nm={daily:{perYear:365,unit:"days"},weekly:{perYear:52,unit:"weeks"},monthly:{perYear:12,unit:"months"},yearly:{perYear:1,unit:"years"},annually:{perYear:1,unit:"years"}};function mp(t){let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=nm[o];if(r===void 0)throw chunkNAZ6PGLS_cjs.c.parsing("UNKNOWN_SAVINGS_PERIOD",`savings goal: expected a contribution period, one of ${Object.keys(nm).join(", ")}, not "${o||"?"}".`);return t.consume(),r}var Fr=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.match("STAR");let n=mp(e);r.emitOpcode(10),r.emitNumber(n.perYear),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r):(r.emitOpcode(10),r.emitNumber(0)),r.emitOpcode(13),r.emitString(n.unit),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(5);}},Hr=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.consume("IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r):(r.emitOpcode(10),r.emitNumber(0)),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);}};var Le=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("RATE_AT"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(2);}};var lp=60;function up(t){for(let e=0;;e++){let o=t.peekAt(e);if(!o)return false;if(o.type==="FROM"||o.type==="WORTH_IN")return true}}var ut=class{constructor(e){this.variant=e;this.category="Finance";}parse(e,o,r){if(!up(e)){e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);return}if(e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),this.variant==="what-was"){e.consume("WORTH_IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitPluginCall("inflationToYearFromPresent",2);return}let n=e.peek();if(n?.type==="FROM"){e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitPluginCall("inflationFromYearToPresent",2);return}if(n?.type==="IN"){e.consume(),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("WORTH_IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(lp),r.emitIndex(3);return}let i=n?n.type:"end of input";throw chunkNAZ6PGLS_cjs.c.parsing("INFLATION_EXPECTED_FROM_OR_IN",`Expected "from <year>" or "in <year> worth in <year>" after "what is <amount>", got ${i}`)}};var Gr=class{constructor(){this.category="Finance";}parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Product,r),e.consume("IN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("ASSUMING"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r);let n=e.peek();if((n&&n.type==="IDENT"?n.value.toLowerCase():void 0)!=="inflation"){let a=n?n.value:"end of input";throw chunkNAZ6PGLS_cjs.c.parsing("INFLATION_EXPECTED_INFLATION_WORD",`Expected the word "inflation" after "assuming <rate>%", got "${a}"`)}e.consume(),r.emitPluginCall("inflationFutureValue",3);}};var zr=class{constructor(){this.category="Finance";this.bindingPower=35;}parse(e,o,r,n){let i=Number(r.value);n.emitOpcode(10),n.emitNumber(i),n.emitPluginCall("inflationToYearFromPresent",2);}};function im(t,e){return chunk6U66HQKQ_cjs.P(t,`Year ${e} is outside the bundled CPI table's range (${chunkEEVUKZ5B_cjs.z}-${chunkEEVUKZ5B_cjs.A})`)}function am(t){let e=t[0],o=t[1].toNumber(),r=new Date().getFullYear(),n=chunkEEVUKZ5B_cjs.B(e.toNumber(),o,r);return n===void 0?im("INFLATION_YEAR_OUT_OF_RANGE",o):e.type===6?chunk6U66HQKQ_cjs.u(n,e.unit):chunk6U66HQKQ_cjs.n(n)}function sm(t){let e=t[0],o=new Date().getFullYear(),r=t[1].toNumber(),n=chunkEEVUKZ5B_cjs.B(e.toNumber(),o,r);return n===void 0?im("INFLATION_YEAR_OUT_OF_RANGE",r):e.type===6?chunk6U66HQKQ_cjs.u(n,e.unit):chunk6U66HQKQ_cjs.n(n)}function mm(t){let e=t[0],o=t[1].toNumber(),r=t[2].toNumber(),n=o-new Date().getFullYear();if(1+r<=0)return chunk6U66HQKQ_cjs.P("INVALID_RATE",`inflationFutureValue: rate ${r} makes (1 + rate) non-positive`);let a=e.toNumber()/Math.pow(1+r,n);return e.type===6?chunk6U66HQKQ_cjs.u(a,e.unit):chunk6U66HQKQ_cjs.n(a)}function lm(t=70){return {name:"finance:in-year-dollars",priority:t,startTokenTypes:["IN"],match(e,o){let r=e[o],n=e[o+1],i=e[o+2];if(r.type!=="IN"||n?.type!=="NUMBER"||i?.type!=="IDENT"&&i?.type!=="UNIT")return null;let a=i.value.toLowerCase();return a!=="dollars"&&a!=="dollar"?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("IN_YEAR_DOLLARS",n.value,e.slice(o,o+3))],ruleName:"finance:in-year-dollars"}}}}var cp={RECURRING_INTERVAL_NOT_POSITIVE:"RECURRING_INTERVAL_NOT_POSITIVE"},pp={daily:365,weekly:52,monthly:12,yearly:1,annually:1},fp={day:365,days:365,week:52,weeks:52,month:12,months:12,year:1,years:1},dp=new Set(["a","an"]),Ep=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]);function ct(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}function um(t){if(!(t===void 0||t.type!=="UNIT"))return fp[ct(t)]}function Tp(t,e){let o=t[e];if(o===void 0)return null;if(o.type==="IDENT"){let r=pp[ct(o)];if(r!==void 0)return {perYear:r,consumed:1};if(ct(o)==="every"){let n=t[e+1];if(n?.type!=="NUMBER")return null;let i=um(t[e+2]);if(i===void 0)return null;let a=Number((n.value??"").replace(/,/g,""));if(!(a>0))throw chunkNAZ6PGLS_cjs.c.parsing({code:cp.RECURRING_INTERVAL_NOT_POSITIVE,message:`A recurring interval must be a positive number, not "${n.value}".`,expected:"a positive interval, e.g. every 2 weeks",found:`every ${n.value} ${ct(t[e+2])}`});return {perYear:i/a,consumed:3}}}return null}function Np(t,e){let o=t[e];if(o===void 0)return null;let r,n;if(o.type==="NUMBER")r=Number((o.value??"").replace(/,/g,"")),n=e+1;else if(o.type==="IDENT"&&dp.has(ct(o)))r=1,n=e+1;else return null;let i=um(t[n]);return i===void 0||!Number.isFinite(r)||r<0?null:{years:r/i,consumed:n-e+1}}function yp(t,e){let o=t*e,r=Math.round(o);return Math.abs(o-r)<1e-9?r:Math.floor(o)}function cm(t=78){return {name:"finance:recurring-schedule",priority:t,match(e,o){let r=e[o];if(r===void 0||!Ep.has(r.type))return null;let n=Tp(e,o+1);if(n===null)return null;let i=o+1+n.consumed;if(e[i]?.type!=="FOR_DURATION")return null;let a=Np(e,i+1);if(a===null)return null;let s=yp(n.perYear,a.years),l=i+1+a.consumed-o,u=e.slice(o,o+l);return {replacement:[r,chunkLZSSAH5D_cjs.b("STAR","*",u),chunkLZSSAH5D_cjs.b("NUMBER",String(s),u)],consumed:l,ruleName:"finance:recurring-schedule"}}}}function Kr(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var pm=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]),fm=new Set(["NUMBER","FLOAT"]);function dm(t=77){return {name:"finance:bill-split",priority:t,match(e,o){let r=e[o];if(r===void 0)return null;if(pm.has(r.type)){let f=e[o+1],T=e[o+2],N=e[o+3];if(f?.type==="IDENT"&&Kr(f)==="split"&&T!==void 0&&fm.has(T.type)&&N?.type==="IDENT"&&Kr(N)==="ways")return {consumed:4,replacement:[r,chunkLZSSAH5D_cjs.b("SPLIT_WAYS","split",[f]),T,chunkLZSSAH5D_cjs.b("WAYS","ways",[N])],ruleName:"finance:bill-split"}}if(r.type!=="IDENT"||Kr(r)!=="split")return null;let n=e[o-1];if(n!==void 0&&pm.has(n.type))return null;let i=-1;for(let f=o+1;f<e.length;f++)if(e[f].type==="BETWEEN"){i=f;break}if(i===-1)return null;let a=e[i+1];if(a===void 0||!fm.has(a.type))return null;let s=i+2,l=e[s]?.type==="IDENT"&&Kr(e[s])==="people",u=l?s:i+1,c=[chunkLZSSAH5D_cjs.b("SPLIT","split",[r]),...e.slice(o+1,i+2)];return l&&c.push(chunkLZSSAH5D_cjs.b("PEOPLE","people",[e[s]])),{consumed:u-o+1,replacement:c,ruleName:"finance:bill-split"}}}}var vn=51,gp=52,$r=55,Wr=56,kn=80,Pp=81,_p=82,Ap=83,xp=84,Op=59,Rp=85,Ip=86,Em=98,Cp=99,hp=100,Bn={name:"solve-finance",phrases:{"compound interest on":"COMPOUND_INTEREST_ON","interest on":"INTEREST_ON","daily repayment on":"DAILY_REPAYMENT_ON","monthly repayment on":"MONTHLY_REPAYMENT_ON","annual repayment on":"ANNUAL_REPAYMENT_ON","total repayment on":"TOTAL_REPAYMENT_ON","daily interest on":"DAILY_LOAN_INTEREST_ON","monthly interest on":"MONTHLY_LOAN_INTEREST_ON","annual interest on":"ANNUAL_LOAN_INTEREST_ON","total interest on":"TOTAL_LOAN_INTEREST_ON","tax on":"TAX_ON","tax off":"TAX_OFF","tax in":"TAX_IN_PHRASE","tax of":"TAX_IN_PHRASE","tax from":"TAX_IN_PHRASE","vat in":"TAX_IN_PHRASE","vat of":"TAX_IN_PHRASE","vat from":"TAX_IN_PHRASE","vat on":"TAX_ON","vat off":"TAX_OFF","what is":"WHAT_IS","what was":"WHAT_WAS","present value of":"PRESENT_VALUE_OF","annual return on":"ANNUAL_RETURN_ON","value of":"VALUE_OF","worth in":"WORTH_IN","how long to save":"SAVINGS_HOW_LONG","how much per month to save":"SAVINGS_HOW_MUCH","how much per month to reach":"SAVINGS_HOW_MUCH",assuming:"ASSUMING"},prefixParselets:{PRESENT_VALUE_OF:new Br(_p),ANNUAL_RETURN_ON:new Ur(xp),COMPOUND_INTEREST_ON:new lt(vn,kn),INTEREST_ON:new lt(gp,Pp),DAILY_REPAYMENT_ON:new W($r,365),MONTHLY_REPAYMENT_ON:new W($r,12),ANNUAL_REPAYMENT_ON:new W($r,1),TOTAL_REPAYMENT_ON:new W($r,0),DAILY_LOAN_INTEREST_ON:new W(Wr,365),MONTHLY_LOAN_INTEREST_ON:new W(Wr,12),ANNUAL_LOAN_INTEREST_ON:new W(Wr,1),TOTAL_LOAN_INTEREST_ON:new W(Wr,0),TAX_ON:new Le(Ip),TAX_OFF:new Le(Op),TAX_IN_PHRASE:new Le(Rp),SPLIT:new br(Em),WHAT_IS:new ut("what-is"),WHAT_WAS:new ut("what-was"),VALUE_OF:new Gr,SAVINGS_HOW_LONG:new Fr(hp),SAVINGS_HOW_MUCH:new Hr(Cp)},infixParselets:{AFTER:new mt(vn,kn),FOR_DURATION:new mt(vn,kn),INVESTED:new Mr(Ap),IN_YEAR_DOLLARS:new zr,SPLIT_WAYS:new Vr(Em)},normalizerRules:[lm(),cm(),dm()],pluginFunctions:{inflationFromYearToPresent:am,inflationToYearFromPresent:sm,inflationFutureValue:mm}};function Sp(t){return (e,o)=>chunk6U66HQKQ_cjs.P(`${t.toUpperCase()}_QUERY_FAILED`,`Failed to resolve "${e}": ${o instanceof Error?o.message:String(o)}`)}function de(t){let e=t.staleTimeMs??3e5,o=t.timeoutMs??1e4,r=t.failureCooldownMs??3e4,n=t.onError??Sp(t.namespace),i=u=>[t.namespace,u];async function a(u,c,f){let{signal:T,cleanup:N}=chunkTLG7VZRX_cjs.a(c,o,`${t.namespace} query`);try{return await t.fetchQuery(u,T)}catch(E){let _=n(u,E);return setTimeout(()=>{f.getQueryData(i(u))===_&&f.removeQueries({queryKey:i(u),exact:true});},r).unref?.(),_}finally{N();}}return {resolver:{namespace:t.namespace,preflight(u,c,f,T,N){let{opcodes:E,strings:_}=c,O=E.length,R=0;for(;R<O;){if(E[R]===50&&R+2<O){let P=E[R+1],C=E[R+2];if(P===t.pluginFunctionIndex&&C>=1&&R>=2&&E[R-2]===13){let S=_[E[R-1]],j=i(S);if(N.getQueryData(j)===void 0){let Ge=N.fetchQuery({queryKey:j,queryFn:({signal:Do})=>a(S,Do,N),staleTime:e}),me={queryKey:j.join(":"),resolver:Ge,packageId:f,signal:T,metadata:{query:S}};return t.refetchIntervalMs!==void 0&&(me.refetchIntervalMs=t.refetchIntervalMs,me.refetch=()=>N.fetchQuery({queryKey:j,queryFn:({signal:Do})=>a(S,Do,N),staleTime:0})),me}}R+=3;continue}R=chunkW5ELYJ4Z_cjs.a(E,R);}return null},destroy(){}},pluginFunction:u=>{let c=u[0]?.value,f=chunkZLRJ7TDP_cjs.b()?.getQueryData(i(c));return f!==void 0?f:chunk6U66HQKQ_cjs.P(`${t.namespace.toUpperCase()}_NOT_PREFLIGHTED`,`No cached result for "${c}"`)}}}function Lp(t,e){let o=[];for(;t.peek()?.type==="IDENT";)o.push(t.consume().value);if(o.length===0)throw chunkNAZ6PGLS_cjs.c.parsing("WEATHER_EXPECTED_CITY",`Expected a city name after "${e}" (e.g. "${e} London")`);return o.join(" ")}function we(t,e){return {category:"Weather",parse(o,r,n){let i=Lp(o,r.value);n.emitOpcode(13),n.emitString(`${t}:${i}`),n.emitPluginCall(e,1);}}}var wp={0:"clear sky",1:"mainly clear",2:"partly cloudy",3:"overcast",45:"fog",48:"depositing rime fog",51:"light drizzle",53:"moderate drizzle",55:"dense drizzle",56:"light freezing drizzle",57:"dense freezing drizzle",61:"slight rain",63:"moderate rain",65:"heavy rain",66:"light freezing rain",67:"heavy freezing rain",71:"slight snow fall",73:"moderate snow fall",75:"heavy snow fall",77:"snow grains",80:"slight rain showers",81:"moderate rain showers",82:"violent rain showers",85:"slight snow showers",86:"heavy snow showers",95:"thunderstorm",96:"thunderstorm with slight hail",99:"thunderstorm with heavy hail"};function Tm(t){return wp[t]??`weather code ${t}`}var ve={GEOCODING_API_ERROR:"WEATHER_GEOCODING_API_ERROR",CITY_NOT_FOUND:"WEATHER_CITY_NOT_FOUND",FORECAST_API_ERROR:"WEATHER_FORECAST_API_ERROR",FORECAST_RESPONSE_MALFORMED:"WEATHER_FORECAST_RESPONSE_MALFORMED",UNKNOWN_QUERY_KIND:"WEATHER_UNKNOWN_QUERY_KIND"},vp="https://geocoding-api.open-meteo.com/v1/search",kp="https://api.open-meteo.com/v1/forecast",Bp=1e4;async function Mp(t,e){let o=`${vp}?name=${encodeURIComponent(t)}&count=1&language=en&format=json`,r=await fetch(o,{signal:e});if(!r.ok)throw chunkNAZ6PGLS_cjs.c.external(ve.GEOCODING_API_ERROR,`Open-Meteo geocoding API returned ${r.status} for "${t}"`,{city:t,status:r.status});let i=(await r.json())?.results?.[0];if(!i)throw chunkNAZ6PGLS_cjs.c.validation(ve.CITY_NOT_FOUND,`No location found for "${t}"`,{city:t});return {latitude:i.latitude,longitude:i.longitude,name:i.name}}async function Up(t,e,o){let r=new URLSearchParams({latitude:String(t),longitude:String(e),current:"temperature_2m,apparent_temperature,weather_code",daily:"temperature_2m_max,temperature_2m_min",timezone:"auto",forecast_days:"1"}),n=await fetch(`${kp}?${r.toString()}`,{signal:o});if(!n.ok)throw chunkNAZ6PGLS_cjs.c.external(ve.FORECAST_API_ERROR,`Open-Meteo forecast API returned ${n.status}`,{status:n.status});let i=await n.json(),a=i?.current,s=i?.daily;if(!a||!s)throw chunkNAZ6PGLS_cjs.c.external(ve.FORECAST_RESPONSE_MALFORMED,"Open-Meteo forecast response missing current/daily blocks");return {weatherCode:a.weather_code,temperature:a.temperature_2m,apparentTemperature:a.apparent_temperature,high:s.temperature_2m_max?.[0],low:s.temperature_2m_min?.[0]}}var Yr=new Map,Dp=6e4;function Nm(t,e){let o=t.trim().toLowerCase(),r=Date.now(),n=Yr.get(o);if(n&&n.expiresAt>r)return n.promise;let{signal:i,cleanup:a}=chunkTLG7VZRX_cjs.a(e,Bp,"Open-Meteo weather query"),s=(async()=>{try{let l=await Mp(t,i),u=await Up(l.latitude,l.longitude,i);return {resolvedName:l.name,weatherCode:u.weatherCode,description:Tm(u.weatherCode),temperature:u.temperature,apparentTemperature:u.apparentTemperature,high:u.high,low:u.low}}finally{a();}})();return Yr.set(o,{promise:s,expiresAt:r+Dp}),s.catch(()=>{Yr.get(o)?.promise===s&&Yr.delete(o);}),s}var ym="solve-weather",Ee="weather",bp=chunkEEVUKZ5B_cjs.F(`${ym}:${Ee}`),{resolver:Vp,pluginFunction:Fp}=de({namespace:"weather",pluginFunctionIndex:bp,staleTimeMs:600*1e3,fetchQuery:async(t,e)=>{let o=t.indexOf(":"),r=o===-1?t:t.slice(0,o),n=o===-1?"":t.slice(o+1),i=await Nm(n,e);switch(r){case "current":return chunk6U66HQKQ_cjs.t(`${Math.round(i.temperature)}\xB0C, ${i.description}`);case "temperature":return chunk6U66HQKQ_cjs.u(i.temperature,"C");case "feelslike":return chunk6U66HQKQ_cjs.u(i.apparentTemperature,"C");case "high":return chunk6U66HQKQ_cjs.u(i.high,"C");case "low":return chunk6U66HQKQ_cjs.u(i.low,"C");default:throw chunkNAZ6PGLS_cjs.c.internal(ve.UNKNOWN_QUERY_KIND,`Unknown weather query kind "${r}"`,{kind:r})}}}),Mn={name:ym,phrases:{"weather in":"WEATHER_IN","temperature in":"TEMPERATURE_IN","feels like in":"FEELS_LIKE_IN","high in":"HIGH_IN","low in":"LOW_IN"},prefixParselets:{WEATHER_IN:we("current",Ee),TEMPERATURE_IN:we("temperature",Ee),FEELS_LIKE_IN:we("feelslike",Ee),HIGH_IN:we("high",Ee),LOW_IN:we("low",Ee)},pluginFunctions:{[Ee]:Fp},asyncResolvers:[Vp]};var jr={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,sept:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11};function Qr(t){return t<10?`0${t}`:String(t)}function pt(t,e,o,r){let n=new Date(t,e,o);if(n.getFullYear()!==t||n.getMonth()!==e||n.getDate()!==o)throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`"${r}" is not a valid calendar date`);return {isoDate:`${t}-${Qr(e+1)}-${Qr(o)}`,raw:r}}function Xr(t,e){if(!/^\d{4}$/.test(t))throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`Expected a 4-digit year in "${e}", got "${t}"`);return parseInt(t,10)}function gm(t){let e=t.peek();if(!e)return null;if(e.type==="DATETIME_LITERAL"){t.consume();let o=new Date(Number(e.value));return Number.isNaN(o.getTime())?null:{isoDate:`${o.getFullYear()}-${Qr(o.getMonth()+1)}-${Qr(o.getDate())}`,raw:e.text??e.value}}if(e.type==="NUMBER"){let o=t.consume(),r=t.peek();if(r&&(r.type==="SLASH"||r.type==="MINUS")){let i=r.type;t.consume();let a=t.consume("NUMBER");t.consume(i);let s=t.consume("NUMBER"),l=`${o.value}${i==="SLASH"?"/":"-"}${a.value}${i==="SLASH"?"/":"-"}${s.value}`;if(i==="SLASH"){let u=parseInt(o.value,10),c=parseInt(a.value,10),f=Xr(s.value,l);return pt(f,u-1,c,l)}else {if(/^\d{4}$/.test(o.value)){let T=parseInt(o.value,10),N=parseInt(a.value,10),E=parseInt(s.value,10);return pt(T,N-1,E,l)}let u=parseInt(o.value,10),c=parseInt(a.value,10),f=Xr(s.value,l);return pt(f,u-1,c,l)}}let n=t.peek();if(n&&n.type==="IDENT"&&jr[n.value.toLowerCase()]!==void 0){let i=jr[n.value.toLowerCase()];t.consume(),t.peek()?.type==="COMMA"&&t.consume();let a=t.consume("NUMBER"),s=`${o.value} ${n.value} ${a.value}`,l=Xr(a.value,s);return pt(l,i,parseInt(o.value,10),s)}throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_DATE",`Expected a date after "on" (e.g. "April 12, 2005" or "4/12/2005"), got "${o.value}"`)}if(e.type==="IDENT"&&jr[e.value.toLowerCase()]!==void 0){let o=jr[e.value.toLowerCase()];t.consume();let r=t.consume("NUMBER");t.peek()?.type==="COMMA"&&t.consume();let n=t.consume("NUMBER"),i=`${e.value} ${r.value}, ${n.value}`,a=Xr(n.value,i);return pt(a,o,parseInt(r.value,10),i)}return null}var Pm=new Set(["AAPL","MSFT","GOOGL","GOOG","AMZN","META","NVDA","TSLA","NFLX","ADBE","CRM","ORCL","IBM","INTC","AMD","CSCO","PYPL","UBER","ABNB","SPOT","SHOP","SQ","COIN","PLTR","SNOW","ZM","JPM","V","MA","BAC","WFC","GS","MS","AXP","WMT","COST","HD","NKE","SBUX","MCD","KO","PEP","DIS","TGT","BA","GE","F","GM","XOM","CVX","PFE","JNJ","UNH","MRNA","TSM","ASML","BABA"]);var ke="STOCK_TICKER",Hp=chunk5IJD5L3O_cjs.c(ke);function _m(){return {name:"stocks:bare-ticker",priority:20,startTokenTypes:["IDENT"],match(t,e){let o=t[e];return !o||o.type!=="IDENT"||!Pm.has(o.value)||e>0&&t[e-1].type==="COLON"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(ke,Hp,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"stocks:bare-ticker"}}}}function Gp(t){let e=t.peek();if(!e||e.type!=="IDENT")return null;let o=e.value.toLowerCase(),r="close";if(o==="close"||o==="volume"){r=o,t.consume();let i=t.peek();if(!i||i.type!=="IDENT"||i.value.toLowerCase()!=="on")throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_EXPECTED_ON",`Expected "on <date>" after "${o}" (e.g. "AAPL ${o} on April 12, 2005")`);t.consume();}else if(o==="on")t.consume();else return null;let n=gm(t);if(!n)throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_EXPECTED_DATE",'Expected a date after "on" (e.g. "April 12, 2005" or "4/12/2005")');return {field:r,date:n}}function Am(t,e,o,r,n){t.emitOpcode(13),o?(t.emitString(`${o.field}:${e}:${o.date.isoDate}`),t.emitPluginCall(n,1)):(t.emitString(e),t.emitPluginCall(r,1));}function xm(t,e,o,r,n){let i=false;t.peek()?.type==="STAR"&&(t.consume(),i=true);let a=Gp(t);if(i&&!a){Am(e,o,null,r,n),t.parseExpression(chunkFVQWN5HZ_cjs.a.Product,e),e.emitOpcode(22);return}Am(e,o,a,r,n);}function Om(t,e){return {category:"Stocks",parse(o,r,n){o.consume("LPAREN");let i=o.consume(),a;if(i.type==="STRING")a=chunkUURM7P3P_cjs.a(i.value).toUpperCase();else if(i.type==="IDENT"||i.type===ke)a=i.value.toUpperCase();else throw chunkNAZ6PGLS_cjs.c.parsing("STOCKS_INVALID_TICKER",`Expected a ticker symbol inside stock(...), got "${i.value}" (${i.type})`);o.consume("RPAREN"),xm(o,n,a,t,e);}}}function Rm(t,e){return {category:"Stocks",parse(o,r,n){let i=r.value.toUpperCase();xm(o,n,i,t,e);}}}var Un="solve-stocks",qr="stock",Zr="stockhistorical";function Im(t={}){function e(s){return chunk6U66HQKQ_cjs.P("STOCKS_NOT_CONFIGURED",`Stock data provider not configured. Supply ${s} via createStocksPackage({ ... }); see the StocksPackage doc comment.`)}let{resolver:o,pluginFunction:r}=de({namespace:"stocks-current",pluginFunctionIndex:chunkEEVUKZ5B_cjs.F(`${Un}:${qr}`),staleTimeMs:t.staleTimeMs??6e4,refetchIntervalMs:t.refetchIntervalMs,fetchQuery:async(s,l)=>{if(!t.fetchQuote)return e("fetchQuote");let u=await t.fetchQuote(s,l);return chunk6U66HQKQ_cjs.u(u.price,u.currency??"USD")}}),{resolver:n,pluginFunction:i}=de({namespace:"stocks-historical",pluginFunctionIndex:chunkEEVUKZ5B_cjs.F(`${Un}:${Zr}`),staleTimeMs:t.historicalStaleTimeMs??720*60*60*1e3,fetchQuery:async(s,l)=>{let[u,c,f]=s.split(":");if(!t.fetchHistoricalQuote)return e("fetchHistoricalQuote");let T=await t.fetchHistoricalQuote(c,f,l);return u==="volume"?chunk6U66HQKQ_cjs.n(T.volume??0):chunk6U66HQKQ_cjs.u(T.close,T.currency??"USD")}});return {name:Un,lexerVocabulary:{keywords:{stock:"STOCK_FN"}},prefixParselets:{STOCK_FN:Om(qr,Zr),...t.enableBareTickerRecognition?{[ke]:Rm(qr,Zr)}:{}},normalizerRules:t.enableBareTickerRecognition?[_m()]:[],pluginFunctions:{[qr]:r,[Zr]:i},asyncResolvers:[o,n]}}function Cm(t){return {category:"Knowledge",parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall(t,1);}}}function hm(t={}){let e="solve-knowledge",o="knowledge",r=chunkEEVUKZ5B_cjs.F(`${e}:${o}`),{resolver:n,pluginFunction:i}=de({namespace:"knowledge",pluginFunctionIndex:r,staleTimeMs:t.staleTimeMs??300*1e3,fetchQuery:async(a,s)=>{if(!t.answerQuery)return chunk6U66HQKQ_cjs.P("KNOWLEDGE_NOT_CONFIGURED","Knowledge answer provider not configured. Supply answerQuery via createKnowledgePackage({ ... }); see the KnowledgePackage doc comment.");let l=await t.answerQuery(a,s);return chunk6U66HQKQ_cjs.t(l)}});return {name:e,lexerVocabulary:{rawLinePatterns:[{pattern:/^(?:search|ask|google)\s*:\s*(.+)$/i,tokenType:"KNOWLEDGE_QUERY"},{pattern:/^(.+?)=\s*\?\s*$/,tokenType:"KNOWLEDGE_QUERY"}]},prefixParselets:{KNOWLEDGE_QUERY:Cm(o)},pluginFunctions:{[o]:i},asyncResolvers:[n]}}var Jr=class{constructor(){this.category="Lines";}parse(e,o,r){r.emitPluginCall("prev",0);}};var eo=class{constructor(){this.category="Lines";}parse(e,o,r){let n=parseInt(o.value,10);r.emitOpcode(10),r.emitNumber(n),r.emitPluginCall("lineRef",1);}};var ft=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,r){e.consume("LPAREN");let n=e.consume("LINE_REF");e.consume("COLON");let i=e.consume("LINE_REF");e.consume("RPAREN");let a=parseInt(n.value,10),s=parseInt(i.value,10);r.emitOpcode(10),r.emitNumber(a),r.emitOpcode(10),r.emitNumber(s),r.emitPluginCall(this.isAverage?"averageRange":"sumRange",2);}};var Be=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,r){r.emitPluginCall(this.isAverage?"averageAbove":"totalAbove",0);}};var zp=chunk5IJD5L3O_cjs.c("LINE_REF"),Kp=chunk5IJD5L3O_cjs.c("SUM_RANGE_CALL"),$p=chunk5IJD5L3O_cjs.c("AVERAGE_RANGE_CALL");function Lm(){return {name:"lines:line-ref",priority:80,startTokenTypes:["IDENT"],match(t,e){if(e>0&&t[e-1].type==="COLON"&&!(e>1&&t[e-2].type==="LINE_REF"))return null;let o=t[e];if(!o)return null;if(o.type==="IDENT"){let r=/^line(\d+)$/i.exec(o.value);if(r)return {consumed:1,replacement:[Sm(r[1],o)],ruleName:"lines:line-ref"}}if(o.type==="IDENT"&&/^line$/i.test(o.value)){let r=t[e+1];if(r&&r.type==="NUMBER"&&/^\d+$/.test(r.value))return {consumed:2,replacement:[Sm(r.value,o)],ruleName:"lines:line-ref"}}return null}}}function Sm(t,e){return new chunkFAGFPVYK_cjs.a("LINE_REF",zp,t,t,e.offset,0,e.line,e.col)}function wm(){return {name:"lines:range-call",priority:80,startTokenTypes:["IDENT"],match(t,e){let o=t[e];if(!o||o.type!=="IDENT")return null;let r=o.value.toLowerCase();if(r!=="sum"&&r!=="total"&&r!=="average"||t[e+1]?.type!=="LPAREN")return null;let n=r==="average"?"AVERAGE_RANGE_CALL":"SUM_RANGE_CALL",i=r==="average"?$p:Kp;return {consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(n,i,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"lines:range-call"}}}}function to(t,e){return t===void 0?chunk6U66HQKQ_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet (forward reference, or out of range)`):t.type===12?chunk6U66HQKQ_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):t.type===13?chunk6U66HQKQ_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function Me(t){return t?.getLineResult?null:chunk6U66HQKQ_cjs.P("LINE_REF_NO_DOCUMENT","Cross-line references require a real document \u2014 not available outside one (e.g. evaluateExpression()'s single-expression path)")}function vm(t,e){let o=Me(e);if(o)return o;let r=e.lineIndex-1,n=e.getLineResult(r);return to(n,r)??n}function km(t,e){let o=Me(e);if(o)return o;let r=t[0].toNumber(),n=e.getLineResult(r);return to(n,r)??n}function Bm(t,e,o,r){let n=0,i=0,a,s=false,l=t<=e?1:-1;for(let c=t;l>0?c<=e:c>=e;c+=l){let f=o.getLineResult(c),T=to(f,c);if(T)return T;if(f.type!==0&&f.type!==6)return chunk6U66HQKQ_cjs.P("LINE_RANGE_NON_NUMERIC",`Line ${c} is not a plain number or unit value \u2014 cannot include it in a sum/total/average range`);if(f.type===6){if(s=true,a===void 0)a=f.unit;else if(f.unit!==a)return chunk6U66HQKQ_cjs.P("LINE_RANGE_MIXED_UNITS",`Line ${c}'s unit (${f.unit}) doesn't match the range's first unit (${a}) \u2014 aggregating mixed units would silently misrepresent the result`)}n+=f.toNumber(),i++;}let u=r?n/i:n;return s?chunk6U66HQKQ_cjs.u(u,a):chunk6U66HQKQ_cjs.n(u)}function Mm(t,e){let o=Me(e);return o||Bm(t[0].toNumber(),t[1].toNumber(),e,false)}function Um(t,e){let o=Me(e);return o||Bm(t[0].toNumber(),t[1].toNumber(),e,true)}function Dm(t,e){let o=t.isLineBoundary;if(!o)return chunk6U66HQKQ_cjs.P("LINE_REF_NO_DOCUMENT",'"above" aggregation requires a real document');let r=0,n=0,i,a=false;for(let l=t.lineIndex-1;l>=1&&!o(l);l--){let u=t.getLineResult(l),c=to(u,l);if(c)return c;if(u.type!==0&&u.type!==6)return chunk6U66HQKQ_cjs.P("LINE_RANGE_NON_NUMERIC",`Line ${l} is not a plain number or unit value \u2014 cannot include it in "above" aggregation`);if(u.type===6){if(a=true,i===void 0)i=u.unit;else if(u.unit!==i)return chunk6U66HQKQ_cjs.P("LINE_RANGE_MIXED_UNITS",`Line ${l}'s unit (${u.unit}) doesn't match the range's unit (${i})`)}r+=u.toNumber(),n++;}if(n===0)return chunk6U66HQKQ_cjs.P("LINE_RANGE_EMPTY","No lines above to aggregate (hit the top of the document, a blank line, or a heading immediately)");let s=e?r/n:r;return a?chunk6U66HQKQ_cjs.u(s,i):chunk6U66HQKQ_cjs.n(s)}function bm(t,e){let o=Me(e);return o||Dm(e,false)}function Vm(t,e){let o=Me(e);return o||Dm(e,true)}var Dn={name:"solve-lines",lexerVocabulary:{keywords:{prev:"PREV"}},phrases:{"total above":"TOTAL_ABOVE","sum above":"SUM_ABOVE","average above":"AVERAGE_ABOVE"},normalizerRules:[Lm(),wm()],prefixParselets:{PREV:new Jr,LINE_REF:new eo,SUM_RANGE_CALL:new ft(false),AVERAGE_RANGE_CALL:new ft(true),TOTAL_ABOVE:new Be(false),SUM_ABOVE:new Be(false),AVERAGE_ABOVE:new Be(true)},pluginFunctions:{prev:vm,lineRef:km,sumRange:Mm,averageRange:Um,totalAbove:bm,averageAbove:Vm}};var b=class{constructor(e){this.pluginFnName=e;this.category="Tables";}parse(e,o,r){let n=e.peek();if(!n||n.type!=="STRING")throw chunkNAZ6PGLS_cjs.c.parsing("TABLE_COLUMN_NAME_EXPECTED",`Expected a quoted column name after "... of column" but got ${n?`"${n.value}"`:"end of input"}`);let i=e.consume("STRING");for(;;){let a=e.peek();if(!a)break;if(a.type==="IN"){e.consume();continue}if(a.type==="IDENT"&&Wp.has(a.value.toLowerCase())){e.consume();continue}break}r.emitOpcode(13),r.emitString(i.value),r.emitPluginCall(this.pluginFnName,1);}},Wp=new Set(["the","table","above"]);function Fm(t){return t.trimStart().startsWith("|")}function Yp(t){let e=t.trim();return e.length===0||!e.includes("-")||!e.includes("|")?false:/^[|\s:-]+$/.test(e)}function Hm(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&!e.endsWith("\\|")&&(e=e.slice(0,-1));let o=[],r="";for(let n=0;n<e.length;n++){let i=e[n];if(i==="\\"&&n+1<e.length&&e[n+1]==="|"){r+="|",n++;continue}if(i==="|"){o.push(r.trim()),r="";continue}r+=i;}return o.push(r.trim()),o}function jp(t){if(t===void 0)return null;let e=t.trim();if(e.length===0)return null;let o=e.replace(/,/g,"");if(!/^[+-]?(\d+(\.\d+)?|\.\d+)$/.test(o))return null;let r=Number.parseFloat(o);return Number.isFinite(r)?r:null}function Gm(t,e){let o=-1;for(let s=e-1;s>=1;s--){let l=t(s);if(l===void 0)break;if(Fm(l)){o=s;break}}if(o===-1)return null;let r=o;for(;r-1>=1;){let s=t(r-1);if(s===void 0||!Fm(s))break;r--;}let n=-1;for(let s=r;s<=o;s++)if(Yp(t(s))){n=s;break}if(n===-1||n===r)return null;let i=Hm(t(n-1)),a=[];for(let s=n+1;s<=o;s++)a.push(Hm(t(s)));return {header:i,rows:a}}function zm(t,e){let o=e.trim().toLowerCase();for(let r=0;r<t.length;r++)if(t[r].trim().toLowerCase()===o)return r;return -1}function Km(t,e){let o=[];for(let r of t.rows){let n=jp(r[e]);n!==null&&o.push(n);}return o}var ro={TABLE_NO_DOCUMENT:"TABLE_NO_DOCUMENT",TABLE_NOT_FOUND:"TABLE_NOT_FOUND",TABLE_COLUMN_NOT_FOUND:"TABLE_COLUMN_NOT_FOUND",TABLE_COLUMN_NO_NUMERIC_CELLS:"TABLE_COLUMN_NO_NUMERIC_CELLS"};function oo(t,e){let o=t.length;if(o===0)return 0;let r=e?o-1:o;if(r<=0)return 0;let n=t.reduce((i,a)=>i+a,0)/o;return t.reduce((i,a)=>i+(a-n)*(a-n),0)/r}function Xp(t,e){switch(t){case "sum":return e.reduce((o,r)=>o+r,0);case "average":return e.reduce((o,r)=>o+r,0)/e.length;case "min":return Math.min(...e);case "max":return Math.max(...e);case "count":return e.length;case "median":{let o=[...e].sort((n,i)=>n-i),r=Math.floor(o.length/2);return o.length%2===0?(o[r-1]+o[r])/2:o[r]}case "stdev":return Math.sqrt(oo(e,false));case "sampleStdev":return Math.sqrt(oo(e,true));case "variance":return oo(e,false);case "sampleVariance":return oo(e,true);case "spread":return Math.max(...e)-Math.min(...e);case "mode":{let o=new Map,r=e[0],n=0;for(let i of e){let a=(o.get(i)??0)+1;o.set(i,a),a>n&&(n=a,r=i);}return r}}}function z(t,e,o){let r=o?.getLineText;if(!r||o.lineIndex<1)return chunk6U66HQKQ_cjs.P(ro.TABLE_NO_DOCUMENT,"Reading a table column needs a real document, which the single-expression path (evaluateExpression) does not have");let n=Gm(r,o.lineIndex);if(!n)return chunk6U66HQKQ_cjs.P(ro.TABLE_NOT_FOUND,'No markdown table found above this line (a table row starts with "|", and needs a "|---|" separator under its header)');let i=zm(n.header,e);if(i===-1){let s=n.header.map(l=>`"${l}"`).join(", ");return chunk6U66HQKQ_cjs.P(ro.TABLE_COLUMN_NOT_FOUND,`The table above has no column named "${e}". Its columns are: ${s}`)}let a=Km(n,i);return t==="count"?chunk6U66HQKQ_cjs.n(a.length):a.length===0?chunk6U66HQKQ_cjs.P(ro.TABLE_COLUMN_NO_NUMERIC_CELLS,`Column "${e}" has no plain-number cells to aggregate (currency and unit cells are not read yet)`):chunk6U66HQKQ_cjs.n(Xp(t,a))}function K(t){let e=t[0];return e&&e.type===3&&typeof e.value=="string"?e.value:String(e?.value??"")}function $m(t,e){return z("sum",K(t),e)}function Wm(t,e){return z("average",K(t),e)}function Ym(t,e){return z("min",K(t),e)}function jm(t,e){return z("max",K(t),e)}function Xm(t,e){return z("count",K(t),e)}function Qm(t,e){return z("median",K(t),e)}function qm(t,e){return z("stdev",K(t),e)}function Zm(t,e){return z("sampleStdev",K(t),e)}function Jm(t,e){return z("variance",K(t),e)}function el(t,e){return z("sampleVariance",K(t),e)}function tl(t,e){return z("spread",K(t),e)}function rl(t,e){return z("mode",K(t),e)}var bn={name:"solve-tables",phrases:{"sum of column":"TABLE_COLUMN_SUM","total of column":"TABLE_COLUMN_SUM","average of column":"TABLE_COLUMN_AVERAGE","mean of column":"TABLE_COLUMN_AVERAGE","min of column":"TABLE_COLUMN_MIN","minimum of column":"TABLE_COLUMN_MIN","max of column":"TABLE_COLUMN_MAX","maximum of column":"TABLE_COLUMN_MAX","count of column":"TABLE_COLUMN_COUNT","median of column":"TABLE_COLUMN_MEDIAN","standard deviation of column":"TABLE_COLUMN_STDEV","stdev of column":"TABLE_COLUMN_STDEV","sample standard deviation of column":"TABLE_COLUMN_SAMPLE_STDEV","variance of column":"TABLE_COLUMN_VARIANCE","sample variance of column":"TABLE_COLUMN_SAMPLE_VARIANCE","spread of column":"TABLE_COLUMN_SPREAD","mode of column":"TABLE_COLUMN_MODE"},prefixParselets:{TABLE_COLUMN_SUM:new b("TABLE_COLUMN_SUM"),TABLE_COLUMN_AVERAGE:new b("TABLE_COLUMN_AVERAGE"),TABLE_COLUMN_MIN:new b("TABLE_COLUMN_MIN"),TABLE_COLUMN_MAX:new b("TABLE_COLUMN_MAX"),TABLE_COLUMN_COUNT:new b("TABLE_COLUMN_COUNT"),TABLE_COLUMN_MEDIAN:new b("TABLE_COLUMN_MEDIAN"),TABLE_COLUMN_STDEV:new b("TABLE_COLUMN_STDEV"),TABLE_COLUMN_SAMPLE_STDEV:new b("TABLE_COLUMN_SAMPLE_STDEV"),TABLE_COLUMN_VARIANCE:new b("TABLE_COLUMN_VARIANCE"),TABLE_COLUMN_SAMPLE_VARIANCE:new b("TABLE_COLUMN_SAMPLE_VARIANCE"),TABLE_COLUMN_SPREAD:new b("TABLE_COLUMN_SPREAD"),TABLE_COLUMN_MODE:new b("TABLE_COLUMN_MODE")},pluginFunctions:{TABLE_COLUMN_SUM:$m,TABLE_COLUMN_AVERAGE:Wm,TABLE_COLUMN_MIN:Ym,TABLE_COLUMN_MAX:jm,TABLE_COLUMN_COUNT:Xm,TABLE_COLUMN_MEDIAN:Qm,TABLE_COLUMN_STDEV:qm,TABLE_COLUMN_SAMPLE_STDEV:Zm,TABLE_COLUMN_VARIANCE:Jm,TABLE_COLUMN_SAMPLE_VARIANCE:el,TABLE_COLUMN_SPREAD:tl,TABLE_COLUMN_MODE:rl}};var Ue=class{constructor(e){this.pluginFnName=e;this.category="Tags";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall(this.pluginFnName,1);}};function no(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var ol={TOTAL_OF:"TAG_SUM",COUNT_OF:"TAG_COUNT",AVERAGE_OF:"TAG_AVERAGE"},Qp=new Set(["total","sum","count","average"]);function nl(t=80){return {name:"tags:aggregate",priority:t,match(e,o){let r=e[o];if(r===void 0)return null;let n=ol[r.type];if(n!==void 0){let i=e[o+1];return i?.type!=="TAG"?null:{consumed:2,replacement:[chunkLZSSAH5D_cjs.b(n,i.value??"",[r,i])],ruleName:"tags:aggregate"}}if(r.type==="IDENT"&&no(r)==="sum"){let i=e[o+1],a=e[o+2];return no(i)!=="of"||a?.type!=="TAG"?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("TAG_SUM",a.value??"",[r,i,a])],ruleName:"tags:aggregate"}}return null}}}function il(t=40){return {name:"tags:strip",priority:t,match(e,o){if(e[o]?.type!=="TAG")return null;let r=e[o-1];return r!==void 0&&(ol[r.type]!==void 0||no(r)==="of"&&Qp.has(no(e[o-2])))?null:{consumed:1,replacement:[],ruleName:"tags:strip"}}}}function qp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function al(t,e){if(e==="")return false;let r=new RegExp(`(?:^|[^0-9A-Za-z_])#${qp(e)}(?![0-9A-Za-z_-])`,"i").exec(t);if(r===null)return false;let n=r.index+r[0].indexOf("#");return t.slice(0,n).trim().length>0}function Zp(t,e){return t===void 0?chunk6U66HQKQ_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet`):t.type===12?chunk6U66HQKQ_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):t.type===13?chunk6U66HQKQ_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function Vn(t){return !t?.getLineResult||!t.getLineText?chunk6U66HQKQ_cjs.P("TAG_NO_DOCUMENT","Category tag sums require a real document, not available outside one (e.g. evaluateExpression()'s single-expression path)"):null}function Fn(t,e,o){let r=t.getLineText,n=t.getLineResult,i=t.isLineBoundary,a=e.toLowerCase(),s=0,l=0,u,c=false;for(let T=1;;T++){let N=r(T);if(N===void 0)break;if(T===t.lineIndex||i&&i(T)||!al(N,a))continue;let E=n(T),_=Zp(E,T);if(_)return _;if(o!=="count"){if(E.type!==0&&E.type!==6)return chunk6U66HQKQ_cjs.P("TAG_NON_NUMERIC",`Line ${T}, tagged #${e}, is not a plain number or unit value.`);if(E.type===6){if(c=true,u===void 0)u=E.unit;else if(E.unit!==u)return chunk6U66HQKQ_cjs.P("TAG_MIXED_UNITS",`Line ${T}'s unit (${E.unit}) doesn't match #${e}'s first unit (${u}), aggregating mixed units would misrepresent the result.`)}s+=E.toNumber();}l++;}if(o==="count")return chunk6U66HQKQ_cjs.n(l);if(l===0)return chunk6U66HQKQ_cjs.P("TAG_EMPTY",`No lines are tagged #${e}.`);let f=o==="average"?s/l:s;return c?chunk6U66HQKQ_cjs.u(f,u):chunk6U66HQKQ_cjs.n(f)}function sl(t,e){let o=Vn(e);return o||Fn(e,String(t[0].value),"sum")}function ml(t,e){let o=Vn(e);return o||Fn(e,String(t[0].value),"average")}function ll(t,e){let o=Vn(e);return o||Fn(e,String(t[0].value),"count")}var Hn={name:"solve-tags",normalizerRules:[nl(),il()],prefixParselets:{TAG_SUM:new Ue("sum"),TAG_AVERAGE:new Ue("average"),TAG_COUNT:new Ue("count")},pluginFunctions:{sum:sl,average:ml,count:ll}};var io=class{constructor(){this.category="operator";this.bindingPower=chunkFVQWN5HZ_cjs.a.Uncertainty;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(28);}};function ul(t=90){return {name:"uncertainty:ascii-plus-minus",priority:t,startTokenTypes:["PLUS"],match(e,o){let r=e[o];if(r?.type!=="PLUS")return null;let n=e[o+1];if(n?.type!=="SLASH")return null;let i=e[o+2];return i?.type!=="MINUS"?null:{consumed:3,replacement:[chunkLZSSAH5D_cjs.b("PLUS_MINUS","\xB1",[r,n,i])],ruleName:"uncertainty:ascii-plus-minus"}}}}var Gn={name:"solve-uncertainty",infixParselets:{PLUS_MINUS:new io},normalizerRules:[ul()]};var cl=1e-9,pl=1e9,Jp=100,ef=1e-9,tf=1e-9,rf=1e-12,of=1e-9,ao="goalseek";function fl(t,e){let o=e?.evaluateLineWithBinding,r=e?.getLineReads;if(!o||!r)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_NO_DOCUMENT","Goal seek only works inside a document, since it re-runs another line. The single-expression entry point has no document to solve against.");let n=t[0].toNumber(),i=typeof t[1].value=="string"?t[1].value:String(t[1].value),a=t[2];if(a.type!==0&&a.type!==6)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC",`Goal seek's target must be a number, as in "solve line ${n} for ${i} = 900".`);let s=a.toNumber();if(!Number.isFinite(s))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC","Goal seek's target is not a finite number.");let l=r(n);if(l===void 0)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_LINE_NOT_READY",`Line ${n} has no evaluated expression to solve (forward reference, out of range, or not an expression).`);if(!l.includes(i))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_VARIABLE_NOT_USED",`Line ${n} does not use ${i}, so changing ${i} cannot move its result toward ${s}.`);let u=o(n,i,chunk6U66HQKQ_cjs.K(chunk2XZCLDHJ_cjs.q(i)),true);if(u.type===9){let f=nf(u.value,s,i);if(f!==null)return chunk6U66HQKQ_cjs.n(f)}let c=e.goalSeekMaxIterations??Jp;return af(o,n,i,s,c)}function nf(t,e,o){let r=chunk2XZCLDHJ_cjs.p(chunk2XZCLDHJ_cjs.d(e)),n;try{n=chunkEEVUKZ5B_cjs.d(t,r,o);}catch{return null}if(n.kind!=="roots")return null;let i=[];for(let l of n.exact){let u=chunk2XZCLDHJ_cjs.Q(l);if(u.kind==="const"){let c=chunk2XZCLDHJ_cjs.e(u.value);Number.isFinite(c)&&i.push(c);}}for(let l of n.approximate)Math.abs(l.im)<=of&&Number.isFinite(l.re)&&i.push(l.re);if(i.length===0)return null;let a=i.filter(l=>l>=cl&&l<=pl),s=a.length>0?a:i;return s.sort((l,u)=>Math.abs(l)-Math.abs(u)),s[0]}function af(t,e,o,r,n){let i=N=>{let E=t(e,o,chunk6U66HQKQ_cjs.n(N),false);if(E.type===13)return {error:E};if(E.type!==0&&E.type!==6)return {error:chunk6U66HQKQ_cjs.P("GOAL_SEEK_TARGET_NOT_NUMERIC",`Line ${e} did not produce a number when ${o} was set to ${N}, so goal seek cannot compare it to the target.`)};let _=E.toNumber();return Number.isFinite(_)?{value:_}:{error:chunk6U66HQKQ_cjs.P("GOAL_SEEK_NON_FINITE",`Line ${e}'s result is not finite when ${o} is ${N}.`)}},a=cl,s=pl,l=i(a);if("error"in l)return l.error;let u=i(s);if("error"in u)return u.error;let c=Math.max(ef,Math.abs(r)*tf),f=l.value-r,T=u.value-r;if(Math.abs(f)<=c)return chunk6U66HQKQ_cjs.n(a);if(Math.abs(T)<=c)return chunk6U66HQKQ_cjs.n(s);if(Math.sign(f)===Math.sign(T))return chunk6U66HQKQ_cjs.P("GOAL_SEEK_NO_SOLUTION",`No value of ${o} between ${a} and ${s} makes line ${e} equal ${r}: across that whole range its result stays on one side of the target.`);for(let N=0;N<n;N++){let E=(a+s)/2,_=i(E);if("error"in _)return _.error;let O=_.value-r;if(Math.abs(O)<=c)return chunk6U66HQKQ_cjs.n(E);if(s-a<=rf)return chunk6U66HQKQ_cjs.P("GOAL_SEEK_DID_NOT_CONVERGE",`Goal seek narrowed ${o} to a single point near ${E} without line ${e} reaching ${r}: the relationship jumps across the target rather than passing through it.`);Math.sign(O)===Math.sign(f)?(a=E,f=O):s=E;}return chunk6U66HQKQ_cjs.P("GOAL_SEEK_DID_NOT_CONVERGE",`Goal seek did not bring line ${e} within tolerance of ${r} by varying ${o} in ${n} steps.`)}var so=class{constructor(){this.category="GoalSeek";}parse(e,o,r){let n=e.peek();if(!n||n.type!=="LINE_REF")throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_SYNTAX",'Goal seek reads "solve line N for <var> = <target>", for example "solve line 4 for rate = 900".',{found:n?.type??"end of input"});e.consume();let i=parseInt(n.value,10),a=e.peek();if(!(!!a&&(a.type==="FOR_DURATION"||a.type==="IDENT"&&a.value.toLowerCase()==="for")))throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_SYNTAX",'Goal seek reads "solve line N for <var> = <target>". Expected "for" after the line reference.',{found:a?.type??"end of input"});e.consume();let l=e.peek();if(!l||l.type!=="IDENT"&&l.type!=="UNIT")throw chunkNAZ6PGLS_cjs.c.parsing("GOAL_SEEK_REQUIRES_VARIABLE_NAME",'Goal seek needs the name of the variable to vary here, as in "solve line 4 for rate = 900".',{found:l?.type??"end of input"});e.consume(),e.consume("EQUALS"),r.emitOpcode(10),r.emitNumber(i),r.emitOpcode(13),r.emitString(l.value),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),r.emitPluginCall(ao,3);}};var sf=chunk5IJD5L3O_cjs.c("GOAL_SEEK");function dl(t=75){return {name:"goalseek:solve-line",priority:t,startTokenTypes:["IDENT"],match(e,o){if(o>0&&e[o-1].type==="COLON")return null;let r=e[o];return !r||r.type!=="IDENT"||r.value.toLowerCase()!=="solve"||e[o+1]?.type!=="LINE_REF"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a("GOAL_SEEK",sf,r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"goalseek:solve-line"}}}}var zn={name:"solve-goalseek",normalizerRules:[dl()],prefixParselets:{GOAL_SEEK:new so},pluginFunctions:{[ao]:fl}};var mo=class{constructor(){this.category="Colour";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("colour",1);}};var Te={COLOUR_INVALID:"COLOUR_INVALID",COLOUR_EXPECTED_COLOUR:"COLOUR_EXPECTED_COLOUR",COLOUR_BAD_ARGUMENTS:"COLOUR_BAD_ARGUMENTS"};function B(t){return t&&t.type===14?t.value:null}function U(t){if(!t)return 0;let e=t.toNumber();return t.type===5?e:e>1?e/100:e}function q(t,e){return chunk6U66HQKQ_cjs.P(Te.COLOUR_BAD_ARGUMENTS,`${t}(...) expects ${e}`)}function Y(t){return chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,`${t}(...) expects a colour as its first argument`)}function El(t){let e=t[0];if(!e||e.type!==3||typeof e.value!="string")return q("color",'a string, e.g. color("#ff0000") or color("red")');let o=chunk5TVI2UPZ_cjs.c(e.value);return o?chunk6U66HQKQ_cjs.G(o):chunk6U66HQKQ_cjs.P(Te.COLOUR_INVALID,`"${e.value}" is not a hex colour (#rgb, #rgba, #rrggbb, #rrggbbaa) or a CSS colour name`)}function mf(t){return t.length!==3?q("rgb","three numbers: rgb(red, green, blue)"):chunk6U66HQKQ_cjs.G({r:chunk5TVI2UPZ_cjs.a(t[0].toNumber()),g:chunk5TVI2UPZ_cjs.a(t[1].toNumber()),b:chunk5TVI2UPZ_cjs.a(t[2].toNumber()),a:1,format:"rgb"})}function lf(t){return t.length!==4?q("rgba","four numbers: rgba(red, green, blue, alpha)"):chunk6U66HQKQ_cjs.G({r:chunk5TVI2UPZ_cjs.a(t[0].toNumber()),g:chunk5TVI2UPZ_cjs.a(t[1].toNumber()),b:chunk5TVI2UPZ_cjs.a(t[2].toNumber()),a:chunk5TVI2UPZ_cjs.b(U(t[3])),format:"rgba"})}function uf(t){if(t.length!==3)return q("hsl","three values: hsl(hue, saturation%, lightness%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.e(t[0].toNumber(),U(t[1]),U(t[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:r,a:1,format:"hsl"})}function cf(t){if(t.length!==4)return q("hsla","four values: hsla(hue, saturation%, lightness%, alpha)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.e(t[0].toNumber(),U(t[1]),U(t[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:r,a:chunk5TVI2UPZ_cjs.b(U(t[3])),format:"hsla"})}function Ne(t,e){return o=>{let r=B(o[0]);return r?o.length<2?q(t,`a colour and an amount, e.g. ${t}(#3366cc, 20%)`):chunk6U66HQKQ_cjs.G(e(r,U(o[1]))):Y(t)}}var pf=Ne("lighten",chunk5TVI2UPZ_cjs.j),ff=Ne("darken",chunk5TVI2UPZ_cjs.k),df=Ne("saturate",chunk5TVI2UPZ_cjs.l),Tl=Ne("desaturate",chunk5TVI2UPZ_cjs.m);function Kn(t){let e=B(t[0]);return e?t.length<2?q("rotate","a colour and a hue angle in degrees, e.g. rotate(#ff0000, 90)"):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.n(e,t[1].toNumber())):Y("rotate")}function Ef(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.o(e)):Y("complement")}function Nl(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.p(e)):Y("grayscale")}function yl(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.q(e,t.length>1?U(t[1]):1)):Y("invert")}function Tf(t){let e=B(t[0]),o=B(t[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"mix(...) expects two colours to blend"):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.r(e,o,t.length>2?U(t[2]):.5))}function $n(t){let e=B(t[0]);return e?t.length<2?chunk6U66HQKQ_cjs.n(e.a):chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.s(e,U(t[1]))):Y("alpha")}function Nf(t){let e=B(t[0]),o=B(t[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"contrast(...) expects two colours"):chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.i(e,o))}function yf(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.h(e)):Y("luminance")}function De(t,e){return o=>{let r=B(o[0]);return r?chunk6U66HQKQ_cjs.n(e(r)):Y(t)}}var gf=De("red",t=>t.r),Pf=De("green",t=>t.g),_f=De("blue",t=>t.b),Af=De("hue",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).h),xf=De("saturation",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).s*100),Of=De("lightness",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).l*100);function gl(t){if(t.length!==3)return q("hsv","three values: hsv(hue, saturation%, value%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.t(t[0].toNumber(),U(t[1]),U(t[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}function Rf(t){if(t.length!==4)return q("hsva","four values: hsva(hue, saturation%, value%, alpha)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.t(t[0].toNumber(),U(t[1]),U(t[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:r,a:chunk5TVI2UPZ_cjs.b(U(t[3])),format:"hex"})}function If(t){if(t.length!==3)return q("hwb","three values: hwb(hue, whiteness%, blackness%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.u(t[0].toNumber(),U(t[1]),U(t[2]));return chunk6U66HQKQ_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}var Cf=Ne("tint",chunk5TVI2UPZ_cjs.v),hf=Ne("shade",chunk5TVI2UPZ_cjs.w),Sf=Ne("tone",chunk5TVI2UPZ_cjs.x);function Lf(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.y(e)):Y("isdark")}function wf(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.L(!chunk5TVI2UPZ_cjs.y(e)):Y("islight")}function Wn(t){let e=B(t[0]);return e?chunk6U66HQKQ_cjs.G(chunk5TVI2UPZ_cjs.z(e)):Y("readable")}function vf(t){if(!t)return chunk5TVI2UPZ_cjs.A.aa;if(t.type===0)return t.toNumber();if(t.type===3){let e=t.value.trim().toLowerCase();if(e==="aaa")return chunk5TVI2UPZ_cjs.A.aaa;if(e==="aa large"||e==="aa-large"||e==="large")return chunk5TVI2UPZ_cjs.A.aaLarge;if(e==="aaa large"||e==="aaa-large")return chunk5TVI2UPZ_cjs.A.aaaLarge}return chunk5TVI2UPZ_cjs.A.aa}function kf(t){let e=B(t[0]),o=B(t[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"iscontrastcompliant(...) expects two colours"):chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.i(e,o)>=vf(t[2]))}function Pl(t){let e=B(t[0]),o=B(t[1]);return !e||!o?chunk6U66HQKQ_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"wcaglevel(...) expects two colours"):chunk6U66HQKQ_cjs.t(chunk5TVI2UPZ_cjs.B(e,o))}var ye={color:El,colour:El,rgb:mf,rgba:lf,hsl:uf,hsla:cf,lighten:pf,darken:ff,saturate:df,desaturate:Tl,desat:Tl,rotate:Kn,spin:Kn,adjusthue:Kn,complement:Ef,grayscale:Nl,greyscale:Nl,invert:yl,mix:Tf,alpha:$n,opacity:$n,fade:$n,contrast:Nf,luminance:yf,red:gf,green:Pf,blue:_f,hue:Af,saturation:xf,lightness:Of,hsv:gl,hsb:gl,hsva:Rf,hwb:If,tint:Cf,shade:hf,tone:Sf,negate:yl,isdark:Lf,islight:wf,readable:Wn,contrastcolor:Wn,contrastcolour:Wn,iscontrastcompliant:kf,wcaglevel:Pl,wcag:Pl};var lo=class{constructor(){this.category="Colour";}parse(e,o,r){let n=o.value.toLowerCase();if(ye[n]===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_COLOUR_FUNCTION",`Unknown colour function: ${n}`,{functionName:n});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var Bf=new Set(Object.keys(ye));function _l(t=80){return {name:"colour:call",priority:t,startTokenTypes:["IDENT"],match(e,o){let r=e[o];if(!r||r.type!=="IDENT")return null;let n=r.value.toLowerCase();return !Bf.has(n)||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a("COLOUR_CALL",chunk5IJD5L3O_cjs.c("COLOUR_CALL"),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"colour:call"}}}}var uo=t=>e=>{if(e.type!==14)return e;let o=e.value;return chunk6U66HQKQ_cjs.G({r:o.r,g:o.g,b:o.b,a:o.a,format:t})},Mf=Object.keys(ye).map(t=>({label:t,category:"function",detail:"colour"})),Yn={name:"solve-colour",prefixParselets:{HEX_COLOUR:new mo,COLOUR_CALL:new lo},normalizerRules:[_l()],pluginFunctions:ye,asConverters:{rgb:uo("rgb"),rgba:uo("rgba"),hsl:uo("hsl"),hsla:uo("hsla")},completionItems:Mf};var jn=32;function Uf(t){if(t.hasSymbolic||t.rows!==1&&t.cols!==1)return null;let e=[];for(let o of t.data){if(typeof o!="number"||!Number.isFinite(o))return null;e.push(o);}return e}function Df(t){let e=t.max-t.min+1,o=Math.min(e,jn),r=[];for(let n=0;n<o;n++)r.push(t.min+Math.round(n*(e-1)/(o-1)));return r}function bf(t,e){if(t.length<=e)return [...t];let o=[];for(let r=0;r<e;r++)o.push(t[Math.round(r*(t.length-1)/(e-1))]);return o}function Al(t){let e=null;if(t.type===7)e=Uf(t.value);else if(t.type===8){let a=t.value;e=a.max-a.min+1>=2?Df(a):null;}if(!e||e.length<2)return null;let o=bf(e,jn),r=Math.min(...e),n=Math.max(...e),i=e.length<=jn?`[${e.join(", ")}]`:`sparkline of ${e.length} values`;return {kind:"sparkline",points:o.map((a,s)=>[s,a]),label:i,domain:[0,o.length-1],range:[r,n]}}var co=class{constructor(){this.category="Plot";}parse(e,o,r){let n=Vf(e),i=new chunkFVQWN5HZ_cjs.d(r.pluginIndexMap);e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,i),e.setBuilder(r);let a=i.build();if(a.hasAsync)throw chunkNAZ6PGLS_cjs.c.parsing("PLOT_EXPR_MUST_BE_SYNCHRONOUS","a plot expression must be synchronous (no weather, stocks or currency calls).");e.consume("FROM"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r),e.consume("TO"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,r);let s=r.emitAnonymousBody(["x"],a);r.emitOpcode(160),r.emitIndex(s),r.emitString(n);}};function Vf(t){let e=[];for(let n=0;;n++){let i=t.peekAt(n);if(!i||i.type==="FROM")break;e.push(i);}if(e.length===0)return "";let o=e[0].offset,r="";for(let n of e){let i=n.offset-o;for(;r.length<i;)r+=" ";r+=n.text??n.value??"";}return r.trim()}var xl="PLOT",Ff=chunk5IJD5L3O_cjs.c(xl),Hf=new Set(["NUMBER","IDENT","FUNC","UNIT","LPAREN","PI","E"]);function Ol(t=80){let e="plot:plot-clause";return {name:e,priority:t,startTokenTypes:["IDENT"],match(o,r){let n=o[r];if(!n||n.type!=="IDENT"||(n.value??"").toLowerCase()!=="plot"||o[r-1]?.type==="COLON")return null;let i=o[r+1];return !i||!Hf.has(i.type)?null:{consumed:1,replacement:[new chunkFAGFPVYK_cjs.a(xl,Ff,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var Xn={name:"solve-chart",asConverters:{sparkline:t=>{let e=Al(t);return e?chunk6U66HQKQ_cjs.I(e):chunk6U66HQKQ_cjs.P("SPARKLINE_NOT_A_SERIES",'"as sparkline" expects a numeric vector or a range, with at least two values')}},prefixParselets:{PLOT:new co},normalizerRules:[Ol()],tokenCategories:{PLOT:"keyword"}};var dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Qn(t){let e=new TextEncoder().encode(t),o="";for(let r=0;r<e.length;r+=3){let n=e[r],i=r+1<e.length?e[r+1]:0,a=r+2<e.length?e[r+2]:0;o+=dt[n>>2],o+=dt[(n&3)<<4|i>>4],o+=r+1<e.length?dt[(i&15)<<2|a>>6]:"=",o+=r+2<e.length?dt[a&63]:"=";}return o}function Rl(t){let e=t.replace(/\s+/g,"");if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))return null;let o=e.replace(/=+$/,""),r=[],n=0,i=0;for(let a of o){let s=dt.indexOf(a);if(s<0)return null;i=i<<6|s,n+=6,n>=8&&(n-=8,r.push(i>>n&255));}try{return new TextDecoder("utf-8",{fatal:!0}).decode(new Uint8Array(r))}catch{return null}}function Il(t){return encodeURIComponent(t)}function Cl(t){try{return decodeURIComponent(t)}catch{return null}}function hl(t){return Array.from(new TextEncoder().encode(t)).map(e=>e.toString(16).padStart(2,"0")).join(" ")}function qn(t){let e=t.trim().split(/[\s,]+/).filter(r=>r.length>0),o=[];for(let r of e){if(!/^[0-9a-fA-F]{1,2}$/.test(r))return null;o.push(parseInt(r,16));}try{return new TextDecoder("utf-8",{fatal:!0}).decode(new Uint8Array(o))}catch{return null}}var po=class{constructor(){this.category="Encoding";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){let i=(r.value??"").replace(/^from\s+/i,"").toLowerCase();n.emitOpcode(13),n.emitString(i),n.emitPluginCall("fromEncoding",2);}};var fo=class{constructor(e){this.fn=e;this.category="Encoding";}parse(e,o,r){e.consume("LPAREN"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),e.consume("RPAREN"),r.emitPluginCall(this.fn,1);}};function Sl(t){return t.type===3?t.value:null}function Eo(t,e){return o=>{let r=Sl(o);return r===null?chunk6U66HQKQ_cjs.P("ENCODING_EXPECTED_TEXT",`"as ${t}" expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(r))}}var Gf={base64:Rl,url:Cl,"hex bytes":qn,hexbytes:qn},Zn={name:"solve-encoding",phrases:{"hex bytes":"CONVERTER_NAME","from base64":"FROM_ENCODING","from url":"FROM_ENCODING","from hex bytes":"FROM_ENCODING"},asConverters:{base64:Eo("base64",Qn),url:Eo("url",Il),"hex bytes":Eo("hex bytes",hl)},infixParselets:{FROM_ENCODING:new po},prefixParselets:{BASE64_FN:new fo("base64")},callFusions:{base64:"BASE64_FN"},pluginFunctions:{base64:t=>Eo("base64",Qn)(t[0]),fromEncoding:t=>{let e=Sl(t[0]),o=String(t[1].value??"");if(e===null)return chunk6U66HQKQ_cjs.P("ENCODING_EXPECTED_TEXT",`"from ${o}" expects text (a "quoted string")`);let r=Gf[o];if(!r)return chunk6U66HQKQ_cjs.P("UNKNOWN_ENCODING",`"from ${o}" is not a known encoding (try base64, url or hex bytes)`);let n=r(e);return n===null?chunk6U66HQKQ_cjs.P("ENCODING_DECODE_FAILED",`"from ${o}": the input is not valid ${o}`):chunk6U66HQKQ_cjs.t(n)}},tokenCategories:{BASE64_FN:"function"}};var To=class{constructor(){this.category="IP";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("ipLiteral",1);}};var be=class{constructor(e){this.pluginFn=e;this.category="IP";}parse(e,o,r){let n=e.peek(),i=e.peekAt(1);n?.type==="SLASH"&&i?.type==="NUMBER"?(e.consume(),e.consume(),r.emitOpcode(13),r.emitString(`|${i.value}`),r.emitPluginCall("ipLiteral",1)):e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,r),r.emitPluginCall(this.pluginFn,1);}};var Ll="IP_CIDR",zf=chunk5IJD5L3O_cjs.c(Ll),Kf=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{1,2})?/,$f=8;function wl(t=72){let e="ip:ip-cidr-literal";return {name:e,priority:t,startTokenTypes:["NUMBER"],match(o,r){let n=o[r];if(!n||n.type!=="NUMBER"||n.sourceEnd!==void 0||!/^\d{1,3}\./.test(n.text??""))return null;let i=n.text??"",a=n.offset+i.length,s=[n];for(let E=r+1;E<o.length&&s.length<$f;E++){let _=o[E];if(_.sourceEnd!==void 0||_.offset!==a||_.type!=="NUMBER"&&_.type!=="SLASH")break;i+=_.text??"",a=_.offset+(_.text?.length??0),s.push(_);}let l=Kf.exec(i);if(l===null)return null;let u=chunk5TVI2UPZ_cjs.C(l[0]);if(u===null||u.addr===void 0)return null;let c=0,f=0;for(let E of s)if(f+=E.text?.length??0,c++,f>=l[0].length)break;if(f!==l[0].length)return null;let T=`${u.addr}|${u.prefix??""}`,N=new chunkFAGFPVYK_cjs.a(Ll,zf,T,l[0],n.offset,0,n.line,n.col,n.offset+l[0].length);return {consumed:c,replacement:[N],ruleName:e}}}}function Et(t,e){return t.type===17?t.value:chunk6U66HQKQ_cjs.P("IP_EXPECTED",`"${e}" expects an IP address or subnet (e.g. 192.168.1.0/24)`)}function vl(t){let[e,o]=String(t[0].value??"").split("|"),r={...e!==""?{addr:Number(e)}:{},...o!==""?{prefix:Number(o)}:{}};return chunk6U66HQKQ_cjs.J(r)}function kl(t){let e=Et(t[0],"hosts in");return e instanceof chunk6U66HQKQ_cjs.m?e:e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NO_PREFIX",'"hosts in" needs a subnet with a prefix, e.g. 192.168.1.0/24'):chunk6U66HQKQ_cjs.n(chunk5TVI2UPZ_cjs.F(e.prefix))}function Bl(t){let e=Et(t[0],"netmask of");return e instanceof chunk6U66HQKQ_cjs.m?e:e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NO_PREFIX",'"netmask of" needs a prefix, e.g. /24 or 192.168.1.0/24'):chunk6U66HQKQ_cjs.J({addr:chunk5TVI2UPZ_cjs.E(e.prefix)})}function Ml(t){let e=Et(t[0],"broadcast of");return e instanceof chunk6U66HQKQ_cjs.m?e:e.addr===void 0||e.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_NEEDS_ADDRESS_AND_PREFIX",'"broadcast of" needs an address and a prefix, e.g. 192.168.1.0/24'):chunk6U66HQKQ_cjs.J({addr:chunk5TVI2UPZ_cjs.G(e.addr,e.prefix)})}function Ul(t){let e=Et(t[0],"in");if(e instanceof chunk6U66HQKQ_cjs.m)return e;let o=Et(t[1],"in");return o instanceof chunk6U66HQKQ_cjs.m?o:e.addr===void 0?chunk6U66HQKQ_cjs.P("IP_EXPECTED_ADDRESS",'"in" expects an address on the left'):o.addr===void 0||o.prefix===void 0?chunk6U66HQKQ_cjs.P("IP_EXPECTED_BLOCK",'"in" expects a subnet on the right, e.g. 10.0.0.0/8'):chunk6U66HQKQ_cjs.L(chunk5TVI2UPZ_cjs.H(e.addr,o.addr,o.prefix))}function Dl(t){if(t.type===17){let e=t.value;return chunk6U66HQKQ_cjs.n(e.addr??0)}return chunk6U66HQKQ_cjs.n(Math.trunc(t.toNumber()))}var Jn={name:"solve-ip",phrases:{"hosts in":"HOSTS_IN","netmask of":"NETMASK_OF","broadcast of":"BROADCAST_OF"},prefixParselets:{IP_CIDR:new To,HOSTS_IN:new be("hostsIn"),NETMASK_OF:new be("netmaskOf"),BROADCAST_OF:new be("broadcastOf")},normalizerRules:[wl()],pluginFunctions:{ipLiteral:vl,hostsIn:kl,netmaskOf:Bl,broadcastOf:Ml,ipInCidr:Ul},asConverters:{int:Dl},tokenCategories:{IP_CIDR:"number",HOSTS_IN:"keyword",NETMASK_OF:"keyword",BROADCAST_OF:"keyword"}};var Wf=chunk5IJD5L3O_cjs.c("UNIT");function bl(t=82){let e="fuel:l-per-100km";return {name:e,priority:t,startTokenTypes:["UNIT","IDENT"],match(o,r){let n=o[r],i=o[r+1],a=o[r+2],s=o[r+3];return !n||n.type!=="UNIT"&&n.type!=="IDENT"||(n.value??"").toLowerCase()!=="l"||i?.type!=="SLASH"||a?.type!=="NUMBER"||a.value!=="100"||s?.type!=="UNIT"||(s.value??"").toLowerCase()!=="km"?null:{consumed:4,replacement:[new chunkFAGFPVYK_cjs.a("UNIT",Wf,"l100km","l/100km",n.offset,0,n.line,n.col)],ruleName:e}}}}var ei={name:"solve-fuel",normalizerRules:[bl()]};var Yf=chunk5IJD5L3O_cjs.c("UNIT");function Vl(t=82){let e="derived:acceleration";return {name:e,priority:t,startTokenTypes:["UNIT"],match(o,r){let n=o[r],i=o[r+1],a=o[r+2],s=o[r+3],l=o[r+4];return !n||n.type!=="UNIT"||(n.value??"")!=="m"||i?.type!=="SLASH"||a?.type!=="UNIT"||(a.value??"")!=="s"||s?.type!=="CARET"||l?.type!=="NUMBER"||l.value!=="2"?null:{consumed:5,replacement:[new chunkFAGFPVYK_cjs.a("UNIT",Yf,"mps2","m/s^2",n.offset,0,n.line,n.col)],ruleName:e}}}}function D(t){return e=>e.type!==6||!e.unit?chunk6U66HQKQ_cjs.P("AS_UNIT_EXPECTED_QUANTITY",`"as ${t}" expects a quantity with a unit`):e.unit===t?e:chunkBKSKZA4W_cjs.d(e.unit,t)?chunk6U66HQKQ_cjs.u(chunkBKSKZA4W_cjs.e(e.toNumber(),e.unit,t),t):chunk6U66HQKQ_cjs.P("AS_UNIT_INCOMPATIBLE",`${e.unit} cannot be expressed as ${t}: they do not measure the same thing`)}var ti={name:"solve-derived-units",normalizerRules:[Vl()],asConverters:{n:D("N"),kn:D("kN"),j:D("J"),kj:D("kJ"),mj:D("MJ"),wh:D("Wh"),kwh:D("kWh"),w:D("W"),kw:D("kW"),mw:D("MW"),pa:D("Pa"),kpa:D("kPa"),mpa:D("MPa"),v:D("V"),mv:D("mV"),kv:D("kV")}};function ri(t){return [...t].length}function Fl(t){return t.trim()}function Hl(t){return [...t].reverse().join("")}function Gl(t,e){return t.includes(e)}function zl(t,e){return t.startsWith(e)}function Kl(t,e){return t.endsWith(e)}function $l(t,e,o){return e===""?t:t.split(e).join(o)}function Wl(t,e){let o=Math.trunc(e);return o<=0?"":t.repeat(o)}function No(t){return t.toUpperCase()}function yo(t){return t.toLowerCase()}function go(t){return t.replace(/\S+/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function Po(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Yl(t){let e=t.trim();return e===""?0:e.split(/\s+/).length}function jl(t){return t===""?0:t.split(/\r\n|\r|\n/).length}function ae(t){return t?.type===3?t.value:null}function Tt(t){return chunk6U66HQKQ_cjs.P("TEXT_EXPECTED",`${t} expects text (a "quoted string")`)}function _o(t,e){return o=>{let r=ae(o[0]);return r===null?Tt(t):chunk6U66HQKQ_cjs.n(e(r))}}function Ve(t,e){return o=>{let r=ae(o[0]);return r===null?Tt(t):chunk6U66HQKQ_cjs.t(e(r))}}function oi(t,e){return o=>{let r=ae(o[0]),n=ae(o[1]);return r===null||n===null?Tt(t):chunk6U66HQKQ_cjs.L(e(r,n))}}var Xl={textLength:_o("length",ri),textWordCount:_o("words in",Yl),textCharCount:_o("characters in",ri),textLineCount:_o("lines in",jl),textTrim:Ve("trim",Fl),textReverse:Ve("reverse",Hl),textUpper:Ve('"as upper"',No),textLower:Ve('"as lower"',yo),textTitle:Ve('"as title"',go),textSlug:Ve('"as slug"',Po),textContains:oi("contains",Gl),textStartsWith:oi("starts with",zl),textEndsWith:oi("ends with",Kl),textReplace:t=>{let e=ae(t[0]),o=ae(t[1]),r=ae(t[2]);return e===null||o===null||r===null?Tt("replace"):chunk6U66HQKQ_cjs.t($l(e,o,r))},textRepeat:t=>{let e=ae(t[0]);if(e===null)return Tt("repeat");let o=t[1];return o?.type!==0?chunk6U66HQKQ_cjs.P("TEXT_EXPECTED","repeat expects a count (a number)"):chunk6U66HQKQ_cjs.t(Wl(e,o.value))}};function ge(t,e){return {category:"Text",parse(o,r,n){o.parseExpression(e,n),n.emitPluginCall(t,1);}}}function Ao(t){return {category:"Text",bindingPower:chunkFVQWN5HZ_cjs.a.Conditional,parse(e,o,r,n){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conditional,n),n.emitPluginCall(t,2);}}}var Ql={category:"Text",bindingPower:chunkFVQWN5HZ_cjs.a.Conditional,parse(t,e,o,r){t.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,r);let n=t.peek();n?.type==="STAR"&&(n.value??"").toLowerCase()==="times"&&t.consume(),r.emitPluginCall("textRepeat",2);}};var xo={length:"textLength",upper:"textUpper",uppercase:"textUpper",lower:"textLower",lowercase:"textLower",title:"textTitle",titlecase:"textTitle",slug:"textSlug",slugify:"textSlug",replace:"textReplace",repeat:"textRepeat",words:"textWordCount",wordcount:"textWordCount",characters:"textCharCount",charcount:"textCharCount",lines:"textLineCount",linecount:"textLineCount"};var Oo=class{constructor(){this.category="Text";}parse(e,o,r){let n=xo[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown text function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};function Ro(t,e){return o=>o.type!==3?chunk6U66HQKQ_cjs.P("TEXT_EXPECTED",`"as ${t}" expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(o.value))}var ni={name:"solve-text",phrases:{"length of":"LENGTH_OF","words in":"WORDS_IN","characters in":"CHARACTERS_IN","lines in":"LINES_IN","starts with":"STARTS_WITH","ends with":"ENDS_WITH"},lexerVocabulary:{keywords:{trim:"TRIM",reverse:"REVERSE",contains:"CONTAINS",repeated:"REPEATED"}},prefixParselets:{LENGTH_OF:ge("textLength",chunkFVQWN5HZ_cjs.a.Lowest),WORDS_IN:ge("textWordCount",chunkFVQWN5HZ_cjs.a.Lowest),CHARACTERS_IN:ge("textCharCount",chunkFVQWN5HZ_cjs.a.Lowest),LINES_IN:ge("textLineCount",chunkFVQWN5HZ_cjs.a.Lowest),TRIM:ge("textTrim",chunkFVQWN5HZ_cjs.a.Prefix),REVERSE:ge("textReverse",chunkFVQWN5HZ_cjs.a.Prefix),TEXT_CALL:new Oo},infixParselets:{CONTAINS:Ao("textContains"),STARTS_WITH:Ao("textStartsWith"),ENDS_WITH:Ao("textEndsWith"),REPEATED:Ql},asConverters:{upper:Ro("upper",No),lower:Ro("lower",yo),title:Ro("title",go),slug:Ro("slug",Po)},callFusions:Object.fromEntries(Object.keys(xo).map(t=>[t,"TEXT_CALL"])),pluginFunctions:Xl,tokenCategories:{LENGTH_OF:"function",WORDS_IN:"function",CHARACTERS_IN:"function",LINES_IN:"function",TRIM:"function",REVERSE:"function",TEXT_CALL:"function",CONTAINS:"operator",STARTS_WITH:"operator",ENDS_WITH:"operator",REPEATED:"operator"}};function Nt(t){return new TextEncoder().encode(t)}function ii(t){let e="";for(let o of t)e+=o.toString(16).padStart(2,"0");return e}var jf=(()=>{let t=new Uint32Array(256);for(let e=0;e<256;e++){let o=e;for(let r=0;r<8;r++)o=o&1?3988292384^o>>>1:o>>>1;t[e]=o>>>0;}return t})();function ql(t){let e=Nt(t),o=4294967295;for(let r of e)o=jf[(o^r)&255]^o>>>8;return o=(o^4294967295)>>>0,o.toString(16).padStart(8,"0")}function Xf(t){let e=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],o=new Int32Array(64);for(let N=0;N<64;N++)o[N]=Math.floor(Math.abs(Math.sin(N+1))*4294967296);let r=t.length*8,n=new Uint8Array(((t.length+8>>6)+1)*64);n.set(t),n[t.length]=128;let i=new DataView(n.buffer);i.setUint32(n.length-8,r>>>0,true),i.setUint32(n.length-4,Math.floor(r/4294967296)>>>0,true);let a=1732584193,s=4023233417,l=2562383102,u=271733878,c=(N,E)=>N<<E|N>>>32-E;for(let N=0;N<n.length;N+=64){let E=new Int32Array(16);for(let P=0;P<16;P++)E[P]=i.getUint32(N+P*4,true);let _=a,O=s,R=l,g=u;for(let P=0;P<64;P++){let C,S;P<16?(C=O&R|~O&g,S=P):P<32?(C=g&O|~g&R,S=(5*P+1)%16):P<48?(C=O^R^g,S=(3*P+5)%16):(C=R^(O|~g),S=7*P%16),C=C+_+o[P]+E[S]|0,_=g,g=R,R=O,O=O+c(C,e[P])|0;}a=a+_|0,s=s+O|0,l=l+R|0,u=u+g|0;}let f=new Uint8Array(16),T=new DataView(f.buffer);return T.setUint32(0,a>>>0,true),T.setUint32(4,s>>>0,true),T.setUint32(8,l>>>0,true),T.setUint32(12,u>>>0,true),f}function Zl(t){return ii(Xf(Nt(t)))}function Qf(t){let e=t.length*8,o=new Uint8Array(((t.length+8>>6)+1)*64);o.set(t),o[t.length]=128;let r=new DataView(o.buffer);r.setUint32(o.length-8,Math.floor(e/4294967296)>>>0),r.setUint32(o.length-4,e>>>0);let n=1732584193,i=4023233417,a=2562383102,s=271733878,l=3285377520,u=(N,E)=>N<<E|N>>>32-E,c=new Int32Array(80);for(let N=0;N<o.length;N+=64){for(let P=0;P<16;P++)c[P]=r.getUint32(N+P*4);for(let P=16;P<80;P++)c[P]=u(c[P-3]^c[P-8]^c[P-14]^c[P-16],1);let E=n,_=i,O=a,R=s,g=l;for(let P=0;P<80;P++){let C,S;P<20?(C=_&O|~_&R,S=1518500249):P<40?(C=_^O^R,S=1859775393):P<60?(C=_&O|_&R|O&R,S=2400959708):(C=_^O^R,S=3395469782);let j=u(E,5)+C+g+S+c[P]|0;g=R,R=O,O=u(_,30),_=E,E=j;}n=n+E|0,i=i+_|0,a=a+O|0,s=s+R|0,l=l+g|0;}let f=new Uint8Array(20),T=new DataView(f.buffer);return [n,i,a,s,l].forEach((N,E)=>T.setUint32(E*4,N>>>0)),f}function Jl(t){return ii(Qf(Nt(t)))}var qf=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Zf(t){let e=t.length*8,o=new Uint8Array(((t.length+8>>6)+1)*64);o.set(t),o[t.length]=128;let r=new DataView(o.buffer);r.setUint32(o.length-8,Math.floor(e/4294967296)>>>0),r.setUint32(o.length-4,e>>>0);let n=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),i=(u,c)=>u>>>c|u<<32-c,a=new Uint32Array(64);for(let u=0;u<o.length;u+=64){for(let g=0;g<16;g++)a[g]=r.getUint32(u+g*4);for(let g=16;g<64;g++){let P=i(a[g-15],7)^i(a[g-15],18)^a[g-15]>>>3,C=i(a[g-2],17)^i(a[g-2],19)^a[g-2]>>>10;a[g]=a[g-16]+P+a[g-7]+C|0;}let[c,f,T,N,E,_,O,R]=n;for(let g=0;g<64;g++){let P=i(E,6)^i(E,11)^i(E,25),C=E&_^~E&O,S=R+P+C+qf[g]+a[g]|0,j=i(c,2)^i(c,13)^i(c,22),Ge=c&f^c&T^f&T,me=j+Ge|0;R=O,O=_,_=E,E=N+S|0,N=T,T=f,f=c,c=S+me|0;}n[0]=n[0]+c|0,n[1]=n[1]+f|0,n[2]=n[2]+T|0,n[3]=n[3]+N|0,n[4]=n[4]+E|0,n[5]=n[5]+_|0,n[6]=n[6]+O|0,n[7]=n[7]+R|0;}let s=new Uint8Array(32),l=new DataView(s.buffer);for(let u=0;u<8;u++)l.setUint32(u*4,n[u]>>>0);return s}function eu(t){return ii(Zf(Nt(t)))}var V=(1n<<64n)-1n,Jf=[0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n];function tu(t){let e=Nt(t),o=((e.length+16>>7)+1)*128,r=new Uint8Array(o);r.set(e),r[e.length]=128;let n=BigInt(e.length)*8n,i=new DataView(r.buffer);i.setUint32(r.length-4,Number(n&0xffffffffn)),i.setUint32(r.length-8,Number(n>>32n&0xffffffffn));let a=[0x6a09e667f3bcc908n,0xbb67ae8584caa73bn,0x3c6ef372fe94f82bn,0xa54ff53a5f1d36f1n,0x510e527fade682d1n,0x9b05688c2b3e6c1fn,0x1f83d9abfb41bd6bn,0x5be0cd19137e2179n],s=(u,c)=>(u>>c|u<<64n-c)&V,l=new Array(80);for(let u=0;u<r.length;u+=128){for(let g=0;g<16;g++){let P=BigInt(i.getUint32(u+g*8)),C=BigInt(i.getUint32(u+g*8+4));l[g]=P<<32n|C;}for(let g=16;g<80;g++){let P=s(l[g-15],1n)^s(l[g-15],8n)^l[g-15]>>7n,C=s(l[g-2],19n)^s(l[g-2],61n)^l[g-2]>>6n;l[g]=l[g-16]+P+l[g-7]+C&V;}let[c,f,T,N,E,_,O,R]=a;for(let g=0;g<80;g++){let P=s(E,14n)^s(E,18n)^s(E,41n),C=E&_^~E&V&O,S=R+P+C+Jf[g]+l[g]&V,j=s(c,28n)^s(c,34n)^s(c,39n),Ge=c&f^c&T^f&T,me=j+Ge&V;R=O,O=_,_=E,E=N+S&V,N=T,T=f,f=c,c=S+me&V;}a[0]=a[0]+c&V,a[1]=a[1]+f&V,a[2]=a[2]+T&V,a[3]=a[3]+N&V,a[4]=a[4]+E&V,a[5]=a[5]+_&V,a[6]=a[6]+O&V,a[7]=a[7]+R&V;}return a.map(u=>u.toString(16).padStart(16,"0")).join("")}var Io={md5:"hashMd5",sha1:"hashSha1",sha256:"hashSha256",sha512:"hashSha512",crc32:"hashCrc32"};function yt(t,e){return o=>{let r=o[0];return r?.type!==3?chunk6U66HQKQ_cjs.P("HASH_EXPECTED_TEXT",`${t}(...) expects text (a "quoted string")`):chunk6U66HQKQ_cjs.t(e(r.value))}}var ru={hashMd5:yt("md5",Zl),hashSha1:yt("sha1",Jl),hashSha256:yt("sha256",eu),hashSha512:yt("sha512",tu),hashCrc32:yt("crc32",ql)};var Co=class{constructor(){this.category="Hash";}parse(e,o,r){let n=Io[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown hash function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var ai={name:"solve-hash",prefixParselets:{HASH_CALL:new Co},callFusions:Object.fromEntries(Object.keys(Io).map(t=>[t,"HASH_CALL"])),pluginFunctions:ru,tokenCategories:{HASH_CALL:"function"}};var ou="0123456789abcdef";function nu(){return ou[Math.floor(Math.random()*16)]}function ed(){let t="";for(let e=0;e<36;e++)e===8||e===13||e===18||e===23?t+="-":e===14?t+="4":e===19?t+=ou[Math.floor(Math.random()*16)&3|8]:t+=nu();return t}function td(t){let e="";for(let o=0;o<t;o++)e+=nu();return e}var iu={randomUuid:()=>chunk6U66HQKQ_cjs.t(ed()),randomCoin:()=>chunk6U66HQKQ_cjs.t(Math.random()<.5?"heads":"tails"),randomHex:t=>{let e=t[0];if(e?.type!==0)return chunk6U66HQKQ_cjs.P("RANDOM_EXPECTED_COUNT","random hex expects a number of digits");let o=Math.trunc(e.value);return o<0?chunk6U66HQKQ_cjs.P("RANDOM_EXPECTED_COUNT","random hex needs a count of 0 or more"):chunk6U66HQKQ_cjs.t(td(o))},randomPick:t=>t.length===0?chunk6U66HQKQ_cjs.P("RANDOM_PICK_EMPTY","pick needs at least one option"):t[Math.floor(Math.random()*t.length)],randomShuffle:t=>{let e=t[0];if(e?.type!==7)return chunk6U66HQKQ_cjs.P("RANDOM_SHUFFLE_EXPECTED_LIST","shuffle expects a list, e.g. shuffle [1, 2, 3]");let o=e.value;if(o.rows!==1&&o.cols!==1)return chunk6U66HQKQ_cjs.P("RANDOM_SHUFFLE_EXPECTED_LIST","shuffle expects a single row or column, not a full matrix");let r=o.data.slice();for(let n=r.length-1;n>0;n--){let i=Math.floor(Math.random()*(n+1));[r[n],r[i]]=[r[i],r[n]];}return chunk6U66HQKQ_cjs.C(o.rows,o.cols,r)}};function si(t){return {category:"Random",parse(e,o,r){r.emitPluginCall(t,0);}}}function mi(t){return {category:"Random",parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Prefix,r),r.emitPluginCall(t,1);}}}var au={category:"Random",parse(t,e,o){t.consume("LPAREN");let r=0;if(t.peek()?.type!=="RPAREN")for(t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),r++;t.match("COMMA");)t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),r++;t.consume("RPAREN"),o.emitPluginCall("randomPick",r);}};var li={name:"solve-random",phrases:{"random hex":"RANDOM_HEX"},lexerVocabulary:{keywords:{uuid:"UUID",coin:"COIN",shuffle:"SHUFFLE"}},prefixParselets:{UUID:si("randomUuid"),COIN:si("randomCoin"),RANDOM_HEX:mi("randomHex"),SHUFFLE:mi("randomShuffle"),PICK_CALL:au},callFusions:{pick:"PICK_CALL"},pluginFunctions:iu,tokenCategories:{UUID:"function",COIN:"function",RANDOM_HEX:"function",SHUFFLE:"function",PICK_CALL:"function"}};function se(t){return t.reduce((e,o)=>e+o,0)/t.length}function rd(t){let e=se(t);return t.reduce((o,r)=>o+(r-e)*(r-e),0)/t.length}function od(t){return Math.sqrt(rd(t))}function ui(t,e){let o=se(t),r=se(e),n=0,i=0,a=0;for(let l=0;l<t.length;l++){let u=t[l]-o,c=e[l]-r;n+=u*c,i+=u*u,a+=c*c;}let s=Math.sqrt(i*a);return s===0?NaN:n/s}function ci(t,e){let o=se(t),r=se(e),n=0,i=0;for(let a=0;a<t.length;a++){let s=t[a]-o;n+=s*(e[a]-r),i+=s*s;}return i===0?NaN:n/i}function su(t,e){return se(e)-ci(t,e)*se(t)}function mu(t,e){let o=ui(t,e);return o*o}function lu(t,e){let o=[...t].sort((a,s)=>a-s);if(o.length===1)return o[0];let r=e/100*(o.length-1),n=Math.floor(r),i=Math.ceil(r);return n===i?o[n]:o[n]+(r-n)*(o[i]-o[n])}function uu(t,e){let o=od(e);return o===0?NaN:(t-se(e))/o}function nd(t){let e=t<0?-1:1,o=1/(1+.3275911*Math.abs(t)),r=1-((((1.061405429*o-1.453152027)*o+1.421413741)*o-.284496736)*o+.254829592)*o*Math.exp(-t*t);return e*r}function cu(t){return .5*(1+nd(t/Math.SQRT2))}function pu(t){return Math.exp(-0.5*t*t)/Math.sqrt(2*Math.PI)}function So(t){if(!t)return null;if(t.type===7){let e=t.value;return e.hasSymbolic||e.rows!==1&&e.cols!==1?null:e.data.slice()}if(t.type===8){let e=t.value,o=[];for(let r=Math.ceil(e.min);r<=e.max;r++)o.push(r);return o}return t.type===0?[t.value]:null}function ho(t,e){return o=>{let r=So(o[0]),n=So(o[1]);return r===null||n===null?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LISTS",`${t} expects two lists, e.g. ${t} of [1, 2, 3] and [2, 4, 6]`):r.length!==n.length?chunk6U66HQKQ_cjs.P("STAT_LENGTH_MISMATCH",`${t}: the two lists must be the same length (got ${r.length} and ${n.length})`):r.length<2?chunk6U66HQKQ_cjs.P("STAT_TOO_FEW",`${t} needs at least two paired points`):chunk6U66HQKQ_cjs.n(e(r,n))}}var fu={statCorrelation:ho("correlation",ui),statSlope:ho("slope",ci),statIntercept:ho("intercept",su),statRSquared:ho("r squared",mu),statPercentile:t=>{let e=So(t[0]),o=t[1];if(e===null)return chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LIST","percentile expects a list, e.g. percentile([1, 2, 3], 90)");if(e.length===0)return chunk6U66HQKQ_cjs.P("STAT_EMPTY","percentile needs at least one value");if(o?.type!==0)return chunk6U66HQKQ_cjs.P("STAT_EXPECTED_PERCENT","percentile needs a percentage, e.g. percentile([...], 90)");let r=o.value;return r<0||r>100?chunk6U66HQKQ_cjs.P("STAT_PERCENT_RANGE","a percentile is between 0 and 100"):chunk6U66HQKQ_cjs.n(lu(e,r))},statZScore:t=>{let e=t[0],o=So(t[1]);return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","zscore expects a value first, e.g. zscore(5, [1, 2, 3])"):o===null||o.length<2?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_LIST","zscore expects a list of at least two values"):chunk6U66HQKQ_cjs.n(uu(e.value,o))},statNormalCdf:t=>{let e=t[0];return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","normalcdf expects a number"):chunk6U66HQKQ_cjs.n(cu(e.value))},statNormalPdf:t=>{let e=t[0];return e?.type!==0?chunk6U66HQKQ_cjs.P("STAT_EXPECTED_VALUE","normalpdf expects a number"):chunk6U66HQKQ_cjs.n(pu(e.value))}};function Lo(t){return {category:"Statistics",parse(e,o,r){e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),e.consume("AND_CONJ"),e.parseExpression(chunkFVQWN5HZ_cjs.a.Conjunction,r),r.emitPluginCall(t,2);}}}var wo={correlation:"statCorrelation",slope:"statSlope",intercept:"statIntercept",rsquared:"statRSquared",percentile:"statPercentile",zscore:"statZScore",normalcdf:"statNormalCdf",normalpdf:"statNormalPdf"};var vo=class{constructor(){this.category="Statistics";}parse(e,o,r){let n=wo[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown statistics function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var pi={name:"solve-statistics",phrases:{"correlation of":"CORRELATION_OF","slope of":"SLOPE_OF","intercept of":"INTERCEPT_OF"},prefixParselets:{CORRELATION_OF:Lo("statCorrelation"),SLOPE_OF:Lo("statSlope"),INTERCEPT_OF:Lo("statIntercept"),STAT_CALL:new vo},callFusions:Object.fromEntries(Object.keys(wo).map(t=>[t,"STAT_CALL"])),pluginFunctions:fu,tokenCategories:{CORRELATION_OF:"function",SLOPE_OF:"function",INTERCEPT_OF:"function",STAT_CALL:"function"}};var id=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],du={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};function fi(t){if(!Number.isInteger(t)||t<1||t>3999)return null;let e="",o=t;for(let[r,n]of id)for(;o>=r;)e+=n,o-=r;return e}function Eu(t){let e=t.trim().toUpperCase();if(e===""||!/^[MDCLXVI]+$/.test(e))return null;let o=0;for(let r=0;r<e.length;r++){let n=du[e[r]],i=r+1<e.length?du[e[r+1]]:0;o+=n<i?-n:n;}return fi(o)===e?o:null}function Tu(t){if(!Number.isInteger(t))return null;let e=Math.abs(t),o=e%100,r=e%10,n="th";return (o<11||o>13)&&(r===1?n="st":r===2?n="nd":r===3&&(n="rd")),`${t}${n}`}var ko=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],ad=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],sd=["","thousand","million","billion","trillion","quadrillion"];function md(t){if(t<20)return ko[t];let e=Math.floor(t/10),o=t%10;return ad[e]+(o?`-${ko[o]}`:"")}function ld(t){let e=Math.floor(t/100),o=t%100,r=[];return e&&r.push(`${ko[e]} hundred`),o&&(e&&r.push("and"),r.push(md(o))),r.join(" ")}function ud(t){if(t===0)return "zero";let e=[],o=t;for(;o>0;)e.push(o%1e3),o=Math.floor(o/1e3);let r=[];for(let i=e.length-1;i>=0;i--){if(e[i]===0)continue;let a=ld(e[i]);i>0&&(a+=` ${sd[i]}`),r.push({scale:i,group:e[i],words:a});}let n="";for(let i=0;i<r.length;i++){if(i>0){let a=i===r.length-1;n+=a&&r[i].scale===0&&r[i].group<100?" and ":" ";}n+=r[i].words;}return n}function Nu(t){if(!Number.isFinite(t))return null;let e=Math.abs(t).toString();if(e.includes("e")||e.includes("E"))return null;let[o,r]=e.split("."),n=ud(parseInt(o,10));return r&&(n+=" point "+[...r].map(i=>ko[Number(i)]).join(" ")),(t<0?"minus ":"")+n}var Bo=class{constructor(){this.category="Numerals";this.bindingPower=chunkFVQWN5HZ_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("romanFromString",1);}};function di(t,e){return o=>{if(o.type!==0)return chunk6U66HQKQ_cjs.P("NUMERAL_EXPECTED_NUMBER",`"as ${t}" expects a number`);let r=e(o.value);return r===null?chunk6U66HQKQ_cjs.P("NUMERAL_OUT_OF_RANGE",`${o.value} cannot be written as ${t}`):chunk6U66HQKQ_cjs.t(r)}}var Ei={name:"solve-numerals",phrases:{"from roman":"FROM_ROMAN"},asConverters:{roman:di("roman",fi),ordinal:di("ordinal",Tu),words:di("words",Nu)},infixParselets:{FROM_ROMAN:new Bo},pluginFunctions:{romanFromString:t=>{let e=t[0];if(e?.type!==3)return chunk6U66HQKQ_cjs.P("NUMERAL_EXPECTED_TEXT",'"from roman" expects text, e.g. "MMXXIV" from roman');let o=Eu(e.value);return o===null?chunk6U66HQKQ_cjs.P("NUMERAL_INVALID_ROMAN",`"${e.value}" is not a valid Roman numeral`):chunk6U66HQKQ_cjs.n(o)}},tokenCategories:{FROM_ROMAN:"operator"}};function cd(t,e){for(t=Math.abs(t),e=Math.abs(e);e;)[t,e]=[e,t%e];return t}function yu(t){if(t.length<2||t.some(o=>!Number.isInteger(o)||o<=0))return null;let e=t.reduce((o,r)=>cd(o,r),0)||1;return t.map(o=>o/e).join(":")}var gu={category:"Ratio",parse(t,e,o){t.consume("LPAREN");let r=0;if(t.peek()?.type!=="RPAREN")for(t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),r++;t.match("COMMA");)t.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,o),r++;t.consume("RPAREN"),o.emitPluginCall("ratioReduce",r);}};var Ti={name:"solve-ratio",prefixParselets:{RATIO_CALL:gu},callFusions:{ratio:"RATIO_CALL"},pluginFunctions:{ratioReduce:t=>{let e=[];for(let r of t){if(r.type!==0)return chunk6U66HQKQ_cjs.P("RATIO_EXPECTED_NUMBERS","ratio expects whole numbers, e.g. ratio(16, 9)");e.push(r.value);}let o=yu(e);return o===null?chunk6U66HQKQ_cjs.P("RATIO_INVALID","ratio needs at least two whole positive numbers"):chunk6U66HQKQ_cjs.t(o)}},tokenCategories:{RATIO_CALL:"function"}};var Pe=Math.PI;function F(t,e){let o=[];for(let r of e){if(!(r in t))return null;o.push(t[r]);}return o}var Ni=["circle","square","rectangle","triangle","sphere","cube","cylinder","cone"],Pu=["radius","side","width","height","base","length"];function _u(t,e,o){let r=i=>({error:`the ${t} of a ${e} needs its ${i}`}),n={error:`the ${t} of a ${e} is not one of the shapes this supports`};switch(`${t}:${e}`){case "area:circle":{let i=F(o,["radius"]);return i?{value:Pe*i[0]**2}:r("radius")}case "perimeter:circle":case "circumference:circle":{let i=F(o,["radius"]);return i?{value:2*Pe*i[0]}:r("radius")}case "area:square":{let i=F(o,["side"]);return i?{value:i[0]**2}:r("side")}case "perimeter:square":{let i=F(o,["side"]);return i?{value:4*i[0]}:r("side")}case "area:rectangle":{let i=F(o,["width","height"]);return i?{value:i[0]*i[1]}:r("width and height")}case "perimeter:rectangle":{let i=F(o,["width","height"]);return i?{value:2*(i[0]+i[1])}:r("width and height")}case "area:triangle":{let i=F(o,["base","height"]);return i?{value:.5*i[0]*i[1]}:r("base and height")}case "volume:sphere":{let i=F(o,["radius"]);return i?{value:4/3*Pe*i[0]**3}:r("radius")}case "surface:sphere":{let i=F(o,["radius"]);return i?{value:4*Pe*i[0]**2}:r("radius")}case "volume:cube":{let i=F(o,["side"]);return i?{value:i[0]**3}:r("side")}case "surface:cube":{let i=F(o,["side"]);return i?{value:6*i[0]**2}:r("side")}case "volume:cylinder":{let i=F(o,["radius","height"]);return i?{value:Pe*i[0]**2*i[1]}:r("radius and height")}case "surface:cylinder":{let i=F(o,["radius","height"]);return i?{value:2*Pe*i[0]*(i[0]+i[1])}:r("radius and height")}case "volume:cone":{let i=F(o,["radius","height"]);return i?{value:1/3*Pe*i[0]**2*i[1]}:r("radius and height")}default:return n}}var pd=new Set(Ni),fd=new Set(Pu);function Fe(t){return {category:"Geometry",parse(e,o,r){let n=e.peek(),i=(n?.value??"").toLowerCase();if(!n||n.type!=="IDENT"||!pd.has(i))throw chunkNAZ6PGLS_cjs.c.parsing("GEOMETRY_EXPECTED_SHAPE",`Expected a shape (${Ni.join(", ")}) after "${t} of" but got ${n?`"${n.value}"`:"end of input"}`);e.consume(),r.emitOpcode(13),r.emitString(t),r.emitOpcode(13),r.emitString(i);let a=2;for(;;){let s=e.peek(),l=(s?.value??"").toLowerCase();if(!s||s.type!=="IDENT"||!fd.has(l))break;e.consume(),r.emitOpcode(13),r.emitString(l),a++,e.parseExpression(chunkFVQWN5HZ_cjs.a.Call,r),a++,e.peek()?.type==="COMMA"&&e.consume();}r.emitPluginCall("geometryCompute",a);}}}var yi={name:"solve-geometry",phrases:{"area of":"AREA_OF","perimeter of":"PERIMETER_OF","circumference of":"CIRCUMFERENCE_OF","volume of":"VOLUME_OF","surface area of":"SURFACE_AREA_OF"},prefixParselets:{AREA_OF:Fe("area"),PERIMETER_OF:Fe("perimeter"),CIRCUMFERENCE_OF:Fe("circumference"),VOLUME_OF:Fe("volume"),SURFACE_AREA_OF:Fe("surface")},pluginFunctions:{geometryCompute:t=>{let e=String(t[0]?.value??""),o=String(t[1]?.value??""),r={};for(let i=2;i+1<t.length;i+=2){let a=String(t[i]?.value??""),s=t[i+1];if(s?.type===13)return s;r[a]=s?.toNumber()??NaN;}let n=_u(e,o,r);return n.error!==void 0?chunk6U66HQKQ_cjs.P("GEOMETRY_ERROR",n.error):chunk6U66HQKQ_cjs.n(n.value)}},tokenCategories:{AREA_OF:"function",PERIMETER_OF:"function",CIRCUMFERENCE_OF:"function",VOLUME_OF:"function",SURFACE_AREA_OF:"function"}};var dd={"speed of light":{value:299792458,unit:"m/s"},gravity:{value:9.80665,unit:"mps2"},"electron mass":{value:91093837015e-41,unit:"kg"},"proton mass":{value:167262192369e-38,unit:"kg"},avogadro:{value:602214076e15},planck:{value:662607015e-42},boltzmann:{value:1380649e-29},"elementary charge":{value:1602176634e-28},"gas constant":{value:8.314462618},tau:{value:6.283185307179586},"golden ratio":{value:1.618033988749895},phi:{value:1.618033988749895}};function Au(t){return dd[t.toLowerCase()]??null}function G(t){return {category:"Constants",parse(e,o,r){r.emitOpcode(13),r.emitString(t),r.emitPluginCall("constantValue",1);}}}var gi={name:"solve-constants",phrases:{"speed of light":"SPEED_OF_LIGHT","electron mass":"ELECTRON_MASS","proton mass":"PROTON_MASS","elementary charge":"ELEMENTARY_CHARGE","gas constant":"GAS_CONSTANT","golden ratio":"GOLDEN_RATIO"},lexerVocabulary:{keywords:{gravity:"GRAVITY",avogadro:"AVOGADRO",planck:"PLANCK",boltzmann:"BOLTZMANN",tau:"TAU",phi:"PHI"}},prefixParselets:{SPEED_OF_LIGHT:G("speed of light"),ELECTRON_MASS:G("electron mass"),PROTON_MASS:G("proton mass"),ELEMENTARY_CHARGE:G("elementary charge"),GAS_CONSTANT:G("gas constant"),GOLDEN_RATIO:G("golden ratio"),GRAVITY:G("gravity"),AVOGADRO:G("avogadro"),PLANCK:G("planck"),BOLTZMANN:G("boltzmann"),TAU:G("tau"),PHI:G("phi")},pluginFunctions:{constantValue:t=>{let e=t[0]?.type===3?t[0].value:"",o=Au(e);return o===null?chunk6U66HQKQ_cjs.P("UNKNOWN_CONSTANT",`"${e}" is not a known constant`):o.unit?chunk6U66HQKQ_cjs.u(o.value,o.unit):chunk6U66HQKQ_cjs.n(o.value)}},tokenCategories:{SPEED_OF_LIGHT:"keyword",ELECTRON_MASS:"keyword",PROTON_MASS:"keyword",ELEMENTARY_CHARGE:"keyword",GAS_CONSTANT:"keyword",GOLDEN_RATIO:"keyword",GRAVITY:"keyword",AVOGADRO:"keyword",PLANCK:"keyword",BOLTZMANN:"keyword",TAU:"keyword",PHI:"keyword"}};function xu(t,e){return t/(e*e)}function Ou(t,e){return t*60/e}function Ru(t,e){let o=e/t,r=Math.floor(o),n=Math.round((o-r)*60);return n===60&&(r+=1,n=0),`${r}:${n.toString().padStart(2,"0")}`}var Mo={bmi:"healthBmi",pace:"healthPace",speed:"healthSpeed"};var Uo=class{constructor(){this.category="Health";}parse(e,o,r){let n=Mo[o.value];if(n===void 0)throw chunkNAZ6PGLS_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown health function: ${o.value}`,{functionName:o.value});e.consume("LPAREN");let i=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkFVQWN5HZ_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};function He(t){return t?.type===0?t.value:t?.type===6?t.toNumber():null}var Pi={name:"solve-health",prefixParselets:{HEALTH_CALL:new Uo},callFusions:Object.fromEntries(Object.keys(Mo).map(t=>[t,"HEALTH_CALL"])),pluginFunctions:{healthBmi:t=>{let e=He(t[0]),o=He(t[1]);return e===null||o===null||o===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","bmi(weight in kg, height in m), e.g. bmi(70, 1.75)"):chunk6U66HQKQ_cjs.n(xu(e,o))},healthPace:t=>{let e=He(t[0]),o=He(t[1]);return e===null||o===null||e===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","pace(distance in km, time in min), e.g. pace(10, 50)"):chunk6U66HQKQ_cjs.t(`${Ru(e,o)} /km`)},healthSpeed:t=>{let e=He(t[0]),o=He(t[1]);return e===null||o===null||o===0?chunk6U66HQKQ_cjs.P("HEALTH_BAD_INPUT","speed(distance in km, time in min), e.g. speed(10, 50)"):chunk6U66HQKQ_cjs.u(Ou(e,o),"km/h")}},tokenCategories:{HEALTH_CALL:"function"}};var O0=[$o,Wo,jo,en,pn,fn,dn,Pn,An,xn,On,Rn,chunkZ4BXU65Y_cjs.a,In,Cn,hn,Ln,Bn,Gn,Mn,Dn,zn,bn,Yn,Xn,Zn,Jn,ei,ti,Hn,ni,ai,li,pi,Ei,Ti,yi,gi,Pi];
|
|
2
|
+
exports.a=$o;exports.b=Wo;exports.c=jo;exports.d=en;exports.e=pn;exports.f=fn;exports.g=dn;exports.h=Pn;exports.i=_n;exports.j=An;exports.k=xn;exports.l=On;exports.m=Rn;exports.n=In;exports.o=Cn;exports.p=hn;exports.q=Ln;exports.r=Bn;exports.s=Mn;exports.t=Im;exports.u=hm;exports.v=Dn;exports.w=bn;exports.x=Hn;exports.y=O0;//# sourceMappingURL=chunk-7EMZOBGW.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-7EMZOBGW.cjs.map
|