solve-engine 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -32
- package/dist/{Configuration-BGQn-cJ8.d.cts → Configuration-DnzYPmoK.d.cts} +33 -0
- package/dist/{Configuration-BGQn-cJ8.d.ts → Configuration-DnzYPmoK.d.ts} +33 -0
- package/dist/{EngineError-DTk7I7hZ.d.cts → EngineError-D1kXsjIj.d.cts} +4 -0
- package/dist/{EngineError-DTk7I7hZ.d.ts → EngineError-D1kXsjIj.d.ts} +4 -0
- package/dist/{PackageCompatibility-BGXSFuL9.d.ts → PackageCompatibility-Bq82y0ZN.d.ts} +1 -1
- package/dist/{PackageCompatibility-BZCqaTOO.d.cts → PackageCompatibility-CeAPVHZr.d.cts} +1 -1
- package/dist/{PackageRegistry-rMGnTh7W.d.cts → PackageRegistry-B9-7fJGH.d.cts} +16 -11
- package/dist/{PackageRegistry-BRoVOYzg.d.ts → PackageRegistry-CDEgfhT_.d.ts} +16 -11
- package/dist/{Parselet-Bkbp9CKD.d.cts → Parselet-4oH5OuRt.d.cts} +1 -1
- package/dist/{Parselet-B-WyUtX4.d.ts → Parselet-BwDqKFfK.d.ts} +1 -1
- package/dist/{ScopeManager-gB9UengK.d.ts → ScopeManager-BQBhlDAu.d.ts} +38 -7
- package/dist/{ScopeManager-bCYewWVt.d.cts → ScopeManager-DrXB3Nvm.d.cts} +38 -7
- package/dist/{VMCheckpoints-DGar9Yg8.d.cts → VMCheckpoints-BK32PTl2.d.cts} +2 -2
- package/dist/{VMCheckpoints-BDRY1Kx8.d.ts → VMCheckpoints-C5jC92o3.d.ts} +2 -2
- package/dist/{Value-DCTqTSeP.d.cts → Value-Ds3Gy07C.d.cts} +1 -1
- package/dist/{Value-DCTqTSeP.d.ts → Value-Ds3Gy07C.d.ts} +1 -1
- package/dist/{WorkerError-DpZgKRks.d.ts → WorkerError-CVQbs6_D.d.ts} +1 -1
- package/dist/{WorkerError-DGBNM3gA.d.cts → WorkerError-DaNWQFp1.d.cts} +1 -1
- package/dist/chunk-2BXNZM3G.js +2 -0
- package/dist/chunk-2BXNZM3G.js.map +1 -0
- package/dist/chunk-2JSNWYYA.cjs +3 -0
- package/dist/chunk-2JSNWYYA.cjs.map +1 -0
- package/dist/{chunk-J7ABVGZH.cjs → chunk-2VE4OW4A.cjs} +2 -2
- package/dist/{chunk-J7ABVGZH.cjs.map → chunk-2VE4OW4A.cjs.map} +1 -1
- package/dist/{chunk-HMC7FJO7.js → chunk-3SHWTGTP.js} +2 -2
- package/dist/{chunk-HMC7FJO7.js.map → chunk-3SHWTGTP.js.map} +1 -1
- package/dist/{chunk-EN3CDYOS.cjs → chunk-5GL4SAVH.cjs} +2 -2
- package/dist/{chunk-EN3CDYOS.cjs.map → chunk-5GL4SAVH.cjs.map} +1 -1
- package/dist/{chunk-SGIDBZ4T.cjs → chunk-72N3ZRVE.cjs} +2 -2
- package/dist/chunk-72N3ZRVE.cjs.map +1 -0
- package/dist/{chunk-CHSO3DCS.js → chunk-7EP36NXE.js} +3 -3
- package/dist/{chunk-CHSO3DCS.js.map → chunk-7EP36NXE.js.map} +1 -1
- package/dist/chunk-A4JV7HRB.js +3 -0
- package/dist/chunk-A4JV7HRB.js.map +1 -0
- package/dist/chunk-AUOE7MFI.cjs +2 -0
- package/dist/chunk-AUOE7MFI.cjs.map +1 -0
- package/dist/chunk-BDF4VCQX.js +3 -0
- package/dist/chunk-BDF4VCQX.js.map +1 -0
- package/dist/{chunk-3SSMOVWB.cjs → chunk-CDNJZBM3.cjs} +2 -2
- package/dist/{chunk-3SSMOVWB.cjs.map → chunk-CDNJZBM3.cjs.map} +1 -1
- package/dist/{chunk-YAONCEAW.cjs → chunk-CMZSK6FY.cjs} +3 -3
- package/dist/{chunk-YAONCEAW.cjs.map → chunk-CMZSK6FY.cjs.map} +1 -1
- package/dist/chunk-D2Q2VFJ6.js +2 -0
- package/dist/chunk-D2Q2VFJ6.js.map +1 -0
- package/dist/{chunk-75JLWK4L.cjs → chunk-DA7M6H63.cjs} +2 -2
- package/dist/{chunk-75JLWK4L.cjs.map → chunk-DA7M6H63.cjs.map} +1 -1
- package/dist/chunk-ELQQKZN3.cjs +3 -0
- package/dist/{chunk-PIZQIQVM.js.map → chunk-ELQQKZN3.cjs.map} +1 -1
- package/dist/chunk-F7QIBC4B.cjs +3 -0
- package/dist/chunk-F7QIBC4B.cjs.map +1 -0
- package/dist/chunk-GP4H5OIT.js +3 -0
- package/dist/chunk-GP4H5OIT.js.map +1 -0
- package/dist/chunk-HQ7BKXG7.js +2 -0
- package/dist/chunk-HQ7BKXG7.js.map +1 -0
- package/dist/{chunk-KRXO3MOW.cjs → chunk-IHAZL4EF.cjs} +2 -2
- package/dist/chunk-IHAZL4EF.cjs.map +1 -0
- package/dist/{chunk-7E7NXKQ5.js → chunk-IJHL3LMH.js} +2 -2
- package/dist/chunk-IJHL3LMH.js.map +1 -0
- package/dist/{chunk-3GR46UOX.js → chunk-IPSOWFCA.js} +2 -2
- package/dist/{chunk-3GR46UOX.js.map → chunk-IPSOWFCA.js.map} +1 -1
- package/dist/chunk-LM6ZQUEU.js +2 -0
- package/dist/chunk-LM6ZQUEU.js.map +1 -0
- package/dist/{chunk-N37PUZJR.cjs → chunk-LTJV3VJE.cjs} +2 -2
- package/dist/{chunk-N37PUZJR.cjs.map → chunk-LTJV3VJE.cjs.map} +1 -1
- package/dist/chunk-MWWAKZOD.cjs +3 -0
- package/dist/chunk-MWWAKZOD.cjs.map +1 -0
- package/dist/chunk-NUF66H57.js +5 -0
- package/dist/chunk-NUF66H57.js.map +1 -0
- package/dist/{chunk-MRRMIBHE.js → chunk-OMHRBKAT.js} +2 -2
- package/dist/{chunk-MRRMIBHE.js.map → chunk-OMHRBKAT.js.map} +1 -1
- package/dist/{chunk-4ETS224G.js → chunk-PTQCHMYA.js} +2 -2
- package/dist/{chunk-4ETS224G.js.map → chunk-PTQCHMYA.js.map} +1 -1
- package/dist/{chunk-4DJJIUQF.js → chunk-PWWQZFAE.js} +2 -2
- package/dist/chunk-PWWQZFAE.js.map +1 -0
- package/dist/chunk-RE6AIU6Y.js +3 -0
- package/dist/chunk-RE6AIU6Y.js.map +1 -0
- package/dist/chunk-RECRD45C.cjs +5 -0
- package/dist/chunk-RECRD45C.cjs.map +1 -0
- package/dist/{chunk-O3BDXOQJ.js → chunk-RENO2AWO.js} +2 -2
- package/dist/{chunk-O3BDXOQJ.js.map → chunk-RENO2AWO.js.map} +1 -1
- package/dist/chunk-RMCN5WFO.cjs +2 -0
- package/dist/chunk-RMCN5WFO.cjs.map +1 -0
- package/dist/{chunk-TL545PXW.cjs → chunk-RN3ISTM3.cjs} +2 -2
- package/dist/{chunk-TL545PXW.cjs.map → chunk-RN3ISTM3.cjs.map} +1 -1
- package/dist/{chunk-JYLNQOPU.cjs → chunk-S46R5QZP.cjs} +2 -2
- package/dist/{chunk-JYLNQOPU.cjs.map → chunk-S46R5QZP.cjs.map} +1 -1
- package/dist/{chunk-USQ4KL6S.cjs → chunk-UPH22K2T.cjs} +2 -2
- package/dist/chunk-UPH22K2T.cjs.map +1 -0
- package/dist/{chunk-KEA5HRL3.js → chunk-UXR7JIPX.js} +2 -2
- package/dist/{chunk-KEA5HRL3.js.map → chunk-UXR7JIPX.js.map} +1 -1
- package/dist/chunk-UY3ID6JF.cjs +2 -0
- package/dist/chunk-UY3ID6JF.cjs.map +1 -0
- package/dist/{chunk-JVMINMAB.js → chunk-WFOQRPA6.js} +2 -2
- package/dist/{chunk-JVMINMAB.js.map → chunk-WFOQRPA6.js.map} +1 -1
- package/dist/{chunk-AF7HQN6I.js → chunk-XFJABR3B.js} +2 -2
- package/dist/chunk-XFJABR3B.js.map +1 -0
- package/dist/{chunk-LNZNJSRW.cjs → chunk-ZVPZQ66D.cjs} +2 -2
- package/dist/chunk-ZVPZQ66D.cjs.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +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.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +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 +14 -8
- package/dist/normalizer.d.ts +14 -8
- 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-B4wf3M1h.d.cts → pipeline-69q2tsLE.d.cts} +1 -1
- package/dist/{pipeline-QIT4iD8f.d.ts → pipeline-DTqGLPsV.d.ts} +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +18 -2
- package/dist/resolvers.d.ts +18 -2
- package/dist/resolvers.js +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 +7 -7
- package/dist/vm.d.ts +7 -7
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +31 -22
- package/dist/worker.d.ts +31 -22
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-42JXN3BH.js +0 -5
- package/dist/chunk-42JXN3BH.js.map +0 -1
- package/dist/chunk-4DJJIUQF.js.map +0 -1
- package/dist/chunk-6YM67DWH.cjs +0 -3
- package/dist/chunk-6YM67DWH.cjs.map +0 -1
- package/dist/chunk-7E7NXKQ5.js.map +0 -1
- package/dist/chunk-7SZBEE5R.cjs +0 -2
- package/dist/chunk-7SZBEE5R.cjs.map +0 -1
- package/dist/chunk-A5M4QZIK.js +0 -2
- package/dist/chunk-A5M4QZIK.js.map +0 -1
- package/dist/chunk-AF7HQN6I.js.map +0 -1
- package/dist/chunk-ALY4ZMYO.js +0 -2
- package/dist/chunk-ALY4ZMYO.js.map +0 -1
- package/dist/chunk-BRJ4RT5U.js +0 -2
- package/dist/chunk-BRJ4RT5U.js.map +0 -1
- package/dist/chunk-CO2BI6WL.cjs +0 -3
- package/dist/chunk-CO2BI6WL.cjs.map +0 -1
- package/dist/chunk-EQDT42JG.js +0 -3
- package/dist/chunk-EQDT42JG.js.map +0 -1
- package/dist/chunk-FMMT5C5H.cjs +0 -3
- package/dist/chunk-FMMT5C5H.cjs.map +0 -1
- package/dist/chunk-FP6Z6PYR.js +0 -2
- package/dist/chunk-FP6Z6PYR.js.map +0 -1
- package/dist/chunk-H3JXNH7X.cjs +0 -3
- package/dist/chunk-H3JXNH7X.cjs.map +0 -1
- package/dist/chunk-HZOLIL5T.js +0 -3
- package/dist/chunk-HZOLIL5T.js.map +0 -1
- package/dist/chunk-KRXO3MOW.cjs.map +0 -1
- package/dist/chunk-KVLJDOZ7.cjs +0 -5
- package/dist/chunk-KVLJDOZ7.cjs.map +0 -1
- package/dist/chunk-LNZNJSRW.cjs.map +0 -1
- package/dist/chunk-PIZQIQVM.js +0 -3
- package/dist/chunk-QTSDIDAS.js +0 -3
- package/dist/chunk-QTSDIDAS.js.map +0 -1
- package/dist/chunk-SGIDBZ4T.cjs.map +0 -1
- package/dist/chunk-UNKSCVIL.cjs +0 -2
- package/dist/chunk-UNKSCVIL.cjs.map +0 -1
- package/dist/chunk-USQ4KL6S.cjs.map +0 -1
- package/dist/chunk-XDXIPVZB.cjs +0 -2
- package/dist/chunk-XDXIPVZB.cjs.map +0 -1
package/dist/chunk-FMMT5C5H.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkTL545PXW_cjs=require('./chunk-TL545PXW.cjs'),chunkN37PUZJR_cjs=require('./chunk-N37PUZJR.cjs'),chunkEN3CDYOS_cjs=require('./chunk-EN3CDYOS.cjs'),chunkSGIDBZ4T_cjs=require('./chunk-SGIDBZ4T.cjs'),chunkUURM7P3P_cjs=require('./chunk-UURM7P3P.cjs'),chunkZLRJ7TDP_cjs=require('./chunk-ZLRJ7TDP.cjs'),chunkXDXIPVZB_cjs=require('./chunk-XDXIPVZB.cjs'),chunk6YM67DWH_cjs=require('./chunk-6YM67DWH.cjs'),chunkTLG7VZRX_cjs=require('./chunk-TLG7VZRX.cjs'),chunk5TVI2UPZ_cjs=require('./chunk-5TVI2UPZ.cjs'),chunkJ7ABVGZH_cjs=require('./chunk-J7ABVGZH.cjs'),chunk75JLWK4L_cjs=require('./chunk-75JLWK4L.cjs'),chunkZKFCKAIX_cjs=require('./chunk-ZKFCKAIX.cjs'),chunkUSQ4KL6S_cjs=require('./chunk-USQ4KL6S.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkJ4LSAHCY_cjs=require('./chunk-J4LSAHCY.cjs'),chunkEZKR44MA_cjs=require('./chunk-EZKR44MA.cjs'),chunkCO2BI6WL_cjs=require('./chunk-CO2BI6WL.cjs');var Gu=/^\d{1,3}(\.\d{3}){2,}$/,zu=/^\d*\.\d*$/,It=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 chunkCO2BI6WL_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 chunkCO2BI6WL_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 chunkCO2BI6WL_cjs.c.parsing("INVALID_NUMBER_LITERAL",`Invalid octal literal: "${a}"`,{raw:a})}else if(Gu.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),zu.test(c)&&(i=c);}if(i!==null){r.emitOpcode(16),r.emitString(i);return}r.emitOpcode(10),r.emitNumber(n);}};var he=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 Ct=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 We=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 Ku={k:3,M:6,G:9,B:9,T:12},$u={thousand:3,thousands:3,million:6,millions:6,mn:6,billion:9,billions:9,bn:9,trillion:12,trillions:12,tn:12},Wu=/^\d+(\.\d+)?$/;function Yu(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 Ia(t=65){return {name:"arithmetic:large-number-suffix",priority:t,shape:[{types:["NUMBER"]},{types:["IDENT","UNIT"]}],match(e,o){let r=e[o];if(r.type!=="NUMBER"||!Wu.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:$u[n.value.toLowerCase()],s=i?Ku[n.value]??a:a;if(s===void 0)return null;let l=Yu(r.text,s);return {consumed:2,replacement:[chunkSGIDBZ4T_cjs.b("NUMBER",l,e.slice(o,o+2))],ruleName:"arithmetic:large-number-suffix"}}}}var Qo={name:"solve-arithmetic",prefixParselets:{NUMBER:new It,LPAREN:new Ct,PI:new We,E:new We,PLUS:new he(27),MINUS:new he(26),BIT_NOT:new he(36)},infixParselets:{PLUS:new k(chunkEN3CDYOS_cjs.a.Sum,20),AND_CONJ:new k(chunkEN3CDYOS_cjs.a.Conjunction,20),MINUS:new k(chunkEN3CDYOS_cjs.a.Sum,21),STAR:new k(chunkEN3CDYOS_cjs.a.Product,22),SLASH:new k(chunkEN3CDYOS_cjs.a.Product,23),MOD:new k(chunkEN3CDYOS_cjs.a.Product,24),CARET:new k(chunkEN3CDYOS_cjs.a.Exponent,25,true),TIMES_BY:new k(chunkEN3CDYOS_cjs.a.Product,22),MULTIPLY_BY:new k(chunkEN3CDYOS_cjs.a.Product,22),DIVIDE_BY:new k(chunkEN3CDYOS_cjs.a.Product,23),LSHIFT:new k(chunkEN3CDYOS_cjs.a.Shift,30),RSHIFT:new k(chunkEN3CDYOS_cjs.a.Shift,31),URSHIFT:new k(chunkEN3CDYOS_cjs.a.Shift,32),BIT_AND:new k(chunkEN3CDYOS_cjs.a.BitwiseAnd,33),BIT_OR:new k(chunkEN3CDYOS_cjs.a.BitwiseOr,34),BIT_XOR:new k(chunkEN3CDYOS_cjs.a.BitwiseXor,35)},normalizerRules:[Ia()]};var St=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Prefix;}parse(e,o,r,n){n.emitOpcode(10),n.emitNumber(100),n.emitOpcode(23),n.emitOpcode(74);}};var Lt=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){if(La(e,"what")){e.consume(),this.parseWhatRate(e,n);return}this.parseWhatBase(e,n);}parseWhatRate(e,o){if(!e.match("PERCENT"))throw chunkCO2BI6WL_cjs.c.parsing("IS_WHAT_EXPECTED_PERCENT",'Expected "%" after "is what", as in "20 is what % of 200"');let r=ju(e);if(r===null){o.emitOpcode(74);return}e.parseExpression(chunkEN3CDYOS_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(chunkEN3CDYOS_cjs.a.Conditional,o),e.match("TO")){Sa(e,"what",'"81 is 9 to what power"'),Sa(e,"power",'"81 is 9 to what power"'),o.emitOpcode(51),o.emitIndex(Ca),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(51),o.emitIndex(Ca),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 chunkCO2BI6WL_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);}},Ca=5;function La(t,e){return (t.peek()?.text??"").toLowerCase()===e}function Sa(t,e,o){if(!La(t,e))throw chunkCO2BI6WL_cjs.c.parsing("IS_WHAT_EXPECTED_WORD",`Expected "${e}" here, as in ${o}`);t.consume();}function ju(t){if(t.match("OF"))return "of";let e=(t.peek()?.text??"").toLowerCase();return e==="off"||e==="on"?(t.consume(),e):null}var Ye=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_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 wa(t=68){return {name:"percentage:on-off",priority:t,shape:[{types:["PERCENT"]},{types:["IDENT"],values:["on","off"]}],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],chunkSGIDBZ4T_cjs.b(n==="on"?"PCT_ON":"PCT_OFF",n,[r])],ruleName:"percentage:on-off"}}}}var wt=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(22);}};var vt=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(2),n.emitOpcode(23);}};var je=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkEN3CDYOS_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 Xe=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 Qe=class{constructor(e){this.multiplier=e;this.category="Percentage";this.bindingPower=chunkEN3CDYOS_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 kt=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_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")&&chunkJ4LSAHCY_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 Xu={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 Qu(t){if(t.type==="NUMBER"){let e=Number(t.value);return Number.isInteger(e)&&e>=0?e:null}return t.type==="IDENT"?Xu[t.value.toLowerCase()]??null:null}var qe=class{constructor(e){this.sign=e;this.category="Percentage";this.bindingPower=chunkEN3CDYOS_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=Qu(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 va(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:chunkSGIDBZ4T_cjs.b(r==="up"?"PCT_UP":"PCT_DOWN",r,[o])}function ka(t=68){return {name:"percentage:up-down",priority:t,shape:[{types:["NUMBER","RPAREN","IDENT"]}],match(e,o){let r=e[o];if(r&&(r.type==="NUMBER"||r.type==="RPAREN")){let i=va(e,o+1);if(i)return {consumed:2,replacement:[r,i],ruleName:"percentage:up-down"}}let n=va(e,o);return n?{consumed:1,replacement:[n],ruleName:"percentage:up-down"}:null}}}var qo={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 St,IS:new Lt,PCT_ON:new Ye(1),PCT_OFF:new Ye(-1),OF:new wt,OF_WHAT_IS:new vt,ON_WHAT_IS:new je(1),OFF_WHAT_IS:new je(-1),TO:new kt,INCREASE_BY:new Qe(1),DECREASE_BY:new Qe(-1),PCT_UP:new qe(1),PCT_DOWN:new qe(-1)},prefixParselets:{INCREASE:new Xe(1),DECREASE:new Xe(-1)},normalizerRules:[wa(),ka()]};var Zo={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},Mt=class{constructor(){this.category="Function";}parse(e,o,r){let n=o.value.toLowerCase(),i=Zo[n];if(i===void 0)throw chunkCO2BI6WL_cjs.c.execution("UNKNOWN_FUNCTION",`Unknown function: ${n}`,{functionName:n});e.consume("LPAREN");let a=0;if(e.peek()?.type!=="RPAREN")for(e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),a++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_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 Mt}};var fe=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 qu={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},Ze=class{constructor(e){this.direction=e;this.category="Date/Time";}parse(e,o,r){let n=e.peek(),i=n?qu[n.type]:void 0;if(i===void 0)throw chunkCO2BI6WL_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 Je=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 Bt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(0,r),r.emitPluginCall("workdaysInDuration",1);}};var et=class{constructor(e){this.direction=e;this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Sum,n),n.emitOpcode(96),n.emitByte(this.direction==="backward"?1:0);}};var Ut=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkEN3CDYOS_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 Dt=class{constructor(){this.category="Date/Time";}parse(e,o,r){let n=o.value;e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitPluginCall("spanBetweenDates",2),r.emitOpcode(13),r.emitString(n),r.emitOpcode(84);}};var tt=class{constructor(e){this.functionName=e;this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_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 Vt=class{constructor(){this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toDateFromAny",1);}};var Ft=class{constructor(){this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toTimestampFromAny",1);}};var Ht=class{constructor(){this.category="Date/Time";}parse(e,o,r){r.emitOpcode(95),r.emitNumber(Number(o.value));}};var Gt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.consume("OF"),e.parseExpression(chunkEN3CDYOS_cjs.a.Postfix,r),r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("nthWeekdayOfMonth",2);}};var Ie=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 Zu=new Set(["year","years","month","months","day","days"]),zt=class{constructor(){this.category="Date/Time";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Postfix,r),this.wordIs(e.peek(),"on")?(e.consume(),e.parseExpression(chunkEN3CDYOS_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"&&Zu.has(n))o=true,e.consume();else if(r.type==="COMMA"||r.type==="AND_CONJ"||n==="and")e.consume();else break}return o}};function Ju(t){let e=t[0],o;if(e.type===6&&e.unit){if(chunkZKFCKAIX_cjs.c(e.unit)!=="time")return chunk75JLWK4L_cjs.P("WORKDAYS_IN_EXPECTED_DURATION",`"workdays in" expects a time duration, got unit "${e.unit}"`);o=chunkZKFCKAIX_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 chunk75JLWK4L_cjs.n(s)}var ec=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function rt(t,e){return t.type===4?t.toNumber():chunk75JLWK4L_cjs.P("DATE_FIELD_EXPECTED_DATE",`"${e}" expects a date, got ${chunk75JLWK4L_cjs.g[t.type]??"an unsupported value"}`)}function tc(t){let e=rt(t[0],"weekday");return typeof e!="number"?e:chunk75JLWK4L_cjs.t(ec[new Date(e).getDay()])}var rc=["January","February","March","April","May","June","July","August","September","October","November","December"];function oc(t){let e=rt(t[0],"month");return typeof e!="number"?e:chunk75JLWK4L_cjs.t(rc[new Date(e).getMonth()])}function nc(t){let e=rt(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 chunk75JLWK4L_cjs.n(Math.floor(a/7)+1)}function Ma(t){let e=new Date(t).getDay();return e===0||e===6}function ic(t){let e=rt(t[0],"is a weekend");return typeof e!="number"?e:chunk75JLWK4L_cjs.L(Ma(e))}function ac(t){let e=rt(t[0],"is a workday");return typeof e!="number"?e:chunk75JLWK4L_cjs.L(!Ma(e))}function sc(t){return chunk75JLWK4L_cjs.u(Math.abs(t[0].toNumber()-t[1].toNumber()),"ms")}function mc(t){let e=t[0];if(e.type===4)return e;if(e.type===3){let o=chunkN37PUZJR_cjs.c(e.value);return o===null?chunk75JLWK4L_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk75JLWK4L_cjs.M(o)}return chunk75JLWK4L_cjs.M(chunkN37PUZJR_cjs.e(e.toNumber()))}function lc(t){let e=t[0];if(e.type===3){let o=chunkN37PUZJR_cjs.c(e.value);return o===null?chunk75JLWK4L_cjs.P("INVALID_ISO8601_STRING",`"${e.value}" is not a recognizable ISO8601 date/time string`):chunk75JLWK4L_cjs.n(Math.floor(o/1e3))}return chunk75JLWK4L_cjs.n(Math.floor(e.toNumber()/1e3))}var Ba=Ju,en=tc,tn=oc,rn=nc,Ua=ic,Da=ac,ba=sc,Va=mc,Fa=lc;function on(t,e){return new Date(t,e+1,0).getDate()}function za(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>on(t,e)?null:new Date(t,e,a).getTime()}function Ka(t,e,o){let r=on(t,e),i=(new Date(t,e,r).getDay()-o+7)%7;return new Date(t,e,r-i).getTime()}function $a(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 Ha(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(),on(n,i));return new Date(n,i,a)}function Ga(t){return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)}function Wa(t,e){let o=new Date(t),r=new Date(e),n=(r.getFullYear()-o.getFullYear())*12+(r.getMonth()-o.getMonth());Ha(o,n)>r&&n--;let i=Ha(o,n),a=Ga(r)-Ga(i);return {years:Math.floor(n/12),months:n%12,days:a}}function Ya(t,e){let o=new Date(t);return new Date(o.getFullYear(),o.getMonth()+e,1).getTime()}function $t(t,e){return t.type===4?t.toNumber():chunk75JLWK4L_cjs.P("DATE_EXPECTED",`"${e}" expects a date, got ${chunk75JLWK4L_cjs.g[t.type]??"an unsupported value"}`)}function uc(t){let e=$t(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 chunk75JLWK4L_cjs.M(Ka(s,l,i));let u=Number(r),c=za(s,l,i,u);return c===null?chunk75JLWK4L_cjs.P("NTH_WEEKDAY_OUT_OF_RANGE",`there is no ${r}${cc(u)} occurrence of that weekday in the month`):chunk75JLWK4L_cjs.M(c)}function cc(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 pc(t){let e=$t(t[0],"month anchor");if(typeof e!="number")return e;let o=t[1].toNumber();return chunk75JLWK4L_cjs.M(Ya(e,o))}var fc="ymd";function dc(t){let e=$t(t[0],"age of");if(typeof e!="number")return e;let o=$t(t[1],"age of");return typeof o!="number"?o:String(t[2].value??"years")===fc?chunk75JLWK4L_cjs.t(Ec(Wa(e,o))):chunk75JLWK4L_cjs.u($a(e,o),"years")}function Ec(t){let e=[];return t.years!==0&&e.push(Kt(t.years,"year")),t.months!==0&&e.push(Kt(t.months,"month")),t.days!==0&&e.push(Kt(t.days,"day")),e.length===0?Kt(0,"day"):e.join(", ")}function Kt(t,e){return `${t} ${e}${Math.abs(t)===1?"":"s"}`}var ja=uc,Xa=pc,Qa=dc;var Tc={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},qa="NTH_WEEKDAY",Nc=chunk5IJD5L3O_cjs.c(qa),yc=/^(\d+)(st|nd|rd|th)$/i;function Za(t=66){let e="datetime:nth-weekday";return {name:e,priority:t,unshapedReason:"Reads an ordinal that may be the LAST keyword, a number, or a word like `third`, so no fixed first-token set describes it.",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=yc.exec(N);if(!E)return null;i=String(Number(E[1])),a=2;}let s=o[r+a],l=s?Tc[s.type]:void 0;if(l===void 0||o[r+a+1]?.type!=="OF")return null;let u=`${i}:${l}`,c=new chunkUSQ4KL6S_cjs.a(qa,Nc,u,u,n.offset,0,n.line,n.col);return {consumed:a+1,replacement:[c],ruleName:e}}}}function Ja(t=60){return {name:"datetime:until-since",priority:t,shape:[{types:["UNIT"]},{types:["UNTIL","SINCE"]}],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:[chunkSGIDBZ4T_cjs.b(i,r.value,[r,n])],ruleName:`datetime:${n.type.toLowerCase()}`}}}}function es(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:[chunkSGIDBZ4T_cjs.b("BETWEEN_UNIT",i.value,u)],ruleName:"datetime:between"}}}}function ts(t=70){return {name:"datetime:workday-rate-denominator",priority:t,shape:[{types:["SLASH"]},{types:["UNIT"],values:["workday","workdays"]}],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 gc={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 rs(t){return t===void 0||t.type!=="IDENT"&&t.type!=="UNIT"?0:gc[(t.text??t.value??"").toLowerCase()]??0}var ot=/^\d+$/;function Wt(t){return t.length===4}function os(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"&&ot.test(n.text??"")){let c=rs(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"&&ot.test(T.text??"")&&Wt(T.text??"")?chunkN37PUZJR_cjs.g(f,c,Number(T.text),e.slice(o,o+3),r):chunkN37PUZJR_cjs.g(f,c,new Date().getFullYear(),e.slice(o,o+2),r)}let i=rs(n);if(i===0)return null;let a=e[o+1];if(a?.type!=="NUMBER"||!ot.test(a.text??""))return null;if(Wt(a.text??""))return chunkN37PUZJR_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"&&ot.test(u.text??"")&&Wt(u.text??"")?chunkN37PUZJR_cjs.g(s,i,Number(u.text),e.slice(o,o+4),r):l?.type==="NUMBER"&&ot.test(l.text??"")&&Wt(l.text??"")?chunkN37PUZJR_cjs.g(s,i,Number(l.text),e.slice(o,o+3),r):chunkN37PUZJR_cjs.g(s,i,new Date().getFullYear(),e.slice(o,o+2),r)}}}var Pc=93,_c={q1:[1,3],q2:[4,6],q3:[7,9],q4:[10,12]};function nn(t,e){return new Date(t,e,0).getDate()}function Ac(t){return nn(t,2)===29?366:365}var Yt=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(Pc),r.emitIndex(1);}readPeriodDays(e){let o=e.peek(),r=(o?.text??o?.value??"").toLowerCase(),n=_c[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+=nn(a,l);return s}if(o?.type==="DATETIME_LITERAL"){e.consume();let a=new Date(Number(o.value));return nn(a.getFullYear(),a.getMonth()+1)}let i=this.readOptionalYear(e);if(i!==null)return Ac(i);throw chunkCO2BI6WL_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 xc=new Set(["q1","q2","q3","q4"]),Rc=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 Oc(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"?xc.has(e)||Rc.has(e):t.type==="NUMBER"&&/^\d{4}$/.test(t.text??"")}function ns(t=60){return {name:"datetime:days-in-period",priority:t,shape:[{types:["UNIT","IDENT"],values:["days"]},{types:["IN"]}],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"||!Oc(e[o+2])?null:{consumed:2,replacement:[chunkSGIDBZ4T_cjs.b("DAYS_IN_PERIOD","days in",[r,e[o+1]])],ruleName:"datetime:days-in-period"}}}}function is(){return {name:"datetime:daily-note-link",priority:80,shape:[{types:["LBRACKET"]},{types:["LBRACKET"]}],match(t,e){return t[e]?.type!=="LBRACKET"||t[e+1]?.type!=="LBRACKET"||t[e+2]?.type!==chunkN37PUZJR_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 an={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 Yt,NOW:new fe(0),TODAY:new fe(0),TOMORROW:new fe(1),YESTERDAY:new fe(-1),NEXT:new Ze("next"),LAST:new Ze("last"),UNTIL_UNIT:new Je("until"),SINCE_UNIT:new Je("since"),WORKDAYS_IN:new Bt,WORKDAYS_BETWEEN:new Ut,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 Dt,CURRENT_TIMESTAMP:new bt,DATETIME_LITERAL:new Ht,NTH_WEEKDAY:new Gt,AGE_OF:new zt,MONTH_ANCHOR_NEXT:new Ie(1),MONTH_ANCHOR_THIS:new Ie(0),MONTH_ANCHOR_LAST:new Ie(-1)},infixParselets:{WORKDAYS_AFTER:new et("forward"),WORKDAYS_BEFORE:new et("backward"),TO_DATE:new Vt,TO_TIMESTAMP:new Ft,IS_WEEKEND:new tt("isWeekendOnDate"),IS_WORKDAY:new tt("isWorkdayOnDate")},normalizerRules:[Ja(),es(),ts(),os(),Za(),ns(),is()],pluginFunctions:{workdaysInDuration:Ba,weekdayOnDate:en,toDateFromAny:Va,toTimestampFromAny:Fa,monthOnDate:tn,weekOnDate:rn,isWeekendOnDate:Ua,isWorkdayOnDate:Da,spanBetweenDates:ba,nthWeekdayOfMonth:ja,monthAnchorShift:Xa,ageBetween:Qa},asConverters:{iso8601:t=>chunk75JLWK4L_cjs.t(chunkN37PUZJR_cjs.d(t.toNumber())),weekday:t=>en([t]),month:t=>tn([t]),week:t=>rn([t])},tokenCategories:{NTH_WEEKDAY:"datetime",MONTH_ANCHOR_NEXT:"datetime",MONTH_ANCHOR_THIS:"datetime",MONTH_ANCHOR_LAST:"datetime",AGE_OF:"keyword"}};var hc={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"},sn={"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"},Ic={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"},as={...hc,...sn,...Ic};var mn="UTCOFFSET:";function ln(t){return `${mn}${t}`}function nt(t){return t.startsWith(mn)}function it(t){return parseInt(t.slice(mn.length),10)}function jt(t,e){if(nt(t))return it(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 ms(t,e,o,r,n,i){let a=Date.UTC(t,e,o,r,n,0),s=jt(i,a);return a-s*6e4}function un(t,e){if(nt(e)){let r=it(e)*6e4;return Cc(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:true}).format(new Date(t))}function ls(t,e){if(nt(e)){let r=it(e)*6e4;return Sc(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"long",day:"numeric"}).format(new Date(t))}function ss(t,e){if(nt(e)){let n=new Date(t+it(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 us(t,e,o){let r=ss(t,e),n=ss(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 Cc(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",hour:"numeric",minute:"2-digit",hour12:true}).format(t)}function Sc(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",year:"numeric",month:"long",day:"numeric"}).format(t)}function cn(t){if(nt(t)){let o=it(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 ie(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=ln(s?-u:u);return {zoneRef:c,displayName:cn(c)}}let a=ln(0);return {zoneRef:a,displayName:cn(a)}}let n=as[r];if(n){t.consume();let i=o.replace(/\b\w/g,a=>a.toUpperCase());return {zoneRef:n,displayName:i}}return null}var Xt="zoneConvert",pn="timeInZone",fn="dateInZone",Qt="timeDifference";function cs(t){let e=t[0].toNumber(),o=t[1].value,r=t[2].value,n=new Date,i=ms(n.getFullYear(),n.getMonth(),n.getDate(),Math.floor(e/60),e%60,o),a=un(i,r),s=us(i,r,o);if(s===0)return chunk75JLWK4L_cjs.t(a);let l=s>0?"+":"";return chunk75JLWK4L_cjs.t(`${a} (${l}${s} day${Math.abs(s)===1?"":"s"})`)}function ps(t){let e=t[0].value;return chunk75JLWK4L_cjs.t(un(Date.now(),e))}function fs(t){let e=t[0].value;return chunk75JLWK4L_cjs.t(ls(Date.now(),e))}function ds(t){let e=t[0].value,o=t[1].value,r=t[2].value,n=t[3].value,i=Date.now(),a=jt(e,i),l=jt(o,i)-a;if(l===0)return chunk75JLWK4L_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"}`),chunk75JLWK4L_cjs.t(`${u} is ${E.join(" ")} ahead of ${c}`)}var qt=class{constructor(){this.category="Time";}parse(e,o,r){let n=parseInt(o.value,10),i=ie(e);if(i!==null){if(e.peek()?.type!=="IN")throw chunkCO2BI6WL_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=ie(e);if(a===null)throw chunkCO2BI6WL_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(Xt,3);return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(120);}};var Zt=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 Jt=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 er=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 dn(t){return {category:"Time",parse(e,o,r){let n=ie(e);if(n===null)throw chunkCO2BI6WL_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 tr=class{constructor(){this.category="Time";}parse(e,o,r){let n=ie(e);if(n===null)throw chunkCO2BI6WL_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=ie(e);if(i===null)throw chunkCO2BI6WL_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(Qt,4);}};var rr=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 chunkCO2BI6WL_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 chunkCO2BI6WL_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 chunkCO2BI6WL_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=chunk75JLWK4L_cjs.z(c);if(e.peek()?.type==="IN"){e.consume();let E=e.peek();if(!E||E.type!=="IDENT"||E.value.toLowerCase()!=="frames")throw chunkCO2BI6WL_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 Es(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 or=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 chunkCO2BI6WL_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(Es(n,s));return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(13),r.emitString("frames"),r.emitOpcode(80);}};function Ts(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 Ns(t){return !!t&&t.type==="IDENT"&&/^(am|pm)$/i.test(t.value)}function ys(t=65){return {name:"time:clock-time",priority:t,shape:[{types:["NUMBER"]},{types:["COLON","IDENT"]}],match(e,o){let r=e[o];if(r.type!=="NUMBER")return null;let n=parseInt(r.value,10);if(isNaN(n)||n<0||n>23||chunkSGIDBZ4T_cjs.e(e,o))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=Ns(u),f=Ts(n,l,c?u.value:void 0);if(f===null)return null;let T=c?4:3;return {consumed:T,replacement:[chunkSGIDBZ4T_cjs.b("CLOCK_TIME",String(f),e.slice(o,o+T))],ruleName:"time:clock-time"}}let s=e[o+1];if(Ns(s)){let l=Ts(n,0,s.value);return l===null?null:{consumed:2,replacement:[chunkSGIDBZ4T_cjs.b("CLOCK_TIME",String(l),e.slice(o,o+2))],ruleName:"time:clock-time"}}return null}}}function gs(t=66){return {name:"time:clock-time-interval",priority:t,shape:[{types:["CLOCK_TIME"]},{types:["TO"]}],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:[chunkSGIDBZ4T_cjs.b("CLOCK_TIME_INTERVAL",`${r.value}:${i.value}`,e.slice(o,o+3))],ruleName:"time:clock-time-interval"}}}}function Ps(t=65){return {name:"time:fps-rate",priority:t,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["fps"]}],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:[chunkSGIDBZ4T_cjs.b("FPS_RATE",r.value,e.slice(o,o+2))],ruleName:"time:fps-rate"}}}}function _s(t=70){return {name:"time:laptime",priority:t,shape:[{types:["NUMBER"]},{types:["COLON"]}],match(e,o){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"||chunkSGIDBZ4T_cjs.e(e,o))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:[chunkSGIDBZ4T_cjs.b("LAPTIME",String(f),e.slice(o,o+5))],ruleName:"time:laptime"}}}}function As(t=75){return {name:"time:video-timecode",priority:t,shape:[{types:["NUMBER"]},{types:["COLON"]}],match(e,o){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"||chunkSGIDBZ4T_cjs.e(e,o))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:[chunkSGIDBZ4T_cjs.b("VIDEO_TIMECODE",`${c},${f},${T},${N}`,e.slice(o,o+7))],ruleName:"time:video-timecode"}}}}function xs(t=65){return {name:"time:frame-count",priority:t,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["frames"]}],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:[chunkSGIDBZ4T_cjs.b("FRAME_COUNT",r.value,e.slice(o,o+2))],ruleName:"time:frame-count"}}}}var Lc=14,wc=[["week","weeks",604800],["day","days",86400],["hour","hours",3600],["minute","minutes",60],["second","seconds",1]];function Rs(t){if(t.type===0)return t.toNumber();if(t.type!==6||t.unit===void 0)return null;let e=chunkEZKR44MA_cjs.a[t.unit.toLowerCase()];return e===void 0||e[0]!==Lc?null:t.toNumber()*e[1]}function Os(t){let e=Rs(t);if(e===null)return chunk75JLWK4L_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 wc){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"}`),chunk75JLWK4L_cjs.t((o?"-":"")+n.join(" "))}function Tn(t){let e=Rs(t);if(e===null)return chunk75JLWK4L_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=`${En(n)}:${En(i)}:${En(s)}`;return chunk75JLWK4L_cjs.t((o?"-":"")+(l>0?`${u}.${String(l).padStart(3,"0")}`:u))}function En(t){return t<10?`0${t}`:String(t)}var Nn={name:"solve-time",asConverters:{timespan:Os,laptime:Tn,lap:Tn},phrases:{"time in":"TIME_IN","date in":"DATE_IN","time difference between":"TIME_DIFFERENCE_BETWEEN",...Object.fromEntries(Object.keys(sn).map(t=>[t,"CITY_NAME"]))},prefixParselets:{CLOCK_TIME:new qt,CLOCK_TIME_INTERVAL:new Zt,FPS_RATE:new Jt,LAPTIME:new er,TIME_IN:dn(pn),DATE_IN:dn(fn),TIME_DIFFERENCE_BETWEEN:new tr,VIDEO_TIMECODE:new rr,FRAME_COUNT:new or},normalizerRules:[ys(),gs(),Ps(),_s(),As(),xs()],pluginFunctions:{[Xt]:cs,[pn]:ps,[fn]:fs,[Qt]:ds}};function nr(t){for(let e of t.alternatives){let o=e.slots[0];if(!o||o.kind!=="keyword")throw chunkCO2BI6WL_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 chunkCO2BI6WL_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 chunkCO2BI6WL_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 vc=37;function ir(t){t.emitOpcode(51),t.emitIndex(vc),t.emitIndex(2);}var kc=nr({category:"Dice",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkEN3CDYOS_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:ir},{slots:[{kind:"keyword",tokenTypes:["FROM"]},{kind:"expr",bindingPower:chunkEN3CDYOS_cjs.a.Product},{kind:"keyword",tokenTypes:["TO"]},{kind:"expr"}],emit:ir},{slots:[{kind:"keyword",tokenTypes:["LPAREN"]},{kind:"expr"},{kind:"keyword",tokenTypes:["COMMA"]},{kind:"expr"},{kind:"keyword",tokenTypes:["RPAREN"]}],emit:ir}]}),ar=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)),ir(r);return}kc.parse(e,o,r);}};var yn={name:"solve-dice",prefixParselets:{ROLL:new ar}};var sr=class{constructor(){this.category="Variable";}parse(e,o,r){let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkCO2BI6WL_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 at=class{constructor(){this.category="Variable";}parse(e,o,r){r.emitOpcode(60),r.emitString(o.value);}};var mr=class{constructor(){this.category="Variable";}parse(e,o,r){e.consume("COLON");let n=e.consume();if(n.type!=="IDENT"&&n.type!=="UNIT")throw chunkCO2BI6WL_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 lr=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(!chunkXDXIPVZB_cjs.J.has(f))return this.pendingResultFor(f,r,n)}u=chunkTL545PXW_cjs.a(a,u);}return null}pendingResultFor(e,o,r){let n=this.pending.get(e);return n||(n=new Promise(i=>{let a=chunkXDXIPVZB_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 gn={name:"solve-variables",asyncResolvers:[new lr],prefixParselets:{COLON:new sr,IDENT:new at,UNIT:new at,GLOBAL:new mr}};var Is="currency-historical",de="historicalCurrency",Mc=`solve-currency:${de}`,ur={NOT_CONFIGURED:"HISTORICAL_RATES_NOT_CONFIGURED",QUERY_FAILED:"HISTORICAL_RATE_QUERY_FAILED",NOT_PREFLIGHTED:"HISTORICAL_RATE_NOT_PREFLIGHTED",INVALID_OPERAND:"HISTORICAL_CURRENCY_INVALID_OPERAND"},Bc=3e4,Cs=1/0,Uc=1e4;function Pn(t,e,o){return [Is,`${t.toUpperCase()}:${e.toUpperCase()}:${o}`]}function hs(t){return t<10?`0${t}`:String(t)}function cr(t,e,o){if(!chunk6YM67DWH_cjs.c.isCurrency(e)||o!==void 0&&!chunk6YM67DWH_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()}-${hs(i.getMonth()+1)}-${hs(i.getDate())}`}async function Ss(t,e,o,r,n,i){let a=e.toUpperCase(),s=o.toUpperCase();if(!t)return chunk75JLWK4L_cjs.P(ur.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,Uc,"Historical currency rate fetch");try{let c=await t(a,s,r,l);return chunk75JLWK4L_cjs.n(c)}catch(c){let f=chunk75JLWK4L_cjs.P(ur.QUERY_FAILED,`Failed to resolve the historical rate for ${a} to ${s} on ${r}: ${c instanceof Error?c.message:String(c)}`),T=Pn(e,o,r);return setTimeout(()=>{i.getQueryData(T)===f&&i.removeQueries({queryKey:T,exact:true});},Bc).unref?.(),f}finally{u();}}function _n(t){return e=>{let o=e[0],r=e[1],n=e[2],i=chunk75JLWK4L_cjs.Q(o);if(i)return i;if(o.type!==6||o.unit===void 0||!chunk6YM67DWH_cjs.c.isCurrency(o.unit))return chunk75JLWK4L_cjs.P(ur.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 chunk75JLWK4L_cjs.u(o.toNumber(),s);let u=chunkZLRJ7TDP_cjs.b(),c=Pn(a,s,l),f=u?.getQueryData(c);if(f===void 0)return u?u.fetchQuery({queryKey:c,queryFn:({signal:N})=>Ss(t,a,s,l,N,u),staleTime:Cs}):chunk75JLWK4L_cjs.P(ur.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 chunk75JLWK4L_cjs.u(o.toNumber()*T,s)}}function Ls(t){return {namespace:Is,preflight(e,o,r,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=chunkXDXIPVZB_cjs.F(Mc),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 A=s[f[f.length-1]],R=s[f[f.length-2]],O=new Set;for(let g=0;g<f.length-2;g++){let P=s[f[g]];chunk6YM67DWH_cjs.c.isCurrency(P)&&O.add(P.toUpperCase());}if(O.size===1){let g=O.values().next().value;if(g!==R.toUpperCase()){let P=Pn(g,R,A);if(i.getQueryData(P)===void 0){let C=i.fetchQuery({queryKey:P,queryFn:({signal:S})=>Ss(t,g,R,A,S,i),staleTime:Cs});return {queryKey:P.join(":"),resolver:C,packageId:r,signal:n,metadata:{from:g,to:R,isoDate:A}}}}}}f=[];}c=chunkTL545PXW_cjs.a(a,c);}return null},destroy(){}}}function ws(t){return chunkJ7ABVGZH_cjs.ta(t)??t}var pr=class{constructor(){this.category="UoM";this.bindingPower=chunkEN3CDYOS_cjs.a.Postfix;}parse(e,o,r,n){let i=ws(r.value);if(n.emitOpcode(13),n.emitString(i),!(e.infixMinBindingPower>=chunkEN3CDYOS_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=ws(s.value),u=cr(e,l,i);if(u!==null){n.emitOpcode(80),n.emitOpcode(13),n.emitString(l),n.emitOpcode(13),n.emitString(u),n.emitPluginCall(de,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 An(t){return chunkJ7ABVGZH_cjs.ta(t)??t}var fr=class{constructor(){this.category="UoM";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Postfix,r);let n=e.peek();if(n&&n.type==="UNIT"){if(e.consume(),r.emitOpcode(13),r.emitString(An(n.value)),e.peek()?.type==="TO"){e.consume("TO");let i=e.consume();i?.type==="UNIT"?(r.emitOpcode(13),r.emitString(An(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(An(i.value)),r.emitOpcode(84)):i?.type==="BEST"&&(e.consume(),r.emitOpcode(83));return}}};var dr=class{constructor(){this.category="UoM";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitOpcode(85);}};function vs(t=60){return {name:"uom:possibilities",priority:t,shape:[{types:["UNIT"]},{types:["TO"]}],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:[chunkSGIDBZ4T_cjs.b("UOM_POSSIBILITIES_QUERY",r.value,[r,n,i])],ruleName:"uom:possibilities"}}}}var ks=14;function Ms(t,e){if(t===void 0||t.type!=="UNIT")return;let o=(t.value??"").toLowerCase();if(o==="m"&&e===ks)return {kind:ks,ratio:60,spelling:"minutes"};let r=chunkEZKR44MA_cjs.a[o];return r===void 0?void 0:{kind:r[0],ratio:r[1],spelling:o}}var Bs=/^\d+(\.\d+)?$/;function Us(t=63){return {name:"uom:compound-quantity",priority:t,shape:[{types:["NUMBER"]},{types:["UNIT"]}],match(e,o){let r=e[o];if(r?.type!=="NUMBER"||!Bs.test(r.text??""))return null;let n=Ms(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"||!Bs.test(N.text??""))break;let E=Ms(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:[chunkSGIDBZ4T_cjs.b("NUMBER",String(T),f),chunkSGIDBZ4T_cjs.b("UNIT",l,[u])],ruleName:"uom:compound-quantity"}}}}function Ds(t){return t===void 0||t.type!=="UNIT"?false:chunkEZKR44MA_cjs.a[(t.value??"").toLowerCase()]!==void 0}function bs(t=59){return {name:"uom:two-unit-conversion",priority:t,shape:[{types:["IN","TO"]},{types:["UNIT"]}],match(e,o){let r=e[o];if(r?.type!=="IN"&&r?.type!=="TO"||!Ds(e[o+1])||e[o+2]?.type!=="AND_CONJ"||!Ds(e[o+3]))return null;let n=e[o+1].value,i=e[o+3].value;return {consumed:4,replacement:[chunkSGIDBZ4T_cjs.b("IN_TWO_UNITS",`${n} ${i}`,e.slice(o,o+4))],ruleName:"uom:two-unit-conversion"}}}}function Vs(t=74){return {name:"uom:degree-symbol",priority:t,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["\xB0"]}],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,chunkSGIDBZ4T_cjs.b("UNIT","degrees",[n])],ruleName:"uom:degree-symbol"}}}}var Er=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkEN3CDYOS_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 Fs(t){return t===void 0||t.type!=="UNIT"?false:chunkEZKR44MA_cjs.a[(t.value??"").toLowerCase()]!==void 0}var xn=new Set(["per","a","an","each","every"]);function Dc(t){if(t===void 0||t.type!=="IDENT")return false;let e=(t.text??t.value??"").toLowerCase();return xn.has(e)?false:/^[a-z][a-z_]{2,}$/.test(e)&&chunkEZKR44MA_cjs.a[e]===void 0}function Hs(t=75){return {name:"uom:bare-rate-denominator",priority:t,unshapedReason:"Fires after any value-ending token, a set broad enough that naming it would filter nothing.",match(e,o){let r=e[o];if(r===void 0)return null;if(r.type==="NUMBER"&&Dc(e[o+1])){let l=e[o+1],u=e[o+2];if((u?.type==="SLASH"||u?.type==="IDENT"&&xn.has((u.text??u.value??"").toLowerCase()))&&Fs(e[o+3]))return {consumed:2,replacement:[r,chunkSGIDBZ4T_cjs.b("UNIT",l.value,[l])],ruleName:"uom:bare-rate-denominator"}}if(!Fs(e[o+1]))return null;let n=r.type==="SLASH",i=(r.text??r.value??"").toLowerCase(),a=r.type==="IDENT"&&xn.has(i);if(!n&&!a)return null;let s=e[o+1];return {consumed:2,replacement:[chunkSGIDBZ4T_cjs.b("PER_UNIT",s.value,[r,s])],ruleName:"uom:bare-rate-denominator"}}}}var Tr=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkEN3CDYOS_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 Nr=class{constructor(e){this.builtinIndex=e;this.category="Uom";this.bindingPower=chunkEN3CDYOS_cjs.a.Product;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};function bc(t){return t===void 0||t.type!=="UNIT"?false:chunkEZKR44MA_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Vc=new Set(["per","a","an","each","every"]);function Fc(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;if(r.type==="UNIT"&&chunkZKFCKAIX_cjs.i(r.value??void 0))return true;let n=(r.text??r.value??"").toLowerCase();if((r.type==="SLASH"||r.type==="IDENT"&&Vc.has(n))&&bc(t[o+1]))return true}return false}function Gs(t=73){return {name:"uom:at-rate",priority:t,shape:[{types:["RATE_AT"]}],match(e,o){return e[o]?.type!=="RATE_AT"||!Fc(e,o+1)?null:{consumed:1,replacement:[chunkSGIDBZ4T_cjs.b("AT_RATE","at",[e[o]])],ruleName:"uom:at-rate"}}}}function Hc(t){return t===void 0||t.type!=="UNIT"?false:chunkEZKR44MA_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Gc=new Set(["a","an"]);function zs(t=76){return {name:"uom:for-duration",priority:t,shape:[{types:["FOR_DURATION"]},{types:["IDENT"]}],match(e,o){let r=e[o];if(r?.type!=="FOR_DURATION")return null;let n=e[o+1];return n?.type!=="IDENT"||!Gc.has((n.text??n.value??"").toLowerCase())||!Hc(e[o+2])?null:{consumed:3,replacement:[chunkSGIDBZ4T_cjs.b("STAR","*",[r]),chunkSGIDBZ4T_cjs.b("NUMBER","1",[n]),e[o+2]],ruleName:"uom:for-duration"}}}}function Rn(t){return t===void 0||t.type!=="UNIT"?false:chunkEZKR44MA_cjs.a[(t.value??"").toLowerCase()]!==void 0}var zc=new Set(["a","an"]);function Ks(t=61){return {name:"uom:reversed-conversion",priority:t,shape:[{types:["UNIT"]},{types:["IN"]}],match(e,o){if(o!==0||!Rn(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"&&Rn(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"&&zc.has(i)&&Rn(e[o+3])?{consumed:4,replacement:[chunkSGIDBZ4T_cjs.b("NUMBER","1",[n]),e[o+3],e[o+1],r],ruleName:"uom:reversed-conversion"}:null}}}var Kc={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},$s=2;function Ws(t){return Kc[t.toLowerCase().trim()]}var yr="cookingConvert";function Ys(t){let e=t[0],o=t[1].value,r=t[2].value;if(e.type!==6||!e.unit)return chunk75JLWK4L_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=chunkZKFCKAIX_cjs.c(n),s=chunkZKFCKAIX_cjs.c(r),l=N=>N==="mass"||N==="volume";if(!l(a))return chunk75JLWK4L_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${n}" is not a recognized mass or volume unit`);if(!l(s))return chunk75JLWK4L_cjs.P("COOKING_CONVERSION_UNSUPPORTED_UNIT",`"${r}" is not a recognized mass or volume unit`);if(a===s)return chunk75JLWK4L_cjs.u(chunkZKFCKAIX_cjs.e(i,n,r),r);let u=Ws(o);if(u===void 0)return chunk75JLWK4L_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=chunkZKFCKAIX_cjs.e(i,n,"g")/u,A=chunkZKFCKAIX_cjs.e(E,"ml",r);return chunk75JLWK4L_cjs.u(A,r)}let f=chunkZKFCKAIX_cjs.e(i,n,"ml")*u,T=chunkZKFCKAIX_cjs.e(f,"g",r);return chunk75JLWK4L_cjs.u(T,r)}var gr=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(yr,3);}};function js(t=68){return {name:"uom-cooking:ingredient-name",priority:t,shape:[{types:["IDENT"]}],match(e,o){let r=e[o-1];if(!r||r.type!=="UNIT")return null;for(let n=$s;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:[chunkSGIDBZ4T_cjs.b("INGREDIENT_NAME",u,i)],ruleName:"uom-cooking:ingredient-name"}}return null}}}function Xs(t=78){return {name:"uom:multi-word-unit",priority:t,shape:[{types:["UNIT"]},{types:["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 chunkEZKR44MA_cjs.a[i]===void 0?null:{consumed:2,replacement:[chunkSGIDBZ4T_cjs.b("UNIT",i,e.slice(o,o+2))],ruleName:"uom:multi-word-unit"}}}}function Qs(t=77){return {name:"uom:compound-unit",priority:t,shape:[{types:["UNIT"]},{types:["SLASH"]}],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:[chunkSGIDBZ4T_cjs.b("UNIT",a,[r,n,i])],ruleName:"uom:compound-unit"}}}}var On={name:"solve-uom",prefixParselets:{CONVERT:new fr,UOM_POSSIBILITIES_QUERY:new dr},infixParselets:{IN_TWO_UNITS:new Er(94),PER_UNIT:new Tr(95),AT_RATE:new Nr(96),UNIT:new pr,INGREDIENT_NAME:new gr},normalizerRules:[Xs(),Qs(),vs(),Us(),bs(),Vs(),Gs(),zs(),Hs(),Ks(),js()],pluginFunctions:{[yr]:Ys}};var q=class{constructor(){this.category="UoM";}parse(e,o,r){let n=chunkJ7ABVGZH_cjs.ta(o.value)??o.value.toUpperCase();e.parseExpression(chunkEN3CDYOS_cjs.a.Prefix,r),e.peek()?.type==="UNIT"&&e.consume(),r.emitOpcode(13),r.emitString(n),r.emitOpcode(80);}};var Pr=class{constructor(){this.category="UoM";this.bindingPower=35;}parse(e,o,r,n){let i=e.peek();if(i?.type==="IP_CIDR"){e.parseExpression(chunkEN3CDYOS_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=chunkJ7ABVGZH_cjs.ta(i.value)??i.value,s=cr(e,a);if(s!==null){n.emitOpcode(13),n.emitString(a),n.emitOpcode(13),n.emitString(s),n.emitPluginCall(de,3);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(84);}}};function hn(t={}){return {name:"solve-currency",asyncResolvers:[new chunkTL545PXW_cjs.b,Ls(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 Pr},pluginFunctions:{[de]:_n(t.historicalRateProvider)}}}var In=hn();var Ce=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 _r=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 Cn={name:"solve-vector",prefixParselets:{VEC2:new Ce(2),VEC3:new Ce(3),VEC4:new Ce(4),FLOAT:new _r}};var Ar=class{constructor(){this.category="Matrix";}parse(e,o,r){let n=0,i=-1;if(e.peek()?.type==="RBRACKET")throw chunkCO2BI6WL_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 chunkCO2BI6WL_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 xr=class{constructor(){this.category="Matrix";this.bindingPower=chunkEN3CDYOS_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 chunkCO2BI6WL_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 Sn={name:"solve-matrix",prefixParselets:{LBRACKET:new Ar},infixParselets:{LBRACKET:new xr}};function Rr(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=Zo[a.toLowerCase()];return s!==void 0?{kind:1,builtinIdx:s}:{kind:2,name:a}}let n=new chunkEN3CDYOS_cjs.d(e.pluginIndexMap);t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,n),t.setBuilder(e);let i=n.build();if(i.hasAsync)throw chunkCO2BI6WL_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 qs(t){let e=t.peek(),o=t.peekAt(1);return !!e&&(e.type==="IDENT"||e.type==="UNIT")&&o?.type==="EQUALS"}function Zs(t){let e=t.peek();if(e&&(e.type==="IDENT"||e.type==="UNIT"))return t.consume(),e.value;throw chunkCO2BI6WL_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 ae(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 Or=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=Rr(e,r);e.consume("COMMA");let i=[];if(qs(e))do{let a=Zs(e);e.consume("EQUALS"),ee(e,r),i.push(a);}while(e.match("COMMA"));else ee(e,r),i.push("x");e.consume("RPAREN"),ae(r,157,n,i,i.length);}};var hr=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=Rr(e,r);e.consume("COMMA"),ee(e,r);let i=0;e.match("COMMA")&&(e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i=1),e.consume("RPAREN"),ae(r,158,n,["acc","x"],i);}};var Ir=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=new chunkEN3CDYOS_cjs.d(r.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,n),e.setBuilder(r),n.emitOpcode(20);let i=n.build();if(i.hasAsync)throw chunkCO2BI6WL_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),ae(r,158,{kind:0,program:i},["acc","x"],1);}};var Cr=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=new chunkEN3CDYOS_cjs.d(r.pluginIndexMap);n.emitOpcode(60),n.emitString("acc"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,n),e.setBuilder(r),n.emitOpcode(22);let i=n.build();if(i.hasAsync)throw chunkCO2BI6WL_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),ae(r,158,{kind:0,program:i},["acc","x"],1);}};var $c={map:"MAP",reduce:"REDUCE",sum:"SUM_FN",prod:"PROD_FN"};function Wc(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 Js(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=$c[n];return !i||e[o+1]?.type!=="LPAREN"||n==="sum"&&Wc(e[o+2],e[o+3])?null:{consumed:1,replacement:[new chunkUSQ4KL6S_cjs.a(i,chunk5IJD5L3O_cjs.c(i),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"mapreduce:call"}}}}var Ln={name:"solve-mapreduce",normalizerRules:[Js()],prefixParselets:{MAP:new Or,REDUCE:new hr,SUM_FN:new Ir,PROD_FN:new Cr}};var Sr=class{constructor(){this.category="BigInt";}parse(e,o,r){r.emitOpcode(11),r.emitString(chunkEN3CDYOS_cjs.e(o.value,e.getLocaleCode()));}};var wn={name:"solve-bigint",prefixParselets:{BIGINT:new Sr}};var te=class{constructor(e){this.opcode=e;this.category="Conditionals";this.bindingPower=chunkEN3CDYOS_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 st=class{constructor(e){this.value=e;this.category="Conditionals";}parse(e,o,r){r.emitOpcode(14),r.emitByte(this.value?1:0);}};var Lr=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 vn={name:"solve-conditionals",prefixParselets:{TRUE:new st(true),FALSE:new st(false),IF:new Lr},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,chunkEN3CDYOS_cjs.a.LogicalOr),LOGICAL_AND:new Se(130,chunkEN3CDYOS_cjs.a.LogicalAnd),LOGICAL_OR:new Se(131,chunkEN3CDYOS_cjs.a.LogicalOr)}};var Yc={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},em={2:143,8:144,16:71},wr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_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 chunkCO2BI6WL_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=em[u];if(c===void 0)throw chunkCO2BI6WL_cjs.c.parsing("AS_CONVERTER_UNSUPPORTED_BASE",`"as base ${l?.value??"?"}": only bases ${Object.keys(em).join(", ")} can be written out`);e.consume(),n.emitOpcode(c);return}let s=Yc[a];if(s!==void 0){s===141&&e.match("OF")&&(e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),n.emitOpcode(23)),n.emitOpcode(s);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(145);}};var tm={ten:10,hundred:100,thousand:1e3,million:1e6,billion:1e9};function rm(t,e,o){t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(23),om(t,o),t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(22);}function om(t,e){let o=e==="up"?Xc:e==="down"?Qc:jc;t.emitOpcode(51),t.emitIndex(o),t.emitIndex(1);}var jc=8,Xc=6,Qc=7,qc=97;function Zc(t){let o=(t.peek()?.text??"").toLowerCase();return o==="up"?(t.consume(),"up"):o==="down"?(t.consume(),"down"):"nearest"}var vr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){let i=Zc(e);if(e.match("TO_NEAREST")){rm(n,nm(e),i);return}om(n,i);}},kr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){rm(n,nm(e),"nearest");}};function nm(t){let e=t.peek(),o=(e?.text??"").toLowerCase(),r=tm[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 chunkCO2BI6WL_cjs.c.parsing("INVALID_ROUNDING_INCREMENT",`"to nearest ${e?.value??"?"}": expected a positive number or one of ${Object.keys(tm).join(", ")}`)}var Mr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){let i=Number(r.value);if(!Number.isFinite(i)||i<0||i>100)throw chunkCO2BI6WL_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(qc),n.emitIndex(2);}};var Jc=new Set(["dp","dps","decimals","digits","digit"]),ep=new Set(["decimal"]);function im(t=66){return {name:"converters:decimal-places",priority:t,shape:[{types:["TO"]},{types:["NUMBER"]}],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(ep.has(i)){let l=(e[o+3]?.text??"").toLowerCase();if(l!=="place"&&l!=="places")return null;a=4;}else if(!Jc.has(i))return null;return {consumed:a,replacement:[chunkSGIDBZ4T_cjs.b("DECIMAL_PLACES",r.value,e.slice(o,o+a))],ruleName:"converters:decimal-places"}}}}var tp=new Set(["hex","bin"]);function am(t=67){return {name:"converters:preposition",priority:t,shape:[{types:["IN","TO"]},{types:["CONVERTER_NAME","FUNC"]}],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"&&tp.has(n.value.toLowerCase())?{consumed:1,replacement:[chunkSGIDBZ4T_cjs.b("AS","as",[r])],ruleName:"converters:preposition"}:null}}}var kn={name:"solve-converters",phrases:{"to nearest":"TO_NEAREST","to the nearest":"TO_NEAREST"},infixParselets:{AS:new wr,ROUNDED:new vr,TO_NEAREST:new kr,DECIMAL_PLACES:new Mr},normalizerRules:[im(),am()]};var H=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,r){let n=0;for(e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),n++;e.match("COMMA")||e.match("AND_CONJ");)e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),n++;r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(n);}};var Br=class{constructor(e){this.builtinIndex=e;this.category="MathPhrases";}parse(e,o,r){let n=0;do{if(e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),n++,!e.match("RATE_AT")&&!e.match("AT")){let i=e.peek();throw chunkCO2BI6WL_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(chunkEN3CDYOS_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 Mn(t){return {category:"MathPhrases",parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(t),r.emitIndex(1);}}}var mm={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkEN3CDYOS_cjs.a.Product,o),!t.match("DIVIDE_BY")&&!t.match("SLASH"))throw chunkCO2BI6WL_cjs.c.parsing("REMAINDER_EXPECTED_DIVIDED_BY",'Expected "divided by" or "/", as in "remainder of 21 divided by 5"');t.parseExpression(chunkEN3CDYOS_cjs.a.Product,o),o.emitOpcode(24);}},lm={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkEN3CDYOS_cjs.a.Product,o),!t.match("OF"))throw chunkCO2BI6WL_cjs.c.parsing("ROOT_EXPECTED_OF",'Expected "of", as in "root 5 of 100"');t.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,o),o.emitOpcode(2),o.emitOpcode(10),o.emitNumber(1),o.emitOpcode(2),o.emitOpcode(23),o.emitOpcode(25);}},um={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,o),sm(o),!t.match("LOG_BASE"))throw chunkCO2BI6WL_cjs.c.parsing("LOG_EXPECTED_BASE",'Expected "base", as in "log 20 base 4"');t.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,o),sm(o),o.emitOpcode(23);}},rp=5;function sm(t){t.emitOpcode(51),t.emitIndex(rp),t.emitIndex(1);}function cm(t=69){return {name:"mathphrases:function-phrase",priority:t,shape:[{types:["FUNC"],values:["root","log"]}],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:[chunkSGIDBZ4T_cjs.b("NTH_ROOT","root",[r])],ruleName:"mathphrases:function-phrase"};let i=op(e,o+1);if(i===-1)return null;let a=e.slice(o,i+1).map((s,l)=>l===0?chunkSGIDBZ4T_cjs.b("LOG_PHRASE","log",[s]):l===i-o?chunkSGIDBZ4T_cjs.b("LOG_BASE","base",[s]):s);return {consumed:i-o+1,replacement:a,ruleName:"mathphrases:function-phrase"}}}}function op(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 mt(t){return {category:"MathPhrases",parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),e.consume("AND_CONJ"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(t),r.emitIndex(2);}}}var pm={category:"MathPhrases",parse(t,e,o){t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var fm={category:"MathPhrases",parse(t,e,o){t.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,o),t.consume("AND_CONJ"),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),o.emitOpcode(20),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var dm=nr({category:"MathPhrases",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkEN3CDYOS_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:t=>{t.emitOpcode(51),t.emitIndex(37),t.emitIndex(2);}}]});var np=47,Ur=class{constructor(){this.category="MathPhrases";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);let n=e.peek();if(n?.type==="BETWEEN")e.consume(),e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.consume("AND_CONJ"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);else if(n?.type==="FROM")e.consume(),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("TO"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);else throw chunkCO2BI6WL_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(np),r.emitIndex(3);}};var ip=46,Dr=class{constructor(){this.category="MathPhrases";this.bindingPower=chunkEN3CDYOS_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 chunkCO2BI6WL_cjs.c.parsing("PROPORTION_EXPECTED_WHAT",`Expected "what" but got ${i?`"${i.value}"`:"end of input"}`);n.emitOpcode(51),n.emitIndex(ip),n.emitIndex(3);}};var ap=42,sp=43,mp=44,lp=45,up=9,cp=10,pp=101,fp=102,dp=103,Ep=104,Tp=105,Np=106,yp=107,gp=38,Pp=39,_p=0,Ap=21,Bn={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(ap),MEDIAN_OF:new H(sp),TOTAL_OF:new H(mp),COUNT_OF:new H(lp),LARGER_OF:mt(cp),SMALLER_OF:mt(up),HALF_OF:pm,MIDPOINT_BETWEEN:fm,RANDOM_NUMBER:dm,REMAINDER_OF:mm,NTH_ROOT:lm,LOG_PHRASE:um,GCD_OF:mt(gp),LCM_OF:mt(Pp),SQUARE_ROOT_OF:Mn(_p),CUBE_ROOT_OF:Mn(Ap),CLAMP:new Ur,STANDARD_DEVIATION_OF:new H(pp),SAMPLE_STANDARD_DEVIATION_OF:new H(fp),VARIANCE_OF:new H(dp),SAMPLE_VARIANCE_OF:new H(Ep),SPREAD_OF:new H(Tp),MODE_OF:new H(Np),WEIGHTED_AVERAGE_OF:new Br(yp)},infixParselets:{IS_TO:new Dr},normalizerRules:[cm()]};var Em={annually:1,yearly:1,"semi-annually":2,quarterly:4,monthly:12,fortnightly:26,weekly:52,daily:365};function Un(t){if(!t.match("COMPOUNDING"))return 1;let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=Em[o];if(r===void 0)throw chunkCO2BI6WL_cjs.c.parsing("UNKNOWN_COMPOUNDING_INTERVAL",`compounding ${o||"?"}: expected one of ${Object.keys(Em).join(", ")}`);return t.consume(),r}var lt=class{constructor(e,o){this.annualIndex=e;this.intervalIndex=o;this.category="Finance";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n);let i=Un(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(chunkEN3CDYOS_cjs.a.Conditional,r),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),r.emitOpcode(2),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);}},Vr=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),e.consume("RETURNED"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}},Fr=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),e.consume("INVESTED"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),e.consume("RETURNED"),!e.match("AFTER")&&!e.match("OVER")&&!e.match("IN")&&e.consume("AFTER"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);}};function Hr(t,e,o){return Nm(t,o)?(t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),Tm(t),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),{swap:true}):(Tm(t),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),xp(t,o),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),{swap:false})}function Nm(t,e){for(let o of e)if(t.match(o))return true;return false}function xp(t,e){Nm(t,e)||t.consume(e[0]);}function Tm(t){t.match("RATE_AT")||t.consume("AT");}var ut=class{constructor(e,o){this.builtinIndex=e;this.intervalIndex=o;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r);let{swap:n}=Hr(e,r,["AFTER","FOR_DURATION","OVER"]),i=Un(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 j=class{constructor(e,o){this.builtinIndex=e;this.periodsPerYear=o;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);let{swap:n}=Hr(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 Gr=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("BETWEEN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.match("PEOPLE"),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(2);}},zr=class{constructor(e){this.builtinIndex=e;this.category="Finance";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),e.consume("WAYS"),n.emitOpcode(51),n.emitIndex(this.builtinIndex),n.emitIndex(2);}};var ym={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 Rp(t){let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=ym[o];if(r===void 0)throw chunkCO2BI6WL_cjs.c.parsing("UNKNOWN_SAVINGS_PERIOD",`savings goal: expected a contribution period, one of ${Object.keys(ym).join(", ")}, not "${o||"?"}".`);return t.consume(),r}var Kr=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),e.match("RATE_AT")||e.consume("AT"),e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.match("STAR");let n=Rp(e);r.emitOpcode(10),r.emitNumber(n.perYear),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkEN3CDYOS_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);}},$r=class{constructor(e){this.builtinIndex=e;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.consume("IN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r),e.match("RATE_AT")||e.match("AT")?e.parseExpression(chunkEN3CDYOS_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(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("RATE_AT"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(2);}};var Op=60;function hp(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 ct=class{constructor(e){this.variant=e;this.category="Finance";}parse(e,o,r){if(!hp(e)){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);return}if(e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),this.variant==="what-was"){e.consume("WORTH_IN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitPluginCall("inflationToYearFromPresent",2);return}let n=e.peek();if(n?.type==="FROM"){e.consume(),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitPluginCall("inflationFromYearToPresent",2);return}if(n?.type==="IN"){e.consume(),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("WORTH_IN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitOpcode(51),r.emitIndex(Op),r.emitIndex(3);return}let i=n?n.type:"end of input";throw chunkCO2BI6WL_cjs.c.parsing("INFLATION_EXPECTED_FROM_OR_IN",`Expected "from <year>" or "in <year> worth in <year>" after "what is <amount>", got ${i}`)}};var Wr=class{constructor(){this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Product,r),e.consume("IN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("ASSUMING"),e.parseExpression(chunkEN3CDYOS_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 chunkCO2BI6WL_cjs.c.parsing("INFLATION_EXPECTED_INFLATION_WORD",`Expected the word "inflation" after "assuming <rate>%", got "${a}"`)}e.consume(),r.emitPluginCall("inflationFutureValue",3);}};var Yr=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 gm(t,e){return chunk75JLWK4L_cjs.P(t,`Year ${e} is outside the bundled CPI table's range (${chunkXDXIPVZB_cjs.z}-${chunkXDXIPVZB_cjs.A})`)}function Pm(t){let e=t[0],o=t[1].toNumber(),r=new Date().getFullYear(),n=chunkXDXIPVZB_cjs.B(e.toNumber(),o,r);return n===void 0?gm("INFLATION_YEAR_OUT_OF_RANGE",o):e.type===6?chunk75JLWK4L_cjs.u(n,e.unit):chunk75JLWK4L_cjs.n(n)}function _m(t){let e=t[0],o=new Date().getFullYear(),r=t[1].toNumber(),n=chunkXDXIPVZB_cjs.B(e.toNumber(),o,r);return n===void 0?gm("INFLATION_YEAR_OUT_OF_RANGE",r):e.type===6?chunk75JLWK4L_cjs.u(n,e.unit):chunk75JLWK4L_cjs.n(n)}function Am(t){let e=t[0],o=t[1].toNumber(),r=t[2].toNumber(),n=o-new Date().getFullYear();if(1+r<=0)return chunk75JLWK4L_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?chunk75JLWK4L_cjs.u(a,e.unit):chunk75JLWK4L_cjs.n(a)}function xm(t=70){return {name:"finance:in-year-dollars",priority:t,shape:[{types:["IN"]},{types:["NUMBER"]}],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:[chunkSGIDBZ4T_cjs.b("IN_YEAR_DOLLARS",n.value,e.slice(o,o+3))],ruleName:"finance:in-year-dollars"}}}}var Ip={RECURRING_INTERVAL_NOT_POSITIVE:"RECURRING_INTERVAL_NOT_POSITIVE"},Cp={daily:365,weekly:52,monthly:12,yearly:1,annually:1},Sp={day:365,days:365,week:52,weeks:52,month:12,months:12,year:1,years:1},Lp=new Set(["a","an"]),wp=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]);function pt(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}function Rm(t){if(!(t===void 0||t.type!=="UNIT"))return Sp[pt(t)]}function vp(t,e){let o=t[e];if(o===void 0)return null;if(o.type==="IDENT"){let r=Cp[pt(o)];if(r!==void 0)return {perYear:r,consumed:1};if(pt(o)==="every"){let n=t[e+1];if(n?.type!=="NUMBER")return null;let i=Rm(t[e+2]);if(i===void 0)return null;let a=Number((n.value??"").replace(/,/g,""));if(!(a>0))throw chunkCO2BI6WL_cjs.c.parsing({code:Ip.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} ${pt(t[e+2])}`});return {perYear:i/a,consumed:3}}}return null}function kp(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"&&Lp.has(pt(o)))r=1,n=e+1;else return null;let i=Rm(t[n]);return i===void 0||!Number.isFinite(r)||r<0?null:{years:r/i,consumed:n-e+1}}function Mp(t,e){let o=t*e,r=Math.round(o);return Math.abs(o-r)<1e-9?r:Math.floor(o)}function Om(t=78){return {name:"finance:recurring-schedule",priority:t,unshapedReason:"Scans forward through a period and a duration sub-grammar of unbounded length, so no fixed leading shape describes it.",match(e,o){let r=e[o];if(r===void 0||!wp.has(r.type))return null;let n=vp(e,o+1);if(n===null)return null;let i=o+1+n.consumed;if(e[i]?.type!=="FOR_DURATION")return null;let a=kp(e,i+1);if(a===null)return null;let s=Mp(n.perYear,a.years),l=i+1+a.consumed-o,u=e.slice(o,o+l);return {replacement:[r,chunkSGIDBZ4T_cjs.b("STAR","*",u),chunkSGIDBZ4T_cjs.b("NUMBER",String(s),u)],consumed:l,ruleName:"finance:recurring-schedule"}}}}function jr(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var hm=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]),Im=new Set(["NUMBER","FLOAT"]);function Cm(t=77){return {name:"finance:bill-split",priority:t,unshapedReason:"Scans forward an unbounded distance for the BETWEEN keyword, and starts at any value-ending token.",match(e,o){let r=e[o];if(r===void 0)return null;if(hm.has(r.type)){let f=e[o+1],T=e[o+2],N=e[o+3];if(f?.type==="IDENT"&&jr(f)==="split"&&T!==void 0&&Im.has(T.type)&&N?.type==="IDENT"&&jr(N)==="ways")return {consumed:4,replacement:[r,chunkSGIDBZ4T_cjs.b("SPLIT_WAYS","split",[f]),T,chunkSGIDBZ4T_cjs.b("WAYS","ways",[N])],ruleName:"finance:bill-split"}}if(r.type!=="IDENT"||jr(r)!=="split")return null;let n=e[o-1];if(n!==void 0&&hm.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||!Im.has(a.type))return null;let s=i+2,l=e[s]?.type==="IDENT"&&jr(e[s])==="people",u=l?s:i+1,c=[chunkSGIDBZ4T_cjs.b("SPLIT","split",[r]),...e.slice(o+1,i+2)];return l&&c.push(chunkSGIDBZ4T_cjs.b("PEOPLE","people",[e[s]])),{consumed:u-o+1,replacement:c,ruleName:"finance:bill-split"}}}}var Dn=51,Bp=52,Xr=55,Qr=56,bn=80,Up=81,Dp=82,bp=83,Vp=84,Fp=59,Hp=85,Gp=86,Sm=98,zp=99,Kp=100,Vn={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(Dp),ANNUAL_RETURN_ON:new Fr(Vp),COMPOUND_INTEREST_ON:new ut(Dn,bn),INTEREST_ON:new ut(Bp,Up),DAILY_REPAYMENT_ON:new j(Xr,365),MONTHLY_REPAYMENT_ON:new j(Xr,12),ANNUAL_REPAYMENT_ON:new j(Xr,1),TOTAL_REPAYMENT_ON:new j(Xr,0),DAILY_LOAN_INTEREST_ON:new j(Qr,365),MONTHLY_LOAN_INTEREST_ON:new j(Qr,12),ANNUAL_LOAN_INTEREST_ON:new j(Qr,1),TOTAL_LOAN_INTEREST_ON:new j(Qr,0),TAX_ON:new Le(Gp),TAX_OFF:new Le(Fp),TAX_IN_PHRASE:new Le(Hp),SPLIT:new Gr(Sm),WHAT_IS:new ct("what-is"),WHAT_WAS:new ct("what-was"),VALUE_OF:new Wr,SAVINGS_HOW_LONG:new Kr(Kp),SAVINGS_HOW_MUCH:new $r(zp)},infixParselets:{AFTER:new lt(Dn,bn),FOR_DURATION:new lt(Dn,bn),INVESTED:new Vr(bp),IN_YEAR_DOLLARS:new Yr,SPLIT_WAYS:new zr(Sm)},normalizerRules:[xm(),Om(),Cm()],pluginFunctions:{inflationFromYearToPresent:Pm,inflationToYearFromPresent:_m,inflationFutureValue:Am}};function $p(t){return (e,o)=>chunk75JLWK4L_cjs.P(`${t.toUpperCase()}_QUERY_FAILED`,`Failed to resolve "${e}": ${o instanceof Error?o.message:String(o)}`)}function re(t){let e=t.staleTimeMs??3e5,o=t.timeoutMs??1e4,r=t.failureCooldownMs??3e4,n=t.onError??$p(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 A=n(u,E);return setTimeout(()=>{f.getQueryData(i(u))===A&&f.removeQueries({queryKey:i(u),exact:true});},r).unref?.(),A}finally{N();}}return {resolver:{namespace:t.namespace,preflight(u,c,f,T,N){let{opcodes:E,strings:A}=c,R=E.length,O=0;for(;O<R;){if(E[O]===50&&O+2<R){let P=E[O+1],C=E[O+2];if(P===t.pluginFunctionIndex&&C>=1&&O>=2&&E[O-2]===13){let S=A[E[O-1]],Q=i(S);if(N.getQueryData(Q)===void 0){let ze=N.fetchQuery({queryKey:Q,queryFn:({signal:Go})=>a(S,Go,N),staleTime:e}),le={queryKey:Q.join(":"),resolver:ze,packageId:f,signal:T,metadata:{query:S}};return t.refetchIntervalMs!==void 0&&(le.refetchIntervalMs=t.refetchIntervalMs,le.refetch=()=>N.fetchQuery({queryKey:Q,queryFn:({signal:Go})=>a(S,Go,N),staleTime:0})),le}}O+=3;continue}O=chunkTL545PXW_cjs.a(E,O);}return null},destroy(){}},pluginFunction:u=>{let c=u[0]?.value,f=chunkZLRJ7TDP_cjs.b()?.getQueryData(i(c));return f!==void 0?f:chunk75JLWK4L_cjs.P(`${t.namespace.toUpperCase()}_NOT_PREFLIGHTED`,`No cached result for "${c}"`)}}}function Wp(t,e){let o=[];for(;t.peek()?.type==="IDENT";)o.push(t.consume().value);if(o.length===0)throw chunkCO2BI6WL_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=Wp(o,r.value);n.emitOpcode(13),n.emitString(`${t}:${i}`),n.emitPluginCall(e,1);}}}var Yp={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 Lm(t){return Yp[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"},jp="https://geocoding-api.open-meteo.com/v1/search",Xp="https://api.open-meteo.com/v1/forecast",Qp=1e4;async function qp(t,e){let o=`${jp}?name=${encodeURIComponent(t)}&count=1&language=en&format=json`,r=await fetch(o,{signal:e});if(!r.ok)throw chunkCO2BI6WL_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 chunkCO2BI6WL_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 Zp(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(`${Xp}?${r.toString()}`,{signal:o});if(!n.ok)throw chunkCO2BI6WL_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 chunkCO2BI6WL_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 qr=new Map,Jp=6e4;function wm(t,e){let o=t.trim().toLowerCase(),r=Date.now(),n=qr.get(o);if(n&&n.expiresAt>r)return n.promise;let{signal:i,cleanup:a}=chunkTLG7VZRX_cjs.a(e,Qp,"Open-Meteo weather query"),s=(async()=>{try{let l=await qp(t,i),u=await Zp(l.latitude,l.longitude,i);return {resolvedName:l.name,weatherCode:u.weatherCode,description:Lm(u.weatherCode),temperature:u.temperature,apparentTemperature:u.apparentTemperature,high:u.high,low:u.low}}finally{a();}})();return qr.set(o,{promise:s,expiresAt:r+Jp}),s.catch(()=>{qr.get(o)?.promise===s&&qr.delete(o);}),s}var vm="solve-weather",Ee="weather",ef=chunkXDXIPVZB_cjs.F(`${vm}:${Ee}`),{resolver:tf,pluginFunction:rf}=re({namespace:"weather",pluginFunctionIndex:ef,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 wm(n,e);switch(r){case "current":return chunk75JLWK4L_cjs.t(`${Math.round(i.temperature)}\xB0C, ${i.description}`);case "temperature":return chunk75JLWK4L_cjs.u(i.temperature,"C");case "feelslike":return chunk75JLWK4L_cjs.u(i.apparentTemperature,"C");case "high":return chunk75JLWK4L_cjs.u(i.high,"C");case "low":return chunk75JLWK4L_cjs.u(i.low,"C");default:throw chunkCO2BI6WL_cjs.c.internal(ve.UNKNOWN_QUERY_KIND,`Unknown weather query kind "${r}"`,{kind:r})}}}),Fn={name:vm,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]:rf},asyncResolvers:[tf]};var Zr={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 eo(t){return t<10?`0${t}`:String(t)}function ft(t,e,o,r){let n=new Date(t,e,o);if(n.getFullYear()!==t||n.getMonth()!==e||n.getDate()!==o)throw chunkCO2BI6WL_cjs.c.parsing("STOCKS_INVALID_DATE",`"${r}" is not a valid calendar date`);return {isoDate:`${t}-${eo(e+1)}-${eo(o)}`,raw:r}}function Jr(t,e){if(!/^\d{4}$/.test(t))throw chunkCO2BI6WL_cjs.c.parsing("STOCKS_INVALID_DATE",`Expected a 4-digit year in "${e}", got "${t}"`);return parseInt(t,10)}function km(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()}-${eo(o.getMonth()+1)}-${eo(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=Jr(s.value,l);return ft(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 ft(T,N-1,E,l)}let u=parseInt(o.value,10),c=parseInt(a.value,10),f=Jr(s.value,l);return ft(f,u-1,c,l)}}let n=t.peek();if(n&&n.type==="IDENT"&&Zr[n.value.toLowerCase()]!==void 0){let i=Zr[n.value.toLowerCase()];t.consume(),t.peek()?.type==="COMMA"&&t.consume();let a=t.consume("NUMBER"),s=`${o.value} ${n.value} ${a.value}`,l=Jr(a.value,s);return ft(l,i,parseInt(o.value,10),s)}throw chunkCO2BI6WL_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"&&Zr[e.value.toLowerCase()]!==void 0){let o=Zr[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=Jr(n.value,i);return ft(a,o,parseInt(r.value,10),i)}return null}var Mm=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",of=chunk5IJD5L3O_cjs.c(ke);function Bm(){return {name:"stocks:bare-ticker",priority:20,startTokenTypes:["IDENT"],match(t,e){let o=t[e];return !o||o.type!=="IDENT"||!Mm.has(o.value)||e>0&&t[e-1].type==="COLON"?null:{consumed:1,replacement:[new chunkUSQ4KL6S_cjs.a(ke,of,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"stocks:bare-ticker"}}}}function nf(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 chunkCO2BI6WL_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=km(t);if(!n)throw chunkCO2BI6WL_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 Um(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 Dm(t,e,o,r,n){let i=false;t.peek()?.type==="STAR"&&(t.consume(),i=true);let a=nf(t);if(i&&!a){Um(e,o,null,r,n),t.parseExpression(chunkEN3CDYOS_cjs.a.Product,e),e.emitOpcode(22);return}Um(e,o,a,r,n);}function bm(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 chunkCO2BI6WL_cjs.c.parsing("STOCKS_INVALID_TICKER",`Expected a ticker symbol inside stock(...), got "${i.value}" (${i.type})`);o.consume("RPAREN"),Dm(o,n,a,t,e);}}}function Vm(t,e){return {category:"Stocks",parse(o,r,n){let i=r.value.toUpperCase();Dm(o,n,i,t,e);}}}var Hn="solve-stocks",to="stock",ro="stockhistorical";function Fm(t={}){function e(s){return chunk75JLWK4L_cjs.P("STOCKS_NOT_CONFIGURED",`Stock data provider not configured. Supply ${s} via createStocksPackage({ ... }); see the StocksPackage doc comment.`)}let{resolver:o,pluginFunction:r}=re({namespace:"stocks-current",pluginFunctionIndex:chunkXDXIPVZB_cjs.F(`${Hn}:${to}`),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 chunk75JLWK4L_cjs.u(u.price,u.currency??"USD")}}),{resolver:n,pluginFunction:i}=re({namespace:"stocks-historical",pluginFunctionIndex:chunkXDXIPVZB_cjs.F(`${Hn}:${ro}`),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"?chunk75JLWK4L_cjs.n(T.volume??0):chunk75JLWK4L_cjs.u(T.close,T.currency??"USD")}});return {name:Hn,lexerVocabulary:{keywords:{stock:"STOCK_FN"}},prefixParselets:{STOCK_FN:bm(to,ro),...t.enableBareTickerRecognition?{[ke]:Vm(to,ro)}:{}},normalizerRules:t.enableBareTickerRecognition?[Bm()]:[],pluginFunctions:{[to]:r,[ro]:i},asyncResolvers:[o,n]}}var oo=class{constructor(e){this.fn=e;this.category="Crypto";}parse(e,o,r){e.consume("LPAREN");let n=e.consume(),i=String(n.value??"").trim().toUpperCase();e.consume("RPAREN"),r.emitOpcode(13),r.emitString(i),r.emitPluginCall(this.fn,1);}};var Hm="solve-crypto",Gn="crypto";function Gm(t={}){function e(){return chunk75JLWK4L_cjs.P("CRYPTO_NOT_CONFIGURED","Crypto price provider not configured. Supply fetchPrice via createCryptoPackage({ fetchPrice }); see the CryptoPackage doc comment.")}let{resolver:o,pluginFunction:r}=re({namespace:"crypto",pluginFunctionIndex:chunkXDXIPVZB_cjs.F(`${Hm}:${Gn}`),staleTimeMs:t.staleTimeMs??6e4,refetchIntervalMs:t.refetchIntervalMs,fetchQuery:async(n,i)=>{if(!t.fetchPrice)return e();let a=await t.fetchPrice(n,i);return chunk75JLWK4L_cjs.u(a.price,a.currency??"USD")}});return {name:Hm,lexerVocabulary:{keywords:{crypto:"CRYPTO_FN"}},prefixParselets:{CRYPTO_FN:new oo(Gn)},pluginFunctions:{[Gn]:r},asyncResolvers:[o],tokenCategories:{CRYPTO_FN:"function"}}}function zm(t){return {category:"Knowledge",parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall(t,1);}}}function Km(t={}){let e="solve-knowledge",o="knowledge",r=chunkXDXIPVZB_cjs.F(`${e}:${o}`),{resolver:n,pluginFunction:i}=re({namespace:"knowledge",pluginFunctionIndex:r,staleTimeMs:t.staleTimeMs??300*1e3,fetchQuery:async(a,s)=>{if(!t.answerQuery)return chunk75JLWK4L_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 chunk75JLWK4L_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:zm(o)},pluginFunctions:{[o]:i},asyncResolvers:[n]}}var no=class{constructor(){this.category="Lines";}parse(e,o,r){r.emitPluginCall("prev",0);}};var io=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 dt=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 Me=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,r){r.emitPluginCall(this.isAverage?"averageAbove":"totalAbove",0);}};var af=chunk5IJD5L3O_cjs.c("LINE_REF"),sf=chunk5IJD5L3O_cjs.c("SUM_RANGE_CALL"),mf=chunk5IJD5L3O_cjs.c("AVERAGE_RANGE_CALL");function Wm(){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:[$m(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:[$m(r.value,o)],ruleName:"lines:line-ref"}}return null}}}function $m(t,e){return new chunkUSQ4KL6S_cjs.a("LINE_REF",af,t,t,e.offset,0,e.line,e.col)}function Ym(){return {name:"lines:range-call",priority:80,shape:[{types:["IDENT"],values:["sum","total","average"]},{types:["LPAREN"]}],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"?mf:sf;return {consumed:1,replacement:[new chunkUSQ4KL6S_cjs.a(n,i,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"lines:range-call"}}}}function ao(t,e){return t===void 0?chunk75JLWK4L_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet (forward reference, or out of range)`):t.type===12?chunk75JLWK4L_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):t.type===13?chunk75JLWK4L_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function Be(t){return t?.getLineResult?null:chunk75JLWK4L_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 jm(t,e){let o=Be(e);if(o)return o;let r=e.lineIndex-1,n=e.getLineResult(r);return ao(n,r)??n}function Xm(t,e){let o=Be(e);if(o)return o;let r=t[0].toNumber(),n=e.getLineResult(r);return ao(n,r)??n}function Qm(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=ao(f,c);if(T)return T;if(f.type!==0&&f.type!==6)return chunk75JLWK4L_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 chunk75JLWK4L_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?chunk75JLWK4L_cjs.u(u,a):chunk75JLWK4L_cjs.n(u)}function qm(t,e){let o=Be(e);return o||Qm(t[0].toNumber(),t[1].toNumber(),e,false)}function Zm(t,e){let o=Be(e);return o||Qm(t[0].toNumber(),t[1].toNumber(),e,true)}function Jm(t,e){let o=t.isLineBoundary;if(!o)return chunk75JLWK4L_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=ao(u,l);if(c)return c;if(u.type!==0&&u.type!==6)return chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_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?chunk75JLWK4L_cjs.u(s,i):chunk75JLWK4L_cjs.n(s)}function el(t,e){let o=Be(e);return o||Jm(e,false)}function tl(t,e){let o=Be(e);return o||Jm(e,true)}var zn={name:"solve-lines",lexerVocabulary:{keywords:{prev:"PREV"}},phrases:{"total above":"TOTAL_ABOVE","sum above":"SUM_ABOVE","average above":"AVERAGE_ABOVE"},normalizerRules:[Wm(),Ym()],prefixParselets:{PREV:new no,LINE_REF:new io,SUM_RANGE_CALL:new dt(false),AVERAGE_RANGE_CALL:new dt(true),TOTAL_ABOVE:new Me(false),SUM_ABOVE:new Me(false),AVERAGE_ABOVE:new Me(true)},pluginFunctions:{prev:jm,lineRef:Xm,sumRange:qm,averageRange:Zm,totalAbove:el,averageAbove:tl}};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 chunkCO2BI6WL_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"&&lf.has(a.value.toLowerCase())){e.consume();continue}break}r.emitOpcode(13),r.emitString(i.value),r.emitPluginCall(this.pluginFnName,1);}},lf=new Set(["the","table","above"]);function rl(t){return t.trimStart().startsWith("|")}function uf(t){let e=t.trim();return e.length===0||!e.includes("-")||!e.includes("|")?false:/^[|\s:-]+$/.test(e)}function ol(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 cf(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 nl(t,e){let o=-1;for(let s=e-1;s>=1;s--){let l=t(s);if(l===void 0)break;if(rl(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||!rl(s))break;r--;}let n=-1;for(let s=r;s<=o;s++)if(uf(t(s))){n=s;break}if(n===-1||n===r)return null;let i=ol(t(n-1)),a=[];for(let s=n+1;s<=o;s++)a.push(ol(t(s)));return {header:i,rows:a}}function il(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 al(t,e){let o=[];for(let r of t.rows){let n=cf(r[e]);n!==null&&o.push(n);}return o}var so={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 mo(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 pf(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(mo(e,false));case "sampleStdev":return Math.sqrt(mo(e,true));case "variance":return mo(e,false);case "sampleVariance":return mo(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 K(t,e,o){let r=o?.getLineText;if(!r||o.lineIndex<1)return chunk75JLWK4L_cjs.P(so.TABLE_NO_DOCUMENT,"Reading a table column needs a real document, which the single-expression path (evaluateExpression) does not have");let n=nl(r,o.lineIndex);if(!n)return chunk75JLWK4L_cjs.P(so.TABLE_NOT_FOUND,'No markdown table found above this line (a table row starts with "|", and needs a "|---|" separator under its header)');let i=il(n.header,e);if(i===-1){let s=n.header.map(l=>`"${l}"`).join(", ");return chunk75JLWK4L_cjs.P(so.TABLE_COLUMN_NOT_FOUND,`The table above has no column named "${e}". Its columns are: ${s}`)}let a=al(n,i);return t==="count"?chunk75JLWK4L_cjs.n(a.length):a.length===0?chunk75JLWK4L_cjs.P(so.TABLE_COLUMN_NO_NUMERIC_CELLS,`Column "${e}" has no plain-number cells to aggregate (currency and unit cells are not read yet)`):chunk75JLWK4L_cjs.n(pf(t,a))}function $(t){let e=t[0];return e&&e.type===3&&typeof e.value=="string"?e.value:String(e?.value??"")}function sl(t,e){return K("sum",$(t),e)}function ml(t,e){return K("average",$(t),e)}function ll(t,e){return K("min",$(t),e)}function ul(t,e){return K("max",$(t),e)}function cl(t,e){return K("count",$(t),e)}function pl(t,e){return K("median",$(t),e)}function fl(t,e){return K("stdev",$(t),e)}function dl(t,e){return K("sampleStdev",$(t),e)}function El(t,e){return K("variance",$(t),e)}function Tl(t,e){return K("sampleVariance",$(t),e)}function Nl(t,e){return K("spread",$(t),e)}function yl(t,e){return K("mode",$(t),e)}var Kn={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:sl,TABLE_COLUMN_AVERAGE:ml,TABLE_COLUMN_MIN:ll,TABLE_COLUMN_MAX:ul,TABLE_COLUMN_COUNT:cl,TABLE_COLUMN_MEDIAN:pl,TABLE_COLUMN_STDEV:fl,TABLE_COLUMN_SAMPLE_STDEV:dl,TABLE_COLUMN_VARIANCE:El,TABLE_COLUMN_SAMPLE_VARIANCE:Tl,TABLE_COLUMN_SPREAD:Nl,TABLE_COLUMN_MODE:yl}};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 lo(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var gl={TOTAL_OF:"TAG_SUM",COUNT_OF:"TAG_COUNT",AVERAGE_OF:"TAG_AVERAGE"},ff=new Set(["total","sum","count","average"]);function Pl(t=80){return {name:"tags:aggregate",priority:t,shape:[{types:["TOTAL_OF","COUNT_OF","AVERAGE_OF","IDENT"]}],match(e,o){let r=e[o];if(r===void 0)return null;let n=gl[r.type];if(n!==void 0){let i=e[o+1];return i?.type!=="TAG"?null:{consumed:2,replacement:[chunkSGIDBZ4T_cjs.b(n,i.value??"",[r,i])],ruleName:"tags:aggregate"}}if(r.type==="IDENT"&&lo(r)==="sum"){let i=e[o+1],a=e[o+2];return lo(i)!=="of"||a?.type!=="TAG"?null:{consumed:3,replacement:[chunkSGIDBZ4T_cjs.b("TAG_SUM",a.value??"",[r,i,a])],ruleName:"tags:aggregate"}}return null}}}function _l(t=40){return {name:"tags:strip",priority:t,shape:[{types:["TAG"]}],match(e,o){if(e[o]?.type!=="TAG")return null;let r=e[o-1];return r!==void 0&&(gl[r.type]!==void 0||lo(r)==="of"&&ff.has(lo(e[o-2])))?null:{consumed:1,replacement:[],ruleName:"tags:strip"}}}}function df(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Al(t,e){if(e==="")return false;let r=new RegExp(`(?:^|[^0-9A-Za-z_])#${df(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 Ef(t,e){return t===void 0?chunk75JLWK4L_cjs.P("LINE_NOT_YET_EVALUATED",`Line ${e} has not been evaluated yet`):t.type===12?chunk75JLWK4L_cjs.P("LINE_RESULT_PENDING",`Line ${e}'s result is still resolving`):t.type===13?chunk75JLWK4L_cjs.P("LINE_RESULT_ERROR",`Line ${e} has an error`):null}function $n(t){return !t?.getLineResult||!t.getLineText?chunk75JLWK4L_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 Wn(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),A=Ef(E,T);if(A)return A;if(o!=="count"){if(E.type!==0&&E.type!==6)return chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_cjs.n(l);if(l===0)return chunk75JLWK4L_cjs.P("TAG_EMPTY",`No lines are tagged #${e}.`);let f=o==="average"?s/l:s;return c?chunk75JLWK4L_cjs.u(f,u):chunk75JLWK4L_cjs.n(f)}function xl(t,e){let o=$n(e);return o||Wn(e,String(t[0].value),"sum")}function Rl(t,e){let o=$n(e);return o||Wn(e,String(t[0].value),"average")}function Ol(t,e){let o=$n(e);return o||Wn(e,String(t[0].value),"count")}var Yn={name:"solve-tags",normalizerRules:[Pl(),_l()],prefixParselets:{TAG_SUM:new Ue("sum"),TAG_AVERAGE:new Ue("average"),TAG_COUNT:new Ue("count")},pluginFunctions:{sum:xl,average:Rl,count:Ol}};var Et=class{constructor(e){this.fn=e;this.category="Payroll";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitPluginCall(this.fn,1);}},Tt=class{constructor(e){this.fn=e;this.category="Payroll";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall(this.fn,1);}};function Tf(t,e){if(t<=e.personalAllowanceTaperFrom)return e.personalAllowance;let o=(t-e.personalAllowanceTaperFrom)/2;return Math.max(0,e.personalAllowance-o)}function Nf(t,e){let o=Math.max(0,t-Tf(t,e)),r=Math.min(o,e.basicRateLimit),n=Math.min(Math.max(0,o-e.basicRateLimit),e.higherRateLimit-e.basicRateLimit),i=Math.max(0,o-e.higherRateLimit);return r*e.basicRate+n*e.higherRate+i*e.additionalRate}function yf(t,e){if(t<=e.niPrimaryThreshold)return 0;let o=Math.min(t,e.niUpperEarningsLimit)-e.niPrimaryThreshold,r=Math.max(0,t-e.niUpperEarningsLimit);return o*e.niMainRate+r*e.niUpperRate}function jn(t,e){return t-Nf(t,e)-yf(t,e)}var gf=1920;function hl(t){return t/gf}var Pf={personalAllowance:12570,personalAllowanceTaperFrom:1e5,basicRateLimit:37700,higherRateLimit:125140,basicRate:.2,higherRate:.4,additionalRate:.45,niPrimaryThreshold:12570,niUpperEarningsLimit:50270,niMainRate:.08,niUpperRate:.02},Xn=Pf;function Qn(t,e){let o=e(t.toNumber());return t.type===6?chunk75JLWK4L_cjs.u(o,t.unit):chunk75JLWK4L_cjs.n(o)}var qn={name:"solve-payroll",phrases:{"take home on":"TAKE_HOME_ON","hourly for":"HOURLY_FOR","after tax":"AFTER_TAX","salary after tax":"AFTER_TAX","per month after tax":"AFTER_TAX_MONTHLY","monthly after tax":"AFTER_TAX_MONTHLY","salary per month after tax":"AFTER_TAX_MONTHLY"},prefixParselets:{TAKE_HOME_ON:new Et("payrollTakeHome"),HOURLY_FOR:new Et("payrollHourly")},infixParselets:{AFTER_TAX:new Tt("payrollTakeHome"),AFTER_TAX_MONTHLY:new Tt("payrollTakeHomeMonthly")},pluginFunctions:{payrollTakeHome:t=>Qn(t[0],e=>jn(e,Xn)),payrollTakeHomeMonthly:t=>Qn(t[0],e=>jn(e,Xn)/12),payrollHourly:t=>Qn(t[0],hl)},tokenCategories:{TAKE_HOME_ON:"function",HOURLY_FOR:"function",AFTER_TAX:"operator",AFTER_TAX_MONTHLY:"operator"}};function _f(t){return {category:"Shopping",bindingPower:chunkEN3CDYOS_cjs.a.Conditional,parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),n.emitPluginCall(t,2);}}}function Af(t){let e=t[0],o=t[1],r=e.toNumber(),n=o.toNumber();if(e.type===6||o.type===6){if(e.type!==6||o.type!==6||e.unit===void 0||o.unit===void 0)return chunk75JLWK4L_cjs.P("VS_INCOMPARABLE","vs: compare two amounts of the same kind");if(e.unit!==o.unit){if(!chunkZKFCKAIX_cjs.d(o.unit,e.unit))return chunk75JLWK4L_cjs.P("VS_INCOMPARABLE",`vs: ${e.unit} and ${o.unit} are not the same kind of thing`);n=chunkZKFCKAIX_cjs.e(n,o.unit,e.unit);}}if(Math.abs(r-n)<=Math.max(Math.abs(r),Math.abs(n))*1e-9)return chunk75JLWK4L_cjs.t("the same");let i=r<n,a=Math.min(r,n),s=Math.max(r,n),l=Math.round((s-a)/s*100);return chunk75JLWK4L_cjs.t(`the ${i?"first":"second"} is cheaper, ${l}% less`)}var Zn={name:"solve-shopping",lexerVocabulary:{keywords:{vs:"VS_COMPARE",versus:"VS_COMPARE"}},infixParselets:{VS_COMPARE:_f("shoppingCompare")},pluginFunctions:{shoppingCompare:Af},tokenCategories:{VS_COMPARE:"operator"}};var uo=class{constructor(){this.category="operator";this.bindingPower=chunkEN3CDYOS_cjs.a.Uncertainty;}parse(e,o,r,n){e.parseExpression(this.bindingPower,n),n.emitOpcode(28);}};function Il(t=90){return {name:"uncertainty:ascii-plus-minus",priority:t,shape:[{types:["PLUS"]},{types:["SLASH"]}],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:[chunkSGIDBZ4T_cjs.b("PLUS_MINUS","\xB1",[r,n,i])],ruleName:"uncertainty:ascii-plus-minus"}}}}var Jn={name:"solve-uncertainty",infixParselets:{PLUS_MINUS:new uo},normalizerRules:[Il()]};var Cl=1e-9,Sl=1e9,xf=100,Rf=1e-9,Of=1e-9,hf=1e-12,If=1e-9,co="goalseek";function Ll(t,e){let o=e?.evaluateLineWithBinding,r=e?.getLineReads;if(!o||!r)return chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_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,chunk75JLWK4L_cjs.K(chunkJ7ABVGZH_cjs.q(i)),true);if(u.type===9){let f=Cf(u.value,s,i);if(f!==null)return chunk75JLWK4L_cjs.n(f)}let c=e.goalSeekMaxIterations??xf;return Sf(o,n,i,s,c)}function Cf(t,e,o){let r=chunkJ7ABVGZH_cjs.p(chunkJ7ABVGZH_cjs.d(e)),n;try{n=chunkXDXIPVZB_cjs.d(t,r,o);}catch{return null}if(n.kind!=="roots")return null;let i=[];for(let l of n.exact){let u=chunkJ7ABVGZH_cjs.Q(l);if(u.kind==="const"){let c=chunkJ7ABVGZH_cjs.e(u.value);Number.isFinite(c)&&i.push(c);}}for(let l of n.approximate)Math.abs(l.im)<=If&&Number.isFinite(l.re)&&i.push(l.re);if(i.length===0)return null;let a=i.filter(l=>l>=Cl&&l<=Sl),s=a.length>0?a:i;return s.sort((l,u)=>Math.abs(l)-Math.abs(u)),s[0]}function Sf(t,e,o,r,n){let i=N=>{let E=t(e,o,chunk75JLWK4L_cjs.n(N),false);if(E.type===13)return {error:E};if(E.type!==0&&E.type!==6)return {error:chunk75JLWK4L_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 A=E.toNumber();return Number.isFinite(A)?{value:A}:{error:chunk75JLWK4L_cjs.P("GOAL_SEEK_NON_FINITE",`Line ${e}'s result is not finite when ${o} is ${N}.`)}},a=Cl,s=Sl,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(Rf,Math.abs(r)*Of),f=l.value-r,T=u.value-r;if(Math.abs(f)<=c)return chunk75JLWK4L_cjs.n(a);if(Math.abs(T)<=c)return chunk75JLWK4L_cjs.n(s);if(Math.sign(f)===Math.sign(T))return chunk75JLWK4L_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,A=i(E);if("error"in A)return A.error;let R=A.value-r;if(Math.abs(R)<=c)return chunk75JLWK4L_cjs.n(E);if(s-a<=hf)return chunk75JLWK4L_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(R)===Math.sign(f)?(a=E,f=R):s=E;}return chunk75JLWK4L_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 po=class{constructor(){this.category="GoalSeek";}parse(e,o,r){let n=e.peek();if(!n||n.type!=="LINE_REF")throw chunkCO2BI6WL_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 chunkCO2BI6WL_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 chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),r.emitPluginCall(co,3);}};var Lf=chunk5IJD5L3O_cjs.c("GOAL_SEEK");function wl(t=75){return {name:"goalseek:solve-line",priority:t,shape:[{types:["IDENT"],values:["solve"]},{types:["LINE_REF"]}],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 chunkUSQ4KL6S_cjs.a("GOAL_SEEK",Lf,r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"goalseek:solve-line"}}}}var ei={name:"solve-goalseek",normalizerRules:[wl()],prefixParselets:{GOAL_SEEK:new po},pluginFunctions:{[co]:Ll}};var fo=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 M(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 Z(t,e){return chunk75JLWK4L_cjs.P(Te.COLOUR_BAD_ARGUMENTS,`${t}(...) expects ${e}`)}function X(t){return chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,`${t}(...) expects a colour as its first argument`)}function vl(t){let e=t[0];if(!e||e.type!==3||typeof e.value!="string")return Z("color",'a string, e.g. color("#ff0000") or color("red")');let o=chunk5TVI2UPZ_cjs.c(e.value);return o?chunk75JLWK4L_cjs.G(o):chunk75JLWK4L_cjs.P(Te.COLOUR_INVALID,`"${e.value}" is not a hex colour (#rgb, #rgba, #rrggbb, #rrggbbaa) or a CSS colour name`)}function wf(t){return t.length!==3?Z("rgb","three numbers: rgb(red, green, blue)"):chunk75JLWK4L_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 vf(t){return t.length!==4?Z("rgba","four numbers: rgba(red, green, blue, alpha)"):chunk75JLWK4L_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 kf(t){if(t.length!==3)return Z("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 chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hsl"})}function Mf(t){if(t.length!==4)return Z("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 chunk75JLWK4L_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=M(o[0]);return r?o.length<2?Z(t,`a colour and an amount, e.g. ${t}(#3366cc, 20%)`):chunk75JLWK4L_cjs.G(e(r,U(o[1]))):X(t)}}var Bf=Ne("lighten",chunk5TVI2UPZ_cjs.j),Uf=Ne("darken",chunk5TVI2UPZ_cjs.k),Df=Ne("saturate",chunk5TVI2UPZ_cjs.l),kl=Ne("desaturate",chunk5TVI2UPZ_cjs.m);function ti(t){let e=M(t[0]);return e?t.length<2?Z("rotate","a colour and a hue angle in degrees, e.g. rotate(#ff0000, 90)"):chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.n(e,t[1].toNumber())):X("rotate")}function bf(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.o(e)):X("complement")}function Ml(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.p(e)):X("grayscale")}function Bl(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.q(e,t.length>1?U(t[1]):1)):X("invert")}function Vf(t){let e=M(t[0]),o=M(t[1]);return !e||!o?chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"mix(...) expects two colours to blend"):chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.r(e,o,t.length>2?U(t[2]):.5))}function ri(t){let e=M(t[0]);return e?t.length<2?chunk75JLWK4L_cjs.n(e.a):chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.s(e,U(t[1]))):X("alpha")}function Ff(t){let e=M(t[0]),o=M(t[1]);return !e||!o?chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"contrast(...) expects two colours"):chunk75JLWK4L_cjs.n(chunk5TVI2UPZ_cjs.i(e,o))}function Hf(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.n(chunk5TVI2UPZ_cjs.h(e)):X("luminance")}function De(t,e){return o=>{let r=M(o[0]);return r?chunk75JLWK4L_cjs.n(e(r)):X(t)}}var Gf=De("red",t=>t.r),zf=De("green",t=>t.g),Kf=De("blue",t=>t.b),$f=De("hue",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).h),Wf=De("saturation",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).s*100),Yf=De("lightness",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).l*100);function Ul(t){if(t.length!==3)return Z("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 chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}function jf(t){if(t.length!==4)return Z("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 chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:chunk5TVI2UPZ_cjs.b(U(t[3])),format:"hex"})}function Xf(t){if(t.length!==3)return Z("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 chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}var Qf=Ne("tint",chunk5TVI2UPZ_cjs.v),qf=Ne("shade",chunk5TVI2UPZ_cjs.w),Zf=Ne("tone",chunk5TVI2UPZ_cjs.x);function Jf(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.L(chunk5TVI2UPZ_cjs.y(e)):X("isdark")}function ed(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.L(!chunk5TVI2UPZ_cjs.y(e)):X("islight")}function oi(t){let e=M(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.z(e)):X("readable")}function td(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 rd(t){let e=M(t[0]),o=M(t[1]);return !e||!o?chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"iscontrastcompliant(...) expects two colours"):chunk75JLWK4L_cjs.L(chunk5TVI2UPZ_cjs.i(e,o)>=td(t[2]))}function Dl(t){let e=M(t[0]),o=M(t[1]);return !e||!o?chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"wcaglevel(...) expects two colours"):chunk75JLWK4L_cjs.t(chunk5TVI2UPZ_cjs.B(e,o))}var ye={color:vl,colour:vl,rgb:wf,rgba:vf,hsl:kf,hsla:Mf,lighten:Bf,darken:Uf,saturate:Df,desaturate:kl,desat:kl,rotate:ti,spin:ti,adjusthue:ti,complement:bf,grayscale:Ml,greyscale:Ml,invert:Bl,mix:Vf,alpha:ri,opacity:ri,fade:ri,contrast:Ff,luminance:Hf,red:Gf,green:zf,blue:Kf,hue:$f,saturation:Wf,lightness:Yf,hsv:Ul,hsb:Ul,hsva:jf,hwb:Xf,tint:Qf,shade:qf,tone:Zf,negate:Bl,isdark:Jf,islight:ed,readable:oi,contrastcolor:oi,contrastcolour:oi,iscontrastcompliant:rd,wcaglevel:Dl,wcag:Dl};var Eo=class{constructor(){this.category="Colour";}parse(e,o,r){let n=o.value.toLowerCase();if(ye[n]===void 0)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var bl=new Set(Object.keys(ye));function Vl(t=80){return {name:"colour:call",priority:t,shape:[{types:["IDENT"],values:[...bl]},{types:["LPAREN"]}],match(e,o){let r=e[o];if(!r||r.type!=="IDENT")return null;let n=r.value.toLowerCase();return !bl.has(n)||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunkUSQ4KL6S_cjs.a("COLOUR_CALL",chunk5IJD5L3O_cjs.c("COLOUR_CALL"),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"colour:call"}}}}var To=t=>e=>{if(e.type!==14)return e;let o=e.value;return chunk75JLWK4L_cjs.G({r:o.r,g:o.g,b:o.b,a:o.a,format:t})},od=Object.keys(ye).map(t=>({label:t,category:"function",detail:"colour"})),ni={name:"solve-colour",prefixParselets:{HEX_COLOUR:new fo,COLOUR_CALL:new Eo},normalizerRules:[Vl()],pluginFunctions:ye,asConverters:{rgb:To("rgb"),rgba:To("rgba"),hsl:To("hsl"),hsla:To("hsla")},completionItems:od};var ii=32;function nd(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 id(t){let e=t.max-t.min+1,o=Math.min(e,ii),r=[];for(let n=0;n<o;n++)r.push(t.min+Math.round(n*(e-1)/(o-1)));return r}function ad(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 Fl(t){let e=null;if(t.type===7)e=nd(t.value);else if(t.type===8){let a=t.value;e=a.max-a.min+1>=2?id(a):null;}if(!e||e.length<2)return null;let o=ad(e,ii),r=Math.min(...e),n=Math.max(...e),i=e.length<=ii?`[${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 No=class{constructor(){this.category="Plot";}parse(e,o,r){let n=sd(e),i=new chunkEN3CDYOS_cjs.d(r.pluginIndexMap);e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,i),e.setBuilder(r);let a=i.build();if(a.hasAsync)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Conditional,r),e.consume("TO"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,r);let s=r.emitAnonymousBody(["x"],a);r.emitOpcode(160),r.emitIndex(s),r.emitString(n);}};function sd(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 Hl="PLOT",md=chunk5IJD5L3O_cjs.c(Hl),ld=new Set(["NUMBER","IDENT","FUNC","UNIT","LPAREN","PI","E"]);function Gl(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||!ld.has(i.type)?null:{consumed:1,replacement:[new chunkUSQ4KL6S_cjs.a(Hl,md,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var ai={name:"solve-chart",asConverters:{sparkline:t=>{let e=Fl(t);return e?chunk75JLWK4L_cjs.I(e):chunk75JLWK4L_cjs.P("SPARKLINE_NOT_A_SERIES",'"as sparkline" expects a numeric vector or a range, with at least two values')}},prefixParselets:{PLOT:new No},normalizerRules:[Gl()],tokenCategories:{PLOT:"keyword"}};var Nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function si(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+=Nt[n>>2],o+=Nt[(n&3)<<4|i>>4],o+=r+1<e.length?Nt[(i&15)<<2|a>>6]:"=",o+=r+2<e.length?Nt[a&63]:"=";}return o}function mi(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=Nt.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 zl(t){return encodeURIComponent(t)}function Kl(t){try{return decodeURIComponent(t)}catch{return null}}function $l(t){return Array.from(new TextEncoder().encode(t)).map(e=>e.toString(16).padStart(2,"0")).join(" ")}function li(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}}function ud(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),o=e.length%4;return o===0?e:e+"=".repeat(4-o)}function ui(t){let e=t.trim().split(".");if(e.length<2||e[1]==="")return null;let o=mi(ud(e[1]));if(o===null)return null;try{let r=JSON.parse(o);return r===null||typeof r!="object"||Array.isArray(r)?null:JSON.stringify(r)}catch{return null}}function ci(t){let e=t.trim().replace(/^\?/,"");if(e==="")return "{}";let o={};for(let r of e.split("&")){if(r==="")continue;let n=r.indexOf("="),i=n===-1?r:r.slice(0,n),a=n===-1?"":r.slice(n+1);try{o[decodeURIComponent(i.replace(/\+/g," "))]=decodeURIComponent(a.replace(/\+/g," "));}catch{return null}}return JSON.stringify(o)}var yo=class{constructor(){this.category="Encoding";this.bindingPower=chunkEN3CDYOS_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 be=class{constructor(e){this.fn=e;this.category="Encoding";}parse(e,o,r){e.consume("LPAREN"),e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),e.consume("RPAREN"),r.emitPluginCall(this.fn,1);}};function Po(t){return t.type===3?t.value:null}function go(t,e){return o=>{let r=Po(o);return r===null?chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",`"as ${t}" expects text (a "quoted string")`):chunk75JLWK4L_cjs.t(e(r))}}var cd={base64:mi,url:Kl,"hex bytes":li,hexbytes:li,jwt:ui,query:ci},pi={name:"solve-encoding",phrases:{"hex bytes":"CONVERTER_NAME","from base64":"FROM_ENCODING","from url":"FROM_ENCODING","from hex bytes":"FROM_ENCODING","from jwt":"FROM_ENCODING","from query":"FROM_ENCODING"},asConverters:{base64:go("base64",si),url:go("url",zl),"hex bytes":go("hex bytes",$l)},infixParselets:{FROM_ENCODING:new yo},prefixParselets:{BASE64_FN:new be("base64"),JWT_FN:new be("jwt"),QUERY_FN:new be("query")},callFusions:{base64:"BASE64_FN",jwt:"JWT_FN",query:"QUERY_FN"},pluginFunctions:{base64:t=>go("base64",si)(t[0]),jwt:t=>{let e=Po(t[0]);if(e===null)return chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",'jwt(...) expects text (a "quoted string")');let o=ui(e);return o===null?chunk75JLWK4L_cjs.P("ENCODING_DECODE_FAILED","jwt(...): the input is not a valid JSON Web Token"):chunk75JLWK4L_cjs.t(o)},query:t=>{let e=Po(t[0]);if(e===null)return chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",'query(...) expects text (a "quoted string")');let o=ci(e);return o===null?chunk75JLWK4L_cjs.P("ENCODING_DECODE_FAILED","query(...): the input is not a valid query string"):chunk75JLWK4L_cjs.t(o)},fromEncoding:t=>{let e=Po(t[0]),o=String(t[1].value??"");if(e===null)return chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",`"from ${o}" expects text (a "quoted string")`);let r=cd[o];if(!r)return chunk75JLWK4L_cjs.P("UNKNOWN_ENCODING",`"from ${o}" is not a known encoding (try base64, url or hex bytes)`);let n=r(e);return n===null?chunk75JLWK4L_cjs.P("ENCODING_DECODE_FAILED",`"from ${o}": the input is not valid ${o}`):chunk75JLWK4L_cjs.t(n)}},tokenCategories:{BASE64_FN:"function",JWT_FN:"function",QUERY_FN:"function"}};var _o=class{constructor(){this.category="IP";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("ipLiteral",1);}};var Ve=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(chunkEN3CDYOS_cjs.a.Prefix,r),r.emitPluginCall(this.pluginFn,1);}};var Wl="IP_CIDR",pd=chunk5IJD5L3O_cjs.c(Wl),fd=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{1,2})?/,dd=8;function Yl(t=72){let e="ip:ip-cidr-literal";return {name:e,priority:t,shape:[{types:["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<dd;E++){let A=o[E];if(A.sourceEnd!==void 0||A.offset!==a||A.type!=="NUMBER"&&A.type!=="SLASH")break;i+=A.text??"",a=A.offset+(A.text?.length??0),s.push(A);}let l=fd.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 chunkUSQ4KL6S_cjs.a(Wl,pd,T,l[0],n.offset,0,n.line,n.col,n.offset+l[0].length);return {consumed:c,replacement:[N],ruleName:e}}}}function yt(t,e){return t.type===17?t.value:chunk75JLWK4L_cjs.P("IP_EXPECTED",`"${e}" expects an IP address or subnet (e.g. 192.168.1.0/24)`)}function jl(t){let[e,o]=String(t[0].value??"").split("|"),r={...e!==""?{addr:Number(e)}:{},...o!==""?{prefix:Number(o)}:{}};return chunk75JLWK4L_cjs.J(r)}function Xl(t){let e=yt(t[0],"hosts in");return e instanceof chunk75JLWK4L_cjs.m?e:e.prefix===void 0?chunk75JLWK4L_cjs.P("IP_NO_PREFIX",'"hosts in" needs a subnet with a prefix, e.g. 192.168.1.0/24'):chunk75JLWK4L_cjs.n(chunk5TVI2UPZ_cjs.F(e.prefix))}function Ql(t){let e=yt(t[0],"netmask of");return e instanceof chunk75JLWK4L_cjs.m?e:e.prefix===void 0?chunk75JLWK4L_cjs.P("IP_NO_PREFIX",'"netmask of" needs a prefix, e.g. /24 or 192.168.1.0/24'):chunk75JLWK4L_cjs.J({addr:chunk5TVI2UPZ_cjs.E(e.prefix)})}function ql(t){let e=yt(t[0],"broadcast of");return e instanceof chunk75JLWK4L_cjs.m?e:e.addr===void 0||e.prefix===void 0?chunk75JLWK4L_cjs.P("IP_NEEDS_ADDRESS_AND_PREFIX",'"broadcast of" needs an address and a prefix, e.g. 192.168.1.0/24'):chunk75JLWK4L_cjs.J({addr:chunk5TVI2UPZ_cjs.G(e.addr,e.prefix)})}function Zl(t){let e=yt(t[0],"in");if(e instanceof chunk75JLWK4L_cjs.m)return e;let o=yt(t[1],"in");return o instanceof chunk75JLWK4L_cjs.m?o:e.addr===void 0?chunk75JLWK4L_cjs.P("IP_EXPECTED_ADDRESS",'"in" expects an address on the left'):o.addr===void 0||o.prefix===void 0?chunk75JLWK4L_cjs.P("IP_EXPECTED_BLOCK",'"in" expects a subnet on the right, e.g. 10.0.0.0/8'):chunk75JLWK4L_cjs.L(chunk5TVI2UPZ_cjs.H(e.addr,o.addr,o.prefix))}function Jl(t){if(t.type===17){let e=t.value;return chunk75JLWK4L_cjs.n(e.addr??0)}return chunk75JLWK4L_cjs.n(Math.trunc(t.toNumber()))}var fi={name:"solve-ip",phrases:{"hosts in":"HOSTS_IN","netmask of":"NETMASK_OF","broadcast of":"BROADCAST_OF"},prefixParselets:{IP_CIDR:new _o,HOSTS_IN:new Ve("hostsIn"),NETMASK_OF:new Ve("netmaskOf"),BROADCAST_OF:new Ve("broadcastOf")},normalizerRules:[Yl()],pluginFunctions:{ipLiteral:jl,hostsIn:Xl,netmaskOf:Ql,broadcastOf:ql,ipInCidr:Zl},asConverters:{int:Jl},tokenCategories:{IP_CIDR:"number",HOSTS_IN:"keyword",NETMASK_OF:"keyword",BROADCAST_OF:"keyword"}};var Ed=chunk5IJD5L3O_cjs.c("UNIT");function eu(t=82){let e="fuel:l-per-100km";return {name:e,priority:t,shape:[{types:["UNIT","IDENT"],values:["l"]},{types:["SLASH"]}],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 chunkUSQ4KL6S_cjs.a("UNIT",Ed,"l100km","l/100km",n.offset,0,n.line,n.col)],ruleName:e}}}}var di={name:"solve-fuel",normalizerRules:[eu()]};var Td=chunk5IJD5L3O_cjs.c("UNIT");function tu(t=82){let e="derived:acceleration";return {name:e,priority:t,shape:[{types:["UNIT"],values:["m"]},{types:["SLASH"]}],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 chunkUSQ4KL6S_cjs.a("UNIT",Td,"mps2","m/s^2",n.offset,0,n.line,n.col)],ruleName:e}}}}function D(t){return e=>e.type!==6||!e.unit?chunk75JLWK4L_cjs.P("AS_UNIT_EXPECTED_QUANTITY",`"as ${t}" expects a quantity with a unit`):e.unit===t?e:chunkZKFCKAIX_cjs.d(e.unit,t)?chunk75JLWK4L_cjs.u(chunkZKFCKAIX_cjs.e(e.toNumber(),e.unit,t),t):chunk75JLWK4L_cjs.P("AS_UNIT_INCOMPATIBLE",`${e.unit} cannot be expressed as ${t}: they do not measure the same thing`)}var Ei={name:"solve-derived-units",normalizerRules:[tu()],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 Ti(t){return [...t].length}function ru(t){return t.trim()}function ou(t){return [...t].reverse().join("")}function nu(t,e){return t.includes(e)}function iu(t,e){return t.startsWith(e)}function au(t,e){return t.endsWith(e)}function su(t,e,o){return e===""?t:t.split(e).join(o)}function mu(t,e){let o=Math.trunc(e);return o<=0?"":t.repeat(o)}function Ao(t){return t.toUpperCase()}function xo(t){return t.toLowerCase()}function Ro(t){return t.replace(/\S+/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function Oo(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function lu(t){let e=t.trim();return e===""?0:e.split(/\s+/).length}function uu(t){return t===""?0:t.split(/\r\n|\r|\n/).length}function se(t){return t?.type===3?t.value:null}function gt(t){return chunk75JLWK4L_cjs.P("TEXT_EXPECTED",`${t} expects text (a "quoted string")`)}function ho(t,e){return o=>{let r=se(o[0]);return r===null?gt(t):chunk75JLWK4L_cjs.n(e(r))}}function Fe(t,e){return o=>{let r=se(o[0]);return r===null?gt(t):chunk75JLWK4L_cjs.t(e(r))}}function Ni(t,e){return o=>{let r=se(o[0]),n=se(o[1]);return r===null||n===null?gt(t):chunk75JLWK4L_cjs.L(e(r,n))}}var cu={textLength:ho("length",Ti),textWordCount:ho("words in",lu),textCharCount:ho("characters in",Ti),textLineCount:ho("lines in",uu),textTrim:Fe("trim",ru),textReverse:Fe("reverse",ou),textUpper:Fe('"as upper"',Ao),textLower:Fe('"as lower"',xo),textTitle:Fe('"as title"',Ro),textSlug:Fe('"as slug"',Oo),textContains:Ni("contains",nu),textStartsWith:Ni("starts with",iu),textEndsWith:Ni("ends with",au),textReplace:t=>{let e=se(t[0]),o=se(t[1]),r=se(t[2]);return e===null||o===null||r===null?gt("replace"):chunk75JLWK4L_cjs.t(su(e,o,r))},textRepeat:t=>{let e=se(t[0]);if(e===null)return gt("repeat");let o=t[1];return o?.type!==0?chunk75JLWK4L_cjs.P("TEXT_EXPECTED","repeat expects a count (a number)"):chunk75JLWK4L_cjs.t(mu(e,o.value))}};function ge(t,e){return {category:"Text",parse(o,r,n){o.parseExpression(e,n),n.emitPluginCall(t,1);}}}function Io(t){return {category:"Text",bindingPower:chunkEN3CDYOS_cjs.a.Conditional,parse(e,o,r,n){e.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,n),n.emitPluginCall(t,2);}}}var pu={category:"Text",bindingPower:chunkEN3CDYOS_cjs.a.Conditional,parse(t,e,o,r){t.parseExpression(chunkEN3CDYOS_cjs.a.Prefix,r);let n=t.peek();n?.type==="STAR"&&(n.value??"").toLowerCase()==="times"&&t.consume(),r.emitPluginCall("textRepeat",2);}};var Co={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 So=class{constructor(){this.category="Text";}parse(e,o,r){let n=Co[o.value];if(n===void 0)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};function Lo(t,e){return o=>o.type!==3?chunk75JLWK4L_cjs.P("TEXT_EXPECTED",`"as ${t}" expects text (a "quoted string")`):chunk75JLWK4L_cjs.t(e(o.value))}var yi={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",chunkEN3CDYOS_cjs.a.Lowest),WORDS_IN:ge("textWordCount",chunkEN3CDYOS_cjs.a.Lowest),CHARACTERS_IN:ge("textCharCount",chunkEN3CDYOS_cjs.a.Lowest),LINES_IN:ge("textLineCount",chunkEN3CDYOS_cjs.a.Lowest),TRIM:ge("textTrim",chunkEN3CDYOS_cjs.a.Prefix),REVERSE:ge("textReverse",chunkEN3CDYOS_cjs.a.Prefix),TEXT_CALL:new So},infixParselets:{CONTAINS:Io("textContains"),STARTS_WITH:Io("textStartsWith"),ENDS_WITH:Io("textEndsWith"),REPEATED:pu},asConverters:{upper:Lo("upper",Ao),lower:Lo("lower",xo),title:Lo("title",Ro),slug:Lo("slug",Oo)},callFusions:Object.fromEntries(Object.keys(Co).map(t=>[t,"TEXT_CALL"])),pluginFunctions:cu,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 Pt(t){return new TextEncoder().encode(t)}function gi(t){let e="";for(let o of t)e+=o.toString(16).padStart(2,"0");return e}var Nd=(()=>{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 fu(t){let e=Pt(t),o=4294967295;for(let r of e)o=Nd[(o^r)&255]^o>>>8;return o=(o^4294967295)>>>0,o.toString(16).padStart(8,"0")}function yd(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=a,R=s,O=l,g=u;for(let P=0;P<64;P++){let C,S;P<16?(C=R&O|~R&g,S=P):P<32?(C=g&R|~g&O,S=(5*P+1)%16):P<48?(C=R^O^g,S=(3*P+5)%16):(C=O^(R|~g),S=7*P%16),C=C+A+o[P]+E[S]|0,A=g,g=O,O=R,R=R+c(C,e[P])|0;}a=a+A|0,s=s+R|0,l=l+O|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 du(t){return gi(yd(Pt(t)))}function gd(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,A=i,R=a,O=s,g=l;for(let P=0;P<80;P++){let C,S;P<20?(C=A&R|~A&O,S=1518500249):P<40?(C=A^R^O,S=1859775393):P<60?(C=A&R|A&O|R&O,S=2400959708):(C=A^R^O,S=3395469782);let Q=u(E,5)+C+g+S+c[P]|0;g=O,O=R,R=u(A,30),A=E,E=Q;}n=n+E|0,i=i+A|0,a=a+R|0,s=s+O|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 Eu(t){return gi(gd(Pt(t)))}var Pd=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 _d(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,A,R,O]=n;for(let g=0;g<64;g++){let P=i(E,6)^i(E,11)^i(E,25),C=E&A^~E&R,S=O+P+C+Pd[g]+a[g]|0,Q=i(c,2)^i(c,13)^i(c,22),ze=c&f^c&T^f&T,le=Q+ze|0;O=R,R=A,A=E,E=N+S|0,N=T,T=f,f=c,c=S+le|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]+A|0,n[6]=n[6]+R|0,n[7]=n[7]+O|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 Tu(t){return gi(_d(Pt(t)))}var V=(1n<<64n)-1n,Ad=[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 Nu(t){let e=Pt(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,A,R,O]=a;for(let g=0;g<80;g++){let P=s(E,14n)^s(E,18n)^s(E,41n),C=E&A^~E&V&R,S=O+P+C+Ad[g]+l[g]&V,Q=s(c,28n)^s(c,34n)^s(c,39n),ze=c&f^c&T^f&T,le=Q+ze&V;O=R,R=A,A=E,E=N+S&V,N=T,T=f,f=c,c=S+le&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]+A&V,a[6]=a[6]+R&V,a[7]=a[7]+O&V;}return a.map(u=>u.toString(16).padStart(16,"0")).join("")}var wo={md5:"hashMd5",sha1:"hashSha1",sha256:"hashSha256",sha512:"hashSha512",crc32:"hashCrc32"};function _t(t,e){return o=>{let r=o[0];return r?.type!==3?chunk75JLWK4L_cjs.P("HASH_EXPECTED_TEXT",`${t}(...) expects text (a "quoted string")`):chunk75JLWK4L_cjs.t(e(r.value))}}var yu={hashMd5:_t("md5",du),hashSha1:_t("sha1",Eu),hashSha256:_t("sha256",Tu),hashSha512:_t("sha512",Nu),hashCrc32:_t("crc32",fu)};var vo=class{constructor(){this.category="Hash";}parse(e,o,r){let n=wo[o.value];if(n===void 0)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var Pi={name:"solve-hash",prefixParselets:{HASH_CALL:new vo},callFusions:Object.fromEntries(Object.keys(wo).map(t=>[t,"HASH_CALL"])),pluginFunctions:yu,tokenCategories:{HASH_CALL:"function"}};var gu="0123456789abcdef";function Pu(){return gu[Math.floor(Math.random()*16)]}function xd(){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+=gu[Math.floor(Math.random()*16)&3|8]:t+=Pu();return t}function Rd(t){let e="";for(let o=0;o<t;o++)e+=Pu();return e}var _u={randomUuid:()=>chunk75JLWK4L_cjs.t(xd()),randomCoin:()=>chunk75JLWK4L_cjs.t(Math.random()<.5?"heads":"tails"),randomHex:t=>{let e=t[0];if(e?.type!==0)return chunk75JLWK4L_cjs.P("RANDOM_EXPECTED_COUNT","random hex expects a number of digits");let o=Math.trunc(e.value);return o<0?chunk75JLWK4L_cjs.P("RANDOM_EXPECTED_COUNT","random hex needs a count of 0 or more"):chunk75JLWK4L_cjs.t(Rd(o))},randomPick:t=>t.length===0?chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_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 chunk75JLWK4L_cjs.C(o.rows,o.cols,r)}};function _i(t){return {category:"Random",parse(e,o,r){r.emitPluginCall(t,0);}}}function Ai(t){return {category:"Random",parse(e,o,r){e.parseExpression(chunkEN3CDYOS_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(chunkEN3CDYOS_cjs.a.Lowest,o),r++;t.match("COMMA");)t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),r++;t.consume("RPAREN"),o.emitPluginCall("randomPick",r);}};var xi={name:"solve-random",phrases:{"random hex":"RANDOM_HEX"},lexerVocabulary:{keywords:{uuid:"UUID",coin:"COIN",shuffle:"SHUFFLE"}},prefixParselets:{UUID:_i("randomUuid"),COIN:_i("randomCoin"),RANDOM_HEX:Ai("randomHex"),SHUFFLE:Ai("randomShuffle"),PICK_CALL:Au},callFusions:{pick:"PICK_CALL"},pluginFunctions:_u,tokenCategories:{UUID:"function",COIN:"function",RANDOM_HEX:"function",SHUFFLE:"function",PICK_CALL:"function"}};function me(t){return t.reduce((e,o)=>e+o,0)/t.length}function Od(t){let e=me(t);return t.reduce((o,r)=>o+(r-e)*(r-e),0)/t.length}function hd(t){return Math.sqrt(Od(t))}function Ri(t,e){let o=me(t),r=me(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 Oi(t,e){let o=me(t),r=me(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 xu(t,e){return me(e)-Oi(t,e)*me(t)}function Ru(t,e){let o=Ri(t,e);return o*o}function Ou(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 hu(t,e){let o=hd(e);return o===0?NaN:(t-me(e))/o}function Id(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 Iu(t){return .5*(1+Id(t/Math.SQRT2))}function Cu(t){return Math.exp(-0.5*t*t)/Math.sqrt(2*Math.PI)}function Mo(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 ko(t,e){return o=>{let r=Mo(o[0]),n=Mo(o[1]);return r===null||n===null?chunk75JLWK4L_cjs.P("STAT_EXPECTED_LISTS",`${t} expects two lists, e.g. ${t} of [1, 2, 3] and [2, 4, 6]`):r.length!==n.length?chunk75JLWK4L_cjs.P("STAT_LENGTH_MISMATCH",`${t}: the two lists must be the same length (got ${r.length} and ${n.length})`):r.length<2?chunk75JLWK4L_cjs.P("STAT_TOO_FEW",`${t} needs at least two paired points`):chunk75JLWK4L_cjs.n(e(r,n))}}var Su={statCorrelation:ko("correlation",Ri),statSlope:ko("slope",Oi),statIntercept:ko("intercept",xu),statRSquared:ko("r squared",Ru),statPercentile:t=>{let e=Mo(t[0]),o=t[1];if(e===null)return chunk75JLWK4L_cjs.P("STAT_EXPECTED_LIST","percentile expects a list, e.g. percentile([1, 2, 3], 90)");if(e.length===0)return chunk75JLWK4L_cjs.P("STAT_EMPTY","percentile needs at least one value");if(o?.type!==0)return chunk75JLWK4L_cjs.P("STAT_EXPECTED_PERCENT","percentile needs a percentage, e.g. percentile([...], 90)");let r=o.value;return r<0||r>100?chunk75JLWK4L_cjs.P("STAT_PERCENT_RANGE","a percentile is between 0 and 100"):chunk75JLWK4L_cjs.n(Ou(e,r))},statZScore:t=>{let e=t[0],o=Mo(t[1]);return e?.type!==0?chunk75JLWK4L_cjs.P("STAT_EXPECTED_VALUE","zscore expects a value first, e.g. zscore(5, [1, 2, 3])"):o===null||o.length<2?chunk75JLWK4L_cjs.P("STAT_EXPECTED_LIST","zscore expects a list of at least two values"):chunk75JLWK4L_cjs.n(hu(e.value,o))},statNormalCdf:t=>{let e=t[0];return e?.type!==0?chunk75JLWK4L_cjs.P("STAT_EXPECTED_VALUE","normalcdf expects a number"):chunk75JLWK4L_cjs.n(Iu(e.value))},statNormalPdf:t=>{let e=t[0];return e?.type!==0?chunk75JLWK4L_cjs.P("STAT_EXPECTED_VALUE","normalpdf expects a number"):chunk75JLWK4L_cjs.n(Cu(e.value))}};function Bo(t){return {category:"Statistics",parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),e.consume("AND_CONJ"),e.parseExpression(chunkEN3CDYOS_cjs.a.Conjunction,r),r.emitPluginCall(t,2);}}}var Uo={correlation:"statCorrelation",slope:"statSlope",intercept:"statIntercept",rsquared:"statRSquared",percentile:"statPercentile",zscore:"statZScore",normalcdf:"statNormalCdf",normalpdf:"statNormalPdf"};var Do=class{constructor(){this.category="Statistics";}parse(e,o,r){let n=Uo[o.value];if(n===void 0)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};var hi={name:"solve-statistics",phrases:{"correlation of":"CORRELATION_OF","slope of":"SLOPE_OF","intercept of":"INTERCEPT_OF"},prefixParselets:{CORRELATION_OF:Bo("statCorrelation"),SLOPE_OF:Bo("statSlope"),INTERCEPT_OF:Bo("statIntercept"),STAT_CALL:new Do},callFusions:Object.fromEntries(Object.keys(Uo).map(t=>[t,"STAT_CALL"])),pluginFunctions:Su,tokenCategories:{CORRELATION_OF:"function",SLOPE_OF:"function",INTERCEPT_OF:"function",STAT_CALL:"function"}};var Cd=[[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"]],Lu={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};function Ii(t){if(!Number.isInteger(t)||t<1||t>3999)return null;let e="",o=t;for(let[r,n]of Cd)for(;o>=r;)e+=n,o-=r;return e}function wu(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=Lu[e[r]],i=r+1<e.length?Lu[e[r+1]]:0;o+=n<i?-n:n;}return Ii(o)===e?o:null}function vu(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 bo=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],Sd=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],Ld=["","thousand","million","billion","trillion","quadrillion"];function wd(t){if(t<20)return bo[t];let e=Math.floor(t/10),o=t%10;return Sd[e]+(o?`-${bo[o]}`:"")}function vd(t){let e=Math.floor(t/100),o=t%100,r=[];return e&&r.push(`${bo[e]} hundred`),o&&(e&&r.push("and"),r.push(wd(o))),r.join(" ")}function kd(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=vd(e[i]);i>0&&(a+=` ${Ld[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 ku(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=kd(parseInt(o,10));return r&&(n+=" point "+[...r].map(i=>bo[Number(i)]).join(" ")),(t<0?"minus ":"")+n}var Vo=class{constructor(){this.category="Numerals";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("romanFromString",1);}};function Ci(t,e){return o=>{if(o.type!==0)return chunk75JLWK4L_cjs.P("NUMERAL_EXPECTED_NUMBER",`"as ${t}" expects a number`);let r=e(o.value);return r===null?chunk75JLWK4L_cjs.P("NUMERAL_OUT_OF_RANGE",`${o.value} cannot be written as ${t}`):chunk75JLWK4L_cjs.t(r)}}var Si={name:"solve-numerals",phrases:{"from roman":"FROM_ROMAN"},asConverters:{roman:Ci("roman",Ii),ordinal:Ci("ordinal",vu),words:Ci("words",ku)},infixParselets:{FROM_ROMAN:new Vo},pluginFunctions:{romanFromString:t=>{let e=t[0];if(e?.type!==3)return chunk75JLWK4L_cjs.P("NUMERAL_EXPECTED_TEXT",'"from roman" expects text, e.g. "MMXXIV" from roman');let o=wu(e.value);return o===null?chunk75JLWK4L_cjs.P("NUMERAL_INVALID_ROMAN",`"${e.value}" is not a valid Roman numeral`):chunk75JLWK4L_cjs.n(o)}},tokenCategories:{FROM_ROMAN:"operator"}};function Md(t,e){for(t=Math.abs(t),e=Math.abs(e);e;)[t,e]=[e,t%e];return t}function Mu(t){if(t.length<2||t.some(o=>!Number.isInteger(o)||o<=0))return null;let e=t.reduce((o,r)=>Md(o,r),0)||1;return t.map(o=>o/e).join(":")}var Bu={category:"Ratio",parse(t,e,o){t.consume("LPAREN");let r=0;if(t.peek()?.type!=="RPAREN")for(t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),r++;t.match("COMMA");)t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),r++;t.consume("RPAREN"),o.emitPluginCall("ratioReduce",r);}};var Li={name:"solve-ratio",prefixParselets:{RATIO_CALL:Bu},callFusions:{ratio:"RATIO_CALL"},pluginFunctions:{ratioReduce:t=>{let e=[];for(let r of t){if(r.type!==0)return chunk75JLWK4L_cjs.P("RATIO_EXPECTED_NUMBERS","ratio expects whole numbers, e.g. ratio(16, 9)");e.push(r.value);}let o=Mu(e);return o===null?chunk75JLWK4L_cjs.P("RATIO_INVALID","ratio needs at least two whole positive numbers"):chunk75JLWK4L_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 wi=["circle","square","rectangle","triangle","sphere","cube","cylinder","cone"],Uu=["radius","side","width","height","base","length"];function Du(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 Bd=new Set(wi),Ud=new Set(Uu);function He(t){return {category:"Geometry",parse(e,o,r){let n=e.peek(),i=(n?.value??"").toLowerCase();if(!n||n.type!=="IDENT"||!Bd.has(i))throw chunkCO2BI6WL_cjs.c.parsing("GEOMETRY_EXPECTED_SHAPE",`Expected a shape (${wi.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"||!Ud.has(l))break;e.consume(),r.emitOpcode(13),r.emitString(l),a++,e.parseExpression(chunkEN3CDYOS_cjs.a.Call,r),a++,e.peek()?.type==="COMMA"&&e.consume();}r.emitPluginCall("geometryCompute",a);}}}var vi={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:He("area"),PERIMETER_OF:He("perimeter"),CIRCUMFERENCE_OF:He("circumference"),VOLUME_OF:He("volume"),SURFACE_AREA_OF:He("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=Du(e,o,r);return n.error!==void 0?chunk75JLWK4L_cjs.P("GEOMETRY_ERROR",n.error):chunk75JLWK4L_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 bu(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 ki={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=bu(e);return o===null?chunk75JLWK4L_cjs.P("UNKNOWN_CONSTANT",`"${e}" is not a known constant`):o.unit?chunk75JLWK4L_cjs.u(o.value,o.unit):chunk75JLWK4L_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 Vu(t,e){return t/(e*e)}function Fu(t,e){return t*60/e}function Hu(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 Fo={bmi:"healthBmi",pace:"healthPace",speed:"healthSpeed"};var Ho=class{constructor(){this.category="Health";}parse(e,o,r){let n=Fo[o.value];if(n===void 0)throw chunkCO2BI6WL_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(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.match("COMMA");)e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r),i++;e.consume("RPAREN"),r.emitPluginCall(n,i);}};function Ge(t){return t?.type===0?t.value:t?.type===6?t.toNumber():null}var Mi={name:"solve-health",prefixParselets:{HEALTH_CALL:new Ho},callFusions:Object.fromEntries(Object.keys(Fo).map(t=>[t,"HEALTH_CALL"])),pluginFunctions:{healthBmi:t=>{let e=Ge(t[0]),o=Ge(t[1]);return e===null||o===null||o===0?chunk75JLWK4L_cjs.P("HEALTH_BAD_INPUT","bmi(weight in kg, height in m), e.g. bmi(70, 1.75)"):chunk75JLWK4L_cjs.n(Vu(e,o))},healthPace:t=>{let e=Ge(t[0]),o=Ge(t[1]);return e===null||o===null||e===0?chunk75JLWK4L_cjs.P("HEALTH_BAD_INPUT","pace(distance in km, time in min), e.g. pace(10, 50)"):chunk75JLWK4L_cjs.t(`${Hu(e,o)} /km`)},healthSpeed:t=>{let e=Ge(t[0]),o=Ge(t[1]);return e===null||o===null||o===0?chunk75JLWK4L_cjs.P("HEALTH_BAD_INPUT","speed(distance in km, time in min), e.g. speed(10, 50)"):chunk75JLWK4L_cjs.u(Fu(e,o),"km/h")}},tokenCategories:{HEALTH_CALL:"function"}};var R0=[Qo,qo,Jo,an,Nn,yn,gn,On,In,Cn,Sn,Ln,chunkN37PUZJR_cjs.a,wn,vn,kn,Bn,Vn,qn,Zn,Jn,Fn,zn,ei,Kn,ni,ai,pi,fi,di,Ei,Yn,yi,Pi,xi,hi,Si,Li,vi,ki,Mi];
|
|
2
|
-
exports.a=Qo;exports.b=qo;exports.c=Jo;exports.d=an;exports.e=Nn;exports.f=yn;exports.g=gn;exports.h=On;exports.i=hn;exports.j=In;exports.k=Cn;exports.l=Sn;exports.m=Ln;exports.n=wn;exports.o=vn;exports.p=kn;exports.q=Bn;exports.r=Vn;exports.s=Fn;exports.t=Fm;exports.u=Gm;exports.v=Km;exports.w=zn;exports.x=Kn;exports.y=Yn;exports.z=R0;//# sourceMappingURL=chunk-FMMT5C5H.cjs.map
|
|
3
|
-
//# sourceMappingURL=chunk-FMMT5C5H.cjs.map
|