solve-engine 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YQV4WGXH.js → chunk-2BET55VH.js} +3 -3
- package/dist/chunk-2BET55VH.js.map +1 -0
- package/dist/{chunk-A2RQUV5H.cjs → chunk-46QSH527.cjs} +4 -4
- package/dist/{chunk-A2RQUV5H.cjs.map → chunk-46QSH527.cjs.map} +1 -1
- package/dist/chunk-53JLDRXA.cjs +2 -0
- package/dist/chunk-53JLDRXA.cjs.map +1 -0
- package/dist/{chunk-2DPKJ2SM.js → chunk-6EPJNHSQ.js} +2 -2
- package/dist/{chunk-2DPKJ2SM.js.map → chunk-6EPJNHSQ.js.map} +1 -1
- package/dist/{chunk-UWAXJX5G.js → chunk-6NXOKM2O.js} +2 -2
- package/dist/{chunk-UWAXJX5G.js.map → chunk-6NXOKM2O.js.map} +1 -1
- package/dist/{chunk-DLAKPF5T.js → chunk-6YGRMAQR.js} +2 -2
- package/dist/{chunk-DLAKPF5T.js.map → chunk-6YGRMAQR.js.map} +1 -1
- package/dist/{chunk-LJFS3XHW.js → chunk-BB5RRSGS.js} +2 -2
- package/dist/{chunk-LJFS3XHW.js.map → chunk-BB5RRSGS.js.map} +1 -1
- package/dist/{chunk-BKSKZA4W.cjs → chunk-BVSATTRX.cjs} +2 -2
- package/dist/{chunk-BKSKZA4W.cjs.map → chunk-BVSATTRX.cjs.map} +1 -1
- package/dist/chunk-CDIHV3ZS.js +2 -0
- package/dist/chunk-CDIHV3ZS.js.map +1 -0
- package/dist/{chunk-G63TMUL2.js → chunk-DLXG73JZ.js} +2 -2
- package/dist/{chunk-G63TMUL2.js.map → chunk-DLXG73JZ.js.map} +1 -1
- package/dist/{chunk-TRDOYAKJ.cjs → chunk-EAB6SSAV.cjs} +2 -2
- package/dist/{chunk-TRDOYAKJ.cjs.map → chunk-EAB6SSAV.cjs.map} +1 -1
- package/dist/{chunk-N64ZK6CL.cjs → chunk-HCPZRSHR.cjs} +2 -2
- package/dist/{chunk-N64ZK6CL.cjs.map → chunk-HCPZRSHR.cjs.map} +1 -1
- package/dist/{chunk-WEAKI5V5.cjs → chunk-IXOE2BQG.cjs} +2 -2
- package/dist/{chunk-WEAKI5V5.cjs.map → chunk-IXOE2BQG.cjs.map} +1 -1
- package/dist/{chunk-SEOIKHYK.js → chunk-JMYBZ6JF.js} +2 -2
- package/dist/{chunk-SEOIKHYK.js.map → chunk-JMYBZ6JF.js.map} +1 -1
- package/dist/{chunk-G2MFTERZ.cjs → chunk-KLPKLTJZ.cjs} +2 -2
- package/dist/{chunk-G2MFTERZ.cjs.map → chunk-KLPKLTJZ.cjs.map} +1 -1
- package/dist/{chunk-44EOEWGP.js → chunk-MDLR2PWN.js} +2 -2
- package/dist/chunk-MDLR2PWN.js.map +1 -0
- package/dist/chunk-O3AVGIX2.cjs +3 -0
- package/dist/chunk-O3AVGIX2.cjs.map +1 -0
- package/dist/{chunk-CEURQXSN.cjs → chunk-OW2SGORC.cjs} +2 -2
- package/dist/{chunk-CEURQXSN.cjs.map → chunk-OW2SGORC.cjs.map} +1 -1
- package/dist/{chunk-5FMYW44V.js → chunk-OZ5BQSAC.js} +2 -2
- package/dist/{chunk-5FMYW44V.js.map → chunk-OZ5BQSAC.js.map} +1 -1
- package/dist/{chunk-PS5OA7QU.js → chunk-P7CQJGNA.js} +3 -3
- package/dist/{chunk-PS5OA7QU.js.map → chunk-P7CQJGNA.js.map} +1 -1
- package/dist/{chunk-BNCBB4H5.cjs → chunk-QD2Z5TDD.cjs} +2 -2
- package/dist/{chunk-BNCBB4H5.cjs.map → chunk-QD2Z5TDD.cjs.map} +1 -1
- package/dist/{chunk-XPJGDGJF.cjs → chunk-TM752D4J.cjs} +2 -2
- package/dist/{chunk-XPJGDGJF.cjs.map → chunk-TM752D4J.cjs.map} +1 -1
- package/dist/{chunk-HQ2PE6HY.cjs → chunk-TYJTGTTY.cjs} +3 -3
- package/dist/{chunk-HQ2PE6HY.cjs.map → chunk-TYJTGTTY.cjs.map} +1 -1
- package/dist/{chunk-6QRHN3I6.cjs → chunk-XB3TWS7J.cjs} +2 -2
- package/dist/chunk-XB3TWS7J.cjs.map +1 -0
- package/dist/{chunk-RLTH2H3U.js → chunk-YBKMCGJ3.js} +2 -2
- package/dist/{chunk-RLTH2H3U.js.map → chunk-YBKMCGJ3.js.map} +1 -1
- package/dist/{chunk-XOEZ7UQI.js → chunk-ZN33O4AL.js} +3 -3
- package/dist/{chunk-XOEZ7UQI.js.map → chunk-ZN33O4AL.js.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/language.cjs +1 -1
- package/dist/language.js +1 -1
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.js +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-44EOEWGP.js.map +0 -1
- package/dist/chunk-6QRHN3I6.cjs.map +0 -1
- package/dist/chunk-IES365YJ.cjs +0 -3
- package/dist/chunk-IES365YJ.cjs.map +0 -1
- package/dist/chunk-RHE3LC4Q.js +0 -2
- package/dist/chunk-RHE3LC4Q.js.map +0 -1
- package/dist/chunk-WMISTHB2.cjs +0 -2
- package/dist/chunk-WMISTHB2.cjs.map +0 -1
- package/dist/chunk-YQV4WGXH.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkTL545PXW_cjs=require('./chunk-TL545PXW.cjs'),chunk53JLDRXA_cjs=require('./chunk-53JLDRXA.cjs'),chunkEN3CDYOS_cjs=require('./chunk-EN3CDYOS.cjs'),chunkKLPKLTJZ_cjs=require('./chunk-KLPKLTJZ.cjs'),chunkUURM7P3P_cjs=require('./chunk-UURM7P3P.cjs'),chunkZLRJ7TDP_cjs=require('./chunk-ZLRJ7TDP.cjs'),chunkHCPZRSHR_cjs=require('./chunk-HCPZRSHR.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'),chunkBVSATTRX_cjs=require('./chunk-BVSATTRX.cjs'),chunkEAB6SSAV_cjs=require('./chunk-EAB6SSAV.cjs'),chunk5IJD5L3O_cjs=require('./chunk-5IJD5L3O.cjs'),chunkS3DFU33X_cjs=require('./chunk-S3DFU33X.cjs'),chunkIXOE2BQG_cjs=require('./chunk-IXOE2BQG.cjs'),chunkXB3TWS7J_cjs=require('./chunk-XB3TWS7J.cjs'),chunkCO2BI6WL_cjs=require('./chunk-CO2BI6WL.cjs');var Su=/^\d{1,3}(\.\d{3}){2,}$/,Lu=/^\d*\.\d*$/,Ot=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(Su.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),Lu.test(c)&&(i=c);}if(i!==null){r.emitOpcode(16),r.emitString(i);return}r.emitOpcode(10),r.emitNumber(n);}};var Ie=class{constructor(e){this.opcode=e;this.category="Arithmetic";}parse(e,o,r){e.parseExpression(60,r),r.emitOpcode(this.opcode);}};var k=class{constructor(e,o,r=false){this.opcode=o;this.category="Arithmetic";this.bindingPower=e,this.rightBindingPower=r?e-1:e;}parse(e,o,r,n){e.parseExpression(this.rightBindingPower,n),n.emitOpcode(this.opcode);}};var Rt=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 wu={k:3,M:6,G:9,B:9,T:12},vu={thousand:3,thousands:3,million:6,millions:6,mn:6,billion:9,billions:9,bn:9,trillion:12,trillions:12,tn:12},ku=/^\d+(\.\d+)?$/;function Bu(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 Na(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"||!ku.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:vu[n.value.toLowerCase()],s=i?wu[n.value]??a:a;if(s===void 0)return null;let l=Bu(r.text,s);return {consumed:2,replacement:[chunkKLPKLTJZ_cjs.b("NUMBER",l,e.slice(o,o+2))],ruleName:"arithmetic:large-number-suffix"}}}}var Wo={name:"solve-arithmetic",prefixParselets:{NUMBER:new Ot,LPAREN:new Rt,PI:new We,E:new We,PLUS:new Ie(27),MINUS:new Ie(26),BIT_NOT:new Ie(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:[Na()]};var It=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 ht=class{constructor(){this.category="Percentage";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){if(Pa(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=Mu(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")){ga(e,"what",'"81 is 9 to what power"'),ga(e,"power",'"81 is 9 to what power"'),o.emitOpcode(51),o.emitIndex(ya),o.emitIndex(1),o.emitOpcode(2),o.emitOpcode(51),o.emitIndex(ya),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);}},ya=5;function Pa(t,e){return (t.peek()?.text??"").toLowerCase()===e}function ga(t,e,o){if(!Pa(t,e))throw chunkCO2BI6WL_cjs.c.parsing("IS_WHAT_EXPECTED_WORD",`Expected "${e}" here, as in ${o}`);t.consume();}function Mu(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 _a(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],chunkKLPKLTJZ_cjs.b(n==="on"?"PCT_ON":"PCT_OFF",n,[r])],ruleName:"percentage:on-off"}}}}var Ct=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 St=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 Lt=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")&&chunkIXOE2BQG_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 Uu={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 Du(t){if(t.type==="NUMBER"){let e=Number(t.value);return Number.isInteger(e)&&e>=0?e:null}return t.type==="IDENT"?Uu[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=Du(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 Aa(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:chunkKLPKLTJZ_cjs.b(r==="up"?"PCT_UP":"PCT_DOWN",r,[o])}function xa(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=Aa(e,o+1);if(i)return {consumed:2,replacement:[r,i],ruleName:"percentage:up-down"}}let n=Aa(e,o);return n?{consumed:1,replacement:[n],ruleName:"percentage:up-down"}:null}}}var Yo={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 It,IS:new ht,PCT_ON:new Ye(1),PCT_OFF:new Ye(-1),OF:new Ct,OF_WHAT_IS:new St,ON_WHAT_IS:new je(1),OFF_WHAT_IS:new je(-1),TO:new Lt,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:[_a(),xa()]};var jo={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},wt=class{constructor(){this.category="Function";}parse(e,o,r){let n=o.value.toLowerCase(),i=jo[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 Xo={name:"solve-function",prefixParselets:{FUNC:new wt}};var pe=class{constructor(e=0){this.category="Date/Time";this.dayOffset=e;}parse(e,o,r){r.emitOpcode(90),this.dayOffset!==0&&(r.emitOpcode(10),r.emitNumber(this.dayOffset),r.emitOpcode(13),r.emitString("days"),r.emitOpcode(80),r.emitOpcode(20));}};var bu={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?bu[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 vt=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 kt=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 Bt=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 Mt=class{constructor(){this.category="Date/Time";}parse(e,o,r){r.emitOpcode(90),r.emitPluginCall("toTimestampFromAny",1);}};var Ut=class{constructor(){this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toDateFromAny",1);}};var Dt=class{constructor(){this.category="Date/Time";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("toTimestampFromAny",1);}};var bt=class{constructor(){this.category="Date/Time";}parse(e,o,r){r.emitOpcode(95),r.emitNumber(Number(o.value));}};var Vt=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 he=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 Vu=new Set(["year","years","month","months","day","days"]),Ft=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"&&Vu.has(n))o=true,e.consume();else if(r.type==="COMMA"||r.type==="AND_CONJ"||n==="and")e.consume();else break}return o}};function Fu(t){let e=t[0],o;if(e.type===6&&e.unit){if(chunkBVSATTRX_cjs.c(e.unit)!=="time")return chunk75JLWK4L_cjs.P("WORKDAYS_IN_EXPECTED_DURATION",`"workdays in" expects a time duration, got unit "${e.unit}"`);o=chunkBVSATTRX_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 Hu=["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 Gu(t){let e=rt(t[0],"weekday");return typeof e!="number"?e:chunk75JLWK4L_cjs.t(Hu[new Date(e).getDay()])}var zu=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ku(t){let e=rt(t[0],"month");return typeof e!="number"?e:chunk75JLWK4L_cjs.t(zu[new Date(e).getMonth()])}function $u(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 Oa(t){let e=new Date(t).getDay();return e===0||e===6}function Wu(t){let e=rt(t[0],"is a weekend");return typeof e!="number"?e:chunk75JLWK4L_cjs.L(Oa(e))}function Yu(t){let e=rt(t[0],"is a workday");return typeof e!="number"?e:chunk75JLWK4L_cjs.L(!Oa(e))}function ju(t){return chunk75JLWK4L_cjs.u(Math.abs(t[0].toNumber()-t[1].toNumber()),"ms")}function Xu(t){let e=t[0];if(e.type===4)return e;if(e.type===3){let o=chunk53JLDRXA_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(chunk53JLDRXA_cjs.e(e.toNumber()))}function Qu(t){let e=t[0];if(e.type===3){let o=chunk53JLDRXA_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 Ra=Fu,Qo=Gu,qo=Ku,Zo=$u,Ia=Wu,ha=Yu,Ca=ju,Sa=Xu,La=Qu;function Jo(t,e){return new Date(t,e+1,0).getDate()}function ka(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>Jo(t,e)?null:new Date(t,e,a).getTime()}function Ba(t,e,o){let r=Jo(t,e),i=(new Date(t,e,r).getDay()-o+7)%7;return new Date(t,e,r-i).getTime()}function Ma(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 wa(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(),Jo(n,i));return new Date(n,i,a)}function va(t){return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)}function Ua(t,e){let o=new Date(t),r=new Date(e),n=(r.getFullYear()-o.getFullYear())*12+(r.getMonth()-o.getMonth());wa(o,n)>r&&n--;let i=wa(o,n),a=va(r)-va(i);return {years:Math.floor(n/12),months:n%12,days:a}}function Da(t,e){let o=new Date(t);return new Date(o.getFullYear(),o.getMonth()+e,1).getTime()}function Gt(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 qu(t){let e=Gt(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(Ba(s,l,i));let u=Number(r),c=ka(s,l,i,u);return c===null?chunk75JLWK4L_cjs.P("NTH_WEEKDAY_OUT_OF_RANGE",`there is no ${r}${Zu(u)} occurrence of that weekday in the month`):chunk75JLWK4L_cjs.M(c)}function Zu(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 Ju(t){let e=Gt(t[0],"month anchor");if(typeof e!="number")return e;let o=t[1].toNumber();return chunk75JLWK4L_cjs.M(Da(e,o))}var ec="ymd";function tc(t){let e=Gt(t[0],"age of");if(typeof e!="number")return e;let o=Gt(t[1],"age of");return typeof o!="number"?o:String(t[2].value??"years")===ec?chunk75JLWK4L_cjs.t(rc(Ua(e,o))):chunk75JLWK4L_cjs.u(Ma(e,o),"years")}function rc(t){let e=[];return t.years!==0&&e.push(Ht(t.years,"year")),t.months!==0&&e.push(Ht(t.months,"month")),t.days!==0&&e.push(Ht(t.days,"day")),e.length===0?Ht(0,"day"):e.join(", ")}function Ht(t,e){return `${t} ${e}${Math.abs(t)===1?"":"s"}`}var ba=qu,Va=Ju,Fa=tc;var oc={SUNDAY:0,MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6},Ha="NTH_WEEKDAY",nc=chunk5IJD5L3O_cjs.c(Ha),ic=/^(\d+)(st|nd|rd|th)$/i;function Ga(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=ic.exec(N);if(!E)return null;i=String(Number(E[1])),a=2;}let s=o[r+a],l=s?oc[s.type]:void 0;if(l===void 0||o[r+a+1]?.type!=="OF")return null;let u=`${i}:${l}`,c=new chunkEAB6SSAV_cjs.a(Ha,nc,u,u,n.offset,0,n.line,n.col);return {consumed:a+1,replacement:[c],ruleName:e}}}}function za(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:[chunkKLPKLTJZ_cjs.b(i,r.value,[r,n])],ruleName:`datetime:${n.type.toLowerCase()}`}}}}function Ka(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:[chunkKLPKLTJZ_cjs.b("BETWEEN_UNIT",i.value,u)],ruleName:"datetime:between"}}}}function $a(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 ac={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 Wa(t){return t===void 0||t.type!=="IDENT"&&t.type!=="UNIT"?0:ac[(t.text??t.value??"").toLowerCase()]??0}var ot=/^\d+$/;function zt(t){return t.length===4}function Ya(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=Wa(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??"")&&zt(T.text??"")?chunk53JLDRXA_cjs.g(f,c,Number(T.text),e.slice(o,o+3),r):chunk53JLDRXA_cjs.g(f,c,new Date().getFullYear(),e.slice(o,o+2),r)}let i=Wa(n);if(i===0)return null;let a=e[o+1];if(a?.type!=="NUMBER"||!ot.test(a.text??""))return null;if(zt(a.text??""))return chunk53JLDRXA_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??"")&&zt(u.text??"")?chunk53JLDRXA_cjs.g(s,i,Number(u.text),e.slice(o,o+4),r):l?.type==="NUMBER"&&ot.test(l.text??"")&&zt(l.text??"")?chunk53JLDRXA_cjs.g(s,i,Number(l.text),e.slice(o,o+3),r):chunk53JLDRXA_cjs.g(s,i,new Date().getFullYear(),e.slice(o,o+2),r)}}}var sc=93,mc={q1:[1,3],q2:[4,6],q3:[7,9],q4:[10,12]};function en(t,e){return new Date(t,e,0).getDate()}function lc(t){return en(t,2)===29?366:365}var Kt=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(sc),r.emitIndex(1);}readPeriodDays(e){let o=e.peek(),r=(o?.text??o?.value??"").toLowerCase(),n=mc[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+=en(a,l);return s}if(o?.type==="DATETIME_LITERAL"){e.consume();let a=new Date(Number(o.value));return en(a.getFullYear(),a.getMonth()+1)}let i=this.readOptionalYear(e);if(i!==null)return lc(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 uc=new Set(["q1","q2","q3","q4"]),cc=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 pc(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"?uc.has(e)||cc.has(e):t.type==="NUMBER"&&/^\d{4}$/.test(t.text??"")}function ja(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"||!pc(e[o+2])?null:{consumed:2,replacement:[chunkKLPKLTJZ_cjs.b("DAYS_IN_PERIOD","days in",[r,e[o+1]])],ruleName:"datetime:days-in-period"}}}}function Xa(){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!==chunk53JLDRXA_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 tn={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 Kt,NOW:new pe(0),TODAY:new pe(0),TOMORROW:new pe(1),YESTERDAY:new pe(-1),NEXT:new Ze("next"),LAST:new Ze("last"),UNTIL_UNIT:new Je("until"),SINCE_UNIT:new Je("since"),WORKDAYS_IN:new vt,WORKDAYS_BETWEEN:new kt,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 Bt,CURRENT_TIMESTAMP:new Mt,DATETIME_LITERAL:new bt,NTH_WEEKDAY:new Vt,AGE_OF:new Ft,MONTH_ANCHOR_NEXT:new he(1),MONTH_ANCHOR_THIS:new he(0),MONTH_ANCHOR_LAST:new he(-1)},infixParselets:{WORKDAYS_AFTER:new et("forward"),WORKDAYS_BEFORE:new et("backward"),TO_DATE:new Ut,TO_TIMESTAMP:new Dt,IS_WEEKEND:new tt("isWeekendOnDate"),IS_WORKDAY:new tt("isWorkdayOnDate")},normalizerRules:[za(),Ka(),$a(),Ya(),Ga(),ja(),Xa()],pluginFunctions:{workdaysInDuration:Ra,weekdayOnDate:Qo,toDateFromAny:Sa,toTimestampFromAny:La,monthOnDate:qo,weekOnDate:Zo,isWeekendOnDate:Ia,isWorkdayOnDate:ha,spanBetweenDates:Ca,nthWeekdayOfMonth:ba,monthAnchorShift:Va,ageBetween:Fa},asConverters:{iso8601:t=>chunk75JLWK4L_cjs.t(chunk53JLDRXA_cjs.d(t.toNumber())),weekday:t=>Qo([t]),month:t=>qo([t]),week:t=>Zo([t])},tokenCategories:{NTH_WEEKDAY:"datetime",MONTH_ANCHOR_NEXT:"datetime",MONTH_ANCHOR_THIS:"datetime",MONTH_ANCHOR_LAST:"datetime",AGE_OF:"keyword"}};var fc={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"},rn={"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"},dc={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"},Qa={...fc,...rn,...dc};var on="UTCOFFSET:";function nn(t){return `${on}${t}`}function nt(t){return t.startsWith(on)}function it(t){return parseInt(t.slice(on.length),10)}function $t(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 Za(t,e,o,r,n,i){let a=Date.UTC(t,e,o,r,n,0),s=$t(i,a);return a-s*6e4}function an(t,e){if(nt(e)){let r=it(e)*6e4;return Ec(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:true}).format(new Date(t))}function Ja(t,e){if(nt(e)){let r=it(e)*6e4;return Tc(new Date(t+r))}return new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"long",day:"numeric"}).format(new Date(t))}function qa(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 es(t,e,o){let r=qa(t,e),n=qa(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 Ec(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",hour:"numeric",minute:"2-digit",hour12:true}).format(t)}function Tc(t){return new Intl.DateTimeFormat("en-US",{timeZone:"UTC",year:"numeric",month:"long",day:"numeric"}).format(t)}function sn(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 ne(t){let e=t.peek();if(!e)return null;let o=e.value,r=o.toLowerCase();if(r==="gmt"||r==="utc"){t.consume();let i=t.peek();if(i?.type==="PLUS"||i?.type==="MINUS"){let s=i.type==="MINUS";t.consume();let l=t.peek(),u;if(l?.type==="CLOCK_TIME")t.consume(),u=parseInt(l.value,10);else {let f=t.consume("NUMBER");if(u=parseInt(f.value,10)*60,t.peek()?.type==="COLON"){t.consume();let T=t.consume("NUMBER");u+=parseInt(T.value,10);}}let c=nn(s?-u:u);return {zoneRef:c,displayName:sn(c)}}let a=nn(0);return {zoneRef:a,displayName:sn(a)}}let n=Qa[r];if(n){t.consume();let i=o.replace(/\b\w/g,a=>a.toUpperCase());return {zoneRef:n,displayName:i}}return null}var Wt="zoneConvert",mn="timeInZone",ln="dateInZone",Yt="timeDifference";function ts(t){let e=t[0].toNumber(),o=t[1].value,r=t[2].value,n=new Date,i=Za(n.getFullYear(),n.getMonth(),n.getDate(),Math.floor(e/60),e%60,o),a=an(i,r),s=es(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 rs(t){let e=t[0].value;return chunk75JLWK4L_cjs.t(an(Date.now(),e))}function os(t){let e=t[0].value;return chunk75JLWK4L_cjs.t(Ja(Date.now(),e))}function ns(t){let e=t[0].value,o=t[1].value,r=t[2].value,n=t[3].value,i=Date.now(),a=$t(e,i),l=$t(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 jt=class{constructor(){this.category="Time";}parse(e,o,r){let n=parseInt(o.value,10),i=ne(e);if(i!==null){if(e.peek()?.type!=="IN")throw 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=ne(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(Wt,3);return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(120);}};var Xt=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 Qt=class{constructor(){this.category="Time";}parse(e,o,r){r.emitOpcode(10),r.emitNumber(parseFloat(o.value)),r.emitOpcode(13),r.emitString("frames/s"),r.emitOpcode(80);}};var qt=class{constructor(){this.category="Time";}parse(e,o,r){r.emitOpcode(10),r.emitNumber(parseFloat(o.value)),r.emitOpcode(13),r.emitString("s"),r.emitOpcode(80);}};function un(t){return {category:"Time",parse(e,o,r){let n=ne(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 Zt=class{constructor(){this.category="Time";}parse(e,o,r){let n=ne(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=ne(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(Yt,4);}};var Jt=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 is(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 er=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(is(n,s));return}r.emitOpcode(10),r.emitNumber(n),r.emitOpcode(13),r.emitString("frames"),r.emitOpcode(80);}};function as(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 ss(t){return !!t&&t.type==="IDENT"&&/^(am|pm)$/i.test(t.value)}function ms(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||chunkKLPKLTJZ_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=ss(u),f=as(n,l,c?u.value:void 0);if(f===null)return null;let T=c?4:3;return {consumed:T,replacement:[chunkKLPKLTJZ_cjs.b("CLOCK_TIME",String(f),e.slice(o,o+T))],ruleName:"time:clock-time"}}let s=e[o+1];if(ss(s)){let l=as(n,0,s.value);return l===null?null:{consumed:2,replacement:[chunkKLPKLTJZ_cjs.b("CLOCK_TIME",String(l),e.slice(o,o+2))],ruleName:"time:clock-time"}}return null}}}function ls(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:[chunkKLPKLTJZ_cjs.b("CLOCK_TIME_INTERVAL",`${r.value}:${i.value}`,e.slice(o,o+3))],ruleName:"time:clock-time-interval"}}}}function us(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:[chunkKLPKLTJZ_cjs.b("FPS_RATE",r.value,e.slice(o,o+2))],ruleName:"time:fps-rate"}}}}function cs(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"||chunkKLPKLTJZ_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:[chunkKLPKLTJZ_cjs.b("LAPTIME",String(f),e.slice(o,o+5))],ruleName:"time:laptime"}}}}function ps(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"||chunkKLPKLTJZ_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:[chunkKLPKLTJZ_cjs.b("VIDEO_TIMECODE",`${c},${f},${T},${N}`,e.slice(o,o+7))],ruleName:"time:video-timecode"}}}}function fs(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:[chunkKLPKLTJZ_cjs.b("FRAME_COUNT",r.value,e.slice(o,o+2))],ruleName:"time:frame-count"}}}}var Nc=14,yc=[["week","weeks",604800],["day","days",86400],["hour","hours",3600],["minute","minutes",60],["second","seconds",1]];function ds(t){if(t.type===0)return t.toNumber();if(t.type!==6||t.unit===void 0)return null;let e=chunkXB3TWS7J_cjs.a[t.unit.toLowerCase()];return e===void 0||e[0]!==Nc?null:t.toNumber()*e[1]}function Es(t){let e=ds(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 yc){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 pn(t){let e=ds(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=`${cn(n)}:${cn(i)}:${cn(s)}`;return chunk75JLWK4L_cjs.t((o?"-":"")+(l>0?`${u}.${String(l).padStart(3,"0")}`:u))}function cn(t){return t<10?`0${t}`:String(t)}var fn={name:"solve-time",asConverters:{timespan:Es,laptime:pn,lap:pn},phrases:{"time in":"TIME_IN","date in":"DATE_IN","time difference between":"TIME_DIFFERENCE_BETWEEN",...Object.fromEntries(Object.keys(rn).map(t=>[t,"CITY_NAME"]))},prefixParselets:{CLOCK_TIME:new jt,CLOCK_TIME_INTERVAL:new Xt,FPS_RATE:new Qt,LAPTIME:new qt,TIME_IN:un(mn),DATE_IN:un(ln),TIME_DIFFERENCE_BETWEEN:new Zt,VIDEO_TIMECODE:new Jt,FRAME_COUNT:new er},normalizerRules:[ms(),ls(),us(),cs(),ps(),fs()],pluginFunctions:{[Wt]:ts,[mn]:rs,[ln]:os,[Yt]:ns}};function tr(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 gc=37;function rr(t){t.emitOpcode(51),t.emitIndex(gc),t.emitIndex(2);}var Pc=tr({category:"Dice",alternatives:[{slots:[{kind:"keyword",tokenTypes:["BETWEEN"]},{kind:"expr",bindingPower:chunkEN3CDYOS_cjs.a.Product},{kind:"keyword",tokenTypes:["AND_CONJ"]},{kind:"expr"}],emit:rr},{slots:[{kind:"keyword",tokenTypes:["FROM"]},{kind:"expr",bindingPower:chunkEN3CDYOS_cjs.a.Product},{kind:"keyword",tokenTypes:["TO"]},{kind:"expr"}],emit:rr},{slots:[{kind:"keyword",tokenTypes:["LPAREN"]},{kind:"expr"},{kind:"keyword",tokenTypes:["COMMA"]},{kind:"expr"},{kind:"keyword",tokenTypes:["RPAREN"]}],emit:rr}]}),or=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)),rr(r);return}Pc.parse(e,o,r);}};var dn={name:"solve-dice",prefixParselets:{ROLL:new or}};var nr=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 ir=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 ar=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(!chunkHCPZRSHR_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=chunkHCPZRSHR_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 En={name:"solve-variables",asyncResolvers:[new ar],prefixParselets:{COLON:new nr,IDENT:new at,UNIT:new at,GLOBAL:new ir}};var Ns="currency-historical",fe="historicalCurrency",_c=`solve-currency:${fe}`,sr={NOT_CONFIGURED:"HISTORICAL_RATES_NOT_CONFIGURED",QUERY_FAILED:"HISTORICAL_RATE_QUERY_FAILED",NOT_PREFLIGHTED:"HISTORICAL_RATE_NOT_PREFLIGHTED",INVALID_OPERAND:"HISTORICAL_CURRENCY_INVALID_OPERAND"},Ac=3e4,ys=1/0,xc=1e4;function Tn(t,e,o){return [Ns,`${t.toUpperCase()}:${e.toUpperCase()}:${o}`]}function Ts(t){return t<10?`0${t}`:String(t)}function mr(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()}-${Ts(i.getMonth()+1)}-${Ts(i.getDate())}`}async function gs(t,e,o,r,n,i){let a=e.toUpperCase(),s=o.toUpperCase();if(!t)return chunk75JLWK4L_cjs.P(sr.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,xc,"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(sr.QUERY_FAILED,`Failed to resolve the historical rate for ${a} to ${s} on ${r}: ${c instanceof Error?c.message:String(c)}`),T=Tn(e,o,r);return setTimeout(()=>{i.getQueryData(T)===f&&i.removeQueries({queryKey:T,exact:true});},Ac).unref?.(),f}finally{u();}}function Nn(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(sr.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=Tn(a,s,l),f=u?.getQueryData(c);if(f===void 0)return u?u.fetchQuery({queryKey:c,queryFn:({signal:N})=>gs(t,a,s,l,N,u),staleTime:ys}):chunk75JLWK4L_cjs.P(sr.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 Ps(t){return {namespace:Ns,preflight(e,o,r,n,i){let{opcodes:a,strings:s}=o,l=a.length,u=chunkHCPZRSHR_cjs.F(_c),c=0,f=[];for(;c<l;){let T=a[c];if(T===13)f.push(a[c+1]);else if(T===50){let N=a[c+1],E=a[c+2];if(N===u&&E===3&&f.length>=3){let _=s[f[f.length-1]],O=s[f[f.length-2]],R=new Set;for(let g=0;g<f.length-2;g++){let P=s[f[g]];chunk6YM67DWH_cjs.c.isCurrency(P)&&R.add(P.toUpperCase());}if(R.size===1){let g=R.values().next().value;if(g!==O.toUpperCase()){let P=Tn(g,O,_);if(i.getQueryData(P)===void 0){let h=i.fetchQuery({queryKey:P,queryFn:({signal:S})=>gs(t,g,O,_,S,i),staleTime:ys});return {queryKey:P.join(":"),resolver:h,packageId:r,signal:n,metadata:{from:g,to:O,isoDate:_}}}}}}f=[];}c=chunkTL545PXW_cjs.a(a,c);}return null},destroy(){}}}function _s(t){return chunkJ7ABVGZH_cjs.ta(t)??t}var lr=class{constructor(){this.category="UoM";this.bindingPower=chunkEN3CDYOS_cjs.a.Postfix;}parse(e,o,r,n){let i=_s(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=_s(s.value),u=mr(e,l,i);if(u!==null){n.emitOpcode(80),n.emitOpcode(13),n.emitString(l),n.emitOpcode(13),n.emitString(u),n.emitPluginCall(fe,3);return}n.emitOpcode(13),n.emitString(l),n.emitOpcode(81);return}if(s?.type==="QUESTION"){e.consume(),n.emitOpcode(85);return}}if(e.peek()?.type==="BEST"){e.consume(),n.emitOpcode(83);return}n.emitOpcode(80);}};function yn(t){return chunkJ7ABVGZH_cjs.ta(t)??t}var ur=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(yn(n.value)),e.peek()?.type==="TO"){e.consume("TO");let i=e.consume();i?.type==="UNIT"?(r.emitOpcode(13),r.emitString(yn(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(yn(i.value)),r.emitOpcode(84)):i?.type==="BEST"&&(e.consume(),r.emitOpcode(83));return}}};var cr=class{constructor(){this.category="UoM";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitOpcode(85);}};function As(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:[chunkKLPKLTJZ_cjs.b("UOM_POSSIBILITIES_QUERY",r.value,[r,n,i])],ruleName:"uom:possibilities"}}}}var xs=14;function Os(t,e){if(t===void 0||t.type!=="UNIT")return;let o=(t.value??"").toLowerCase();if(o==="m"&&e===xs)return {kind:xs,ratio:60,spelling:"minutes"};let r=chunkXB3TWS7J_cjs.a[o];return r===void 0?void 0:{kind:r[0],ratio:r[1],spelling:o}}var Rs=/^\d+(\.\d+)?$/;function Is(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"||!Rs.test(r.text??""))return null;let n=Os(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"||!Rs.test(N.text??""))break;let E=Os(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:[chunkKLPKLTJZ_cjs.b("NUMBER",String(T),f),chunkKLPKLTJZ_cjs.b("UNIT",l,[u])],ruleName:"uom:compound-quantity"}}}}function hs(t){return t===void 0||t.type!=="UNIT"?false:chunkXB3TWS7J_cjs.a[(t.value??"").toLowerCase()]!==void 0}function Cs(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"||!hs(e[o+1])||e[o+2]?.type!=="AND_CONJ"||!hs(e[o+3]))return null;let n=e[o+1].value,i=e[o+3].value;return {consumed:4,replacement:[chunkKLPKLTJZ_cjs.b("IN_TWO_UNITS",`${n} ${i}`,e.slice(o,o+4))],ruleName:"uom:two-unit-conversion"}}}}function Ss(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,chunkKLPKLTJZ_cjs.b("UNIT","degrees",[n])],ruleName:"uom:degree-symbol"}}}}var pr=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 Ls(t){return t===void 0||t.type!=="UNIT"?false:chunkXB3TWS7J_cjs.a[(t.value??"").toLowerCase()]!==void 0}var gn=new Set(["per","a","an","each","every"]);function Oc(t){if(t===void 0||t.type!=="IDENT")return false;let e=(t.text??t.value??"").toLowerCase();return gn.has(e)?false:/^[a-z][a-z_]{2,}$/.test(e)&&chunkXB3TWS7J_cjs.a[e]===void 0}function ws(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"&&Oc(e[o+1])){let l=e[o+1],u=e[o+2];if((u?.type==="SLASH"||u?.type==="IDENT"&&gn.has((u.text??u.value??"").toLowerCase()))&&Ls(e[o+3]))return {consumed:2,replacement:[r,chunkKLPKLTJZ_cjs.b("UNIT",l.value,[l])],ruleName:"uom:bare-rate-denominator"}}if(!Ls(e[o+1]))return null;let n=r.type==="SLASH",i=(r.text??r.value??"").toLowerCase(),a=r.type==="IDENT"&&gn.has(i);if(!n&&!a)return null;let s=e[o+1];return {consumed:2,replacement:[chunkKLPKLTJZ_cjs.b("PER_UNIT",s.value,[r,s])],ruleName:"uom:bare-rate-denominator"}}}}var fr=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 dr=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 Rc(t){return t===void 0||t.type!=="UNIT"?false:chunkXB3TWS7J_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Ic=new Set(["per","a","an","each","every"]);function hc(t,e){for(let o=e;o<t.length&&o<e+5;o++){let r=t[o];if(r.type==="PER_UNIT")return true;if(r.type==="EOF"||r.type==="COMMA"||r.type==="RATE_AT")return false;let n=(r.text??r.value??"").toLowerCase();if((r.type==="SLASH"||r.type==="IDENT"&&Ic.has(n))&&Rc(t[o+1]))return true}return false}function vs(t=73){return {name:"uom:at-rate",priority:t,shape:[{types:["RATE_AT"]}],match(e,o){return e[o]?.type!=="RATE_AT"||!hc(e,o+1)?null:{consumed:1,replacement:[chunkKLPKLTJZ_cjs.b("AT_RATE","at",[e[o]])],ruleName:"uom:at-rate"}}}}function Cc(t){return t===void 0||t.type!=="UNIT"?false:chunkXB3TWS7J_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Sc=new Set(["a","an"]);function ks(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"||!Sc.has((n.text??n.value??"").toLowerCase())||!Cc(e[o+2])?null:{consumed:3,replacement:[chunkKLPKLTJZ_cjs.b("STAR","*",[r]),chunkKLPKLTJZ_cjs.b("NUMBER","1",[n]),e[o+2]],ruleName:"uom:for-duration"}}}}function Pn(t){return t===void 0||t.type!=="UNIT"?false:chunkXB3TWS7J_cjs.a[(t.value??"").toLowerCase()]!==void 0}var Lc=new Set(["a","an"]);function Bs(t=61){return {name:"uom:reversed-conversion",priority:t,shape:[{types:["UNIT"]},{types:["IN"]}],match(e,o){if(o!==0||!Pn(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"&&Pn(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"&&Lc.has(i)&&Pn(e[o+3])?{consumed:4,replacement:[chunkKLPKLTJZ_cjs.b("NUMBER","1",[n]),e[o+3],e[o+1],r],ruleName:"uom:reversed-conversion"}:null}}}var wc={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},Ms=2;function Us(t){return wc[t.toLowerCase().trim()]}var Er="cookingConvert";function Ds(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=chunkBVSATTRX_cjs.c(n),s=chunkBVSATTRX_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(chunkBVSATTRX_cjs.e(i,n,r),r);let u=Us(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=chunkBVSATTRX_cjs.e(i,n,"g")/u,_=chunkBVSATTRX_cjs.e(E,"ml",r);return chunk75JLWK4L_cjs.u(_,r)}let f=chunkBVSATTRX_cjs.e(i,n,"ml")*u,T=chunkBVSATTRX_cjs.e(f,"g",r);return chunk75JLWK4L_cjs.u(T,r)}var Tr=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(Er,3);}};function bs(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=Ms;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:[chunkKLPKLTJZ_cjs.b("INGREDIENT_NAME",u,i)],ruleName:"uom-cooking:ingredient-name"}}return null}}}function Vs(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 chunkXB3TWS7J_cjs.a[i]===void 0?null:{consumed:2,replacement:[chunkKLPKLTJZ_cjs.b("UNIT",i,e.slice(o,o+2))],ruleName:"uom:multi-word-unit"}}}}function Fs(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:[chunkKLPKLTJZ_cjs.b("UNIT",a,[r,n,i])],ruleName:"uom:compound-unit"}}}}var _n={name:"solve-uom",prefixParselets:{CONVERT:new ur,UOM_POSSIBILITIES_QUERY:new cr},infixParselets:{IN_TWO_UNITS:new pr(94),PER_UNIT:new fr(95),AT_RATE:new dr(96),UNIT:new lr,INGREDIENT_NAME:new Tr},normalizerRules:[Vs(),Fs(),As(),Is(),Cs(),Ss(),vs(),ks(),ws(),Bs(),bs()],pluginFunctions:{[Er]:Ds}};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 Nr=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=mr(e,a);if(s!==null){n.emitOpcode(13),n.emitString(a),n.emitOpcode(13),n.emitString(s),n.emitPluginCall(fe,3);return}n.emitOpcode(13),n.emitString(a),n.emitOpcode(84);}}};function An(t={}){return {name:"solve-currency",asyncResolvers:[new chunkTL545PXW_cjs.b,Ps(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 Nr},pluginFunctions:{[fe]:Nn(t.historicalRateProvider)}}}var xn=An();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 yr=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 On={name:"solve-vector",prefixParselets:{VEC2:new Ce(2),VEC3:new Ce(3),VEC4:new Ce(4),FLOAT:new yr}};var gr=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 Pr=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 Rn={name:"solve-matrix",prefixParselets:{LBRACKET:new gr},infixParselets:{LBRACKET:new Pr}};function _r(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=jo[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 Hs(t){let e=t.peek(),o=t.peekAt(1);return !!e&&(e.type==="IDENT"||e.type==="UNIT")&&o?.type==="EQUALS"}function Gs(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 ie(t,e,o,r,n){if(t.emitOpcode(e),t.emitIndex(o.kind),o.kind===0){let i=t.emitAnonymousBody(r,o.program);t.emitIndex(i);}else o.kind===1?t.emitIndex(o.builtinIdx):t.emitString(o.name);t.emitIndex(n);}var Ar=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=_r(e,r);e.consume("COMMA");let i=[];if(Hs(e))do{let a=Gs(e);e.consume("EQUALS"),ee(e,r),i.push(a);}while(e.match("COMMA"));else ee(e,r),i.push("x");e.consume("RPAREN"),ie(r,157,n,i,i.length);}};var xr=class{constructor(){this.category="MapReduce";}parse(e,o,r){e.consume("LPAREN");let n=_r(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"),ie(r,158,n,["acc","x"],i);}};var Or=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),ie(r,158,{kind:0,program:i},["acc","x"],1);}};var Rr=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),ie(r,158,{kind:0,program:i},["acc","x"],1);}};var vc={map:"MAP",reduce:"REDUCE",sum:"SUM_FN",prod:"PROD_FN"};function kc(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 zs(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=vc[n];return !i||e[o+1]?.type!=="LPAREN"||n==="sum"&&kc(e[o+2],e[o+3])?null:{consumed:1,replacement:[new chunkEAB6SSAV_cjs.a(i,chunk5IJD5L3O_cjs.c(i),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"mapreduce:call"}}}}var In={name:"solve-mapreduce",normalizerRules:[zs()],prefixParselets:{MAP:new Ar,REDUCE:new xr,SUM_FN:new Or,PROD_FN:new Rr}};var Ir=class{constructor(){this.category="BigInt";}parse(e,o,r){r.emitOpcode(11),r.emitString(chunkEN3CDYOS_cjs.e(o.value,e.getLocaleCode()));}};var hn={name:"solve-bigint",prefixParselets:{BIGINT:new Ir}};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 hr=class{constructor(){this.category="Conditionals";}parse(e,o,r){e.parseExpression(0,r),e.consume("THEN"),e.parseExpression(0,r),e.consume("ELSE"),e.parseExpression(0,r),r.emitOpcode(132);}};var Cn={name:"solve-conditionals",prefixParselets:{TRUE:new st(true),FALSE:new st(false),IF:new hr},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 Bc={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},Ks={2:143,8:144,16:71},Cr=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=Ks[u];if(c===void 0)throw chunkCO2BI6WL_cjs.c.parsing("AS_CONVERTER_UNSUPPORTED_BASE",`"as base ${l?.value??"?"}": only bases ${Object.keys(Ks).join(", ")} can be written out`);e.consume(),n.emitOpcode(c);return}let s=Bc[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 $s={ten:10,hundred:100,thousand:1e3,million:1e6,billion:1e9};function Ws(t,e,o){t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(23),Ys(t,o),t.emitOpcode(10),t.emitNumber(e),t.emitOpcode(22);}function Ys(t,e){let o=e==="up"?Uc:e==="down"?Dc:Mc;t.emitOpcode(51),t.emitIndex(o),t.emitIndex(1);}var Mc=8,Uc=6,Dc=7,bc=97;function Vc(t){let o=(t.peek()?.text??"").toLowerCase();return o==="up"?(t.consume(),"up"):o==="down"?(t.consume(),"down"):"nearest"}var Sr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){let i=Vc(e);if(e.match("TO_NEAREST")){Ws(n,js(e),i);return}Ys(n,i);}},Lr=class{constructor(){this.category="Converters";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){Ws(n,js(e),"nearest");}};function js(t){let e=t.peek(),o=(e?.text??"").toLowerCase(),r=$s[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($s).join(", ")}`)}var wr=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(bc),n.emitIndex(2);}};var Fc=new Set(["dp","dps","decimals","digits","digit"]),Hc=new Set(["decimal"]);function Xs(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(Hc.has(i)){let l=(e[o+3]?.text??"").toLowerCase();if(l!=="place"&&l!=="places")return null;a=4;}else if(!Fc.has(i))return null;return {consumed:a,replacement:[chunkKLPKLTJZ_cjs.b("DECIMAL_PLACES",r.value,e.slice(o,o+a))],ruleName:"converters:decimal-places"}}}}var Gc=new Set(["hex","bin"]);function Qs(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"&&Gc.has(n.value.toLowerCase())?{consumed:1,replacement:[chunkKLPKLTJZ_cjs.b("AS","as",[r])],ruleName:"converters:preposition"}:null}}}var Sn={name:"solve-converters",phrases:{"to nearest":"TO_NEAREST","to the nearest":"TO_NEAREST"},infixParselets:{AS:new Cr,ROUNDED:new Sr,TO_NEAREST:new Lr,DECIMAL_PLACES:new wr},normalizerRules:[Xs(),Qs()]};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 vr=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 Ln(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 Zs={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);}},Js={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);}},em={category:"MathPhrases",parse(t,e,o){if(t.parseExpression(chunkEN3CDYOS_cjs.a.Conditional,o),qs(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),qs(o),o.emitOpcode(23);}},zc=5;function qs(t){t.emitOpcode(51),t.emitIndex(zc),t.emitIndex(1);}function tm(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:[chunkKLPKLTJZ_cjs.b("NTH_ROOT","root",[r])],ruleName:"mathphrases:function-phrase"};let i=Kc(e,o+1);if(i===-1)return null;let a=e.slice(o,i+1).map((s,l)=>l===0?chunkKLPKLTJZ_cjs.b("LOG_PHRASE","log",[s]):l===i-o?chunkKLPKLTJZ_cjs.b("LOG_BASE","base",[s]):s);return {consumed:i-o+1,replacement:a,ruleName:"mathphrases:function-phrase"}}}}function Kc(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 rm={category:"MathPhrases",parse(t,e,o){t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,o),o.emitOpcode(10),o.emitNumber(2),o.emitOpcode(23);}};var om={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 nm=tr({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 $c=47,kr=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($c),r.emitIndex(3);}};var Wc=46,Br=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(Wc),n.emitIndex(3);}};var Yc=42,jc=43,Xc=44,Qc=45,qc=9,Zc=10,Jc=101,ep=102,tp=103,rp=104,op=105,np=106,ip=107,ap=38,sp=39,mp=0,lp=21,wn={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(Yc),MEDIAN_OF:new H(jc),TOTAL_OF:new H(Xc),COUNT_OF:new H(Qc),LARGER_OF:mt(Zc),SMALLER_OF:mt(qc),HALF_OF:rm,MIDPOINT_BETWEEN:om,RANDOM_NUMBER:nm,REMAINDER_OF:Zs,NTH_ROOT:Js,LOG_PHRASE:em,GCD_OF:mt(ap),LCM_OF:mt(sp),SQUARE_ROOT_OF:Ln(mp),CUBE_ROOT_OF:Ln(lp),CLAMP:new kr,STANDARD_DEVIATION_OF:new H(Jc),SAMPLE_STANDARD_DEVIATION_OF:new H(ep),VARIANCE_OF:new H(tp),SAMPLE_VARIANCE_OF:new H(rp),SPREAD_OF:new H(op),MODE_OF:new H(np),WEIGHTED_AVERAGE_OF:new vr(ip)},infixParselets:{IS_TO:new Br},normalizerRules:[tm()]};var im={annually:1,yearly:1,"semi-annually":2,quarterly:4,monthly:12,fortnightly:26,weekly:52,daily:365};function vn(t){if(!t.match("COMPOUNDING"))return 1;let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=im[o];if(r===void 0)throw chunkCO2BI6WL_cjs.c.parsing("UNKNOWN_COMPOUNDING_INTERVAL",`compounding ${o||"?"}: expected one of ${Object.keys(im).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=vn(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);}},Mr=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);}},Ur=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);}},Dr=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 br(t,e,o){return sm(t,o)?(t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),am(t),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),{swap:true}):(am(t),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),up(t,o),t.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,e),{swap:false})}function sm(t,e){for(let o of e)if(t.match(o))return true;return false}function up(t,e){sm(t,e)||t.consume(e[0]);}function am(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}=br(e,r,["AFTER","FOR_DURATION","OVER"]),i=vn(e);if(n&&r.emitOpcode(2),i===1){r.emitOpcode(51),r.emitIndex(this.builtinIndex),r.emitIndex(3);return}r.emitOpcode(10),r.emitNumber(i),r.emitOpcode(51),r.emitIndex(this.intervalIndex),r.emitIndex(4);}};var W=class{constructor(e,o){this.builtinIndex=e;this.periodsPerYear=o;this.category="Finance";}parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Lowest,r);let{swap:n}=br(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 Vr=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);}},Fr=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 mm={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 cp(t){let e=t.peek(),o=(e?.text??e?.value??"").toLowerCase(),r=mm[o];if(r===void 0)throw chunkCO2BI6WL_cjs.c.parsing("UNKNOWN_SAVINGS_PERIOD",`savings goal: expected a contribution period, one of ${Object.keys(mm).join(", ")}, not "${o||"?"}".`);return t.consume(),r}var Hr=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=cp(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);}},Gr=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 pp=60;function fp(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(!fp(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(pp),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 zr=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 Kr=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 lm(t,e){return chunk75JLWK4L_cjs.P(t,`Year ${e} is outside the bundled CPI table's range (${chunkHCPZRSHR_cjs.z}-${chunkHCPZRSHR_cjs.A})`)}function um(t){let e=t[0],o=t[1].toNumber(),r=new Date().getFullYear(),n=chunkHCPZRSHR_cjs.B(e.toNumber(),o,r);return n===void 0?lm("INFLATION_YEAR_OUT_OF_RANGE",o):e.type===6?chunk75JLWK4L_cjs.u(n,e.unit):chunk75JLWK4L_cjs.n(n)}function cm(t){let e=t[0],o=new Date().getFullYear(),r=t[1].toNumber(),n=chunkHCPZRSHR_cjs.B(e.toNumber(),o,r);return n===void 0?lm("INFLATION_YEAR_OUT_OF_RANGE",r):e.type===6?chunk75JLWK4L_cjs.u(n,e.unit):chunk75JLWK4L_cjs.n(n)}function pm(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 fm(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:[chunkKLPKLTJZ_cjs.b("IN_YEAR_DOLLARS",n.value,e.slice(o,o+3))],ruleName:"finance:in-year-dollars"}}}}var dp={RECURRING_INTERVAL_NOT_POSITIVE:"RECURRING_INTERVAL_NOT_POSITIVE"},Ep={daily:365,weekly:52,monthly:12,yearly:1,annually:1},Tp={day:365,days:365,week:52,weeks:52,month:12,months:12,year:1,years:1},Np=new Set(["a","an"]),yp=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]);function pt(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}function dm(t){if(!(t===void 0||t.type!=="UNIT"))return Tp[pt(t)]}function gp(t,e){let o=t[e];if(o===void 0)return null;if(o.type==="IDENT"){let r=Ep[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=dm(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:dp.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 Pp(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"&&Np.has(pt(o)))r=1,n=e+1;else return null;let i=dm(t[n]);return i===void 0||!Number.isFinite(r)||r<0?null:{years:r/i,consumed:n-e+1}}function _p(t,e){let o=t*e,r=Math.round(o);return Math.abs(o-r)<1e-9?r:Math.floor(o)}function Em(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||!yp.has(r.type))return null;let n=gp(e,o+1);if(n===null)return null;let i=o+1+n.consumed;if(e[i]?.type!=="FOR_DURATION")return null;let a=Pp(e,i+1);if(a===null)return null;let s=_p(n.perYear,a.years),l=i+1+a.consumed-o,u=e.slice(o,o+l);return {replacement:[r,chunkKLPKLTJZ_cjs.b("STAR","*",u),chunkKLPKLTJZ_cjs.b("NUMBER",String(s),u)],consumed:l,ruleName:"finance:recurring-schedule"}}}}function $r(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var Tm=new Set(["NUMBER","FLOAT","HEX","BIGINT","RPAREN","RBRACKET","IDENT","PERCENT","STRING"]),Nm=new Set(["NUMBER","FLOAT"]);function ym(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(Tm.has(r.type)){let f=e[o+1],T=e[o+2],N=e[o+3];if(f?.type==="IDENT"&&$r(f)==="split"&&T!==void 0&&Nm.has(T.type)&&N?.type==="IDENT"&&$r(N)==="ways")return {consumed:4,replacement:[r,chunkKLPKLTJZ_cjs.b("SPLIT_WAYS","split",[f]),T,chunkKLPKLTJZ_cjs.b("WAYS","ways",[N])],ruleName:"finance:bill-split"}}if(r.type!=="IDENT"||$r(r)!=="split")return null;let n=e[o-1];if(n!==void 0&&Tm.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||!Nm.has(a.type))return null;let s=i+2,l=e[s]?.type==="IDENT"&&$r(e[s])==="people",u=l?s:i+1,c=[chunkKLPKLTJZ_cjs.b("SPLIT","split",[r]),...e.slice(o+1,i+2)];return l&&c.push(chunkKLPKLTJZ_cjs.b("PEOPLE","people",[e[s]])),{consumed:u-o+1,replacement:c,ruleName:"finance:bill-split"}}}}var kn=51,Ap=52,Wr=55,Yr=56,Bn=80,xp=81,Op=82,Rp=83,Ip=84,hp=59,Cp=85,Sp=86,gm=98,Lp=99,wp=100,Mn={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 Mr(Op),ANNUAL_RETURN_ON:new Dr(Ip),COMPOUND_INTEREST_ON:new ut(kn,Bn),INTEREST_ON:new ut(Ap,xp),DAILY_REPAYMENT_ON:new W(Wr,365),MONTHLY_REPAYMENT_ON:new W(Wr,12),ANNUAL_REPAYMENT_ON:new W(Wr,1),TOTAL_REPAYMENT_ON:new W(Wr,0),DAILY_LOAN_INTEREST_ON:new W(Yr,365),MONTHLY_LOAN_INTEREST_ON:new W(Yr,12),ANNUAL_LOAN_INTEREST_ON:new W(Yr,1),TOTAL_LOAN_INTEREST_ON:new W(Yr,0),TAX_ON:new Le(Sp),TAX_OFF:new Le(hp),TAX_IN_PHRASE:new Le(Cp),SPLIT:new Vr(gm),WHAT_IS:new ct("what-is"),WHAT_WAS:new ct("what-was"),VALUE_OF:new zr,SAVINGS_HOW_LONG:new Hr(wp),SAVINGS_HOW_MUCH:new Gr(Lp)},infixParselets:{AFTER:new lt(kn,Bn),FOR_DURATION:new lt(kn,Bn),INVESTED:new Ur(Rp),IN_YEAR_DOLLARS:new Kr,SPLIT_WAYS:new Fr(gm)},normalizerRules:[fm(),Em(),ym()],pluginFunctions:{inflationFromYearToPresent:um,inflationToYearFromPresent:cm,inflationFutureValue:pm}};function vp(t){return (e,o)=>chunk75JLWK4L_cjs.P(`${t.toUpperCase()}_QUERY_FAILED`,`Failed to resolve "${e}": ${o instanceof Error?o.message:String(o)}`)}function de(t){let e=t.staleTimeMs??3e5,o=t.timeoutMs??1e4,r=t.failureCooldownMs??3e4,n=t.onError??vp(t.namespace),i=u=>[t.namespace,u];async function a(u,c,f){let{signal:T,cleanup:N}=chunkTLG7VZRX_cjs.a(c,o,`${t.namespace} query`);try{return await t.fetchQuery(u,T)}catch(E){let _=n(u,E);return setTimeout(()=>{f.getQueryData(i(u))===_&&f.removeQueries({queryKey:i(u),exact:true});},r).unref?.(),_}finally{N();}}return {resolver:{namespace:t.namespace,preflight(u,c,f,T,N){let{opcodes:E,strings:_}=c,O=E.length,R=0;for(;R<O;){if(E[R]===50&&R+2<O){let P=E[R+1],h=E[R+2];if(P===t.pluginFunctionIndex&&h>=1&&R>=2&&E[R-2]===13){let S=_[E[R-1]],j=i(S);if(N.getQueryData(j)===void 0){let ze=N.fetchQuery({queryKey:j,queryFn:({signal:bo})=>a(S,bo,N),staleTime:e}),me={queryKey:j.join(":"),resolver:ze,packageId:f,signal:T,metadata:{query:S}};return t.refetchIntervalMs!==void 0&&(me.refetchIntervalMs=t.refetchIntervalMs,me.refetch=()=>N.fetchQuery({queryKey:j,queryFn:({signal:bo})=>a(S,bo,N),staleTime:0})),me}}R+=3;continue}R=chunkTL545PXW_cjs.a(E,R);}return null},destroy(){}},pluginFunction:u=>{let c=u[0]?.value,f=chunkZLRJ7TDP_cjs.b()?.getQueryData(i(c));return f!==void 0?f:chunk75JLWK4L_cjs.P(`${t.namespace.toUpperCase()}_NOT_PREFLIGHTED`,`No cached result for "${c}"`)}}}function kp(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=kp(o,r.value);n.emitOpcode(13),n.emitString(`${t}:${i}`),n.emitPluginCall(e,1);}}}var Bp={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 Pm(t){return Bp[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"},Mp="https://geocoding-api.open-meteo.com/v1/search",Up="https://api.open-meteo.com/v1/forecast",Dp=1e4;async function bp(t,e){let o=`${Mp}?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 Vp(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(`${Up}?${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 jr=new Map,Fp=6e4;function _m(t,e){let o=t.trim().toLowerCase(),r=Date.now(),n=jr.get(o);if(n&&n.expiresAt>r)return n.promise;let{signal:i,cleanup:a}=chunkTLG7VZRX_cjs.a(e,Dp,"Open-Meteo weather query"),s=(async()=>{try{let l=await bp(t,i),u=await Vp(l.latitude,l.longitude,i);return {resolvedName:l.name,weatherCode:u.weatherCode,description:Pm(u.weatherCode),temperature:u.temperature,apparentTemperature:u.apparentTemperature,high:u.high,low:u.low}}finally{a();}})();return jr.set(o,{promise:s,expiresAt:r+Fp}),s.catch(()=>{jr.get(o)?.promise===s&&jr.delete(o);}),s}var Am="solve-weather",Ee="weather",Hp=chunkHCPZRSHR_cjs.F(`${Am}:${Ee}`),{resolver:Gp,pluginFunction:zp}=de({namespace:"weather",pluginFunctionIndex:Hp,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 _m(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})}}}),Un={name:Am,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]:zp},asyncResolvers:[Gp]};var Xr={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,sept:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11};function qr(t){return t<10?`0${t}`:String(t)}function 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}-${qr(e+1)}-${qr(o)}`,raw:r}}function Qr(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 xm(t){let e=t.peek();if(!e)return null;if(e.type==="DATETIME_LITERAL"){t.consume();let o=new Date(Number(e.value));return Number.isNaN(o.getTime())?null:{isoDate:`${o.getFullYear()}-${qr(o.getMonth()+1)}-${qr(o.getDate())}`,raw:e.text??e.value}}if(e.type==="NUMBER"){let o=t.consume(),r=t.peek();if(r&&(r.type==="SLASH"||r.type==="MINUS")){let i=r.type;t.consume();let a=t.consume("NUMBER");t.consume(i);let s=t.consume("NUMBER"),l=`${o.value}${i==="SLASH"?"/":"-"}${a.value}${i==="SLASH"?"/":"-"}${s.value}`;if(i==="SLASH"){let u=parseInt(o.value,10),c=parseInt(a.value,10),f=Qr(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=Qr(s.value,l);return ft(f,u-1,c,l)}}let n=t.peek();if(n&&n.type==="IDENT"&&Xr[n.value.toLowerCase()]!==void 0){let i=Xr[n.value.toLowerCase()];t.consume(),t.peek()?.type==="COMMA"&&t.consume();let a=t.consume("NUMBER"),s=`${o.value} ${n.value} ${a.value}`,l=Qr(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"&&Xr[e.value.toLowerCase()]!==void 0){let o=Xr[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=Qr(n.value,i);return ft(a,o,parseInt(r.value,10),i)}return null}var Om=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",Kp=chunk5IJD5L3O_cjs.c(ke);function Rm(){return {name:"stocks:bare-ticker",priority:20,startTokenTypes:["IDENT"],match(t,e){let o=t[e];return !o||o.type!=="IDENT"||!Om.has(o.value)||e>0&&t[e-1].type==="COLON"?null:{consumed:1,replacement:[new chunkEAB6SSAV_cjs.a(ke,Kp,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"stocks:bare-ticker"}}}}function $p(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=xm(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 Im(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 hm(t,e,o,r,n){let i=false;t.peek()?.type==="STAR"&&(t.consume(),i=true);let a=$p(t);if(i&&!a){Im(e,o,null,r,n),t.parseExpression(chunkEN3CDYOS_cjs.a.Product,e),e.emitOpcode(22);return}Im(e,o,a,r,n);}function Cm(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"),hm(o,n,a,t,e);}}}function Sm(t,e){return {category:"Stocks",parse(o,r,n){let i=r.value.toUpperCase();hm(o,n,i,t,e);}}}var Dn="solve-stocks",Zr="stock",Jr="stockhistorical";function Lm(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}=de({namespace:"stocks-current",pluginFunctionIndex:chunkHCPZRSHR_cjs.F(`${Dn}:${Zr}`),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}=de({namespace:"stocks-historical",pluginFunctionIndex:chunkHCPZRSHR_cjs.F(`${Dn}:${Jr}`),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:Dn,lexerVocabulary:{keywords:{stock:"STOCK_FN"}},prefixParselets:{STOCK_FN:Cm(Zr,Jr),...t.enableBareTickerRecognition?{[ke]:Sm(Zr,Jr)}:{}},normalizerRules:t.enableBareTickerRecognition?[Rm()]:[],pluginFunctions:{[Zr]:r,[Jr]:i},asyncResolvers:[o,n]}}function wm(t){return {category:"Knowledge",parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall(t,1);}}}function vm(t={}){let e="solve-knowledge",o="knowledge",r=chunkHCPZRSHR_cjs.F(`${e}:${o}`),{resolver:n,pluginFunction:i}=de({namespace:"knowledge",pluginFunctionIndex:r,staleTimeMs:t.staleTimeMs??300*1e3,fetchQuery:async(a,s)=>{if(!t.answerQuery)return 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:wm(o)},pluginFunctions:{[o]:i},asyncResolvers:[n]}}var eo=class{constructor(){this.category="Lines";}parse(e,o,r){r.emitPluginCall("prev",0);}};var to=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 Be=class{constructor(e){this.isAverage=e;this.category="Lines";}parse(e,o,r){r.emitPluginCall(this.isAverage?"averageAbove":"totalAbove",0);}};var Wp=chunk5IJD5L3O_cjs.c("LINE_REF"),Yp=chunk5IJD5L3O_cjs.c("SUM_RANGE_CALL"),jp=chunk5IJD5L3O_cjs.c("AVERAGE_RANGE_CALL");function Bm(){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:[km(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:[km(r.value,o)],ruleName:"lines:line-ref"}}return null}}}function km(t,e){return new chunkEAB6SSAV_cjs.a("LINE_REF",Wp,t,t,e.offset,0,e.line,e.col)}function Mm(){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"?jp:Yp;return {consumed:1,replacement:[new chunkEAB6SSAV_cjs.a(n,i,o.value,o.value,o.offset,0,o.line,o.col)],ruleName:"lines:range-call"}}}}function ro(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 Me(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 Um(t,e){let o=Me(e);if(o)return o;let r=e.lineIndex-1,n=e.getLineResult(r);return ro(n,r)??n}function Dm(t,e){let o=Me(e);if(o)return o;let r=t[0].toNumber(),n=e.getLineResult(r);return ro(n,r)??n}function bm(t,e,o,r){let n=0,i=0,a,s=false,l=t<=e?1:-1;for(let c=t;l>0?c<=e:c>=e;c+=l){let f=o.getLineResult(c),T=ro(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 Vm(t,e){let o=Me(e);return o||bm(t[0].toNumber(),t[1].toNumber(),e,false)}function Fm(t,e){let o=Me(e);return o||bm(t[0].toNumber(),t[1].toNumber(),e,true)}function Hm(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=ro(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 Gm(t,e){let o=Me(e);return o||Hm(e,false)}function zm(t,e){let o=Me(e);return o||Hm(e,true)}var bn={name:"solve-lines",lexerVocabulary:{keywords:{prev:"PREV"}},phrases:{"total above":"TOTAL_ABOVE","sum above":"SUM_ABOVE","average above":"AVERAGE_ABOVE"},normalizerRules:[Bm(),Mm()],prefixParselets:{PREV:new eo,LINE_REF:new to,SUM_RANGE_CALL:new dt(false),AVERAGE_RANGE_CALL:new dt(true),TOTAL_ABOVE:new Be(false),SUM_ABOVE:new Be(false),AVERAGE_ABOVE:new Be(true)},pluginFunctions:{prev:Um,lineRef:Dm,sumRange:Vm,averageRange:Fm,totalAbove:Gm,averageAbove:zm}};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"&&Xp.has(a.value.toLowerCase())){e.consume();continue}break}r.emitOpcode(13),r.emitString(i.value),r.emitPluginCall(this.pluginFnName,1);}},Xp=new Set(["the","table","above"]);function Km(t){return t.trimStart().startsWith("|")}function Qp(t){let e=t.trim();return e.length===0||!e.includes("-")||!e.includes("|")?false:/^[|\s:-]+$/.test(e)}function $m(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 qp(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 Wm(t,e){let o=-1;for(let s=e-1;s>=1;s--){let l=t(s);if(l===void 0)break;if(Km(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||!Km(s))break;r--;}let n=-1;for(let s=r;s<=o;s++)if(Qp(t(s))){n=s;break}if(n===-1||n===r)return null;let i=$m(t(n-1)),a=[];for(let s=n+1;s<=o;s++)a.push($m(t(s)));return {header:i,rows:a}}function Ym(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 jm(t,e){let o=[];for(let r of t.rows){let n=qp(r[e]);n!==null&&o.push(n);}return o}var oo={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 no(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 Zp(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(no(e,false));case "sampleStdev":return Math.sqrt(no(e,true));case "variance":return no(e,false);case "sampleVariance":return no(e,true);case "spread":return Math.max(...e)-Math.min(...e);case "mode":{let o=new Map,r=e[0],n=0;for(let i of e){let a=(o.get(i)??0)+1;o.set(i,a),a>n&&(n=a,r=i);}return r}}}function z(t,e,o){let r=o?.getLineText;if(!r||o.lineIndex<1)return chunk75JLWK4L_cjs.P(oo.TABLE_NO_DOCUMENT,"Reading a table column needs a real document, which the single-expression path (evaluateExpression) does not have");let n=Wm(r,o.lineIndex);if(!n)return chunk75JLWK4L_cjs.P(oo.TABLE_NOT_FOUND,'No markdown table found above this line (a table row starts with "|", and needs a "|---|" separator under its header)');let i=Ym(n.header,e);if(i===-1){let s=n.header.map(l=>`"${l}"`).join(", ");return chunk75JLWK4L_cjs.P(oo.TABLE_COLUMN_NOT_FOUND,`The table above has no column named "${e}". Its columns are: ${s}`)}let a=jm(n,i);return t==="count"?chunk75JLWK4L_cjs.n(a.length):a.length===0?chunk75JLWK4L_cjs.P(oo.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(Zp(t,a))}function K(t){let e=t[0];return e&&e.type===3&&typeof e.value=="string"?e.value:String(e?.value??"")}function Xm(t,e){return z("sum",K(t),e)}function Qm(t,e){return z("average",K(t),e)}function qm(t,e){return z("min",K(t),e)}function Zm(t,e){return z("max",K(t),e)}function Jm(t,e){return z("count",K(t),e)}function el(t,e){return z("median",K(t),e)}function tl(t,e){return z("stdev",K(t),e)}function rl(t,e){return z("sampleStdev",K(t),e)}function ol(t,e){return z("variance",K(t),e)}function nl(t,e){return z("sampleVariance",K(t),e)}function il(t,e){return z("spread",K(t),e)}function al(t,e){return z("mode",K(t),e)}var Vn={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:Xm,TABLE_COLUMN_AVERAGE:Qm,TABLE_COLUMN_MIN:qm,TABLE_COLUMN_MAX:Zm,TABLE_COLUMN_COUNT:Jm,TABLE_COLUMN_MEDIAN:el,TABLE_COLUMN_STDEV:tl,TABLE_COLUMN_SAMPLE_STDEV:rl,TABLE_COLUMN_VARIANCE:ol,TABLE_COLUMN_SAMPLE_VARIANCE:nl,TABLE_COLUMN_SPREAD:il,TABLE_COLUMN_MODE:al}};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 io(t){return t===void 0?"":(t.text??t.value??"").toLowerCase()}var sl={TOTAL_OF:"TAG_SUM",COUNT_OF:"TAG_COUNT",AVERAGE_OF:"TAG_AVERAGE"},Jp=new Set(["total","sum","count","average"]);function ml(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=sl[r.type];if(n!==void 0){let i=e[o+1];return i?.type!=="TAG"?null:{consumed:2,replacement:[chunkKLPKLTJZ_cjs.b(n,i.value??"",[r,i])],ruleName:"tags:aggregate"}}if(r.type==="IDENT"&&io(r)==="sum"){let i=e[o+1],a=e[o+2];return io(i)!=="of"||a?.type!=="TAG"?null:{consumed:3,replacement:[chunkKLPKLTJZ_cjs.b("TAG_SUM",a.value??"",[r,i,a])],ruleName:"tags:aggregate"}}return null}}}function ll(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&&(sl[r.type]!==void 0||io(r)==="of"&&Jp.has(io(e[o-2])))?null:{consumed:1,replacement:[],ruleName:"tags:strip"}}}}function ef(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ul(t,e){if(e==="")return false;let r=new RegExp(`(?:^|[^0-9A-Za-z_])#${ef(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 tf(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 Fn(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 Hn(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)||!ul(N,a))continue;let E=n(T),_=tf(E,T);if(_)return _;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 cl(t,e){let o=Fn(e);return o||Hn(e,String(t[0].value),"sum")}function pl(t,e){let o=Fn(e);return o||Hn(e,String(t[0].value),"average")}function fl(t,e){let o=Fn(e);return o||Hn(e,String(t[0].value),"count")}var Gn={name:"solve-tags",normalizerRules:[ml(),ll()],prefixParselets:{TAG_SUM:new Ue("sum"),TAG_AVERAGE:new Ue("average"),TAG_COUNT:new Ue("count")},pluginFunctions:{sum:cl,average:pl,count:fl}};var ao=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 dl(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:[chunkKLPKLTJZ_cjs.b("PLUS_MINUS","\xB1",[r,n,i])],ruleName:"uncertainty:ascii-plus-minus"}}}}var zn={name:"solve-uncertainty",infixParselets:{PLUS_MINUS:new ao},normalizerRules:[dl()]};var El=1e-9,Tl=1e9,rf=100,of=1e-9,nf=1e-9,af=1e-12,sf=1e-9,so="goalseek";function Nl(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=mf(u.value,s,i);if(f!==null)return chunk75JLWK4L_cjs.n(f)}let c=e.goalSeekMaxIterations??rf;return lf(o,n,i,s,c)}function mf(t,e,o){let r=chunkJ7ABVGZH_cjs.p(chunkJ7ABVGZH_cjs.d(e)),n;try{n=chunkHCPZRSHR_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)<=sf&&Number.isFinite(l.re)&&i.push(l.re);if(i.length===0)return null;let a=i.filter(l=>l>=El&&l<=Tl),s=a.length>0?a:i;return s.sort((l,u)=>Math.abs(l)-Math.abs(u)),s[0]}function lf(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 _=E.toNumber();return Number.isFinite(_)?{value:_}:{error:chunk75JLWK4L_cjs.P("GOAL_SEEK_NON_FINITE",`Line ${e}'s result is not finite when ${o} is ${N}.`)}},a=El,s=Tl,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(of,Math.abs(r)*nf),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,_=i(E);if("error"in _)return _.error;let O=_.value-r;if(Math.abs(O)<=c)return chunk75JLWK4L_cjs.n(E);if(s-a<=af)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(O)===Math.sign(f)?(a=E,f=O):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 mo=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(so,3);}};var uf=chunk5IJD5L3O_cjs.c("GOAL_SEEK");function yl(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 chunkEAB6SSAV_cjs.a("GOAL_SEEK",uf,r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"goalseek:solve-line"}}}}var Kn={name:"solve-goalseek",normalizerRules:[yl()],prefixParselets:{GOAL_SEEK:new mo},pluginFunctions:{[so]:Nl}};var lo=class{constructor(){this.category="Colour";}parse(e,o,r){r.emitOpcode(13),r.emitString(o.value),r.emitPluginCall("colour",1);}};var Te={COLOUR_INVALID:"COLOUR_INVALID",COLOUR_EXPECTED_COLOUR:"COLOUR_EXPECTED_COLOUR",COLOUR_BAD_ARGUMENTS:"COLOUR_BAD_ARGUMENTS"};function B(t){return t&&t.type===14?t.value:null}function U(t){if(!t)return 0;let e=t.toNumber();return t.type===5?e:e>1?e/100:e}function q(t,e){return chunk75JLWK4L_cjs.P(Te.COLOUR_BAD_ARGUMENTS,`${t}(...) expects ${e}`)}function Y(t){return chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,`${t}(...) expects a colour as its first argument`)}function gl(t){let e=t[0];if(!e||e.type!==3||typeof e.value!="string")return q("color",'a string, e.g. color("#ff0000") or color("red")');let o=chunk5TVI2UPZ_cjs.c(e.value);return o?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 cf(t){return t.length!==3?q("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 pf(t){return t.length!==4?q("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 ff(t){if(t.length!==3)return q("hsl","three values: hsl(hue, saturation%, lightness%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.e(t[0].toNumber(),U(t[1]),U(t[2]));return chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hsl"})}function df(t){if(t.length!==4)return q("hsla","four values: hsla(hue, saturation%, lightness%, alpha)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.e(t[0].toNumber(),U(t[1]),U(t[2]));return 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=B(o[0]);return r?o.length<2?q(t,`a colour and an amount, e.g. ${t}(#3366cc, 20%)`):chunk75JLWK4L_cjs.G(e(r,U(o[1]))):Y(t)}}var Ef=Ne("lighten",chunk5TVI2UPZ_cjs.j),Tf=Ne("darken",chunk5TVI2UPZ_cjs.k),Nf=Ne("saturate",chunk5TVI2UPZ_cjs.l),Pl=Ne("desaturate",chunk5TVI2UPZ_cjs.m);function $n(t){let e=B(t[0]);return e?t.length<2?q("rotate","a colour and a hue angle in degrees, e.g. rotate(#ff0000, 90)"):chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.n(e,t[1].toNumber())):Y("rotate")}function yf(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.o(e)):Y("complement")}function _l(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.p(e)):Y("grayscale")}function Al(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.q(e,t.length>1?U(t[1]):1)):Y("invert")}function gf(t){let e=B(t[0]),o=B(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 Wn(t){let e=B(t[0]);return e?t.length<2?chunk75JLWK4L_cjs.n(e.a):chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.s(e,U(t[1]))):Y("alpha")}function Pf(t){let e=B(t[0]),o=B(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 _f(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.n(chunk5TVI2UPZ_cjs.h(e)):Y("luminance")}function De(t,e){return o=>{let r=B(o[0]);return r?chunk75JLWK4L_cjs.n(e(r)):Y(t)}}var Af=De("red",t=>t.r),xf=De("green",t=>t.g),Of=De("blue",t=>t.b),Rf=De("hue",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).h),If=De("saturation",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).s*100),hf=De("lightness",t=>chunk5TVI2UPZ_cjs.d(t.r,t.g,t.b).l*100);function xl(t){if(t.length!==3)return q("hsv","three values: hsv(hue, saturation%, value%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.t(t[0].toNumber(),U(t[1]),U(t[2]));return chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}function Cf(t){if(t.length!==4)return q("hsva","four values: hsva(hue, saturation%, value%, alpha)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.t(t[0].toNumber(),U(t[1]),U(t[2]));return chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:chunk5TVI2UPZ_cjs.b(U(t[3])),format:"hex"})}function Sf(t){if(t.length!==3)return q("hwb","three values: hwb(hue, whiteness%, blackness%)");let{r:e,g:o,b:r}=chunk5TVI2UPZ_cjs.u(t[0].toNumber(),U(t[1]),U(t[2]));return chunk75JLWK4L_cjs.G({r:e,g:o,b:r,a:1,format:"hex"})}var Lf=Ne("tint",chunk5TVI2UPZ_cjs.v),wf=Ne("shade",chunk5TVI2UPZ_cjs.w),vf=Ne("tone",chunk5TVI2UPZ_cjs.x);function kf(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.L(chunk5TVI2UPZ_cjs.y(e)):Y("isdark")}function Bf(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.L(!chunk5TVI2UPZ_cjs.y(e)):Y("islight")}function Yn(t){let e=B(t[0]);return e?chunk75JLWK4L_cjs.G(chunk5TVI2UPZ_cjs.z(e)):Y("readable")}function Mf(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 Uf(t){let e=B(t[0]),o=B(t[1]);return !e||!o?chunk75JLWK4L_cjs.P(Te.COLOUR_EXPECTED_COLOUR,"iscontrastcompliant(...) expects two colours"):chunk75JLWK4L_cjs.L(chunk5TVI2UPZ_cjs.i(e,o)>=Mf(t[2]))}function Ol(t){let e=B(t[0]),o=B(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:gl,colour:gl,rgb:cf,rgba:pf,hsl:ff,hsla:df,lighten:Ef,darken:Tf,saturate:Nf,desaturate:Pl,desat:Pl,rotate:$n,spin:$n,adjusthue:$n,complement:yf,grayscale:_l,greyscale:_l,invert:Al,mix:gf,alpha:Wn,opacity:Wn,fade:Wn,contrast:Pf,luminance:_f,red:Af,green:xf,blue:Of,hue:Rf,saturation:If,lightness:hf,hsv:xl,hsb:xl,hsva:Cf,hwb:Sf,tint:Lf,shade:wf,tone:vf,negate:Al,isdark:kf,islight:Bf,readable:Yn,contrastcolor:Yn,contrastcolour:Yn,iscontrastcompliant:Uf,wcaglevel:Ol,wcag:Ol};var uo=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 Rl=new Set(Object.keys(ye));function Il(t=80){return {name:"colour:call",priority:t,shape:[{types:["IDENT"],values:[...Rl]},{types:["LPAREN"]}],match(e,o){let r=e[o];if(!r||r.type!=="IDENT")return null;let n=r.value.toLowerCase();return !Rl.has(n)||e[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new chunkEAB6SSAV_cjs.a("COLOUR_CALL",chunk5IJD5L3O_cjs.c("COLOUR_CALL"),r.value,r.value,r.offset,0,r.line,r.col)],ruleName:"colour:call"}}}}var co=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})},Df=Object.keys(ye).map(t=>({label:t,category:"function",detail:"colour"})),jn={name:"solve-colour",prefixParselets:{HEX_COLOUR:new lo,COLOUR_CALL:new uo},normalizerRules:[Il()],pluginFunctions:ye,asConverters:{rgb:co("rgb"),rgba:co("rgba"),hsl:co("hsl"),hsla:co("hsla")},completionItems:Df};var Xn=32;function bf(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 Vf(t){let e=t.max-t.min+1,o=Math.min(e,Xn),r=[];for(let n=0;n<o;n++)r.push(t.min+Math.round(n*(e-1)/(o-1)));return r}function Ff(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 hl(t){let e=null;if(t.type===7)e=bf(t.value);else if(t.type===8){let a=t.value;e=a.max-a.min+1>=2?Vf(a):null;}if(!e||e.length<2)return null;let o=Ff(e,Xn),r=Math.min(...e),n=Math.max(...e),i=e.length<=Xn?`[${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 po=class{constructor(){this.category="Plot";}parse(e,o,r){let n=Hf(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 Hf(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 Cl="PLOT",Gf=chunk5IJD5L3O_cjs.c(Cl),zf=new Set(["NUMBER","IDENT","FUNC","UNIT","LPAREN","PI","E"]);function Sl(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||!zf.has(i.type)?null:{consumed:1,replacement:[new chunkEAB6SSAV_cjs.a(Cl,Gf,n.value,n.value,n.offset,0,n.line,n.col)],ruleName:e}}}}var Qn={name:"solve-chart",asConverters:{sparkline:t=>{let e=hl(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 po},normalizerRules:[Sl()],tokenCategories:{PLOT:"keyword"}};var Et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function qn(t){let e=new TextEncoder().encode(t),o="";for(let r=0;r<e.length;r+=3){let n=e[r],i=r+1<e.length?e[r+1]:0,a=r+2<e.length?e[r+2]:0;o+=Et[n>>2],o+=Et[(n&3)<<4|i>>4],o+=r+1<e.length?Et[(i&15)<<2|a>>6]:"=",o+=r+2<e.length?Et[a&63]:"=";}return o}function Zn(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=Et.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 Ll(t){return encodeURIComponent(t)}function wl(t){try{return decodeURIComponent(t)}catch{return null}}function vl(t){return Array.from(new TextEncoder().encode(t)).map(e=>e.toString(16).padStart(2,"0")).join(" ")}function Jn(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 Kf(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),o=e.length%4;return o===0?e:e+"=".repeat(4-o)}function ei(t){let e=t.trim().split(".");if(e.length<2||e[1]==="")return null;let o=Zn(Kf(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 ti(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 fo=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 To(t){return t.type===3?t.value:null}function Eo(t,e){return o=>{let r=To(o);return r===null?chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",`"as ${t}" expects text (a "quoted string")`):chunk75JLWK4L_cjs.t(e(r))}}var $f={base64:Zn,url:wl,"hex bytes":Jn,hexbytes:Jn,jwt:ei,query:ti},ri={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:Eo("base64",qn),url:Eo("url",Ll),"hex bytes":Eo("hex bytes",vl)},infixParselets:{FROM_ENCODING:new fo},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=>Eo("base64",qn)(t[0]),jwt:t=>{let e=To(t[0]);if(e===null)return chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",'jwt(...) expects text (a "quoted string")');let o=ei(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=To(t[0]);if(e===null)return chunk75JLWK4L_cjs.P("ENCODING_EXPECTED_TEXT",'query(...) expects text (a "quoted string")');let o=ti(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=To(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=$f[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 No=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 kl="IP_CIDR",Wf=chunk5IJD5L3O_cjs.c(kl),Yf=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{1,2})?/,jf=8;function Bl(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<jf;E++){let _=o[E];if(_.sourceEnd!==void 0||_.offset!==a||_.type!=="NUMBER"&&_.type!=="SLASH")break;i+=_.text??"",a=_.offset+(_.text?.length??0),s.push(_);}let l=Yf.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 chunkEAB6SSAV_cjs.a(kl,Wf,T,l[0],n.offset,0,n.line,n.col,n.offset+l[0].length);return {consumed:c,replacement:[N],ruleName:e}}}}function Tt(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 Ml(t){let[e,o]=String(t[0].value??"").split("|"),r={...e!==""?{addr:Number(e)}:{},...o!==""?{prefix:Number(o)}:{}};return chunk75JLWK4L_cjs.J(r)}function Ul(t){let e=Tt(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 Dl(t){let e=Tt(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 bl(t){let e=Tt(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 Vl(t){let e=Tt(t[0],"in");if(e instanceof chunk75JLWK4L_cjs.m)return e;let o=Tt(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 Fl(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 oi={name:"solve-ip",phrases:{"hosts in":"HOSTS_IN","netmask of":"NETMASK_OF","broadcast of":"BROADCAST_OF"},prefixParselets:{IP_CIDR:new No,HOSTS_IN:new Ve("hostsIn"),NETMASK_OF:new Ve("netmaskOf"),BROADCAST_OF:new Ve("broadcastOf")},normalizerRules:[Bl()],pluginFunctions:{ipLiteral:Ml,hostsIn:Ul,netmaskOf:Dl,broadcastOf:bl,ipInCidr:Vl},asConverters:{int:Fl},tokenCategories:{IP_CIDR:"number",HOSTS_IN:"keyword",NETMASK_OF:"keyword",BROADCAST_OF:"keyword"}};var Xf=chunk5IJD5L3O_cjs.c("UNIT");function Hl(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 chunkEAB6SSAV_cjs.a("UNIT",Xf,"l100km","l/100km",n.offset,0,n.line,n.col)],ruleName:e}}}}var ni={name:"solve-fuel",normalizerRules:[Hl()]};var Qf=chunk5IJD5L3O_cjs.c("UNIT");function Gl(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 chunkEAB6SSAV_cjs.a("UNIT",Qf,"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:chunkBVSATTRX_cjs.d(e.unit,t)?chunk75JLWK4L_cjs.u(chunkBVSATTRX_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 ii={name:"solve-derived-units",normalizerRules:[Gl()],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 ai(t){return [...t].length}function zl(t){return t.trim()}function Kl(t){return [...t].reverse().join("")}function $l(t,e){return t.includes(e)}function Wl(t,e){return t.startsWith(e)}function Yl(t,e){return t.endsWith(e)}function jl(t,e,o){return e===""?t:t.split(e).join(o)}function Xl(t,e){let o=Math.trunc(e);return o<=0?"":t.repeat(o)}function yo(t){return t.toUpperCase()}function go(t){return t.toLowerCase()}function Po(t){return t.replace(/\S+/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function _o(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ql(t){let e=t.trim();return e===""?0:e.split(/\s+/).length}function ql(t){return t===""?0:t.split(/\r\n|\r|\n/).length}function ae(t){return t?.type===3?t.value:null}function Nt(t){return chunk75JLWK4L_cjs.P("TEXT_EXPECTED",`${t} expects text (a "quoted string")`)}function Ao(t,e){return o=>{let r=ae(o[0]);return r===null?Nt(t):chunk75JLWK4L_cjs.n(e(r))}}function Fe(t,e){return o=>{let r=ae(o[0]);return r===null?Nt(t):chunk75JLWK4L_cjs.t(e(r))}}function si(t,e){return o=>{let r=ae(o[0]),n=ae(o[1]);return r===null||n===null?Nt(t):chunk75JLWK4L_cjs.L(e(r,n))}}var Zl={textLength:Ao("length",ai),textWordCount:Ao("words in",Ql),textCharCount:Ao("characters in",ai),textLineCount:Ao("lines in",ql),textTrim:Fe("trim",zl),textReverse:Fe("reverse",Kl),textUpper:Fe('"as upper"',yo),textLower:Fe('"as lower"',go),textTitle:Fe('"as title"',Po),textSlug:Fe('"as slug"',_o),textContains:si("contains",$l),textStartsWith:si("starts with",Wl),textEndsWith:si("ends with",Yl),textReplace:t=>{let e=ae(t[0]),o=ae(t[1]),r=ae(t[2]);return e===null||o===null||r===null?Nt("replace"):chunk75JLWK4L_cjs.t(jl(e,o,r))},textRepeat:t=>{let e=ae(t[0]);if(e===null)return Nt("repeat");let o=t[1];return o?.type!==0?chunk75JLWK4L_cjs.P("TEXT_EXPECTED","repeat expects a count (a number)"):chunk75JLWK4L_cjs.t(Xl(e,o.value))}};function ge(t,e){return {category:"Text",parse(o,r,n){o.parseExpression(e,n),n.emitPluginCall(t,1);}}}function xo(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 Jl={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 Oo={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 Ro=class{constructor(){this.category="Text";}parse(e,o,r){let n=Oo[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 Io(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 mi={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 Ro},infixParselets:{CONTAINS:xo("textContains"),STARTS_WITH:xo("textStartsWith"),ENDS_WITH:xo("textEndsWith"),REPEATED:Jl},asConverters:{upper:Io("upper",yo),lower:Io("lower",go),title:Io("title",Po),slug:Io("slug",_o)},callFusions:Object.fromEntries(Object.keys(Oo).map(t=>[t,"TEXT_CALL"])),pluginFunctions:Zl,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 yt(t){return new TextEncoder().encode(t)}function li(t){let e="";for(let o of t)e+=o.toString(16).padStart(2,"0");return e}var qf=(()=>{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 eu(t){let e=yt(t),o=4294967295;for(let r of e)o=qf[(o^r)&255]^o>>>8;return o=(o^4294967295)>>>0,o.toString(16).padStart(8,"0")}function Zf(t){let e=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],o=new Int32Array(64);for(let N=0;N<64;N++)o[N]=Math.floor(Math.abs(Math.sin(N+1))*4294967296);let r=t.length*8,n=new Uint8Array(((t.length+8>>6)+1)*64);n.set(t),n[t.length]=128;let i=new DataView(n.buffer);i.setUint32(n.length-8,r>>>0,true),i.setUint32(n.length-4,Math.floor(r/4294967296)>>>0,true);let a=1732584193,s=4023233417,l=2562383102,u=271733878,c=(N,E)=>N<<E|N>>>32-E;for(let N=0;N<n.length;N+=64){let E=new Int32Array(16);for(let P=0;P<16;P++)E[P]=i.getUint32(N+P*4,true);let _=a,O=s,R=l,g=u;for(let P=0;P<64;P++){let h,S;P<16?(h=O&R|~O&g,S=P):P<32?(h=g&O|~g&R,S=(5*P+1)%16):P<48?(h=O^R^g,S=(3*P+5)%16):(h=R^(O|~g),S=7*P%16),h=h+_+o[P]+E[S]|0,_=g,g=R,R=O,O=O+c(h,e[P])|0;}a=a+_|0,s=s+O|0,l=l+R|0,u=u+g|0;}let f=new Uint8Array(16),T=new DataView(f.buffer);return T.setUint32(0,a>>>0,true),T.setUint32(4,s>>>0,true),T.setUint32(8,l>>>0,true),T.setUint32(12,u>>>0,true),f}function tu(t){return li(Zf(yt(t)))}function Jf(t){let e=t.length*8,o=new Uint8Array(((t.length+8>>6)+1)*64);o.set(t),o[t.length]=128;let r=new DataView(o.buffer);r.setUint32(o.length-8,Math.floor(e/4294967296)>>>0),r.setUint32(o.length-4,e>>>0);let n=1732584193,i=4023233417,a=2562383102,s=271733878,l=3285377520,u=(N,E)=>N<<E|N>>>32-E,c=new Int32Array(80);for(let N=0;N<o.length;N+=64){for(let P=0;P<16;P++)c[P]=r.getUint32(N+P*4);for(let P=16;P<80;P++)c[P]=u(c[P-3]^c[P-8]^c[P-14]^c[P-16],1);let E=n,_=i,O=a,R=s,g=l;for(let P=0;P<80;P++){let h,S;P<20?(h=_&O|~_&R,S=1518500249):P<40?(h=_^O^R,S=1859775393):P<60?(h=_&O|_&R|O&R,S=2400959708):(h=_^O^R,S=3395469782);let j=u(E,5)+h+g+S+c[P]|0;g=R,R=O,O=u(_,30),_=E,E=j;}n=n+E|0,i=i+_|0,a=a+O|0,s=s+R|0,l=l+g|0;}let f=new Uint8Array(20),T=new DataView(f.buffer);return [n,i,a,s,l].forEach((N,E)=>T.setUint32(E*4,N>>>0)),f}function ru(t){return li(Jf(yt(t)))}var ed=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 td(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,h=i(a[g-2],17)^i(a[g-2],19)^a[g-2]>>>10;a[g]=a[g-16]+P+a[g-7]+h|0;}let[c,f,T,N,E,_,O,R]=n;for(let g=0;g<64;g++){let P=i(E,6)^i(E,11)^i(E,25),h=E&_^~E&O,S=R+P+h+ed[g]+a[g]|0,j=i(c,2)^i(c,13)^i(c,22),ze=c&f^c&T^f&T,me=j+ze|0;R=O,O=_,_=E,E=N+S|0,N=T,T=f,f=c,c=S+me|0;}n[0]=n[0]+c|0,n[1]=n[1]+f|0,n[2]=n[2]+T|0,n[3]=n[3]+N|0,n[4]=n[4]+E|0,n[5]=n[5]+_|0,n[6]=n[6]+O|0,n[7]=n[7]+R|0;}let s=new Uint8Array(32),l=new DataView(s.buffer);for(let u=0;u<8;u++)l.setUint32(u*4,n[u]>>>0);return s}function ou(t){return li(td(yt(t)))}var V=(1n<<64n)-1n,rd=[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=yt(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)),h=BigInt(i.getUint32(u+g*8+4));l[g]=P<<32n|h;}for(let g=16;g<80;g++){let P=s(l[g-15],1n)^s(l[g-15],8n)^l[g-15]>>7n,h=s(l[g-2],19n)^s(l[g-2],61n)^l[g-2]>>6n;l[g]=l[g-16]+P+l[g-7]+h&V;}let[c,f,T,N,E,_,O,R]=a;for(let g=0;g<80;g++){let P=s(E,14n)^s(E,18n)^s(E,41n),h=E&_^~E&V&O,S=R+P+h+rd[g]+l[g]&V,j=s(c,28n)^s(c,34n)^s(c,39n),ze=c&f^c&T^f&T,me=j+ze&V;R=O,O=_,_=E,E=N+S&V,N=T,T=f,f=c,c=S+me&V;}a[0]=a[0]+c&V,a[1]=a[1]+f&V,a[2]=a[2]+T&V,a[3]=a[3]+N&V,a[4]=a[4]+E&V,a[5]=a[5]+_&V,a[6]=a[6]+O&V,a[7]=a[7]+R&V;}return a.map(u=>u.toString(16).padStart(16,"0")).join("")}var ho={md5:"hashMd5",sha1:"hashSha1",sha256:"hashSha256",sha512:"hashSha512",crc32:"hashCrc32"};function gt(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 iu={hashMd5:gt("md5",tu),hashSha1:gt("sha1",ru),hashSha256:gt("sha256",ou),hashSha512:gt("sha512",nu),hashCrc32:gt("crc32",eu)};var Co=class{constructor(){this.category="Hash";}parse(e,o,r){let n=ho[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 ui={name:"solve-hash",prefixParselets:{HASH_CALL:new Co},callFusions:Object.fromEntries(Object.keys(ho).map(t=>[t,"HASH_CALL"])),pluginFunctions:iu,tokenCategories:{HASH_CALL:"function"}};var au="0123456789abcdef";function su(){return au[Math.floor(Math.random()*16)]}function od(){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+=au[Math.floor(Math.random()*16)&3|8]:t+=su();return t}function nd(t){let e="";for(let o=0;o<t;o++)e+=su();return e}var mu={randomUuid:()=>chunk75JLWK4L_cjs.t(od()),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(nd(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 ci(t){return {category:"Random",parse(e,o,r){r.emitPluginCall(t,0);}}}function pi(t){return {category:"Random",parse(e,o,r){e.parseExpression(chunkEN3CDYOS_cjs.a.Prefix,r),r.emitPluginCall(t,1);}}}var lu={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 fi={name:"solve-random",phrases:{"random hex":"RANDOM_HEX"},lexerVocabulary:{keywords:{uuid:"UUID",coin:"COIN",shuffle:"SHUFFLE"}},prefixParselets:{UUID:ci("randomUuid"),COIN:ci("randomCoin"),RANDOM_HEX:pi("randomHex"),SHUFFLE:pi("randomShuffle"),PICK_CALL:lu},callFusions:{pick:"PICK_CALL"},pluginFunctions:mu,tokenCategories:{UUID:"function",COIN:"function",RANDOM_HEX:"function",SHUFFLE:"function",PICK_CALL:"function"}};function se(t){return t.reduce((e,o)=>e+o,0)/t.length}function id(t){let e=se(t);return t.reduce((o,r)=>o+(r-e)*(r-e),0)/t.length}function ad(t){return Math.sqrt(id(t))}function di(t,e){let o=se(t),r=se(e),n=0,i=0,a=0;for(let l=0;l<t.length;l++){let u=t[l]-o,c=e[l]-r;n+=u*c,i+=u*u,a+=c*c;}let s=Math.sqrt(i*a);return s===0?NaN:n/s}function Ei(t,e){let o=se(t),r=se(e),n=0,i=0;for(let a=0;a<t.length;a++){let s=t[a]-o;n+=s*(e[a]-r),i+=s*s;}return i===0?NaN:n/i}function uu(t,e){return se(e)-Ei(t,e)*se(t)}function cu(t,e){let o=di(t,e);return o*o}function pu(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 fu(t,e){let o=ad(e);return o===0?NaN:(t-se(e))/o}function sd(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 du(t){return .5*(1+sd(t/Math.SQRT2))}function Eu(t){return Math.exp(-0.5*t*t)/Math.sqrt(2*Math.PI)}function Lo(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 So(t,e){return o=>{let r=Lo(o[0]),n=Lo(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 Tu={statCorrelation:So("correlation",di),statSlope:So("slope",Ei),statIntercept:So("intercept",uu),statRSquared:So("r squared",cu),statPercentile:t=>{let e=Lo(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(pu(e,r))},statZScore:t=>{let e=t[0],o=Lo(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(fu(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(du(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(Eu(e.value))}};function wo(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 vo={correlation:"statCorrelation",slope:"statSlope",intercept:"statIntercept",rsquared:"statRSquared",percentile:"statPercentile",zscore:"statZScore",normalcdf:"statNormalCdf",normalpdf:"statNormalPdf"};var ko=class{constructor(){this.category="Statistics";}parse(e,o,r){let n=vo[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 Ti={name:"solve-statistics",phrases:{"correlation of":"CORRELATION_OF","slope of":"SLOPE_OF","intercept of":"INTERCEPT_OF"},prefixParselets:{CORRELATION_OF:wo("statCorrelation"),SLOPE_OF:wo("statSlope"),INTERCEPT_OF:wo("statIntercept"),STAT_CALL:new ko},callFusions:Object.fromEntries(Object.keys(vo).map(t=>[t,"STAT_CALL"])),pluginFunctions:Tu,tokenCategories:{CORRELATION_OF:"function",SLOPE_OF:"function",INTERCEPT_OF:"function",STAT_CALL:"function"}};var md=[[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"]],Nu={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};function Ni(t){if(!Number.isInteger(t)||t<1||t>3999)return null;let e="",o=t;for(let[r,n]of md)for(;o>=r;)e+=n,o-=r;return e}function yu(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=Nu[e[r]],i=r+1<e.length?Nu[e[r+1]]:0;o+=n<i?-n:n;}return Ni(o)===e?o:null}function gu(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"],ld=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],ud=["","thousand","million","billion","trillion","quadrillion"];function cd(t){if(t<20)return Bo[t];let e=Math.floor(t/10),o=t%10;return ld[e]+(o?`-${Bo[o]}`:"")}function pd(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(cd(o))),r.join(" ")}function fd(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=pd(e[i]);i>0&&(a+=` ${ud[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 Pu(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=fd(parseInt(o,10));return r&&(n+=" point "+[...r].map(i=>Bo[Number(i)]).join(" ")),(t<0?"minus ":"")+n}var Mo=class{constructor(){this.category="Numerals";this.bindingPower=chunkEN3CDYOS_cjs.a.Conditional;}parse(e,o,r,n){n.emitPluginCall("romanFromString",1);}};function yi(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 gi={name:"solve-numerals",phrases:{"from roman":"FROM_ROMAN"},asConverters:{roman:yi("roman",Ni),ordinal:yi("ordinal",gu),words:yi("words",Pu)},infixParselets:{FROM_ROMAN:new Mo},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=yu(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 dd(t,e){for(t=Math.abs(t),e=Math.abs(e);e;)[t,e]=[e,t%e];return t}function _u(t){if(t.length<2||t.some(o=>!Number.isInteger(o)||o<=0))return null;let e=t.reduce((o,r)=>dd(o,r),0)||1;return t.map(o=>o/e).join(":")}var Au={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 Pi={name:"solve-ratio",prefixParselets:{RATIO_CALL:Au},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=_u(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 _i=["circle","square","rectangle","triangle","sphere","cube","cylinder","cone"],xu=["radius","side","width","height","base","length"];function Ou(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 Ed=new Set(_i),Td=new Set(xu);function He(t){return {category:"Geometry",parse(e,o,r){let n=e.peek(),i=(n?.value??"").toLowerCase();if(!n||n.type!=="IDENT"||!Ed.has(i))throw chunkCO2BI6WL_cjs.c.parsing("GEOMETRY_EXPECTED_SHAPE",`Expected a shape (${_i.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"||!Td.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 Ai={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=Ou(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 Nd={"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 Ru(t){return Nd[t.toLowerCase()]??null}function G(t){return {category:"Constants",parse(e,o,r){r.emitOpcode(13),r.emitString(t),r.emitPluginCall("constantValue",1);}}}var xi={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=Ru(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 Iu(t,e){return t/(e*e)}function hu(t,e){return t*60/e}function Cu(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 Uo={bmi:"healthBmi",pace:"healthPace",speed:"healthSpeed"};var Do=class{constructor(){this.category="Health";}parse(e,o,r){let n=Uo[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 Oi={name:"solve-health",prefixParselets:{HEALTH_CALL:new Do},callFusions:Object.fromEntries(Object.keys(Uo).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(Iu(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(`${Cu(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(hu(e,o),"km/h")}},tokenCategories:{HEALTH_CALL:"function"}};var hL=[Wo,Yo,Xo,tn,fn,dn,En,_n,xn,On,Rn,In,chunk53JLDRXA_cjs.a,hn,Cn,Sn,wn,Mn,zn,Un,bn,Kn,Vn,jn,Qn,ri,oi,ni,ii,Gn,mi,ui,fi,Ti,gi,Pi,Ai,xi,Oi];
|
|
2
|
+
exports.a=Wo;exports.b=Yo;exports.c=Xo;exports.d=tn;exports.e=fn;exports.f=dn;exports.g=En;exports.h=_n;exports.i=An;exports.j=xn;exports.k=On;exports.l=Rn;exports.m=In;exports.n=hn;exports.o=Cn;exports.p=Sn;exports.q=wn;exports.r=Mn;exports.s=Un;exports.t=Lm;exports.u=vm;exports.v=bn;exports.w=Vn;exports.x=Gn;exports.y=hL;//# sourceMappingURL=chunk-O3AVGIX2.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-O3AVGIX2.cjs.map
|